poe-code 11.0.22 → 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 +19 -11
- package/dist/index.js.map +3 -3
- package/dist/metafile.json +1 -1
- package/package.json +1 -1
- package/packages/safejs/dist/chunks/{chunk-IB5DSFBQ.js → chunk-3627FMJF.js} +19 -9
- package/packages/safejs/dist/chunks/{chunk-IB5DSFBQ.js.map → chunk-3627FMJF.js.map} +4 -4
- package/packages/safejs/dist/chunks/{chunk-K3DCXHEE.js → chunk-LRGHMX22.js} +2 -2
- package/packages/safejs/dist/cli.js +2 -2
- package/packages/safejs/dist/core.js +1 -1
- package/packages/safejs/dist/index.js +2 -2
- package/packages/safejs/dist/interp/host-bridge.js +1 -1
- package/packages/safejs/dist/run.js +6 -1
- package/packages/safejs/dist/runner/signal-dump.js +4 -3
- package/packages/safejs/dist/snapshot/dump.d.ts +4 -1
- package/packages/safejs/dist/snapshot/dump.js +11 -6
- /package/packages/safejs/dist/chunks/{chunk-K3DCXHEE.js.map → chunk-LRGHMX22.js.map} +0 -0
|
@@ -27,7 +27,7 @@ import {
|
|
|
27
27
|
validateMigrationSemantics,
|
|
28
28
|
validateSnapshotData,
|
|
29
29
|
validateSnapshotMigration
|
|
30
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-3627FMJF.js";
|
|
31
31
|
|
|
32
32
|
// packages/safejs/src/migrate.ts
|
|
33
33
|
import { createHash } from "node:crypto";
|
|
@@ -8055,4 +8055,4 @@ export {
|
|
|
8055
8055
|
parseMcpConfig,
|
|
8056
8056
|
makeMcpModule
|
|
8057
8057
|
};
|
|
8058
|
-
//# sourceMappingURL=chunk-
|
|
8058
|
+
//# sourceMappingURL=chunk-LRGHMX22.js.map
|
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
parseMcpConfig,
|
|
21
21
|
splitFrontmatter,
|
|
22
22
|
withBrokenPipeGuard
|
|
23
|
-
} from "./chunks/chunk-
|
|
23
|
+
} from "./chunks/chunk-LRGHMX22.js";
|
|
24
24
|
import {
|
|
25
25
|
Budget,
|
|
26
26
|
SandboxError,
|
|
@@ -32,7 +32,7 @@ import {
|
|
|
32
32
|
replaceErrorStack,
|
|
33
33
|
restore,
|
|
34
34
|
run
|
|
35
|
-
} from "./chunks/chunk-
|
|
35
|
+
} from "./chunks/chunk-3627FMJF.js";
|
|
36
36
|
import "./chunks/chunk-4YIDX44G.js";
|
|
37
37
|
|
|
38
38
|
// packages/safejs/src/cli.ts
|
|
@@ -27,7 +27,7 @@ import {
|
|
|
27
27
|
runWithSpawnUsageAccumulator,
|
|
28
28
|
splitFrontmatter,
|
|
29
29
|
supportsSpawnMode
|
|
30
|
-
} from "./chunks/chunk-
|
|
30
|
+
} from "./chunks/chunk-LRGHMX22.js";
|
|
31
31
|
import {
|
|
32
32
|
Budget,
|
|
33
33
|
FileSnapshotBackend,
|
|
@@ -49,7 +49,7 @@ import {
|
|
|
49
49
|
registerPendingHostCallPolicy,
|
|
50
50
|
restore,
|
|
51
51
|
run
|
|
52
|
-
} from "./chunks/chunk-
|
|
52
|
+
} from "./chunks/chunk-3627FMJF.js";
|
|
53
53
|
import "./chunks/chunk-4YIDX44G.js";
|
|
54
54
|
|
|
55
55
|
// packages/safejs/src/runner/run-harness.ts
|
|
@@ -150,7 +150,7 @@ function invokeHostCallback(invoke, options) {
|
|
|
150
150
|
}
|
|
151
151
|
lifecycle.hostCallbackDepth += 1;
|
|
152
152
|
try {
|
|
153
|
-
const result = invoke
|
|
153
|
+
const result = lifecycle.hostCallbackContext.run(true, invoke);
|
|
154
154
|
if (isPromiseLike(result)) {
|
|
155
155
|
return Promise.resolve(result).finally(() => {
|
|
156
156
|
lifecycle.hostCallbackDepth -= 1;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
1
2
|
import { hashSource } from "./parse/hash.js";
|
|
2
3
|
import { withRunResources } from "./interp/resources.js";
|
|
3
4
|
import { createReplayableRandom } from "./random.js";
|
|
@@ -41,7 +42,10 @@ export class UnhandledRejectionError extends Error {
|
|
|
41
42
|
}
|
|
42
43
|
const DEFAULT_MAX_CALL_DEPTH = 1_000;
|
|
43
44
|
export function run(source, options = {}) {
|
|
44
|
-
const lifecycle = {
|
|
45
|
+
const lifecycle = {
|
|
46
|
+
hostCallbackDepth: 0,
|
|
47
|
+
hostCallbackContext: new AsyncLocalStorage()
|
|
48
|
+
};
|
|
45
49
|
const dumpController = createDumpController(lifecycle);
|
|
46
50
|
const promiseTracker = createSandboxPromiseRejectionTracker();
|
|
47
51
|
let completedSnapshot;
|
|
@@ -335,6 +339,7 @@ export function run(source, options = {}) {
|
|
|
335
339
|
throw error;
|
|
336
340
|
}
|
|
337
341
|
finally {
|
|
342
|
+
lifecycle.hostCallbackContext.disable();
|
|
338
343
|
options.signal?.removeEventListener("abort", captureCancellationSnapshot);
|
|
339
344
|
leaveInputReplay?.();
|
|
340
345
|
leaveHostReplay?.();
|
|
@@ -2,9 +2,8 @@ import { randomUUID } from "node:crypto";
|
|
|
2
2
|
import { mkdir, rename, rm, writeFile as nodeWriteFile } from "node:fs/promises";
|
|
3
3
|
import { basename, dirname, join } from "node:path";
|
|
4
4
|
import { hasOwnErrorCode } from "../error-codes.js";
|
|
5
|
-
import {
|
|
5
|
+
import { dump } from "../snapshot/dump.js";
|
|
6
6
|
export function attachSignalDumpHandler(result, options = {}) {
|
|
7
|
-
const dumpResult = options.dumpResult ?? dumpCurrent;
|
|
8
7
|
const signalProcess = options.process ?? process;
|
|
9
8
|
const stderr = options.stderr ?? process.stderr;
|
|
10
9
|
const writeDumpFile = options.writeFile ?? nodeWriteFile;
|
|
@@ -19,7 +18,9 @@ export function attachSignalDumpHandler(result, options = {}) {
|
|
|
19
18
|
}
|
|
20
19
|
async function writeDump(signal) {
|
|
21
20
|
try {
|
|
22
|
-
const snapshot =
|
|
21
|
+
const snapshot = options.dumpResult === undefined
|
|
22
|
+
? await dump(result, { mode: "replay" })
|
|
23
|
+
: await options.dumpResult(result);
|
|
23
24
|
if (options.dumpPath !== undefined) {
|
|
24
25
|
const parentPath = dirname(options.dumpPath);
|
|
25
26
|
const tempPath = join(parentPath, `.${basename(options.dumpPath)}.${randomUUID()}.tmp`);
|
|
@@ -1,15 +1,18 @@
|
|
|
1
|
+
import type { AsyncLocalStorage } from "node:async_hooks";
|
|
1
2
|
import type { RunResult, RunSnapshot } from "../run.js";
|
|
2
3
|
export type DumpOptions = {
|
|
4
|
+
mode?: "capture" | "replay";
|
|
3
5
|
onFailure?: "throw" | "checkpoint";
|
|
4
6
|
};
|
|
5
7
|
type DumpController = {
|
|
6
8
|
fail(error: unknown): void;
|
|
7
9
|
finalize(snapshot: RunSnapshot): void;
|
|
8
10
|
onYield(createSnapshot: () => RunSnapshot): void;
|
|
9
|
-
requestCurrentSnapshot(): Promise<string>;
|
|
11
|
+
requestCurrentSnapshot(options?: DumpOptions): Promise<string>;
|
|
10
12
|
requestSnapshot(options?: DumpOptions): Promise<string>;
|
|
11
13
|
};
|
|
12
14
|
export type RunLifecycle = {
|
|
15
|
+
hostCallbackContext: AsyncLocalStorage<boolean>;
|
|
13
16
|
hostCallbackDepth: number;
|
|
14
17
|
};
|
|
15
18
|
export declare function attachDumpController(result: Promise<RunResult>, controller: DumpController): Promise<RunResult>;
|
|
@@ -46,8 +46,8 @@ export function createDumpController(lifecycle) {
|
|
|
46
46
|
}
|
|
47
47
|
settlePendingSnapshot(createSnapshot());
|
|
48
48
|
},
|
|
49
|
-
requestCurrentSnapshot() {
|
|
50
|
-
assertDumpAllowed();
|
|
49
|
+
requestCurrentSnapshot(options = {}) {
|
|
50
|
+
assertDumpAllowed(options);
|
|
51
51
|
if (failed !== undefined) {
|
|
52
52
|
return Promise.reject(failed.error);
|
|
53
53
|
}
|
|
@@ -59,10 +59,10 @@ export function createDumpController(lifecycle) {
|
|
|
59
59
|
return Promise.reject(error);
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
|
-
return this.requestSnapshot();
|
|
62
|
+
return this.requestSnapshot(options);
|
|
63
63
|
},
|
|
64
64
|
requestSnapshot(options = {}) {
|
|
65
|
-
assertDumpAllowed();
|
|
65
|
+
assertDumpAllowed(options);
|
|
66
66
|
if (failed !== undefined) {
|
|
67
67
|
if ((options.onFailure === "checkpoint" ||
|
|
68
68
|
(options.onFailure === undefined && isDataBudgetError(failed.error))) &&
|
|
@@ -88,6 +88,10 @@ export function createDumpController(lifecycle) {
|
|
|
88
88
|
return Promise.reject(error);
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
|
+
if (options.mode === "replay" &&
|
|
92
|
+
(latestSnapshot !== undefined || latestSnapshotFactory !== undefined)) {
|
|
93
|
+
return this.requestCurrentSnapshot(options);
|
|
94
|
+
}
|
|
91
95
|
if (pendingRequest !== undefined) {
|
|
92
96
|
return pendingRequest.promise;
|
|
93
97
|
}
|
|
@@ -105,8 +109,9 @@ export function createDumpController(lifecycle) {
|
|
|
105
109
|
return promise;
|
|
106
110
|
}
|
|
107
111
|
};
|
|
108
|
-
function assertDumpAllowed() {
|
|
109
|
-
if ((lifecycle?.hostCallbackDepth ?? 0) > 0
|
|
112
|
+
function assertDumpAllowed(options) {
|
|
113
|
+
if ((lifecycle?.hostCallbackDepth ?? 0) > 0 &&
|
|
114
|
+
(options.mode !== "replay" || lifecycle?.hostCallbackContext.getStore() === true)) {
|
|
110
115
|
throw new SandboxError("reentry");
|
|
111
116
|
}
|
|
112
117
|
}
|
|
File without changes
|