noumen 0.3.0 → 0.5.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.
- package/README.md +63 -8
- package/dist/a2a/index.d.ts +4 -2
- package/dist/acp/index.d.ts +5 -3
- package/dist/{agent-1nFVUP9E.d.ts → agent-C3eDRsxs.d.ts} +19 -508
- package/dist/chunk-I5SBSOS6.js +40 -0
- package/dist/chunk-I5SBSOS6.js.map +1 -0
- package/dist/{chunk-4HW6LN6D.js → chunk-WPCYGZOE.js} +58 -1228
- package/dist/chunk-WPCYGZOE.js.map +1 -0
- package/dist/{chunk-5JN4SPI7.js → chunk-WTLK2ZAR.js} +1 -1
- package/dist/{chunk-HL6JCRZJ.js → chunk-XZN4QZLK.js} +4 -4
- package/dist/cli/index.js +10 -10
- package/dist/computer-BPdxSo6X.d.ts +88 -0
- package/dist/docker.d.ts +129 -0
- package/dist/docker.js +401 -0
- package/dist/docker.js.map +1 -0
- package/dist/e2b.d.ts +157 -0
- package/dist/e2b.js +202 -0
- package/dist/e2b.js.map +1 -0
- package/dist/freestyle.d.ts +174 -0
- package/dist/freestyle.js +240 -0
- package/dist/freestyle.js.map +1 -0
- package/dist/index.d.ts +9 -201
- package/dist/index.js +24 -48
- package/dist/lsp/index.d.ts +3 -2
- package/dist/mcp/index.d.ts +4 -3
- package/dist/mcp/index.js +2 -2
- package/dist/{provider-factory-KCLIF34X.js → provider-factory-KI7OZUY3.js} +2 -2
- package/dist/{resolve-4JA2BBDA.js → resolve-GDSHNMG6.js} +2 -2
- package/dist/sandbox-9qeMTNrD.d.ts +126 -0
- package/dist/server/index.d.ts +4 -2
- package/dist/{server-CHMxuWKq.d.ts → server-Cu9gv1dk.d.ts} +1 -1
- package/dist/sprites.d.ts +136 -0
- package/dist/sprites.js +334 -0
- package/dist/sprites.js.map +1 -0
- package/dist/ssh.d.ts +187 -0
- package/dist/ssh.js +392 -0
- package/dist/ssh.js.map +1 -0
- package/dist/{types-RPKUTu1k.d.ts → types-BA87bHPV.d.ts} +2 -88
- package/package.json +28 -1
- package/dist/chunk-4HW6LN6D.js.map +0 -1
- /package/dist/{chunk-5JN4SPI7.js.map → chunk-WTLK2ZAR.js.map} +0 -0
- /package/dist/{chunk-HL6JCRZJ.js.map → chunk-XZN4QZLK.js.map} +0 -0
- /package/dist/{provider-factory-KCLIF34X.js.map → provider-factory-KI7OZUY3.js.map} +0 -0
- /package/dist/{resolve-4JA2BBDA.js.map → resolve-GDSHNMG6.js.map} +0 -0
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { A as AIProvider, S as StreamEvent, b as ChatMessage, E as Entry, U as UUID, d as FileCheckpointSnapshot, f as ContentReplacementRecord$1, g as SessionInfo, M as ModelPricing, h as UsageRecord, i as CostSummary, j as ModelUsageSummary, k as ChatCompletionUsage, l as ThinkingConfig, m as MemoryConfig, O as OutputFormat, e as ContentPart, R as RunOptions, c as CheckpointConfig, n as ToolResult } from './types-LrU4LRmX.js';
|
|
2
|
-
import {
|
|
2
|
+
import { S as Sandbox } from './sandbox-9qeMTNrD.js';
|
|
3
|
+
import { T as Tool, H as HookDefinition, S as SubagentConfig, i as SubagentRun, j as TaskStore, e as LspServerManager, F as FileCheckpointManager, k as FileStateCacheConfig, L as LspServerConfig } from './types-BA87bHPV.js';
|
|
3
4
|
import { C as CacheControlConfig } from './cache-DsRqxx6v.js';
|
|
4
5
|
import { M as McpServerConfig, T as TokenStorage } from './types-2kTLUCnD.js';
|
|
5
6
|
import { c as PermissionHandler, d as PermissionConfig } from './types-CD0rUKKT.js';
|
|
7
|
+
import { a as VirtualFs, V as VirtualComputer } from './computer-BPdxSo6X.js';
|
|
6
8
|
|
|
7
9
|
type ProviderName = "openai" | "anthropic" | "gemini" | "openrouter" | "bedrock" | "vertex" | "ollama";
|
|
8
10
|
declare const DEFAULT_MODELS: Record<string, string>;
|
|
@@ -25,508 +27,6 @@ declare function resolveProvider(input: AIProvider | ProviderName, opts?: Resolv
|
|
|
25
27
|
*/
|
|
26
28
|
declare function detectProvider(): Promise<ProviderName | undefined>;
|
|
27
29
|
|
|
28
|
-
/**
|
|
29
|
-
* Filesystem and network restriction config passed to `@anthropic-ai/sandbox-runtime`.
|
|
30
|
-
*/
|
|
31
|
-
interface SandboxConfig {
|
|
32
|
-
filesystem?: {
|
|
33
|
-
/** Paths the agent may write to (default: `[cwd]`). Write is denied everywhere else. */
|
|
34
|
-
allowWrite?: string[];
|
|
35
|
-
/** Paths to explicitly deny writes within allowed regions. */
|
|
36
|
-
denyWrite?: string[];
|
|
37
|
-
/** Paths to deny reading. By default everything is readable. */
|
|
38
|
-
denyRead?: string[];
|
|
39
|
-
/** Paths to re-allow reading within denyRead regions. Takes precedence over denyRead. */
|
|
40
|
-
allowRead?: string[];
|
|
41
|
-
};
|
|
42
|
-
network?: {
|
|
43
|
-
/** Domains the agent may reach via HTTP/HTTPS/SOCKS. */
|
|
44
|
-
allowedDomains?: string[];
|
|
45
|
-
/** Domains to explicitly block. */
|
|
46
|
-
deniedDomains?: string[];
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
interface SandboxedLocalComputerOptions {
|
|
50
|
-
defaultCwd?: string;
|
|
51
|
-
defaultTimeout?: number;
|
|
52
|
-
sandbox?: SandboxConfig;
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* `VirtualComputer` that wraps every command with OS-level sandboxing via
|
|
56
|
-
* `@anthropic-ai/sandbox-runtime`. Uses macOS Seatbelt (`sandbox-exec`) or
|
|
57
|
-
* Linux bubblewrap (`bwrap`) under the hood.
|
|
58
|
-
*/
|
|
59
|
-
declare class SandboxedLocalComputer implements VirtualComputer {
|
|
60
|
-
private defaultCwd;
|
|
61
|
-
private defaultTimeout;
|
|
62
|
-
private sandboxConfig;
|
|
63
|
-
private initPromise;
|
|
64
|
-
private initialized;
|
|
65
|
-
constructor(opts?: SandboxedLocalComputerOptions);
|
|
66
|
-
private buildRuntimeConfig;
|
|
67
|
-
private ensureInitialized;
|
|
68
|
-
executeCommand(command: string, opts?: ExecOptions): Promise<CommandResult>;
|
|
69
|
-
/**
|
|
70
|
-
* Tear down the sandbox runtime. Call when the agent is done.
|
|
71
|
-
*/
|
|
72
|
-
dispose(): Promise<void>;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* Minimal subset of the dockerode Container interface used by DockerComputer.
|
|
77
|
-
* Avoids a hard import of dockerode at the module level.
|
|
78
|
-
*/
|
|
79
|
-
interface DockerContainer {
|
|
80
|
-
exec(options: Record<string, unknown>): Promise<{
|
|
81
|
-
start(opts?: Record<string, unknown>): Promise<NodeJS.ReadableStream>;
|
|
82
|
-
inspect(): Promise<{
|
|
83
|
-
ExitCode: number;
|
|
84
|
-
}>;
|
|
85
|
-
}>;
|
|
86
|
-
}
|
|
87
|
-
interface DockerComputerOptions {
|
|
88
|
-
/** A dockerode Container instance for the target container. */
|
|
89
|
-
container: DockerContainer;
|
|
90
|
-
/** Default working directory for commands (default: /). */
|
|
91
|
-
defaultCwd?: string;
|
|
92
|
-
/** Default timeout in ms for commands (default: 30000). */
|
|
93
|
-
defaultTimeout?: number;
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* VirtualComputer backed by command execution inside a Docker container.
|
|
97
|
-
*
|
|
98
|
-
* Requires `dockerode` as an optional peer dependency.
|
|
99
|
-
* The user is responsible for container lifecycle (create, start, stop).
|
|
100
|
-
*/
|
|
101
|
-
declare class DockerComputer implements VirtualComputer {
|
|
102
|
-
private container;
|
|
103
|
-
private defaultCwd;
|
|
104
|
-
private defaultTimeout;
|
|
105
|
-
constructor(opts: DockerComputerOptions);
|
|
106
|
-
executeCommand(command: string, opts?: ExecOptions): Promise<CommandResult>;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* Minimal subset of the E2B Sandbox interface used by E2BComputer and E2BFs.
|
|
111
|
-
* Avoids a hard import of `e2b` at the module level.
|
|
112
|
-
*/
|
|
113
|
-
interface E2BSandboxInstance {
|
|
114
|
-
commands: {
|
|
115
|
-
run(cmd: string, opts?: {
|
|
116
|
-
cwd?: string;
|
|
117
|
-
timeout?: number;
|
|
118
|
-
envs?: Record<string, string>;
|
|
119
|
-
}): Promise<{
|
|
120
|
-
exitCode: number;
|
|
121
|
-
stdout: string;
|
|
122
|
-
stderr: string;
|
|
123
|
-
}>;
|
|
124
|
-
};
|
|
125
|
-
files: {
|
|
126
|
-
read(path: string, opts?: {
|
|
127
|
-
format?: string;
|
|
128
|
-
}): Promise<string>;
|
|
129
|
-
write(path: string, data: string): Promise<unknown>;
|
|
130
|
-
remove(path: string): Promise<void>;
|
|
131
|
-
makeDir(path: string): Promise<unknown>;
|
|
132
|
-
list(path: string): Promise<Array<{
|
|
133
|
-
name: string;
|
|
134
|
-
path: string;
|
|
135
|
-
type?: string;
|
|
136
|
-
size?: number;
|
|
137
|
-
modifiedTime?: Date;
|
|
138
|
-
}>>;
|
|
139
|
-
exists(path: string): Promise<boolean>;
|
|
140
|
-
getInfo(path: string): Promise<{
|
|
141
|
-
name: string;
|
|
142
|
-
path: string;
|
|
143
|
-
type?: string;
|
|
144
|
-
size?: number;
|
|
145
|
-
modifiedTime?: Date;
|
|
146
|
-
}>;
|
|
147
|
-
};
|
|
148
|
-
}
|
|
149
|
-
interface E2BComputerOptions {
|
|
150
|
-
/** An E2B Sandbox instance created via `Sandbox.create()`. */
|
|
151
|
-
sandbox: E2BSandboxInstance;
|
|
152
|
-
/** Default working directory for commands. */
|
|
153
|
-
defaultCwd?: string;
|
|
154
|
-
/** Default timeout in ms for commands (default: 30000). */
|
|
155
|
-
defaultTimeout?: number;
|
|
156
|
-
}
|
|
157
|
-
/**
|
|
158
|
-
* VirtualComputer backed by command execution in an E2B cloud sandbox.
|
|
159
|
-
*
|
|
160
|
-
* Requires `e2b` as an optional peer dependency.
|
|
161
|
-
* The user is responsible for sandbox lifecycle (create, close).
|
|
162
|
-
*/
|
|
163
|
-
declare class E2BComputer implements VirtualComputer {
|
|
164
|
-
private sandbox;
|
|
165
|
-
private defaultCwd;
|
|
166
|
-
private defaultTimeout;
|
|
167
|
-
constructor(opts: E2BComputerOptions);
|
|
168
|
-
executeCommand(command: string, opts?: ExecOptions): Promise<CommandResult>;
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
/**
|
|
172
|
-
* Minimal subset of the Freestyle VM interface used by FreestyleComputer and
|
|
173
|
-
* FreestyleFs. Avoids a hard import of `freestyle-sandboxes` at the module
|
|
174
|
-
* level — the real SDK is only loaded dynamically during `FreestyleSandbox`
|
|
175
|
-
* auto-creation.
|
|
176
|
-
*/
|
|
177
|
-
interface FreestyleVmInstance {
|
|
178
|
-
exec(command: string, opts?: {
|
|
179
|
-
cwd?: string;
|
|
180
|
-
timeout?: number;
|
|
181
|
-
}): Promise<{
|
|
182
|
-
stdout: string | null;
|
|
183
|
-
stderr: string | null;
|
|
184
|
-
statusCode: number | null;
|
|
185
|
-
}>;
|
|
186
|
-
fs: {
|
|
187
|
-
readTextFile(path: string): Promise<string>;
|
|
188
|
-
writeTextFile(path: string, content: string): Promise<void>;
|
|
189
|
-
readDir(path: string): Promise<Array<{
|
|
190
|
-
name: string;
|
|
191
|
-
kind: string;
|
|
192
|
-
}>>;
|
|
193
|
-
};
|
|
194
|
-
suspend(): Promise<unknown>;
|
|
195
|
-
start(): Promise<unknown>;
|
|
196
|
-
}
|
|
197
|
-
interface FreestyleComputerOptions {
|
|
198
|
-
/** A Freestyle VM instance. */
|
|
199
|
-
vm: FreestyleVmInstance;
|
|
200
|
-
/** Default working directory for commands. */
|
|
201
|
-
defaultCwd?: string;
|
|
202
|
-
/** Default timeout in ms for commands (default: 30000). */
|
|
203
|
-
defaultTimeout?: number;
|
|
204
|
-
}
|
|
205
|
-
/**
|
|
206
|
-
* VirtualComputer backed by command execution in a Freestyle VM.
|
|
207
|
-
*
|
|
208
|
-
* Requires `freestyle-sandboxes` as an optional peer dependency.
|
|
209
|
-
* The user is responsible for VM lifecycle when using explicit mode.
|
|
210
|
-
*/
|
|
211
|
-
declare class FreestyleComputer implements VirtualComputer {
|
|
212
|
-
private vm;
|
|
213
|
-
private defaultCwd;
|
|
214
|
-
private defaultTimeout;
|
|
215
|
-
constructor(opts: FreestyleComputerOptions);
|
|
216
|
-
executeCommand(command: string, opts?: ExecOptions): Promise<CommandResult>;
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
/**
|
|
220
|
-
* Bundled sandbox: a `VirtualFs` and `VirtualComputer` paired together.
|
|
221
|
-
*
|
|
222
|
-
* Use one of the built-in factories (`LocalSandbox`, `UnsandboxedLocal`,
|
|
223
|
-
* `SpritesSandbox`) or supply any object that satisfies this shape for
|
|
224
|
-
* custom sandboxes (Docker, E2B, Daytona, in-memory, etc.).
|
|
225
|
-
*/
|
|
226
|
-
interface Sandbox {
|
|
227
|
-
fs: VirtualFs;
|
|
228
|
-
computer: VirtualComputer;
|
|
229
|
-
/** Optional cleanup — called by Agent.close() to tear down OS-level sandbox state. */
|
|
230
|
-
dispose?(): Promise<void>;
|
|
231
|
-
/**
|
|
232
|
-
* Lazily provision the underlying sandbox resource. Idempotent — repeated
|
|
233
|
-
* calls return the same single-flight promise.
|
|
234
|
-
*
|
|
235
|
-
* When `sandboxId` is provided the sandbox reconnects to an existing
|
|
236
|
-
* resource instead of creating a new one. This is used during session
|
|
237
|
-
* resume: the stored sandbox identifier is read from session metadata
|
|
238
|
-
* and passed here so the agent reattaches to its previous container.
|
|
239
|
-
*
|
|
240
|
-
* When omitted a fresh resource is provisioned (for factories that
|
|
241
|
-
* support auto-creation) or the call is a no-op (for factories that
|
|
242
|
-
* were given a pre-created resource up front).
|
|
243
|
-
*/
|
|
244
|
-
init?(sandboxId?: string): Promise<void>;
|
|
245
|
-
/**
|
|
246
|
-
* Return the opaque identifier for this sandbox instance so it can be
|
|
247
|
-
* persisted in session metadata and used to reconnect later via `init()`.
|
|
248
|
-
* Returns `undefined` before `init()` has resolved or for sandboxes
|
|
249
|
-
* that don't support reconnection.
|
|
250
|
-
*/
|
|
251
|
-
sandboxId?(): string | undefined;
|
|
252
|
-
}
|
|
253
|
-
interface UnsandboxedLocalOptions {
|
|
254
|
-
/** Working directory for both file resolution and command execution. */
|
|
255
|
-
cwd?: string;
|
|
256
|
-
/** Default timeout (ms) for shell commands. */
|
|
257
|
-
defaultTimeout?: number;
|
|
258
|
-
}
|
|
259
|
-
/**
|
|
260
|
-
* Create a `Sandbox` backed by the host filesystem and shell with **no
|
|
261
|
-
* OS-level isolation**. The agent can access anything the host process can.
|
|
262
|
-
*
|
|
263
|
-
* Use this for development or fully-trusted environments where sandboxing
|
|
264
|
-
* overhead is unwanted. For production use, prefer `LocalSandbox()` (which
|
|
265
|
-
* wraps commands with `@anthropic-ai/sandbox-runtime`).
|
|
266
|
-
*/
|
|
267
|
-
declare function UnsandboxedLocal(opts?: UnsandboxedLocalOptions): Sandbox;
|
|
268
|
-
interface LocalSandboxOptions {
|
|
269
|
-
/** Working directory for both file resolution and command execution. */
|
|
270
|
-
cwd?: string;
|
|
271
|
-
/** Default timeout (ms) for shell commands. */
|
|
272
|
-
defaultTimeout?: number;
|
|
273
|
-
/**
|
|
274
|
-
* Sandbox restrictions. Defaults: writes allowed only in `cwd`,
|
|
275
|
-
* reads allowed everywhere, network unrestricted.
|
|
276
|
-
*/
|
|
277
|
-
sandbox?: SandboxConfig;
|
|
278
|
-
}
|
|
279
|
-
/**
|
|
280
|
-
* Create a `Sandbox` with OS-level isolation via `@anthropic-ai/sandbox-runtime`.
|
|
281
|
-
*
|
|
282
|
-
* - **macOS**: Seatbelt (`sandbox-exec`) profiles restrict filesystem and network.
|
|
283
|
-
* - **Linux**: bubblewrap (`bwrap`) + socat for namespace-based isolation.
|
|
284
|
-
*
|
|
285
|
-
* Filesystem operations (`VirtualFs`) use the host `node:fs` — the sandbox
|
|
286
|
-
* boundary is enforced on shell commands (`VirtualComputer`), which is where
|
|
287
|
-
* the agent executes arbitrary code.
|
|
288
|
-
*
|
|
289
|
-
* Requires `@anthropic-ai/sandbox-runtime` as a peer dependency.
|
|
290
|
-
*/
|
|
291
|
-
declare function LocalSandbox(opts?: LocalSandboxOptions): Sandbox;
|
|
292
|
-
interface SpritesSandboxOptions {
|
|
293
|
-
/** sprites.dev API token. */
|
|
294
|
-
token: string;
|
|
295
|
-
/**
|
|
296
|
-
* Name of an existing sprite container. When provided the sandbox
|
|
297
|
-
* attaches to this sprite directly — no auto-creation occurs and
|
|
298
|
-
* `dispose()` will **not** delete it (lifecycle is yours to manage).
|
|
299
|
-
*
|
|
300
|
-
* When omitted a new sprite is provisioned on the first `init()` call
|
|
301
|
-
* (via `POST /v1/sprites`). The auto-created sprite is deleted when
|
|
302
|
-
* `dispose()` is called, and its name is available via `sandboxId()`
|
|
303
|
-
* for session persistence.
|
|
304
|
-
*/
|
|
305
|
-
spriteName?: string;
|
|
306
|
-
/** Base URL for sprites API (default: https://api.sprites.dev). */
|
|
307
|
-
baseURL?: string;
|
|
308
|
-
/** Working directory inside the sprite (default: /home/sprite). */
|
|
309
|
-
workingDir?: string;
|
|
310
|
-
/**
|
|
311
|
-
* Optional prefix for auto-generated sprite names (default: "noumen-").
|
|
312
|
-
* Only used when `spriteName` is omitted.
|
|
313
|
-
*/
|
|
314
|
-
namePrefix?: string;
|
|
315
|
-
}
|
|
316
|
-
/**
|
|
317
|
-
* Create a `Sandbox` backed by a remote sprites.dev container.
|
|
318
|
-
* Full isolation — the agent has no access to the host machine.
|
|
319
|
-
*
|
|
320
|
-
* **Auto-creation:** When `spriteName` is omitted the sandbox is created
|
|
321
|
-
* lazily on the first `init()` call via the Sprites REST API. The sprite
|
|
322
|
-
* name is available through `sandboxId()` so callers can persist it in
|
|
323
|
-
* session metadata for reconnection on resume. Pass the stored name back
|
|
324
|
-
* through `init(storedId)` to reattach instead of creating a new sprite.
|
|
325
|
-
*
|
|
326
|
-
* **Explicit ID:** When `spriteName` is provided the sandbox attaches to
|
|
327
|
-
* that sprite immediately on `init()`. `dispose()` is a no-op in this
|
|
328
|
-
* case — the caller owns the sprite's lifecycle.
|
|
329
|
-
*
|
|
330
|
-
* @example
|
|
331
|
-
* ```ts
|
|
332
|
-
* // Auto-create — sprite provisioned on first init()
|
|
333
|
-
* const sandbox = SpritesSandbox({ token: process.env.SPRITES_TOKEN! });
|
|
334
|
-
*
|
|
335
|
-
* // Explicit — attach to pre-existing sprite, no auto-lifecycle
|
|
336
|
-
* const sandbox = SpritesSandbox({
|
|
337
|
-
* token: process.env.SPRITES_TOKEN!,
|
|
338
|
-
* spriteName: "my-sprite",
|
|
339
|
-
* });
|
|
340
|
-
* ```
|
|
341
|
-
*/
|
|
342
|
-
declare function SpritesSandbox(opts: SpritesSandboxOptions): Sandbox;
|
|
343
|
-
interface DockerSandboxOptions {
|
|
344
|
-
/**
|
|
345
|
-
* A pre-existing dockerode Container instance. When provided the sandbox
|
|
346
|
-
* attaches to this container directly — no auto-creation occurs and
|
|
347
|
-
* `dispose()` will **not** stop or remove it.
|
|
348
|
-
*
|
|
349
|
-
* When omitted, a new container is created from `image` on the first
|
|
350
|
-
* `init()` call via a dynamic import of `dockerode`. The auto-created
|
|
351
|
-
* container is stopped and removed when `dispose()` is called.
|
|
352
|
-
*/
|
|
353
|
-
container?: DockerContainer;
|
|
354
|
-
/**
|
|
355
|
-
* Docker image to use for auto-creation (e.g. `"ubuntu:22.04"`).
|
|
356
|
-
* Required when `container` is omitted; ignored when `container` is provided.
|
|
357
|
-
*/
|
|
358
|
-
image?: string;
|
|
359
|
-
/** Command to run in the auto-created container (default: `["sleep", "infinity"]`). */
|
|
360
|
-
cmd?: string[];
|
|
361
|
-
/** Environment variables for the auto-created container. */
|
|
362
|
-
env?: string[];
|
|
363
|
-
/** Extra options passed to dockerode `createContainer`. */
|
|
364
|
-
dockerOptions?: Record<string, unknown>;
|
|
365
|
-
/** Working directory inside the container. */
|
|
366
|
-
cwd?: string;
|
|
367
|
-
/** Default timeout (ms) for shell commands. */
|
|
368
|
-
defaultTimeout?: number;
|
|
369
|
-
}
|
|
370
|
-
/**
|
|
371
|
-
* Create a `Sandbox` backed by a Docker container.
|
|
372
|
-
* Requires `dockerode` as an optional peer dependency.
|
|
373
|
-
*
|
|
374
|
-
* **Auto-creation:** When `container` is omitted and `image` is provided,
|
|
375
|
-
* the container is created and started lazily on the first `init()` call.
|
|
376
|
-
* The container ID is available through `sandboxId()` for session
|
|
377
|
-
* persistence. Pass the stored ID back through `init(storedId)` to
|
|
378
|
-
* reattach to an existing container on resume.
|
|
379
|
-
*
|
|
380
|
-
* **Explicit container:** When `container` is provided, `init()` binds
|
|
381
|
-
* it immediately. `dispose()` is a no-op — the caller owns the
|
|
382
|
-
* container's lifecycle.
|
|
383
|
-
*
|
|
384
|
-
* @example
|
|
385
|
-
* ```ts
|
|
386
|
-
* // Auto-create from image
|
|
387
|
-
* const sandbox = DockerSandbox({ image: "ubuntu:22.04", cwd: "/workspace" });
|
|
388
|
-
*
|
|
389
|
-
* // Explicit container (lifecycle managed externally)
|
|
390
|
-
* const sandbox = DockerSandbox({ container: myDockerodeContainer });
|
|
391
|
-
* ```
|
|
392
|
-
*/
|
|
393
|
-
declare function DockerSandbox(opts: DockerSandboxOptions): Sandbox;
|
|
394
|
-
interface E2BSandboxOptions {
|
|
395
|
-
/**
|
|
396
|
-
* A pre-existing E2B Sandbox instance (e.g. from `Sandbox.create()`).
|
|
397
|
-
* When provided the sandbox attaches to this instance — no auto-creation
|
|
398
|
-
* occurs and `dispose()` will **not** kill it.
|
|
399
|
-
*
|
|
400
|
-
* When omitted, a new E2B sandbox is created on the first `init()` call
|
|
401
|
-
* via a dynamic import of the `e2b` package. The auto-created sandbox
|
|
402
|
-
* is killed when `dispose()` is called.
|
|
403
|
-
*/
|
|
404
|
-
sandbox?: E2BSandboxInstance;
|
|
405
|
-
/**
|
|
406
|
-
* E2B template to use for auto-creation (default: `"base"`).
|
|
407
|
-
* Only used when `sandbox` is omitted.
|
|
408
|
-
*/
|
|
409
|
-
template?: string;
|
|
410
|
-
/**
|
|
411
|
-
* E2B API key. Falls back to the `E2B_API_KEY` environment variable
|
|
412
|
-
* when omitted. Only used during auto-creation.
|
|
413
|
-
*/
|
|
414
|
-
apiKey?: string;
|
|
415
|
-
/** Timeout (ms) for the auto-created E2B sandbox (default: E2B SDK default). */
|
|
416
|
-
timeoutMs?: number;
|
|
417
|
-
/** Working directory inside the sandbox. */
|
|
418
|
-
cwd?: string;
|
|
419
|
-
/** Default timeout (ms) for shell commands. */
|
|
420
|
-
defaultTimeout?: number;
|
|
421
|
-
}
|
|
422
|
-
/**
|
|
423
|
-
* Create a `Sandbox` backed by an E2B cloud sandbox.
|
|
424
|
-
* Requires `e2b` as an optional peer dependency.
|
|
425
|
-
*
|
|
426
|
-
* **Auto-creation:** When `sandbox` is omitted the E2B sandbox is
|
|
427
|
-
* provisioned lazily on the first `init()` call via the E2B SDK.
|
|
428
|
-
* The sandbox ID is available through `sandboxId()` for session
|
|
429
|
-
* persistence. Pass the stored ID back through `init(storedId)` to
|
|
430
|
-
* reconnect to the same sandbox on resume (via `Sandbox.connect()`).
|
|
431
|
-
*
|
|
432
|
-
* **Explicit instance:** When `sandbox` is provided, `init()` binds
|
|
433
|
-
* it immediately. `dispose()` is a no-op — the caller owns the
|
|
434
|
-
* sandbox's lifecycle.
|
|
435
|
-
*
|
|
436
|
-
* @example
|
|
437
|
-
* ```ts
|
|
438
|
-
* // Auto-create — sandbox provisioned on first init()
|
|
439
|
-
* const sandbox = E2BSandbox({ template: "base" });
|
|
440
|
-
*
|
|
441
|
-
* // Explicit — attach to pre-existing instance
|
|
442
|
-
* const sandbox = E2BSandbox({ sandbox: await E2BSdk.Sandbox.create() });
|
|
443
|
-
* ```
|
|
444
|
-
*/
|
|
445
|
-
declare function E2BSandbox(opts: E2BSandboxOptions): Sandbox;
|
|
446
|
-
interface FreestyleSandboxOptions {
|
|
447
|
-
/**
|
|
448
|
-
* A pre-existing Freestyle VM instance. When provided the sandbox
|
|
449
|
-
* attaches to this VM directly — no auto-creation occurs and
|
|
450
|
-
* `dispose()` will **not** suspend or delete it.
|
|
451
|
-
*
|
|
452
|
-
* When omitted, a new VM is created on the first `init()` call via
|
|
453
|
-
* a dynamic import of the `freestyle-sandboxes` package.
|
|
454
|
-
*/
|
|
455
|
-
vm?: FreestyleVmInstance;
|
|
456
|
-
/**
|
|
457
|
-
* Freestyle API key. Falls back to the `FREESTYLE_API_KEY` environment
|
|
458
|
-
* variable when omitted. Only used during auto-creation.
|
|
459
|
-
*/
|
|
460
|
-
apiKey?: string;
|
|
461
|
-
/** Snapshot ID to create the VM from. Only used during auto-creation. */
|
|
462
|
-
snapshotId?: string;
|
|
463
|
-
/**
|
|
464
|
-
* A `VmSpec` instance or configuration object passed through to
|
|
465
|
-
* `freestyle.vms.create()`. Only used during auto-creation.
|
|
466
|
-
*/
|
|
467
|
-
spec?: unknown;
|
|
468
|
-
/**
|
|
469
|
-
* Idle timeout in seconds for the auto-created VM (default: 600).
|
|
470
|
-
* The VM auto-suspends after this many seconds of network inactivity.
|
|
471
|
-
*/
|
|
472
|
-
idleTimeoutSeconds?: number;
|
|
473
|
-
/** Working directory inside the VM. */
|
|
474
|
-
cwd?: string;
|
|
475
|
-
/** Default timeout (ms) for shell commands. */
|
|
476
|
-
defaultTimeout?: number;
|
|
477
|
-
/** Files to provision at creation time. */
|
|
478
|
-
additionalFiles?: Record<string, {
|
|
479
|
-
content: string;
|
|
480
|
-
encoding?: string;
|
|
481
|
-
}>;
|
|
482
|
-
/** Git repos to clone at creation time. */
|
|
483
|
-
gitRepos?: Array<{
|
|
484
|
-
repo: string;
|
|
485
|
-
path: string;
|
|
486
|
-
rev?: string;
|
|
487
|
-
}>;
|
|
488
|
-
/**
|
|
489
|
-
* What to do with auto-created VMs on `dispose()`:
|
|
490
|
-
* - `"suspend"` (default) — suspends the VM, preserving full memory
|
|
491
|
-
* state for near-instant resume on reconnect.
|
|
492
|
-
* - `"delete"` — permanently deletes the VM and frees all resources.
|
|
493
|
-
*/
|
|
494
|
-
disposeStrategy?: "suspend" | "delete";
|
|
495
|
-
}
|
|
496
|
-
/**
|
|
497
|
-
* Create a `Sandbox` backed by a Freestyle VM.
|
|
498
|
-
* Requires `freestyle-sandboxes` as an optional peer dependency.
|
|
499
|
-
*
|
|
500
|
-
* **Auto-creation:** When `vm` is omitted a new Freestyle VM is
|
|
501
|
-
* provisioned lazily on the first `init()` call. The VM ID is available
|
|
502
|
-
* through `sandboxId()` for session persistence. Pass the stored ID back
|
|
503
|
-
* through `init(storedId)` to reconnect (this also wakes suspended VMs).
|
|
504
|
-
*
|
|
505
|
-
* By default, auto-created VMs are **suspended** on `dispose()` rather
|
|
506
|
-
* than deleted. This preserves full memory state and allows near-instant
|
|
507
|
-
* resume. Set `disposeStrategy: "delete"` for full cleanup.
|
|
508
|
-
*
|
|
509
|
-
* **Explicit instance:** When `vm` is provided, `init()` binds it
|
|
510
|
-
* immediately. `dispose()` is a no-op — the caller owns the VM's
|
|
511
|
-
* lifecycle.
|
|
512
|
-
*
|
|
513
|
-
* @example
|
|
514
|
-
* ```ts
|
|
515
|
-
* // Auto-create — VM provisioned on first init()
|
|
516
|
-
* const sandbox = FreestyleSandbox({ cwd: "/workspace" });
|
|
517
|
-
*
|
|
518
|
-
* // Auto-create from a snapshot
|
|
519
|
-
* const sandbox = FreestyleSandbox({
|
|
520
|
-
* snapshotId: "abc123",
|
|
521
|
-
* cwd: "/workspace",
|
|
522
|
-
* });
|
|
523
|
-
*
|
|
524
|
-
* // Explicit — attach to pre-existing VM
|
|
525
|
-
* const sandbox = FreestyleSandbox({ vm: existingVm });
|
|
526
|
-
* ```
|
|
527
|
-
*/
|
|
528
|
-
declare function FreestyleSandbox(opts: FreestyleSandboxOptions): Sandbox;
|
|
529
|
-
|
|
530
30
|
interface SkillDefinition {
|
|
531
31
|
name: string;
|
|
532
32
|
/** Skill body content (after frontmatter is stripped) */
|
|
@@ -1127,10 +627,21 @@ interface AgentOptions {
|
|
|
1127
627
|
cwd?: string;
|
|
1128
628
|
/**
|
|
1129
629
|
* Bundled sandbox providing both filesystem and shell execution.
|
|
1130
|
-
*
|
|
1131
|
-
*
|
|
1132
|
-
*
|
|
1133
|
-
*
|
|
630
|
+
*
|
|
631
|
+
* Local backends live on the root barrel:
|
|
632
|
+
* - `LocalSandbox()` — OS-level sandboxing (requires `@anthropic-ai/sandbox-runtime`).
|
|
633
|
+
* - `UnsandboxedLocal()` — raw host access.
|
|
634
|
+
*
|
|
635
|
+
* Remote backends are subpath imports so their optional peer deps do
|
|
636
|
+
* not enter the module graph unless opted into:
|
|
637
|
+
* - `import { DockerSandbox } from "noumen/docker"`
|
|
638
|
+
* - `import { E2BSandbox } from "noumen/e2b"`
|
|
639
|
+
* - `import { FreestyleSandbox } from "noumen/freestyle"`
|
|
640
|
+
* - `import { SshSandbox } from "noumen/ssh"`
|
|
641
|
+
* - `import { SpritesSandbox } from "noumen/sprites"`
|
|
642
|
+
*
|
|
643
|
+
* You can also pass any `{ fs: VirtualFs; computer: VirtualComputer }`
|
|
644
|
+
* for custom sandboxes.
|
|
1134
645
|
*
|
|
1135
646
|
* Defaults to `UnsandboxedLocal({ cwd })` when omitted — the library
|
|
1136
647
|
* default is non-sandboxed for backward compatibility. The CLI defaults
|
|
@@ -1329,4 +840,4 @@ declare class Agent {
|
|
|
1329
840
|
close(): Promise<void>;
|
|
1330
841
|
}
|
|
1331
842
|
|
|
1332
|
-
export {
|
|
843
|
+
export { createAutoCompactConfig as $, Agent as A, type BudgetState as B, type ContextFile as C, DEFAULT_MODELS as D, type RunCallbacks as E, type RunResult as F, SUPPORTED_PROVIDERS as G, type SnipConfig as H, type SnipResult as I, Thread as J, type ThreadOptions as K, type ToolResultBudgetConfig as L, type MicrocompactConfig as M, type ToolResultBudgetResult as N, type ContentReplacementRecord as O, type ProjectContextConfig as P, type ToolResultSpillResult as Q, type RetryConfig as R, type SkillDefinition as S, type ThreadConfig as T, type ToolResultStorageConfig as U, type TracingConfig as V, type WebSearchConfig as W, type WebSearchResult as X, applyPersistedReplacements as Y, applySnipRemovals as Z, canAutoCompact as _, SessionStorage as a, createAutoCompactTracking as a0, createBudgetState as a1, createContentReplacementState as a2, createWebSearchTool as a3, detectProvider as a4, enforceToolResultBudget as a5, enforceToolResultStorageBudget as a6, microcompactMessages as a7, persistToolResult as a8, projectSnippedView as a9, reconstructContentReplacementState as aa, recordAutoCompactFailure as ab, recordAutoCompactSuccess as ac, resolveProvider as ad, shouldAutoCompact as ae, snipMessagesByUuids as af, tryReactiveCompact as ag, webSearchToolPlaceholder as ah, type ContextScope as b, type RetryContext as c, type RetryEngineOptions as d, type Span as e, type SpanAttributeValue as f, SpanStatusCode as g, type Tracer as h, type SpanOptions as i, type StoredCostState as j, type AgentOptions as k, type AutoCompactConfig as l, type AutoCompactTrackingState as m, CLEARED_PLACEHOLDER as n, COMPACTABLE_TOOLS as o, type ContentReplacementState as p, CostTracker as q, DEFAULT_RETRY_CONFIG as r, type DiagnoseCheckResult as s, type DiagnoseResult as t, type MicrocompactResult as u, type ProviderName as v, type ReactiveCompactConfig as w, type ReactiveCompactResult as x, type ResolveProviderOptions as y, type RetryEvent as z };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// src/virtual/proxy.ts
|
|
2
|
+
function uninitError() {
|
|
3
|
+
throw new Error(
|
|
4
|
+
"Sandbox not initialized \u2014 call init() or pass a pre-created resource"
|
|
5
|
+
);
|
|
6
|
+
}
|
|
7
|
+
function createFsProxy() {
|
|
8
|
+
let inner = null;
|
|
9
|
+
const get = () => inner ?? uninitError();
|
|
10
|
+
return {
|
|
11
|
+
setTarget(target) {
|
|
12
|
+
inner = target;
|
|
13
|
+
},
|
|
14
|
+
readFile: (...args) => get().readFile(...args),
|
|
15
|
+
readFileBytes: (...args) => get().readFileBytes?.(...args),
|
|
16
|
+
writeFile: (...args) => get().writeFile(...args),
|
|
17
|
+
appendFile: (...args) => get().appendFile(...args),
|
|
18
|
+
deleteFile: (...args) => get().deleteFile(...args),
|
|
19
|
+
mkdir: (...args) => get().mkdir(...args),
|
|
20
|
+
readdir: (...args) => get().readdir(...args),
|
|
21
|
+
exists: (...args) => get().exists(...args),
|
|
22
|
+
stat: (...args) => get().stat(...args)
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
function createComputerProxy() {
|
|
26
|
+
let inner = null;
|
|
27
|
+
const get = () => inner ?? uninitError();
|
|
28
|
+
return {
|
|
29
|
+
setTarget(target) {
|
|
30
|
+
inner = target;
|
|
31
|
+
},
|
|
32
|
+
executeCommand: (...args) => get().executeCommand(...args)
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export {
|
|
37
|
+
createFsProxy,
|
|
38
|
+
createComputerProxy
|
|
39
|
+
};
|
|
40
|
+
//# sourceMappingURL=chunk-I5SBSOS6.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/virtual/proxy.ts"],"sourcesContent":["import type { VirtualFs } from \"./fs.js\";\nimport type { VirtualComputer } from \"./computer.js\";\n\n/**\n * Thin forwarding wrappers whose inner target is set by a sandbox factory's\n * `init()`. Methods throw until the target is bound.\n *\n * These proxies let remote sandbox factories return a `Sandbox` synchronously\n * while provisioning the real backend lazily inside `init()`. Consumers hold\n * the proxy reference and get transparent forwarding once `setTarget` fires.\n */\n\nexport type FsProxySetter = { setTarget(target: VirtualFs): void };\nexport type ComputerProxySetter = { setTarget(target: VirtualComputer): void };\n\nexport function uninitError(): never {\n throw new Error(\n \"Sandbox not initialized — call init() or pass a pre-created resource\",\n );\n}\n\nexport function createFsProxy(): VirtualFs & FsProxySetter {\n let inner: VirtualFs | null = null;\n const get = (): VirtualFs => inner ?? uninitError();\n return {\n setTarget(target: VirtualFs) { inner = target; },\n readFile: (...args) => get().readFile(...args),\n readFileBytes: (...args) => get().readFileBytes?.(...args) as any,\n writeFile: (...args) => get().writeFile(...args),\n appendFile: (...args) => get().appendFile(...args),\n deleteFile: (...args) => get().deleteFile(...args),\n mkdir: (...args) => get().mkdir(...args),\n readdir: (...args) => get().readdir(...args),\n exists: (...args) => get().exists(...args),\n stat: (...args) => get().stat(...args),\n };\n}\n\nexport function createComputerProxy(): VirtualComputer & ComputerProxySetter {\n let inner: VirtualComputer | null = null;\n const get = (): VirtualComputer => inner ?? uninitError();\n return {\n setTarget(target: VirtualComputer) { inner = target; },\n executeCommand: (...args) => get().executeCommand(...args),\n };\n}\n"],"mappings":";AAeO,SAAS,cAAqB;AACnC,QAAM,IAAI;AAAA,IACR;AAAA,EACF;AACF;AAEO,SAAS,gBAA2C;AACzD,MAAI,QAA0B;AAC9B,QAAM,MAAM,MAAiB,SAAS,YAAY;AAClD,SAAO;AAAA,IACL,UAAU,QAAmB;AAAE,cAAQ;AAAA,IAAQ;AAAA,IAC/C,UAAU,IAAI,SAAS,IAAI,EAAE,SAAS,GAAG,IAAI;AAAA,IAC7C,eAAe,IAAI,SAAS,IAAI,EAAE,gBAAgB,GAAG,IAAI;AAAA,IACzD,WAAW,IAAI,SAAS,IAAI,EAAE,UAAU,GAAG,IAAI;AAAA,IAC/C,YAAY,IAAI,SAAS,IAAI,EAAE,WAAW,GAAG,IAAI;AAAA,IACjD,YAAY,IAAI,SAAS,IAAI,EAAE,WAAW,GAAG,IAAI;AAAA,IACjD,OAAO,IAAI,SAAS,IAAI,EAAE,MAAM,GAAG,IAAI;AAAA,IACvC,SAAS,IAAI,SAAS,IAAI,EAAE,QAAQ,GAAG,IAAI;AAAA,IAC3C,QAAQ,IAAI,SAAS,IAAI,EAAE,OAAO,GAAG,IAAI;AAAA,IACzC,MAAM,IAAI,SAAS,IAAI,EAAE,KAAK,GAAG,IAAI;AAAA,EACvC;AACF;AAEO,SAAS,sBAA6D;AAC3E,MAAI,QAAgC;AACpC,QAAM,MAAM,MAAuB,SAAS,YAAY;AACxD,SAAO;AAAA,IACL,UAAU,QAAyB;AAAE,cAAQ;AAAA,IAAQ;AAAA,IACrD,gBAAgB,IAAI,SAAS,IAAI,EAAE,eAAe,GAAG,IAAI;AAAA,EAC3D;AACF;","names":[]}
|