poe-code 11.0.25 → 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.
package/dist/index.js CHANGED
@@ -140216,11 +140216,14 @@ function copyToSandbox(value, state, path191 = "<root>", cloneSandboxCollections
140216
140216
  return copy;
140217
140217
  }
140218
140218
  if (isHostPromise(value)) {
140219
+ const existing = state.seen.get(value);
140220
+ if (existing !== void 0) return existing;
140219
140221
  const promise = Promise.resolve(value).then(
140220
140222
  (resolved) => copyToSandbox(resolved, { seen: /* @__PURE__ */ new WeakMap() }),
140221
140223
  (reason) => Promise.reject(copyToSandbox(reason, { seen: /* @__PURE__ */ new WeakMap() }))
140222
140224
  );
140223
140225
  const sandboxPromise = createSandboxPromise(promise);
140226
+ state.seen.set(value, sandboxPromise);
140224
140227
  const span = getBoundOtelSpan(value);
140225
140228
  if (span !== void 0) {
140226
140229
  bindOtelSpan(promise, span);
@@ -141496,6 +141499,7 @@ function wrapCallerInjectedFunction(name, value, options, state) {
141496
141499
  entries: /* @__PURE__ */ new Map(),
141497
141500
  hostFunctions: /* @__PURE__ */ new Map(),
141498
141501
  sourceFunctions: /* @__PURE__ */ new Map(),
141502
+ proofFunctions: /* @__PURE__ */ new WeakMap(),
141499
141503
  active: /* @__PURE__ */ new Set(),
141500
141504
  seen: /* @__PURE__ */ new WeakMap(),
141501
141505
  restored: []
@@ -141674,6 +141678,7 @@ function executeHostCall(record2, restored, invoke2, stackFrames, options, span,
141674
141678
  );
141675
141679
  }
141676
141680
  if (restored && record2.policy === "read-side-effect" && record2.lifecycle !== "created") {
141681
+ let active = true;
141677
141682
  const context = callbacks === void 0 ? void 0 : {
141678
141683
  callbacks: new Map(callbacks.hostFunctions),
141679
141684
  replayed: callbacks.restored.map((invocation) => ({
@@ -141682,9 +141687,23 @@ function executeHostCall(record2, restored, invoke2, stackFrames, options, span,
141682
141687
  })),
141683
141688
  async waitForCallbacks() {
141684
141689
  while (callbacks.active.size > 0) await Promise.allSettled([...callbacks.active]);
141690
+ },
141691
+ toSandboxValue(value) {
141692
+ if (!active) throw new TypeError("Host call resume context is no longer active.");
141693
+ if (options.signal?.aborted) throw readAbortReason2(options.signal);
141694
+ return copyHostValueToSandbox(
141695
+ value,
141696
+ stackFrames,
141697
+ { ...options, proofFunctions: callbacks.proofFunctions },
141698
+ { seen: /* @__PURE__ */ new WeakMap() },
141699
+ "<root>"
141700
+ );
141685
141701
  }
141686
141702
  };
141687
- return createHostCallPromise(record2, hostCalls.reconcile(record2, context), hostCalls);
141703
+ const outcome2 = hostCalls.reconcile(record2, context).finally(() => {
141704
+ active = false;
141705
+ });
141706
+ return createHostCallPromise(record2, outcome2, hostCalls);
141688
141707
  }
141689
141708
  if (restored && callbacks !== void 0) callbacks.nextReissuedInvocation = 0;
141690
141709
  hostCalls.start(record2);
@@ -141924,6 +141943,7 @@ function wrapSandboxClosureForHost(closure, stackFrames, budget, callbacks) {
141924
141943
  callbacks?.entries.set(id, invoke2);
141925
141944
  callbacks?.hostFunctions.set(id, wrapped);
141926
141945
  callbacks?.sourceFunctions.set(id, closure);
141946
+ callbacks?.proofFunctions.set(wrapped, closure);
141927
141947
  if (callbacks?.record !== void 0)
141928
141948
  callbacks.journal?.registerCallbackFunction(callbacks.record, id, closure, wrapped);
141929
141949
  return wrapped;
@@ -142002,9 +142022,17 @@ function copyHostValueToSandbox(value, stackFrames, options, state, path191) {
142002
142022
  throw new TypeError("Host error data must not contain functions or promises.");
142003
142023
  }
142004
142024
  if (isSandboxClosure(value) || isSandboxPromise(value)) {
142025
+ if (options.proofFunctions !== void 0)
142026
+ throw new TypeError(`Unsupported proof value at ${path191}: sandbox capability`);
142005
142027
  return deepCopyToSandbox(value);
142006
142028
  }
142007
142029
  if (typeof value === "function") {
142030
+ if (options.proofFunctions !== void 0) {
142031
+ const sourceClosure2 = options.proofFunctions.get(value);
142032
+ if (sourceClosure2 === void 0)
142033
+ throw new TypeError(`Unsupported proof value at ${path191}: function`);
142034
+ return sourceClosure2;
142035
+ }
142008
142036
  const sourceClosure = options.hostCalls?.nativeClosures.get(value);
142009
142037
  if (sourceClosure !== void 0) return sourceClosure;
142010
142038
  const callable = value;
@@ -142023,6 +142051,10 @@ function copyHostValueToSandbox(value, stackFrames, options, state, path191) {
142023
142051
  );
142024
142052
  }
142025
142053
  if (!options.errorData && isPromiseLike5(value)) {
142054
+ if (options.proofFunctions !== void 0)
142055
+ throw new TypeError(`Unsupported proof value at ${path191}: promise`);
142056
+ const existing = state.seen.get(value);
142057
+ if (existing !== void 0) return existing;
142026
142058
  const promise = wrapHostPromiseWithSignal(Promise.resolve(value), options.signal).then(
142027
142059
  (resolved) => {
142028
142060
  try {
@@ -142050,6 +142082,7 @@ function copyHostValueToSandbox(value, stackFrames, options, state, path191) {
142050
142082
  }
142051
142083
  );
142052
142084
  const sandboxPromise = createSandboxPromise(promise);
142085
+ state.seen.set(value, sandboxPromise);
142053
142086
  const span = getBoundOtelSpan(value);
142054
142087
  if (span !== void 0) {
142055
142088
  bindOtelSpan(promise, span);
@@ -155775,7 +155808,7 @@ var init_package2 = __esm({
155775
155808
  "package.json"() {
155776
155809
  package_default2 = {
155777
155810
  name: "poe-code",
155778
- version: "11.0.25",
155811
+ version: "11.0.27",
155779
155812
  description: "CLI tool to configure Poe API for developer workflows.",
155780
155813
  license: "MIT",
155781
155814
  type: "module",