agentbox-sdk 0.1.0 → 0.1.1
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 +29 -14
- package/dist/{Sandbox-DTprxRZf.d.ts → Sandbox-BQX-sWzs.d.ts} +49 -6
- package/dist/agents/index.d.ts +24 -4
- package/dist/agents/index.js +13 -4
- package/dist/chunk-2NKMDGYH.js +18 -0
- package/dist/{chunk-BW43ESRM.js → chunk-G27423WX.js} +293 -309
- package/dist/{chunk-HMBWQSVN.js → chunk-O7HCJXKW.js} +28 -1
- package/dist/{chunk-QRQFQTGH.js → chunk-X7AWPYDK.js} +401 -13
- package/dist/cli.js +16 -8
- package/dist/enums.d.ts +25 -0
- package/dist/enums.js +8 -0
- package/dist/events/index.d.ts +4 -2
- package/dist/index.d.ts +5 -3
- package/dist/index.js +15 -4
- package/dist/sandboxes/index.d.ts +12 -2
- package/dist/sandboxes/index.js +7 -3
- package/dist/{types-BwcoN0n-.d.ts → types-Et22oPap.d.ts} +3 -2
- package/package.json +9 -2
- /package/dist/{chunk-JFDP556Q.js → chunk-NSJM57Z4.js} +0 -0
package/README.md
CHANGED
|
@@ -18,7 +18,7 @@ const run = new Agent("claude-code", {
|
|
|
18
18
|
cwd: "/workspace",
|
|
19
19
|
approvalMode: "auto",
|
|
20
20
|
}).stream({
|
|
21
|
-
model: "
|
|
21
|
+
model: "sonnet",
|
|
22
22
|
input: "Create a hello world Express server in /workspace/server.ts",
|
|
23
23
|
});
|
|
24
24
|
|
|
@@ -32,7 +32,7 @@ await sandbox.delete();
|
|
|
32
32
|
Providers are mix-and-match:
|
|
33
33
|
|
|
34
34
|
- **Agents** — [`claude-code`](./src/agents/providers/claude-code.ts), [`opencode`](./src/agents/providers/opencode.ts), [`codex`](./src/agents/providers/codex.ts)
|
|
35
|
-
- **Sandboxes** — [`local-docker`](./src/sandboxes/providers/local-docker.ts), [`e2b`](./src/sandboxes/providers/e2b.ts), [`modal`](./src/sandboxes/providers/modal.ts), [`daytona`](./src/sandboxes/providers/daytona.ts)
|
|
35
|
+
- **Sandboxes** — [`local-docker`](./src/sandboxes/providers/local-docker.ts), [`e2b`](./src/sandboxes/providers/e2b.ts), [`modal`](./src/sandboxes/providers/modal.ts), [`daytona`](./src/sandboxes/providers/daytona.ts), [`vercel`](./src/sandboxes/providers/vercel.ts)
|
|
36
36
|
|
|
37
37
|
Swap either one and your app code stays the same.
|
|
38
38
|
|
|
@@ -78,7 +78,7 @@ const agent = new Agent("claude-code", {
|
|
|
78
78
|
});
|
|
79
79
|
|
|
80
80
|
const result = await agent.run({
|
|
81
|
-
model: "
|
|
81
|
+
model: "sonnet",
|
|
82
82
|
input:
|
|
83
83
|
"Explain the project structure and write a summary to /workspace/OVERVIEW.md",
|
|
84
84
|
});
|
|
@@ -93,7 +93,7 @@ await sandbox.delete();
|
|
|
93
93
|
|
|
94
94
|
```ts
|
|
95
95
|
const run = agent.stream({
|
|
96
|
-
model: "
|
|
96
|
+
model: "sonnet",
|
|
97
97
|
input: "Write a fizzbuzz in Python",
|
|
98
98
|
});
|
|
99
99
|
|
|
@@ -112,9 +112,9 @@ Three agent providers are supported. Each wraps a CLI that runs inside the sandb
|
|
|
112
112
|
|
|
113
113
|
| Provider | CLI | Model format |
|
|
114
114
|
| ------------- | ---------- | ----------------------------------------------- |
|
|
115
|
-
| `claude-code` | `claude` | `
|
|
115
|
+
| `claude-code` | `claude` | `sonnet`, `opus`, `haiku` |
|
|
116
116
|
| `opencode` | `opencode` | `anthropic/claude-sonnet-4-6`, `openai/gpt-4.1` |
|
|
117
|
-
| `codex` | `codex` | `gpt-5-codex`
|
|
117
|
+
| `codex` | `codex` | `gpt-5.3-codex`, `gpt-5.4` |
|
|
118
118
|
|
|
119
119
|
```ts
|
|
120
120
|
new Agent("claude-code", { sandbox, cwd: "/workspace", approvalMode: "auto" });
|
|
@@ -124,17 +124,31 @@ new Agent("codex", { sandbox, cwd: "/workspace", approvalMode: "auto" });
|
|
|
124
124
|
|
|
125
125
|
## Sandboxes
|
|
126
126
|
|
|
127
|
-
|
|
127
|
+
Five sandbox providers are supported. Each gives you an isolated environment with the same interface:
|
|
128
128
|
|
|
129
|
-
| Provider | What it is | Auth
|
|
130
|
-
| -------------- | ---------------------- |
|
|
131
|
-
| `local-docker` | Local Docker container | Docker daemon
|
|
132
|
-
| `e2b` | Cloud micro-VM | `E2B_API_KEY`
|
|
133
|
-
| `modal` | Cloud container | `MODAL_TOKEN_ID` + `MODAL_TOKEN_SECRET`
|
|
134
|
-
| `daytona` | Cloud dev environment | `DAYTONA_API_KEY`
|
|
129
|
+
| Provider | What it is | Auth |
|
|
130
|
+
| -------------- | ---------------------- | ------------------------------------------------------- |
|
|
131
|
+
| `local-docker` | Local Docker container | Docker daemon |
|
|
132
|
+
| `e2b` | Cloud micro-VM | `E2B_API_KEY` |
|
|
133
|
+
| `modal` | Cloud container | `MODAL_TOKEN_ID` + `MODAL_TOKEN_SECRET` |
|
|
134
|
+
| `daytona` | Cloud dev environment | `DAYTONA_API_KEY` |
|
|
135
|
+
| `vercel` | Ephemeral cloud VM | `VERCEL_TOKEN` + `VERCEL_TEAM_ID` + `VERCEL_PROJECT_ID` |
|
|
135
136
|
|
|
136
137
|
Every sandbox supports: `run()`, `runAsync()`, `gitClone()`, `openPort()`, `getPreviewLink()`, `snapshot()`, `stop()`, `delete()`.
|
|
137
138
|
|
|
139
|
+
Vercel sandboxes use runtime snapshots instead of pre-built images — call `sandbox.snapshot()` to capture state and pass the returned id via `provider.snapshotId` on the next run.
|
|
140
|
+
|
|
141
|
+
Vercel also requires ports to be declared at create time via `provider.ports` — `openPort()` is a no-op at runtime, so any port the agent (or your own code) will listen on must be listed up front:
|
|
142
|
+
|
|
143
|
+
```ts
|
|
144
|
+
const sandbox = new Sandbox("vercel", {
|
|
145
|
+
provider: {
|
|
146
|
+
snapshotId: process.env.VERCEL_SNAPSHOT_ID!,
|
|
147
|
+
ports: [4096], // e.g. opencode; codex/claude-code use 43180
|
|
148
|
+
},
|
|
149
|
+
});
|
|
150
|
+
```
|
|
151
|
+
|
|
138
152
|
## Skills
|
|
139
153
|
|
|
140
154
|
Attach GitHub repos as agent skills. They're cloned into the sandbox and surfaced to the agent:
|
|
@@ -241,7 +255,7 @@ Pass images and files alongside text:
|
|
|
241
255
|
import { pathToFileURL } from "node:url";
|
|
242
256
|
|
|
243
257
|
const result = await agent.run({
|
|
244
|
-
model: "
|
|
258
|
+
model: "sonnet",
|
|
245
259
|
input: [
|
|
246
260
|
{ type: "text", text: "Describe this mockup and suggest improvements." },
|
|
247
261
|
{ type: "image", image: pathToFileURL("/workspace/mockup.png") },
|
|
@@ -348,6 +362,7 @@ The [`examples/`](./examples) directory has short, runnable scripts that each de
|
|
|
348
362
|
| [`multimodal.ts`](./examples/multimodal.ts) | Send images to the agent |
|
|
349
363
|
| [`custom-image.ts`](./examples/custom-image.ts) | Build a custom sandbox image |
|
|
350
364
|
| [`cloud-sandbox.ts`](./examples/cloud-sandbox.ts) | Use E2B, Modal, or Daytona |
|
|
365
|
+
| [`basic-vercel.ts`](./examples/basic-vercel.ts) | Use a Vercel sandbox |
|
|
351
366
|
| [`git-clone.ts`](./examples/git-clone.ts) | Clone a repo into the sandbox |
|
|
352
367
|
|
|
353
368
|
All examples import from `"agentbox-sdk"` like a normal dependency. Run them with:
|
|
@@ -1,20 +1,26 @@
|
|
|
1
1
|
import { Sandbox as Sandbox$1 } from 'e2b';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { Sandbox as Sandbox$2 } from '@vercel/sandbox';
|
|
3
|
+
import { Daytona, Sandbox as Sandbox$3 } from '@daytonaio/sdk';
|
|
4
|
+
import { ModalClient, Sandbox as Sandbox$4 } from 'modal';
|
|
4
5
|
import Docker from 'dockerode';
|
|
6
|
+
import { SandboxProvider } from './enums.js';
|
|
5
7
|
|
|
6
8
|
type E2bRaw = {
|
|
7
9
|
sandbox?: Sandbox$1;
|
|
8
10
|
};
|
|
9
11
|
|
|
12
|
+
type VercelRaw = {
|
|
13
|
+
sandbox?: Sandbox$2;
|
|
14
|
+
};
|
|
15
|
+
|
|
10
16
|
type DaytonaRaw = {
|
|
11
17
|
client: Daytona;
|
|
12
|
-
sandbox?: Sandbox$
|
|
18
|
+
sandbox?: Sandbox$3;
|
|
13
19
|
};
|
|
14
20
|
|
|
15
21
|
type ModalRaw = {
|
|
16
22
|
client: ModalClient;
|
|
17
|
-
sandbox?: Sandbox$
|
|
23
|
+
sandbox?: Sandbox$4;
|
|
18
24
|
};
|
|
19
25
|
|
|
20
26
|
type DockerRaw = {
|
|
@@ -22,7 +28,7 @@ type DockerRaw = {
|
|
|
22
28
|
container?: Docker.Container;
|
|
23
29
|
};
|
|
24
30
|
|
|
25
|
-
type SandboxProviderName =
|
|
31
|
+
type SandboxProviderName = SandboxProvider;
|
|
26
32
|
interface CommandOptions {
|
|
27
33
|
cwd?: string;
|
|
28
34
|
env?: Record<string, string>;
|
|
@@ -113,6 +119,35 @@ interface DaytonaProviderOptions {
|
|
|
113
119
|
user?: string;
|
|
114
120
|
public?: boolean;
|
|
115
121
|
}
|
|
122
|
+
interface VercelGitSource {
|
|
123
|
+
url: string;
|
|
124
|
+
depth?: number;
|
|
125
|
+
revision?: string;
|
|
126
|
+
username?: string;
|
|
127
|
+
password?: string;
|
|
128
|
+
}
|
|
129
|
+
interface VercelProviderOptions {
|
|
130
|
+
token?: string;
|
|
131
|
+
teamId?: string;
|
|
132
|
+
projectId?: string;
|
|
133
|
+
runtime?: string;
|
|
134
|
+
snapshotId?: string;
|
|
135
|
+
timeoutMs?: number;
|
|
136
|
+
gitSource?: VercelGitSource;
|
|
137
|
+
/**
|
|
138
|
+
* Ports to declare at sandbox creation time. The Vercel SDK requires ports
|
|
139
|
+
* to be known upfront; runtime-opened ports are not supported. Max 4.
|
|
140
|
+
*/
|
|
141
|
+
ports?: number[];
|
|
142
|
+
/**
|
|
143
|
+
* Vercel Deployment Protection bypass token. When set, every request the
|
|
144
|
+
* agent transports send through the sandbox preview URL will include
|
|
145
|
+
* `x-vercel-protection-bypass: <token>`. Required when the linked Vercel
|
|
146
|
+
* project has Deployment Protection enabled — without it, POST requests
|
|
147
|
+
* to sandbox-exposed ports come back 200 + empty body.
|
|
148
|
+
*/
|
|
149
|
+
protectionBypass?: string;
|
|
150
|
+
}
|
|
116
151
|
interface E2bProviderOptions {
|
|
117
152
|
apiKey?: string;
|
|
118
153
|
accessToken?: string;
|
|
@@ -139,6 +174,9 @@ interface ModalSandboxOptions extends SandboxOptionsBase {
|
|
|
139
174
|
interface DaytonaSandboxOptions extends SandboxOptionsBase {
|
|
140
175
|
provider?: DaytonaProviderOptions;
|
|
141
176
|
}
|
|
177
|
+
interface VercelSandboxOptions extends SandboxOptionsBase {
|
|
178
|
+
provider?: VercelProviderOptions;
|
|
179
|
+
}
|
|
142
180
|
interface E2bSandboxOptions extends SandboxOptionsBase {
|
|
143
181
|
provider?: E2bProviderOptions;
|
|
144
182
|
}
|
|
@@ -146,6 +184,7 @@ type SandboxOptionsMap = {
|
|
|
146
184
|
"local-docker": LocalDockerSandboxOptions;
|
|
147
185
|
modal: ModalSandboxOptions;
|
|
148
186
|
daytona: DaytonaSandboxOptions;
|
|
187
|
+
vercel: VercelSandboxOptions;
|
|
149
188
|
e2b: E2bSandboxOptions;
|
|
150
189
|
};
|
|
151
190
|
type SandboxOptions<P extends SandboxProviderName = SandboxProviderName> = SandboxOptionsMap[P];
|
|
@@ -153,6 +192,7 @@ type SandboxRawMap = {
|
|
|
153
192
|
"local-docker": DockerRaw;
|
|
154
193
|
modal: ModalRaw;
|
|
155
194
|
daytona: DaytonaRaw;
|
|
195
|
+
vercel: VercelRaw;
|
|
156
196
|
e2b: E2bRaw;
|
|
157
197
|
};
|
|
158
198
|
type SandboxRaw<P extends SandboxProviderName = SandboxProviderName> = SandboxRawMap[P];
|
|
@@ -177,6 +217,9 @@ declare class Sandbox<P extends SandboxProviderName = SandboxProviderName> {
|
|
|
177
217
|
stop(): Promise<void>;
|
|
178
218
|
delete(): Promise<void>;
|
|
179
219
|
getPreviewLink(port: number): Promise<string>;
|
|
220
|
+
get previewHeaders(): Record<string, string>;
|
|
221
|
+
uploadFile(content: Buffer | string, targetPath: string): Promise<void>;
|
|
222
|
+
downloadFile(sourcePath: string): Promise<Buffer>;
|
|
180
223
|
}
|
|
181
224
|
|
|
182
|
-
export { type AsyncCommandHandle as A, type CommandEvent as C, type DaytonaProviderOptions as D, type E2bProviderOptions as E, type GitCloneOptions as G, type LocalDockerProviderOptions as L, type ModalProviderOptions as M, Sandbox as S, type CommandOptions as a, type CommandResult as b, type DaytonaSandboxOptions as c, type E2bSandboxOptions as d, type LocalDockerSandboxOptions as e, type ModalSandboxOptions as f, type SandboxDescriptor as g, type SandboxListOptions as h, type SandboxOptions as i, type SandboxOptionsBase as j, type SandboxOptionsMap as k, type SandboxProviderName as l, type SandboxRaw as m, type SandboxRawMap as n, type SandboxResourceSpec as o };
|
|
225
|
+
export { type AsyncCommandHandle as A, type CommandEvent as C, type DaytonaProviderOptions as D, type E2bProviderOptions as E, type GitCloneOptions as G, type LocalDockerProviderOptions as L, type ModalProviderOptions as M, Sandbox as S, type VercelGitSource as V, type CommandOptions as a, type CommandResult as b, type DaytonaSandboxOptions as c, type E2bSandboxOptions as d, type LocalDockerSandboxOptions as e, type ModalSandboxOptions as f, type SandboxDescriptor as g, type SandboxListOptions as h, type SandboxOptions as i, type SandboxOptionsBase as j, type SandboxOptionsMap as k, type SandboxProviderName as l, type SandboxRaw as m, type SandboxRawMap as n, type SandboxResourceSpec as o, type VercelProviderOptions as p, type VercelSandboxOptions as q };
|
package/dist/agents/index.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { m as AgentProviderName, f as AgentOptions, q as AgentRunConfig, p as AgentRun, o as AgentResult, Z as RawAgentEvent } from '../types-
|
|
2
|
-
export { a as AgentApprovalMode, b as AgentCommandConfig, c as AgentExecutionRequest, d as AgentLocalMcpConfig, e as AgentMcpConfig, g as AgentOptionsBase, h as AgentOptionsMap, i as AgentPermissionDecision, j as AgentPermissionKind, k as AgentPermissionResponse, l as AgentProviderAdapter, n as AgentRemoteMcpConfig, r as AgentRunSink, s as AgentSkillConfig, t as AgentSubAgentConfig, C as ClaudeCodeAgentOptions, u as ClaudeCodeHookConfig, v as ClaudeCodeHookEvent, w as ClaudeCodeHookHandler, x as ClaudeCodeHookMatcherGroup, y as ClaudeCodeHooksConfig, z as ClaudeCodeProviderOptions, B as CodexAgentOptions, D as CodexCommandHook, E as CodexHookEvent, F as CodexHookMatcherGroup, G as CodexHooksConfig, H as CodexProviderOptions, I as DataContent, J as EmbeddedSkillConfig, K as FilePart, L as ImagePart, S as OpenCodeAgentOptions, T as OpenCodePluginConfig, U as OpenCodePluginEvent, V as OpenCodePluginHookConfig, W as OpenCodeProviderOptions, $ as RepoSkillConfig, a4 as TextPart, a8 as UserContent, a9 as UserContentPart } from '../types-
|
|
3
|
-
|
|
1
|
+
import { m as AgentProviderName, f as AgentOptions, q as AgentRunConfig, p as AgentRun, o as AgentResult, Z as RawAgentEvent } from '../types-Et22oPap.js';
|
|
2
|
+
export { a as AgentApprovalMode, b as AgentCommandConfig, c as AgentExecutionRequest, d as AgentLocalMcpConfig, e as AgentMcpConfig, g as AgentOptionsBase, h as AgentOptionsMap, i as AgentPermissionDecision, j as AgentPermissionKind, k as AgentPermissionResponse, l as AgentProviderAdapter, n as AgentRemoteMcpConfig, r as AgentRunSink, s as AgentSkillConfig, t as AgentSubAgentConfig, C as ClaudeCodeAgentOptions, u as ClaudeCodeHookConfig, v as ClaudeCodeHookEvent, w as ClaudeCodeHookHandler, x as ClaudeCodeHookMatcherGroup, y as ClaudeCodeHooksConfig, z as ClaudeCodeProviderOptions, B as CodexAgentOptions, D as CodexCommandHook, E as CodexHookEvent, F as CodexHookMatcherGroup, G as CodexHooksConfig, H as CodexProviderOptions, I as DataContent, J as EmbeddedSkillConfig, K as FilePart, L as ImagePart, S as OpenCodeAgentOptions, T as OpenCodePluginConfig, U as OpenCodePluginEvent, V as OpenCodePluginHookConfig, W as OpenCodeProviderOptions, $ as RepoSkillConfig, a4 as TextPart, a8 as UserContent, a9 as UserContentPart } from '../types-Et22oPap.js';
|
|
3
|
+
export { AgentProvider } from '../enums.js';
|
|
4
|
+
import '../Sandbox-BQX-sWzs.js';
|
|
4
5
|
import 'e2b';
|
|
6
|
+
import '@vercel/sandbox';
|
|
5
7
|
import '@daytonaio/sdk';
|
|
6
8
|
import 'modal';
|
|
7
9
|
import 'dockerode';
|
|
@@ -16,4 +18,22 @@ declare class Agent<P extends AgentProviderName = AgentProviderName> {
|
|
|
16
18
|
rawEvents(runConfig: AgentRunConfig): AsyncIterable<RawAgentEvent>;
|
|
17
19
|
}
|
|
18
20
|
|
|
19
|
-
|
|
21
|
+
/**
|
|
22
|
+
* Ports each agent harness needs exposed on its sandbox in order to reach
|
|
23
|
+
* its app-server (or equivalent local server). These are used to:
|
|
24
|
+
*
|
|
25
|
+
* 1. Drive `sandbox.openPort(...)` at `Agent` construction time so providers
|
|
26
|
+
* whose `openPort` only mutates options before provisioning (Modal) still
|
|
27
|
+
* include the port.
|
|
28
|
+
* 2. Pre-declare the ports on Modal sandboxes by default so that a Modal
|
|
29
|
+
* sandbox created without explicit `unencryptedPorts` still works when
|
|
30
|
+
* the caller later points an `Agent` at it.
|
|
31
|
+
*
|
|
32
|
+
* Exported so callers can forward the ports to sandbox creation options when
|
|
33
|
+
* they know in advance which harness will be used (e.g.
|
|
34
|
+
* `provider.unencryptedPorts: AGENT_RESERVED_PORTS.codex`).
|
|
35
|
+
*/
|
|
36
|
+
declare const AGENT_RESERVED_PORTS: Record<AgentProviderName, readonly number[]>;
|
|
37
|
+
declare function collectAllAgentReservedPorts(): number[];
|
|
38
|
+
|
|
39
|
+
export { AGENT_RESERVED_PORTS, Agent, AgentOptions, AgentProviderName, AgentResult, AgentRun, AgentRunConfig, collectAllAgentReservedPorts };
|
package/dist/agents/index.js
CHANGED
|
@@ -1,9 +1,18 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Agent
|
|
3
|
-
} from "../chunk-
|
|
3
|
+
} from "../chunk-G27423WX.js";
|
|
4
4
|
import "../chunk-7FLLQJ6J.js";
|
|
5
|
-
import
|
|
6
|
-
|
|
5
|
+
import {
|
|
6
|
+
AGENT_RESERVED_PORTS,
|
|
7
|
+
collectAllAgentReservedPorts
|
|
8
|
+
} from "../chunk-O7HCJXKW.js";
|
|
9
|
+
import "../chunk-NSJM57Z4.js";
|
|
10
|
+
import {
|
|
11
|
+
AgentProvider
|
|
12
|
+
} from "../chunk-2NKMDGYH.js";
|
|
7
13
|
export {
|
|
8
|
-
|
|
14
|
+
AGENT_RESERVED_PORTS,
|
|
15
|
+
Agent,
|
|
16
|
+
AgentProvider,
|
|
17
|
+
collectAllAgentReservedPorts
|
|
9
18
|
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// src/enums.ts
|
|
2
|
+
var AgentProvider = {
|
|
3
|
+
ClaudeCode: "claude-code",
|
|
4
|
+
OpenCode: "opencode",
|
|
5
|
+
Codex: "codex"
|
|
6
|
+
};
|
|
7
|
+
var SandboxProvider = {
|
|
8
|
+
LocalDocker: "local-docker",
|
|
9
|
+
Modal: "modal",
|
|
10
|
+
Daytona: "daytona",
|
|
11
|
+
Vercel: "vercel",
|
|
12
|
+
E2B: "e2b"
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export {
|
|
16
|
+
AgentProvider,
|
|
17
|
+
SandboxProvider
|
|
18
|
+
};
|