poe-code 10.0.1 → 10.0.3
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/cli/commands/harness.js +13 -1
- package/dist/cli/commands/harness.js.map +1 -1
- package/dist/index.js +64 -14
- package/dist/index.js.map +3 -3
- package/dist/metafile.json +1 -1
- package/package.json +1 -1
- package/packages/agent-harness/dist/loader/run.d.ts +2 -0
- package/packages/agent-harness/dist/loader/run.js +1 -0
- package/packages/safejs/dist/chunks/{chunk-E6LJNTDX.js → chunk-A2XBEN3H.js} +47 -15
- package/packages/safejs/dist/chunks/{chunk-E6LJNTDX.js.map → chunk-A2XBEN3H.js.map} +2 -2
- package/packages/safejs/dist/chunks/{chunk-HNGGGIMP.js → chunk-MRH5YDMR.js} +2 -2
- package/packages/safejs/dist/cli.js +21 -5
- package/packages/safejs/dist/cli.js.map +2 -2
- package/packages/safejs/dist/core.js +1 -1
- package/packages/safejs/dist/dump.d.ts +1 -1
- package/packages/safejs/dist/index.d.ts +1 -1
- package/packages/safejs/dist/index.js +4 -2
- package/packages/safejs/dist/index.js.map +2 -2
- package/packages/safejs/dist/interp/promise-replay.d.ts +1 -1
- package/packages/safejs/dist/interp/promise-replay.js +15 -1
- package/packages/safejs/dist/run.js +33 -6
- package/packages/safejs/dist/runner/run-harness.d.ts +2 -1
- package/packages/safejs/dist/runner/run-harness.js +2 -0
- package/packages/safejs/dist/snapshot/dump.d.ts +5 -2
- package/packages/safejs/dist/snapshot/dump.js +7 -6
- /package/packages/safejs/dist/chunks/{chunk-HNGGGIMP.js.map → chunk-MRH5YDMR.js.map} +0 -0
package/package.json
CHANGED
|
@@ -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],
|
|
@@ -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,
|
|
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 (
|
|
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 {
|
|
@@ -28300,6 +28308,7 @@ function run(source, options = {}) {
|
|
|
28300
28308
|
const lifecycle = { hostCallbackDepth: 0 };
|
|
28301
28309
|
const dumpController = createDumpController(lifecycle);
|
|
28302
28310
|
const promiseTracker = createSandboxPromiseRejectionTracker();
|
|
28311
|
+
let completedSnapshot;
|
|
28303
28312
|
const execute = async () => {
|
|
28304
28313
|
const promiseReplay = new PromiseReplay(options.snapshot?.promiseReplay);
|
|
28305
28314
|
return promiseReplayContext.run(promiseReplay, async () => {
|
|
@@ -28308,8 +28317,17 @@ function run(source, options = {}) {
|
|
|
28308
28317
|
let leaveHostReplay;
|
|
28309
28318
|
let leaveInputReplay;
|
|
28310
28319
|
let createFailureSnapshot;
|
|
28311
|
-
let
|
|
28320
|
+
let cancellationSnapshot;
|
|
28321
|
+
let cancellationSnapshotError;
|
|
28312
28322
|
let snapshotScheduler;
|
|
28323
|
+
const captureCancellationSnapshot = () => {
|
|
28324
|
+
try {
|
|
28325
|
+
cancellationSnapshot = createFailureSnapshot?.();
|
|
28326
|
+
} catch (reason) {
|
|
28327
|
+
cancellationSnapshotError = { reason };
|
|
28328
|
+
}
|
|
28329
|
+
};
|
|
28330
|
+
options.signal?.addEventListener("abort", captureCancellationSnapshot, { once: true });
|
|
28313
28331
|
try {
|
|
28314
28332
|
const restoredSnapshot = options.snapshot === void 0 ? void 0 : restore(options.snapshot, { source });
|
|
28315
28333
|
if (restoredSnapshot !== void 0) {
|
|
@@ -28446,6 +28464,9 @@ function run(source, options = {}) {
|
|
|
28446
28464
|
bindings: executionScope.snapshot().bindings,
|
|
28447
28465
|
clock: options.clock,
|
|
28448
28466
|
hostCalls: hostCalls.snapshot(),
|
|
28467
|
+
replay: hostCalls.snapshotReplay(),
|
|
28468
|
+
initialInputs: initialInputs.snapshot,
|
|
28469
|
+
promiseReplay: promiseReplay.snapshot(),
|
|
28449
28470
|
random,
|
|
28450
28471
|
sourceHash
|
|
28451
28472
|
});
|
|
@@ -28477,7 +28498,6 @@ function run(source, options = {}) {
|
|
|
28477
28498
|
randomResumeState: typeof yieldPoint.replayState === "number" ? yieldPoint.replayState : void 0,
|
|
28478
28499
|
sourceHash
|
|
28479
28500
|
});
|
|
28480
|
-
lastCheckpoint = snapshot2;
|
|
28481
28501
|
return snapshot2;
|
|
28482
28502
|
};
|
|
28483
28503
|
activeSnapshotScheduler.onYield(createSnapshot);
|
|
@@ -28519,7 +28539,6 @@ function run(source, options = {}) {
|
|
|
28519
28539
|
randomResumeState: typeof yieldPoint.replayState === "number" ? yieldPoint.replayState : void 0,
|
|
28520
28540
|
sourceHash
|
|
28521
28541
|
});
|
|
28522
|
-
lastCheckpoint = snapshot2;
|
|
28523
28542
|
return snapshot2;
|
|
28524
28543
|
};
|
|
28525
28544
|
activeSnapshotScheduler.onYield(createSnapshot);
|
|
@@ -28552,6 +28571,7 @@ function run(source, options = {}) {
|
|
|
28552
28571
|
});
|
|
28553
28572
|
if (replayError !== void 0) snapshot.replayError = replayError;
|
|
28554
28573
|
dumpController.finalize(snapshot);
|
|
28574
|
+
completedSnapshot = snapshot;
|
|
28555
28575
|
return {
|
|
28556
28576
|
...result2,
|
|
28557
28577
|
snapshot
|
|
@@ -28561,9 +28581,10 @@ function run(source, options = {}) {
|
|
|
28561
28581
|
materializeWrappedErrorCause(error);
|
|
28562
28582
|
if (createFailureSnapshot !== void 0 && snapshotScheduler !== void 0) {
|
|
28563
28583
|
try {
|
|
28564
|
-
|
|
28565
|
-
|
|
28584
|
+
if (cancellationSnapshotError !== void 0) throw cancellationSnapshotError.reason;
|
|
28585
|
+
const snapshot = cancellationSnapshot ?? createFailureSnapshot();
|
|
28566
28586
|
dumpController.finalize(snapshot);
|
|
28587
|
+
await snapshotScheduler.write(snapshot);
|
|
28567
28588
|
} catch (snapshotError) {
|
|
28568
28589
|
if (snapshotError instanceof UnsnapshotableValueError) {
|
|
28569
28590
|
console.warn(`Skipping failure snapshot: ${snapshotError.message}`);
|
|
@@ -28575,6 +28596,7 @@ function run(source, options = {}) {
|
|
|
28575
28596
|
dumpController.fail(error);
|
|
28576
28597
|
throw error;
|
|
28577
28598
|
} finally {
|
|
28599
|
+
options.signal?.removeEventListener("abort", captureCancellationSnapshot);
|
|
28578
28600
|
leaveInputReplay?.();
|
|
28579
28601
|
leaveHostReplay?.();
|
|
28580
28602
|
promiseReplay.dispose();
|
|
@@ -28586,7 +28608,17 @@ function run(source, options = {}) {
|
|
|
28586
28608
|
const result = withRunResources(
|
|
28587
28609
|
options.signal,
|
|
28588
28610
|
() => withSandboxPromiseRejectionTracker(promiseTracker, execute)
|
|
28589
|
-
)
|
|
28611
|
+
).catch(async (error) => {
|
|
28612
|
+
if (completedSnapshot !== void 0) {
|
|
28613
|
+
try {
|
|
28614
|
+
await createSnapshotScheduler(options).write(completedSnapshot);
|
|
28615
|
+
} catch (snapshotError) {
|
|
28616
|
+
console.warn("Failed to write failure snapshot.", snapshotError);
|
|
28617
|
+
}
|
|
28618
|
+
}
|
|
28619
|
+
dumpController.fail(error);
|
|
28620
|
+
throw error;
|
|
28621
|
+
});
|
|
28590
28622
|
return attachDumpController(result, dumpController);
|
|
28591
28623
|
}
|
|
28592
28624
|
async function throwIfReturnedPromiseRejected(result) {
|
|
@@ -28795,4 +28827,4 @@ export {
|
|
|
28795
28827
|
FileSnapshotBackend,
|
|
28796
28828
|
run
|
|
28797
28829
|
};
|
|
28798
|
-
//# sourceMappingURL=chunk-
|
|
28830
|
+
//# sourceMappingURL=chunk-A2XBEN3H.js.map
|