coding-agents-sdk 0.9.0 → 0.11.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 (70) hide show
  1. package/README.md +9 -3
  2. package/dist/Agent-BD2xHVi0.mjs +4 -0
  3. package/dist/{SdkAgent-CxDlEycD.mjs → SdkAgent-DQfLwPwY.mjs} +1 -1
  4. package/dist/adapters/claude-code-cli/index.d.mts +1 -1
  5. package/dist/adapters/claude-code-cli/index.mjs +1 -2
  6. package/dist/adapters/claude-code-cli-pty/index.d.mts +3 -0
  7. package/dist/adapters/claude-code-cli-pty/index.mjs +35 -0
  8. package/dist/adapters/claude-code-sdk/index.d.mts +1 -1
  9. package/dist/adapters/claude-code-sdk/index.mjs +3 -3
  10. package/dist/adapters/codex-cli/index.d.mts +1 -1
  11. package/dist/adapters/codex-cli/index.mjs +2 -2
  12. package/dist/adapters/codex-sdk/index.d.mts +1 -1
  13. package/dist/adapters/codex-sdk/index.mjs +1 -1
  14. package/dist/adapters/cursor-cli/index.d.mts +1 -1
  15. package/dist/adapters/cursor-cli/index.mjs +1 -1
  16. package/dist/adapters/cursor-sdk/index.d.mts +1 -1
  17. package/dist/adapters/cursor-sdk/index.mjs +1 -1
  18. package/dist/adapters/gemini-cli/index.d.mts +1 -1
  19. package/dist/adapters/gemini-cli/index.mjs +1 -1
  20. package/dist/adapters/opencode-cli/index.d.mts +1 -1
  21. package/dist/adapters/opencode-cli/index.mjs +1 -1
  22. package/dist/adapters/pi-cli/index.d.mts +1 -1
  23. package/dist/adapters/pi-cli/index.mjs +1 -1
  24. package/dist/{classify-error-DoH0BqEA.mjs → classify-error-BcWmNftw.mjs} +1 -1
  25. package/dist/container/index.d.mts +2 -2
  26. package/dist/container/index.mjs +1 -1
  27. package/dist/container-BhXUiAiK.mjs +1 -0
  28. package/dist/{container-BuaAmhBf.mjs → container-BurV5WG9.mjs} +1 -1
  29. package/dist/container-D31bbA4L.mjs +1 -0
  30. package/dist/{container-RMYjapoN.mjs → container-TizHce_7.mjs} +1 -1
  31. package/dist/{diff-DkMPJCxL.mjs → diff-DWM1ciiV.mjs} +1 -1
  32. package/dist/errors-CeKI_bYK.mjs +1 -0
  33. package/dist/{events-BE9s04ko.d.mts → events-Bwfw__Q3.d.mts} +140 -0
  34. package/dist/execution-target-CGTSqVEP.mjs +1 -0
  35. package/dist/index-B0x76PaA.d.mts +104 -0
  36. package/dist/{index-BC_KQvvz.d.mts → index-BQNj8DHq.d.mts} +46 -15
  37. package/dist/index-B_MIEnNS.d.mts +60 -0
  38. package/dist/index-BeejNCvc.d.mts +429 -0
  39. package/dist/index-C8wbKjj3.d.mts +188 -0
  40. package/dist/index-CEHYyi4k.d.mts +68 -0
  41. package/dist/{index-DM6yXz_N.d.mts → index-ClURbAqF.d.mts} +67 -1
  42. package/dist/index-CyxdNK5W.d.mts +58 -0
  43. package/dist/{index-BTcDyVsX.d.mts → index-D5zrCo6s.d.mts} +43 -12
  44. package/dist/index-ILgtPW1P.d.mts +97 -0
  45. package/dist/index-dPV54_sZ.d.mts +69 -0
  46. package/dist/{index-nx85iU6i.d.mts → index-p8MJ49dZ.d.mts} +77 -1
  47. package/dist/index.d.mts +69 -17
  48. package/dist/index.mjs +1 -1
  49. package/dist/oci-tjdSZfTm.mjs +1 -0
  50. package/dist/parser-BBJPNGZ2.mjs +2 -0
  51. package/dist/sandbox/index.d.mts +1 -1
  52. package/dist/schemas/index.d.mts +1 -1
  53. package/dist/schemas/index.mjs +1 -1
  54. package/dist/schemas-mNF2Xlg_.mjs +1 -0
  55. package/dist/types-Bk-YpdbX.d.mts +476 -0
  56. package/package.json +25 -20
  57. package/dist/container--0TOW4sB.mjs +0 -1
  58. package/dist/container-C5h5Bdf_.mjs +0 -1
  59. package/dist/errors-XV0frS3r.mjs +0 -1
  60. package/dist/execution-target-Dr2SFmkz.mjs +0 -4
  61. package/dist/index-BsTS0n1I.d.mts +0 -46
  62. package/dist/index-BsWb681o.d.mts +0 -85
  63. package/dist/index-CK9BK1t2.d.mts +0 -42
  64. package/dist/index-CkX15fCQ.d.mts +0 -242
  65. package/dist/index-Cpz-hhM0.d.mts +0 -42
  66. package/dist/index-CzjmvgZI.d.mts +0 -39
  67. package/dist/index-l1U15W0k.d.mts +0 -46
  68. package/dist/oci-BVYPHn7b.mjs +0 -1
  69. package/dist/schemas-CXVWDOoT.mjs +0 -1
  70. package/dist/types-BnnsL3U5.d.mts +0 -162
@@ -0,0 +1,60 @@
1
+ import { A as ProcessSpawner, f as EnsureDisjoint, l as BaseAgent, p as ExclusiveExecutionTargetOptions, t as AgentEventHandler } from "./types-Bk-YpdbX.mjs";
2
+ import { t as Container } from "./index-BeejNCvc.mjs";
3
+ import { c as Sandbox } from "./index-C8wbKjj3.mjs";
4
+ import { z } from "zod/v4";
5
+
6
+ //#region src/adapters/gemini-cli/events/schemas.d.ts
7
+ /**
8
+ * Permissive raw-event shape for Gemini CLI: `{ type: string }` plus
9
+ * arbitrary additional fields the CLI may emit.
10
+ */
11
+ declare const geminiEventSchema: z.ZodObject<{
12
+ type: z.ZodString;
13
+ }, z.core.$loose>;
14
+ type GeminiEvent = z.infer<typeof geminiEventSchema>;
15
+ //#endregion
16
+ //#region src/adapters/gemini-cli/types.d.ts
17
+ /**
18
+ * Permission handling for Gemini CLI.
19
+ * - `"default"`: prompt before risky tool calls.
20
+ * - `"full"`: full-auto (no prompts).
21
+ */
22
+ type GeminiCliPermissionMode = "default" | "full";
23
+ /** Per-run options for the `gemini-cli` adapter. */
24
+ interface GeminiCliRunOptions {
25
+ /** Allowlist of tool names. */
26
+ allowedTools?: string[];
27
+ /**
28
+ * Filter applied against `allowedTools` — tool names listed here are
29
+ * removed from the allowlist before it's passed to Gemini. Ignored when
30
+ * `allowedTools` is empty/undefined (Gemini CLI has no standalone
31
+ * denylist flag).
32
+ */
33
+ disallowedTools?: string[];
34
+ /** Permission strategy. See {@link GeminiCliPermissionMode}. */
35
+ permissionMode?: GeminiCliPermissionMode;
36
+ /** Extra CLI flags appended verbatim. */
37
+ extraArgs?: string[];
38
+ }
39
+ /** Constructor options for `createAgent("gemini-cli", ...)`. */
40
+ type GeminiCliAgentOptions = ExclusiveExecutionTargetOptions<Container, Sandbox> & GeminiCliRunOptions & {
41
+ /** Path or argv to the `gemini` binary. */command?: string[] | string; /** Working directory the agent operates against. */
42
+ cwd?: string; /** Environment variables for the subprocess. Layered on top of host env when `propagateEnv` is `true` (default). */
43
+ env?: Record<string, string>; /** Default `true`: `process.env` is inherited and `env` overlays it. Set `false` to suppress host-env propagation. */
44
+ propagateEnv?: boolean; /** Existing Gemini session ID to resume. */
45
+ sessionId?: string; /** Gemini model identifier. */
46
+ model?: string; /** Replaces Gemini's default system prompt entirely. */
47
+ systemPrompt?: string; /** File path to write the raw CLI log to (useful for debugging). */
48
+ logPath?: string; /** Custom process spawner; set by `createContainer`/`createSandbox`, rarely needed manually. */
49
+ spawner?: ProcessSpawner; /** Convenience: equivalent to calling `agent.onEvent(handler)` post-construction. */
50
+ onEvent?: AgentEventHandler;
51
+ };
52
+ /** Agent instance returned by `createAgent("gemini-cli", ...)`. */
53
+ interface GeminiCliAgent extends BaseAgent<EnsureDisjoint<GeminiCliRunOptions>> {
54
+ readonly type: "gemini-cli";
55
+ }
56
+ //#endregion
57
+ //#region src/adapters/gemini-cli/adapter.d.ts
58
+ declare const createGeminiCliAgent: (options?: GeminiCliAgentOptions) => GeminiCliAgent;
59
+ //#endregion
60
+ export { GeminiCliRunOptions as a, GeminiCliPermissionMode as i, GeminiCliAgent as n, GeminiEvent as o, GeminiCliAgentOptions as r, createGeminiCliAgent as t };
@@ -0,0 +1,429 @@
1
+ import { A as ProcessSpawner } from "./types-Bk-YpdbX.mjs";
2
+
3
+ //#region src/container/types.d.ts
4
+ /** Which provider backs a container. Selects which CLI/SDK the adapter speaks. */
5
+ type ContainerType = "docker" | "e2b" | "nerdctl" | "podman";
6
+ /** Container port → host port mapping for `start`/`run`. */
7
+ interface PortMapping {
8
+ /** Port number exposed inside the container. */
9
+ container: number;
10
+ /** Host port to bind to. Defaults to a random free port if omitted. */
11
+ host?: number;
12
+ /** Transport protocol. Defaults to `"tcp"`. */
13
+ protocol?: "tcp" | "udp";
14
+ }
15
+ /** Bind mount or volume binding from host to container. */
16
+ interface VolumeMount {
17
+ /** Host path (absolute) or named volume. */
18
+ source: string;
19
+ /** Container path to mount at (absolute). */
20
+ target: string;
21
+ /** When `true`, mount is read-only inside the container. */
22
+ readonly?: boolean;
23
+ }
24
+ /** Fields shared by every provider-specific container config. */
25
+ interface ContainerConfigBase<TType extends ContainerType> {
26
+ type: TType;
27
+ /** Default working directory for `exec` and the agent's session. */
28
+ workdir: string;
29
+ /** Optional human-readable name. Defaults to a random unique name. */
30
+ name?: string;
31
+ /** Environment variables baked into the container. */
32
+ env?: Record<string, string>;
33
+ }
34
+ /** Per-call execution options for {@link ContainerExecution.exec}. */
35
+ interface ExecOptions {
36
+ /** Working directory inside the container; defaults to the container's `workdir`. */
37
+ cwd?: string;
38
+ /** Environment overrides layered on top of the container env. */
39
+ env?: Record<string, string>;
40
+ /** Hard timeout in milliseconds. */
41
+ timeoutMs?: number;
42
+ /** Caller-supplied AbortSignal that cancels the exec. */
43
+ signal?: AbortSignal;
44
+ }
45
+ /** Result of an exec call. */
46
+ interface ExecResult {
47
+ /** Exit code reported by the command. */
48
+ exitCode: number;
49
+ /** Captured stdout. */
50
+ stdout: string;
51
+ /** Captured stderr. */
52
+ stderr: string;
53
+ }
54
+ /** Lifecycle state of a container. */
55
+ type ContainerStatus = "created" | "disposed" | "running" | "stopped";
56
+ /** Per-file change kind in a {@link WorkdirDiff}. */
57
+ type WorkdirChangeKind = "added" | "deleted" | "modified" | "renamed";
58
+ /** Options for {@link ContainerObservability.snapshotWorkdir}. */
59
+ interface WorkdirSnapshotOptions {
60
+ /** Directory to snapshot; defaults to the container's `workdir`. */
61
+ cwd?: string;
62
+ }
63
+ /** Opaque snapshot reference used to compute a diff later. Release with {@link ContainerObservability.releaseWorkdirSnapshot}. */
64
+ interface WorkdirSnapshot {
65
+ readonly cwd: string;
66
+ readonly createdAt: Date;
67
+ }
68
+ /** Single-file entry in a {@link WorkdirDiff}. */
69
+ interface WorkdirFileChange {
70
+ readonly path: string;
71
+ /** For `kind: "renamed"`, the original path. */
72
+ readonly previousPath?: string;
73
+ readonly kind: WorkdirChangeKind;
74
+ readonly beforeHash?: string;
75
+ readonly afterHash?: string;
76
+ readonly beforeSize?: number;
77
+ readonly afterSize?: number;
78
+ }
79
+ /** Summary stats for a workdir diff operation. */
80
+ interface WorkdirDiffStats {
81
+ readonly durationMs: number;
82
+ readonly filesCompared: number;
83
+ }
84
+ /** Difference between a {@link WorkdirSnapshot} and the current container state. */
85
+ interface WorkdirDiff {
86
+ readonly cwd: string;
87
+ /** Convenience flat list of changed paths. */
88
+ readonly changedFiles: readonly string[];
89
+ /** Detailed per-file change records. */
90
+ readonly fileChanges: readonly WorkdirFileChange[];
91
+ readonly stats: WorkdirDiffStats;
92
+ }
93
+ /** Identity facet of a container — id, name, status, config. */
94
+ interface ContainerIdentity<TType extends ContainerType, TConfig extends ContainerConfigBase<TType>> {
95
+ readonly type: TType;
96
+ /** Provider-assigned container ID (Docker/Podman id, E2B sandbox id, etc.). */
97
+ readonly id: string;
98
+ readonly name: string;
99
+ readonly config: TConfig;
100
+ readonly status: ContainerStatus;
101
+ readonly workdir: string;
102
+ }
103
+ /** Lifecycle facet — start/stop/dispose plus `await using` support. */
104
+ interface ContainerLifecycle {
105
+ /** Start the container. Idempotent for already-running containers. */
106
+ start: () => Promise<void>;
107
+ /** Stop the container without removing it. */
108
+ stop: () => Promise<void>;
109
+ /** Stop and remove the container. Idempotent. */
110
+ dispose: () => Promise<void>;
111
+ [Symbol.asyncDispose]: () => Promise<void>;
112
+ }
113
+ /** Execution facet — run commands inside the container. */
114
+ interface ContainerExecution {
115
+ /**
116
+ * Execute `command` with `args` inside the container, returning the
117
+ * complete {@link ExecResult} once the process exits. Streams of stdout
118
+ * and stderr are buffered into the result strings.
119
+ */
120
+ exec: (command: string, args: string[], options?: ExecOptions) => Promise<ExecResult>;
121
+ /** Convenience wrapper that runs `script` under `/bin/sh -lc`. */
122
+ execShell: (script: string, options?: ExecOptions) => Promise<ExecResult>;
123
+ /** Process spawner used by agent adapters when wiring this container as `container`. */
124
+ readonly spawner: ProcessSpawner;
125
+ }
126
+ /** Filesystem facet — file I/O between host and container. */
127
+ interface ContainerFileSystem {
128
+ /** Copy a host file or directory into the container. */
129
+ copyTo: (hostPath: string, containerPath: string) => Promise<void>;
130
+ /** Copy a container file or directory out to the host. */
131
+ copyFrom: (containerPath: string, hostPath: string) => Promise<void>;
132
+ /** Write `content` to `path` inside the container, replacing any existing file. */
133
+ writeFile: (path: string, content: Uint8Array | string) => Promise<void>;
134
+ /** Read `path` as a UTF-8 string. */
135
+ readFile: (path: string) => Promise<string>;
136
+ /** Check whether `path` exists inside the container. */
137
+ fileExists: (path: string) => Promise<boolean>;
138
+ /** Create a directory (and parents) inside the container. */
139
+ mkdir: (path: string) => Promise<void>;
140
+ }
141
+ /** Observability facet — logs, status sync, workdir diffing. */
142
+ interface ContainerObservability {
143
+ /** Tail the container's log output. `tail` limits the number of trailing lines. */
144
+ logs: (options?: {
145
+ tail?: number;
146
+ }) => Promise<string>;
147
+ /** Re-query the provider for the container's current status. */
148
+ syncStatus: () => Promise<ContainerStatus>;
149
+ /** Capture an immutable snapshot of `workdir` for later diffing. */
150
+ snapshotWorkdir: (options?: WorkdirSnapshotOptions) => Promise<WorkdirSnapshot>;
151
+ /** Compute the diff between an earlier snapshot and the current workdir. */
152
+ diffWorkdir: (snapshot: WorkdirSnapshot) => Promise<WorkdirDiff>;
153
+ /** Release storage held by a snapshot. Safe to call multiple times. */
154
+ releaseWorkdirSnapshot: (snapshot: WorkdirSnapshot) => Promise<void>;
155
+ }
156
+ /** Composed shape of every concrete container instance. */
157
+ interface ContainerBase<TType extends ContainerType, TConfig extends ContainerConfigBase<TType>> extends ContainerExecution, ContainerFileSystem, ContainerIdentity<TType, TConfig>, ContainerLifecycle, ContainerObservability {}
158
+ //#endregion
159
+ //#region src/container/oci.d.ts
160
+ interface OciBuildBase {
161
+ context?: string;
162
+ args?: Record<string, string>;
163
+ tag?: string;
164
+ }
165
+ type OciBuildConfig = OciBuildBase & ({
166
+ dockerfile: string;
167
+ content?: never;
168
+ } | {
169
+ dockerfile?: never;
170
+ content: string;
171
+ });
172
+ interface OciProviderBase {
173
+ ports?: PortMapping[];
174
+ mounts?: VolumeMount[];
175
+ mountCwd?: string;
176
+ user?: string;
177
+ binary?: string;
178
+ extraArgs?: string[];
179
+ network?: string;
180
+ platform?: string;
181
+ }
182
+ type OciProviderConfig = OciProviderBase & ({
183
+ image: string;
184
+ build?: never;
185
+ } | {
186
+ image?: never;
187
+ build: OciBuildConfig;
188
+ });
189
+ //#endregion
190
+ //#region src/container/docker/types.d.ts
191
+ /** Inline Dockerfile content and build-context shape (re-exported from OCI). */
192
+ type DockerBuildBase = OciBuildBase;
193
+ /** Docker `docker build` configuration: image tag, context, build args. */
194
+ type DockerBuildConfig = OciBuildConfig;
195
+ /** Common provider fields shared with other OCI-style providers. */
196
+ type DockerContainerBase = OciProviderBase;
197
+ /** Provider-specific fields for Docker (image, build, mounts, ports, env). */
198
+ type DockerProviderConfig = OciProviderConfig;
199
+ /** Full config passed to `createContainer({ type: "docker", ... })`. */
200
+ type DockerContainerConfig = ContainerConfigBase<"docker"> & OciProviderConfig;
201
+ /** Docker container instance. */
202
+ interface DockerContainer extends ContainerBase<"docker", DockerContainerConfig> {
203
+ /** Resolve the host port bound to a container port from {@link PortMapping}, or `undefined` if unmapped. */
204
+ getMappedPort: (containerPort: number) => number | undefined;
205
+ }
206
+ //#endregion
207
+ //#region src/container/e2b/types.d.ts
208
+ interface E2BSandboxNetworkOptions {
209
+ allowOut?: string[];
210
+ denyOut?: string[];
211
+ allowPublicTraffic?: boolean;
212
+ maskRequestHost?: string;
213
+ }
214
+ interface E2BSandboxLifecycleOptions {
215
+ onTimeout: "kill" | "pause";
216
+ autoResume?: boolean;
217
+ }
218
+ /** Auth and transport fields shared by every E2B operation. */
219
+ interface E2BConnectionConfig {
220
+ /** E2B API key. Falls back to `E2B_API_KEY` if omitted. */
221
+ apiKey?: string;
222
+ /** Personal access token; an alternative to `apiKey`. Falls back to `E2B_ACCESS_TOKEN`. */
223
+ accessToken?: string;
224
+ /** Override the E2B API domain. Use for self-hosted or staging endpoints. */
225
+ domain?: string;
226
+ /** HTTP request timeout in milliseconds. */
227
+ requestTimeoutMs?: number;
228
+ /** Extra HTTP headers attached to every E2B API call. */
229
+ headers?: Record<string, string>;
230
+ }
231
+ /** Connection + sandbox-instance options shared by create and connect modes. */
232
+ interface E2BContainerBase extends E2BConnectionConfig {
233
+ /** Unix user inside the sandbox. */
234
+ user?: string;
235
+ /** Sandbox lifetime in milliseconds before E2B auto-pauses or kills it. */
236
+ timeoutMs?: number;
237
+ }
238
+ /**
239
+ * Create a fresh E2B sandbox. Use this when you don't have an existing
240
+ * sandbox ID to attach to.
241
+ */
242
+ interface E2BCreateConfig extends E2BContainerBase {
243
+ /** Type-level discriminator — `sandboxId` is forbidden on create. */
244
+ sandboxId?: never;
245
+ /** E2B template ID or alias. Defaults to E2B's `base` template. */
246
+ template?: string;
247
+ /** Arbitrary metadata attached to the sandbox. */
248
+ metadata?: Record<string, string>;
249
+ /** Run in secure mode (no outbound network unless `network` allows it). */
250
+ secure?: boolean;
251
+ /** Convenience toggle: opens unrestricted outbound network access. */
252
+ allowInternetAccess?: boolean;
253
+ /** Network allowlist/denylist for outbound traffic. */
254
+ network?: E2BSandboxNetworkOptions;
255
+ /** What to do when `timeoutMs` expires (`"kill"` or `"pause"`). */
256
+ lifecycle?: E2BSandboxLifecycleOptions;
257
+ }
258
+ /**
259
+ * Re-attach to an existing E2B sandbox by ID. The create-only fields are
260
+ * forbidden here so the type-system rules out "create-or-connect" ambiguity.
261
+ */
262
+ interface E2BConnectConfig extends E2BContainerBase {
263
+ /** Existing E2B sandbox ID to attach to. Required. */
264
+ sandboxId: string;
265
+ template?: never;
266
+ metadata?: never;
267
+ secure?: never;
268
+ allowInternetAccess?: never;
269
+ network?: never;
270
+ lifecycle?: never;
271
+ }
272
+ /** Provider-specific fields: either create-new or connect-to-existing. */
273
+ type E2BProviderConfig = E2BConnectConfig | E2BCreateConfig;
274
+ /** Full config passed to `createContainer({ type: "e2b", ... })`. */
275
+ type E2BContainerConfig = ContainerConfigBase<"e2b"> & E2BProviderConfig;
276
+ /** E2B container instance. */
277
+ interface E2BContainer extends ContainerBase<"e2b", E2BContainerConfig> {
278
+ /** Resolve the externally-reachable hostname for a sandbox port. */
279
+ getHost: (port: number) => string;
280
+ }
281
+ //#endregion
282
+ //#region src/container/nerdctl/types.d.ts
283
+ /** Inline Dockerfile content and build-context shape (re-exported from OCI). */
284
+ type NerdctlBuildBase = OciBuildBase;
285
+ /** nerdctl `nerdctl build` configuration: image tag, context, build args. */
286
+ type NerdctlBuildConfig = OciBuildConfig;
287
+ /** Common provider fields shared with other OCI-style providers. */
288
+ type NerdctlContainerBase = NerdctlProviderBase;
289
+ /** Provider-specific fields for nerdctl, layered on top of generic OCI provider options. */
290
+ interface NerdctlProviderBase extends OciProviderBase {
291
+ /** containerd namespace. Defaults to `"default"`. */
292
+ namespace?: string;
293
+ /** Address of the containerd socket (e.g. `unix:///run/containerd/containerd.sock`). */
294
+ address?: string;
295
+ /** Address of the BuildKit daemon used for `nerdctl build`. */
296
+ buildkitHost?: string;
297
+ /** Snapshotter to use (`overlayfs`, `stargz`, etc.). */
298
+ snapshotter?: string;
299
+ /** Extra `nerdctl` flags appended verbatim. */
300
+ args?: string[];
301
+ }
302
+ /** Provider-specific config: nerdctl-specific fields plus generic OCI provider config. */
303
+ type NerdctlProviderConfig = NerdctlProviderBase & OciProviderConfig;
304
+ /** Full config passed to `createContainer({ type: "nerdctl", ... })`. */
305
+ type NerdctlContainerConfig = ContainerConfigBase<"nerdctl"> & NerdctlProviderConfig;
306
+ /** nerdctl container instance. */
307
+ interface NerdctlContainer extends ContainerBase<"nerdctl", NerdctlContainerConfig> {
308
+ /** Resolve the host port bound to a container port from {@link PortMapping}, or `undefined` if unmapped. */
309
+ getMappedPort: (containerPort: number) => number | undefined;
310
+ }
311
+ //#endregion
312
+ //#region src/container/podman/types.d.ts
313
+ /** Inline Dockerfile content and build-context shape (re-exported from OCI). */
314
+ type PodmanBuildBase = OciBuildBase;
315
+ /** Podman `podman build` configuration: image tag, context, build args. */
316
+ type PodmanBuildConfig = OciBuildConfig;
317
+ /** Common provider fields shared with other OCI-style providers. */
318
+ type PodmanContainerBase = OciProviderBase;
319
+ /** Provider-specific fields for Podman (image, build, mounts, ports, env). */
320
+ type PodmanProviderConfig = OciProviderConfig;
321
+ /** Full config passed to `createContainer({ type: "podman", ... })`. */
322
+ type PodmanContainerConfig = ContainerConfigBase<"podman"> & OciProviderConfig;
323
+ /** Podman container instance. */
324
+ interface PodmanContainer extends ContainerBase<"podman", PodmanContainerConfig> {
325
+ /** Resolve the host port bound to a container port from {@link PortMapping}, or `undefined` if unmapped. */
326
+ getMappedPort: (containerPort: number) => number | undefined;
327
+ }
328
+ //#endregion
329
+ //#region src/container/errors.d.ts
330
+ /**
331
+ * Base class for every error thrown by `createContainer(...)` and the
332
+ * resulting container instance. Catch this if you want to handle any
333
+ * container failure uniformly.
334
+ */
335
+ declare class ContainerError extends Error {
336
+ constructor(message: string);
337
+ }
338
+ /**
339
+ * Thrown by `createContainer(...)` before the container is started — e.g. the
340
+ * configured provider isn't available, a required peer dependency is missing,
341
+ * the image can't be pulled, or required environment variables are absent.
342
+ */
343
+ declare class ContainerCreateError extends ContainerError {
344
+ constructor(message: string);
345
+ }
346
+ /**
347
+ * Thrown when a configured `mounts` entry fails pre-flight validation —
348
+ * typically a missing or unreadable source path on the host.
349
+ */
350
+ declare class MountValidationError extends ContainerError {
351
+ constructor(message: string);
352
+ }
353
+ /**
354
+ * Thrown when the container has been created but fails to enter the running
355
+ * state — daemon refused, image entrypoint exited immediately, etc.
356
+ */
357
+ declare class ContainerStartError extends ContainerError {
358
+ constructor(message: string);
359
+ }
360
+ /**
361
+ * Thrown by `container.exec(...)` when the command could not be dispatched
362
+ * (the inner command's non-zero exit code is reported on the `ExecResult`
363
+ * itself, not as a thrown error).
364
+ */
365
+ declare class ContainerExecError extends ContainerError {
366
+ constructor(message: string);
367
+ }
368
+ /**
369
+ * Thrown when an operation requires the container to be running but it is in
370
+ * `"created"` or `"stopped"` state.
371
+ */
372
+ declare class ContainerNotRunningError extends ContainerError {
373
+ constructor(message?: string);
374
+ }
375
+ /**
376
+ * Thrown when any operation is attempted on a container after `dispose()` (or
377
+ * `await using` cleanup) has run.
378
+ */
379
+ declare class ContainerDisposedError extends ContainerError {
380
+ constructor(message?: string);
381
+ }
382
+ /**
383
+ * Thrown by `container.diffWorkdir(...)` when the diff cannot be computed —
384
+ * e.g. the snapshot reference is invalid, the working directory disappeared,
385
+ * or the provider does not support diffs for the current configuration.
386
+ */
387
+ declare class ContainerDiffError extends ContainerError {
388
+ constructor(message: string);
389
+ }
390
+ //#endregion
391
+ //#region src/container/index.d.ts
392
+ /** Union of every provider config accepted by `createContainer(...)`. Narrow on `type` to pick a provider. */
393
+ type ContainerConfig = DockerContainerConfig | E2BContainerConfig | NerdctlContainerConfig | PodmanContainerConfig;
394
+ /** Union of every provider's running container instance. Narrow on `container.type` to access provider-specific methods. */
395
+ type Container = DockerContainer | E2BContainer | NerdctlContainer | PodmanContainer;
396
+ /**
397
+ * Create a container for sandboxed agent execution.
398
+ *
399
+ * The `type` field on `config` selects the provider; supported values are
400
+ * `"docker"`, `"e2b"`, `"nerdctl"`, and `"podman"`. The provider's daemon
401
+ * (Docker, Podman, etc.) must be running locally, except for `"e2b"` which
402
+ * requires `E2B_API_KEY` / `E2B_ACCESS_TOKEN` and the optional `e2b` peer
403
+ * dependency.
404
+ *
405
+ * Containers are async-disposable. Use `await using` to ensure cleanup:
406
+ *
407
+ * ```ts
408
+ * await using container = await createContainer({
409
+ * type: "docker",
410
+ * image: "node:22",
411
+ * workdir: "/workspace",
412
+ * });
413
+ * await container.exec({ command: ["npm", "install"] });
414
+ * ```
415
+ *
416
+ * Pass the resulting container to a cli-adapter's `container` option to run
417
+ * the agent inside it.
418
+ *
419
+ * @param config Provider-specific configuration. Each provider accepts at minimum `image` or `template` and `workdir`.
420
+ * @returns A promise that resolves to a started container of the selected provider type.
421
+ * @throws {ContainerCreateError} If the provider isn't available, the image can't be pulled, or required env vars are missing.
422
+ * @throws {ContainerStartError} If the container fails to start.
423
+ */
424
+ declare function createContainer(config: DockerContainerConfig): Promise<DockerContainer>;
425
+ declare function createContainer(config: E2BContainerConfig): Promise<E2BContainer>;
426
+ declare function createContainer(config: NerdctlContainerConfig): Promise<NerdctlContainer>;
427
+ declare function createContainer(config: PodmanContainerConfig): Promise<PodmanContainer>;
428
+ //#endregion
429
+ export { WorkdirDiffStats as $, E2BCreateConfig as A, ContainerExecution as B, NerdctlProviderBase as C, E2BContainer as D, E2BConnectionConfig as E, DockerContainerBase as F, ContainerStatus as G, ContainerIdentity as H, DockerContainerConfig as I, ExecResult as J, ContainerType as K, DockerProviderConfig as L, DockerBuildBase as M, DockerBuildConfig as N, E2BContainerBase as O, DockerContainer as P, WorkdirDiff as Q, ContainerBase as R, NerdctlContainerConfig as S, E2BConnectConfig as T, ContainerLifecycle as U, ContainerFileSystem as V, ContainerObservability as W, VolumeMount as X, PortMapping as Y, WorkdirChangeKind as Z, PodmanProviderConfig as _, ContainerDiffError as a, NerdctlContainer as b, ContainerExecError as c, MountValidationError as d, WorkdirFileChange as et, PodmanBuildBase as f, PodmanContainerConfig as g, PodmanContainerBase as h, ContainerCreateError as i, E2BProviderConfig as j, E2BContainerConfig as k, ContainerNotRunningError as l, PodmanContainer as m, ContainerConfig as n, WorkdirSnapshotOptions as nt, ContainerDisposedError as o, PodmanBuildConfig as p, ExecOptions as q, createContainer as r, ContainerError as s, Container as t, WorkdirSnapshot as tt, ContainerStartError as u, NerdctlBuildBase as v, NerdctlProviderConfig as w, NerdctlContainerBase as x, NerdctlBuildConfig as y, ContainerConfigBase as z };
@@ -0,0 +1,188 @@
1
+ import { A as ProcessSpawner } from "./types-Bk-YpdbX.mjs";
2
+ import { X as VolumeMount } from "./index-BeejNCvc.mjs";
3
+
4
+ //#region src/sandbox/types.d.ts
5
+ /** Which sandbox binary backs the policy. The binary must be installed on the host. */
6
+ type SandboxType = "bubblewrap" | "firejail" | "nsjail";
7
+ /** Lifecycle state of a sandbox. */
8
+ type SandboxStatus = "created" | "disposed" | "running" | "stopped";
9
+ /** Fields shared by every sandbox config. */
10
+ interface SandboxConfigBase<TType extends SandboxType> {
11
+ type: TType;
12
+ /** Working directory the wrapped agent process operates against. */
13
+ workdir: string;
14
+ }
15
+ /** Identity facet of a sandbox. */
16
+ interface SandboxIdentity<TType extends SandboxType, TConfig extends SandboxConfigBase<TType>> {
17
+ readonly type: TType;
18
+ readonly config: TConfig;
19
+ readonly status: SandboxStatus;
20
+ readonly workdir: string;
21
+ }
22
+ /** Lifecycle facet of a sandbox. Unlike containers, sandboxes typically have nothing to "start" — `dispose` releases any temp resources. */
23
+ interface SandboxLifecycle {
24
+ /** No-op for most backends; reserved for backends that need to materialize state. */
25
+ start: () => Promise<void>;
26
+ /** No-op for most backends; reserved for backends that need to release resources. */
27
+ stop: () => Promise<void>;
28
+ /** Release any temporary files, mounts, or seccomp rules associated with this sandbox. Idempotent. */
29
+ dispose: () => Promise<void>;
30
+ [Symbol.asyncDispose]: () => Promise<void>;
31
+ }
32
+ /** Execution facet — exposes the spawner the adapter wires into the wrapped agent. */
33
+ interface SandboxExecution {
34
+ /** Process spawner that runs subprocesses inside the sandbox. */
35
+ readonly spawner: ProcessSpawner;
36
+ }
37
+ /** Composed shape of every concrete sandbox instance. */
38
+ interface SandboxBase<TType extends SandboxType, TConfig extends SandboxConfigBase<TType>> extends SandboxExecution, SandboxIdentity<TType, TConfig>, SandboxLifecycle {}
39
+ /**
40
+ * Bubblewrap-backed sandbox. Lightweight, namespace-based, no setuid required
41
+ * on modern kernels. Good default for most use cases.
42
+ */
43
+ interface BubblewrapSandboxConfig extends SandboxConfigBase<"bubblewrap"> {
44
+ /** Override the path to the `bwrap` binary. Defaults to looking up `bwrap` on `PATH`. */
45
+ binary?: string;
46
+ /** Mounts to bind into the sandbox. Use `readonly: true` for read-only mounts. */
47
+ binds?: VolumeMount[];
48
+ /** Start from an empty environment, ignoring the host's `process.env`. */
49
+ clearEnv?: boolean;
50
+ /** Environment variables to set inside the sandbox. */
51
+ setEnv?: Record<string, string>;
52
+ /** Environment variable names to delete inside the sandbox. */
53
+ unsetEnv?: string[];
54
+ /** Unshare all namespaces (PID, IPC, mount, network, UTS, user). */
55
+ unshareAll?: boolean;
56
+ /** When `unshareAll` is set, keep the host network namespace. */
57
+ shareNetwork?: boolean;
58
+ /** Hostname inside the sandbox. */
59
+ hostname?: string;
60
+ /** Inside-sandbox UID. */
61
+ uid?: number;
62
+ /** Inside-sandbox GID. */
63
+ gid?: number;
64
+ /** Paths to mount as tmpfs inside the sandbox. */
65
+ tmpfs?: string[];
66
+ /** Paths to remount read-only. */
67
+ remountReadonly?: string[];
68
+ /** Where to mount `/proc`. `false` disables; defaults to `/proc`. */
69
+ proc?: false | string;
70
+ /** Where to mount `/dev`. `false` disables; defaults to `/dev`. */
71
+ dev?: false | string;
72
+ /** Extra `bwrap` flags appended verbatim. */
73
+ args?: string[];
74
+ }
75
+ /** Bubblewrap sandbox instance. */
76
+ interface BubblewrapSandbox extends SandboxBase<"bubblewrap", BubblewrapSandboxConfig> {}
77
+ /**
78
+ * Firejail-backed sandbox. Higher-level than bubblewrap; uses seccomp profiles
79
+ * and a curated `whitelist`/`blacklist` model.
80
+ */
81
+ interface FirejailSandboxConfig extends SandboxConfigBase<"firejail"> {
82
+ /** Override the path to the `firejail` binary. */
83
+ binary?: string;
84
+ /** Start from an empty environment, ignoring the host's `process.env`. */
85
+ clearEnv?: boolean;
86
+ /** Environment variables to set inside the sandbox. */
87
+ setEnv?: Record<string, string>;
88
+ /** Environment variable names to delete inside the sandbox. */
89
+ unsetEnv?: string[];
90
+ /** Allow network access. Disabled by default. */
91
+ shareNetwork?: boolean;
92
+ /** Paths visible to the sandboxed process; everything else is hidden. */
93
+ whitelist?: string[];
94
+ /** Paths hidden from the sandboxed process. */
95
+ blacklist?: string[];
96
+ /** Paths exposed read-only. */
97
+ readOnly?: string[];
98
+ /** Paths exposed read-write. */
99
+ readWrite?: string[];
100
+ /** Use a private tmpfs `/tmp`. */
101
+ privateTmp?: boolean;
102
+ /** Extra `firejail` flags appended verbatim. */
103
+ args?: string[];
104
+ }
105
+ /** Firejail sandbox instance. */
106
+ interface FirejailSandbox extends SandboxBase<"firejail", FirejailSandboxConfig> {}
107
+ /**
108
+ * nsjail-backed sandbox. Most flexible (full namespace and rlimit control,
109
+ * custom seccomp policies), most complex to configure.
110
+ */
111
+ interface NsjailSandboxConfig extends SandboxConfigBase<"nsjail"> {
112
+ /** Override the path to the `nsjail` binary. */
113
+ binary?: string;
114
+ /** Mounts to bind into the sandbox. */
115
+ binds?: VolumeMount[];
116
+ /** Paths exposed read-only. */
117
+ readOnly?: string[];
118
+ /** Start from an empty environment, ignoring the host's `process.env`. */
119
+ clearEnv?: boolean;
120
+ /** Environment variables to set inside the sandbox. */
121
+ setEnv?: Record<string, string>;
122
+ /** Environment variable names to delete inside the sandbox. */
123
+ unsetEnv?: string[];
124
+ /** Allow network access. Disabled by default. */
125
+ shareNetwork?: boolean;
126
+ /** Inside-sandbox UID. Host IDs are mapped from the current process. */
127
+ uid?: number;
128
+ /** Inside-sandbox GID. Host IDs are mapped from the current process. */
129
+ gid?: number;
130
+ hostname?: string;
131
+ /** Paths to mount as tmpfs. */
132
+ tmpfs?: string[];
133
+ /** Wall-clock time limit for jailed processes, in seconds. */
134
+ timeLimitSec?: number;
135
+ /** Disable nsjail's default rlimits. */
136
+ disableRlimits?: boolean;
137
+ /** Custom seccomp BPF program as a string (advanced). */
138
+ seccompString?: string;
139
+ /** Extra `nsjail` flags appended verbatim. */
140
+ args?: string[];
141
+ }
142
+ /** nsjail sandbox instance. */
143
+ interface NsjailSandbox extends SandboxBase<"nsjail", NsjailSandboxConfig> {}
144
+ /** Union of all sandbox configs accepted by `createSandbox(...)`. */
145
+ type SandboxConfig = BubblewrapSandboxConfig | FirejailSandboxConfig | NsjailSandboxConfig;
146
+ /** Union of all sandbox instance types. */
147
+ type Sandbox = BubblewrapSandbox | FirejailSandbox | NsjailSandbox;
148
+ //#endregion
149
+ //#region src/sandbox/index.d.ts
150
+ /**
151
+ * Create a Linux-only process sandbox for confined agent execution.
152
+ *
153
+ * Unlike `createContainer`, sandboxes don't isolate the filesystem in a new
154
+ * mount namespace by default — they wrap subprocess invocation with a sandbox
155
+ * binary (`bubblewrap`, `firejail`, or `nsjail`) that enforces a configured
156
+ * policy: which paths are readable, writable, executable, and which syscalls
157
+ * or network operations are allowed.
158
+ *
159
+ * The `type` field selects which sandbox binary is used; the binary must be
160
+ * installed on the host. Bubblewrap is the most common; firejail and nsjail
161
+ * suit stricter syscall-filtering policies.
162
+ *
163
+ * Pass the resulting sandbox to a cli-adapter's `sandbox` option to wrap the
164
+ * agent's subprocess. Container and sandbox are mutually exclusive — use one
165
+ * or the other.
166
+ *
167
+ * ```ts
168
+ * const sandbox = await createSandbox({
169
+ * type: "bubblewrap",
170
+ * workdir: process.cwd(),
171
+ * binds: [
172
+ * { source: "/usr", target: "/usr", readonly: true },
173
+ * { source: process.cwd(), target: process.cwd() },
174
+ * ],
175
+ * shareNetwork: false,
176
+ * });
177
+ * await using agent = await createAgent("claude-code-cli", { sandbox });
178
+ * ```
179
+ *
180
+ * @param config Sandbox configuration. Required: `type`. Optional: binds, env, network policy.
181
+ * @returns A promise that resolves to a sandbox handle whose `spawner` is wired into the chosen agent adapter.
182
+ * @throws {Error} If `config.type` is not one of the supported sandbox kinds.
183
+ */
184
+ declare function createSandbox(config: BubblewrapSandboxConfig): Promise<BubblewrapSandbox>;
185
+ declare function createSandbox(config: FirejailSandboxConfig): Promise<FirejailSandbox>;
186
+ declare function createSandbox(config: NsjailSandboxConfig): Promise<NsjailSandbox>;
187
+ //#endregion
188
+ export { FirejailSandboxConfig as a, Sandbox as c, SandboxConfigBase as d, SandboxExecution as f, SandboxType as g, SandboxStatus as h, FirejailSandbox as i, SandboxBase as l, SandboxLifecycle as m, BubblewrapSandbox as n, NsjailSandbox as o, SandboxIdentity as p, BubblewrapSandboxConfig as r, NsjailSandboxConfig as s, createSandbox as t, SandboxConfig as u };