@rivet-dev/agentos-sandbox 0.0.0-main.2f99c77 → 0.0.0-main.5ac5a14

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.
@@ -0,0 +1,2 @@
1
+ export type { AgentOsSandboxClientOptions as SandboxBindingsOptions } from "@rivet-dev/agentos-core";
2
+ export { createSandboxBindings } from "@rivet-dev/agentos-core";
@@ -0,0 +1 @@
1
+ export { createSandboxBindings } from "@rivet-dev/agentos-core";
@@ -0,0 +1,5 @@
1
+ import type { AgentOsSandboxProvider } from "@rivet-dev/agentos-core";
2
+ import type { CloudflareProviderOptions, CloudflareSandboxClient } from "sandbox-agent/cloudflare";
3
+ export type { CloudflareProviderOptions, CloudflareSandboxClient };
4
+ /** Start a Cloudflare sandbox for each AgentOS VM. */
5
+ export declare function cloudflare(options: CloudflareProviderOptions): AgentOsSandboxProvider;
@@ -0,0 +1,6 @@
1
+ import { cloudflare as sandboxAgentCloudflare } from "sandbox-agent/cloudflare";
2
+ import { sandboxAgentProvider } from "./provider.js";
3
+ /** Start a Cloudflare sandbox for each AgentOS VM. */
4
+ export function cloudflare(options) {
5
+ return sandboxAgentProvider(sandboxAgentCloudflare(options));
6
+ }
@@ -0,0 +1,5 @@
1
+ import type { AgentOsSandboxProvider } from "@rivet-dev/agentos-core";
2
+ import type { ComputeSdkProviderOptions } from "sandbox-agent/computesdk";
3
+ export type { ComputeSdkProviderOptions };
4
+ /** Start a ComputeSDK sandbox for each AgentOS VM. */
5
+ export declare function computesdk(options?: ComputeSdkProviderOptions): AgentOsSandboxProvider;
@@ -0,0 +1,6 @@
1
+ import { computesdk as sandboxAgentComputeSdk } from "sandbox-agent/computesdk";
2
+ import { sandboxAgentProvider } from "./provider.js";
3
+ /** Start a ComputeSDK sandbox for each AgentOS VM. */
4
+ export function computesdk(options) {
5
+ return sandboxAgentProvider(sandboxAgentComputeSdk(options));
6
+ }
@@ -0,0 +1,5 @@
1
+ import type { AgentOsSandboxProvider } from "@rivet-dev/agentos-core";
2
+ import type { DaytonaProviderOptions } from "sandbox-agent/daytona";
3
+ export type { DaytonaProviderOptions };
4
+ /** Start a Daytona sandbox for each AgentOS VM. */
5
+ export declare function daytona(options?: DaytonaProviderOptions): AgentOsSandboxProvider;
@@ -0,0 +1,6 @@
1
+ import { daytona as sandboxAgentDaytona } from "sandbox-agent/daytona";
2
+ import { sandboxAgentProvider } from "./provider.js";
3
+ /** Start a Daytona sandbox for each AgentOS VM. */
4
+ export function daytona(options) {
5
+ return sandboxAgentProvider(sandboxAgentDaytona(options));
6
+ }
@@ -0,0 +1,5 @@
1
+ import type { AgentOsSandboxProvider } from "@rivet-dev/agentos-core";
2
+ import type { DockerProviderOptions } from "sandbox-agent/docker";
3
+ export type { DockerProviderOptions };
4
+ /** Start a local Docker sandbox for each AgentOS VM. */
5
+ export declare function docker(options?: DockerProviderOptions): AgentOsSandboxProvider;
package/dist/docker.js ADDED
@@ -0,0 +1,6 @@
1
+ import { docker as sandboxAgentDocker } from "sandbox-agent/docker";
2
+ import { sandboxAgentProvider } from "./provider.js";
3
+ /** Start a local Docker sandbox for each AgentOS VM. */
4
+ export function docker(options) {
5
+ return sandboxAgentProvider(sandboxAgentDocker(options));
6
+ }
package/dist/e2b.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ import type { AgentOsSandboxProvider } from "@rivet-dev/agentos-core";
2
+ import type { E2BProviderOptions } from "sandbox-agent/e2b";
3
+ export type { E2BProviderOptions };
4
+ /** Start an E2B sandbox for each AgentOS VM. */
5
+ export declare function e2b(options?: E2BProviderOptions): AgentOsSandboxProvider;
package/dist/e2b.js ADDED
@@ -0,0 +1,6 @@
1
+ import { e2b as sandboxAgentE2b } from "sandbox-agent/e2b";
2
+ import { sandboxAgentProvider } from "./provider.js";
3
+ /** Start an E2B sandbox for each AgentOS VM. */
4
+ export function e2b(options) {
5
+ return sandboxAgentProvider(sandboxAgentE2b(options));
6
+ }
package/dist/index.d.ts CHANGED
@@ -1,4 +1,9 @@
1
+ export type { AgentOsSandboxClient as SandboxClient, AgentOsSandboxClientOptions as SandboxClientOptions, AgentOsSandboxInput as SandboxInput, AgentOsSandboxOptions as SandboxOptions, AgentOsSandboxProvider as SandboxProvider, AgentOsSandboxProviderOptions as SandboxProviderOptions, } from "@rivet-dev/agentos-core";
2
+ export type { SandboxBindingsOptions } from "./bindings.js";
3
+ export { createSandboxBindings } from "./bindings.js";
4
+ export type { DockerProviderOptions } from "./docker.js";
5
+ export { docker } from "./docker.js";
1
6
  export type { SandboxFsOptions, SandboxMountPluginConfig, } from "./mount.js";
2
7
  export { createSandboxFs } from "./mount.js";
3
- export type { SandboxToolkitOptions } from "./toolkit.js";
4
- export { createSandboxToolkit } from "./toolkit.js";
8
+ export type { SandboxAgentProviderOptions } from "./provider.js";
9
+ export { sandboxAgentProvider } from "./provider.js";
package/dist/index.js CHANGED
@@ -1,2 +1,4 @@
1
+ export { createSandboxBindings } from "./bindings.js";
2
+ export { docker } from "./docker.js";
1
3
  export { createSandboxFs } from "./mount.js";
2
- export { createSandboxToolkit } from "./toolkit.js";
4
+ export { sandboxAgentProvider } from "./provider.js";
@@ -0,0 +1,5 @@
1
+ import type { AgentOsSandboxProvider } from "@rivet-dev/agentos-core";
2
+ import type { LocalProviderOptions } from "sandbox-agent/local";
3
+ export type { LocalProviderOptions };
4
+ /** Start a local Sandbox Agent process for each AgentOS VM. */
5
+ export declare function local(options?: LocalProviderOptions): AgentOsSandboxProvider;
package/dist/local.js ADDED
@@ -0,0 +1,6 @@
1
+ import { local as sandboxAgentLocal } from "sandbox-agent/local";
2
+ import { sandboxAgentProvider } from "./provider.js";
3
+ /** Start a local Sandbox Agent process for each AgentOS VM. */
4
+ export function local(options) {
5
+ return sandboxAgentProvider(sandboxAgentLocal(options));
6
+ }
@@ -0,0 +1,5 @@
1
+ import type { AgentOsSandboxProvider } from "@rivet-dev/agentos-core";
2
+ import type { ModalProviderOptions } from "sandbox-agent/modal";
3
+ export type { ModalProviderOptions };
4
+ /** Start a Modal sandbox for each AgentOS VM. */
5
+ export declare function modal(options?: ModalProviderOptions): AgentOsSandboxProvider;
package/dist/modal.js ADDED
@@ -0,0 +1,6 @@
1
+ import { modal as sandboxAgentModal } from "sandbox-agent/modal";
2
+ import { sandboxAgentProvider } from "./provider.js";
3
+ /** Start a Modal sandbox for each AgentOS VM. */
4
+ export function modal(options) {
5
+ return sandboxAgentProvider(sandboxAgentModal(options));
6
+ }
package/dist/mount.d.ts CHANGED
@@ -1,27 +1,2 @@
1
- import type { MountConfigJsonObject, NativeMountPluginDescriptor } from "@rivet-dev/agentos-runtime-core/descriptors";
2
- import type { SandboxAgent } from "sandbox-agent";
3
- export interface SandboxFsOptions {
4
- /** A connected SandboxAgent client instance. */
5
- client: SandboxAgent;
6
- /** Base path to scope all operations under. Defaults to "/". */
7
- basePath?: string;
8
- /** Per-request timeout for sandbox-agent HTTP calls. */
9
- timeoutMs?: number;
10
- /** Maximum file size allowed for buffered pread/truncate fallbacks. */
11
- maxFullReadBytes?: number;
12
- }
13
- export type SandboxMountPluginConfig = MountConfigJsonObject & {
14
- baseUrl: string;
15
- token?: string;
16
- headers?: Record<string, string>;
17
- basePath?: string;
18
- timeoutMs?: number;
19
- maxFullReadBytes?: number;
20
- };
21
- /**
22
- * Create a declarative sandbox-agent mount plugin descriptor.
23
- *
24
- * This keeps the legacy helper name while routing first-party sandbox mounts
25
- * through the native `sandbox_agent` plugin instead of a JS VFS backend.
26
- */
27
- export declare function createSandboxFs(options: SandboxFsOptions): NativeMountPluginDescriptor<SandboxMountPluginConfig>;
1
+ export type { AgentOsSandboxClientOptions as SandboxFsOptions, SandboxMountPluginConfig, } from "@rivet-dev/agentos-core";
2
+ export { createSandboxFs } from "@rivet-dev/agentos-core";
package/dist/mount.js CHANGED
@@ -1,45 +1 @@
1
- function normalizeHeaders(headers) {
2
- if (!headers) {
3
- return undefined;
4
- }
5
- if (headers instanceof Headers) {
6
- return Object.fromEntries(headers.entries());
7
- }
8
- if (Array.isArray(headers)) {
9
- return Object.fromEntries(headers);
10
- }
11
- return Object.fromEntries(Object.entries(headers).map(([name, value]) => [name, String(value)]));
12
- }
13
- function getSerializableClientConfig(client) {
14
- const serializable = client;
15
- const baseUrl = serializable.baseUrl?.trim().replace(/\/+$/, "");
16
- if (!baseUrl) {
17
- throw new Error("SandboxAgent client does not expose a serializable baseUrl; connect with a standard sandbox-agent client instance");
18
- }
19
- return {
20
- baseUrl,
21
- ...(serializable.token ? { token: serializable.token } : {}),
22
- ...(serializable.defaultHeaders
23
- ? { headers: normalizeHeaders(serializable.defaultHeaders) }
24
- : {}),
25
- };
26
- }
27
- /**
28
- * Create a declarative sandbox-agent mount plugin descriptor.
29
- *
30
- * This keeps the legacy helper name while routing first-party sandbox mounts
31
- * through the native `sandbox_agent` plugin instead of a JS VFS backend.
32
- */
33
- export function createSandboxFs(options) {
34
- return {
35
- id: "sandbox_agent",
36
- config: {
37
- ...getSerializableClientConfig(options.client),
38
- ...(options.basePath ? { basePath: options.basePath } : {}),
39
- ...(options.timeoutMs != null ? { timeoutMs: options.timeoutMs } : {}),
40
- ...(options.maxFullReadBytes != null
41
- ? { maxFullReadBytes: options.maxFullReadBytes }
42
- : {}),
43
- },
44
- };
45
- }
1
+ export { createSandboxFs } from "@rivet-dev/agentos-core";
@@ -0,0 +1,5 @@
1
+ import type { AgentOsSandboxProvider } from "@rivet-dev/agentos-core";
2
+ import { type SandboxProvider as SandboxAgentBackend, type SandboxAgentStartOptions } from "sandbox-agent";
3
+ export type SandboxAgentProviderOptions = Omit<SandboxAgentStartOptions, "sandbox" | "sandboxId">;
4
+ /** Adapt any sandbox-agent backend into a per-VM AgentOS sandbox provider. */
5
+ export declare function sandboxAgentProvider(backend: SandboxAgentBackend, options?: SandboxAgentProviderOptions): AgentOsSandboxProvider;
@@ -0,0 +1,18 @@
1
+ import { SandboxAgent, } from "sandbox-agent";
2
+ /** Adapt any sandbox-agent backend into a per-VM AgentOS sandbox provider. */
3
+ export function sandboxAgentProvider(backend, options = {}) {
4
+ return {
5
+ async start() {
6
+ const client = await SandboxAgent.start({ ...options, sandbox: backend });
7
+ return new Proxy(client, {
8
+ get(target, property) {
9
+ if (property === "dispose") {
10
+ return target.destroySandbox.bind(target);
11
+ }
12
+ const value = Reflect.get(target, property, target);
13
+ return typeof value === "function" ? value.bind(target) : value;
14
+ },
15
+ });
16
+ },
17
+ };
18
+ }
@@ -0,0 +1,5 @@
1
+ import type { AgentOsSandboxProvider } from "@rivet-dev/agentos-core";
2
+ import type { SpritesClientOverrides, SpritesCreateOverrides, SpritesProviderOptions } from "sandbox-agent/sprites";
3
+ export type { SpritesClientOverrides, SpritesCreateOverrides, SpritesProviderOptions, };
4
+ /** Start a Fly.io Sprite for each AgentOS VM. */
5
+ export declare function sprites(options?: SpritesProviderOptions): AgentOsSandboxProvider;
@@ -0,0 +1,6 @@
1
+ import { sprites as sandboxAgentSprites } from "sandbox-agent/sprites";
2
+ import { sandboxAgentProvider } from "./provider.js";
3
+ /** Start a Fly.io Sprite for each AgentOS VM. */
4
+ export function sprites(options) {
5
+ return sandboxAgentProvider(sandboxAgentSprites(options));
6
+ }
@@ -0,0 +1,5 @@
1
+ import type { AgentOsSandboxProvider } from "@rivet-dev/agentos-core";
2
+ import type { VercelProviderOptions } from "sandbox-agent/vercel";
3
+ export type { VercelProviderOptions };
4
+ /** Start a Vercel Sandbox for each AgentOS VM. */
5
+ export declare function vercel(options?: VercelProviderOptions): AgentOsSandboxProvider;
package/dist/vercel.js ADDED
@@ -0,0 +1,6 @@
1
+ import { vercel as sandboxAgentVercel } from "sandbox-agent/vercel";
2
+ import { sandboxAgentProvider } from "./provider.js";
3
+ /** Start a Vercel Sandbox for each AgentOS VM. */
4
+ export function vercel(options) {
5
+ return sandboxAgentProvider(sandboxAgentVercel(options));
6
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rivet-dev/agentos-sandbox",
3
- "version": "0.0.0-main.2f99c77",
3
+ "version": "0.0.0-main.5ac5a14",
4
4
  "type": "module",
5
5
  "license": "Apache-2.0",
6
6
  "main": "./dist/index.js",
@@ -13,6 +13,51 @@
13
13
  "types": "./dist/index.d.ts",
14
14
  "import": "./dist/index.js",
15
15
  "default": "./dist/index.js"
16
+ },
17
+ "./local": {
18
+ "types": "./dist/local.d.ts",
19
+ "import": "./dist/local.js",
20
+ "default": "./dist/local.js"
21
+ },
22
+ "./e2b": {
23
+ "types": "./dist/e2b.d.ts",
24
+ "import": "./dist/e2b.js",
25
+ "default": "./dist/e2b.js"
26
+ },
27
+ "./daytona": {
28
+ "types": "./dist/daytona.d.ts",
29
+ "import": "./dist/daytona.js",
30
+ "default": "./dist/daytona.js"
31
+ },
32
+ "./docker": {
33
+ "types": "./dist/docker.d.ts",
34
+ "import": "./dist/docker.js",
35
+ "default": "./dist/docker.js"
36
+ },
37
+ "./vercel": {
38
+ "types": "./dist/vercel.d.ts",
39
+ "import": "./dist/vercel.js",
40
+ "default": "./dist/vercel.js"
41
+ },
42
+ "./cloudflare": {
43
+ "types": "./dist/cloudflare.d.ts",
44
+ "import": "./dist/cloudflare.js",
45
+ "default": "./dist/cloudflare.js"
46
+ },
47
+ "./modal": {
48
+ "types": "./dist/modal.d.ts",
49
+ "import": "./dist/modal.js",
50
+ "default": "./dist/modal.js"
51
+ },
52
+ "./computesdk": {
53
+ "types": "./dist/computesdk.d.ts",
54
+ "import": "./dist/computesdk.js",
55
+ "default": "./dist/computesdk.js"
56
+ },
57
+ "./sprites": {
58
+ "types": "./dist/sprites.d.ts",
59
+ "import": "./dist/sprites.js",
60
+ "default": "./dist/sprites.js"
16
61
  }
17
62
  },
18
63
  "scripts": {
@@ -21,15 +66,20 @@
21
66
  "test": "vitest run"
22
67
  },
23
68
  "dependencies": {
24
- "@rivet-dev/agentos-core": "0.0.0-main.2f99c77",
25
- "@rivet-dev/agentos-runtime-core": "0.0.0-main.2f99c77",
26
- "sandbox-agent": "^0.4.2",
27
- "zod": "^4.1.11"
69
+ "@rivet-dev/agentos-core": "0.0.0-main.5ac5a14",
70
+ "dockerode": "^4.0.9",
71
+ "get-port": "^7.1.0",
72
+ "sandbox-agent": "^0.4.2"
28
73
  },
29
74
  "devDependencies": {
30
- "@agentos-software/common": "0.0.0-main.2f99c77",
75
+ "@agentos-software/common": "0.0.0-main.5ac5a14",
31
76
  "@types/node": "^22.10.2",
32
77
  "typescript": "^5.7.2",
33
78
  "vitest": "^2.1.8"
79
+ },
80
+ "repository": {
81
+ "type": "git",
82
+ "url": "https://github.com/rivet-dev/agentos.git",
83
+ "directory": "packages/agentos-sandbox"
34
84
  }
35
85
  }
package/dist/toolkit.d.ts DELETED
@@ -1,14 +0,0 @@
1
- /**
2
- * Sandbox toolkit exposing process management and command execution
3
- * as host tools for agents running inside an agentOS VM.
4
- */
5
- import type { ToolKit } from "@rivet-dev/agentos-core";
6
- import type { SandboxAgent } from "sandbox-agent";
7
- export interface SandboxToolkitOptions {
8
- /** A connected SandboxAgent client instance. */
9
- client: SandboxAgent;
10
- }
11
- /**
12
- * Create a ToolKit that exposes sandbox process management operations.
13
- */
14
- export declare function createSandboxToolkit(options: SandboxToolkitOptions): ToolKit;
package/dist/toolkit.js DELETED
@@ -1,191 +0,0 @@
1
- /**
2
- * Sandbox toolkit exposing process management and command execution
3
- * as host tools for agents running inside an agentOS VM.
4
- */
5
- import { z } from "zod";
6
- /** Host tool type alias for convenience. */
7
- function hostTool(def) {
8
- return def;
9
- }
10
- /**
11
- * Create a ToolKit that exposes sandbox process management operations.
12
- */
13
- export function createSandboxToolkit(options) {
14
- const { client } = options;
15
- return {
16
- name: "sandbox",
17
- description: "Execute commands and manage processes in a remote sandbox environment.",
18
- tools: {
19
- "run-command": hostTool({
20
- description: "Run a command synchronously in the sandbox and return its stdout, stderr, and exit code.",
21
- inputSchema: z.object({
22
- command: z
23
- .string()
24
- .describe("The command to execute (e.g. 'ls', 'python3')."),
25
- args: z
26
- .array(z.string())
27
- .optional()
28
- .describe("Arguments to pass to the command."),
29
- cwd: z
30
- .string()
31
- .optional()
32
- .describe("Working directory for the command."),
33
- env: z
34
- .record(z.string(), z.string())
35
- .optional()
36
- .describe("Additional environment variables."),
37
- timeoutMs: z
38
- .number()
39
- .optional()
40
- .describe("Maximum execution time in milliseconds."),
41
- }),
42
- timeout: 120_000,
43
- execute: async (input) => {
44
- const result = await client.runProcess({
45
- command: input.command,
46
- args: input.args,
47
- cwd: input.cwd,
48
- env: input.env,
49
- timeoutMs: input.timeoutMs,
50
- });
51
- return {
52
- stdout: result.stdout,
53
- stderr: result.stderr,
54
- exitCode: result.exitCode,
55
- timedOut: result.timedOut,
56
- durationMs: result.durationMs,
57
- };
58
- },
59
- }),
60
- "create-process": hostTool({
61
- description: "Start a long-running background process in the sandbox. Returns a process ID for later management.",
62
- inputSchema: z.object({
63
- command: z.string().describe("The command to execute."),
64
- args: z
65
- .array(z.string())
66
- .optional()
67
- .describe("Arguments to pass to the command."),
68
- cwd: z
69
- .string()
70
- .optional()
71
- .describe("Working directory for the process."),
72
- env: z
73
- .record(z.string(), z.string())
74
- .optional()
75
- .describe("Additional environment variables."),
76
- }),
77
- execute: async (input) => {
78
- const proc = await client.createProcess({
79
- command: input.command,
80
- args: input.args,
81
- cwd: input.cwd,
82
- env: input.env,
83
- });
84
- return {
85
- id: proc.id,
86
- command: proc.command,
87
- args: proc.args,
88
- status: proc.status,
89
- pid: proc.pid,
90
- };
91
- },
92
- }),
93
- "list-processes": hostTool({
94
- description: "List all processes running in the sandbox.",
95
- inputSchema: z.object({}),
96
- execute: async () => {
97
- const result = await client.listProcesses();
98
- return {
99
- processes: result.processes.map((p) => ({
100
- id: p.id,
101
- command: p.command,
102
- args: p.args,
103
- status: p.status,
104
- exitCode: p.exitCode,
105
- pid: p.pid,
106
- })),
107
- };
108
- },
109
- }),
110
- "stop-process": hostTool({
111
- description: "Gracefully stop a running process in the sandbox.",
112
- inputSchema: z.object({
113
- id: z.string().describe("The process ID to stop."),
114
- }),
115
- execute: async (input) => {
116
- const proc = await client.stopProcess(input.id);
117
- return {
118
- id: proc.id,
119
- status: proc.status,
120
- exitCode: proc.exitCode,
121
- };
122
- },
123
- }),
124
- "kill-process": hostTool({
125
- description: "Forcefully kill a running process in the sandbox.",
126
- inputSchema: z.object({
127
- id: z.string().describe("The process ID to kill."),
128
- }),
129
- execute: async (input) => {
130
- const proc = await client.killProcess(input.id);
131
- return {
132
- id: proc.id,
133
- status: proc.status,
134
- exitCode: proc.exitCode,
135
- };
136
- },
137
- }),
138
- "get-process-logs": hostTool({
139
- description: "Get stdout/stderr logs from a sandbox process.",
140
- inputSchema: z.object({
141
- id: z.string().describe("The process ID."),
142
- stream: z
143
- .enum(["stdout", "stderr", "combined"])
144
- .optional()
145
- .describe("Which output stream to read. Defaults to combined."),
146
- tail: z
147
- .number()
148
- .optional()
149
- .describe("Only return the last N log entries."),
150
- }),
151
- execute: async (input) => {
152
- const result = await client.getProcessLogs(input.id, {
153
- stream: input.stream,
154
- tail: input.tail,
155
- });
156
- return {
157
- logs: result.entries.map((e) => {
158
- // The sandbox-agent SDK returns log data as base64. Decode it
159
- // so callers receive plain text.
160
- let text = e.data;
161
- if (e.encoding === "base64") {
162
- text = Buffer.from(e.data, "base64").toString("utf-8");
163
- }
164
- return {
165
- data: text,
166
- stream: e.stream,
167
- timestampMs: e.timestampMs,
168
- };
169
- }),
170
- };
171
- },
172
- }),
173
- "send-input": hostTool({
174
- description: "Send text input to an interactive sandbox process via stdin.",
175
- inputSchema: z.object({
176
- id: z.string().describe("The process ID."),
177
- data: z.string().describe("The text to send to the process stdin."),
178
- }),
179
- execute: async (input) => {
180
- // Encode the text as base64 for the sandbox-agent API.
181
- const encoded = Buffer.from(input.data, "utf-8").toString("base64");
182
- await client.sendProcessInput(input.id, {
183
- data: encoded,
184
- encoding: "base64",
185
- });
186
- return { sent: true };
187
- },
188
- }),
189
- },
190
- };
191
- }