poe-code 11.0.21 → 11.0.23

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
@@ -141613,7 +141613,7 @@ function invokeHostCallback(invoke2, options) {
141613
141613
  }
141614
141614
  lifecycle.hostCallbackDepth += 1;
141615
141615
  try {
141616
- const result = invoke2();
141616
+ const result = lifecycle.hostCallbackContext.run(true, invoke2);
141617
141617
  if (isPromiseLike5(result)) {
141618
141618
  return Promise.resolve(result).finally(() => {
141619
141619
  lifecycle.hostCallbackDepth -= 1;
@@ -144514,7 +144514,8 @@ function callSplit(value, args, budget) {
144514
144514
  let endedWithZeroWidthMatch = false;
144515
144515
  for (const match of collectRegexMatches(splitter, value, true)) {
144516
144516
  endedWithZeroWidthMatch = match.text.length === 0 && match.index === value.length;
144517
- if (match.text.length === 0 && match.index === 0) continue;
144517
+ if (match.text.length === 0 && (match.index === copiedThrough || match.index === value.length))
144518
+ continue;
144518
144519
  if (result2.length >= limit2) break;
144519
144520
  result2.push(budget.allocateString(value.slice(copiedThrough, match.index)));
144520
144521
  for (const capture of match.captures) {
@@ -144523,7 +144524,7 @@ function callSplit(value, args, budget) {
144523
144524
  }
144524
144525
  copiedThrough = match.index + match.text.length;
144525
144526
  }
144526
- if (result2.length < limit2 && !endedWithZeroWidthMatch)
144527
+ if (result2.length < limit2 && (value.length > 0 || !endedWithZeroWidthMatch))
144527
144528
  result2.push(budget.allocateString(value.slice(copiedThrough)));
144528
144529
  budget.allocateArrayLength(result2.length);
144529
144530
  return result2;
@@ -147662,8 +147663,8 @@ function createDumpController(lifecycle) {
147662
147663
  }
147663
147664
  settlePendingSnapshot(createSnapshot());
147664
147665
  },
147665
- requestCurrentSnapshot() {
147666
- assertDumpAllowed();
147666
+ requestCurrentSnapshot(options = {}) {
147667
+ assertDumpAllowed(options);
147667
147668
  if (failed !== void 0) {
147668
147669
  return Promise.reject(failed.error);
147669
147670
  }
@@ -147674,10 +147675,10 @@ function createDumpController(lifecycle) {
147674
147675
  return Promise.reject(error3);
147675
147676
  }
147676
147677
  }
147677
- return this.requestSnapshot();
147678
+ return this.requestSnapshot(options);
147678
147679
  },
147679
147680
  requestSnapshot(options = {}) {
147680
- assertDumpAllowed();
147681
+ assertDumpAllowed(options);
147681
147682
  if (failed !== void 0) {
147682
147683
  if ((options.onFailure === "checkpoint" || options.onFailure === void 0 && isDataBudgetError(failed.error)) && finalSnapshot !== void 0) {
147683
147684
  try {
@@ -147699,6 +147700,9 @@ function createDumpController(lifecycle) {
147699
147700
  return Promise.reject(error3);
147700
147701
  }
147701
147702
  }
147703
+ if (options.mode === "replay" && (latestSnapshot !== void 0 || latestSnapshotFactory !== void 0)) {
147704
+ return this.requestCurrentSnapshot(options);
147705
+ }
147702
147706
  if (pendingRequest !== void 0) {
147703
147707
  return pendingRequest.promise;
147704
147708
  }
@@ -147716,8 +147720,8 @@ function createDumpController(lifecycle) {
147716
147720
  return promise;
147717
147721
  }
147718
147722
  };
147719
- function assertDumpAllowed() {
147720
- if ((lifecycle?.hostCallbackDepth ?? 0) > 0) {
147723
+ function assertDumpAllowed(options) {
147724
+ if ((lifecycle?.hostCallbackDepth ?? 0) > 0 && (options.mode !== "replay" || lifecycle?.hostCallbackContext.getStore() === true)) {
147721
147725
  throw new SandboxError("reentry");
147722
147726
  }
147723
147727
  }
@@ -148162,8 +148166,12 @@ var init_replay_inputs = __esm({
148162
148166
  });
148163
148167
 
148164
148168
  // packages/safejs/src/run.ts
148169
+ import { AsyncLocalStorage as AsyncLocalStorage8 } from "node:async_hooks";
148165
148170
  function run(source, options = {}) {
148166
- const lifecycle = { hostCallbackDepth: 0 };
148171
+ const lifecycle = {
148172
+ hostCallbackDepth: 0,
148173
+ hostCallbackContext: new AsyncLocalStorage8()
148174
+ };
148167
148175
  const dumpController = createDumpController(lifecycle);
148168
148176
  const promiseTracker = createSandboxPromiseRejectionTracker();
148169
148177
  let completedSnapshot;
@@ -148469,6 +148477,7 @@ function run(source, options = {}) {
148469
148477
  dumpController.fail(error3);
148470
148478
  throw error3;
148471
148479
  } finally {
148480
+ lifecycle.hostCallbackContext.disable();
148472
148481
  options.signal?.removeEventListener("abort", captureCancellationSnapshot);
148473
148482
  leaveInputReplay?.();
148474
148483
  leaveHostReplay?.();
@@ -149036,7 +149045,7 @@ var init_find_exported = __esm({
149036
149045
  });
149037
149046
 
149038
149047
  // packages/safejs/src/modules/agent.ts
149039
- import { AsyncLocalStorage as AsyncLocalStorage8 } from "node:async_hooks";
149048
+ import { AsyncLocalStorage as AsyncLocalStorage9 } from "node:async_hooks";
149040
149049
  function createSpawnUsageAccumulator() {
149041
149050
  let inputTokens = 0;
149042
149051
  let outputTokens = 0;
@@ -149939,7 +149948,7 @@ var init_agent3 = __esm({
149939
149948
  hostErrorData.set(this, { result });
149940
149949
  }
149941
149950
  };
149942
- activeUsageAccumulator = new AsyncLocalStorage8();
149951
+ activeUsageAccumulator = new AsyncLocalStorage9();
149943
149952
  oneAttemptRetryOptions = {
149944
149953
  maxAttempts: 1,
149945
149954
  backoffMs: 0,
@@ -155708,7 +155717,7 @@ var init_package2 = __esm({
155708
155717
  "package.json"() {
155709
155718
  package_default2 = {
155710
155719
  name: "poe-code",
155711
- version: "11.0.21",
155720
+ version: "11.0.23",
155712
155721
  description: "CLI tool to configure Poe API for developer workflows.",
155713
155722
  license: "MIT",
155714
155723
  type: "module",