poe-code 11.0.16 → 11.0.18

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.
@@ -27,7 +27,7 @@ import {
27
27
  validateMigrationSemantics,
28
28
  validateSnapshotData,
29
29
  validateSnapshotMigration
30
- } from "./chunk-KNMVUWS7.js";
30
+ } from "./chunk-6BCUWJFF.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-X4JCDSRU.js.map
8058
+ //# sourceMappingURL=chunk-BIGMX2WV.js.map
@@ -20,7 +20,7 @@ import {
20
20
  parseMcpConfig,
21
21
  splitFrontmatter,
22
22
  withBrokenPipeGuard
23
- } from "./chunks/chunk-X4JCDSRU.js";
23
+ } from "./chunks/chunk-BIGMX2WV.js";
24
24
  import {
25
25
  Budget,
26
26
  SandboxError,
@@ -32,7 +32,7 @@ import {
32
32
  replaceErrorStack,
33
33
  restore,
34
34
  run
35
- } from "./chunks/chunk-KNMVUWS7.js";
35
+ } from "./chunks/chunk-6BCUWJFF.js";
36
36
  import "./chunks/chunk-4YIDX44G.js";
37
37
 
38
38
  // packages/safejs/src/cli.ts
@@ -3,7 +3,7 @@ import {
3
3
  createReplayableRandom,
4
4
  lint,
5
5
  run
6
- } from "./chunks/chunk-KNMVUWS7.js";
6
+ } from "./chunks/chunk-6BCUWJFF.js";
7
7
  import "./chunks/chunk-4YIDX44G.js";
8
8
  export {
9
9
  Budget,
@@ -27,7 +27,7 @@ import {
27
27
  runWithSpawnUsageAccumulator,
28
28
  splitFrontmatter,
29
29
  supportsSpawnMode
30
- } from "./chunks/chunk-X4JCDSRU.js";
30
+ } from "./chunks/chunk-BIGMX2WV.js";
31
31
  import {
32
32
  Budget,
33
33
  FileSnapshotBackend,
@@ -49,7 +49,7 @@ import {
49
49
  registerPendingHostCallPolicy,
50
50
  restore,
51
51
  run
52
- } from "./chunks/chunk-KNMVUWS7.js";
52
+ } from "./chunks/chunk-6BCUWJFF.js";
53
53
  import "./chunks/chunk-4YIDX44G.js";
54
54
 
55
55
  // packages/safejs/src/runner/run-harness.ts
@@ -21,6 +21,7 @@ export type EvaluationResult<TError> = CompletionResult | {
21
21
  };
22
22
  type CapturedException = {
23
23
  readonly reason: unknown;
24
+ readonly sandbox: boolean;
24
25
  readonly stackFrames: readonly string[];
25
26
  readonly [capturedExceptionBrand]: true;
26
27
  };
@@ -32,9 +33,9 @@ type ExceptionContext = {
32
33
  type EvaluateExceptionNode<TContext, TError> = (node: ParseResult, context: TContext) => Promise<EvaluationResult<TError>>;
33
34
  export declare function evaluateThrowStatement<TContext extends ExceptionContext, TError>(node: ThrowStatement, context: TContext, evaluateNode: EvaluateExceptionNode<TContext, TError>): Promise<EvaluationResult<TError>>;
34
35
  export declare function evaluateTryStatement<TContext extends ExceptionContext, TError>(node: TryStatement, context: TContext, evaluateNode: EvaluateExceptionNode<TContext, TError>): Promise<EvaluationResult<TError>>;
35
- export declare function createCapturedException(reason: unknown, stackFrames: readonly string[]): CapturedException;
36
+ export declare function createCapturedException(reason: unknown, stackFrames: readonly string[], sandbox?: boolean): CapturedException;
36
37
  export declare function isCapturedException(value: unknown): value is CapturedException;
37
- export declare function coerceThrownValue(reason: unknown, budget: Budget, stackFrames: readonly string[], span?: ErrorSourceSpan): SandboxValue;
38
+ export declare function coerceThrownValue(reason: unknown, budget: Budget, stackFrames: readonly string[], span?: ErrorSourceSpan, sandbox?: boolean): SandboxValue;
38
39
  export declare function surfaceThrownValue(reason: unknown, budget: Budget, stackFrames?: readonly string[], span?: ErrorSourceSpan): SandboxObject;
39
40
  export declare function createSubsetErrorValue(name: string, message: SandboxValue, stackFrames: readonly string[], budget: Budget, options?: {
40
41
  cause?: unknown;
@@ -54,9 +54,10 @@ export async function evaluateTryStatement(node, context, evaluateNode) {
54
54
  }
55
55
  return finalizerResult;
56
56
  }
57
- export function createCapturedException(reason, stackFrames) {
57
+ export function createCapturedException(reason, stackFrames, sandbox = false) {
58
58
  return {
59
59
  reason,
60
+ sandbox,
60
61
  stackFrames,
61
62
  [capturedExceptionBrand]: true
62
63
  };
@@ -64,7 +65,7 @@ export function createCapturedException(reason, stackFrames) {
64
65
  export function isCapturedException(value) {
65
66
  return typeof value === "object" && value !== null && capturedExceptionBrand in value;
66
67
  }
67
- export function coerceThrownValue(reason, budget, stackFrames, span) {
68
+ export function coerceThrownValue(reason, budget, stackFrames, span, sandbox = false) {
68
69
  if (isSubsetErrorValue(reason)) {
69
70
  attachErrorSpan(reason, readErrorSpan(reason) ?? span);
70
71
  return reason;
@@ -76,6 +77,9 @@ export function coerceThrownValue(reason, budget, stackFrames, span) {
76
77
  span
77
78
  });
78
79
  }
80
+ if (sandbox) {
81
+ return reason;
82
+ }
79
83
  if (isErrorLikeValue(reason)) {
80
84
  return createSubsetErrorValue(reason.name || "Error", reason.message, stackFrames, budget, {
81
85
  chargeBudget: false,
@@ -189,8 +189,8 @@ async function evaluateNode(node, context) {
189
189
  };
190
190
  }
191
191
  const exception = isCapturedException(error)
192
- ? coerceThrownValue(error.reason, context.budget, error.stackFrames, node.span)
193
- : coerceThrownValue(error, context.budget, context.callStack, node.span);
192
+ ? coerceThrownValue(error.reason, context.budget, error.stackFrames, node.span, error.sandbox)
193
+ : coerceThrownValue(error, context.budget, context.callStack, node.span, true);
194
194
  return {
195
195
  kind: "throw",
196
196
  hasValue: true,
@@ -1833,7 +1833,7 @@ async function evaluateStringMethodCall(node, target, methodName, context) {
1833
1833
  if (isFatalSandboxError(error)) {
1834
1834
  throw error;
1835
1835
  }
1836
- throw captureException(error, [...context.callStack, formatStackFrame(node, methodName)]);
1836
+ throw captureException(error, [...context.callStack, formatStackFrame(node, methodName)], true);
1837
1837
  }
1838
1838
  finally {
1839
1839
  leaveCall();
@@ -1856,7 +1856,7 @@ async function evaluateArrayMethodCall(node, target, methodName, context) {
1856
1856
  if (isFatalSandboxError(error)) {
1857
1857
  throw error;
1858
1858
  }
1859
- throw captureException(error, [...context.callStack, formatStackFrame(node, methodName)]);
1859
+ throw captureException(error, [...context.callStack, formatStackFrame(node, methodName)], true);
1860
1860
  }
1861
1861
  finally {
1862
1862
  leaveCall();
@@ -1879,7 +1879,7 @@ async function evaluateMapMethodCall(node, target, methodName, context) {
1879
1879
  if (isFatalSandboxError(error)) {
1880
1880
  throw error;
1881
1881
  }
1882
- throw captureException(error, [...context.callStack, formatStackFrame(node, methodName)]);
1882
+ throw captureException(error, [...context.callStack, formatStackFrame(node, methodName)], true);
1883
1883
  }
1884
1884
  finally {
1885
1885
  leaveCall();
@@ -1902,7 +1902,7 @@ async function evaluateSetMethodCall(node, target, methodName, context) {
1902
1902
  if (isFatalSandboxError(error)) {
1903
1903
  throw error;
1904
1904
  }
1905
- throw captureException(error, [...context.callStack, formatStackFrame(node, methodName)]);
1905
+ throw captureException(error, [...context.callStack, formatStackFrame(node, methodName)], true);
1906
1906
  }
1907
1907
  finally {
1908
1908
  leaveCall();
@@ -2280,7 +2280,7 @@ async function evaluateNumberMethodCall(node, target, methodName, context) {
2280
2280
  if (isFatalSandboxError(error)) {
2281
2281
  throw error;
2282
2282
  }
2283
- throw captureException(error, [...context.callStack, formatStackFrame(node, methodName)]);
2283
+ throw captureException(error, [...context.callStack, formatStackFrame(node, methodName)], true);
2284
2284
  }
2285
2285
  }
2286
2286
  function createArrayMethodOptions(context) {
@@ -2324,14 +2324,14 @@ async function invokeSandboxClosure(callee, args, context, stack, span, thisValu
2324
2324
  await result.synchronousPrefix;
2325
2325
  }
2326
2326
  return !construct && callee.async === true
2327
- ? normalizeClosureResult(wrapHostResult(result, stack), context.budget)
2328
- : await wrapHostResult(result, stack);
2327
+ ? normalizeClosureResult(wrapHostResult(result, stack, callee.sandbox === true), context.budget)
2328
+ : await wrapHostResult(result, stack, callee.sandbox === true);
2329
2329
  }
2330
2330
  catch (error) {
2331
2331
  if (isFatalSandboxError(error)) {
2332
2332
  throw error;
2333
2333
  }
2334
- throw captureException(error, stack);
2334
+ throw captureException(error, stack, callee.sandbox === true);
2335
2335
  }
2336
2336
  finally {
2337
2337
  leaveCall();
@@ -2461,16 +2461,16 @@ function isInterpreterError(value) {
2461
2461
  function hasOwnProperty(value, name) {
2462
2462
  return Object.prototype.hasOwnProperty.call(value, name);
2463
2463
  }
2464
- function wrapHostResult(result, stack) {
2464
+ function wrapHostResult(result, stack, sandbox) {
2465
2465
  if (!isPromiseLikeResult(result)) {
2466
2466
  return result;
2467
2467
  }
2468
2468
  return Promise.resolve(result).then((value) => value, (reason) => Promise.reject(isInterpreterError(reason) || reason instanceof SandboxError || isCapturedException(reason)
2469
2469
  ? reason
2470
- : createCapturedException(reason, stack)));
2470
+ : createCapturedException(reason, stack, sandbox)));
2471
2471
  }
2472
- function captureException(error, stack) {
2473
- return isCapturedException(error) ? error : createCapturedException(error, stack);
2472
+ function captureException(error, stack, sandbox) {
2473
+ return isCapturedException(error) ? error : createCapturedException(error, stack, sandbox);
2474
2474
  }
2475
2475
  function isFatalSandboxError(error) {
2476
2476
  return (error instanceof SandboxError && (error.code === "budgetExceeded" || error.code === "reentry"));
@@ -200,8 +200,11 @@ export function measureSandboxData(values, options = {}) {
200
200
  usage += 1;
201
201
  if (Array.isArray(value)) {
202
202
  usage += value.length;
203
- for (const entry of value)
204
- visit(entry);
203
+ for (let index = 0; index < value.length; index += 1) {
204
+ const descriptor = Object.getOwnPropertyDescriptor(value, index);
205
+ if (descriptor !== undefined && "value" in descriptor)
206
+ visit(descriptor.value);
207
+ }
205
208
  return;
206
209
  }
207
210
  if (isSandboxMap(value)) {
@@ -243,7 +246,9 @@ export function measureSandboxData(values, options = {}) {
243
246
  }
244
247
  const entries = isSandboxArguments(value)
245
248
  ? getSandboxArgumentEntries(value)
246
- : Object.entries(value);
249
+ : Object.entries(Object.getOwnPropertyDescriptors(value))
250
+ .filter(([, descriptor]) => descriptor.enumerable)
251
+ .map(([key, descriptor]) => [key, "value" in descriptor ? descriptor.value : undefined]);
247
252
  usage += entries.length;
248
253
  for (const [key, entry] of entries) {
249
254
  usage += key.length;