@alan-ai-hq/agent-manager-darwin-arm64 0.1.150 → 0.1.152
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/alan-agent.cjs +536 -940
- package/alan-holder.cjs +243 -744
- package/package.json +1 -1
package/alan-agent.cjs
CHANGED
|
@@ -22720,7 +22720,7 @@ function plan(command, args, options) {
|
|
|
22720
22720
|
function captureOutput(command, args, options) {
|
|
22721
22721
|
const launch = plan(command, args, options);
|
|
22722
22722
|
if (launch === void 0) return Promise.resolve(NEVER_STARTED);
|
|
22723
|
-
return new Promise((
|
|
22723
|
+
return new Promise((resolve13) => {
|
|
22724
22724
|
(0, import_child_process.execFile)(
|
|
22725
22725
|
launch.file,
|
|
22726
22726
|
[...launch.args],
|
|
@@ -22734,7 +22734,7 @@ function captureOutput(command, args, options) {
|
|
|
22734
22734
|
},
|
|
22735
22735
|
(error61, stdout, stderr) => {
|
|
22736
22736
|
const code = error61 && typeof error61.code === "number" ? error61.code : error61 ? void 0 : 0;
|
|
22737
|
-
|
|
22737
|
+
resolve13({ stdout, stderr, exitCode: code });
|
|
22738
22738
|
}
|
|
22739
22739
|
);
|
|
22740
22740
|
});
|
|
@@ -22776,18 +22776,18 @@ function decode3(bytes, start, end) {
|
|
|
22776
22776
|
}
|
|
22777
22777
|
async function linuxStartTicks(pid) {
|
|
22778
22778
|
try {
|
|
22779
|
-
const
|
|
22780
|
-
const fields =
|
|
22779
|
+
const stat22 = await (0, import_promises9.readFile)(`/proc/${pid}/stat`, "utf8");
|
|
22780
|
+
const fields = stat22.slice(stat22.lastIndexOf(")") + 2).split(" ");
|
|
22781
22781
|
return fields[19];
|
|
22782
22782
|
} catch {
|
|
22783
22783
|
return void 0;
|
|
22784
22784
|
}
|
|
22785
22785
|
}
|
|
22786
22786
|
function psStartTime(pid) {
|
|
22787
|
-
return new Promise((
|
|
22787
|
+
return new Promise((resolve13) => {
|
|
22788
22788
|
(0, import_child_process2.execFile)("ps", ["-o", "lstart=", "-p", String(pid)], { timeout: 2e3 }, (error61, stdout) => {
|
|
22789
22789
|
const text3 = stdout.trim();
|
|
22790
|
-
|
|
22790
|
+
resolve13(error61 || !text3 ? void 0 : text3);
|
|
22791
22791
|
});
|
|
22792
22792
|
});
|
|
22793
22793
|
}
|
|
@@ -22816,12 +22816,12 @@ function parseProcessList(text3) {
|
|
|
22816
22816
|
}
|
|
22817
22817
|
function listProcesses(platform3 = process.platform) {
|
|
22818
22818
|
if (platform3 === "win32") return Promise.resolve([]);
|
|
22819
|
-
return new Promise((
|
|
22819
|
+
return new Promise((resolve13) => {
|
|
22820
22820
|
(0, import_child_process3.execFile)(
|
|
22821
22821
|
"ps",
|
|
22822
22822
|
["-A", "-o", "pid=,ppid=,pgid=,lstart="],
|
|
22823
22823
|
{ timeout: 5e3, maxBuffer: 8 * 1024 * 1024 },
|
|
22824
|
-
(error61, stdout) =>
|
|
22824
|
+
(error61, stdout) => resolve13(error61 ? [] : parseProcessList(stdout))
|
|
22825
22825
|
);
|
|
22826
22826
|
});
|
|
22827
22827
|
}
|
|
@@ -22861,11 +22861,11 @@ async function taskkill(pid, options) {
|
|
|
22861
22861
|
stdio: "ignore",
|
|
22862
22862
|
windowsHide: true
|
|
22863
22863
|
});
|
|
22864
|
-
const exited = new Promise((
|
|
22865
|
-
killer.once("error", (error210) =>
|
|
22864
|
+
const exited = new Promise((resolve13) => {
|
|
22865
|
+
killer.once("error", (error210) => resolve13(error210));
|
|
22866
22866
|
killer.once(
|
|
22867
22867
|
"exit",
|
|
22868
|
-
(code, signal) =>
|
|
22868
|
+
(code, signal) => resolve13(code === 0 ? void 0 : new Error(`taskkill failed: exit ${code}, signal ${signal}`))
|
|
22869
22869
|
);
|
|
22870
22870
|
});
|
|
22871
22871
|
const timedOut = clock.sleep(options.timeoutMs ?? DEFAULT_TASKKILL_TIMEOUT_MS, timeout.signal).then(() => new Error("taskkill timed out")).catch(() => void 0);
|
|
@@ -22908,9 +22908,9 @@ function signalGroup(pgid, signal, onError) {
|
|
|
22908
22908
|
if (!isAlreadyDead(error61)) onError?.("group", error61);
|
|
22909
22909
|
}
|
|
22910
22910
|
}
|
|
22911
|
-
function liveEscapedGroups(
|
|
22912
|
-
const leaders = new Map(
|
|
22913
|
-
const groups = new Set(escapedGroups(
|
|
22911
|
+
function liveEscapedGroups(snapshot, rootPid, remembered) {
|
|
22912
|
+
const leaders = new Map(snapshot.map((entry) => [entry.pid, entry.startedAt]));
|
|
22913
|
+
const groups = new Set(escapedGroups(snapshot, rootPid).map((group) => group.pgid));
|
|
22914
22914
|
for (const [pgid, startedAt] of remembered) {
|
|
22915
22915
|
if (leaders.get(pgid) === startedAt) groups.add(pgid);
|
|
22916
22916
|
}
|
|
@@ -23121,10 +23121,10 @@ function spawnCli(options) {
|
|
|
23121
23121
|
function waitForSpawn(child, command) {
|
|
23122
23122
|
if (isWindowsJob(child)) return waitForWindowsJob(child, command);
|
|
23123
23123
|
if (child.pid !== void 0) return Promise.resolve();
|
|
23124
|
-
return new Promise((
|
|
23124
|
+
return new Promise((resolve13, reject) => {
|
|
23125
23125
|
const onSpawn = () => {
|
|
23126
23126
|
child.off("error", onError);
|
|
23127
|
-
|
|
23127
|
+
resolve13();
|
|
23128
23128
|
};
|
|
23129
23129
|
const onError = (error61) => {
|
|
23130
23130
|
child.off("spawn", onSpawn);
|
|
@@ -24903,6 +24903,7 @@ function settleOpenToolCalls(state) {
|
|
|
24903
24903
|
if (outlivesTheTurn(entry))
|
|
24904
24904
|
continue;
|
|
24905
24905
|
entry.status = "cancelled";
|
|
24906
|
+
entry.lastUpdateIndex = state.updateCount;
|
|
24906
24907
|
}
|
|
24907
24908
|
}
|
|
24908
24909
|
function applyTool(state, index, update) {
|
|
@@ -26780,8 +26781,8 @@ function readMediaFiles(candidates2, cwd, mimeByExt, maxBytes) {
|
|
|
26780
26781
|
seen.add(path4);
|
|
26781
26782
|
const mimeType = mimeByExt[(0, import_path3.extname)(path4).toLowerCase()];
|
|
26782
26783
|
if (!mimeType) continue;
|
|
26783
|
-
const
|
|
26784
|
-
if (!
|
|
26784
|
+
const stat22 = (0, import_fs4.statSync)(path4);
|
|
26785
|
+
if (!stat22.isFile() || stat22.size <= 0 || stat22.size > maxBytes) continue;
|
|
26785
26786
|
files.push({ path: path4, mimeType, buffer: (0, import_fs4.readFileSync)(path4) });
|
|
26786
26787
|
}
|
|
26787
26788
|
return files;
|
|
@@ -26856,8 +26857,8 @@ function createJsonRpcPeer(writer, handlers) {
|
|
|
26856
26857
|
},
|
|
26857
26858
|
request: (method, params = {}) => {
|
|
26858
26859
|
const id = counter.next++;
|
|
26859
|
-
return new Promise((
|
|
26860
|
-
pending.set(id, { method, resolve:
|
|
26860
|
+
return new Promise((resolve13, reject) => {
|
|
26861
|
+
pending.set(id, { method, resolve: resolve13, reject });
|
|
26861
26862
|
writer.write({ id, method, params }).catch((error61) => {
|
|
26862
26863
|
pending.delete(id);
|
|
26863
26864
|
reject(error61 instanceof Error ? error61 : new Error(String(error61)));
|
|
@@ -26970,7 +26971,7 @@ function createNdjsonWriter(stream) {
|
|
|
26970
26971
|
get writable() {
|
|
26971
26972
|
return stream.writable && !stream.destroyed && failure6.error === void 0;
|
|
26972
26973
|
},
|
|
26973
|
-
write: (value2) => new Promise((
|
|
26974
|
+
write: (value2) => new Promise((resolve13, reject) => {
|
|
26974
26975
|
if (failure6.error) {
|
|
26975
26976
|
reject(failure6.error);
|
|
26976
26977
|
return;
|
|
@@ -26982,7 +26983,7 @@ function createNdjsonWriter(stream) {
|
|
|
26982
26983
|
stream.write(`${JSON.stringify(value2)}
|
|
26983
26984
|
`, (error61) => {
|
|
26984
26985
|
if (error61) reject(error61);
|
|
26985
|
-
else
|
|
26986
|
+
else resolve13();
|
|
26986
26987
|
});
|
|
26987
26988
|
}),
|
|
26988
26989
|
end: () => {
|
|
@@ -27014,11 +27015,11 @@ function hostProcess(child, tree, options, handlers) {
|
|
|
27014
27015
|
});
|
|
27015
27016
|
child.stderr.on("data", (chunk) => stderr.push(chunk));
|
|
27016
27017
|
child.stderr.once("end", () => stderr.flush());
|
|
27017
|
-
const processExit = new Promise((
|
|
27018
|
-
child.once("exit", (code, signal) =>
|
|
27018
|
+
const processExit = new Promise((resolve13) => {
|
|
27019
|
+
child.once("exit", (code, signal) => resolve13({ code, signal }));
|
|
27019
27020
|
});
|
|
27020
|
-
const outputEnded = new Promise((
|
|
27021
|
-
child.stdout.once("close", () =>
|
|
27021
|
+
const outputEnded = new Promise((resolve13) => {
|
|
27022
|
+
child.stdout.once("close", () => resolve13());
|
|
27022
27023
|
});
|
|
27023
27024
|
const watch = async () => {
|
|
27024
27025
|
const { clock, stdoutDrainMs, log, name } = options;
|
|
@@ -27315,13 +27316,13 @@ var init_chunk_A2TG6ROT = __esm({
|
|
|
27315
27316
|
const turnId = input2.turnId;
|
|
27316
27317
|
let finish = () => {
|
|
27317
27318
|
};
|
|
27318
|
-
const done = new Promise((
|
|
27319
|
+
const done = new Promise((resolve13) => {
|
|
27319
27320
|
finish = (outcome2) => {
|
|
27320
27321
|
if (this.#current?.id !== turnId) return;
|
|
27321
27322
|
this.#current = void 0;
|
|
27322
27323
|
if (this.#state === "busy") this.#state = "idle";
|
|
27323
27324
|
this.#emit({ type: "turn_ended", turnId, outcome: outcome2 });
|
|
27324
|
-
|
|
27325
|
+
resolve13({ turnId, outcome: outcome2, providerSessionId: this.#sessionId });
|
|
27325
27326
|
};
|
|
27326
27327
|
});
|
|
27327
27328
|
const pending = {
|
|
@@ -27619,18 +27620,18 @@ function environmentInstructions(environment, cwd) {
|
|
|
27619
27620
|
}
|
|
27620
27621
|
return lines2;
|
|
27621
27622
|
}
|
|
27622
|
-
function instructionsFor(
|
|
27623
|
-
const cwd =
|
|
27623
|
+
function instructionsFor(snapshot) {
|
|
27624
|
+
const cwd = snapshot.workspace.cwd ?? snapshot.workspace.root ?? "the workspace";
|
|
27624
27625
|
return [
|
|
27625
|
-
...
|
|
27626
|
-
...
|
|
27626
|
+
...snapshot.session.trigger === "image_build" ? ["Alan sent this turn, not the user: it reports an image build result."] : [],
|
|
27627
|
+
...snapshot.environment ? environmentInstructions(snapshot.environment, cwd) : []
|
|
27627
27628
|
];
|
|
27628
27629
|
}
|
|
27629
|
-
function startingInstructions(
|
|
27630
|
-
const cwd =
|
|
27630
|
+
function startingInstructions(snapshot) {
|
|
27631
|
+
const cwd = snapshot.workspace.cwd ?? snapshot.workspace.root;
|
|
27631
27632
|
return [
|
|
27632
27633
|
...cwd ? [`Work from ${cwd}.`] : [],
|
|
27633
|
-
...
|
|
27634
|
+
...snapshot.workspace.repositories.flatMap(repositoryInstructions)
|
|
27634
27635
|
];
|
|
27635
27636
|
}
|
|
27636
27637
|
function sessionKind(input2, context) {
|
|
@@ -27653,17 +27654,17 @@ function environmentOf(input2, context) {
|
|
|
27653
27654
|
...start ? { start: start.state === "not_configured" ? start : { ...start, log: input2.startLogPath } } : {}
|
|
27654
27655
|
};
|
|
27655
27656
|
}
|
|
27656
|
-
function knownContext(
|
|
27657
|
-
const organizationId =
|
|
27658
|
-
if (!
|
|
27659
|
-
const environment =
|
|
27657
|
+
function knownContext(snapshot) {
|
|
27658
|
+
const organizationId = snapshot?.session.organizationId;
|
|
27659
|
+
if (!snapshot || !organizationId) return void 0;
|
|
27660
|
+
const environment = snapshot.environment;
|
|
27660
27661
|
return {
|
|
27661
|
-
kind:
|
|
27662
|
+
kind: snapshot.session.kind,
|
|
27662
27663
|
trigger: "user",
|
|
27663
27664
|
organizationId,
|
|
27664
|
-
...
|
|
27665
|
-
...
|
|
27666
|
-
repositories:
|
|
27665
|
+
...snapshot.task ? { taskWorkingBranch: snapshot.task.workingBranch } : {},
|
|
27666
|
+
...snapshot.pullRequest ? { pullRequest: snapshot.pullRequest } : {},
|
|
27667
|
+
repositories: snapshot.workspace.repositories.flatMap(
|
|
27667
27668
|
({ path: path4, name, url: url3, branch, branchSource, base }) => name && url3 && branch && branchSource && base ? [{ path: path4, name, url: url3, branch, branchSource, base }] : []
|
|
27668
27669
|
),
|
|
27669
27670
|
...environment ? {
|
|
@@ -27790,15 +27791,15 @@ function updateBody(previous, next) {
|
|
|
27790
27791
|
if (Object.keys(facts).length === 0) return void 0;
|
|
27791
27792
|
return next.session.trigger === "user" ? facts : { session: { trigger: next.session.trigger }, ...facts };
|
|
27792
27793
|
}
|
|
27793
|
-
function renderAgentContext(
|
|
27794
|
+
function renderAgentContext(snapshot, previous) {
|
|
27794
27795
|
const full = block("alan_agent_context", {
|
|
27795
|
-
...
|
|
27796
|
-
...
|
|
27797
|
-
instructions: [...startingInstructions(
|
|
27796
|
+
...snapshot,
|
|
27797
|
+
...snapshot.environment ? { environment: withCommandPreviews(snapshot.environment) } : {},
|
|
27798
|
+
instructions: [...startingInstructions(snapshot), ...snapshot.instructions]
|
|
27798
27799
|
});
|
|
27799
|
-
const update = previous ? updateBody(previous,
|
|
27800
|
+
const update = previous ? updateBody(previous, snapshot) : void 0;
|
|
27800
27801
|
return {
|
|
27801
|
-
snapshot
|
|
27802
|
+
snapshot,
|
|
27802
27803
|
full,
|
|
27803
27804
|
...update ? { update: block("alan_agent_context_update", update) } : {}
|
|
27804
27805
|
};
|
|
@@ -29218,18 +29219,24 @@ function realCwd(cwd) {
|
|
|
29218
29219
|
return cwd;
|
|
29219
29220
|
}
|
|
29220
29221
|
}
|
|
29222
|
+
function projectDirs(projectsRoot) {
|
|
29223
|
+
try {
|
|
29224
|
+
return (0, import_fs5.readdirSync)(projectsRoot, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => entry.name);
|
|
29225
|
+
} catch {
|
|
29226
|
+
return [];
|
|
29227
|
+
}
|
|
29228
|
+
}
|
|
29221
29229
|
function claudeSessionLogExists(query) {
|
|
29222
29230
|
if (!query.sessionId || !query.cwd) return false;
|
|
29223
|
-
|
|
29224
|
-
|
|
29225
|
-
|
|
29226
|
-
|
|
29227
|
-
|
|
29228
|
-
|
|
29229
|
-
|
|
29230
|
-
|
|
29231
|
-
|
|
29232
|
-
return false;
|
|
29231
|
+
const projectsRoot = (0, import_path5.join)(query.claudeHome, "projects");
|
|
29232
|
+
const fileName = `${query.sessionId}.jsonl`;
|
|
29233
|
+
const here = new Set([query.cwd, realCwd(query.cwd)].map(encodeProjectDir));
|
|
29234
|
+
for (const dir of here) {
|
|
29235
|
+
if ((0, import_fs5.existsSync)((0, import_path5.join)(projectsRoot, dir, fileName))) return true;
|
|
29236
|
+
}
|
|
29237
|
+
return projectDirs(projectsRoot).some(
|
|
29238
|
+
(dir) => !here.has(dir) && (0, import_fs5.existsSync)((0, import_path5.join)(projectsRoot, dir, fileName))
|
|
29239
|
+
);
|
|
29233
29240
|
}
|
|
29234
29241
|
function envDigest(env) {
|
|
29235
29242
|
const hash2 = (0, import_crypto7.createHash)("sha256");
|
|
@@ -30231,8 +30238,8 @@ var init_claude = __esm({
|
|
|
30231
30238
|
}
|
|
30232
30239
|
async #awaitTaskStop(requestId, taskId) {
|
|
30233
30240
|
const timer = new AbortController();
|
|
30234
|
-
const answered = new Promise((
|
|
30235
|
-
this.#taskStops.set(requestId,
|
|
30241
|
+
const answered = new Promise((resolve13) => {
|
|
30242
|
+
this.#taskStops.set(requestId, resolve13);
|
|
30236
30243
|
});
|
|
30237
30244
|
const timeoutMs = this.#options.stopTaskTimeoutMs;
|
|
30238
30245
|
const timedOut = this.#options.clock.sleep(timeoutMs, timer.signal).then(
|
|
@@ -30305,17 +30312,17 @@ var init_claude = __esm({
|
|
|
30305
30312
|
};
|
|
30306
30313
|
let markStarted = () => {
|
|
30307
30314
|
};
|
|
30308
|
-
const whenStarted = new Promise((
|
|
30309
|
-
markStarted =
|
|
30315
|
+
const whenStarted = new Promise((resolve13) => {
|
|
30316
|
+
markStarted = resolve13;
|
|
30310
30317
|
});
|
|
30311
|
-
const done = new Promise((
|
|
30318
|
+
const done = new Promise((resolve13) => {
|
|
30312
30319
|
finish = (outcome2) => {
|
|
30313
30320
|
if (this.#current?.id !== id) return;
|
|
30314
30321
|
this.#current = void 0;
|
|
30315
30322
|
this.#lastTurn = turn;
|
|
30316
30323
|
if (this.#state === "busy") this.#state = "idle";
|
|
30317
30324
|
this.#emit({ type: "turn_ended", turnId: id, outcome: outcome2 });
|
|
30318
|
-
|
|
30325
|
+
resolve13({ turnId: id, outcome: outcome2, providerSessionId: this.#providerSessionId });
|
|
30319
30326
|
};
|
|
30320
30327
|
});
|
|
30321
30328
|
const active = {
|
|
@@ -30433,8 +30440,8 @@ var init_claude = __esm({
|
|
|
30433
30440
|
void removeLaunchFiles(this.#launchFiles).catch((error61) => {
|
|
30434
30441
|
this.#options.log.warn("claude.launch_files_cleanup_failed", { error: error61 });
|
|
30435
30442
|
});
|
|
30436
|
-
for (const
|
|
30437
|
-
|
|
30443
|
+
for (const resolve13 of this.#taskStops.values()) {
|
|
30444
|
+
resolve13({ ok: false, reason: "runtime_unavailable", message: "Claude Code exited." });
|
|
30438
30445
|
}
|
|
30439
30446
|
const active = this.#current;
|
|
30440
30447
|
if (active) {
|
|
@@ -32575,7 +32582,7 @@ var init_codex = __esm({
|
|
|
32575
32582
|
const buckets = asRecord(response?.rateLimitsByLimitId);
|
|
32576
32583
|
if (buckets) {
|
|
32577
32584
|
return Object.entries(buckets).flatMap(
|
|
32578
|
-
([limitId,
|
|
32585
|
+
([limitId, snapshot]) => this.#update(snapshot, limitId)
|
|
32579
32586
|
);
|
|
32580
32587
|
}
|
|
32581
32588
|
return this.#update(response?.rateLimits);
|
|
@@ -32584,16 +32591,16 @@ var init_codex = __esm({
|
|
|
32584
32591
|
return this.#update(params.rateLimits);
|
|
32585
32592
|
}
|
|
32586
32593
|
#update(value2, bucketId) {
|
|
32587
|
-
const
|
|
32588
|
-
if (!
|
|
32589
|
-
const primary = windowPatch(
|
|
32590
|
-
const secondary = windowPatch(
|
|
32591
|
-
const spend = spendPatch(
|
|
32592
|
-
const credits = creditsPatch(
|
|
32593
|
-
const planType =
|
|
32594
|
+
const snapshot = asRecord(value2);
|
|
32595
|
+
if (!snapshot) return [];
|
|
32596
|
+
const primary = windowPatch(snapshot.primary);
|
|
32597
|
+
const secondary = windowPatch(snapshot.secondary);
|
|
32598
|
+
const spend = spendPatch(snapshot.individualLimit, snapshot.spendControlReached);
|
|
32599
|
+
const credits = creditsPatch(snapshot.credits);
|
|
32600
|
+
const planType = snapshot.planType === null ? null : asString(snapshot.planType) || void 0;
|
|
32594
32601
|
const parsed = runCodexRateLimitsUpdateSchema.safeParse({
|
|
32595
32602
|
sessionUpdate: "_alan/codex.rate_limits",
|
|
32596
|
-
limitId: bucketId ?? (asString(
|
|
32603
|
+
limitId: bucketId ?? (asString(snapshot.limitId) || "codex"),
|
|
32597
32604
|
...primary === void 0 ? {} : { primary },
|
|
32598
32605
|
...secondary === void 0 ? {} : { secondary },
|
|
32599
32606
|
...spend === void 0 ? {} : { spend },
|
|
@@ -33039,10 +33046,10 @@ var init_codex = __esm({
|
|
|
33039
33046
|
};
|
|
33040
33047
|
let identify = () => {
|
|
33041
33048
|
};
|
|
33042
|
-
const identified = new Promise((
|
|
33043
|
-
identify =
|
|
33049
|
+
const identified = new Promise((resolve13) => {
|
|
33050
|
+
identify = resolve13;
|
|
33044
33051
|
});
|
|
33045
|
-
const done = new Promise((
|
|
33052
|
+
const done = new Promise((resolve13) => {
|
|
33046
33053
|
finish = (outcome2) => {
|
|
33047
33054
|
if (this.#current?.id !== id) return;
|
|
33048
33055
|
this.#current = void 0;
|
|
@@ -33050,7 +33057,7 @@ var init_codex = __esm({
|
|
|
33050
33057
|
if (this.#state === "busy") this.#state = "idle";
|
|
33051
33058
|
this.#host.scanDescendants(true);
|
|
33052
33059
|
this.#emit({ type: "turn_ended", turnId: id, outcome: outcome2 });
|
|
33053
|
-
|
|
33060
|
+
resolve13({ turnId: id, outcome: outcome2, providerSessionId: this.#threadId });
|
|
33054
33061
|
};
|
|
33055
33062
|
});
|
|
33056
33063
|
const active = {
|
|
@@ -33606,7 +33613,7 @@ function alanCodeConfigContent(existing, input2) {
|
|
|
33606
33613
|
});
|
|
33607
33614
|
}
|
|
33608
33615
|
function readBody2(response) {
|
|
33609
|
-
return new Promise((
|
|
33616
|
+
return new Promise((resolve13, reject) => {
|
|
33610
33617
|
const chunks = [];
|
|
33611
33618
|
let size = 0;
|
|
33612
33619
|
response.on("data", (chunk) => {
|
|
@@ -33614,7 +33621,7 @@ function readBody2(response) {
|
|
|
33614
33621
|
if (size > MAX_CATALOG_BYTES) response.destroy(new Error("catalog too large"));
|
|
33615
33622
|
else chunks.push(chunk);
|
|
33616
33623
|
});
|
|
33617
|
-
response.on("end", () =>
|
|
33624
|
+
response.on("end", () => resolve13(Buffer.concat(chunks).toString("utf8")));
|
|
33618
33625
|
response.on("error", reject);
|
|
33619
33626
|
});
|
|
33620
33627
|
}
|
|
@@ -33630,13 +33637,13 @@ function parseResponseBody(text3, status) {
|
|
|
33630
33637
|
}
|
|
33631
33638
|
function getJson(url3, headers, timeout, signal) {
|
|
33632
33639
|
const request2 = url3.protocol === "https:" ? import_https.request : import_http9.request;
|
|
33633
|
-
return new Promise((
|
|
33640
|
+
return new Promise((resolve13, reject) => {
|
|
33634
33641
|
const outgoing = request2(url3, { method: "GET", headers, timeout, signal }, (response) => {
|
|
33635
33642
|
const status = response.statusCode ?? 0;
|
|
33636
33643
|
readBody2(response).then((text3) => {
|
|
33637
33644
|
const body = parseResponseBody(text3, status);
|
|
33638
33645
|
if (status < 200 || status >= 300) reject(new CatalogResponseError(status, body));
|
|
33639
|
-
else
|
|
33646
|
+
else resolve13(body);
|
|
33640
33647
|
}).catch(reject);
|
|
33641
33648
|
});
|
|
33642
33649
|
outgoing.on("timeout", () => outgoing.destroy(new Error("catalog timed out")));
|
|
@@ -42513,8 +42520,8 @@ var require_streamx = __commonJS({
|
|
|
42513
42520
|
return this;
|
|
42514
42521
|
},
|
|
42515
42522
|
next() {
|
|
42516
|
-
return new Promise(function(
|
|
42517
|
-
promiseResolve =
|
|
42523
|
+
return new Promise(function(resolve13, reject) {
|
|
42524
|
+
promiseResolve = resolve13;
|
|
42518
42525
|
promiseReject = reject;
|
|
42519
42526
|
const data = stream.read();
|
|
42520
42527
|
if (data !== null) ondata(data);
|
|
@@ -42547,11 +42554,11 @@ var require_streamx = __commonJS({
|
|
|
42547
42554
|
}
|
|
42548
42555
|
function destroy(err) {
|
|
42549
42556
|
stream.destroy(err);
|
|
42550
|
-
return new Promise((
|
|
42551
|
-
if (stream._duplexState & DESTROYED) return
|
|
42557
|
+
return new Promise((resolve13, reject) => {
|
|
42558
|
+
if (stream._duplexState & DESTROYED) return resolve13({ value: void 0, done: true });
|
|
42552
42559
|
stream.once("close", function() {
|
|
42553
42560
|
if (err) reject(err);
|
|
42554
|
-
else
|
|
42561
|
+
else resolve13({ value: void 0, done: true });
|
|
42555
42562
|
});
|
|
42556
42563
|
});
|
|
42557
42564
|
}
|
|
@@ -42595,8 +42602,8 @@ var require_streamx = __commonJS({
|
|
|
42595
42602
|
const writes = pending + (ws._duplexState & WRITE_WRITING ? 1 : 0);
|
|
42596
42603
|
if (writes === 0) return Promise.resolve(true);
|
|
42597
42604
|
if (state.drains === null) state.drains = [];
|
|
42598
|
-
return new Promise((
|
|
42599
|
-
state.drains.push({ writes, resolve:
|
|
42605
|
+
return new Promise((resolve13) => {
|
|
42606
|
+
state.drains.push({ writes, resolve: resolve13 });
|
|
42600
42607
|
});
|
|
42601
42608
|
}
|
|
42602
42609
|
write(data) {
|
|
@@ -42701,10 +42708,10 @@ var require_streamx = __commonJS({
|
|
|
42701
42708
|
cb(null);
|
|
42702
42709
|
}
|
|
42703
42710
|
function pipelinePromise(...streams) {
|
|
42704
|
-
return new Promise((
|
|
42711
|
+
return new Promise((resolve13, reject) => {
|
|
42705
42712
|
return pipeline(...streams, (err) => {
|
|
42706
42713
|
if (err) return reject(err);
|
|
42707
|
-
|
|
42714
|
+
resolve13();
|
|
42708
42715
|
});
|
|
42709
42716
|
});
|
|
42710
42717
|
}
|
|
@@ -42827,9 +42834,9 @@ var require_streamx = __commonJS({
|
|
|
42827
42834
|
}
|
|
42828
42835
|
});
|
|
42829
42836
|
|
|
42830
|
-
//
|
|
42837
|
+
// ../../node_modules/tar-stream/headers.js
|
|
42831
42838
|
var require_headers = __commonJS({
|
|
42832
|
-
"
|
|
42839
|
+
"../../node_modules/tar-stream/headers.js"(exports2) {
|
|
42833
42840
|
"use strict";
|
|
42834
42841
|
var b4a = require_b4a();
|
|
42835
42842
|
var ZEROS = "0000000000000000000";
|
|
@@ -43090,9 +43097,9 @@ var require_headers = __commonJS({
|
|
|
43090
43097
|
}
|
|
43091
43098
|
});
|
|
43092
43099
|
|
|
43093
|
-
//
|
|
43100
|
+
// ../../node_modules/tar-stream/extract.js
|
|
43094
43101
|
var require_extract = __commonJS({
|
|
43095
|
-
"
|
|
43102
|
+
"../../node_modules/tar-stream/extract.js"(exports2, module2) {
|
|
43096
43103
|
"use strict";
|
|
43097
43104
|
var { Writable, Readable: Readable2, getStreamError } = require_streamx();
|
|
43098
43105
|
var FIFO = require_fast_fifo();
|
|
@@ -43376,16 +43383,16 @@ var require_extract = __commonJS({
|
|
|
43376
43383
|
entryCallback = null;
|
|
43377
43384
|
cb(err);
|
|
43378
43385
|
}
|
|
43379
|
-
function onnext(
|
|
43386
|
+
function onnext(resolve13, reject) {
|
|
43380
43387
|
if (error61) {
|
|
43381
43388
|
return reject(error61);
|
|
43382
43389
|
}
|
|
43383
43390
|
if (entryStream) {
|
|
43384
|
-
|
|
43391
|
+
resolve13({ value: entryStream, done: false });
|
|
43385
43392
|
entryStream = null;
|
|
43386
43393
|
return;
|
|
43387
43394
|
}
|
|
43388
|
-
promiseResolve =
|
|
43395
|
+
promiseResolve = resolve13;
|
|
43389
43396
|
promiseReject = reject;
|
|
43390
43397
|
consumeCallback(null);
|
|
43391
43398
|
if (extract2._finished && promiseResolve) {
|
|
@@ -43413,11 +43420,11 @@ var require_extract = __commonJS({
|
|
|
43413
43420
|
function destroy(err) {
|
|
43414
43421
|
extract2.destroy(err);
|
|
43415
43422
|
consumeCallback(err);
|
|
43416
|
-
return new Promise((
|
|
43417
|
-
if (extract2.destroyed) return
|
|
43423
|
+
return new Promise((resolve13, reject) => {
|
|
43424
|
+
if (extract2.destroyed) return resolve13({ value: void 0, done: true });
|
|
43418
43425
|
extract2.once("close", function() {
|
|
43419
43426
|
if (err) reject(err);
|
|
43420
|
-
else
|
|
43427
|
+
else resolve13({ value: void 0, done: true });
|
|
43421
43428
|
});
|
|
43422
43429
|
});
|
|
43423
43430
|
}
|
|
@@ -43435,9 +43442,9 @@ var require_extract = __commonJS({
|
|
|
43435
43442
|
}
|
|
43436
43443
|
});
|
|
43437
43444
|
|
|
43438
|
-
//
|
|
43445
|
+
// ../../node_modules/tar-stream/constants.js
|
|
43439
43446
|
var require_constants = __commonJS({
|
|
43440
|
-
"
|
|
43447
|
+
"../../node_modules/tar-stream/constants.js"(exports2, module2) {
|
|
43441
43448
|
"use strict";
|
|
43442
43449
|
var constants5 = {
|
|
43443
43450
|
// just for envs without fs
|
|
@@ -43456,9 +43463,9 @@ var require_constants = __commonJS({
|
|
|
43456
43463
|
}
|
|
43457
43464
|
});
|
|
43458
43465
|
|
|
43459
|
-
//
|
|
43466
|
+
// ../../node_modules/tar-stream/pack.js
|
|
43460
43467
|
var require_pack = __commonJS({
|
|
43461
|
-
"
|
|
43468
|
+
"../../node_modules/tar-stream/pack.js"(exports2, module2) {
|
|
43462
43469
|
"use strict";
|
|
43463
43470
|
var { Readable: Readable2, Writable, getStreamError } = require_streamx();
|
|
43464
43471
|
var b4a = require_b4a();
|
|
@@ -43691,9 +43698,9 @@ var require_pack = __commonJS({
|
|
|
43691
43698
|
}
|
|
43692
43699
|
});
|
|
43693
43700
|
|
|
43694
|
-
//
|
|
43701
|
+
// ../../node_modules/tar-stream/index.js
|
|
43695
43702
|
var require_tar_stream = __commonJS({
|
|
43696
|
-
"
|
|
43703
|
+
"../../node_modules/tar-stream/index.js"(exports2) {
|
|
43697
43704
|
"use strict";
|
|
43698
43705
|
exports2.extract = require_extract();
|
|
43699
43706
|
exports2.pack = require_pack();
|
|
@@ -44305,12 +44312,12 @@ function shellStart(update, sessionId) {
|
|
|
44305
44312
|
];
|
|
44306
44313
|
}
|
|
44307
44314
|
function shellEnd(update) {
|
|
44308
|
-
const
|
|
44309
|
-
const taskId = optional2(
|
|
44310
|
-
if (!
|
|
44311
|
-
const killed =
|
|
44312
|
-
const exitCode =
|
|
44313
|
-
const failed = typeof exitCode === "number" && exitCode !== 0 || optional2(
|
|
44315
|
+
const snapshot = asRecord(update.task_snapshot);
|
|
44316
|
+
const taskId = optional2(snapshot?.task_id);
|
|
44317
|
+
if (!snapshot || !taskId) return [];
|
|
44318
|
+
const killed = snapshot.explicitly_killed === true;
|
|
44319
|
+
const exitCode = snapshot.exit_code;
|
|
44320
|
+
const failed = typeof exitCode === "number" && exitCode !== 0 || optional2(snapshot.signal) !== void 0;
|
|
44314
44321
|
const ending = killed ? "stopped" : failed ? "failed" : "completed";
|
|
44315
44322
|
return [{ type: "end", taskId, ending }];
|
|
44316
44323
|
}
|
|
@@ -44982,7 +44989,7 @@ var init_acp3 = __esm({
|
|
|
44982
44989
|
const turn = new AcpTurn(`acp-${this.#turns}-${id}`, this.#profile);
|
|
44983
44990
|
let finish = () => {
|
|
44984
44991
|
};
|
|
44985
|
-
const done = new Promise((
|
|
44992
|
+
const done = new Promise((resolve13) => {
|
|
44986
44993
|
finish = (outcome2) => {
|
|
44987
44994
|
if (this.#current?.id !== id) return;
|
|
44988
44995
|
this.#current = void 0;
|
|
@@ -44990,7 +44997,7 @@ var init_acp3 = __esm({
|
|
|
44990
44997
|
if (this.#state === "busy") this.#state = "idle";
|
|
44991
44998
|
this.#host.scanDescendants(true);
|
|
44992
44999
|
this.#emit({ type: "turn_ended", turnId: id, outcome: outcome2 });
|
|
44993
|
-
|
|
45000
|
+
resolve13({ turnId: id, outcome: outcome2, providerSessionId: this.#sessionId });
|
|
44994
45001
|
};
|
|
44995
45002
|
});
|
|
44996
45003
|
const active = { id, turn, done, finish, cancelRequested: false };
|
|
@@ -45575,12 +45582,11 @@ function createPersistentDriver(provider4, options) {
|
|
|
45575
45582
|
log.warn("holder.history_rejected", { harness: provider4.harness });
|
|
45576
45583
|
await session.suspend();
|
|
45577
45584
|
};
|
|
45578
|
-
const respond = async (request2
|
|
45585
|
+
const respond = async (request2) => {
|
|
45579
45586
|
const turn = live.turn;
|
|
45580
45587
|
if (turn === void 0 || turn.runId !== request2.runId) return "unknown_run";
|
|
45581
45588
|
const isWaiting = () => live.turn === turn && turn.waiting.has(request2.toolCallId);
|
|
45582
45589
|
if (!isWaiting() || turn.session.respond === void 0) return "not_waiting";
|
|
45583
|
-
if (!await mayWrite() || !isWaiting()) return "not_waiting";
|
|
45584
45590
|
turn.waiting.delete(request2.toolCallId);
|
|
45585
45591
|
try {
|
|
45586
45592
|
await turn.session.respond(request2.toolCallId, request2.answer);
|
|
@@ -47806,8 +47812,8 @@ function createDroidPeer(writer, handlers) {
|
|
|
47806
47812
|
},
|
|
47807
47813
|
request: (method, params = {}) => {
|
|
47808
47814
|
const id = `alan-${counter.next++}`;
|
|
47809
|
-
return new Promise((
|
|
47810
|
-
pending.set(id, { method, resolve:
|
|
47815
|
+
return new Promise((resolve13, reject) => {
|
|
47816
|
+
pending.set(id, { method, resolve: resolve13, reject });
|
|
47811
47817
|
writer.write(envelope("request", { id, method, params })).catch((error61) => {
|
|
47812
47818
|
pending.delete(id);
|
|
47813
47819
|
reject(error61 instanceof Error ? error61 : new Error(String(error61)));
|
|
@@ -48435,14 +48441,14 @@ var init_droid = __esm({
|
|
|
48435
48441
|
const turn = new DroidTurn(sessionId, this.#memory);
|
|
48436
48442
|
let finish = () => {
|
|
48437
48443
|
};
|
|
48438
|
-
const done = new Promise((
|
|
48444
|
+
const done = new Promise((resolve13) => {
|
|
48439
48445
|
finish = (outcome2) => {
|
|
48440
48446
|
if (this.#current?.id !== id) return;
|
|
48441
48447
|
this.#current = void 0;
|
|
48442
48448
|
if (this.#state === "busy") this.#state = "idle";
|
|
48443
48449
|
this.#host.scanDescendants(true);
|
|
48444
48450
|
this.#emit({ type: "turn_ended", turnId: id, outcome: outcome2 });
|
|
48445
|
-
|
|
48451
|
+
resolve13({ turnId: id, outcome: outcome2, providerSessionId: this.#sessionId });
|
|
48446
48452
|
};
|
|
48447
48453
|
});
|
|
48448
48454
|
const active = { id, turn, done, finish, cancelRequested: false };
|
|
@@ -55368,7 +55374,7 @@ var require_websocket_server = __commonJS({
|
|
|
55368
55374
|
// package.json
|
|
55369
55375
|
var package_default = {
|
|
55370
55376
|
name: "@alan-ai-hq/agent-manager",
|
|
55371
|
-
version: "0.1.
|
|
55377
|
+
version: "0.1.152",
|
|
55372
55378
|
private: true,
|
|
55373
55379
|
type: "module",
|
|
55374
55380
|
description: "Alan machine runtime (alan-agent): identity, link, reconciler, session holders, run log, uploader, local API",
|
|
@@ -55418,7 +55424,7 @@ var package_default = {
|
|
|
55418
55424
|
|
|
55419
55425
|
// src/cli/commands/compat.ts
|
|
55420
55426
|
var import_node_crypto32 = require("crypto");
|
|
55421
|
-
var
|
|
55427
|
+
var import_promises69 = require("fs/promises");
|
|
55422
55428
|
init_runtime_v2();
|
|
55423
55429
|
init_zod();
|
|
55424
55430
|
|
|
@@ -55577,8 +55583,8 @@ async function writeJsonFileAtomic(path4, value2) {
|
|
|
55577
55583
|
var LIFECYCLE_DRAIN_MS = 5e3;
|
|
55578
55584
|
function createGate() {
|
|
55579
55585
|
const opened = {};
|
|
55580
|
-
const promise2 = new Promise((
|
|
55581
|
-
opened.resolve =
|
|
55586
|
+
const promise2 = new Promise((resolve13) => {
|
|
55587
|
+
opened.resolve = resolve13;
|
|
55582
55588
|
});
|
|
55583
55589
|
return { promise: promise2, open: () => opened.resolve?.() };
|
|
55584
55590
|
}
|
|
@@ -55805,7 +55811,7 @@ function transportFailure(request2, error61) {
|
|
|
55805
55811
|
});
|
|
55806
55812
|
}
|
|
55807
55813
|
function readBody(incoming, url3, maxBytes) {
|
|
55808
|
-
return new Promise((
|
|
55814
|
+
return new Promise((resolve13, reject) => {
|
|
55809
55815
|
const declared = Number(incoming.headers["content-length"] ?? "0");
|
|
55810
55816
|
if (maxBytes !== void 0 && declared > maxBytes) {
|
|
55811
55817
|
incoming.destroy();
|
|
@@ -55824,7 +55830,7 @@ function readBody(incoming, url3, maxBytes) {
|
|
|
55824
55830
|
chunks.push(chunk);
|
|
55825
55831
|
});
|
|
55826
55832
|
incoming.on("error", reject);
|
|
55827
|
-
incoming.on("end", () =>
|
|
55833
|
+
incoming.on("end", () => resolve13(Buffer.concat(chunks)));
|
|
55828
55834
|
});
|
|
55829
55835
|
}
|
|
55830
55836
|
function isConnectionReset(error61) {
|
|
@@ -55832,7 +55838,7 @@ function isConnectionReset(error61) {
|
|
|
55832
55838
|
}
|
|
55833
55839
|
function exchange(request2, agents, attempt2 = 0) {
|
|
55834
55840
|
const { signal, url: url3 } = request2;
|
|
55835
|
-
return new Promise((
|
|
55841
|
+
return new Promise((resolve13, reject) => {
|
|
55836
55842
|
if (signal.aborted) {
|
|
55837
55843
|
reject(signal.reason);
|
|
55838
55844
|
return;
|
|
@@ -55859,7 +55865,7 @@ function exchange(request2, agents, attempt2 = 0) {
|
|
|
55859
55865
|
const stale = outgoing.reusedSocket && !responded && isConnectionReset(error61);
|
|
55860
55866
|
if (stale && attempt2 < STALE_SOCKET_RETRIES && !signal.aborted) {
|
|
55861
55867
|
settle();
|
|
55862
|
-
|
|
55868
|
+
resolve13(exchange(request2, agents, attempt2 + 1));
|
|
55863
55869
|
return;
|
|
55864
55870
|
}
|
|
55865
55871
|
fail(error61);
|
|
@@ -55872,7 +55878,7 @@ function exchange(request2, agents, attempt2 = 0) {
|
|
|
55872
55878
|
readBody(incoming, url3, isRedirect(status) ? void 0 : request2.maxBodyBytes).then(
|
|
55873
55879
|
(body) => {
|
|
55874
55880
|
settle();
|
|
55875
|
-
|
|
55881
|
+
resolve13({ status, headers: incoming.headers, body });
|
|
55876
55882
|
},
|
|
55877
55883
|
fail
|
|
55878
55884
|
);
|
|
@@ -56117,8 +56123,8 @@ function isBodyless(method) {
|
|
|
56117
56123
|
return method === "GET" || method === "HEAD";
|
|
56118
56124
|
}
|
|
56119
56125
|
function exchange2(send2, options, input2) {
|
|
56120
|
-
return new Promise((
|
|
56121
|
-
const outgoing = send2({ ...options, method: input2.method, signal: input2.signal },
|
|
56126
|
+
return new Promise((resolve13, reject) => {
|
|
56127
|
+
const outgoing = send2({ ...options, method: input2.method, signal: input2.signal }, resolve13);
|
|
56122
56128
|
outgoing.on("error", reject);
|
|
56123
56129
|
if (isBodyless(input2.method)) {
|
|
56124
56130
|
input2.body.resume();
|
|
@@ -57604,7 +57610,7 @@ function createGitRunner(options) {
|
|
|
57604
57610
|
}
|
|
57605
57611
|
await killProcessTree(child.pid, { signal: "SIGKILL", child, platform: platform3 });
|
|
57606
57612
|
};
|
|
57607
|
-
return new Promise((
|
|
57613
|
+
return new Promise((resolve13, reject) => {
|
|
57608
57614
|
let ending = null;
|
|
57609
57615
|
const stop = (next) => {
|
|
57610
57616
|
if (ending !== null) return;
|
|
@@ -57629,7 +57635,7 @@ function createGitRunner(options) {
|
|
|
57629
57635
|
signal.removeEventListener("abort", onAbort);
|
|
57630
57636
|
const final = ending ?? last;
|
|
57631
57637
|
if (final.kind === "exited") {
|
|
57632
|
-
|
|
57638
|
+
resolve13({ exitCode: final.exitCode, stdout: stdout.text(), stderr: stderr.text() });
|
|
57633
57639
|
} else {
|
|
57634
57640
|
reject(faultFor(final, command));
|
|
57635
57641
|
}
|
|
@@ -57771,35 +57777,35 @@ async function checkOne(path4, deps, signal) {
|
|
|
57771
57777
|
await write({ state: "checking", path: path4 });
|
|
57772
57778
|
const read = await readSnapshot(deps.git, path4, signal);
|
|
57773
57779
|
if (read.kind !== "snapshot") return write({ state: read.kind, path: path4, reason: read.reason });
|
|
57774
|
-
const { snapshot
|
|
57780
|
+
const { snapshot } = read;
|
|
57775
57781
|
const advertised = await deps.git.run(
|
|
57776
57782
|
{
|
|
57777
57783
|
cwd: path4,
|
|
57778
|
-
args: ["ls-remote", "--exit-code", REMOTE, `refs/heads/${
|
|
57784
|
+
args: ["ls-remote", "--exit-code", REMOTE, `refs/heads/${snapshot.base}`],
|
|
57779
57785
|
network: true,
|
|
57780
57786
|
readOnly: true
|
|
57781
57787
|
},
|
|
57782
57788
|
signal
|
|
57783
57789
|
);
|
|
57784
57790
|
if (advertised.exitCode !== 0) {
|
|
57785
|
-
return write({ state: "failed", path: path4, snapshot
|
|
57791
|
+
return write({ state: "failed", path: path4, snapshot, reason: gitError(advertised, "ls-remote") });
|
|
57786
57792
|
}
|
|
57787
57793
|
const tip = advertised.stdout.split(/\s+/)[0] ?? "";
|
|
57788
|
-
if (tip ===
|
|
57789
|
-
if (tip ===
|
|
57790
|
-
return write({ state: "behind", path: path4, snapshot
|
|
57794
|
+
if (tip === snapshot.head) return write({ state: "current", path: path4, snapshot });
|
|
57795
|
+
if (tip === snapshot.published) {
|
|
57796
|
+
return write({ state: "behind", path: path4, snapshot, tip, fetched: true });
|
|
57791
57797
|
}
|
|
57792
|
-
await write({ state: "behind", path: path4, snapshot
|
|
57793
|
-
const depth =
|
|
57798
|
+
await write({ state: "behind", path: path4, snapshot, tip, fetched: false });
|
|
57799
|
+
const depth = snapshot.shallow ? ["--depth=1"] : [];
|
|
57794
57800
|
const fetched = await deps.git.run(
|
|
57795
57801
|
{
|
|
57796
57802
|
cwd: path4,
|
|
57797
|
-
args: ["fetch", "--no-tags", "--quiet", ...depth, REMOTE,
|
|
57803
|
+
args: ["fetch", "--no-tags", "--quiet", ...depth, REMOTE, snapshot.base],
|
|
57798
57804
|
network: true
|
|
57799
57805
|
},
|
|
57800
57806
|
signal
|
|
57801
57807
|
);
|
|
57802
|
-
return fetched.exitCode === 0 ? write({ state: "behind", path: path4, snapshot
|
|
57808
|
+
return fetched.exitCode === 0 ? write({ state: "behind", path: path4, snapshot, tip, fetched: true }) : write({ state: "failed", path: path4, snapshot, reason: gitError(fetched, "fetch") });
|
|
57803
57809
|
}
|
|
57804
57810
|
async function isCheckout(path4) {
|
|
57805
57811
|
return (0, import_promises11.stat)((0, import_node_path7.join)(path4, ".git")).then(
|
|
@@ -58167,9 +58173,9 @@ function isProcessAlive(pid) {
|
|
|
58167
58173
|
}
|
|
58168
58174
|
}
|
|
58169
58175
|
async function linuxStartTime(pid) {
|
|
58170
|
-
const
|
|
58171
|
-
if (
|
|
58172
|
-
const fields =
|
|
58176
|
+
const stat22 = await (0, import_promises13.readFile)(`/proc/${pid}/stat`, "utf8").catch(() => null);
|
|
58177
|
+
if (stat22 === null) return null;
|
|
58178
|
+
const fields = stat22.slice(stat22.lastIndexOf(")") + 2).split(" ");
|
|
58173
58179
|
return fields[19] ?? null;
|
|
58174
58180
|
}
|
|
58175
58181
|
async function linuxCommand(pid) {
|
|
@@ -59149,7 +59155,7 @@ function statusOf(error61) {
|
|
|
59149
59155
|
}
|
|
59150
59156
|
return 1;
|
|
59151
59157
|
}
|
|
59152
|
-
var systemExec = (request2) => new Promise((
|
|
59158
|
+
var systemExec = (request2) => new Promise((resolve13) => {
|
|
59153
59159
|
const child = (0, import_node_child_process6.execFile)(
|
|
59154
59160
|
request2.command,
|
|
59155
59161
|
[...request2.args],
|
|
@@ -59160,7 +59166,7 @@ var systemExec = (request2) => new Promise((resolve14) => {
|
|
|
59160
59166
|
windowsHide: true
|
|
59161
59167
|
},
|
|
59162
59168
|
(error61, stdout, stderr) => {
|
|
59163
|
-
|
|
59169
|
+
resolve13({ status: statusOf(error61), stdout, stderr });
|
|
59164
59170
|
}
|
|
59165
59171
|
);
|
|
59166
59172
|
child.stdin?.on("error", () => {
|
|
@@ -59981,6 +59987,10 @@ function createServiceManager(host, profile) {
|
|
|
59981
59987
|
// src/platform/sleep.ts
|
|
59982
59988
|
var import_node_child_process7 = require("child_process");
|
|
59983
59989
|
var WAKE_THRESHOLD_MS = 3e4;
|
|
59990
|
+
var WINDOWS_WAKE_THRESHOLD_MS = 12e4;
|
|
59991
|
+
function wakeThresholdMs(platform3) {
|
|
59992
|
+
return platform3 === "win32" ? WINDOWS_WAKE_THRESHOLD_MS : WAKE_THRESHOLD_MS;
|
|
59993
|
+
}
|
|
59984
59994
|
function createWakeDetector(clock, thresholdMs = WAKE_THRESHOLD_MS, platform3 = process.platform) {
|
|
59985
59995
|
const last = { wall: clock.now(), drift: clock.now() - clock.monotonic() };
|
|
59986
59996
|
return {
|
|
@@ -59994,7 +60004,7 @@ function createWakeDetector(clock, thresholdMs = WAKE_THRESHOLD_MS, platform3 =
|
|
|
59994
60004
|
}
|
|
59995
60005
|
};
|
|
59996
60006
|
}
|
|
59997
|
-
function wakeJob(clock, onWake,
|
|
60007
|
+
function wakeJob(clock, onWake, platform3 = process.platform, thresholdMs = wakeThresholdMs(platform3)) {
|
|
59998
60008
|
const detector = createWakeDetector(clock, thresholdMs, platform3);
|
|
59999
60009
|
return {
|
|
60000
60010
|
name: "wake.detect",
|
|
@@ -60350,11 +60360,11 @@ async function startGitCredentialServer(options) {
|
|
|
60350
60360
|
});
|
|
60351
60361
|
});
|
|
60352
60362
|
removeStaleEndpoint(options.endpoint);
|
|
60353
|
-
await new Promise((
|
|
60363
|
+
await new Promise((resolve13, reject) => {
|
|
60354
60364
|
server.once("error", reject);
|
|
60355
60365
|
server.listen(options.endpoint, () => {
|
|
60356
60366
|
server.off("error", reject);
|
|
60357
|
-
|
|
60367
|
+
resolve13();
|
|
60358
60368
|
});
|
|
60359
60369
|
});
|
|
60360
60370
|
options.log.info("git.credential_server_listening", { endpoint: options.endpoint });
|
|
@@ -60362,7 +60372,7 @@ async function startGitCredentialServer(options) {
|
|
|
60362
60372
|
endpoint: options.endpoint,
|
|
60363
60373
|
[Symbol.asyncDispose]: async () => {
|
|
60364
60374
|
closing.abort();
|
|
60365
|
-
await new Promise((
|
|
60375
|
+
await new Promise((resolve13) => server.close(() => resolve13()));
|
|
60366
60376
|
removeStaleEndpoint(options.endpoint);
|
|
60367
60377
|
}
|
|
60368
60378
|
};
|
|
@@ -60436,13 +60446,13 @@ authorityKeyIdentifier = keyid
|
|
|
60436
60446
|
`;
|
|
60437
60447
|
}
|
|
60438
60448
|
function openssl(args, cwd) {
|
|
60439
|
-
return new Promise((
|
|
60449
|
+
return new Promise((resolve13, reject) => {
|
|
60440
60450
|
(0, import_node_child_process9.execFile)(
|
|
60441
60451
|
"openssl",
|
|
60442
60452
|
[...args],
|
|
60443
60453
|
{ cwd, timeout: OPENSSL_TIMEOUT_MS },
|
|
60444
60454
|
(error61, _stdout, stderr) => {
|
|
60445
|
-
if (error61 === null)
|
|
60455
|
+
if (error61 === null) resolve13();
|
|
60446
60456
|
else
|
|
60447
60457
|
reject(new Error(`openssl ${args[0] ?? ""} failed: ${stderr.trim() || error61.message}`));
|
|
60448
60458
|
}
|
|
@@ -60619,21 +60629,21 @@ function relayTo(forward, log) {
|
|
|
60619
60629
|
};
|
|
60620
60630
|
}
|
|
60621
60631
|
function listen(server, target) {
|
|
60622
|
-
return new Promise((
|
|
60632
|
+
return new Promise((resolve13, reject) => {
|
|
60623
60633
|
server.once("error", reject);
|
|
60624
60634
|
const done = () => {
|
|
60625
60635
|
server.off("error", reject);
|
|
60626
|
-
|
|
60636
|
+
resolve13();
|
|
60627
60637
|
};
|
|
60628
60638
|
if (typeof target === "string") server.listen(target, done);
|
|
60629
60639
|
else server.listen(target.port, target.host, done);
|
|
60630
60640
|
});
|
|
60631
60641
|
}
|
|
60632
60642
|
function close(server, sockets = /* @__PURE__ */ new Set()) {
|
|
60633
|
-
return new Promise((
|
|
60643
|
+
return new Promise((resolve13) => {
|
|
60634
60644
|
for (const socket of sockets) socket.destroy();
|
|
60635
60645
|
server.closeAllConnections();
|
|
60636
|
-
server.close(() =>
|
|
60646
|
+
server.close(() => resolve13());
|
|
60637
60647
|
});
|
|
60638
60648
|
}
|
|
60639
60649
|
function portOf(server) {
|
|
@@ -62767,8 +62777,8 @@ async function openNativeSessionStore(stateDir, maxEntries = MAX_NATIVE_SESSION_
|
|
|
62767
62777
|
sessions.delete(sessionKey(entry.provider, entry.externalSessionId));
|
|
62768
62778
|
}
|
|
62769
62779
|
}
|
|
62770
|
-
const
|
|
62771
|
-
writing = writing.catch(() => void 0).then(() => writeJsonFileAtomic(path4,
|
|
62780
|
+
const snapshot = { version: 1, sessions: [...sessions.values()] };
|
|
62781
|
+
writing = writing.catch(() => void 0).then(() => writeJsonFileAtomic(path4, snapshot));
|
|
62772
62782
|
return writing;
|
|
62773
62783
|
};
|
|
62774
62784
|
return {
|
|
@@ -63416,7 +63426,7 @@ async function startNativeIngest(deps) {
|
|
|
63416
63426
|
};
|
|
63417
63427
|
const settleIdle = () => {
|
|
63418
63428
|
if (workers.size > 0) return;
|
|
63419
|
-
for (const
|
|
63429
|
+
for (const resolve13 of idleWaiters) resolve13();
|
|
63420
63430
|
idleWaiters.clear();
|
|
63421
63431
|
};
|
|
63422
63432
|
const retryDelay = (worker) => {
|
|
@@ -63659,7 +63669,7 @@ async function startNativeIngest(deps) {
|
|
|
63659
63669
|
sweep: sweep2,
|
|
63660
63670
|
whenIdle: () => {
|
|
63661
63671
|
if (workers.size === 0) return Promise.resolve();
|
|
63662
|
-
return new Promise((
|
|
63672
|
+
return new Promise((resolve13) => idleWaiters.add(resolve13));
|
|
63663
63673
|
},
|
|
63664
63674
|
[Symbol.asyncDispose]: async () => {
|
|
63665
63675
|
shutdown.abort();
|
|
@@ -63807,7 +63817,7 @@ function captureProbe(command, args, options) {
|
|
|
63807
63817
|
const launch = directLaunch(command, args, options);
|
|
63808
63818
|
if (launch === void 0) return Promise.resolve({ stdout: "", stderr: "", exitCode: void 0 });
|
|
63809
63819
|
const env = platform3 === "win32" ? withWindowsHelper(canonicalWindowsEnvironment(options.env)) : options.env;
|
|
63810
|
-
return new Promise((
|
|
63820
|
+
return new Promise((resolve13) => {
|
|
63811
63821
|
const limit = options.maxBufferBytes ?? DEFAULT_MAX_BYTES;
|
|
63812
63822
|
const stdout = [];
|
|
63813
63823
|
const stderr = [];
|
|
@@ -63842,7 +63852,7 @@ function captureProbe(command, args, options) {
|
|
|
63842
63852
|
settled2 = true;
|
|
63843
63853
|
deadlineController.abort();
|
|
63844
63854
|
options.signal?.removeEventListener("abort", abort);
|
|
63845
|
-
|
|
63855
|
+
resolve13({
|
|
63846
63856
|
stdout: Buffer.concat(stdout).toString("utf8"),
|
|
63847
63857
|
stderr: Buffer.concat(stderr).toString("utf8"),
|
|
63848
63858
|
exitCode
|
|
@@ -63975,7 +63985,7 @@ function cursorAccountLabel(output2) {
|
|
|
63975
63985
|
function waitForAbort(signal) {
|
|
63976
63986
|
if (signal.aborted) return Promise.resolve();
|
|
63977
63987
|
return new Promise(
|
|
63978
|
-
(
|
|
63988
|
+
(resolve13) => signal.addEventListener("abort", () => resolve13(), { once: true })
|
|
63979
63989
|
);
|
|
63980
63990
|
}
|
|
63981
63991
|
function idlePrompt(signal) {
|
|
@@ -64053,14 +64063,14 @@ async function codexLabel(executable, env) {
|
|
|
64053
64063
|
windowsVerbatimArguments: launch.windowsVerbatimArguments
|
|
64054
64064
|
});
|
|
64055
64065
|
const timeout = AbortSignal.timeout(ACCOUNT_TIMEOUT_MS);
|
|
64056
|
-
return new Promise((
|
|
64066
|
+
return new Promise((resolve13) => {
|
|
64057
64067
|
let finished = false;
|
|
64058
64068
|
let buffer = "";
|
|
64059
64069
|
const finish = (label) => {
|
|
64060
64070
|
if (finished) return;
|
|
64061
64071
|
finished = true;
|
|
64062
64072
|
child.kill();
|
|
64063
|
-
|
|
64073
|
+
resolve13(label);
|
|
64064
64074
|
};
|
|
64065
64075
|
const send2 = (value2) => {
|
|
64066
64076
|
child.stdin.write(`${JSON.stringify(value2)}
|
|
@@ -64203,7 +64213,7 @@ function createProbeQueue(capture, env, limit) {
|
|
|
64203
64213
|
active += 1;
|
|
64204
64214
|
return Promise.resolve();
|
|
64205
64215
|
}
|
|
64206
|
-
return new Promise((
|
|
64216
|
+
return new Promise((resolve13) => waiting.push(resolve13));
|
|
64207
64217
|
};
|
|
64208
64218
|
const release2 = () => {
|
|
64209
64219
|
const next = waiting.shift();
|
|
@@ -64643,11 +64653,11 @@ async function resolveCliEnvironment(options) {
|
|
|
64643
64653
|
}
|
|
64644
64654
|
async function openCliEnvironment(options) {
|
|
64645
64655
|
const decorate = options.decorate ?? ((env) => env);
|
|
64646
|
-
const
|
|
64656
|
+
const resolve13 = async () => {
|
|
64647
64657
|
const resolved = await resolveCliEnvironmentDetailed(options);
|
|
64648
64658
|
return { env: decorate(resolved.env), source: resolved.source };
|
|
64649
64659
|
};
|
|
64650
|
-
let state = await
|
|
64660
|
+
let state = await resolve13();
|
|
64651
64661
|
let retryAt = options.clock.now() + DEGRADED_RETRY_MS;
|
|
64652
64662
|
return {
|
|
64653
64663
|
current: () => state.env,
|
|
@@ -64656,7 +64666,7 @@ async function openCliEnvironment(options) {
|
|
|
64656
64666
|
if (state.source === "login_shell" || options.platform === "win32") return false;
|
|
64657
64667
|
if (options.clock.now() < retryAt) return false;
|
|
64658
64668
|
retryAt = options.clock.now() + DEGRADED_RETRY_MS;
|
|
64659
|
-
const next = await
|
|
64669
|
+
const next = await resolve13();
|
|
64660
64670
|
const changed2 = envValue(next.env, "PATH") !== envValue(state.env, "PATH");
|
|
64661
64671
|
state = next;
|
|
64662
64672
|
return changed2;
|
|
@@ -64733,11 +64743,11 @@ async function installVersion2(backendKind, requested, options, signal) {
|
|
|
64733
64743
|
}
|
|
64734
64744
|
return exact;
|
|
64735
64745
|
}
|
|
64736
|
-
const
|
|
64737
|
-
if (
|
|
64746
|
+
const resolve13 = options.resolveVersion;
|
|
64747
|
+
if (resolve13 === void 0) throw new Error("Latest version lookup is unavailable");
|
|
64738
64748
|
const packageName = packageFor(backendKind).name;
|
|
64739
64749
|
return checkedVersion(
|
|
64740
|
-
await
|
|
64750
|
+
await resolve13(backendKind === "opencode_serve" ? `${packageName}@1` : packageName, signal)
|
|
64741
64751
|
);
|
|
64742
64752
|
}
|
|
64743
64753
|
function selection(root, backendKind, version2) {
|
|
@@ -66304,8 +66314,8 @@ async function collectStream(stream) {
|
|
|
66304
66314
|
return import_node_buffer2.Buffer.concat(chunks);
|
|
66305
66315
|
}
|
|
66306
66316
|
function addArchiveEntry(archive, header, bytes) {
|
|
66307
|
-
return new Promise((
|
|
66308
|
-
archive.entry(header, bytes, (error61) => error61 ? reject(error61) :
|
|
66317
|
+
return new Promise((resolve13, reject) => {
|
|
66318
|
+
archive.entry(header, bytes, (error61) => error61 ? reject(error61) : resolve13());
|
|
66309
66319
|
});
|
|
66310
66320
|
}
|
|
66311
66321
|
async function decompressBounded(archiveBytes) {
|
|
@@ -66331,7 +66341,7 @@ async function extractTar(tarBytes, destination) {
|
|
|
66331
66341
|
const extractor = (0, import_tar_stream.extract)();
|
|
66332
66342
|
let fileCount = 0;
|
|
66333
66343
|
let totalBytes = 0;
|
|
66334
|
-
const completion = new Promise((
|
|
66344
|
+
const completion = new Promise((resolve13, reject) => {
|
|
66335
66345
|
extractor.on("entry", (header, stream, next) => {
|
|
66336
66346
|
void extractEntry(header, stream, destination, {
|
|
66337
66347
|
addFile(size) {
|
|
@@ -66346,7 +66356,7 @@ async function extractTar(tarBytes, destination) {
|
|
|
66346
66356
|
}
|
|
66347
66357
|
}).then(next, (error61) => extractor.destroy(error61 instanceof Error ? error61 : new Error(String(error61))));
|
|
66348
66358
|
});
|
|
66349
|
-
extractor.once("finish",
|
|
66359
|
+
extractor.once("finish", resolve13);
|
|
66350
66360
|
extractor.once("error", reject);
|
|
66351
66361
|
});
|
|
66352
66362
|
import_node_stream.Readable.from(tarBytes).pipe(extractor);
|
|
@@ -66829,9 +66839,9 @@ async function syncOnce(env, local, onRecorded, signal) {
|
|
|
66829
66839
|
return report2;
|
|
66830
66840
|
}
|
|
66831
66841
|
function aborted2(signal) {
|
|
66832
|
-
return new Promise((
|
|
66833
|
-
if (signal.aborted)
|
|
66834
|
-
else signal.addEventListener("abort", () =>
|
|
66842
|
+
return new Promise((resolve13) => {
|
|
66843
|
+
if (signal.aborted) resolve13(null);
|
|
66844
|
+
else signal.addEventListener("abort", () => resolve13(null), { once: true });
|
|
66835
66845
|
});
|
|
66836
66846
|
}
|
|
66837
66847
|
function openMachineSkills(options) {
|
|
@@ -66920,11 +66930,11 @@ function openMachineSkills(options) {
|
|
|
66920
66930
|
if ((await resolveSkillInvocations(layout, named, "exact")).kind === "resolved") return;
|
|
66921
66931
|
}
|
|
66922
66932
|
};
|
|
66923
|
-
const recordedUntilResolved = (named, until) => new Promise((
|
|
66933
|
+
const recordedUntilResolved = (named, until) => new Promise((resolve13) => {
|
|
66924
66934
|
const done = () => {
|
|
66925
66935
|
recordWatchers.delete(check3);
|
|
66926
66936
|
until.removeEventListener("abort", done);
|
|
66927
|
-
|
|
66937
|
+
resolve13();
|
|
66928
66938
|
};
|
|
66929
66939
|
const check3 = () => {
|
|
66930
66940
|
void resolveSkillInvocations(layout, named, "exact").then((resolution) => {
|
|
@@ -66932,7 +66942,7 @@ function openMachineSkills(options) {
|
|
|
66932
66942
|
});
|
|
66933
66943
|
};
|
|
66934
66944
|
if (until.aborted) {
|
|
66935
|
-
|
|
66945
|
+
resolve13();
|
|
66936
66946
|
return;
|
|
66937
66947
|
}
|
|
66938
66948
|
recordWatchers.add(check3);
|
|
@@ -67428,7 +67438,7 @@ async function openWorkspaces(options) {
|
|
|
67428
67438
|
|
|
67429
67439
|
// src/cli/config.ts
|
|
67430
67440
|
var import_node_os11 = require("os");
|
|
67431
|
-
var
|
|
67441
|
+
var import_node_path68 = require("path");
|
|
67432
67442
|
init_zod();
|
|
67433
67443
|
|
|
67434
67444
|
// src/client/contract.ts
|
|
@@ -67846,8 +67856,8 @@ function nextOffsetOf(response) {
|
|
|
67846
67856
|
async function pause(ms, signal) {
|
|
67847
67857
|
const either = AbortSignal.any([signal, AbortSignal.timeout(ms)]);
|
|
67848
67858
|
if (either.aborted) return;
|
|
67849
|
-
await new Promise((
|
|
67850
|
-
either.addEventListener("abort", () =>
|
|
67859
|
+
await new Promise((resolve13) => {
|
|
67860
|
+
either.addEventListener("abort", () => resolve13(), { once: true });
|
|
67851
67861
|
});
|
|
67852
67862
|
}
|
|
67853
67863
|
function jittered(backoff, failures) {
|
|
@@ -68156,9 +68166,9 @@ async function sendNativeHookSignal(discoveryPath, hookSignal, signal) {
|
|
|
68156
68166
|
|
|
68157
68167
|
// src/sessions/index.ts
|
|
68158
68168
|
var import_node_crypto31 = require("crypto");
|
|
68159
|
-
var
|
|
68169
|
+
var import_promises67 = require("fs/promises");
|
|
68160
68170
|
var import_node_os10 = require("os");
|
|
68161
|
-
var
|
|
68171
|
+
var import_node_path67 = require("path");
|
|
68162
68172
|
init_runtime_v2();
|
|
68163
68173
|
|
|
68164
68174
|
// src/holder/control-client.ts
|
|
@@ -68209,8 +68219,8 @@ function isReply(message2) {
|
|
|
68209
68219
|
async function connectHolder(endpoint, token, onEvent) {
|
|
68210
68220
|
const socket = (0, import_node_net2.connect)(endpoint);
|
|
68211
68221
|
const pending = /* @__PURE__ */ new Map();
|
|
68212
|
-
const closed = new Promise((
|
|
68213
|
-
const ready = new Promise((
|
|
68222
|
+
const closed = new Promise((resolve13) => socket.once("close", () => resolve13()));
|
|
68223
|
+
const ready = new Promise((resolve13, reject) => {
|
|
68214
68224
|
socket.once("error", reject);
|
|
68215
68225
|
socket.once(
|
|
68216
68226
|
"close",
|
|
@@ -68218,7 +68228,7 @@ async function connectHolder(endpoint, token, onEvent) {
|
|
|
68218
68228
|
);
|
|
68219
68229
|
readMessages(socket, holderMessageSchema, {
|
|
68220
68230
|
onMessage: (message2) => {
|
|
68221
|
-
if (message2.type === "ready")
|
|
68231
|
+
if (message2.type === "ready") resolve13(message2.pid);
|
|
68222
68232
|
else if (isReply(message2)) {
|
|
68223
68233
|
const id = message2.id;
|
|
68224
68234
|
if (id === null) return;
|
|
@@ -68233,13 +68243,13 @@ async function connectHolder(endpoint, token, onEvent) {
|
|
|
68233
68243
|
const pid = await ready;
|
|
68234
68244
|
const request2 = (body) => {
|
|
68235
68245
|
const id = (0, import_node_crypto26.randomUUID)();
|
|
68236
|
-
return new Promise((
|
|
68246
|
+
return new Promise((resolve13, reject) => {
|
|
68237
68247
|
const timer = AbortSignal.timeout(REQUEST_TIMEOUT_MS7);
|
|
68238
68248
|
timer.addEventListener("abort", () => {
|
|
68239
68249
|
pending.delete(id);
|
|
68240
68250
|
reject(new RuntimeFault("io_failed", "Holder did not answer"));
|
|
68241
68251
|
});
|
|
68242
|
-
pending.set(id,
|
|
68252
|
+
pending.set(id, resolve13);
|
|
68243
68253
|
writeMessage(socket, { ...body, id });
|
|
68244
68254
|
});
|
|
68245
68255
|
};
|
|
@@ -68270,9 +68280,9 @@ function selectDriver(persistent, fallback) {
|
|
|
68270
68280
|
suspend: async () => {
|
|
68271
68281
|
await Promise.all([...drivers].map((driver) => driver.suspend?.()));
|
|
68272
68282
|
},
|
|
68273
|
-
respond: async (request2
|
|
68283
|
+
respond: async (request2) => {
|
|
68274
68284
|
for (const driver of drivers) {
|
|
68275
|
-
const status = await driver.respond?.(request2
|
|
68285
|
+
const status = await driver.respond?.(request2);
|
|
68276
68286
|
if (status !== void 0 && status !== "unknown_run") return status;
|
|
68277
68287
|
}
|
|
68278
68288
|
return "unknown_run";
|
|
@@ -68312,9 +68322,9 @@ function createLazyDriver(load) {
|
|
|
68312
68322
|
suspend: async () => {
|
|
68313
68323
|
if (loaded.driver !== void 0) await (await loaded.driver).suspend?.();
|
|
68314
68324
|
},
|
|
68315
|
-
respond: async (request2
|
|
68325
|
+
respond: async (request2) => {
|
|
68316
68326
|
if (loaded.driver === void 0) return "unknown_run";
|
|
68317
|
-
return await (await loaded.driver).respond?.(request2
|
|
68327
|
+
return await (await loaded.driver).respond?.(request2) ?? "unknown_run";
|
|
68318
68328
|
},
|
|
68319
68329
|
stopTask: async (taskId) => {
|
|
68320
68330
|
if (loaded.driver === void 0) return TASK_NOT_FOUND;
|
|
@@ -68576,14 +68586,14 @@ async function prepareRunInputs(spec, { source, tmpDir, signal, skills = [] }) {
|
|
|
68576
68586
|
var import_node_crypto30 = require("crypto");
|
|
68577
68587
|
var import_node_fs22 = require("fs");
|
|
68578
68588
|
var import_node_net3 = require("net");
|
|
68579
|
-
var
|
|
68589
|
+
var import_node_path66 = require("path");
|
|
68580
68590
|
init_runtime_v2();
|
|
68581
68591
|
|
|
68582
68592
|
// src/holder/admission.ts
|
|
68583
68593
|
var import_node_fs19 = require("fs");
|
|
68584
|
-
var
|
|
68594
|
+
var import_promises61 = require("fs/promises");
|
|
68585
68595
|
var import_node_os9 = require("os");
|
|
68586
|
-
var
|
|
68596
|
+
var import_node_path60 = require("path");
|
|
68587
68597
|
init_constants();
|
|
68588
68598
|
|
|
68589
68599
|
// ../shared/dist/node/local-workspace.js
|
|
@@ -68594,88 +68604,16 @@ function resolveAlanDefaultWorkspacePath(homeDirectory = (0, import_node_os8.hom
|
|
|
68594
68604
|
return (0, import_node_path55.join)(homeDirectory, ".alan", "workspace");
|
|
68595
68605
|
}
|
|
68596
68606
|
|
|
68597
|
-
// src/holder/
|
|
68607
|
+
// src/holder/agent-context.ts
|
|
68598
68608
|
var import_promises58 = require("fs/promises");
|
|
68599
68609
|
var import_node_path56 = require("path");
|
|
68600
|
-
var MAX_RELOCATION_CANDIDATES = 200;
|
|
68601
|
-
var RELOCATION_BUDGET_MS = 2e4;
|
|
68602
|
-
function repositoryIdentity(url3) {
|
|
68603
|
-
const trimmed4 = url3.trim().replace(/\/+$/, "").replace(/\.git$/i, "");
|
|
68604
|
-
if (trimmed4.length === 0) return null;
|
|
68605
|
-
const scp = /^(?:[^@/]+@)?([^:/]+):(.+)$/.exec(trimmed4);
|
|
68606
|
-
if (scp !== null && !trimmed4.includes("://")) {
|
|
68607
|
-
return `${scp[1]}/${scp[2]}`.toLowerCase();
|
|
68608
|
-
}
|
|
68609
|
-
try {
|
|
68610
|
-
const parsed = new URL(trimmed4);
|
|
68611
|
-
return `${parsed.hostname}${parsed.pathname}`.replace(/\/+$/, "").toLowerCase();
|
|
68612
|
-
} catch {
|
|
68613
|
-
return null;
|
|
68614
|
-
}
|
|
68615
|
-
}
|
|
68616
|
-
function repositoryIdentities(urls) {
|
|
68617
|
-
return new Set(
|
|
68618
|
-
urls.map(repositoryIdentity).filter((identity) => identity !== null)
|
|
68619
|
-
);
|
|
68620
|
-
}
|
|
68621
|
-
async function originIdentity(git, path4, signal) {
|
|
68622
|
-
try {
|
|
68623
|
-
const output2 = await git.run(
|
|
68624
|
-
{ cwd: path4, args: ["config", "--get", "remote.origin.url"], readOnly: true },
|
|
68625
|
-
signal
|
|
68626
|
-
);
|
|
68627
|
-
return output2.exitCode === 0 ? repositoryIdentity(output2.stdout) : null;
|
|
68628
|
-
} catch {
|
|
68629
|
-
return null;
|
|
68630
|
-
}
|
|
68631
|
-
}
|
|
68632
|
-
async function childDirectories(parent, limit) {
|
|
68633
|
-
try {
|
|
68634
|
-
const entries = await (0, import_promises58.readdir)(parent, { withFileTypes: true });
|
|
68635
|
-
return entries.filter((entry) => entry.isDirectory()).slice(0, limit).map((entry) => (0, import_node_path56.join)(parent, entry.name));
|
|
68636
|
-
} catch {
|
|
68637
|
-
return [];
|
|
68638
|
-
}
|
|
68639
|
-
}
|
|
68640
|
-
async function candidateFolders(search) {
|
|
68641
|
-
const roots = /* @__PURE__ */ new Map();
|
|
68642
|
-
for (const path4 of [search.missingPath, ...search.approvedWorkspacePaths]) {
|
|
68643
|
-
const parent = (0, import_node_path56.dirname)((0, import_node_path56.resolve)(path4));
|
|
68644
|
-
roots.set(comparablePath(parent, search.platform), parent);
|
|
68645
|
-
}
|
|
68646
|
-
const candidates2 = /* @__PURE__ */ new Map();
|
|
68647
|
-
for (const root of roots.values()) {
|
|
68648
|
-
const remaining = MAX_RELOCATION_CANDIDATES - candidates2.size;
|
|
68649
|
-
if (remaining <= 0) break;
|
|
68650
|
-
for (const child of await childDirectories(root, remaining)) {
|
|
68651
|
-
candidates2.set(comparablePath(child, search.platform), child);
|
|
68652
|
-
}
|
|
68653
|
-
}
|
|
68654
|
-
return [...candidates2.values()];
|
|
68655
|
-
}
|
|
68656
|
-
async function discoverRelocatedWorkspace(search) {
|
|
68657
|
-
if (search.expected.size === 0) return null;
|
|
68658
|
-
const signal = AbortSignal.any([search.signal, AbortSignal.timeout(RELOCATION_BUDGET_MS)]);
|
|
68659
|
-
const matches = [];
|
|
68660
|
-
for (const candidate of await candidateFolders(search)) {
|
|
68661
|
-
if (signal.aborted) return null;
|
|
68662
|
-
const identity = await originIdentity(search.git, candidate, signal);
|
|
68663
|
-
if (identity !== null && search.expected.has(identity)) matches.push(candidate);
|
|
68664
|
-
if (matches.length > 1) return null;
|
|
68665
|
-
}
|
|
68666
|
-
return matches[0] ?? null;
|
|
68667
|
-
}
|
|
68668
|
-
|
|
68669
|
-
// src/holder/agent-context.ts
|
|
68670
|
-
var import_promises59 = require("fs/promises");
|
|
68671
|
-
var import_node_path57 = require("path");
|
|
68672
68610
|
|
|
68673
68611
|
// ../agent-core/dist/prompt.js
|
|
68674
68612
|
init_chunk_GI3ZGXTY();
|
|
68675
68613
|
|
|
68676
68614
|
// src/holder/agent-context.ts
|
|
68677
68615
|
async function readText4(path4) {
|
|
68678
|
-
return (0,
|
|
68616
|
+
return (0, import_promises58.readFile)(path4, "utf8").then(
|
|
68679
68617
|
(text3) => text3.trim(),
|
|
68680
68618
|
() => null
|
|
68681
68619
|
);
|
|
@@ -68690,15 +68628,15 @@ async function startCommandState(statusPath) {
|
|
|
68690
68628
|
return code === 0 ? { state: "exited_ok" } : { state: "failed", exitCode: code };
|
|
68691
68629
|
}
|
|
68692
68630
|
function createAgentContext(deps) {
|
|
68693
|
-
const statusPath = (0,
|
|
68694
|
-
const logPath = (0,
|
|
68631
|
+
const statusPath = (0, import_node_path56.join)(deps.homeDir, ".alan", "start-commands.status");
|
|
68632
|
+
const logPath = (0, import_node_path56.join)(deps.homeDir, ".alan", "start-commands.log");
|
|
68695
68633
|
return async (spec, problems) => {
|
|
68696
|
-
const file2 = (0,
|
|
68634
|
+
const file2 = (0, import_node_path56.join)(deps.dir, `${spec.conversationId}.json`);
|
|
68697
68635
|
const saved = await readJsonFile(file2, agentContextSnapshotSchema);
|
|
68698
68636
|
const known = saved.kind === "ok" ? saved.value : void 0;
|
|
68699
68637
|
const hasEnvironment = (spec.agentContext ?? known)?.environment !== void 0;
|
|
68700
68638
|
const start = hasEnvironment ? await startCommandState(statusPath) : void 0;
|
|
68701
|
-
const
|
|
68639
|
+
const snapshot = agentContextSnapshot({
|
|
68702
68640
|
spec,
|
|
68703
68641
|
...spec.approvedWorkspacePaths?.[0] ? { workspaceRoot: spec.approvedWorkspacePaths[0] } : {},
|
|
68704
68642
|
problems,
|
|
@@ -68706,39 +68644,39 @@ function createAgentContext(deps) {
|
|
|
68706
68644
|
startLogPath: logPath,
|
|
68707
68645
|
...known ? { known } : {}
|
|
68708
68646
|
});
|
|
68709
|
-
if (
|
|
68710
|
-
const rendered = renderAgentContext(
|
|
68647
|
+
if (snapshot === null) return void 0;
|
|
68648
|
+
const rendered = renderAgentContext(snapshot, known);
|
|
68711
68649
|
return {
|
|
68712
68650
|
full: rendered.full,
|
|
68713
68651
|
...rendered.update ? { update: rendered.update } : {},
|
|
68714
|
-
save: () => writeJsonFileAtomic(file2,
|
|
68652
|
+
save: () => writeJsonFileAtomic(file2, snapshot)
|
|
68715
68653
|
};
|
|
68716
68654
|
};
|
|
68717
68655
|
}
|
|
68718
68656
|
|
|
68719
68657
|
// src/holder/checkout-refresh.ts
|
|
68720
|
-
var
|
|
68658
|
+
var import_node_path59 = require("path");
|
|
68721
68659
|
|
|
68722
68660
|
// src/holder/claim-once.ts
|
|
68723
68661
|
var import_node_crypto28 = require("crypto");
|
|
68724
|
-
var
|
|
68725
|
-
var
|
|
68662
|
+
var import_promises59 = require("fs/promises");
|
|
68663
|
+
var import_node_path57 = require("path");
|
|
68726
68664
|
async function claimOnce(dir, name) {
|
|
68727
68665
|
try {
|
|
68728
|
-
await (0,
|
|
68729
|
-
await (await (0,
|
|
68666
|
+
await (0, import_promises59.mkdir)(dir, { recursive: true, mode: 448 });
|
|
68667
|
+
await (await (0, import_promises59.open)((0, import_node_path57.join)(dir, name), "wx")).close();
|
|
68730
68668
|
return true;
|
|
68731
68669
|
} catch {
|
|
68732
68670
|
return false;
|
|
68733
68671
|
}
|
|
68734
68672
|
}
|
|
68735
68673
|
function claimFirstLease(freshnessDir, path4) {
|
|
68736
|
-
return claimOnce((0,
|
|
68674
|
+
return claimOnce((0, import_node_path57.join)(freshnessDir, "leased"), (0, import_node_crypto28.createHash)("sha256").update(path4).digest("hex"));
|
|
68737
68675
|
}
|
|
68738
68676
|
|
|
68739
68677
|
// src/holder/requested-checkout.ts
|
|
68740
|
-
var
|
|
68741
|
-
var
|
|
68678
|
+
var import_promises60 = require("fs/promises");
|
|
68679
|
+
var import_node_path58 = require("path");
|
|
68742
68680
|
var REMOTE2 = "origin";
|
|
68743
68681
|
var REASON_MAX_CHARS = 200;
|
|
68744
68682
|
function firstLine3(text3) {
|
|
@@ -68759,8 +68697,8 @@ function notSwitched(checkout, current, reason) {
|
|
|
68759
68697
|
);
|
|
68760
68698
|
}
|
|
68761
68699
|
async function clone2(checkout, deps, signal) {
|
|
68762
|
-
const parent = (0,
|
|
68763
|
-
await (0,
|
|
68700
|
+
const parent = (0, import_node_path58.dirname)(checkout.path);
|
|
68701
|
+
await (0, import_promises60.mkdir)(parent, { recursive: true });
|
|
68764
68702
|
await assertValidBranch(deps.git, parent, checkout.branch, signal);
|
|
68765
68703
|
const output2 = await deps.git.run(
|
|
68766
68704
|
{
|
|
@@ -68912,9 +68850,9 @@ async function applyRequestedCheckout(checkout, spec, deps, signal) {
|
|
|
68912
68850
|
function short(sha) {
|
|
68913
68851
|
return sha.slice(0, 12);
|
|
68914
68852
|
}
|
|
68915
|
-
function staleCheckout(path4,
|
|
68916
|
-
const checkout =
|
|
68917
|
-
const base =
|
|
68853
|
+
function staleCheckout(path4, snapshot, tip) {
|
|
68854
|
+
const checkout = snapshot === void 0 ? "is the environment snapshot's checkout" : `is the environment snapshot's checkout of ${snapshot.branch} (commit ${short(snapshot.head)})`;
|
|
68855
|
+
const base = snapshot === void 0 ? "its upstream" : `origin/${snapshot.base}`;
|
|
68918
68856
|
const remote = tip === void 0 ? "may be ahead" : `is ahead at ${short(tip)}`;
|
|
68919
68857
|
return {
|
|
68920
68858
|
path: path4,
|
|
@@ -68925,18 +68863,18 @@ function staleCheckout(path4, snapshot2, tip) {
|
|
|
68925
68863
|
async function fastForward(freshness, operationId, deps, signal) {
|
|
68926
68864
|
var _stack = [];
|
|
68927
68865
|
try {
|
|
68928
|
-
const { path: cwd, snapshot
|
|
68929
|
-
const attempt2 = await deps.locks.tryExclusive(
|
|
68866
|
+
const { path: cwd, snapshot, tip } = freshness;
|
|
68867
|
+
const attempt2 = await deps.locks.tryExclusive(snapshot.commonDir, operationId);
|
|
68930
68868
|
if (attempt2.kind === "busy") return false;
|
|
68931
68869
|
const _lock = __using(_stack, attempt2.lock, true);
|
|
68932
68870
|
const now = await readCheckoutStatus(deps.git, cwd, signal);
|
|
68933
|
-
if (now === null || now.dirty || now.head !==
|
|
68871
|
+
if (now === null || now.dirty || now.head !== snapshot.head || now.branch !== snapshot.branch) {
|
|
68934
68872
|
return false;
|
|
68935
68873
|
}
|
|
68936
68874
|
const git = (args) => deps.git.run({ cwd, args }, signal);
|
|
68937
68875
|
if ((await git(["switch", "--quiet", "--detach", tip])).exitCode !== 0) return false;
|
|
68938
|
-
const moved = await git(["update-ref", `refs/heads/${
|
|
68939
|
-
const back = await git(["switch", "--quiet",
|
|
68876
|
+
const moved = await git(["update-ref", `refs/heads/${snapshot.branch}`, tip, snapshot.head]);
|
|
68877
|
+
const back = await git(["switch", "--quiet", snapshot.branch]);
|
|
68940
68878
|
return moved.exitCode === 0 && back.exitCode === 0;
|
|
68941
68879
|
} catch (_) {
|
|
68942
68880
|
var _error = _, _hasError = true;
|
|
@@ -68968,9 +68906,8 @@ function problemFor(freshness) {
|
|
|
68968
68906
|
return staleCheckout(freshness.path, void 0);
|
|
68969
68907
|
}
|
|
68970
68908
|
}
|
|
68971
|
-
async function checkoutsOf(spec
|
|
68972
|
-
|
|
68973
|
-
return checkoutsUnder(spec.projectPath);
|
|
68909
|
+
async function checkoutsOf(spec) {
|
|
68910
|
+
return spec.projectPath === void 0 ? [] : checkoutsUnder(spec.projectPath);
|
|
68974
68911
|
}
|
|
68975
68912
|
function requestedCheckoutsOf(spec, log) {
|
|
68976
68913
|
const roots = spec.approvedWorkspacePaths ?? [];
|
|
@@ -68998,7 +68935,7 @@ async function applyRequestedCheckouts(spec, deps, signal) {
|
|
|
68998
68935
|
...outcome2.kind === "moved" ? { how: outcome2.how } : {}
|
|
68999
68936
|
});
|
|
69000
68937
|
if (outcome2.kind === "on_branch") continue;
|
|
69001
|
-
settled2.add((0,
|
|
68938
|
+
settled2.add((0, import_node_path59.resolve)(checkout.path));
|
|
69002
68939
|
if (outcome2.kind === "noted") {
|
|
69003
68940
|
problems.push({ path: checkout.path, problem: outcome2.problem, action: outcome2.action });
|
|
69004
68941
|
}
|
|
@@ -69008,7 +68945,7 @@ async function applyRequestedCheckouts(spec, deps, signal) {
|
|
|
69008
68945
|
async function refreshSnapshotCheckouts(spec, targets, settled2, deps, signal) {
|
|
69009
68946
|
const problems = [];
|
|
69010
68947
|
for (const target of targets) {
|
|
69011
|
-
if (settled2.has((0,
|
|
68948
|
+
if (settled2.has((0, import_node_path59.resolve)(target))) continue;
|
|
69012
68949
|
const freshness = await readCheckoutFreshness(deps.dir, target);
|
|
69013
68950
|
if (freshness === null) continue;
|
|
69014
68951
|
const outcome2 = await atFirstLease(freshness, spec, deps, signal).catch(
|
|
@@ -69025,11 +68962,11 @@ async function refreshSnapshotCheckouts(spec, targets, settled2, deps, signal) {
|
|
|
69025
68962
|
return problems;
|
|
69026
68963
|
}
|
|
69027
68964
|
function createCheckoutRefresh(deps) {
|
|
69028
|
-
return async (spec,
|
|
68965
|
+
return async (spec, signal) => {
|
|
69029
68966
|
if (spec.providerSessionId !== void 0) return [];
|
|
69030
|
-
if (!await claimOnce((0,
|
|
68967
|
+
if (!await claimOnce((0, import_node_path59.join)(deps.dir, "conversations"), spec.conversationId)) return [];
|
|
69031
68968
|
const requested = await applyRequestedCheckouts(spec, deps, signal);
|
|
69032
|
-
const targets = await checkoutsOf(spec
|
|
68969
|
+
const targets = await checkoutsOf(spec);
|
|
69033
68970
|
return [
|
|
69034
68971
|
...requested.problems,
|
|
69035
68972
|
...await refreshSnapshotCheckouts(spec, targets, requested.settled, deps, signal)
|
|
@@ -69037,207 +68974,6 @@ function createCheckoutRefresh(deps) {
|
|
|
69037
68974
|
};
|
|
69038
68975
|
}
|
|
69039
68976
|
|
|
69040
|
-
// src/holder/lease.ts
|
|
69041
|
-
var import_promises62 = require("fs/promises");
|
|
69042
|
-
var import_node_path61 = require("path");
|
|
69043
|
-
var LEASE_CHECK_EVERY_MS = 5e3;
|
|
69044
|
-
var MAX_TRANSIENT_FAILURES = 3;
|
|
69045
|
-
var BACKOFF_BASE_MS = 1e3;
|
|
69046
|
-
var BACKOFF_MAX_MS = 15e3;
|
|
69047
|
-
var MESSAGES = {
|
|
69048
|
-
workspace_lease_unavailable: "The workspace or Git checkout became unavailable while the run was active. Restore it and start a new run.",
|
|
69049
|
-
workspace_lease_path_changed: "The selected workspace folder changed while the run was active. The run stopped before continuing; choose the correct folder and start a new run.",
|
|
69050
|
-
workspace_lease_repository_changed: "The workspace now points to a different repository or worktree. The run stopped before continuing; restore the original checkout and start a new run."
|
|
69051
|
-
};
|
|
69052
|
-
function identityFailure(code, workspacePath) {
|
|
69053
|
-
return { code, problemCode: "app.workspace.missing", message: MESSAGES[code], workspacePath };
|
|
69054
|
-
}
|
|
69055
|
-
async function fileIdentity(path4) {
|
|
69056
|
-
const canonical = await (0, import_promises62.realpath)(path4);
|
|
69057
|
-
const info = await (0, import_promises62.stat)(canonical, { bigint: true });
|
|
69058
|
-
return `${canonical}:${info.dev}:${info.ino}`;
|
|
69059
|
-
}
|
|
69060
|
-
async function snapshot(git, path4, signal) {
|
|
69061
|
-
try {
|
|
69062
|
-
const output2 = await git.run(
|
|
69063
|
-
{
|
|
69064
|
-
cwd: path4,
|
|
69065
|
-
args: ["rev-parse", "--path-format=absolute", "--git-dir", "--git-common-dir"],
|
|
69066
|
-
readOnly: true
|
|
69067
|
-
},
|
|
69068
|
-
signal
|
|
69069
|
-
);
|
|
69070
|
-
const [gitDir, commonDir] = output2.stdout.trim().split("\n");
|
|
69071
|
-
if (output2.exitCode !== 0 || !gitDir || !commonDir) return null;
|
|
69072
|
-
return {
|
|
69073
|
-
workspace: await fileIdentity(path4),
|
|
69074
|
-
repository: await fileIdentity(commonDir),
|
|
69075
|
-
worktree: await fileIdentity(gitDir),
|
|
69076
|
-
commonDir: await (0, import_promises62.realpath)(commonDir)
|
|
69077
|
-
};
|
|
69078
|
-
} catch {
|
|
69079
|
-
return null;
|
|
69080
|
-
}
|
|
69081
|
-
}
|
|
69082
|
-
async function gitValue(git, path4, args, signal) {
|
|
69083
|
-
const output2 = await git.run({ cwd: path4, args, readOnly: true }, signal).catch(() => null);
|
|
69084
|
-
const value2 = output2?.exitCode === 0 ? output2.stdout.trim() : "";
|
|
69085
|
-
return value2.length > 0 ? value2 : null;
|
|
69086
|
-
}
|
|
69087
|
-
async function pathExists(path4) {
|
|
69088
|
-
try {
|
|
69089
|
-
await (0, import_promises62.stat)(path4);
|
|
69090
|
-
return true;
|
|
69091
|
-
} catch (error61) {
|
|
69092
|
-
return errnoCode(error61) !== "ENOENT" && errnoCode(error61) !== "ENOTDIR";
|
|
69093
|
-
}
|
|
69094
|
-
}
|
|
69095
|
-
async function hasGitMarker(path4) {
|
|
69096
|
-
let directory;
|
|
69097
|
-
try {
|
|
69098
|
-
directory = await (0, import_promises62.realpath)(path4);
|
|
69099
|
-
} catch {
|
|
69100
|
-
return true;
|
|
69101
|
-
}
|
|
69102
|
-
for (; ; ) {
|
|
69103
|
-
try {
|
|
69104
|
-
await (0, import_promises62.stat)((0, import_node_path61.join)(directory, ".git"));
|
|
69105
|
-
return true;
|
|
69106
|
-
} catch (error61) {
|
|
69107
|
-
const code = errnoCode(error61);
|
|
69108
|
-
if (code !== "ENOENT" && code !== "ENOTDIR") return true;
|
|
69109
|
-
}
|
|
69110
|
-
const parent = (0, import_node_path61.dirname)(directory);
|
|
69111
|
-
if (parent === directory) return false;
|
|
69112
|
-
directory = parent;
|
|
69113
|
-
}
|
|
69114
|
-
}
|
|
69115
|
-
async function probeCheckout(git, path4, captured, signal) {
|
|
69116
|
-
const current = await snapshot(git, path4, signal);
|
|
69117
|
-
if (current === null) {
|
|
69118
|
-
const failure6 = identityFailure("workspace_lease_unavailable", path4);
|
|
69119
|
-
return await pathExists(path4) ? { kind: "transient", failure: failure6 } : { kind: "failed", failure: failure6 };
|
|
69120
|
-
}
|
|
69121
|
-
if (current.workspace !== captured.workspace) {
|
|
69122
|
-
return { kind: "failed", failure: identityFailure("workspace_lease_path_changed", path4) };
|
|
69123
|
-
}
|
|
69124
|
-
if (current.repository !== captured.repository || current.worktree !== captured.worktree) {
|
|
69125
|
-
return { kind: "failed", failure: identityFailure("workspace_lease_repository_changed", path4) };
|
|
69126
|
-
}
|
|
69127
|
-
return { kind: "ok" };
|
|
69128
|
-
}
|
|
69129
|
-
async function releaseAll(locks) {
|
|
69130
|
-
for (const lock of locks) await lock[Symbol.asyncDispose]();
|
|
69131
|
-
}
|
|
69132
|
-
async function captureOne(git, path4, signal) {
|
|
69133
|
-
const identity = await snapshot(git, path4, signal);
|
|
69134
|
-
if (identity === null) return identityFailure("workspace_lease_unavailable", path4);
|
|
69135
|
-
const branch = await gitValue(git, path4, ["symbolic-ref", "-q", "--short", "HEAD"], signal);
|
|
69136
|
-
const head = await gitValue(git, path4, ["rev-parse", "-q", "--verify", "HEAD"], signal);
|
|
69137
|
-
return { path: path4, identity, checkout: { path: path4, commonDir: identity.commonDir, branch, head } };
|
|
69138
|
-
}
|
|
69139
|
-
async function captureWorkspaceLease(runId, paths, deps, signal) {
|
|
69140
|
-
const captured = [];
|
|
69141
|
-
const locks = [];
|
|
69142
|
-
const locked = /* @__PURE__ */ new Set();
|
|
69143
|
-
for (const path4 of paths) {
|
|
69144
|
-
const one = await captureOne(deps.git, path4, signal);
|
|
69145
|
-
if (!("identity" in one)) {
|
|
69146
|
-
await releaseAll(locks);
|
|
69147
|
-
return { kind: "failed", failure: one };
|
|
69148
|
-
}
|
|
69149
|
-
const key = comparablePath(one.identity.commonDir, deps.platform);
|
|
69150
|
-
if (!locked.has(key)) {
|
|
69151
|
-
const attempt2 = await deps.locks.tryShared(one.identity.commonDir, runId);
|
|
69152
|
-
if (attempt2.kind === "busy") {
|
|
69153
|
-
await releaseAll(locks);
|
|
69154
|
-
return {
|
|
69155
|
-
kind: "failed",
|
|
69156
|
-
failure: {
|
|
69157
|
-
code: "workspace_busy",
|
|
69158
|
-
problemCode: null,
|
|
69159
|
-
message: "Alan is committing or pushing in this repository for a checkout switch. Try again when it finishes.",
|
|
69160
|
-
workspacePath: path4
|
|
69161
|
-
}
|
|
69162
|
-
};
|
|
69163
|
-
}
|
|
69164
|
-
locked.add(key);
|
|
69165
|
-
locks.push(attempt2.lock);
|
|
69166
|
-
}
|
|
69167
|
-
captured.push(one);
|
|
69168
|
-
}
|
|
69169
|
-
return { kind: "held", lease: holdLease(captured, locks, deps) };
|
|
69170
|
-
}
|
|
69171
|
-
function holdLease(captured, locks, deps) {
|
|
69172
|
-
const lifetime = new AbortController();
|
|
69173
|
-
const lost = new AbortController();
|
|
69174
|
-
const state = { failure: null, inFlight: null, transientStreak: 0, nextCheckAt: 0 };
|
|
69175
|
-
const probeOnce = async () => {
|
|
69176
|
-
for (const { path: path4, identity } of captured) {
|
|
69177
|
-
const probe = await probeCheckout(deps.git, path4, identity, lifetime.signal);
|
|
69178
|
-
if (probe.kind !== "ok") return probe;
|
|
69179
|
-
}
|
|
69180
|
-
return { kind: "ok" };
|
|
69181
|
-
};
|
|
69182
|
-
const lose = (failure6) => {
|
|
69183
|
-
if (state.failure !== null) return;
|
|
69184
|
-
state.failure = failure6;
|
|
69185
|
-
deps.log.warn("holder.workspace_lease_lost", {
|
|
69186
|
-
code: failure6.code,
|
|
69187
|
-
workspacePath: failure6.workspacePath
|
|
69188
|
-
});
|
|
69189
|
-
lost.abort(failure6);
|
|
69190
|
-
};
|
|
69191
|
-
const apply = (probe) => {
|
|
69192
|
-
if (probe.kind === "ok") {
|
|
69193
|
-
state.transientStreak = 0;
|
|
69194
|
-
state.nextCheckAt = 0;
|
|
69195
|
-
} else if (probe.kind === "failed") {
|
|
69196
|
-
lose(probe.failure);
|
|
69197
|
-
} else {
|
|
69198
|
-
state.transientStreak += 1;
|
|
69199
|
-
if (state.transientStreak >= MAX_TRANSIENT_FAILURES) lose(probe.failure);
|
|
69200
|
-
else {
|
|
69201
|
-
const backoff = BACKOFF_BASE_MS * 2 ** (state.transientStreak - 1);
|
|
69202
|
-
state.nextCheckAt = deps.clock.monotonic() + Math.min(backoff, BACKOFF_MAX_MS);
|
|
69203
|
-
}
|
|
69204
|
-
}
|
|
69205
|
-
return state.failure === null;
|
|
69206
|
-
};
|
|
69207
|
-
const check3 = () => {
|
|
69208
|
-
if (state.failure !== null) return Promise.resolve(false);
|
|
69209
|
-
state.inFlight ??= probeOnce().then((probe) => lifetime.signal.aborted ? state.failure === null : apply(probe)).finally(() => {
|
|
69210
|
-
state.inFlight = null;
|
|
69211
|
-
});
|
|
69212
|
-
return state.inFlight;
|
|
69213
|
-
};
|
|
69214
|
-
const monitor = captured.length === 0 ? null : startMaintenance({
|
|
69215
|
-
everyMs: deps.everyMs ?? LEASE_CHECK_EVERY_MS,
|
|
69216
|
-
jobs: [
|
|
69217
|
-
{
|
|
69218
|
-
name: "holder.workspace_lease",
|
|
69219
|
-
run: async () => {
|
|
69220
|
-
if (state.failure !== null || deps.clock.monotonic() < state.nextCheckAt) return;
|
|
69221
|
-
await check3();
|
|
69222
|
-
}
|
|
69223
|
-
}
|
|
69224
|
-
],
|
|
69225
|
-
clock: deps.clock,
|
|
69226
|
-
log: deps.log
|
|
69227
|
-
});
|
|
69228
|
-
return {
|
|
69229
|
-
checkouts: captured.map((entry) => entry.checkout),
|
|
69230
|
-
lost: lost.signal,
|
|
69231
|
-
failure: () => state.failure,
|
|
69232
|
-
verify: check3,
|
|
69233
|
-
[Symbol.asyncDispose]: async () => {
|
|
69234
|
-
lifetime.abort();
|
|
69235
|
-
await monitor?.[Symbol.asyncDispose]();
|
|
69236
|
-
await releaseAll(locks);
|
|
69237
|
-
}
|
|
69238
|
-
};
|
|
69239
|
-
}
|
|
69240
|
-
|
|
69241
68977
|
// src/holder/admission.ts
|
|
69242
68978
|
var VOLUME_ERRORS = /* @__PURE__ */ new Set([
|
|
69243
68979
|
"EIO",
|
|
@@ -69246,13 +68982,12 @@ var VOLUME_ERRORS = /* @__PURE__ */ new Set([
|
|
|
69246
68982
|
"ENXIO",
|
|
69247
68983
|
"ESTALE"
|
|
69248
68984
|
]);
|
|
69249
|
-
var
|
|
68985
|
+
var MESSAGES = {
|
|
69250
68986
|
missing: "This project folder was moved or removed. Locate it before starting the run.",
|
|
69251
68987
|
permission: "Alan needs permission to access this project folder.",
|
|
69252
68988
|
volume: "The drive containing this project is unavailable. Connect it and try again.",
|
|
69253
68989
|
pinnedMissing: "This run must use exactly this project folder, and it was moved or removed. Restore it or choose another folder.",
|
|
69254
|
-
notApproved: "This folder is not one of the workspaces approved on this computer."
|
|
69255
|
-
mismatch: "This folder belongs to a different repository. Choose the correct project folder and try again."
|
|
68990
|
+
notApproved: "This folder is not one of the workspaces approved on this computer."
|
|
69256
68991
|
};
|
|
69257
68992
|
function rejected(rejection2, message2) {
|
|
69258
68993
|
return { kind: "rejected", rejection: rejection2, message: message2 };
|
|
@@ -69271,7 +69006,7 @@ function volumeRoot(path4) {
|
|
|
69271
69006
|
}
|
|
69272
69007
|
async function exists4(path4) {
|
|
69273
69008
|
try {
|
|
69274
|
-
await (0,
|
|
69009
|
+
await (0, import_promises61.stat)(path4);
|
|
69275
69010
|
return true;
|
|
69276
69011
|
} catch {
|
|
69277
69012
|
return false;
|
|
@@ -69279,30 +69014,23 @@ async function exists4(path4) {
|
|
|
69279
69014
|
}
|
|
69280
69015
|
async function inspectReadiness(path4) {
|
|
69281
69016
|
try {
|
|
69282
|
-
if (!(await (0,
|
|
69283
|
-
return { ready: false, missing: true, message:
|
|
69017
|
+
if (!(await (0, import_promises61.stat)(path4)).isDirectory()) {
|
|
69018
|
+
return { ready: false, missing: true, message: MESSAGES.missing };
|
|
69284
69019
|
}
|
|
69285
|
-
await (0,
|
|
69020
|
+
await (0, import_promises61.access)(path4, import_node_fs19.constants.R_OK | import_node_fs19.constants.W_OK | import_node_fs19.constants.X_OK);
|
|
69286
69021
|
return { ready: true };
|
|
69287
69022
|
} catch (error61) {
|
|
69288
69023
|
const code = errnoCode(error61) ?? "";
|
|
69289
69024
|
if (code === "EACCES" || code === "EPERM") {
|
|
69290
|
-
return { ready: false, missing: false, message:
|
|
69025
|
+
return { ready: false, missing: false, message: MESSAGES.permission };
|
|
69291
69026
|
}
|
|
69292
69027
|
const root = volumeRoot(path4);
|
|
69293
69028
|
if (VOLUME_ERRORS.has(code) || code === "ENOENT" && root !== null && !await exists4(root)) {
|
|
69294
|
-
return { ready: false, missing: false, message:
|
|
69029
|
+
return { ready: false, missing: false, message: MESSAGES.volume };
|
|
69295
69030
|
}
|
|
69296
|
-
return { ready: false, missing: true, message:
|
|
69031
|
+
return { ready: false, missing: true, message: MESSAGES.missing };
|
|
69297
69032
|
}
|
|
69298
69033
|
}
|
|
69299
|
-
function expectedRepositoryUrls(spec, projectPath, platform3) {
|
|
69300
|
-
const folder = comparablePath(projectPath, platform3);
|
|
69301
|
-
return [
|
|
69302
|
-
...(spec.repoLocalPaths ?? []).filter((repo) => comparablePath(repo.localPath, platform3) === folder).map((repo) => repo.repoUrl),
|
|
69303
|
-
...spec.localRepoUrls ?? []
|
|
69304
|
-
];
|
|
69305
|
-
}
|
|
69306
69034
|
function resolveSelectedSkills(spec, context) {
|
|
69307
69035
|
const invocations = spec.skillInvocations ?? [];
|
|
69308
69036
|
if (context.skills === void 0) {
|
|
@@ -69329,51 +69057,18 @@ async function checkProvider(spec, context) {
|
|
|
69329
69057
|
`The ${provider4.name} CLI (\`${provider4.command}\`) is not installed on this computer, or it is not on the PATH Alan uses. Install it and try again.`
|
|
69330
69058
|
);
|
|
69331
69059
|
}
|
|
69332
|
-
async function locateWorkspace(spec, projectPath, expected, context, signal) {
|
|
69333
|
-
const readiness2 = await inspectReadiness(projectPath);
|
|
69334
|
-
if (readiness2.ready) return { cwd: projectPath, relocated: null };
|
|
69335
|
-
if (!readiness2.missing) return rejected("workspace_unavailable", readiness2.message);
|
|
69336
|
-
if (spec.workspacePathPinned === true) {
|
|
69337
|
-
return rejected("workspace_pinned_missing", MESSAGES2.pinnedMissing);
|
|
69338
|
-
}
|
|
69339
|
-
const found = await discoverRelocatedWorkspace({
|
|
69340
|
-
missingPath: projectPath,
|
|
69341
|
-
approvedWorkspacePaths: spec.approvedWorkspacePaths ?? [],
|
|
69342
|
-
expected,
|
|
69343
|
-
git: context.git,
|
|
69344
|
-
platform: context.platform,
|
|
69345
|
-
signal
|
|
69346
|
-
});
|
|
69347
|
-
if (found === null) return rejected("workspace_unavailable", readiness2.message);
|
|
69348
|
-
const moved = await inspectReadiness(found);
|
|
69349
|
-
if (!moved.ready) return rejected("workspace_unavailable", moved.message);
|
|
69350
|
-
return {
|
|
69351
|
-
cwd: found,
|
|
69352
|
-
relocated: {
|
|
69353
|
-
sessionUpdate: "_alan/run.workspace_relocated",
|
|
69354
|
-
previousPath: projectPath,
|
|
69355
|
-
canonicalPath: found
|
|
69356
|
-
}
|
|
69357
|
-
};
|
|
69358
|
-
}
|
|
69359
69060
|
async function admitDefaultWorkspace(spec, context, skills) {
|
|
69360
69061
|
const { env } = context;
|
|
69361
69062
|
const path4 = resolveAlanDefaultWorkspacePath(env.HOME || env.USERPROFILE || (0, import_node_os9.homedir)());
|
|
69362
69063
|
try {
|
|
69363
|
-
await (0,
|
|
69364
|
-
await (0,
|
|
69365
|
-
return {
|
|
69366
|
-
kind: "admitted",
|
|
69367
|
-
spec: { ...spec, projectPath: path4 },
|
|
69368
|
-
relocated: null,
|
|
69369
|
-
leaseTargets: [],
|
|
69370
|
-
skills
|
|
69371
|
-
};
|
|
69064
|
+
await (0, import_promises61.mkdir)(path4, { recursive: true, mode: 448 });
|
|
69065
|
+
await (0, import_promises61.access)(path4, import_node_fs19.constants.R_OK | import_node_fs19.constants.W_OK | import_node_fs19.constants.X_OK);
|
|
69066
|
+
return { kind: "admitted", spec: { ...spec, projectPath: path4 }, skills };
|
|
69372
69067
|
} catch (error61) {
|
|
69373
69068
|
const code = errnoCode(error61);
|
|
69374
69069
|
return rejected(
|
|
69375
69070
|
"workspace_unavailable",
|
|
69376
|
-
code === "EACCES" || code === "EPERM" ?
|
|
69071
|
+
code === "EACCES" || code === "EPERM" ? MESSAGES.permission : MESSAGES.missing
|
|
69377
69072
|
);
|
|
69378
69073
|
}
|
|
69379
69074
|
}
|
|
@@ -69387,7 +69082,7 @@ async function withInstalledCloudSkills(spec, context) {
|
|
|
69387
69082
|
}
|
|
69388
69083
|
};
|
|
69389
69084
|
}
|
|
69390
|
-
async function admitRun(spec, context
|
|
69085
|
+
async function admitRun(spec, context) {
|
|
69391
69086
|
const provider4 = await checkProvider(spec, context);
|
|
69392
69087
|
if (provider4 !== null) return provider4;
|
|
69393
69088
|
const selected = await resolveSelectedSkills(spec, context);
|
|
@@ -69400,50 +69095,30 @@ async function admitRun(spec, context, signal) {
|
|
|
69400
69095
|
const skills = selected.skills;
|
|
69401
69096
|
spec = await withInstalledCloudSkills(spec, context);
|
|
69402
69097
|
const projectPath = spec.projectPath;
|
|
69403
|
-
if (projectPath === void 0) {
|
|
69404
|
-
return { kind: "admitted", spec, relocated: null, leaseTargets: [], skills };
|
|
69405
|
-
}
|
|
69098
|
+
if (projectPath === void 0) return { kind: "admitted", spec, skills };
|
|
69406
69099
|
if (isAlanDefaultWorkspace(projectPath)) return admitDefaultWorkspace(spec, context, skills);
|
|
69407
|
-
const
|
|
69408
|
-
|
|
69409
|
-
|
|
69410
|
-
|
|
69411
|
-
const { cwd, relocated } = located;
|
|
69100
|
+
const readiness2 = await inspectReadiness(projectPath);
|
|
69101
|
+
if (!readiness2.ready) {
|
|
69102
|
+
return readiness2.missing && spec.workspacePathPinned === true ? rejected("workspace_pinned_missing", MESSAGES.pinnedMissing) : rejected("workspace_unavailable", readiness2.message);
|
|
69103
|
+
}
|
|
69412
69104
|
const roots = [
|
|
69413
69105
|
...await context.approvedRoots(),
|
|
69414
69106
|
projectPath,
|
|
69415
69107
|
...spec.approvedWorkspacePaths ?? [],
|
|
69416
|
-
...(spec.repoLocalPaths ?? []).map((repo) => repo.localPath)
|
|
69417
|
-
...relocated === null ? [] : [relocated.canonicalPath]
|
|
69108
|
+
...(spec.repoLocalPaths ?? []).map((repo) => repo.localPath)
|
|
69418
69109
|
];
|
|
69419
|
-
if (!await isApprovedPath(
|
|
69420
|
-
return rejected("workspace_unavailable",
|
|
69421
|
-
}
|
|
69422
|
-
if (expected.size > 0) {
|
|
69423
|
-
const identity = await originIdentity(context.git, cwd, signal);
|
|
69424
|
-
if (identity === null || !expected.has(identity)) {
|
|
69425
|
-
return rejected("workspace_repository_mismatch", MESSAGES2.mismatch);
|
|
69426
|
-
}
|
|
69110
|
+
if (!await isApprovedPath(projectPath, roots, context.platform)) {
|
|
69111
|
+
return rejected("workspace_unavailable", MESSAGES.notApproved);
|
|
69427
69112
|
}
|
|
69428
|
-
return {
|
|
69429
|
-
kind: "admitted",
|
|
69430
|
-
spec: relocated === null ? spec : { ...spec, projectPath: cwd },
|
|
69431
|
-
relocated,
|
|
69432
|
-
leaseTargets: await hasGitMarker(cwd) ? [cwd] : [],
|
|
69433
|
-
skills
|
|
69434
|
-
};
|
|
69113
|
+
return { kind: "admitted", spec, skills };
|
|
69435
69114
|
}
|
|
69436
|
-
var PROBE_TIMEOUT_MS2 = 5e3;
|
|
69437
69115
|
var CHECKOUT_LOCAL_TIMEOUT_MS = 6e4;
|
|
69438
69116
|
var CHECKOUT_NETWORK_TIMEOUT_MS = 12e4;
|
|
69439
69117
|
function createHolderWorkspace(machine, clock, log) {
|
|
69440
69118
|
const platform3 = machine.platform ?? process.platform;
|
|
69441
|
-
const git = createGitRunner({ env: machine.env, platform: platform3, localTimeoutMs: PROBE_TIMEOUT_MS2 });
|
|
69442
|
-
const locks = openRepositoryLocks({ dir: (0, import_node_path62.join)(machine.stateDir, "locks"), clock, platform: platform3 });
|
|
69443
69119
|
return {
|
|
69444
69120
|
admission: {
|
|
69445
69121
|
env: machine.env,
|
|
69446
|
-
git,
|
|
69447
69122
|
platform: platform3,
|
|
69448
69123
|
skills: skillsLayout(
|
|
69449
69124
|
machine.stateDir,
|
|
@@ -69451,14 +69126,13 @@ function createHolderWorkspace(machine, clock, log) {
|
|
|
69451
69126
|
),
|
|
69452
69127
|
approvedRoots: async () => {
|
|
69453
69128
|
const approved = await openApprovedPaths({
|
|
69454
|
-
file: (0,
|
|
69129
|
+
file: (0, import_node_path60.join)(machine.stateDir, "workspaces.json"),
|
|
69455
69130
|
log,
|
|
69456
69131
|
platform: platform3
|
|
69457
69132
|
});
|
|
69458
69133
|
return approved.roots();
|
|
69459
69134
|
}
|
|
69460
69135
|
},
|
|
69461
|
-
lease: { git, locks, clock, log, platform: platform3 },
|
|
69462
69136
|
...machine.refreshesFirstCheckout === true ? {
|
|
69463
69137
|
refreshFirstCheckout: createCheckoutRefresh({
|
|
69464
69138
|
git: createGitRunner({
|
|
@@ -69467,12 +69141,12 @@ function createHolderWorkspace(machine, clock, log) {
|
|
|
69467
69141
|
localTimeoutMs: CHECKOUT_LOCAL_TIMEOUT_MS,
|
|
69468
69142
|
networkTimeoutMs: CHECKOUT_NETWORK_TIMEOUT_MS
|
|
69469
69143
|
}),
|
|
69470
|
-
locks,
|
|
69144
|
+
locks: openRepositoryLocks({ dir: (0, import_node_path60.join)(machine.stateDir, "locks"), clock, platform: platform3 }),
|
|
69471
69145
|
log,
|
|
69472
|
-
dir: (0,
|
|
69146
|
+
dir: (0, import_node_path60.join)(machine.stateDir, "checkout-freshness")
|
|
69473
69147
|
}),
|
|
69474
69148
|
prepareAgentContext: createAgentContext({
|
|
69475
|
-
dir: (0,
|
|
69149
|
+
dir: (0, import_node_path60.join)(machine.stateDir, "agent-context"),
|
|
69476
69150
|
homeDir: machine.env.HOME || (0, import_node_os9.homedir)()
|
|
69477
69151
|
})
|
|
69478
69152
|
} : {}
|
|
@@ -69480,28 +69154,14 @@ function createHolderWorkspace(machine, clock, log) {
|
|
|
69480
69154
|
}
|
|
69481
69155
|
|
|
69482
69156
|
// src/holder/respond.ts
|
|
69483
|
-
function
|
|
69484
|
-
const state = { lease: null };
|
|
69485
|
-
return {
|
|
69486
|
-
allows: () => state.lease?.verify() ?? Promise.resolve(true),
|
|
69487
|
-
guard: (lease) => {
|
|
69488
|
-
state.lease = lease;
|
|
69489
|
-
return {
|
|
69490
|
-
[Symbol.dispose]: () => {
|
|
69491
|
-
if (state.lease === lease) state.lease = null;
|
|
69492
|
-
}
|
|
69493
|
-
};
|
|
69494
|
-
}
|
|
69495
|
-
};
|
|
69496
|
-
}
|
|
69497
|
-
async function respondToTurn(runningRunId, gate, driver, request2) {
|
|
69157
|
+
async function respondToTurn(runningRunId, driver, request2) {
|
|
69498
69158
|
if (runningRunId !== request2.runId) return "unknown_run";
|
|
69499
69159
|
if (driver.respond === void 0) return "not_waiting";
|
|
69500
|
-
return driver.respond(request2
|
|
69160
|
+
return driver.respond(request2);
|
|
69501
69161
|
}
|
|
69502
69162
|
|
|
69503
69163
|
// src/holder/session-facts.ts
|
|
69504
|
-
var
|
|
69164
|
+
var import_promises62 = require("fs/promises");
|
|
69505
69165
|
var CLI_RSS_CACHE_MS = 1e4;
|
|
69506
69166
|
var LOGIN_PROBLEM_PREFIX = "cli.auth.";
|
|
69507
69167
|
function isLoginFailure(result) {
|
|
@@ -69527,8 +69187,8 @@ function createSessionFacts(options) {
|
|
|
69527
69187
|
const path4 = await resolveCommandOnPath(command, env, platform3);
|
|
69528
69188
|
if (path4 === null) return null;
|
|
69529
69189
|
try {
|
|
69530
|
-
const real = await (0,
|
|
69531
|
-
const info = await (0,
|
|
69190
|
+
const real = await (0, import_promises62.realpath)(path4);
|
|
69191
|
+
const info = await (0, import_promises62.stat)(real);
|
|
69532
69192
|
return { command, key: `${real}:${info.ino}:${info.size}:${info.mtimeMs}` };
|
|
69533
69193
|
} catch {
|
|
69534
69194
|
return null;
|
|
@@ -69615,12 +69275,12 @@ function createSessionFacts(options) {
|
|
|
69615
69275
|
init_acp2();
|
|
69616
69276
|
|
|
69617
69277
|
// src/run-log/archive.ts
|
|
69618
|
-
var
|
|
69619
|
-
var
|
|
69278
|
+
var import_promises63 = require("fs/promises");
|
|
69279
|
+
var import_node_path61 = require("path");
|
|
69620
69280
|
init_runtime_v2();
|
|
69621
69281
|
async function openRunArchive(runsDir) {
|
|
69622
|
-
const path4 = (0,
|
|
69623
|
-
const text3 = await (0,
|
|
69282
|
+
const path4 = (0, import_node_path61.join)((0, import_node_path61.dirname)(runsDir), "archived-runs.txt");
|
|
69283
|
+
const text3 = await (0, import_promises63.readFile)(path4, "utf8").catch((error61) => {
|
|
69624
69284
|
if (errnoCode(error61) === "ENOENT") return "";
|
|
69625
69285
|
throw error61;
|
|
69626
69286
|
});
|
|
@@ -69634,7 +69294,7 @@ async function openRunArchive(runsDir) {
|
|
|
69634
69294
|
add: async (runIds) => {
|
|
69635
69295
|
const added = runIds.filter((runId) => !archived.has(runId));
|
|
69636
69296
|
if (added.length === 0) return;
|
|
69637
|
-
await (0,
|
|
69297
|
+
await (0, import_promises63.appendFile)(path4, `
|
|
69638
69298
|
${added.join("\n")}
|
|
69639
69299
|
`, { mode: 384 });
|
|
69640
69300
|
for (const runId of added) archived.add(runId);
|
|
@@ -69645,11 +69305,11 @@ ${added.join("\n")}
|
|
|
69645
69305
|
// src/run-log/complete.ts
|
|
69646
69306
|
var import_node_crypto29 = require("crypto");
|
|
69647
69307
|
var import_node_fs20 = require("fs");
|
|
69648
|
-
var
|
|
69308
|
+
var import_node_path63 = require("path");
|
|
69649
69309
|
|
|
69650
69310
|
// src/run-log/directory.ts
|
|
69651
|
-
var
|
|
69652
|
-
var
|
|
69311
|
+
var import_promises64 = require("fs/promises");
|
|
69312
|
+
var import_node_path62 = require("path");
|
|
69653
69313
|
init_runtime_v2();
|
|
69654
69314
|
init_zod();
|
|
69655
69315
|
var runMetaSchema = external_exports.object({
|
|
@@ -69675,17 +69335,17 @@ async function readRunMeta(path4) {
|
|
|
69675
69335
|
return read.kind === "ok" ? read.value : null;
|
|
69676
69336
|
}
|
|
69677
69337
|
function runDirectory(runsDir, runId) {
|
|
69678
|
-
const dir = (0,
|
|
69338
|
+
const dir = (0, import_node_path62.join)(runsDir, runId);
|
|
69679
69339
|
return {
|
|
69680
69340
|
dir,
|
|
69681
|
-
log: (0,
|
|
69682
|
-
upload: (0,
|
|
69683
|
-
meta: (0,
|
|
69341
|
+
log: (0, import_node_path62.join)(dir, "log.jsonl"),
|
|
69342
|
+
upload: (0, import_node_path62.join)(dir, "upload.json"),
|
|
69343
|
+
meta: (0, import_node_path62.join)(dir, "run.json")
|
|
69684
69344
|
};
|
|
69685
69345
|
}
|
|
69686
69346
|
async function isRunClaimed(runsDir, runId) {
|
|
69687
69347
|
try {
|
|
69688
|
-
return (await (0,
|
|
69348
|
+
return (await (0, import_promises64.stat)(runDirectory(runsDir, runId).log)).size > 0;
|
|
69689
69349
|
} catch (error61) {
|
|
69690
69350
|
if (errnoCode(error61) === "ENOENT") return false;
|
|
69691
69351
|
throw error61;
|
|
@@ -69694,7 +69354,7 @@ async function isRunClaimed(runsDir, runId) {
|
|
|
69694
69354
|
|
|
69695
69355
|
// src/run-log/complete.ts
|
|
69696
69356
|
function writeLogFile(path4, dir, text3) {
|
|
69697
|
-
const temp = (0,
|
|
69357
|
+
const temp = (0, import_node_path63.join)(dir, `.log.${(0, import_node_crypto29.randomUUID)()}.tmp`);
|
|
69698
69358
|
const fd = (0, import_node_fs20.openSync)(temp, "wx", 384);
|
|
69699
69359
|
try {
|
|
69700
69360
|
(0, import_node_fs20.writeSync)(fd, text3);
|
|
@@ -69723,8 +69383,8 @@ async function writeCompleteRunLog(runsDir, meta3, records) {
|
|
|
69723
69383
|
}
|
|
69724
69384
|
|
|
69725
69385
|
// src/run-log/conversation-index.ts
|
|
69726
|
-
var
|
|
69727
|
-
var
|
|
69386
|
+
var import_promises65 = require("fs/promises");
|
|
69387
|
+
var import_node_path64 = require("path");
|
|
69728
69388
|
init_runtime_v2();
|
|
69729
69389
|
init_zod();
|
|
69730
69390
|
var ORDINALS_PER_SHARD = 1e3;
|
|
@@ -69741,13 +69401,13 @@ var coverageSchema = external_exports.object({
|
|
|
69741
69401
|
nextExpectedOrdinal: external_exports.number().int().positive()
|
|
69742
69402
|
});
|
|
69743
69403
|
function conversationsDirectory(runsDir) {
|
|
69744
|
-
return (0,
|
|
69404
|
+
return (0, import_node_path64.join)((0, import_node_path64.dirname)(runsDir), "conversations");
|
|
69745
69405
|
}
|
|
69746
69406
|
function indexDirectory(runsDir, conversationId) {
|
|
69747
|
-
return (0,
|
|
69407
|
+
return (0, import_node_path64.join)(conversationsDirectory(runsDir), conversationId, "turn-index");
|
|
69748
69408
|
}
|
|
69749
69409
|
function shardPath(runsDir, conversationId, ordinal) {
|
|
69750
|
-
return (0,
|
|
69410
|
+
return (0, import_node_path64.join)(
|
|
69751
69411
|
indexDirectory(runsDir, conversationId),
|
|
69752
69412
|
`${Math.floor(ordinal / ORDINALS_PER_SHARD)}.jsonl`
|
|
69753
69413
|
);
|
|
@@ -69756,10 +69416,10 @@ async function indexConversationRun(runsDir, conversationId, ordinal, assistantO
|
|
|
69756
69416
|
const nextOrdinal = assistantOrdinal + 1;
|
|
69757
69417
|
if (nextOrdinal <= ordinal) throw new Error("Assistant order must follow the prompt");
|
|
69758
69418
|
const path4 = shardPath(runsDir, conversationId, ordinal);
|
|
69759
|
-
await (0,
|
|
69760
|
-
await (0,
|
|
69419
|
+
await (0, import_promises65.mkdir)((0, import_node_path64.dirname)(path4), { recursive: true, mode: 448 });
|
|
69420
|
+
await (0, import_promises65.appendFile)(path4, `${JSON.stringify({ ordinal, nextOrdinal, runId })}
|
|
69761
69421
|
`, { mode: 384 });
|
|
69762
|
-
const coveragePath = (0,
|
|
69422
|
+
const coveragePath = (0, import_node_path64.join)((0, import_node_path64.dirname)((0, import_node_path64.dirname)(path4)), "coverage.json");
|
|
69763
69423
|
const coverage = await readJsonFile(coveragePath, coverageSchema);
|
|
69764
69424
|
const current = coverage.kind === "ok" ? coverage.value : null;
|
|
69765
69425
|
const next = nextCoverage(current, ordinal, nextOrdinal);
|
|
@@ -69774,13 +69434,13 @@ function nextCoverage(current, ordinal, nextOrdinal) {
|
|
|
69774
69434
|
return null;
|
|
69775
69435
|
}
|
|
69776
69436
|
async function readConversationIndexCoverage(runsDir, conversationId) {
|
|
69777
|
-
const path4 = (0,
|
|
69437
|
+
const path4 = (0, import_node_path64.join)((0, import_node_path64.dirname)(indexDirectory(runsDir, conversationId)), "coverage.json");
|
|
69778
69438
|
const result = await readJsonFile(path4, coverageSchema);
|
|
69779
69439
|
return result.kind === "ok" ? result.value : null;
|
|
69780
69440
|
}
|
|
69781
69441
|
async function readConversationRunIndex(runsDir, conversationId, before, limit) {
|
|
69782
69442
|
const directory = indexDirectory(runsDir, conversationId);
|
|
69783
|
-
const names = await (0,
|
|
69443
|
+
const names = await (0, import_promises65.readdir)(directory).catch((error61) => {
|
|
69784
69444
|
if (error61.code === "ENOENT") return [];
|
|
69785
69445
|
throw error61;
|
|
69786
69446
|
});
|
|
@@ -69789,7 +69449,7 @@ async function readConversationRunIndex(runsDir, conversationId, before, limit)
|
|
|
69789
69449
|
).sort((left, right) => right - left);
|
|
69790
69450
|
const selected = [];
|
|
69791
69451
|
for (const shard of shards) {
|
|
69792
|
-
const text3 = await (0,
|
|
69452
|
+
const text3 = await (0, import_promises65.readFile)((0, import_node_path64.join)(directory, `${shard}.jsonl`), "utf8");
|
|
69793
69453
|
const records = text3.split("\n").flatMap((line) => {
|
|
69794
69454
|
if (!line) return [];
|
|
69795
69455
|
const parsed = indexRecordSchema.parse(JSON.parse(line));
|
|
@@ -69814,7 +69474,7 @@ async function readIndexableRun(runsDir, name) {
|
|
|
69814
69474
|
return { conversationId: meta3.conversationId, ordinal, assistantOrdinal, runId: runId.data };
|
|
69815
69475
|
}
|
|
69816
69476
|
async function readIndexableRuns(runsDir) {
|
|
69817
|
-
const names = await (0,
|
|
69477
|
+
const names = await (0, import_promises65.readdir)(runsDir).catch(() => []);
|
|
69818
69478
|
const byConversation = /* @__PURE__ */ new Map();
|
|
69819
69479
|
let next = 0;
|
|
69820
69480
|
const worker = async () => {
|
|
@@ -69844,21 +69504,21 @@ async function writeConversationIndex(directory, runs) {
|
|
|
69844
69504
|
else lines2.push(line);
|
|
69845
69505
|
coverage = nextCoverage(coverage, run2.ordinal, nextOrdinal) ?? coverage;
|
|
69846
69506
|
}
|
|
69847
|
-
await (0,
|
|
69507
|
+
await (0, import_promises65.mkdir)((0, import_node_path64.join)(directory, "turn-index"), { recursive: true, mode: 448 });
|
|
69848
69508
|
for (const [shard, lines2] of shards) {
|
|
69849
|
-
await (0,
|
|
69509
|
+
await (0, import_promises65.writeFile)((0, import_node_path64.join)(directory, "turn-index", `${shard}.jsonl`), `${lines2.join("\n")}
|
|
69850
69510
|
`, {
|
|
69851
69511
|
mode: 384
|
|
69852
69512
|
});
|
|
69853
69513
|
}
|
|
69854
|
-
await (0,
|
|
69514
|
+
await (0, import_promises65.writeFile)((0, import_node_path64.join)(directory, "coverage.json"), `${JSON.stringify(coverage)}
|
|
69855
69515
|
`, {
|
|
69856
69516
|
mode: 384
|
|
69857
69517
|
});
|
|
69858
69518
|
}
|
|
69859
69519
|
async function rebuildConversationIndexes(runsDir) {
|
|
69860
69520
|
const root = conversationsDirectory(runsDir);
|
|
69861
|
-
const exists6 = await (0,
|
|
69521
|
+
const exists6 = await (0, import_promises65.stat)(root).then(
|
|
69862
69522
|
() => true,
|
|
69863
69523
|
(error61) => {
|
|
69864
69524
|
if (errnoCode(error61) === "ENOENT") return false;
|
|
@@ -69867,18 +69527,18 @@ async function rebuildConversationIndexes(runsDir) {
|
|
|
69867
69527
|
);
|
|
69868
69528
|
if (exists6) return 0;
|
|
69869
69529
|
const building = `${root}.rebuilding`;
|
|
69870
|
-
await (0,
|
|
69871
|
-
await (0,
|
|
69530
|
+
await (0, import_promises65.rm)(building, { recursive: true, force: true });
|
|
69531
|
+
await (0, import_promises65.mkdir)(building, { recursive: true, mode: 448 });
|
|
69872
69532
|
const byConversation = await readIndexableRuns(runsDir);
|
|
69873
69533
|
for (const [conversationId, runs] of byConversation) {
|
|
69874
|
-
await writeConversationIndex((0,
|
|
69534
|
+
await writeConversationIndex((0, import_node_path64.join)(building, conversationId), runs);
|
|
69875
69535
|
}
|
|
69876
|
-
await (0,
|
|
69536
|
+
await (0, import_promises65.rename)(building, root);
|
|
69877
69537
|
return byConversation.size;
|
|
69878
69538
|
}
|
|
69879
69539
|
|
|
69880
69540
|
// src/run-log/reader.ts
|
|
69881
|
-
var
|
|
69541
|
+
var import_promises66 = require("fs/promises");
|
|
69882
69542
|
init_runtime_v2();
|
|
69883
69543
|
|
|
69884
69544
|
// src/run-log/tail.ts
|
|
@@ -69901,7 +69561,7 @@ function firstRecordLength(bytes) {
|
|
|
69901
69561
|
return bytes.indexOf(RUN_LOG_RECORD_SEPARATOR) + 1;
|
|
69902
69562
|
}
|
|
69903
69563
|
async function openRunLogReader(path4) {
|
|
69904
|
-
const handle = await (0,
|
|
69564
|
+
const handle = await (0, import_promises66.open)(path4, "r");
|
|
69905
69565
|
const readAt = async (position, length) => {
|
|
69906
69566
|
const buffer = Buffer.alloc(length);
|
|
69907
69567
|
const { bytesRead } = await handle.read(buffer, 0, length, position);
|
|
@@ -69935,7 +69595,7 @@ async function openRunLogReader(path4) {
|
|
|
69935
69595
|
};
|
|
69936
69596
|
}
|
|
69937
69597
|
async function readLastRecord(path4) {
|
|
69938
|
-
const handle = await (0,
|
|
69598
|
+
const handle = await (0, import_promises66.open)(path4, "r").catch(() => null);
|
|
69939
69599
|
if (handle === null) return null;
|
|
69940
69600
|
try {
|
|
69941
69601
|
const { size } = await handle.stat();
|
|
@@ -69969,7 +69629,7 @@ var decoder = new TextDecoder();
|
|
|
69969
69629
|
|
|
69970
69630
|
// src/run-log/writer.ts
|
|
69971
69631
|
var import_node_fs21 = require("fs");
|
|
69972
|
-
var
|
|
69632
|
+
var import_node_path65 = require("path");
|
|
69973
69633
|
init_runtime_v2();
|
|
69974
69634
|
function lastSeq(fd, size) {
|
|
69975
69635
|
for (const length of tailWindows(size)) {
|
|
@@ -69985,7 +69645,7 @@ function lastSeq(fd, size) {
|
|
|
69985
69645
|
throw new RuntimeFault("record_too_large", "Run log tail record is larger than any record");
|
|
69986
69646
|
}
|
|
69987
69647
|
function openRunLog(path4, clock) {
|
|
69988
|
-
(0, import_node_fs21.mkdirSync)((0,
|
|
69648
|
+
(0, import_node_fs21.mkdirSync)((0, import_node_path65.dirname)(path4), { recursive: true, mode: 448 });
|
|
69989
69649
|
const fd = (0, import_node_fs21.openSync)(path4, "a+", 384);
|
|
69990
69650
|
let size = (0, import_node_fs21.fstatSync)(fd).size;
|
|
69991
69651
|
let seq = lastSeq(fd, size);
|
|
@@ -70022,107 +69682,6 @@ function openRunLog(path4, clock) {
|
|
|
70022
69682
|
};
|
|
70023
69683
|
}
|
|
70024
69684
|
|
|
70025
|
-
// src/holder/lease-gate.ts
|
|
70026
|
-
init_acp();
|
|
70027
|
-
var READ_ONLY_TOOL_KINDS = /* @__PURE__ */ new Set([
|
|
70028
|
-
"read",
|
|
70029
|
-
"search",
|
|
70030
|
-
"think",
|
|
70031
|
-
"fetch",
|
|
70032
|
-
"switch_mode"
|
|
70033
|
-
]);
|
|
70034
|
-
function gateWorkspaceWrites(sink, lease) {
|
|
70035
|
-
const kinds = /* @__PURE__ */ new Map();
|
|
70036
|
-
const state = { tail: Promise.resolve(), pending: 0, gate: null, blocked: 0 };
|
|
70037
|
-
const writesFiles = (update) => {
|
|
70038
|
-
if (!isUpdate(update, "tool_call_update")) return false;
|
|
70039
|
-
if (typeof update.kind === "string") kinds.set(update.toolCallId, update.kind);
|
|
70040
|
-
const kind = kinds.get(update.toolCallId);
|
|
70041
|
-
return kind === void 0 || !READ_ONLY_TOOL_KINDS.has(kind);
|
|
70042
|
-
};
|
|
70043
|
-
const deliver = (event) => {
|
|
70044
|
-
if (lease.failure() === null) {
|
|
70045
|
-
sink.onEvent(event);
|
|
70046
|
-
return;
|
|
70047
|
-
}
|
|
70048
|
-
if (event.update.sessionUpdate === "tool_call_update") state.blocked += 1;
|
|
70049
|
-
};
|
|
70050
|
-
const enqueue = (event, gate) => {
|
|
70051
|
-
state.pending += 1;
|
|
70052
|
-
state.tail = state.tail.then(async () => {
|
|
70053
|
-
if (gate === null || await gate) deliver(event);
|
|
70054
|
-
else if (event.update.sessionUpdate === "tool_call_update") state.blocked += 1;
|
|
70055
|
-
}).finally(() => {
|
|
70056
|
-
state.pending -= 1;
|
|
70057
|
-
if (state.pending === 0) state.gate = null;
|
|
70058
|
-
});
|
|
70059
|
-
};
|
|
70060
|
-
return {
|
|
70061
|
-
onSpawned: (pid) => sink.onSpawned(pid),
|
|
70062
|
-
onEvent: (event) => {
|
|
70063
|
-
const write = writesFiles(event.update);
|
|
70064
|
-
if (!write && state.pending === 0) {
|
|
70065
|
-
deliver(event);
|
|
70066
|
-
return;
|
|
70067
|
-
}
|
|
70068
|
-
if (write) state.gate ??= lease.verify();
|
|
70069
|
-
enqueue(event, state.gate);
|
|
70070
|
-
},
|
|
70071
|
-
drain: async () => {
|
|
70072
|
-
while (state.pending > 0) await state.tail;
|
|
70073
|
-
},
|
|
70074
|
-
blocked: () => state.blocked
|
|
70075
|
-
};
|
|
70076
|
-
}
|
|
70077
|
-
|
|
70078
|
-
// src/holder/lease-turn.ts
|
|
70079
|
-
function leaseNotice(failure6, blocked) {
|
|
70080
|
-
const withheld = blocked === 0 ? "" : ` ${blocked} tool ${blocked === 1 ? "update was" : "updates were"} withheld.`;
|
|
70081
|
-
return {
|
|
70082
|
-
sessionUpdate: "notice",
|
|
70083
|
-
severity: "error",
|
|
70084
|
-
title: "The workspace changed while the agent was working",
|
|
70085
|
-
description: `${failure6.message}${withheld}`,
|
|
70086
|
-
_meta: {
|
|
70087
|
-
"alan.dev/noticeKind": "workspace_lease_lost",
|
|
70088
|
-
...failure6.problemCode === null ? {} : { "alan.dev/problem": { domain: "application", code: failure6.problemCode } }
|
|
70089
|
-
}
|
|
70090
|
-
};
|
|
70091
|
-
}
|
|
70092
|
-
async function runLeased(spec, paths, turn, sink, signal, run2) {
|
|
70093
|
-
var _stack = [];
|
|
70094
|
-
try {
|
|
70095
|
-
const capture = await captureWorkspaceLease(spec.runId, paths, turn.lease, signal);
|
|
70096
|
-
if (capture.kind === "failed") {
|
|
70097
|
-
turn.log.warn("holder.workspace_lease_refused", {
|
|
70098
|
-
runId: spec.runId,
|
|
70099
|
-
code: capture.failure.code
|
|
70100
|
-
});
|
|
70101
|
-
return { outcome: "failed", message: capture.failure.message };
|
|
70102
|
-
}
|
|
70103
|
-
const lease = __using(_stack, capture.lease, true);
|
|
70104
|
-
const _answers = __using(_stack, turn.answerGate?.guard(lease));
|
|
70105
|
-
turn.log.info("holder.workspace_leased", { runId: spec.runId, checkouts: lease.checkouts });
|
|
70106
|
-
const gated = gateWorkspaceWrites(sink, lease);
|
|
70107
|
-
const result = await run2(gated, AbortSignal.any([signal, lease.lost]));
|
|
70108
|
-
await gated.drain();
|
|
70109
|
-
const failure6 = lease.failure();
|
|
70110
|
-
if (failure6 === null) return result;
|
|
70111
|
-
sink.onEvent({ seq: 0, at: turn.clock.now(), update: leaseNotice(failure6, gated.blocked()) });
|
|
70112
|
-
await turn.driver.suspend?.().catch((error61) => turn.log.warn("holder.driver_suspend_failed", { error: error61 }));
|
|
70113
|
-
return {
|
|
70114
|
-
outcome: "failed",
|
|
70115
|
-
message: failure6.message,
|
|
70116
|
-
...result.providerSessionId === void 0 ? {} : { providerSessionId: result.providerSessionId }
|
|
70117
|
-
};
|
|
70118
|
-
} catch (_) {
|
|
70119
|
-
var _error = _, _hasError = true;
|
|
70120
|
-
} finally {
|
|
70121
|
-
var _promise2 = __callDispose(_stack, _error, _hasError);
|
|
70122
|
-
_promise2 && await _promise2;
|
|
70123
|
-
}
|
|
70124
|
-
}
|
|
70125
|
-
|
|
70126
69685
|
// src/holder/record-fit.ts
|
|
70127
69686
|
init_acp2();
|
|
70128
69687
|
init_runtime_v2();
|
|
@@ -70160,11 +69719,11 @@ function fitForRunLog(update) {
|
|
|
70160
69719
|
}
|
|
70161
69720
|
|
|
70162
69721
|
// src/holder/turn.ts
|
|
70163
|
-
async function runWithInputs({ spec,
|
|
69722
|
+
async function runWithInputs({ spec, skills }, context, sink, signal) {
|
|
70164
69723
|
var _stack = [];
|
|
70165
69724
|
try {
|
|
70166
69725
|
const workspace = context.workspace;
|
|
70167
|
-
const sessionContext = (workspace?.refreshFirstCheckout?.(spec,
|
|
69726
|
+
const sessionContext = (workspace?.refreshFirstCheckout?.(spec, signal) ?? Promise.resolve([])).catch((error61) => {
|
|
70168
69727
|
context.log.warn("workspace.refresh_failed", { runId: spec.runId, error: error61 });
|
|
70169
69728
|
return [];
|
|
70170
69729
|
}).then((problems) => workspace?.prepareAgentContext?.(spec, problems)).catch((error61) => {
|
|
@@ -70183,35 +69742,24 @@ async function runWithInputs({ spec, leaseTargets, skills }, context, sink, sign
|
|
|
70183
69742
|
}
|
|
70184
69743
|
const agentContext = await sessionContext;
|
|
70185
69744
|
const prepared = __using(_stack, inputs, true);
|
|
70186
|
-
const
|
|
70187
|
-
const result = await context.driver.runTurn(
|
|
70188
|
-
spec,
|
|
70189
|
-
turnSink,
|
|
70190
|
-
turnSignal,
|
|
70191
|
-
agentContext === void 0 ? prepared : {
|
|
70192
|
-
...prepared,
|
|
70193
|
-
agentContext: {
|
|
70194
|
-
full: agentContext.full,
|
|
70195
|
-
...agentContext.update ? { update: agentContext.update } : {}
|
|
70196
|
-
}
|
|
70197
|
-
}
|
|
70198
|
-
);
|
|
70199
|
-
if (agentContext !== void 0 && result.outcome !== "rejected") {
|
|
70200
|
-
await agentContext.save().catch((error61) => {
|
|
70201
|
-
context.log.warn("holder.agent_context_save_failed", { runId: spec.runId, error: error61 });
|
|
70202
|
-
});
|
|
70203
|
-
}
|
|
70204
|
-
return result;
|
|
70205
|
-
};
|
|
70206
|
-
if (workspace === void 0) return await run2(sink, signal);
|
|
70207
|
-
return await runLeased(
|
|
69745
|
+
const result = await context.driver.runTurn(
|
|
70208
69746
|
spec,
|
|
70209
|
-
leaseTargets,
|
|
70210
|
-
{ ...context, lease: workspace.lease },
|
|
70211
69747
|
sink,
|
|
70212
69748
|
signal,
|
|
70213
|
-
|
|
69749
|
+
agentContext === void 0 ? prepared : {
|
|
69750
|
+
...prepared,
|
|
69751
|
+
agentContext: {
|
|
69752
|
+
full: agentContext.full,
|
|
69753
|
+
...agentContext.update ? { update: agentContext.update } : {}
|
|
69754
|
+
}
|
|
69755
|
+
}
|
|
70214
69756
|
);
|
|
69757
|
+
if (agentContext !== void 0 && result.outcome !== "rejected") {
|
|
69758
|
+
await agentContext.save().catch((error61) => {
|
|
69759
|
+
context.log.warn("holder.agent_context_save_failed", { runId: spec.runId, error: error61 });
|
|
69760
|
+
});
|
|
69761
|
+
}
|
|
69762
|
+
return result;
|
|
70215
69763
|
} catch (_) {
|
|
70216
69764
|
var _error = _, _hasError = true;
|
|
70217
69765
|
} finally {
|
|
@@ -70219,7 +69767,7 @@ async function runWithInputs({ spec, leaseTargets, skills }, context, sink, sign
|
|
|
70219
69767
|
_promise2 && await _promise2;
|
|
70220
69768
|
}
|
|
70221
69769
|
}
|
|
70222
|
-
async function admitAndRun(spec, context,
|
|
69770
|
+
async function admitAndRun(spec, context, sink, signal) {
|
|
70223
69771
|
if (context.workspace === void 0) {
|
|
70224
69772
|
if (spec.skillInvocations?.length) {
|
|
70225
69773
|
return {
|
|
@@ -70228,14 +69776,13 @@ async function admitAndRun(spec, context, append, sink, signal) {
|
|
|
70228
69776
|
message: "Selected skills need this computer's skill sync, which this holder does not have."
|
|
70229
69777
|
};
|
|
70230
69778
|
}
|
|
70231
|
-
return runWithInputs({ spec,
|
|
69779
|
+
return runWithInputs({ spec, skills: [] }, context, sink, signal);
|
|
70232
69780
|
}
|
|
70233
|
-
const admission = await admitRun(spec, context.workspace.admission
|
|
69781
|
+
const admission = await admitRun(spec, context.workspace.admission);
|
|
70234
69782
|
if (admission.kind === "rejected") {
|
|
70235
69783
|
context.log.info("holder.run_rejected", { runId: spec.runId, rejection: admission.rejection });
|
|
70236
69784
|
return { outcome: "rejected", rejection: admission.rejection, message: admission.message };
|
|
70237
69785
|
}
|
|
70238
|
-
if (admission.relocated !== null) append(admission.relocated);
|
|
70239
69786
|
return runWithInputs(admission, context, sink, signal);
|
|
70240
69787
|
}
|
|
70241
69788
|
async function claimRun(spec, context) {
|
|
@@ -70282,7 +69829,6 @@ async function runClaimedTurn(spec, claimed, context, signal) {
|
|
|
70282
69829
|
result = await admitAndRun(
|
|
70283
69830
|
spec,
|
|
70284
69831
|
context,
|
|
70285
|
-
append,
|
|
70286
69832
|
{
|
|
70287
69833
|
onSpawned: (pid) => append(runStarted({ pid })),
|
|
70288
69834
|
// Base64 media in provider payloads and tool output never reaches the log (main 13590db369).
|
|
@@ -70345,12 +69891,11 @@ async function runHolder({
|
|
|
70345
69891
|
try {
|
|
70346
69892
|
const identity = await readProcessIdentity(process.pid);
|
|
70347
69893
|
if (identity === null) throw new RuntimeFault("internal", "Cannot read own process identity");
|
|
70348
|
-
const _engines = __using(_stack, recordSpawnedEngines(engineRecordsPath((0,
|
|
69894
|
+
const _engines = __using(_stack, recordSpawnedEngines(engineRecordsPath((0, import_node_path66.dirname)(launch.statusPath)), clock, log));
|
|
70349
69895
|
const holder = {
|
|
70350
69896
|
state: "idle",
|
|
70351
69897
|
runId: null,
|
|
70352
69898
|
turn: null,
|
|
70353
|
-
answerGate: createAnswerGate(),
|
|
70354
69899
|
clients: /* @__PURE__ */ new Set()
|
|
70355
69900
|
};
|
|
70356
69901
|
const exit = new AbortController();
|
|
@@ -70408,8 +69953,7 @@ async function runHolder({
|
|
|
70408
69953
|
log,
|
|
70409
69954
|
onAppended: (runId, offset) => broadcast({ type: "appended", runId, offset }),
|
|
70410
69955
|
...inputs === void 0 ? {} : { inputs },
|
|
70411
|
-
...workspace === void 0 ? {} : { workspace }
|
|
70412
|
-
answerGate: holder.answerGate
|
|
69956
|
+
...workspace === void 0 ? {} : { workspace }
|
|
70413
69957
|
};
|
|
70414
69958
|
claimRun(spec, context).then(
|
|
70415
69959
|
(claimed) => {
|
|
@@ -70441,7 +69985,7 @@ async function runHolder({
|
|
|
70441
69985
|
);
|
|
70442
69986
|
};
|
|
70443
69987
|
const respond = (request2, client) => {
|
|
70444
|
-
respondToTurn(holder.runId,
|
|
69988
|
+
respondToTurn(holder.runId, driver, request2).then((status) => {
|
|
70445
69989
|
log.info("holder.responded", { runId: request2.runId, status });
|
|
70446
69990
|
writeMessage(client, { type: "responded", id: request2.id, status });
|
|
70447
69991
|
}).catch((error61) => {
|
|
@@ -70487,12 +70031,12 @@ async function runHolder({
|
|
|
70487
70031
|
return;
|
|
70488
70032
|
case "status":
|
|
70489
70033
|
void facts.snapshot().then(
|
|
70490
|
-
(
|
|
70034
|
+
(snapshot) => writeMessage(client, {
|
|
70491
70035
|
type: "status",
|
|
70492
70036
|
id: request2.id,
|
|
70493
70037
|
state: holder.state,
|
|
70494
70038
|
runId: holder.runId,
|
|
70495
|
-
facts:
|
|
70039
|
+
facts: snapshot
|
|
70496
70040
|
})
|
|
70497
70041
|
);
|
|
70498
70042
|
return;
|
|
@@ -70541,16 +70085,16 @@ async function runHolder({
|
|
|
70541
70085
|
client.on("error", () => holder.clients.delete(client));
|
|
70542
70086
|
});
|
|
70543
70087
|
removeStaleEndpoint(launch.endpoint);
|
|
70544
|
-
await new Promise((
|
|
70088
|
+
await new Promise((resolve13, reject) => {
|
|
70545
70089
|
server.once("error", reject);
|
|
70546
|
-
server.listen(launch.endpoint, () =>
|
|
70090
|
+
server.listen(launch.endpoint, () => resolve13());
|
|
70547
70091
|
});
|
|
70548
70092
|
await writeStatus();
|
|
70549
70093
|
log.info("holder.ready", { conversationId: launch.conversationId, pid: identity.pid });
|
|
70550
|
-
await new Promise((
|
|
70094
|
+
await new Promise((resolve13) => exit.signal.addEventListener("abort", () => resolve13()));
|
|
70551
70095
|
await driver.suspend?.().catch((error61) => log.warn("holder.driver_suspend_failed", { error: error61 }));
|
|
70552
70096
|
for (const client of holder.clients) client.end();
|
|
70553
|
-
await new Promise((
|
|
70097
|
+
await new Promise((resolve13) => server.close(() => resolve13()));
|
|
70554
70098
|
(0, import_node_fs22.rmSync)(launch.statusPath, { force: true });
|
|
70555
70099
|
log.info("holder.suspended", { conversationId: launch.conversationId });
|
|
70556
70100
|
} catch (_) {
|
|
@@ -70639,7 +70183,7 @@ var DEFAULT_MAX_ACTIVE_RUNS = 32;
|
|
|
70639
70183
|
var HOLDER_BUSY = "busy";
|
|
70640
70184
|
async function listIds(dir, schema) {
|
|
70641
70185
|
const ids = [];
|
|
70642
|
-
for (const name of await (0,
|
|
70186
|
+
for (const name of await (0, import_promises67.readdir)(dir).catch(() => [])) {
|
|
70643
70187
|
const parsed = schema.safeParse(name);
|
|
70644
70188
|
if (parsed.success) ids.push(parsed.data);
|
|
70645
70189
|
}
|
|
@@ -70653,14 +70197,14 @@ function holderIdentity(status) {
|
|
|
70653
70197
|
return command === void 0 ? { pid, startedAt } : { pid, startedAt, command };
|
|
70654
70198
|
}
|
|
70655
70199
|
function sessionFiles(paths, conversationId) {
|
|
70656
|
-
const dir = (0,
|
|
70657
|
-
return { dir, launch: (0,
|
|
70200
|
+
const dir = (0, import_node_path67.join)(paths.sessions, conversationId);
|
|
70201
|
+
return { dir, launch: (0, import_node_path67.join)(dir, "launch.json"), status: (0, import_node_path67.join)(dir, "holder.json") };
|
|
70658
70202
|
}
|
|
70659
70203
|
async function removeHolderFiles(files) {
|
|
70660
70204
|
for (const path4 of [files.launch, files.status, engineRecordsPath(files.dir)]) {
|
|
70661
|
-
await (0,
|
|
70205
|
+
await (0, import_promises67.rm)(path4, { force: true });
|
|
70662
70206
|
}
|
|
70663
|
-
await (0,
|
|
70207
|
+
await (0, import_promises67.rmdir)(files.dir).catch((error61) => {
|
|
70664
70208
|
if (!["ENOENT", "ENOTEMPTY", "EEXIST"].includes(errnoCode(error61) ?? "")) throw error61;
|
|
70665
70209
|
});
|
|
70666
70210
|
}
|
|
@@ -70850,7 +70394,7 @@ async function openSessions(deps) {
|
|
|
70850
70394
|
const meta3 = await readRunMeta(dir.meta);
|
|
70851
70395
|
const last = await readLastRecord(dir.log);
|
|
70852
70396
|
if (meta3 === null || last === null) return null;
|
|
70853
|
-
const logged = await (0,
|
|
70397
|
+
const logged = await (0, import_promises67.stat)(dir.log).catch((error61) => {
|
|
70854
70398
|
if (errnoCode(error61) === "ENOENT") return null;
|
|
70855
70399
|
throw error61;
|
|
70856
70400
|
});
|
|
@@ -71162,7 +70706,7 @@ function loadRuntimeConfig(env = process.env, totalMemoryBytes = (0, import_node
|
|
|
71162
70706
|
providerProbes: ALAN_RUNTIME_PROVIDER_PROBES === "on",
|
|
71163
70707
|
providerToolchain: ALAN_RUNTIME_PROVIDER_NODE !== void 0 && ALAN_RUNTIME_PROVIDER_NPM_CLI !== void 0 ? { node: ALAN_RUNTIME_PROVIDER_NODE, npmCli: ALAN_RUNTIME_PROVIDER_NPM_CLI } : null,
|
|
71164
70708
|
home,
|
|
71165
|
-
configHome: XDG_CONFIG_HOME ?? (0,
|
|
70709
|
+
configHome: XDG_CONFIG_HOME ?? (0, import_node_path68.join)(home, ".config"),
|
|
71166
70710
|
codexHome: resolveCodexHome(CODEX_HOME, home),
|
|
71167
70711
|
...githubProxyConfig({ ALAN_RUNTIME_GITHUB_PROXY, XDG_CONFIG_HOME, GH_CONFIG_DIR }, home),
|
|
71168
70712
|
gitGatewayUrl: ALAN_RUNTIME_GIT_GATEWAY_URL ?? null,
|
|
@@ -71172,13 +70716,13 @@ function loadRuntimeConfig(env = process.env, totalMemoryBytes = (0, import_node
|
|
|
71172
70716
|
};
|
|
71173
70717
|
}
|
|
71174
70718
|
function resolveCodexHome(configuredHome, home) {
|
|
71175
|
-
return configuredHome ?? (0,
|
|
70719
|
+
return configuredHome ?? (0, import_node_path68.join)(home, ".codex");
|
|
71176
70720
|
}
|
|
71177
70721
|
function githubProxyConfig(env, home) {
|
|
71178
|
-
const configHome = env.XDG_CONFIG_HOME ?? (0,
|
|
70722
|
+
const configHome = env.XDG_CONFIG_HOME ?? (0, import_node_path68.join)(home, ".config");
|
|
71179
70723
|
return {
|
|
71180
70724
|
githubProxy: env.ALAN_RUNTIME_GITHUB_PROXY === "on",
|
|
71181
|
-
ghConfigDir: env.GH_CONFIG_DIR ?? (0,
|
|
70725
|
+
ghConfigDir: env.GH_CONFIG_DIR ?? (0, import_node_path68.join)(configHome, "gh")
|
|
71182
70726
|
};
|
|
71183
70727
|
}
|
|
71184
70728
|
function serviceEnvironment2(env, profile) {
|
|
@@ -71236,9 +70780,9 @@ function takeEnrollmentCodeFromEnv(env = process.env) {
|
|
|
71236
70780
|
}
|
|
71237
70781
|
|
|
71238
70782
|
// src/cli/context.ts
|
|
71239
|
-
var
|
|
70783
|
+
var import_promises68 = require("fs/promises");
|
|
71240
70784
|
var import_node_os12 = require("os");
|
|
71241
|
-
var
|
|
70785
|
+
var import_node_path69 = require("path");
|
|
71242
70786
|
var DESKTOP_BUNDLE_IDS = {
|
|
71243
70787
|
production: ["com.alan-ai.desktop"],
|
|
71244
70788
|
staging: ["com.alan-ai.desktop.staging"],
|
|
@@ -71278,7 +70822,7 @@ function serviceSpec({ config: config2, paths, self }) {
|
|
|
71278
70822
|
profile: config2.profile,
|
|
71279
70823
|
program: serviceCommand(config2.host, self, launcher),
|
|
71280
70824
|
environment: config2.serviceEnvironment,
|
|
71281
|
-
logPath: (0,
|
|
70825
|
+
logPath: (0, import_node_path69.join)(paths.logs, "service.log"),
|
|
71282
70826
|
associatedBundleIds: DESKTOP_BUNDLE_IDS[config2.profile]
|
|
71283
70827
|
};
|
|
71284
70828
|
}
|
|
@@ -71286,7 +70830,7 @@ async function installedServiceSpec(ctx) {
|
|
|
71286
70830
|
const spec = serviceSpec(ctx);
|
|
71287
70831
|
if (ctx.config.host === "app") return spec;
|
|
71288
70832
|
const layout = installLayout(ctx.config.installDir, ctx.config.profile);
|
|
71289
|
-
const installed = await (0,
|
|
70833
|
+
const installed = await (0, import_promises68.access)(layout.launcher).then(
|
|
71290
70834
|
() => true,
|
|
71291
70835
|
() => false
|
|
71292
70836
|
);
|
|
@@ -71414,7 +70958,7 @@ var manifestRevisionSchema = external_exports.object({ revision: external_export
|
|
|
71414
70958
|
async function manifestRevision(path4) {
|
|
71415
70959
|
let raw;
|
|
71416
70960
|
try {
|
|
71417
|
-
raw = JSON.parse(await (0,
|
|
70961
|
+
raw = JSON.parse(await (0, import_promises69.readFile)(path4, "utf8"));
|
|
71418
70962
|
} catch (error61) {
|
|
71419
70963
|
throw new RuntimeFault("invalid_file", `Cannot read the skill manifest at ${path4}`, {
|
|
71420
70964
|
cause: error61
|
|
@@ -71468,8 +71012,8 @@ async function runSkills(argv) {
|
|
|
71468
71012
|
}
|
|
71469
71013
|
|
|
71470
71014
|
// src/cli/commands/doctor.ts
|
|
71471
|
-
var
|
|
71472
|
-
var
|
|
71015
|
+
var import_promises72 = require("fs/promises");
|
|
71016
|
+
var import_node_path73 = require("path");
|
|
71473
71017
|
init_runtime_v2();
|
|
71474
71018
|
|
|
71475
71019
|
// src/identity/credential.ts
|
|
@@ -71478,7 +71022,7 @@ init_zod();
|
|
|
71478
71022
|
|
|
71479
71023
|
// src/identity/installation.ts
|
|
71480
71024
|
var import_node_crypto33 = require("crypto");
|
|
71481
|
-
var
|
|
71025
|
+
var import_node_path70 = require("path");
|
|
71482
71026
|
init_runtime_v2();
|
|
71483
71027
|
init_zod();
|
|
71484
71028
|
var installationFileSchema = external_exports.object({
|
|
@@ -71486,7 +71030,7 @@ var installationFileSchema = external_exports.object({
|
|
|
71486
71030
|
machineId: machineIdSchema.optional()
|
|
71487
71031
|
});
|
|
71488
71032
|
function installationPath(paths) {
|
|
71489
|
-
return (0,
|
|
71033
|
+
return (0, import_node_path70.join)(paths.stateDir, "installation.json");
|
|
71490
71034
|
}
|
|
71491
71035
|
async function readInstallation(paths) {
|
|
71492
71036
|
const result = await readJsonFile(installationPath(paths), installationFileSchema);
|
|
@@ -71677,7 +71221,7 @@ async function authorizeDevice(input2) {
|
|
|
71677
71221
|
}
|
|
71678
71222
|
|
|
71679
71223
|
// src/identity/enroll.ts
|
|
71680
|
-
var
|
|
71224
|
+
var import_promises70 = require("fs/promises");
|
|
71681
71225
|
init_runtime_v2();
|
|
71682
71226
|
async function enrollMachine(input2) {
|
|
71683
71227
|
const machineId = input2.machineId ?? (await readMachineFile(input2.paths))?.machineId ?? (await readInstallation(input2.paths))?.machineId;
|
|
@@ -71760,13 +71304,13 @@ async function enrollFromGrantFile(input2) {
|
|
|
71760
71304
|
clock: input2.clock,
|
|
71761
71305
|
access: input2.access
|
|
71762
71306
|
});
|
|
71763
|
-
await (0,
|
|
71307
|
+
await (0, import_promises70.rm)(input2.grantPath, { force: true });
|
|
71764
71308
|
return machine;
|
|
71765
71309
|
}
|
|
71766
71310
|
|
|
71767
71311
|
// src/identity/migrate-v1.ts
|
|
71768
|
-
var
|
|
71769
|
-
var
|
|
71312
|
+
var import_promises71 = require("fs/promises");
|
|
71313
|
+
var import_node_path71 = require("path");
|
|
71770
71314
|
init_runtime_v2();
|
|
71771
71315
|
init_zod();
|
|
71772
71316
|
var EXIT_POLL_MS = 200;
|
|
@@ -71787,11 +71331,11 @@ var ownerLeaseSchema = external_exports.looseObject({ pid: external_exports.numb
|
|
|
71787
71331
|
function legacyConfigPath(home, profile) {
|
|
71788
71332
|
switch (profile) {
|
|
71789
71333
|
case "production":
|
|
71790
|
-
return (0,
|
|
71334
|
+
return (0, import_node_path71.join)(home, ".alan", "agent", "config.json");
|
|
71791
71335
|
case "staging":
|
|
71792
|
-
return (0,
|
|
71336
|
+
return (0, import_node_path71.join)(home, ".alan-staging", "agent", "config.json");
|
|
71793
71337
|
default:
|
|
71794
|
-
return (0,
|
|
71338
|
+
return (0, import_node_path71.join)(home, ".alan-dev", "agent", "config.json");
|
|
71795
71339
|
}
|
|
71796
71340
|
}
|
|
71797
71341
|
async function findLegacyInstall(home, profile) {
|
|
@@ -71816,8 +71360,8 @@ async function scrubLegacyInstall(install2) {
|
|
|
71816
71360
|
const scrubbed = { ...install2.config, migratedToRuntimeV2: true };
|
|
71817
71361
|
for (const key of SCRUBBED_KEYS) delete scrubbed[key];
|
|
71818
71362
|
await writeJsonFileAtomic(`${install2.configPath}.migrated-v1`, scrubbed);
|
|
71819
|
-
await (0,
|
|
71820
|
-
await (0,
|
|
71363
|
+
await (0, import_promises71.rm)(install2.configPath, { force: true });
|
|
71364
|
+
await (0, import_promises71.rm)(install2.ownerLeasePath, { force: true });
|
|
71821
71365
|
}
|
|
71822
71366
|
async function exchangeCredential(deps) {
|
|
71823
71367
|
const { config: config2 } = deps.install;
|
|
@@ -71926,7 +71470,7 @@ async function loadIdentity(paths, options = {}) {
|
|
|
71926
71470
|
}
|
|
71927
71471
|
|
|
71928
71472
|
// src/cli/commands/status.ts
|
|
71929
|
-
var
|
|
71473
|
+
var import_node_path72 = require("path");
|
|
71930
71474
|
async function serviceStatus(ctx) {
|
|
71931
71475
|
try {
|
|
71932
71476
|
return await createServiceManager(ctx.host, ctx.config.profile).status();
|
|
@@ -71953,7 +71497,7 @@ async function runtimeState(ctx) {
|
|
|
71953
71497
|
const running = await readRunningRuntime(ctx.paths.lock);
|
|
71954
71498
|
if (running === null) return { state: "offline", pid: null, localApi: null };
|
|
71955
71499
|
const discovery = await readJsonFile(
|
|
71956
|
-
(0,
|
|
71500
|
+
(0, import_node_path72.join)(ctx.paths.stateDir, LOCAL_API_DISCOVERY_FILE),
|
|
71957
71501
|
localApiDiscoverySchema
|
|
71958
71502
|
);
|
|
71959
71503
|
const localApi = discovery.kind === "ok" && discovery.value.pid === running.pid ? {
|
|
@@ -71998,7 +71542,7 @@ async function runStatus(argv, ctx = cliContext()) {
|
|
|
71998
71542
|
}
|
|
71999
71543
|
|
|
72000
71544
|
// src/cli/commands/doctor.ts
|
|
72001
|
-
var
|
|
71545
|
+
var PROBE_TIMEOUT_MS2 = 1e4;
|
|
72002
71546
|
var LOCAL_TIMEOUT_MS = 3e3;
|
|
72003
71547
|
var DISK_WARN_BYTES = 1024 ** 3;
|
|
72004
71548
|
var DISK_FAIL_BYTES = 100 * 1024 ** 2;
|
|
@@ -72090,7 +71634,7 @@ async function credentialCheck(ctx) {
|
|
|
72090
71634
|
async function serverCheck(facts) {
|
|
72091
71635
|
const api = createApiClient({ apiUrl: facts.apiUrl, accessToken: () => facts.accessToken });
|
|
72092
71636
|
try {
|
|
72093
|
-
const desired = await api.fetchDesired(AbortSignal.timeout(
|
|
71637
|
+
const desired = await api.fetchDesired(AbortSignal.timeout(PROBE_TIMEOUT_MS2));
|
|
72094
71638
|
return check2("server", "ok", `${facts.apiUrl} accepts this machine's credential`, {
|
|
72095
71639
|
machineId: facts.machineId,
|
|
72096
71640
|
desiredRuns: desired.runs.length
|
|
@@ -72116,7 +71660,7 @@ function isStale(machine, now) {
|
|
|
72116
71660
|
async function machinesCheck(facts) {
|
|
72117
71661
|
const api = createApiClient({ apiUrl: facts.apiUrl, accessToken: () => facts.accessToken });
|
|
72118
71662
|
try {
|
|
72119
|
-
const machines = await api.listSiblings(AbortSignal.timeout(
|
|
71663
|
+
const machines = await api.listSiblings(AbortSignal.timeout(PROBE_TIMEOUT_MS2));
|
|
72120
71664
|
if (machines === null) {
|
|
72121
71665
|
return check2("machines", "skipped", `${facts.apiUrl} does not list machines`);
|
|
72122
71666
|
}
|
|
@@ -72146,7 +71690,7 @@ async function releaseCheck(ctx, facts) {
|
|
|
72146
71690
|
const apiUrl = facts?.apiUrl ?? ctx.config.apiUrl;
|
|
72147
71691
|
const api = createApiClient({ apiUrl, accessToken: () => facts?.accessToken ?? "" });
|
|
72148
71692
|
try {
|
|
72149
|
-
const release2 = await api.currentRelease(AbortSignal.timeout(
|
|
71693
|
+
const release2 = await api.currentRelease(AbortSignal.timeout(PROBE_TIMEOUT_MS2));
|
|
72150
71694
|
const layout = installLayout(ctx.config.installDir, ctx.config.profile);
|
|
72151
71695
|
const plan2 = planUpdate({
|
|
72152
71696
|
current: package_default.version,
|
|
@@ -72174,7 +71718,7 @@ async function runtimeCheck(ctx, status) {
|
|
|
72174
71718
|
return check2("runtime", "warn", "No runtime is running for this profile");
|
|
72175
71719
|
}
|
|
72176
71720
|
const client = createRuntimeClient({
|
|
72177
|
-
discoveryPath: (0,
|
|
71721
|
+
discoveryPath: (0, import_node_path73.join)(ctx.paths.stateDir, LOCAL_API_DISCOVERY_FILE)
|
|
72178
71722
|
});
|
|
72179
71723
|
try {
|
|
72180
71724
|
const live = await client.status(AbortSignal.timeout(LOCAL_TIMEOUT_MS));
|
|
@@ -72201,7 +71745,7 @@ async function runtimeCheck(ctx, status) {
|
|
|
72201
71745
|
}
|
|
72202
71746
|
}
|
|
72203
71747
|
async function probeHolder(dir, conversationId) {
|
|
72204
|
-
const launch = await readJsonFile((0,
|
|
71748
|
+
const launch = await readJsonFile((0, import_node_path73.join)(dir, "launch.json"), holderLaunchSchema);
|
|
72205
71749
|
if (launch.kind !== "ok") return null;
|
|
72206
71750
|
try {
|
|
72207
71751
|
const reply2 = await withTimeout(
|
|
@@ -72226,8 +71770,8 @@ async function probeHolder(dir, conversationId) {
|
|
|
72226
71770
|
}
|
|
72227
71771
|
}
|
|
72228
71772
|
async function holdersCheck(ctx) {
|
|
72229
|
-
const names = await (0,
|
|
72230
|
-
const holders = (await Promise.all(names.map((name) => probeHolder((0,
|
|
71773
|
+
const names = await (0, import_promises72.readdir)(ctx.paths.sessions).catch(() => []);
|
|
71774
|
+
const holders = (await Promise.all(names.map((name) => probeHolder((0, import_node_path73.join)(ctx.paths.sessions, name), name)))).filter((facts) => facts !== null);
|
|
72231
71775
|
const dead = holders.filter((holder) => !holder.alive).length;
|
|
72232
71776
|
return check2(
|
|
72233
71777
|
"holders",
|
|
@@ -72238,10 +71782,10 @@ async function holdersCheck(ctx) {
|
|
|
72238
71782
|
}
|
|
72239
71783
|
async function freeBytesAt(path4) {
|
|
72240
71784
|
try {
|
|
72241
|
-
const stats = await (0,
|
|
71785
|
+
const stats = await (0, import_promises72.statfs)(path4);
|
|
72242
71786
|
return { path: path4, freeBytes: stats.bavail * stats.bsize };
|
|
72243
71787
|
} catch (error61) {
|
|
72244
|
-
const parent = (0,
|
|
71788
|
+
const parent = (0, import_node_path73.dirname)(path4);
|
|
72245
71789
|
if (parent === path4) throw error61;
|
|
72246
71790
|
return freeBytesAt(parent);
|
|
72247
71791
|
}
|
|
@@ -72259,9 +71803,9 @@ async function diskCheck(ctx) {
|
|
|
72259
71803
|
}
|
|
72260
71804
|
}
|
|
72261
71805
|
var resolveFromLoginShell = (own2) => resolveCliEnvironment({ env: own2, platform: process.platform });
|
|
72262
|
-
async function cliDiscoveryCheck(
|
|
71806
|
+
async function cliDiscoveryCheck(resolve13) {
|
|
72263
71807
|
const own2 = readCliEnvironment();
|
|
72264
|
-
const env = await
|
|
71808
|
+
const env = await resolve13(own2);
|
|
72265
71809
|
const delimiter = process.platform === "win32" ? ";" : ":";
|
|
72266
71810
|
const ownDirs = new Set((own2.PATH ?? "").split(delimiter));
|
|
72267
71811
|
const added = (env.PATH ?? "").split(delimiter).filter((dir) => dir.length > 0 && !ownDirs.has(dir));
|
|
@@ -72377,7 +71921,7 @@ async function runDoctor(argv, context = cliContext) {
|
|
|
72377
71921
|
}
|
|
72378
71922
|
|
|
72379
71923
|
// src/cli/commands/git-credential.ts
|
|
72380
|
-
var
|
|
71924
|
+
var import_promises73 = require("fs/promises");
|
|
72381
71925
|
var import_node_net4 = require("net");
|
|
72382
71926
|
var MAX_RESPONSE_BYTES = 64 * 1024;
|
|
72383
71927
|
async function readAll(stream) {
|
|
@@ -72395,7 +71939,7 @@ function processIo() {
|
|
|
72395
71939
|
};
|
|
72396
71940
|
}
|
|
72397
71941
|
function askGitCredentialSocket(endpoint, request2, signal) {
|
|
72398
|
-
return new Promise((
|
|
71942
|
+
return new Promise((resolve13, reject) => {
|
|
72399
71943
|
const socket = (0, import_node_net4.createConnection)(endpoint);
|
|
72400
71944
|
let buffered = "";
|
|
72401
71945
|
const fail = (error61) => {
|
|
@@ -72422,7 +71966,7 @@ function askGitCredentialSocket(endpoint, request2, signal) {
|
|
|
72422
71966
|
signal.removeEventListener("abort", onAbort);
|
|
72423
71967
|
try {
|
|
72424
71968
|
const line = buffered.split("\n", 1)[0] ?? "";
|
|
72425
|
-
|
|
71969
|
+
resolve13(gitCredentialSocketResponseSchema.parse(JSON.parse(line)));
|
|
72426
71970
|
} catch (error61) {
|
|
72427
71971
|
reject(
|
|
72428
71972
|
new RuntimeFault("io_failed", "the Alan runtime sent an invalid reply", { cause: error61 })
|
|
@@ -72487,7 +72031,7 @@ async function configure(argv) {
|
|
|
72487
72031
|
}
|
|
72488
72032
|
async function configureGitGateway(config2, gatewayUrl, signal) {
|
|
72489
72033
|
const { launcher } = installLayout(config2.installDir, config2.profile);
|
|
72490
|
-
const installed = await (0,
|
|
72034
|
+
const installed = await (0, import_promises73.access)(launcher).then(
|
|
72491
72035
|
() => true,
|
|
72492
72036
|
() => false
|
|
72493
72037
|
);
|
|
@@ -72514,7 +72058,7 @@ async function runGitCredential(argv) {
|
|
|
72514
72058
|
}
|
|
72515
72059
|
|
|
72516
72060
|
// src/cli/commands/hold.ts
|
|
72517
|
-
var
|
|
72061
|
+
var import_node_path74 = require("path");
|
|
72518
72062
|
init_agent2();
|
|
72519
72063
|
init_runtime_v2();
|
|
72520
72064
|
async function machineAccess(paths, log, conversationId, transport) {
|
|
@@ -72572,7 +72116,7 @@ async function runHold(argv) {
|
|
|
72572
72116
|
const config2 = loadRuntimeConfig();
|
|
72573
72117
|
const paths = runtimePaths(config2.stateDir);
|
|
72574
72118
|
const log = __using(_stack, openFileLog(
|
|
72575
|
-
(0,
|
|
72119
|
+
(0, import_node_path74.join)(paths.logs, `holder-${launch.value.conversationId}.jsonl`),
|
|
72576
72120
|
config2.logLevel,
|
|
72577
72121
|
systemClock
|
|
72578
72122
|
));
|
|
@@ -72583,7 +72127,7 @@ async function runHold(argv) {
|
|
|
72583
72127
|
);
|
|
72584
72128
|
const transport = __using(_stack, createHttpTransport());
|
|
72585
72129
|
const access7 = await machineAccess(paths, log, launch.value.conversationId, transport);
|
|
72586
|
-
const credentialPath = (0,
|
|
72130
|
+
const credentialPath = (0, import_node_path74.join)(paths.tmp, "mcp", `${launch.value.conversationId}.json`);
|
|
72587
72131
|
const managedMcp = __using(_stack, access7.managedMcp === void 0 ? void 0 : createHelperMcpAccess({
|
|
72588
72132
|
managedMcp: access7.managedMcp,
|
|
72589
72133
|
conversationId: launch.value.conversationId,
|
|
@@ -72624,7 +72168,7 @@ async function runHold(argv) {
|
|
|
72624
72168
|
}
|
|
72625
72169
|
|
|
72626
72170
|
// src/cli/commands/hook.ts
|
|
72627
|
-
var
|
|
72171
|
+
var import_node_path75 = require("path");
|
|
72628
72172
|
var RUNTIME_ANSWER_MS = 2e3;
|
|
72629
72173
|
var DEBUG_VARIABLE = "ALAN_HOOK_DEBUG";
|
|
72630
72174
|
function flag(argv, name) {
|
|
@@ -72656,7 +72200,7 @@ async function forwardHook(argv, io) {
|
|
|
72656
72200
|
return "transcript outside provider root";
|
|
72657
72201
|
}
|
|
72658
72202
|
const verdict = await io.send(
|
|
72659
|
-
(0,
|
|
72203
|
+
(0, import_node_path75.join)(io.stateDir, LOCAL_API_DISCOVERY_FILE),
|
|
72660
72204
|
hookSignal,
|
|
72661
72205
|
AbortSignal.timeout(RUNTIME_ANSWER_MS)
|
|
72662
72206
|
);
|
|
@@ -72692,7 +72236,7 @@ async function runHook(argv, overrides = {}) {
|
|
|
72692
72236
|
}
|
|
72693
72237
|
|
|
72694
72238
|
// src/cli/commands/ingestion-hooks.ts
|
|
72695
|
-
var
|
|
72239
|
+
var import_promises74 = require("fs/promises");
|
|
72696
72240
|
var CODEX_TRUST_NOTE = "Codex runs new hooks only after you review them: open /hooks in Codex.";
|
|
72697
72241
|
function isAction(value2) {
|
|
72698
72242
|
return value2 === "enable" || value2 === "disable" || value2 === "status";
|
|
@@ -72715,7 +72259,7 @@ function errorMessage2(error61) {
|
|
|
72715
72259
|
return error61 instanceof Error ? error61.message : String(error61);
|
|
72716
72260
|
}
|
|
72717
72261
|
async function exists5(path4) {
|
|
72718
|
-
return (0,
|
|
72262
|
+
return (0, import_promises74.access)(path4).then(
|
|
72719
72263
|
() => true,
|
|
72720
72264
|
() => false
|
|
72721
72265
|
);
|
|
@@ -72818,10 +72362,10 @@ async function runIntegrationsCommand(argv) {
|
|
|
72818
72362
|
}
|
|
72819
72363
|
|
|
72820
72364
|
// src/cli/commands/legacy.ts
|
|
72821
|
-
var
|
|
72365
|
+
var import_node_path77 = require("path");
|
|
72822
72366
|
|
|
72823
72367
|
// src/cli/commands/setup.ts
|
|
72824
|
-
var
|
|
72368
|
+
var import_node_path76 = require("path");
|
|
72825
72369
|
init_zod();
|
|
72826
72370
|
|
|
72827
72371
|
// src/cli/legacy.ts
|
|
@@ -72903,7 +72447,7 @@ async function grantFileCredential(argv, grantPath, ctx, deps) {
|
|
|
72903
72447
|
return enrollFromGrantFile({
|
|
72904
72448
|
paths: ctx.paths,
|
|
72905
72449
|
storeKind: credentialStoreFlag(argv) ?? ctx.config.credentialStore,
|
|
72906
|
-
grantPath: (0,
|
|
72450
|
+
grantPath: (0, import_node_path76.resolve)(grantPath),
|
|
72907
72451
|
clock: deps.clock,
|
|
72908
72452
|
access: ctx.access
|
|
72909
72453
|
});
|
|
@@ -72979,7 +72523,7 @@ async function runSetup(argv, signal) {
|
|
|
72979
72523
|
var _stack = [];
|
|
72980
72524
|
try {
|
|
72981
72525
|
const ctx = cliContext();
|
|
72982
|
-
const log = __using(_stack, openFileLog((0,
|
|
72526
|
+
const log = __using(_stack, openFileLog((0, import_node_path76.join)(ctx.paths.logs, "cli.jsonl"), ctx.config.logLevel, systemClock));
|
|
72983
72527
|
const result = await setupMachine(argv, ctx, {
|
|
72984
72528
|
enrollment: (apiUrl) => createEnrollmentClient({ apiUrl }),
|
|
72985
72529
|
isProcessAlive,
|
|
@@ -73062,7 +72606,7 @@ async function runToken(argv, signal) {
|
|
|
73062
72606
|
);
|
|
73063
72607
|
}
|
|
73064
72608
|
const ctx = cliContext();
|
|
73065
|
-
const log = __using(_stack, openFileLog((0,
|
|
72609
|
+
const log = __using(_stack, openFileLog((0, import_node_path77.join)(ctx.paths.logs, "cli.jsonl"), ctx.config.logLevel, systemClock));
|
|
73066
72610
|
const result = await rotateMachineCredential(ctx, { clock: systemClock, log, signal });
|
|
73067
72611
|
process.stdout.write(`${rotationMessage(result)}
|
|
73068
72612
|
`);
|
|
@@ -73074,8 +72618,8 @@ async function runToken(argv, signal) {
|
|
|
73074
72618
|
}
|
|
73075
72619
|
|
|
73076
72620
|
// src/cli/commands/logout.ts
|
|
73077
|
-
var
|
|
73078
|
-
var
|
|
72621
|
+
var import_promises75 = require("fs/promises");
|
|
72622
|
+
var import_node_path78 = require("path");
|
|
73079
72623
|
init_runtime_v2();
|
|
73080
72624
|
var RUNTIME_EXIT_WAIT_MS = 35e3;
|
|
73081
72625
|
var TURN_END_WAIT_MS = 3e4;
|
|
@@ -73134,9 +72678,9 @@ async function stopHolder(launch, deps, outcome2) {
|
|
|
73134
72678
|
}
|
|
73135
72679
|
async function stopHeldRuns(ctx, deps, outcome2 = "aborted") {
|
|
73136
72680
|
const stopped = [];
|
|
73137
|
-
for (const name of await (0,
|
|
72681
|
+
for (const name of await (0, import_promises75.readdir)(ctx.paths.sessions).catch(() => [])) {
|
|
73138
72682
|
const launch = await readJsonFile(
|
|
73139
|
-
(0,
|
|
72683
|
+
(0, import_node_path78.join)(ctx.paths.sessions, name, "launch.json"),
|
|
73140
72684
|
holderLaunchSchema
|
|
73141
72685
|
);
|
|
73142
72686
|
if (launch.kind !== "ok") continue;
|
|
@@ -73173,13 +72717,13 @@ async function forgetMachineLocally(ctx) {
|
|
|
73173
72717
|
const machine = await readMachineFile(ctx.paths);
|
|
73174
72718
|
if (machine === null) return;
|
|
73175
72719
|
await credentialStoreFor(ctx.paths, machine.credentialStore, ctx.access).clear();
|
|
73176
|
-
await (0,
|
|
72720
|
+
await (0, import_promises75.rm)(ctx.paths.machine, { force: true });
|
|
73177
72721
|
}
|
|
73178
72722
|
async function runLogout(argv, signal) {
|
|
73179
72723
|
var _stack = [];
|
|
73180
72724
|
try {
|
|
73181
72725
|
const ctx = cliContext();
|
|
73182
|
-
const log = __using(_stack, openFileLog((0,
|
|
72726
|
+
const log = __using(_stack, openFileLog((0, import_node_path78.join)(ctx.paths.logs, "cli.jsonl"), ctx.config.logLevel, systemClock));
|
|
73183
72727
|
const result = await logoutMachine(argv, ctx, {
|
|
73184
72728
|
api: (apiUrl, accessToken) => createApiClient({ apiUrl, accessToken }),
|
|
73185
72729
|
stopHeldRuns,
|
|
@@ -73197,7 +72741,7 @@ async function runLogout(argv, signal) {
|
|
|
73197
72741
|
|
|
73198
72742
|
// src/cli/commands/run.ts
|
|
73199
72743
|
var import_node_fs24 = require("fs");
|
|
73200
|
-
var
|
|
72744
|
+
var import_node_path82 = require("path");
|
|
73201
72745
|
|
|
73202
72746
|
// src/local-api/app-attachments.ts
|
|
73203
72747
|
function createAppAttachments(clock) {
|
|
@@ -73237,7 +72781,7 @@ function createRunAppends() {
|
|
|
73237
72781
|
const pending = waiters.get(runId);
|
|
73238
72782
|
if (pending === void 0) return;
|
|
73239
72783
|
waiters.delete(runId);
|
|
73240
|
-
for (const
|
|
72784
|
+
for (const resolve13 of pending) resolve13();
|
|
73241
72785
|
};
|
|
73242
72786
|
return {
|
|
73243
72787
|
notify: wake,
|
|
@@ -73255,13 +72799,13 @@ function createRunAppends() {
|
|
|
73255
72799
|
},
|
|
73256
72800
|
nextAppend: (runId, signal) => {
|
|
73257
72801
|
if (signal.aborted) return Promise.resolve();
|
|
73258
|
-
return new Promise((
|
|
72802
|
+
return new Promise((resolve13) => {
|
|
73259
72803
|
const done = () => {
|
|
73260
72804
|
signal.removeEventListener("abort", done);
|
|
73261
72805
|
const pending2 = waiters.get(runId);
|
|
73262
72806
|
pending2?.delete(done);
|
|
73263
72807
|
if (pending2?.size === 0) waiters.delete(runId);
|
|
73264
|
-
|
|
72808
|
+
resolve13();
|
|
73265
72809
|
};
|
|
73266
72810
|
const pending = waiters.get(runId) ?? /* @__PURE__ */ new Set();
|
|
73267
72811
|
pending.add(done);
|
|
@@ -73274,9 +72818,9 @@ function createRunAppends() {
|
|
|
73274
72818
|
|
|
73275
72819
|
// src/local-api/server.ts
|
|
73276
72820
|
var import_node_crypto35 = require("crypto");
|
|
73277
|
-
var
|
|
72821
|
+
var import_promises76 = require("fs/promises");
|
|
73278
72822
|
var import_node_http4 = require("http");
|
|
73279
|
-
var
|
|
72823
|
+
var import_node_path79 = require("path");
|
|
73280
72824
|
|
|
73281
72825
|
// src/local-api/guard.ts
|
|
73282
72826
|
var import_node_crypto34 = require("crypto");
|
|
@@ -73353,11 +72897,11 @@ id: ${event.id}
|
|
|
73353
72897
|
${data}
|
|
73354
72898
|
`);
|
|
73355
72899
|
if (accepted || res.destroyed) return;
|
|
73356
|
-
await new Promise((
|
|
72900
|
+
await new Promise((resolve13) => {
|
|
73357
72901
|
const done = () => {
|
|
73358
72902
|
res.off("drain", done);
|
|
73359
72903
|
res.off("close", done);
|
|
73360
|
-
|
|
72904
|
+
resolve13();
|
|
73361
72905
|
};
|
|
73362
72906
|
res.once("drain", done);
|
|
73363
72907
|
res.once("close", done);
|
|
@@ -73463,7 +73007,7 @@ async function openLocalTurnProjection(runsDir, runId, conversationId, ordinal)
|
|
|
73463
73007
|
if (!reader) return null;
|
|
73464
73008
|
let offset = toByteOffset(0);
|
|
73465
73009
|
let ended = false;
|
|
73466
|
-
let
|
|
73010
|
+
let snapshot;
|
|
73467
73011
|
let prepared;
|
|
73468
73012
|
const merge2 = /* @__PURE__ */ new Map();
|
|
73469
73013
|
const decoder3 = new TextDecoder();
|
|
@@ -73475,13 +73019,13 @@ async function openLocalTurnProjection(runsDir, runId, conversationId, ordinal)
|
|
|
73475
73019
|
if (applyLogChunk(decoder3.decode(chunk.bytes), assistantMessageId, state)) ended = true;
|
|
73476
73020
|
offset = chunk.to;
|
|
73477
73021
|
}
|
|
73478
|
-
if (offset === priorOffset &&
|
|
73022
|
+
if (offset === priorOffset && snapshot) return snapshot;
|
|
73479
73023
|
if (ended) state.state = "idle";
|
|
73480
|
-
|
|
73024
|
+
snapshot = mergeTranscriptMessages(
|
|
73481
73025
|
[{ messageId: assistantMessageId, turnOrdinal: ordinal, role: "assistant", state }],
|
|
73482
73026
|
merge2
|
|
73483
73027
|
);
|
|
73484
|
-
return
|
|
73028
|
+
return snapshot;
|
|
73485
73029
|
};
|
|
73486
73030
|
return {
|
|
73487
73031
|
runId,
|
|
@@ -73585,9 +73129,9 @@ async function readChangedTurn(deps, conversationId, runId, slot) {
|
|
|
73585
73129
|
}
|
|
73586
73130
|
async function nextChangedRuns(bell, signal) {
|
|
73587
73131
|
if (bell.pending.size === 0) {
|
|
73588
|
-
await new Promise((
|
|
73589
|
-
bell.wake =
|
|
73590
|
-
if (signal.aborted || bell.pending.size > 0)
|
|
73132
|
+
await new Promise((resolve13) => {
|
|
73133
|
+
bell.wake = resolve13;
|
|
73134
|
+
if (signal.aborted || bell.pending.size > 0) resolve13();
|
|
73591
73135
|
});
|
|
73592
73136
|
bell.wake = void 0;
|
|
73593
73137
|
}
|
|
@@ -73887,12 +73431,12 @@ function activeRunIds(runs) {
|
|
|
73887
73431
|
var streamStatus = async ({ feed, appAttachments }, { res, signal }) => {
|
|
73888
73432
|
var _stack = [];
|
|
73889
73433
|
try {
|
|
73890
|
-
const
|
|
73434
|
+
const snapshot = await feed.refresh(signal);
|
|
73891
73435
|
const _attachment = __using(_stack, appAttachments.attach());
|
|
73892
73436
|
startEventStream(res);
|
|
73893
73437
|
const send2 = (name, event) => writeEvent(res, { name, id: String(event.seq), dataLines: [JSON.stringify(event)] });
|
|
73894
73438
|
let latest = null;
|
|
73895
|
-
let writing = send2("snapshot",
|
|
73439
|
+
let writing = send2("snapshot", snapshot);
|
|
73896
73440
|
const flush = async () => {
|
|
73897
73441
|
while (latest !== null && !res.destroyed) {
|
|
73898
73442
|
const next = latest;
|
|
@@ -73904,9 +73448,9 @@ var streamStatus = async ({ feed, appAttachments }, { res, signal }) => {
|
|
|
73904
73448
|
latest = event;
|
|
73905
73449
|
writing = writing.then(flush);
|
|
73906
73450
|
}));
|
|
73907
|
-
await new Promise((
|
|
73908
|
-
if (signal.aborted)
|
|
73909
|
-
signal.addEventListener("abort", () =>
|
|
73451
|
+
await new Promise((resolve13) => {
|
|
73452
|
+
if (signal.aborted) resolve13();
|
|
73453
|
+
signal.addEventListener("abort", () => resolve13(), { once: true });
|
|
73910
73454
|
});
|
|
73911
73455
|
await writing;
|
|
73912
73456
|
} catch (_) {
|
|
@@ -74229,11 +73773,11 @@ function localRequestSignal(path4, closed) {
|
|
|
74229
73773
|
]);
|
|
74230
73774
|
}
|
|
74231
73775
|
async function listenOnLoopback(server) {
|
|
74232
|
-
await new Promise((
|
|
73776
|
+
await new Promise((resolve13, reject) => {
|
|
74233
73777
|
server.once("error", reject);
|
|
74234
73778
|
server.listen(0, "127.0.0.1", () => {
|
|
74235
73779
|
server.off("error", reject);
|
|
74236
|
-
|
|
73780
|
+
resolve13();
|
|
74237
73781
|
});
|
|
74238
73782
|
}).catch((error61) => {
|
|
74239
73783
|
throw new RuntimeFault("io_failed", "The local API could not listen on loopback", {
|
|
@@ -74248,7 +73792,7 @@ async function listenOnLoopback(server) {
|
|
|
74248
73792
|
}
|
|
74249
73793
|
async function closeServer(server) {
|
|
74250
73794
|
server.closeAllConnections();
|
|
74251
|
-
await new Promise((
|
|
73795
|
+
await new Promise((resolve13) => server.close(() => resolve13()));
|
|
74252
73796
|
}
|
|
74253
73797
|
async function serveLocalApi(deps) {
|
|
74254
73798
|
const limits = { ...DEFAULT_LIMITS, ...deps.limits };
|
|
@@ -74319,7 +73863,7 @@ async function serveLocalApi(deps) {
|
|
|
74319
73863
|
startedAtMs,
|
|
74320
73864
|
runtimeVersion: deps.runtimeVersion
|
|
74321
73865
|
};
|
|
74322
|
-
const discoveryPath = (0,
|
|
73866
|
+
const discoveryPath = (0, import_node_path79.join)(deps.stateDir, LOCAL_API_DISCOVERY_FILE);
|
|
74323
73867
|
await writeJsonFileAtomic(discoveryPath, discovery);
|
|
74324
73868
|
const followers = startMaintenance({
|
|
74325
73869
|
everyMs: limits.refreshEveryMs,
|
|
@@ -74353,7 +73897,7 @@ async function serveLocalApi(deps) {
|
|
|
74353
73897
|
await watchedStatus[Symbol.asyncDispose]();
|
|
74354
73898
|
const current = await readJsonFile(discoveryPath, localApiDiscoverySchema);
|
|
74355
73899
|
if (current.kind === "ok" && current.value.token === token) {
|
|
74356
|
-
await (0,
|
|
73900
|
+
await (0, import_promises76.rm)(discoveryPath, { force: true });
|
|
74357
73901
|
}
|
|
74358
73902
|
await closeServer(server);
|
|
74359
73903
|
log.info("local_api.closed", {});
|
|
@@ -74438,7 +73982,7 @@ function machineFeatureActions(deps) {
|
|
|
74438
73982
|
}
|
|
74439
73983
|
|
|
74440
73984
|
// src/cli/commands/machine-plane.ts
|
|
74441
|
-
var
|
|
73985
|
+
var import_node_path81 = require("path");
|
|
74442
73986
|
|
|
74443
73987
|
// src/link/index.ts
|
|
74444
73988
|
init_runtime_v2();
|
|
@@ -77005,9 +76549,9 @@ var Socket2 = class extends Emitter {
|
|
|
77005
76549
|
* @return a Promise that will be fulfilled when the server acknowledges the event
|
|
77006
76550
|
*/
|
|
77007
76551
|
emitWithAck(ev, ...args) {
|
|
77008
|
-
return new Promise((
|
|
76552
|
+
return new Promise((resolve13, reject) => {
|
|
77009
76553
|
const fn = (arg1, arg2) => {
|
|
77010
|
-
return arg1 ? reject(arg1) :
|
|
76554
|
+
return arg1 ? reject(arg1) : resolve13(arg2);
|
|
77011
76555
|
};
|
|
77012
76556
|
fn.withError = true;
|
|
77013
76557
|
args.push(fn);
|
|
@@ -78106,10 +77650,10 @@ function refusalFailure(refusal2) {
|
|
|
78106
77650
|
}
|
|
78107
77651
|
|
|
78108
77652
|
// src/link/probe.ts
|
|
78109
|
-
var
|
|
77653
|
+
var import_promises77 = require("dns/promises");
|
|
78110
77654
|
var import_node_net5 = require("net");
|
|
78111
77655
|
var import_node_tls2 = require("tls");
|
|
78112
|
-
var
|
|
77656
|
+
var PROBE_TIMEOUT_MS3 = 5e3;
|
|
78113
77657
|
function openSocket(url3) {
|
|
78114
77658
|
const secure = url3.protocol === "https:" || url3.protocol === "wss:";
|
|
78115
77659
|
const host = url3.hostname;
|
|
@@ -78126,11 +77670,11 @@ async function connectOnce(url3, clock) {
|
|
|
78126
77670
|
const timer = new AbortController();
|
|
78127
77671
|
try {
|
|
78128
77672
|
return await Promise.race([
|
|
78129
|
-
new Promise((
|
|
78130
|
-
socket.once(ready, () =>
|
|
78131
|
-
socket.once("error", (error61) =>
|
|
77673
|
+
new Promise((resolve13) => {
|
|
77674
|
+
socket.once(ready, () => resolve13(null));
|
|
77675
|
+
socket.once("error", (error61) => resolve13(classifyTransportFailure(error61)));
|
|
78132
77676
|
}),
|
|
78133
|
-
clock.sleep(
|
|
77677
|
+
clock.sleep(PROBE_TIMEOUT_MS3, timer.signal).then(
|
|
78134
77678
|
() => "connection_timeout",
|
|
78135
77679
|
() => null
|
|
78136
77680
|
)
|
|
@@ -78142,7 +77686,7 @@ async function connectOnce(url3, clock) {
|
|
|
78142
77686
|
}
|
|
78143
77687
|
async function probeEndpoint(url3, clock) {
|
|
78144
77688
|
try {
|
|
78145
|
-
await (0,
|
|
77689
|
+
await (0, import_promises77.lookup)(url3.hostname);
|
|
78146
77690
|
} catch (error61) {
|
|
78147
77691
|
const reason = classifyTransportFailure(error61);
|
|
78148
77692
|
return reason === "other" ? "dns" : reason;
|
|
@@ -78213,6 +77757,7 @@ var REDIAL_BASE_MS = 1e3;
|
|
|
78213
77757
|
var REDIAL_MAX_MS = 1e4;
|
|
78214
77758
|
var MAX_CREDENTIAL_FAILURES = 3;
|
|
78215
77759
|
var DISABLED_RETRY_MS = 5 * 6e4;
|
|
77760
|
+
var WAKE_PROBE_MS = 5e3;
|
|
78216
77761
|
function redialDelayMs(attempt2) {
|
|
78217
77762
|
return Math.min(REDIAL_BASE_MS * 2 ** attempt2, REDIAL_MAX_MS) * (0.5 + 0.5 * Math.random());
|
|
78218
77763
|
}
|
|
@@ -78243,6 +77788,8 @@ function connectLink(options) {
|
|
|
78243
77788
|
const counts = {};
|
|
78244
77789
|
const retry = { pending: new AbortController(), attempt: 0, credentialFailures: 0 };
|
|
78245
77790
|
const probe = { running: false };
|
|
77791
|
+
const wake = { recovering: null };
|
|
77792
|
+
const closing = new AbortController();
|
|
78246
77793
|
const socket = lookup(
|
|
78247
77794
|
new URL(LINK_NAMESPACE, wsUrl).toString(),
|
|
78248
77795
|
{
|
|
@@ -78413,20 +77960,59 @@ function connectLink(options) {
|
|
|
78413
77960
|
return false;
|
|
78414
77961
|
}
|
|
78415
77962
|
};
|
|
77963
|
+
const redial2 = () => {
|
|
77964
|
+
retry.attempt = 0;
|
|
77965
|
+
retry.credentialFailures = 0;
|
|
77966
|
+
cancelRedial();
|
|
77967
|
+
setState({ kind: "connecting", lastFailure: null });
|
|
77968
|
+
log.info("link.redial", { connected: socket.connected });
|
|
77969
|
+
if (socket.connected) {
|
|
77970
|
+
socket.io.engine.close();
|
|
77971
|
+
return;
|
|
77972
|
+
}
|
|
77973
|
+
socket.disconnect();
|
|
77974
|
+
socket.connect();
|
|
77975
|
+
};
|
|
77976
|
+
const hearsServer = (timeoutMs) => new Promise((resolve13) => {
|
|
77977
|
+
const waiting = new AbortController();
|
|
77978
|
+
const settle = (alive) => {
|
|
77979
|
+
waiting.abort();
|
|
77980
|
+
socket.io.off("ping", onPing);
|
|
77981
|
+
socket.off("disconnect", onDrop);
|
|
77982
|
+
resolve13(alive);
|
|
77983
|
+
};
|
|
77984
|
+
const onPing = () => settle(true);
|
|
77985
|
+
const onDrop = () => settle(false);
|
|
77986
|
+
socket.io.on("ping", onPing);
|
|
77987
|
+
socket.on("disconnect", onDrop);
|
|
77988
|
+
clock.sleep(timeoutMs, AbortSignal.any([waiting.signal, closing.signal])).then(
|
|
77989
|
+
() => settle(false),
|
|
77990
|
+
() => settle(false)
|
|
77991
|
+
);
|
|
77992
|
+
});
|
|
77993
|
+
const recover = async () => {
|
|
77994
|
+
if (current.kind !== "stopped" && socket.connected) {
|
|
77995
|
+
const alive = await hearsServer(options.wakeProbeMs ?? WAKE_PROBE_MS);
|
|
77996
|
+
if (closing.signal.aborted) return "closed";
|
|
77997
|
+
log.info("link.wake_probe", { alive });
|
|
77998
|
+
if (alive) return "alive";
|
|
77999
|
+
}
|
|
78000
|
+
redial2();
|
|
78001
|
+
return "redialed";
|
|
78002
|
+
};
|
|
78416
78003
|
return {
|
|
78417
78004
|
state: () => current,
|
|
78418
78005
|
failureCounts: () => ({ ...counts }),
|
|
78419
|
-
redial:
|
|
78420
|
-
|
|
78421
|
-
|
|
78422
|
-
|
|
78423
|
-
|
|
78424
|
-
|
|
78425
|
-
socket.disconnect();
|
|
78426
|
-
socket.connect();
|
|
78006
|
+
redial: redial2,
|
|
78007
|
+
recoverAfterWake: () => {
|
|
78008
|
+
wake.recovering ??= recover().finally(() => {
|
|
78009
|
+
wake.recovering = null;
|
|
78010
|
+
});
|
|
78011
|
+
return wake.recovering;
|
|
78427
78012
|
},
|
|
78428
78013
|
pushCapabilities,
|
|
78429
78014
|
[Symbol.asyncDispose]: async () => {
|
|
78015
|
+
closing.abort();
|
|
78430
78016
|
cancelRedial();
|
|
78431
78017
|
socket.removeAllListeners();
|
|
78432
78018
|
socket.disconnect();
|
|
@@ -78591,7 +78177,7 @@ function createReconciler(host, lifecycle, log, signal) {
|
|
|
78591
78177
|
}
|
|
78592
78178
|
|
|
78593
78179
|
// src/uploader/index.ts
|
|
78594
|
-
var
|
|
78180
|
+
var import_promises78 = require("fs/promises");
|
|
78595
78181
|
init_runtime_v2();
|
|
78596
78182
|
init_zod();
|
|
78597
78183
|
var RETRY_DELAYS_MS = [250, 500, 1e3, 2e3, 5e3, 1e4, 3e4];
|
|
@@ -78611,6 +78197,7 @@ function startUploader({ api, runsDir, clock, log, archive }) {
|
|
|
78611
78197
|
const active = /* @__PURE__ */ new Map();
|
|
78612
78198
|
const again = /* @__PURE__ */ new Set();
|
|
78613
78199
|
const sealed = /* @__PURE__ */ new Set();
|
|
78200
|
+
const receiptBackoff = /* @__PURE__ */ new Map();
|
|
78614
78201
|
const reject = async (runId, progressPath, progress, rejection2) => {
|
|
78615
78202
|
log.error("upload.rejected", { runId, status: rejection2.status, message: rejection2.message });
|
|
78616
78203
|
if (rejection2.status === UNAUTHORIZED) return;
|
|
@@ -78624,6 +78211,7 @@ function startUploader({ api, runsDir, clock, log, archive }) {
|
|
|
78624
78211
|
const receipt = await api.readReceipt(target, controller.signal);
|
|
78625
78212
|
switch (receipt.kind) {
|
|
78626
78213
|
case "read": {
|
|
78214
|
+
receiptBackoff.delete(runId);
|
|
78627
78215
|
log.debug("upload.resumed", {
|
|
78628
78216
|
runId,
|
|
78629
78217
|
admittedOffset: receipt.receipt?.admittedOffset ?? 0
|
|
@@ -78635,8 +78223,12 @@ function startUploader({ api, runsDir, clock, log, archive }) {
|
|
|
78635
78223
|
case "rejected":
|
|
78636
78224
|
await reject(runId, path4, progressFromReceipt(null), receipt);
|
|
78637
78225
|
return null;
|
|
78638
|
-
case "retry":
|
|
78226
|
+
case "retry": {
|
|
78227
|
+
const failures = (receiptBackoff.get(runId)?.failures ?? 0) + 1;
|
|
78228
|
+
const delayMs = RETRY_DELAYS_MS[Math.min(failures, RETRY_DELAYS_MS.length - 1)] ?? 3e4;
|
|
78229
|
+
receiptBackoff.set(runId, { failures, notBefore: clock.now() + delayMs });
|
|
78639
78230
|
throw new RuntimeFault("io_failed", `Receipt request failed: ${receipt.status}`);
|
|
78231
|
+
}
|
|
78640
78232
|
default:
|
|
78641
78233
|
return assertNever2(receipt);
|
|
78642
78234
|
}
|
|
@@ -78711,6 +78303,8 @@ function startUploader({ api, runsDir, clock, log, archive }) {
|
|
|
78711
78303
|
const meta3 = await readRunMeta(dir.meta);
|
|
78712
78304
|
if (meta3 === null) return;
|
|
78713
78305
|
const target = { conversationId: meta3.conversationId, runId };
|
|
78306
|
+
const backoff = receiptBackoff.get(runId);
|
|
78307
|
+
if (backoff !== void 0 && backoff.notBefore > clock.now()) return;
|
|
78714
78308
|
const progress = await progressOf(runId, target, dir.upload);
|
|
78715
78309
|
if (progress?.sealed) sealed.add(runId);
|
|
78716
78310
|
if (progress === null || progress.sealed) return;
|
|
@@ -78739,7 +78333,7 @@ function startUploader({ api, runsDir, clock, log, archive }) {
|
|
|
78739
78333
|
};
|
|
78740
78334
|
const unsealedRunIds = async () => {
|
|
78741
78335
|
const runIds = [];
|
|
78742
|
-
for (const name of await (0,
|
|
78336
|
+
for (const name of await (0, import_promises78.readdir)(runsDir).catch(() => [])) {
|
|
78743
78337
|
const runId = runIdSchema.safeParse(name);
|
|
78744
78338
|
if (runId.success && !sealed.has(runId.data) && !archive?.has(runId.data))
|
|
78745
78339
|
runIds.push(runId.data);
|
|
@@ -78754,13 +78348,13 @@ function startUploader({ api, runsDir, clock, log, archive }) {
|
|
|
78754
78348
|
const dir = runDirectory(runsDir, runId);
|
|
78755
78349
|
const progress = await readJsonFile(dir.upload, uploadProgressSchema);
|
|
78756
78350
|
if (progress.kind !== "ok" || !progress.value.sealed) return false;
|
|
78757
|
-
const sealedAt = (await (0,
|
|
78351
|
+
const sealedAt = (await (0, import_promises78.stat)(dir.upload)).mtimeMs;
|
|
78758
78352
|
if (clock.now() - sealedAt < options.sealedForMs) return false;
|
|
78759
78353
|
return (await readLastRecord(dir.log))?.update.sessionUpdate === "_alan/run.ended";
|
|
78760
78354
|
};
|
|
78761
78355
|
const archivable = async (options) => {
|
|
78762
78356
|
const found = [];
|
|
78763
|
-
for (const name of await (0,
|
|
78357
|
+
for (const name of await (0, import_promises78.readdir)(runsDir).catch(() => [])) {
|
|
78764
78358
|
const runId = runIdSchema.safeParse(name);
|
|
78765
78359
|
if (!runId.success || archive?.has(runId.data)) continue;
|
|
78766
78360
|
try {
|
|
@@ -78962,12 +78556,12 @@ async function startMachineNativeIngest(deps) {
|
|
|
78962
78556
|
}
|
|
78963
78557
|
|
|
78964
78558
|
// src/cli/commands/run-updates.ts
|
|
78965
|
-
var
|
|
78559
|
+
var import_node_path80 = require("path");
|
|
78966
78560
|
init_runtime_v2();
|
|
78967
78561
|
var UPDATE_CHECK_EVERY_MS = 6 * 60 * 60 * 1e3;
|
|
78968
78562
|
var DEFERRED_RETRY_MS = 5 * 60 * 1e3;
|
|
78969
78563
|
function isInstalledBundle(layout, bundlePath) {
|
|
78970
|
-
return (0,
|
|
78564
|
+
return (0, import_node_path80.resolve)((0, import_node_path80.dirname)((0, import_node_path80.dirname)(bundlePath))) === (0, import_node_path80.resolve)(layout.versions);
|
|
78971
78565
|
}
|
|
78972
78566
|
async function settleUpgradeOnStart({
|
|
78973
78567
|
layout,
|
|
@@ -79074,7 +78668,7 @@ function startRuntimeUpdates(options) {
|
|
|
79074
78668
|
layout,
|
|
79075
78669
|
release: npmRelease,
|
|
79076
78670
|
tarball: await options.downloader.download(npmRelease.dist.tarball, signal),
|
|
79077
|
-
tmpDir: (0,
|
|
78671
|
+
tmpDir: (0, import_node_path80.join)(layout.root, ".downloads")
|
|
79078
78672
|
});
|
|
79079
78673
|
await lifecycle.exclusive("upgrade", async () => {
|
|
79080
78674
|
await recordPendingUpgrade(layout, currentVersion2, version2, clock.now());
|
|
@@ -79307,7 +78901,7 @@ async function startMachinePlane(deps) {
|
|
|
79307
78901
|
[ALAN_MANAGED_SESSION_ENV]: "1"
|
|
79308
78902
|
},
|
|
79309
78903
|
cwd: paths.stateDir,
|
|
79310
|
-
outputPath: (0,
|
|
78904
|
+
outputPath: (0, import_node_path81.join)(paths.logs, "holders.log")
|
|
79311
78905
|
},
|
|
79312
78906
|
deps.holderIsolation
|
|
79313
78907
|
);
|
|
@@ -79344,7 +78938,7 @@ async function startMachinePlane(deps) {
|
|
|
79344
78938
|
}),
|
|
79345
78939
|
local: { home: config2.home, machineId: identity.machineId },
|
|
79346
78940
|
// Only a cloud sandbox's runtime has a git gateway; a person's own ~/.codex is theirs.
|
|
79347
|
-
...config2.gitGatewayUrl === null ? {} : { codexSkillsDir: (0,
|
|
78941
|
+
...config2.gitGatewayUrl === null ? {} : { codexSkillsDir: (0, import_node_path81.join)(config2.codexHome, "skills") },
|
|
79348
78942
|
log
|
|
79349
78943
|
})
|
|
79350
78944
|
);
|
|
@@ -79546,7 +79140,7 @@ async function startMachinePlane(deps) {
|
|
|
79546
79140
|
git: createGitRunner({ env: cliEnvironment }),
|
|
79547
79141
|
clock,
|
|
79548
79142
|
log,
|
|
79549
|
-
dir: (0,
|
|
79143
|
+
dir: (0, import_node_path81.join)(paths.stateDir, "checkout-freshness")
|
|
79550
79144
|
},
|
|
79551
79145
|
stopped.signal
|
|
79552
79146
|
);
|
|
@@ -79575,8 +79169,9 @@ async function startMachinePlane(deps) {
|
|
|
79575
79169
|
jobs: [
|
|
79576
79170
|
wakeJob(clock, (sleptMs) => {
|
|
79577
79171
|
log.info("runtime.woke", { sleptMs });
|
|
79578
|
-
link.
|
|
79579
|
-
|
|
79172
|
+
link.recoverAfterWake().then((recovery) => {
|
|
79173
|
+
if (recovery === "alive") refreshDesired();
|
|
79174
|
+
}).catch((error61) => log.warn("runtime.wake_recovery_failed", { error: error61 }));
|
|
79580
79175
|
})
|
|
79581
79176
|
],
|
|
79582
79177
|
clock,
|
|
@@ -79808,11 +79403,11 @@ function createMachineSlot(deps) {
|
|
|
79808
79403
|
|
|
79809
79404
|
// src/cli/commands/run-exit.ts
|
|
79810
79405
|
function firstAborted(signals) {
|
|
79811
|
-
return new Promise((
|
|
79406
|
+
return new Promise((resolve13) => {
|
|
79812
79407
|
for (const reason of ["stop", "restart"]) {
|
|
79813
79408
|
const signal = signals[reason];
|
|
79814
|
-
if (signal.aborted)
|
|
79815
|
-
signal.addEventListener("abort", () =>
|
|
79409
|
+
if (signal.aborted) resolve13(reason);
|
|
79410
|
+
signal.addEventListener("abort", () => resolve13(reason), { once: true });
|
|
79816
79411
|
}
|
|
79817
79412
|
});
|
|
79818
79413
|
}
|
|
@@ -79840,7 +79435,7 @@ function lockWaitMs(argv) {
|
|
|
79840
79435
|
}
|
|
79841
79436
|
async function openManagedProviders(config2, paths) {
|
|
79842
79437
|
const providerEnv = readCliEnvironment();
|
|
79843
|
-
const bundledNpm = (0,
|
|
79438
|
+
const bundledNpm = (0, import_node_path82.join)((0, import_node_path82.dirname)(process.execPath), "npm", "bin", "npm-cli.js");
|
|
79844
79439
|
const providerToolchain = config2.providerToolchain ?? (process.platform === "win32" && (0, import_node_fs24.existsSync)(bundledNpm) ? { node: process.execPath, npmCli: bundledNpm } : null);
|
|
79845
79440
|
const npmPath = providerToolchain?.node ?? await resolveCommandOnPath("npm", providerEnv, process.platform);
|
|
79846
79441
|
const npmOptions = npmPath === null || process.platform === "win32" && providerToolchain === null ? null : {
|
|
@@ -79848,7 +79443,7 @@ async function openManagedProviders(config2, paths) {
|
|
|
79848
79443
|
...providerToolchain === null ? {} : { argsBeforeNpm: [providerToolchain.npmCli] },
|
|
79849
79444
|
env: providerEnv
|
|
79850
79445
|
};
|
|
79851
|
-
const providerNodeDir = providerToolchain?.node === void 0 ? void 0 : (0,
|
|
79446
|
+
const providerNodeDir = providerToolchain?.node === void 0 ? void 0 : (0, import_node_path82.dirname)(providerToolchain.node);
|
|
79852
79447
|
const probeEnv = providerNodeDir === void 0 ? providerEnv : {
|
|
79853
79448
|
...providerEnv,
|
|
79854
79449
|
PATH: `${providerNodeDir}${pathDelimiter(process.platform)}${envValue(providerEnv, "PATH")}`
|
|
@@ -79858,7 +79453,7 @@ async function openManagedProviders(config2, paths) {
|
|
|
79858
79453
|
throw new Error("Provider installer is unavailable on this computer");
|
|
79859
79454
|
};
|
|
79860
79455
|
const managed = createManagedProviderClis({
|
|
79861
|
-
root: (0,
|
|
79456
|
+
root: (0, import_node_path82.join)(paths.stateDir, "provider-clis"),
|
|
79862
79457
|
resolveVersion: npmOptions === null ? unavailable : createNpmVersionResolver(npmOptions),
|
|
79863
79458
|
installPackage: npmOptions === null ? unavailable : createNpmPackageInstaller(npmOptions),
|
|
79864
79459
|
probe: (executable, backendKind) => probeManagedProvider(executable, backendKind, canonicalProbeEnv)
|
|
@@ -79890,7 +79485,7 @@ async function runService(argv, stop, restart = new AbortController().signal) {
|
|
|
79890
79485
|
waitMs: lockWaitMs(argv),
|
|
79891
79486
|
signal: stop
|
|
79892
79487
|
}));
|
|
79893
|
-
const log = __using(_stack, openFileLog((0,
|
|
79488
|
+
const log = __using(_stack, openFileLog((0, import_node_path82.join)(paths.logs, "runtime.jsonl"), config2.logLevel, clock));
|
|
79894
79489
|
const lifecycle = createLifecycleQueue({ clock, log });
|
|
79895
79490
|
const install2 = installLayout(config2.installDir, config2.profile);
|
|
79896
79491
|
const bundlePath = process.argv[1] ?? "";
|
|
@@ -79924,7 +79519,7 @@ async function runService(argv, stop, restart = new AbortController().signal) {
|
|
|
79924
79519
|
openCliEnvironment({
|
|
79925
79520
|
env: readCliEnvironment(),
|
|
79926
79521
|
platform: process.platform,
|
|
79927
|
-
lastKnownGoodFile: (0,
|
|
79522
|
+
lastKnownGoodFile: (0, import_node_path82.join)(paths.stateDir, "login-path.json"),
|
|
79928
79523
|
clock,
|
|
79929
79524
|
decorate: (env) => withPackagedAlanCodeEngine(env, bundlePath, process.platform)
|
|
79930
79525
|
})
|
|
@@ -80101,17 +79696,17 @@ async function runServiceCommand(argv, ctx = cliContext()) {
|
|
|
80101
79696
|
}
|
|
80102
79697
|
|
|
80103
79698
|
// src/cli/commands/upgrade.ts
|
|
80104
|
-
var
|
|
80105
|
-
var
|
|
79699
|
+
var import_promises79 = require("fs/promises");
|
|
79700
|
+
var import_node_path83 = require("path");
|
|
80106
79701
|
function isNotNewer(version2, installed) {
|
|
80107
79702
|
return installed !== null && isReleaseVersion(version2) && isReleaseVersion(installed) && compareVersions(version2, installed) <= 0;
|
|
80108
79703
|
}
|
|
80109
79704
|
async function installFromSource(source) {
|
|
80110
79705
|
const { layout, from, ifNewer } = source;
|
|
80111
|
-
const isTarball = (await (0,
|
|
80112
|
-
const downloads = (0,
|
|
80113
|
-
if (isTarball) await (0,
|
|
80114
|
-
const scratch = isTarball ? await (0,
|
|
79706
|
+
const isTarball = (await (0, import_promises79.stat)(from)).isFile();
|
|
79707
|
+
const downloads = (0, import_node_path83.join)(layout.root, ".downloads");
|
|
79708
|
+
if (isTarball) await (0, import_promises79.mkdir)(downloads, { recursive: true, mode: 448 });
|
|
79709
|
+
const scratch = isTarball ? await (0, import_promises79.mkdtemp)((0, import_node_path83.join)(downloads, "upgrade-")) : null;
|
|
80115
79710
|
try {
|
|
80116
79711
|
const sourceDir = scratch === null ? from : await extractPackageTarball(from, scratch);
|
|
80117
79712
|
const version2 = await readPackageVersion(sourceDir);
|
|
@@ -80119,7 +79714,7 @@ async function installFromSource(source) {
|
|
|
80119
79714
|
if (ifNewer && isNotNewer(version2, installed)) return { kind: "skipped", version: version2, installed };
|
|
80120
79715
|
return { kind: "installed", ...await installVersion(layout, sourceDir) };
|
|
80121
79716
|
} finally {
|
|
80122
|
-
if (scratch !== null) await (0,
|
|
79717
|
+
if (scratch !== null) await (0, import_promises79.rm)(scratch, { recursive: true, force: true });
|
|
80123
79718
|
}
|
|
80124
79719
|
}
|
|
80125
79720
|
async function runUpgrade(argv) {
|
|
@@ -80131,7 +79726,7 @@ async function runUpgrade(argv) {
|
|
|
80131
79726
|
const layout = installLayout(config2.installDir, config2.profile);
|
|
80132
79727
|
const outcome2 = await installFromSource({
|
|
80133
79728
|
layout,
|
|
80134
|
-
from: (0,
|
|
79729
|
+
from: (0, import_node_path83.resolve)(from),
|
|
80135
79730
|
ifNewer: hasFlag(argv, "--if-newer")
|
|
80136
79731
|
});
|
|
80137
79732
|
if (outcome2.kind === "skipped") {
|
|
@@ -80337,7 +79932,8 @@ keeps running and waits for setup.
|
|
|
80337
79932
|
|
|
80338
79933
|
While a turn runs it holds an idle-sleep assertion (macOS caffeinate -i, Linux
|
|
80339
79934
|
systemd-inhibit --what=idle), never the display and never a sleep you ask for. After
|
|
80340
|
-
the computer wakes it
|
|
79935
|
+
the computer wakes it checks its link to Alan, redials if the link has gone quiet, and
|
|
79936
|
+
re-reads its work.
|
|
80341
79937
|
|
|
80342
79938
|
Exit codes: 0 stopped; 75 restart requested;
|
|
80343
79939
|
73 another runtime holds the lock; 78 invalid configuration;
|