poe-code 10.0.1 → 10.0.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "poe-code",
3
- "version": "10.0.1",
3
+ "version": "10.0.2",
4
4
  "description": "CLI tool to configure Poe API for developer workflows.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -1,4 +1,5 @@
1
1
  import { lint, run, type Diagnostic, type OtelSink, type SnapshotBackend, type SpawnUsageTotal } from "../../../safejs/dist/index.js";
2
+ type RunOptions = NonNullable<Parameters<typeof run>[1]>;
2
3
  type LintOptions = NonNullable<Parameters<typeof lint>[1]>;
3
4
  export type RunResult = Awaited<ReturnType<typeof run>> & {
4
5
  usage: SpawnUsageTotal;
@@ -18,6 +19,7 @@ export type HarnessImportMeta = {
18
19
  };
19
20
  export type RunHarnessPairOptions = {
20
21
  allowedGlobals?: LintOptions["allowedGlobals"];
22
+ budget?: RunOptions["budget"];
21
23
  clock?: {
22
24
  now: () => number;
23
25
  };
@@ -118,6 +118,7 @@ export async function runHarnessPair(mdPath, options) {
118
118
  let result;
119
119
  try {
120
120
  result = await runWithSpawnUsageAccumulator(usageAccumulator, () => run(executableSource, {
121
+ budget: options.budget,
121
122
  clock: runtimeClock,
122
123
  importMeta: meta,
123
124
  entryPointArgs: [validated],
@@ -14,7 +14,7 @@ import {
14
14
  safeEndSpan,
15
15
  safeRecordException,
16
16
  safeStartSpan
17
- } from "./chunk-E6LJNTDX.js";
17
+ } from "./chunk-RSK47E4C.js";
18
18
 
19
19
  // packages/safejs/src/error/format.ts
20
20
  var DEFAULT_MAX_MESSAGE_LENGTH = 1e4;
@@ -7886,4 +7886,4 @@ export {
7886
7886
  parseMcpConfig,
7887
7887
  makeMcpModule
7888
7888
  };
7889
- //# sourceMappingURL=chunk-HNGGGIMP.js.map
7889
+ //# sourceMappingURL=chunk-EUCMIR4E.js.map
@@ -17781,9 +17781,14 @@ var PromiseReplay = class {
17781
17781
  const id = this.nextPromise++;
17782
17782
  if (!this.replaying) {
17783
17783
  const settled = () => {
17784
+ if (this.failure !== void 0) return;
17784
17785
  this.events.push({ kind: "promise", id, step: this.steps });
17785
17786
  };
17786
- void promise.then(settled, settled);
17787
+ void promise.then(settled, (reason) => {
17788
+ if (reason instanceof SandboxError && (reason.code === "budgetExceeded" || reason.code === "reentry"))
17789
+ return;
17790
+ settled();
17791
+ });
17787
17792
  return promise;
17788
17793
  }
17789
17794
  const tracked = new Promise((resolve, reject) => {
@@ -17799,6 +17804,11 @@ var PromiseReplay = class {
17799
17804
  },
17800
17805
  (reason) => {
17801
17806
  if (this.failure !== void 0) return;
17807
+ if (reason instanceof SandboxError && (reason.code === "budgetExceeded" || reason.code === "reentry")) {
17808
+ this.rejectors.delete(id);
17809
+ reject(reason);
17810
+ return;
17811
+ }
17802
17812
  this.ready.set(id, () => {
17803
17813
  this.rejectors.delete(id);
17804
17814
  reject(reason);
@@ -22702,14 +22712,12 @@ function createDumpController(lifecycle) {
22702
22712
  }
22703
22713
  return this.requestSnapshot();
22704
22714
  },
22705
- requestSnapshot() {
22715
+ requestSnapshot(options = {}) {
22706
22716
  assertDumpAllowed();
22707
22717
  if (failed !== void 0) {
22708
- if (isDataBudgetError(failed.error) && (latestSnapshot !== void 0 || latestSnapshotFactory !== void 0)) {
22718
+ if ((options.onFailure === "checkpoint" || options.onFailure === void 0 && isDataBudgetError(failed.error)) && finalSnapshot !== void 0) {
22709
22719
  try {
22710
- return Promise.resolve(
22711
- serializeRunSnapshot(latestSnapshot ?? latestSnapshotFactory())
22712
- );
22720
+ return Promise.resolve(serializeRunSnapshot(finalSnapshot));
22713
22721
  } catch (error) {
22714
22722
  return Promise.reject(error);
22715
22723
  }
@@ -22768,10 +22776,10 @@ function createDumpController(lifecycle) {
22768
22776
  function isDataBudgetError(error) {
22769
22777
  return typeof error === "object" && error !== null && "code" in error && error.code === "budgetExceeded" && "budget" in error && error.budget === "dataSize";
22770
22778
  }
22771
- function dump(result) {
22779
+ function dump(result, options = {}) {
22772
22780
  const controller = readDumpController(result);
22773
22781
  if (controller !== void 0) {
22774
- return controller.requestSnapshot();
22782
+ return controller.requestSnapshot(options);
22775
22783
  }
22776
22784
  if (hasSnapshot(result)) {
22777
22785
  try {
@@ -28308,8 +28316,17 @@ function run(source, options = {}) {
28308
28316
  let leaveHostReplay;
28309
28317
  let leaveInputReplay;
28310
28318
  let createFailureSnapshot;
28311
- let lastCheckpoint;
28319
+ let cancellationSnapshot;
28320
+ let cancellationSnapshotError;
28312
28321
  let snapshotScheduler;
28322
+ const captureCancellationSnapshot = () => {
28323
+ try {
28324
+ cancellationSnapshot = createFailureSnapshot?.();
28325
+ } catch (reason) {
28326
+ cancellationSnapshotError = { reason };
28327
+ }
28328
+ };
28329
+ options.signal?.addEventListener("abort", captureCancellationSnapshot, { once: true });
28313
28330
  try {
28314
28331
  const restoredSnapshot = options.snapshot === void 0 ? void 0 : restore(options.snapshot, { source });
28315
28332
  if (restoredSnapshot !== void 0) {
@@ -28446,6 +28463,9 @@ function run(source, options = {}) {
28446
28463
  bindings: executionScope.snapshot().bindings,
28447
28464
  clock: options.clock,
28448
28465
  hostCalls: hostCalls.snapshot(),
28466
+ replay: hostCalls.snapshotReplay(),
28467
+ initialInputs: initialInputs.snapshot,
28468
+ promiseReplay: promiseReplay.snapshot(),
28449
28469
  random,
28450
28470
  sourceHash
28451
28471
  });
@@ -28477,7 +28497,6 @@ function run(source, options = {}) {
28477
28497
  randomResumeState: typeof yieldPoint.replayState === "number" ? yieldPoint.replayState : void 0,
28478
28498
  sourceHash
28479
28499
  });
28480
- lastCheckpoint = snapshot2;
28481
28500
  return snapshot2;
28482
28501
  };
28483
28502
  activeSnapshotScheduler.onYield(createSnapshot);
@@ -28519,7 +28538,6 @@ function run(source, options = {}) {
28519
28538
  randomResumeState: typeof yieldPoint.replayState === "number" ? yieldPoint.replayState : void 0,
28520
28539
  sourceHash
28521
28540
  });
28522
- lastCheckpoint = snapshot2;
28523
28541
  return snapshot2;
28524
28542
  };
28525
28543
  activeSnapshotScheduler.onYield(createSnapshot);
@@ -28561,9 +28579,10 @@ function run(source, options = {}) {
28561
28579
  materializeWrappedErrorCause(error);
28562
28580
  if (createFailureSnapshot !== void 0 && snapshotScheduler !== void 0) {
28563
28581
  try {
28564
- const snapshot = lastCheckpoint ?? createFailureSnapshot();
28565
- await snapshotScheduler.write(snapshot);
28582
+ if (cancellationSnapshotError !== void 0) throw cancellationSnapshotError.reason;
28583
+ const snapshot = cancellationSnapshot ?? createFailureSnapshot();
28566
28584
  dumpController.finalize(snapshot);
28585
+ await snapshotScheduler.write(snapshot);
28567
28586
  } catch (snapshotError) {
28568
28587
  if (snapshotError instanceof UnsnapshotableValueError) {
28569
28588
  console.warn(`Skipping failure snapshot: ${snapshotError.message}`);
@@ -28575,6 +28594,7 @@ function run(source, options = {}) {
28575
28594
  dumpController.fail(error);
28576
28595
  throw error;
28577
28596
  } finally {
28597
+ options.signal?.removeEventListener("abort", captureCancellationSnapshot);
28578
28598
  leaveInputReplay?.();
28579
28599
  leaveHostReplay?.();
28580
28600
  promiseReplay.dispose();
@@ -28795,4 +28815,4 @@ export {
28795
28815
  FileSnapshotBackend,
28796
28816
  run
28797
28817
  };
28798
- //# sourceMappingURL=chunk-E6LJNTDX.js.map
28818
+ //# sourceMappingURL=chunk-RSK47E4C.js.map