poe-code 4.0.11 → 4.0.13
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 +41 -3
- package/dist/cli/commands/harness.js.map +1 -1
- package/dist/index.js +1050 -420
- package/dist/index.js.map +4 -4
- package/dist/metafile.json +1 -1
- package/package.json +2 -1
- package/packages/safejs/dist/cli.js +24 -1
- package/packages/safejs/dist/index.d.ts +2 -0
- package/packages/safejs/dist/index.js +1 -0
- package/packages/safejs/dist/interp/cancel.js +4 -0
- package/packages/safejs/dist/interp/host-bridge.js +32 -1
- package/packages/safejs/dist/interp/promise.d.ts +1 -0
- package/packages/safejs/dist/interp/promise.js +10 -2
- package/packages/safejs/dist/modules/canonical-path.d.ts +15 -0
- package/packages/safejs/dist/modules/canonical-path.js +161 -0
- package/packages/safejs/dist/modules/fs.conformance-cases.d.ts +99 -0
- package/packages/safejs/dist/modules/fs.conformance-cases.js +1293 -0
- package/packages/safejs/dist/modules/fs.d.ts +72 -0
- package/packages/safejs/dist/modules/fs.js +558 -0
- package/packages/safejs/dist/modules/git.js +13 -33
- package/packages/safejs/dist/run.js +2 -4
package/dist/index.js
CHANGED
|
@@ -2307,7 +2307,7 @@ function browserCommand(url, platform) {
|
|
|
2307
2307
|
return { command: "xdg-open", args: [url] };
|
|
2308
2308
|
}
|
|
2309
2309
|
function launchBrowser(command, args, spawnProcess) {
|
|
2310
|
-
return new Promise((
|
|
2310
|
+
return new Promise((resolve16, reject) => {
|
|
2311
2311
|
const child = spawnProcess(command, args, { detached: true, stdio: "ignore" });
|
|
2312
2312
|
child.once("error", reject);
|
|
2313
2313
|
child.once("close", (code, signal) => {
|
|
@@ -2317,7 +2317,7 @@ function launchBrowser(command, args, spawnProcess) {
|
|
|
2317
2317
|
return;
|
|
2318
2318
|
}
|
|
2319
2319
|
child.unref();
|
|
2320
|
-
|
|
2320
|
+
resolve16();
|
|
2321
2321
|
});
|
|
2322
2322
|
});
|
|
2323
2323
|
}
|
|
@@ -10386,18 +10386,18 @@ function createDetailJobs(emit) {
|
|
|
10386
10386
|
};
|
|
10387
10387
|
}
|
|
10388
10388
|
function waitUnlessAborted(ms, signal) {
|
|
10389
|
-
return new Promise((
|
|
10389
|
+
return new Promise((resolve16) => {
|
|
10390
10390
|
if (signal.aborted) {
|
|
10391
|
-
|
|
10391
|
+
resolve16();
|
|
10392
10392
|
return;
|
|
10393
10393
|
}
|
|
10394
10394
|
const onAbort = () => {
|
|
10395
10395
|
clearTimeout(timer);
|
|
10396
|
-
|
|
10396
|
+
resolve16();
|
|
10397
10397
|
};
|
|
10398
10398
|
const timer = setTimeout(() => {
|
|
10399
10399
|
signal.removeEventListener("abort", onAbort);
|
|
10400
|
-
|
|
10400
|
+
resolve16();
|
|
10401
10401
|
}, ms);
|
|
10402
10402
|
signal.addEventListener("abort", onAbort, { once: true });
|
|
10403
10403
|
});
|
|
@@ -12865,8 +12865,8 @@ var init_runtime = __esm({
|
|
|
12865
12865
|
stopped = false;
|
|
12866
12866
|
settle;
|
|
12867
12867
|
run() {
|
|
12868
|
-
return new Promise((
|
|
12869
|
-
this.settle = { resolve:
|
|
12868
|
+
return new Promise((resolve16, reject) => {
|
|
12869
|
+
this.settle = { resolve: resolve16, reject };
|
|
12870
12870
|
try {
|
|
12871
12871
|
this.startTerminal();
|
|
12872
12872
|
if (this.config.initialRows !== void 0 && this.config.initialRows.length > 0) {
|
|
@@ -13074,7 +13074,7 @@ var init_runtime = __esm({
|
|
|
13074
13074
|
}
|
|
13075
13075
|
}
|
|
13076
13076
|
confirm(prompt) {
|
|
13077
|
-
return new Promise((
|
|
13077
|
+
return new Promise((resolve16) => {
|
|
13078
13078
|
const action = {
|
|
13079
13079
|
id: "__confirm__",
|
|
13080
13080
|
label: prompt,
|
|
@@ -13087,7 +13087,7 @@ var init_runtime = __esm({
|
|
|
13087
13087
|
kind: "confirm",
|
|
13088
13088
|
action,
|
|
13089
13089
|
rows: row === void 0 ? [] : [row],
|
|
13090
|
-
resolver:
|
|
13090
|
+
resolver: resolve16
|
|
13091
13091
|
},
|
|
13092
13092
|
dirty: REGION_MODAL
|
|
13093
13093
|
};
|
|
@@ -13378,9 +13378,9 @@ var init_core = __esm({
|
|
|
13378
13378
|
if (this.input.isTTY !== true) {
|
|
13379
13379
|
return this.promptNonTty();
|
|
13380
13380
|
}
|
|
13381
|
-
return new Promise((
|
|
13382
|
-
const onSubmit = (value) =>
|
|
13383
|
-
const onCancel = () =>
|
|
13381
|
+
return new Promise((resolve16) => {
|
|
13382
|
+
const onSubmit = (value) => resolve16(value);
|
|
13383
|
+
const onCancel = () => resolve16(CANCEL);
|
|
13384
13384
|
this.once("submit", onSubmit);
|
|
13385
13385
|
this.once("cancel", onCancel);
|
|
13386
13386
|
this.abortListener = () => {
|
|
@@ -13412,7 +13412,7 @@ var init_core = __esm({
|
|
|
13412
13412
|
return Promise.reject(new Error(nonTtyPromptMessage()));
|
|
13413
13413
|
}
|
|
13414
13414
|
readNonTtyLine() {
|
|
13415
|
-
return new Promise((
|
|
13415
|
+
return new Promise((resolve16) => {
|
|
13416
13416
|
const rl = readline2.createInterface({ input: this.input, terminal: false });
|
|
13417
13417
|
let settled = false;
|
|
13418
13418
|
const settle = (value) => {
|
|
@@ -13421,7 +13421,7 @@ var init_core = __esm({
|
|
|
13421
13421
|
}
|
|
13422
13422
|
settled = true;
|
|
13423
13423
|
rl.close();
|
|
13424
|
-
|
|
13424
|
+
resolve16(value);
|
|
13425
13425
|
};
|
|
13426
13426
|
rl.once("line", settle);
|
|
13427
13427
|
rl.once("close", () => settle(rl.line));
|
|
@@ -16493,7 +16493,7 @@ function compileGraph(schema, options = {}) {
|
|
|
16493
16493
|
const alternate = dialect === "draft7" ? "draft2020-12" : "draft7";
|
|
16494
16494
|
return map.get(mapKey2(dialect, uri)) ?? map.get(mapKey2(alternate, uri));
|
|
16495
16495
|
}
|
|
16496
|
-
function
|
|
16496
|
+
function resolve16(node, reference) {
|
|
16497
16497
|
const absolute = resolveUri(reference, node.baseUri);
|
|
16498
16498
|
const direct = findByDialect(locations, node.dialect, absolute) ?? findByDialect(resources, node.dialect, absolute) ?? findByDialect(anchors, node.dialect, absolute);
|
|
16499
16499
|
if (direct !== void 0) {
|
|
@@ -16541,7 +16541,7 @@ function compileGraph(schema, options = {}) {
|
|
|
16541
16541
|
if (!reachableDocuments.has(pending.node.documentId)) {
|
|
16542
16542
|
continue;
|
|
16543
16543
|
}
|
|
16544
|
-
const target =
|
|
16544
|
+
const target = resolve16(pending.node, pending.reference);
|
|
16545
16545
|
if (!reachableDocuments.has(target.documentId)) {
|
|
16546
16546
|
reachableDocuments.add(target.documentId);
|
|
16547
16547
|
discoveredDocument = true;
|
|
@@ -16554,7 +16554,7 @@ function compileGraph(schema, options = {}) {
|
|
|
16554
16554
|
resources,
|
|
16555
16555
|
anchors,
|
|
16556
16556
|
dynamicAnchors,
|
|
16557
|
-
resolve:
|
|
16557
|
+
resolve: resolve16,
|
|
16558
16558
|
dynamicAnchor(scope, name) {
|
|
16559
16559
|
return dynamicAnchors.get(mapKey2(scope.dialect, `${scope.resourceUri}#${name}`));
|
|
16560
16560
|
}
|
|
@@ -19448,8 +19448,8 @@ async function applyChmod(mutation, context, options) {
|
|
|
19448
19448
|
}
|
|
19449
19449
|
try {
|
|
19450
19450
|
await assertRegularWriteTarget(context, targetPath);
|
|
19451
|
-
const
|
|
19452
|
-
const currentMode = typeof
|
|
19451
|
+
const stat36 = await context.fs.stat(targetPath);
|
|
19452
|
+
const currentMode = typeof stat36.mode === "number" ? stat36.mode & 511 : null;
|
|
19453
19453
|
if (currentMode === mutation.mode) {
|
|
19454
19454
|
return {
|
|
19455
19455
|
outcome: { changed: false, effect: "none", detail: "noop" },
|
|
@@ -21683,8 +21683,8 @@ function createJobRegistry(homeDir, fs31 = defaultStateFs) {
|
|
|
21683
21683
|
}
|
|
21684
21684
|
const filePath = path13.join(jobsDir, entry);
|
|
21685
21685
|
await assertSafeJobPath(filePath);
|
|
21686
|
-
const
|
|
21687
|
-
if (!
|
|
21686
|
+
const stat36 = await fs31.stat(filePath);
|
|
21687
|
+
if (!stat36.isFile()) {
|
|
21688
21688
|
continue;
|
|
21689
21689
|
}
|
|
21690
21690
|
const job = parseJobEntry(
|
|
@@ -23422,8 +23422,8 @@ function createDockerRunner(options) {
|
|
|
23422
23422
|
let exitCodeOverride = null;
|
|
23423
23423
|
let resolveResult = null;
|
|
23424
23424
|
let abortEscalationTimers = [];
|
|
23425
|
-
const result = new Promise((
|
|
23426
|
-
resolveResult =
|
|
23425
|
+
const result = new Promise((resolve16) => {
|
|
23426
|
+
resolveResult = resolve16;
|
|
23427
23427
|
});
|
|
23428
23428
|
const clearAbortEscalation = () => {
|
|
23429
23429
|
for (const timer of abortEscalationTimers) {
|
|
@@ -23612,8 +23612,8 @@ function createHostRunner(options = {}) {
|
|
|
23612
23612
|
};
|
|
23613
23613
|
let settled = false;
|
|
23614
23614
|
let resolveResult = null;
|
|
23615
|
-
const result = new Promise((
|
|
23616
|
-
resolveResult =
|
|
23615
|
+
const result = new Promise((resolve16) => {
|
|
23616
|
+
resolveResult = resolve16;
|
|
23617
23617
|
});
|
|
23618
23618
|
const cleanupAbort = bindAbortSignal2(spec10.signal, () => {
|
|
23619
23619
|
try {
|
|
@@ -24772,7 +24772,7 @@ function createContainerJob(containerId, runner, engine, context, detachedJobCon
|
|
|
24772
24772
|
if (opts?.follow !== true || await this.status() !== "running") {
|
|
24773
24773
|
return;
|
|
24774
24774
|
}
|
|
24775
|
-
await new Promise((
|
|
24775
|
+
await new Promise((resolve16) => setTimeout(resolve16, 250));
|
|
24776
24776
|
}
|
|
24777
24777
|
},
|
|
24778
24778
|
async wait() {
|
|
@@ -24785,7 +24785,7 @@ function createContainerJob(containerId, runner, engine, context, detachedJobCon
|
|
|
24785
24785
|
if (detached.kind === "unreachable") {
|
|
24786
24786
|
return { exitCode: 1 };
|
|
24787
24787
|
}
|
|
24788
|
-
await new Promise((
|
|
24788
|
+
await new Promise((resolve16) => setTimeout(resolve16, 25));
|
|
24789
24789
|
}
|
|
24790
24790
|
}
|
|
24791
24791
|
const handle = runner.exec({
|
|
@@ -28399,8 +28399,8 @@ function createTokenBucket(rate) {
|
|
|
28399
28399
|
tokens -= 1;
|
|
28400
28400
|
return;
|
|
28401
28401
|
}
|
|
28402
|
-
await new Promise((
|
|
28403
|
-
setTimeout(
|
|
28402
|
+
await new Promise((resolve16) => {
|
|
28403
|
+
setTimeout(resolve16, Math.ceil((1 - tokens) * intervalMs));
|
|
28404
28404
|
});
|
|
28405
28405
|
}
|
|
28406
28406
|
};
|
|
@@ -28829,8 +28829,8 @@ async function readPlanPaths(fs31, directoryPath) {
|
|
|
28829
28829
|
continue;
|
|
28830
28830
|
}
|
|
28831
28831
|
const absolutePath = path27.join(directoryPath, fileName);
|
|
28832
|
-
const
|
|
28833
|
-
if (
|
|
28832
|
+
const stat36 = await fs31.stat(absolutePath);
|
|
28833
|
+
if (stat36.isFile()) {
|
|
28834
28834
|
const existingPath = pathsById.get(id);
|
|
28835
28835
|
if (existingPath !== void 0) {
|
|
28836
28836
|
throw new Error(`Duplicate active plan identifier "${id}": ${existingPath} and ${absolutePath}`);
|
|
@@ -29723,7 +29723,7 @@ async function assertManagedJobDirectory(lstat35) {
|
|
|
29723
29723
|
}
|
|
29724
29724
|
}
|
|
29725
29725
|
function sleep(ms, signal) {
|
|
29726
|
-
return new Promise((
|
|
29726
|
+
return new Promise((resolve16, reject) => {
|
|
29727
29727
|
let timer = null;
|
|
29728
29728
|
const abort = () => {
|
|
29729
29729
|
if (timer !== null) {
|
|
@@ -29737,7 +29737,7 @@ function sleep(ms, signal) {
|
|
|
29737
29737
|
}
|
|
29738
29738
|
timer = setTimeout(() => {
|
|
29739
29739
|
signal?.removeEventListener("abort", abort);
|
|
29740
|
-
|
|
29740
|
+
resolve16();
|
|
29741
29741
|
}, ms);
|
|
29742
29742
|
signal?.addEventListener("abort", abort, { once: true });
|
|
29743
29743
|
});
|
|
@@ -29951,7 +29951,7 @@ function captureRunStreams(handle, execution, onActivity) {
|
|
|
29951
29951
|
let stderr = "";
|
|
29952
29952
|
const listeners = [];
|
|
29953
29953
|
const drainPromises = [];
|
|
29954
|
-
const
|
|
29954
|
+
const bind2 = (stream, onChunk, countsAsActivity) => {
|
|
29955
29955
|
if (!stream) return;
|
|
29956
29956
|
stream.setEncoding("utf8");
|
|
29957
29957
|
let settled = false;
|
|
@@ -29963,7 +29963,7 @@ function captureRunStreams(handle, execution, onActivity) {
|
|
|
29963
29963
|
}
|
|
29964
29964
|
onChunk(chunk.toString());
|
|
29965
29965
|
};
|
|
29966
|
-
const drainPromise = new Promise((
|
|
29966
|
+
const drainPromise = new Promise((resolve16) => {
|
|
29967
29967
|
settleDrain = () => {
|
|
29968
29968
|
if (settled) {
|
|
29969
29969
|
return;
|
|
@@ -29972,7 +29972,7 @@ function captureRunStreams(handle, execution, onActivity) {
|
|
|
29972
29972
|
stream.off("end", settleDrain);
|
|
29973
29973
|
stream.off("close", settleDrain);
|
|
29974
29974
|
stream.off("error", settleDrain);
|
|
29975
|
-
|
|
29975
|
+
resolve16();
|
|
29976
29976
|
};
|
|
29977
29977
|
});
|
|
29978
29978
|
stream.on("data", listener);
|
|
@@ -29985,11 +29985,11 @@ function captureRunStreams(handle, execution, onActivity) {
|
|
|
29985
29985
|
settleDrain();
|
|
29986
29986
|
});
|
|
29987
29987
|
};
|
|
29988
|
-
|
|
29988
|
+
bind2(handle.stdout, (chunk) => {
|
|
29989
29989
|
stdout += chunk;
|
|
29990
29990
|
execution?.onStdout?.(chunk);
|
|
29991
29991
|
}, true);
|
|
29992
|
-
|
|
29992
|
+
bind2(handle.stderr, (chunk) => {
|
|
29993
29993
|
stderr += chunk;
|
|
29994
29994
|
execution?.onStderr?.(chunk);
|
|
29995
29995
|
}, execution?.activityTimeoutSource !== "stdout");
|
|
@@ -30011,8 +30011,8 @@ function createAbortSync(signal, handle, activityTimeoutMs, opts = {}) {
|
|
|
30011
30011
|
let forceKillTimer;
|
|
30012
30012
|
let terminationError;
|
|
30013
30013
|
let notifyTermination;
|
|
30014
|
-
const terminationPromise = new Promise((
|
|
30015
|
-
notifyTermination =
|
|
30014
|
+
const terminationPromise = new Promise((resolve16) => {
|
|
30015
|
+
notifyTermination = resolve16;
|
|
30016
30016
|
});
|
|
30017
30017
|
const exitWaitController = new AbortController();
|
|
30018
30018
|
const terminate = (error3) => {
|
|
@@ -30113,16 +30113,16 @@ async function writeExecutionInput(handle, input) {
|
|
|
30113
30113
|
if (stdin === null) {
|
|
30114
30114
|
return;
|
|
30115
30115
|
}
|
|
30116
|
-
await new Promise((
|
|
30116
|
+
await new Promise((resolve16, reject) => {
|
|
30117
30117
|
stdin.on("error", (error3) => {
|
|
30118
30118
|
if (hasOwnErrorCode4(error3, "EPIPE")) {
|
|
30119
|
-
|
|
30119
|
+
resolve16();
|
|
30120
30120
|
return;
|
|
30121
30121
|
}
|
|
30122
30122
|
reject(error3);
|
|
30123
30123
|
});
|
|
30124
30124
|
stdin.setDefaultEncoding("utf8");
|
|
30125
|
-
stdin.end(input,
|
|
30125
|
+
stdin.end(input, resolve16);
|
|
30126
30126
|
});
|
|
30127
30127
|
}
|
|
30128
30128
|
function isPromiseLike2(value) {
|
|
@@ -30492,12 +30492,12 @@ function runHost(spawnProcess, spec10) {
|
|
|
30492
30492
|
stdio
|
|
30493
30493
|
})
|
|
30494
30494
|
);
|
|
30495
|
-
const result = new Promise((
|
|
30495
|
+
const result = new Promise((resolve16) => {
|
|
30496
30496
|
child.once("close", (code) => {
|
|
30497
|
-
|
|
30497
|
+
resolve16({ exitCode: code ?? 1 });
|
|
30498
30498
|
});
|
|
30499
30499
|
child.once("error", () => {
|
|
30500
|
-
|
|
30500
|
+
resolve16({ exitCode: 1 });
|
|
30501
30501
|
});
|
|
30502
30502
|
});
|
|
30503
30503
|
const kill = (signal) => {
|
|
@@ -30665,9 +30665,9 @@ async function startNativeOtelCapture(agentId, content = false) {
|
|
|
30665
30665
|
const server = createServer((request, response) => {
|
|
30666
30666
|
void receive(request, response, records);
|
|
30667
30667
|
});
|
|
30668
|
-
await new Promise((
|
|
30668
|
+
await new Promise((resolve16, reject) => {
|
|
30669
30669
|
server.once("error", reject);
|
|
30670
|
-
server.listen(0, "127.0.0.1", () =>
|
|
30670
|
+
server.listen(0, "127.0.0.1", () => resolve16());
|
|
30671
30671
|
});
|
|
30672
30672
|
const address = server.address();
|
|
30673
30673
|
if (!address || typeof address === "string") {
|
|
@@ -30695,7 +30695,7 @@ async function startNativeOtelCapture(agentId, content = false) {
|
|
|
30695
30695
|
args: definition.args?.(endpoint, content) ?? [],
|
|
30696
30696
|
correlationId,
|
|
30697
30697
|
async drain() {
|
|
30698
|
-
await new Promise((
|
|
30698
|
+
await new Promise((resolve16) => server.close(() => resolve16()));
|
|
30699
30699
|
return records;
|
|
30700
30700
|
}
|
|
30701
30701
|
};
|
|
@@ -30753,10 +30753,10 @@ import { spawn as spawn3 } from "node:child_process";
|
|
|
30753
30753
|
import { constants } from "node:os";
|
|
30754
30754
|
import { setTimeout as delay } from "node:timers/promises";
|
|
30755
30755
|
function runCommand(command, args, inputOptions) {
|
|
30756
|
-
return new Promise((
|
|
30756
|
+
return new Promise((resolve16) => {
|
|
30757
30757
|
const options = normalizeCommandRunnerOptions(inputOptions);
|
|
30758
30758
|
if (options?.signal?.aborted === true) {
|
|
30759
|
-
|
|
30759
|
+
resolve16({
|
|
30760
30760
|
stdout: "",
|
|
30761
30761
|
stderr: "Command aborted before start.",
|
|
30762
30762
|
exitCode: 130,
|
|
@@ -30810,7 +30810,7 @@ function runCommand(command, args, inputOptions) {
|
|
|
30810
30810
|
}
|
|
30811
30811
|
settled = true;
|
|
30812
30812
|
cleanup();
|
|
30813
|
-
|
|
30813
|
+
resolve16(result);
|
|
30814
30814
|
};
|
|
30815
30815
|
const terminate = (reason) => {
|
|
30816
30816
|
if (settled || timedOut || aborted) {
|
|
@@ -31991,10 +31991,10 @@ function createWaitEvent(attempt, delayMs) {
|
|
|
31991
31991
|
}
|
|
31992
31992
|
function sleep2(delayMs, signal) {
|
|
31993
31993
|
throwIfAborted4(signal);
|
|
31994
|
-
return new Promise((
|
|
31994
|
+
return new Promise((resolve16, reject) => {
|
|
31995
31995
|
const timeout = setTimeout(() => {
|
|
31996
31996
|
signal?.removeEventListener("abort", onAbort);
|
|
31997
|
-
|
|
31997
|
+
resolve16();
|
|
31998
31998
|
}, delayMs);
|
|
31999
31999
|
const onAbort = () => {
|
|
32000
32000
|
clearTimeout(timeout);
|
|
@@ -32028,8 +32028,8 @@ function createEventQueue() {
|
|
|
32028
32028
|
if (closed) {
|
|
32029
32029
|
return Promise.resolve({ value: void 0, done: true });
|
|
32030
32030
|
}
|
|
32031
|
-
return new Promise((
|
|
32032
|
-
waiters.push({ resolve:
|
|
32031
|
+
return new Promise((resolve16, reject) => {
|
|
32032
|
+
waiters.push({ resolve: resolve16, reject });
|
|
32033
32033
|
});
|
|
32034
32034
|
};
|
|
32035
32035
|
return {
|
|
@@ -34990,8 +34990,8 @@ function createLineQueue() {
|
|
|
34990
34990
|
if (closed) {
|
|
34991
34991
|
return Promise.resolve({ done: true, value: void 0 });
|
|
34992
34992
|
}
|
|
34993
|
-
return new Promise((
|
|
34994
|
-
waiters.push({ resolve:
|
|
34993
|
+
return new Promise((resolve16) => {
|
|
34994
|
+
waiters.push({ resolve: resolve16 });
|
|
34995
34995
|
});
|
|
34996
34996
|
}
|
|
34997
34997
|
};
|
|
@@ -35123,8 +35123,8 @@ function spawnStreaming(input) {
|
|
|
35123
35123
|
const adapter = getAdapter(spawnConfig.adapter);
|
|
35124
35124
|
let resolveEventStreamDone;
|
|
35125
35125
|
let rejectEventStreamDone;
|
|
35126
|
-
const eventStreamDone = new Promise((
|
|
35127
|
-
resolveEventStreamDone =
|
|
35126
|
+
const eventStreamDone = new Promise((resolve16, reject) => {
|
|
35127
|
+
resolveEventStreamDone = resolve16;
|
|
35128
35128
|
rejectEventStreamDone = reject;
|
|
35129
35129
|
});
|
|
35130
35130
|
const eventQueue = [];
|
|
@@ -35194,8 +35194,8 @@ function spawnStreaming(input) {
|
|
|
35194
35194
|
if (eventsDone) {
|
|
35195
35195
|
return Promise.resolve({ done: true, value: void 0 });
|
|
35196
35196
|
}
|
|
35197
|
-
return new Promise((
|
|
35198
|
-
waiters.push({ resolve:
|
|
35197
|
+
return new Promise((resolve16, reject) => {
|
|
35198
|
+
waiters.push({ resolve: resolve16, reject });
|
|
35199
35199
|
});
|
|
35200
35200
|
}
|
|
35201
35201
|
};
|
|
@@ -35217,8 +35217,8 @@ function spawnStreaming(input) {
|
|
|
35217
35217
|
})();
|
|
35218
35218
|
const hasMiddlewares = options.middlewares !== void 0 && options.middlewares.length > 0;
|
|
35219
35219
|
let resolveMiddlewaresApplied;
|
|
35220
|
-
const middlewaresApplied = hasMiddlewares ? new Promise((
|
|
35221
|
-
resolveMiddlewaresApplied =
|
|
35220
|
+
const middlewaresApplied = hasMiddlewares ? new Promise((resolve16) => {
|
|
35221
|
+
resolveMiddlewaresApplied = resolve16;
|
|
35222
35222
|
}) : void 0;
|
|
35223
35223
|
const done = (async () => {
|
|
35224
35224
|
let restoreMcpFile;
|
|
@@ -36490,10 +36490,10 @@ var init_jsonrpc_message_layer = __esm({
|
|
|
36490
36490
|
if (params !== void 0) {
|
|
36491
36491
|
request.params = params;
|
|
36492
36492
|
}
|
|
36493
|
-
return new Promise((
|
|
36493
|
+
return new Promise((resolve16, reject) => {
|
|
36494
36494
|
this.pending.set(id, {
|
|
36495
36495
|
method,
|
|
36496
|
-
resolve:
|
|
36496
|
+
resolve: resolve16,
|
|
36497
36497
|
reject
|
|
36498
36498
|
});
|
|
36499
36499
|
try {
|
|
@@ -36643,8 +36643,8 @@ var init_acp_transport = __esm({
|
|
|
36643
36643
|
spawn: spawn11 = spawnChildProcess3
|
|
36644
36644
|
} = options;
|
|
36645
36645
|
this.command = command;
|
|
36646
|
-
this.closed = new Promise((
|
|
36647
|
-
this.resolveClosed =
|
|
36646
|
+
this.closed = new Promise((resolve16) => {
|
|
36647
|
+
this.resolveClosed = resolve16;
|
|
36648
36648
|
});
|
|
36649
36649
|
this.child = spawn11(command, [...args], {
|
|
36650
36650
|
cwd,
|
|
@@ -37216,8 +37216,8 @@ function createAsyncQueue() {
|
|
|
37216
37216
|
if (closed) {
|
|
37217
37217
|
return { done: true, value: void 0 };
|
|
37218
37218
|
}
|
|
37219
|
-
return new Promise((
|
|
37220
|
-
waiters.push({ resolve:
|
|
37219
|
+
return new Promise((resolve16, reject) => {
|
|
37220
|
+
waiters.push({ resolve: resolve16, reject });
|
|
37221
37221
|
});
|
|
37222
37222
|
},
|
|
37223
37223
|
async return() {
|
|
@@ -38253,8 +38253,8 @@ function spawnAcp(input) {
|
|
|
38253
38253
|
if (eventsDone) {
|
|
38254
38254
|
return Promise.resolve({ done: true, value: void 0 });
|
|
38255
38255
|
}
|
|
38256
|
-
return new Promise((
|
|
38257
|
-
waiters.push(
|
|
38256
|
+
return new Promise((resolve16) => {
|
|
38257
|
+
waiters.push(resolve16);
|
|
38258
38258
|
});
|
|
38259
38259
|
}
|
|
38260
38260
|
};
|
|
@@ -38263,8 +38263,8 @@ function spawnAcp(input) {
|
|
|
38263
38263
|
ctx.eventStream = events;
|
|
38264
38264
|
const hasMiddlewares = options.middlewares !== void 0 && options.middlewares.length > 0;
|
|
38265
38265
|
let resolveMiddlewaresApplied;
|
|
38266
|
-
const middlewaresApplied = hasMiddlewares ? new Promise((
|
|
38267
|
-
resolveMiddlewaresApplied =
|
|
38266
|
+
const middlewaresApplied = hasMiddlewares ? new Promise((resolve16) => {
|
|
38267
|
+
resolveMiddlewaresApplied = resolve16;
|
|
38268
38268
|
}) : void 0;
|
|
38269
38269
|
const done = (async () => {
|
|
38270
38270
|
try {
|
|
@@ -40610,8 +40610,8 @@ var init_acp_core = __esm({
|
|
|
40610
40610
|
if (this.#closed) {
|
|
40611
40611
|
return { done: true, value: void 0 };
|
|
40612
40612
|
}
|
|
40613
|
-
return new Promise((
|
|
40614
|
-
this.#resolvers.push(
|
|
40613
|
+
return new Promise((resolve16) => {
|
|
40614
|
+
this.#resolvers.push(resolve16);
|
|
40615
40615
|
});
|
|
40616
40616
|
}
|
|
40617
40617
|
async return() {
|
|
@@ -41382,13 +41382,13 @@ async function deriveEncryptionKey(getMachineIdentity, salt) {
|
|
|
41382
41382
|
if (cached2) {
|
|
41383
41383
|
return cached2;
|
|
41384
41384
|
}
|
|
41385
|
-
const keyPromise = new Promise((
|
|
41385
|
+
const keyPromise = new Promise((resolve16, reject) => {
|
|
41386
41386
|
scrypt(secret, salt, ENCRYPTION_KEY_BYTES, (error3, derivedKey) => {
|
|
41387
41387
|
if (error3) {
|
|
41388
41388
|
reject(error3);
|
|
41389
41389
|
return;
|
|
41390
41390
|
}
|
|
41391
|
-
|
|
41391
|
+
resolve16(Buffer.from(derivedKey));
|
|
41392
41392
|
});
|
|
41393
41393
|
});
|
|
41394
41394
|
derivedKeyCache.set(cacheKey, keyPromise);
|
|
@@ -41599,7 +41599,7 @@ var init_encrypted_file_store = __esm({
|
|
|
41599
41599
|
// packages/auth-store/src/keychain-store.ts
|
|
41600
41600
|
import { spawn as spawn5 } from "node:child_process";
|
|
41601
41601
|
function runSecurityCommand(command, args, options) {
|
|
41602
|
-
return new Promise((
|
|
41602
|
+
return new Promise((resolve16) => {
|
|
41603
41603
|
const child = spawn5(command, args, {
|
|
41604
41604
|
stdio: [options?.stdin === void 0 ? "ignore" : "pipe", "pipe", "pipe"]
|
|
41605
41605
|
});
|
|
@@ -41634,7 +41634,7 @@ function runSecurityCommand(command, args, options) {
|
|
|
41634
41634
|
const message2 = error3 instanceof Error ? error3.message : String(error3 ?? "Unknown error");
|
|
41635
41635
|
appendStdinError();
|
|
41636
41636
|
appendStderr(message2);
|
|
41637
|
-
|
|
41637
|
+
resolve16({
|
|
41638
41638
|
stdout,
|
|
41639
41639
|
stderr,
|
|
41640
41640
|
exitCode: 127
|
|
@@ -41642,7 +41642,7 @@ function runSecurityCommand(command, args, options) {
|
|
|
41642
41642
|
});
|
|
41643
41643
|
child.on("close", (code) => {
|
|
41644
41644
|
appendStdinError();
|
|
41645
|
-
|
|
41645
|
+
resolve16({
|
|
41646
41646
|
stdout,
|
|
41647
41647
|
stderr,
|
|
41648
41648
|
exitCode: code ?? 1
|
|
@@ -43444,9 +43444,9 @@ function spawnShellCommand(command, cwd, options) {
|
|
|
43444
43444
|
timedOut = true;
|
|
43445
43445
|
terminate();
|
|
43446
43446
|
}, options.timeoutMs);
|
|
43447
|
-
const completion = new Promise((
|
|
43447
|
+
const completion = new Promise((resolve16) => {
|
|
43448
43448
|
const resolveOutcome = (outcome) => {
|
|
43449
|
-
|
|
43449
|
+
resolve16({
|
|
43450
43450
|
...outcome,
|
|
43451
43451
|
...outcome.error === void 0 && notificationError ? { error: notificationError } : {}
|
|
43452
43452
|
});
|
|
@@ -44377,8 +44377,8 @@ async function readOptionalTrustedFile(filePath, trustedDirectory, fs31) {
|
|
|
44377
44377
|
if (!await exists(filePath, fs31)) {
|
|
44378
44378
|
return void 0;
|
|
44379
44379
|
}
|
|
44380
|
-
const
|
|
44381
|
-
if (
|
|
44380
|
+
const stat36 = await fs31.lstat(filePath);
|
|
44381
|
+
if (stat36.isSymbolicLink()) {
|
|
44382
44382
|
throw new Error(`AGENTS.md file escapes its trusted directory: ${filePath}`);
|
|
44383
44383
|
}
|
|
44384
44384
|
const [canonicalPath, canonicalDirectory] = await Promise.all([
|
|
@@ -45684,8 +45684,8 @@ function createInMemoryAcpTransport(options) {
|
|
|
45684
45684
|
let closed = false;
|
|
45685
45685
|
let sessionCounter = 0;
|
|
45686
45686
|
let resolveClosed;
|
|
45687
|
-
const closedPromise = new Promise((
|
|
45688
|
-
resolveClosed =
|
|
45687
|
+
const closedPromise = new Promise((resolve16) => {
|
|
45688
|
+
resolveClosed = resolve16;
|
|
45689
45689
|
});
|
|
45690
45690
|
const closeTransport = (reason) => {
|
|
45691
45691
|
if (closed) {
|
|
@@ -46326,7 +46326,7 @@ async function createLoopbackAuthorizationSession(options = {}) {
|
|
|
46326
46326
|
};
|
|
46327
46327
|
}
|
|
46328
46328
|
async function startServer(server) {
|
|
46329
|
-
return new Promise((
|
|
46329
|
+
return new Promise((resolve16, reject) => {
|
|
46330
46330
|
const handleError = (error3) => {
|
|
46331
46331
|
server.off("error", handleError);
|
|
46332
46332
|
reject(error3);
|
|
@@ -46335,13 +46335,13 @@ async function startServer(server) {
|
|
|
46335
46335
|
server.listen(0, "127.0.0.1", () => {
|
|
46336
46336
|
server.off("error", handleError);
|
|
46337
46337
|
const address = server.address();
|
|
46338
|
-
|
|
46338
|
+
resolve16(address.port);
|
|
46339
46339
|
});
|
|
46340
46340
|
});
|
|
46341
46341
|
}
|
|
46342
46342
|
function waitForAuthorizationCode(server, authorizationUrl, options, callbackPath) {
|
|
46343
46343
|
const expectedAuthorization = readExpectedAuthorizationCallback(authorizationUrl);
|
|
46344
|
-
return new Promise((
|
|
46344
|
+
return new Promise((resolve16, reject) => {
|
|
46345
46345
|
let settled = false;
|
|
46346
46346
|
const settle = (fn) => {
|
|
46347
46347
|
if (!settled) {
|
|
@@ -46386,7 +46386,7 @@ function waitForAuthorizationCode(server, authorizationUrl, options, callbackPat
|
|
|
46386
46386
|
);
|
|
46387
46387
|
res.writeHead(200, { "Content-Type": "text/html" });
|
|
46388
46388
|
res.end(buildSuccessPage(options.landingPage));
|
|
46389
|
-
settle(() =>
|
|
46389
|
+
settle(() => resolve16(code));
|
|
46390
46390
|
} catch (error3) {
|
|
46391
46391
|
res.writeHead(400);
|
|
46392
46392
|
res.end(error3 instanceof Error ? error3.message : "Invalid OAuth callback");
|
|
@@ -46410,7 +46410,7 @@ function waitForAuthorizationCode(server, authorizationUrl, options, callbackPat
|
|
|
46410
46410
|
callbackParameters,
|
|
46411
46411
|
expectedAuthorization
|
|
46412
46412
|
);
|
|
46413
|
-
settle(() =>
|
|
46413
|
+
settle(() => resolve16(code));
|
|
46414
46414
|
} catch (error3) {
|
|
46415
46415
|
settle(() => reject(error3 instanceof Error ? error3 : new Error(String(error3))));
|
|
46416
46416
|
}
|
|
@@ -48518,14 +48518,14 @@ var init_internal = __esm({
|
|
|
48518
48518
|
child.stderr.once("end", () => {
|
|
48519
48519
|
this.appendStderrOutput(stderrDecoder.decode());
|
|
48520
48520
|
});
|
|
48521
|
-
this.closed = new Promise((
|
|
48521
|
+
this.closed = new Promise((resolve16) => {
|
|
48522
48522
|
let settled = false;
|
|
48523
48523
|
const resolveClosed = (event) => {
|
|
48524
48524
|
if (settled) {
|
|
48525
48525
|
return;
|
|
48526
48526
|
}
|
|
48527
48527
|
settled = true;
|
|
48528
|
-
|
|
48528
|
+
resolve16(event);
|
|
48529
48529
|
};
|
|
48530
48530
|
child.once("exit", (code, signal) => {
|
|
48531
48531
|
const closedEvent = {
|
|
@@ -48614,8 +48614,8 @@ var init_internal = __esm({
|
|
|
48614
48614
|
});
|
|
48615
48615
|
this.readable = this.readStream;
|
|
48616
48616
|
this.writable = this.writeStream;
|
|
48617
|
-
this.closed = new Promise((
|
|
48618
|
-
this.resolveClosed =
|
|
48617
|
+
this.closed = new Promise((resolve16) => {
|
|
48618
|
+
this.resolveClosed = resolve16;
|
|
48619
48619
|
});
|
|
48620
48620
|
this.readStream.once("error", (error3) => {
|
|
48621
48621
|
this.dispose(error3 instanceof Error ? error3 : new Error(String(error3)));
|
|
@@ -49118,13 +49118,13 @@ var init_internal = __esm({
|
|
|
49118
49118
|
if (params !== void 0) {
|
|
49119
49119
|
message2.params = params;
|
|
49120
49120
|
}
|
|
49121
|
-
return new Promise((
|
|
49121
|
+
return new Promise((resolve16, reject) => {
|
|
49122
49122
|
const timeout = setTimeout(() => {
|
|
49123
49123
|
this.pendingRequests.delete(id);
|
|
49124
49124
|
options.onTimeout?.(id);
|
|
49125
49125
|
reject(new Error(`JSON-RPC request "${method}" timed out after ${timeoutMs}ms`));
|
|
49126
49126
|
}, timeoutMs);
|
|
49127
|
-
this.pendingRequests.set(id, { resolve:
|
|
49127
|
+
this.pendingRequests.set(id, { resolve: resolve16, reject, timeout });
|
|
49128
49128
|
try {
|
|
49129
49129
|
this.output.write(serializeJsonRpcMessage2(message2));
|
|
49130
49130
|
} catch (error3) {
|
|
@@ -49210,9 +49210,9 @@ var init_internal = __esm({
|
|
|
49210
49210
|
try {
|
|
49211
49211
|
return await Promise.race([
|
|
49212
49212
|
this.inputClosedReason,
|
|
49213
|
-
new Promise((
|
|
49213
|
+
new Promise((resolve16) => {
|
|
49214
49214
|
setTimeout(() => {
|
|
49215
|
-
|
|
49215
|
+
resolve16(streamClosedError);
|
|
49216
49216
|
}, 50);
|
|
49217
49217
|
})
|
|
49218
49218
|
]);
|
|
@@ -50270,8 +50270,8 @@ var init_agent = __esm({
|
|
|
50270
50270
|
if (this.#pending.has(intent.intentId)) {
|
|
50271
50271
|
throw new Error(`Duplicate pending tool intent: ${intent.intentId}`);
|
|
50272
50272
|
}
|
|
50273
|
-
return await new Promise((
|
|
50274
|
-
this.#pending.set(intent.intentId, { resolve:
|
|
50273
|
+
return await new Promise((resolve16, reject) => {
|
|
50274
|
+
this.#pending.set(intent.intentId, { resolve: resolve16, reject });
|
|
50275
50275
|
});
|
|
50276
50276
|
}
|
|
50277
50277
|
async fork(request) {
|
|
@@ -53448,16 +53448,16 @@ function createDefaultFs2() {
|
|
|
53448
53448
|
writeFile: fsPromises13.writeFile,
|
|
53449
53449
|
readdir: fsPromises13.readdir,
|
|
53450
53450
|
stat: async (filePath) => {
|
|
53451
|
-
const
|
|
53451
|
+
const stat36 = await fsPromises13.stat(filePath);
|
|
53452
53452
|
return {
|
|
53453
|
-
isFile: () =>
|
|
53454
|
-
isDirectory: () =>
|
|
53455
|
-
mtimeMs:
|
|
53453
|
+
isFile: () => stat36.isFile(),
|
|
53454
|
+
isDirectory: () => stat36.isDirectory(),
|
|
53455
|
+
mtimeMs: stat36.mtimeMs
|
|
53456
53456
|
};
|
|
53457
53457
|
},
|
|
53458
53458
|
lstat: async (filePath) => {
|
|
53459
|
-
const
|
|
53460
|
-
return { isSymbolicLink: () =>
|
|
53459
|
+
const stat36 = await fsPromises13.lstat(filePath);
|
|
53460
|
+
return { isSymbolicLink: () => stat36.isSymbolicLink() };
|
|
53461
53461
|
},
|
|
53462
53462
|
mkdir: async (filePath, options) => {
|
|
53463
53463
|
await fsPromises13.mkdir(filePath, options);
|
|
@@ -54239,8 +54239,8 @@ var init_complete = __esm({
|
|
|
54239
54239
|
params: completeParams,
|
|
54240
54240
|
scope: ["cli", "mcp", "sdk"],
|
|
54241
54241
|
handler: async ({ params, fs: fs31 }) => {
|
|
54242
|
-
const
|
|
54243
|
-
if (
|
|
54242
|
+
const stat36 = await lstatDocument(params.path, fs31);
|
|
54243
|
+
if (stat36.isSymbolicLink()) {
|
|
54244
54244
|
throw new UserError2(`Refusing to complete superintendent document through symbolic link: ${params.path}`);
|
|
54245
54245
|
}
|
|
54246
54246
|
const content = await readDocument5(params.path, fs31);
|
|
@@ -55069,8 +55069,8 @@ function createClient(opts) {
|
|
|
55069
55069
|
try {
|
|
55070
55070
|
await Promise.race([
|
|
55071
55071
|
flushAll,
|
|
55072
|
-
new Promise((
|
|
55073
|
-
timeout = setTimeout(
|
|
55072
|
+
new Promise((resolve16) => {
|
|
55073
|
+
timeout = setTimeout(resolve16, timeoutMs);
|
|
55074
55074
|
})
|
|
55075
55075
|
]);
|
|
55076
55076
|
} catch (err) {
|
|
@@ -57282,8 +57282,8 @@ async function waitForResume(session) {
|
|
|
57282
57282
|
if (session.stopRequested || !session.paused) {
|
|
57283
57283
|
return;
|
|
57284
57284
|
}
|
|
57285
|
-
await new Promise((
|
|
57286
|
-
session.resumeWaiters.push(
|
|
57285
|
+
await new Promise((resolve16) => {
|
|
57286
|
+
session.resumeWaiters.push(resolve16);
|
|
57287
57287
|
});
|
|
57288
57288
|
}
|
|
57289
57289
|
function stripStopReason(result) {
|
|
@@ -57309,16 +57309,16 @@ function createDefaultFs3() {
|
|
|
57309
57309
|
writeFile: fsPromises14.writeFile,
|
|
57310
57310
|
readdir: fsPromises14.readdir,
|
|
57311
57311
|
stat: async (filePath) => {
|
|
57312
|
-
const
|
|
57312
|
+
const stat36 = await fsPromises14.stat(filePath);
|
|
57313
57313
|
return {
|
|
57314
|
-
isFile: () =>
|
|
57315
|
-
isDirectory: () =>
|
|
57316
|
-
mtimeMs:
|
|
57314
|
+
isFile: () => stat36.isFile(),
|
|
57315
|
+
isDirectory: () => stat36.isDirectory(),
|
|
57316
|
+
mtimeMs: stat36.mtimeMs
|
|
57317
57317
|
};
|
|
57318
57318
|
},
|
|
57319
57319
|
lstat: async (filePath) => {
|
|
57320
|
-
const
|
|
57321
|
-
return { isSymbolicLink: () =>
|
|
57320
|
+
const stat36 = await fsPromises14.lstat(filePath);
|
|
57321
|
+
return { isSymbolicLink: () => stat36.isSymbolicLink() };
|
|
57322
57322
|
},
|
|
57323
57323
|
mkdir: async (filePath, mkdirOptions) => {
|
|
57324
57324
|
await fsPromises14.mkdir(filePath, mkdirOptions);
|
|
@@ -57494,12 +57494,12 @@ var init_run = __esm({
|
|
|
57494
57494
|
unlink: (filePath) => fsPromises14.unlink(filePath),
|
|
57495
57495
|
rename: (oldPath, newPath) => fsPromises14.rename(oldPath, newPath),
|
|
57496
57496
|
stat: async (filePath) => {
|
|
57497
|
-
const
|
|
57498
|
-
return { mode:
|
|
57497
|
+
const stat36 = await fsPromises14.stat(filePath);
|
|
57498
|
+
return { mode: stat36.mode };
|
|
57499
57499
|
},
|
|
57500
57500
|
lstat: async (filePath) => {
|
|
57501
|
-
const
|
|
57502
|
-
return { isSymbolicLink: () =>
|
|
57501
|
+
const stat36 = await fsPromises14.lstat(filePath);
|
|
57502
|
+
return { isSymbolicLink: () => stat36.isSymbolicLink() };
|
|
57503
57503
|
},
|
|
57504
57504
|
readdir: (filePath) => fsPromises14.readdir(filePath)
|
|
57505
57505
|
};
|
|
@@ -59832,7 +59832,7 @@ async function withFileLock2(lockPath, lockTimeoutMs, operation) {
|
|
|
59832
59832
|
if (Date.now() - startedAt >= lockTimeoutMs) {
|
|
59833
59833
|
throw new Error(`Timed out waiting for code review lock: ${lockPath}`);
|
|
59834
59834
|
}
|
|
59835
|
-
await new Promise((
|
|
59835
|
+
await new Promise((resolve16) => setTimeout(resolve16, 5));
|
|
59836
59836
|
}
|
|
59837
59837
|
}
|
|
59838
59838
|
try {
|
|
@@ -63126,7 +63126,7 @@ function createServer2(options) {
|
|
|
63126
63126
|
});
|
|
63127
63127
|
},
|
|
63128
63128
|
async connect(transport) {
|
|
63129
|
-
return new Promise((
|
|
63129
|
+
return new Promise((resolve16) => {
|
|
63130
63130
|
const listener = (notification) => {
|
|
63131
63131
|
transport.writable.write(`${JSON.stringify(notification)}
|
|
63132
63132
|
`);
|
|
@@ -63151,12 +63151,12 @@ function createServer2(options) {
|
|
|
63151
63151
|
rl.on("close", async () => {
|
|
63152
63152
|
await Promise.all([...pendingMessages]);
|
|
63153
63153
|
session.close();
|
|
63154
|
-
|
|
63154
|
+
resolve16();
|
|
63155
63155
|
});
|
|
63156
63156
|
});
|
|
63157
63157
|
},
|
|
63158
63158
|
async connectSDK(transport) {
|
|
63159
|
-
return new Promise((
|
|
63159
|
+
return new Promise((resolve16, reject) => {
|
|
63160
63160
|
const listener = (notification) => transport.send(notification);
|
|
63161
63161
|
const session = server.createMessageSession(listener);
|
|
63162
63162
|
transport.onmessage = async (message2) => {
|
|
@@ -63219,7 +63219,7 @@ function createServer2(options) {
|
|
|
63219
63219
|
};
|
|
63220
63220
|
transport.onclose = () => {
|
|
63221
63221
|
session.close();
|
|
63222
|
-
|
|
63222
|
+
resolve16();
|
|
63223
63223
|
};
|
|
63224
63224
|
void transport.start().catch((error3) => {
|
|
63225
63225
|
session.close();
|
|
@@ -69083,11 +69083,11 @@ function createServiceRegistry() {
|
|
|
69083
69083
|
return adapter;
|
|
69084
69084
|
};
|
|
69085
69085
|
const list = () => Array.from(canonicalAdapters.values());
|
|
69086
|
-
const
|
|
69086
|
+
const invoke2 = async (serviceName, operation, runner) => {
|
|
69087
69087
|
const adapter = require3(serviceName);
|
|
69088
69088
|
return await runner(adapter);
|
|
69089
69089
|
};
|
|
69090
|
-
return { register, discover, get, require: require3, list, invoke };
|
|
69090
|
+
return { register, discover, get, require: require3, list, invoke: invoke2 };
|
|
69091
69091
|
}
|
|
69092
69092
|
var init_service_registry = __esm({
|
|
69093
69093
|
"src/cli/service-registry.ts"() {
|
|
@@ -69292,7 +69292,7 @@ async function createLoopbackAuthorizationSession2(options = {}) {
|
|
|
69292
69292
|
};
|
|
69293
69293
|
}
|
|
69294
69294
|
async function startServer2(server) {
|
|
69295
|
-
return new Promise((
|
|
69295
|
+
return new Promise((resolve16, reject) => {
|
|
69296
69296
|
const handleError = (error3) => {
|
|
69297
69297
|
reject(error3);
|
|
69298
69298
|
};
|
|
@@ -69300,13 +69300,13 @@ async function startServer2(server) {
|
|
|
69300
69300
|
server.listen(0, "127.0.0.1", () => {
|
|
69301
69301
|
server.off("error", handleError);
|
|
69302
69302
|
const address = server.address();
|
|
69303
|
-
|
|
69303
|
+
resolve16(address.port);
|
|
69304
69304
|
});
|
|
69305
69305
|
});
|
|
69306
69306
|
}
|
|
69307
69307
|
function waitForAuthorizationCode2(server, authorizationUrl, options, callbackPath) {
|
|
69308
69308
|
const expectedAuthorization = readExpectedAuthorizationCallback2(authorizationUrl);
|
|
69309
|
-
return new Promise((
|
|
69309
|
+
return new Promise((resolve16, reject) => {
|
|
69310
69310
|
let settled = false;
|
|
69311
69311
|
const settle = (fn) => {
|
|
69312
69312
|
if (!settled) {
|
|
@@ -69355,7 +69355,7 @@ function waitForAuthorizationCode2(server, authorizationUrl, options, callbackPa
|
|
|
69355
69355
|
);
|
|
69356
69356
|
res.writeHead(200, { "Content-Type": "text/html" });
|
|
69357
69357
|
res.end(buildSuccessPage2(options.landingPage));
|
|
69358
|
-
settle(() =>
|
|
69358
|
+
settle(() => resolve16(code));
|
|
69359
69359
|
} catch (error4) {
|
|
69360
69360
|
res.writeHead(400);
|
|
69361
69361
|
res.end(error4 instanceof Error ? error4.message : "Invalid OAuth callback");
|
|
@@ -69374,7 +69374,7 @@ function waitForAuthorizationCode2(server, authorizationUrl, options, callbackPa
|
|
|
69374
69374
|
callbackParameters,
|
|
69375
69375
|
expectedAuthorization
|
|
69376
69376
|
);
|
|
69377
|
-
settle(() =>
|
|
69377
|
+
settle(() => resolve16(code));
|
|
69378
69378
|
} catch (error3) {
|
|
69379
69379
|
settle(() => reject(error3 instanceof Error ? error3 : new Error(String(error3))));
|
|
69380
69380
|
}
|
|
@@ -71095,8 +71095,8 @@ function spawn9(service, promptOrOptions, maybeOptions) {
|
|
|
71095
71095
|
})();
|
|
71096
71096
|
let resolveEvents;
|
|
71097
71097
|
let eventsResolved = false;
|
|
71098
|
-
const eventsPromise = new Promise((
|
|
71099
|
-
resolveEvents =
|
|
71098
|
+
const eventsPromise = new Promise((resolve16) => {
|
|
71099
|
+
resolveEvents = resolve16;
|
|
71100
71100
|
});
|
|
71101
71101
|
const resolveEventsOnce = (value) => {
|
|
71102
71102
|
if (eventsResolved) return;
|
|
@@ -71459,10 +71459,10 @@ function calculateRetryBackoffMs(baseBackoffMs, completedAttempt) {
|
|
|
71459
71459
|
}
|
|
71460
71460
|
function sleep3(delayMs, signal) {
|
|
71461
71461
|
throwIfAborted5(signal);
|
|
71462
|
-
return new Promise((
|
|
71462
|
+
return new Promise((resolve16, reject) => {
|
|
71463
71463
|
const timeout = setTimeout(() => {
|
|
71464
71464
|
signal?.removeEventListener("abort", onAbort);
|
|
71465
|
-
|
|
71465
|
+
resolve16();
|
|
71466
71466
|
}, delayMs);
|
|
71467
71467
|
const onAbort = () => {
|
|
71468
71468
|
clearTimeout(timeout);
|
|
@@ -71496,8 +71496,8 @@ function createEventQueue2() {
|
|
|
71496
71496
|
if (closed) {
|
|
71497
71497
|
return Promise.resolve({ value: void 0, done: true });
|
|
71498
71498
|
}
|
|
71499
|
-
return new Promise((
|
|
71500
|
-
waiters.push({ resolve:
|
|
71499
|
+
return new Promise((resolve16, reject) => {
|
|
71500
|
+
waiters.push({ resolve: resolve16, reject });
|
|
71501
71501
|
});
|
|
71502
71502
|
};
|
|
71503
71503
|
return {
|
|
@@ -72304,11 +72304,11 @@ function createDefaultFs4() {
|
|
|
72304
72304
|
readFile: fsPromises15.readFile,
|
|
72305
72305
|
readdir: fsPromises15.readdir,
|
|
72306
72306
|
stat: async (filePath) => {
|
|
72307
|
-
const
|
|
72307
|
+
const stat36 = await fsPromises15.stat(filePath);
|
|
72308
72308
|
return {
|
|
72309
|
-
isFile: () =>
|
|
72310
|
-
isDirectory: () =>
|
|
72311
|
-
mtimeMs:
|
|
72309
|
+
isFile: () => stat36.isFile(),
|
|
72310
|
+
isDirectory: () => stat36.isDirectory(),
|
|
72311
|
+
mtimeMs: stat36.mtimeMs
|
|
72312
72312
|
};
|
|
72313
72313
|
}
|
|
72314
72314
|
};
|
|
@@ -72331,13 +72331,13 @@ function countCompletedTasks(planPath, content) {
|
|
|
72331
72331
|
}
|
|
72332
72332
|
async function ensurePlanExists(fs31, cwd, planPath) {
|
|
72333
72333
|
const absolutePath = path81.isAbsolute(planPath) ? planPath : path81.resolve(cwd, planPath);
|
|
72334
|
-
const
|
|
72334
|
+
const stat36 = await fs31.stat(absolutePath).catch((error3) => {
|
|
72335
72335
|
if (isNotFound3(error3)) {
|
|
72336
72336
|
return void 0;
|
|
72337
72337
|
}
|
|
72338
72338
|
throw error3;
|
|
72339
72339
|
});
|
|
72340
|
-
if (
|
|
72340
|
+
if (stat36 === void 0 || !stat36.isFile()) {
|
|
72341
72341
|
throw new UserError(
|
|
72342
72342
|
`Plan not found at "${planPath}".
|
|
72343
72343
|
Pass --plan <path> to an existing plan file, or run "poe-code pipeline show-plan-path" to see where plans are discovered.`
|
|
@@ -72853,16 +72853,16 @@ function createDefaultFs5() {
|
|
|
72853
72853
|
writeFile: fsPromises16.writeFile,
|
|
72854
72854
|
readdir: fsPromises16.readdir,
|
|
72855
72855
|
stat: async (filePath) => {
|
|
72856
|
-
const
|
|
72856
|
+
const stat36 = await fsPromises16.stat(filePath);
|
|
72857
72857
|
return {
|
|
72858
|
-
isFile: () =>
|
|
72859
|
-
isDirectory: () =>
|
|
72860
|
-
mtimeMs:
|
|
72858
|
+
isFile: () => stat36.isFile(),
|
|
72859
|
+
isDirectory: () => stat36.isDirectory(),
|
|
72860
|
+
mtimeMs: stat36.mtimeMs
|
|
72861
72861
|
};
|
|
72862
72862
|
},
|
|
72863
72863
|
lstat: async (filePath) => {
|
|
72864
|
-
const
|
|
72865
|
-
return { isSymbolicLink: () =>
|
|
72864
|
+
const stat36 = await fsPromises16.lstat(filePath);
|
|
72865
|
+
return { isSymbolicLink: () => stat36.isSymbolicLink() };
|
|
72866
72866
|
},
|
|
72867
72867
|
mkdir: async (filePath, options) => {
|
|
72868
72868
|
await fsPromises16.mkdir(filePath, options);
|
|
@@ -74027,16 +74027,16 @@ function createDefaultFs7() {
|
|
|
74027
74027
|
writeFile: (filePath, content, options) => fsPromises18.writeFile(filePath, content, options ?? { encoding: "utf8" }),
|
|
74028
74028
|
readdir: fsPromises18.readdir,
|
|
74029
74029
|
stat: async (filePath) => {
|
|
74030
|
-
const
|
|
74030
|
+
const stat36 = await fsPromises18.stat(filePath);
|
|
74031
74031
|
return {
|
|
74032
|
-
isFile: () =>
|
|
74033
|
-
isDirectory: () =>
|
|
74034
|
-
mtimeMs:
|
|
74032
|
+
isFile: () => stat36.isFile(),
|
|
74033
|
+
isDirectory: () => stat36.isDirectory(),
|
|
74034
|
+
mtimeMs: stat36.mtimeMs
|
|
74035
74035
|
};
|
|
74036
74036
|
},
|
|
74037
74037
|
lstat: async (filePath) => {
|
|
74038
|
-
const
|
|
74039
|
-
return { isSymbolicLink: () =>
|
|
74038
|
+
const stat36 = await fsPromises18.lstat(filePath);
|
|
74039
|
+
return { isSymbolicLink: () => stat36.isSymbolicLink() };
|
|
74040
74040
|
},
|
|
74041
74041
|
mkdir: async (filePath, options) => {
|
|
74042
74042
|
await fsPromises18.mkdir(filePath, options);
|
|
@@ -74777,15 +74777,15 @@ function createDefaultFs8() {
|
|
|
74777
74777
|
readFile: fsPromises19.readFile,
|
|
74778
74778
|
readdir: fsPromises19.readdir,
|
|
74779
74779
|
lstat: async (filePath) => {
|
|
74780
|
-
const
|
|
74781
|
-
return { isSymbolicLink: () =>
|
|
74780
|
+
const stat36 = await fsPromises19.lstat(filePath);
|
|
74781
|
+
return { isSymbolicLink: () => stat36.isSymbolicLink() };
|
|
74782
74782
|
},
|
|
74783
74783
|
stat: async (filePath) => {
|
|
74784
|
-
const
|
|
74784
|
+
const stat36 = await fsPromises19.stat(filePath);
|
|
74785
74785
|
return {
|
|
74786
|
-
isFile: () =>
|
|
74787
|
-
isDirectory: () =>
|
|
74788
|
-
mtimeMs:
|
|
74786
|
+
isFile: () => stat36.isFile(),
|
|
74787
|
+
isDirectory: () => stat36.isDirectory(),
|
|
74788
|
+
mtimeMs: stat36.mtimeMs
|
|
74789
74789
|
};
|
|
74790
74790
|
}
|
|
74791
74791
|
};
|
|
@@ -75088,15 +75088,15 @@ function createDefaultFs9() {
|
|
|
75088
75088
|
readdir: fsPromises20.readdir,
|
|
75089
75089
|
open: (filePath, flags) => fsPromises20.open(filePath, flags),
|
|
75090
75090
|
lstat: async (filePath) => {
|
|
75091
|
-
const
|
|
75092
|
-
return { isSymbolicLink: () =>
|
|
75091
|
+
const stat36 = await fsPromises20.lstat(filePath);
|
|
75092
|
+
return { isSymbolicLink: () => stat36.isSymbolicLink() };
|
|
75093
75093
|
},
|
|
75094
75094
|
stat: async (filePath) => {
|
|
75095
|
-
const
|
|
75095
|
+
const stat36 = await fsPromises20.stat(filePath);
|
|
75096
75096
|
return {
|
|
75097
|
-
isFile: () =>
|
|
75098
|
-
isDirectory: () =>
|
|
75099
|
-
mtimeMs:
|
|
75097
|
+
isFile: () => stat36.isFile(),
|
|
75098
|
+
isDirectory: () => stat36.isDirectory(),
|
|
75099
|
+
mtimeMs: stat36.mtimeMs
|
|
75100
75100
|
};
|
|
75101
75101
|
},
|
|
75102
75102
|
unlink: async (filePath) => {
|
|
@@ -75622,16 +75622,16 @@ function createDefaultFs10() {
|
|
|
75622
75622
|
readdir: fsPromises21.readdir,
|
|
75623
75623
|
realpath: fsPromises21.realpath,
|
|
75624
75624
|
stat: async (filePath) => {
|
|
75625
|
-
const
|
|
75625
|
+
const stat36 = await fsPromises21.stat(filePath);
|
|
75626
75626
|
return {
|
|
75627
|
-
isFile: () =>
|
|
75628
|
-
isDirectory: () =>
|
|
75629
|
-
mtimeMs:
|
|
75627
|
+
isFile: () => stat36.isFile(),
|
|
75628
|
+
isDirectory: () => stat36.isDirectory(),
|
|
75629
|
+
mtimeMs: stat36.mtimeMs
|
|
75630
75630
|
};
|
|
75631
75631
|
},
|
|
75632
75632
|
lstat: async (filePath) => {
|
|
75633
|
-
const
|
|
75634
|
-
return { isSymbolicLink: () =>
|
|
75633
|
+
const stat36 = await fsPromises21.lstat(filePath);
|
|
75634
|
+
return { isSymbolicLink: () => stat36.isSymbolicLink() };
|
|
75635
75635
|
},
|
|
75636
75636
|
mkdir: async (directoryPath, mkdirOptions) => {
|
|
75637
75637
|
await fsPromises21.mkdir(directoryPath, mkdirOptions);
|
|
@@ -75782,16 +75782,16 @@ async function discoverPlanDirectoryEntries(options) {
|
|
|
75782
75782
|
if (canonicalPath !== path89.resolve(absolutePath)) {
|
|
75783
75783
|
throw new Error(`Plan file must not be a symbolic link: ${path89.join(options.displayDir, name)}`);
|
|
75784
75784
|
}
|
|
75785
|
-
const
|
|
75785
|
+
const stat36 = await options.fs.stat(absolutePath).catch((error3) => {
|
|
75786
75786
|
if (isNotFound4(error3)) {
|
|
75787
75787
|
return void 0;
|
|
75788
75788
|
}
|
|
75789
75789
|
throw error3;
|
|
75790
75790
|
});
|
|
75791
|
-
if (
|
|
75791
|
+
if (stat36 === void 0) {
|
|
75792
75792
|
continue;
|
|
75793
75793
|
}
|
|
75794
|
-
if (!
|
|
75794
|
+
if (!stat36.isFile()) {
|
|
75795
75795
|
continue;
|
|
75796
75796
|
}
|
|
75797
75797
|
const displayPath = path89.join(options.displayDir, name);
|
|
@@ -75817,7 +75817,7 @@ async function discoverPlanDirectoryEntries(options) {
|
|
|
75817
75817
|
format: metadata.format,
|
|
75818
75818
|
title: metadata.title,
|
|
75819
75819
|
detail: metadata.detail,
|
|
75820
|
-
updatedAt:
|
|
75820
|
+
updatedAt: stat36.mtimeMs,
|
|
75821
75821
|
...savedForLater === void 0 ? {} : { savedForLater }
|
|
75822
75822
|
});
|
|
75823
75823
|
}
|
|
@@ -76237,13 +76237,13 @@ async function loadMarkdownUnlessAborted(signal, load3) {
|
|
|
76237
76237
|
if (signal.aborted) {
|
|
76238
76238
|
return void 0;
|
|
76239
76239
|
}
|
|
76240
|
-
return new Promise((
|
|
76240
|
+
return new Promise((resolve16, reject) => {
|
|
76241
76241
|
const abort = () => {
|
|
76242
|
-
|
|
76242
|
+
resolve16(void 0);
|
|
76243
76243
|
};
|
|
76244
76244
|
signal.addEventListener("abort", abort, { once: true });
|
|
76245
76245
|
load3().then((markdown) => {
|
|
76246
|
-
|
|
76246
|
+
resolve16(signal.aborted ? void 0 : markdown);
|
|
76247
76247
|
}, reject).finally(() => {
|
|
76248
76248
|
signal.removeEventListener("abort", abort);
|
|
76249
76249
|
});
|
|
@@ -77948,15 +77948,15 @@ async function discoverMarkdownFiles(fs31, absoluteDirectory, parentRelativePath
|
|
|
77948
77948
|
for (const entry of [...entries].sort((left, right) => left.localeCompare(right))) {
|
|
77949
77949
|
const absolutePath = path94.join(absoluteDirectory, entry);
|
|
77950
77950
|
const relativePath = parentRelativePath.length > 0 ? path94.join(parentRelativePath, entry) : entry;
|
|
77951
|
-
const
|
|
77952
|
-
if (
|
|
77951
|
+
const stat36 = await fs31.stat(absolutePath);
|
|
77952
|
+
if (stat36.isDirectory()) {
|
|
77953
77953
|
if (entry === "archive") {
|
|
77954
77954
|
continue;
|
|
77955
77955
|
}
|
|
77956
77956
|
markdownFiles.push(...await discoverMarkdownFiles(fs31, absolutePath, relativePath));
|
|
77957
77957
|
continue;
|
|
77958
77958
|
}
|
|
77959
|
-
if (!
|
|
77959
|
+
if (!stat36.isFile() || !entry.toLowerCase().endsWith(".md")) {
|
|
77960
77960
|
continue;
|
|
77961
77961
|
}
|
|
77962
77962
|
markdownFiles.push({
|
|
@@ -79188,11 +79188,11 @@ async function assertPathAncestorsHaveNoSymbolicLinks(targetPath) {
|
|
|
79188
79188
|
let currentPath = root;
|
|
79189
79189
|
for (const segment of segments.slice(0, -1)) {
|
|
79190
79190
|
currentPath = path98.join(currentPath, segment);
|
|
79191
|
-
const
|
|
79192
|
-
if (
|
|
79191
|
+
const stat36 = await lstatIfExists(currentPath);
|
|
79192
|
+
if (stat36 === void 0) {
|
|
79193
79193
|
return;
|
|
79194
79194
|
}
|
|
79195
|
-
if (
|
|
79195
|
+
if (stat36.isSymbolicLink()) {
|
|
79196
79196
|
throw new Error(`workspace path must not contain symbolic links: ${targetPath}`);
|
|
79197
79197
|
}
|
|
79198
79198
|
}
|
|
@@ -80696,8 +80696,8 @@ async function withBudget(promise, ms) {
|
|
|
80696
80696
|
try {
|
|
80697
80697
|
return await Promise.race([
|
|
80698
80698
|
promise,
|
|
80699
|
-
new Promise((
|
|
80700
|
-
timer = setTimeout(() =>
|
|
80699
|
+
new Promise((resolve16) => {
|
|
80700
|
+
timer = setTimeout(() => resolve16(void 0), ms);
|
|
80701
80701
|
})
|
|
80702
80702
|
]);
|
|
80703
80703
|
} finally {
|
|
@@ -80915,8 +80915,8 @@ async function removeDirectory2(fs31, directoryPath) {
|
|
|
80915
80915
|
}
|
|
80916
80916
|
for (const entry of entries) {
|
|
80917
80917
|
const entryPath = path105.join(directoryPath, entry);
|
|
80918
|
-
const
|
|
80919
|
-
if (
|
|
80918
|
+
const stat36 = await fs31.stat(entryPath);
|
|
80919
|
+
if (stat36.isFile()) {
|
|
80920
80920
|
await fs31.rm(entryPath, { force: true });
|
|
80921
80921
|
continue;
|
|
80922
80922
|
}
|
|
@@ -81004,8 +81004,8 @@ function createStateStore(stateDir, fs31 = nodeFs7) {
|
|
|
81004
81004
|
}
|
|
81005
81005
|
const entryPath = path105.join(stateDir, entry);
|
|
81006
81006
|
try {
|
|
81007
|
-
const
|
|
81008
|
-
if (
|
|
81007
|
+
const stat36 = await fs31.stat(entryPath);
|
|
81008
|
+
if (stat36.isFile()) {
|
|
81009
81009
|
continue;
|
|
81010
81010
|
}
|
|
81011
81011
|
} catch (error3) {
|
|
@@ -81298,7 +81298,7 @@ function waitForLogPattern(pattern, options) {
|
|
|
81298
81298
|
return Promise.reject(new Error("A subscribable log source is required for log-pattern readiness checks."));
|
|
81299
81299
|
}
|
|
81300
81300
|
const logSource = options.onLog;
|
|
81301
|
-
return new Promise((
|
|
81301
|
+
return new Promise((resolve16) => {
|
|
81302
81302
|
let finished = false;
|
|
81303
81303
|
const timeout = setTimeout(() => {
|
|
81304
81304
|
finish(false);
|
|
@@ -81320,7 +81320,7 @@ function waitForLogPattern(pattern, options) {
|
|
|
81320
81320
|
clearTimeout(timeout);
|
|
81321
81321
|
options.signal?.removeEventListener("abort", onAbort);
|
|
81322
81322
|
unsubscribe();
|
|
81323
|
-
|
|
81323
|
+
resolve16(result);
|
|
81324
81324
|
}
|
|
81325
81325
|
});
|
|
81326
81326
|
}
|
|
@@ -81332,7 +81332,7 @@ function waitForTcp(check, options) {
|
|
|
81332
81332
|
const timeoutMs = options.timeoutMs ?? check.timeoutMs ?? 3e4;
|
|
81333
81333
|
assertValidTimeout(timeoutMs, "TCP readiness timeout");
|
|
81334
81334
|
const deadline = Date.now() + timeoutMs;
|
|
81335
|
-
return new Promise((
|
|
81335
|
+
return new Promise((resolve16) => {
|
|
81336
81336
|
let finished = false;
|
|
81337
81337
|
let activeSocket;
|
|
81338
81338
|
let retryTimer;
|
|
@@ -81399,7 +81399,7 @@ function waitForTcp(check, options) {
|
|
|
81399
81399
|
activeSocket?.destroy();
|
|
81400
81400
|
activeSocket = void 0;
|
|
81401
81401
|
signal?.removeEventListener("abort", onAbort);
|
|
81402
|
-
|
|
81402
|
+
resolve16(result);
|
|
81403
81403
|
}
|
|
81404
81404
|
});
|
|
81405
81405
|
}
|
|
@@ -81758,8 +81758,8 @@ async function hasSurvivedSettleWindow(activeHandle, settleMs) {
|
|
|
81758
81758
|
return true;
|
|
81759
81759
|
}
|
|
81760
81760
|
let timer;
|
|
81761
|
-
const survived = new Promise((
|
|
81762
|
-
timer = setTimeout(() =>
|
|
81761
|
+
const survived = new Promise((resolve16) => {
|
|
81762
|
+
timer = setTimeout(() => resolve16(true), settleMs);
|
|
81763
81763
|
});
|
|
81764
81764
|
try {
|
|
81765
81765
|
return await Promise.race([activeHandle.result.then(() => false, () => false), survived]);
|
|
@@ -81792,8 +81792,8 @@ function assertValidRestartConfig(spec10) {
|
|
|
81792
81792
|
}
|
|
81793
81793
|
}
|
|
81794
81794
|
function delay2(durationMs) {
|
|
81795
|
-
return new Promise((
|
|
81796
|
-
setTimeout(
|
|
81795
|
+
return new Promise((resolve16) => {
|
|
81796
|
+
setTimeout(resolve16, durationMs);
|
|
81797
81797
|
});
|
|
81798
81798
|
}
|
|
81799
81799
|
async function terminateHandle(activeHandle) {
|
|
@@ -81805,7 +81805,7 @@ async function terminateHandle(activeHandle) {
|
|
|
81805
81805
|
}
|
|
81806
81806
|
}
|
|
81807
81807
|
function waitForExit2(activeHandle, timeoutMs) {
|
|
81808
|
-
return new Promise((
|
|
81808
|
+
return new Promise((resolve16) => {
|
|
81809
81809
|
let finished = false;
|
|
81810
81810
|
const timeout = setTimeout(() => {
|
|
81811
81811
|
finish(false);
|
|
@@ -81819,7 +81819,7 @@ function waitForExit2(activeHandle, timeoutMs) {
|
|
|
81819
81819
|
}
|
|
81820
81820
|
finished = true;
|
|
81821
81821
|
clearTimeout(timeout);
|
|
81822
|
-
|
|
81822
|
+
resolve16(result);
|
|
81823
81823
|
}
|
|
81824
81824
|
});
|
|
81825
81825
|
}
|
|
@@ -81847,7 +81847,7 @@ function pipeOutput(stream, output, write2, logSource) {
|
|
|
81847
81847
|
if (stream === null) {
|
|
81848
81848
|
return Promise.resolve();
|
|
81849
81849
|
}
|
|
81850
|
-
return new Promise((
|
|
81850
|
+
return new Promise((resolve16, reject) => {
|
|
81851
81851
|
let remainder = "";
|
|
81852
81852
|
let writes = Promise.resolve();
|
|
81853
81853
|
stream.setEncoding("utf8");
|
|
@@ -81879,7 +81879,7 @@ function pipeOutput(stream, output, write2, logSource) {
|
|
|
81879
81879
|
});
|
|
81880
81880
|
}
|
|
81881
81881
|
void writes.then(() => {
|
|
81882
|
-
|
|
81882
|
+
resolve16();
|
|
81883
81883
|
}, reject);
|
|
81884
81884
|
});
|
|
81885
81885
|
stream.once("error", reject);
|
|
@@ -81920,9 +81920,9 @@ function resolveWorkspaceHomeDir(stateDir) {
|
|
|
81920
81920
|
return os14.homedir();
|
|
81921
81921
|
}
|
|
81922
81922
|
function execWorkspaceCommand(command, args, cwd, signal) {
|
|
81923
|
-
return new Promise((
|
|
81923
|
+
return new Promise((resolve16) => {
|
|
81924
81924
|
if (signal?.aborted) {
|
|
81925
|
-
|
|
81925
|
+
resolve16({
|
|
81926
81926
|
stdout: "",
|
|
81927
81927
|
stderr: "Workspace command aborted.",
|
|
81928
81928
|
exitCode: 130
|
|
@@ -81960,7 +81960,7 @@ function execWorkspaceCommand(command, args, cwd, signal) {
|
|
|
81960
81960
|
}
|
|
81961
81961
|
settled = true;
|
|
81962
81962
|
cleanup();
|
|
81963
|
-
|
|
81963
|
+
resolve16(result);
|
|
81964
81964
|
};
|
|
81965
81965
|
const terminate = (reason) => {
|
|
81966
81966
|
if (settled || timedOut || aborted) {
|
|
@@ -82271,9 +82271,9 @@ function createFollowLogCursor() {
|
|
|
82271
82271
|
}
|
|
82272
82272
|
async function readInitialFollowLogWindow(fs31, baseDir, id, stream, lines, cursor2) {
|
|
82273
82273
|
assertValidLogLineCount(lines);
|
|
82274
|
-
const
|
|
82275
|
-
resetFollowCursor(cursor2,
|
|
82276
|
-
if (
|
|
82274
|
+
const stat36 = await statFollowedLog(fs31, baseDir, id, stream);
|
|
82275
|
+
resetFollowCursor(cursor2, stat36?.fileId ?? null);
|
|
82276
|
+
if (stat36 === null) {
|
|
82277
82277
|
return [];
|
|
82278
82278
|
}
|
|
82279
82279
|
const bytes = await readFollowedLogBytes(
|
|
@@ -82294,13 +82294,13 @@ function assertValidLogLineCount(lines) {
|
|
|
82294
82294
|
}
|
|
82295
82295
|
}
|
|
82296
82296
|
async function primeFollowCursor(fs31, baseDir, id, stream, cursor2) {
|
|
82297
|
-
const
|
|
82298
|
-
resetFollowCursor(cursor2,
|
|
82299
|
-
if (
|
|
82297
|
+
const stat36 = await statFollowedLog(fs31, baseDir, id, stream);
|
|
82298
|
+
resetFollowCursor(cursor2, stat36?.fileId ?? null);
|
|
82299
|
+
if (stat36 === null) {
|
|
82300
82300
|
return;
|
|
82301
82301
|
}
|
|
82302
|
-
if (
|
|
82303
|
-
cursor2.offset =
|
|
82302
|
+
if (stat36.size !== null) {
|
|
82303
|
+
cursor2.offset = stat36.size;
|
|
82304
82304
|
return;
|
|
82305
82305
|
}
|
|
82306
82306
|
const bytes = await readFollowedLogBytes(
|
|
@@ -82308,21 +82308,21 @@ async function primeFollowCursor(fs31, baseDir, id, stream, cursor2) {
|
|
|
82308
82308
|
resolveCurrentLogPath(baseDir, id, stream),
|
|
82309
82309
|
0
|
|
82310
82310
|
);
|
|
82311
|
-
resetFollowCursor(cursor2,
|
|
82311
|
+
resetFollowCursor(cursor2, stat36.fileId);
|
|
82312
82312
|
cursor2.offset = bytes.byteLength;
|
|
82313
82313
|
}
|
|
82314
82314
|
async function readFollowedLogDelta(fs31, baseDir, id, stream, cursor2) {
|
|
82315
|
-
const
|
|
82316
|
-
if (
|
|
82315
|
+
const stat36 = await statFollowedLog(fs31, baseDir, id, stream);
|
|
82316
|
+
if (stat36 === null) {
|
|
82317
82317
|
resetFollowCursor(cursor2, null);
|
|
82318
82318
|
return [];
|
|
82319
82319
|
}
|
|
82320
|
-
if (cursor2.fileId !== null &&
|
|
82321
|
-
resetFollowCursor(cursor2,
|
|
82320
|
+
if (cursor2.fileId !== null && stat36.fileId !== null && cursor2.fileId !== stat36.fileId || stat36.size !== null && stat36.size < cursor2.offset) {
|
|
82321
|
+
resetFollowCursor(cursor2, stat36.fileId);
|
|
82322
82322
|
} else if (cursor2.fileId === null) {
|
|
82323
|
-
cursor2.fileId =
|
|
82323
|
+
cursor2.fileId = stat36.fileId;
|
|
82324
82324
|
}
|
|
82325
|
-
if (
|
|
82325
|
+
if (stat36.size !== null && stat36.size === cursor2.offset) {
|
|
82326
82326
|
return [];
|
|
82327
82327
|
}
|
|
82328
82328
|
const bytes = await readFollowedLogBytes(
|
|
@@ -82342,10 +82342,10 @@ async function statFollowedLog(fs31, baseDir, id, stream) {
|
|
|
82342
82342
|
const logPath = resolveCurrentLogPath(baseDir, id, stream);
|
|
82343
82343
|
await assertPathNotSymbolicLink(fs31, logPath);
|
|
82344
82344
|
try {
|
|
82345
|
-
const
|
|
82345
|
+
const stat36 = await fs31.stat(logPath);
|
|
82346
82346
|
return {
|
|
82347
|
-
fileId: getFileId(
|
|
82348
|
-
size: typeof
|
|
82347
|
+
fileId: getFileId(stat36),
|
|
82348
|
+
size: typeof stat36.size === "number" ? stat36.size : null
|
|
82349
82349
|
};
|
|
82350
82350
|
} catch (error3) {
|
|
82351
82351
|
if (isNotFoundError9(error3)) {
|
|
@@ -82385,8 +82385,8 @@ function resetFollowCursor(cursor2, fileId3) {
|
|
|
82385
82385
|
function normalizeLogLine2(line) {
|
|
82386
82386
|
return line.endsWith("\r") ? line.slice(0, -1) : line;
|
|
82387
82387
|
}
|
|
82388
|
-
function getFileId(
|
|
82389
|
-
return typeof
|
|
82388
|
+
function getFileId(stat36) {
|
|
82389
|
+
return typeof stat36.dev === "number" && typeof stat36.ino === "number" ? `${stat36.dev}:${stat36.ino}` : null;
|
|
82390
82390
|
}
|
|
82391
82391
|
async function removeManagedProcess(options) {
|
|
82392
82392
|
const fs31 = options.fs ?? defaultFs3();
|
|
@@ -82600,8 +82600,8 @@ async function listIds(fs31, baseDir) {
|
|
|
82600
82600
|
const entryPath = path108.join(baseDir, entry);
|
|
82601
82601
|
try {
|
|
82602
82602
|
await assertPathNotSymbolicLink(fs31, entryPath);
|
|
82603
|
-
const
|
|
82604
|
-
if (!
|
|
82603
|
+
const stat36 = await fs31.stat(entryPath);
|
|
82604
|
+
if (!stat36.isFile()) {
|
|
82605
82605
|
ids.push(entry);
|
|
82606
82606
|
}
|
|
82607
82607
|
} catch (error3) {
|
|
@@ -82834,8 +82834,8 @@ function defaultFs3() {
|
|
|
82834
82834
|
async function readDefaultFileBytes(filePath, start) {
|
|
82835
82835
|
const handle = await nodeFs10.open(filePath, "r");
|
|
82836
82836
|
try {
|
|
82837
|
-
const
|
|
82838
|
-
const length = Math.max(0,
|
|
82837
|
+
const stat36 = await handle.stat();
|
|
82838
|
+
const length = Math.max(0, stat36.size - start);
|
|
82839
82839
|
if (length === 0) {
|
|
82840
82840
|
return new Uint8Array();
|
|
82841
82841
|
}
|
|
@@ -82864,8 +82864,8 @@ function isProcessRunning2(pid, isPidRunningOverride) {
|
|
|
82864
82864
|
}
|
|
82865
82865
|
}
|
|
82866
82866
|
function sleep4(durationMs) {
|
|
82867
|
-
return new Promise((
|
|
82868
|
-
setTimeout(
|
|
82867
|
+
return new Promise((resolve16) => {
|
|
82868
|
+
setTimeout(resolve16, durationMs);
|
|
82869
82869
|
});
|
|
82870
82870
|
}
|
|
82871
82871
|
var DEFAULT_POLL_INTERVAL_MS, DEFAULT_STARTUP_TIMEOUT_MS, DEFAULT_STOP_TIMEOUT_MS, TEMP_WRITE_MAX_ATTEMPTS;
|
|
@@ -82974,16 +82974,16 @@ function createDefaultFs11() {
|
|
|
82974
82974
|
},
|
|
82975
82975
|
readdir: fsPromises23.readdir,
|
|
82976
82976
|
stat: async (filePath) => {
|
|
82977
|
-
const
|
|
82977
|
+
const stat36 = await fsPromises23.stat(filePath);
|
|
82978
82978
|
return {
|
|
82979
|
-
isFile: () =>
|
|
82980
|
-
isDirectory: () =>
|
|
82981
|
-
mtimeMs:
|
|
82979
|
+
isFile: () => stat36.isFile(),
|
|
82980
|
+
isDirectory: () => stat36.isDirectory(),
|
|
82981
|
+
mtimeMs: stat36.mtimeMs
|
|
82982
82982
|
};
|
|
82983
82983
|
},
|
|
82984
82984
|
lstat: async (filePath) => {
|
|
82985
|
-
const
|
|
82986
|
-
return { isSymbolicLink: () =>
|
|
82985
|
+
const stat36 = await fsPromises23.lstat(filePath);
|
|
82986
|
+
return { isSymbolicLink: () => stat36.isSymbolicLink() };
|
|
82987
82987
|
},
|
|
82988
82988
|
mkdir: async (filePath, options) => {
|
|
82989
82989
|
await fsPromises23.mkdir(filePath, options);
|
|
@@ -84515,8 +84515,8 @@ var init_pi4 = __esm({
|
|
|
84515
84515
|
const references = [];
|
|
84516
84516
|
for (const directory of directories) {
|
|
84517
84517
|
for (const filePath of await listJsonlFiles2(options.fs, directory)) {
|
|
84518
|
-
const
|
|
84519
|
-
const updatedAt =
|
|
84518
|
+
const stat36 = await options.fs.stat(filePath);
|
|
84519
|
+
const updatedAt = stat36.mtime;
|
|
84520
84520
|
if (options.since && updatedAt && updatedAt < options.since) {
|
|
84521
84521
|
continue;
|
|
84522
84522
|
}
|
|
@@ -88252,8 +88252,8 @@ async function listEvals(source, fs31 = nodeFs17) {
|
|
|
88252
88252
|
const name = typeof entry === "string" ? entry : entry.name;
|
|
88253
88253
|
const entryPath = join9(source.rootDir, name);
|
|
88254
88254
|
if (typeof entry === "string") {
|
|
88255
|
-
const
|
|
88256
|
-
if (!
|
|
88255
|
+
const stat36 = await fs31.stat(entryPath);
|
|
88256
|
+
if (!stat36.isDirectory()) {
|
|
88257
88257
|
continue;
|
|
88258
88258
|
}
|
|
88259
88259
|
} else if (!entry.isDirectory()) {
|
|
@@ -88336,8 +88336,8 @@ async function loadEval(source, id, fs31 = nodeFs17) {
|
|
|
88336
88336
|
}
|
|
88337
88337
|
async function isFile2(path186, fs31) {
|
|
88338
88338
|
try {
|
|
88339
|
-
const
|
|
88340
|
-
return typeof
|
|
88339
|
+
const stat36 = await fs31.stat(path186);
|
|
88340
|
+
return typeof stat36.isFile === "function" ? stat36.isFile() : !stat36.isDirectory();
|
|
88341
88341
|
} catch (error3) {
|
|
88342
88342
|
if (isMissingPath4(error3)) {
|
|
88343
88343
|
return false;
|
|
@@ -88433,16 +88433,16 @@ async function openSource(dir, fs31 = nodeFs18) {
|
|
|
88433
88433
|
if (!isAbsolute6(dir)) {
|
|
88434
88434
|
throw new UserError2(`Eval source path must be absolute, received "${dir}".`);
|
|
88435
88435
|
}
|
|
88436
|
-
let
|
|
88436
|
+
let stat36;
|
|
88437
88437
|
try {
|
|
88438
|
-
|
|
88438
|
+
stat36 = await fs31.stat(dir);
|
|
88439
88439
|
} catch (error3) {
|
|
88440
88440
|
if (isMissingPath5(error3)) {
|
|
88441
88441
|
throw new UserError2(`Eval source "${dir}" does not exist or is not a directory.`);
|
|
88442
88442
|
}
|
|
88443
88443
|
throw error3;
|
|
88444
88444
|
}
|
|
88445
|
-
if (!
|
|
88445
|
+
if (!stat36.isDirectory()) {
|
|
88446
88446
|
throw new UserError2(`Eval source "${dir}" is not a directory.`);
|
|
88447
88447
|
}
|
|
88448
88448
|
const source = { rootDir: dir };
|
|
@@ -88838,9 +88838,9 @@ function waitForRunHandle(handle, timeoutMs) {
|
|
|
88838
88838
|
() => true,
|
|
88839
88839
|
() => true
|
|
88840
88840
|
),
|
|
88841
|
-
new Promise((
|
|
88841
|
+
new Promise((resolve16) => {
|
|
88842
88842
|
timeout = setTimeout(() => {
|
|
88843
|
-
|
|
88843
|
+
resolve16(false);
|
|
88844
88844
|
}, timeoutMs);
|
|
88845
88845
|
})
|
|
88846
88846
|
]).finally(() => {
|
|
@@ -88949,7 +88949,7 @@ async function waitForVitest(handle, timeoutMs, signal) {
|
|
|
88949
88949
|
await terminateRunHandle(handle);
|
|
88950
88950
|
throw abortReason(signal);
|
|
88951
88951
|
}
|
|
88952
|
-
return new Promise((
|
|
88952
|
+
return new Promise((resolve16, reject) => {
|
|
88953
88953
|
let settled = false;
|
|
88954
88954
|
let cancelling = false;
|
|
88955
88955
|
let timeout = null;
|
|
@@ -88997,7 +88997,7 @@ async function waitForVitest(handle, timeoutMs, signal) {
|
|
|
88997
88997
|
if (cancelling) {
|
|
88998
88998
|
return;
|
|
88999
88999
|
}
|
|
89000
|
-
finish(() =>
|
|
89000
|
+
finish(() => resolve16({ exitCode: result.exitCode }));
|
|
89001
89001
|
},
|
|
89002
89002
|
(error3) => {
|
|
89003
89003
|
if (cancelling) {
|
|
@@ -89069,8 +89069,8 @@ function drainStream(stream) {
|
|
|
89069
89069
|
return Promise.resolve();
|
|
89070
89070
|
}
|
|
89071
89071
|
stream.resume();
|
|
89072
|
-
return new Promise((
|
|
89073
|
-
stream.once("end",
|
|
89072
|
+
return new Promise((resolve16, reject) => {
|
|
89073
|
+
stream.once("end", resolve16);
|
|
89074
89074
|
stream.once("error", reject);
|
|
89075
89075
|
});
|
|
89076
89076
|
}
|
|
@@ -89263,9 +89263,9 @@ function assertValidTimeout3(timeoutMs) {
|
|
|
89263
89263
|
}
|
|
89264
89264
|
async function waitForResult(handle, timeoutMs) {
|
|
89265
89265
|
let timeout = null;
|
|
89266
|
-
const timeoutPromise = new Promise((
|
|
89266
|
+
const timeoutPromise = new Promise((resolve16) => {
|
|
89267
89267
|
timeout = setTimeout(() => {
|
|
89268
|
-
|
|
89268
|
+
resolve16({ exitCode: 1, timedOut: true });
|
|
89269
89269
|
}, timeoutMs);
|
|
89270
89270
|
});
|
|
89271
89271
|
const result = await Promise.race([
|
|
@@ -89289,11 +89289,11 @@ function captureStream(stream) {
|
|
|
89289
89289
|
}
|
|
89290
89290
|
let output = "";
|
|
89291
89291
|
stream.setEncoding("utf8");
|
|
89292
|
-
const finished = new Promise((
|
|
89292
|
+
const finished = new Promise((resolve16, reject) => {
|
|
89293
89293
|
stream.on("data", (chunk) => {
|
|
89294
89294
|
output += chunk;
|
|
89295
89295
|
});
|
|
89296
|
-
stream.once("end",
|
|
89296
|
+
stream.once("end", resolve16);
|
|
89297
89297
|
stream.once("error", reject);
|
|
89298
89298
|
});
|
|
89299
89299
|
return {
|
|
@@ -89872,8 +89872,8 @@ async function readTextIfPresent(filePath, fs31) {
|
|
|
89872
89872
|
}
|
|
89873
89873
|
async function isDirectory3(dirPath, fs31) {
|
|
89874
89874
|
try {
|
|
89875
|
-
const
|
|
89876
|
-
return
|
|
89875
|
+
const stat36 = await fs31.stat(dirPath);
|
|
89876
|
+
return stat36.isDirectory();
|
|
89877
89877
|
} catch (error3) {
|
|
89878
89878
|
if (isMissingPath8(error3)) {
|
|
89879
89879
|
return false;
|
|
@@ -90738,10 +90738,10 @@ async function collectFiles(rootDir, currentDir2, files) {
|
|
|
90738
90738
|
if (!entry.isFile()) {
|
|
90739
90739
|
continue;
|
|
90740
90740
|
}
|
|
90741
|
-
const
|
|
90741
|
+
const stat36 = await fs13.stat(absolutePath);
|
|
90742
90742
|
files.push({
|
|
90743
90743
|
path: path133.relative(rootDir, absolutePath),
|
|
90744
|
-
bytes:
|
|
90744
|
+
bytes: stat36.size
|
|
90745
90745
|
});
|
|
90746
90746
|
}
|
|
90747
90747
|
}
|
|
@@ -90787,13 +90787,13 @@ function createJudgeStreamingSpawn() {
|
|
|
90787
90787
|
async function* emptyEvents() {
|
|
90788
90788
|
}
|
|
90789
90789
|
function createDeferred() {
|
|
90790
|
-
let
|
|
90790
|
+
let resolve16;
|
|
90791
90791
|
let reject;
|
|
90792
90792
|
const promise = new Promise((resolvePromise, rejectPromise) => {
|
|
90793
|
-
|
|
90793
|
+
resolve16 = resolvePromise;
|
|
90794
90794
|
reject = rejectPromise;
|
|
90795
90795
|
});
|
|
90796
|
-
return { promise, resolve:
|
|
90796
|
+
return { promise, resolve: resolve16, reject };
|
|
90797
90797
|
}
|
|
90798
90798
|
function resolveJudgeMode(agent3) {
|
|
90799
90799
|
const config2 = getSpawnConfig(agent3);
|
|
@@ -91034,8 +91034,8 @@ async function assertRunArtifactPath(sourceRootDir, targetPath) {
|
|
|
91034
91034
|
for (const segment of relativePath.split(path134.sep).filter(Boolean)) {
|
|
91035
91035
|
current = path134.join(current, segment);
|
|
91036
91036
|
try {
|
|
91037
|
-
const
|
|
91038
|
-
if (
|
|
91037
|
+
const stat36 = await lstat30(current);
|
|
91038
|
+
if (stat36.isSymbolicLink()) {
|
|
91039
91039
|
throw new Error(`Run artifact path must not traverse a symbolic link: ${current}`);
|
|
91040
91040
|
}
|
|
91041
91041
|
} catch (error3) {
|
|
@@ -91138,9 +91138,9 @@ function createOracleEnv(oracleDir) {
|
|
|
91138
91138
|
}
|
|
91139
91139
|
async function waitForResult2(handle, timeoutMs) {
|
|
91140
91140
|
let timeout = null;
|
|
91141
|
-
const timeoutPromise = new Promise((
|
|
91141
|
+
const timeoutPromise = new Promise((resolve16) => {
|
|
91142
91142
|
timeout = setTimeout(() => {
|
|
91143
|
-
|
|
91143
|
+
resolve16({ exitCode: 1, timedOut: true });
|
|
91144
91144
|
}, timeoutMs);
|
|
91145
91145
|
});
|
|
91146
91146
|
const result = await Promise.race([
|
|
@@ -91164,11 +91164,11 @@ function captureStream2(stream) {
|
|
|
91164
91164
|
}
|
|
91165
91165
|
let output = "";
|
|
91166
91166
|
stream.setEncoding("utf8");
|
|
91167
|
-
const finished = new Promise((
|
|
91167
|
+
const finished = new Promise((resolve16, reject) => {
|
|
91168
91168
|
stream.on("data", (chunk) => {
|
|
91169
91169
|
output += chunk;
|
|
91170
91170
|
});
|
|
91171
|
-
stream.once("end",
|
|
91171
|
+
stream.once("end", resolve16);
|
|
91172
91172
|
stream.once("error", reject);
|
|
91173
91173
|
});
|
|
91174
91174
|
return {
|
|
@@ -92658,16 +92658,16 @@ async function resolveDefaultEvalIds(sourceDir, fs31) {
|
|
|
92658
92658
|
return evalIds.length === 1 ? [evalIds[0]] : evalIds;
|
|
92659
92659
|
}
|
|
92660
92660
|
async function assertSourceDirectory(sourceDir, fs31) {
|
|
92661
|
-
let
|
|
92661
|
+
let stat36;
|
|
92662
92662
|
try {
|
|
92663
|
-
|
|
92663
|
+
stat36 = await fs31.stat(sourceDir);
|
|
92664
92664
|
} catch (error3) {
|
|
92665
92665
|
if (isMissingPath13(error3)) {
|
|
92666
92666
|
throw new UserError2(`Eval source "${sourceDir}" does not exist or is not a directory.`);
|
|
92667
92667
|
}
|
|
92668
92668
|
throw error3;
|
|
92669
92669
|
}
|
|
92670
|
-
if (!
|
|
92670
|
+
if (!stat36.isDirectory()) {
|
|
92671
92671
|
throw new UserError2(`Eval source "${sourceDir}" is not a directory.`);
|
|
92672
92672
|
}
|
|
92673
92673
|
}
|
|
@@ -94006,8 +94006,8 @@ function createEventQueue3() {
|
|
|
94006
94006
|
if (completed) {
|
|
94007
94007
|
return Promise.resolve({ done: true, value: void 0 });
|
|
94008
94008
|
}
|
|
94009
|
-
return new Promise((
|
|
94010
|
-
waiters.push(
|
|
94009
|
+
return new Promise((resolve16) => {
|
|
94010
|
+
waiters.push(resolve16);
|
|
94011
94011
|
});
|
|
94012
94012
|
}
|
|
94013
94013
|
};
|
|
@@ -94317,8 +94317,8 @@ function createInMemoryAcpTransport2(options) {
|
|
|
94317
94317
|
const requestHandlers = /* @__PURE__ */ new Map();
|
|
94318
94318
|
let closed = false;
|
|
94319
94319
|
let resolveClosed;
|
|
94320
|
-
const closedPromise = new Promise((
|
|
94321
|
-
resolveClosed =
|
|
94320
|
+
const closedPromise = new Promise((resolve16) => {
|
|
94321
|
+
resolveClosed = resolve16;
|
|
94322
94322
|
});
|
|
94323
94323
|
const sessionMcpServers = options.mcpServers ? toAgentSessionMcpServers(options.mcpServers) : void 0;
|
|
94324
94324
|
const closeTransport = (reason) => {
|
|
@@ -100516,13 +100516,13 @@ async function loadMarkdownUnlessAborted2(signal, load3) {
|
|
|
100516
100516
|
if (signal.aborted) {
|
|
100517
100517
|
return void 0;
|
|
100518
100518
|
}
|
|
100519
|
-
return new Promise((
|
|
100519
|
+
return new Promise((resolve16, reject) => {
|
|
100520
100520
|
const abort = () => {
|
|
100521
|
-
|
|
100521
|
+
resolve16(void 0);
|
|
100522
100522
|
};
|
|
100523
100523
|
signal.addEventListener("abort", abort, { once: true });
|
|
100524
100524
|
load3().then((markdown) => {
|
|
100525
|
-
|
|
100525
|
+
resolve16(signal.aborted ? void 0 : markdown);
|
|
100526
100526
|
}, reject).finally(() => {
|
|
100527
100527
|
signal.removeEventListener("abort", abort);
|
|
100528
100528
|
});
|
|
@@ -100623,8 +100623,8 @@ async function resolveApiKeyViaOAuth(options = {}, dependencies = {}) {
|
|
|
100623
100623
|
log.warn("Could not open browser automatically.");
|
|
100624
100624
|
failIfUnavailable();
|
|
100625
100625
|
}),
|
|
100626
|
-
readLine: () => new Promise((
|
|
100627
|
-
rl.once("line", (line) =>
|
|
100626
|
+
readLine: () => new Promise((resolve16) => {
|
|
100627
|
+
rl.once("line", (line) => resolve16(line));
|
|
100628
100628
|
})
|
|
100629
100629
|
});
|
|
100630
100630
|
const authorization = await client.authorize();
|
|
@@ -100639,14 +100639,14 @@ async function resolveApiKeyViaOAuth(options = {}, dependencies = {}) {
|
|
|
100639
100639
|
}
|
|
100640
100640
|
}
|
|
100641
100641
|
function openInBrowser(url) {
|
|
100642
|
-
return new Promise((
|
|
100642
|
+
return new Promise((resolve16, reject) => {
|
|
100643
100643
|
const platform = process.platform;
|
|
100644
100644
|
const command = platform === "darwin" ? `open "${url}"` : platform === "win32" ? `start "" "${url}"` : `xdg-open "${url}"`;
|
|
100645
100645
|
exec(command, (error3) => {
|
|
100646
100646
|
if (error3) {
|
|
100647
100647
|
reject(error3);
|
|
100648
100648
|
} else {
|
|
100649
|
-
|
|
100649
|
+
resolve16();
|
|
100650
100650
|
}
|
|
100651
100651
|
});
|
|
100652
100652
|
});
|
|
@@ -107714,8 +107714,8 @@ async function countTokensYielding(text5) {
|
|
|
107714
107714
|
return total2;
|
|
107715
107715
|
}
|
|
107716
107716
|
function yieldToEventLoop() {
|
|
107717
|
-
return new Promise((
|
|
107718
|
-
setImmediate(
|
|
107717
|
+
return new Promise((resolve16) => {
|
|
107718
|
+
setImmediate(resolve16);
|
|
107719
107719
|
});
|
|
107720
107720
|
}
|
|
107721
107721
|
var MATCHERS, TURNS_PER_YIELD, ESTIMATOR_SAMPLE_TARGET_CHARS, ESTIMATOR_SAMPLE_CHARS_PER_TURN, ESTIMATOR_DEFAULT_CHARS_PER_TOKEN, COUNT_CHUNK_CHARS;
|
|
@@ -108030,7 +108030,7 @@ function scheduleExactBreakdown(trace, filePath, identity, cacheDir, options) {
|
|
|
108030
108030
|
return;
|
|
108031
108031
|
}
|
|
108032
108032
|
const task = (async () => {
|
|
108033
|
-
await new Promise((
|
|
108033
|
+
await new Promise((resolve16) => setTimeout(resolve16, EXACT_BREAKDOWN_START_DELAY_MS));
|
|
108034
108034
|
const breakdown = await computeContextBreakdown(trace);
|
|
108035
108035
|
await writeCachedBreakdown(options.fs, cacheDir, filePath, identity, breakdown);
|
|
108036
108036
|
options.onExactBreakdown?.(breakdown);
|
|
@@ -108175,14 +108175,14 @@ function detectTraceFile(firstLine) {
|
|
|
108175
108175
|
return void 0;
|
|
108176
108176
|
}
|
|
108177
108177
|
async function loadTraceFromFile(path186, options) {
|
|
108178
|
-
const
|
|
108179
|
-
if (
|
|
108178
|
+
const stat36 = await options.fs.stat(path186).catch(() => void 0);
|
|
108179
|
+
if (stat36 === void 0) {
|
|
108180
108180
|
throw new UserError(
|
|
108181
108181
|
`Trace file not found: ${path186}
|
|
108182
108182
|
Pass a path to an existing trace file, or run "poe-code traces" to list the traces found.`
|
|
108183
108183
|
);
|
|
108184
108184
|
}
|
|
108185
|
-
if (
|
|
108185
|
+
if (stat36.isDirectory()) {
|
|
108186
108186
|
throw new UserError(
|
|
108187
108187
|
`Trace path is a directory: ${path186}
|
|
108188
108188
|
Pass a path to a trace file, or run "poe-code traces" to list the traces found.`
|
|
@@ -108363,8 +108363,8 @@ async function renderTraceDetail(view, subagents = [], options = {}) {
|
|
|
108363
108363
|
return lines.join("\n");
|
|
108364
108364
|
}
|
|
108365
108365
|
function yieldToEventLoop2() {
|
|
108366
|
-
return new Promise((
|
|
108367
|
-
setImmediate(
|
|
108366
|
+
return new Promise((resolve16) => {
|
|
108367
|
+
setImmediate(resolve16);
|
|
108368
108368
|
});
|
|
108369
108369
|
}
|
|
108370
108370
|
function renderBreakdownItems(items, minimumTokenWidth, theme) {
|
|
@@ -110078,13 +110078,13 @@ async function loadUnlessAborted(signal, load3) {
|
|
|
110078
110078
|
if (signal.aborted) {
|
|
110079
110079
|
return void 0;
|
|
110080
110080
|
}
|
|
110081
|
-
return new Promise((
|
|
110081
|
+
return new Promise((resolve16, reject) => {
|
|
110082
110082
|
const abort = () => {
|
|
110083
|
-
|
|
110083
|
+
resolve16(void 0);
|
|
110084
110084
|
};
|
|
110085
110085
|
signal.addEventListener("abort", abort, { once: true });
|
|
110086
110086
|
load3().then((value) => {
|
|
110087
|
-
|
|
110087
|
+
resolve16(signal.aborted ? void 0 : value);
|
|
110088
110088
|
}, reject).finally(() => {
|
|
110089
110089
|
signal.removeEventListener("abort", abort);
|
|
110090
110090
|
});
|
|
@@ -112460,8 +112460,8 @@ async function assertNoSymlinkSegments(root, relPath) {
|
|
|
112460
112460
|
for (const segment of normalizedRelPath.split("/")) {
|
|
112461
112461
|
currentPath = path160.join(currentPath, segment);
|
|
112462
112462
|
try {
|
|
112463
|
-
const
|
|
112464
|
-
if (
|
|
112463
|
+
const stat36 = await fs15.lstat(currentPath);
|
|
112464
|
+
if (stat36.isSymbolicLink()) {
|
|
112465
112465
|
throw new MemoryPathError(`Memory path "${relPath}" cannot traverse a symbolic link.`);
|
|
112466
112466
|
}
|
|
112467
112467
|
} catch (error3) {
|
|
@@ -112479,8 +112479,8 @@ async function assertMemoryRootIsNotSymlink(root) {
|
|
|
112479
112479
|
for (const segment of absoluteRoot.slice(pathRoot.length).split(path160.sep).filter(Boolean)) {
|
|
112480
112480
|
currentPath = path160.join(currentPath, segment);
|
|
112481
112481
|
try {
|
|
112482
|
-
const
|
|
112483
|
-
if (
|
|
112482
|
+
const stat36 = await fs15.lstat(currentPath);
|
|
112483
|
+
if (stat36.isSymbolicLink()) {
|
|
112484
112484
|
if (await isAllowedMacSystemAlias(currentPath)) {
|
|
112485
112485
|
continue;
|
|
112486
112486
|
}
|
|
@@ -112819,7 +112819,7 @@ async function readPage(root, relPath) {
|
|
|
112819
112819
|
const normalizedRelPath = assertMarkdownRelPath(relPath);
|
|
112820
112820
|
await assertNoSymlinkSegments(root, normalizedRelPath);
|
|
112821
112821
|
const absPath = path163.join(root, normalizedRelPath);
|
|
112822
|
-
const [content,
|
|
112822
|
+
const [content, stat36] = await Promise.all([fs17.readFile(absPath, "utf8"), fs17.stat(absPath)]);
|
|
112823
112823
|
try {
|
|
112824
112824
|
const parsed = parseFrontmatter4(content);
|
|
112825
112825
|
return {
|
|
@@ -112827,7 +112827,7 @@ async function readPage(root, relPath) {
|
|
|
112827
112827
|
frontmatter: parsed.frontmatter,
|
|
112828
112828
|
body: parsed.body,
|
|
112829
112829
|
bytes: Buffer.byteLength(content),
|
|
112830
|
-
mtimeMs:
|
|
112830
|
+
mtimeMs: stat36.mtimeMs
|
|
112831
112831
|
};
|
|
112832
112832
|
} catch (error3) {
|
|
112833
112833
|
const message2 = error3 instanceof Error ? error3.message : String(error3);
|
|
@@ -112837,7 +112837,7 @@ async function readPage(root, relPath) {
|
|
|
112837
112837
|
frontmatter: {},
|
|
112838
112838
|
body: content,
|
|
112839
112839
|
bytes: Buffer.byteLength(content),
|
|
112840
|
-
mtimeMs:
|
|
112840
|
+
mtimeMs: stat36.mtimeMs
|
|
112841
112841
|
};
|
|
112842
112842
|
}
|
|
112843
112843
|
}
|
|
@@ -112969,9 +112969,9 @@ async function statusOf(root) {
|
|
|
112969
112969
|
let lastWriteAtMs = Number.NEGATIVE_INFINITY;
|
|
112970
112970
|
for (const relPath of markdownRelPaths) {
|
|
112971
112971
|
await assertNoSymlinkSegments(root, relPath);
|
|
112972
|
-
const
|
|
112973
|
-
totalBytes +=
|
|
112974
|
-
lastWriteAtMs = Math.max(lastWriteAtMs,
|
|
112972
|
+
const stat36 = await fs19.stat(path165.join(root, relPath));
|
|
112973
|
+
totalBytes += stat36.size;
|
|
112974
|
+
lastWriteAtMs = Math.max(lastWriteAtMs, stat36.mtimeMs);
|
|
112975
112975
|
}
|
|
112976
112976
|
return {
|
|
112977
112977
|
pageCount: pageRelPaths.length,
|
|
@@ -114160,7 +114160,7 @@ function inferRepoRoot(root) {
|
|
|
114160
114160
|
return path172.resolve(root, "..", "..");
|
|
114161
114161
|
}
|
|
114162
114162
|
async function runWithTimeout(promise, timeoutMs, onTimeout) {
|
|
114163
|
-
return await new Promise((
|
|
114163
|
+
return await new Promise((resolve16, reject) => {
|
|
114164
114164
|
const timer = setTimeout(() => {
|
|
114165
114165
|
onTimeout();
|
|
114166
114166
|
reject(new Error(`ingest timed out after ${timeoutMs}ms`));
|
|
@@ -114168,7 +114168,7 @@ async function runWithTimeout(promise, timeoutMs, onTimeout) {
|
|
|
114168
114168
|
promise.then(
|
|
114169
114169
|
(value) => {
|
|
114170
114170
|
clearTimeout(timer);
|
|
114171
|
-
|
|
114171
|
+
resolve16(value);
|
|
114172
114172
|
},
|
|
114173
114173
|
(error3) => {
|
|
114174
114174
|
clearTimeout(timer);
|
|
@@ -116644,8 +116644,8 @@ function isStrictlyNewer(left, right) {
|
|
|
116644
116644
|
return Number.isFinite(leftStart) && Number.isFinite(rightStart) && leftStart > rightStart;
|
|
116645
116645
|
}
|
|
116646
116646
|
function sleep5(ms) {
|
|
116647
|
-
return new Promise((
|
|
116648
|
-
setTimeout(() =>
|
|
116647
|
+
return new Promise((resolve16) => {
|
|
116648
|
+
setTimeout(() => resolve16("timeout"), ms);
|
|
116649
116649
|
});
|
|
116650
116650
|
}
|
|
116651
116651
|
function pendingForever() {
|
|
@@ -135655,8 +135655,8 @@ function indexHeapContainers(snapshot2) {
|
|
|
135655
135655
|
}
|
|
135656
135656
|
const heapIds = /* @__PURE__ */ new WeakMap();
|
|
135657
135657
|
let nextId = 1;
|
|
135658
|
-
for (const [value,
|
|
135659
|
-
if (
|
|
135658
|
+
for (const [value, stat36] of stats2.entries()) {
|
|
135659
|
+
if (stat36.count > 1 || stat36.cyclic) {
|
|
135660
135660
|
heapIds.set(value, nextId);
|
|
135661
135661
|
nextId += 1;
|
|
135662
135662
|
}
|
|
@@ -135670,24 +135670,24 @@ function collectContainerStats(value, stats2, ancestors) {
|
|
|
135670
135670
|
if (!Array.isArray(value) && !isPlainObject9(value)) {
|
|
135671
135671
|
return;
|
|
135672
135672
|
}
|
|
135673
|
-
let
|
|
135674
|
-
if (
|
|
135675
|
-
|
|
135673
|
+
let stat36 = stats2.get(value);
|
|
135674
|
+
if (stat36 === void 0) {
|
|
135675
|
+
stat36 = {
|
|
135676
135676
|
count: 0,
|
|
135677
135677
|
cyclic: false,
|
|
135678
135678
|
expanded: false
|
|
135679
135679
|
};
|
|
135680
|
-
stats2.set(value,
|
|
135680
|
+
stats2.set(value, stat36);
|
|
135681
135681
|
}
|
|
135682
|
-
|
|
135682
|
+
stat36.count += 1;
|
|
135683
135683
|
if (ancestors.has(value)) {
|
|
135684
|
-
|
|
135684
|
+
stat36.cyclic = true;
|
|
135685
135685
|
return;
|
|
135686
135686
|
}
|
|
135687
|
-
if (
|
|
135687
|
+
if (stat36.expanded) {
|
|
135688
135688
|
return;
|
|
135689
135689
|
}
|
|
135690
|
-
|
|
135690
|
+
stat36.expanded = true;
|
|
135691
135691
|
ancestors.add(value);
|
|
135692
135692
|
const entries = Array.isArray(value) ? getArrayDataItems(value) : getEnumerableDataValues(value);
|
|
135693
135693
|
for (const entry of entries) {
|
|
@@ -136909,6 +136909,7 @@ function wrapCancelableValue(value, signal, seen) {
|
|
|
136909
136909
|
return wrapped2;
|
|
136910
136910
|
}
|
|
136911
136911
|
if (isSandboxPromise(value)) {
|
|
136912
|
+
observeSandboxPromise(value);
|
|
136912
136913
|
const wrapped2 = createSandboxPromise(wrapCancelablePromise(value.promise, signal, seen), {
|
|
136913
136914
|
...value.hostCall === void 0 ? {} : { hostCall: value.hostCall },
|
|
136914
136915
|
...value.hostCallJournal === void 0 ? {} : { hostCallJournal: value.hostCallJournal },
|
|
@@ -136942,7 +136943,7 @@ function wrapCancelablePromise(promise, signal, seen) {
|
|
|
136942
136943
|
if (signal.aborted) {
|
|
136943
136944
|
return Promise.reject(readAbortReason(signal));
|
|
136944
136945
|
}
|
|
136945
|
-
return new Promise((
|
|
136946
|
+
return new Promise((resolve16, reject) => {
|
|
136946
136947
|
let listenerActive = true;
|
|
136947
136948
|
let settled = false;
|
|
136948
136949
|
const onAbort = () => {
|
|
@@ -136969,7 +136970,7 @@ function wrapCancelablePromise(promise, signal, seen) {
|
|
|
136969
136970
|
signal.addEventListener("abort", onAbort, { once: true });
|
|
136970
136971
|
Promise.resolve(promise).then(
|
|
136971
136972
|
(value) => {
|
|
136972
|
-
settle(() =>
|
|
136973
|
+
settle(() => resolve16(wrapCancelableValue(value, signal, seen)));
|
|
136973
136974
|
},
|
|
136974
136975
|
(reason) => {
|
|
136975
136976
|
settle(() => reject(wrapCancelableUnknown(reason, signal, seen)));
|
|
@@ -137012,6 +137013,7 @@ var init_cancel2 = __esm({
|
|
|
137012
137013
|
"packages/safejs/src/interp/cancel.ts"() {
|
|
137013
137014
|
"use strict";
|
|
137014
137015
|
init_values();
|
|
137016
|
+
init_promise_tracker();
|
|
137015
137017
|
init_shape();
|
|
137016
137018
|
}
|
|
137017
137019
|
});
|
|
@@ -137501,6 +137503,12 @@ function budgetSandboxValue(value, budget) {
|
|
|
137501
137503
|
function resolveSandboxValue(value, options = {}) {
|
|
137502
137504
|
return Promise.resolve().then(() => resolveSandboxValueNow(value, options, /* @__PURE__ */ new WeakSet()));
|
|
137503
137505
|
}
|
|
137506
|
+
function consumeSettledHostCall(value) {
|
|
137507
|
+
if (value.hostCall?.lifecycle !== "settled") {
|
|
137508
|
+
return;
|
|
137509
|
+
}
|
|
137510
|
+
value.hostCallJournal?.consume(value.hostCall);
|
|
137511
|
+
}
|
|
137504
137512
|
function resolveSandboxValueNow(value, options, seenThenables) {
|
|
137505
137513
|
if (isPromiseLike4(value)) {
|
|
137506
137514
|
return Promise.resolve(value).then(
|
|
@@ -137512,11 +137520,11 @@ function resolveSandboxValueNow(value, options, seenThenables) {
|
|
|
137512
137520
|
observeSandboxPromise(value);
|
|
137513
137521
|
return value.promise.then(
|
|
137514
137522
|
(resolved) => {
|
|
137515
|
-
|
|
137523
|
+
consumeSettledHostCall(value);
|
|
137516
137524
|
return resolveSandboxValueNow(resolved, options, seenThenables);
|
|
137517
137525
|
},
|
|
137518
137526
|
(reason) => {
|
|
137519
|
-
|
|
137527
|
+
consumeSettledHostCall(value);
|
|
137520
137528
|
return Promise.reject(budgetIfNeeded(reason, options.budget));
|
|
137521
137529
|
}
|
|
137522
137530
|
);
|
|
@@ -137538,14 +137546,14 @@ function resolveThenable(value, then, options, seenThenables) {
|
|
|
137538
137546
|
});
|
|
137539
137547
|
}
|
|
137540
137548
|
seenThenables.add(value);
|
|
137541
|
-
return new Promise((
|
|
137549
|
+
return new Promise((resolve16, reject) => {
|
|
137542
137550
|
let settlement;
|
|
137543
137551
|
let completed = false;
|
|
137544
137552
|
const complete = () => {
|
|
137545
137553
|
if (completed || settlement === void 0) return;
|
|
137546
137554
|
completed = true;
|
|
137547
137555
|
if (settlement.state === "fulfilled") {
|
|
137548
|
-
|
|
137556
|
+
resolve16(resolveSandboxValueNow(settlement.value, options, seenThenables));
|
|
137549
137557
|
} else {
|
|
137550
137558
|
reject(budgetIfNeeded(settlement.value, options.budget));
|
|
137551
137559
|
}
|
|
@@ -137965,7 +137973,7 @@ function getSandboxIterator(value) {
|
|
|
137965
137973
|
return syncIterator(Reflect.apply(iteratorMethod, value, []));
|
|
137966
137974
|
}
|
|
137967
137975
|
function generatorIterator(generator) {
|
|
137968
|
-
const
|
|
137976
|
+
const invoke2 = async (method, value) => {
|
|
137969
137977
|
const leaveRunning = enterRunningState(generator);
|
|
137970
137978
|
generator.state = "running";
|
|
137971
137979
|
try {
|
|
@@ -137981,13 +137989,13 @@ function generatorIterator(generator) {
|
|
|
137981
137989
|
};
|
|
137982
137990
|
return {
|
|
137983
137991
|
generator: true,
|
|
137984
|
-
next: (value) =>
|
|
137985
|
-
return: (value) =>
|
|
137986
|
-
throw: (error3) =>
|
|
137992
|
+
next: (value) => invoke2("next", value),
|
|
137993
|
+
return: (value) => invoke2("return", value),
|
|
137994
|
+
throw: (error3) => invoke2("throw", error3)
|
|
137987
137995
|
};
|
|
137988
137996
|
}
|
|
137989
137997
|
function syncIterator(iterator) {
|
|
137990
|
-
const
|
|
137998
|
+
const invoke2 = async (method, value) => {
|
|
137991
137999
|
const leaveRunning = enterRunningState(iterator);
|
|
137992
138000
|
try {
|
|
137993
138001
|
return await iterator[method](value);
|
|
@@ -137996,9 +138004,9 @@ function syncIterator(iterator) {
|
|
|
137996
138004
|
}
|
|
137997
138005
|
};
|
|
137998
138006
|
return {
|
|
137999
|
-
next: (value) =>
|
|
138000
|
-
...typeof iterator.return === "function" ? { return: (value) =>
|
|
138001
|
-
...typeof iterator.throw === "function" ? { throw: (error3) =>
|
|
138007
|
+
next: (value) => invoke2("next", value),
|
|
138008
|
+
...typeof iterator.return === "function" ? { return: (value) => invoke2("return", value) } : {},
|
|
138009
|
+
...typeof iterator.throw === "function" ? { throw: (error3) => invoke2("throw", error3) } : {}
|
|
138002
138010
|
};
|
|
138003
138011
|
}
|
|
138004
138012
|
var init_iteration = __esm({
|
|
@@ -139128,13 +139136,13 @@ function createGeneratorChannel(body) {
|
|
|
139128
139136
|
};
|
|
139129
139137
|
}
|
|
139130
139138
|
function deferred() {
|
|
139131
|
-
let
|
|
139139
|
+
let resolve16;
|
|
139132
139140
|
let reject;
|
|
139133
139141
|
const promise = new Promise((innerResolve, innerReject) => {
|
|
139134
|
-
|
|
139142
|
+
resolve16 = innerResolve;
|
|
139135
139143
|
reject = innerReject;
|
|
139136
139144
|
});
|
|
139137
|
-
return { promise, reject, resolve:
|
|
139145
|
+
return { promise, reject, resolve: resolve16 };
|
|
139138
139146
|
}
|
|
139139
139147
|
var init_generator = __esm({
|
|
139140
139148
|
"packages/safejs/src/interp/generator.ts"() {
|
|
@@ -139746,6 +139754,10 @@ var init_async = __esm({
|
|
|
139746
139754
|
});
|
|
139747
139755
|
|
|
139748
139756
|
// packages/safejs/src/interp/host-bridge.ts
|
|
139757
|
+
function declareHostOperation(operation, policy) {
|
|
139758
|
+
hostOperationPolicies.set(operation, policy);
|
|
139759
|
+
return operation;
|
|
139760
|
+
}
|
|
139749
139761
|
function readHostOperationPolicy(operation) {
|
|
139750
139762
|
return hostOperationPolicies.get(operation);
|
|
139751
139763
|
}
|
|
@@ -139810,14 +139822,14 @@ function wrapCallerInjectedFunction(name, value, options, state) {
|
|
|
139810
139822
|
...properties ? { properties } : {}
|
|
139811
139823
|
});
|
|
139812
139824
|
}
|
|
139813
|
-
function invokeHostCallback(
|
|
139825
|
+
function invokeHostCallback(invoke2, options) {
|
|
139814
139826
|
const lifecycle = options.lifecycle;
|
|
139815
139827
|
if (lifecycle === void 0) {
|
|
139816
|
-
return
|
|
139828
|
+
return invoke2();
|
|
139817
139829
|
}
|
|
139818
139830
|
lifecycle.hostCallbackDepth += 1;
|
|
139819
139831
|
try {
|
|
139820
|
-
const result =
|
|
139832
|
+
const result = invoke2();
|
|
139821
139833
|
if (isPromiseLike5(result)) {
|
|
139822
139834
|
return Promise.resolve(result).finally(() => {
|
|
139823
139835
|
lifecycle.hostCallbackDepth -= 1;
|
|
@@ -139830,7 +139842,7 @@ function invokeHostCallback(invoke, options) {
|
|
|
139830
139842
|
throw error3;
|
|
139831
139843
|
}
|
|
139832
139844
|
}
|
|
139833
|
-
function executeHostCall(record, restored,
|
|
139845
|
+
function executeHostCall(record, restored, invoke2, stackFrames, options, span) {
|
|
139834
139846
|
const hostCalls = options.hostCalls;
|
|
139835
139847
|
if (restored && record.policy === "read-side-effect" && record.lifecycle === "consumed" && record.outcome !== void 0) {
|
|
139836
139848
|
return createReplayedHostCallResult(record.outcome);
|
|
@@ -139851,7 +139863,7 @@ function executeHostCall(record, restored, invoke, stackFrames, options, span) {
|
|
|
139851
139863
|
hostCalls.start(record);
|
|
139852
139864
|
let result;
|
|
139853
139865
|
try {
|
|
139854
|
-
result =
|
|
139866
|
+
result = invoke2();
|
|
139855
139867
|
} catch (error3) {
|
|
139856
139868
|
const reason = createHostErrorValue(error3, stackFrames, options.budget, span);
|
|
139857
139869
|
hostCalls.settle(record, { status: "rejected", reason });
|
|
@@ -139932,9 +139944,30 @@ function createHostErrorValue(reason, stackFrames, budget, span) {
|
|
|
139932
139944
|
}) : createSubsetErrorValue("Error", describeThrownReason(reason), stackFrames, budget, {
|
|
139933
139945
|
chargeBudget: false
|
|
139934
139946
|
});
|
|
139947
|
+
if (reason instanceof Error) {
|
|
139948
|
+
copyHostErrorMetadata(error3, reason, budget);
|
|
139949
|
+
}
|
|
139935
139950
|
attachErrorSpan(error3, span);
|
|
139936
139951
|
return error3;
|
|
139937
139952
|
}
|
|
139953
|
+
function copyHostErrorMetadata(error3, reason, budget) {
|
|
139954
|
+
const resumeChecks = budget.suspendChecks();
|
|
139955
|
+
try {
|
|
139956
|
+
for (const [key2, expectedType] of Object.entries(hostErrorMetadata)) {
|
|
139957
|
+
const descriptor = Object.getOwnPropertyDescriptor(reason, key2);
|
|
139958
|
+
if (descriptor === void 0 || "get" in descriptor || "set" in descriptor) {
|
|
139959
|
+
continue;
|
|
139960
|
+
}
|
|
139961
|
+
const value = descriptor.value;
|
|
139962
|
+
if (typeof value !== expectedType) {
|
|
139963
|
+
continue;
|
|
139964
|
+
}
|
|
139965
|
+
error3[key2] = typeof value === "string" ? budget.allocateString(value) : value;
|
|
139966
|
+
}
|
|
139967
|
+
} finally {
|
|
139968
|
+
resumeChecks();
|
|
139969
|
+
}
|
|
139970
|
+
}
|
|
139938
139971
|
function wrapSandboxClosureForHost(closure, stackFrames, budget) {
|
|
139939
139972
|
return async (...args) => {
|
|
139940
139973
|
const leaveRunning = enterRunningState(closure);
|
|
@@ -139997,7 +140030,7 @@ function wrapHostPromiseWithSignal(promise, signal) {
|
|
|
139997
140030
|
if (signal.aborted) {
|
|
139998
140031
|
return Promise.reject(readAbortReason2(signal));
|
|
139999
140032
|
}
|
|
140000
|
-
return new Promise((
|
|
140033
|
+
return new Promise((resolve16, reject) => {
|
|
140001
140034
|
let settled = false;
|
|
140002
140035
|
const cleanup = () => {
|
|
140003
140036
|
signal.removeEventListener("abort", onAbort);
|
|
@@ -140016,7 +140049,7 @@ function wrapHostPromiseWithSignal(promise, signal) {
|
|
|
140016
140049
|
signal.addEventListener("abort", onAbort, { once: true });
|
|
140017
140050
|
promise.then(
|
|
140018
140051
|
(value) => {
|
|
140019
|
-
settle(() =>
|
|
140052
|
+
settle(() => resolve16(value));
|
|
140020
140053
|
},
|
|
140021
140054
|
(reason) => {
|
|
140022
140055
|
settle(() => reject(reason));
|
|
@@ -140165,7 +140198,7 @@ function copyHostValueToSandbox(value, stackFrames, options, state, path186) {
|
|
|
140165
140198
|
`Unsupported sandbox value at ${joinPath2(path186, key2)}: accessor property`
|
|
140166
140199
|
);
|
|
140167
140200
|
}
|
|
140168
|
-
Object.defineProperty(copy, key2, {
|
|
140201
|
+
Object.defineProperty(copy, budget.allocateString(key2), {
|
|
140169
140202
|
enumerable: true,
|
|
140170
140203
|
configurable: true,
|
|
140171
140204
|
writable: true,
|
|
@@ -140282,7 +140315,7 @@ function describeValue2(value) {
|
|
|
140282
140315
|
}
|
|
140283
140316
|
return typeof value;
|
|
140284
140317
|
}
|
|
140285
|
-
var AsyncFunction, hostOperationPolicies;
|
|
140318
|
+
var AsyncFunction, hostErrorMetadata, hostOperationPolicies;
|
|
140286
140319
|
var init_host_bridge = __esm({
|
|
140287
140320
|
"packages/safejs/src/interp/host-bridge.ts"() {
|
|
140288
140321
|
"use strict";
|
|
@@ -140295,6 +140328,13 @@ var init_host_bridge = __esm({
|
|
|
140295
140328
|
init_values();
|
|
140296
140329
|
init_running_state();
|
|
140297
140330
|
AsyncFunction = (async () => void 0).constructor;
|
|
140331
|
+
hostErrorMetadata = {
|
|
140332
|
+
code: "string",
|
|
140333
|
+
dest: "string",
|
|
140334
|
+
errno: "number",
|
|
140335
|
+
path: "string",
|
|
140336
|
+
syscall: "string"
|
|
140337
|
+
};
|
|
140298
140338
|
hostOperationPolicies = /* @__PURE__ */ new WeakMap();
|
|
140299
140339
|
}
|
|
140300
140340
|
});
|
|
@@ -143559,9 +143599,9 @@ async function evaluateMemberExpression(node, context) {
|
|
|
143559
143599
|
};
|
|
143560
143600
|
}
|
|
143561
143601
|
function enqueueMicrotask(context, task) {
|
|
143562
|
-
return new Promise((
|
|
143602
|
+
return new Promise((resolve16, reject) => {
|
|
143563
143603
|
context.microtasks.push(() => {
|
|
143564
|
-
task().then(
|
|
143604
|
+
task().then(resolve16, reject);
|
|
143565
143605
|
});
|
|
143566
143606
|
});
|
|
143567
143607
|
}
|
|
@@ -144800,8 +144840,8 @@ function createDumpController(lifecycle) {
|
|
|
144800
144840
|
}
|
|
144801
144841
|
let resolveSnapshot = () => void 0;
|
|
144802
144842
|
let rejectSnapshot = () => void 0;
|
|
144803
|
-
const promise = new Promise((
|
|
144804
|
-
resolveSnapshot =
|
|
144843
|
+
const promise = new Promise((resolve16, reject) => {
|
|
144844
|
+
resolveSnapshot = resolve16;
|
|
144805
144845
|
rejectSnapshot = reject;
|
|
144806
144846
|
});
|
|
144807
144847
|
pendingRequest = {
|
|
@@ -144973,7 +145013,7 @@ async function delay3(ms) {
|
|
|
144973
145013
|
if (ms === 0) {
|
|
144974
145014
|
return;
|
|
144975
145015
|
}
|
|
144976
|
-
await new Promise((
|
|
145016
|
+
await new Promise((resolve16) => setTimeout(resolve16, ms));
|
|
144977
145017
|
}
|
|
144978
145018
|
function hasErrorCode5(error3, code) {
|
|
144979
145019
|
return hasOwnErrorCode29(error3, code);
|
|
@@ -145364,9 +145404,7 @@ async function throwIfReturnedPromiseRejected(result) {
|
|
|
145364
145404
|
await Promise.resolve();
|
|
145365
145405
|
await Promise.resolve();
|
|
145366
145406
|
if (rejected) {
|
|
145367
|
-
|
|
145368
|
-
result.returnValue.hostCallJournal?.consume(result.returnValue.hostCall);
|
|
145369
|
-
}
|
|
145407
|
+
consumeSettledHostCall(result.returnValue);
|
|
145370
145408
|
throw new UnhandledRejectionError(rejectionReason, result.returnValue.span);
|
|
145371
145409
|
}
|
|
145372
145410
|
}
|
|
@@ -146280,10 +146318,10 @@ function calculateBackoffMs2(baseBackoffMs, completedAttempt) {
|
|
|
146280
146318
|
}
|
|
146281
146319
|
function sleep6(delayMs, signal) {
|
|
146282
146320
|
throwIfAborted7(signal);
|
|
146283
|
-
return new Promise((
|
|
146321
|
+
return new Promise((resolve16, reject) => {
|
|
146284
146322
|
const timeout = setTimeout(() => {
|
|
146285
146323
|
signal?.removeEventListener("abort", onAbort);
|
|
146286
|
-
|
|
146324
|
+
resolve16();
|
|
146287
146325
|
}, delayMs);
|
|
146288
146326
|
const onAbort = () => {
|
|
146289
146327
|
clearTimeout(timeout);
|
|
@@ -146624,10 +146662,578 @@ var init_fail = __esm({
|
|
|
146624
146662
|
}
|
|
146625
146663
|
});
|
|
146626
146664
|
|
|
146665
|
+
// packages/safejs/src/modules/canonical-path.ts
|
|
146666
|
+
import { basename as basename8, dirname as dirname12, isAbsolute as isAbsolute9, relative as relative7, resolve as resolve12, sep as sep6 } from "node:path";
|
|
146667
|
+
async function resolveCanonicalPath({ realpath: realpath20, readlink: readlink5 }, path186) {
|
|
146668
|
+
const missingSegments = [];
|
|
146669
|
+
let current = path186;
|
|
146670
|
+
let follows = 0;
|
|
146671
|
+
while (true) {
|
|
146672
|
+
try {
|
|
146673
|
+
const canonicalCurrent = await realpath20(current);
|
|
146674
|
+
return resolve12(canonicalCurrent, ...missingSegments.reverse());
|
|
146675
|
+
} catch (error3) {
|
|
146676
|
+
if (!MISSING_PATH_CODES.includes(getOwnErrorCode2(error3) ?? "")) {
|
|
146677
|
+
throw error3;
|
|
146678
|
+
}
|
|
146679
|
+
const target = await readSymlinkTarget2(readlink5, current);
|
|
146680
|
+
if (target !== void 0) {
|
|
146681
|
+
if (++follows > MAX_SYMLINK_FOLLOWS) {
|
|
146682
|
+
throw createLoopError(path186);
|
|
146683
|
+
}
|
|
146684
|
+
current = isAbsolute9(target) ? resolve12(target) : resolve12(dirname12(current), target);
|
|
146685
|
+
continue;
|
|
146686
|
+
}
|
|
146687
|
+
const parent = dirname12(current);
|
|
146688
|
+
if (parent === current) {
|
|
146689
|
+
return resolve12(path186);
|
|
146690
|
+
}
|
|
146691
|
+
missingSegments.push(basename8(current));
|
|
146692
|
+
current = parent;
|
|
146693
|
+
}
|
|
146694
|
+
}
|
|
146695
|
+
}
|
|
146696
|
+
async function readSymlinkTarget2(readlink5, path186) {
|
|
146697
|
+
try {
|
|
146698
|
+
return await readlink5(path186);
|
|
146699
|
+
} catch (error3) {
|
|
146700
|
+
if (NOT_A_SYMLINK_CODES.includes(getOwnErrorCode2(error3) ?? "")) {
|
|
146701
|
+
return void 0;
|
|
146702
|
+
}
|
|
146703
|
+
throw error3;
|
|
146704
|
+
}
|
|
146705
|
+
}
|
|
146706
|
+
function createLoopError(path186) {
|
|
146707
|
+
const error3 = new Error(
|
|
146708
|
+
`ELOOP: too many symbolic links encountered, realpath '${path186}'`
|
|
146709
|
+
);
|
|
146710
|
+
error3.code = "ELOOP";
|
|
146711
|
+
return error3;
|
|
146712
|
+
}
|
|
146713
|
+
async function containsPath(stat36, canonicalRoot, canonicalPath) {
|
|
146714
|
+
if (containsCanonicalSpelling(canonicalRoot, canonicalPath)) {
|
|
146715
|
+
return true;
|
|
146716
|
+
}
|
|
146717
|
+
return descendsFromRoot(stat36, canonicalRoot, canonicalPath);
|
|
146718
|
+
}
|
|
146719
|
+
async function isSamePath(stat36, canonicalLeft, canonicalRight) {
|
|
146720
|
+
if (canonicalLeft === canonicalRight) {
|
|
146721
|
+
return true;
|
|
146722
|
+
}
|
|
146723
|
+
const [left, right] = await Promise.all([
|
|
146724
|
+
readIdentity(stat36, canonicalLeft),
|
|
146725
|
+
readIdentity(stat36, canonicalRight)
|
|
146726
|
+
]);
|
|
146727
|
+
return left !== void 0 && right !== void 0 && left.dev === right.dev && left.ino === right.ino;
|
|
146728
|
+
}
|
|
146729
|
+
function containsCanonicalSpelling(canonicalRoot, canonicalPath) {
|
|
146730
|
+
const relativePath = relative7(canonicalRoot, canonicalPath);
|
|
146731
|
+
return !(relativePath === ".." || relativePath.startsWith(`..${sep6}`) || isAbsolute9(relativePath));
|
|
146732
|
+
}
|
|
146733
|
+
async function descendsFromRoot(stat36, canonicalRoot, canonicalPath) {
|
|
146734
|
+
const root = await readIdentity(stat36, canonicalRoot);
|
|
146735
|
+
if (root === void 0) {
|
|
146736
|
+
return false;
|
|
146737
|
+
}
|
|
146738
|
+
let current = canonicalPath;
|
|
146739
|
+
while (true) {
|
|
146740
|
+
const identity = await readIdentity(stat36, current);
|
|
146741
|
+
if (identity !== void 0 && identity.dev === root.dev && identity.ino === root.ino) {
|
|
146742
|
+
return true;
|
|
146743
|
+
}
|
|
146744
|
+
const parent = dirname12(current);
|
|
146745
|
+
if (parent === current) {
|
|
146746
|
+
return false;
|
|
146747
|
+
}
|
|
146748
|
+
current = parent;
|
|
146749
|
+
}
|
|
146750
|
+
}
|
|
146751
|
+
async function readIdentity(stat36, path186) {
|
|
146752
|
+
try {
|
|
146753
|
+
const { dev, ino } = await stat36(path186);
|
|
146754
|
+
return { dev, ino };
|
|
146755
|
+
} catch (error3) {
|
|
146756
|
+
if (MISSING_PATH_CODES.includes(getOwnErrorCode2(error3) ?? "")) {
|
|
146757
|
+
return void 0;
|
|
146758
|
+
}
|
|
146759
|
+
throw error3;
|
|
146760
|
+
}
|
|
146761
|
+
}
|
|
146762
|
+
var MISSING_PATH_CODES, NOT_A_SYMLINK_CODES, MAX_SYMLINK_FOLLOWS;
|
|
146763
|
+
var init_canonical_path = __esm({
|
|
146764
|
+
"packages/safejs/src/modules/canonical-path.ts"() {
|
|
146765
|
+
"use strict";
|
|
146766
|
+
init_error_codes22();
|
|
146767
|
+
MISSING_PATH_CODES = ["ENOENT", "ENOTDIR"];
|
|
146768
|
+
NOT_A_SYMLINK_CODES = [...MISSING_PATH_CODES, "EINVAL"];
|
|
146769
|
+
MAX_SYMLINK_FOLLOWS = 32;
|
|
146770
|
+
}
|
|
146771
|
+
});
|
|
146772
|
+
|
|
146773
|
+
// packages/safejs/src/modules/fs.ts
|
|
146774
|
+
import { constants as nodeFsConstants } from "node:fs";
|
|
146775
|
+
import * as nodeFsPromises from "node:fs/promises";
|
|
146776
|
+
import { dirname as dirname13, isAbsolute as isAbsolute10, resolve as resolve13 } from "node:path";
|
|
146777
|
+
import { getSystemErrorMap, inspect } from "node:util";
|
|
146778
|
+
function makeFsModule(options = {}) {
|
|
146779
|
+
assertSupportedPlatform();
|
|
146780
|
+
const implementation = options.fs ?? nodeFsPromises;
|
|
146781
|
+
const fs31 = options.root === void 0 ? implementation : makeRootedFs(implementation, options.root);
|
|
146782
|
+
return {
|
|
146783
|
+
access: bind(fs31, "access", "re-issue"),
|
|
146784
|
+
appendFile: bind(fs31, "appendFile", "read-side-effect"),
|
|
146785
|
+
chmod: bind(fs31, "chmod", "read-side-effect"),
|
|
146786
|
+
copyFile: bind(fs31, "copyFile", "read-side-effect"),
|
|
146787
|
+
cp: bind(fs31, "cp", "read-side-effect"),
|
|
146788
|
+
link: bind(fs31, "link", "read-side-effect"),
|
|
146789
|
+
lstat: bindStat(fs31, "lstat"),
|
|
146790
|
+
mkdir: bind(fs31, "mkdir", "read-side-effect"),
|
|
146791
|
+
// Creates a directory, so it cannot be re-issued on resume like the other
|
|
146792
|
+
// string-result operations, but its name still crosses as a Buffer for a buffer
|
|
146793
|
+
// encoding and so goes through the same guard.
|
|
146794
|
+
mkdtemp: bindStringResult(fs31, "mkdtemp", "read-side-effect"),
|
|
146795
|
+
readFile: bindStringResult(fs31, "readFile"),
|
|
146796
|
+
readdir: bindReaddir(fs31),
|
|
146797
|
+
readlink: bindStringResult(fs31, "readlink"),
|
|
146798
|
+
realpath: bindStringResult(fs31, "realpath"),
|
|
146799
|
+
rename: bind(fs31, "rename", "read-side-effect"),
|
|
146800
|
+
rm: bind(fs31, "rm", "read-side-effect"),
|
|
146801
|
+
rmdir: bind(fs31, "rmdir", "read-side-effect"),
|
|
146802
|
+
stat: bindStat(fs31, "stat"),
|
|
146803
|
+
symlink: bind(fs31, "symlink", "read-side-effect"),
|
|
146804
|
+
truncate: bind(fs31, "truncate", "read-side-effect"),
|
|
146805
|
+
utimes: bind(fs31, "utimes", "read-side-effect"),
|
|
146806
|
+
writeFile: bind(fs31, "writeFile", "read-side-effect"),
|
|
146807
|
+
constants: {
|
|
146808
|
+
F_OK: nodeFsConstants.F_OK,
|
|
146809
|
+
R_OK: nodeFsConstants.R_OK,
|
|
146810
|
+
W_OK: nodeFsConstants.W_OK,
|
|
146811
|
+
X_OK: nodeFsConstants.X_OK,
|
|
146812
|
+
COPYFILE_EXCL: nodeFsConstants.COPYFILE_EXCL
|
|
146813
|
+
}
|
|
146814
|
+
};
|
|
146815
|
+
}
|
|
146816
|
+
function assertSupportedPlatform() {
|
|
146817
|
+
if (process.platform !== "win32") {
|
|
146818
|
+
return;
|
|
146819
|
+
}
|
|
146820
|
+
throw new Error(
|
|
146821
|
+
"SafeJS's fs module does not support win32: node's fs answers a different code there (EPERM or UNKNOWN where darwin and linux answer EISDIR or ENOTEMPTY), a path carries a drive letter that root confinement has no rule for, and a symlink needs a privilege a script cannot hold. Run on darwin or linux, or build a host module for the surface you need."
|
|
146822
|
+
);
|
|
146823
|
+
}
|
|
146824
|
+
function bind(fs31, name, policy) {
|
|
146825
|
+
return declare(
|
|
146826
|
+
name,
|
|
146827
|
+
policy,
|
|
146828
|
+
(...args) => invoke(fs31, name, args)
|
|
146829
|
+
);
|
|
146830
|
+
}
|
|
146831
|
+
function bindStringResult(fs31, name, policy = "re-issue") {
|
|
146832
|
+
return declare(name, policy, async (...args) => {
|
|
146833
|
+
assertNoBufferResult(name, args[1]);
|
|
146834
|
+
return await invoke(fs31, name, args);
|
|
146835
|
+
});
|
|
146836
|
+
}
|
|
146837
|
+
function bindReaddir(fs31) {
|
|
146838
|
+
return declare("readdir", "re-issue", async (...args) => {
|
|
146839
|
+
assertNoBufferResult("readdir", args[1]);
|
|
146840
|
+
const entries = await invoke(fs31, "readdir", args);
|
|
146841
|
+
return entries.map((entry) => typeof entry === "string" ? entry : toSandboxDirent(entry));
|
|
146842
|
+
});
|
|
146843
|
+
}
|
|
146844
|
+
function bindStat(fs31, name) {
|
|
146845
|
+
return declare(name, "re-issue", async (...args) => {
|
|
146846
|
+
assertNoBigIntResult(name, args[1]);
|
|
146847
|
+
return toSandboxStats(await invoke(fs31, name, args));
|
|
146848
|
+
});
|
|
146849
|
+
}
|
|
146850
|
+
function declare(name, policy, operation) {
|
|
146851
|
+
const validated = async (...args) => {
|
|
146852
|
+
FS_PATH_ARGUMENTS[name].forEach(
|
|
146853
|
+
(argument, index) => assertSupportedPath(name, argument, args[index])
|
|
146854
|
+
);
|
|
146855
|
+
assertSupportedOptions(name, args);
|
|
146856
|
+
return await operation(...args);
|
|
146857
|
+
};
|
|
146858
|
+
Object.defineProperty(validated, "name", { value: name });
|
|
146859
|
+
declareHostOperation(validated, policy);
|
|
146860
|
+
return validated;
|
|
146861
|
+
}
|
|
146862
|
+
function invoke(fs31, name, args) {
|
|
146863
|
+
return Reflect.apply(fs31[name], fs31, args);
|
|
146864
|
+
}
|
|
146865
|
+
function makeRootedFs(fs31, root) {
|
|
146866
|
+
if (root.trim().length === 0) {
|
|
146867
|
+
throw new Error("fs module root must be a non-empty string.");
|
|
146868
|
+
}
|
|
146869
|
+
const rooted = {};
|
|
146870
|
+
for (const name of Object.keys(FS_SYSCALLS)) {
|
|
146871
|
+
rooted[name] = async (...args) => {
|
|
146872
|
+
assertRootCanConfineOptions(name, args);
|
|
146873
|
+
return invoke(fs31, name, await resolvePathArguments(fs31, root, name, args));
|
|
146874
|
+
};
|
|
146875
|
+
}
|
|
146876
|
+
return rooted;
|
|
146877
|
+
}
|
|
146878
|
+
function assertRootCanConfineOptions(name, args) {
|
|
146879
|
+
if (name !== "cp") {
|
|
146880
|
+
return;
|
|
146881
|
+
}
|
|
146882
|
+
const options = args[FS_OPTION_SURFACE.cp.argument];
|
|
146883
|
+
if (isObjectLike2(options) && options.dereference === true) {
|
|
146884
|
+
throw createUnsupportedOptionError("cp", "dereference", ROOT_REFUSED_DEREFERENCE_REASON);
|
|
146885
|
+
}
|
|
146886
|
+
}
|
|
146887
|
+
async function resolvePathArguments(fs31, root, name, args) {
|
|
146888
|
+
const canonicalRoot = await resolveCanonicalPath(readCanonicalPathFs(fs31), resolve13(root));
|
|
146889
|
+
const resolved = [...args];
|
|
146890
|
+
if (name === "symlink") {
|
|
146891
|
+
const linkPath = readPath(canonicalRoot, args[1]);
|
|
146892
|
+
resolved[1] = linkPath;
|
|
146893
|
+
await assertInsideRoot2(fs31, canonicalRoot, name, [
|
|
146894
|
+
readPath(dirname13(linkPath), args[0]),
|
|
146895
|
+
linkPath
|
|
146896
|
+
]);
|
|
146897
|
+
return resolved;
|
|
146898
|
+
}
|
|
146899
|
+
const paths = FS_PATH_ARGUMENTS[name].map((_, index) => {
|
|
146900
|
+
const path186 = readPath(canonicalRoot, args[index]);
|
|
146901
|
+
resolved[index] = path186;
|
|
146902
|
+
return path186;
|
|
146903
|
+
});
|
|
146904
|
+
await assertInsideRoot2(fs31, canonicalRoot, name, paths);
|
|
146905
|
+
return resolved;
|
|
146906
|
+
}
|
|
146907
|
+
async function assertInsideRoot2(fs31, canonicalRoot, name, paths) {
|
|
146908
|
+
for (const path186 of paths) {
|
|
146909
|
+
if (await escapesRoot(fs31, canonicalRoot, path186)) {
|
|
146910
|
+
throw createAccessDeniedError(name, paths[0], paths[1]);
|
|
146911
|
+
}
|
|
146912
|
+
}
|
|
146913
|
+
}
|
|
146914
|
+
async function escapesRoot(fs31, canonicalRoot, path186) {
|
|
146915
|
+
const canonicalPath = await resolveCanonicalPath(readCanonicalPathFs(fs31), path186);
|
|
146916
|
+
return !await containsPath(readStat(fs31), canonicalRoot, canonicalPath);
|
|
146917
|
+
}
|
|
146918
|
+
function readCanonicalPathFs(fs31) {
|
|
146919
|
+
return {
|
|
146920
|
+
realpath: async (path186) => await invoke(fs31, "realpath", [path186]),
|
|
146921
|
+
readlink: async (path186) => await invoke(fs31, "readlink", [path186])
|
|
146922
|
+
};
|
|
146923
|
+
}
|
|
146924
|
+
function readStat(fs31) {
|
|
146925
|
+
return async (path186) => await invoke(fs31, "stat", [path186]);
|
|
146926
|
+
}
|
|
146927
|
+
function assertSupportedPath(name, argument, value) {
|
|
146928
|
+
if (typeof value === "string") {
|
|
146929
|
+
if (value.includes(NULL_BYTE)) {
|
|
146930
|
+
throw createNullByteError(argument, value);
|
|
146931
|
+
}
|
|
146932
|
+
return;
|
|
146933
|
+
}
|
|
146934
|
+
const form = readUnsupportedPathForm(value);
|
|
146935
|
+
throw form === void 0 ? createInvalidPathTypeError(argument, value) : createUnsupportedPathError(name, argument, form);
|
|
146936
|
+
}
|
|
146937
|
+
function readUnsupportedPathForm(value) {
|
|
146938
|
+
if (value instanceof Uint8Array) {
|
|
146939
|
+
return "a Buffer or Uint8Array";
|
|
146940
|
+
}
|
|
146941
|
+
return value instanceof URL ? "a URL" : void 0;
|
|
146942
|
+
}
|
|
146943
|
+
function createNullByteError(argument, value) {
|
|
146944
|
+
const error3 = new TypeError(
|
|
146945
|
+
`The argument '${argument}' must be a string, Uint8Array, or URL without null bytes. Received ${inspect(value)}`
|
|
146946
|
+
);
|
|
146947
|
+
error3.code = INVALID_ARGUMENT_CODE;
|
|
146948
|
+
return error3;
|
|
146949
|
+
}
|
|
146950
|
+
function createInvalidPathTypeError(argument, value) {
|
|
146951
|
+
const error3 = new TypeError(
|
|
146952
|
+
`The "${argument}" argument must be of type string or an instance of Buffer or URL. Received ${describeReceivedValue(value)}`
|
|
146953
|
+
);
|
|
146954
|
+
error3.code = INVALID_ARGUMENT_TYPE_CODE;
|
|
146955
|
+
return error3;
|
|
146956
|
+
}
|
|
146957
|
+
function createUnsupportedPathError(name, argument, form) {
|
|
146958
|
+
return new TypeError(
|
|
146959
|
+
`fs.${name} cannot accept ${form} as the '${argument}' argument inside SafeJS; pass the path as a string.`
|
|
146960
|
+
);
|
|
146961
|
+
}
|
|
146962
|
+
function describeReceivedValue(value) {
|
|
146963
|
+
if (value === null || value === void 0) {
|
|
146964
|
+
return String(value);
|
|
146965
|
+
}
|
|
146966
|
+
if (typeof value === "function") {
|
|
146967
|
+
return `function ${value.name}`;
|
|
146968
|
+
}
|
|
146969
|
+
if (typeof value === "object") {
|
|
146970
|
+
const constructorName = value.constructor?.name;
|
|
146971
|
+
return constructorName === void 0 ? inspect(value, { depth: -1 }) : `an instance of ${constructorName}`;
|
|
146972
|
+
}
|
|
146973
|
+
return `type ${typeof value} (${inspect(value)})`;
|
|
146974
|
+
}
|
|
146975
|
+
function readPath(base, value) {
|
|
146976
|
+
const path186 = value;
|
|
146977
|
+
return isAbsolute10(path186) ? resolve13(path186) : resolve13(base, path186);
|
|
146978
|
+
}
|
|
146979
|
+
function createAccessDeniedError(name, path186, dest) {
|
|
146980
|
+
const syscall = FS_SYSCALLS[name];
|
|
146981
|
+
const target = dest === void 0 ? `'${path186}'` : `'${path186}' -> '${dest}'`;
|
|
146982
|
+
const error3 = new Error(
|
|
146983
|
+
`${ACCESS_DENIED_CODE}: ${ACCESS_DENIED_MESSAGE}, ${syscall} ${target}`
|
|
146984
|
+
);
|
|
146985
|
+
error3.code = ACCESS_DENIED_CODE;
|
|
146986
|
+
error3.errno = ACCESS_DENIED_ERRNO;
|
|
146987
|
+
error3.syscall = syscall;
|
|
146988
|
+
error3.path = path186;
|
|
146989
|
+
if (dest !== void 0) {
|
|
146990
|
+
error3.dest = dest;
|
|
146991
|
+
}
|
|
146992
|
+
return error3;
|
|
146993
|
+
}
|
|
146994
|
+
function readSystemError(code) {
|
|
146995
|
+
for (const [errno, [name, message2]] of getSystemErrorMap()) {
|
|
146996
|
+
if (name === code) {
|
|
146997
|
+
return [errno, message2];
|
|
146998
|
+
}
|
|
146999
|
+
}
|
|
147000
|
+
throw new Error(`node does not define the ${code} system error.`);
|
|
147001
|
+
}
|
|
147002
|
+
function assertSupportedOptions(name, args) {
|
|
147003
|
+
const surface = FS_OPTION_SURFACE[name];
|
|
147004
|
+
if (surface === void 0 || !isObjectLike2(args[surface.argument])) {
|
|
147005
|
+
return;
|
|
147006
|
+
}
|
|
147007
|
+
const options = args[surface.argument];
|
|
147008
|
+
for (const option of surface.refused) {
|
|
147009
|
+
if (option in options) {
|
|
147010
|
+
throw createUnsupportedOptionError(name, option, REFUSED_OPTION_REASONS[option]);
|
|
147011
|
+
}
|
|
147012
|
+
}
|
|
147013
|
+
for (const option in options) {
|
|
147014
|
+
if (!surface.honoured.includes(option)) {
|
|
147015
|
+
throw createUnsupportedOptionError(name, option, UNKNOWN_OPTION_REASON);
|
|
147016
|
+
}
|
|
147017
|
+
}
|
|
147018
|
+
}
|
|
147019
|
+
function assertNoBufferResult(operation, options) {
|
|
147020
|
+
if (readsBuffer(options, BUFFER_BY_DEFAULT[operation])) {
|
|
147021
|
+
throw createUnsupportedCapabilityError(
|
|
147022
|
+
operation,
|
|
147023
|
+
"return a Buffer",
|
|
147024
|
+
'pass a string encoding such as "utf8"'
|
|
147025
|
+
);
|
|
147026
|
+
}
|
|
147027
|
+
}
|
|
147028
|
+
function assertNoBigIntResult(operation, options) {
|
|
147029
|
+
if (isObjectLike2(options) && options.bigint === true) {
|
|
147030
|
+
throw createUnsupportedCapabilityError(
|
|
147031
|
+
operation,
|
|
147032
|
+
"return BigInt fields",
|
|
147033
|
+
"omit bigint and read the *Ms timestamps instead"
|
|
147034
|
+
);
|
|
147035
|
+
}
|
|
147036
|
+
}
|
|
147037
|
+
function createUnsupportedOptionError(operation, option, reason) {
|
|
147038
|
+
return createUnsupportedCapabilityError(operation, `honour the '${option}' option`, reason);
|
|
147039
|
+
}
|
|
147040
|
+
function createUnsupportedCapabilityError(operation, capability, remedy) {
|
|
147041
|
+
return new TypeError(`fs.${operation} cannot ${capability} inside SafeJS; ${remedy}.`);
|
|
147042
|
+
}
|
|
147043
|
+
function readsBuffer(options, bufferByDefault) {
|
|
147044
|
+
if (typeof options === "string") {
|
|
147045
|
+
return options === BUFFER_ENCODING;
|
|
147046
|
+
}
|
|
147047
|
+
if (options === void 0 || options === null) {
|
|
147048
|
+
return bufferByDefault;
|
|
147049
|
+
}
|
|
147050
|
+
if (!isObjectLike2(options)) {
|
|
147051
|
+
return false;
|
|
147052
|
+
}
|
|
147053
|
+
const { encoding } = options;
|
|
147054
|
+
if (encoding === BUFFER_ENCODING) {
|
|
147055
|
+
return true;
|
|
147056
|
+
}
|
|
147057
|
+
return (encoding === void 0 || encoding === null) && bufferByDefault;
|
|
147058
|
+
}
|
|
147059
|
+
function toSandboxStats(stats2) {
|
|
147060
|
+
const numbers = {};
|
|
147061
|
+
for (const field of STAT_NUMBER_FIELDS) {
|
|
147062
|
+
numbers[field] = stats2[field];
|
|
147063
|
+
}
|
|
147064
|
+
return { ...numbers, ...toFileTypePredicates(stats2) };
|
|
147065
|
+
}
|
|
147066
|
+
function toSandboxDirent(dirent) {
|
|
147067
|
+
return {
|
|
147068
|
+
name: dirent.name,
|
|
147069
|
+
parentPath: dirent.parentPath,
|
|
147070
|
+
...toFileTypePredicates(dirent)
|
|
147071
|
+
};
|
|
147072
|
+
}
|
|
147073
|
+
function toFileTypePredicates(source) {
|
|
147074
|
+
const predicates = {};
|
|
147075
|
+
for (const predicate of FILE_TYPE_PREDICATES) {
|
|
147076
|
+
const result = source[predicate]();
|
|
147077
|
+
predicates[predicate] = () => result;
|
|
147078
|
+
}
|
|
147079
|
+
return predicates;
|
|
147080
|
+
}
|
|
147081
|
+
function isObjectLike2(value) {
|
|
147082
|
+
return typeof value === "object" && value !== null || typeof value === "function";
|
|
147083
|
+
}
|
|
147084
|
+
var BUFFER_BY_DEFAULT, REFUSED_OPTION_REASONS, UNKNOWN_OPTION_REASON, ROOT_REFUSED_DEREFERENCE_REASON, FS_OPTION_SURFACE, STAT_NUMBER_FIELDS, FILE_TYPE_PREDICATES, BUFFER_ENCODING, FS_SYSCALLS, FS_PATH_ARGUMENTS, ACCESS_DENIED_CODE, INVALID_ARGUMENT_CODE, INVALID_ARGUMENT_TYPE_CODE, NULL_BYTE, ACCESS_DENIED_ERRNO, ACCESS_DENIED_MESSAGE;
|
|
147085
|
+
var init_fs2 = __esm({
|
|
147086
|
+
"packages/safejs/src/modules/fs.ts"() {
|
|
147087
|
+
"use strict";
|
|
147088
|
+
init_host_bridge();
|
|
147089
|
+
init_canonical_path();
|
|
147090
|
+
BUFFER_BY_DEFAULT = {
|
|
147091
|
+
readFile: true,
|
|
147092
|
+
readdir: false,
|
|
147093
|
+
readlink: false,
|
|
147094
|
+
realpath: false,
|
|
147095
|
+
mkdtemp: false
|
|
147096
|
+
};
|
|
147097
|
+
REFUSED_OPTION_REASONS = {
|
|
147098
|
+
signal: "the sandbox has no AbortController, and cancelling a run is the host's to request rather than the script's",
|
|
147099
|
+
// @types/node declares this on fs/promises stat and lstat and types
|
|
147100
|
+
// `throwIfNoEntry: false` as answering `Stats | undefined`, but the typings are
|
|
147101
|
+
// ahead of node: only the synchronous API reads the option. Forwarding it would
|
|
147102
|
+
// leave a script holding the ENOENT rejection the typings told it to expect
|
|
147103
|
+
// undefined for, so it is refused rather than dropped.
|
|
147104
|
+
throwIfNoEntry: "only node's synchronous stat reads it and fs/promises rejects a missing path whatever it says, so catch the ENOENT rejection instead",
|
|
147105
|
+
// cp's filter is a callback the host would invoke, which a sandbox closure can cross the
|
|
147106
|
+
// bridge to serve. It is refused for what happens around the call rather than during it:
|
|
147107
|
+
// the digest that identifies a host call across a snapshot is built by stringifying the
|
|
147108
|
+
// arguments, and a function does not survive that, so cp(filter: keep) and
|
|
147109
|
+
// cp(filter: drop) are one call to the resume machinery.
|
|
147110
|
+
filter: "a closure is dropped from the digest that identifies a host call across a snapshot, so a resumed run could reconcile against a copy that took a different set of files, and under a root it would read the rewritten host paths rather than the ones the script wrote \u2014 walk the tree with readdir and copy the entries you want instead"
|
|
147111
|
+
};
|
|
147112
|
+
UNKNOWN_OPTION_REASON = "node declares no such option for it, and an unrecognised option is refused rather than silently ignored";
|
|
147113
|
+
ROOT_REFUSED_DEREFERENCE_REASON = "a root canonicalizes cp's src and dest but never the paths nested inside the tree, so node would copy an escaping link's target inside root where the script could read it \u2014 copy without dereference and a nested link stays a link the root still refuses to read through";
|
|
147114
|
+
FS_OPTION_SURFACE = {
|
|
147115
|
+
appendFile: {
|
|
147116
|
+
argument: 2,
|
|
147117
|
+
honoured: ["encoding", "mode", "flag", "flush"],
|
|
147118
|
+
// node's appendFile forwards to writeFile, so it honours a signal even though
|
|
147119
|
+
// @types/node does not declare one for it.
|
|
147120
|
+
refused: ["signal"]
|
|
147121
|
+
},
|
|
147122
|
+
// node reads cp's bag from a parameter it names opts rather than options, and validates
|
|
147123
|
+
// every key it knows — while still ignoring one it does not, which is what the unknown
|
|
147124
|
+
// refusal covers. mode is copyFile's flag set rather than a permission.
|
|
147125
|
+
cp: {
|
|
147126
|
+
argument: 2,
|
|
147127
|
+
honoured: [
|
|
147128
|
+
"dereference",
|
|
147129
|
+
"errorOnExist",
|
|
147130
|
+
"force",
|
|
147131
|
+
"mode",
|
|
147132
|
+
"preserveTimestamps",
|
|
147133
|
+
"recursive",
|
|
147134
|
+
"verbatimSymlinks"
|
|
147135
|
+
],
|
|
147136
|
+
refused: ["filter"]
|
|
147137
|
+
},
|
|
147138
|
+
lstat: { argument: 1, honoured: ["bigint"], refused: ["throwIfNoEntry"] },
|
|
147139
|
+
mkdir: { argument: 1, honoured: ["recursive", "mode"], refused: [] },
|
|
147140
|
+
mkdtemp: { argument: 1, honoured: ["encoding"], refused: [] },
|
|
147141
|
+
readFile: { argument: 1, honoured: ["encoding", "flag"], refused: ["signal"] },
|
|
147142
|
+
readdir: { argument: 1, honoured: ["encoding", "withFileTypes", "recursive"], refused: [] },
|
|
147143
|
+
readlink: { argument: 1, honoured: ["encoding"], refused: [] },
|
|
147144
|
+
realpath: { argument: 1, honoured: ["encoding"], refused: [] },
|
|
147145
|
+
rm: { argument: 1, honoured: ["force", "recursive", "maxRetries", "retryDelay"], refused: [] },
|
|
147146
|
+
rmdir: { argument: 1, honoured: ["recursive", "maxRetries", "retryDelay"], refused: [] },
|
|
147147
|
+
stat: { argument: 1, honoured: ["bigint"], refused: ["throwIfNoEntry"] },
|
|
147148
|
+
writeFile: { argument: 2, honoured: ["encoding", "mode", "flag", "flush"], refused: ["signal"] }
|
|
147149
|
+
};
|
|
147150
|
+
STAT_NUMBER_FIELDS = [
|
|
147151
|
+
"dev",
|
|
147152
|
+
"mode",
|
|
147153
|
+
"nlink",
|
|
147154
|
+
"uid",
|
|
147155
|
+
"gid",
|
|
147156
|
+
"rdev",
|
|
147157
|
+
"blksize",
|
|
147158
|
+
"ino",
|
|
147159
|
+
"size",
|
|
147160
|
+
"blocks",
|
|
147161
|
+
"atimeMs",
|
|
147162
|
+
"mtimeMs",
|
|
147163
|
+
"ctimeMs",
|
|
147164
|
+
"birthtimeMs"
|
|
147165
|
+
];
|
|
147166
|
+
FILE_TYPE_PREDICATES = [
|
|
147167
|
+
"isFile",
|
|
147168
|
+
"isDirectory",
|
|
147169
|
+
"isSymbolicLink",
|
|
147170
|
+
"isBlockDevice",
|
|
147171
|
+
"isCharacterDevice",
|
|
147172
|
+
"isFIFO",
|
|
147173
|
+
"isSocket"
|
|
147174
|
+
];
|
|
147175
|
+
BUFFER_ENCODING = "buffer";
|
|
147176
|
+
FS_SYSCALLS = {
|
|
147177
|
+
access: "access",
|
|
147178
|
+
appendFile: "open",
|
|
147179
|
+
chmod: "chmod",
|
|
147180
|
+
copyFile: "copyfile",
|
|
147181
|
+
// node's cp is its own JavaScript layer rather than a syscall wrapper, so it blames the
|
|
147182
|
+
// fs function by name: its ERR_FS_CP_* errors carry syscall 'cp'.
|
|
147183
|
+
cp: "cp",
|
|
147184
|
+
link: "link",
|
|
147185
|
+
lstat: "lstat",
|
|
147186
|
+
mkdir: "mkdir",
|
|
147187
|
+
mkdtemp: "mkdtemp",
|
|
147188
|
+
readFile: "open",
|
|
147189
|
+
readdir: "scandir",
|
|
147190
|
+
readlink: "readlink",
|
|
147191
|
+
realpath: "realpath",
|
|
147192
|
+
rename: "rename",
|
|
147193
|
+
rm: "lstat",
|
|
147194
|
+
rmdir: "rmdir",
|
|
147195
|
+
stat: "stat",
|
|
147196
|
+
symlink: "symlink",
|
|
147197
|
+
truncate: "open",
|
|
147198
|
+
utimes: "utime",
|
|
147199
|
+
writeFile: "open"
|
|
147200
|
+
};
|
|
147201
|
+
FS_PATH_ARGUMENTS = {
|
|
147202
|
+
access: ["path"],
|
|
147203
|
+
appendFile: ["path"],
|
|
147204
|
+
chmod: ["path"],
|
|
147205
|
+
copyFile: ["src", "dest"],
|
|
147206
|
+
// node blames these by the same names it uses for copyFile's two paths.
|
|
147207
|
+
cp: ["src", "dest"],
|
|
147208
|
+
link: ["existingPath", "newPath"],
|
|
147209
|
+
lstat: ["path"],
|
|
147210
|
+
mkdir: ["path"],
|
|
147211
|
+
mkdtemp: ["prefix"],
|
|
147212
|
+
readFile: ["path"],
|
|
147213
|
+
readdir: ["path"],
|
|
147214
|
+
readlink: ["oldPath"],
|
|
147215
|
+
realpath: ["path"],
|
|
147216
|
+
rename: ["oldPath", "newPath"],
|
|
147217
|
+
rm: ["path"],
|
|
147218
|
+
rmdir: ["path"],
|
|
147219
|
+
stat: ["path"],
|
|
147220
|
+
symlink: ["target", "path"],
|
|
147221
|
+
truncate: ["path"],
|
|
147222
|
+
utimes: ["path"],
|
|
147223
|
+
writeFile: ["path"]
|
|
147224
|
+
};
|
|
147225
|
+
ACCESS_DENIED_CODE = "EACCES";
|
|
147226
|
+
INVALID_ARGUMENT_CODE = "ERR_INVALID_ARG_VALUE";
|
|
147227
|
+
INVALID_ARGUMENT_TYPE_CODE = "ERR_INVALID_ARG_TYPE";
|
|
147228
|
+
NULL_BYTE = "\0";
|
|
147229
|
+
[ACCESS_DENIED_ERRNO, ACCESS_DENIED_MESSAGE] = readSystemError(ACCESS_DENIED_CODE);
|
|
147230
|
+
}
|
|
147231
|
+
});
|
|
147232
|
+
|
|
146627
147233
|
// packages/safejs/src/modules/git.ts
|
|
146628
147234
|
import { execFile as execFile3 } from "node:child_process";
|
|
146629
|
-
import { mkdir as mkdir38, realpath as realpath19, rm as rm16 } from "node:fs/promises";
|
|
146630
|
-
import {
|
|
147235
|
+
import { mkdir as mkdir38, readlink as readlink4, realpath as realpath19, rm as rm16, stat as stat35 } from "node:fs/promises";
|
|
147236
|
+
import { dirname as dirname14, isAbsolute as isAbsolute11, resolve as resolve14 } from "node:path";
|
|
146631
147237
|
function makeGitModule(cwd) {
|
|
146632
147238
|
const normalizedCwd = readNonEmptyString6(cwd, "Git module cwd");
|
|
146633
147239
|
return {
|
|
@@ -146712,7 +147318,7 @@ function makeGitModule(cwd) {
|
|
|
146712
147318
|
if (await gitRefExists(normalizedCwd, `refs/heads/${normalizedBranch}`)) {
|
|
146713
147319
|
throw new Error(`Git worktree branch '${normalizedBranch}' already exists.`);
|
|
146714
147320
|
}
|
|
146715
|
-
await mkdir38(
|
|
147321
|
+
await mkdir38(dirname14(worktreePath), { recursive: true });
|
|
146716
147322
|
try {
|
|
146717
147323
|
await runGit(normalizedCwd, [
|
|
146718
147324
|
"worktree",
|
|
@@ -146737,7 +147343,7 @@ function makeGitModule(cwd) {
|
|
|
146737
147343
|
const repoRoot = await getRepoRoot(normalizedCwd);
|
|
146738
147344
|
const worktreePath = await resolveWorktreePath(repoRoot, path186, "Git worktree path");
|
|
146739
147345
|
const worktrees = await listWorktrees2(normalizedCwd);
|
|
146740
|
-
if (!worktrees.some((worktree) =>
|
|
147346
|
+
if (!worktrees.some((worktree) => resolve14(worktree.path) === worktreePath)) {
|
|
146741
147347
|
return;
|
|
146742
147348
|
}
|
|
146743
147349
|
await runGit(normalizedCwd, ["worktree", "remove", "--force", worktreePath]);
|
|
@@ -146792,7 +147398,7 @@ function createSavepointRef() {
|
|
|
146792
147398
|
return `${SAVEPOINT_REF_PREFIX}${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`;
|
|
146793
147399
|
}
|
|
146794
147400
|
function createDefaultWorktreePath(repoRoot, branch) {
|
|
146795
|
-
return
|
|
147401
|
+
return resolve14(repoRoot, ".poe-code", "worktrees", createSafeBranchDirectoryName(branch));
|
|
146796
147402
|
}
|
|
146797
147403
|
function createSafeBranchDirectoryName(branch) {
|
|
146798
147404
|
return encodeURIComponent(branch);
|
|
@@ -146846,39 +147452,19 @@ function parseBranchRef(ref) {
|
|
|
146846
147452
|
return ref.startsWith(branchPrefix) ? ref.slice(branchPrefix.length) : ref;
|
|
146847
147453
|
}
|
|
146848
147454
|
async function resolveWorktreePath(repoRoot, path186, label) {
|
|
146849
|
-
const resolvedRoot =
|
|
146850
|
-
const resolvedPath =
|
|
147455
|
+
const resolvedRoot = resolve14(repoRoot);
|
|
147456
|
+
const resolvedPath = isAbsolute11(path186) ? resolve14(path186) : resolve14(resolvedRoot, path186);
|
|
146851
147457
|
const canonicalRoot = await realpath19(resolvedRoot);
|
|
146852
|
-
const canonicalPath = await resolveCanonicalPath(resolvedPath);
|
|
146853
|
-
const
|
|
146854
|
-
|
|
147458
|
+
const canonicalPath = await resolveCanonicalPath({ realpath: realpath19, readlink: readlink4 }, resolvedPath);
|
|
147459
|
+
const [inside, isRootItself] = await Promise.all([
|
|
147460
|
+
containsPath(stat35, canonicalRoot, canonicalPath),
|
|
147461
|
+
isSamePath(stat35, canonicalPath, canonicalRoot)
|
|
147462
|
+
]);
|
|
147463
|
+
if (!inside || isRootItself) {
|
|
146855
147464
|
throw new Error(`${label} must be inside the git repository.`);
|
|
146856
147465
|
}
|
|
146857
147466
|
return canonicalPath;
|
|
146858
147467
|
}
|
|
146859
|
-
async function resolveCanonicalPath(path186) {
|
|
146860
|
-
const missingSegments = [];
|
|
146861
|
-
let current = path186;
|
|
146862
|
-
while (true) {
|
|
146863
|
-
try {
|
|
146864
|
-
const canonicalCurrent = await realpath19(current);
|
|
146865
|
-
return resolve12(canonicalCurrent, ...missingSegments.reverse());
|
|
146866
|
-
} catch (error3) {
|
|
146867
|
-
if (!isNotFoundError11(error3)) {
|
|
146868
|
-
throw error3;
|
|
146869
|
-
}
|
|
146870
|
-
const parent = dirname12(current);
|
|
146871
|
-
if (parent === current) {
|
|
146872
|
-
return resolve12(path186);
|
|
146873
|
-
}
|
|
146874
|
-
missingSegments.push(basename8(current));
|
|
146875
|
-
current = parent;
|
|
146876
|
-
}
|
|
146877
|
-
}
|
|
146878
|
-
}
|
|
146879
|
-
function isNotFoundError11(error3) {
|
|
146880
|
-
return hasOwnErrorCode29(error3, "ENOENT");
|
|
146881
|
-
}
|
|
146882
147468
|
function isBranchAlreadyExistsError(error3, branch) {
|
|
146883
147469
|
return error3 instanceof Error && error3.message.includes(branch) && error3.message.includes("already exists");
|
|
146884
147470
|
}
|
|
@@ -146887,7 +147473,7 @@ async function runGitAndTrim(cwd, args) {
|
|
|
146887
147473
|
return stdout.trim();
|
|
146888
147474
|
}
|
|
146889
147475
|
async function runGit(cwd, args) {
|
|
146890
|
-
return new Promise((
|
|
147476
|
+
return new Promise((resolve16, reject) => {
|
|
146891
147477
|
execFile3(
|
|
146892
147478
|
"git",
|
|
146893
147479
|
args,
|
|
@@ -146905,7 +147491,7 @@ async function runGit(cwd, args) {
|
|
|
146905
147491
|
);
|
|
146906
147492
|
return;
|
|
146907
147493
|
}
|
|
146908
|
-
|
|
147494
|
+
resolve16({
|
|
146909
147495
|
stdout,
|
|
146910
147496
|
stderr
|
|
146911
147497
|
});
|
|
@@ -146972,7 +147558,7 @@ var GIT_EXEC_MAX_BUFFER, SAVEPOINT_REF_PREFIX;
|
|
|
146972
147558
|
var init_git2 = __esm({
|
|
146973
147559
|
"packages/safejs/src/modules/git.ts"() {
|
|
146974
147560
|
"use strict";
|
|
146975
|
-
|
|
147561
|
+
init_canonical_path();
|
|
146976
147562
|
GIT_EXEC_MAX_BUFFER = 10 * 1024 * 1024;
|
|
146977
147563
|
SAVEPOINT_REF_PREFIX = "refs/poe-code/checkpoints/";
|
|
146978
147564
|
}
|
|
@@ -147248,7 +147834,7 @@ function makeTimeModule(options = {}) {
|
|
|
147248
147834
|
const signal = options.signal;
|
|
147249
147835
|
async function sleep7(ms) {
|
|
147250
147836
|
assertSleepDelay(ms);
|
|
147251
|
-
return await new Promise((
|
|
147837
|
+
return await new Promise((resolve16, reject) => {
|
|
147252
147838
|
if (signal?.aborted === true) {
|
|
147253
147839
|
reject(createSleepAbortError());
|
|
147254
147840
|
return;
|
|
@@ -147266,7 +147852,7 @@ function makeTimeModule(options = {}) {
|
|
|
147266
147852
|
return;
|
|
147267
147853
|
}
|
|
147268
147854
|
cleanup();
|
|
147269
|
-
|
|
147855
|
+
resolve16();
|
|
147270
147856
|
}
|
|
147271
147857
|
function rejectSleep() {
|
|
147272
147858
|
cleanup();
|
|
@@ -147343,6 +147929,7 @@ var init_src49 = __esm({
|
|
|
147343
147929
|
init_agent3();
|
|
147344
147930
|
init_env();
|
|
147345
147931
|
init_fail();
|
|
147932
|
+
init_fs2();
|
|
147346
147933
|
init_git2();
|
|
147347
147934
|
init_harness2();
|
|
147348
147935
|
init_log2();
|
|
@@ -147486,14 +148073,14 @@ var init_emit_schemas = __esm({
|
|
|
147486
148073
|
|
|
147487
148074
|
// packages/agent-harness/src/loader/pair.ts
|
|
147488
148075
|
import nodeFs22 from "node:fs/promises";
|
|
147489
|
-
import { basename as pathBasename, dirname as
|
|
148076
|
+
import { basename as pathBasename, dirname as dirname15, extname as extname2, join as join15 } from "node:path";
|
|
147490
148077
|
async function resolvePair(inputPath, fs31 = nodeFs22) {
|
|
147491
148078
|
const extension = extname2(inputPath);
|
|
147492
148079
|
if (extension !== ".md" && extension !== ".ajs") {
|
|
147493
148080
|
throw new InvalidPairExtensionError(inputPath, extension);
|
|
147494
148081
|
}
|
|
147495
148082
|
const pairBasename = pathBasename(inputPath, extension);
|
|
147496
|
-
const pairDir =
|
|
148083
|
+
const pairDir = dirname15(inputPath);
|
|
147497
148084
|
const pair = {
|
|
147498
148085
|
ajsPath: join15(pairDir, `${pairBasename}.ajs`),
|
|
147499
148086
|
mdPath: join15(pairDir, `${pairBasename}.md`),
|
|
@@ -147507,16 +148094,16 @@ async function resolvePair(inputPath, fs31 = nodeFs22) {
|
|
|
147507
148094
|
{ side: "md", path: pair.mdPath }
|
|
147508
148095
|
];
|
|
147509
148096
|
for (const check of checks) {
|
|
147510
|
-
let
|
|
148097
|
+
let stat36;
|
|
147511
148098
|
try {
|
|
147512
|
-
|
|
148099
|
+
stat36 = await fs31.stat(check.path);
|
|
147513
148100
|
} catch (error3) {
|
|
147514
148101
|
if (hasOwnErrorCode28(error3, "ENOENT")) {
|
|
147515
148102
|
throw new MissingPairError(check.side, check.path);
|
|
147516
148103
|
}
|
|
147517
148104
|
throw error3;
|
|
147518
148105
|
}
|
|
147519
|
-
if (!
|
|
148106
|
+
if (!stat36.isFile()) {
|
|
147520
148107
|
throw new MissingPairError(check.side, check.path);
|
|
147521
148108
|
}
|
|
147522
148109
|
}
|
|
@@ -147579,8 +148166,8 @@ async function discoverHarnesses(rootDir, fs31 = nodeFs23) {
|
|
|
147579
148166
|
continue;
|
|
147580
148167
|
}
|
|
147581
148168
|
if (typeof entry === "string") {
|
|
147582
|
-
const
|
|
147583
|
-
if (!
|
|
148169
|
+
const stat36 = await fs31.stat(join16(rootDir, entry));
|
|
148170
|
+
if (!stat36.isDirectory?.()) {
|
|
147584
148171
|
continue;
|
|
147585
148172
|
}
|
|
147586
148173
|
}
|
|
@@ -147637,7 +148224,7 @@ var init_validate4 = __esm({
|
|
|
147637
148224
|
import { createHash as createHash13, randomUUID as randomUUID51 } from "node:crypto";
|
|
147638
148225
|
import { lstat as lstat34, mkdir as mkdir39, readFile as readFile55, rename as rename28, unlink as unlink25, writeFile as writeFile29 } from "node:fs/promises";
|
|
147639
148226
|
import os24 from "node:os";
|
|
147640
|
-
import { dirname as
|
|
148227
|
+
import { dirname as dirname16, join as join17, parse as parse15, resolve as resolve15, sep as sep7 } from "node:path";
|
|
147641
148228
|
async function runHarnessPair2(mdPath, options) {
|
|
147642
148229
|
const pair = await resolvePair(mdPath);
|
|
147643
148230
|
{
|
|
@@ -147653,7 +148240,7 @@ async function runHarnessPair2(mdPath, options) {
|
|
|
147653
148240
|
kind: readString10(validated.kind),
|
|
147654
148241
|
version: readNumber6(validated.version),
|
|
147655
148242
|
filename: pair.mdPath,
|
|
147656
|
-
dirname:
|
|
148243
|
+
dirname: dirname16(pair.mdPath),
|
|
147657
148244
|
body
|
|
147658
148245
|
};
|
|
147659
148246
|
const snapshotPath = resolveSnapshotPath(pair.mdPath, options.snapshotPath);
|
|
@@ -147992,7 +148579,7 @@ async function writeHostCallRecords(storePath, records) {
|
|
|
147992
148579
|
} catch {
|
|
147993
148580
|
return;
|
|
147994
148581
|
}
|
|
147995
|
-
await mkdir39(
|
|
148582
|
+
await mkdir39(dirname16(storePath), { recursive: true });
|
|
147996
148583
|
await writeTextFileAtomically2(storePath, serialized);
|
|
147997
148584
|
}
|
|
147998
148585
|
async function writeTextFileAtomically2(filePath, content) {
|
|
@@ -148050,7 +148637,7 @@ function listModuleExports(moduleExports) {
|
|
|
148050
148637
|
return exportNames.filter((exportName) => exportName.length > 0).sort((left, right) => left.localeCompare(right));
|
|
148051
148638
|
}
|
|
148052
148639
|
function resolveSnapshotPath(mdPath, snapshotPath) {
|
|
148053
|
-
const documentKey = createHash13("sha256").update(
|
|
148640
|
+
const documentKey = createHash13("sha256").update(resolve15(mdPath)).digest("hex").slice(0, 12);
|
|
148054
148641
|
return snapshotPath ?? join17(
|
|
148055
148642
|
resolveRunLogDir({
|
|
148056
148643
|
planPath: mdPath,
|
|
@@ -148061,7 +148648,7 @@ function resolveSnapshotPath(mdPath, snapshotPath) {
|
|
|
148061
148648
|
);
|
|
148062
148649
|
}
|
|
148063
148650
|
async function assertDefaultSnapshotPathIsRegular(snapshotPath) {
|
|
148064
|
-
const absolutePath =
|
|
148651
|
+
const absolutePath = resolve15(snapshotPath);
|
|
148065
148652
|
const rootPath = parse15(absolutePath).root;
|
|
148066
148653
|
let currentPath = rootPath;
|
|
148067
148654
|
for (const segment of absolutePath.slice(rootPath.length).split(sep7).filter(Boolean)) {
|
|
@@ -148240,7 +148827,10 @@ import { Argument } from "commander";
|
|
|
148240
148827
|
function registerHarnessCommand(program, container) {
|
|
148241
148828
|
const harness = program.command("harness").description("Run and manage agent harness pairs.");
|
|
148242
148829
|
addWorktreeOptions(
|
|
148243
|
-
harness.command("run").description("Run a harness pair.").argument("[md-paths...]", "Paths to harness .md files to run sequentially").option("--dir <path>", "Directory to search for harness pairs when no md-path is given.").option("--fix", "Apply supported lint fixes to the harness .ajs file before running.").option("--
|
|
148830
|
+
harness.command("run").description("Run a harness pair.").argument("[md-paths...]", "Paths to harness .md files to run sequentially").option("--dir <path>", "Directory to search for harness pairs when no md-path is given.").option("--fix", "Apply supported lint fixes to the harness .ajs file before running.").option("--fs", "Give the harness a real filesystem module, confined to --fs-root.").option(
|
|
148831
|
+
"--fs-root <path>",
|
|
148832
|
+
"Directory --fs confines the harness to (default: the harness directory)."
|
|
148833
|
+
).option("--snapshot-path <path>", "File to write/read harness snapshots.").option("--resume", "Resume from the snapshot file when it exists.").option("--agent <name>", "Override the agent id from the harness frontmatter agent block.").option("--model <name>", "Override the model from the harness frontmatter agent block.").option(
|
|
148244
148834
|
"--mode <mode>",
|
|
148245
148835
|
"Override the mode from the harness frontmatter agent block (read|edit|auto|yolo)."
|
|
148246
148836
|
).option("-y, --yes", "Accept defaults without prompting.")
|
|
@@ -148260,12 +148850,18 @@ function registerHarnessCommand(program, container) {
|
|
|
148260
148850
|
async function executeHarnessRun(program, container, mdPath, options) {
|
|
148261
148851
|
const flags = resolveHarnessFlags(program, options.yes);
|
|
148262
148852
|
const resources = createExecutionResources(container, flags, "harness:run");
|
|
148853
|
+
const fsOptions = resolveHarnessFsOptions(container, options);
|
|
148263
148854
|
const selectedPath = mdPath ? path182.resolve(container.env.cwd, mdPath) : (await resolveDiscoveredHarness(container, options.dir, flags.assumeYes)).mdPath;
|
|
148264
148855
|
if (flags.dryRun) {
|
|
148265
148856
|
await resolvePair(selectedPath, container.fs);
|
|
148266
148857
|
resources.logger.dryRun(
|
|
148267
148858
|
`Dry run: would run ${formatDisplayPath3(container, selectedPath)} without executing its script or applying fixes.`
|
|
148268
148859
|
);
|
|
148860
|
+
if (fsOptions !== void 0) {
|
|
148861
|
+
resources.logger.dryRun(
|
|
148862
|
+
`Dry run: would enable the fs module rooted at ${formatDisplayPath3(container, resolveFsRoot(fsOptions, path182.dirname(selectedPath)))}.`
|
|
148863
|
+
);
|
|
148864
|
+
}
|
|
148269
148865
|
return;
|
|
148270
148866
|
}
|
|
148271
148867
|
const snapshotPath = resolveRunSnapshotPath(container, selectedPath, options.snapshotPath);
|
|
@@ -148298,10 +148894,20 @@ async function executeHarnessRun(program, container, mdPath, options) {
|
|
|
148298
148894
|
snapshotPath,
|
|
148299
148895
|
worktreeCwd
|
|
148300
148896
|
);
|
|
148897
|
+
const runFsOptions = fsOptions?.root === void 0 ? fsOptions : {
|
|
148898
|
+
root: mapSourcePathIntoWorktree3(container.env.cwd, fsOptions.root, worktreeCwd)
|
|
148899
|
+
};
|
|
148301
148900
|
return await runHarnessPair2(runSelectedPath, {
|
|
148302
|
-
modulesFor: (frontmatter, meta) => createHarnessModules(
|
|
148303
|
-
|
|
148304
|
-
|
|
148901
|
+
modulesFor: (frontmatter, meta) => createHarnessModules(
|
|
148902
|
+
container,
|
|
148903
|
+
resources.logger,
|
|
148904
|
+
frontmatter,
|
|
148905
|
+
meta,
|
|
148906
|
+
(error3) => {
|
|
148907
|
+
reportedSpawnFailures.add(error3);
|
|
148908
|
+
},
|
|
148909
|
+
runFsOptions
|
|
148910
|
+
),
|
|
148305
148911
|
onDiagnostics: (diagnostics) => {
|
|
148306
148912
|
lintDiagnostics.push(...diagnostics);
|
|
148307
148913
|
},
|
|
@@ -148767,11 +149373,11 @@ async function discoverProjectThenUserHarnesses(container, dir) {
|
|
|
148767
149373
|
...await discoverPairsDirectlyIn(container, root)
|
|
148768
149374
|
];
|
|
148769
149375
|
for (const pair of pairs) {
|
|
148770
|
-
const
|
|
149376
|
+
const stat36 = await container.fs.stat(pair.mdPath);
|
|
148771
149377
|
discovered.push({
|
|
148772
149378
|
...pair,
|
|
148773
149379
|
dir: path182.dirname(pair.mdPath),
|
|
148774
|
-
mdMtimeMs:
|
|
149380
|
+
mdMtimeMs: stat36.mtimeMs
|
|
148775
149381
|
});
|
|
148776
149382
|
}
|
|
148777
149383
|
}
|
|
@@ -148809,7 +149415,29 @@ async function assertFilesDoNotExist(container, filePaths) {
|
|
|
148809
149415
|
}
|
|
148810
149416
|
}
|
|
148811
149417
|
}
|
|
148812
|
-
function
|
|
149418
|
+
function resolveHarnessFsOptions(container, options) {
|
|
149419
|
+
if (options.fs !== true) {
|
|
149420
|
+
if (options.fsRoot === void 0) {
|
|
149421
|
+
return void 0;
|
|
149422
|
+
}
|
|
149423
|
+
throw new ValidationError(
|
|
149424
|
+
"--fs-root requires --fs. Pass --fs to give the harness a filesystem confined to that root, or drop --fs-root."
|
|
149425
|
+
);
|
|
149426
|
+
}
|
|
149427
|
+
if (options.fsRoot === void 0) {
|
|
149428
|
+
return {};
|
|
149429
|
+
}
|
|
149430
|
+
if (options.fsRoot.trim().length === 0) {
|
|
149431
|
+
throw new ValidationError(
|
|
149432
|
+
"--fs-root needs a directory path. Pass --fs-root <path> to confine the harness to that directory, or drop --fs-root to confine it to the harness directory."
|
|
149433
|
+
);
|
|
149434
|
+
}
|
|
149435
|
+
return { root: path182.resolve(container.env.cwd, options.fsRoot) };
|
|
149436
|
+
}
|
|
149437
|
+
function resolveFsRoot(fsOptions, harnessDir) {
|
|
149438
|
+
return fsOptions.root ?? harnessDir;
|
|
149439
|
+
}
|
|
149440
|
+
function createHarnessModules(container, logger2, frontmatter, meta, onSpawnFailure, fsOptions) {
|
|
148813
149441
|
const harnessMeta = {
|
|
148814
149442
|
kind: meta.kind,
|
|
148815
149443
|
version: meta.version,
|
|
@@ -148863,6 +149491,7 @@ function createHarnessModules(container, logger2, frontmatter, meta, onSpawnFail
|
|
|
148863
149491
|
return {
|
|
148864
149492
|
agent: toModuleExports(agent3),
|
|
148865
149493
|
fail: toModuleExports(/* @__PURE__ */ new Map([["default", fail3]])),
|
|
149494
|
+
...fsOptions === void 0 ? {} : { fs: toModuleExports(makeFsModule({ root: resolveFsRoot(fsOptions, meta.dirname) })) },
|
|
148866
149495
|
git: toModuleExports(git2),
|
|
148867
149496
|
harness: toModuleExports(harness),
|
|
148868
149497
|
log: toModuleExports(log2),
|
|
@@ -150712,7 +151341,7 @@ var init_package2 = __esm({
|
|
|
150712
151341
|
"package.json"() {
|
|
150713
151342
|
package_default2 = {
|
|
150714
151343
|
name: "poe-code",
|
|
150715
|
-
version: "4.0.
|
|
151344
|
+
version: "4.0.13",
|
|
150716
151345
|
description: "CLI tool to configure Poe API for developer workflows.",
|
|
150717
151346
|
license: "MIT",
|
|
150718
151347
|
type: "module",
|
|
@@ -150802,6 +151431,7 @@ var init_package2 = __esm({
|
|
|
150802
151431
|
"smoke:toolcraft-standalone": "node scripts/verify-toolcraft-standalone.mjs",
|
|
150803
151432
|
"smoke:toolcraft-sdk-types": "node scripts/verify-toolcraft-published-sdk-types.mjs",
|
|
150804
151433
|
"sync-skills": "tsx scripts/sync-skills.ts",
|
|
151434
|
+
"record:fs-conformance": "tsx scripts/record-fs-conformance.ts",
|
|
150805
151435
|
"sync:json-schema-test-suite": "node scripts/sync-json-schema-test-suite.mjs",
|
|
150806
151436
|
"sync:uri-template-test": "node scripts/sync-uri-template-test.mjs",
|
|
150807
151437
|
postinstall: "node scripts/postinstall-sync-skills.mjs"
|