Skip to content

architecture cursor integration

github-actions[bot] edited this page Oct 29, 2026 · 53 revisions

Cursor API sidecar integration

Purpose

This page documents the Cursor API provider: Solomon talks to a local Node sidecar (OpenAI-compatible HTTP), the sidecar drives the Cursor Agent SDK, and Solomon Go executes workspace tools on the project root.

Cursor Sub is a separate provider. It signs in through a browser and connects Solomon's native backend directly to Cursor's subscription Agent service; it does not use this sidecar. See Cursor Sub direct Agent connection and the provider setup guide.

User setup (TOML, /connect, /integrations, /cursortools): Configuration — Cursor API integration.

Proxy requirements and policy tables: CURSOR-PROXY-FIX.md.

Mental model

Solomon Runtime  --OpenAI HTTP-->  sidecar (:8766/v1/)  --Cursor SDK-->  remote model
       |                                    |
       +-------- tools.Exec (Go) -----------+  (orchestrate-first proxy: default)
  • Sidecar = policy gate + stream bridge (integrations/cursor/).
  • Go integration = install bundle, start process, health, /integrations (internal/integrations/cursor/).
  • Executor = always Solomon tools.Exec on ProjRoot. cursor_internal_tools is deprecated and forced off — Cursor built-ins never run on the repo.

Composer is steered toward Solomon native entry tools (orchestrate, searchTools, subagent, …). Cursor IDE built-ins (Read, StrReplace, Shell, Task, …) are blocked and corrected — not bridged to deferred readFile / editFile / shell tool_calls. Workspace read/edit/shell/find and MCP work goes through orchestrate (sandbox SDK inside Go code mode); MCP schemas are discovered with searchTools and invoked as sdk.mcp.<tool>(intent, args).

End-to-end flow

sequenceDiagram
  participant RT as Runtime turns
  participant LLM as OpenAI client
  participant Side as Node sidecar
  participant SDK as Cursor Agent SDK
  participant Go as tools.Exec

  RT->>LLM: StreamTurn base_url=127.0.0.1:8766/v1 + tools[]
  LLM->>Side: POST /v1/chat/completions
  Side->>SDK: agent run on project cwd
  SDK-->>Side: stream deltas + Cursor tool proposals
  alt native Solomon tool (orchestrate, subagent, …)
    Side->>Side: bridge invocation, forceStopRun
    Side-->>LLM: SSE OpenAI tool_calls (native names)
    LLM-->>RT: native tool_calls
    RT->>Go: execTool on ProjRoot
  else blocked Cursor built-in (Read, Shell, …)
    Side->>Side: policy block, forceStopRun
    Side-->>LLM: solomon_proxy_correction (orchestrate-first)
    LLM-->>RT: model retries with orchestrate / searchTools / searchSkill
    Note over RT: turn loop stops after 3 consecutive proxy corrections (circuit breaker)
  end
Loading

Sidecar startup: manager.go spawns node dist/index.js with env from config. Runtime ensures sidecar via cursor_sidecar.go → agent/runtime.go.

Operating modes

Mode Agent cwd Who runs file/shell tools on repo
Production (only supported path) project root Solomon Go only

[tools].cursor_internal_tools is deprecated: config load/save normalizes it to false, CursorInternalToolsEnabled() always returns false, and /cursortools on is rejected. Solomon never sets CURSOR_API_ALLOW_INTERNAL_TOOLS=true on the sidecar.

Use /cursortools off (or bare /cursortools) to confirm the setting and restart the sidecar. Implementation: thinking.go (CursorTools). Inspect status: /integrations (integrations_slash.go).

Orchestrate-first proxy (default)

Native tool exposure

Mechanism: SDK local.customTools + Go execution prehook — prompt XML remains a fallback.

Layer Role
Go system prompt agent.tmpl ExternalToolBridge — lists native entry tools, blocks Cursor built-ins
Sidecar harness harness-clauses.txt, harness-prompt.ts — orchestrate-first workflow; Solomon tools are real registered tools
OpenAI tools[] on request Converted to SDK customTools via custom-tools.ts (openAIToolsToMcpTools)
Model invocation Composer calls registered tool names (orchestrate, searchTools, …) as native tool_calls or MCP custom-user-tools
Prehook / bridge stream-events.ts intercepts solomon and custom-user-tools MCP calls → forceStopRun → OpenAI tool_calls to Go; stub execute in Node must not run workspace work
Fallback wire <tool_calls> XML still parsed by openai-tools.ts when the model emits text blocks

Agent.create in cursor-agent.ts registers local.customTools from the request tools[]. Execution always happens in Go (tools.Exec on ProjRoot), not in the sidecar process.

Policy gate

Central module: tool-policy.ts. Applied on stream and non-stream paths (chat/stream.ts, chat/nonstream.ts) via finalizeTurnToolResults.

Class Examples Sidecar action
Native pass-through orchestrate, searchTools, subagent, listSubAgents, switchMode, searchSkill, loadSkill Bridge → OpenAI tool_calls → Go tools.Exec
Block — redirect Read, StrReplace, Shell, Grep, Task, WebFetch, deferred mcp:editFile, … solomon_proxy_correction → searchTools + orchestrate; no bridge to readFile/editFile/shell
Hard deny AskQuestion, browser_*, mcp:external, GenerateImage, Await, ApplyPatch Deny with class-specific correction; no host execution

Full mapping tables: CURSOR-PROXY-FIX.md §3. Matrix tests: policy-matrix.test.ts.

Run control

On bridged native invocation or a covered policy-blocked tool, the sidecar calls forceStopRun to request SDK cancellation and exits the shared stream loop (stream-loop.ts, run-control.ts). Cancellation is conditional on SDK support and errors are swallowed. Sandbox startup can fall back to an unsandboxed agent; SDK non-execution in those paths remains to be verified under PRD task 2.20.

Correction copy (orchestrate-first, names searchTools, orchestrate, searchSkill, loadSkill): proxy-correction.ts. Go-side policy mirror: tool_print.go; mode-aware fallback and display: cursor_proxy_corrections.go.

Corrections retain the full request tool surface to identify agent/chat mode while honoring the restricted catalog imposed by tool_choice for recovery suggestions. Shared detection also covers single-tool chat catalogs. Chat recovery never recommends agent workspace entry points; switchMode and native web tools are suggested only when callable in the current request.

Proxy correction circuit breaker

If Composer emits more than three consecutive proxy corrections in one user turn (blocked Cursor built-in with no successful native tool invocation in between), the Go turn loop stops retrying and prints a system bailout message (turnloop/loop.go). This prevents infinite correction loops while keeping the REPL usable.

HTTP API (sidecar)

Base URL: http://127.0.0.1:8766/v1/ (port from DefaultPort, overridable via env).

Method Path Role
GET /health, /v1/health Liveness ({ ok: true })
GET /v1/models, /models Model list for picker
GET /v1/models?all=1 Full model list
POST /v1/chat/completions, /chat/completions Chat completion proxy

Implementation: server.ts. Request limits: body 8 MiB, 256 messages, 64 tools (see server constants).

Sidecar environment

Set by Go when starting the process (manager.go):

Variable Role
CURSOR_API_KEY Cursor API key from provider config
CURSOR_API_PORT Listen port (default 8766)
CURSOR_API_CWD Project root
CURSOR_API_ALLOW_INTERNAL_TOOLS Always omitted / false (cursor_internal_tools deprecated)
CURSOR_API_PROXY_OBS "1" — Solomon sets this when starting the sidecar (structured proxy JSON on stderr)

Optional overrides:

Variable Role
SOLOMON_NODE Path to node binary
SOLOMON_CURSOR_API_ROOT Override install dir (pathresolver.go)

Logs: ~/.solomon/logs/cursor-sidecar.log (stdout/stderr from the sidecar process).

Observability

proxy-observability.ts records per-turn counters (native bridged vs blocked by policy class, correction streaks, deferred-direct blocks). With Solomon-managed sidecar startup, structured proxy_turn / proxy_correction_loop JSON lines are written to cursor-sidecar.log automatically. Disable only by running the sidecar outside Solomon without CURSOR_API_PROXY_OBS.

Install and lifecycle

Step Where
Embed + extract bundle bootstrap.go, embed.go
Install dir ~/.solomon/integrations/cursor/ (dist/index.js, node_modules/@cursor/sdk)
First use / missing SDK Bootstrap runs npm prod deps
Process manager manager.go — singleton, health poll, restart on key change
Build from source npm --prefix integrations/cursor run build then go run scripts/cursor_bundler.go bundle (CI / make build)

Entry: integrations/cursor/src/index.ts.

Go package map

File Role
pathresolver.go Install dir, default base URL, entry script path
bootstrap.go Extract embedded bundle, npm deps
manager.go Start/stop sidecar, health, ProxyStatus
sidecar_async.go Async kick/wait when Cursor API provider active
ensure_configured.go Wait for sidecar if configured
agent/runtime.go EnsureSidecar from runtime
models.go Model list via sidecar HTTP

Runtime display when native tools enabled: cursor_native_display.go.

Node package map

File Role
server.ts HTTP router, request validation
chat/index.ts Chat completions entry
chat/stream.ts Streaming completion path
chat/nonstream.ts Non-streaming completion path
chat/turn.ts Turn finalization, proxy correction resolution
chat/helpers/stream-loop.ts SDK stream drain, forceStopRun
chat/helpers/stream-events.ts Per-event policy enforcement
chat/helpers/proxy-correction.ts solomon_proxy_correction text
tool-policy.ts Block / redirect / hard-deny policy
proxy-observability.ts Turn counters and optional JSON logs
bridge/invocation.ts Native tool bridging
legacy.ts Re-exports bridge + legacy alias map
legacy-normalize.ts Argument normalization (legacy paths)
openai-tools.ts OpenAI tool_calls SSE, XML parsing, openAIToolsToMcpTools
custom-tools.ts OpenAI tools → SDK customTools; Node execute stub (Go owns work)
openai-sse.ts SSE chunks
cursor-agent.ts SDK agent create (sandbox, harness)
cursor-native-tools.ts solomon_cursor_tool_event chunks
harness-prompt.ts Orchestrate-first harness clauses
run-control.ts Abort, usage, forceStopRun

Legacy alias map

tool-policy.ts CURSOR_NATIVE_ALIASES (also re-exported by legacy.ts) documents how Cursor names would map to Solomon deferred tools. Under orchestrate-first policy, redirect-class Cursor tools are not bridged — the map drives correction hints and tests, not transparent Read → readFile handoff.

Native MCP unwrap (mcp provider solomon): MCP tool calls are redirected to searchTools plus orchestrate; only Solomon native entry tools (e.g. subagent) pass through when allowed.

Tool name bridge

CURSOR_NATIVE_ALIASES maps Cursor search names (Grep, Glob, SemanticSearch, rg, and similar) to Solomon find, and directory aliases (LS, ls, ListDir, list_dir, listDir) to deferred listDir. Directory recovery uses sdk.ListDir inside orchestrate; direct native directory calls remain blocked. SemanticSearch uses regexp fallback today (no vector index). Under orchestrate-first policy, redirect-class Cursor tools are corrected toward orchestrate rather than bridged transparently; the alias map remains for correction hints and compatibility helpers; managed runtimes keep Cursor internal tools off.

SSE extensions

Field When Consumer
solomon_proxy_correction Blocked Cursor / deferred-direct tool Model retry guidance (orchestrate-first)
solomon_cursor_tool_event Deprecated (cursor_internal_tools removed) Was REPL display when Cursor ran tools on disk

Native event shape: cursor-native-tools.ts (name, status, args, result, error).

Limits and caveats

  • Policy enforcement + forceStopRun is the primary execution gate; SDK sandbox is secondary when enabled.
  • Chat mode with the Cursor API provider is Phase 3 — the current documented policy covers agent mode (CURSOR-PROXY-FIX.md).
  • Guarantees depend on sidecar + Cursor SDK versions (@cursor/sdk 1.0.20+ for customTools).
  • Requires Node.js when the Cursor API provider is enabled.
  • Manual check after upgrades: Composer should call registered Solomon tools by name; Read/StrReplace attempts should yield one correction then recovery via orchestrate / searchTools.

Debug playbook

Symptom Start here Tests
Sidecar won't start manager.go, bootstrap.go, ~/.solomon/logs/cursor-sidecar.log test/cursor_paths_test.go
/integrations health fail Port 8766, CURSOR_API_KEY, firewall —
Cursor tool ran on repo (policy bug) tool-policy.ts, forceStopRun in stream-loop.ts policy-matrix.test.ts
Correction loop (>3 same class) Inspect proxy_correction_loop / proxy_turn JSON in cursor-sidecar.log; Go bailout in turnloop/loop.go proxy-observability.test.ts
Model still tries Read/StrReplace harness-prompt.ts, proxy-correction.ts, Go tool_print.go openai-tools-mapping.test.ts
No REPL display for native tools cursor_native_display.go test/cursor_native_display_test.go
Provider config / base URL config, /connect Cursor flow test/config_provider_cursor_test.go

See also

Verified sidecar reuse (health protocol v1)

Manager.Ensure checks compatibility on both startup and reuse, not just HTTP liveness. /health and /v1/health expose identity: protocol version, startup runtime SHA-256, absolute workspace cwd, internal-tools flag, and observability flag. The runtime digest covers dist/index.js, dist/prompts/*, package.json, and package-lock.json; the running process retains its startup snapshot so replacing files cannot disguise a stale process.

A fresh 32-byte nonce (64 lowercase hex characters) yields an HMAC-SHA256 proof, keyed with the configured API key and bound to the nonce and identity fields. The API key is neither sent in the health request nor exposed in the response; no static key fingerprint is published. This checks configuration consistency for the local listener, not remote Cursor API reachability.

Compatible pre-existing listeners can be reused. Legacy health responses, stale bundles, configuration/credential mismatches and unsupported protocols are refused. Solomon restarts only processes it owns; an incompatible external listener requires explicit operator shutdown and reports an actionable error. A live but unverified process no longer produces a successful Ensure result. /integrations health remains a liveness indicator, not proof of compatibility.

Rebuild and deploy the sidecar bundle before using this protocol (npm --prefix integrations/cursor run build, then go run scripts/cursor_bundler.go bundle for the embedded distribution). Existing installed listeners must be restarted explicitly if not owned by the current process.

Verification: go test ./test -run 'Test(EnsureVerifiedListener|RuntimeDigestTracksAssets|HealthProofVector|ManagedNodeHandshakeLifecycle)' -count=1 covers compatible adoption, legacy/malformed/stale metadata, flags/cwd/credential mismatch and managed Node startup/reuse/restart. The managed Node test uses a temporary local port and dummy key, never calls Cursor, and skips when the built sidecar or Node dependencies are unavailable.

Clone this wiki locally