Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): sandboxed Cursor threads keep working after a Full access thread #13805

Mergedjuliusmarmingemerged 1 commit intot3code/codex-turn-mapping fromrefs/pull/13805/headmerged by juliusmarminge View on GitHub

Showing 3 changed files with 104 additions and 3 deletions.

x
0 of 3 viewed, 3 left
34 additions and 1 deletionapps/server/src/orchestration-v2/Adapters/CursorAgentSdk.tsModified
View file
@@ -16,7 +16,7 @@
import * as Layer from "effect/Layer";
import * as Schema from "effect/Schema";
​
-import { Agent } from "../../provider/cursorSdk.ts";
+import { Agent, createAgentPlatform } from "../../provider/cursorSdk.ts";
import type { EventNdjsonLogger } from "../../provider/Layers/EventNdjsonLogger.ts";
import { ProviderEventLoggers } from "../../provider/Layers/ProviderEventLoggers.ts";
​
@@ -295,6 +295,36 @@
.pipe(Effect.ignore);
​
+/**
+ * The Cursor SDK decides once per process whether local sandboxing works, and
+ * caches the answer the first time any run starts. Only sandboxed runs point
+ * it at its `cursorsandbox` helper first, so after an unsandboxed (Full access)
+ * run it caches "unsupported" and rejects every later sandboxed run until the
+ * server restarts. Warming a bare sandboxed executor before the first
+ * unsandboxed agent opens lets the SDK find the helper and cache the real
+ * answer. Warming is best effort: on a machine without sandbox support it
+ * fails, the SDK caches "unsupported", and sandboxed runs report that as
+ * before.
+ */
+let cursorSandboxSupportPrime: Promise<void> | undefined;
+​
+function primeCursorSandboxSupport(options: AgentOptions): Promise<void> {
+ cursorSandboxSupportPrime ??= (async () => {
+ const cwd = typeof options.local?.cwd === "string" ? options.local.cwd : undefined;