poe-code 11.0.26 → 11.0.27

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.
@@ -20,7 +20,7 @@ import {
20
20
  parseMcpConfig,
21
21
  splitFrontmatter,
22
22
  withBrokenPipeGuard
23
- } from "./chunks/chunk-YVBVZ7MR.js";
23
+ } from "./chunks/chunk-EW4KQ32H.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-4TA6S7L6.js";
35
+ } from "./chunks/chunk-LSVSAZHI.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-4TA6S7L6.js";
6
+ } from "./chunks/chunk-LSVSAZHI.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-YVBVZ7MR.js";
30
+ } from "./chunks/chunk-EW4KQ32H.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-4TA6S7L6.js";
52
+ } from "./chunks/chunk-LSVSAZHI.js";
53
53
  import "./chunks/chunk-4YIDX44G.js";
54
54
 
55
55
  // packages/safejs/src/runner/run-harness.ts
@@ -1,7 +1,7 @@
1
1
  import { type Budget } from "./budget.js";
2
2
  import type { PendingHostCallPolicyMode } from "../snapshot/policy.js";
3
3
  import { type HostCallJournal, type HostCallOutcome } from "./host-call.js";
4
- import { type SandboxValue } from "./values.js";
4
+ import { type SandboxClosure, type SandboxValue } from "./values.js";
5
5
  import type { RunLifecycle } from "../snapshot/dump.js";
6
6
  type CallerInjectedFunction = {
7
7
  bivarianceHack(...args: readonly unknown[]): unknown;
@@ -15,6 +15,7 @@ type HostBridgeOptions = {
15
15
  operation?: string;
16
16
  signal?: AbortSignal;
17
17
  lifecycle?: RunLifecycle;
18
+ proofFunctions?: WeakMap<object, SandboxClosure>;
18
19
  };
19
20
  export type CallerInjectedBinding = SandboxValue | CallerInjectedFunction | readonly CallerInjectedBinding[] | {
20
21
  readonly [key: string]: CallerInjectedBinding;
@@ -59,6 +59,7 @@ function wrapCallerInjectedFunction(name, value, options, state) {
59
59
  entries: new Map(),
60
60
  hostFunctions: new Map(),
61
61
  sourceFunctions: new Map(),
62
+ proofFunctions: new WeakMap(),
62
63
  active: new Set(),
63
64
  seen: new WeakMap(),
64
65
  restored: []
@@ -220,6 +221,7 @@ function executeHostCall(record, restored, invoke, stackFrames, options, span, c
220
221
  throw new HostCallResumabilityError(record, "reset", `Host call ${record.id} was cancelled; reset is required.`);
221
222
  }
222
223
  if (restored && record.policy === "read-side-effect" && record.lifecycle !== "created") {
224
+ let active = true;
223
225
  const context = callbacks === undefined
224
226
  ? undefined
225
227
  : {
@@ -231,9 +233,19 @@ function executeHostCall(record, restored, invoke, stackFrames, options, span, c
231
233
  async waitForCallbacks() {
232
234
  while (callbacks.active.size > 0)
233
235
  await Promise.allSettled([...callbacks.active]);
236
+ },
237
+ toSandboxValue(value) {
238
+ if (!active)
239
+ throw new TypeError("Host call resume context is no longer active.");
240
+ if (options.signal?.aborted)
241
+ throw readAbortReason(options.signal);
242
+ return copyHostValueToSandbox(value, stackFrames, { ...options, proofFunctions: callbacks.proofFunctions }, { seen: new WeakMap() }, "<root>");
234
243
  }
235
244
  };
236
- return createHostCallPromise(record, hostCalls.reconcile(record, context), hostCalls);
245
+ const outcome = hostCalls.reconcile(record, context).finally(() => {
246
+ active = false;
247
+ });
248
+ return createHostCallPromise(record, outcome, hostCalls);
237
249
  }
238
250
  if (restored && callbacks !== undefined)
239
251
  callbacks.nextReissuedInvocation = 0;
@@ -465,6 +477,7 @@ function wrapSandboxClosureForHost(closure, stackFrames, budget, callbacks) {
465
477
  callbacks?.entries.set(id, invoke);
466
478
  callbacks?.hostFunctions.set(id, wrapped);
467
479
  callbacks?.sourceFunctions.set(id, closure);
480
+ callbacks?.proofFunctions.set(wrapped, closure);
468
481
  if (callbacks?.record !== undefined)
469
482
  callbacks.journal?.registerCallbackFunction(callbacks.record, id, closure, wrapped);
470
483
  return wrapped;
@@ -552,9 +565,17 @@ function copyHostValueToSandbox(value, stackFrames, options, state, path) {
552
565
  throw new TypeError("Host error data must not contain functions or promises.");
553
566
  }
554
567
  if (isSandboxClosure(value) || isSandboxPromise(value)) {
568
+ if (options.proofFunctions !== undefined)
569
+ throw new TypeError(`Unsupported proof value at ${path}: sandbox capability`);
555
570
  return deepCopyToSandbox(value);
556
571
  }
557
572
  if (typeof value === "function") {
573
+ if (options.proofFunctions !== undefined) {
574
+ const sourceClosure = options.proofFunctions.get(value);
575
+ if (sourceClosure === undefined)
576
+ throw new TypeError(`Unsupported proof value at ${path}: function`);
577
+ return sourceClosure;
578
+ }
558
579
  const sourceClosure = options.hostCalls?.nativeClosures.get(value);
559
580
  if (sourceClosure !== undefined)
560
581
  return sourceClosure;
@@ -571,6 +592,8 @@ function copyHostValueToSandbox(value, stackFrames, options, state, path) {
571
592
  }, state);
572
593
  }
573
594
  if (!options.errorData && isPromiseLike(value)) {
595
+ if (options.proofFunctions !== undefined)
596
+ throw new TypeError(`Unsupported proof value at ${path}: promise`);
574
597
  const existing = state.seen.get(value);
575
598
  if (existing !== undefined)
576
599
  return existing;
@@ -54,6 +54,7 @@ export type HostCallResumeContext = {
54
54
  result: Promise<unknown>;
55
55
  }>;
56
56
  waitForCallbacks: () => Promise<void>;
57
+ toSandboxValue: (value: unknown) => SandboxValue;
57
58
  };
58
59
  export type HostCallResumeRequest = Omit<HostCallRecord, "id" | "outcome"> & {
59
60
  callId: string;