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/dist/cli/commands/harness.js +13 -1
- package/dist/cli/commands/harness.js.map +1 -1
- package/dist/index.js +51 -13
- 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-HNGGGIMP.js → chunk-EUCMIR4E.js} +2 -2
- package/packages/safejs/dist/chunks/{chunk-E6LJNTDX.js → chunk-RSK47E4C.js} +34 -14
- package/packages/safejs/dist/chunks/{chunk-E6LJNTDX.js.map → chunk-RSK47E4C.js.map} +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 +19 -5
- 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-EUCMIR4E.js.map} +0 -0
|
@@ -52,8 +52,18 @@ export function run(source, options = {}) {
|
|
|
52
52
|
let leaveHostReplay;
|
|
53
53
|
let leaveInputReplay;
|
|
54
54
|
let createFailureSnapshot;
|
|
55
|
-
let
|
|
55
|
+
let cancellationSnapshot;
|
|
56
|
+
let cancellationSnapshotError;
|
|
56
57
|
let snapshotScheduler;
|
|
58
|
+
const captureCancellationSnapshot = () => {
|
|
59
|
+
try {
|
|
60
|
+
cancellationSnapshot = createFailureSnapshot?.();
|
|
61
|
+
}
|
|
62
|
+
catch (reason) {
|
|
63
|
+
cancellationSnapshotError = { reason };
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
options.signal?.addEventListener("abort", captureCancellationSnapshot, { once: true });
|
|
57
67
|
try {
|
|
58
68
|
const restoredSnapshot = options.snapshot === undefined ? undefined : restore(options.snapshot, { source });
|
|
59
69
|
if (restoredSnapshot !== undefined) {
|
|
@@ -165,6 +175,9 @@ export function run(source, options = {}) {
|
|
|
165
175
|
bindings: executionScope.snapshot().bindings,
|
|
166
176
|
clock: options.clock,
|
|
167
177
|
hostCalls: hostCalls.snapshot(),
|
|
178
|
+
replay: hostCalls.snapshotReplay(),
|
|
179
|
+
initialInputs: initialInputs.snapshot,
|
|
180
|
+
promiseReplay: promiseReplay.snapshot(),
|
|
168
181
|
random,
|
|
169
182
|
sourceHash
|
|
170
183
|
});
|
|
@@ -196,7 +209,6 @@ export function run(source, options = {}) {
|
|
|
196
209
|
randomResumeState: typeof yieldPoint.replayState === "number" ? yieldPoint.replayState : undefined,
|
|
197
210
|
sourceHash
|
|
198
211
|
});
|
|
199
|
-
lastCheckpoint = snapshot;
|
|
200
212
|
return snapshot;
|
|
201
213
|
};
|
|
202
214
|
activeSnapshotScheduler.onYield(createSnapshot);
|
|
@@ -242,7 +254,6 @@ export function run(source, options = {}) {
|
|
|
242
254
|
: undefined,
|
|
243
255
|
sourceHash
|
|
244
256
|
});
|
|
245
|
-
lastCheckpoint = snapshot;
|
|
246
257
|
return snapshot;
|
|
247
258
|
};
|
|
248
259
|
activeSnapshotScheduler.onYield(createSnapshot);
|
|
@@ -288,9 +299,11 @@ export function run(source, options = {}) {
|
|
|
288
299
|
materializeWrappedErrorCause(error);
|
|
289
300
|
if (createFailureSnapshot !== undefined && snapshotScheduler !== undefined) {
|
|
290
301
|
try {
|
|
291
|
-
|
|
292
|
-
|
|
302
|
+
if (cancellationSnapshotError !== undefined)
|
|
303
|
+
throw cancellationSnapshotError.reason;
|
|
304
|
+
const snapshot = cancellationSnapshot ?? createFailureSnapshot();
|
|
293
305
|
dumpController.finalize(snapshot);
|
|
306
|
+
await snapshotScheduler.write(snapshot);
|
|
294
307
|
}
|
|
295
308
|
catch (snapshotError) {
|
|
296
309
|
if (snapshotError instanceof UnsnapshotableValueError) {
|
|
@@ -305,6 +318,7 @@ export function run(source, options = {}) {
|
|
|
305
318
|
throw error;
|
|
306
319
|
}
|
|
307
320
|
finally {
|
|
321
|
+
options.signal?.removeEventListener("abort", captureCancellationSnapshot);
|
|
308
322
|
leaveInputReplay?.();
|
|
309
323
|
leaveHostReplay?.();
|
|
310
324
|
promiseReplay.dispose();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type Diagnostic } from "../lint.js";
|
|
2
2
|
import type { ModuleRegistry } from "../modules/registry.js";
|
|
3
3
|
import type { OtelSink } from "../observability/otel.js";
|
|
4
|
-
import { type RunResult } from "../run.js";
|
|
4
|
+
import { type RunOptions, type RunResult } from "../run.js";
|
|
5
5
|
import type { SnapshotBackend } from "../snapshot/backend.js";
|
|
6
6
|
type HarnessMeta = {
|
|
7
7
|
filepath: string;
|
|
@@ -9,6 +9,7 @@ type HarnessMeta = {
|
|
|
9
9
|
version: unknown;
|
|
10
10
|
};
|
|
11
11
|
export type RunHarnessOptions = {
|
|
12
|
+
budget?: RunOptions["budget"];
|
|
12
13
|
modulesFor: (frontmatter: Record<string, unknown>, meta: HarnessMeta) => ModuleRegistry;
|
|
13
14
|
otelSink?: OtelSink;
|
|
14
15
|
signal?: AbortSignal;
|
|
@@ -66,6 +66,7 @@ export async function runHarness(filepath, options) {
|
|
|
66
66
|
throw new LintError(lintErrors);
|
|
67
67
|
}
|
|
68
68
|
return runHarnessSource(executableSource, {
|
|
69
|
+
budget: options.budget,
|
|
69
70
|
entryPointArgs: hasDefaultExport(executableSource, filepath) ? [] : undefined,
|
|
70
71
|
filename: filepath,
|
|
71
72
|
modules,
|
|
@@ -102,6 +103,7 @@ export async function runHarnessPair(filepath, options) {
|
|
|
102
103
|
throw new LintError(lintErrors);
|
|
103
104
|
}
|
|
104
105
|
return runHarnessSource(executableSource, {
|
|
106
|
+
budget: options.budget,
|
|
105
107
|
entryPointArgs: [frontmatter],
|
|
106
108
|
filename: pair.scriptPath,
|
|
107
109
|
importMeta: {
|
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
import type { RunResult, RunSnapshot } from "../run.js";
|
|
2
|
+
export type DumpOptions = {
|
|
3
|
+
onFailure?: "throw" | "checkpoint";
|
|
4
|
+
};
|
|
2
5
|
type DumpController = {
|
|
3
6
|
fail(error: unknown): void;
|
|
4
7
|
finalize(snapshot: RunSnapshot): void;
|
|
5
8
|
onYield(createSnapshot: () => RunSnapshot): void;
|
|
6
9
|
requestCurrentSnapshot(): Promise<string>;
|
|
7
|
-
requestSnapshot(): Promise<string>;
|
|
10
|
+
requestSnapshot(options?: DumpOptions): Promise<string>;
|
|
8
11
|
};
|
|
9
12
|
export type RunLifecycle = {
|
|
10
13
|
hostCallbackDepth: number;
|
|
11
14
|
};
|
|
12
15
|
export declare function attachDumpController(result: Promise<RunResult>, controller: DumpController): Promise<RunResult>;
|
|
13
16
|
export declare function createDumpController(lifecycle?: RunLifecycle): DumpController;
|
|
14
|
-
export declare function dump(result: Pick<RunResult, "snapshot"> | PromiseLike<RunResult
|
|
17
|
+
export declare function dump(result: Pick<RunResult, "snapshot"> | PromiseLike<RunResult>, options?: DumpOptions): Promise<string>;
|
|
15
18
|
export declare function dumpCurrent(result: Pick<RunResult, "snapshot"> | PromiseLike<RunResult>): Promise<string>;
|
|
16
19
|
export declare function serializeRunSnapshot(snapshot: RunSnapshot): string;
|
|
17
20
|
export {};
|
|
@@ -61,13 +61,14 @@ export function createDumpController(lifecycle) {
|
|
|
61
61
|
}
|
|
62
62
|
return this.requestSnapshot();
|
|
63
63
|
},
|
|
64
|
-
requestSnapshot() {
|
|
64
|
+
requestSnapshot(options = {}) {
|
|
65
65
|
assertDumpAllowed();
|
|
66
66
|
if (failed !== undefined) {
|
|
67
|
-
if (
|
|
68
|
-
(
|
|
67
|
+
if ((options.onFailure === "checkpoint" ||
|
|
68
|
+
(options.onFailure === undefined && isDataBudgetError(failed.error))) &&
|
|
69
|
+
finalSnapshot !== undefined) {
|
|
69
70
|
try {
|
|
70
|
-
return Promise.resolve(serializeRunSnapshot(
|
|
71
|
+
return Promise.resolve(serializeRunSnapshot(finalSnapshot));
|
|
71
72
|
}
|
|
72
73
|
catch (error) {
|
|
73
74
|
return Promise.reject(error);
|
|
@@ -134,10 +135,10 @@ function isDataBudgetError(error) {
|
|
|
134
135
|
"budget" in error &&
|
|
135
136
|
error.budget === "dataSize");
|
|
136
137
|
}
|
|
137
|
-
export function dump(result) {
|
|
138
|
+
export function dump(result, options = {}) {
|
|
138
139
|
const controller = readDumpController(result);
|
|
139
140
|
if (controller !== undefined) {
|
|
140
|
-
return controller.requestSnapshot();
|
|
141
|
+
return controller.requestSnapshot(options);
|
|
141
142
|
}
|
|
142
143
|
if (hasSnapshot(result)) {
|
|
143
144
|
try {
|
|
File without changes
|