Skip to content

项目更新验证#2

Open
hzsw1234 wants to merge 5 commits into
mainfrom
cursor/-bc-5ff6181d-f24f-4427-a974-bf6871093ff5-b0d5
Open

项目更新验证#2
hzsw1234 wants to merge 5 commits into
mainfrom
cursor/-bc-5ff6181d-f24f-4427-a974-bf6871093ff5-b0d5

Conversation

@hzsw1234

Copy link
Copy Markdown
Owner

This pull request contains changes generated by a Cursor Cloud Agent

Open in Web Open in Cursor 

- Update cursor_client_version default from 2.0.0 to 2.6.0 (Cursor is now at v2.6+)
  This is likely the root cause of token verification failures, as the
  Cursor backend returns OutdatedClient (410 Gone) for old client versions.

- Update Electron/Chrome versions in UA strings:
  - Client UA: Chrome/138 Electron/37.7.0 -> Chrome/140 Electron/38.0.0
  - Web UA: Chrome/143 -> Chrome/145 (latest stable browser)
  - sec-ch-ua: Chromium/138 -> Chromium/140 (matching Electron 38)

- Update connect-es version from 1.6.1 to 2.1.1

- Update Version default in cursor_version.rs from 2.0.0 to 2.6.0

These changes address the most likely cause of 'token obtained but
verification always fails' - the server-side OutdatedClient check
rejecting requests with x-cursor-client-version: 2.0.0.

Co-authored-by: hzsw1234 <hzsw1234@users.noreply.github.com>
@cursor

cursor Bot commented Mar 23, 2026

Copy link
Copy Markdown

Cursor Agent can help with this pull request. Just @cursor in comments and I'll start working on changes in this branch.
Learn more about Cursor Agents

@hzsw1234 hzsw1234 marked this pull request as ready for review March 23, 2026 13:46
@hzsw1234 hzsw1234 closed this Mar 23, 2026
@hzsw1234 hzsw1234 reopened this Mar 23, 2026
cursoragent and others added 4 commits March 23, 2026 15:10
Add a new independent backend that calls the official Cursor CLI tool
('agent') to handle chat completion requests. This bypasses the direct
gRPC/protobuf path, using the CLI's built-in authentication and protocol
handling instead.

New endpoint: POST /cli/chat/completions (requires admin auth)
- Supports both sync and streaming (SSE) modes
- Builds prompt from OpenAI-format messages array
- Parses CLI stream-json output with deduplication
- Uses std::process via spawn_blocking (no new dependencies)

Configuration (all optional, disabled by default):
- CLI_BACKEND_ENABLED=true  - Enable the CLI backend
- CLI_AGENT_BIN=agent       - Path to the agent binary
- CLI_TIMEOUT_MS=300000     - Request timeout
- CLI_WORKSPACE=/tmp        - Working directory for CLI

Prerequisites:
- Install Cursor CLI: curl https://cursor.com/install -fsS | bash
- Login: agent login (or set CURSOR_API_KEY)

This does NOT modify the existing gRPC code path.

Co-authored-by: hzsw1234 <hzsw1234@users.noreply.github.com>
- Rewrite StreamParser to handle CLI stream-json format correctly:
  - Parse 'thinking' delta events → reasoning_content field
  - Parse 'assistant' delta events → content field
  - Skip final accumulated assistant message (dedup)
  - Capture usage info from 'result' event

- Add reasoning_content to OpenAI-compatible response format:
  - Sync mode: message.reasoning_content contains full thinking
  - Stream mode: delta.reasoning_content streams thinking chunks
  - Compatible with OpenAI o1/o3 reasoning_content format

- Fix sync mode to use stream-json internally to capture thinking
- Add proper usage token counts from CLI output

Tested with claude-4.5-sonnet-thinking:
- Sync: reasoning_content + content both populated correctly
- Stream: 44 thinking chunks + 24 content chunks, no truncation

Co-authored-by: hzsw1234 <hzsw1234@users.noreply.github.com>
When the Cursor agent writes code to files via tool_calls (editToolCall),
the file content is now captured and included in the API response.

This fixes the issue where thinking models (opus-thinking, sonnet-thinking)
would write code to files instead of outputting to stdout, resulting in
empty or summary-only responses.

Changes:
- StreamParser now handles 'tool_call' events with editToolCall
- File content is emitted as code blocks in the response content
- Both sync and stream modes capture file content
- Added CLI_USE_ASK_MODE config (default false) - without ask mode,
  agent has full tool access and can write files
- build_agent_command helper for DRY CLI argument construction

Co-authored-by: hzsw1234 <hzsw1234@users.noreply.github.com>
CLI outputs deltas per segment (before/after each tool_call), followed by
an accumulated message containing all segment text. Previous logic failed
to detect mid-stream accumulated messages.

New approach:
- Track accumulated_text per segment
- If current text == accumulated_text → it's the accumulated msg, skip it
- Reset accumulated_text on tool_call completion
- Handles multi-segment conversations (pre-tool + post-tool text)

Verified: no more duplicated text in responses.

Co-authored-by: hzsw1234 <hzsw1234@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants