@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.
Files changed (113) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +141 -2
  3. package/dist/acp/index.d.ts +9 -0
  4. package/dist/acp/index.js +25 -0
  5. package/dist/backend/contracts.d.ts +41 -0
  6. package/dist/backend/contracts.js +0 -0
  7. package/dist/backend/index.d.ts +6 -0
  8. package/dist/backend/index.js +64 -0
  9. package/dist/backend/spill.d.ts +15 -0
  10. package/dist/backend/spill.js +0 -0
  11. package/dist/contracts.d.ts +37 -0
  12. package/dist/contracts.js +0 -0
  13. package/dist/errors.d.ts +46 -0
  14. package/dist/errors.js +73 -0
  15. package/dist/files/bytes.d.ts +31 -0
  16. package/dist/files/bytes.js +134 -0
  17. package/dist/files/iterator.d.ts +13 -0
  18. package/dist/files/iterator.js +59 -0
  19. package/dist/files/metadata/index.d.ts +12 -0
  20. package/dist/files/metadata/index.js +193 -0
  21. package/dist/files/metadata/records.d.ts +21 -0
  22. package/dist/files/metadata/records.js +50 -0
  23. package/dist/files/metadata/sort.d.ts +13 -0
  24. package/dist/files/metadata/sort.js +63 -0
  25. package/dist/files/metadata/storage.d.ts +12 -0
  26. package/dist/files/metadata/storage.js +69 -0
  27. package/dist/files/metadata/types.d.ts +19 -0
  28. package/dist/files/metadata/types.js +0 -0
  29. package/dist/files/parse.d.ts +20 -0
  30. package/dist/files/parse.js +62 -0
  31. package/dist/files/pathSchemas.d.ts +5 -0
  32. package/dist/files/pathSchemas.js +16 -0
  33. package/dist/files/paths.d.ts +4 -0
  34. package/dist/files/paths.js +12 -0
  35. package/dist/files/quotas.d.ts +18 -0
  36. package/dist/files/quotas.js +37 -0
  37. package/dist/files/types.d.ts +81 -0
  38. package/dist/files/types.js +0 -0
  39. package/dist/index.d.ts +15 -0
  40. package/dist/index.js +35 -0
  41. package/dist/internal/data.d.ts +6 -0
  42. package/dist/internal/data.js +68 -0
  43. package/dist/internal/operations.d.ts +4 -0
  44. package/dist/internal/operations.js +30 -0
  45. package/dist/internal/parse.d.ts +3 -0
  46. package/dist/internal/parse.js +12 -0
  47. package/dist/lifecycle/deadline.d.ts +3 -0
  48. package/dist/lifecycle/deadline.js +18 -0
  49. package/dist/lifecycle/journal.d.ts +14 -0
  50. package/dist/lifecycle/journal.js +51 -0
  51. package/dist/lifecycle/observation.d.ts +9 -0
  52. package/dist/lifecycle/observation.js +41 -0
  53. package/dist/lifecycle/owner.d.ts +38 -0
  54. package/dist/lifecycle/owner.js +288 -0
  55. package/dist/lifecycle/recovered.d.ts +16 -0
  56. package/dist/lifecycle/recovered.js +62 -0
  57. package/dist/lifecycle/recoveryIdentity.d.ts +3 -0
  58. package/dist/lifecycle/recoveryIdentity.js +18 -0
  59. package/dist/lifecycle/transfer.d.ts +10 -0
  60. package/dist/lifecycle/transfer.js +339 -0
  61. package/dist/node/directories/closing.d.ts +2 -0
  62. package/dist/node/directories/closing.js +19 -0
  63. package/dist/node/directories/export.d.ts +6 -0
  64. package/dist/node/directories/export.js +43 -0
  65. package/dist/node/directories/file.d.ts +26 -0
  66. package/dist/node/directories/file.js +104 -0
  67. package/dist/node/directories/import.d.ts +6 -0
  68. package/dist/node/directories/import.js +38 -0
  69. package/dist/node/directories/options.d.ts +4 -0
  70. package/dist/node/directories/options.js +10 -0
  71. package/dist/node/directories/ownership.d.ts +33 -0
  72. package/dist/node/directories/ownership.js +148 -0
  73. package/dist/node/directories/source.d.ts +25 -0
  74. package/dist/node/directories/source.js +143 -0
  75. package/dist/node/directories/stage.d.ts +43 -0
  76. package/dist/node/directories/stage.js +302 -0
  77. package/dist/node/directories/types.d.ts +23 -0
  78. package/dist/node/directories/types.js +17 -0
  79. package/dist/node/hostPath.d.ts +7 -0
  80. package/dist/node/hostPath.js +37 -0
  81. package/dist/node/index.d.ts +8 -0
  82. package/dist/node/index.js +14 -0
  83. package/dist/node/spill.d.ts +14 -0
  84. package/dist/node/spill.js +97 -0
  85. package/dist/node/spillDirectory.d.ts +4 -0
  86. package/dist/node/spillDirectory.js +17 -0
  87. package/dist/node/spillFile.d.ts +24 -0
  88. package/dist/node/spillFile.js +96 -0
  89. package/dist/policy/limits.d.ts +31 -0
  90. package/dist/policy/limits.js +35 -0
  91. package/dist/policy/parse.d.ts +11 -0
  92. package/dist/policy/parse.js +47 -0
  93. package/dist/policy/schemas.d.ts +148 -0
  94. package/dist/policy/schemas.js +75 -0
  95. package/dist/policy/types.d.ts +105 -0
  96. package/dist/policy/types.js +0 -0
  97. package/dist/process/input.d.ts +23 -0
  98. package/dist/process/input.js +93 -0
  99. package/dist/process/output.d.ts +13 -0
  100. package/dist/process/output.js +43 -0
  101. package/dist/process/parse.d.ts +4 -0
  102. package/dist/process/parse.js +32 -0
  103. package/dist/process/streams.d.ts +9 -0
  104. package/dist/process/streams.js +61 -0
  105. package/dist/process/types.d.ts +38 -0
  106. package/dist/process/types.js +0 -0
  107. package/dist/recovery/parse.d.ts +4 -0
  108. package/dist/recovery/parse.js +67 -0
  109. package/dist/recovery/types.d.ts +59 -0
  110. package/dist/recovery/types.js +0 -0
  111. package/dist/withSandbox.d.ts +4 -0
  112. package/dist/withSandbox.js +39 -0
  113. 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.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
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
  }