@anvia/sandbox 1.1.7 → 1.1.8

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 (2) hide show
  1. package/README.md +24 -60
  2. package/package.json +3 -3
package/README.md CHANGED
@@ -1,6 +1,16 @@
1
- # `@anvia/sandbox`
1
+ # @anvia/sandbox
2
2
 
3
- Docker-backed sandbox ownership and tools for Anvia applications.
3
+ Give agents a workspace where they can run commands and work with files. Docker-backed sandboxes keep execution infrastructure explicit and under your application’s control.
4
+
5
+ ## Installation
6
+
7
+ ```sh
8
+ pnpm add @anvia/sandbox @anvia/core
9
+ ```
10
+
11
+ ## Quick start
12
+
13
+ Requires Node.js 20.12 or later and an accessible Docker daemon. Pull an image before creating a sandbox.
4
14
 
5
15
  ```ts
6
16
  import { createDockerSandboxTools, DockerSandboxClient } from "@anvia/sandbox";
@@ -18,67 +28,21 @@ const tools = createDockerSandboxTools({
18
28
  sandbox: sandbox.runtime,
19
29
  tools: ["exec_command", "read_file", "write_file", "list_files"],
20
30
  });
31
+ // Pass tools to new Agent({ id, model, tools }).
21
32
  ```
22
33
 
23
- `DockerSandboxClient` performs explicit infrastructure operations. Its constructor performs no I/O,
24
- and `createSandbox()` and `resumeSandbox()` never pull images. `DockerSandbox` owns the container and,
25
- for an ephemeral workspace, its Docker volume. Dispose it asynchronously or call `destroy()`.
26
-
27
- `stop()` preserves the container and workspace. `resumeSandbox({ id })` creates a fresh live handle for
28
- that container; workspace files persist, while the in-memory managed-process registry starts empty. A
29
- caller-owned `{ type: "docker-volume", name }` workspace is never deleted by the sandbox.
30
-
31
- Networking is explicit. Use `{ mode: "none" }` or `{ mode: "bridge", ports: [...] }`; published ports
32
- bind only to `127.0.0.1`. Runtime methods use object arguments, propagate abort signals, and expose
33
- command and process output as bytes. Tool wrappers decode UTF-8 strictly and return structured values.
34
+ ## What you get
34
35
 
35
- `exec_command` accepts a complete shell command line in `command`, including pipes, redirects, and
36
- multiline scripts. For exact argv execution without shell parsing, provide the executable in
37
- `command` and its arguments in `args`. Command policies apply to the implicit `sh` executable when a
38
- shell command line is used. Natural command lines are rejected with block-mode command policies
39
- because arbitrary shell syntax cannot be checked safely against an executable block list; use exact
40
- `command` and `args` input in that configuration.
36
+ - Command execution, file access, and managed processes.
37
+ - Ephemeral workspaces or caller-owned Docker volumes.
38
+ - Explicit networking, resource limits, and command policies.
39
+ - Stop/resume lifecycle and automatic disposal.
40
+ - Read-only sandbox inspection in Anvia Studio.
41
41
 
42
- File paths and command working directories passed to agent tools may be workspace-relative (for
43
- example `notes/result.txt`) or absolute paths inside the sandbox workdir (for example
44
- `/workspace/notes/result.txt` with the default workdir). Paths outside the sandbox workdir are
45
- rejected.
42
+ `await using` destroys the owned container and ephemeral volume at scope exit. Keep the scope open while agents use its tools. Command policies filter executable names; they do not restrict what an allowed interpreter can execute.
46
43
 
47
- With `exec.commands.mode: "allow"`, both `exec_command` and `start_process` reject known shell
48
- executables by default, including path-qualified names such as `/bin/sh`. To permit an allowlisted
49
- shell, set `exec.commands.allowShellInterpreters` to the boolean `true`. Omitted or `false` keeps the
50
- guard enabled; non-boolean values such as `"false"` are rejected when creating tools. This guard
51
- checks executable names only: allowlisted runtimes such as Node.js or Python can still launch other
52
- commands, so the command policy does not restrict what those programs can execute.
53
-
54
- `resources.sharedMemoryMb` maps to a private Docker `/dev/shm` size. A security configuration may use
55
- explicit `dropCapabilities` and `addCapabilities` arrays, plus
56
- `seccompProfile: { type: "path", path }` with an absolute host path. These options are used by
57
- `@anvia/browser` to keep Chromium's own process sandbox enabled.
58
-
59
- `createSandbox()` accepts `containerRuntime` — the runtime name registered in the Docker daemon (for
60
- example `runsc` for gVisor). The runtime must already be registered (`runsc install` followed by a
61
- daemon restart); creation fails with a `runtime_not_found` error otherwise. `resumeSandbox()` keeps
62
- the container's original runtime. Under gVisor, workspace files persist through
63
- `stop()`/`resumeSandbox()` because they live on a Docker volume, but changes to the container's
64
- writable rootfs outside the workspace do not survive a resume, and `security.seccompProfile` is not
65
- enforced the way it is on the default runtime because the gVisor sentry mediates application
66
- syscalls itself.
67
-
68
- Studio does not discover sandboxes through tool metadata. Register a read-only inspector explicitly:
69
-
70
- ```ts
71
- const studio = new Studio([agent], {
72
- sandboxes: [
73
- {
74
- inspector: sandbox.inspector({ files: true, ports: true, processes: true }),
75
- agentIds: [agent.id],
76
- toolNames: tools.map((tool) => tool.name),
77
- },
78
- ],
79
- });
80
- ```
44
+ ## Learn more
81
45
 
82
- The `anvia-sandbox create-image` CLI only builds images. It does not create, resume, stop, or destroy
83
- sandboxes. Its `playwright` feature remains a general code-sandbox image; the visible Chromium/CDP/
84
- noVNC appliance is source-controlled and owned by `@anvia/browser`.
46
+ - [Usage guide](https://github.com/anvia-hq/anvia/blob/main/docs/packages/tool-sandbox.md)
47
+ - [Anvia](https://github.com/anvia-hq/anvia/blob/main/README.md)
48
+ - [Contributing](https://github.com/anvia-hq/anvia/blob/main/CONTRIBUTING.md)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anvia/sandbox",
3
- "version": "1.1.7",
3
+ "version": "1.1.8",
4
4
  "description": "Sandboxed workspace tools for Anvia agents.",
5
5
  "author": "anvia",
6
6
  "license": "MIT",
@@ -36,10 +36,10 @@
36
36
  "tsup": "^8.5.0",
37
37
  "typescript": "^5.9.3",
38
38
  "vitest": "^4.1.11",
39
- "@anvia/core": "1.5.1"
39
+ "@anvia/core": "1.6.1"
40
40
  },
41
41
  "peerDependencies": {
42
- "@anvia/core": "^1.5.1"
42
+ "@anvia/core": "^1.6.1"
43
43
  },
44
44
  "engines": {
45
45
  "node": ">=20.12.0"