@agen-ai/sandbox 0.0.0-stage → 0.4.4
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/LICENSE +21 -0
- package/README.md +141 -2
- package/dist/acp/index.d.ts +9 -0
- package/dist/acp/index.js +25 -0
- package/dist/backend/contracts.d.ts +41 -0
- package/dist/backend/contracts.js +0 -0
- package/dist/backend/index.d.ts +6 -0
- package/dist/backend/index.js +64 -0
- package/dist/backend/spill.d.ts +15 -0
- package/dist/backend/spill.js +0 -0
- package/dist/contracts.d.ts +37 -0
- package/dist/contracts.js +0 -0
- package/dist/errors.d.ts +46 -0
- package/dist/errors.js +73 -0
- package/dist/files/bytes.d.ts +31 -0
- package/dist/files/bytes.js +134 -0
- package/dist/files/iterator.d.ts +13 -0
- package/dist/files/iterator.js +59 -0
- package/dist/files/metadata/index.d.ts +12 -0
- package/dist/files/metadata/index.js +193 -0
- package/dist/files/metadata/records.d.ts +21 -0
- package/dist/files/metadata/records.js +50 -0
- package/dist/files/metadata/sort.d.ts +13 -0
- package/dist/files/metadata/sort.js +63 -0
- package/dist/files/metadata/storage.d.ts +12 -0
- package/dist/files/metadata/storage.js +69 -0
- package/dist/files/metadata/types.d.ts +19 -0
- package/dist/files/metadata/types.js +0 -0
- package/dist/files/parse.d.ts +20 -0
- package/dist/files/parse.js +62 -0
- package/dist/files/pathSchemas.d.ts +5 -0
- package/dist/files/pathSchemas.js +16 -0
- package/dist/files/paths.d.ts +4 -0
- package/dist/files/paths.js +12 -0
- package/dist/files/quotas.d.ts +18 -0
- package/dist/files/quotas.js +37 -0
- package/dist/files/types.d.ts +81 -0
- package/dist/files/types.js +0 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.js +35 -0
- package/dist/internal/data.d.ts +6 -0
- package/dist/internal/data.js +68 -0
- package/dist/internal/operations.d.ts +4 -0
- package/dist/internal/operations.js +30 -0
- package/dist/internal/parse.d.ts +3 -0
- package/dist/internal/parse.js +12 -0
- package/dist/lifecycle/deadline.d.ts +3 -0
- package/dist/lifecycle/deadline.js +18 -0
- package/dist/lifecycle/journal.d.ts +14 -0
- package/dist/lifecycle/journal.js +51 -0
- package/dist/lifecycle/observation.d.ts +9 -0
- package/dist/lifecycle/observation.js +41 -0
- package/dist/lifecycle/owner.d.ts +38 -0
- package/dist/lifecycle/owner.js +288 -0
- package/dist/lifecycle/recovered.d.ts +16 -0
- package/dist/lifecycle/recovered.js +62 -0
- package/dist/lifecycle/recoveryIdentity.d.ts +3 -0
- package/dist/lifecycle/recoveryIdentity.js +18 -0
- package/dist/lifecycle/transfer.d.ts +10 -0
- package/dist/lifecycle/transfer.js +339 -0
- package/dist/node/directories/closing.d.ts +2 -0
- package/dist/node/directories/closing.js +19 -0
- package/dist/node/directories/export.d.ts +6 -0
- package/dist/node/directories/export.js +43 -0
- package/dist/node/directories/file.d.ts +26 -0
- package/dist/node/directories/file.js +104 -0
- package/dist/node/directories/import.d.ts +6 -0
- package/dist/node/directories/import.js +38 -0
- package/dist/node/directories/options.d.ts +4 -0
- package/dist/node/directories/options.js +10 -0
- package/dist/node/directories/ownership.d.ts +33 -0
- package/dist/node/directories/ownership.js +148 -0
- package/dist/node/directories/source.d.ts +25 -0
- package/dist/node/directories/source.js +143 -0
- package/dist/node/directories/stage.d.ts +43 -0
- package/dist/node/directories/stage.js +302 -0
- package/dist/node/directories/types.d.ts +23 -0
- package/dist/node/directories/types.js +17 -0
- package/dist/node/hostPath.d.ts +7 -0
- package/dist/node/hostPath.js +37 -0
- package/dist/node/index.d.ts +8 -0
- package/dist/node/index.js +14 -0
- package/dist/node/spill.d.ts +14 -0
- package/dist/node/spill.js +97 -0
- package/dist/node/spillDirectory.d.ts +4 -0
- package/dist/node/spillDirectory.js +17 -0
- package/dist/node/spillFile.d.ts +24 -0
- package/dist/node/spillFile.js +96 -0
- package/dist/policy/limits.d.ts +31 -0
- package/dist/policy/limits.js +35 -0
- package/dist/policy/parse.d.ts +11 -0
- package/dist/policy/parse.js +47 -0
- package/dist/policy/schemas.d.ts +148 -0
- package/dist/policy/schemas.js +75 -0
- package/dist/policy/types.d.ts +105 -0
- package/dist/policy/types.js +0 -0
- package/dist/process/input.d.ts +23 -0
- package/dist/process/input.js +93 -0
- package/dist/process/output.d.ts +13 -0
- package/dist/process/output.js +43 -0
- package/dist/process/parse.d.ts +4 -0
- package/dist/process/parse.js +32 -0
- package/dist/process/streams.d.ts +9 -0
- package/dist/process/streams.js +61 -0
- package/dist/process/types.d.ts +38 -0
- package/dist/process/types.js +0 -0
- package/dist/recovery/parse.d.ts +4 -0
- package/dist/recovery/parse.js +67 -0
- package/dist/recovery/types.d.ts +59 -0
- package/dist/recovery/types.js +0 -0
- package/dist/withSandbox.d.ts +4 -0
- package/dist/withSandbox.js +39 -0
- package/package.json +76 -3
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { SandboxRunError } from "./errors.js";
|
|
2
|
+
import { parseSandboxRunOptions } from "./internal/operations.js";
|
|
3
|
+
import { actualOperation, observe } from "./lifecycle/observation.js";
|
|
4
|
+
import { parseSandboxRequest } from "./policy/parse.js";
|
|
5
|
+
async function withSandbox(backend, request, use, options) {
|
|
6
|
+
const parsed = parseSandboxRunOptions(options);
|
|
7
|
+
const admitted = parseSandboxRequest(request);
|
|
8
|
+
if (typeof use !== "function") throw new TypeError("Sandbox use must be a function.");
|
|
9
|
+
const operation = parsed.signal === void 0 ? {} : { signal: parsed.signal };
|
|
10
|
+
const owner = backend.reserve(admitted, parsed.recovery);
|
|
11
|
+
let outcome;
|
|
12
|
+
try {
|
|
13
|
+
const sandbox = await owner.start(operation);
|
|
14
|
+
operation.signal?.throwIfAborted();
|
|
15
|
+
const actual = actualOperation(() => use(sandbox));
|
|
16
|
+
const execution = admitted.policy.execution;
|
|
17
|
+
const value = await observe(actual, execution.kind === "deadline" ? execution.timeoutMs : void 0, {
|
|
18
|
+
...operation,
|
|
19
|
+
onInterrupt: () => {
|
|
20
|
+
void owner.stop().catch(() => {
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
outcome = { kind: "returned", value };
|
|
25
|
+
} catch (error) {
|
|
26
|
+
outcome = { kind: "threw", error };
|
|
27
|
+
}
|
|
28
|
+
try {
|
|
29
|
+
await owner.destroy();
|
|
30
|
+
} catch (cleanupError) {
|
|
31
|
+
if (outcome.kind === "threw") throw new SandboxRunError({ primaryError: outcome.error, cleanupError, owner });
|
|
32
|
+
throw cleanupError;
|
|
33
|
+
}
|
|
34
|
+
if (outcome.kind === "threw") throw outcome.error;
|
|
35
|
+
return outcome.value;
|
|
36
|
+
}
|
|
37
|
+
export {
|
|
38
|
+
withSandbox
|
|
39
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,79 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agen-ai/sandbox",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"description": "
|
|
3
|
+
"version": "0.4.4",
|
|
4
|
+
"private": false,
|
|
5
|
+
"description": "Bounded provider-neutral sandbox ownership, processes, files and recovery contracts.",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"sideEffects": false,
|
|
8
|
+
"license": "MIT",
|
|
9
|
+
"main": "./dist/index.js",
|
|
10
|
+
"module": "./dist/index.js",
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"files": [
|
|
13
|
+
"dist/**/*.js",
|
|
14
|
+
"dist/**/*.d.ts",
|
|
15
|
+
"README.md",
|
|
16
|
+
"LICENSE"
|
|
17
|
+
],
|
|
18
|
+
"exports": {
|
|
19
|
+
".": {
|
|
20
|
+
"types": "./dist/index.d.ts",
|
|
21
|
+
"import": "./dist/index.js"
|
|
22
|
+
},
|
|
23
|
+
"./backend": {
|
|
24
|
+
"types": "./dist/backend/index.d.ts",
|
|
25
|
+
"import": "./dist/backend/index.js"
|
|
26
|
+
},
|
|
27
|
+
"./acp": {
|
|
28
|
+
"types": "./dist/acp/index.d.ts",
|
|
29
|
+
"import": "./dist/acp/index.js"
|
|
30
|
+
},
|
|
31
|
+
"./node": {
|
|
32
|
+
"types": "./dist/node/index.d.ts",
|
|
33
|
+
"import": "./dist/node/index.js"
|
|
34
|
+
},
|
|
35
|
+
"./package.json": "./package.json"
|
|
36
|
+
},
|
|
37
|
+
"dependencies": {
|
|
38
|
+
"zod": "4.4.3",
|
|
39
|
+
"@agen-ai/validation": "^0.4.4"
|
|
40
|
+
},
|
|
41
|
+
"devDependencies": {
|
|
42
|
+
"tsup": "^8.5.0",
|
|
43
|
+
"@agen-ai/agent-runtime": "^0.4.4",
|
|
44
|
+
"@agen-ai/provider-acp": "^0.4.4",
|
|
45
|
+
"@agen-ai/agent-protocol": "^0.4.4"
|
|
46
|
+
},
|
|
47
|
+
"peerDependencies": {
|
|
48
|
+
"@agen-ai/provider-acp": "^0.4.4"
|
|
49
|
+
},
|
|
50
|
+
"peerDependenciesMeta": {
|
|
51
|
+
"@agen-ai/provider-acp": {
|
|
52
|
+
"optional": true
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
"engines": {
|
|
56
|
+
"node": ">=22.0.0"
|
|
57
|
+
},
|
|
58
|
+
"repository": {
|
|
59
|
+
"type": "git",
|
|
60
|
+
"url": "git+https://github.com/trevor-nichols/agenai-agent-sdk.git",
|
|
61
|
+
"directory": "packages/sandbox"
|
|
62
|
+
},
|
|
63
|
+
"homepage": "https://github.com/trevor-nichols/agenai-agent-sdk#readme",
|
|
64
|
+
"bugs": {
|
|
65
|
+
"url": "https://github.com/trevor-nichols/agenai-agent-sdk/issues"
|
|
66
|
+
},
|
|
67
|
+
"publishConfig": {
|
|
68
|
+
"access": "public",
|
|
69
|
+
"provenance": true
|
|
70
|
+
},
|
|
71
|
+
"scripts": {
|
|
72
|
+
"build": "pnpm run clean && pnpm run build:runtime && pnpm run build:types",
|
|
73
|
+
"build:runtime": "tsup",
|
|
74
|
+
"build:types": "tsc --project tsconfig.json --emitDeclarationOnly --outDir dist",
|
|
75
|
+
"typecheck": "tsc --noEmit && tsc --project tsconfig.test.json --noEmit",
|
|
76
|
+
"test": "node --import tsx --test tests/*.test.ts",
|
|
77
|
+
"clean": "rimraf dist *.tsbuildinfo"
|
|
78
|
+
}
|
|
6
79
|
}
|