poe-code 11.0.22 → 11.0.24

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;
@@ -143060,7 +143060,7 @@ function isAssignableSandboxTarget(value) {
143060
143060
  return typeof value === "object" && value !== null && !isSandboxClosure(value) && !isSandboxMap(value) && !isSandboxSet(value) && !isSandboxPromise(value) && !isSandboxRegex(value);
143061
143061
  }
143062
143062
  async function arrayFromSandboxValues(args, budget) {
143063
- const [items, mapFn] = args;
143063
+ const [items, mapFn, thisValue] = args;
143064
143064
  const iterator = getSandboxIterator(items);
143065
143065
  const values = iterator === void 0 ? Reflect.apply(Array.from, Array, [items]) : await collectIteratorValues(iterator);
143066
143066
  if (mapFn === void 0 || !isSandboxClosure(mapFn)) {
@@ -143071,7 +143071,7 @@ async function arrayFromSandboxValues(args, budget) {
143071
143071
  }
143072
143072
  const mappedValues = [];
143073
143073
  for (const [index, value] of values.entries()) {
143074
- const result = await mapFn.call([value, index]);
143074
+ const result = await mapFn.call([value, index], { stack: [], thisValue });
143075
143075
  if (isSandboxPromise(result) && result.synchronousPrefix !== void 0) {
143076
143076
  await result.synchronousPrefix;
143077
143077
  }
@@ -143205,17 +143205,17 @@ async function callArrayMethodUnlocked(value, methodName, args, options, stack)
143205
143205
  switch (methodName) {
143206
143206
  case "map":
143207
143207
  return budgetProducedValue(
143208
- await mapArray(value, getRequiredCallback(methodName, args[0]), options, stack),
143208
+ await mapArray(value, getRequiredCallback(methodName, args[0]), options, stack, args[1]),
143209
143209
  options.budget
143210
143210
  );
143211
143211
  case "filter":
143212
143212
  return budgetProducedValue(
143213
- await filterArray(value, getRequiredCallback(methodName, args[0]), options, stack),
143213
+ await filterArray(value, getRequiredCallback(methodName, args[0]), options, stack, args[1]),
143214
143214
  options.budget
143215
143215
  );
143216
143216
  case "find":
143217
143217
  return budgetProducedValue(
143218
- await findInArray(value, getRequiredCallback(methodName, args[0]), options, stack),
143218
+ await findInArray(value, getRequiredCallback(methodName, args[0]), options, stack, args[1]),
143219
143219
  options.budget
143220
143220
  );
143221
143221
  case "findIndex":
@@ -143223,11 +143223,18 @@ async function callArrayMethodUnlocked(value, methodName, args, options, stack)
143223
143223
  value,
143224
143224
  getRequiredCallback(methodName, args[0]),
143225
143225
  options,
143226
- stack
143226
+ stack,
143227
+ args[1]
143227
143228
  );
143228
143229
  case "findLast":
143229
143230
  return budgetProducedValue(
143230
- await findLastInArray(value, getRequiredCallback(methodName, args[0]), options, stack),
143231
+ await findLastInArray(
143232
+ value,
143233
+ getRequiredCallback(methodName, args[0]),
143234
+ options,
143235
+ stack,
143236
+ args[1]
143237
+ ),
143231
143238
  options.budget
143232
143239
  );
143233
143240
  case "findLastIndex":
@@ -143235,12 +143242,25 @@ async function callArrayMethodUnlocked(value, methodName, args, options, stack)
143235
143242
  value,
143236
143243
  getRequiredCallback(methodName, args[0]),
143237
143244
  options,
143238
- stack
143245
+ stack,
143246
+ args[1]
143239
143247
  );
143240
143248
  case "some":
143241
- return await someInArray(value, getRequiredCallback(methodName, args[0]), options, stack);
143249
+ return await someInArray(
143250
+ value,
143251
+ getRequiredCallback(methodName, args[0]),
143252
+ options,
143253
+ stack,
143254
+ args[1]
143255
+ );
143242
143256
  case "every":
143243
- return await everyInArray(value, getRequiredCallback(methodName, args[0]), options, stack);
143257
+ return await everyInArray(
143258
+ value,
143259
+ getRequiredCallback(methodName, args[0]),
143260
+ options,
143261
+ stack,
143262
+ args[1]
143263
+ );
143244
143264
  case "reduce":
143245
143265
  return budgetProducedValue(
143246
143266
  await reduceArray(
@@ -143266,11 +143286,17 @@ async function callArrayMethodUnlocked(value, methodName, args, options, stack)
143266
143286
  options.budget
143267
143287
  );
143268
143288
  case "forEach":
143269
- await forEachArray(value, getRequiredCallback(methodName, args[0]), options, stack);
143289
+ await forEachArray(value, getRequiredCallback(methodName, args[0]), options, stack, args[1]);
143270
143290
  return void 0;
143271
143291
  case "flatMap":
143272
143292
  return budgetProducedValue(
143273
- await flatMapArray(value, getRequiredCallback(methodName, args[0]), options, stack),
143293
+ await flatMapArray(
143294
+ value,
143295
+ getRequiredCallback(methodName, args[0]),
143296
+ options,
143297
+ stack,
143298
+ args[1]
143299
+ ),
143274
143300
  options.budget
143275
143301
  );
143276
143302
  case "flat":
@@ -143407,83 +143433,91 @@ function getRequiredCallback(methodName, value) {
143407
143433
  }
143408
143434
  return value;
143409
143435
  }
143410
- async function mapArray(value, callback, options, stack) {
143436
+ async function mapArray(value, callback, options, stack, thisValue) {
143411
143437
  const length = value.length;
143412
143438
  const result = new Array(length);
143413
143439
  for (let index = 0; index < length; index += 1) {
143414
143440
  if (!(index in value)) {
143415
143441
  continue;
143416
143442
  }
143417
- result[index] = await callArrayCallback(callback, value[index], index, value, options, stack);
143443
+ result[index] = await callArrayCallback(
143444
+ callback,
143445
+ value[index],
143446
+ index,
143447
+ value,
143448
+ options,
143449
+ stack,
143450
+ thisValue
143451
+ );
143418
143452
  }
143419
143453
  return result;
143420
143454
  }
143421
- async function filterArray(value, callback, options, stack) {
143455
+ async function filterArray(value, callback, options, stack, thisValue) {
143422
143456
  const length = value.length;
143423
143457
  const result = [];
143424
143458
  for (let index = 0; index < length; index += 1) {
143425
143459
  if (!(index in value)) {
143426
143460
  continue;
143427
143461
  }
143428
- if (await callArrayCallback(callback, value[index], index, value, options, stack)) {
143462
+ if (await callArrayCallback(callback, value[index], index, value, options, stack, thisValue)) {
143429
143463
  result.push(value[index]);
143430
143464
  }
143431
143465
  }
143432
143466
  return result;
143433
143467
  }
143434
- async function findInArray(value, callback, options, stack) {
143435
- const index = await findIndexInArray(value, callback, options, stack);
143468
+ async function findInArray(value, callback, options, stack, thisValue) {
143469
+ const index = await findIndexInArray(value, callback, options, stack, thisValue);
143436
143470
  return index < 0 ? void 0 : value[index];
143437
143471
  }
143438
- async function findIndexInArray(value, callback, options, stack) {
143472
+ async function findIndexInArray(value, callback, options, stack, thisValue) {
143439
143473
  const length = value.length;
143440
143474
  for (let index = 0; index < length; index += 1) {
143441
143475
  const entry = index in value ? value[index] : void 0;
143442
- if (await callArrayCallback(callback, entry, index, value, options, stack)) {
143476
+ if (await callArrayCallback(callback, entry, index, value, options, stack, thisValue)) {
143443
143477
  return index;
143444
143478
  }
143445
143479
  }
143446
143480
  return -1;
143447
143481
  }
143448
- async function findLastInArray(value, callback, options, stack) {
143482
+ async function findLastInArray(value, callback, options, stack, thisValue) {
143449
143483
  const length = value.length;
143450
143484
  for (let index = length - 1; index >= 0; index -= 1) {
143451
143485
  const entry = index in value ? value[index] : void 0;
143452
- if (await callArrayCallback(callback, entry, index, value, options, stack)) {
143486
+ if (await callArrayCallback(callback, entry, index, value, options, stack, thisValue)) {
143453
143487
  return entry;
143454
143488
  }
143455
143489
  }
143456
143490
  return void 0;
143457
143491
  }
143458
- async function findLastIndexInArray(value, callback, options, stack) {
143492
+ async function findLastIndexInArray(value, callback, options, stack, thisValue) {
143459
143493
  const length = value.length;
143460
143494
  for (let index = length - 1; index >= 0; index -= 1) {
143461
143495
  const entry = index in value ? value[index] : void 0;
143462
- if (await callArrayCallback(callback, entry, index, value, options, stack)) {
143496
+ if (await callArrayCallback(callback, entry, index, value, options, stack, thisValue)) {
143463
143497
  return index;
143464
143498
  }
143465
143499
  }
143466
143500
  return -1;
143467
143501
  }
143468
- async function someInArray(value, callback, options, stack) {
143502
+ async function someInArray(value, callback, options, stack, thisValue) {
143469
143503
  const length = value.length;
143470
143504
  for (let index = 0; index < length; index += 1) {
143471
143505
  if (!(index in value)) {
143472
143506
  continue;
143473
143507
  }
143474
- if (await callArrayCallback(callback, value[index], index, value, options, stack)) {
143508
+ if (await callArrayCallback(callback, value[index], index, value, options, stack, thisValue)) {
143475
143509
  return true;
143476
143510
  }
143477
143511
  }
143478
143512
  return false;
143479
143513
  }
143480
- async function everyInArray(value, callback, options, stack) {
143514
+ async function everyInArray(value, callback, options, stack, thisValue) {
143481
143515
  const length = value.length;
143482
143516
  for (let index = 0; index < length; index += 1) {
143483
143517
  if (!(index in value)) {
143484
143518
  continue;
143485
143519
  }
143486
- if (!await callArrayCallback(callback, value[index], index, value, options, stack)) {
143520
+ if (!await callArrayCallback(callback, value[index], index, value, options, stack, thisValue)) {
143487
143521
  return false;
143488
143522
  }
143489
143523
  }
@@ -143531,23 +143565,31 @@ async function reduceFromRight(value, callback, accumulator, startIndex, length,
143531
143565
  }
143532
143566
  return current;
143533
143567
  }
143534
- async function forEachArray(value, callback, options, stack) {
143568
+ async function forEachArray(value, callback, options, stack, thisValue) {
143535
143569
  const length = value.length;
143536
143570
  for (let index = 0; index < length; index += 1) {
143537
143571
  if (!(index in value)) {
143538
143572
  continue;
143539
143573
  }
143540
- await callArrayCallback(callback, value[index], index, value, options, stack);
143574
+ await callArrayCallback(callback, value[index], index, value, options, stack, thisValue);
143541
143575
  }
143542
143576
  }
143543
- async function flatMapArray(value, callback, options, stack) {
143577
+ async function flatMapArray(value, callback, options, stack, thisValue) {
143544
143578
  const length = value.length;
143545
143579
  const result = [];
143546
143580
  for (let index = 0; index < length; index += 1) {
143547
143581
  if (!(index in value)) {
143548
143582
  continue;
143549
143583
  }
143550
- const mapped = await callArrayCallback(callback, value[index], index, value, options, stack);
143584
+ const mapped = await callArrayCallback(
143585
+ callback,
143586
+ value[index],
143587
+ index,
143588
+ value,
143589
+ options,
143590
+ stack,
143591
+ thisValue
143592
+ );
143551
143593
  if (Array.isArray(mapped)) {
143552
143594
  for (let mappedIndex = 0; mappedIndex < mapped.length; mappedIndex += 1) {
143553
143595
  if (!(mappedIndex in mapped)) {
@@ -143619,8 +143661,8 @@ async function compareEntries(left, right, comparator, options, stack) {
143619
143661
  const result = Number(await options.callClosure(comparator, [left, right], stack));
143620
143662
  return Number.isNaN(result) ? 0 : result;
143621
143663
  }
143622
- async function callArrayCallback(callback, value, index, array, options, stack) {
143623
- return options.callClosure(callback, [value, index, array], stack);
143664
+ async function callArrayCallback(callback, value, index, array, options, stack, thisValue) {
143665
+ return options.callClosure(callback, [value, index, array], stack, thisValue);
143624
143666
  }
143625
143667
  function findNextDefinedIndex(value, startIndex, direction, length) {
143626
143668
  for (let index = startIndex; direction > 0 ? index < length : index >= 0; index += direction) {
@@ -143850,7 +143892,7 @@ async function callMapMethod(target, methodName, args, options, stack = []) {
143850
143892
  const entries = [...target.entries];
143851
143893
  for (let index = 0; index < entries.length; index += 1) {
143852
143894
  const [key3, value] = entries[index];
143853
- await options.callClosure(callback, [value, key3, target], stack);
143895
+ await options.callClosure(callback, [value, key3, target], stack, args[1]);
143854
143896
  }
143855
143897
  } finally {
143856
143898
  leaveCallback();
@@ -144665,7 +144707,7 @@ async function callSetMethod(target, methodName, args, options, stack = []) {
144665
144707
  const values = [...target.values];
144666
144708
  for (let index = 0; index < values.length; index += 1) {
144667
144709
  const value = values[index];
144668
- await options.callClosure(callback, [value, value, target], stack);
144710
+ await options.callClosure(callback, [value, value, target], stack, args[1]);
144669
144711
  }
144670
144712
  } finally {
144671
144713
  leaveCallback();
@@ -147219,19 +147261,19 @@ async function evaluateNumberMethodCall(node, target, methodName, context) {
147219
147261
  function createArrayMethodOptions(context) {
147220
147262
  return {
147221
147263
  budget: context.budget,
147222
- callClosure: (closure, args, stack) => invokeSandboxClosure(closure, args, context, stack)
147264
+ callClosure: (closure, args, stack, thisValue) => invokeSandboxClosure(closure, args, context, stack, void 0, thisValue)
147223
147265
  };
147224
147266
  }
147225
147267
  function createMapMethodOptions(context) {
147226
147268
  return {
147227
147269
  budget: context.budget,
147228
- callClosure: (closure, args, stack) => invokeSandboxClosure(closure, args, context, stack)
147270
+ callClosure: (closure, args, stack, thisValue) => invokeSandboxClosure(closure, args, context, stack, void 0, thisValue)
147229
147271
  };
147230
147272
  }
147231
147273
  function createSetMethodOptions(context) {
147232
147274
  return {
147233
147275
  budget: context.budget,
147234
- callClosure: (closure, args, stack) => invokeSandboxClosure(closure, args, context, stack)
147276
+ callClosure: (closure, args, stack, thisValue) => invokeSandboxClosure(closure, args, context, stack, void 0, thisValue)
147235
147277
  };
147236
147278
  }
147237
147279
  function createFunctionMethodOptions(context) {
@@ -147663,8 +147705,8 @@ function createDumpController(lifecycle) {
147663
147705
  }
147664
147706
  settlePendingSnapshot(createSnapshot());
147665
147707
  },
147666
- requestCurrentSnapshot() {
147667
- assertDumpAllowed();
147708
+ requestCurrentSnapshot(options = {}) {
147709
+ assertDumpAllowed(options);
147668
147710
  if (failed !== void 0) {
147669
147711
  return Promise.reject(failed.error);
147670
147712
  }
@@ -147675,10 +147717,10 @@ function createDumpController(lifecycle) {
147675
147717
  return Promise.reject(error3);
147676
147718
  }
147677
147719
  }
147678
- return this.requestSnapshot();
147720
+ return this.requestSnapshot(options);
147679
147721
  },
147680
147722
  requestSnapshot(options = {}) {
147681
- assertDumpAllowed();
147723
+ assertDumpAllowed(options);
147682
147724
  if (failed !== void 0) {
147683
147725
  if ((options.onFailure === "checkpoint" || options.onFailure === void 0 && isDataBudgetError(failed.error)) && finalSnapshot !== void 0) {
147684
147726
  try {
@@ -147700,6 +147742,9 @@ function createDumpController(lifecycle) {
147700
147742
  return Promise.reject(error3);
147701
147743
  }
147702
147744
  }
147745
+ if (options.mode === "replay" && (latestSnapshot !== void 0 || latestSnapshotFactory !== void 0)) {
147746
+ return this.requestCurrentSnapshot(options);
147747
+ }
147703
147748
  if (pendingRequest !== void 0) {
147704
147749
  return pendingRequest.promise;
147705
147750
  }
@@ -147717,8 +147762,8 @@ function createDumpController(lifecycle) {
147717
147762
  return promise;
147718
147763
  }
147719
147764
  };
147720
- function assertDumpAllowed() {
147721
- if ((lifecycle?.hostCallbackDepth ?? 0) > 0) {
147765
+ function assertDumpAllowed(options) {
147766
+ if ((lifecycle?.hostCallbackDepth ?? 0) > 0 && (options.mode !== "replay" || lifecycle?.hostCallbackContext.getStore() === true)) {
147722
147767
  throw new SandboxError("reentry");
147723
147768
  }
147724
147769
  }
@@ -148163,8 +148208,12 @@ var init_replay_inputs = __esm({
148163
148208
  });
148164
148209
 
148165
148210
  // packages/safejs/src/run.ts
148211
+ import { AsyncLocalStorage as AsyncLocalStorage8 } from "node:async_hooks";
148166
148212
  function run(source, options = {}) {
148167
- const lifecycle = { hostCallbackDepth: 0 };
148213
+ const lifecycle = {
148214
+ hostCallbackDepth: 0,
148215
+ hostCallbackContext: new AsyncLocalStorage8()
148216
+ };
148168
148217
  const dumpController = createDumpController(lifecycle);
148169
148218
  const promiseTracker = createSandboxPromiseRejectionTracker();
148170
148219
  let completedSnapshot;
@@ -148470,6 +148519,7 @@ function run(source, options = {}) {
148470
148519
  dumpController.fail(error3);
148471
148520
  throw error3;
148472
148521
  } finally {
148522
+ lifecycle.hostCallbackContext.disable();
148473
148523
  options.signal?.removeEventListener("abort", captureCancellationSnapshot);
148474
148524
  leaveInputReplay?.();
148475
148525
  leaveHostReplay?.();
@@ -149037,7 +149087,7 @@ var init_find_exported = __esm({
149037
149087
  });
149038
149088
 
149039
149089
  // packages/safejs/src/modules/agent.ts
149040
- import { AsyncLocalStorage as AsyncLocalStorage8 } from "node:async_hooks";
149090
+ import { AsyncLocalStorage as AsyncLocalStorage9 } from "node:async_hooks";
149041
149091
  function createSpawnUsageAccumulator() {
149042
149092
  let inputTokens = 0;
149043
149093
  let outputTokens = 0;
@@ -149940,7 +149990,7 @@ var init_agent3 = __esm({
149940
149990
  hostErrorData.set(this, { result });
149941
149991
  }
149942
149992
  };
149943
- activeUsageAccumulator = new AsyncLocalStorage8();
149993
+ activeUsageAccumulator = new AsyncLocalStorage9();
149944
149994
  oneAttemptRetryOptions = {
149945
149995
  maxAttempts: 1,
149946
149996
  backoffMs: 0,
@@ -155709,7 +155759,7 @@ var init_package2 = __esm({
155709
155759
  "package.json"() {
155710
155760
  package_default2 = {
155711
155761
  name: "poe-code",
155712
- version: "11.0.22",
155762
+ version: "11.0.24",
155713
155763
  description: "CLI tool to configure Poe API for developer workflows.",
155714
155764
  license: "MIT",
155715
155765
  type: "module",