@nodetool-ai/sandbox-runtime 0.0.0-stage → 0.8.9-beta.1
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 +24 -2
- package/dist/.nodetool-build-stamp +1 -0
- package/dist/host-access-gate.d.ts +24 -0
- package/dist/host-access-gate.d.ts.map +1 -0
- package/dist/host-access-gate.js +31 -0
- package/dist/host-access-gate.js.map +1 -0
- package/dist/index.d.ts +32 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +318 -0
- package/dist/index.js.map +1 -0
- package/dist/js-sandbox-worker/engine.d.ts +4 -0
- package/dist/js-sandbox-worker/engine.d.ts.map +1 -0
- package/dist/js-sandbox-worker/engine.js +82 -0
- package/dist/js-sandbox-worker/engine.js.map +1 -0
- package/dist/js-sandbox-worker/host.d.ts +136 -0
- package/dist/js-sandbox-worker/host.d.ts.map +1 -0
- package/dist/js-sandbox-worker/host.js +482 -0
- package/dist/js-sandbox-worker/host.js.map +1 -0
- package/dist/js-sandbox-worker/interpreter.d.ts +276 -0
- package/dist/js-sandbox-worker/interpreter.d.ts.map +1 -0
- package/dist/js-sandbox-worker/interpreter.js +1318 -0
- package/dist/js-sandbox-worker/interpreter.js.map +1 -0
- package/dist/js-sandbox-worker/protocol.d.ts +168 -0
- package/dist/js-sandbox-worker/protocol.d.ts.map +1 -0
- package/dist/js-sandbox-worker/protocol.js +217 -0
- package/dist/js-sandbox-worker/protocol.js.map +1 -0
- package/dist/js-sandbox-worker/worker-entry.d.ts +26 -0
- package/dist/js-sandbox-worker/worker-entry.d.ts.map +1 -0
- package/dist/js-sandbox-worker/worker-entry.js +308 -0
- package/dist/js-sandbox-worker/worker-entry.js.map +1 -0
- package/dist/limits.d.ts +77 -0
- package/dist/limits.d.ts.map +1 -0
- package/dist/limits.js +56 -0
- package/dist/limits.js.map +1 -0
- package/dist/sandbox-bootstrap-modules.d.ts +54 -0
- package/dist/sandbox-bootstrap-modules.d.ts.map +1 -0
- package/dist/sandbox-bootstrap-modules.js +104 -0
- package/dist/sandbox-bootstrap-modules.js.map +1 -0
- package/dist/sandbox-bytes.d.ts +43 -0
- package/dist/sandbox-bytes.d.ts.map +1 -0
- package/dist/sandbox-bytes.js +61 -0
- package/dist/sandbox-bytes.js.map +1 -0
- package/dist/sandbox-canvas-api.d.ts +30 -0
- package/dist/sandbox-canvas-api.d.ts.map +1 -0
- package/dist/sandbox-canvas-api.js +81 -0
- package/dist/sandbox-canvas-api.js.map +1 -0
- package/dist/sandbox-constants.d.ts +5 -0
- package/dist/sandbox-constants.d.ts.map +1 -0
- package/dist/sandbox-constants.js +13 -0
- package/dist/sandbox-constants.js.map +1 -0
- package/dist/sandbox-json-transport.d.ts +107 -0
- package/dist/sandbox-json-transport.d.ts.map +1 -0
- package/dist/sandbox-json-transport.js +324 -0
- package/dist/sandbox-json-transport.js.map +1 -0
- package/dist/timeline-capture.d.ts +21 -0
- package/dist/timeline-capture.d.ts.map +1 -0
- package/dist/timeline-capture.js +564 -0
- package/dist/timeline-capture.js.map +1 -0
- package/dist/utils/type-guards.d.ts +26 -0
- package/dist/utils/type-guards.d.ts.map +1 -0
- package/dist/utils/type-guards.js +44 -0
- package/dist/utils/type-guards.js.map +1 -0
- package/package.json +138 -4
- package/vendor/README.md +17 -0
- package/vendor/quickjs/LICENSE +21 -0
- package/vendor/quickjs/PROVENANCE.json +8 -0
- package/vendor/quickjs/adapter/fetch.d.ts +56 -0
- package/vendor/quickjs/adapter/fetch.js +140 -0
- package/vendor/quickjs/createTimeInterval.d.ts +9 -0
- package/vendor/quickjs/createTimeInterval.js +22 -0
- package/vendor/quickjs/createVirtualFileSystem.d.ts +13 -0
- package/vendor/quickjs/createVirtualFileSystem.js +191 -0
- package/vendor/quickjs/index.d.ts +77 -0
- package/vendor/quickjs/index.js +77 -0
- package/vendor/quickjs/loadAsyncQuickJs.d.ts +12 -0
- package/vendor/quickjs/loadAsyncQuickJs.js +66 -0
- package/vendor/quickjs/loadQuickJs.d.ts +12 -0
- package/vendor/quickjs/loadQuickJs.js +73 -0
- package/vendor/quickjs/modules/assert.d.ts +2 -0
- package/vendor/quickjs/modules/assert.js +47 -0
- package/vendor/quickjs/modules/buffer.d.ts +2 -0
- package/vendor/quickjs/modules/buffer.js +106 -0
- package/vendor/quickjs/modules/build/test-lib.js +2 -0
- package/vendor/quickjs/modules/events.d.ts +2 -0
- package/vendor/quickjs/modules/events.js +4 -0
- package/vendor/quickjs/modules/fs.d.ts +2 -0
- package/vendor/quickjs/modules/fs.js +76 -0
- package/vendor/quickjs/modules/fs_promises.d.ts +2 -0
- package/vendor/quickjs/modules/fs_promises.js +328 -0
- package/vendor/quickjs/modules/module.d.ts +2 -0
- package/vendor/quickjs/modules/module.js +33 -0
- package/vendor/quickjs/modules/nodeCompatibility/headers.d.ts +2 -0
- package/vendor/quickjs/modules/nodeCompatibility/headers.js +58 -0
- package/vendor/quickjs/modules/nodeCompatibility/request.d.ts +2 -0
- package/vendor/quickjs/modules/nodeCompatibility/request.js +5 -0
- package/vendor/quickjs/modules/nodeCompatibility/response.d.ts +2 -0
- package/vendor/quickjs/modules/nodeCompatibility/response.js +5 -0
- package/vendor/quickjs/modules/path.d.ts +2 -0
- package/vendor/quickjs/modules/path.js +504 -0
- package/vendor/quickjs/modules/process.d.ts +2 -0
- package/vendor/quickjs/modules/process.js +309 -0
- package/vendor/quickjs/modules/punycode.d.ts +2 -0
- package/vendor/quickjs/modules/punycode.js +443 -0
- package/vendor/quickjs/modules/querystring.d.ts +2 -0
- package/vendor/quickjs/modules/querystring.js +15 -0
- package/vendor/quickjs/modules/string_decoder.d.ts +2 -0
- package/vendor/quickjs/modules/string_decoder.js +223 -0
- package/vendor/quickjs/modules/timers.d.ts +2 -0
- package/vendor/quickjs/modules/timers.js +10 -0
- package/vendor/quickjs/modules/timers_promises.d.ts +2 -0
- package/vendor/quickjs/modules/timers_promises.js +40 -0
- package/vendor/quickjs/modules/url.d.ts +2 -0
- package/vendor/quickjs/modules/url.js +104 -0
- package/vendor/quickjs/modules/util.d.ts +2 -0
- package/vendor/quickjs/modules/util.js +233 -0
- package/vendor/quickjs/package.json +3 -0
- package/vendor/quickjs/sandbox/asyncVersion/createAsyncEvalCodeFunction.d.ts +4 -0
- package/vendor/quickjs/sandbox/asyncVersion/createAsyncEvalCodeFunction.js +76 -0
- package/vendor/quickjs/sandbox/asyncVersion/createAsyncValidateCodeFunction.d.ts +3 -0
- package/vendor/quickjs/sandbox/asyncVersion/createAsyncValidateCodeFunction.js +22 -0
- package/vendor/quickjs/sandbox/asyncVersion/executeAsyncSandboxFunction.d.ts +12 -0
- package/vendor/quickjs/sandbox/asyncVersion/executeAsyncSandboxFunction.js +9 -0
- package/vendor/quickjs/sandbox/asyncVersion/getAsyncModuleLoader.d.ts +4 -0
- package/vendor/quickjs/sandbox/asyncVersion/getAsyncModuleLoader.js +30 -0
- package/vendor/quickjs/sandbox/asyncVersion/modulePathNormalizerAsync.d.ts +2 -0
- package/vendor/quickjs/sandbox/asyncVersion/modulePathNormalizerAsync.js +12 -0
- package/vendor/quickjs/sandbox/asyncVersion/prepareAsyncNodeCompatibility.d.ts +3 -0
- package/vendor/quickjs/sandbox/asyncVersion/prepareAsyncNodeCompatibility.js +11 -0
- package/vendor/quickjs/sandbox/asyncVersion/prepareAsyncSandbox.d.ts +4 -0
- package/vendor/quickjs/sandbox/asyncVersion/prepareAsyncSandbox.js +10 -0
- package/vendor/quickjs/sandbox/expose/expose.d.ts +3 -0
- package/vendor/quickjs/sandbox/expose/expose.js +155 -0
- package/vendor/quickjs/sandbox/expose/isES2015Class.d.ts +1 -0
- package/vendor/quickjs/sandbox/expose/isES2015Class.js +4 -0
- package/vendor/quickjs/sandbox/expose/isObject.d.ts +1 -0
- package/vendor/quickjs/sandbox/expose/isObject.js +4 -0
- package/vendor/quickjs/sandbox/expose/pendingHostPromises.d.ts +6 -0
- package/vendor/quickjs/sandbox/expose/pendingHostPromises.js +40 -0
- package/vendor/quickjs/sandbox/getMaxIntervalAmount.d.ts +8 -0
- package/vendor/quickjs/sandbox/getMaxIntervalAmount.js +12 -0
- package/vendor/quickjs/sandbox/getMaxTimeoutAmount.d.ts +8 -0
- package/vendor/quickjs/sandbox/getMaxTimeoutAmount.js +12 -0
- package/vendor/quickjs/sandbox/handleEvalError.d.ts +2 -0
- package/vendor/quickjs/sandbox/handleEvalError.js +21 -0
- package/vendor/quickjs/sandbox/handleToNative/handleToNative.d.ts +9 -0
- package/vendor/quickjs/sandbox/handleToNative/handleToNative.js +153 -0
- package/vendor/quickjs/sandbox/handleToNative/serializer/index.d.ts +10 -0
- package/vendor/quickjs/sandbox/handleToNative/serializer/index.js +36 -0
- package/vendor/quickjs/sandbox/handleToNative/serializer/serializeArrayBuffer.d.ts +2 -0
- package/vendor/quickjs/sandbox/handleToNative/serializer/serializeArrayBuffer.js +4 -0
- package/vendor/quickjs/sandbox/handleToNative/serializer/serializeBuffer.d.ts +2 -0
- package/vendor/quickjs/sandbox/handleToNative/serializer/serializeBuffer.js +16 -0
- package/vendor/quickjs/sandbox/handleToNative/serializer/serializeDate.d.ts +2 -0
- package/vendor/quickjs/sandbox/handleToNative/serializer/serializeDate.js +16 -0
- package/vendor/quickjs/sandbox/handleToNative/serializer/serializeError.d.ts +2 -0
- package/vendor/quickjs/sandbox/handleToNative/serializer/serializeError.js +18 -0
- package/vendor/quickjs/sandbox/handleToNative/serializer/serializeHeaders.d.ts +2 -0
- package/vendor/quickjs/sandbox/handleToNative/serializer/serializeHeaders.js +17 -0
- package/vendor/quickjs/sandbox/handleToNative/serializer/serializeMap.d.ts +2 -0
- package/vendor/quickjs/sandbox/handleToNative/serializer/serializeMap.js +18 -0
- package/vendor/quickjs/sandbox/handleToNative/serializer/serializeSet.d.ts +2 -0
- package/vendor/quickjs/sandbox/handleToNative/serializer/serializeSet.js +16 -0
- package/vendor/quickjs/sandbox/handleToNative/serializer/serializeURLSearchParams.d.ts +2 -0
- package/vendor/quickjs/sandbox/handleToNative/serializer/serializeURLSearchParams.js +17 -0
- package/vendor/quickjs/sandbox/handleToNative/serializer/serializeUrl.d.ts +2 -0
- package/vendor/quickjs/sandbox/handleToNative/serializer/serializeUrl.js +17 -0
- package/vendor/quickjs/sandbox/helper.d.ts +2 -0
- package/vendor/quickjs/sandbox/helper.js +14 -0
- package/vendor/quickjs/sandbox/provide/provideConsole.d.ts +6 -0
- package/vendor/quickjs/sandbox/provide/provideConsole.js +53 -0
- package/vendor/quickjs/sandbox/provide/provideEnv.d.ts +3 -0
- package/vendor/quickjs/sandbox/provide/provideEnv.js +10 -0
- package/vendor/quickjs/sandbox/provide/provideFs.d.ts +4 -0
- package/vendor/quickjs/sandbox/provide/provideFs.js +159 -0
- package/vendor/quickjs/sandbox/provide/provideHttp.d.ts +9 -0
- package/vendor/quickjs/sandbox/provide/provideHttp.js +42 -0
- package/vendor/quickjs/sandbox/provide/provideTimingFunctions.d.ts +7 -0
- package/vendor/quickjs/sandbox/provide/provideTimingFunctions.js +119 -0
- package/vendor/quickjs/sandbox/setupFileSystem.d.ts +3 -0
- package/vendor/quickjs/sandbox/setupFileSystem.js +13 -0
- package/vendor/quickjs/sandbox/syncVersion/createEvalCodeFunction.d.ts +4 -0
- package/vendor/quickjs/sandbox/syncVersion/createEvalCodeFunction.js +76 -0
- package/vendor/quickjs/sandbox/syncVersion/createValidateCodeFunction.d.ts +3 -0
- package/vendor/quickjs/sandbox/syncVersion/createValidateCodeFunction.js +22 -0
- package/vendor/quickjs/sandbox/syncVersion/executeSandboxFunction.d.ts +12 -0
- package/vendor/quickjs/sandbox/syncVersion/executeSandboxFunction.js +9 -0
- package/vendor/quickjs/sandbox/syncVersion/getModuleLoader.d.ts +4 -0
- package/vendor/quickjs/sandbox/syncVersion/getModuleLoader.js +30 -0
- package/vendor/quickjs/sandbox/syncVersion/modulePathNormalizer.d.ts +2 -0
- package/vendor/quickjs/sandbox/syncVersion/modulePathNormalizer.js +12 -0
- package/vendor/quickjs/sandbox/syncVersion/prepareNodeCompatibility.d.ts +3 -0
- package/vendor/quickjs/sandbox/syncVersion/prepareNodeCompatibility.js +11 -0
- package/vendor/quickjs/sandbox/syncVersion/prepareSandbox.d.ts +4 -0
- package/vendor/quickjs/sandbox/syncVersion/prepareSandbox.js +10 -0
- package/vendor/quickjs/types/CodeFunctionInput.d.ts +12 -0
- package/vendor/quickjs/types/CodeFunctionInput.js +1 -0
- package/vendor/quickjs/types/ErrorResponse.d.ts +9 -0
- package/vendor/quickjs/types/ErrorResponse.js +1 -0
- package/vendor/quickjs/types/LoadQuickJsOptions.d.ts +3 -0
- package/vendor/quickjs/types/LoadQuickJsOptions.js +1 -0
- package/vendor/quickjs/types/OkResponse.d.ts +4 -0
- package/vendor/quickjs/types/OkResponse.js +1 -0
- package/vendor/quickjs/types/OkResponseCheck.d.ts +3 -0
- package/vendor/quickjs/types/OkResponseCheck.js +1 -0
- package/vendor/quickjs/types/Prettify.d.ts +3 -0
- package/vendor/quickjs/types/Prettify.js +1 -0
- package/vendor/quickjs/types/RuntimeOptions.d.ts +87 -0
- package/vendor/quickjs/types/RuntimeOptions.js +1 -0
- package/vendor/quickjs/types/SandboxEvalCode.d.ts +5 -0
- package/vendor/quickjs/types/SandboxEvalCode.js +1 -0
- package/vendor/quickjs/types/SandboxFunction.d.ts +16 -0
- package/vendor/quickjs/types/SandboxFunction.js +1 -0
- package/vendor/quickjs/types/SandboxOptions.d.ts +152 -0
- package/vendor/quickjs/types/SandboxOptions.js +1 -0
- package/vendor/quickjs/types/SandboxValidateCode.d.ts +9 -0
- package/vendor/quickjs/types/SandboxValidateCode.js +1 -0
- package/vendor/quickjs/types/Serializer.d.ts +2 -0
- package/vendor/quickjs/types/Serializer.js +1 -0
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Named predicates for the shapes this package reads off its untrusted
|
|
3
|
+
* boundaries: QuickJS guest results, tool call arguments, model output, and
|
|
4
|
+
* media refs. Each one is the check the call sites used to inline, so the
|
|
5
|
+
* leniency of a boundary stays exactly where it was — a value that passed
|
|
6
|
+
* before passes now.
|
|
7
|
+
*/
|
|
8
|
+
export function isString(value) {
|
|
9
|
+
return typeof value === "string";
|
|
10
|
+
}
|
|
11
|
+
/** A string with at least one character. */
|
|
12
|
+
export function isNonEmptyString(value) {
|
|
13
|
+
return typeof value === "string" && value !== "";
|
|
14
|
+
}
|
|
15
|
+
/** A string that holds something other than whitespace. */
|
|
16
|
+
export function isNonBlankString(value) {
|
|
17
|
+
return typeof value === "string" && value.trim() !== "";
|
|
18
|
+
}
|
|
19
|
+
export function isNumber(value) {
|
|
20
|
+
return typeof value === "number";
|
|
21
|
+
}
|
|
22
|
+
/** A number that is neither `NaN` nor an infinity. */
|
|
23
|
+
export function isFiniteNumber(value) {
|
|
24
|
+
return typeof value === "number" && Number.isFinite(value);
|
|
25
|
+
}
|
|
26
|
+
export function isBoolean(value) {
|
|
27
|
+
return typeof value === "boolean";
|
|
28
|
+
}
|
|
29
|
+
export function isFunction(value) {
|
|
30
|
+
return typeof value === "function";
|
|
31
|
+
}
|
|
32
|
+
/** A keyed object — never `null`, never an array. */
|
|
33
|
+
export function isRecord(value) {
|
|
34
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Anything `typeof` calls an object, `null` aside — an array passes. The
|
|
38
|
+
* looser sibling of {@link isRecord}, kept apart because the boundaries that
|
|
39
|
+
* accept an array here must keep accepting it.
|
|
40
|
+
*/
|
|
41
|
+
export function isObjectLike(value) {
|
|
42
|
+
return value !== null && typeof value === "object";
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=type-guards.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type-guards.js","sourceRoot":"","sources":["../../src/utils/type-guards.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,MAAM,UAAU,QAAQ,CAAC,KAAc;IACrC,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC;AACnC,CAAC;AAED,4CAA4C;AAC5C,MAAM,UAAU,gBAAgB,CAAC,KAAc;IAC7C,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,EAAE,CAAC;AACnD,CAAC;AAED,2DAA2D;AAC3D,MAAM,UAAU,gBAAgB,CAAC,KAAc;IAC7C,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC;AAC1D,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,KAAc;IACrC,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC;AACnC,CAAC;AAED,sDAAsD;AACtD,MAAM,UAAU,cAAc,CAAC,KAAc;IAC3C,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AAC7D,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,KAAc;IACtC,OAAO,OAAO,KAAK,KAAK,SAAS,CAAC;AACpC,CAAC;AAED,MAAM,UAAU,UAAU,CACxB,KAAc;IAEd,OAAO,OAAO,KAAK,KAAK,UAAU,CAAC;AACrC,CAAC;AAED,qDAAqD;AACrD,MAAM,UAAU,QAAQ,CAAC,KAAc;IACrC,OAAO,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAC,KAAc;IACzC,OAAO,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,CAAC;AACrD,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,140 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nodetool-ai/sandbox-runtime",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.8.9-beta.1",
|
|
4
|
+
"description": "Shared QuickJS interpreter, worker isolation and lean host bridges",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"engines": {
|
|
7
|
+
"node": "24.22.1"
|
|
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/config": "0.8.9-beta.1",
|
|
18
|
+
"@nodetool-ai/protocol": "0.8.9-beta.1",
|
|
19
|
+
"@nodetool-ai/runtime-core": "0.8.9-beta.1",
|
|
20
|
+
"@jitl/quickjs-ng-wasmfile-release-sync": "^0.31.0",
|
|
21
|
+
"quickjs-emscripten-core": "^0.31.0",
|
|
22
|
+
"acorn": "^8.15.0",
|
|
23
|
+
"eslint-scope": "^8.4.0",
|
|
24
|
+
"memfs": "^4.56.10",
|
|
25
|
+
"rate-limiter-flexible": "^9.1.1"
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"typescript": "npm:@typescript/typescript6@6.0.2",
|
|
29
|
+
"vitest": "^5.0.1",
|
|
30
|
+
"@types/node": "^22.0.0",
|
|
31
|
+
"@types/eslint-scope": "^3.7.7",
|
|
32
|
+
"@sebastianwessel/quickjs": "3.0.1"
|
|
33
|
+
},
|
|
34
|
+
"exports": {
|
|
35
|
+
".": {
|
|
36
|
+
"nodetool-dev": "./src/index.ts",
|
|
37
|
+
"types": "./dist/index.d.ts",
|
|
38
|
+
"import": "./dist/index.js"
|
|
39
|
+
},
|
|
40
|
+
"./js-sandbox-worker/engine": {
|
|
41
|
+
"nodetool-dev": "./src/js-sandbox-worker/engine.ts",
|
|
42
|
+
"types": "./dist/js-sandbox-worker/engine.d.ts",
|
|
43
|
+
"import": "./dist/js-sandbox-worker/engine.js"
|
|
44
|
+
},
|
|
45
|
+
"./js-sandbox-worker/interpreter": {
|
|
46
|
+
"nodetool-dev": "./src/js-sandbox-worker/interpreter.ts",
|
|
47
|
+
"types": "./dist/js-sandbox-worker/interpreter.d.ts",
|
|
48
|
+
"import": "./dist/js-sandbox-worker/interpreter.js"
|
|
49
|
+
},
|
|
50
|
+
"./js-sandbox-worker/host": {
|
|
51
|
+
"nodetool-dev": "./src/js-sandbox-worker/host.ts",
|
|
52
|
+
"types": "./dist/js-sandbox-worker/host.d.ts",
|
|
53
|
+
"import": "./dist/js-sandbox-worker/host.js"
|
|
54
|
+
},
|
|
55
|
+
"./js-sandbox-worker/protocol": {
|
|
56
|
+
"nodetool-dev": "./src/js-sandbox-worker/protocol.ts",
|
|
57
|
+
"types": "./dist/js-sandbox-worker/protocol.d.ts",
|
|
58
|
+
"import": "./dist/js-sandbox-worker/protocol.js"
|
|
59
|
+
},
|
|
60
|
+
"./js-sandbox-worker/worker-entry": {
|
|
61
|
+
"nodetool-dev": "./src/js-sandbox-worker/worker-entry.ts",
|
|
62
|
+
"types": "./dist/js-sandbox-worker/worker-entry.d.ts",
|
|
63
|
+
"import": "./dist/js-sandbox-worker/worker-entry.js"
|
|
64
|
+
},
|
|
65
|
+
"./sandbox-canvas-api": {
|
|
66
|
+
"nodetool-dev": "./src/sandbox-canvas-api.ts",
|
|
67
|
+
"types": "./dist/sandbox-canvas-api.d.ts",
|
|
68
|
+
"import": "./dist/sandbox-canvas-api.js"
|
|
69
|
+
},
|
|
70
|
+
"./sandbox-bytes": {
|
|
71
|
+
"nodetool-dev": "./src/sandbox-bytes.ts",
|
|
72
|
+
"types": "./dist/sandbox-bytes.d.ts",
|
|
73
|
+
"import": "./dist/sandbox-bytes.js"
|
|
74
|
+
},
|
|
75
|
+
"./sandbox-constants": {
|
|
76
|
+
"nodetool-dev": "./src/sandbox-constants.ts",
|
|
77
|
+
"types": "./dist/sandbox-constants.d.ts",
|
|
78
|
+
"import": "./dist/sandbox-constants.js"
|
|
79
|
+
},
|
|
80
|
+
"./sandbox-bootstrap-modules": {
|
|
81
|
+
"nodetool-dev": "./src/sandbox-bootstrap-modules.ts",
|
|
82
|
+
"types": "./dist/sandbox-bootstrap-modules.d.ts",
|
|
83
|
+
"import": "./dist/sandbox-bootstrap-modules.js"
|
|
84
|
+
},
|
|
85
|
+
"./sandbox-json-transport": {
|
|
86
|
+
"nodetool-dev": "./src/sandbox-json-transport.ts",
|
|
87
|
+
"types": "./dist/sandbox-json-transport.d.ts",
|
|
88
|
+
"import": "./dist/sandbox-json-transport.js"
|
|
89
|
+
},
|
|
90
|
+
"./timeline-capture": {
|
|
91
|
+
"nodetool-dev": "./src/timeline-capture.ts",
|
|
92
|
+
"types": "./dist/timeline-capture.d.ts",
|
|
93
|
+
"import": "./dist/timeline-capture.js"
|
|
94
|
+
},
|
|
95
|
+
"./utils/type-guards": {
|
|
96
|
+
"nodetool-dev": "./src/utils/type-guards.ts",
|
|
97
|
+
"types": "./dist/utils/type-guards.d.ts",
|
|
98
|
+
"import": "./dist/utils/type-guards.js"
|
|
99
|
+
},
|
|
100
|
+
"./host-access-gate": {
|
|
101
|
+
"nodetool-dev": "./src/host-access-gate.ts",
|
|
102
|
+
"types": "./dist/host-access-gate.d.ts",
|
|
103
|
+
"import": "./dist/host-access-gate.js"
|
|
104
|
+
},
|
|
105
|
+
"./limits": {
|
|
106
|
+
"nodetool-dev": "./src/limits.ts",
|
|
107
|
+
"types": "./dist/limits.d.ts",
|
|
108
|
+
"import": "./dist/limits.js"
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
"license": "MIT",
|
|
112
|
+
"repository": {
|
|
113
|
+
"type": "git",
|
|
114
|
+
"url": "https://github.com/nodetool-ai/nodetool.git",
|
|
115
|
+
"directory": "packages/sandbox-runtime"
|
|
116
|
+
},
|
|
117
|
+
"homepage": "https://nodetool.ai",
|
|
118
|
+
"bugs": {
|
|
119
|
+
"url": "https://github.com/nodetool-ai/nodetool/issues"
|
|
120
|
+
},
|
|
121
|
+
"publishConfig": {
|
|
122
|
+
"access": "public"
|
|
123
|
+
},
|
|
124
|
+
"files": [
|
|
125
|
+
"dist",
|
|
126
|
+
"README.md",
|
|
127
|
+
"vendor"
|
|
128
|
+
],
|
|
129
|
+
"keywords": [
|
|
130
|
+
"nodetool",
|
|
131
|
+
"ai",
|
|
132
|
+
"workflow",
|
|
133
|
+
"workflow-automation",
|
|
134
|
+
"typescript",
|
|
135
|
+
"message-types",
|
|
136
|
+
"msgpack",
|
|
137
|
+
"protocol",
|
|
138
|
+
"websocket"
|
|
139
|
+
]
|
|
140
|
+
}
|
package/vendor/README.md
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# QuickJS JavaScript profile
|
|
2
|
+
|
|
3
|
+
`quickjs/` contains the ESM distribution of `@sebastianwessel/quickjs@3.0.1`.
|
|
4
|
+
Its upstream license is preserved in `quickjs/LICENSE`.
|
|
5
|
+
|
|
6
|
+
NodeTool uses the JavaScript execution path. This copy removes the unused
|
|
7
|
+
TypeScript transform helper, its public export, and the compiler options from
|
|
8
|
+
both sandbox option declarations. The two engine loaders use the same identity
|
|
9
|
+
transform as upstream's disabled TypeScript path. The virtual filesystem,
|
|
10
|
+
module loader, WASM engine, host bridges, scheduling, and disposal stay upstream.
|
|
11
|
+
TypeScript compilation remains in `@nodetool-ai/sandbox-compiler`.
|
|
12
|
+
|
|
13
|
+
To refresh from an unpacked npm artifact, run
|
|
14
|
+
`node scripts/vendor-quickjs-javascript.mjs /path/to/package` from the repository
|
|
15
|
+
root. The script checks the upstream package name and version and fails when a
|
|
16
|
+
patch target changes. Review the generated diff and run the packed sandbox
|
|
17
|
+
consumer regression before accepting an update.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Sebastian Wessel
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@sebastianwessel/quickjs",
|
|
3
|
+
"version": "3.0.1",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"npmIntegrity": "sha512-9pKTzjtsHIBxokMhYgNPyqvBSpX9WLus5j+cqspB2VHOKbC0L45NQiVQhbEiaWXEyBtxd3W8MLnvlxvtBLo0Ew==",
|
|
6
|
+
"esmAndLicenseSha256": "3537d085ff5f01fb797945cbf25fd8b6a32901b3c6a73bcddfb9d68303dc0ed5",
|
|
7
|
+
"generator": "scripts/vendor-quickjs-javascript.mjs"
|
|
8
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { IFs } from 'memfs';
|
|
2
|
+
declare const HEADERS_MARKER = "__quickjsHeadersObject__";
|
|
3
|
+
/**
|
|
4
|
+
* Options for creating the default fetch adapter
|
|
5
|
+
*/
|
|
6
|
+
export type GetFetchAdapterOptions = {
|
|
7
|
+
/**
|
|
8
|
+
* The virtual file system of the sandbox (excludes node_modules)
|
|
9
|
+
*/
|
|
10
|
+
fs?: IFs;
|
|
11
|
+
/**
|
|
12
|
+
* List of allowed hosts. If set, only these hosts are allowed to call
|
|
13
|
+
*/
|
|
14
|
+
allowedHosts?: string[];
|
|
15
|
+
/**
|
|
16
|
+
* List of allowed protocols. If set, only these protocols are allowed to call
|
|
17
|
+
*/
|
|
18
|
+
allowedProtocols?: string[];
|
|
19
|
+
/**
|
|
20
|
+
* List of disallowed hosts. If set, these hosts are not allowed to call
|
|
21
|
+
* @default ['localhost', '127.0.0.1']
|
|
22
|
+
*/
|
|
23
|
+
disallowedHosts?: string[];
|
|
24
|
+
/**
|
|
25
|
+
* Timeout for fetch requests in milliseconds
|
|
26
|
+
* @default 5000
|
|
27
|
+
*/
|
|
28
|
+
timeout?: number;
|
|
29
|
+
/**
|
|
30
|
+
* Flag to enable CORS policy check
|
|
31
|
+
* @default false
|
|
32
|
+
*/
|
|
33
|
+
corsCheck?: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* List of allowed CORS origins
|
|
36
|
+
* @default ['*']
|
|
37
|
+
*/
|
|
38
|
+
allowedCorsOrigins?: string[];
|
|
39
|
+
/**
|
|
40
|
+
* Number of requests allowed in the specified duration
|
|
41
|
+
* @default 10
|
|
42
|
+
*/
|
|
43
|
+
rateLimitPoints?: number;
|
|
44
|
+
/**
|
|
45
|
+
* Duration in seconds for the rate limit
|
|
46
|
+
* @default 1
|
|
47
|
+
*/
|
|
48
|
+
rateLimitDuration?: number;
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* Create a default fetch adapter
|
|
52
|
+
* @param adapterOptions Options for creating the fetch adapter
|
|
53
|
+
* @returns A fetch adapter function
|
|
54
|
+
*/
|
|
55
|
+
export declare const getDefaultFetchAdapter: (adapterOptions?: GetFetchAdapterOptions) => typeof fetch;
|
|
56
|
+
export { HEADERS_MARKER };
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { RateLimiterMemory } from 'rate-limiter-flexible';
|
|
2
|
+
const DISALLOW_HOSTS_DEFAULT = ['localhost', '127.0.0.1'];
|
|
3
|
+
const DEFAULT_TIMEOUT = 5000; // 5 seconds
|
|
4
|
+
const DEFAULT_RATE_LIMIT_POINTS = 10; // Number of requests
|
|
5
|
+
const DEFAULT_RATE_LIMIT_DURATION = 1; // Per second
|
|
6
|
+
const HEADERS_MARKER = '__quickjsHeadersObject__';
|
|
7
|
+
/**
|
|
8
|
+
* Map a fetch Response to a simplified response object
|
|
9
|
+
* @param res The original response
|
|
10
|
+
* @returns The mapped response object
|
|
11
|
+
*/
|
|
12
|
+
const createHeadersObject = (headers) => ({
|
|
13
|
+
[HEADERS_MARKER]: true,
|
|
14
|
+
_headers: Object.fromEntries(headers.entries()),
|
|
15
|
+
});
|
|
16
|
+
/**
|
|
17
|
+
* Map a fetch Response to a simplified response object
|
|
18
|
+
* @param res The original response
|
|
19
|
+
* @returns The mapped response object
|
|
20
|
+
*/
|
|
21
|
+
const mapResponse = (res) => ({
|
|
22
|
+
status: res.status,
|
|
23
|
+
ok: res.ok,
|
|
24
|
+
statusText: res.statusText,
|
|
25
|
+
json: () => res.json(),
|
|
26
|
+
text: () => res.text(),
|
|
27
|
+
formData: () => res.formData(),
|
|
28
|
+
headers: createHeadersObject(res.headers),
|
|
29
|
+
type: res.type,
|
|
30
|
+
url: res.url,
|
|
31
|
+
blob: () => res.blob(),
|
|
32
|
+
bodyUsed: res.bodyUsed,
|
|
33
|
+
redirected: res.redirected,
|
|
34
|
+
body: undefined,
|
|
35
|
+
arrayBuffer: () => res.arrayBuffer(),
|
|
36
|
+
clone: () => res.clone(),
|
|
37
|
+
bytes: res.bytes,
|
|
38
|
+
});
|
|
39
|
+
/**
|
|
40
|
+
* Create a 403 forbidden response
|
|
41
|
+
* @returns A 403 forbidden response
|
|
42
|
+
*/
|
|
43
|
+
const getForbiddenResponse = () => {
|
|
44
|
+
const res = new Response('', { status: 403, statusText: 'FORBIDDEN' });
|
|
45
|
+
return mapResponse(res);
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Create a default fetch adapter
|
|
49
|
+
* @param adapterOptions Options for creating the fetch adapter
|
|
50
|
+
* @returns A fetch adapter function
|
|
51
|
+
*/
|
|
52
|
+
export const getDefaultFetchAdapter = (adapterOptions = {}) => {
|
|
53
|
+
const options = {
|
|
54
|
+
allowedProtocols: ['http:', 'https:'],
|
|
55
|
+
disallowedHosts: adapterOptions.disallowedHosts ?? DISALLOW_HOSTS_DEFAULT,
|
|
56
|
+
timeout: adapterOptions.timeout ?? DEFAULT_TIMEOUT,
|
|
57
|
+
corsCheck: adapterOptions.corsCheck ?? false,
|
|
58
|
+
allowedCorsOrigins: adapterOptions.allowedCorsOrigins ?? ['*'],
|
|
59
|
+
rateLimitPoints: adapterOptions.rateLimitPoints ?? DEFAULT_RATE_LIMIT_POINTS,
|
|
60
|
+
rateLimitDuration: adapterOptions.rateLimitDuration ?? DEFAULT_RATE_LIMIT_DURATION,
|
|
61
|
+
...adapterOptions,
|
|
62
|
+
};
|
|
63
|
+
const rateLimiter = new RateLimiterMemory({
|
|
64
|
+
points: options.rateLimitPoints,
|
|
65
|
+
duration: options.rateLimitDuration,
|
|
66
|
+
});
|
|
67
|
+
const fetchAdapter = Object.assign(async (input, init) => {
|
|
68
|
+
try {
|
|
69
|
+
await rateLimiter.consume('fetch', 1);
|
|
70
|
+
let urlString;
|
|
71
|
+
if (typeof input === 'string') {
|
|
72
|
+
urlString = input;
|
|
73
|
+
}
|
|
74
|
+
else if (input instanceof URL) {
|
|
75
|
+
urlString = input.toString();
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
urlString = input.url;
|
|
79
|
+
}
|
|
80
|
+
const parsedUrl = new URL(urlString);
|
|
81
|
+
// Check disallowed hosts
|
|
82
|
+
if (options.disallowedHosts.includes(parsedUrl.hostname)) {
|
|
83
|
+
return getForbiddenResponse();
|
|
84
|
+
}
|
|
85
|
+
// Check allowed hosts
|
|
86
|
+
if (options.allowedHosts && !options.allowedHosts.includes(parsedUrl.hostname)) {
|
|
87
|
+
return getForbiddenResponse();
|
|
88
|
+
}
|
|
89
|
+
// Check allowed protocols
|
|
90
|
+
if (!options.allowedProtocols.includes(parsedUrl.protocol)) {
|
|
91
|
+
return getForbiddenResponse();
|
|
92
|
+
}
|
|
93
|
+
// Handle file:// protocol with virtual file system
|
|
94
|
+
if (parsedUrl.protocol === 'file:') {
|
|
95
|
+
if (!options.fs) {
|
|
96
|
+
return getForbiddenResponse();
|
|
97
|
+
}
|
|
98
|
+
const filePath = parsedUrl.pathname;
|
|
99
|
+
if (!options.fs.existsSync(filePath)) {
|
|
100
|
+
const res = new Response('', { status: 404, statusText: 'NOT_FOUND' });
|
|
101
|
+
return mapResponse(res);
|
|
102
|
+
}
|
|
103
|
+
const content = options.fs.readFileSync(filePath);
|
|
104
|
+
const res = new Response(content, { status: 200, statusText: 'OK' });
|
|
105
|
+
return mapResponse(res);
|
|
106
|
+
}
|
|
107
|
+
// Setup request with timeout
|
|
108
|
+
const initWithDefaults = {
|
|
109
|
+
redirect: 'error',
|
|
110
|
+
...init,
|
|
111
|
+
signal: AbortSignal.timeout(options.timeout),
|
|
112
|
+
};
|
|
113
|
+
const res = await fetch(input, initWithDefaults);
|
|
114
|
+
// Enforce CORS policy if needed
|
|
115
|
+
if (options.corsCheck) {
|
|
116
|
+
const origin = res.headers.get('Access-Control-Allow-Origin');
|
|
117
|
+
if (!origin || (!options.allowedCorsOrigins.includes('*') && !options.allowedCorsOrigins.includes(origin))) {
|
|
118
|
+
return getForbiddenResponse();
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
return mapResponse(res);
|
|
122
|
+
}
|
|
123
|
+
catch (err) {
|
|
124
|
+
if (err instanceof Error) {
|
|
125
|
+
console.error('Fetch adapter error:', err);
|
|
126
|
+
const res = new Response('', { status: 500, statusText: 'INTERNAL SERVER ERROR' });
|
|
127
|
+
return mapResponse(res);
|
|
128
|
+
}
|
|
129
|
+
const res = new Response('', { status: 429, statusText: 'TOO MANY REQUESTS' });
|
|
130
|
+
return mapResponse(res);
|
|
131
|
+
}
|
|
132
|
+
}, {
|
|
133
|
+
// Dummy implementation of preconnect for Bun compatibility
|
|
134
|
+
preconnect: async (_url, _options) => {
|
|
135
|
+
return;
|
|
136
|
+
},
|
|
137
|
+
});
|
|
138
|
+
return fetchAdapter;
|
|
139
|
+
};
|
|
140
|
+
export { HEADERS_MARKER };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utilizes the standard setInterval to work properly with javascript `using` statement.
|
|
3
|
+
* Because of this, the interval gets automatically cleared on dispose.
|
|
4
|
+
*/
|
|
5
|
+
export declare const createTimeInterval: (...params: Parameters<typeof setInterval>) => {
|
|
6
|
+
id: ReturnType<typeof setInterval> | undefined;
|
|
7
|
+
clear: () => void;
|
|
8
|
+
[Symbol.dispose]: () => void;
|
|
9
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utilizes the standard setInterval to work properly with javascript `using` statement.
|
|
3
|
+
* Because of this, the interval gets automatically cleared on dispose.
|
|
4
|
+
*/
|
|
5
|
+
export const createTimeInterval = (...params) => {
|
|
6
|
+
const interval = {
|
|
7
|
+
id: setInterval(...params),
|
|
8
|
+
clear: function () {
|
|
9
|
+
if (this.id) {
|
|
10
|
+
clearInterval(this.id);
|
|
11
|
+
}
|
|
12
|
+
this.id = undefined;
|
|
13
|
+
},
|
|
14
|
+
[Symbol.dispose]: function () {
|
|
15
|
+
if (this.id) {
|
|
16
|
+
clearInterval(this.id);
|
|
17
|
+
}
|
|
18
|
+
this.id = undefined;
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
return interval;
|
|
22
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as memfsPkg from 'memfs';
|
|
2
|
+
import type { RuntimeOptions } from './types/RuntimeOptions.js';
|
|
3
|
+
/**
|
|
4
|
+
* Create the virtual file system for the sandbox
|
|
5
|
+
* Creates a node_modules folder with packages and ensures the src folder
|
|
6
|
+
*
|
|
7
|
+
* @param runtimeOptions
|
|
8
|
+
* @returns filesystem fs and volume vol
|
|
9
|
+
*/
|
|
10
|
+
export declare const createVirtualFileSystem: (runtimeOptions?: RuntimeOptions) => {
|
|
11
|
+
vol: memfsPkg.Volume;
|
|
12
|
+
fs: memfsPkg.IFs;
|
|
13
|
+
};
|