@devries-cameron20 / t3code Mirror · read-only / commits / 19e06dc875
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 22, 23:15 UTC

fix(provider-cursor): start default Cursor threads on Windows (#20046)

Co-authored-by: Julius Marminge <julius0216@outlook.com> Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>

fabiocolor committed Oct 20, 2026 at 06:05 UTC 19e06dc875835cf4e7e2b8477d117aeeec727526
4 files changed +195 -44
apps/server/src/orchestration-v2/Adapters/CursorAdapterV2.testkit.ts
+1
@@ -711,6 +711,7 @@ export const recordCursorAgentSdkReplayTranscript = Effect.fn(
711 }),
712 threadId,
713 mcpSession: undefined,
714 + platform: yield* HostProcess.Platform,
715 });
716 const sendOptions = {
717 model: cursorSdkModelSelection(input.modelSelection),
docs/user/cursor.md
+6 -3
@@ -60,9 +60,12 @@ a provider thread to native task projections or advertise subagent thread IDs. A
60 read-only: send messages from the parent thread.
61
62 Runtime modes map to the controls the local SDK exposes: full access disables its sandbox, while
63 -restricted modes and explicit non-full-access sandbox policies enable it. Explicit approval policy
64 -overrides also control Cursor Auto-review. Auto-review is not represented as an interactive T3 Code
65 -approval flow.
63 +restricted modes normally enable it. On Windows, Auto and Supervised run without filesystem
64 +isolation when Cursor Auto-review is enabled, because the SDK does not support a filesystem sandbox
65 +there. Restricted modes without Auto-review, including the default Auto-accept edits mode, still
66 +request the sandbox and cannot start on Windows. Explicit sandbox policies remain authoritative,
67 +including restrictive policies that the Windows SDK rejects. Explicit approval policy overrides
68 +control Auto-review, which is not represented as an interactive T3 Code approval flow.
69
70 The existing Cursor binary path and API endpoint settings belong to the CLI/ACP integration. Cursor
71 V2 execution does not launch that binary, and the SDK does not expose an API endpoint override.
packages/provider-cursor/src/server/adapter.test.ts
+155 -28
@@ -22,6 +22,7 @@ import * as Path from "effect/Path";
22 import * as Schema from "effect/Schema";
23 import * as Stream from "effect/Stream";
24
25 +import * as HostProcess from "@t3tools/shared/HostProcess";
26 import * as TestProviderHost from "@t3tools/provider-testing/TestProviderHost";
27 import * as IdAllocator from "@t3tools/provider-core/server/IdAllocator";
28 import * as McpProviderSessions from "@t3tools/provider-core/server/McpProviderSessions";
@@ -1066,71 +1067,195 @@ describe("CursorAdapterV2", () => {
1067 cwd: "/tmp/cursor-adapter",
1068 };
1069 assert.deepEqual(
1069 - cursorRuntimeAgentPolicy({
1070 - ...base,
1071 - runtimeMode: "full-access",
1072 - }),
1070 + cursorRuntimeAgentPolicy(
1071 + {
1072 + ...base,
1073 + runtimeMode: "full-access",
1074 + },
1075 + "linux",
1076 + ),
1077 {
1078 autoReview: false,
1079 sandboxEnabled: false,
1080 },
1081 );
1082 assert.deepEqual(
1079 - cursorRuntimeAgentPolicy({
1080 - ...base,
1081 - runtimeMode: "auto-accept-edits",
1082 - }),
1083 + cursorRuntimeAgentPolicy(
1084 + {
1085 + ...base,
1086 + runtimeMode: "auto-accept-edits",
1087 + },
1088 + "linux",
1089 + ),
1090 {
1091 autoReview: false,
1092 sandboxEnabled: true,
1093 },
1094 );
1095 assert.deepEqual(
1089 - cursorRuntimeAgentPolicy({
1090 - ...base,
1091 - runtimeMode: "auto",
1092 - }),
1096 + cursorRuntimeAgentPolicy(
1097 + {
1098 + ...base,
1099 + runtimeMode: "auto",
1100 + },
1101 + "linux",
1102 + ),
1103 {
1104 autoReview: true,
1105 sandboxEnabled: true,
1106 },
1107 );
1108 assert.deepEqual(
1099 - cursorRuntimeAgentPolicy({
1100 - ...base,
1101 - runtimeMode: "approval-required",
1102 - }),
1109 + cursorRuntimeAgentPolicy(
1110 + {
1111 + ...base,
1112 + runtimeMode: "approval-required",
1113 + },
1114 + "linux",
1115 + ),
1116 {
1117 autoReview: true,
1118 sandboxEnabled: true,
1119 },
1120 );
1121 assert.deepEqual(
1109 - cursorRuntimeAgentPolicy({
1110 - ...base,
1111 - runtimeMode: "full-access",
1112 - approvalPolicy: "never",
1113 - sandboxPolicy: { type: "readOnly" },
1114 - }),
1122 + cursorRuntimeAgentPolicy(
1123 + {
1124 + ...base,
1125 + runtimeMode: "full-access",
1126 + approvalPolicy: "never",
1127 + sandboxPolicy: { type: "readOnly" },
1128 + },
1129 + "linux",
1130 + ),
1131 {
1132 autoReview: false,
1133 sandboxEnabled: true,
1134 },
1135 );
1136 assert.deepEqual(
1121 - cursorRuntimeAgentPolicy({
1122 - ...base,
1123 - runtimeMode: "approval-required",
1124 - approvalPolicy: "never",
1125 - sandboxPolicy: { type: "dangerFullAccess" },
1126 - }),
1137 + cursorRuntimeAgentPolicy(
1138 + {
1139 + ...base,
1140 + runtimeMode: "approval-required",
1141 + approvalPolicy: "never",
1142 + sandboxPolicy: { type: "dangerFullAccess" },
1143 + },
1144 + "linux",
1145 + ),
1146 {
1147 autoReview: false,
1148 sandboxEnabled: false,
1149 },
1150 );
1151 + assert.deepEqual(
1152 + cursorRuntimeAgentPolicy(
1153 + {
1154 + ...base,
1155 + runtimeMode: "auto-accept-edits",
1156 + },
1157 + "win32",
1158 + ),
1159 + {
1160 + autoReview: false,
1161 + sandboxEnabled: true,
1162 + },
1163 + );
1164 + assert.deepEqual(
1165 + cursorRuntimeAgentPolicy(
1166 + {
1167 + ...base,
1168 + runtimeMode: "auto",
1169 + approvalPolicy: "never",
1170 + },
1171 + "win32",
1172 + ),
1173 + {
1174 + autoReview: false,
1175 + sandboxEnabled: true,
1176 + },
1177 + );
1178 + // Auto-review can gate Windows execution without the unsupported SDK sandbox.
1179 + assert.deepEqual(
1180 + cursorRuntimeAgentPolicy(
1181 + {
1182 + ...base,
1183 + runtimeMode: "auto",
1184 + },
1185 + "win32",
1186 + ),
1187 + {
1188 + autoReview: true,
1189 + sandboxEnabled: false,
1190 + },
1191 + );
1192 + assert.deepEqual(
1193 + cursorRuntimeAgentPolicy(
1194 + {
1195 + ...base,
1196 + runtimeMode: "auto",
1197 + sandboxPolicy: { type: "workspaceWrite" },
1198 + },
1199 + "win32",
1200 + ),
1201 + {
1202 + autoReview: true,
1203 + sandboxEnabled: true,
1204 + },
1205 + );
1206 });
1207
1208 + it.effect("opens Windows threads without requesting the unsupported SDK sandbox", () =>
1209 + Effect.gen(function* () {
1210 + const instanceId = ProviderInstanceId.make("cursor");
1211 + const threadId = ThreadId.make("cursor-windows-thread");
1212 + const modelSelection = { instanceId, model: "auto" };
1213 + const runtimePolicy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
1214 + runtimeMode: "auto",
1215 + interactionMode: "default",
1216 + cwd: "/workspace",
1217 + });
1218 + let opened = false;
1219 + const adapter = yield* makeCursorAdapterV2({
1220 + instanceId,
1221 + settings: yield* decodeCursorSettings({}),
1222 + environment: {},
1223 + }).pipe(
1224 + Effect.provideService(HostProcess.Platform, "win32"),
1225 + Effect.provideService(CursorAgentSdk.CursorAgentSdkRunner, {
1226 + assertComplete: Effect.void,
1227 + open: (input) =>
1228 + Effect.sync(() => {
1229 + assert.isFalse(input.options.local?.sandboxOptions?.enabled);
1230 + assert.isTrue(input.options.local?.autoReview);
1231 + opened = true;
1232 + return {
1233 + agentId: "native-cursor-windows",
1234 + listMessages: Effect.succeed([]),
1235 + close: Effect.void,
1236 + send: () => Effect.die("not used"),
1237 + };
1238 + }),
1239 + }),
1240 + Effect.provide(TestProviderHost.layer({ cwd: "/workspace" })),
1241 + );
1242 + const runtime = yield* adapter.openSession({
1243 + threadId,
1244 + providerSessionId: ProviderSessionId.make("cursor-windows-session"),
1245 + modelSelection,
1246 + runtimePolicy,
1247 + });
1248 + const thread = yield* runtime.ensureThread({ threadId, modelSelection, runtimePolicy });
1249 + assert.isTrue(opened);
1250 + assert.equal(thread.nativeThreadRef?.nativeId, "native-cursor-windows");
1251 + }).pipe(
1252 + Effect.scoped,
1253 + Effect.provide(
1254 + Layer.mergeAll(NodeServices.layer, IdAllocator.layer, McpProviderSessions.layer),
1255 + ),
1256 + ),
1257 + );
1258 +
1259 it("loads the user's Cursor settings layers in every runtime mode", () => {
1260 for (const runtimeMode of ["full-access", "auto-accept-edits", "approval-required"] as const) {
1261 const options = makeCursorAgentOptions({
@@ -1141,6 +1266,7 @@ describe("CursorAdapterV2", () => {
1266 runtimePolicy: { runtimeMode, interactionMode: "default", cwd: "/workspace" },
1267 threadId: ThreadId.make("thread-cursor-setting-sources"),
1268 mcpSession: undefined,
1269 + platform: "linux",
1270 });
1271 assert.deepEqual(options.local?.settingSources, [
1272 "project",
@@ -1187,6 +1313,7 @@ describe("CursorAdapterV2", () => {
1313 },
1314 threadId,
1315 mcpSession,
1316 + platform: "linux",
1317 });
1318 assert.deepEqual(options.mcpServers, cursorMcpServers(mcpSession));
1319
packages/provider-cursor/src/server/adapter.ts
+33 -13
@@ -183,6 +183,7 @@ export interface CursorRuntimeAgentPolicy {
183
184 export function cursorRuntimeAgentPolicy(
185 runtimePolicy: ProviderAdapter.ProviderAdapterV2RuntimePolicy,
186 + platform: NodeJS.Platform,
187 ): CursorRuntimeAgentPolicy {
188 const sandboxPolicyType =
189 typeof runtimePolicy.sandboxPolicy === "object" &&
@@ -191,14 +192,17 @@ export function cursorRuntimeAgentPolicy(
192 typeof runtimePolicy.sandboxPolicy.type === "string"
193 ? runtimePolicy.sandboxPolicy.type
194 : undefined;
195 + const autoReview =
196 + runtimePolicy.approvalPolicy === undefined
197 + ? runtimePolicy.runtimeMode === "approval-required" || runtimePolicy.runtimeMode === "auto"
198 + : runtimePolicy.approvalPolicy !== "never";
199 return {
195 - autoReview:
196 - runtimePolicy.approvalPolicy === undefined
197 - ? runtimePolicy.runtimeMode === "approval-required" || runtimePolicy.runtimeMode === "auto"
198 - : runtimePolicy.approvalPolicy !== "never",
200 + autoReview,
201 + // The Windows SDK has no filesystem sandbox; omit the default only when
202 + // Auto-review still gates execution. Explicit policies remain authoritative.
203 sandboxEnabled:
204 runtimePolicy.sandboxPolicy === undefined
201 - ? runtimePolicy.runtimeMode !== "full-access"
205 + ? runtimePolicy.runtimeMode !== "full-access" && !(platform === "win32" && autoReview)
206 : sandboxPolicyType !== "dangerFullAccess",
207 };
208 }
@@ -307,8 +311,9 @@ export function makeCursorAgentOptions(input: {
311 readonly runtimePolicy: ProviderAdapter.ProviderAdapterV2RuntimePolicy;
312 readonly threadId: ThreadId;
313 readonly mcpSession: McpProviderSession.McpProviderSessionConfig | undefined;
314 + readonly platform: NodeJS.Platform;
315 }): AgentOptions {
311 - const policy = cursorRuntimeAgentPolicy(input.runtimePolicy);
316 + const policy = cursorRuntimeAgentPolicy(input.runtimePolicy, input.platform);
317 const mcpServers = cursorMcpServers(input.mcpSession);
318 return {
319 model: cursorSdkModelSelection(input.modelSelection),
@@ -887,6 +892,7 @@ export const makeCursorAdapterV2 = Effect.fn("makeCursorAdapterV2")(function* (
892 const path = yield* Path.Path;
893 const idAllocator = yield* IdAllocator.IdAllocatorV2;
894 const runner = yield* CursorAgentSdk.CursorAgentSdkRunner;
895 + const platform = yield* HostProcess.Platform;
896 const host = yield* ProviderHost.ProviderHost;
897 const mcpSessions = yield* McpProviderSessions.McpProviderSessions;
898 const adapterOptions = options;
@@ -910,6 +916,7 @@ export const makeCursorAdapterV2 = Effect.fn("makeCursorAdapterV2")(function* (
916 });
917 const events = yield* Queue.unbounded<ProviderAdapter.ProviderAdapterV2Event>();
918 const liveAgent = yield* Ref.make<CursorLiveAgent | null>(null);
919 + const warnedUnsupportedSandbox = yield* Ref.make(false);
920 const activeTurn = yield* Ref.make<ActiveCursorTurn | null>(null);
921 const planIds = yield* Ref.make(new Map<string, OrchestrationV2PlanArtifact["id"]>());
922
@@ -2126,17 +2133,30 @@ export const makeCursorAdapterV2 = Effect.fn("makeCursorAdapterV2")(function* (
2133 yield* existing.session.close.pipe(Effect.ignore);
2134 yield* Ref.set(liveAgent, null);
2135 }
2136 + const options = makeCursorAgentOptions({
2137 + ...(apiKey === undefined ? {} : { apiKey }),
2138 + modelSelection: openInput.modelSelection,
2139 + runtimePolicy: openInput.runtimePolicy,
2140 + platform,
2141 + threadId: openInput.threadId,
2142 + mcpSession: yield* mcpSessions.read(openInput.threadId),
2143 + });
2144 + if (
2145 + platform === "win32" &&
2146 + openInput.runtimePolicy.sandboxPolicy === undefined &&
2147 + openInput.runtimePolicy.runtimeMode !== "full-access" &&
2148 + options.local?.sandboxOptions?.enabled === false &&
2149 + !(yield* Ref.getAndSet(warnedUnsupportedSandbox, true))
2150 + ) {
2151 + yield* Effect.logWarning(
2152 + "Cursor cannot sandbox the filesystem on Windows; this thread runs without filesystem isolation.",
2153 + );
2154 + }
2155 const sdkSession = yield* runner
2156 .open({
2157 operation: openInput.operation,
2158 ...(openInput.agentId === undefined ? {} : { agentId: openInput.agentId }),
2133 - options: makeCursorAgentOptions({
2134 - ...(apiKey === undefined ? {} : { apiKey }),
2135 - modelSelection: openInput.modelSelection,
2136 - runtimePolicy: openInput.runtimePolicy,
2137 - threadId: openInput.threadId,
2138 - mcpSession: yield* mcpSessions.read(openInput.threadId),
2139 - }),
2159 + options,
2160 threadId: openInput.threadId,
2161 providerSessionId: input.providerSessionId,
2162 })