@ai-hero/sandcastle 0.10.0 → 0.13.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 (62) hide show
  1. package/README.md +15 -1316
  2. package/dist/LinuxCapability-B_PQfsY_.d.ts +32 -0
  3. package/dist/{SandboxProvider-EkSMuBp8.d.ts → SandboxProvider-YCL97qco.d.ts} +30 -3
  4. package/dist/chunk-4EIVTSOZ.js +93 -0
  5. package/dist/chunk-4EIVTSOZ.js.map +1 -0
  6. package/dist/{chunk-NGBM7T3E.js → chunk-6NQPCXSG.js} +5 -2
  7. package/dist/chunk-6NQPCXSG.js.map +1 -0
  8. package/dist/chunk-767EAJVT.js +112 -0
  9. package/dist/chunk-767EAJVT.js.map +1 -0
  10. package/dist/chunk-7N7AMUYA.js +353 -0
  11. package/dist/chunk-7N7AMUYA.js.map +1 -0
  12. package/dist/{chunk-52CIJF45.js → chunk-A4C2FG74.js} +258 -327
  13. package/dist/chunk-A4C2FG74.js.map +1 -0
  14. package/dist/chunk-J5J5YJ5S.js +50 -0
  15. package/dist/chunk-J5J5YJ5S.js.map +1 -0
  16. package/dist/{chunk-5VM5QZ26.js → chunk-LWNC4UTZ.js} +12097 -3252
  17. package/dist/chunk-LWNC4UTZ.js.map +1 -0
  18. package/dist/chunk-NMQ5Z6YG.js +148 -0
  19. package/dist/chunk-NMQ5Z6YG.js.map +1 -0
  20. package/dist/{chunk-NSFQW6ML.js → chunk-U42XXICG.js} +92 -85
  21. package/dist/chunk-U42XXICG.js.map +1 -0
  22. package/dist/chunk-XCWKLDH4.js +24 -0
  23. package/dist/chunk-XCWKLDH4.js.map +1 -0
  24. package/dist/{chunk-BIWNFKGV.js → chunk-XCYK7I45.js} +2 -2
  25. package/dist/chunk-XCYK7I45.js.map +1 -0
  26. package/dist/index.d.ts +335 -39
  27. package/dist/index.js +2854 -2090
  28. package/dist/index.js.map +1 -1
  29. package/dist/main.js +1006 -627
  30. package/dist/main.js.map +1 -1
  31. package/dist/sandboxes/bwrap.d.ts +58 -0
  32. package/dist/sandboxes/bwrap.js +293 -0
  33. package/dist/sandboxes/bwrap.js.map +1 -0
  34. package/dist/sandboxes/daytona.d.ts +1 -1
  35. package/dist/sandboxes/daytona.js +78 -17
  36. package/dist/sandboxes/daytona.js.map +1 -1
  37. package/dist/sandboxes/docker.d.ts +19 -5
  38. package/dist/sandboxes/docker.js +4 -4
  39. package/dist/sandboxes/no-sandbox.d.ts +2 -2
  40. package/dist/sandboxes/no-sandbox.js +2 -2
  41. package/dist/sandboxes/podman.d.ts +19 -5
  42. package/dist/sandboxes/podman.js +69 -56
  43. package/dist/sandboxes/podman.js.map +1 -1
  44. package/dist/sandboxes/seatbelt.d.ts +65 -0
  45. package/dist/sandboxes/seatbelt.js +422 -0
  46. package/dist/sandboxes/seatbelt.js.map +1 -0
  47. package/dist/sandboxes/vercel.d.ts +13 -6
  48. package/dist/sandboxes/vercel.js +195 -126
  49. package/dist/sandboxes/vercel.js.map +1 -1
  50. package/dist/templates/blank/main.mts +1 -1
  51. package/dist/templates/parallel-planner/main.mts +14 -23
  52. package/dist/templates/parallel-planner-with-review/main.mts +14 -16
  53. package/dist/templates/simple-loop/main.mts +1 -1
  54. package/package.json +34 -10
  55. package/dist/chunk-52CIJF45.js.map +0 -1
  56. package/dist/chunk-5VM5QZ26.js.map +0 -1
  57. package/dist/chunk-72UVAC7B.js +0 -99
  58. package/dist/chunk-72UVAC7B.js.map +0 -1
  59. package/dist/chunk-BIWNFKGV.js.map +0 -1
  60. package/dist/chunk-NGBM7T3E.js.map +0 -1
  61. package/dist/chunk-NSFQW6ML.js.map +0 -1
  62. package/dist/mountUtils-CCA-bbpK.d.ts +0 -25
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/SandboxProvider.ts"],"names":[],"mappings":";;;;;AA+UO,IAAM,8BAAA,GAAiC,CAC5C,MAAA,MAC8B;AAAA,EAC9B,GAAA,EAAK,YAAA;AAAA,EACL,MAAM,MAAA,CAAO,IAAA;AAAA,EACb,GAAA,EAAK,MAAA,CAAO,GAAA,IAAO,EAAC;AAAA,EACpB,gBAAgB,MAAA,CAAO,cAAA;AAAA,EACvB,QAAQ,MAAA,CAAO;AACjB,CAAA;AAMO,IAAM,6BAAA,GAAgC,CAC3C,MAAA,MAC6B;AAAA,EAC7B,GAAA,EAAK,UAAA;AAAA,EACL,MAAM,MAAA,CAAO,IAAA;AAAA,EACb,GAAA,EAAK,MAAA,CAAO,GAAA,IAAO,EAAC;AAAA,EACpB,QAAQ,MAAA,CAAO;AACjB,CAAA","file":"chunk-XCYK7I45.js","sourcesContent":["/**\n * Sandbox provider types — the pluggable interface for sandbox runtimes.\n *\n * Provider authors implement a small Promise-based interface. Sandcastle\n * handles worktree creation, git mount resolution, and commit extraction.\n */\n\n/** Result of executing a command inside a sandbox. */\nexport interface ExecResult {\n readonly stdout: string;\n readonly stderr: string;\n readonly exitCode: number;\n}\n\n/** Options for interactiveExec — the streams the provider should wire to the spawned process. */\nexport interface InteractiveExecOptions {\n readonly stdin: NodeJS.ReadableStream;\n readonly stdout: NodeJS.WritableStream;\n readonly stderr: NodeJS.WritableStream;\n readonly cwd?: string;\n}\n\n/** Handle to a running bind-mount sandbox. */\nexport interface BindMountSandboxHandle {\n /** Absolute path to the worktree inside the sandbox. */\n readonly worktreePath: string;\n /**\n * The id a supervisor outside this process can use to address the sandbox\n * with the runtime's own tools, e.g. `docker()` and `podman()` set it to the\n * container name (`docker rm -f <sandboxId>`). Surfaced as\n * `Sandbox.sandboxId`. Omit it when there is nothing outside the process to\n * address, as for the native `bwrap()` and `seatbelt()` sandboxes, whose\n * sandbox is a child process of this one.\n */\n readonly sandboxId?: string;\n /**\n * Absolute path to the agent's home directory, as commands running inside\n * the sandbox see it. Sandcastle runs commands there to find and place agent\n * session files. Omit when it is `/home/agent`, as in the Docker image.\n */\n readonly sandboxHomedir?: string;\n /**\n * Absolute path to a writable temp directory, as commands running inside\n * the sandbox see it. Omit when it is `/tmp`.\n */\n readonly sandboxTmpdir?: string;\n /**\n * Execute a command in the sandbox.\n *\n * Implementations MUST support line-by-line streaming via `onLine`. This is\n * how Sandcastle delivers live feedback to the user and enforces idle timeouts —\n * without a streaming implementation, neither will work. A buffered/batch\n * implementation that only calls `onLine` after the process exits does NOT\n * satisfy this contract.\n *\n * When `stdin` is set, the implementation pipes the string to the child\n * process's stdin and closes it. This avoids the Linux 128 KB per-arg limit.\n */\n exec(\n command: string,\n options?: {\n onLine?: (line: string) => void;\n cwd?: string;\n sudo?: boolean;\n stdin?: string;\n },\n ): Promise<ExecResult>;\n /**\n * Launch an interactive process inside the sandbox.\n * Optional — providers that support interactive sessions implement this.\n * The provider detects TTY mode from the streams (e.g. stdin.isTTY) and\n * allocates a pseudo-terminal accordingly.\n */\n interactiveExec?(\n args: string[],\n options: InteractiveExecOptions,\n ): Promise<{ exitCode: number }>;\n /** Copy a single file from the host into the sandbox. */\n copyFileIn(hostPath: string, sandboxPath: string): Promise<void>;\n /** Copy a single file from the sandbox to the host. */\n copyFileOut(sandboxPath: string, hostPath: string): Promise<void>;\n /** Tear down the sandbox. */\n close(): Promise<void>;\n}\n\n/** Options passed to a bind-mount provider's `create` function. */\nexport interface BindMountCreateOptions {\n /** Host-side path to the worktree directory. */\n readonly worktreePath: string;\n /** Host-side path to the original repo root. */\n readonly hostRepoPath: string;\n /** Volume mounts to apply (host:sandbox pairs). */\n readonly mounts: {\n hostPath: string;\n sandboxPath: string;\n readonly?: boolean;\n }[];\n /** Environment variables to inject into the sandbox. */\n readonly env: Record<string, string>;\n}\n\n/** Configuration for createBindMountSandboxProvider. */\nexport interface BindMountSandboxProviderConfig {\n /** Human-readable name for this provider (e.g. \"docker\", \"podman\"). */\n readonly name: string;\n /** Environment variables injected by this provider. Merged at launch time. */\n readonly env?: Record<string, string>;\n /**\n * Absolute path to the home directory inside the sandbox (e.g. `\"/home/agent\"`).\n * Used to expand `~` in user-provided `sandboxPath` mount configs.\n * Set to `undefined` for providers that do not have a fixed home directory.\n */\n readonly sandboxHomedir?: string;\n /** Create a sandbox handle from the given options. */\n readonly create: (\n options: BindMountCreateOptions,\n ) => Promise<BindMountSandboxHandle>;\n}\n\n/** Handle to a running isolated sandbox (extends bind-mount with file transfer). */\nexport interface IsolatedSandboxHandle {\n /** Absolute path to the worktree inside the sandbox. */\n readonly worktreePath: string;\n /**\n * The vendor's id for the sandbox, so a supervisor outside this process can\n * address it with the vendor's own CLI or API, e.g. `vercel()` and\n * `daytona()` set it to the Vercel and Daytona sandbox ids. Surfaced as\n * `Sandbox.sandboxId`. Omit it when the provider has no such id.\n */\n readonly sandboxId?: string;\n /**\n * Execute a command in the sandbox.\n *\n * Implementations MUST support line-by-line streaming via `onLine`. This is\n * how Sandcastle delivers live feedback to the user and enforces idle timeouts —\n * without a streaming implementation, neither will work. A buffered/batch\n * implementation that only calls `onLine` after the process exits does NOT\n * satisfy this contract.\n *\n * When `stdin` is set, the implementation pipes the string to the child\n * process's stdin and closes it. This avoids the Linux 128 KB per-arg limit.\n */\n exec(\n command: string,\n options?: {\n onLine?: (line: string) => void;\n cwd?: string;\n sudo?: boolean;\n stdin?: string;\n },\n ): Promise<ExecResult>;\n /**\n * Launch an interactive process inside the sandbox.\n * Optional — providers that support interactive sessions implement this.\n * The provider detects TTY mode from the streams (e.g. stdin.isTTY) and\n * allocates a pseudo-terminal accordingly.\n */\n interactiveExec?(\n args: string[],\n options: InteractiveExecOptions,\n ): Promise<{ exitCode: number }>;\n /** Copy a file or directory from the host into the sandbox. */\n copyIn(hostPath: string, sandboxPath: string): Promise<void>;\n /** Copy a single file from the sandbox to the host. */\n copyFileOut(sandboxPath: string, hostPath: string): Promise<void>;\n /** Tear down the sandbox. */\n close(): Promise<void>;\n}\n\n/** Options passed to an isolated provider's `create` function. */\nexport interface IsolatedCreateOptions {\n /** Environment variables to inject into the sandbox. */\n readonly env: Record<string, string>;\n}\n\n/** Configuration for createIsolatedSandboxProvider. */\nexport interface IsolatedSandboxProviderConfig {\n /** Human-readable name for this provider (e.g. \"daytona\", \"e2b\"). */\n readonly name: string;\n /** Environment variables injected by this provider. Merged at launch time. */\n readonly env?: Record<string, string>;\n /** Create an isolated sandbox handle from the given options. */\n readonly create: (\n options: IsolatedCreateOptions,\n ) => Promise<IsolatedSandboxHandle>;\n}\n\n/** A bind-mount sandbox provider. */\nexport interface BindMountSandboxProvider {\n /** @internal Discriminator for internal dispatch. */\n readonly tag: \"bind-mount\";\n /** Human-readable provider name. */\n readonly name: string;\n /** Environment variables injected by this provider. */\n readonly env: Record<string, string>;\n /**\n * Absolute path to the home directory inside the sandbox (e.g. `\"/home/agent\"`).\n * `undefined` when the provider does not declare a sandbox home directory.\n */\n readonly sandboxHomedir: string | undefined;\n /** @internal Create a sandbox handle. */\n readonly create: (\n options: BindMountCreateOptions,\n ) => Promise<BindMountSandboxHandle>;\n}\n\n/** An isolated sandbox provider. */\nexport interface IsolatedSandboxProvider {\n /** @internal Discriminator for internal dispatch. */\n readonly tag: \"isolated\";\n /** Human-readable provider name. */\n readonly name: string;\n /** Environment variables injected by this provider. */\n readonly env: Record<string, string>;\n /** @internal Create an isolated sandbox handle. */\n readonly create: (\n options: IsolatedCreateOptions,\n ) => Promise<IsolatedSandboxHandle>;\n}\n\n/** Handle to a no-sandbox session — runs commands directly on the host. */\nexport interface NoSandboxHandle {\n /** Absolute path to the worktree on the host. */\n readonly worktreePath: string;\n /**\n * Execute a command on the host.\n *\n * Implementations MUST support line-by-line streaming via `onLine`. This is\n * how Sandcastle delivers live feedback to the user and enforces idle timeouts —\n * without a streaming implementation, neither will work.\n *\n * When `stdin` is set, the implementation pipes the string to the child\n * process's stdin and closes it. This avoids the Linux 128 KB per-arg limit.\n */\n exec(\n command: string,\n options?: {\n onLine?: (line: string) => void;\n cwd?: string;\n sudo?: boolean;\n stdin?: string;\n },\n ): Promise<ExecResult>;\n /**\n * Launch an interactive process on the host with inherited stdio.\n */\n interactiveExec(\n args: string[],\n options: InteractiveExecOptions,\n ): Promise<{ exitCode: number }>;\n /** No-op — no container to tear down. */\n close(): Promise<void>;\n}\n\n/** A no-sandbox provider — runs the agent directly on the host with no container isolation. */\nexport interface NoSandboxProvider {\n /** @internal Discriminator for internal dispatch. */\n readonly tag: \"none\";\n /** Human-readable provider name. */\n readonly name: string;\n /** Environment variables injected by this provider. */\n readonly env: Record<string, string>;\n /** @internal Create a no-sandbox handle. */\n readonly create: (options: {\n readonly worktreePath: string;\n readonly env: Record<string, string>;\n }) => Promise<NoSandboxHandle>;\n}\n\n// ---------- Branch strategy types ----------\n\n/** Head strategy: agent writes directly to host working directory. Bind-mount only. */\nexport interface HeadBranchStrategy {\n readonly type: \"head\";\n}\n\n/** Merge-to-head strategy: temp branch, merge back to HEAD, delete temp branch. */\nexport interface MergeToHeadBranchStrategy {\n readonly type: \"merge-to-head\";\n}\n\n/** Branch strategy: commits land on an explicit named branch. */\nexport interface NamedBranchStrategy {\n readonly type: \"branch\";\n readonly branch: string;\n /**\n * Git ref to use as the starting point when creating a new branch.\n * Only used when the branch doesn't already exist — ignored otherwise.\n * Callers are responsible for ensuring the ref is current (e.g. `git fetch`).\n * Defaults to `HEAD` when omitted.\n */\n readonly baseBranch?: string;\n}\n\n/** Branch strategy for bind-mount providers (all three variants). */\nexport type BindMountBranchStrategy =\n | HeadBranchStrategy\n | MergeToHeadBranchStrategy\n | NamedBranchStrategy;\n\n/** Branch strategy for isolated providers (no head — can't write to host). */\nexport type IsolatedBranchStrategy =\n | MergeToHeadBranchStrategy\n | NamedBranchStrategy;\n\n/** Branch strategy for no-sandbox providers (all three — same as bind-mount). */\nexport type NoSandboxBranchStrategy =\n | HeadBranchStrategy\n | MergeToHeadBranchStrategy\n | NamedBranchStrategy;\n\n/** Union of all branch strategy variants. */\nexport type BranchStrategy =\n | BindMountBranchStrategy\n | IsolatedBranchStrategy\n | NoSandboxBranchStrategy;\n\n/**\n * A sandbox provider — the pluggable unit that `run()`, `interactive()`, and\n * `createSandbox()` accept. Tagged for internal dispatch: \"bind-mount\",\n * \"isolated\", or \"none\". When `NoSandboxProvider` is used, the agent runs\n * directly on the host with no container isolation — opt in at your own risk.\n */\nexport type SandboxProvider =\n | BindMountSandboxProvider\n | IsolatedSandboxProvider\n | NoSandboxProvider;\n\n/** @deprecated Use `SandboxProvider` — it now includes `NoSandboxProvider`. */\nexport type AnySandboxProvider = SandboxProvider;\n\n/**\n * Create a bind-mount sandbox provider from a config object.\n * The returned provider can be passed to `run()` or `createSandbox()`.\n */\nexport const createBindMountSandboxProvider = (\n config: BindMountSandboxProviderConfig,\n): BindMountSandboxProvider => ({\n tag: \"bind-mount\",\n name: config.name,\n env: config.env ?? {},\n sandboxHomedir: config.sandboxHomedir,\n create: config.create,\n});\n\n/**\n * Create an isolated sandbox provider from a config object.\n * The returned provider can be passed to `run()` or `createSandbox()`.\n */\nexport const createIsolatedSandboxProvider = (\n config: IsolatedSandboxProviderConfig,\n): IsolatedSandboxProvider => ({\n tag: \"isolated\",\n name: config.name,\n env: config.env ?? {},\n create: config.create,\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, M as MergeToHeadBranchStrategy, b as NamedBranchStrategy } from './SandboxProvider-EkSMuBp8.js';
2
- export { c as BindMountBranchStrategy, d as BindMountCreateOptions, e as BindMountSandboxProvider, f as BindMountSandboxProviderConfig, E as ExecResult, 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-YCL97qco.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-YCL97qco.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
  /**
@@ -313,14 +395,38 @@ interface OutputObjectDefinition<T> {
313
395
  readonly _tag: "object";
314
396
  readonly tag: string;
315
397
  readonly schema: StandardSchemaV1<unknown, T>;
398
+ /**
399
+ * Maximum number of additional attempts after the first if structured output
400
+ * extraction or validation fails. Each retry resumes the failed run's agent
401
+ * session and feeds back a token-efficient description of the error so the
402
+ * agent can re-emit a corrected tag. Default: `0` (no retries).
403
+ *
404
+ * Retries require the agent provider to support session resumption (i.e.
405
+ * `provider.sessionStorage` is populated — Claude Code, Codex, Pi). `run()`
406
+ * fails at entry with a clear error when retries are requested but the
407
+ * provider cannot resume.
408
+ */
409
+ readonly maxRetries?: number;
316
410
  }
317
411
  /** Branded output definition for `Output.string({ tag })`. */
318
412
  interface OutputStringDefinition {
319
413
  readonly _tag: "string";
320
414
  readonly tag: string;
415
+ /**
416
+ * Maximum number of additional attempts after the first if structured output
417
+ * extraction fails. Each retry resumes the failed run's agent session and
418
+ * feeds back a token-efficient description of the error so the agent can
419
+ * re-emit a corrected tag. Default: `0` (no retries).
420
+ *
421
+ * Retries require the agent provider to support session resumption (i.e.
422
+ * `provider.sessionStorage` is populated — Claude Code, Codex, Pi). `run()`
423
+ * fails at entry with a clear error when retries are requested but the
424
+ * provider cannot resume.
425
+ */
426
+ readonly maxRetries?: number;
321
427
  }
322
428
  /** Union of all output definition shapes accepted by `run()`. */
323
- type OutputDefinition = OutputObjectDefinition<any> | OutputStringDefinition;
429
+ type OutputDefinition = OutputObjectDefinition<unknown> | OutputStringDefinition;
324
430
  /**
325
431
  * Helpers for declaring structured output on `run()`.
326
432
  *
@@ -340,18 +446,28 @@ declare const Output: {
340
446
  * Declare an object-typed structured output extracted from an XML tag in
341
447
  * the agent's stdout. The tag contents are JSON-parsed (with fence-aware
342
448
  * unwrapping) and validated against the provided Standard Schema validator.
449
+ *
450
+ * Set `maxRetries` to have `run()` automatically resume the failed session
451
+ * and ask the agent to re-emit corrected output when extraction or
452
+ * validation fails. Default: `0` (no retries).
343
453
  */
344
454
  readonly object: <Schema extends StandardSchemaV1>(opts: {
345
455
  tag: string;
346
456
  schema: Schema;
457
+ maxRetries?: number;
347
458
  }) => OutputObjectDefinition<StandardSchemaV1.InferOutput<Schema>>;
348
459
  /**
349
460
  * Declare a string-typed structured output extracted from an XML tag in
350
461
  * the agent's stdout. The tag contents are whitespace-trimmed and returned
351
462
  * as a plain string — no JSON parsing, no schema validation.
463
+ *
464
+ * Set `maxRetries` to have `run()` automatically resume the failed session
465
+ * and ask the agent to re-emit corrected output when extraction fails.
466
+ * Default: `0` (no retries).
352
467
  */
353
468
  readonly string: (opts: {
354
469
  tag: string;
470
+ maxRetries?: number;
355
471
  }) => OutputStringDefinition;
356
472
  };
357
473
  interface StructuredOutputErrorOptions {
@@ -466,7 +582,7 @@ interface Timeouts {
466
582
  readonly mergeToHostMs?: number;
467
583
  }
468
584
  interface RunOptions<A extends AgentProvider = AgentProvider> {
469
- /** Agent provider to use (e.g. claudeCode("claude-opus-4-7")) */
585
+ /** Agent provider to use (e.g. claudeCode("claude-opus-4-8")) */
470
586
  readonly agent: A;
471
587
  /** Sandbox provider (e.g. docker({ imageName: "sandcastle:myrepo" })). */
472
588
  readonly sandbox: SandboxProvider;
@@ -531,7 +647,8 @@ interface RunOptions<A extends AgentProvider = AgentProvider> {
531
647
  * - Phase boundaries (between iterations) also check the signal.
532
648
  * - The rejected promise surfaces `signal.reason` via
533
649
  * `signal.throwIfAborted()` — no Sandcastle-specific wrapping.
534
- * - 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.
535
652
  */
536
653
  readonly signal?: AbortSignal;
537
654
  /** Override default timeouts for built-in lifecycle steps. Unset keys keep their defaults. */
@@ -572,7 +689,9 @@ interface RunResult {
572
689
  /** Host path to the preserved worktree, set when the run succeeded but the worktree had uncommitted changes. */
573
690
  readonly preservedWorktreePath?: string;
574
691
  /** Continue the last captured agent session for exactly one iteration.
575
- * 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). */
576
695
  readonly resume?: (prompt: string, options?: ResumeRunResultOptions) => Promise<RunResult>;
577
696
  /**
578
697
  * Fork the last captured agent session for exactly one iteration: the
@@ -585,6 +704,8 @@ interface RunResult {
585
704
  * sandbox. Safe concurrent fan-out (`Promise.all([r.fork(a), r.fork(b)])`)
586
705
  * requires the caller to give each fork a distinct `branch` — `head` and
587
706
  * `merge-to-head` are not safe for concurrent forks. See ADR 0018.
707
+ *
708
+ * Like `resume`, `output` and `promptArgs` are not inherited.
588
709
  */
589
710
  readonly fork?: (prompt: string, options?: ResumeRunResultOptions) => Promise<RunResult>;
590
711
  }
@@ -604,10 +725,10 @@ declare function run<A extends AgentProvider>(options: RunOptions<A> & {
604
725
  declare function run<A extends AgentProvider>(options: RunOptions<A>): Promise<RunResult>;
605
726
 
606
727
  interface InteractiveOptions {
607
- /** Agent provider to use (e.g. claudeCode("claude-opus-4-7")) */
728
+ /** Agent provider to use (e.g. claudeCode("claude-opus-4-8")) */
608
729
  readonly agent: AgentProvider;
609
730
  /** Sandbox provider (e.g. docker(), noSandbox()). */
610
- readonly sandbox?: AnySandboxProvider;
731
+ readonly sandbox?: SandboxProvider;
611
732
  /** Inline prompt string (mutually exclusive with promptFile). */
612
733
  readonly prompt?: string;
613
734
  /** Path to a prompt file (mutually exclusive with prompt). */
@@ -698,17 +819,19 @@ interface CreateSandboxOptions {
698
819
  /** Override default timeouts for built-in lifecycle steps. Unset keys keep their defaults. */
699
820
  readonly timeouts?: Timeouts;
700
821
  }
701
- interface SandboxRunOptions {
702
- /** Agent provider to use (e.g. claudeCode("claude-opus-4-7")). */
703
- readonly agent: AgentProvider;
704
- /** Inline prompt string (mutually exclusive with promptFile). */
705
- readonly prompt?: string;
706
- /** Path to a prompt file (mutually exclusive with prompt). */
707
- readonly promptFile?: string;
822
+ /**
823
+ * Options accepted by `SandboxRunResult.resume()` / `.fork()`. Mirrors
824
+ * `ResumeRunResultOptions` in `run.ts` — drops the fields owned by the
825
+ * captured run (prompt, iteration count, resumeSession/forkSession bookkeeping).
826
+ *
827
+ * Defined as the base interface that `SandboxRunOptions` extends — the
828
+ * interface-extends shape is cheaper for the TS checker than
829
+ * `Omit<SandboxRunOptions, ...>` (which forces a mapped-type computation
830
+ * on every reference).
831
+ */
832
+ interface ResumeSandboxRunResultOptions {
708
833
  /** Key-value map for {{KEY}} placeholder substitution in prompts. */
709
834
  readonly promptArgs?: PromptArgs;
710
- /** Maximum iterations to run (default: 1). */
711
- readonly maxIterations?: number;
712
835
  /** Substring(s) the agent emits to stop the iteration loop early. */
713
836
  readonly completionSignal?: string | string[];
714
837
  /** Idle timeout in seconds. Default: 600. */
@@ -730,6 +853,18 @@ interface SandboxRunOptions {
730
853
  */
731
854
  readonly signal?: AbortSignal;
732
855
  }
856
+ interface SandboxRunOptions extends ResumeSandboxRunResultOptions {
857
+ /** Agent provider to use (e.g. claudeCode("claude-opus-4-8")). */
858
+ readonly agent: AgentProvider;
859
+ /** Inline prompt string (mutually exclusive with promptFile). */
860
+ readonly prompt?: string;
861
+ /** Path to a prompt file (mutually exclusive with prompt). */
862
+ readonly promptFile?: string;
863
+ /** Maximum iterations to run (default: 1). */
864
+ readonly maxIterations?: number;
865
+ /** Resume a prior agent session by id. The session JSONL must exist on the host (captured by a prior `sandbox.run()`). Incompatible with `maxIterations > 1`. */
866
+ readonly resumeSession?: string;
867
+ }
733
868
  interface SandboxRunResult {
734
869
  /** Per-iteration results (use `iterations.length` for the count). */
735
870
  readonly iterations: IterationResult[];
@@ -743,9 +878,23 @@ interface SandboxRunResult {
743
878
  }[];
744
879
  /** Path to the log file, if logging was drained to a file. */
745
880
  readonly logFilePath?: string;
881
+ /**
882
+ * Continue the last captured agent session for exactly one iteration inside
883
+ * the same long-lived sandbox. Present only when the provider supports
884
+ * resume (`sessionStorage` populated) and a session id was captured.
885
+ */
886
+ readonly resume?: (prompt: string, options?: ResumeSandboxRunResultOptions) => Promise<SandboxRunResult>;
887
+ /**
888
+ * Fork the last captured agent session for exactly one iteration inside the
889
+ * same long-lived sandbox: the parent session JSONL is left intact and the
890
+ * child run gets its own session id. Present only when the provider
891
+ * supports resume (`sessionStorage` populated) and a session id was
892
+ * captured. See ADR 0018 for fork semantics.
893
+ */
894
+ readonly fork?: (prompt: string, options?: ResumeSandboxRunResultOptions) => Promise<SandboxRunResult>;
746
895
  }
747
896
  interface SandboxInteractiveOptions {
748
- /** Agent provider to use (e.g. claudeCode("claude-opus-4-7")). */
897
+ /** Agent provider to use (e.g. claudeCode("claude-opus-4-8")). */
749
898
  readonly agent: AgentProvider;
750
899
  /** Inline prompt string (mutually exclusive with promptFile). */
751
900
  readonly prompt?: string;
@@ -781,15 +930,59 @@ interface Sandbox {
781
930
  readonly branch: string;
782
931
  /** Host path to the worktree. */
783
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
+ * - A custom provider: whatever its handle's `sandboxId` is.
948
+ *
949
+ * `undefined` for `noSandbox()` and the native `bwrap()` and `seatbelt()`
950
+ * sandboxes: their sandbox is a child process of this one, with nothing
951
+ * outside it to address.
952
+ */
953
+ readonly sandboxId?: string;
784
954
  /** Invoke an agent inside the existing sandbox. */
785
955
  run(options: SandboxRunOptions): Promise<SandboxRunResult>;
786
956
  /** Launch an interactive agent session inside the existing sandbox. */
787
957
  interactive(options: SandboxInteractiveOptions): Promise<SandboxInteractiveResult>;
958
+ /**
959
+ * Execute a command inside the existing sandbox.
960
+ *
961
+ * `cwd` defaults to the sandbox repo path (same default `interactive()`
962
+ * uses), so callers get the same working directory across providers. Pass
963
+ * `cwd` to override.
964
+ *
965
+ * Returns the full `ExecResult` — non-zero `exitCode` is surfaced, not
966
+ * thrown. Callers that want strict semantics should check `result.exitCode`
967
+ * themselves (matching the contract of `BindMountSandboxHandle.exec`).
968
+ */
969
+ exec(command: string, options?: SandboxExecOptions): Promise<ExecResult>;
788
970
  /** Tear down the sandbox and worktree. */
789
971
  close(): Promise<CloseResult>;
790
972
  /** Auto teardown via `await using`. */
791
973
  [Symbol.asyncDispose](): Promise<void>;
792
974
  }
975
+ /** Options accepted by `Sandbox.exec()`. Mirrors the provider handle's `exec` options. */
976
+ interface SandboxExecOptions {
977
+ /** Per-line stdout callback for streaming output. */
978
+ readonly onLine?: (line: string) => void;
979
+ /** Working directory for the command. Defaults to the sandbox repo path. */
980
+ readonly cwd?: string;
981
+ /** Run the whole command as root, when the provider supports it. */
982
+ readonly sudo?: boolean;
983
+ /** Stdin payload — piped to the child process and then closed. Avoids the Linux 128 KB per-arg limit. */
984
+ readonly stdin?: string;
985
+ }
793
986
  /**
794
987
  * Eagerly creates a git worktree on the provided explicit branch and starts
795
988
  * a sandbox with the worktree bind-mounted. Returns a Sandbox handle that
@@ -821,10 +1014,10 @@ interface CreateWorktreeOptions {
821
1014
  readonly timeouts?: Timeouts;
822
1015
  }
823
1016
  interface WorktreeInteractiveOptions {
824
- /** Agent provider to use (e.g. claudeCode("claude-opus-4-7")) */
1017
+ /** Agent provider to use (e.g. claudeCode("claude-opus-4-8")) */
825
1018
  readonly agent: AgentProvider;
826
1019
  /** Sandbox provider (e.g. docker(), noSandbox()). Defaults to noSandbox(). */
827
- readonly sandbox?: AnySandboxProvider;
1020
+ readonly sandbox?: SandboxProvider;
828
1021
  /** Inline prompt string (mutually exclusive with promptFile). */
829
1022
  readonly prompt?: string;
830
1023
  /** Path to a prompt file (mutually exclusive with prompt). */
@@ -850,7 +1043,7 @@ interface WorktreeInteractiveOptions {
850
1043
  readonly signal?: AbortSignal;
851
1044
  }
852
1045
  interface WorktreeRunOptions {
853
- /** Agent provider to use (e.g. claudeCode("claude-opus-4-7")) */
1046
+ /** Agent provider to use (e.g. claudeCode("claude-opus-4-8")) */
854
1047
  readonly agent: AgentProvider;
855
1048
  /** Sandbox provider (e.g. docker()). Required — AFK agents should always be sandboxed. */
856
1049
  readonly sandbox: SandboxProvider;
@@ -963,4 +1156,107 @@ interface CwdError extends Error {
963
1156
  /** The provided `cwd` path does not exist or is not a directory. */
964
1157
  declare const CwdError: CwdErrorConstructor;
965
1158
 
966
- 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, 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 RunOptions, type RunResult, type Sandbox, 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 };
1159
+ /**
1160
+ * Thrown by `.fork()` (and by any run given `forkSession`) when the **agent
1161
+ * provider** can resume a session but its CLI has no native fork. It is thrown
1162
+ * before any sandbox starts. Use `.resume()` instead, which continues the
1163
+ * session in place.
1164
+ *
1165
+ * Public-facing shape of the internal `ForkNotSupportedError` in `errors.ts`,
1166
+ * declared here so Effect's types stay out of the published `.d.ts` files.
1167
+ * Match it on `_tag` (or `name`), both `"ForkNotSupportedError"`.
1168
+ */
1169
+ interface ForkNotSupportedError extends Error {
1170
+ readonly _tag: "ForkNotSupportedError";
1171
+ readonly name: "ForkNotSupportedError";
1172
+ /** The agent provider's name, e.g. `"copilot"`. */
1173
+ readonly agentProvider: string;
1174
+ }
1175
+
1176
+ interface SyncOutPathErrorConstructor {
1177
+ new (args: {
1178
+ readonly message: string;
1179
+ readonly path: string;
1180
+ }): SyncOutPathError;
1181
+ readonly prototype: SyncOutPathError;
1182
+ }
1183
+ /**
1184
+ * Sync-out refused to write a file on the host because its path, as reported
1185
+ * by an isolated sandbox, would land outside the host worktree (or in its
1186
+ * `.git`): an absolute path, a `..` segment, or a symlink leading out.
1187
+ *
1188
+ * Public-facing type for `SyncOutPathError`. The runtime class is the same
1189
+ * `Data.TaggedError` from `errors.ts`, re-declared here as a plain `Error`
1190
+ * subclass so that Effect's types stay out of Sandcastle's published `.d.ts`
1191
+ * files.
1192
+ */
1193
+ interface SyncOutPathError extends Error {
1194
+ readonly _tag: "SyncOutPathError";
1195
+ readonly message: string;
1196
+ /** The offending path, as the sandbox reported it. */
1197
+ readonly path: string;
1198
+ }
1199
+ /** Sync-out refused a host path that would land outside the worktree. */
1200
+ declare const SyncOutPathError: SyncOutPathErrorConstructor;
1201
+
1202
+ /**
1203
+ * Native sandbox providers: bind-mount sandbox providers that contain the
1204
+ * agent with the host OS's own process sandbox (Bubblewrap, Seatbelt) instead
1205
+ * of a container. They share the "bind-mount" tag, so core knows them by a
1206
+ * mark set when the provider is constructed.
1207
+ */
1208
+
1209
+ interface NativeInteractiveNotSupportedErrorConstructor {
1210
+ new (args: {
1211
+ readonly message: string;
1212
+ readonly provider: string;
1213
+ }): NativeInteractiveNotSupportedError;
1214
+ readonly prototype: NativeInteractiveNotSupportedError;
1215
+ }
1216
+ /**
1217
+ * `interactive()` was called with a native sandbox provider (`bwrap()`,
1218
+ * `seatbelt()`). Native providers don't run interactive sessions: use `run()`,
1219
+ * or pass `docker()` or `noSandbox()` to `interactive()`.
1220
+ *
1221
+ * Public-facing type for `NativeInteractiveNotSupportedError`. The runtime
1222
+ * class is the same `Data.TaggedError` from `errors.ts`, re-declared here as a
1223
+ * plain `Error` subclass so that Effect's types stay out of Sandcastle's
1224
+ * published `.d.ts` files.
1225
+ */
1226
+ interface NativeInteractiveNotSupportedError extends Error {
1227
+ readonly _tag: "NativeInteractiveNotSupportedError";
1228
+ readonly message: string;
1229
+ /** The native sandbox provider `interactive()` was called with. */
1230
+ readonly provider: string;
1231
+ }
1232
+ /** `interactive()` was called with a native sandbox provider. */
1233
+ declare const NativeInteractiveNotSupportedError: NativeInteractiveNotSupportedErrorConstructor;
1234
+
1235
+ interface NativeSandboxUnavailableErrorConstructor {
1236
+ new (args: {
1237
+ readonly message: string;
1238
+ readonly fixCommand?: string;
1239
+ }): NativeSandboxUnavailableError;
1240
+ readonly prototype: NativeSandboxUnavailableError;
1241
+ }
1242
+ /**
1243
+ * A native sandbox provider (`bwrap()`, `seatbelt()`) can't run on this host:
1244
+ * the wrong OS, its tool isn't installed, or the kernel blocks it. Thrown when
1245
+ * the provider is constructed, before any worktree exists, so a run never
1246
+ * falls back to running unsandboxed.
1247
+ *
1248
+ * Public-facing type for `NativeSandboxUnavailableError`. The runtime class is
1249
+ * the same `Data.TaggedError` from `errors.ts`, re-declared here as a plain
1250
+ * `Error` subclass so that Effect's types stay out of Sandcastle's published
1251
+ * `.d.ts` files.
1252
+ */
1253
+ interface NativeSandboxUnavailableError extends Error {
1254
+ readonly _tag: "NativeSandboxUnavailableError";
1255
+ readonly message: string;
1256
+ /** A shell command that fixes the host, when there is one (e.g. an install command). */
1257
+ readonly fixCommand?: string;
1258
+ }
1259
+ /** A native sandbox provider can't run on this host. */
1260
+ declare const NativeSandboxUnavailableError: NativeSandboxUnavailableErrorConstructor;
1261
+
1262
+ 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 };