@lite-agent/sandbox-anthropic 0.1.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.
@@ -0,0 +1,16 @@
1
+ import { Sandbox } from '@lite-agent/core';
2
+
3
+ interface SandboxRuntimeOptions {
4
+ allowedDomains?: string[];
5
+ deniedDomains?: string[];
6
+ allowWrite?: string[];
7
+ denyRead?: string[];
8
+ denyWrite?: string[];
9
+ /** If the OS sandbox can't initialize (no bubblewrap, native Windows, …): false (default) → degrade to noop; true → throw. */
10
+ requireSandbox?: boolean;
11
+ /** Called once when degrading to noop (requireSandbox=false and init failed). */
12
+ onUnavailable?: (err: Error) => void;
13
+ }
14
+ declare function sandboxRuntime(opts?: SandboxRuntimeOptions): Sandbox;
15
+
16
+ export { type SandboxRuntimeOptions, sandboxRuntime };
package/dist/index.js ADDED
@@ -0,0 +1,41 @@
1
+ // src/index.ts
2
+ import {
3
+ SandboxManager
4
+ } from "@anthropic-ai/sandbox-runtime";
5
+ function sandboxRuntime(opts = {}) {
6
+ const config = {
7
+ network: {
8
+ allowedDomains: opts.allowedDomains ?? [],
9
+ deniedDomains: opts.deniedDomains ?? []
10
+ },
11
+ filesystem: {
12
+ allowWrite: opts.allowWrite ?? ["."],
13
+ denyRead: opts.denyRead ?? ["~/.ssh", "~/.aws"],
14
+ denyWrite: opts.denyWrite ?? []
15
+ }
16
+ };
17
+ let ready;
18
+ let degraded = false;
19
+ return {
20
+ id: "sandbox-runtime",
21
+ async wrap(command) {
22
+ if (degraded) return command;
23
+ try {
24
+ ready ??= SandboxManager.initialize(config);
25
+ await ready;
26
+ } catch (err) {
27
+ if (opts.requireSandbox) throw err;
28
+ degraded = true;
29
+ opts.onUnavailable?.(err);
30
+ return command;
31
+ }
32
+ return SandboxManager.wrapWithSandbox(command);
33
+ },
34
+ dispose: async () => {
35
+ if (ready && !degraded) await SandboxManager.reset();
36
+ }
37
+ };
38
+ }
39
+ export {
40
+ sandboxRuntime
41
+ };
package/package.json ADDED
@@ -0,0 +1,53 @@
1
+ {
2
+ "name": "@lite-agent/sandbox-anthropic",
3
+ "version": "0.1.0",
4
+ "description": "OS-level Sandbox adapter for @lite-agent/core over @anthropic-ai/sandbox-runtime (Seatbelt / bubblewrap).",
5
+ "license": "ISC",
6
+ "type": "module",
7
+ "main": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/index.js"
13
+ }
14
+ },
15
+ "sideEffects": false,
16
+ "files": [
17
+ "dist"
18
+ ],
19
+ "engines": {
20
+ "node": ">=20"
21
+ },
22
+ "keywords": [
23
+ "agent",
24
+ "ai",
25
+ "llm",
26
+ "sandbox",
27
+ "seatbelt",
28
+ "bubblewrap"
29
+ ],
30
+ "repository": {
31
+ "type": "git",
32
+ "url": "git+https://github.com/NelsonYong/lite-agent.git",
33
+ "directory": "packages/sandbox-anthropic"
34
+ },
35
+ "publishConfig": {
36
+ "access": "public"
37
+ },
38
+ "scripts": {
39
+ "build": "tsup src/index.ts --format esm --dts --clean --tsconfig tsconfig.build.json",
40
+ "test": "vitest run",
41
+ "typecheck": "tsc --noEmit"
42
+ },
43
+ "dependencies": {
44
+ "@anthropic-ai/sandbox-runtime": "^0.0.55",
45
+ "@lite-agent/core": "workspace:*"
46
+ },
47
+ "devDependencies": {
48
+ "@types/node": "^25.5.0",
49
+ "tsup": "^8.3.0",
50
+ "typescript": "^6.0.2",
51
+ "vitest": "^2.1.0"
52
+ }
53
+ }