Repository navigation
feat(sse): Cursor plan images via Agent CLI (IMAGE_PROVIDERS.cursor) - #10842
Merged
diegosouzapw merged 5 commits intoAug 20, 2026
Merged
Conversation
Add cursor-agent-image format that reuses the chat Cursor OAuth connection and drives the Agent CLI native generateImage tool with a locked prompt and per-request workspace. Chat AgentService rejects built-ins; CLI is the seat path.
review) Two mechanical hardening fixes requested in review: - Model: the request's `model=cursor/<…>` flowed unfiltered into the Agent CLI `--model` argv. Add resolveCursorImageModel() — an allowlist derived from IMAGE_PROVIDERS.cursor.models (auto | composer-2 | composer-2.5), mirroring the auggie executor. Unknown or flag-shaped values fall back to "auto" and never reach argv. Operator overrides (connection psd / CURSOR_IMG_MODEL) stay trusted. - Timeout: request `timeout_ms` had no upper bound while the shared Cursor seat has only CURSOR_IMG_MAX_CONCURRENT (default 2) slots. Add resolveCursorImageTimeoutMs() clamping the caller value to MAX_TIMEOUT_MS (300000ms); the operator default (CURSOR_IMG_TIMEOUT_MS) stays uncapped. Tests: +3 (12/12) — allowlist unit test, end-to-end proof a flag-shaped model resolves to "auto" in argv, and the timeout clamp. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…ules #15/#17) handleCursorAgentImageGeneration spawns the Cursor `agent` CLI, but POST /v1/images/generations is shared by ~40 non-spawning image providers that remote callers legitimately use, so the whole route can't be classified LOCAL_ONLY without breaking them. Instead the handler now rejects before any credential lookup or spawn unless the trusted AUTHZ_HEADER_PEER_LOCALITY verdict (stamped by the authz pipeline from the real TCP peer, never the spoofable Host header) is "loopback" or "lan" — mirroring the policy every other LOCAL_ONLY route already gets. Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com>
… test The model-allowlist test (from the allowlist/timeout-clamp commit) and the loopback/LAN guard (from the security-guard commit) were written independently against diverging histories of this PR and didn't know about each other — cherry-picking both here exposed the gap: this one test still called handleCursorAgentImageGeneration without peerLocality, so the guard's fail-closed default rejected it with 403 before reaching the argv-sanitization logic the test actually exercises. Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com>
Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com>
1 of 3 tasks
diegosouzapw
pushed a commit
that referenced
this pull request
Aug 20, 2026
muhamadgalihsaputra
pushed a commit
to niyatna/NiyatnaRoute
that referenced
this pull request
Sep 27, 2026
…heaper-inference#10842) Merged — locally validated (60/60 combined image-generation tests, typecheck:core clean, complexity/cognitive/file-size/changelog gates green, small rebaseline for the combined imageRegistry.ts growth).
muhamadgalihsaputra
pushed a commit
to niyatna/NiyatnaRoute
that referenced
this pull request
Sep 27, 2026
cheaper-inference#10737) Merged — locally validated (fusion-vision-panel-3378 test green, file-size/changelog gates green) after resolving base-drift against cheaper-inference#10842/cheaper-inference#10838 (both landed just before).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Carries forward #8338 (@valvesss) — Cursor plan image generation via the Agent CLI's native
generateImagetool, reusing the existing Cursor OAuth/API-key chat connection. Opened as a new PR because the fork (cold-code-labs/OmniRoute-1, an organization fork) does not support "allow edits from maintainers" — GitHub only grants that for personal-account forks — so the pending review fixes below could not be pushed to the original branch, and #8338 had also drifted into merge conflicts against the current release tip.All 3 of the original commits are preserved with @valvesss's authorship intact:
feat(sse): Cursor plan images via Agent CLI— the original feature.fix(cursor-image): allowlist CLI model + clamp request timeout— @valvesss's own response to the first review round (model argv allowlist againstIMAGE_PROVIDERS.cursor.models,timeout_msserver-side clamp).fix(sse): loopback/LAN-gate the cursor-agent-image spawn path (Hard Rules #15/#17)— @valvesss's response to the second review round (this is the first image-provider handler that spawns a local process; it's now gated on the trustedAUTHZ_HEADER_PEER_LOCALITYverdict so a leaked API key via a tunnel can't trigger a spawn from a remote caller — mirrors every other spawn-capable route in the codebase).Plus 2 small commits from me reconciling the rebase:
peerLocalitythreaded through.imageRegistry.ts(+14 lines, the newcursorregistry entry — same "provider catalog, no split" rationale as prior registry rebaselines).Validation (TDD, Hard Rule #18)
tests/unit/cursor-agent-image.test.ts: 14/14 pass (includes the argv-injection defense, the timeout clamp, and both loopback-gate tests — non-local caller rejected before spawn, and fail-closed whenpeerLocalityis missing).tests/unit/image-generation-route.test.ts+tests/unit/image-generation-handler.test.ts: 79/79 pass combined, no regression in the other ~40 image providers sharing this route.npm run typecheck:core— clean.check:file-size,check:complexity,check:cognitive-complexity,check:changelog-integrity— all green (file-size baseline bump documented above).Related
🙏 Full credit to @valvesss for the design (seat-bridge via Agent CLI, locked prompt, per-request workspace) and for responding to both review rounds — this PR only carries the work across the org-fork gap.