poe-code 5.0.4 → 6.0.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/dist/index.js +3181 -2636
- package/dist/index.js.map +4 -4
- package/dist/metafile.json +1 -1
- package/package.json +1 -1
- package/packages/safejs/dist/interp/async.js +31 -9
- package/packages/safejs/dist/interp/cancel.d.ts +7 -2
- package/packages/safejs/dist/interp/cancel.js +128 -92
- package/packages/safejs/dist/interp/exceptions.js +7 -3
- package/packages/safejs/dist/interp/globals/collections.js +2 -0
- package/packages/safejs/dist/interp/globals/console-json.js +4 -0
- package/packages/safejs/dist/interp/globals/error.js +1 -5
- package/packages/safejs/dist/interp/globals/math.js +2 -4
- package/packages/safejs/dist/interp/globals/misc.js +5 -0
- package/packages/safejs/dist/interp/globals/object-array.js +25 -0
- package/packages/safejs/dist/interp/globals/regex.js +1 -1
- package/packages/safejs/dist/interp/host-bridge.js +8 -5
- package/packages/safejs/dist/interp/interpreter.js +26 -32
- package/packages/safejs/dist/interp/iteration.d.ts +3 -3
- package/packages/safejs/dist/interp/iteration.js +20 -9
- package/packages/safejs/dist/interp/methods/array.js +1 -0
- package/packages/safejs/dist/interp/methods/function.d.ts +1 -1
- package/packages/safejs/dist/interp/methods/function.js +17 -1
- package/packages/safejs/dist/interp/methods/generator.js +1 -0
- package/packages/safejs/dist/interp/methods/map.js +1 -0
- package/packages/safejs/dist/interp/methods/number.js +1 -0
- package/packages/safejs/dist/interp/methods/regex.js +1 -0
- package/packages/safejs/dist/interp/methods/set.js +1 -0
- package/packages/safejs/dist/interp/methods/string.js +1 -0
- package/packages/safejs/dist/interp/promise-tracker.d.ts +12 -2
- package/packages/safejs/dist/interp/promise-tracker.js +65 -7
- package/packages/safejs/dist/interp/promise.d.ts +7 -5
- package/packages/safejs/dist/interp/promise.js +531 -148
- package/packages/safejs/dist/interp/values.d.ts +6 -0
- package/packages/safejs/dist/interp/values.js +25 -5
- package/packages/safejs/dist/lint/rules/AS001.js +0 -5
- package/packages/safejs/dist/snapshot/dump-format.d.ts +1 -1
- package/packages/safejs/dist/snapshot/dump-format.js +1 -1
- package/packages/safejs/dist/snapshot/replay-data.js +3 -0
|
@@ -52,6 +52,9 @@ export type SandboxCallContext = {
|
|
|
52
52
|
};
|
|
53
53
|
export type SandboxClosure = {
|
|
54
54
|
readonly async?: true;
|
|
55
|
+
readonly sandbox?: true;
|
|
56
|
+
readonly boundTarget?: SandboxClosure;
|
|
57
|
+
readonly cancellationSignal?: AbortSignal;
|
|
55
58
|
readonly kind: "fn";
|
|
56
59
|
readonly name?: string;
|
|
57
60
|
readonly properties?: SandboxObject;
|
|
@@ -82,6 +85,9 @@ type CopyFromSandboxOptions = {
|
|
|
82
85
|
};
|
|
83
86
|
export declare function createSandboxClosure(input: {
|
|
84
87
|
async?: boolean;
|
|
88
|
+
sandbox?: boolean;
|
|
89
|
+
boundTarget?: SandboxClosure;
|
|
90
|
+
cancellationSignal?: AbortSignal;
|
|
85
91
|
call: (args: readonly SandboxValue[], context?: SandboxCallContext) => SandboxValue | Promise<SandboxValue>;
|
|
86
92
|
construct?: (args: readonly SandboxValue[], context?: SandboxCallContext) => SandboxValue | Promise<SandboxValue>;
|
|
87
93
|
name?: string;
|
|
@@ -2,6 +2,7 @@ import { bindOtelSpan, getBoundOtelSpan } from "../observability/otel.js";
|
|
|
2
2
|
import { SandboxError } from "./budget.js";
|
|
3
3
|
import { observeSandboxPromise, trackSandboxPromise } from "./promise-tracker.js";
|
|
4
4
|
import { promiseReplayContext } from "./promise-replay.js";
|
|
5
|
+
import { invokeCancelableClosure, readPromiseCancellation, registerPromiseCancellation } from "./cancel.js";
|
|
5
6
|
import { parseRegex } from "./regex/parse.js";
|
|
6
7
|
import { assertSandboxDataDepth } from "../graph-depth.js";
|
|
7
8
|
import { copySandboxArgumentProperties, createSandboxArguments, getSandboxArgumentEntries, isSandboxArguments } from "./arguments.js";
|
|
@@ -17,15 +18,30 @@ const sandboxRetainedValues = Symbol("SandboxRetainedValues");
|
|
|
17
18
|
export function createSandboxClosure(input) {
|
|
18
19
|
const closure = {
|
|
19
20
|
kind: "fn",
|
|
20
|
-
call: input.call,
|
|
21
|
+
call: (args, context) => invokeCancelableClosure(closure, input.call, args, context),
|
|
21
22
|
name: input.name,
|
|
22
|
-
...(input.construct === undefined
|
|
23
|
+
...(input.construct === undefined
|
|
24
|
+
? {}
|
|
25
|
+
: {
|
|
26
|
+
construct: (args, context) => invokeCancelableClosure(closure, input.construct, args, context, true)
|
|
27
|
+
}),
|
|
23
28
|
...(input.async === true ? { async: true } : {})
|
|
24
29
|
};
|
|
25
30
|
Object.defineProperty(closure, sandboxClosureBrand, {
|
|
26
31
|
enumerable: false,
|
|
27
32
|
value: true
|
|
28
33
|
});
|
|
34
|
+
if (input.sandbox === true) {
|
|
35
|
+
Object.defineProperty(closure, "sandbox", { value: true });
|
|
36
|
+
}
|
|
37
|
+
if (input.boundTarget !== undefined) {
|
|
38
|
+
Object.defineProperty(closure, "boundTarget", { value: input.boundTarget });
|
|
39
|
+
}
|
|
40
|
+
if (input.cancellationSignal !== undefined) {
|
|
41
|
+
Object.defineProperty(closure, "cancellationSignal", {
|
|
42
|
+
value: input.cancellationSignal
|
|
43
|
+
});
|
|
44
|
+
}
|
|
29
45
|
if (input.properties !== undefined) {
|
|
30
46
|
Object.defineProperty(closure, "properties", {
|
|
31
47
|
enumerable: false,
|
|
@@ -40,11 +56,14 @@ export function createSandboxClosure(input) {
|
|
|
40
56
|
return Object.freeze(closure);
|
|
41
57
|
}
|
|
42
58
|
export function createSandboxPromise(promise, metadata = {}) {
|
|
59
|
+
const original = metadata.trackReplay === false
|
|
60
|
+
? promise
|
|
61
|
+
: (promiseReplayContext.getStore()?.track(promise) ?? promise);
|
|
43
62
|
const sandboxPromise = {
|
|
44
63
|
kind: "promise",
|
|
45
|
-
promise
|
|
46
|
-
|
|
47
|
-
|
|
64
|
+
get promise() {
|
|
65
|
+
return readPromiseCancellation(sandboxPromise, original);
|
|
66
|
+
}
|
|
48
67
|
};
|
|
49
68
|
Object.defineProperty(sandboxPromise, sandboxPromiseBrand, {
|
|
50
69
|
enumerable: false,
|
|
@@ -70,6 +89,7 @@ export function createSandboxPromise(promise, metadata = {}) {
|
|
|
70
89
|
});
|
|
71
90
|
}
|
|
72
91
|
trackSandboxPromise(sandboxPromise);
|
|
92
|
+
registerPromiseCancellation(sandboxPromise);
|
|
73
93
|
return Object.freeze(sandboxPromise);
|
|
74
94
|
}
|
|
75
95
|
export function createSandboxGenerator(channel, metadata = undefined) {
|
|
@@ -220,11 +220,6 @@ class AS001Scanner {
|
|
|
220
220
|
case "with":
|
|
221
221
|
this.report(token.value, token.start, token.end);
|
|
222
222
|
return;
|
|
223
|
-
case "new":
|
|
224
|
-
if (!this.source.slice(this.skipTriviaFrom(token.end.offset)).startsWith("RegExp")) {
|
|
225
|
-
this.report(token.value, token.start, token.end);
|
|
226
|
-
}
|
|
227
|
-
return;
|
|
228
223
|
default:
|
|
229
224
|
return;
|
|
230
225
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export const DUMP_FORMAT_VERSION = 1;
|
|
2
|
-
export const EXECUTION_SEMANTICS = "jobs-
|
|
2
|
+
export const EXECUTION_SEMANTICS = "jobs-v2";
|
|
3
3
|
import { assertSnapshotGraphDepth } from "../graph-depth.js";
|
|
4
4
|
import { getSandboxArgumentEntries, isSandboxArguments } from "../interp/arguments.js";
|
|
5
5
|
import { serializeArguments } from "./arguments.js";
|
|
@@ -180,6 +180,9 @@ export function decodeReplayData(input, options = {}) {
|
|
|
180
180
|
}
|
|
181
181
|
return createSandboxClosure({
|
|
182
182
|
...capability,
|
|
183
|
+
boundTarget: capability.boundTarget,
|
|
184
|
+
cancellationSignal: capability.cancellationSignal,
|
|
185
|
+
sandbox: capability.sandbox,
|
|
183
186
|
retainedValues: () => [capability],
|
|
184
187
|
properties: (closure) => {
|
|
185
188
|
restored.set(id, closure);
|