@ai-hero/sandcastle 0.12.0 → 0.14.0

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 (77) hide show
  1. package/README.md +15 -1368
  2. package/dist/LinuxCapability-B_PQfsY_.d.ts +32 -0
  3. package/dist/{SandboxProvider-EkSMuBp8.d.ts → SandboxProvider-Chsi-Zs6.d.ts} +31 -3
  4. package/dist/{chunk-NGBM7T3E.js → chunk-6NQPCXSG.js} +5 -2
  5. package/dist/chunk-6NQPCXSG.js.map +1 -0
  6. package/dist/chunk-7N7AMUYA.js +353 -0
  7. package/dist/chunk-7N7AMUYA.js.map +1 -0
  8. package/dist/chunk-ATA2V2TC.js +112 -0
  9. package/dist/chunk-ATA2V2TC.js.map +1 -0
  10. package/dist/chunk-BIF2X6QB.js +94 -0
  11. package/dist/chunk-BIF2X6QB.js.map +1 -0
  12. package/dist/{chunk-BIWNFKGV.js → chunk-BVZWLFFT.js} +2 -2
  13. package/dist/chunk-BVZWLFFT.js.map +1 -0
  14. package/dist/chunk-EXYXBRCX.js +60 -0
  15. package/dist/chunk-EXYXBRCX.js.map +1 -0
  16. package/dist/chunk-G2R53CVZ.js +3172 -0
  17. package/dist/chunk-G2R53CVZ.js.map +1 -0
  18. package/dist/{chunk-CP3TYXZA.js → chunk-GCLEXPXG.js} +95 -85
  19. package/dist/chunk-GCLEXPXG.js.map +1 -0
  20. package/dist/chunk-H2PEFS4W.js +1244 -0
  21. package/dist/chunk-H2PEFS4W.js.map +1 -0
  22. package/dist/chunk-HSXPRZKG.js +150 -0
  23. package/dist/chunk-HSXPRZKG.js.map +1 -0
  24. package/dist/chunk-IBK2XNSS.js +50 -0
  25. package/dist/chunk-IBK2XNSS.js.map +1 -0
  26. package/dist/chunk-RDW7FNN6.js +792 -0
  27. package/dist/chunk-RDW7FNN6.js.map +1 -0
  28. package/dist/{chunk-DJRHWPEH.js → chunk-S6UHPTRG.js} +284 -352
  29. package/dist/chunk-S6UHPTRG.js.map +1 -0
  30. package/dist/{chunk-VOG34SRF.js → chunk-STB2U7BB.js} +11823 -6977
  31. package/dist/chunk-STB2U7BB.js.map +1 -0
  32. package/dist/chunk-VRXR2T3S.js +24 -0
  33. package/dist/chunk-VRXR2T3S.js.map +1 -0
  34. package/dist/index.d.ts +241 -26
  35. package/dist/index.js +1082 -1679
  36. package/dist/index.js.map +1 -1
  37. package/dist/main.js +1248 -854
  38. package/dist/main.js.map +1 -1
  39. package/dist/sandboxes/bwrap.d.ts +58 -0
  40. package/dist/sandboxes/bwrap.js +296 -0
  41. package/dist/sandboxes/bwrap.js.map +1 -0
  42. package/dist/sandboxes/daytona.d.ts +1 -1
  43. package/dist/sandboxes/daytona.js +203 -98
  44. package/dist/sandboxes/daytona.js.map +1 -1
  45. package/dist/sandboxes/docker.d.ts +18 -4
  46. package/dist/sandboxes/docker.js +7 -4
  47. package/dist/sandboxes/e2b.d.ts +41 -0
  48. package/dist/sandboxes/e2b.js +202 -0
  49. package/dist/sandboxes/e2b.js.map +1 -0
  50. package/dist/sandboxes/modal.d.ts +78 -0
  51. package/dist/sandboxes/modal.js +171 -0
  52. package/dist/sandboxes/modal.js.map +1 -0
  53. package/dist/sandboxes/no-sandbox.d.ts +1 -1
  54. package/dist/sandboxes/no-sandbox.js +2 -2
  55. package/dist/sandboxes/podman.d.ts +18 -4
  56. package/dist/sandboxes/podman.js +72 -56
  57. package/dist/sandboxes/podman.js.map +1 -1
  58. package/dist/sandboxes/seatbelt.d.ts +65 -0
  59. package/dist/sandboxes/seatbelt.js +425 -0
  60. package/dist/sandboxes/seatbelt.js.map +1 -0
  61. package/dist/sandboxes/sprites.d.ts +54 -0
  62. package/dist/sandboxes/sprites.js +198 -0
  63. package/dist/sandboxes/sprites.js.map +1 -0
  64. package/dist/sandboxes/vercel.d.ts +12 -5
  65. package/dist/sandboxes/vercel.js +195 -126
  66. package/dist/sandboxes/vercel.js.map +1 -1
  67. package/dist/templates/parallel-planner/main.mts +13 -22
  68. package/dist/templates/parallel-planner-with-review/main.mts +13 -15
  69. package/package.json +63 -11
  70. package/dist/chunk-62WN33RK.js +0 -104
  71. package/dist/chunk-62WN33RK.js.map +0 -1
  72. package/dist/chunk-BIWNFKGV.js.map +0 -1
  73. package/dist/chunk-CP3TYXZA.js.map +0 -1
  74. package/dist/chunk-DJRHWPEH.js.map +0 -1
  75. package/dist/chunk-NGBM7T3E.js.map +0 -1
  76. package/dist/chunk-VOG34SRF.js.map +0 -1
  77. package/dist/mountUtils-CCA-bbpK.d.ts +0 -25
@@ -0,0 +1,24 @@
1
+ import { createRequire } from 'node:module';
2
+ import { NativeInteractiveNotSupportedError } from './chunk-RDW7FNN6.js';
3
+
4
+ createRequire(import.meta.url);
5
+
6
+ // src/nativeSandboxProvider.ts
7
+ var nativeProviders = /* @__PURE__ */ new WeakSet();
8
+ var markNativeSandboxProvider = (provider) => {
9
+ nativeProviders.add(provider);
10
+ return provider;
11
+ };
12
+ var NativeInteractiveNotSupportedError2 = NativeInteractiveNotSupportedError;
13
+ var assertInteractiveSupported = (provider) => {
14
+ if (provider !== void 0 && nativeProviders.has(provider)) {
15
+ throw new NativeInteractiveNotSupportedError2({
16
+ message: `interactive() is not supported on native providers (got ${provider.name}()). Use run(), or pass docker() or noSandbox() to interactive().`,
17
+ provider: provider.name
18
+ });
19
+ }
20
+ };
21
+
22
+ export { NativeInteractiveNotSupportedError2 as NativeInteractiveNotSupportedError, assertInteractiveSupported, markNativeSandboxProvider };
23
+ //# sourceMappingURL=chunk-VRXR2T3S.js.map
24
+ //# sourceMappingURL=chunk-VRXR2T3S.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/nativeSandboxProvider.ts"],"names":["NativeInteractiveNotSupportedError"],"mappings":";;;;;;AAUA,IAAM,eAAA,uBAAsB,OAAA,EAAyB;AAG9C,IAAM,yBAAA,GAA4B,CACvC,QAAA,KACM;AACN,EAAA,eAAA,CAAgB,IAAI,QAAQ,CAAA;AAC5B,EAAA,OAAO,QAAA;AACT;AA4BO,IAAMA,mCAAAA,GACX;AAGK,IAAM,0BAAA,GAA6B,CACxC,QAAA,KACS;AACT,EAAA,IAAI,QAAA,KAAa,MAAA,IAAa,eAAA,CAAgB,GAAA,CAAI,QAAQ,CAAA,EAAG;AAC3D,IAAA,MAAM,IAAIA,mCAAAA,CAAmC;AAAA,MAC3C,OAAA,EACE,CAAA,wDAAA,EAA2D,QAAA,CAAS,IAAI,CAAA,iEAAA,CAAA;AAAA,MAE1E,UAAU,QAAA,CAAS;AAAA,KACpB,CAAA;AAAA,EACH;AACF","file":"chunk-VRXR2T3S.js","sourcesContent":["/**\n * Native sandbox providers: bind-mount sandbox providers that contain the\n * agent with the host OS's own process sandbox (Bubblewrap, Seatbelt) instead\n * of a container. They share the \"bind-mount\" tag, so core knows them by a\n * mark set when the provider is constructed.\n */\n\nimport { NativeInteractiveNotSupportedError as NativeInteractiveNotSupportedErrorImpl } from \"./errors.js\";\nimport type { SandboxProvider } from \"./SandboxProvider.js\";\n\nconst nativeProviders = new WeakSet<SandboxProvider>();\n\n/** Marks `provider` as a native sandbox provider, and returns it. */\nexport const markNativeSandboxProvider = <P extends SandboxProvider>(\n provider: P,\n): P => {\n nativeProviders.add(provider);\n return provider;\n};\n\n/**\n * `interactive()` was called with a native sandbox provider (`bwrap()`,\n * `seatbelt()`). Native providers don't run interactive sessions: use `run()`,\n * or pass `docker()` or `noSandbox()` to `interactive()`.\n *\n * Public-facing type for `NativeInteractiveNotSupportedError`. The runtime\n * class is the same `Data.TaggedError` from `errors.ts`, re-declared here as a\n * plain `Error` subclass so that Effect's types stay out of Sandcastle's\n * published `.d.ts` files.\n */\nexport interface NativeInteractiveNotSupportedError extends Error {\n readonly _tag: \"NativeInteractiveNotSupportedError\";\n readonly message: string;\n /** The native sandbox provider `interactive()` was called with. */\n readonly provider: string;\n}\n\ninterface NativeInteractiveNotSupportedErrorConstructor {\n new (args: {\n readonly message: string;\n readonly provider: string;\n }): NativeInteractiveNotSupportedError;\n readonly prototype: NativeInteractiveNotSupportedError;\n}\n\n/** `interactive()` was called with a native sandbox provider. */\nexport const NativeInteractiveNotSupportedError: NativeInteractiveNotSupportedErrorConstructor =\n NativeInteractiveNotSupportedErrorImpl;\n\n/** Throws `NativeInteractiveNotSupportedError` when `provider` is a native sandbox provider. */\nexport const assertInteractiveSupported = (\n provider: SandboxProvider | undefined,\n): void => {\n if (provider !== undefined && nativeProviders.has(provider)) {\n throw new NativeInteractiveNotSupportedError({\n message:\n `interactive() is not supported on native providers (got ${provider.name}()). ` +\n `Use run(), or pass docker() or noSandbox() to interactive().`,\n provider: provider.name,\n });\n }\n};\n"]}
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { B as BindMountSandboxHandle, S as SandboxProvider, a as BranchStrategy, A as AnySandboxProvider, E as ExecResult, M as MergeToHeadBranchStrategy, b as NamedBranchStrategy } from './SandboxProvider-EkSMuBp8.js';
2
- export { c as BindMountBranchStrategy, d as BindMountCreateOptions, e as BindMountSandboxProvider, f as BindMountSandboxProviderConfig, H as HeadBranchStrategy, g as InteractiveExecOptions, h as IsolatedBranchStrategy, i as IsolatedCreateOptions, j as IsolatedSandboxHandle, I as IsolatedSandboxProvider, k as IsolatedSandboxProviderConfig, l as NoSandboxBranchStrategy, m as NoSandboxHandle, N as NoSandboxProvider, n as createBindMountSandboxProvider, o as createIsolatedSandboxProvider } from './SandboxProvider-EkSMuBp8.js';
1
+ import { a as BindMountSandboxHandle, S as SandboxProvider, b as BranchStrategy, E as ExecResult, M as MergeToHeadBranchStrategy, c as NamedBranchStrategy } from './SandboxProvider-Chsi-Zs6.js';
2
+ export { A as AnySandboxProvider, d as BindMountBranchStrategy, e as BindMountCreateOptions, B as BindMountSandboxProvider, f as BindMountSandboxProviderConfig, H as HeadBranchStrategy, g as InteractiveExecOptions, h as IsolatedBranchStrategy, i as IsolatedCreateOptions, j as IsolatedSandboxHandle, I as IsolatedSandboxProvider, k as IsolatedSandboxProviderConfig, l as NoSandboxBranchStrategy, m as NoSandboxHandle, N as NoSandboxProvider, n as createBindMountSandboxProvider, o as createIsolatedSandboxProvider } from './SandboxProvider-Chsi-Zs6.js';
3
3
  import { StandardSchemaV1 } from '@standard-schema/spec';
4
4
  export { M as MountConfig } from './MountConfig-CmXclHA5.js';
5
5
 
@@ -26,8 +26,11 @@ interface HostSessionLookup {
26
26
  readonly searchedRoot: string;
27
27
  }
28
28
  /**
29
- * Encode a cwd into the Claude Code `~/.claude/projects/<encoded>/` layout.
30
- * Replaces path separators with hyphens, matching Claude Code's convention.
29
+ * Encode a cwd into the Claude Code `~/.claude/projects/<encoded>/` layout,
30
+ * matching Claude Code's own naming: every character that isn't an ASCII
31
+ * letter or digit becomes a hyphen (so `/`, `\`, `:` and `.` all do), and a
32
+ * name longer than 200 characters is cut to 200 and suffixed with a hash of
33
+ * the full path. A trailing path separator is ignored.
31
34
  */
32
35
  declare const encodeProjectPath: (cwd: string) => string;
33
36
  /** Absolute host path to a Claude session JSONL file. */
@@ -46,8 +49,8 @@ declare const findClaudeSessionOnHost: (id: string, projectsDir?: string) => Pro
46
49
  */
47
50
  declare const transferClaudeSession: (jsonl: string, fromCwd: string, toCwd: string) => string;
48
51
  /**
49
- * Locate a Codex session rollout file on the host by its id, reusing the
50
- * date-nested scan.
52
+ * Locate a Codex session rollout file on the host by its id, scanning the
53
+ * date-nested `YYYY/MM/DD/` directories depth-first.
51
54
  */
52
55
  declare const findCodexSessionOnHost: (id: string, sessionsDir?: string) => Promise<HostSessionLookup>;
53
56
  /**
@@ -57,9 +60,33 @@ declare const findCodexSessionOnHost: (id: string, sessionsDir?: string) => Prom
57
60
  */
58
61
  declare const transferCodexSession: (jsonl: string, fromCwd: string, toCwd: string) => string;
59
62
 
63
+ /**
64
+ * How full an iteration's context window was: the input side of its LAST
65
+ * model call, cache reads and cache writes included (see ADR 0023).
66
+ *
67
+ * Each model call's input already holds the whole conversation so far, so the
68
+ * last call is the context size. Never sum calls, and never use a total the
69
+ * agent reports for a turn or a session: those grow with every tool
70
+ * round-trip and can exceed the window.
71
+ */
72
+ interface ContextWindow {
73
+ /** Input tokens of the last model call, cached and uncached together. */
74
+ readonly tokens: number;
75
+ /** The model's context window size, only when the agent itself reports it. */
76
+ readonly limit?: number;
77
+ }
78
+
60
79
  type ParsedStreamEvent = {
61
80
  type: "text";
62
81
  text: string;
82
+ }
83
+ /**
84
+ * The input side of ONE model call (cache included), emitted once per call.
85
+ * The Orchestrator keeps the last one per iteration; see ContextWindow.
86
+ */
87
+ | {
88
+ type: "context_window";
89
+ contextWindow: ContextWindow;
63
90
  } | {
64
91
  type: "result";
65
92
  result: string;
@@ -73,6 +100,15 @@ type ParsedStreamEvent = {
73
100
  } | {
74
101
  type: "usage";
75
102
  usage: IterationUsage;
103
+ }
104
+ /**
105
+ * The agent reported a failure in its own stream (an API rejection, a
106
+ * failed turn). Some agents exit 0 after one, so the Orchestrator fails the
107
+ * run on it whatever the exit code.
108
+ */
109
+ | {
110
+ type: "error";
111
+ message: string;
76
112
  };
77
113
  /** Options passed to buildPrintCommand and buildInteractiveArgs. */
78
114
  interface AgentCommandOptions {
@@ -82,7 +118,7 @@ interface AgentCommandOptions {
82
118
  readonly resumeSession?: string;
83
119
  /**
84
120
  * When true alongside `resumeSession`, the agent should fork the session
85
- * instead of mutating it — Claude's `--fork-session`, Codex's
121
+ * instead of mutating it — Claude's `--fork-session`, pi's `--fork`, Codex's
86
122
  * `codex exec fork`. The parent session JSONL is left intact and the agent
87
123
  * writes a new session under a fresh id.
88
124
  */
@@ -131,6 +167,12 @@ interface AgentSessionStorage {
131
167
  * directory that was searched (for not-found errors).
132
168
  */
133
169
  findByIdOnHost(sessionId: string): Promise<HostSessionLookup>;
170
+ /**
171
+ * `false` when the agent's CLI can resume a session but has no native fork:
172
+ * `.fork()` then throws `ForkNotSupportedError` before any sandbox starts.
173
+ * Omitted means the agent forks.
174
+ */
175
+ readonly canFork?: boolean;
134
176
  }
135
177
  interface AgentProvider {
136
178
  readonly name: string;
@@ -145,10 +187,21 @@ interface AgentProvider {
145
187
  parseStreamLine(line: string): ParsedStreamEvent[];
146
188
  /** Parse token usage from the captured session JSONL content. Only implemented by Claude Code. */
147
189
  parseSessionUsage?(content: string): IterationUsage | undefined;
190
+ /**
191
+ * Parse the last model call's context window from the captured session
192
+ * JSONL. For agents whose stream has no per-call figure (codex). Overrides
193
+ * the stream's `context_window` events when it returns a value.
194
+ */
195
+ parseSessionContextWindow?(content: string): ContextWindow | undefined;
148
196
  }
149
197
  /** Options for the pi agent provider. */
150
198
  interface PiOptions {
151
- /** Reasoning effort level. Maps to the CLI's --thinking flag. */
199
+ /**
200
+ * Reasoning effort level. Maps to the CLI's --thinking flag. When omitted,
201
+ * no flag is passed and pi uses its own default (`medium`), which some
202
+ * models reject: with pi 0.73.1, `anthropic/claude-haiku-5-5` returns a 400.
203
+ * Pass `"off"` for those.
204
+ */
152
205
  readonly thinking?: "off" | "minimal" | "low" | "medium" | "high" | "xhigh";
153
206
  /** Environment variables injected by this agent provider. */
154
207
  readonly env?: Record<string, string>;
@@ -193,8 +246,17 @@ declare const codex: (model: string, options?: CodexOptions) => AgentProvider &
193
246
  interface CursorOptions {
194
247
  /** Environment variables injected by this agent provider. */
195
248
  readonly env?: Record<string, string>;
249
+ /** When false, session capture is disabled. Default: true. */
250
+ readonly captureSessions?: boolean;
251
+ /** Override Cursor `chats` directories for tests or non-standard installs. */
252
+ readonly sessionStorage?: {
253
+ readonly hostChatsDir?: string;
254
+ readonly sandboxChatsDir?: string;
255
+ };
196
256
  }
197
- declare const cursor: (model: string, options?: CursorOptions) => AgentProvider;
257
+ declare const cursor: (model: string, options?: CursorOptions) => AgentProvider & {
258
+ readonly sessionStorage: AgentSessionStorage;
259
+ };
198
260
  /** Options for the opencode agent provider. */
199
261
  interface OpenCodeOptions {
200
262
  /** Provider-specific reasoning effort variant (e.g. "high", "max", "low", "minimal"). */
@@ -207,16 +269,34 @@ interface OpenCodeOptions {
207
269
  readonly agent?: string;
208
270
  /** Environment variables injected by this agent provider. */
209
271
  readonly env?: Record<string, string>;
272
+ /** When false, session capture is disabled. Default: true. */
273
+ readonly captureSessions?: boolean;
274
+ /** Override where session exports live, for tests or non-standard installs. */
275
+ readonly sessionStorage?: {
276
+ readonly hostSessionsDir?: string;
277
+ readonly sandboxExportDir?: string;
278
+ };
210
279
  }
211
- declare const opencode: (model: string, options?: OpenCodeOptions) => AgentProvider;
280
+ declare const opencode: (model: string, options?: OpenCodeOptions) => AgentProvider & {
281
+ readonly sessionStorage: AgentSessionStorage;
282
+ };
212
283
  /** Options for the GitHub Copilot CLI agent provider. */
213
284
  interface CopilotOptions {
214
285
  /** Reasoning effort level. Maps to the CLI's --effort flag. */
215
286
  readonly effort?: "low" | "medium" | "high";
216
287
  /** Environment variables injected by this agent provider. */
217
288
  readonly env?: Record<string, string>;
289
+ /** When false, session capture is disabled. Default: true. */
290
+ readonly captureSessions?: boolean;
291
+ /** Override Copilot `session-state` directories for tests or non-standard installs. */
292
+ readonly sessionStorage?: {
293
+ readonly hostSessionsDir?: string;
294
+ readonly sandboxSessionsDir?: string;
295
+ };
218
296
  }
219
- declare const copilot: (model: string, options?: CopilotOptions) => AgentProvider;
297
+ declare const copilot: (model: string, options?: CopilotOptions) => AgentProvider & {
298
+ readonly sessionStorage: AgentSessionStorage;
299
+ };
220
300
  interface ClaudeCodeOptions {
221
301
  readonly effort?: "low" | "medium" | "high" | "xhigh" | "max";
222
302
  /** Environment variables injected by this agent provider. */
@@ -271,25 +351,25 @@ type AgentStreamEvent = {
271
351
  readonly timestamp: Date;
272
352
  };
273
353
 
274
- type SandboxHooks = {
354
+ interface SandboxHooks {
275
355
  readonly host?: {
276
- readonly onWorktreeReady?: ReadonlyArray<{
356
+ readonly onWorktreeReady?: readonly {
277
357
  readonly command: string;
278
358
  readonly timeoutMs?: number;
279
- }>;
280
- readonly onSandboxReady?: ReadonlyArray<{
359
+ }[];
360
+ readonly onSandboxReady?: readonly {
281
361
  readonly command: string;
282
362
  readonly timeoutMs?: number;
283
- }>;
363
+ }[];
284
364
  };
285
365
  readonly sandbox?: {
286
- readonly onSandboxReady?: ReadonlyArray<{
366
+ readonly onSandboxReady?: readonly {
287
367
  readonly command: string;
288
368
  readonly sudo?: boolean;
289
369
  readonly timeoutMs?: number;
290
- }>;
370
+ }[];
291
371
  };
292
- };
372
+ }
293
373
 
294
374
  /** Per-iteration result carrying an optional session ID. */
295
375
  interface IterationResult {
@@ -299,6 +379,8 @@ interface IterationResult {
299
379
  readonly sessionFilePath?: string;
300
380
  /** Token usage snapshot from the last assistant message in the session, or undefined when capture is disabled or provider does not support usage parsing. */
301
381
  readonly usage?: IterationUsage;
382
+ /** Input tokens of the iteration's last model call (cache included), plus the model's limit when the agent reports it. Undefined when the agent reports no per-call figure. */
383
+ readonly contextWindow?: ContextWindow;
302
384
  }
303
385
 
304
386
  /**
@@ -344,7 +426,7 @@ interface OutputStringDefinition {
344
426
  readonly maxRetries?: number;
345
427
  }
346
428
  /** Union of all output definition shapes accepted by `run()`. */
347
- type OutputDefinition = OutputObjectDefinition<any> | OutputStringDefinition;
429
+ type OutputDefinition = OutputObjectDefinition<unknown> | OutputStringDefinition;
348
430
  /**
349
431
  * Helpers for declaring structured output on `run()`.
350
432
  *
@@ -565,7 +647,8 @@ interface RunOptions<A extends AgentProvider = AgentProvider> {
565
647
  * - Phase boundaries (between iterations) also check the signal.
566
648
  * - The rejected promise surfaces `signal.reason` via
567
649
  * `signal.throwIfAborted()` — no Sandcastle-specific wrapping.
568
- * - The worktree is preserved on disk after abort (error-path behavior).
650
+ * - The worktree is preserved on disk after abort, even when it has no
651
+ * uncommitted changes, and its path is printed to stderr.
569
652
  */
570
653
  readonly signal?: AbortSignal;
571
654
  /** Override default timeouts for built-in lifecycle steps. Unset keys keep their defaults. */
@@ -606,7 +689,9 @@ interface RunResult {
606
689
  /** Host path to the preserved worktree, set when the run succeeded but the worktree had uncommitted changes. */
607
690
  readonly preservedWorktreePath?: string;
608
691
  /** Continue the last captured agent session for exactly one iteration.
609
- * Present only when the provider supports resume (`sessionStorage` populated). */
692
+ * Present only when the provider supports resume (`sessionStorage` populated).
693
+ * `output` and `promptArgs` are not inherited: pass `output` again to get
694
+ * structured output from the follow-up (its prompt must contain the tag). */
610
695
  readonly resume?: (prompt: string, options?: ResumeRunResultOptions) => Promise<RunResult>;
611
696
  /**
612
697
  * Fork the last captured agent session for exactly one iteration: the
@@ -619,6 +704,8 @@ interface RunResult {
619
704
  * sandbox. Safe concurrent fan-out (`Promise.all([r.fork(a), r.fork(b)])`)
620
705
  * requires the caller to give each fork a distinct `branch` — `head` and
621
706
  * `merge-to-head` are not safe for concurrent forks. See ADR 0018.
707
+ *
708
+ * Like `resume`, `output` and `promptArgs` are not inherited.
622
709
  */
623
710
  readonly fork?: (prompt: string, options?: ResumeRunResultOptions) => Promise<RunResult>;
624
711
  }
@@ -641,7 +728,7 @@ interface InteractiveOptions {
641
728
  /** Agent provider to use (e.g. claudeCode("claude-opus-4-8")) */
642
729
  readonly agent: AgentProvider;
643
730
  /** Sandbox provider (e.g. docker(), noSandbox()). */
644
- readonly sandbox?: AnySandboxProvider;
731
+ readonly sandbox?: SandboxProvider;
645
732
  /** Inline prompt string (mutually exclusive with promptFile). */
646
733
  readonly prompt?: string;
647
734
  /** Path to a prompt file (mutually exclusive with prompt). */
@@ -843,6 +930,31 @@ interface Sandbox {
843
930
  readonly branch: string;
844
931
  /** Host path to the worktree. */
845
932
  readonly worktreePath: string;
933
+ /**
934
+ * The provider's id for this sandbox, for a supervisor outside this process
935
+ * (a run registry, a kill step for stuck runs) to address it with the
936
+ * provider's own tools:
937
+ *
938
+ * - `docker()`: the container name: `docker inspect <sandboxId>`,
939
+ * `docker rm -f <sandboxId>`.
940
+ * - `podman()`: the container name: `podman inspect <sandboxId>`,
941
+ * `podman rm -f <sandboxId>`.
942
+ * - `vercel()`: the Vercel sandbox's id (its `name` from `@vercel/sandbox`
943
+ * 2 on, its `sandboxId` in 1.x): pass it to the SDK's `Sandbox.get()`,
944
+ * then call `stop()`.
945
+ * - `daytona()`: the Daytona sandbox id: `daytona.get(<sandboxId>)`, then
946
+ * `delete()`, from `@daytona/sdk`.
947
+ * - `modal()`: the Modal sandbox id: `modal.sandboxes.fromId(<sandboxId>)`,
948
+ * then `terminate()`, from `modal`.
949
+ * - `sprites()`: the Sprite's name: `client.getSprite(<sandboxId>)`, then
950
+ * `delete()`, from `@fly/sprites`.
951
+ * - A custom provider: whatever its handle's `sandboxId` is.
952
+ *
953
+ * `undefined` for `noSandbox()` and the native `bwrap()` and `seatbelt()`
954
+ * sandboxes: their sandbox is a child process of this one, with nothing
955
+ * outside it to address.
956
+ */
957
+ readonly sandboxId?: string;
846
958
  /** Invoke an agent inside the existing sandbox. */
847
959
  run(options: SandboxRunOptions): Promise<SandboxRunResult>;
848
960
  /** Launch an interactive agent session inside the existing sandbox. */
@@ -870,7 +982,7 @@ interface SandboxExecOptions {
870
982
  readonly onLine?: (line: string) => void;
871
983
  /** Working directory for the command. Defaults to the sandbox repo path. */
872
984
  readonly cwd?: string;
873
- /** Run the command with sudo, when the provider supports it. */
985
+ /** Run the whole command as root, when the provider supports it. */
874
986
  readonly sudo?: boolean;
875
987
  /** Stdin payload — piped to the child process and then closed. Avoids the Linux 128 KB per-arg limit. */
876
988
  readonly stdin?: string;
@@ -909,7 +1021,7 @@ interface WorktreeInteractiveOptions {
909
1021
  /** Agent provider to use (e.g. claudeCode("claude-opus-4-8")) */
910
1022
  readonly agent: AgentProvider;
911
1023
  /** Sandbox provider (e.g. docker(), noSandbox()). Defaults to noSandbox(). */
912
- readonly sandbox?: AnySandboxProvider;
1024
+ readonly sandbox?: SandboxProvider;
913
1025
  /** Inline prompt string (mutually exclusive with promptFile). */
914
1026
  readonly prompt?: string;
915
1027
  /** Path to a prompt file (mutually exclusive with prompt). */
@@ -1048,4 +1160,107 @@ interface CwdError extends Error {
1048
1160
  /** The provided `cwd` path does not exist or is not a directory. */
1049
1161
  declare const CwdError: CwdErrorConstructor;
1050
1162
 
1051
- export { type AgentCommandOptions, type AgentProvider, type AgentStreamEvent, AnySandboxProvider, BindMountSandboxHandle, BranchStrategy, type ClaudeCodeOptions, type CloseResult, type CodexOptions, type CopilotOptions, type CreateSandboxOptions, type CreateWorktreeOptions, type CursorOptions, CwdError, ExecResult, type HostSessionLookup, type InteractiveOptions, type InteractiveResult, type IterationResult, type IterationUsage, type LoggingOption, MergeToHeadBranchStrategy, NamedBranchStrategy, type OpenCodeOptions, Output, type OutputDefinition, type OutputObjectDefinition, type OutputStringDefinition, type PiOptions, type PrintCommand, type PromptArgs, type ResumeSandboxRunResultOptions, type RunOptions, type RunResult, type Sandbox, type SandboxExecOptions, type SandboxHooks, type SandboxInteractiveOptions, type SandboxInteractiveResult, SandboxProvider, type SandboxRunOptions, type SandboxRunResult, StructuredOutputError, type Timeouts, type Worktree, type WorktreeBranchStrategy, type WorktreeCreateSandboxOptions, type WorktreeInteractiveOptions, type WorktreeRunOptions, type WorktreeRunResult, claudeCode, claudeHostSessionPath, claudeSandboxSessionPath, codex, copilot, createSandbox, createWorktree, cursor, encodeProjectPath, findClaudeSessionOnHost, findCodexSessionOnHost, interactive, opencode, pi, run, transferClaudeSession, transferCodexSession };
1163
+ /**
1164
+ * Thrown by `.fork()` (and by any run given `forkSession`) when the **agent
1165
+ * provider** can resume a session but its CLI has no native fork. It is thrown
1166
+ * before any sandbox starts. Use `.resume()` instead, which continues the
1167
+ * session in place.
1168
+ *
1169
+ * Public-facing shape of the internal `ForkNotSupportedError` in `errors.ts`,
1170
+ * declared here so Effect's types stay out of the published `.d.ts` files.
1171
+ * Match it on `_tag` (or `name`), both `"ForkNotSupportedError"`.
1172
+ */
1173
+ interface ForkNotSupportedError extends Error {
1174
+ readonly _tag: "ForkNotSupportedError";
1175
+ readonly name: "ForkNotSupportedError";
1176
+ /** The agent provider's name, e.g. `"copilot"`. */
1177
+ readonly agentProvider: string;
1178
+ }
1179
+
1180
+ interface SyncOutPathErrorConstructor {
1181
+ new (args: {
1182
+ readonly message: string;
1183
+ readonly path: string;
1184
+ }): SyncOutPathError;
1185
+ readonly prototype: SyncOutPathError;
1186
+ }
1187
+ /**
1188
+ * Sync-out refused to write a file on the host because its path, as reported
1189
+ * by an isolated sandbox, would land outside the host worktree (or in its
1190
+ * `.git`): an absolute path, a `..` segment, or a symlink leading out.
1191
+ *
1192
+ * Public-facing type for `SyncOutPathError`. The runtime class is the same
1193
+ * `Data.TaggedError` from `errors.ts`, re-declared here as a plain `Error`
1194
+ * subclass so that Effect's types stay out of Sandcastle's published `.d.ts`
1195
+ * files.
1196
+ */
1197
+ interface SyncOutPathError extends Error {
1198
+ readonly _tag: "SyncOutPathError";
1199
+ readonly message: string;
1200
+ /** The offending path, as the sandbox reported it. */
1201
+ readonly path: string;
1202
+ }
1203
+ /** Sync-out refused a host path that would land outside the worktree. */
1204
+ declare const SyncOutPathError: SyncOutPathErrorConstructor;
1205
+
1206
+ /**
1207
+ * Native sandbox providers: bind-mount sandbox providers that contain the
1208
+ * agent with the host OS's own process sandbox (Bubblewrap, Seatbelt) instead
1209
+ * of a container. They share the "bind-mount" tag, so core knows them by a
1210
+ * mark set when the provider is constructed.
1211
+ */
1212
+
1213
+ interface NativeInteractiveNotSupportedErrorConstructor {
1214
+ new (args: {
1215
+ readonly message: string;
1216
+ readonly provider: string;
1217
+ }): NativeInteractiveNotSupportedError;
1218
+ readonly prototype: NativeInteractiveNotSupportedError;
1219
+ }
1220
+ /**
1221
+ * `interactive()` was called with a native sandbox provider (`bwrap()`,
1222
+ * `seatbelt()`). Native providers don't run interactive sessions: use `run()`,
1223
+ * or pass `docker()` or `noSandbox()` to `interactive()`.
1224
+ *
1225
+ * Public-facing type for `NativeInteractiveNotSupportedError`. The runtime
1226
+ * class is the same `Data.TaggedError` from `errors.ts`, re-declared here as a
1227
+ * plain `Error` subclass so that Effect's types stay out of Sandcastle's
1228
+ * published `.d.ts` files.
1229
+ */
1230
+ interface NativeInteractiveNotSupportedError extends Error {
1231
+ readonly _tag: "NativeInteractiveNotSupportedError";
1232
+ readonly message: string;
1233
+ /** The native sandbox provider `interactive()` was called with. */
1234
+ readonly provider: string;
1235
+ }
1236
+ /** `interactive()` was called with a native sandbox provider. */
1237
+ declare const NativeInteractiveNotSupportedError: NativeInteractiveNotSupportedErrorConstructor;
1238
+
1239
+ interface NativeSandboxUnavailableErrorConstructor {
1240
+ new (args: {
1241
+ readonly message: string;
1242
+ readonly fixCommand?: string;
1243
+ }): NativeSandboxUnavailableError;
1244
+ readonly prototype: NativeSandboxUnavailableError;
1245
+ }
1246
+ /**
1247
+ * A native sandbox provider (`bwrap()`, `seatbelt()`) can't run on this host:
1248
+ * the wrong OS, its tool isn't installed, or the kernel blocks it. Thrown when
1249
+ * the provider is constructed, before any worktree exists, so a run never
1250
+ * falls back to running unsandboxed.
1251
+ *
1252
+ * Public-facing type for `NativeSandboxUnavailableError`. The runtime class is
1253
+ * the same `Data.TaggedError` from `errors.ts`, re-declared here as a plain
1254
+ * `Error` subclass so that Effect's types stay out of Sandcastle's published
1255
+ * `.d.ts` files.
1256
+ */
1257
+ interface NativeSandboxUnavailableError extends Error {
1258
+ readonly _tag: "NativeSandboxUnavailableError";
1259
+ readonly message: string;
1260
+ /** A shell command that fixes the host, when there is one (e.g. an install command). */
1261
+ readonly fixCommand?: string;
1262
+ }
1263
+ /** A native sandbox provider can't run on this host. */
1264
+ declare const NativeSandboxUnavailableError: NativeSandboxUnavailableErrorConstructor;
1265
+
1266
+ export { type AgentCommandOptions, type AgentProvider, type AgentStreamEvent, BindMountSandboxHandle, BranchStrategy, type ClaudeCodeOptions, type CloseResult, type CodexOptions, type ContextWindow, type CopilotOptions, type CreateSandboxOptions, type CreateWorktreeOptions, type CursorOptions, CwdError, ExecResult, type ForkNotSupportedError, type HostSessionLookup, type InteractiveOptions, type InteractiveResult, type IterationResult, type IterationUsage, type LoggingOption, MergeToHeadBranchStrategy, NamedBranchStrategy, NativeInteractiveNotSupportedError, NativeSandboxUnavailableError, type OpenCodeOptions, Output, type OutputDefinition, type OutputObjectDefinition, type OutputStringDefinition, type PiOptions, type PrintCommand, type PromptArgs, type ResumeSandboxRunResultOptions, type RunOptions, type RunResult, type Sandbox, type SandboxExecOptions, type SandboxHooks, type SandboxInteractiveOptions, type SandboxInteractiveResult, SandboxProvider, type SandboxRunOptions, type SandboxRunResult, StructuredOutputError, SyncOutPathError, type Timeouts, type Worktree, type WorktreeBranchStrategy, type WorktreeCreateSandboxOptions, type WorktreeInteractiveOptions, type WorktreeRunOptions, type WorktreeRunResult, claudeCode, claudeHostSessionPath, claudeSandboxSessionPath, codex, copilot, createSandbox, createWorktree, cursor, encodeProjectPath, findClaudeSessionOnHost, findCodexSessionOnHost, interactive, opencode, pi, run, transferClaudeSession, transferCodexSession };