@stigmer/runner 3.15.2 → 3.15.3-dev.20260914121148

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/dist/.build-fingerprint +1 -1
  2. package/dist/activities/execute-cursor/__test-utils__/contract-subject.js +12 -9
  3. package/dist/activities/execute-cursor/__test-utils__/contract-subject.js.map +1 -1
  4. package/dist/activities/execute-cursor/__test-utils__/hermetic-cursor.d.ts +5 -2
  5. package/dist/activities/execute-cursor/__test-utils__/hermetic-cursor.js +5 -2
  6. package/dist/activities/execute-cursor/__test-utils__/hermetic-cursor.js.map +1 -1
  7. package/dist/activities/execute-cursor/__test-utils__/scripted-agent.d.ts +11 -27
  8. package/dist/activities/execute-cursor/__test-utils__/scripted-agent.js +13 -10
  9. package/dist/activities/execute-cursor/__test-utils__/scripted-agent.js.map +1 -1
  10. package/dist/activities/execute-cursor/__test-utils__/scripted-sdk.d.ts +70 -26
  11. package/dist/activities/execute-cursor/__test-utils__/scripted-sdk.js +82 -32
  12. package/dist/activities/execute-cursor/__test-utils__/scripted-sdk.js.map +1 -1
  13. package/dist/activities/execute-cursor/adapter.d.ts +4 -3
  14. package/dist/activities/execute-cursor/adapter.js +9 -5
  15. package/dist/activities/execute-cursor/adapter.js.map +1 -1
  16. package/dist/activities/execute-cursor/sdk-warmup.d.ts +15 -6
  17. package/dist/activities/execute-cursor/sdk-warmup.js +15 -6
  18. package/dist/activities/execute-cursor/sdk-warmup.js.map +1 -1
  19. package/dist/activities/execute-cursor/session-lifecycle.d.ts +38 -59
  20. package/dist/activities/execute-cursor/session-lifecycle.js +59 -96
  21. package/dist/activities/execute-cursor/session-lifecycle.js.map +1 -1
  22. package/dist/activities/execute-cursor/session-store.d.ts +100 -0
  23. package/dist/activities/execute-cursor/session-store.js +157 -0
  24. package/dist/activities/execute-cursor/session-store.js.map +1 -0
  25. package/dist/shared/attachment-vision.d.ts +2 -1
  26. package/dist/shared/attachment-vision.js.map +1 -1
  27. package/package.json +5 -5
  28. package/src/activities/execute-cursor/__test-utils__/__tests__/scripted-double.test.ts +31 -7
  29. package/src/activities/execute-cursor/__test-utils__/contract-subject.ts +10 -8
  30. package/src/activities/execute-cursor/__test-utils__/hermetic-cursor.ts +5 -2
  31. package/src/activities/execute-cursor/__test-utils__/scripted-agent.ts +20 -28
  32. package/src/activities/execute-cursor/__test-utils__/scripted-sdk.ts +94 -38
  33. package/src/activities/execute-cursor/__tests__/cursor-baseurl-routing.test.ts +10 -8
  34. package/src/activities/execute-cursor/__tests__/cursor-fetch-interceptor-bypass.test.ts +5 -4
  35. package/src/activities/execute-cursor/__tests__/cursor-generate-image-live.test.ts +7 -2
  36. package/src/activities/execute-cursor/__tests__/cursor-hook-protocol-live.test.ts +163 -0
  37. package/src/activities/execute-cursor/__tests__/cursor-sdk-auth-smoke.test.ts +13 -12
  38. package/src/activities/execute-cursor/__tests__/hermetic/deny-and-retry.test.ts +4 -1
  39. package/src/activities/execute-cursor/__tests__/hermetic/file-review-capture.test.ts +4 -1
  40. package/src/activities/execute-cursor/__tests__/hermetic/harness-contract.test.ts +3 -0
  41. package/src/activities/execute-cursor/__tests__/hermetic/pause-vs-shutdown.test.ts +3 -0
  42. package/src/activities/execute-cursor/__tests__/hermetic/plain-turn.test.ts +4 -1
  43. package/src/activities/execute-cursor/__tests__/hermetic/recovery-fresh-agent.test.ts +4 -1
  44. package/src/activities/execute-cursor/__tests__/hermetic/run-wait-arms.test.ts +4 -1
  45. package/src/activities/execute-cursor/__tests__/hermetic/stream-self-stop-arms.test.ts +4 -1
  46. package/src/activities/execute-cursor/__tests__/hermetic/thrown-error-arms.test.ts +3 -0
  47. package/src/activities/execute-cursor/__tests__/hermetic/tool-call.test.ts +4 -1
  48. package/src/activities/execute-cursor/__tests__/hermetic/unattributed-hook-block.test.ts +4 -1
  49. package/src/activities/execute-cursor/__tests__/hermetic/workspace-lock-timeout.test.ts +3 -0
  50. package/src/activities/execute-cursor/__tests__/session-lifecycle.test.ts +86 -58
  51. package/src/activities/execute-cursor/__tests__/session-store.test.ts +220 -0
  52. package/src/activities/execute-cursor/adapter.ts +9 -5
  53. package/src/activities/execute-cursor/sdk-warmup.ts +15 -6
  54. package/src/activities/execute-cursor/session-lifecycle.ts +63 -109
  55. package/src/activities/execute-cursor/session-store.ts +187 -0
  56. package/src/shared/attachment-vision.ts +2 -1
@@ -1,11 +1,16 @@
1
1
  /**
2
2
  * The `@cursor/sdk` module a hermetic `ExecuteCursor` run imports — every
3
- * runtime surface the activity path touches, backed by scripted agents.
3
+ * runtime surface the activity path touches, backed by scripted agents — and
4
+ * the `@cursor/sdk/sqlite` module beside it, backed by a store that holds
5
+ * nothing.
4
6
  *
5
- * The activity reaches the SDK at three runtime sites and nowhere else:
7
+ * The activity reaches the SDK at four runtime sites and nowhere else:
6
8
  *
7
- * - `session-lifecycle.ts`: `Agent.create(options)`, `Agent.resume(id, options)`,
8
- * `Agent.archive(id, ...)` — the agent handle.
9
+ * - `session-lifecycle.ts`: `Agent.create(options)`, `Agent.resume(id, options)`
10
+ * — the agent handle.
11
+ * - `session-store.ts`: `SqliteLocalAgentStore.open({ workspaceRef, stateRoot })`
12
+ * from `@cursor/sdk/sqlite` — the session's store the handle is created and
13
+ * resumed over (`local.store`).
9
14
  * - `service-tier.ts`: `Cursor.models.list({ apiKey })` — the catalog the
10
15
  * variant params (`fast`, `thinking`) are pinned from.
11
16
  * - `index.ts` outer catch: `import("@cursor/sdk")` for `CursorSdkError`, the
@@ -13,50 +18,78 @@
13
18
  *
14
19
  * Neither the SDK nor the client is injectable into the activity (the real
15
20
  * seam arrives with the harness contract; parent Q1/Q2), so — exactly as the
16
- * native activity tests already do for their boundary modules — the module is
17
- * substituted with `vi.mock`. Three existing tests each mock ONE of these
21
+ * native activity tests already do for their boundary modules — the modules
22
+ * are substituted with `vi.mock`. Three existing tests each mock ONE of these
18
23
  * surfaces (`session-lifecycle.test.ts`, `service-tier.test.ts`,
19
- * `sdk-warmup.test.ts`); a whole-activity run needs all three at once, which is
20
- * what this module is.
24
+ * `sdk-warmup.test.ts`); a whole-activity run needs all of them at once, which
25
+ * is what this module is.
21
26
  *
22
- * `vi.mock` is hoisted and must appear in the test file; the factory can
23
- * `await import()` this module and return {@link scriptedCursorSdkModule}. The
24
- * module's statics read the {@link ScriptedCursorSdk} bound for the current
27
+ * `vi.mock` is hoisted and must appear in the test file, once per module id
28
+ * (a subpath is its own module id, so `@cursor/sdk/sqlite` needs its own
29
+ * `vi.mock`); the factories `await import()` this module and return
30
+ * {@link scriptedCursorSdkModule} and {@link scriptedCursorSqliteModule}. The
31
+ * modules' statics read the {@link ScriptedCursorSdk} bound for the current
25
32
  * scenario ({@link bindScriptedSdk}), so one test file can run several
26
- * scenarios with different agents against the same mocked module.
33
+ * scenarios with different agents against the same mocked modules.
27
34
  *
28
35
  * Resolution rules a scenario declares, mirroring what the real SDK does:
29
36
  * - `Agent.create` hands out the agent declared for the session it is asked
30
- * for (`agentForSession`, when the scenario resolves agents per session —
31
- * the harness contract kit runs several sessions concurrently on one
32
- * adapter, and the order their creates arrive in is real I/O timing), else
33
- * the NEXT unclaimed agent in `agents` (turn 1 of a fresh session; the fresh
34
- * agent of a poisoned-handle recovery) — unless the scenario declared a
35
- * `createFailure`, which the FIRST create throws instead (the SDK refusing
37
+ * for (`agentForWorkspaceRef`, when the scenario resolves agents per
38
+ * session — the harness contract kit runs several sessions concurrently on
39
+ * one adapter, and the order their creates arrive in is real I/O timing),
40
+ * else the NEXT unclaimed agent in `agents` (turn 1 of a fresh session; the
41
+ * fresh agent of a poisoned-handle recovery) — unless the scenario declared
42
+ * a `createFailure`, which the FIRST create throws instead (the SDK refusing
36
43
  * to mint an agent: a 401 on the key, a validation error).
37
44
  * - `Agent.resume(id)` hands back the agent with that id if the scenario
38
45
  * declared it (in `agents` or `resumableAgents`, or handed out for a
39
46
  * session), else throws — `resolveAgent` then falls back to `create`, which
40
47
  * is the production shape of a lost handle.
41
48
  * - `Cursor.models.list` answers the scenario's catalog.
49
+ * - `SqliteLocalAgentStore.open` hands out a {@link ScriptedLocalAgentStore}
50
+ * carrying the ref and root it was asked for, and records the open; its
51
+ * `dispose()` is recorded too, so a scenario can assert the adapter's
52
+ * session-store lifetime (`releaseSession`, `shutdown`).
42
53
  */
43
54
  /**
44
- * The `platform.workspaceRef` a create names, read defensively: the platform
45
- * option's type re-exports from the unshipped `@anysphere/cursor-sdk-local-runtime`
46
- * and resolves to `any` under `skipLibCheck` (the same gap `scripted-agent.ts`
47
- * records for the delta channel), so the shape is checked here, not assumed.
55
+ * The session a create names: the `workspaceRef` of the store it passes as
56
+ * `local.store`. In a hermetic run that store is the one this module's sqlite
57
+ * double opened; anything else (a test that mocks `@cursor/sdk` with its own
58
+ * stub and passes no store) names no session and falls through to the list.
48
59
  */
49
60
  function workspaceRefOf(options) {
50
- const platform = options.platform;
51
- if (typeof platform !== "object" || platform === null)
52
- return undefined;
53
- const ref = platform.workspaceRef;
54
- return typeof ref === "string" ? ref : undefined;
61
+ const store = options.local?.store;
62
+ return store instanceof ScriptedLocalAgentStore ? store.workspaceRef : undefined;
63
+ }
64
+ /**
65
+ * The `@cursor/sdk/sqlite` store the adapter opens per session, holding
66
+ * nothing: the scripted agents carry their own state, so the store only has
67
+ * to be the thing `Agent.create` / `Agent.resume` are handed and the thing
68
+ * `releaseSession` / `shutdown` dispose. `open` and `dispose` are recorded on
69
+ * the bound {@link ScriptedCursorSdk} for lifetime assertions.
70
+ */
71
+ export class ScriptedLocalAgentStore {
72
+ workspaceRef;
73
+ stateRoot;
74
+ disposeCalls = 0;
75
+ constructor(workspaceRef, stateRoot) {
76
+ this.workspaceRef = workspaceRef;
77
+ this.stateRoot = stateRoot;
78
+ }
79
+ static async open(options) {
80
+ const store = new ScriptedLocalAgentStore(options.workspaceRef, options.stateRoot ?? "");
81
+ current().stores.push(store);
82
+ return store;
83
+ }
84
+ async dispose() {
85
+ this.disposeCalls++;
86
+ }
55
87
  }
56
88
  export class ScriptedCursorSdk {
57
89
  options;
58
90
  resolutions = [];
59
- archived = [];
91
+ /** Every store `SqliteLocalAgentStore.open` handed out, in order. */
92
+ stores = [];
60
93
  nextCreate = 0;
61
94
  createFailurePending;
62
95
  byId = new Map();
@@ -101,9 +134,6 @@ export class ScriptedCursorSdk {
101
134
  agent.model = options.model;
102
135
  return agent;
103
136
  }
104
- archive(agentId) {
105
- this.archived.push(agentId);
106
- }
107
137
  listModels() {
108
138
  return this.options.catalog;
109
139
  }
@@ -178,7 +208,6 @@ export function scriptedCursorSdkModule() {
178
208
  Agent: {
179
209
  create: async (options) => current().create(options),
180
210
  resume: async (agentId, options) => current().resume(agentId, options),
181
- archive: async (agentId) => current().archive(agentId),
182
211
  },
183
212
  Cursor: {
184
213
  models: {
@@ -188,4 +217,25 @@ export function scriptedCursorSdkModule() {
188
217
  CursorSdkError: ScriptedCursorSdkError,
189
218
  };
190
219
  }
220
+ /**
221
+ * The factory a test passes to `vi.mock("@cursor/sdk/sqlite", ...)`, beside
222
+ * the one above:
223
+ *
224
+ * ```ts
225
+ * vi.mock("@cursor/sdk/sqlite", async () =>
226
+ * (await import("../../__test-utils__/scripted-sdk.js")).scriptedCursorSqliteModule(),
227
+ * );
228
+ * ```
229
+ *
230
+ * The one export the runner reads from that entry (`session-store.ts`). The
231
+ * class is exported under the SDK's name so `session-store.ts`'s dynamic
232
+ * import destructures it unchanged; its type is the SDK's, which is why
233
+ * {@link ScriptedLocalAgentStore} carries `workspaceRef`, `stateRoot` and
234
+ * `dispose()` — the members the runner touches — and nothing else.
235
+ */
236
+ export function scriptedCursorSqliteModule() {
237
+ return {
238
+ SqliteLocalAgentStore: ScriptedLocalAgentStore,
239
+ };
240
+ }
191
241
  //# sourceMappingURL=scripted-sdk.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"scripted-sdk.js","sourceRoot":"","sources":["../../../../src/activities/execute-cursor/__test-utils__/scripted-sdk.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;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,OAAO,EAAE,OAAO,CAAC;SACrC;QACD,MAAM,EAAE;YACN,MAAM,EAAE;gBACN,IAAI,EAAE,KAAK,IAAuC,EAAE,CAAC,OAAO,EAAE,CAAC,UAAU,EAAE;aAC5E;SACF;QACD,cAAc,EAAE,sBAAsB;KACvC,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,0BAA0B;IACxC,OAAO;QACL,qBAAqB,EAAE,uBAEtB;KACF,CAAC;AACJ,CAAC"}
@@ -5,9 +5,10 @@
5
5
  * module boots, releases, and delegates.
6
6
  *
7
7
  * What this adapter owns: the proxy interceptors and the parked-agent cache
8
- * (worker lifetime), the parked agent per session (session lifetime), and one
9
- * engine turn (`runTurn`, through `turn.ts`). Everything else about a turn is
10
- * the runtime's (`harness/run-turn.ts`).
8
+ * (worker lifetime), the parked agent and the SDK store per session (session
9
+ * lifetime; `agent-session-cache.ts`, `session-store.ts`), and one engine turn
10
+ * (`runTurn`, through `turn.ts`). Everything else about a turn is the
11
+ * runtime's (`harness/run-turn.ts`).
11
12
  *
12
13
  * THIS MODULE'S STATIC GRAPH IS SDK-FREE, ON PURPOSE. The composition roots
13
14
  * import it (through `src/harness-adapters.ts`) BEFORE they boot it, and
@@ -5,9 +5,10 @@
5
5
  * module boots, releases, and delegates.
6
6
  *
7
7
  * What this adapter owns: the proxy interceptors and the parked-agent cache
8
- * (worker lifetime), the parked agent per session (session lifetime), and one
9
- * engine turn (`runTurn`, through `turn.ts`). Everything else about a turn is
10
- * the runtime's (`harness/run-turn.ts`).
8
+ * (worker lifetime), the parked agent and the SDK store per session (session
9
+ * lifetime; `agent-session-cache.ts`, `session-store.ts`), and one engine turn
10
+ * (`runTurn`, through `turn.ts`). Everything else about a turn is the
11
+ * runtime's (`harness/run-turn.ts`).
11
12
  *
12
13
  * THIS MODULE'S STATIC GRAPH IS SDK-FREE, ON PURPOSE. The composition roots
13
14
  * import it (through `src/harness-adapters.ts`) BEFORE they boot it, and
@@ -54,6 +55,7 @@ import { closeAllCachedAgents, evictSessionAgent } from "./agent-session-cache.j
54
55
  import { CURSOR_CAPABILITIES } from "./cursor-capabilities.js";
55
56
  import { installFetchInterceptor } from "./fetch-interceptor.js";
56
57
  import { assertHttp2ConnectPatched, installHttp2Interceptor } from "./http2-interceptor.js";
58
+ import { releaseAllSessionStores, releaseSessionStore } from "./session-store.js";
57
59
  /** The config slice this adapter reads per turn, taken at `boot`; a whole `Config` satisfies it. */
58
60
  export function resolveCursorConfig(config) {
59
61
  return {
@@ -102,13 +104,15 @@ export function createCursorAdapter() {
102
104
  const { runCursorTurn } = await import("./turn.js");
103
105
  booted = { config: resolveCursorConfig(bootConfig), runCursorTurn };
104
106
  },
105
- /** Close every parked agent (their executor leases and MCP subprocesses). */
107
+ /** Close every parked agent (their executor leases and MCP subprocesses), then every session's SDK store. */
106
108
  async shutdown() {
107
109
  closeAllCachedAgents();
110
+ await releaseAllSessionStores();
108
111
  },
109
- /** The session is done on this host: close the agent parked for it, if any (#215). */
112
+ /** The session is done on this host: close the agent parked for it, if any (#215), then its SDK store (#1053). */
110
113
  async releaseSession(sessionId) {
111
114
  evictSessionAgent(sessionId);
115
+ await releaseSessionStore(sessionId);
112
116
  },
113
117
  async runTurn(input, sink) {
114
118
  if (booted === undefined) {
@@ -1 +1 @@
1
- {"version":3,"file":"adapter.js","sourceRoot":"","sources":["../../../src/activities/execute-cursor/adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkDG;AAIH,OAAO,EAAE,QAAQ,EAAE,MAAM,mCAAmC,CAAC;AAC7D,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AACnF,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,EAAE,yBAAyB,EAAE,uBA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AAC,SAAS,CAAC,CAAC;YAC7B,MAAM,mBAAmB,CAAC,SAAS,CAAC,CAAC;QACvC,CAAC;QAED,KAAK,CAAC,OAAO,CAAC,KAAgB,EAAE,IAAc;YAC5C,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;gBACzB,MAAM,IAAI,KAAK,CAAC,gGAAgG,CAAC,CAAC;YACpH,CAAC;YACD,OAAO,MAAM,CAAC,aAAa,CAAC,KAAK,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;QAC1D,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -3,10 +3,19 @@
3
3
  *
4
4
  * The first `Agent.create` in a pod pays the SDK's platform construction:
5
5
  * four SQLite-backed stores (run/checkpoint/event stores + notifier) whose
6
- * first use loads the sqlite native binding and compiles the schema
7
- * migrations. The 2026-07-30 instrumented baseline (issue #209) measured
8
- * this at ~1.2s of the ~2.4s `resolve_agent` segment, with a 624ms floor —
9
- * roughly half the cost is per-process warm-up, not per-session work.
6
+ * first use compiles the schema migrations. The 2026-07-30 instrumented
7
+ * baseline (issue #209, @cursor/sdk 1.0.13) measured this at ~1.2s of the
8
+ * ~2.4s `resolve_agent` segment, with a 624ms floor — roughly half the cost
9
+ * was per-process warm-up, not per-session work. Part of that floor was the
10
+ * `sqlite3` native binding's load; since 1.0.31 (stigmer/stigmer#1053) the
11
+ * SDK's stores run on `node:sqlite`, which is inside the Node binary, and the
12
+ * session's store is opened by the runner itself (`session-store.ts`,
13
+ * `SqliteLocalAgentStore.open`) rather than through the platform this
14
+ * warm-up constructs. What this warm-up still saves at 1.0.31 is therefore a
15
+ * measurement, not a known quantity: its `durationMs` and the cold-start
16
+ * timeline answer it, and the harness program carries the question of
17
+ * whether to warm through the store the runner actually opens, or through
18
+ * the SDK's own `prewarmLocalWorkspace`, or not at all.
10
19
  *
11
20
  * Pool members idle between boot and claim, so constructing one throwaway
12
21
  * platform there moves that per-process cost off the user-visible path.
@@ -26,8 +35,8 @@ export interface SdkWarmupResult {
26
35
  }
27
36
  /**
28
37
  * Construct (and abandon) one SDK agent platform on a throwaway temp-dir
29
- * state root, forcing the sqlite native binding + store schema work to
30
- * happen now instead of inside the first user-facing `Agent.create`.
38
+ * state root, forcing the store schema work to happen now instead of inside
39
+ * the first user-facing `Agent.create`.
31
40
  *
32
41
  * Total by construction — warm-up is an optimization and must never affect
33
42
  * the member's ability to serve. The throwaway state root is a few KB on
@@ -3,10 +3,19 @@
3
3
  *
4
4
  * The first `Agent.create` in a pod pays the SDK's platform construction:
5
5
  * four SQLite-backed stores (run/checkpoint/event stores + notifier) whose
6
- * first use loads the sqlite native binding and compiles the schema
7
- * migrations. The 2026-07-30 instrumented baseline (issue #209) measured
8
- * this at ~1.2s of the ~2.4s `resolve_agent` segment, with a 624ms floor —
9
- * roughly half the cost is per-process warm-up, not per-session work.
6
+ * first use compiles the schema migrations. The 2026-07-30 instrumented
7
+ * baseline (issue #209, @cursor/sdk 1.0.13) measured this at ~1.2s of the
8
+ * ~2.4s `resolve_agent` segment, with a 624ms floor — roughly half the cost
9
+ * was per-process warm-up, not per-session work. Part of that floor was the
10
+ * `sqlite3` native binding's load; since 1.0.31 (stigmer/stigmer#1053) the
11
+ * SDK's stores run on `node:sqlite`, which is inside the Node binary, and the
12
+ * session's store is opened by the runner itself (`session-store.ts`,
13
+ * `SqliteLocalAgentStore.open`) rather than through the platform this
14
+ * warm-up constructs. What this warm-up still saves at 1.0.31 is therefore a
15
+ * measurement, not a known quantity: its `durationMs` and the cold-start
16
+ * timeline answer it, and the harness program carries the question of
17
+ * whether to warm through the store the runner actually opens, or through
18
+ * the SDK's own `prewarmLocalWorkspace`, or not at all.
10
19
  *
11
20
  * Pool members idle between boot and claim, so constructing one throwaway
12
21
  * platform there moves that per-process cost off the user-visible path.
@@ -24,8 +33,8 @@ import { tmpdir } from "node:os";
24
33
  import { join } from "node:path";
25
34
  /**
26
35
  * Construct (and abandon) one SDK agent platform on a throwaway temp-dir
27
- * state root, forcing the sqlite native binding + store schema work to
28
- * happen now instead of inside the first user-facing `Agent.create`.
36
+ * state root, forcing the store schema work to happen now instead of inside
37
+ * the first user-facing `Agent.create`.
29
38
  *
30
39
  * Total by construction — warm-up is an optimization and must never affect
31
40
  * the member's ability to serve. The throwaway state root is a few KB on
@@ -1 +1 @@
1
- {"version":3,"file":"sdk-warmup.js","sourceRoot":"","sources":["../../../src/activities/execute-cursor/sdk-warmup.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAQjC;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,KAAK,UAAU,wBAAwB;IAC5C,MAAM,OAAO,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC;IAClC,IAAI,CAAC;QACH,MAAM,SAAS,GAAG,WAAW,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,kBAAkB,CAAC,CAAC,CAAC;QAClE,MAAM,EAAE,mBAAmB,EAAE,GAAG,MAAM,MAAM,CAAC,aAAa,CAAC,CAAC;QAC5D,MAAM,mBAAmB,CAAC,EAAE,YAAY,EAAE,mBAAmB,EAAE,SAAS,EAAE,CAAC,CAAC;QAC5E,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;IACxD,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO;YACL,MAAM,EAAE,KAAK;YACb,UAAU,EAAE,OAAO,CAAC,OAAO,CAAC;YAC5B,KAAK,EAAE,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC;SACxD,CAAC;IACJ,CAAC;AACH,CAAC;AAED,SAAS,OAAO,CAA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,KAAK,CAAC,CAAC,WAAW,CAAC,GAAG,EAAE,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,CAAC;AAC7D,CAAC"}
@@ -3,39 +3,46 @@
3
3
  *
4
4
  * SessionSpec.harness_state_id stores the Cursor agentId. This module handles
5
5
  * creating new agents (first execution), resuming existing agents
6
- * (subsequent executions), graceful fallback on resume failure, and
7
- * cleaning up agents (session deletion).
6
+ * (subsequent executions) and graceful fallback on resume failure.
8
7
  *
9
8
  * Two execution modes:
10
9
  *
11
- * - Local mode: Agent.create({ local: { cwd } }) with explicit
12
- * platform.workspaceRef/stateRoot for deterministic store keying.
13
- * Produces agent- prefixed IDs.
10
+ * - Local mode: Agent.create({ local: { cwd, dirs, store, ... } }) over the
11
+ * session's own SQLite store (`session-store.ts`). Produces agent- prefixed
12
+ * IDs.
14
13
  *
15
14
  * - Cloud mode (feature-flagged): Agent.create({ cloud: { repos } })
16
- * for git-backed workspaces. Produces bc- prefixed IDs. No platform
17
- * options — cloud state lives on Cursor's servers, not local SQLite.
18
- *
19
- * Key SDK limitation: mcpServers are NOT persisted across Agent.resume().
20
- * They must be passed again on every resume call.
21
- *
22
- * Platform store keying (local only): The Cursor SDK defaults to
23
- * process.cwd() for its internal state root lookup. In cloud sandboxes,
24
- * process.cwd() is the runner's app directory, not the workspace causing
25
- * Agent.resume() to fail with "Agent not found". We pass explicit
26
- * platform.workspaceRef and platform.stateRoot derived from the Stigmer
27
- * sessionId to ensure deterministic store lookup regardless of process.cwd().
28
- *
29
- * Durability model: the SDK's local SQLite store (agent records, runs,
30
- * checkpoints) is the source of truth for conversation continuation. It is
31
- * persisted under the durable workspace volume (see resolvePlatformOptions)
32
- * so Agent.resume() survives pod restart, reschedule, and snapshot restore.
33
- * When resume nonetheless fails (store lost, corrupted, or agent unknown),
34
- * this module creates a fresh agent and the caller starts a new turn from
35
- * the user message plus re-injected instructions — there is no separate
36
- * continuation store.
15
+ * for git-backed workspaces. Produces bc- prefixed IDs. No store — cloud
16
+ * state lives on Cursor's servers, not local SQLite.
17
+ *
18
+ * Nothing under `local` survives Agent.resume(): `cwd`, `dirs`,
19
+ * `settingSources`, `store` and `enableAgentRetries` are re-supplied on every
20
+ * resume, exactly like `mcpServers`, `agents` and the model params. Omitting
21
+ * `cwd` re-roots the resumed agent at process.cwd() and loads the "project"
22
+ * setting source (the .cursor/hooks.json carrying the HITL approval hook) from
23
+ * the wrong directory, silently disabling the gate on every resumed turn;
24
+ * omitting `store` would make the SDK look the agent up in a default store
25
+ * derived from `cwd`, not the one the session's records are in.
26
+ *
27
+ * Durability model: the session's SQLite store (agent records, runs,
28
+ * checkpoints) is the source of truth for conversation continuation. It lives
29
+ * under the durable workspace volume (`session-store.ts`) so Agent.resume()
30
+ * survives pod restart, reschedule, and snapshot restore. When resume
31
+ * nonetheless fails (store lost, corrupted, or agent unknown), this module
32
+ * creates a fresh agent and the caller starts a new turn from the user message
33
+ * plus re-injected instructions there is no separate continuation store.
34
+ *
35
+ * Retries are the runner's, not the SDK's. `@cursor/sdk` 1.0.31 defaults
36
+ * `enableAgentRetries` to true for headless embedders (1.0.13 defaulted it to
37
+ * false); the runner already owns recovery from a dead or stalled transport —
38
+ * `withTimeout` around agent resolution, `resolveAgentWithTransportRecovery`
39
+ * (reset the transport, retry once), the two recovery spines in
40
+ * `turn-settle.ts`, and the stall detector — so the SDK's layer is pinned OFF
41
+ * to keep one retry authority and the 1.0.13 timing of every provider fault.
42
+ * Whether to adopt the SDK's retries and delete ours is an open design
43
+ * question for the harness program, recorded there; it is not decided here.
37
44
  */
38
- import type { SDKAgent, CursorAgentPlatformOptions, AgentDefinition, ModelParameterValue } from "@cursor/sdk";
45
+ import type { SDKAgent, AgentDefinition, ModelParameterValue } from "@cursor/sdk";
39
46
  import type { CloudRepo } from "../../shared/blueprint-resolver.js";
40
47
  import type { CursorMcpServerConfig } from "./cursor-mcp-config.js";
41
48
  export interface CreateAgentOptions {
@@ -129,31 +136,8 @@ export interface AgentResolution {
129
136
  /** Non-empty only when reason is "created_after_resume_failure". */
130
137
  resumeFailureDetail?: string;
131
138
  }
132
- /**
133
- * Compute deterministic platform options for a Stigmer session.
134
- *
135
- * workspaceRef is a synthetic identifier (not a filesystem path) that
136
- * ensures the SDK's platform cache key is stable across activity
137
- * invocations regardless of process.cwd().
138
- *
139
- * stateRoot is a session-isolated directory under the durable workspace
140
- * volume ({workspaceRootDir}/.stigmer/cursor-sdk-state/{sessionId}) where
141
- * the SDK persists its SQLite stores (agent records, runs, checkpoints).
142
- * Placing it on the workspace volume (rather than $HOME) makes native
143
- * Agent.resume() survive pod restart/reschedule and snapshot restore, and
144
- * keys it by sessionId so sessions sharing one volume (e.g. the child agent
145
- * executions of a workflow sandbox) never collide. Created eagerly to
146
- * prevent ENOENT on first SDK write.
147
- *
148
- * Both inputs are required and must be non-empty: the stateRoot is keyed by
149
- * sessionId, so an empty sessionId would collapse every session sharing the
150
- * volume onto the same store and corrupt their conversation state.
151
- */
152
- export declare function resolvePlatformOptions(sessionId: string, workspaceRootDir: string): CursorAgentPlatformOptions;
153
139
  /**
154
140
  * Create a new local Cursor Agent for the first execution in a session.
155
- *
156
- * Supports multi-workspace: passes string[] when multiple dirs, string when single.
157
141
  */
158
142
  export declare function createAgent(options: CreateAgentOptions): Promise<SDKAgent>;
159
143
  /**
@@ -167,7 +151,7 @@ export declare function resumeAgent(options: ResumeAgentOptions): Promise<SDKAge
167
151
  * Create a new cloud Cursor Agent for git-backed sessions.
168
152
  *
169
153
  * Cloud agents (bc- prefix) run on Cursor's servers with cloned repos.
170
- * No platform options — cloud state lives server-side, not in local SQLite.
154
+ * No store — cloud state lives server-side, not in local SQLite.
171
155
  * Model is optional — Cursor resolves the caller's configured default
172
156
  * when omitted.
173
157
  */
@@ -177,7 +161,7 @@ export declare function createCloudAgent(options: CreateCloudAgentOptions): Prom
177
161
  *
178
162
  * Throws on failure — the caller (resolveAgent) decides whether to
179
163
  * propagate or fall back to a fresh cloud agent with continuation context.
180
- * No platform options — cloud state lives server-side.
164
+ * No store — cloud state lives server-side.
181
165
  */
182
166
  export declare function resumeCloudAgent(options: ResumeCloudAgentOptions): Promise<SDKAgent>;
183
167
  /**
@@ -185,8 +169,8 @@ export declare function resumeCloudAgent(options: ResumeCloudAgentOptions): Prom
185
169
  * graceful fallback if resume fails.
186
170
  *
187
171
  * The mode parameter determines which create/resume functions are used:
188
- * - "local": createAgent / resumeAgent (with platform options)
189
- * - "cloud": createCloudAgent / resumeCloudAgent (no platform options)
172
+ * - "local": createAgent / resumeAgent (over the session's store)
173
+ * - "cloud": createCloudAgent / resumeCloudAgent (no store)
190
174
  *
191
175
  * When harnessStateId is non-empty (subsequent execution):
192
176
  * 1. Attempt Agent.resume with mode-appropriate options.
@@ -248,8 +232,3 @@ export interface ResolveWithTransportRecoveryOptions {
248
232
  * cost, no state impact, cleaned up with the sandbox.
249
233
  */
250
234
  export declare function resolveAgentWithTransportRecovery(opts: ResolveWithTransportRecoveryOptions): Promise<AgentResolution>;
251
- /**
252
- * Dispose a Cursor Agent when a session is deleted.
253
- * Best-effort: logs and swallows errors.
254
- */
255
- export declare function disposeAgent(agentId: string, apiKey: string): Promise<void>;