Skip to content

Resolve client version at runtime - #1

Merged
oakimov merged 3 commits into
oakimov:mainfrom
Nomadcxx:harden-client-version
Jul 13, 2026
Merged

oakimov merged 3 commits into
oakimov:mainfrom
Nomadcxx:harden-client-version

Conversation

@Nomadcxx

@Nomadcxx Nomadcxx commented Jul 13, 2026 •

Copy link
Copy Markdown
Contributor

Problem

The provider sends a hardcoded x-cursor-client-version value. On 2026-07-14, Cursor's live endpoint required the cli- prefix and did not check build currency. The pinned value passed that gate. A future currency check would force users to wait for a provider release.

Change

  • Resolve the version from CURSOR_CLIENT_VERSION, installed cursor-agent builds, Cursor's installer, then the fallback constant.
  • Validate values before using them as request headers.
  • Cache installer results for 24 hours and serve stale cache when refresh fails.
  • Pass the resolved version to model discovery and Run requests.

The resolver aborts installer requests after five seconds. Linux and macOS use ~/.local/share/cursor-agent/versions/ for local discovery. Windows uses the environment, remote, cache, and fallback paths until Cursor documents a local versions directory.

Follow-up

Live endpoint checks accepted requests without checksum and device-id headers. This PR leaves those headers unchanged; I can send that cleanup if useful.

Test plan

  • bun run typecheck
  • bun test (214 pass)
  • bun run build

@oakimov oakimov left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving. Independently verified the test plan in a clean worktree: bun run typecheck clean, bun test → 214 pass / 0 fail, bun run build → exit 0.

What I checked beyond the plan:

  • All references to the old CURSOR_CLIENT_VERSION are removed; both buildBaseHeaders call sites are updated.
  • Every version source (env, cache, remote) is regex-validated before becoming a header, which blocks CRLF/header injection (covered by a test).
  • The remote cursor.com/install fetch sends no auth token — no secret leakage — and is bounded by a 5s abort.
  • The cache dir matches the existing resolveModelCacheDir() convention, so the version cache lands next to cursor-models.json.

Minor notes (non-blocking, all documented behavior):

  • Local installed build takes priority over the remote installer; fine today while there's no server-side currency check.
  • Resolution is memoized for the process lifetime, so a long-lived provider won't re-resolve mid-session (acceptable; providers restart).

Nice, clean change. Thanks!

@oakimov
oakimov merged commit ece004a into oakimov:main Jul 13, 2026
nkoynov added a commit to nkoynov/cursor-opencode-provider that referenced this pull request Oct 5, 2026
OpenCode moves the images an MCP tool returns into a trailing
`Attached media from tool result:` user message. Since oakimov#34 that message
no longer forces a fresh Run, so the held Run got the MCP result as text
only and the model saw the image at the earliest after the next user
message. The README gave the reason as "Cursor's exec-result channel has
no image field", but agent.v1 has one: Cursor CLI 2026.10.01 declares
`McpImageContent|1 data 12|2 mime_type 9` and
`McpToolResultContentItem|1 text #0 content|2 image oakimov#1 content` in
`agent/v1/mcp_exec_pb.js`, and its MCP executor appends every MCP `image`
item as `{content: {case: "image", value: McpImageContent{data, mimeType}}}`.

Declare the type and the oneof case, and append the images attributed to
an `mcp_result` (the trailing-media path from the read-image change) as
image items after the text, as the CLI does. Update the README and
AGENTS.md: only results without an image field (shell, write) still wait
for the history path.
oakimov pushed a commit to nkoynov/cursor-opencode-provider that referenced this pull request Oct 7, 2026
OpenCode moves the images an MCP tool returns into a trailing
`Attached media from tool result:` user message. Since oakimov#34 that message
no longer forces a fresh Run, so the held Run got the MCP result as text
only and the model saw the image at the earliest after the next user
message. The README gave the reason as "Cursor's exec-result channel has
no image field", but agent.v1 has one: Cursor CLI 2026.10.01 declares
`McpImageContent|1 data 12|2 mime_type 9` and
`McpToolResultContentItem|1 text #0 content|2 image oakimov#1 content` in
`agent/v1/mcp_exec_pb.js`, and its MCP executor appends every MCP `image`
item as `{content: {case: "image", value: McpImageContent{data, mimeType}}}`.

Declare the type and the oneof case, and append the images attributed to
an `mcp_result` (the trailing-media path from the read-image change) as
image items after the text, as the CLI does. Update the README and
AGENTS.md: only results without an image field (shell, write) still wait
for the history path.
oakimov pushed a commit to nkoynov/cursor-opencode-provider that referenced this pull request Oct 8, 2026
OpenCode moves the images an MCP tool returns into a trailing
`Attached media from tool result:` user message. Since oakimov#34 that message
no longer forces a fresh Run, so the held Run got the MCP result as text
only and the model saw the image at the earliest after the next user
message. The README gave the reason as "Cursor's exec-result channel has
no image field", but agent.v1 has one: Cursor CLI 2026.10.01 declares
`McpImageContent|1 data 12|2 mime_type 9` and
`McpToolResultContentItem|1 text #0 content|2 image oakimov#1 content` in
`agent/v1/mcp_exec_pb.js`, and its MCP executor appends every MCP `image`
item as `{content: {case: "image", value: McpImageContent{data, mimeType}}}`.

Declare the type and the oneof case, and append the images attributed to
an `mcp_result` (the trailing-media path from the read-image change) as
image items after the text, as the CLI does. Update the README and
AGENTS.md: only results without an image field (shell, write) still wait
for the history path.
oakimov added a commit that referenced this pull request Oct 8, 2026
* fix: deliver MCP tool images on the held Run as McpImageContent

OpenCode moves the images an MCP tool returns into a trailing
`Attached media from tool result:` user message. Since #34 that message
no longer forces a fresh Run, so the held Run got the MCP result as text
only and the model saw the image at the earliest after the next user
message. The README gave the reason as "Cursor's exec-result channel has
no image field", but agent.v1 has one: Cursor CLI 2026.10.01 declares
`McpImageContent|1 data 12|2 mime_type 9` and
`McpToolResultContentItem|1 text #0 content|2 image #1 content` in
`agent/v1/mcp_exec_pb.js`, and its MCP executor appends every MCP `image`
item as `{content: {case: "image", value: McpImageContent{data, mimeType}}}`.

Declare the type and the oneof case, and append the images attributed to
an `mcp_result` (the trailing-media path from the read-image change) as
image items after the text, as the CLI does. Update the README and
AGENTS.md: only results without an image field (shell, write) still wait
for the history path.

* fix: recognize OpenCode MCP media part shapes on held Runs

Normalize host mime/uri and OpenCode 1 type:media tool parts before
ReadSuccess/McpImageContent decode, and log continuation prompt-tail
media counts for cache/live diagnosis.

* fix: harden held-Run image attribution and result delivery

---------

Co-authored-by: oakimov <[email protected]>
oakimov added a commit that referenced this pull request Nov 6, 2026
analyzeReplayFrame reads an echo only from a frame validInteractionUpdateWire
accepted, which already proved update #6 holds exactly one length-delimited
user_message #1. appendedEcho checked that again, and its fallback branch
could never run (Codecov: the one uncovered patch line). State the
precondition instead, and cover an empty user_message.
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