poe-code 11.0.17 → 11.0.19
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 +90 -24
- package/dist/index.js.map +4 -4
- package/dist/metafile.json +1 -1
- package/package.json +1 -1
- package/packages/safejs/dist/chunks/{chunk-COHIMIAF.js → chunk-2USRJY3R.js} +2 -2
- package/packages/safejs/dist/chunks/{chunk-D4DDI3HH.js → chunk-TIKUUEG2.js} +83 -24
- package/packages/safejs/dist/chunks/{chunk-D4DDI3HH.js.map → chunk-TIKUUEG2.js.map} +3 -3
- package/packages/safejs/dist/cli.js +2 -2
- package/packages/safejs/dist/core.js +1 -1
- package/packages/safejs/dist/graph-depth.js +1 -3
- package/packages/safejs/dist/index.js +2 -2
- package/packages/safejs/dist/interp/exceptions.d.ts +3 -2
- package/packages/safejs/dist/interp/exceptions.js +6 -2
- package/packages/safejs/dist/interp/interpreter.js +14 -14
- package/packages/safejs/dist/snapshot/arrays.d.ts +10 -0
- package/packages/safejs/dist/snapshot/arrays.js +24 -0
- package/packages/safejs/dist/snapshot/dump-format.js +7 -7
- package/packages/safejs/dist/snapshot/restore.js +9 -3
- package/packages/safejs/dist/snapshot/serialize.d.ts +2 -4
- package/packages/safejs/dist/snapshot/serialize.js +4 -7
- package/packages/safejs/dist/snapshot/validation.js +27 -2
- /package/packages/safejs/dist/chunks/{chunk-COHIMIAF.js.map → chunk-2USRJY3R.js.map} +0 -0
package/package.json
CHANGED
|
@@ -27,7 +27,7 @@ import {
|
|
|
27
27
|
validateMigrationSemantics,
|
|
28
28
|
validateSnapshotData,
|
|
29
29
|
validateSnapshotMigration
|
|
30
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-TIKUUEG2.js";
|
|
31
31
|
|
|
32
32
|
// packages/safejs/src/migrate.ts
|
|
33
33
|
import { createHash } from "node:crypto";
|
|
@@ -8055,4 +8055,4 @@ export {
|
|
|
8055
8055
|
parseMcpConfig,
|
|
8056
8056
|
makeMcpModule
|
|
8057
8057
|
};
|
|
8058
|
-
//# sourceMappingURL=chunk-
|
|
8058
|
+
//# sourceMappingURL=chunk-2USRJY3R.js.map
|
|
@@ -16879,7 +16879,6 @@ function graphEntries(value) {
|
|
|
16879
16879
|
if (isSandboxArguments(value)) {
|
|
16880
16880
|
return getSandboxArgumentEntries(value).map(([key, entry]) => [`.${key}`, entry]);
|
|
16881
16881
|
}
|
|
16882
|
-
if (Array.isArray(value)) return value.map((entry, index) => [`[${index}]`, entry]);
|
|
16883
16882
|
if (value instanceof Map) {
|
|
16884
16883
|
return [...value.entries()].flatMap(([key, entry], index) => [
|
|
16885
16884
|
[`.<map>[${index}].key`, key],
|
|
@@ -16893,7 +16892,7 @@ function graphEntries(value) {
|
|
|
16893
16892
|
for (const key of Object.keys(value)) {
|
|
16894
16893
|
const descriptor = Object.getOwnPropertyDescriptor(value, key);
|
|
16895
16894
|
if (descriptor !== void 0 && "value" in descriptor)
|
|
16896
|
-
entries.push([`.${key}`, descriptor.value]);
|
|
16895
|
+
entries.push([Array.isArray(value) ? `[${key}]` : `.${key}`, descriptor.value]);
|
|
16897
16896
|
}
|
|
16898
16897
|
return entries;
|
|
16899
16898
|
}
|
|
@@ -16931,6 +16930,35 @@ function serializeArguments(value, serializeValue) {
|
|
|
16931
16930
|
};
|
|
16932
16931
|
}
|
|
16933
16932
|
|
|
16933
|
+
// packages/safejs/src/snapshot/arrays.ts
|
|
16934
|
+
function requiresArrayEntries(value) {
|
|
16935
|
+
const keys = Object.keys(value);
|
|
16936
|
+
return keys.length !== value.length || keys.some((key, index) => key !== String(index));
|
|
16937
|
+
}
|
|
16938
|
+
function serializeArray(value, serializeValue) {
|
|
16939
|
+
if (!requiresArrayEntries(value)) {
|
|
16940
|
+
return {
|
|
16941
|
+
kind: "array",
|
|
16942
|
+
items: Array.from({ length: value.length }, (_, index) => {
|
|
16943
|
+
const key = String(index);
|
|
16944
|
+
const descriptor = Object.getOwnPropertyDescriptor(value, key);
|
|
16945
|
+
return serializeValue(
|
|
16946
|
+
descriptor !== void 0 && "value" in descriptor ? descriptor.value : void 0,
|
|
16947
|
+
key
|
|
16948
|
+
);
|
|
16949
|
+
})
|
|
16950
|
+
};
|
|
16951
|
+
}
|
|
16952
|
+
const entries = /* @__PURE__ */ Object.create(null);
|
|
16953
|
+
for (const key of Object.keys(value)) {
|
|
16954
|
+
const descriptor = Object.getOwnPropertyDescriptor(value, key);
|
|
16955
|
+
if (descriptor !== void 0 && "value" in descriptor) {
|
|
16956
|
+
entries[key] = serializeValue(descriptor.value, key);
|
|
16957
|
+
}
|
|
16958
|
+
}
|
|
16959
|
+
return { kind: "array", length: value.length, entries };
|
|
16960
|
+
}
|
|
16961
|
+
|
|
16934
16962
|
// packages/safejs/src/snapshot/dump-format.ts
|
|
16935
16963
|
var DUMP_FORMAT_VERSION = 1;
|
|
16936
16964
|
var EXECUTION_SEMANTICS = "jobs-v6";
|
|
@@ -17017,10 +17045,10 @@ function serializeHeapReference(value, path, state) {
|
|
|
17017
17045
|
return serialized === SKIP_VALUE ? { kind: "undefined" } : serialized;
|
|
17018
17046
|
});
|
|
17019
17047
|
} else if (Array.isArray(value)) {
|
|
17020
|
-
state.heap[String(id)] = {
|
|
17021
|
-
|
|
17022
|
-
|
|
17023
|
-
};
|
|
17048
|
+
state.heap[String(id)] = serializeArray(value, (entry, key) => {
|
|
17049
|
+
const serialized = serializeDumpValue(entry, `${path}[${key}]`, state);
|
|
17050
|
+
return serialized === SKIP_VALUE ? { kind: "undefined" } : serialized;
|
|
17051
|
+
});
|
|
17024
17052
|
} else {
|
|
17025
17053
|
const errorType = sandboxErrorTypes.get(value);
|
|
17026
17054
|
state.heap[String(id)] = {
|
|
@@ -17057,7 +17085,7 @@ function indexHeapContainers(snapshot) {
|
|
|
17057
17085
|
const heapIds = /* @__PURE__ */ new WeakMap();
|
|
17058
17086
|
let nextId = 1;
|
|
17059
17087
|
for (const [value, stat2] of stats.entries()) {
|
|
17060
|
-
if (stat2.count > 1 || stat2.cyclic || isSandboxArguments(value) || sandboxErrorTypes.has(value)) {
|
|
17088
|
+
if (stat2.count > 1 || stat2.cyclic || Array.isArray(value) && requiresArrayEntries(value) || isSandboxArguments(value) || sandboxErrorTypes.has(value)) {
|
|
17061
17089
|
heapIds.set(value, nextId);
|
|
17062
17090
|
nextId += 1;
|
|
17063
17091
|
}
|
|
@@ -17090,7 +17118,7 @@ function collectContainerStats(value, stats, ancestors) {
|
|
|
17090
17118
|
}
|
|
17091
17119
|
stat2.expanded = true;
|
|
17092
17120
|
ancestors.add(value);
|
|
17093
|
-
const entries = isSandboxArguments(value) ? getSandboxArgumentEntries(value).map(([, entry]) => entry) :
|
|
17121
|
+
const entries = isSandboxArguments(value) ? getSandboxArgumentEntries(value).map(([, entry]) => entry) : getEnumerableDataValues(value);
|
|
17094
17122
|
for (const entry of entries) {
|
|
17095
17123
|
collectContainerStats(entry, stats, ancestors);
|
|
17096
17124
|
}
|
|
@@ -17209,7 +17237,7 @@ function validateDumpHeap(root, state) {
|
|
|
17209
17237
|
continue;
|
|
17210
17238
|
}
|
|
17211
17239
|
if (entry.kind === "array") {
|
|
17212
|
-
|
|
17240
|
+
validateArrayHeap(entry, path, state);
|
|
17213
17241
|
continue;
|
|
17214
17242
|
}
|
|
17215
17243
|
if (entry.kind === "object") {
|
|
@@ -17356,6 +17384,30 @@ function validateGeneratorShape(record2, path, state) {
|
|
|
17356
17384
|
}
|
|
17357
17385
|
});
|
|
17358
17386
|
}
|
|
17387
|
+
function validateArrayHeap(record2, path, state) {
|
|
17388
|
+
if (Object.hasOwn(record2, "items")) {
|
|
17389
|
+
requireArray(record2.items, `${path}.items`, state);
|
|
17390
|
+
if (Object.hasOwn(record2, "length") || Object.hasOwn(record2, "entries"))
|
|
17391
|
+
fail("invalidValue", path, "array must use either items or length and entries");
|
|
17392
|
+
return;
|
|
17393
|
+
}
|
|
17394
|
+
const length = requireSafeInteger(record2.length, `${path}.length`, 0);
|
|
17395
|
+
if (length > 4294967295) fail("invalidValue", `${path}.length`, "exceeds maximum array length");
|
|
17396
|
+
if (length > state.limits.maxEntries)
|
|
17397
|
+
fail(
|
|
17398
|
+
"budgetExceeded",
|
|
17399
|
+
`${path}.length`,
|
|
17400
|
+
`exceeds collection entry limit ${state.limits.maxEntries}`
|
|
17401
|
+
);
|
|
17402
|
+
const entries = requireRecord(record2.entries, `${path}.entries`);
|
|
17403
|
+
for (const key of Object.keys(entries)) {
|
|
17404
|
+
if (key === "length")
|
|
17405
|
+
fail("invalidValue", `${path}.entries.length`, "array length is stored separately");
|
|
17406
|
+
const index = Number(key);
|
|
17407
|
+
if (String(index) === key && Number.isInteger(index) && index >= 0 && index < 4294967295 && index >= length)
|
|
17408
|
+
fail("invalidValue", `${path}.entries${formatKey(key)}`, "array index exceeds its length");
|
|
17409
|
+
}
|
|
17410
|
+
}
|
|
17359
17411
|
function validateErrorType(record2, path) {
|
|
17360
17412
|
if (!Object.hasOwn(record2, "errorType")) return;
|
|
17361
17413
|
if (record2.kind !== "object" || !sandboxErrorNames.includes(record2.errorType)) {
|
|
@@ -18107,9 +18159,10 @@ async function evaluateTryStatement(node, context, evaluateNode2) {
|
|
|
18107
18159
|
}
|
|
18108
18160
|
return finalizerResult;
|
|
18109
18161
|
}
|
|
18110
|
-
function createCapturedException(reason, stackFrames) {
|
|
18162
|
+
function createCapturedException(reason, stackFrames, sandbox = false) {
|
|
18111
18163
|
return {
|
|
18112
18164
|
reason,
|
|
18165
|
+
sandbox,
|
|
18113
18166
|
stackFrames,
|
|
18114
18167
|
[capturedExceptionBrand]: true
|
|
18115
18168
|
};
|
|
@@ -18117,7 +18170,7 @@ function createCapturedException(reason, stackFrames) {
|
|
|
18117
18170
|
function isCapturedException(value) {
|
|
18118
18171
|
return typeof value === "object" && value !== null && capturedExceptionBrand in value;
|
|
18119
18172
|
}
|
|
18120
|
-
function coerceThrownValue(reason, budget, stackFrames, span) {
|
|
18173
|
+
function coerceThrownValue(reason, budget, stackFrames, span, sandbox = false) {
|
|
18121
18174
|
if (isSubsetErrorValue(reason)) {
|
|
18122
18175
|
attachErrorSpan(reason, readErrorSpan(reason) ?? span);
|
|
18123
18176
|
return reason;
|
|
@@ -18129,6 +18182,9 @@ function coerceThrownValue(reason, budget, stackFrames, span) {
|
|
|
18129
18182
|
span
|
|
18130
18183
|
});
|
|
18131
18184
|
}
|
|
18185
|
+
if (sandbox) {
|
|
18186
|
+
return reason;
|
|
18187
|
+
}
|
|
18132
18188
|
if (isErrorLikeValue(reason)) {
|
|
18133
18189
|
return createSubsetErrorValue(reason.name || "Error", reason.message, stackFrames, budget, {
|
|
18134
18190
|
chargeBudget: false,
|
|
@@ -25846,7 +25902,7 @@ async function evaluateNode(node, context) {
|
|
|
25846
25902
|
error
|
|
25847
25903
|
};
|
|
25848
25904
|
}
|
|
25849
|
-
const exception = isCapturedException(error) ? coerceThrownValue(error.reason, context.budget, error.stackFrames, node.span) : coerceThrownValue(error, context.budget, context.callStack, node.span);
|
|
25905
|
+
const exception = isCapturedException(error) ? coerceThrownValue(error.reason, context.budget, error.stackFrames, node.span, error.sandbox) : coerceThrownValue(error, context.budget, context.callStack, node.span, true);
|
|
25850
25906
|
return {
|
|
25851
25907
|
kind: "throw",
|
|
25852
25908
|
hasValue: true,
|
|
@@ -27541,7 +27597,7 @@ async function evaluateStringMethodCall(node, target, methodName, context) {
|
|
|
27541
27597
|
if (isFatalSandboxError(error)) {
|
|
27542
27598
|
throw error;
|
|
27543
27599
|
}
|
|
27544
|
-
throw captureException(error, [...context.callStack, formatStackFrame(node, methodName)]);
|
|
27600
|
+
throw captureException(error, [...context.callStack, formatStackFrame(node, methodName)], true);
|
|
27545
27601
|
} finally {
|
|
27546
27602
|
leaveCall();
|
|
27547
27603
|
}
|
|
@@ -27568,7 +27624,7 @@ async function evaluateArrayMethodCall(node, target, methodName, context) {
|
|
|
27568
27624
|
if (isFatalSandboxError(error)) {
|
|
27569
27625
|
throw error;
|
|
27570
27626
|
}
|
|
27571
|
-
throw captureException(error, [...context.callStack, formatStackFrame(node, methodName)]);
|
|
27627
|
+
throw captureException(error, [...context.callStack, formatStackFrame(node, methodName)], true);
|
|
27572
27628
|
} finally {
|
|
27573
27629
|
leaveCall();
|
|
27574
27630
|
}
|
|
@@ -27595,7 +27651,7 @@ async function evaluateMapMethodCall(node, target, methodName, context) {
|
|
|
27595
27651
|
if (isFatalSandboxError(error)) {
|
|
27596
27652
|
throw error;
|
|
27597
27653
|
}
|
|
27598
|
-
throw captureException(error, [...context.callStack, formatStackFrame(node, methodName)]);
|
|
27654
|
+
throw captureException(error, [...context.callStack, formatStackFrame(node, methodName)], true);
|
|
27599
27655
|
} finally {
|
|
27600
27656
|
leaveCall();
|
|
27601
27657
|
}
|
|
@@ -27622,7 +27678,7 @@ async function evaluateSetMethodCall(node, target, methodName, context) {
|
|
|
27622
27678
|
if (isFatalSandboxError(error)) {
|
|
27623
27679
|
throw error;
|
|
27624
27680
|
}
|
|
27625
|
-
throw captureException(error, [...context.callStack, formatStackFrame(node, methodName)]);
|
|
27681
|
+
throw captureException(error, [...context.callStack, formatStackFrame(node, methodName)], true);
|
|
27626
27682
|
} finally {
|
|
27627
27683
|
leaveCall();
|
|
27628
27684
|
}
|
|
@@ -28000,7 +28056,7 @@ async function evaluateNumberMethodCall(node, target, methodName, context) {
|
|
|
28000
28056
|
if (isFatalSandboxError(error)) {
|
|
28001
28057
|
throw error;
|
|
28002
28058
|
}
|
|
28003
|
-
throw captureException(error, [...context.callStack, formatStackFrame(node, methodName)]);
|
|
28059
|
+
throw captureException(error, [...context.callStack, formatStackFrame(node, methodName)], true);
|
|
28004
28060
|
}
|
|
28005
28061
|
}
|
|
28006
28062
|
function createArrayMethodOptions(context) {
|
|
@@ -28042,12 +28098,15 @@ async function invokeSandboxClosure(callee, args, context, stack, span, thisValu
|
|
|
28042
28098
|
if (isSandboxPromise(result) && result.synchronousPrefix !== void 0) {
|
|
28043
28099
|
await result.synchronousPrefix;
|
|
28044
28100
|
}
|
|
28045
|
-
return !construct && callee.async === true ? normalizeClosureResult(
|
|
28101
|
+
return !construct && callee.async === true ? normalizeClosureResult(
|
|
28102
|
+
wrapHostResult(result, stack, callee.sandbox === true),
|
|
28103
|
+
context.budget
|
|
28104
|
+
) : await wrapHostResult(result, stack, callee.sandbox === true);
|
|
28046
28105
|
} catch (error) {
|
|
28047
28106
|
if (isFatalSandboxError(error)) {
|
|
28048
28107
|
throw error;
|
|
28049
28108
|
}
|
|
28050
|
-
throw captureException(error, stack);
|
|
28109
|
+
throw captureException(error, stack, callee.sandbox === true);
|
|
28051
28110
|
} finally {
|
|
28052
28111
|
leaveCall();
|
|
28053
28112
|
}
|
|
@@ -28172,19 +28231,19 @@ function isInterpreterError(value) {
|
|
|
28172
28231
|
function hasOwnProperty2(value, name) {
|
|
28173
28232
|
return Object.prototype.hasOwnProperty.call(value, name);
|
|
28174
28233
|
}
|
|
28175
|
-
function wrapHostResult(result, stack) {
|
|
28234
|
+
function wrapHostResult(result, stack, sandbox) {
|
|
28176
28235
|
if (!isPromiseLikeResult(result)) {
|
|
28177
28236
|
return result;
|
|
28178
28237
|
}
|
|
28179
28238
|
return Promise.resolve(result).then(
|
|
28180
28239
|
(value) => value,
|
|
28181
28240
|
(reason) => Promise.reject(
|
|
28182
|
-
isInterpreterError(reason) || reason instanceof SandboxError || isCapturedException(reason) ? reason : createCapturedException(reason, stack)
|
|
28241
|
+
isInterpreterError(reason) || reason instanceof SandboxError || isCapturedException(reason) ? reason : createCapturedException(reason, stack, sandbox)
|
|
28183
28242
|
)
|
|
28184
28243
|
);
|
|
28185
28244
|
}
|
|
28186
|
-
function captureException(error, stack) {
|
|
28187
|
-
return isCapturedException(error) ? error : createCapturedException(error, stack);
|
|
28245
|
+
function captureException(error, stack, sandbox) {
|
|
28246
|
+
return isCapturedException(error) ? error : createCapturedException(error, stack, sandbox);
|
|
28188
28247
|
}
|
|
28189
28248
|
function isFatalSandboxError(error) {
|
|
28190
28249
|
return error instanceof SandboxError && (error.code === "budgetExceeded" || error.code === "reentry");
|
|
@@ -29065,4 +29124,4 @@ export {
|
|
|
29065
29124
|
FileSnapshotBackend,
|
|
29066
29125
|
run
|
|
29067
29126
|
};
|
|
29068
|
-
//# sourceMappingURL=chunk-
|
|
29127
|
+
//# sourceMappingURL=chunk-TIKUUEG2.js.map
|