@poe-platform/safe-bash 0.1.629 → 0.1.630
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 +1 -2
- package/dist/safe-bash/chunks/chunk-3BZ5NQ73.js +3952 -0
- package/dist/safe-bash/chunks/chunk-3BZ5NQ73.js.map +7 -0
- package/dist/safe-bash/chunks/{chunk-KYNRHYHP.js → chunk-6YSBXTTJ.js} +5 -5
- package/dist/safe-bash/chunks/{chunk-HHJSJWUD.js → chunk-K7W6Q6FN.js} +4 -4
- package/dist/safe-bash/chunks/{chunk-WPEMUXV4.js → chunk-KQ6J7JHQ.js} +4 -4
- package/dist/safe-bash/commands/llm/index.browser.js +2 -2
- package/dist/safe-bash/commands/network/index.browser.js +2 -2
- package/dist/safe-bash/commands/node/browser.d.ts +2 -0
- package/dist/safe-bash/commands/node/browser.d.ts.map +1 -0
- package/dist/safe-bash/commands/node/browser.js +2 -0
- package/dist/safe-bash/commands/node/browser.js.map +1 -0
- package/dist/safe-bash/commands/node/index.browser.js +16 -0
- package/dist/safe-bash/commands/node/index.browser.js.map +7 -0
- package/dist/safe-bash/commands/node/safejs.d.ts +6 -0
- package/dist/safe-bash/commands/node/safejs.d.ts.map +1 -1
- package/dist/safe-bash/commands/node/safejs.js +25 -1
- package/dist/safe-bash/commands/node/safejs.js.map +1 -1
- package/dist/safe-bash/commands/safejs/index.d.ts +5 -17
- package/dist/safe-bash/commands/safejs/index.d.ts.map +1 -1
- package/dist/safe-bash/commands/safejs/index.js +3 -202
- package/dist/safe-bash/commands/safejs/index.js.map +1 -1
- package/dist/safe-bash/commands/safejs/runtime.d.ts +15 -0
- package/dist/safe-bash/commands/safejs/runtime.d.ts.map +1 -0
- package/dist/safe-bash/commands/safejs/runtime.js +190 -0
- package/dist/safe-bash/commands/safejs/runtime.js.map +1 -0
- package/dist/safe-bash/commands/yq/index.browser.js +2 -2
- package/dist/safe-bash/core.browser.js +498 -4349
- package/dist/safe-bash/core.browser.js.map +4 -4
- package/dist/safe-bash/core.d.ts +1 -0
- package/dist/safe-bash/core.d.ts.map +1 -1
- package/dist/safe-bash/core.js +1 -0
- package/dist/safe-bash/core.js.map +1 -1
- package/dist/safe-bash/index.d.ts +1 -0
- package/dist/safe-bash/index.d.ts.map +1 -1
- package/dist/safe-bash/index.js +1 -0
- package/dist/safe-bash/index.js.map +1 -1
- package/package.json +9 -3
- /package/dist/safe-bash/chunks/{chunk-KYNRHYHP.js.map → chunk-6YSBXTTJ.js.map} +0 -0
- /package/dist/safe-bash/chunks/{chunk-HHJSJWUD.js.map → chunk-K7W6Q6FN.js.map} +0 -0
- /package/dist/safe-bash/chunks/{chunk-WPEMUXV4.js.map → chunk-KQ6J7JHQ.js.map} +0 -0
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
pathOf,
|
|
3
|
-
writeDiagnostic
|
|
4
|
-
} from "./chunk-GFZKQIPL.js";
|
|
5
1
|
import {
|
|
6
2
|
openFileOutput
|
|
7
3
|
} from "./chunk-4DBWBEU7.js";
|
|
8
4
|
import {
|
|
9
5
|
createOutputOperation
|
|
10
6
|
} from "./chunk-RNKTWFEM.js";
|
|
7
|
+
import {
|
|
8
|
+
pathOf,
|
|
9
|
+
writeDiagnostic
|
|
10
|
+
} from "./chunk-GFZKQIPL.js";
|
|
11
11
|
import {
|
|
12
12
|
getCommandArguments,
|
|
13
13
|
shellValueByteLength,
|
|
@@ -1430,4 +1430,4 @@ export {
|
|
|
1430
1430
|
createCurlCommands,
|
|
1431
1431
|
curlCommands
|
|
1432
1432
|
};
|
|
1433
|
-
//# sourceMappingURL=chunk-
|
|
1433
|
+
//# sourceMappingURL=chunk-6YSBXTTJ.js.map
|
|
@@ -22,13 +22,13 @@ import {
|
|
|
22
22
|
truth,
|
|
23
23
|
wellFormed
|
|
24
24
|
} from "./chunk-AFH57PPL.js";
|
|
25
|
+
import {
|
|
26
|
+
createOutputOperation
|
|
27
|
+
} from "./chunk-RNKTWFEM.js";
|
|
25
28
|
import {
|
|
26
29
|
escapeText,
|
|
27
30
|
pathOf
|
|
28
31
|
} from "./chunk-GFZKQIPL.js";
|
|
29
|
-
import {
|
|
30
|
-
createOutputOperation
|
|
31
|
-
} from "./chunk-RNKTWFEM.js";
|
|
32
32
|
import {
|
|
33
33
|
getCommandArguments,
|
|
34
34
|
shellValueByteLength,
|
|
@@ -5158,4 +5158,4 @@ export {
|
|
|
5158
5158
|
createYqCommands,
|
|
5159
5159
|
yqCommands
|
|
5160
5160
|
};
|
|
5161
|
-
//# sourceMappingURL=chunk-
|
|
5161
|
+
//# sourceMappingURL=chunk-K7W6Q6FN.js.map
|
|
@@ -2,13 +2,13 @@ import {
|
|
|
2
2
|
acceptsMimeType,
|
|
3
3
|
sniffMimeType
|
|
4
4
|
} from "./chunk-PVJJFCGA.js";
|
|
5
|
+
import {
|
|
6
|
+
createOutputOperation
|
|
7
|
+
} from "./chunk-RNKTWFEM.js";
|
|
5
8
|
import {
|
|
6
9
|
pathOf,
|
|
7
10
|
writeDiagnostic
|
|
8
11
|
} from "./chunk-GFZKQIPL.js";
|
|
9
|
-
import {
|
|
10
|
-
createOutputOperation
|
|
11
|
-
} from "./chunk-RNKTWFEM.js";
|
|
12
12
|
import {
|
|
13
13
|
getCommandArguments,
|
|
14
14
|
inheritYieldCheckpoint,
|
|
@@ -283,4 +283,4 @@ export {
|
|
|
283
283
|
createLlmCommands,
|
|
284
284
|
llmCommands
|
|
285
285
|
};
|
|
286
|
-
//# sourceMappingURL=chunk-
|
|
286
|
+
//# sourceMappingURL=chunk-KQ6J7JHQ.js.map
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createLlmCommands,
|
|
3
3
|
llmCommands
|
|
4
|
-
} from "../../chunks/chunk-
|
|
4
|
+
} from "../../chunks/chunk-KQ6J7JHQ.js";
|
|
5
5
|
import {
|
|
6
6
|
createElevenLabsProvider,
|
|
7
7
|
createOpenAiProvider
|
|
8
8
|
} from "../../chunks/chunk-PVJJFCGA.js";
|
|
9
|
-
import "../../chunks/chunk-GFZKQIPL.js";
|
|
10
9
|
import "../../chunks/chunk-RNKTWFEM.js";
|
|
10
|
+
import "../../chunks/chunk-GFZKQIPL.js";
|
|
11
11
|
import "../../chunks/chunk-UYX72YHY.js";
|
|
12
12
|
import "../../chunks/chunk-DPJWEGIX.js";
|
|
13
13
|
import "../../chunks/chunk-CXMIIXJA.js";
|
|
@@ -10,10 +10,10 @@ import {
|
|
|
10
10
|
curlCommands,
|
|
11
11
|
defaultNetworkLimits,
|
|
12
12
|
networkCommands
|
|
13
|
-
} from "../../chunks/chunk-
|
|
14
|
-
import "../../chunks/chunk-GFZKQIPL.js";
|
|
13
|
+
} from "../../chunks/chunk-6YSBXTTJ.js";
|
|
15
14
|
import "../../chunks/chunk-4DBWBEU7.js";
|
|
16
15
|
import "../../chunks/chunk-RNKTWFEM.js";
|
|
16
|
+
import "../../chunks/chunk-GFZKQIPL.js";
|
|
17
17
|
import "../../chunks/chunk-UYX72YHY.js";
|
|
18
18
|
import "../../chunks/chunk-DPJWEGIX.js";
|
|
19
19
|
import "../../chunks/chunk-CXMIIXJA.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../../../src/commands/node/browser.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,IAAI,iBAAiB,EAC5C,wBAAwB,IAAI,kBAAkB,EAC9C,kBAAkB,IAAI,YAAY,EAClC,KAAK,yBAAyB,IAAI,mBAAmB,GACtD,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browser.js","sourceRoot":"","sources":["../../../src/commands/node/browser.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,IAAI,iBAAiB,EAC5C,wBAAwB,IAAI,kBAAkB,EAC9C,kBAAkB,IAAI,YAAY,GAEnC,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createSafeJsNodeCommand,
|
|
3
|
+
createSafeJsNodeCommands,
|
|
4
|
+
safeJsNodeCommands
|
|
5
|
+
} from "../../chunks/chunk-3BZ5NQ73.js";
|
|
6
|
+
import "../../chunks/chunk-GFZKQIPL.js";
|
|
7
|
+
import "../../chunks/chunk-UYX72YHY.js";
|
|
8
|
+
import "../../chunks/chunk-DPJWEGIX.js";
|
|
9
|
+
import "../../chunks/chunk-CXMIIXJA.js";
|
|
10
|
+
import "../../chunks/chunk-2KL6W6NB.js";
|
|
11
|
+
export {
|
|
12
|
+
createSafeJsNodeCommand as createNodeCommand,
|
|
13
|
+
createSafeJsNodeCommands as createNodeCommands,
|
|
14
|
+
safeJsNodeCommands as nodeCommands
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=index.browser.js.map
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import type { CommandDefinition } from "../../contracts/command.js";
|
|
2
|
+
import type { VirtualShellPlugin } from "../../contracts/plugin.js";
|
|
2
3
|
import type { NodeSafeJsCommandOptions } from "./types.js";
|
|
4
|
+
export type SafeJsNodeCommandsOptions<Budget = unknown> = NodeSafeJsCommandOptions<Budget> & {
|
|
5
|
+
readonly replace?: boolean;
|
|
6
|
+
};
|
|
7
|
+
export declare function createSafeJsNodeCommands<Budget>(options: SafeJsNodeCommandsOptions<Budget>): readonly CommandDefinition[];
|
|
8
|
+
export declare function safeJsNodeCommands<Budget>(options: SafeJsNodeCommandsOptions<Budget>): VirtualShellPlugin;
|
|
3
9
|
export declare function createSafeJsNodeCommand<Budget>(options: NodeSafeJsCommandOptions<Budget>): CommandDefinition;
|
|
4
10
|
//# sourceMappingURL=safejs.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"safejs.d.ts","sourceRoot":"","sources":["../../../src/commands/node/safejs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"safejs.d.ts","sourceRoot":"","sources":["../../../src/commands/node/safejs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AACpE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAKpE,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAC;AAE3D,MAAM,MAAM,yBAAyB,CAAC,MAAM,GAAG,OAAO,IAAI,wBAAwB,CAAC,MAAM,CAAC,GAAG;IAAE,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AAE5H,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,OAAO,EAAE,yBAAyB,CAAC,MAAM,CAAC,GAAG,SAAS,iBAAiB,EAAE,CAMzH;AAED,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,OAAO,EAAE,yBAAyB,CAAC,MAAM,CAAC,GAAG,kBAAkB,CAOzG;AAiCD,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,OAAO,EAAE,wBAAwB,CAAC,MAAM,CAAC,GAAG,iBAAiB,CAuC5G"}
|
|
@@ -1,5 +1,24 @@
|
|
|
1
|
+
import { onlyKeys, record } from "../../integrations/safejs/values.js";
|
|
1
2
|
import { UsageError } from "../internal.js";
|
|
2
|
-
import { createSafeJsCommands } from "../safejs/
|
|
3
|
+
import { createSafeJsCommands } from "../safejs/runtime.js";
|
|
4
|
+
export function createSafeJsNodeCommands(options) {
|
|
5
|
+
const settings = record(options, "node options");
|
|
6
|
+
onlyKeys(settings, ["runtime", "limits", "replace"]);
|
|
7
|
+
if (Object.hasOwn(settings, "replace") && typeof settings.replace !== "boolean")
|
|
8
|
+
throw new TypeError("node replace must be boolean");
|
|
9
|
+
delete settings.replace;
|
|
10
|
+
return Object.freeze([createSafeJsNodeCommand(settings)]);
|
|
11
|
+
}
|
|
12
|
+
export function safeJsNodeCommands(options) {
|
|
13
|
+
const definitions = createSafeJsNodeCommands(options);
|
|
14
|
+
const replace = options.replace ?? false;
|
|
15
|
+
return { name: "node-commands", setup(host) {
|
|
16
|
+
if (!replace && host.commands.has("node"))
|
|
17
|
+
throw new Error("Command already registered: node");
|
|
18
|
+
for (const definition of definitions)
|
|
19
|
+
host.commands.register(definition, { replace });
|
|
20
|
+
} };
|
|
21
|
+
}
|
|
3
22
|
function invocation(args) {
|
|
4
23
|
let source;
|
|
5
24
|
let print = false;
|
|
@@ -40,6 +59,11 @@ function invocation(args) {
|
|
|
40
59
|
return { file: args[index] ?? "-", args: args.slice(index + 1), print: false, help: false };
|
|
41
60
|
}
|
|
42
61
|
export function createSafeJsNodeCommand(options) {
|
|
62
|
+
const settings = record(options, "node options");
|
|
63
|
+
onlyKeys(settings, ["runtime", "limits"]);
|
|
64
|
+
if (settings.runtime === undefined || settings.runtime === null)
|
|
65
|
+
throw new TypeError("node requires an injected SafeJS runtime");
|
|
66
|
+
options = settings;
|
|
43
67
|
const definitions = createSafeJsCommands(options, {
|
|
44
68
|
name: "node",
|
|
45
69
|
description: "Execute JavaScript with an injected SafeJS runtime and virtual I/O",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"safejs.js","sourceRoot":"","sources":["../../../src/commands/node/safejs.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"safejs.js","sourceRoot":"","sources":["../../../src/commands/node/safejs.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AACvE,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAM5D,MAAM,UAAU,wBAAwB,CAAS,OAA0C;IACzF,MAAM,QAAQ,GAAG,MAAM,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC;IACjD,QAAQ,CAAC,QAAQ,EAAE,CAA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AAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,kBAAkB,MAAM,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,6CAA6C;gBACnH,QAAQ,EAAE;oBACR,OAAO,EAAE,aAAa,EAAE,qBAAqB,EAAE,OAAO,CAAC,WAAW;oBAClE,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,oBAAoB,CAAC,CAAC,IAAa,EAAE,EAAE;wBAC9D,MAAM,MAAM,GAAG,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,eAAe,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;wBAChF,IAAI,CAAC,MAAM;4BAAE,MAAM,IAAI,SAAS,CAAC,8DAA8D,CAAC,CAAC;wBACjG,OAAO,MAAM,CAAC;oBAChB,CAAC,EAAE,kBAAkB,CAAC;iBACvB;aACF,CAAC;QACJ,CAAC;KACF,CAAC,CAAC;IACH,OAAO,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,CAAE,CAAC,CAAC;AACxC,CAAC"}
|
|
@@ -1,18 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export {
|
|
5
|
-
export type { SafeJsBudgetOptions, SafeJsCommandLimits,
|
|
6
|
-
export interface SafeJsCommandDialect {
|
|
7
|
-
readonly name: string;
|
|
8
|
-
readonly description: string;
|
|
9
|
-
readonly help: string;
|
|
10
|
-
readonly invocation: (args: readonly string[]) => Invocation;
|
|
11
|
-
readonly prepare?: (source: string, selected: Invocation, modules: Record<string, SafeJsModule>) => {
|
|
12
|
-
readonly source: string;
|
|
13
|
-
readonly bindings: SafeJsModule;
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
export declare function createSafeJsCommands<Budget = unknown>(options?: SafeJsCommandsOptions<Budget>, dialect?: SafeJsCommandDialect): readonly CommandDefinition[];
|
|
17
|
-
export declare function safeJsCommands<Budget = unknown>(options?: SafeJsCommandsOptions<Budget>): VirtualShellPlugin;
|
|
1
|
+
export { createNodeCommands as createSafeJsCommands, nodeCommands as safeJsCommands } from "../node/browser.js";
|
|
2
|
+
export type { NodeCommandsOptions as SafeJsCommandsOptions } from "../node/browser.js";
|
|
3
|
+
export { defaultSafeJsLimits } from "./options.js";
|
|
4
|
+
export { SafeJsCommandLimitError } from "./types.js";
|
|
5
|
+
export type { SafeJsBudgetOptions, SafeJsCommandLimits, SafeJsHostFunction, SafeJsHostValue, SafeJsModule, SafeJsRunOptions, SafeJsRunResult, SafeJsRuntime } from "./types.js";
|
|
18
6
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/safejs/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/safejs/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,IAAI,oBAAoB,EAAE,YAAY,IAAI,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAChH,YAAY,EAAE,mBAAmB,IAAI,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AACvF,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AACrD,YAAY,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,eAAe,EAAE,YAAY,EAAE,gBAAgB,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -1,203 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import { makeSafeJsFsModule } from "../../integrations/safejs/index.js";
|
|
5
|
-
import { record, withSignal } from "../../integrations/safejs/values.js";
|
|
6
|
-
import { pathOf, UsageError } from "../internal.js";
|
|
7
|
-
import { GuestInput, GuestOutput } from "./io.js";
|
|
8
|
-
import { commandLimits, defaultSafeJsLimits, invocation } from "./options.js";
|
|
9
|
-
import { SafeJsCommandLimitError } from "./types.js";
|
|
10
|
-
export { defaultSafeJsLimits, SafeJsCommandLimitError };
|
|
11
|
-
const help = "Usage: safejs [-p|--print] [-e SOURCE [--] ARG... | FILE ARG... | - ARG...]\nNo source operand reads SafeJS source from stdin. Inline/file source leaves stdin for guest data.\n-p prints the returned string or JSON value followed by LF; this is not Node.js.\nGuest modules: fs, stdio, command. A host-injected SafeJS runtime is required.\n";
|
|
12
|
-
class GuestDiagnostic extends PublicDiagnostic {
|
|
13
|
-
info;
|
|
14
|
-
constructor(info) {
|
|
15
|
-
super(info.message);
|
|
16
|
-
this.info = info;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
function errorInfo(error) {
|
|
20
|
-
if (typeof error === "string")
|
|
21
|
-
return { name: "Error", code: "", message: error };
|
|
22
|
-
if (typeof error !== "object" || error === null)
|
|
23
|
-
return { name: "Error", code: "", message: "SafeJS execution failed" };
|
|
24
|
-
const field = (name) => {
|
|
25
|
-
const descriptor = Object.getOwnPropertyDescriptor(error, name);
|
|
26
|
-
return descriptor && "value" in descriptor && typeof descriptor.value === "string" ? descriptor.value : "";
|
|
27
|
-
};
|
|
28
|
-
return { name: field("name"), code: field("code"), message: field("message") || "SafeJS execution failed" };
|
|
29
|
-
}
|
|
30
|
-
function statusField(error, name) {
|
|
31
|
-
if (typeof error !== "object" || error === null)
|
|
32
|
-
return "";
|
|
33
|
-
const descriptor = Object.getOwnPropertyDescriptor(error, name);
|
|
34
|
-
return descriptor && "value" in descriptor && typeof descriptor.value === "string" ? descriptor.value : "";
|
|
35
|
-
}
|
|
36
|
-
function validateRuntime(runtime) {
|
|
37
|
-
if (runtime === undefined)
|
|
38
|
-
return;
|
|
39
|
-
for (const key of ["run", "createBudget", "makeFsModule", "declareHostOperation"]) {
|
|
40
|
-
if (typeof runtime[key] !== "function")
|
|
41
|
-
throw new TypeError(`SafeJS runtime.${key} must be injected`);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
export function createSafeJsCommands(options = {}, dialect = {
|
|
45
|
-
name: "safejs", description: "Execute an injected SafeJS interpreter against the virtual filesystem", help, invocation,
|
|
46
|
-
}) {
|
|
47
|
-
const limits = commandLimits(options.limits);
|
|
48
|
-
const runtime = options.runtime;
|
|
49
|
-
validateRuntime(runtime);
|
|
50
|
-
return [{ name: dialect.name, description: dialect.description, async execute(context) {
|
|
51
|
-
const deadline = Date.now() + limits.timeoutMs;
|
|
52
|
-
const diagnose = async (message) => {
|
|
53
|
-
const diagnostic = new AbortController();
|
|
54
|
-
const timer = setTimeout(() => diagnostic.abort(), Math.max(1, Math.min(limits.timeoutMs, deadline - Date.now())));
|
|
55
|
-
try {
|
|
56
|
-
await writeDiagnostic(context.stderr, `${dialect.name}: ${message.slice(0, 4096)}\n`, AbortSignal.any([context.signal, diagnostic.signal]));
|
|
57
|
-
}
|
|
58
|
-
catch (error) {
|
|
59
|
-
context.signal.throwIfAborted();
|
|
60
|
-
if (!diagnostic.signal.aborted)
|
|
61
|
-
throw error;
|
|
62
|
-
}
|
|
63
|
-
finally {
|
|
64
|
-
clearTimeout(timer);
|
|
65
|
-
}
|
|
66
|
-
};
|
|
67
|
-
let parsed;
|
|
68
|
-
try {
|
|
69
|
-
parsed = dialect.invocation(context.args);
|
|
70
|
-
}
|
|
71
|
-
catch (error) {
|
|
72
|
-
await diagnose(publicDiagnosticMessage(error, context.onInternalError));
|
|
73
|
-
return { exitCode: 2 };
|
|
74
|
-
}
|
|
75
|
-
context.signal.throwIfAborted();
|
|
76
|
-
if (parsed.help) {
|
|
77
|
-
await writeBytes(context.stdout, Buffer.from(dialect.help), context.signal);
|
|
78
|
-
return { exitCode: 0 };
|
|
79
|
-
}
|
|
80
|
-
if (!runtime) {
|
|
81
|
-
await diagnose("runtime not installed; inject run, createBudget, makeFsModule and declareHostOperation");
|
|
82
|
-
return { exitCode: 127 };
|
|
83
|
-
}
|
|
84
|
-
const controller = new AbortController();
|
|
85
|
-
const signal = AbortSignal.any([context.signal, controller.signal]);
|
|
86
|
-
let failure;
|
|
87
|
-
let hasFailure = false;
|
|
88
|
-
const fail = (error) => {
|
|
89
|
-
if (!hasFailure && !controller.signal.aborted) {
|
|
90
|
-
hasFailure = true;
|
|
91
|
-
failure = error;
|
|
92
|
-
queueMicrotask(() => controller.abort(error));
|
|
93
|
-
}
|
|
94
|
-
};
|
|
95
|
-
const timeout = setTimeout(() => fail(new SafeJsCommandLimitError("timeoutMs")), limits.timeoutMs);
|
|
96
|
-
let input;
|
|
97
|
-
const output = new GuestOutput(context.stdout, context.stderr, limits.maxOutputBytes, signal, fail);
|
|
98
|
-
let exitCode = 0;
|
|
99
|
-
let thrown;
|
|
100
|
-
let failed = false;
|
|
101
|
-
try {
|
|
102
|
-
const fromStdin = parsed.source === undefined && parsed.file === "-";
|
|
103
|
-
let source = parsed.source;
|
|
104
|
-
let filename = parsed.file;
|
|
105
|
-
if (source === undefined) {
|
|
106
|
-
if (!fromStdin)
|
|
107
|
-
filename = pathOf(context, parsed.file);
|
|
108
|
-
const capabilities = fromStdin ? undefined : await withSignal(signal, async () => await context.fs.capabilitiesFor?.(filename, { signal }) ?? context.fs.capabilities);
|
|
109
|
-
const bytes = fromStdin ? context.stdin : context.fs.readStream && capabilities?.streamingRead !== false
|
|
110
|
-
? context.fs.readStream(filename, { signal, chunkSize: 65536 })
|
|
111
|
-
: toByteSource(await withSignal(signal, () => context.fs.readFile(filename, { signal, maxBytes: limits.maxSourceBytes })));
|
|
112
|
-
const reader = new GuestInput(bytes, limits.maxSourceBytes, signal, fail, "maxSourceBytes");
|
|
113
|
-
try {
|
|
114
|
-
source = await reader.readText();
|
|
115
|
-
}
|
|
116
|
-
finally {
|
|
117
|
-
await reader.close();
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
else if (Buffer.byteLength(source) > limits.maxSourceBytes)
|
|
121
|
-
throw new SafeJsCommandLimitError("maxSourceBytes");
|
|
122
|
-
if (source.startsWith("\uFEFF"))
|
|
123
|
-
source = source.slice(1);
|
|
124
|
-
input = new GuestInput(fromStdin ? toByteSource("") : context.stdin, limits.maxInputBytes, signal, fail);
|
|
125
|
-
const guestInput = input;
|
|
126
|
-
const declare = runtime.declareHostOperation;
|
|
127
|
-
const stdio = {
|
|
128
|
-
readBytes: declare(async (size) => guestInput.readBytes(size), "read-side-effect"),
|
|
129
|
-
readText: declare(async () => guestInput.readText(), "read-side-effect"),
|
|
130
|
-
write: declare(async (text) => output.text(text), "read-side-effect"),
|
|
131
|
-
writeBytes: declare(async (bytes) => output.bytes(bytes), "read-side-effect"),
|
|
132
|
-
error: declare(async (text) => output.text(text, true), "read-side-effect"),
|
|
133
|
-
errorBytes: declare(async (bytes) => output.bytes(bytes, true), "read-side-effect"),
|
|
134
|
-
};
|
|
135
|
-
const env = Object.create(null);
|
|
136
|
-
for (const [key, value] of Object.entries(context.env))
|
|
137
|
-
env[key] = value;
|
|
138
|
-
const command = {
|
|
139
|
-
args: [...parsed.args], cwd: context.cwd, env,
|
|
140
|
-
setExitCode: declare((value) => {
|
|
141
|
-
signal.throwIfAborted();
|
|
142
|
-
if (typeof value !== "number" || !Number.isInteger(value) || value < 0 || value > 255)
|
|
143
|
-
throw new TypeError("exit code must be an integer from 0 through 255");
|
|
144
|
-
exitCode = value;
|
|
145
|
-
}, "read-side-effect"),
|
|
146
|
-
};
|
|
147
|
-
const budget = runtime.createBudget({ maxSteps: limits.maxSteps, deadline,
|
|
148
|
-
maxCallDepth: limits.maxCallDepth, stringLength: limits.stringLength, arrayLength: limits.arrayLength, dataSize: limits.dataSize });
|
|
149
|
-
const modules = { fs: makeSafeJsFsModule(runtime.makeFsModule, context.fs, { cwd: context.cwd, signal }), stdio, command };
|
|
150
|
-
const prepared = dialect.prepare?.(source, { ...parsed, file: filename }, modules);
|
|
151
|
-
const result = record(await withSignal(signal, () => runtime.run(prepared?.source ?? source, {
|
|
152
|
-
budget, filename, modules, signal, ...(prepared ? { bindings: prepared.bindings } : {}),
|
|
153
|
-
sink: { log: (...args) => output.console(args, false), error: (...args) => output.console(args, true) },
|
|
154
|
-
})), "SafeJS run result");
|
|
155
|
-
signal.throwIfAborted();
|
|
156
|
-
if (result.ok !== true && result.ok !== false)
|
|
157
|
-
throw new TypeError("Invalid SafeJS run result.ok");
|
|
158
|
-
if (!result.ok) {
|
|
159
|
-
const info = errorInfo(result.error);
|
|
160
|
-
throw new GuestDiagnostic(info);
|
|
161
|
-
}
|
|
162
|
-
if (parsed.print && result.returnValue !== undefined)
|
|
163
|
-
await output.result(result.returnValue);
|
|
164
|
-
await output.drain();
|
|
165
|
-
}
|
|
166
|
-
catch (error) {
|
|
167
|
-
thrown = hasFailure ? failure : error;
|
|
168
|
-
failed = true;
|
|
169
|
-
}
|
|
170
|
-
finally {
|
|
171
|
-
try {
|
|
172
|
-
await output.drain();
|
|
173
|
-
}
|
|
174
|
-
catch (error) {
|
|
175
|
-
thrown = hasFailure ? failure : error;
|
|
176
|
-
failed = true;
|
|
177
|
-
}
|
|
178
|
-
controller.abort();
|
|
179
|
-
clearTimeout(timeout);
|
|
180
|
-
await input?.close().catch(() => { });
|
|
181
|
-
}
|
|
182
|
-
context.signal.throwIfAborted();
|
|
183
|
-
if (failed) {
|
|
184
|
-
const info = thrown instanceof GuestDiagnostic ? thrown.info : { name: statusField(thrown, "name"), code: statusField(thrown, "code") };
|
|
185
|
-
const detail = thrown instanceof SafeJsCommandLimitError ? thrown.message : publicDiagnosticMessage(thrown, context.onInternalError);
|
|
186
|
-
if (!output.stderrFailed)
|
|
187
|
-
await diagnose(detail);
|
|
188
|
-
return { exitCode: thrown instanceof SafeJsCommandLimitError || info.code === "budgetExceeded" ? 124
|
|
189
|
-
: thrown instanceof UsageError || info.name === "ParseError" ? 2 : 1 };
|
|
190
|
-
}
|
|
191
|
-
return { exitCode };
|
|
192
|
-
} }];
|
|
193
|
-
}
|
|
194
|
-
export function safeJsCommands(options = {}) {
|
|
195
|
-
const definitions = createSafeJsCommands(options);
|
|
196
|
-
return { name: "safejs-commands", setup(host) {
|
|
197
|
-
if (!options.replace && host.commands.has("safejs"))
|
|
198
|
-
throw new Error("Command already registered: safejs");
|
|
199
|
-
for (const definition of definitions)
|
|
200
|
-
host.commands.register(definition, { replace: options.replace ?? false });
|
|
201
|
-
} };
|
|
202
|
-
}
|
|
1
|
+
export { createNodeCommands as createSafeJsCommands, nodeCommands as safeJsCommands } from "../node/browser.js";
|
|
2
|
+
export { defaultSafeJsLimits } from "./options.js";
|
|
3
|
+
export { SafeJsCommandLimitError } from "./types.js";
|
|
203
4
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/safejs/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AACjF,OAAO,EAAE,YAAY,EAAE,UAAU,EAAmD,MAAM,0BAA0B,CAAC;AACrH,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AACxE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,qCAAqC,CAAC;AACzE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,UAAU,EAAmB,MAAM,cAAc,CAAC;AAC/F,OAAO,EAAE,uBAAuB,EAAqE,MAAM,YAAY,CAAC;AAExH,OAAO,EAAE,mBAAmB,EAAE,uBAAuB,EAAE,CAAC;AAGxD,MAAM,IAAI,GAAG,oVAAoV,CAAC;AAalW,MAAM,eAAgB,SAAQ,gBAAgB;IACvB;IAArB,YAAqB,IAAqD;QAAI,KAAK,CAAC,IAAI,CAAC,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,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;gBAC3E,CAAC;gBACD,OAAO,EAAE,QAAQ,EAAE,CAAC;YACtB,CAAC,EAAE,CAAC,CAAC;AACP,CAAC;AAED,MAAM,UAAU,cAAc,CAAmB,UAAyC,EAAE;IAC1F,MAAM,WAAW,GAAG,oBAAoB,CAAC,OAAO,CAAC,CAAC;IAClD,OAAO,EAAE,IAAI,EAAE,iBAAiB,EAAE,KAAK,CAAC,IAAI;YAC1C,IAAI,CAAC,OAAO,CAAC,OAAO,IAAI,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC;gBAAE,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAC;YAC3G,KAAK,MAAM,UAAU,IAAI,WAAW;gBAAE,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,UAAU,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,IAAI,KAAK,EAAE,CAAC,CAAC;QAClH,CAAC,EAAE,CAAC;AACN,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/safejs/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,IAAI,oBAAoB,EAAE,YAAY,IAAI,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEhH,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type CommandDefinition } from "../../contracts/index.js";
|
|
2
|
+
import { type Invocation } from "./options.js";
|
|
3
|
+
import { type SafeJsCommandsOptions, type SafeJsModule } from "./types.js";
|
|
4
|
+
export interface SafeJsCommandDialect {
|
|
5
|
+
readonly name: string;
|
|
6
|
+
readonly description: string;
|
|
7
|
+
readonly help: string;
|
|
8
|
+
readonly invocation: (args: readonly string[]) => Invocation;
|
|
9
|
+
readonly prepare?: (source: string, selected: Invocation, modules: Record<string, SafeJsModule>) => {
|
|
10
|
+
readonly source: string;
|
|
11
|
+
readonly bindings: SafeJsModule;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
export declare function createSafeJsCommands<Budget = unknown>(options: SafeJsCommandsOptions<Budget>, dialect: SafeJsCommandDialect): readonly CommandDefinition[];
|
|
15
|
+
//# sourceMappingURL=runtime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../../src/commands/safejs/runtime.ts"],"names":[],"mappings":"AACA,OAAO,EAA4B,KAAK,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAM5F,OAAO,EAAiB,KAAK,UAAU,EAAE,MAAM,cAAc,CAAC;AAC9D,OAAO,EAA2B,KAAK,qBAAqB,EAAE,KAAK,YAAY,EAAsB,MAAM,YAAY,CAAC;AAExH,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,UAAU,EAAE,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,KAAK,UAAU,CAAC;IAC7D,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,KAAK;QAClG,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;QACxB,QAAQ,CAAC,QAAQ,EAAE,YAAY,CAAC;KACjC,CAAC;CACH;AA6BD,wBAAgB,oBAAoB,CAAC,MAAM,GAAG,OAAO,EAAE,OAAO,EAAE,qBAAqB,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,oBAAoB,GAAG,SAAS,iBAAiB,EAAE,CAyG1J"}
|