@nodetool-ai/server-feature-sandbox 0.0.0-stage → 0.8.9-bootstrap.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.
package/README.md CHANGED
@@ -1,3 +1,22 @@
1
- # Temporary Holding Version
1
+ # Sandbox feature
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Install this package explicitly alongside the minimal server and configure
4
+ `NODETOOL_FEATURES=code=@nodetool-ai/server-feature-sandbox`. It enables
5
+ `nodetool.code.Code` through the shared QuickJS WASM interpreter on an isolated
6
+ worker thread. It does not install agents, the full runtime, media codecs or
7
+ the sandbox compiler.
8
+
9
+ Buffered Code receives `inputs` and persistent invocation `state`, and returns
10
+ named results through `output` or `emit`. The existing legacy return contract
11
+ also works. Node timeout, response limits, secret scopes, logs and progress use
12
+ the stored node properties. `createSandboxFeature({ limits })` lets the host
13
+ configure memory and output ceilings.
14
+
15
+ Workspace access stays inside the authenticated run's workspace. Secret and
16
+ asset reads use the authenticated user's injected host callbacks. Host filesystem
17
+ access and private network access are unavailable in this adapter. Cancellation
18
+ terminates the worker, including CPU-bound code.
19
+
20
+ Streaming-input Code bodies and imported host or WASM capability modules still
21
+ require the full composition. The shared runtime accepts explicitly resolved
22
+ guest JavaScript modules without a compiler.
@@ -0,0 +1 @@
1
+ 2026-10-30T19:34:00.731Z
@@ -0,0 +1,12 @@
1
+ import type { SandboxModuleResolution } from "@nodetool-ai/protocol";
2
+ import type { SandboxLimits } from "@nodetool-ai/sandbox-runtime";
3
+ import type { ServerFeature } from "@nodetool-ai/server-features";
4
+ import type { MinimalFeatureHost } from "@nodetool-ai/server-minimal";
5
+ /** Explicitly installed QuickJS execution. Host JavaScript is never a fallback. */
6
+ export declare function createSandboxFeature(options?: {
7
+ readonly limits?: SandboxLimits;
8
+ readonly modules?: SandboxModuleResolution;
9
+ }): ServerFeature<MinimalFeatureHost>;
10
+ declare const _default: ServerFeature<MinimalFeatureHost>;
11
+ export default _default;
12
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AACrE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAEtE,mFAAmF;AACnF,wBAAgB,oBAAoB,CAClC,OAAO,GAAE;IACP,QAAQ,CAAC,MAAM,CAAC,EAAE,aAAa,CAAC;IAChC,QAAQ,CAAC,OAAO,CAAC,EAAE,uBAAuB,CAAC;CACvC,GACL,aAAa,CAAC,kBAAkB,CAAC,CAkHnC"}
package/dist/index.js ADDED
@@ -0,0 +1,104 @@
1
+ import { hasReturnStatement, wrapImplicitReturn, usesEmitOutputContract, normalizeCodeOutput } from "@nodetool-ai/protocol/code-body";
2
+ import { runInSandbox } from "@nodetool-ai/sandbox-runtime";
3
+ /** Explicitly installed QuickJS execution. Host JavaScript is never a fallback. */
4
+ export function createSandboxFeature(options = {}) {
5
+ return {
6
+ descriptor: {
7
+ id: "code",
8
+ apiVersion: 1,
9
+ requires: [],
10
+ capabilities: ["sandbox"],
11
+ nodeTypes: ["nodetool.code.Code"]
12
+ },
13
+ activate(host) {
14
+ host.execution.register({
15
+ dynamicOutputs: true,
16
+ type: {
17
+ nodeType: "nodetool.code.Code",
18
+ supportsDynamicInputs: true,
19
+ outputs: {},
20
+ descriptorDefaults: { input_mode: "buffered" }
21
+ },
22
+ create: (node, request) => {
23
+ const state = {};
24
+ return {
25
+ async process(inputs) {
26
+ if (typeof inputs.code !== "string") {
27
+ throw new Error("Code must be a JavaScript string");
28
+ }
29
+ const modern = usesEmitOutputContract(inputs.code);
30
+ const code = modern || hasReturnStatement(inputs.code)
31
+ ? inputs.code
32
+ : wrapImplicitReturn(inputs.code);
33
+ const declaredSecrets = Array.isArray(inputs.secrets)
34
+ ? inputs.secrets.filter((value) => typeof value === "string" && value.length > 0)
35
+ : [];
36
+ const timeoutSeconds = typeof inputs.timeout === "number" ? inputs.timeout : 30;
37
+ const maxResponseMB = typeof inputs.max_response_mb === "number"
38
+ ? inputs.max_response_mb
39
+ : 1;
40
+ const hostScope = options.limits?.secretScope;
41
+ const secretScope = hostScope == null
42
+ ? declaredSecrets.length > 0
43
+ ? declaredSecrets
44
+ : null
45
+ : declaredSecrets.length > 0
46
+ ? declaredSecrets.filter((name) => hostScope.includes(name))
47
+ : hostScope;
48
+ const requestedResponseBytes = maxResponseMB * 1024 * 1024;
49
+ const maxResponseBodyBytes = options.limits?.maxResponseBodyBytes === undefined
50
+ ? requestedResponseBytes
51
+ : Math.min(options.limits.maxResponseBodyBytes, requestedResponseBytes);
52
+ const result = await runInSandbox({
53
+ code,
54
+ modules: options.modules,
55
+ globals: { inputs, state },
56
+ signal: request.signal,
57
+ timeoutMs: timeoutSeconds > 0 ? timeoutSeconds * 1000 : undefined,
58
+ workspace: request.workspace,
59
+ getSecret: (name) => host.readSecret(request.userId, name),
60
+ readAsset: (reference) => host.readAsset(request.userId, reference),
61
+ limits: {
62
+ ...options.limits,
63
+ maxResponseBodyBytes,
64
+ secretScope
65
+ },
66
+ onLog: (level, content) => request.emit({
67
+ type: "log_update",
68
+ node_id: node.id,
69
+ node_name: "Code",
70
+ content,
71
+ severity: level === "error"
72
+ ? "error"
73
+ : level === "warn"
74
+ ? "warning"
75
+ : "info"
76
+ }),
77
+ onProgress: (progress, chunk) => request.emit({
78
+ type: "node_progress",
79
+ node_id: node.id,
80
+ progress,
81
+ total: 100,
82
+ chunk
83
+ })
84
+ });
85
+ if (!result.success) {
86
+ throw new Error(result.error ?? "Sandbox execution failed");
87
+ }
88
+ if (!modern) {
89
+ return normalizeCodeOutput(result.result);
90
+ }
91
+ const outputs = {};
92
+ for (const entry of result.emitted ?? []) {
93
+ outputs[entry.name] = entry.value;
94
+ }
95
+ return { ...outputs, ...result.outputs };
96
+ }
97
+ };
98
+ }
99
+ });
100
+ }
101
+ };
102
+ }
103
+ export default createSandboxFeature();
104
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,sBAAsB,EACtB,mBAAmB,EACpB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAM5D,mFAAmF;AACnF,MAAM,UAAU,oBAAoB,CAClC,OAAO,GAGH,EAAE;IAEN,OAAO;QACL,UAAU,EAAE;YACV,EAAE,EAAE,MAAM;YACV,UAAU,EAAE,CAAC;YACb,QAAQ,EAAE,EAAE;YACZ,YAAY,EAAE,CAAC,SAAS,CAAC;YACzB,SAAS,EAAE,CAAC,oBAAoB,CAAC;SAClC;QACD,QAAQ,CAAC,IAAI;YACX,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC;gBACtB,cAAc,EAAE,IAAI;gBACpB,IAAI,EAAE;oBACJ,QAAQ,EAAE,oBAAoB;oBAC9B,qBAAqB,EAAE,IAAI;oBAC3B,OAAO,EAAE,EAAE;oBACX,kBAAkB,EAAE,EAAE,UAAU,EAAE,UAAU,EAAE;iBAC/C;gBACD,MAAM,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE;oBACxB,MAAM,KAAK,GAA4B,EAAE,CAAC;oBAC1C,OAAO;wBACL,KAAK,CAAC,OAAO,CAAC,MAAM;4BAClB,IAAI,OAAO,MAAM,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;gCACpC,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;4BACtD,CAAC;4BACD,MAAM,MAAM,GAAG,sBAAsB,CAAC,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;oCACrB,OAAO,EAAE,IAAI,CAAC,EAAE;oCAChB,QAAQ;oCACR,KAAK,EAAE,GAAG;oCACV,KAAK;iCACN,CAAC;6BACL,CAAC,CAAC;4BACH,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;gCACpB,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,IAAI,0BAA0B,CAAC,CAAC;4BAC9D,CAAC;4BACD,IAAI,CAAC,MAAM,EAAE,CAAC;gCACZ,OAAO,mBAAmB,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;4BAC5C,CAAC;4BACD,MAAM,OAAO,GAA4B,EAAE,CAAC;4BAC5C,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,OAAO,IAAI,EAAE,EAAE,CAAC;gCACzC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC;4BACpC,CAAC;4BACD,OAAO,EAAE,GAAG,OAAO,EAAE,GAAG,MAAM,CAAC,OAAO,EAAE,CAAC;wBAC3C,CAAC;qBACF,CAAC;gBACJ,CAAC;aACF,CAAC,CAAC;QACL,CAAC;KACF,CAAC;AACJ,CAAC;AACD,eAAe,oBAAoB,EAAE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,63 @@
1
1
  {
2
2
  "name": "@nodetool-ai/server-feature-sandbox",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.8.9-bootstrap.0",
4
+ "description": "Explicit QuickJS sandbox feature for the minimal NodeTool server",
5
+ "type": "module",
6
+ "engines": {
7
+ "node": ">=22.0.0"
8
+ },
9
+ "main": "dist/index.js",
10
+ "types": "dist/index.d.ts",
11
+ "scripts": {
12
+ "build": "node ../../scripts/build-typescript-workspace.mjs",
13
+ "test": "node ../../scripts/run-vitest.mjs run",
14
+ "lint": "node ../../scripts/run-tsc.mjs --noEmit"
15
+ },
16
+ "dependencies": {
17
+ "@nodetool-ai/server-features": "0.8.9-bootstrap.0",
18
+ "@nodetool-ai/server-minimal": "0.8.9-bootstrap.0",
19
+ "@nodetool-ai/sandbox-runtime": "0.8.9-bootstrap.0",
20
+ "@nodetool-ai/protocol": "0.8.9-bootstrap.0"
21
+ },
22
+ "devDependencies": {
23
+ "typescript": "npm:@typescript/typescript6@6.0.2",
24
+ "vitest": "^5.0.1",
25
+ "@types/node": "^22.0.0",
26
+ "@nodetool-ai/nodes-core": "*"
27
+ },
28
+ "exports": {
29
+ ".": {
30
+ "nodetool-dev": "./src/index.ts",
31
+ "types": "./dist/index.d.ts",
32
+ "import": "./dist/index.js"
33
+ }
34
+ },
35
+ "license": "MIT",
36
+ "repository": {
37
+ "type": "git",
38
+ "url": "https://github.com/nodetool-ai/nodetool.git",
39
+ "directory": "packages/server-feature-sandbox"
40
+ },
41
+ "homepage": "https://nodetool.ai",
42
+ "bugs": {
43
+ "url": "https://github.com/nodetool-ai/nodetool/issues"
44
+ },
45
+ "publishConfig": {
46
+ "access": "public"
47
+ },
48
+ "files": [
49
+ "dist",
50
+ "README.md"
51
+ ],
52
+ "keywords": [
53
+ "nodetool",
54
+ "ai",
55
+ "workflow",
56
+ "workflow-automation",
57
+ "typescript",
58
+ "message-types",
59
+ "msgpack",
60
+ "protocol",
61
+ "websocket"
62
+ ]
63
+ }