fix(server): Cursor sandboxed threads find their helper when running from source #13571
t3code/codex-turn-mapping fromrefs/pull/13571/head·merged by juliusmarminge View on GitHubRestricted-mode (sandboxed) Cursor threads fail when T3 runs from source (vp run dev, node apps/server/dist/bin.mjs) with "Local SDK sandboxing was requested, but sandboxing is not supported in this environment."
Cause#
@cursor/sdk 1.0.31 finds its platform package through platform-package-locator: starting at dirname(process.argv[1]) and then dirname(process.execPath), it walks up parent directories looking for <dir>/node_modules/@cursor/sdk-<platform>-<arch>/<file> (or @cursor/february-*). pnpm's isolated layout installs that optional dependency only as a sibling inside the virtual store (node_modules/.pnpm/@cursor+sdk@1.0.31/node_modules/@cursor/sdk-linux-x64). apps/server/node_modules/@cursor/ contains only sdk, so the walk from apps/server/src never finds the package. Without cursorsandbox, isSandboxSupported returns false and the SDK refuses sandboxed runs.
Two other lookups use the same locator and were silently degraded too:
rgfell back to whatever ripgrep is on PATH, or none.- The tree-sitter
vendornatives were missing, which disables shell command analysis.
Fix#
Add publicHoistPattern: ["@cursor/sdk-*"] to pnpm-workspace.yaml. pnpm then links the installed platform package into the root node_modules/@cursor/, which the upward walk from apps/server/... reaches.
supportedArchitecturesstill filters optionals, so only the matching platform package is linked. On this Linux box that issdk-linux-x64.- The lockfile does not change.
- No version pin to keep in sync with
@cursor/sdk, unlike declaring the five platform packages as server optionalDependencies.
Effect on packaged builds#
- Desktop: unaffected.
build-desktop-artifact.tsruns its own stagedvp install --prodwith a generatedpnpm-workspace.yamlthat does not carrypublicHoistPattern.stageCursorSdkPlatformPackagesstill copiessdk-*from beside the real SDK directory intoresources/node_modules/@cursor. The root-level link is a symlink to the same store directory, and the asar globs already exclude**/node_modules/@cursor/sdk-*. - CLI archive /
npx t3: unaffected.build-cli-archive.tsinstalls runtime externals withnodeLinker: hoistedinto a separate stage dir, from its own generated workspace config.
Verification#
- Locator probe. It runs the SDK's own
platform-package-locatormodule, sliced out ofdist/esm/index.js, withargv[1]set to each server entry:apps/server/src/bin.ts,apps/server/dist/bin.mjs, andapps/server/scripts/record-cursor-agent-sdk-replay-fixture.ts.- Before:
cursorsandbox: null,rg: null,vendor: nullfor all three. - After:
cursorsandbox,rgandvendorall resolve under<repo>/node_modules/@cursor/sdk-linux-x64/…for all three.
- Before:
- Live sandboxed Cursor turn.
Agent.create({ model: { id: "composer-2.5" }, local: { cwd, autoReview: false, sandboxOptions: { enabled: true } } })withargv[1]atapps/server/src/bin.ts, prompt "Runcat hello.txt".- Before:
Local SDK sandboxing was requested, but sandboxing is not supported in this environment. - After:
status: finished, outputsandbox-ok.
- Before:
vp i: lockfile up to date. The only new entry in the rootnode_modulesis the@cursor/sdk-linux-x64symlink.cd apps/server && vp test run src/orchestration-v2/testkit/OrchestratorReplayFixtures.integration.test.ts -t cursor: 10 passed.vp test run scripts/build-desktop-artifact.test.ts scripts/lib/cursor-sdk-packaging.test.ts: 67 passed, 6 failed. The same 6 fail on the base branch without this change, after a reinstall to the base layout. The causes are environmental on this box:cursor-sdk-packaging.test.tsasserts there is nonode_modulesabove TMPDIR, and/tmp/node_modulesexists.- Five Windows sidecar tests fail in asar packing with "expected native binaries … but none were unpacked".
cd apps/server && vp exec tsc --noEmit -p .: noerror TSorwarning TS.vp run knip:check: one unused export,THREAD_DETAILS_PANEL_SPLIT_BUTTON_SURFACE_CLASSinapps/web. It comes from the base branch's head commit and is unrelated to this change.- Not run: a packaged desktop or CLI build, and macOS/Windows installs. Their staging paths do not read this setting.
Model: Claude Opus 5.5 (Claude Code)
🤖 Generated with Claude Code
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:XS
Approvability#
Verdict: Approved at
1f8fb38Macroscope's review found this PR approvable — This small workspace configuration fix makes the already-supported Cursor sandbox helpers discoverable during source-based server runs. Its effect is localized to dependency layout and existing Cursor execution, with staged desktop and CLI packaging paths remaining separately configured.
You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).Thread transfer impact#
✅ Thread transfer remains within every enforced ceiling.
ℹ️ No successful
mainbaseline artifact is available yet. This run establishes the initial measurement.Provider Metric Main baseline This PR Impact PR ceiling Codex Total thread wire — 4.9 KiB — 6.8 KiB ✅ Codex Thread snapshot wire — 3.7 KiB — 4.9 KiB ✅ Codex Live turn WebSocket wire — 1.1 KiB — 2.0 KiB ✅ Codex Live turn WebSocket decoded — 20.4 KiB — 29.3 KiB ✅ Codex Live turn messages — 1 — 8 ✅ Claude Total thread wire — 4.9 KiB — 6.8 KiB ✅ Claude Thread snapshot wire — 3.7 KiB — 4.9 KiB ✅ Claude Live turn WebSocket wire — 1.2 KiB — 2.0 KiB ✅ Claude Live turn WebSocket decoded — 20.8 KiB — 29.3 KiB ✅ Claude Live turn messages — 2 — 8 ✅ Baseline: unavailable · PR result:
1f8fb38· Source CI: failureScenario and decoded snapshot size
10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.
- Codex decoded thread snapshot: 106.1 KiB
- Claude decoded thread snapshot: 106.4 KiB
Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.
juliusmarminge merged thise24ad9a
juliusmarminge closed this
Sign in to join this conversation.
macroscopeapp[bot](GitHub profile, opens in a new tab) approved these changes