claude-use 11.48.0 → 11.49.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.cjs +663 -454
- package/dist/index.cjs +431 -291
- package/dist/index.mjs +429 -290
- package/dist/types/index.d.ts +41 -4
- package/package.json +1 -1
package/dist/cli.cjs
CHANGED
|
@@ -27490,10 +27490,10 @@ var init_schema = __esm({
|
|
|
27490
27490
|
});
|
|
27491
27491
|
|
|
27492
27492
|
// src/frontdoor/state.ts
|
|
27493
|
-
function readFrontDoorState(
|
|
27493
|
+
function readFrontDoorState(fs29, stateFile) {
|
|
27494
27494
|
let raw;
|
|
27495
27495
|
try {
|
|
27496
|
-
raw =
|
|
27496
|
+
raw = fs29.readFileUtf8(stateFile);
|
|
27497
27497
|
} catch {
|
|
27498
27498
|
return void 0;
|
|
27499
27499
|
}
|
|
@@ -27507,9 +27507,9 @@ function readFrontDoorState(fs28, stateFile) {
|
|
|
27507
27507
|
return void 0;
|
|
27508
27508
|
}
|
|
27509
27509
|
}
|
|
27510
|
-
function writeFrontDoorState(
|
|
27511
|
-
|
|
27512
|
-
|
|
27510
|
+
function writeFrontDoorState(fs29, stateFile, state) {
|
|
27511
|
+
fs29.mkdirp(import_node_path5.default.dirname(stateFile));
|
|
27512
|
+
fs29.writeFilePrivate(stateFile, `${JSON.stringify(state, null, 2)}
|
|
27513
27513
|
`);
|
|
27514
27514
|
}
|
|
27515
27515
|
function directOrigin(port) {
|
|
@@ -27519,27 +27519,37 @@ function frontDoorOrigin(state) {
|
|
|
27519
27519
|
const port = state?.directPort ?? state?.lastDirectPort;
|
|
27520
27520
|
return port === void 0 ? void 0 : directOrigin(port);
|
|
27521
27521
|
}
|
|
27522
|
-
function writeFrontDoorDirectRecord(
|
|
27523
|
-
|
|
27524
|
-
|
|
27522
|
+
function writeFrontDoorDirectRecord(fs29, recordsDir, record2) {
|
|
27523
|
+
fs29.mkdirp(recordsDir);
|
|
27524
|
+
fs29.writeFilePrivate(import_node_path5.default.join(recordsDir, `${String(record2.pid)}.json`), `${JSON.stringify({ directPort: record2.directPort })}
|
|
27525
27525
|
`);
|
|
27526
27526
|
}
|
|
27527
|
-
function removeFrontDoorDirectRecord(
|
|
27528
|
-
|
|
27527
|
+
function removeFrontDoorDirectRecord(fs29, recordsDir, pid) {
|
|
27528
|
+
fs29.removeRecursive(import_node_path5.default.join(recordsDir, `${String(pid)}.json`));
|
|
27529
|
+
}
|
|
27530
|
+
function markFrontDoorDraining(fs29, markersDir, pid) {
|
|
27531
|
+
fs29.mkdirp(markersDir);
|
|
27532
|
+
fs29.writeFilePrivate(import_node_path5.default.join(markersDir, String(pid)), "\n");
|
|
27533
|
+
}
|
|
27534
|
+
function unmarkFrontDoorDraining(fs29, markersDir, pid) {
|
|
27535
|
+
fs29.removeRecursive(import_node_path5.default.join(markersDir, String(pid)));
|
|
27536
|
+
}
|
|
27537
|
+
function listDrainingFrontDoors(fs29, markersDir, isRunning) {
|
|
27538
|
+
return fs29.readdir(markersDir).flatMap((file2) => /^[1-9]\d*$/.test(file2) && Number.isSafeInteger(Number(file2)) ? [Number(file2)] : []).filter(isRunning).sort((a10, b) => a10 - b);
|
|
27529
27539
|
}
|
|
27530
27540
|
function recordPid(file2) {
|
|
27531
27541
|
const pidText = /^([1-9]\d*)\.json$/.exec(file2)?.[1];
|
|
27532
27542
|
const pid = pidText === void 0 ? void 0 : Number(pidText);
|
|
27533
27543
|
return pid !== void 0 && Number.isSafeInteger(pid) ? pid : void 0;
|
|
27534
27544
|
}
|
|
27535
|
-
function readDirectRecordEntry(
|
|
27545
|
+
function readDirectRecordEntry(fs29, recordsDir, file2) {
|
|
27536
27546
|
const pid = recordPid(file2);
|
|
27537
27547
|
if (pid === void 0) {
|
|
27538
27548
|
return void 0;
|
|
27539
27549
|
}
|
|
27540
27550
|
let raw;
|
|
27541
27551
|
try {
|
|
27542
|
-
raw =
|
|
27552
|
+
raw = fs29.readFileUtf8(import_node_path5.default.join(recordsDir, file2));
|
|
27543
27553
|
} catch {
|
|
27544
27554
|
return void 0;
|
|
27545
27555
|
}
|
|
@@ -27553,47 +27563,47 @@ function readDirectRecordEntry(fs28, recordsDir, file2) {
|
|
|
27553
27563
|
return { malformed: true };
|
|
27554
27564
|
}
|
|
27555
27565
|
}
|
|
27556
|
-
function listFrontDoorDirectRecords(
|
|
27557
|
-
return
|
|
27558
|
-
const entry = readDirectRecordEntry(
|
|
27566
|
+
function listFrontDoorDirectRecords(fs29, recordsDir) {
|
|
27567
|
+
return fs29.readdir(recordsDir).flatMap((file2) => {
|
|
27568
|
+
const entry = readDirectRecordEntry(fs29, recordsDir, file2);
|
|
27559
27569
|
return entry?.record === void 0 ? [] : [entry.record];
|
|
27560
27570
|
}).sort((a10, b) => a10.pid - b.pid);
|
|
27561
27571
|
}
|
|
27562
|
-
function pruneMalformedFrontDoorDirectFiles(
|
|
27563
|
-
for (const file2 of
|
|
27572
|
+
function pruneMalformedFrontDoorDirectFiles(fs29, recordsDir, isRunning) {
|
|
27573
|
+
for (const file2 of fs29.readdir(recordsDir)) {
|
|
27564
27574
|
const writer = RECORD_TEMPORARY_FILE.exec(file2)?.[1];
|
|
27565
27575
|
const stale = writer !== void 0 && !isRunning(Number(writer));
|
|
27566
|
-
if (stale || readDirectRecordEntry(
|
|
27567
|
-
|
|
27576
|
+
if (stale || readDirectRecordEntry(fs29, recordsDir, file2)?.malformed === true) {
|
|
27577
|
+
fs29.removeRecursive(import_node_path5.default.join(recordsDir, file2));
|
|
27568
27578
|
}
|
|
27569
27579
|
}
|
|
27570
27580
|
}
|
|
27571
27581
|
function liveFrontDoorDirectRecords(records, liveness) {
|
|
27572
27582
|
return records.filter((record2) => liveness.doors.has(record2.pid) || liveness.unknown.has(record2.pid));
|
|
27573
27583
|
}
|
|
27574
|
-
function pruneDeadFrontDoorDirectRecords(
|
|
27584
|
+
function pruneDeadFrontDoorDirectRecords(fs29, recordsDir, records, liveness) {
|
|
27575
27585
|
for (const record2 of records) {
|
|
27576
27586
|
if (!liveness.doors.has(record2.pid) && !liveness.unknown.has(record2.pid)) {
|
|
27577
|
-
removeFrontDoorDirectRecord(
|
|
27587
|
+
removeFrontDoorDirectRecord(fs29, recordsDir, record2.pid);
|
|
27578
27588
|
}
|
|
27579
27589
|
}
|
|
27580
27590
|
}
|
|
27581
27591
|
function recordOf(details) {
|
|
27582
27592
|
return details === void 0 ? {} : { sessionId: details.sessionId, ...details.models === void 0 ? {} : { models: details.models } };
|
|
27583
27593
|
}
|
|
27584
|
-
function writeFrontDoorSession(
|
|
27585
|
-
|
|
27586
|
-
|
|
27594
|
+
function writeFrontDoorSession(fs29, sessionsDir, session) {
|
|
27595
|
+
fs29.mkdirPrivate(sessionsDir);
|
|
27596
|
+
fs29.writeFilePrivate(import_node_path5.default.join(sessionsDir, `${String(session.pid)}.json`), `${JSON.stringify(session, null, 2)}
|
|
27587
27597
|
`);
|
|
27588
27598
|
}
|
|
27589
|
-
function listFrontDoorSessions(
|
|
27599
|
+
function listFrontDoorSessions(fs29, sessionsDir) {
|
|
27590
27600
|
const sessions = [];
|
|
27591
|
-
for (const name of
|
|
27601
|
+
for (const name of fs29.readdir(sessionsDir)) {
|
|
27592
27602
|
if (!name.endsWith(".json")) {
|
|
27593
27603
|
continue;
|
|
27594
27604
|
}
|
|
27595
27605
|
try {
|
|
27596
|
-
const parsed = FrontDoorSessionSchema.safeParse(JSON.parse(
|
|
27606
|
+
const parsed = FrontDoorSessionSchema.safeParse(JSON.parse(fs29.readFileUtf8(import_node_path5.default.join(sessionsDir, name)) ?? ""));
|
|
27597
27607
|
if (parsed.success) {
|
|
27598
27608
|
sessions.push({ pid: parsed.data.pid, startedAt: parsed.data.startedAt, ...parsed.data.supervisorPid === void 0 ? {} : { supervisorPid: parsed.data.supervisorPid } });
|
|
27599
27609
|
}
|
|
@@ -27603,27 +27613,27 @@ function listFrontDoorSessions(fs28, sessionsDir) {
|
|
|
27603
27613
|
}
|
|
27604
27614
|
return sessions.sort((a10, b) => a10.pid - b.pid);
|
|
27605
27615
|
}
|
|
27606
|
-
function removeFrontDoorSession(
|
|
27607
|
-
|
|
27616
|
+
function removeFrontDoorSession(fs29, sessionsDir, pid) {
|
|
27617
|
+
fs29.removeRecursive(import_node_path5.default.join(sessionsDir, `${String(pid)}.json`));
|
|
27608
27618
|
}
|
|
27609
|
-
function pruneDeadFrontDoorSessions(
|
|
27619
|
+
function pruneDeadFrontDoorSessions(fs29, sessionsDir, isRunning) {
|
|
27610
27620
|
const removed = [];
|
|
27611
|
-
for (const session of listFrontDoorSessions(
|
|
27621
|
+
for (const session of listFrontDoorSessions(fs29, sessionsDir)) {
|
|
27612
27622
|
if (!isRunning(session.pid)) {
|
|
27613
|
-
removeFrontDoorSession(
|
|
27623
|
+
removeFrontDoorSession(fs29, sessionsDir, session.pid);
|
|
27614
27624
|
removed.push(session.pid);
|
|
27615
27625
|
}
|
|
27616
27626
|
}
|
|
27617
27627
|
return removed;
|
|
27618
27628
|
}
|
|
27619
|
-
function liveSessionTokens(
|
|
27629
|
+
function liveSessionTokens(fs29, sessionsDir) {
|
|
27620
27630
|
const tokens = /* @__PURE__ */ new Set();
|
|
27621
|
-
for (const name of
|
|
27631
|
+
for (const name of fs29.readdir(sessionsDir)) {
|
|
27622
27632
|
if (!name.endsWith(".json")) {
|
|
27623
27633
|
continue;
|
|
27624
27634
|
}
|
|
27625
27635
|
try {
|
|
27626
|
-
const parsed = FrontDoorSessionSchema.safeParse(JSON.parse(
|
|
27636
|
+
const parsed = FrontDoorSessionSchema.safeParse(JSON.parse(fs29.readFileUtf8(import_node_path5.default.join(sessionsDir, name)) ?? ""));
|
|
27627
27637
|
if (parsed.success) {
|
|
27628
27638
|
tokens.add(parsed.data.token);
|
|
27629
27639
|
}
|
|
@@ -27633,13 +27643,13 @@ function liveSessionTokens(fs28, sessionsDir) {
|
|
|
27633
27643
|
}
|
|
27634
27644
|
return tokens;
|
|
27635
27645
|
}
|
|
27636
|
-
function readFrontDoorSessionModels(
|
|
27637
|
-
for (const name of
|
|
27646
|
+
function readFrontDoorSessionModels(fs29, sessionsDir, sessionId) {
|
|
27647
|
+
for (const name of fs29.readdir(sessionsDir)) {
|
|
27638
27648
|
if (!name.endsWith(".json")) {
|
|
27639
27649
|
continue;
|
|
27640
27650
|
}
|
|
27641
27651
|
try {
|
|
27642
|
-
const parsed = FrontDoorSessionSchema.safeParse(JSON.parse(
|
|
27652
|
+
const parsed = FrontDoorSessionSchema.safeParse(JSON.parse(fs29.readFileUtf8(import_node_path5.default.join(sessionsDir, name)) ?? ""));
|
|
27643
27653
|
if (parsed.success && parsed.data.sessionId === sessionId) {
|
|
27644
27654
|
return parsed.data.models;
|
|
27645
27655
|
}
|
|
@@ -27702,43 +27712,43 @@ function parseJson(raw, schema) {
|
|
|
27702
27712
|
const parsed = schema.safeParse(JSON.parse(raw));
|
|
27703
27713
|
return parsed.success ? parsed.data : void 0;
|
|
27704
27714
|
}
|
|
27705
|
-
function readHeadroomState(
|
|
27715
|
+
function readHeadroomState(fs29, stateFile) {
|
|
27706
27716
|
try {
|
|
27707
|
-
return parseJson(
|
|
27717
|
+
return parseJson(fs29.readFileUtf8(stateFile), HeadroomStateSchema);
|
|
27708
27718
|
} catch {
|
|
27709
27719
|
return void 0;
|
|
27710
27720
|
}
|
|
27711
27721
|
}
|
|
27712
|
-
function writeHeadroomState(
|
|
27713
|
-
|
|
27714
|
-
|
|
27722
|
+
function writeHeadroomState(fs29, stateFile, state) {
|
|
27723
|
+
fs29.mkdirp(import_node_path6.default.dirname(stateFile));
|
|
27724
|
+
fs29.writeFilePrivate(stateFile, `${JSON.stringify(state, null, 2)}
|
|
27715
27725
|
`);
|
|
27716
27726
|
}
|
|
27717
|
-
function resolveServingHeadroomState(
|
|
27718
|
-
const current = readHeadroomState(
|
|
27727
|
+
function resolveServingHeadroomState(fs29, files, isRunning) {
|
|
27728
|
+
const current = readHeadroomState(fs29, files.stateFile);
|
|
27719
27729
|
if (current !== void 0) {
|
|
27720
27730
|
return { path: files.stateFile, state: current };
|
|
27721
27731
|
}
|
|
27722
|
-
const legacy = readHeadroomState(
|
|
27732
|
+
const legacy = readHeadroomState(fs29, files.legacyStateFile);
|
|
27723
27733
|
if (legacy?.supervisorPid !== void 0 && isRunning(legacy.supervisorPid)) {
|
|
27724
27734
|
return { path: files.legacyStateFile, state: legacy };
|
|
27725
27735
|
}
|
|
27726
27736
|
return void 0;
|
|
27727
27737
|
}
|
|
27728
|
-
function migrateHeadroomState(
|
|
27729
|
-
const legacy = readHeadroomState(
|
|
27738
|
+
function migrateHeadroomState(fs29, files, isRunning) {
|
|
27739
|
+
const legacy = readHeadroomState(fs29, files.legacyStateFile);
|
|
27730
27740
|
const legacyLive = legacy?.supervisorPid !== void 0 && isRunning(legacy.supervisorPid);
|
|
27731
|
-
const current = readHeadroomState(
|
|
27741
|
+
const current = readHeadroomState(fs29, files.stateFile);
|
|
27732
27742
|
if (current !== void 0 || legacyLive) {
|
|
27733
|
-
if (!legacyLive &&
|
|
27734
|
-
|
|
27743
|
+
if (!legacyLive && fs29.readFileUtf8(files.legacyStateFile) !== void 0) {
|
|
27744
|
+
fs29.removeRecursive(files.legacyStateFile);
|
|
27735
27745
|
}
|
|
27736
27746
|
return;
|
|
27737
27747
|
}
|
|
27738
27748
|
if (legacy !== void 0) {
|
|
27739
|
-
writeHeadroomState(
|
|
27749
|
+
writeHeadroomState(fs29, files.stateFile, legacy);
|
|
27740
27750
|
}
|
|
27741
|
-
|
|
27751
|
+
fs29.removeRecursive(files.legacyStateFile);
|
|
27742
27752
|
}
|
|
27743
27753
|
function hashAllowlist(allowlist) {
|
|
27744
27754
|
return (0, import_node_crypto2.createHash)("sha256").update(allowlist.join("\n")).digest("hex");
|
|
@@ -27771,27 +27781,27 @@ function isAdmissibleUrl(entry) {
|
|
|
27771
27781
|
function parseAllowlistFile(content) {
|
|
27772
27782
|
return content.replace(/^\uFEFF/, "").replace(ALLOWLIST_FILE_COMMENT, "").split(ALLOWLIST_FILE_SEPARATORS).map((entry) => entry.replace(ALLOWLIST_SURROUNDING_WHITESPACE, "")).filter((entry) => entry !== "" && !ALLOWLIST_ENTRY_WHITESPACE.test(entry) && (entry.includes("://") ? isAdmissibleUrl(entry) : isBareHost(entry)));
|
|
27773
27783
|
}
|
|
27774
|
-
function writeAllowlistFile(
|
|
27775
|
-
|
|
27776
|
-
|
|
27784
|
+
function writeAllowlistFile(fs29, allowlistFile, allowlist) {
|
|
27785
|
+
fs29.mkdirPrivate(import_node_path6.default.dirname(allowlistFile));
|
|
27786
|
+
fs29.writeFilePrivate(allowlistFile, formatAllowlistFile(allowlist));
|
|
27777
27787
|
}
|
|
27778
|
-
function pruneStaleAllowlistTemporaries(
|
|
27788
|
+
function pruneStaleAllowlistTemporaries(fs29, allowlistFile, isRunning) {
|
|
27779
27789
|
const prefix = `${import_node_path6.default.basename(allowlistFile)}.`;
|
|
27780
|
-
for (const name of
|
|
27790
|
+
for (const name of fs29.readdir(import_node_path6.default.dirname(allowlistFile))) {
|
|
27781
27791
|
const writer = name.startsWith(prefix) ? /^([1-9]\d*)\.tmp$/.exec(name.slice(prefix.length))?.[1] : void 0;
|
|
27782
27792
|
if (writer !== void 0 && !isRunning(Number(writer))) {
|
|
27783
|
-
|
|
27793
|
+
fs29.removeRecursive(import_node_path6.default.join(import_node_path6.default.dirname(allowlistFile), name));
|
|
27784
27794
|
}
|
|
27785
27795
|
}
|
|
27786
27796
|
}
|
|
27787
|
-
function readAllProviders(
|
|
27797
|
+
function readAllProviders(fs29, providersDir) {
|
|
27788
27798
|
const result = [];
|
|
27789
|
-
for (const name of
|
|
27799
|
+
for (const name of fs29.readdir(providersDir)) {
|
|
27790
27800
|
if (!name.endsWith(".json")) {
|
|
27791
27801
|
continue;
|
|
27792
27802
|
}
|
|
27793
27803
|
try {
|
|
27794
|
-
const parsed = parseJson(
|
|
27804
|
+
const parsed = parseJson(fs29.readFileUtf8(import_node_path6.default.join(providersDir, name)), ProviderSchema);
|
|
27795
27805
|
if (parsed !== void 0) {
|
|
27796
27806
|
result.push({ name: name.slice(0, -".json".length), provider: parsed });
|
|
27797
27807
|
}
|
|
@@ -27801,22 +27811,22 @@ function readAllProviders(fs28, providersDir) {
|
|
|
27801
27811
|
}
|
|
27802
27812
|
return result;
|
|
27803
27813
|
}
|
|
27804
|
-
function writeSession(
|
|
27805
|
-
|
|
27806
|
-
|
|
27814
|
+
function writeSession(fs29, sessionsDir, session) {
|
|
27815
|
+
fs29.mkdirp(sessionsDir);
|
|
27816
|
+
fs29.writeFileUtf8(import_node_path6.default.join(sessionsDir, `${String(session.pid)}.json`), `${JSON.stringify(session, null, 2)}
|
|
27807
27817
|
`);
|
|
27808
27818
|
}
|
|
27809
|
-
function removeSession(
|
|
27810
|
-
|
|
27819
|
+
function removeSession(fs29, sessionsDir, pid) {
|
|
27820
|
+
fs29.removeRecursive(import_node_path6.default.join(sessionsDir, `${String(pid)}.json`));
|
|
27811
27821
|
}
|
|
27812
|
-
function listSessions(
|
|
27822
|
+
function listSessions(fs29, sessionsDir) {
|
|
27813
27823
|
const sessions = [];
|
|
27814
|
-
for (const name of
|
|
27824
|
+
for (const name of fs29.readdir(sessionsDir)) {
|
|
27815
27825
|
if (!name.endsWith(".json")) {
|
|
27816
27826
|
continue;
|
|
27817
27827
|
}
|
|
27818
27828
|
try {
|
|
27819
|
-
const parsed = parseJson(
|
|
27829
|
+
const parsed = parseJson(fs29.readFileUtf8(import_node_path6.default.join(sessionsDir, name)), HeadroomSessionSchema);
|
|
27820
27830
|
if (parsed !== void 0) {
|
|
27821
27831
|
sessions.push(parsed);
|
|
27822
27832
|
}
|
|
@@ -27826,22 +27836,22 @@ function listSessions(fs28, sessionsDir) {
|
|
|
27826
27836
|
}
|
|
27827
27837
|
return sessions.sort((a10, b) => a10.pid - b.pid);
|
|
27828
27838
|
}
|
|
27829
|
-
function sessionsForSupervisor(
|
|
27830
|
-
return listSessions(
|
|
27839
|
+
function sessionsForSupervisor(fs29, sessionsDir, supervisorPid) {
|
|
27840
|
+
return listSessions(fs29, sessionsDir).filter((session) => session.supervisorPid === supervisorPid);
|
|
27831
27841
|
}
|
|
27832
|
-
function pruneDeadSessions(
|
|
27842
|
+
function pruneDeadSessions(fs29, sessionsDir, isRunning) {
|
|
27833
27843
|
const removed = [];
|
|
27834
|
-
for (const session of listSessions(
|
|
27844
|
+
for (const session of listSessions(fs29, sessionsDir)) {
|
|
27835
27845
|
if (!isRunning(session.pid)) {
|
|
27836
|
-
removeSession(
|
|
27846
|
+
removeSession(fs29, sessionsDir, session.pid);
|
|
27837
27847
|
removed.push(session.pid);
|
|
27838
27848
|
}
|
|
27839
27849
|
}
|
|
27840
27850
|
return removed;
|
|
27841
27851
|
}
|
|
27842
|
-
function readStartLock(
|
|
27852
|
+
function readStartLock(fs29, lockFile) {
|
|
27843
27853
|
try {
|
|
27844
|
-
return parseJson(
|
|
27854
|
+
return parseJson(fs29.readFileUtf8(lockFile), HeadroomLockSchema);
|
|
27845
27855
|
} catch {
|
|
27846
27856
|
return void 0;
|
|
27847
27857
|
}
|
|
@@ -27934,12 +27944,12 @@ function earlierReleaseAllowlistHash(providers, doorOrigin) {
|
|
|
27934
27944
|
}
|
|
27935
27945
|
return hashAllowlist([...entries].sort());
|
|
27936
27946
|
}
|
|
27937
|
-
function earlierReleaseDaemon(
|
|
27947
|
+
function earlierReleaseDaemon(fs29, paths, daemon) {
|
|
27938
27948
|
if (daemonIdentity(daemon.commandLine, daemon.socketPath) !== "earlier-release") {
|
|
27939
27949
|
return void 0;
|
|
27940
27950
|
}
|
|
27941
|
-
const providers = readAllProviders(
|
|
27942
|
-
const expected = earlierReleaseAllowlistHash(providers, frontDoorOrigin(readFrontDoorState(
|
|
27951
|
+
const providers = readAllProviders(fs29, paths.providersDir).map((entry) => entry.provider);
|
|
27952
|
+
const expected = earlierReleaseAllowlistHash(providers, frontDoorOrigin(readFrontDoorState(fs29, paths.frontdoorStateFile)));
|
|
27943
27953
|
return { admitsServingDoor: daemon.recordedHash === expected };
|
|
27944
27954
|
}
|
|
27945
27955
|
var EARLIER_RELEASE_ALLOWLIST, EARLIER_RELEASE_ANTHROPIC_UPSTREAM;
|
|
@@ -27964,8 +27974,8 @@ function awaitingCause(daemonPid, identity, allowlistFile) {
|
|
|
27964
27974
|
}
|
|
27965
27975
|
return `the headroom supervisor has not written an allowlist admitting this launch's upstreams to ${allowlistFile} within ${String(HEADROOM_START_TIMEOUT_MS)}ms`;
|
|
27966
27976
|
}
|
|
27967
|
-
function daemonAdmits(
|
|
27968
|
-
const content =
|
|
27977
|
+
function daemonAdmits(fs29, allowlistFile, recordedHash, required2) {
|
|
27978
|
+
const content = fs29.readFileUtf8(allowlistFile);
|
|
27969
27979
|
if (content === void 0 || recordedHash === void 0) {
|
|
27970
27980
|
return false;
|
|
27971
27981
|
}
|
|
@@ -28355,7 +28365,7 @@ function verifyAllowlistFile(allowlistFile, ports) {
|
|
|
28355
28365
|
const replaceable = fileStat === void 0 || fileStat.kind === "file" || fileStat.kind === "symlink";
|
|
28356
28366
|
return { message: refusal2, repairable: replaceable };
|
|
28357
28367
|
}
|
|
28358
|
-
function prepareHeadroomSocket(
|
|
28368
|
+
function prepareHeadroomSocket(fs29, ports, paths, supervisorPid) {
|
|
28359
28369
|
const unsupported = platformRefusal(ports.platform);
|
|
28360
28370
|
if (unsupported !== void 0) {
|
|
28361
28371
|
return { refused: unsupported };
|
|
@@ -28370,18 +28380,18 @@ function prepareHeadroomSocket(fs28, ports, paths, supervisorPid) {
|
|
|
28370
28380
|
if (ports.lstat(paths.headroomSocketDir)?.kind === "symlink") {
|
|
28371
28381
|
return { refused: `the headroom socket directory ${paths.headroomSocketDir} is a symlink; it must be the real directory` };
|
|
28372
28382
|
}
|
|
28373
|
-
|
|
28383
|
+
fs29.mkdirPrivate(paths.headroomSocketDir);
|
|
28374
28384
|
const refusal2 = ownerOnlyRefusal("socket directory", paths.headroomSocketDir, ports.lstat(paths.headroomSocketDir), "dir", ports.currentUid());
|
|
28375
28385
|
return refusal2 === void 0 ? { socketPath } : { refused: refusal2 };
|
|
28376
28386
|
}
|
|
28377
|
-
function pruneStaleHeadroomSockets(
|
|
28387
|
+
function pruneStaleHeadroomSockets(fs29, paths, isRunning) {
|
|
28378
28388
|
const removed = [];
|
|
28379
|
-
for (const name of
|
|
28389
|
+
for (const name of fs29.readdir(paths.headroomSocketDir)) {
|
|
28380
28390
|
const pid = HEADROOM_SOCKET_NAME.exec(name)?.[1];
|
|
28381
28391
|
if (pid === void 0 || isRunning(Number.parseInt(pid, 10))) {
|
|
28382
28392
|
continue;
|
|
28383
28393
|
}
|
|
28384
|
-
|
|
28394
|
+
fs29.removeRecursive(import_node_path7.default.join(paths.headroomSocketDir, name));
|
|
28385
28395
|
removed.push(name);
|
|
28386
28396
|
}
|
|
28387
28397
|
return removed;
|
|
@@ -28528,37 +28538,37 @@ function compareVersions2(a10, b) {
|
|
|
28528
28538
|
return 0;
|
|
28529
28539
|
}
|
|
28530
28540
|
async function runSupervisor(initialConfig, ports, options = {}) {
|
|
28531
|
-
const { fs:
|
|
28541
|
+
const { fs: fs29, paths } = ports;
|
|
28532
28542
|
let config2 = initialConfig;
|
|
28533
|
-
migrateHeadroomState(
|
|
28534
|
-
const previousState = resolveServingHeadroomState(
|
|
28543
|
+
migrateHeadroomState(fs29, { stateFile: paths.headroomStateFile, legacyStateFile: paths.headroomLegacyStateFile }, ports.isRunning);
|
|
28544
|
+
const previousState = resolveServingHeadroomState(fs29, { stateFile: paths.headroomStateFile, legacyStateFile: paths.headroomLegacyStateFile }, ports.isRunning)?.state;
|
|
28535
28545
|
if (previousState?.supervisorPid !== void 0 && previousState.supervisorPid !== ports.ownPid && ports.isRunning(previousState.supervisorPid)) {
|
|
28536
28546
|
ports.log(`agent-shim headroom supervisor ${String(ports.ownPid)}: supervisor ${String(previousState.supervisorPid)} already owns the daemon; exiting`);
|
|
28537
28547
|
return 0;
|
|
28538
28548
|
}
|
|
28539
28549
|
let installedSource = previousState?.installedSource;
|
|
28540
28550
|
const ownsState = () => {
|
|
28541
|
-
const owner = readHeadroomState(
|
|
28551
|
+
const owner = readHeadroomState(fs29, paths.headroomStateFile)?.supervisorPid;
|
|
28542
28552
|
return owner === void 0 || owner === ports.ownPid || !ports.isRunning(owner);
|
|
28543
28553
|
};
|
|
28544
28554
|
const writeOwnState = (state) => {
|
|
28545
28555
|
if (!ownsState()) {
|
|
28546
28556
|
return false;
|
|
28547
28557
|
}
|
|
28548
|
-
writeHeadroomState(
|
|
28558
|
+
writeHeadroomState(fs29, paths.headroomStateFile, state);
|
|
28549
28559
|
return true;
|
|
28550
28560
|
};
|
|
28551
28561
|
const fail = (message) => {
|
|
28552
28562
|
if (writeOwnState({ lastError: message })) {
|
|
28553
|
-
|
|
28563
|
+
fs29.removeRecursive(paths.headroomLockFile);
|
|
28554
28564
|
}
|
|
28555
28565
|
ports.log(`agent-shim headroom supervisor: ${message}`);
|
|
28556
28566
|
return 1;
|
|
28557
28567
|
};
|
|
28558
28568
|
const syncAllowlistFile = (allowlist) => {
|
|
28559
28569
|
try {
|
|
28560
|
-
if (
|
|
28561
|
-
writeAllowlistFile(
|
|
28570
|
+
if (fs29.readFileUtf8(paths.headroomAllowlistFile) !== formatAllowlistFile(allowlist)) {
|
|
28571
|
+
writeAllowlistFile(fs29, paths.headroomAllowlistFile, allowlist);
|
|
28562
28572
|
ports.log(`agent-shim headroom supervisor: wrote allowlist [${allowlist.join(", ")}] to ${paths.headroomAllowlistFile}`);
|
|
28563
28573
|
}
|
|
28564
28574
|
return void 0;
|
|
@@ -28576,9 +28586,9 @@ async function runSupervisor(initialConfig, ports, options = {}) {
|
|
|
28576
28586
|
}
|
|
28577
28587
|
ports.log(`agent-shim headroom supervisor: repairing the allowlist file: ${problem.message}`);
|
|
28578
28588
|
try {
|
|
28579
|
-
|
|
28580
|
-
|
|
28581
|
-
writeAllowlistFile(
|
|
28589
|
+
fs29.mkdirPrivate(paths.headroomDir);
|
|
28590
|
+
fs29.mkdirPrivate(import_node_path8.default.dirname(paths.headroomAllowlistFile));
|
|
28591
|
+
writeAllowlistFile(fs29, paths.headroomAllowlistFile, allowlist);
|
|
28582
28592
|
} catch (error63) {
|
|
28583
28593
|
return `could not write the headroom allowlist file ${paths.headroomAllowlistFile}: ${error63 instanceof Error ? error63.message : String(error63)}`;
|
|
28584
28594
|
}
|
|
@@ -28603,20 +28613,20 @@ async function runSupervisor(initialConfig, ports, options = {}) {
|
|
|
28603
28613
|
installedSource = config2.source;
|
|
28604
28614
|
return void 0;
|
|
28605
28615
|
};
|
|
28606
|
-
const socket = prepareHeadroomSocket(
|
|
28616
|
+
const socket = prepareHeadroomSocket(fs29, ports.socketTrust, paths, ports.ownPid);
|
|
28607
28617
|
if (socket.refused !== void 0) {
|
|
28608
28618
|
return fail(socket.refused);
|
|
28609
28619
|
}
|
|
28610
28620
|
const { socketPath } = socket;
|
|
28611
|
-
pruneStaleHeadroomSockets(
|
|
28612
|
-
pruneStaleAllowlistTemporaries(
|
|
28621
|
+
pruneStaleHeadroomSockets(fs29, paths, ports.isRunning);
|
|
28622
|
+
pruneStaleAllowlistTemporaries(fs29, paths.headroomAllowlistFile, ports.isRunning);
|
|
28613
28623
|
const installFailure = ensureInstalled();
|
|
28614
28624
|
if (installFailure !== void 0) {
|
|
28615
28625
|
return fail(installFailure);
|
|
28616
28626
|
}
|
|
28617
28627
|
const version2 = ports.headroomVersion() ?? "unknown";
|
|
28618
28628
|
writeOwnState({ supervisorPid: ports.ownPid, version: version2, installedSource });
|
|
28619
|
-
ports.log(`agent-shim headroom supervisor ${String(ports.ownPid)}: managing headroom on allowlist [${currentHeadroomAllowlistInputs(
|
|
28629
|
+
ports.log(`agent-shim headroom supervisor ${String(ports.ownPid)}: managing headroom on allowlist [${currentHeadroomAllowlistInputs(fs29, paths, ports.frontDoorLiveness).frontDoorOrigins.join(", ")}]`);
|
|
28620
28630
|
const orphanPid = previousState?.headroomPid;
|
|
28621
28631
|
const orphanSocket = previousState?.socketPath ?? (previousState?.supervisorPid === void 0 ? void 0 : headroomSocketPath(paths, previousState.supervisorPid));
|
|
28622
28632
|
const orphanIdentity = orphanPid === void 0 || orphanSocket === void 0 || !ports.isRunning(orphanPid) ? void 0 : daemonIdentity(ports.daemonCommandLine(orphanPid), orphanSocket);
|
|
@@ -28651,12 +28661,12 @@ async function runSupervisor(initialConfig, ports, options = {}) {
|
|
|
28651
28661
|
ticks += 1;
|
|
28652
28662
|
config2 = ports.readConfig();
|
|
28653
28663
|
const settingsHash = hashSettings(config2.settings);
|
|
28654
|
-
const inputs = currentHeadroomAllowlistInputs(
|
|
28655
|
-
pruneDeadFrontDoorDirectRecords(
|
|
28656
|
-
pruneMalformedFrontDoorDirectFiles(
|
|
28664
|
+
const inputs = currentHeadroomAllowlistInputs(fs29, paths, ports.frontDoorLiveness);
|
|
28665
|
+
pruneDeadFrontDoorDirectRecords(fs29, paths.frontdoorDirectRecordsDir, inputs.frontDoorRecords, inputs.frontDoorLiveness);
|
|
28666
|
+
pruneMalformedFrontDoorDirectFiles(fs29, paths.frontdoorDirectRecordsDir, ports.isRunning);
|
|
28657
28667
|
const allowlist = inputs.frontDoorOrigins;
|
|
28658
28668
|
const allowlistHash = hashAllowlist(allowlist);
|
|
28659
|
-
pruneDeadSessions(
|
|
28669
|
+
pruneDeadSessions(fs29, paths.headroomSessionsDir, ports.isRunning);
|
|
28660
28670
|
const ownsNow = ownsState();
|
|
28661
28671
|
if (!ownsNow && !superseded) {
|
|
28662
28672
|
ports.log("agent-shim headroom supervisor: another supervisor now owns the state file; serving this daemon's own sessions until they end");
|
|
@@ -28703,7 +28713,7 @@ async function runSupervisor(initialConfig, ports, options = {}) {
|
|
|
28703
28713
|
runningSettingsHash = settingsHash;
|
|
28704
28714
|
const recorded = writeOwnState(servingState(pid));
|
|
28705
28715
|
if (recorded) {
|
|
28706
|
-
|
|
28716
|
+
fs29.removeRecursive(paths.headroomLockFile);
|
|
28707
28717
|
}
|
|
28708
28718
|
idleSince = void 0;
|
|
28709
28719
|
ports.log(`agent-shim headroom supervisor: headroom pid ${String(pid)} ready on unix socket ${socketPath}`);
|
|
@@ -28731,7 +28741,7 @@ async function runSupervisor(initialConfig, ports, options = {}) {
|
|
|
28731
28741
|
ports.log(`agent-shim headroom supervisor: headroom pid ${String(headroomPid)} now serves allowlist [${allowlist.join(", ")}]`);
|
|
28732
28742
|
}
|
|
28733
28743
|
if (runningSettingsHash !== settingsHash || installedSource !== config2.source) {
|
|
28734
|
-
if (sessionsForSupervisor(
|
|
28744
|
+
if (sessionsForSupervisor(fs29, paths.headroomSessionsDir, ports.ownPid).length === 0) {
|
|
28735
28745
|
ports.log("agent-shim headroom supervisor: configuration drifted and no sessions are live; restarting headroom");
|
|
28736
28746
|
ports.stopProcess(headroomPid);
|
|
28737
28747
|
headroomPid = void 0;
|
|
@@ -28740,7 +28750,7 @@ async function runSupervisor(initialConfig, ports, options = {}) {
|
|
|
28740
28750
|
continue;
|
|
28741
28751
|
}
|
|
28742
28752
|
}
|
|
28743
|
-
const sessions = sessionsForSupervisor(
|
|
28753
|
+
const sessions = sessionsForSupervisor(fs29, paths.headroomSessionsDir, ports.ownPid);
|
|
28744
28754
|
if (sessions.length === 0) {
|
|
28745
28755
|
idleSince ??= ports.now();
|
|
28746
28756
|
const idleMs = ports.now() - idleSince;
|
|
@@ -28765,9 +28775,9 @@ function undeterminedFrontDoors(inputs) {
|
|
|
28765
28775
|
return reason === void 0 ? [] : [{ pid: record2.pid, origin: directOrigin(record2.directPort), reason }];
|
|
28766
28776
|
});
|
|
28767
28777
|
}
|
|
28768
|
-
function currentHeadroomAllowlistInputs(
|
|
28769
|
-
const named = frontDoorOrigin(readFrontDoorState(
|
|
28770
|
-
const records = listFrontDoorDirectRecords(
|
|
28778
|
+
function currentHeadroomAllowlistInputs(fs29, paths, frontDoorLiveness) {
|
|
28779
|
+
const named = frontDoorOrigin(readFrontDoorState(fs29, paths.frontdoorStateFile));
|
|
28780
|
+
const records = listFrontDoorDirectRecords(fs29, paths.frontdoorDirectRecordsDir);
|
|
28771
28781
|
const liveness = frontDoorLiveness(records.map((record2) => record2.pid));
|
|
28772
28782
|
const live = liveFrontDoorDirectRecords(records, liveness).map((record2) => directOrigin(record2.directPort));
|
|
28773
28783
|
return {
|
|
@@ -28776,8 +28786,8 @@ function currentHeadroomAllowlistInputs(fs28, paths, frontDoorLiveness) {
|
|
|
28776
28786
|
frontDoorOrigins: [.../* @__PURE__ */ new Set([...named === void 0 ? [] : [named], ...live])].sort()
|
|
28777
28787
|
};
|
|
28778
28788
|
}
|
|
28779
|
-
function launchRequiredUpstreams(
|
|
28780
|
-
const door = frontDoorOrigin(readFrontDoorState(
|
|
28789
|
+
function launchRequiredUpstreams(fs29, paths) {
|
|
28790
|
+
const door = frontDoorOrigin(readFrontDoorState(fs29, paths.frontdoorStateFile));
|
|
28781
28791
|
return door === void 0 ? [] : [door];
|
|
28782
28792
|
}
|
|
28783
28793
|
async function waitUntilReady(ports, socketPath, pid) {
|
|
@@ -31704,8 +31714,8 @@ var init_classify = __esm({
|
|
|
31704
31714
|
function poolNameOf(selector) {
|
|
31705
31715
|
return selector.startsWith(POOL_SELECTOR_PREFIX) ? selector.slice(POOL_SELECTOR_PREFIX.length) : void 0;
|
|
31706
31716
|
}
|
|
31707
|
-
function readActiveIdentity(
|
|
31708
|
-
const trimmed =
|
|
31717
|
+
function readActiveIdentity(fs29, activeIdentityFile) {
|
|
31718
|
+
const trimmed = fs29.readFileUtf8(activeIdentityFile)?.trim();
|
|
31709
31719
|
return trimmed === void 0 || trimmed === "" ? void 0 : trimmed;
|
|
31710
31720
|
}
|
|
31711
31721
|
function isNonEmpty(value2) {
|
|
@@ -31752,8 +31762,8 @@ function decideConfigProfile(params) {
|
|
|
31752
31762
|
}
|
|
31753
31763
|
return { source: "none" };
|
|
31754
31764
|
}
|
|
31755
|
-
function loadIdentity(identitiesDir, name,
|
|
31756
|
-
return loadConfigFile(import_node_path11.default.join(identitiesDir, name, "identity.json"), IdentitySchema,
|
|
31765
|
+
function loadIdentity(identitiesDir, name, fs29) {
|
|
31766
|
+
return loadConfigFile(import_node_path11.default.join(identitiesDir, name, "identity.json"), IdentitySchema, fs29.readConfigFile);
|
|
31757
31767
|
}
|
|
31758
31768
|
var import_node_path11, IDENTITY_DECISION_SOURCES, CONFIG_PROFILE_DECISION_SOURCES;
|
|
31759
31769
|
var init_identity = __esm({
|
|
@@ -33460,8 +33470,8 @@ var init_pipeline = __esm({
|
|
|
33460
33470
|
});
|
|
33461
33471
|
|
|
33462
33472
|
// src/launcher/farm.ts
|
|
33463
|
-
function readFarmManifest(
|
|
33464
|
-
const raw =
|
|
33473
|
+
function readFarmManifest(fs29, farmRoot) {
|
|
33474
|
+
const raw = fs29.readFileUtf8(import_node_path19.default.join(farmRoot, FARM_MANIFEST_FILENAME)) ?? fs29.readFileUtf8(import_node_path19.default.join(farmRoot, LEGACY_FARM_MANIFEST_FILENAME));
|
|
33465
33475
|
if (raw === void 0) {
|
|
33466
33476
|
return void 0;
|
|
33467
33477
|
}
|
|
@@ -33519,9 +33529,9 @@ function buildEntryFacts(params) {
|
|
|
33519
33529
|
entries
|
|
33520
33530
|
};
|
|
33521
33531
|
}
|
|
33522
|
-
function listSubtree(
|
|
33532
|
+
function listSubtree(fs29, root, rel) {
|
|
33523
33533
|
const absolute = import_node_path19.default.join(root, rel);
|
|
33524
|
-
const stat =
|
|
33534
|
+
const stat = fs29.lstat(absolute);
|
|
33525
33535
|
if (stat === void 0) {
|
|
33526
33536
|
return [];
|
|
33527
33537
|
}
|
|
@@ -33529,10 +33539,10 @@ function listSubtree(fs28, root, rel) {
|
|
|
33529
33539
|
return [{ rel, kind: "symlink" }];
|
|
33530
33540
|
}
|
|
33531
33541
|
if (stat.kind === "dir") {
|
|
33532
|
-
const children = [...
|
|
33542
|
+
const children = [...fs29.readdir(absolute)].sort().flatMap((name) => listSubtree(fs29, root, `${rel}/${name}`));
|
|
33533
33543
|
return [{ rel, kind: "dir" }, ...children];
|
|
33534
33544
|
}
|
|
33535
|
-
const contentHash =
|
|
33545
|
+
const contentHash = fs29.hashFile(absolute);
|
|
33536
33546
|
return [{ rel, kind: "file", ...contentHash === void 0 ? {} : { contentHash } }];
|
|
33537
33547
|
}
|
|
33538
33548
|
function topLevelScopeRoots(roots) {
|
|
@@ -33546,25 +33556,25 @@ function topLevelScopeRoots(roots) {
|
|
|
33546
33556
|
}
|
|
33547
33557
|
return kept;
|
|
33548
33558
|
}
|
|
33549
|
-
function reconciliationScope(
|
|
33559
|
+
function reconciliationScope(fs29, farmRoot, manifest) {
|
|
33550
33560
|
if (manifest !== void 0) {
|
|
33551
33561
|
return topLevelScopeRoots(manifest.materialised);
|
|
33552
33562
|
}
|
|
33553
|
-
return [...
|
|
33563
|
+
return [...fs29.readdir(farmRoot)].filter((name) => name !== FARM_MANIFEST_FILENAME && name !== LEGACY_FARM_MANIFEST_FILENAME && fs29.lstat(import_node_path19.default.join(farmRoot, name))?.kind === "dir").sort();
|
|
33554
33564
|
}
|
|
33555
|
-
function collectFarmListing(
|
|
33556
|
-
return scopeRoots.flatMap((root) => listSubtree(
|
|
33565
|
+
function collectFarmListing(fs29, farmRoot, scopeRoots) {
|
|
33566
|
+
return scopeRoots.flatMap((root) => listSubtree(fs29, farmRoot, root));
|
|
33557
33567
|
}
|
|
33558
|
-
function collectCanonicalCounterparts(
|
|
33568
|
+
function collectCanonicalCounterparts(fs29, claudeHome, farmListing) {
|
|
33559
33569
|
const out = [];
|
|
33560
33570
|
for (const entry of farmListing) {
|
|
33561
33571
|
const absolute = import_node_path19.default.join(claudeHome, entry.rel);
|
|
33562
|
-
const stat =
|
|
33572
|
+
const stat = fs29.lstat(absolute);
|
|
33563
33573
|
if (stat === void 0) {
|
|
33564
33574
|
continue;
|
|
33565
33575
|
}
|
|
33566
33576
|
if (stat.kind === "file") {
|
|
33567
|
-
const contentHash =
|
|
33577
|
+
const contentHash = fs29.hashFile(absolute);
|
|
33568
33578
|
out.push({ rel: entry.rel, kind: "file", ...contentHash === void 0 ? {} : { contentHash } });
|
|
33569
33579
|
continue;
|
|
33570
33580
|
}
|
|
@@ -33999,6 +34009,7 @@ function buildLayoutPaths(root) {
|
|
|
33999
34009
|
frontdoorControlTokenFile: import_node_path20.default.join(root, "frontdoor", "control-token"),
|
|
34000
34010
|
frontdoorSessionsDir: import_node_path20.default.join(root, "frontdoor", "sessions"),
|
|
34001
34011
|
frontdoorDirectRecordsDir: import_node_path20.default.join(root, "frontdoor", "direct"),
|
|
34012
|
+
frontdoorDrainingDir: import_node_path20.default.join(root, "frontdoor", "draining"),
|
|
34002
34013
|
frontdoorRcCredentialsDir: import_node_path20.default.join(root, "frontdoor", "rc-credentials"),
|
|
34003
34014
|
frontdoorLogPath: import_node_path20.default.join(root, "logs", "frontdoor.log"),
|
|
34004
34015
|
usageDir: import_node_path20.default.join(root, "usage"),
|
|
@@ -35236,9 +35247,9 @@ async function runFrontDoorSupervisor(idleShutdownMinutes, ports, options = {})
|
|
|
35236
35247
|
}
|
|
35237
35248
|
}
|
|
35238
35249
|
async function serveFrontDoor(idleShutdownMinutes, ports, options) {
|
|
35239
|
-
const { fs:
|
|
35250
|
+
const { fs: fs29, paths } = ports;
|
|
35240
35251
|
const servingBinary = ports.statOwnExecutable();
|
|
35241
|
-
const previous = readFrontDoorState(
|
|
35252
|
+
const previous = readFrontDoorState(fs29, paths.frontdoorStateFile);
|
|
35242
35253
|
let lastPort = previous?.lastPort;
|
|
35243
35254
|
let lastConnectPort = previous?.lastConnectPort;
|
|
35244
35255
|
let lastDirectPort = previous?.lastDirectPort;
|
|
@@ -35249,12 +35260,12 @@ async function serveFrontDoor(idleShutdownMinutes, ports, options) {
|
|
|
35249
35260
|
});
|
|
35250
35261
|
const fail = (message) => {
|
|
35251
35262
|
ports.closeRcStreamHub();
|
|
35252
|
-
writeFrontDoorState(
|
|
35253
|
-
|
|
35263
|
+
writeFrontDoorState(fs29, paths.frontdoorStateFile, { lastError: message, ...sticky() });
|
|
35264
|
+
fs29.removeRecursive(paths.frontdoorLockFile);
|
|
35254
35265
|
ports.log(`agent-shim frontdoor supervisor: ${message}`);
|
|
35255
35266
|
return 1;
|
|
35256
35267
|
};
|
|
35257
|
-
writeFrontDoorState(
|
|
35268
|
+
writeFrontDoorState(fs29, paths.frontdoorStateFile, { supervisorPid: ports.ownPid, ...sticky() });
|
|
35258
35269
|
const previousSticky = lastPort;
|
|
35259
35270
|
let http9;
|
|
35260
35271
|
try {
|
|
@@ -35294,16 +35305,16 @@ async function serveFrontDoor(idleShutdownMinutes, ports, options) {
|
|
|
35294
35305
|
ports.log(`agent-shim frontdoor supervisor: sticky direct port ${String(previousStickyDirect)} was occupied; moving to ${String(direct.port)} (headroom admits the new address once its supervisor rewrites the allowlist file)`);
|
|
35295
35306
|
}
|
|
35296
35307
|
lastDirectPort = direct.port;
|
|
35297
|
-
writeFrontDoorDirectRecord(
|
|
35298
|
-
writeFrontDoorState(
|
|
35308
|
+
writeFrontDoorDirectRecord(fs29, paths.frontdoorDirectRecordsDir, { pid: ports.ownPid, directPort: direct.port });
|
|
35309
|
+
writeFrontDoorState(fs29, paths.frontdoorStateFile, { protocol: FRONT_DOOR_PROTOCOL, supervisorPid: ports.ownPid, port: http9.port, connectPort: connect3.port, directPort: direct.port, ...sticky() });
|
|
35299
35310
|
ports.doorHealth.generation({ providerPort: http9.port, connectPort: connect3.port, directPort: direct.port });
|
|
35300
|
-
|
|
35311
|
+
fs29.removeRecursive(paths.frontdoorLockFile);
|
|
35301
35312
|
ports.log(`agent-shim frontdoor supervisor ${String(ports.ownPid)}: front door on 127.0.0.1:${String(http9.port)}, CONNECT surface on 127.0.0.1:${String(connect3.port)}`);
|
|
35302
35313
|
const watchdog = ports.startWatchdog?.();
|
|
35303
35314
|
let idleSince;
|
|
35304
35315
|
let ticks = 0;
|
|
35305
35316
|
const supersedingOwner = () => {
|
|
35306
|
-
const owner = readFrontDoorState(
|
|
35317
|
+
const owner = readFrontDoorState(fs29, paths.frontdoorStateFile)?.supervisorPid;
|
|
35307
35318
|
return owner !== void 0 && owner !== ports.ownPid && ports.isRunning(owner) ? owner : void 0;
|
|
35308
35319
|
};
|
|
35309
35320
|
let supersededBy;
|
|
@@ -35312,30 +35323,61 @@ async function serveFrontDoor(idleShutdownMinutes, ports, options) {
|
|
|
35312
35323
|
const current = ports.statOwnExecutable();
|
|
35313
35324
|
return current !== void 0 && servingBinary !== void 0 && (current.dev !== servingBinary.dev || current.ino !== servingBinary.ino || current.size !== servingBinary.size || current.mtimeMs !== servingBinary.mtimeMs);
|
|
35314
35325
|
};
|
|
35326
|
+
const pause = async () => {
|
|
35327
|
+
await new Promise((resolve2) => {
|
|
35328
|
+
const wake = () => {
|
|
35329
|
+
resolve2();
|
|
35330
|
+
};
|
|
35331
|
+
ports.retire?.addEventListener("abort", wake, { once: true });
|
|
35332
|
+
void ports.sleep(FRONTDOOR_POLL_MS).then(() => {
|
|
35333
|
+
ports.retire?.removeEventListener("abort", wake);
|
|
35334
|
+
resolve2();
|
|
35335
|
+
});
|
|
35336
|
+
});
|
|
35337
|
+
};
|
|
35338
|
+
const retireByDrain = async () => {
|
|
35339
|
+
ports.log(`agent-shim frontdoor supervisor ${String(ports.ownPid)}: asked to exit; releasing the front door's addresses and finishing the connections it carries`);
|
|
35340
|
+
watchdog?.stop();
|
|
35341
|
+
ports.stopBackgroundWork?.();
|
|
35342
|
+
const drained = [direct.drain(), connect3.drain(), http9.drain()];
|
|
35343
|
+
if (supersedingOwner() === void 0) {
|
|
35344
|
+
writeFrontDoorState(fs29, paths.frontdoorStateFile, sticky());
|
|
35345
|
+
}
|
|
35346
|
+
markFrontDoorDraining(fs29, paths.frontdoorDrainingDir, ports.ownPid);
|
|
35347
|
+
ports.closeRcStreamHub();
|
|
35348
|
+
await Promise.all(drained);
|
|
35349
|
+
unmarkFrontDoorDraining(fs29, paths.frontdoorDrainingDir, ports.ownPid);
|
|
35350
|
+
removeFrontDoorDirectRecord(fs29, paths.frontdoorDirectRecordsDir, ports.ownPid);
|
|
35351
|
+
ports.log(`agent-shim frontdoor supervisor ${String(ports.ownPid)}: the connections this door carried have ended; exiting`);
|
|
35352
|
+
return 0;
|
|
35353
|
+
};
|
|
35315
35354
|
const closeServing = async () => {
|
|
35316
35355
|
watchdog?.stop();
|
|
35317
35356
|
await direct.close();
|
|
35318
35357
|
await connect3.close();
|
|
35319
35358
|
await http9.close();
|
|
35320
35359
|
ports.closeRcStreamHub();
|
|
35321
|
-
removeFrontDoorDirectRecord(
|
|
35360
|
+
removeFrontDoorDirectRecord(fs29, paths.frontdoorDirectRecordsDir, ports.ownPid);
|
|
35322
35361
|
};
|
|
35323
35362
|
const shutdown = async () => {
|
|
35324
35363
|
await closeServing();
|
|
35325
35364
|
if (supersedingOwner() === void 0) {
|
|
35326
|
-
writeFrontDoorState(
|
|
35365
|
+
writeFrontDoorState(fs29, paths.frontdoorStateFile, sticky());
|
|
35327
35366
|
}
|
|
35328
35367
|
return 0;
|
|
35329
35368
|
};
|
|
35330
35369
|
for (; ; ) {
|
|
35331
35370
|
watchdog?.beat();
|
|
35371
|
+
if (ports.retire?.aborted === true) {
|
|
35372
|
+
return await retireByDrain();
|
|
35373
|
+
}
|
|
35332
35374
|
if (options.tickLimit !== void 0 && ticks >= options.tickLimit) {
|
|
35333
35375
|
watchdog?.stop();
|
|
35334
35376
|
return FRONTDOOR_SUPERVISOR_STILL_RUNNING;
|
|
35335
35377
|
}
|
|
35336
35378
|
ticks += 1;
|
|
35337
|
-
const listed = listFrontDoorSessions(
|
|
35338
|
-
const pruned = pruneDeadFrontDoorSessions(
|
|
35379
|
+
const listed = listFrontDoorSessions(fs29, paths.frontdoorSessionsDir);
|
|
35380
|
+
const pruned = pruneDeadFrontDoorSessions(fs29, paths.frontdoorSessionsDir, ports.isRunning);
|
|
35339
35381
|
ports.observeLaunchRegistry(listed, pruned);
|
|
35340
35382
|
ports.checkQuotaExpiry();
|
|
35341
35383
|
const prunedPids = new Set(pruned);
|
|
@@ -35345,7 +35387,7 @@ async function serveFrontDoor(idleShutdownMinutes, ports, options) {
|
|
|
35345
35387
|
if (supersededBy !== void 0) {
|
|
35346
35388
|
ports.log(`agent-shim frontdoor supervisor ${String(ports.ownPid)}: supervisor ${String(supersededBy)} now owns the front door; taking no new sessions and exiting once the sessions this door serves have ended`);
|
|
35347
35389
|
ports.doorHealth.superseded(supersededBy);
|
|
35348
|
-
await
|
|
35390
|
+
await pause();
|
|
35349
35391
|
continue;
|
|
35350
35392
|
}
|
|
35351
35393
|
} else {
|
|
@@ -35357,7 +35399,7 @@ async function serveFrontDoor(idleShutdownMinutes, ports, options) {
|
|
|
35357
35399
|
await closeServing();
|
|
35358
35400
|
return 0;
|
|
35359
35401
|
}
|
|
35360
|
-
await
|
|
35402
|
+
await pause();
|
|
35361
35403
|
continue;
|
|
35362
35404
|
}
|
|
35363
35405
|
if (live.length === 0) {
|
|
@@ -35375,7 +35417,7 @@ async function serveFrontDoor(idleShutdownMinutes, ports, options) {
|
|
|
35375
35417
|
} else {
|
|
35376
35418
|
idleSince = void 0;
|
|
35377
35419
|
}
|
|
35378
|
-
await
|
|
35420
|
+
await pause();
|
|
35379
35421
|
}
|
|
35380
35422
|
}
|
|
35381
35423
|
var import_node_path23, AWAIT_PID_POLL_MS, FRONTDOOR_SUPERVISOR_STILL_RUNNING, FRONTDOOR_POLL_MS, MS_PER_MINUTE3;
|
|
@@ -35526,25 +35568,35 @@ ${request7.rawHeaders.reduce((accumulated, value2, index) => index % 2 === 0 ? `
|
|
|
35526
35568
|
const transparent = config2.transparentPort === void 0 || apiSession === void 0 ? void 0 : await effects.listenLoopback(config2.transparentPort, (socket) => {
|
|
35527
35569
|
sniAcceptor.accept(socket);
|
|
35528
35570
|
});
|
|
35571
|
+
const closeSurface = async () => {
|
|
35572
|
+
ledger.close();
|
|
35573
|
+
await listener.close();
|
|
35574
|
+
await transparent?.close();
|
|
35575
|
+
sniAcceptor.close();
|
|
35576
|
+
for (const { httpSession, tlsAcceptor } of sessions) {
|
|
35577
|
+
tlsAcceptor.close();
|
|
35578
|
+
httpSession?.close();
|
|
35579
|
+
}
|
|
35580
|
+
};
|
|
35529
35581
|
return {
|
|
35530
35582
|
port: listener.port,
|
|
35531
35583
|
...transparent === void 0 ? {} : { transparentPort: transparent.port },
|
|
35532
|
-
|
|
35533
|
-
|
|
35534
|
-
|
|
35584
|
+
openTunnels: ledger.openTunnels,
|
|
35585
|
+
drain: async () => {
|
|
35586
|
+
listener.stopAccepting();
|
|
35535
35587
|
await transparent?.close();
|
|
35536
|
-
|
|
35537
|
-
|
|
35538
|
-
|
|
35539
|
-
|
|
35540
|
-
}
|
|
35541
|
-
}
|
|
35588
|
+
await ledger.retire();
|
|
35589
|
+
await closeSurface();
|
|
35590
|
+
},
|
|
35591
|
+
close: closeSurface
|
|
35542
35592
|
};
|
|
35543
35593
|
}
|
|
35544
35594
|
function createConnectionLedger(limits, isLiveCapability2) {
|
|
35545
35595
|
const pending = /* @__PURE__ */ new Map();
|
|
35546
35596
|
const authenticated = /* @__PURE__ */ new Map();
|
|
35547
35597
|
let tunnels = 0;
|
|
35598
|
+
const blind = /* @__PURE__ */ new Set();
|
|
35599
|
+
let onNoBlindTunnels;
|
|
35548
35600
|
const leavePending = (socket) => {
|
|
35549
35601
|
const deadline = pending.get(socket);
|
|
35550
35602
|
if (deadline !== void 0) {
|
|
@@ -35581,16 +35633,45 @@ function createConnectionLedger(limits, isLiveCapability2) {
|
|
|
35581
35633
|
});
|
|
35582
35634
|
},
|
|
35583
35635
|
headReceived: leavePending,
|
|
35584
|
-
|
|
35636
|
+
openTunnels: () => tunnels,
|
|
35637
|
+
retire: async () => {
|
|
35638
|
+
for (const socket of pending.keys()) {
|
|
35639
|
+
socket.destroy();
|
|
35640
|
+
}
|
|
35641
|
+
for (const deadline of pending.values()) {
|
|
35642
|
+
clearTimeout(deadline);
|
|
35643
|
+
}
|
|
35644
|
+
pending.clear();
|
|
35645
|
+
for (const sockets of authenticated.values()) {
|
|
35646
|
+
for (const socket of sockets) {
|
|
35647
|
+
if (!blind.has(socket)) {
|
|
35648
|
+
socket.destroy();
|
|
35649
|
+
}
|
|
35650
|
+
}
|
|
35651
|
+
}
|
|
35652
|
+
if (blind.size > 0) {
|
|
35653
|
+
await new Promise((resolve2) => {
|
|
35654
|
+
onNoBlindTunnels = resolve2;
|
|
35655
|
+
});
|
|
35656
|
+
}
|
|
35657
|
+
},
|
|
35658
|
+
establish: (socket, capability, kind) => {
|
|
35585
35659
|
if (tunnels >= limits.maxTunnels) {
|
|
35586
35660
|
return false;
|
|
35587
35661
|
}
|
|
35588
35662
|
tunnels += 1;
|
|
35663
|
+
if (kind === "blind") {
|
|
35664
|
+
blind.add(socket);
|
|
35665
|
+
}
|
|
35589
35666
|
const sockets = authenticated.get(capability) ?? /* @__PURE__ */ new Set();
|
|
35590
35667
|
sockets.add(socket);
|
|
35591
35668
|
authenticated.set(capability, sockets);
|
|
35592
35669
|
socket.once("close", () => {
|
|
35593
35670
|
tunnels -= 1;
|
|
35671
|
+
blind.delete(socket);
|
|
35672
|
+
if (blind.size === 0) {
|
|
35673
|
+
onNoBlindTunnels?.();
|
|
35674
|
+
}
|
|
35594
35675
|
sockets.delete(socket);
|
|
35595
35676
|
if (sockets.size === 0 && authenticated.get(capability) === sockets) {
|
|
35596
35677
|
authenticated.delete(capability);
|
|
@@ -35672,11 +35753,11 @@ function routeConnect(socket, head, context) {
|
|
|
35672
35753
|
refuse(socket, REFUSAL.badRequest);
|
|
35673
35754
|
return;
|
|
35674
35755
|
}
|
|
35675
|
-
|
|
35756
|
+
const session = sessions.find((entry) => entry.host === target.host);
|
|
35757
|
+
if (!ledger.establish(socket, capability, session === void 0 ? "blind" : "terminated")) {
|
|
35676
35758
|
refuse(socket, REFUSAL.serviceUnavailable);
|
|
35677
35759
|
return;
|
|
35678
35760
|
}
|
|
35679
|
-
const session = sessions.find((entry) => entry.host === target.host);
|
|
35680
35761
|
config2.capture?.connect(target, session !== void 0);
|
|
35681
35762
|
socket.write(CONNECT_ESTABLISHED);
|
|
35682
35763
|
if (session !== void 0) {
|
|
@@ -35846,7 +35927,7 @@ var init_package = __esm({
|
|
|
35846
35927
|
"package.json"() {
|
|
35847
35928
|
package_default = {
|
|
35848
35929
|
name: "claude-use",
|
|
35849
|
-
version: "11.
|
|
35930
|
+
version: "11.49.0",
|
|
35850
35931
|
description: "A profile manager and launcher for Claude Code that lets one person run multiple logins from one machine while controlling what gets shared between them.",
|
|
35851
35932
|
license: "MIT",
|
|
35852
35933
|
author: "Joseph Mearman <joseph@mearman.co.uk>",
|
|
@@ -35959,14 +36040,14 @@ function isIdentityName(name) {
|
|
|
35959
36040
|
function claudeJsonPath(identitiesDir, identity) {
|
|
35960
36041
|
return import_node_path25.default.join(identitiesDir, identity, CLAUDE_JSON);
|
|
35961
36042
|
}
|
|
35962
|
-
function readAccountMetadata(
|
|
36043
|
+
function readAccountMetadata(fs29, identitiesDir, identity) {
|
|
35963
36044
|
if (!isIdentityName(identity)) {
|
|
35964
36045
|
throw new Error(`"${identity}" is not a valid identity name.`);
|
|
35965
36046
|
}
|
|
35966
|
-
return readAccountMetadataFile(
|
|
36047
|
+
return readAccountMetadataFile(fs29, claudeJsonPath(identitiesDir, identity));
|
|
35967
36048
|
}
|
|
35968
|
-
function readAccountMetadataFile(
|
|
35969
|
-
const raw =
|
|
36049
|
+
function readAccountMetadataFile(fs29, file2) {
|
|
36050
|
+
const raw = fs29.readFileUtf8(file2);
|
|
35970
36051
|
if (raw === void 0) {
|
|
35971
36052
|
return void 0;
|
|
35972
36053
|
}
|
|
@@ -35996,19 +36077,19 @@ function readAccountMetadataFile(fs28, file2) {
|
|
|
35996
36077
|
}
|
|
35997
36078
|
return account.data;
|
|
35998
36079
|
}
|
|
35999
|
-
function createAccountReader(
|
|
36080
|
+
function createAccountReader(fs29, identitiesDir) {
|
|
36000
36081
|
const cache = /* @__PURE__ */ new Map();
|
|
36001
36082
|
return (identity) => {
|
|
36002
36083
|
if (!isIdentityName(identity)) {
|
|
36003
36084
|
throw new Error(`"${identity}" is not a valid identity name.`);
|
|
36004
36085
|
}
|
|
36005
|
-
const stat =
|
|
36086
|
+
const stat = fs29.lstat(claudeJsonPath(identitiesDir, identity));
|
|
36006
36087
|
const stamp = stat === void 0 ? "absent" : `${String(stat.mtimeMs)}:${String(stat.sizeBytes)}`;
|
|
36007
36088
|
const cached2 = cache.get(identity);
|
|
36008
36089
|
if (cached2?.stamp === stamp) {
|
|
36009
36090
|
return cached2.account;
|
|
36010
36091
|
}
|
|
36011
|
-
const account = readAccountMetadata(
|
|
36092
|
+
const account = readAccountMetadata(fs29, identitiesDir, identity);
|
|
36012
36093
|
cache.set(identity, { stamp, account });
|
|
36013
36094
|
return account;
|
|
36014
36095
|
};
|
|
@@ -36838,8 +36919,8 @@ function segmentDay(epochMs) {
|
|
|
36838
36919
|
function segmentName(day, pid) {
|
|
36839
36920
|
return `${day}.${String(pid)}.jsonl`;
|
|
36840
36921
|
}
|
|
36841
|
-
function listLogSegments(
|
|
36842
|
-
return
|
|
36922
|
+
function listLogSegments(fs29, logDir) {
|
|
36923
|
+
return fs29.readdir(logDir).flatMap((name) => {
|
|
36843
36924
|
const match = SEGMENT_RE.exec(name);
|
|
36844
36925
|
const day = match?.[1];
|
|
36845
36926
|
if (day === void 0) {
|
|
@@ -36848,15 +36929,15 @@ function listLogSegments(fs28, logDir) {
|
|
|
36848
36929
|
return [{ name, day, endsAt: Date.parse(`${day}T00:00:00.000Z`) + DAY_MS }];
|
|
36849
36930
|
}).sort((left, right) => left.day.localeCompare(right.day) || left.name.localeCompare(right.name));
|
|
36850
36931
|
}
|
|
36851
|
-
function readUsageLog(
|
|
36932
|
+
function readUsageLog(fs29, logDir, options = {}) {
|
|
36852
36933
|
const { sinceMs } = options;
|
|
36853
36934
|
const records = [];
|
|
36854
36935
|
let invalidLines = 0;
|
|
36855
|
-
for (const segment of listLogSegments(
|
|
36936
|
+
for (const segment of listLogSegments(fs29, logDir)) {
|
|
36856
36937
|
if (sinceMs !== void 0 && segment.endsAt <= sinceMs) {
|
|
36857
36938
|
continue;
|
|
36858
36939
|
}
|
|
36859
|
-
const contents =
|
|
36940
|
+
const contents = fs29.readFileUtf8(import_node_path26.default.join(logDir, segment.name));
|
|
36860
36941
|
if (contents === void 0) {
|
|
36861
36942
|
continue;
|
|
36862
36943
|
}
|
|
@@ -36892,9 +36973,9 @@ function snapshotPath(snapshotsDir, identity) {
|
|
|
36892
36973
|
}
|
|
36893
36974
|
return import_node_path26.default.join(snapshotsDir, `${identity}.json`);
|
|
36894
36975
|
}
|
|
36895
|
-
function readUsageSnapshot(
|
|
36976
|
+
function readUsageSnapshot(fs29, snapshotsDir, identity) {
|
|
36896
36977
|
const file2 = snapshotPath(snapshotsDir, identity);
|
|
36897
|
-
const raw =
|
|
36978
|
+
const raw = fs29.readFileUtf8(file2);
|
|
36898
36979
|
if (raw === void 0) {
|
|
36899
36980
|
return void 0;
|
|
36900
36981
|
}
|
|
@@ -36910,8 +36991,8 @@ function readUsageSnapshot(fs28, snapshotsDir, identity) {
|
|
|
36910
36991
|
}
|
|
36911
36992
|
return snapshot.data;
|
|
36912
36993
|
}
|
|
36913
|
-
function listUsageSnapshots(
|
|
36914
|
-
return
|
|
36994
|
+
function listUsageSnapshots(fs29, snapshotsDir) {
|
|
36995
|
+
return fs29.readdir(snapshotsDir).flatMap((name) => {
|
|
36915
36996
|
if (!name.endsWith(".json")) {
|
|
36916
36997
|
return [];
|
|
36917
36998
|
}
|
|
@@ -36919,7 +37000,7 @@ function listUsageSnapshots(fs28, snapshotsDir) {
|
|
|
36919
37000
|
if (!isIdentityName(identity)) {
|
|
36920
37001
|
return [];
|
|
36921
37002
|
}
|
|
36922
|
-
const snapshot = readUsageSnapshot(
|
|
37003
|
+
const snapshot = readUsageSnapshot(fs29, snapshotsDir, identity);
|
|
36923
37004
|
return snapshot === void 0 ? [] : [snapshot];
|
|
36924
37005
|
}).sort((left, right) => left.identity.localeCompare(right.identity));
|
|
36925
37006
|
}
|
|
@@ -36993,11 +37074,11 @@ var init_read = __esm({
|
|
|
36993
37074
|
});
|
|
36994
37075
|
|
|
36995
37076
|
// src/usage/store.ts
|
|
36996
|
-
function pruneUsageLog(
|
|
37077
|
+
function pruneUsageLog(fs29, logDir, nowMs) {
|
|
36997
37078
|
const cutoff = nowMs - USAGE_RETENTION_MS;
|
|
36998
|
-
for (const segment of listLogSegments(
|
|
37079
|
+
for (const segment of listLogSegments(fs29, logDir)) {
|
|
36999
37080
|
if (segment.endsAt <= cutoff) {
|
|
37000
|
-
|
|
37081
|
+
fs29.removeRecursive(import_node_path27.default.join(logDir, segment.name));
|
|
37001
37082
|
}
|
|
37002
37083
|
}
|
|
37003
37084
|
}
|
|
@@ -37026,7 +37107,7 @@ function foldProviderState(current, record2) {
|
|
|
37026
37107
|
};
|
|
37027
37108
|
}
|
|
37028
37109
|
function createUsageStore(deps) {
|
|
37029
|
-
const { fs:
|
|
37110
|
+
const { fs: fs29, paths } = deps;
|
|
37030
37111
|
let prunedDay;
|
|
37031
37112
|
const rewriteSnapshot = (identity, fold) => {
|
|
37032
37113
|
if (!isIdentityName(identity)) {
|
|
@@ -37035,7 +37116,7 @@ function createUsageStore(deps) {
|
|
|
37035
37116
|
}
|
|
37036
37117
|
let current;
|
|
37037
37118
|
try {
|
|
37038
|
-
current = readUsageSnapshot(
|
|
37119
|
+
current = readUsageSnapshot(fs29, paths.usageSnapshotsDir, identity);
|
|
37039
37120
|
} catch (error63) {
|
|
37040
37121
|
if (!(error63 instanceof UsageSnapshotError)) {
|
|
37041
37122
|
throw error63;
|
|
@@ -37062,8 +37143,8 @@ function createUsageStore(deps) {
|
|
|
37062
37143
|
...account === void 0 ? {} : { account },
|
|
37063
37144
|
providers
|
|
37064
37145
|
});
|
|
37065
|
-
|
|
37066
|
-
|
|
37146
|
+
fs29.mkdirPrivate(paths.usageSnapshotsDir);
|
|
37147
|
+
fs29.writeFilePrivate(snapshotPath(paths.usageSnapshotsDir, identity), `${JSON.stringify(snapshot, null, 2)}
|
|
37067
37148
|
`);
|
|
37068
37149
|
deps.publish?.(snapshot);
|
|
37069
37150
|
return true;
|
|
@@ -37072,14 +37153,14 @@ function createUsageStore(deps) {
|
|
|
37072
37153
|
record: (input2) => {
|
|
37073
37154
|
const record2 = UsageRecordSchema.parse(input2);
|
|
37074
37155
|
const nowMs = deps.now();
|
|
37075
|
-
|
|
37076
|
-
|
|
37156
|
+
fs29.mkdirPrivate(paths.usageDir);
|
|
37157
|
+
fs29.mkdirPrivate(paths.usageLogDir);
|
|
37077
37158
|
const day = segmentDay(nowMs);
|
|
37078
37159
|
if (prunedDay !== day) {
|
|
37079
|
-
pruneUsageLog(
|
|
37160
|
+
pruneUsageLog(fs29, paths.usageLogDir, nowMs);
|
|
37080
37161
|
prunedDay = day;
|
|
37081
37162
|
}
|
|
37082
|
-
|
|
37163
|
+
fs29.appendFilePrivate(import_node_path27.default.join(paths.usageLogDir, segmentName(day, deps.pid)), `${JSON.stringify(record2)}
|
|
37083
37164
|
`);
|
|
37084
37165
|
deps.onRecord?.(record2);
|
|
37085
37166
|
if (record2.identity !== void 0) {
|
|
@@ -37122,14 +37203,14 @@ var init_store2 = __esm({
|
|
|
37122
37203
|
function errorMessage(error63) {
|
|
37123
37204
|
return error63 instanceof Error ? error63.message : String(error63);
|
|
37124
37205
|
}
|
|
37125
|
-
function loadPoolMembers(
|
|
37206
|
+
function loadPoolMembers(fs29, paths, identities, nowMs) {
|
|
37126
37207
|
const windowStartMs = nowMs - FIVE_HOUR_WINDOW_MS;
|
|
37127
|
-
const log = readUsageLog(
|
|
37208
|
+
const log = readUsageLog(fs29, paths.usageLogDir, { sinceMs: windowStartMs });
|
|
37128
37209
|
return identities.map((identity) => {
|
|
37129
37210
|
const records = log.records.filter((record2) => record2.identity === identity && record2.provider === ANTHROPIC_PROVIDER && Date.parse(record2.at) >= windowStartMs);
|
|
37130
37211
|
try {
|
|
37131
|
-
const snapshot = readUsageSnapshot(
|
|
37132
|
-
const account = readAccountMetadata(
|
|
37212
|
+
const snapshot = readUsageSnapshot(fs29, paths.usageSnapshotsDir, identity);
|
|
37213
|
+
const account = readAccountMetadata(fs29, paths.identitiesDir, identity) ?? snapshot?.account;
|
|
37133
37214
|
return { identity, records, ...snapshot === void 0 ? {} : { snapshot }, ...account === void 0 ? {} : { account } };
|
|
37134
37215
|
} catch (error63) {
|
|
37135
37216
|
if (error63 instanceof UsageSnapshotError || error63 instanceof AccountMetadataError) {
|
|
@@ -37202,9 +37283,9 @@ function nestedMember(input2, nestedName, childStack, sticky) {
|
|
|
37202
37283
|
missing: nested.missing
|
|
37203
37284
|
};
|
|
37204
37285
|
}
|
|
37205
|
-
function readPicksFile(
|
|
37286
|
+
function readPicksFile(fs29, file2) {
|
|
37206
37287
|
const empty = { schemaVersion: SCHEMA_VERSION, picks: {} };
|
|
37207
|
-
const raw =
|
|
37288
|
+
const raw = fs29.readFileUtf8(file2);
|
|
37208
37289
|
if (raw === void 0) {
|
|
37209
37290
|
return { file: empty };
|
|
37210
37291
|
}
|
|
@@ -37217,17 +37298,17 @@ function readPicksFile(fs28, file2) {
|
|
|
37217
37298
|
const result = PicksFileSchema.safeParse(parsed);
|
|
37218
37299
|
return result.success ? { file: result.data } : { file: empty, problem: `${file2} is not a picks file this agent-shim can read` };
|
|
37219
37300
|
}
|
|
37220
|
-
function readStickyPick(
|
|
37221
|
-
const read = readPicksFile(
|
|
37301
|
+
function readStickyPick(fs29, picksFile, directory) {
|
|
37302
|
+
const read = readPicksFile(fs29, picksFile);
|
|
37222
37303
|
const entry = read.file.picks[directory];
|
|
37223
37304
|
return { ...entry === void 0 ? {} : { sticky: entry }, ...read.problem === void 0 ? {} : { problem: read.problem } };
|
|
37224
37305
|
}
|
|
37225
|
-
function recordStickyPick(
|
|
37226
|
-
const current = readPicksFile(
|
|
37306
|
+
function recordStickyPick(fs29, picksFile, directory, identity, nowMs) {
|
|
37307
|
+
const current = readPicksFile(fs29, picksFile).file.picks;
|
|
37227
37308
|
const kept = Object.entries(current).filter(([, entry]) => nowMs - Date.parse(entry.at) <= USAGE_RETENTION_MS);
|
|
37228
37309
|
const next = { schemaVersion: SCHEMA_VERSION, picks: { ...Object.fromEntries(kept), [directory]: { identity, at: new Date(nowMs).toISOString() } } };
|
|
37229
|
-
|
|
37230
|
-
|
|
37310
|
+
fs29.mkdirPrivate(import_node_path28.default.dirname(picksFile));
|
|
37311
|
+
fs29.writeFilePrivate(picksFile, `${JSON.stringify(next, null, 2)}
|
|
37231
37312
|
`);
|
|
37232
37313
|
}
|
|
37233
37314
|
var import_node_path28, PoolGraphError, SCHEMA_VERSION, PickEntrySchema, PicksFileSchema;
|
|
@@ -38094,12 +38175,12 @@ function decideSignIn(facts) {
|
|
|
38094
38175
|
function credentialsFilePath(farmRoot) {
|
|
38095
38176
|
return import_node_path31.default.join(farmRoot, CREDENTIALS_FILE);
|
|
38096
38177
|
}
|
|
38097
|
-
function identitySignIn(
|
|
38178
|
+
function identitySignIn(fs29, probe, identity) {
|
|
38098
38179
|
const probing = !identity.hasCredentialBlock;
|
|
38099
38180
|
return decideSignIn({
|
|
38100
38181
|
hasCredentialBlock: identity.hasCredentialBlock,
|
|
38101
38182
|
keychainItem: probing && probe.platform === "darwin" && probe.run !== void 0 ? keychainHasItem(probe.run, identity.farmRoot) : void 0,
|
|
38102
|
-
credentialsFile: probing &&
|
|
38183
|
+
credentialsFile: probing && fs29.lstat(credentialsFilePath(identity.farmRoot)) !== void 0,
|
|
38103
38184
|
platform: probe.platform
|
|
38104
38185
|
});
|
|
38105
38186
|
}
|
|
@@ -64088,6 +64169,58 @@ ${captureLines}` : capture.stack;
|
|
|
64088
64169
|
}
|
|
64089
64170
|
});
|
|
64090
64171
|
|
|
64172
|
+
// src/frontdoor/doorLog.ts
|
|
64173
|
+
function appendDoorLog(paths, line) {
|
|
64174
|
+
import_node_fs14.default.mkdirSync(paths.logsDir, { recursive: true });
|
|
64175
|
+
import_node_fs14.default.appendFileSync(paths.frontdoorLogPath, `${(/* @__PURE__ */ new Date()).toISOString()} ${line}
|
|
64176
|
+
`);
|
|
64177
|
+
}
|
|
64178
|
+
var import_node_fs14;
|
|
64179
|
+
var init_doorLog = __esm({
|
|
64180
|
+
"src/frontdoor/doorLog.ts"() {
|
|
64181
|
+
"use strict";
|
|
64182
|
+
import_node_fs14 = __toESM(require("node:fs"), 1);
|
|
64183
|
+
}
|
|
64184
|
+
});
|
|
64185
|
+
|
|
64186
|
+
// src/frontdoor/replacement.ts
|
|
64187
|
+
function replacementLine(facts) {
|
|
64188
|
+
return `launcher ${String(facts.launcherPid)}: replacing front door; reason=${facts.reason} signal=${facts.signal} door=${String(facts.doorPid)} doorProtocol=${String(facts.doorProtocol)} launcherProtocol=${String(facts.launcherProtocol)} liveSessions=${String(facts.liveSessions)}`;
|
|
64189
|
+
}
|
|
64190
|
+
function retireLine(doorPid, signal, facts) {
|
|
64191
|
+
return `frontdoor ${String(doorPid)}: received ${signal}; retiring; tunnelsOpen=${String(facts.tunnels)} liveSessions=${String(facts.liveSessions)} protocol=${String(facts.protocol)} uptimeSeconds=${String(facts.uptimeSeconds)}`;
|
|
64192
|
+
}
|
|
64193
|
+
function exitNowLine(doorPid, facts) {
|
|
64194
|
+
return `frontdoor ${String(doorPid)}: received SIGINT again; exiting now; tunnelsDropped=${String(facts.tunnels)} liveSessions=${String(facts.liveSessions)}`;
|
|
64195
|
+
}
|
|
64196
|
+
function alreadyRetiringLine(doorPid) {
|
|
64197
|
+
return `frontdoor ${String(doorPid)}: received SIGTERM again; already retiring`;
|
|
64198
|
+
}
|
|
64199
|
+
function retireOnSignals(source, params) {
|
|
64200
|
+
let retiring = false;
|
|
64201
|
+
for (const signal of ["SIGTERM", "SIGINT"]) {
|
|
64202
|
+
source.on(signal, () => {
|
|
64203
|
+
if (retiring && signal === "SIGTERM") {
|
|
64204
|
+
params.log(alreadyRetiringLine(params.doorPid));
|
|
64205
|
+
return;
|
|
64206
|
+
}
|
|
64207
|
+
if (retiring) {
|
|
64208
|
+
params.log(exitNowLine(params.doorPid, params.facts()));
|
|
64209
|
+
params.exit(0);
|
|
64210
|
+
return;
|
|
64211
|
+
}
|
|
64212
|
+
retiring = true;
|
|
64213
|
+
params.log(retireLine(params.doorPid, signal, params.facts()));
|
|
64214
|
+
params.retire();
|
|
64215
|
+
});
|
|
64216
|
+
}
|
|
64217
|
+
}
|
|
64218
|
+
var init_replacement = __esm({
|
|
64219
|
+
"src/frontdoor/replacement.ts"() {
|
|
64220
|
+
"use strict";
|
|
64221
|
+
}
|
|
64222
|
+
});
|
|
64223
|
+
|
|
64091
64224
|
// src/frontdoor/ensure.ts
|
|
64092
64225
|
function ensureFrontDoor(params) {
|
|
64093
64226
|
const { paths, ports } = params;
|
|
@@ -64098,7 +64231,7 @@ function ensureFrontDoor(params) {
|
|
|
64098
64231
|
let lastRejection;
|
|
64099
64232
|
let busyDoor;
|
|
64100
64233
|
const liveSessionsOn = (doorPid) => listFrontDoorSessions(ports.fs, paths.frontdoorSessionsDir).filter(
|
|
64101
|
-
(session) => session.pid !== params.launcherPid && ports.isRunning(session.pid) && (session.supervisorPid === void 0 || session.supervisorPid === doorPid)
|
|
64234
|
+
(session) => session.pid !== params.launcherPid && ports.isRunning(session.pid) && (session.supervisorPid === void 0 || session.supervisorPid === doorPid || !ports.isRunning(session.supervisorPid))
|
|
64102
64235
|
).length;
|
|
64103
64236
|
const verifyWithRetry = (port) => {
|
|
64104
64237
|
let verdict = ports.verifyListener(port);
|
|
@@ -64108,12 +64241,20 @@ function ensureFrontDoor(params) {
|
|
|
64108
64241
|
}
|
|
64109
64242
|
return verdict;
|
|
64110
64243
|
};
|
|
64111
|
-
const
|
|
64244
|
+
const recordReplacement = (doorPid, doorProtocol, reason, signal) => {
|
|
64245
|
+
ports.recordReplacement(
|
|
64246
|
+
replacementLine({ reason, signal, launcherPid: params.launcherPid, launcherProtocol: FRONT_DOOR_PROTOCOL, doorPid, doorProtocol, liveSessions: liveSessionsOn(doorPid) })
|
|
64247
|
+
);
|
|
64248
|
+
};
|
|
64249
|
+
const stopAndAwaitExit = (supervisorPid, doorProtocol, reason, failure2) => {
|
|
64250
|
+
recordReplacement(supervisorPid, doorProtocol, reason, "SIGTERM");
|
|
64112
64251
|
ports.stopSupervisor(supervisorPid);
|
|
64113
64252
|
const graceEnds = ports.now() + FRONTDOOR_EXIT_GRACE_MS;
|
|
64114
64253
|
let killed = false;
|
|
64115
|
-
|
|
64254
|
+
const holdsAddresses = () => ports.isRunning(supervisorPid) && readFrontDoorState(ports.fs, paths.frontdoorStateFile)?.supervisorPid === supervisorPid;
|
|
64255
|
+
while (holdsAddresses()) {
|
|
64116
64256
|
if (!killed && ports.now() >= graceEnds) {
|
|
64257
|
+
recordReplacement(supervisorPid, doorProtocol, reason, "SIGKILL");
|
|
64117
64258
|
ports.killSupervisor(supervisorPid);
|
|
64118
64259
|
killed = true;
|
|
64119
64260
|
}
|
|
@@ -64128,16 +64269,19 @@ function ensureFrontDoor(params) {
|
|
|
64128
64269
|
const supervisorPid = state?.supervisorPid;
|
|
64129
64270
|
if (supervisorPid !== void 0 && !distrusted.has(supervisorPid) && ports.isRunning(supervisorPid)) {
|
|
64130
64271
|
if (state?.port !== void 0 && state.connectPort !== void 0) {
|
|
64131
|
-
if (supervisorPid === params.launcherPid && params.replace
|
|
64272
|
+
if (supervisorPid === params.launcherPid && params.replace === void 0 && ports.isFrontDoorSupervisor(supervisorPid)) {
|
|
64132
64273
|
const token = (0, import_node_crypto14.randomUUID)();
|
|
64133
64274
|
writeFrontDoorSession(ports.fs, paths.frontdoorSessionsDir, { pid: params.launcherPid, startedAt: ports.now(), token, supervisorPid, ...recordOf(params.session) });
|
|
64134
64275
|
return { port: state.port, connectPort: state.connectPort, token };
|
|
64135
64276
|
}
|
|
64136
64277
|
const verdict = verifyWithRetry(state.port);
|
|
64137
|
-
|
|
64278
|
+
const doorProtocol = state.protocol ?? 0;
|
|
64279
|
+
if (verdict.ok && !replaced && !spawned && (params.replace !== void 0 || doorProtocol < FRONT_DOOR_PROTOCOL)) {
|
|
64138
64280
|
stopAndAwaitExit(
|
|
64139
64281
|
supervisorPid,
|
|
64140
|
-
|
|
64282
|
+
doorProtocol,
|
|
64283
|
+
params.replace ?? "protocol-older",
|
|
64284
|
+
`the front door (pid ${String(supervisorPid)}, protocol ${String(doorProtocol)}; this launcher speaks protocol ${String(FRONT_DOOR_PROTOCOL)}) was asked to be replaced and did not exit`
|
|
64141
64285
|
);
|
|
64142
64286
|
replaced = true;
|
|
64143
64287
|
continue;
|
|
@@ -64153,15 +64297,15 @@ function ensureFrontDoor(params) {
|
|
|
64153
64297
|
}
|
|
64154
64298
|
if (ports.isFrontDoorSupervisor(supervisorPid)) {
|
|
64155
64299
|
const stranded = liveSessionsOn(supervisorPid);
|
|
64156
|
-
if (params.replace
|
|
64157
|
-
stopAndAwaitExit(supervisorPid, `the front door (pid ${String(supervisorPid)}) stopped answering and did not exit when asked to`);
|
|
64300
|
+
if (params.replace !== void 0 && !replaced) {
|
|
64301
|
+
stopAndAwaitExit(supervisorPid, doorProtocol, "probe-failed-restart", `the front door (pid ${String(supervisorPid)}) stopped answering and did not exit when asked to`);
|
|
64158
64302
|
replaced = true;
|
|
64159
64303
|
continue;
|
|
64160
64304
|
}
|
|
64161
64305
|
if (stranded > 0) {
|
|
64162
64306
|
busyDoor = { pid: supervisorPid, sessions: stranded };
|
|
64163
64307
|
} else {
|
|
64164
|
-
stopAndAwaitExit(supervisorPid, `the front door (pid ${String(supervisorPid)}) stopped answering and did not exit when asked to`);
|
|
64308
|
+
stopAndAwaitExit(supervisorPid, doorProtocol, "probe-failed-idle", `the front door (pid ${String(supervisorPid)}) stopped answering and did not exit when asked to`);
|
|
64165
64309
|
continue;
|
|
64166
64310
|
}
|
|
64167
64311
|
} else {
|
|
@@ -64203,7 +64347,7 @@ function restartFrontDoor(params) {
|
|
|
64203
64347
|
return { action: "not-running" };
|
|
64204
64348
|
}
|
|
64205
64349
|
try {
|
|
64206
|
-
ensureFrontDoor({ paths, launcherPid: params.pid, replace:
|
|
64350
|
+
ensureFrontDoor({ paths, launcherPid: params.pid, replace: params.reason, ports });
|
|
64207
64351
|
} finally {
|
|
64208
64352
|
removeFrontDoorSession(ports.fs, paths.frontdoorSessionsDir, params.pid);
|
|
64209
64353
|
}
|
|
@@ -64220,6 +64364,7 @@ var init_ensure2 = __esm({
|
|
|
64220
64364
|
import_node_crypto14 = require("node:crypto");
|
|
64221
64365
|
init_cliError();
|
|
64222
64366
|
init_state2();
|
|
64367
|
+
init_replacement();
|
|
64223
64368
|
init_state();
|
|
64224
64369
|
FRONTDOOR_START_TIMEOUT_MS = 3e4;
|
|
64225
64370
|
FRONTDOOR_LAUNCHER_POLL_MS = 100;
|
|
@@ -64350,14 +64495,14 @@ var init_selfIdentity = __esm({
|
|
|
64350
64495
|
|
|
64351
64496
|
// src/frontdoor/trust.ts
|
|
64352
64497
|
function resolveTrustBundle(params) {
|
|
64353
|
-
const { caCertFile, bundlesDir, variable, inherited, fs:
|
|
64498
|
+
const { caCertFile, bundlesDir, variable, inherited, fs: fs29 } = params;
|
|
64354
64499
|
if (inherited === void 0 || inherited === "" || import_node_path38.default.resolve(inherited) === import_node_path38.default.resolve(caCertFile)) {
|
|
64355
64500
|
return { path: caCertFile };
|
|
64356
64501
|
}
|
|
64357
|
-
const caPem =
|
|
64502
|
+
const caPem = fs29.readFileUtf8(caCertFile);
|
|
64358
64503
|
let inheritedPem;
|
|
64359
64504
|
try {
|
|
64360
|
-
inheritedPem =
|
|
64505
|
+
inheritedPem = fs29.readFileUtf8(inherited);
|
|
64361
64506
|
} catch (error63) {
|
|
64362
64507
|
return {
|
|
64363
64508
|
path: caCertFile,
|
|
@@ -64370,9 +64515,9 @@ function resolveTrustBundle(params) {
|
|
|
64370
64515
|
const combined = `${inheritedPem.trimEnd()}
|
|
64371
64516
|
${caPem}`;
|
|
64372
64517
|
const bundle = import_node_path38.default.join(bundlesDir, `${(0, import_node_crypto15.createHash)("sha256").update(combined).digest("hex").slice(0, BUNDLE_NAME_HEX_DIGITS)}.pem`);
|
|
64373
|
-
if (!
|
|
64374
|
-
|
|
64375
|
-
|
|
64518
|
+
if (!fs29.exists(bundle)) {
|
|
64519
|
+
fs29.mkdirp(bundlesDir);
|
|
64520
|
+
fs29.writeFileAtomic(bundle, combined);
|
|
64376
64521
|
}
|
|
64377
64522
|
return { path: bundle };
|
|
64378
64523
|
}
|
|
@@ -64395,6 +64540,9 @@ function realEnsurePorts(paths, spawnDaemon) {
|
|
|
64395
64540
|
sleep: realSleepSync,
|
|
64396
64541
|
spawnSupervisor: (layout) => spawnDaemon(layout, "__frontdoor-supervisor", layout.frontdoorLogPath),
|
|
64397
64542
|
isFrontDoorSupervisor: (pid) => isFrontDoorSupervisorPid(pid, realIsFrontDoorSupervisor),
|
|
64543
|
+
recordReplacement: (line) => {
|
|
64544
|
+
appendDoorLog(paths, line);
|
|
64545
|
+
},
|
|
64398
64546
|
stopSupervisor: (pid) => {
|
|
64399
64547
|
process.kill(pid, "SIGTERM");
|
|
64400
64548
|
},
|
|
@@ -64402,11 +64550,11 @@ function realEnsurePorts(paths, spawnDaemon) {
|
|
|
64402
64550
|
process.kill(pid, "SIGKILL");
|
|
64403
64551
|
},
|
|
64404
64552
|
// Read fresh for each probe: a replacement supervisor may have regenerated an unparseable CA, and the probe must trust exactly what the serving door's leaf chains to.
|
|
64405
|
-
verifyListener: (port) => probeFrontDoorSync(port,
|
|
64553
|
+
verifyListener: (port) => probeFrontDoorSync(port, import_node_fs15.default.readFileSync(paths.frontdoorCaCertFile, "utf8"))
|
|
64406
64554
|
};
|
|
64407
64555
|
}
|
|
64408
|
-
function realRestartFrontDoor(paths, spawnDaemon) {
|
|
64409
|
-
return restartFrontDoor({ paths, pid: process.pid, ports: realEnsurePorts(paths, spawnDaemon) });
|
|
64556
|
+
function realRestartFrontDoor(paths, spawnDaemon, reason) {
|
|
64557
|
+
return restartFrontDoor({ paths, pid: process.pid, reason, ports: realEnsurePorts(paths, spawnDaemon) });
|
|
64410
64558
|
}
|
|
64411
64559
|
function realFrontDoorPort(paths, spawnDaemon) {
|
|
64412
64560
|
return {
|
|
@@ -64426,22 +64574,23 @@ function realFrontDoorPort(paths, spawnDaemon) {
|
|
|
64426
64574
|
}
|
|
64427
64575
|
};
|
|
64428
64576
|
}
|
|
64429
|
-
var
|
|
64577
|
+
var import_node_fs15, realTrustBundleFs;
|
|
64430
64578
|
var init_realFrontDoorPort = __esm({
|
|
64431
64579
|
"src/frontdoor/realFrontDoorPort.ts"() {
|
|
64432
64580
|
"use strict";
|
|
64433
|
-
|
|
64581
|
+
import_node_fs15 = __toESM(require("node:fs"), 1);
|
|
64434
64582
|
init_realPorts();
|
|
64583
|
+
init_doorLog();
|
|
64435
64584
|
init_ensure2();
|
|
64436
64585
|
init_state();
|
|
64437
64586
|
init_probe();
|
|
64438
64587
|
init_selfIdentity();
|
|
64439
64588
|
init_trust();
|
|
64440
64589
|
realTrustBundleFs = {
|
|
64441
|
-
readFileUtf8: (file2) =>
|
|
64442
|
-
exists: (file2) =>
|
|
64590
|
+
readFileUtf8: (file2) => import_node_fs15.default.readFileSync(file2, "utf8"),
|
|
64591
|
+
exists: (file2) => import_node_fs15.default.existsSync(file2),
|
|
64443
64592
|
mkdirp: (dir) => {
|
|
64444
|
-
|
|
64593
|
+
import_node_fs15.default.mkdirSync(dir, { recursive: true });
|
|
64445
64594
|
},
|
|
64446
64595
|
writeFileAtomic: (file2, contents) => {
|
|
64447
64596
|
realFarmFs.writeFilePrivate(file2, contents);
|
|
@@ -64539,20 +64688,20 @@ function lockHolder(contents) {
|
|
|
64539
64688
|
const pid = Number((contents ?? "").trim());
|
|
64540
64689
|
return Number.isInteger(pid) && pid > 0 ? pid : void 0;
|
|
64541
64690
|
}
|
|
64542
|
-
function acquireUpdateLock(
|
|
64543
|
-
const take = () =>
|
|
64691
|
+
function acquireUpdateLock(fs29, isProcessAlive, pid, lockPath) {
|
|
64692
|
+
const take = () => fs29.writeFileExclusive(lockPath, `${String(pid)}
|
|
64544
64693
|
`);
|
|
64545
64694
|
const release = () => {
|
|
64546
|
-
|
|
64695
|
+
fs29.unlink(lockPath);
|
|
64547
64696
|
};
|
|
64548
64697
|
if (take()) {
|
|
64549
64698
|
return release;
|
|
64550
64699
|
}
|
|
64551
|
-
const holder = lockHolder(
|
|
64700
|
+
const holder = lockHolder(fs29.readFileUtf8(lockPath));
|
|
64552
64701
|
if (holder !== void 0 && holder !== pid && isProcessAlive(holder)) {
|
|
64553
64702
|
throw new UpdateConflictError(`another agent-shim update (pid ${String(holder)}) is already running`);
|
|
64554
64703
|
}
|
|
64555
|
-
|
|
64704
|
+
fs29.unlink(lockPath);
|
|
64556
64705
|
if (!take()) {
|
|
64557
64706
|
throw new UpdateConflictError("another agent-shim update took the lock while it was being replaced");
|
|
64558
64707
|
}
|
|
@@ -65298,15 +65447,15 @@ function contextTokensOfTranscript(text2) {
|
|
|
65298
65447
|
}
|
|
65299
65448
|
return void 0;
|
|
65300
65449
|
}
|
|
65301
|
-
function newestTranscript(
|
|
65450
|
+
function newestTranscript(fs29, projectDir) {
|
|
65302
65451
|
let newest;
|
|
65303
65452
|
let newestMs = -Infinity;
|
|
65304
|
-
for (const name of
|
|
65453
|
+
for (const name of fs29.readdir(projectDir)) {
|
|
65305
65454
|
if (!name.endsWith(".jsonl")) {
|
|
65306
65455
|
continue;
|
|
65307
65456
|
}
|
|
65308
65457
|
const candidate = import_node_path43.default.join(projectDir, name);
|
|
65309
|
-
const stat =
|
|
65458
|
+
const stat = fs29.lstat(candidate);
|
|
65310
65459
|
if (stat?.kind === "file" && stat.mtimeMs > newestMs) {
|
|
65311
65460
|
newestMs = stat.mtimeMs;
|
|
65312
65461
|
newest = candidate;
|
|
@@ -65314,18 +65463,18 @@ function newestTranscript(fs28, projectDir) {
|
|
|
65314
65463
|
}
|
|
65315
65464
|
return newest;
|
|
65316
65465
|
}
|
|
65317
|
-
function latestConversationId(
|
|
65318
|
-
const file2 = newestTranscript(
|
|
65466
|
+
function latestConversationId(fs29, params) {
|
|
65467
|
+
const file2 = newestTranscript(fs29, import_node_path43.default.join(params.claudeHome, "projects", projectDirNameOf(params.cwd)));
|
|
65319
65468
|
return file2 === void 0 ? void 0 : import_node_path43.default.basename(file2, ".jsonl");
|
|
65320
65469
|
}
|
|
65321
|
-
function resumedContextTokens(
|
|
65470
|
+
function resumedContextTokens(fs29, params) {
|
|
65322
65471
|
const target = resumeTargetOf(params.passthrough);
|
|
65323
65472
|
if (target === void 0) {
|
|
65324
65473
|
return void 0;
|
|
65325
65474
|
}
|
|
65326
65475
|
const projectDir = import_node_path43.default.join(params.claudeHome, "projects", projectDirNameOf(params.cwd));
|
|
65327
|
-
const file2 = target.kind === "id" ? import_node_path43.default.join(projectDir, `${target.id}.jsonl`) : newestTranscript(
|
|
65328
|
-
const text2 = file2 === void 0 ? void 0 :
|
|
65476
|
+
const file2 = target.kind === "id" ? import_node_path43.default.join(projectDir, `${target.id}.jsonl`) : newestTranscript(fs29, projectDir);
|
|
65477
|
+
const text2 = file2 === void 0 ? void 0 : fs29.readFileUtf8(file2);
|
|
65329
65478
|
return text2 === void 0 ? void 0 : contextTokensOfTranscript(text2);
|
|
65330
65479
|
}
|
|
65331
65480
|
var import_node_path43;
|
|
@@ -67355,7 +67504,7 @@ function resolveIdentityCredential(identity, credential, env, port) {
|
|
|
67355
67504
|
return resolution.ok ? resolution : { ok: false, status: CREDENTIAL_UNAVAILABLE_EXIT, message: resolution.message };
|
|
67356
67505
|
}
|
|
67357
67506
|
function pickFromPool(decided, params, parsedArgv, readOnly) {
|
|
67358
|
-
const { paths, fs:
|
|
67507
|
+
const { paths, fs: fs29, proc, log } = params;
|
|
67359
67508
|
if (decided.pool === void 0) {
|
|
67360
67509
|
return { identityDecision: decided };
|
|
67361
67510
|
}
|
|
@@ -67374,7 +67523,7 @@ function pickFromPool(decided, params, parsedArgv, readOnly) {
|
|
|
67374
67523
|
selectedVia: decided.source,
|
|
67375
67524
|
pools: params.pools,
|
|
67376
67525
|
paths,
|
|
67377
|
-
fs:
|
|
67526
|
+
fs: fs29,
|
|
67378
67527
|
usageFs: farmRuntime.fs,
|
|
67379
67528
|
cwd: farmRuntime.cwd,
|
|
67380
67529
|
now: farmRuntime.now,
|
|
@@ -67397,7 +67546,7 @@ function pickFromPool(decided, params, parsedArgv, readOnly) {
|
|
|
67397
67546
|
};
|
|
67398
67547
|
}
|
|
67399
67548
|
function decideLaunch(params, readOnly) {
|
|
67400
|
-
const { paths, fs:
|
|
67549
|
+
const { paths, fs: fs29, proc, log } = params;
|
|
67401
67550
|
const { env, argv } = proc;
|
|
67402
67551
|
const parsedArgv = parseLauncherArgv(argv);
|
|
67403
67552
|
const cliOverride = buildCliOverride({
|
|
@@ -67412,7 +67561,7 @@ function decideLaunch(params, readOnly) {
|
|
|
67412
67561
|
argv0Identity: parsedArgv.identity,
|
|
67413
67562
|
directoryPinnedIdentity: params.directoryPinnedIdentity,
|
|
67414
67563
|
readActiveIdentityFile: () => {
|
|
67415
|
-
const raw =
|
|
67564
|
+
const raw = fs29.readFileUtf8(paths.activeIdentityFile);
|
|
67416
67565
|
if (raw === void 0) {
|
|
67417
67566
|
return void 0;
|
|
67418
67567
|
}
|
|
@@ -67447,7 +67596,7 @@ function decideLaunch(params, readOnly) {
|
|
|
67447
67596
|
}
|
|
67448
67597
|
let loadedIdentity;
|
|
67449
67598
|
if (identityDecision.name !== void 0) {
|
|
67450
|
-
loadedIdentity = loadIdentity(paths.identitiesDir, identityDecision.name,
|
|
67599
|
+
loadedIdentity = loadIdentity(paths.identitiesDir, identityDecision.name, fs29);
|
|
67451
67600
|
if (loadedIdentity === void 0) {
|
|
67452
67601
|
log.error(
|
|
67453
67602
|
`agent-shim: no identity named "${identityDecision.name}" (selected via ${identityDecision.source}). Run \`agent-shim identity add ${identityDecision.name}\` first.`
|
|
@@ -67462,7 +67611,7 @@ function decideLaunch(params, readOnly) {
|
|
|
67462
67611
|
identityDefaultConfigProfile: loadedIdentity?.config.defaultConfigProfile,
|
|
67463
67612
|
globalDefaultConfigProfile: params.globalDefaultConfigProfile
|
|
67464
67613
|
});
|
|
67465
|
-
if (configProfileDecision.name !== void 0 && params.allowMissingConfigProfile !== true &&
|
|
67614
|
+
if (configProfileDecision.name !== void 0 && params.allowMissingConfigProfile !== true && fs29.readConfigFile(import_node_path45.default.join(paths.configProfilesDir, `${configProfileDecision.name}.json`)) === void 0) {
|
|
67466
67615
|
log.error(
|
|
67467
67616
|
`agent-shim: no configuration profile named "${configProfileDecision.name}" (selected via ${configProfileDecision.source}). Run \`agent-shim profile add ${configProfileDecision.name}\` first.`
|
|
67468
67617
|
);
|
|
@@ -67471,7 +67620,7 @@ function decideLaunch(params, readOnly) {
|
|
|
67471
67620
|
const farmContext = farm !== void 0 && farmIdentity !== void 0 ? { farm, identity: farmIdentity, cascade: farm.loadCascade(configProfileDecision.name, cliOverride) } : void 0;
|
|
67472
67621
|
const providerParams = {
|
|
67473
67622
|
paths,
|
|
67474
|
-
port:
|
|
67623
|
+
port: fs29,
|
|
67475
67624
|
...parsedArgv.provider === void 0 || parsedArgv.provider === false ? {} : { cliProvider: parsedArgv.provider },
|
|
67476
67625
|
...farmContext === void 0 ? {} : { cascade: farmContext.cascade }
|
|
67477
67626
|
};
|
|
@@ -67570,9 +67719,9 @@ function decideLaunch(params, readOnly) {
|
|
|
67570
67719
|
const flags = loginlessProvider === void 0 ? requestedFlags : { ...requestedFlags, remoteControl: false };
|
|
67571
67720
|
const globalModels = loadConfigFile(paths.globalConfigFile, GlobalConfigSchema, params.fs.readConfigFile)?.config.models;
|
|
67572
67721
|
const models = launchCascade !== void 0 && params.farm !== void 0 ? cascadeModels : globalModels;
|
|
67573
|
-
const listedProviders = listProviderNames(
|
|
67722
|
+
const listedProviders = listProviderNames(fs29.readdir, paths.providersDir).flatMap((name) => {
|
|
67574
67723
|
try {
|
|
67575
|
-
const definition = loadProvider(paths.providersDir, name,
|
|
67724
|
+
const definition = loadProvider(paths.providersDir, name, fs29);
|
|
67576
67725
|
return definition === void 0 ? [] : [[name, definition, parseCatalogueCache(params.fs.readFileUtf8(catalogueCachePath(paths, name)))?.models ?? []]];
|
|
67577
67726
|
} catch {
|
|
67578
67727
|
return [];
|
|
@@ -68912,10 +69061,10 @@ function Ww(e14) {
|
|
|
68912
69061
|
}
|
|
68913
69062
|
function M_() {
|
|
68914
69063
|
let e14 = "";
|
|
68915
|
-
if (typeof process < "u" && typeof process.cwd === "function" && typeof
|
|
69064
|
+
if (typeof process < "u" && typeof process.cwd === "function" && typeof import_node_fs17.realpathSync === "function") try {
|
|
68916
69065
|
let t10 = (0, import_node_process4.cwd)();
|
|
68917
69066
|
try {
|
|
68918
|
-
e14 = Ww((0,
|
|
69067
|
+
e14 = Ww((0, import_node_fs17.realpathSync)(t10));
|
|
68919
69068
|
} catch {
|
|
68920
69069
|
e14 = Ww(t10);
|
|
68921
69070
|
}
|
|
@@ -75539,11 +75688,11 @@ function hm(e14, t10, n10, r10) {
|
|
|
75539
75688
|
function EU(e14, t10) {
|
|
75540
75689
|
let n10 = e14.data;
|
|
75541
75690
|
if (n10.isSidechain === true) return null;
|
|
75542
|
-
let r10 =
|
|
75691
|
+
let r10 = fs18(n10.firstPromptLocked === true ? n10.firstPrompt : n10.commandFallback) || void 0, o = fs18(n10.customTitle) || fs18(n10.aiTitle) || void 0, s = o || fs18(n10.lastPrompt) || fs18(n10.summaryHint) || r10;
|
|
75543
75692
|
if (!s) return null;
|
|
75544
|
-
return { sessionId: e14.sessionId, summary: s, lastModified: e14.mtime, fileSize: void 0, customTitle: o, firstPrompt: r10, gitBranch:
|
|
75693
|
+
return { sessionId: e14.sessionId, summary: s, lastModified: e14.mtime, fileSize: void 0, customTitle: o, firstPrompt: r10, gitBranch: fs18(n10.gitBranch) || void 0, cwd: fs18(n10.cwd) || t10 || void 0, tag: fs18(n10.tag) || void 0, createdAt: uAe(n10.createdAt) };
|
|
75545
75694
|
}
|
|
75546
|
-
function
|
|
75695
|
+
function fs18(e14) {
|
|
75547
75696
|
return typeof e14 === "string" ? e14 : void 0;
|
|
75548
75697
|
}
|
|
75549
75698
|
function uAe(e14) {
|
|
@@ -82579,14 +82728,14 @@ async function jGe(e14, t10, n10, r10) {
|
|
|
82579
82728
|
if (d.length === 0) return [];
|
|
82580
82729
|
return iv(Buffer.from(gZ(d)), { limit: r10.limit, offset: r10.offset }, l, c10);
|
|
82581
82730
|
}
|
|
82582
|
-
var import_node_module, import_crypto, import_crypto2, import_path, import_node_fs16, import_node_process4, import_fs, import_os, import_path2, yy, import_fs2, import_promises, import_path3, import_readline, import_promises2, import_path4, import_os2, import_path5, Se, import_promises3, xe, import_promises4, import_fs3, import_promises5, import_os3, import_path6, import_promises6, import_os4, import_node_path47, import_node_os10, import_node_process5, import_path7, import_events, import_fs4, import_promises7, import_path8, import_child_process, import_util9, import_child_process2, import_fs5, import_path9, import_path10, import_crypto3, import_fs6, import_path11, import_promises8, import_path12, import_path13, import_promises9, import_path14, import_path15, import_fs7, import_promises10, import_path16, import_crypto4, import_path17, import_async_hooks, import_fs8, import_promises11, import_crypto5, import_fs9, import_promises12, import_path18, import_promises13, import_path19, import_crypto6, import_path20, import_path21, import_path22, import_path23, import_promises14, import_fs10, import_promises15, import_path24, import_util10, import_path25, import_os5, import_path26, import_path27, import_path28, import_path29, import_path30, import_net, import_os6, import_child_process3, import_fs11, import_child_process4, import_crypto7, import_promises16, import_module, import_os7, import_path31, import_url, import_events2, import_child_process5, import_fs12, import_readline2, import_string_decoder, import_fs13, import_promises17, import_os8, import_path32, import_crypto8, import_os9, import_fs14, import_path33, import_crypto9, import_fs15, import_promises18, import_path34, IZ, DZ, v_, LZ, OT, NZ, UZ, kT, X, FZ, dr, HZ, jZ, BZ, ot, st, ed, Kv, Te, Me, Oo, nd, hF, Xv, Qv, rd, LF, or, WF, ZF, sA, XF, od, sd, hg, id, Sg, Oz, fA, $z, Wz, Zz, s$, a$, d$, f$, g$, _$, E$, v$, T$, O$, I$, L$, wg, z$, j$, G$, V$, yA, SA, rH, lH, uH, _H, EH, EA, RH, TH, kH, DH, NH, zH, jH, GH, VH, ZH, JH, ej, nj, ij, cj, uj, CA, bj, Aj, wj, PT, KZ, GZ, VGe, VZ, MT, wr, jo, JZ, XZ, NT, UT, FT, zT, Bo, $T, HT, jT, BT, a4, sp, l4, c4, vt, u4, Nt, KT, d4, p4, uc, GT, m4, g4, WT, _4, y4, VT, Dn, Et, b4, C4, v4, A4, ra, x4, ip, qT, ZT, w4, O4, ro, P4, I4, D4, L4, M4, N4, U4, YT, JT, Sn, H4, Ko, j4, oo, XT, QT, G4, W4, V4, ew, Z4, Y4, tw, X4, nw, R_, rw, ow, Go, sw, iw, aw, lw, ei, aY, cw, Or, cY, uw, dw, lp, pw, cp, mY, gY, up, _Y, aa, fw, la, EY, bY, CY, vY, AY, RY, xY, TY, wY, OY, kY, PY, IY, mw, x_, gw, ca, MY, et, dp, hw, pp, zY, $Y, _w, HY, ua, yw, wt, KY, T_, Sw, WY, VY, qY, so, mp, Ew, vw, bw, YY, Cw, JY, XY, kr, QY, e9, Wo, n9, da, o9, s9, i9, a9, l9, c9, u9, d9, p9, f9, m9, g9, h9, _9, y9, S9, E9, b9, C9, v9, A9, R9, x9, T9, Qe, Aw, pa, hp, Rw, dc, k9, w_, P9, Pr, xw, I9, fa, D9, L9, _p, N9, ma, yp, z9, Tw, $9, H9, ww, Vo, Ir, pc, W9, V9, q9, Ow, Y9, Sp, J9, Ep, X9, qo, Q9, bp, kw, eJ, Pw, Iw, Dw, Lw, tJ, nJ, rJ, oJ, sJ, ti, io, iJ, Mw, Nw, Cp, aJ, Uw, Fw, ga, pr, uJ, Fe, $w, O_, k_, I_, ha, Bw, D_, qw, Vw, N_, U_, yJ, _a3, Yo, Zw, bJ, Rp, Yw, vJ, AJ, Jw, xp, Xw, Tp, Qw, kJ, ya, IJ, DJ, Sa, MJ, fc, NJ, eO, FJ, zJ, $J, tO, Ea, jJ, nO, rO, sO, iO, Vn, GJ, Ln, Jo, aO, lO, cO, wp, XJ, QJ, uO, ba, dO, pO, fO, Dr, ao, mO, Ca, gO, z_, $_, H_, j_, B_, K_, G_, W_, V_, q_, Z_, _O, Y_, J_, yO, X_, c3, Q_, ey, ty, ny, ry, oy, sy, iy, ay, ly, cy, we, SO, en, d3, Pp, vO, g3, gy, wO, S3, BO, KO, Ip, Dp, v3, GO, WO, F9e, IO, A3, hy, x3, NO, I3, Ay, Ry, D3, xy, L3, bc, xa, Ty, wy, Oy, ky, XO, Py, Iy, Dy, Ly, My, Ny, Uy, Fy, zy, nk, rk, d3e, p3e, f3e, m3e, g3e, U3, jp, jy, ik, By, Ky, lk, $3, uk, ck, G3, W3, V3, it, Y3, J3, hk, tXe, Q3, kt, We, gX, Ta, SX, mr, Yp, Jp, eS, nS, yXe, IX, DX, rS, ka, oS, Ok, kk, HX, jX, ef, bXe, Uk, Mr, wc, Fk, Pa, OXe, kXe, iS, PXe, IXe, DXe, GX, YX, JX, XX, QX, e6, t6, Yk, n6, r6, o6, s6, i6, a6, l6, c6, Vk, uS, lf, dS, Qk, eP, uf, os10, qXe, ZXe, h6, tP, df, _6, y6, S6, E6, b6, Jn, gr, nP, rP, Dc, pS, oP, gS, lP, C6, mS, lS, sP, w6, O6, dP, k6, YXe, JXe, P6, I6, pf, L6, fP, XXe, QXe, M6, SS, z6, $6, j6, bP, CP, G6, Lc, si, Z6, ES, bS, X6, Q6, e5, t5, n5, u5, r5, o5, s5, i5, a5, l5, c5, u52, d5, p5, f5, m5, g5, h5, _5, y5, S5, E5, b5, C5, v5, A5, R5, x5, T5, w5, O5, k5, P5, I5, D5, L5, M5, N5, U5, F5, z5, $5, H5, j5, B5, K5, G5, W5, V5, q5, Z5, Y5, J5, X5, Q5, e8, t8, n8, r8, o8, s8, i8, a8, l8, c8, u8, d8, CS, p8, f8, m8, g8, h8, _8, y8, S8, E8, b8, C8, v8, A8, R8, x8, T8, w8, O8, k8, P8, I8, D8, L8, M8, N8, U8, F8, z8, $8, H8, j8, B8, K8, G8, W8, V8, q8, Z8, Y8, J8, X8, Q8, e7, t7, n7, r7, o7, s7, i7, a7, l7, c7, u7, d7, p7, f7, m7, g7, h7, _7, y7, S7, E7, b7, C7, TP, v7, L6e, RP, A7, x7, kP, ff, U6e, F6e, Ua, z6e, $6e, H6e, j6e, PP, IP, vS, DP, w7, LP, O7, k7, P7, AS, RS, xS, I7, MP, NP, D7, G6e, L7, W6e, M7, N7, UP, V6e, U7, F7, z7, $7, H7, j7, B7, q6e, is, wS, Fa, K7, G7, W7, i5e, X7, Q7, HP, $P, BP, tQ, WP, VP, JP, _Q, QP, eI, xQ, Uc, DS, $a, wQ, OQ, kQ, PQ, IQ, DQ, LQ, MQ, NQ, UQ, FQ, zQ, $Q, HQ, jQ, BQ, KQ, GQ, WQ, VQ, qQ, ZQ, YQ, JQ, XQ, QQ, eee, tee, nee, ree, oee, see, iee, aee, lee, cee, uee, dee, pee, fee, mee, gee, hee, _ee, yee, See, Eee, bee, Cee, vee, Aee, Ree, xee, Tee, wee, Oee, kee, Pee, Iee, Dee, Lee, Mee, Nee, Uee, Fee, zee, $ee, Hee, jee, Bee, Kee, Gee, Wee, Vee, qee, Zee, Yee, Jee, Xee, Qee, ete, tte, nte, rte, ote, ste, ite, ate, lte, cte, ute, dte, pte, fte, mte, gte, hte, _te, yte, Ste, Ete, bte, Cte, vte, Ate, Rte, xte, Tte, wte, Ote, kte, Pte, Ite, Dte, Lte, Mte, Nte, Ute, Fte, zte, $te, Hte, jte, Bte, Kte, Gte, Wte, Vte, qte, Zte, Yte, Jte, Xte, Qte, ene, tne, nne, rne, one, sne, ine, ane, lne, cne, une, dne, pne, fne, mne, gne, hne, _ne, yne, Sne, Ene, bne, Cne, vne, Ane, Rne, xne, Tne, wne, One, kne, Pne, Ine, Dne, Lne, Mne, Nne, Une, Fne, zne, $ne, Hne, jne, Bne, Kne, Gne, Wne, Vne, qne, Zne, Yne, Jne, Xne, Qne, ere, tre, nre, rre, ore, sre, ire, are, lre, cre, ure, dre, pre, fre, mre, gre, hre, _re, yre, Sre, Ere, bre, Cre, vre, Are, Rre, xre, Tre, wre, Ore, kre, Pre, Ire, Dre, Lre, Mre, Nre, Ure, Fre, zre, $re, Hre, jre, Bre, Kre, Gre, Wre, Vre, qre, Zre, Yre, Jre, Xre, Qre, eoe, toe, noe, roe, ooe, soe, ioe, aoe, loe, coe, uoe, doe, poe, foe, moe, goe, hoe, _oe, yoe, Soe, Eoe, boe, Coe, voe, Aoe, Roe, xoe, Toe, woe, Ooe, koe, Poe, Ioe, Doe, Loe, Moe, Noe, Uoe, Foe, zoe, $oe, Hoe, joe, Boe, Koe, Goe, Woe, Voe, qoe, Zoe, Yoe, Joe, Xoe, Qoe, ese, tse, nse, rse, ose, sse, ise, ase, lse, cse, use, dse, pse, fse, mse, gse, hse, _se, yse, Sse, Ese, LS, bse, Cse, vse, Ase, Rse, xse, Tse, wse, Ose, kse, Pse, Ise, Dse, Lse, Mse, Nse, Use, Fse, zse, $se, Hse, jse, Bse, Kse, Gse, Wse, Vse, qse, Zse, Yse, Jse, Xse, Qse, eie, tie, nie, rie, oie, sie, iie, aie, lie, cie, uie, die, pie, fie, mie, gie, hie, _ie, yie, Sie, Eie, bie, Cie, vie, Aie, Rie, xie, Tie, wie, Oie, kie, Pie, Iie, Die, Lie, Mie, Nie, Uie, Fie, zie, $ie, Hie, jie, Bie, Kie, Gie, Wie, Vie, qie, Zie, Yie, Jie, Xie, Qie, eae, tae, nae, rae, oae, sae, iae, aae, lae, cae, uae, dae, pae, fae, mae, gae, hae, _ae, yae, Sae, Eae, bae, Cae, vae, Aae, Rae, xae, Tae, wae, Oae, kae, Pae, Iae, Dae, Lae, Mae, Nae, Uae, Fae, zae, $ae, Hae, jae, Bae, Kae, Gae, Wae, Vae, qae, Zae, Yae, Jae, Xae, Qae, ele, tle, nle, rle, ole, sle, ile, ale, lle, cle, ule, dle, ple, fle, mle, gle, hle, _le, yle, Sle, Ele, ble, Cle, vle, Ale, Rle, xle, Tle, wle, Ole, kle, Ple, Ile, Dle, Lle, Mle, Nle, Ule, Fle, zle, $le, Hle, jle, Ble, Kle, Gle, Wle, Vle, qle, Zle, Yle, Jle, MS, Xle, Qle, ece, tce, nce, rce, oce, sce, ice, ace, lce, cce, uce, dce, pce, fce, mce, gce, hce, _ce, yce, Sce, Ece, bce, Cce, vce, Ace, Rce, xce, Tce, wce, Oce, kce, Pce, Ice, Dce, Lce, Mce, Nce, Uce, Fce, zce, $ce, Hce, jce, Bce, Kce, Gce, Wce, Vce, qce, Zce, Yce, Jce, Xce, Qce, eue, tue, nue, rue, oue, sue, iue, aue, lue, cue, uue, due, pue, fue, mue, gue, hue, _ue, yue, Sue, Eue, bue, Cue, vue, Aue, Rue, xue, Tue, wue, Oue, kue, Pue, Iue, Due, Lue, Mue, Nue, Uue, Fue, zue, $ue, Hue, jue, Bue, Kue, Gue, Wue, Vue, que, Zue, Yue, Jue, Xue, Que, ede, tde, nde, rde, ode, sde, ide, ade, lde, cde, ude, dde, pde, fde, mde, gde, hde, _de, yde, Sde, Ede, bde, Cde, vde, Ade, Rde, xde, Tde, wde, Ode, kde, Pde, Ide, Dde, Lde, Mde, Nde, Ude, Fde, zde, $de, Hde, jde, Bde, Kde, Gde, Wde, Vde, qde, Zde, Yde, Jde, Xde, Qde, epe, tpe, npe, rpe, ope, spe, ipe, ape, lpe, cpe, upe, dpe, ppe, fpe, mpe, gpe, hpe, _pe, ype, Spe, Epe, bpe, Cpe, vpe, Ape, Rpe, xpe, Tpe, wpe, Ope, kpe, Ppe, Ipe, Dpe, Lpe, Mpe, Npe, Upe, Fpe, zpe, $pe, Hpe, jpe, Bpe, Kpe, Gpe, Wpe, Vpe, qpe, Zpe, Ype, Jpe, Xpe, Qpe, efe, tfe, nfe, rfe, ofe, sfe, ife, afe, lfe, cfe, ufe, dfe, pfe, ffe, mfe, gfe, hfe, _fe, yfe, Sfe, Efe, bfe, Cfe, vfe, Afe, Rfe, xfe, Tfe, wfe, Ofe, kfe, Pfe, Ife, Dfe, Lfe, Mfe, Nfe, Ufe, Ffe, zfe, $fe, Hfe, jfe, Bfe, Kfe, Gfe, Wfe, Vfe, qfe, Zfe, Yfe, Jfe, Xfe, Qfe, eme, tme, nme, rme, ome, sme, ime, ame, lme, cme, ume, dme, pme, fme, mme, gme, hme, _me, yme, Sme, Eme, bme, Cme, vme, Ame, Rme, xme, Tme, wme, Ome, kme, Pme, Ime, Dme, Lme, Mme, Nme, Ume, Fme, zme, $me, Hme, jme, Bme, Kme, Gme, Wme, Vme, qme, Zme, Yme, Jme, NS, Xme, Qme, ege, tge, nge, rge, oge, sge, ige, age, lge, cge, uge, dge, pge, fge, mge, gge, hge, _ge, yge, Sge, Ege, bge, Cge, vge, Age, Rge, xge, Tge, wge, Oge, kge, Pge, Ige, Dge, Lge, Mge, Nge, Uge, Fge, zge, $ge, Hge, US, jge, Bge, Kge, Gge, Wge, Vge, qge, Zge, Yge, Jge, Xge, Qge, ehe, the, nhe, rhe, ohe, she, ihe, ahe, lhe, che, uhe, dhe, phe, fhe, mhe, ghe, hhe, _he, yhe, She, Ehe, bhe, Che, vhe, Ahe, Rhe, xhe, The, whe, Ohe, khe, Phe, Ihe, Dhe, Lhe, Mhe, Nhe, FS, rI, oI, Uhe, Fhe, zhe, $he, Hhe, jhe, Bhe, Khe, Ghe, Whe, Vhe, qhe, Zhe, Yhe, Jhe, Xhe, Qhe, e_e, t_e, n_e, r_e, o_e, s_e, i_e, a_e, l_e, c_e, u_e, d_e, p_e, f_e, m_e, g_e, h_e, __e, y_e, S_e, E_e, b_e, C_e, v_e, A_e, R_e, x_e, T_e, w_e, O_e, k_e, P_e, I_e, D_e, L_e, M_e, N_e, U_e, F_e, z_e, $_e, H_e, j_e, B_e, K_e, G_e, W_e, V_e, q_e, Z_e, Y_e, J_e, Q_e, Xn, eye, F8e, tye, z8e, nye, iI, rye, oye, lI, cye, uye, dye, _ye, on, vye, Aye, dI, C7e, v7e, ho, kI, PI, Dye, Sf, Lye, jc, Mye, Nye, LI, NI, Fye, VS, zye, $ye, x7e, zI, YS, KI, GI, VI, Hye, qS, ls, Kye, Gye, oD, nE, sD, So, Yc, vn, Zye, oE, sE, iD, aD, wf, Jc, Xc, kf, Qc, Pf, eu, fi, tu, mi, lD, cD, uD, dD, pD, fD, mD, gD, hD, _D, yD, SD, ED, bD, vD, AD, cE, RD, Xye, TD, wD, OD, kD, PD, uE, ID, DD, LD, MD, FD, If, nu, zD, $D, HD, jD, BD, zt, dE, Df, pE, fE, KD, GD, WD, VD, qD, ru, ZD, YD, JD, XD, QD, eL, tL, mE, yr, He, rL, ou, Je, yE, SE, EE, fL, mL, tSe, bE, CE, vE, AE, RE, xE, TE, wE, gL, hL, _L, yL, OE, sSe, kE, PE, IE, DE, LE, ME, NE, Nf, UE, FE, zE, $E, HE, jE, BE, cSe, gE, KE, vL, Uf, GE, WE, VE, qE, ZE, YE, Ff, JE, XE, QE, eb, tb, nb, zf, AL, rb, ob, sb, TL, ab, RL, xL, $f, Hf, dSe, fSe, OL, kL, Sr, FL, ML, zL, lu, hSe, iC, aC, lC, HL, jL, cC, uC, BL, dC, KL, pC, GL, fC, mC, WL, VL, qL, ZL, gC, YL, hC, JL, XL, _C, yC, SC, EC, QL, sC, bC, CC, vC, AC, RC, xC, TC, wC, OC, tM, qf, kC, $L, rM, ASe, Fn, oM, sM, iM, aM, lM, cM, uM, dM, pM, fM, mM, gM, Be, SM, LC, ct, MC, EM, bM, CM, pEe, fEe, Yf, mEe, gEe, hEe, _Ee, yEe, SEe, EEe, bEe, CEe, vEe, AEe, REe, xEe, TEe, wEe, OEe, NC, kEe, vM, PEe, IEe, DEe, LEe, MEe, fu, AM, NEe, UEe, IC, DC, FEe, zEe, qa, TM, HEe, jEe, KEe, wM, em, mu, qEe, ZEe, JEe, OM, Qn, kM, LM, nbe, rbe, abe, lbe, cbe, rm, pbe, At, hbe, BC, BM, Zet, WM, VM, qM, ZM, Cbe, vbe, YM, Abe, Rbe, JM, xbe, Tbe, QM, Ibe, eN, Lbe, nN, Mbe, Nbe, sm, rN, iN, Fbe, aN, $be, jbe, Kbe, Gbe, yu, lN, uN, dN, Xbe, KM, Qbe, eCe, tCe, oCe, iCe, _N, yN, wN, Ytt, ON, OCe, DCe, LN, $Ce, HCe, Cu, BCe, MN, VCe, QCe, ive, uve, VN, pve, fve, _rt, gve, Sve, nv, tv, GN, tU, Fve, Hve, iU, tAe, sAe, iAe, aAe, cAe, Ie, bU, Q, vo, F, zn, fAe, ms, mAe, _m, nn, he, Xa, an, lv, cv, Si, wu, se, br, CU, Oe, gAe, hAe, _Ae, yAe, SAe, EAe, bAe, CAe, vAe, uv, AAe, RAe, xAe, TAe, wAe, OAe, vU, kAe, Ro, el, tl, ym, ku, Sm, Pu, Iu, Em, Ei, xo, bm, Fr, ft, Du, Ao, pv, Lu, To, Cm, vm, nl, Ou, Mu, Nu, bi, Uu, rl, $r, zr, gs, Fu, zu, Am, fv, Rm, $u, wot, H, Oot, kot, Pot, Iot, Dot, Lot, Mot, Not, Uot, Fot, zot, $ot, Hot, jot, xU, Bot, Kot, Got, Wot, Vot, qot, Zot, Yot, Jot, Xot, Qot, est, tst, nst, rst, ost, sst, ist, ast, FAe, zAe, gv, OU, Ss, km, Mt, kU, PU, kst, HAe, jAe, hv, $n, Hu, IU, Yt, tr, nr, Jt, Pm, DU, _v, LU, MU, yv, ju, le, Sv, NU, Pst, Ist, Im, BAe, Dm, KAe, Bu, ol, UU, GAe, WAe, VAe, qAe, ZAe, YAe, Ev, JAe, XAe, bv, Lm, QAe, eRe, Mm, tRe, Ku, Gu, nRe, Wu, sl, rRe, Vu, Nm, Um, Fm, Dst, zm, $m, Hm, FU, zU, $U, Cv, HU, qu, il, jU, oRe, jm, sRe, Bm, iRe, vv, aRe, Km, lRe, cRe, uRe, dRe, pRe, fRe, mRe, gRe, hRe, _Re, Gm, yRe, SRe, Wm, Av, Rv, xv, ERe, bRe, CRe, Tv, vRe, ARe, RRe, xRe, TRe, BU, Vm, wRe, qm, Lst, ORe, al, kRe, Mst, Zu, PRe, wv, IRe, DRe, LRe, MRe, NRe, URe, FRe, Om, zRe, $Re, HRe, Yu, Ov, jRe, BRe, KRe, GRe, WRe, VRe, qRe, ZRe, YRe, JRe, XRe, QRe, exe, txe, nxe, rxe, oxe, sxe, ll, ixe, axe, lxe, Zm, cxe, uxe, dxe, kv, pxe, Nst, Ust, Fst, zst, $st, Hst, ae, WU, qU, VU, ZU, YU, Ym, e0, fxe, mxe, Dv, Cr, gxe, Ju, d0, h0, _0, v0, A0, Sxe, Exe, Mv, Cxe, Fv, Oj, kj, PA, IA, DA, Lj, Dj, aLe, NA, FA, uLe, dd, fLe, Po, SLe, ELe, zA, bLe, xLe, TLe, wLe, OLe, kLe, $j, qj, ILe, DLe, LLe, MLe, Ce, NLe, Wg, Oi, VA, Do, Jj, Xj, Qj, eB, tB, nB, qA, ZA, jA, Bj, jLe, BLe, GLe, rB, BA, Gg, GA, WA, VLe, qLe, Kj, Hs, sB, QLe, YA, iB, uB, eMe, dB, pB, fB, mB, tMe, XA, aB, QA, gB, hB, _B, yB, jn, lMe, SB, dMe, bB, mMe, fd, RB, hMe, Rr, TB, SMe, EMe, Pl, wB, Vg, AMe, Il, RMe, xMe, qg, OB, wMe, OMe, kB, eo, Dl, Zg, DB, NMe, FB, WMe, VMe, $B, HB, jB, BB, Ml, GB, nR, WB, Jg, KB, eNe, Bs, VB, gd, Nl, Xg, tNe, YB, qB, Pi, rK, iK, pNe, hd, _d, to, yd, nh, uK, aK, _Ne, lK, cK, Sd, Ul, rh, oh, dK, CNe, pK, sh, fK, RNe, xNe, TNe, mK, wNe, ONe, ih, Ed, lr, gK, hK, yK, SK, EK, ah, bK, FNe, CK, zNe, $Ne, HNe, vK, BNe, lh, AK, RK, xK, VNe, dn, TK, wK, OK, kK, PK, QNe, eUe, IK, DK, rUe, LK, MK, NK, UK, iUe, aUe, lUe, cUe, uUe, dUe, pUe, fUe, mUe, gUe, hUe, _Ue, yUe, SUe, EUe, bUe, CUe, vUe, AUe, FK, xUe, zK, $K, wUe, HK, OUe, jK, BK, PUe, KK, IUe, DUe, LUe, GK, MUe, NUe, UUe, FUe, WK, zUe, $Ue, HUe, VK, jUe, BUe, KUe, GUe, WUe, VUe, qUe, ZUe, YUe, JUe, XUe, QUe, e0e, t0e, n0e, r0e, Xe, qK, ZK, YK, JK, a0e, l0e, uh, XK, QK, e1, n1, r1, dh, m0e, g0e, h0e, _0e, bd, o1, S0e, Fl, s1, b0e, i1, Di, a1, l1, c1, u1, d1, p1, f1, P0e, I0e, m1, D0e, g1, h1, _1, vyt, U0e, y1, Ayt, iR, F0e, z0e, $0e, Gs, zl, fh, E1, b1, H0e, j0e, B0e, K0e, mh, $l, gh, Ws, aR, hh, _h, G0e, W0e, lR, R1, x1, V0e, uR, k1, P1, I1, D1, L1, Y0e, dR, J0e, Fyt, pR, X0e, fR, mR, Q0e, zyt, eFe, gR, hR, _R, $yt, M1, yR, N1, U1, tFe, nFe, rFe, oFe, iFe, Mi, cFe, $1, Wyt, Vyt, H1, j1, B1, K1, uFe, G1, W1, V1, q1, dFe, pFe, SR, fFe, eSt, tSt, mFe, jl, Vs, gFe, Y1, hFe, _Fe, X1, Q1, eG, yFe, SFe, tG, EFe, bFe, CFe, vFe, bR, CR, RFe, xFe, vR, TFe, Eh, nSt, Cd, wFe, OFe, aSt, rG, PFe, IFe, _St, oG, sG, bSt, CSt, HFe, jFe, $St, BFe, KFe, HSt, JSt, XSt, lG, OR, VFe, YFe, uG, eze, nze, gG, vd, vh, kR, zi, sze, yG, ize, yEt, Ad, $i, bG, Kn, AEt, REt, xEt, aze, AG, wG, $R, dze, $G, pze, fze, mze, gze, hze, BR, HG, jG, fbt, yze, Sze, Eze, Gn, ji, kG, PG, NR, UR, KR, GG, Cze, vze, Rze, GR, xze, Tze, xh, WR, Oze, kze, mbt, Pze, Ize, Dze, Lze, Mze, Nze, qG, Uze, Fze, zze, $ze, ZG, Hze, IG, jze, Bze, YG, Kze, Gze, DG, Wze, Vze, JG, qze, Zze, Yze, Jze, QG, Xze, Qze, e$e, t$e, r$e, o$e, s$e, i$e, a$e, eW, nW, c$e, m$e, xd, VR, gbt, hbt, _bt, h$e, qR, Th, MR, aW, _$e, S$e, lW, E$e, b$e, C$e, v$e, A$e, x$e, w$e, O$e, k$e, P$e, I$e, N$e, ybt, FR, Sbt, U$e, MG, Td, Ebt, bbt, uW, z$e, $$e, H$e, Cbt, j$e, B$e, vbt, Abt, K$e, Rbt, Oh, kh, G$e, YR, Ph, W$e, Ih, Mbt, Nbt, Ubt, Dh, V$e, Z$e, tx, EW, Id, Fh, X$e, xCt, Q$e, eHe, ix, ax, lx, cx, zh, $h, MW, tHe, nHe, aHe, uHe, dHe, Zs, pHe, CW, vW, AW, Nh, UW, fHe, mHe, gHe, hHe, _He, yHe, SHe, EHe, pn, dx, nx, Mh, Bi, AHe, TCt, xHe, Pd, RW, THe, xW, wHe, OHe, Hh, kHe, TW, fx, Bh, Ki, KW, Gl, PHe, Kh, kW, Wl, NHe, Ld, UHe, tV, rV, jHe, XHe, cvt, tje, fV, mV, sje, aje, _V, yV, pje, zvt, $vt, gje, yje, Sje, Kvt, Gvt, eAt, RV, Eje, bje, mAt, Cje, gAt, xV, wV, OV, Js, Lje, FV, Yh, Jh, Md, Tx, zV, $V, HV, Xh, jV, cr, KV, Mo, Fje, zje, yRt, jje, Gje, Vje, sBe, YV, e22, o_, gBe, t2, s_, kx, o2, LBe, UBe, $x, Vi, R2, KBe, GBe, Dx, ZBe, k2, n_, l2, sKe, lKe, z2, bKe, RKe, ec, W2, H2, xKe, wKe, PKe, IKe, $Ke, X2, HKe, jKe, BKe, KKe, VKe, eTt, qKe, tTt, nTt, ZKe, rTt, YKe, oTt, JKe, Wx, XKe, iTt, eq, tq, QKe, nq, rq, e1e, t1e, oq, sq, n1e, r1e, aTt, lTt, c1e, Zx, cq, u1e, uq, a_, d1e, Xx, nc, S1e, c_, mq, gq, Qx, hq, _q, E1e, Sq, u_, rc, d_, b1e, bq, Uo, Cq, vq, A1e, Yd, Jd, R1e, x1e, Aq, gn, T1e, w1e, O1e, Xs, k1e, P1e, xq, Pwt, I1e, Oq, kq, Pq, D1e, L1e, Iq, M1e, N1e, nT, U1e, p_, rT, Dq, oT, iT, F1e, Uq, aT, jq, K1e, Gq, yOt, sGe, cGe, uGe, yGe;
|
|
82731
|
+
var import_node_module, import_crypto, import_crypto2, import_path, import_node_fs17, import_node_process4, import_fs, import_os, import_path2, yy, import_fs2, import_promises, import_path3, import_readline, import_promises2, import_path4, import_os2, import_path5, Se, import_promises3, xe, import_promises4, import_fs3, import_promises5, import_os3, import_path6, import_promises6, import_os4, import_node_path47, import_node_os10, import_node_process5, import_path7, import_events, import_fs4, import_promises7, import_path8, import_child_process, import_util9, import_child_process2, import_fs5, import_path9, import_path10, import_crypto3, import_fs6, import_path11, import_promises8, import_path12, import_path13, import_promises9, import_path14, import_path15, import_fs7, import_promises10, import_path16, import_crypto4, import_path17, import_async_hooks, import_fs8, import_promises11, import_crypto5, import_fs9, import_promises12, import_path18, import_promises13, import_path19, import_crypto6, import_path20, import_path21, import_path22, import_path23, import_promises14, import_fs10, import_promises15, import_path24, import_util10, import_path25, import_os5, import_path26, import_path27, import_path28, import_path29, import_path30, import_net, import_os6, import_child_process3, import_fs11, import_child_process4, import_crypto7, import_promises16, import_module, import_os7, import_path31, import_url, import_events2, import_child_process5, import_fs12, import_readline2, import_string_decoder, import_fs13, import_promises17, import_os8, import_path32, import_crypto8, import_os9, import_fs14, import_path33, import_crypto9, import_fs15, import_promises18, import_path34, IZ, DZ, v_, LZ, OT, NZ, UZ, kT, X, FZ, dr, HZ, jZ, BZ, ot, st, ed, Kv, Te, Me, Oo, nd, hF, Xv, Qv, rd, LF, or, WF, ZF, sA, XF, od, sd, hg, id, Sg, Oz, fA, $z, Wz, Zz, s$, a$, d$, f$, g$, _$, E$, v$, T$, O$, I$, L$, wg, z$, j$, G$, V$, yA, SA, rH, lH, uH, _H, EH, EA, RH, TH, kH, DH, NH, zH, jH, GH, VH, ZH, JH, ej, nj, ij, cj, uj, CA, bj, Aj, wj, PT, KZ, GZ, VGe, VZ, MT, wr, jo, JZ, XZ, NT, UT, FT, zT, Bo, $T, HT, jT, BT, a4, sp, l4, c4, vt, u4, Nt, KT, d4, p4, uc, GT, m4, g4, WT, _4, y4, VT, Dn, Et, b4, C4, v4, A4, ra, x4, ip, qT, ZT, w4, O4, ro, P4, I4, D4, L4, M4, N4, U4, YT, JT, Sn, H4, Ko, j4, oo, XT, QT, G4, W4, V4, ew, Z4, Y4, tw, X4, nw, R_, rw, ow, Go, sw, iw, aw, lw, ei, aY, cw, Or, cY, uw, dw, lp, pw, cp, mY, gY, up, _Y, aa, fw, la, EY, bY, CY, vY, AY, RY, xY, TY, wY, OY, kY, PY, IY, mw, x_, gw, ca, MY, et, dp, hw, pp, zY, $Y, _w, HY, ua, yw, wt, KY, T_, Sw, WY, VY, qY, so, mp, Ew, vw, bw, YY, Cw, JY, XY, kr, QY, e9, Wo, n9, da, o9, s9, i9, a9, l9, c9, u9, d9, p9, f9, m9, g9, h9, _9, y9, S9, E9, b9, C9, v9, A9, R9, x9, T9, Qe, Aw, pa, hp, Rw, dc, k9, w_, P9, Pr, xw, I9, fa, D9, L9, _p, N9, ma, yp, z9, Tw, $9, H9, ww, Vo, Ir, pc, W9, V9, q9, Ow, Y9, Sp, J9, Ep, X9, qo, Q9, bp, kw, eJ, Pw, Iw, Dw, Lw, tJ, nJ, rJ, oJ, sJ, ti, io, iJ, Mw, Nw, Cp, aJ, Uw, Fw, ga, pr, uJ, Fe, $w, O_, k_, I_, ha, Bw, D_, qw, Vw, N_, U_, yJ, _a3, Yo, Zw, bJ, Rp, Yw, vJ, AJ, Jw, xp, Xw, Tp, Qw, kJ, ya, IJ, DJ, Sa, MJ, fc, NJ, eO, FJ, zJ, $J, tO, Ea, jJ, nO, rO, sO, iO, Vn, GJ, Ln, Jo, aO, lO, cO, wp, XJ, QJ, uO, ba, dO, pO, fO, Dr, ao, mO, Ca, gO, z_, $_, H_, j_, B_, K_, G_, W_, V_, q_, Z_, _O, Y_, J_, yO, X_, c3, Q_, ey, ty, ny, ry, oy, sy, iy, ay, ly, cy, we, SO, en, d3, Pp, vO, g3, gy, wO, S3, BO, KO, Ip, Dp, v3, GO, WO, F9e, IO, A3, hy, x3, NO, I3, Ay, Ry, D3, xy, L3, bc, xa, Ty, wy, Oy, ky, XO, Py, Iy, Dy, Ly, My, Ny, Uy, Fy, zy, nk, rk, d3e, p3e, f3e, m3e, g3e, U3, jp, jy, ik, By, Ky, lk, $3, uk, ck, G3, W3, V3, it, Y3, J3, hk, tXe, Q3, kt, We, gX, Ta, SX, mr, Yp, Jp, eS, nS, yXe, IX, DX, rS, ka, oS, Ok, kk, HX, jX, ef, bXe, Uk, Mr, wc, Fk, Pa, OXe, kXe, iS, PXe, IXe, DXe, GX, YX, JX, XX, QX, e6, t6, Yk, n6, r6, o6, s6, i6, a6, l6, c6, Vk, uS, lf, dS, Qk, eP, uf, os10, qXe, ZXe, h6, tP, df, _6, y6, S6, E6, b6, Jn, gr, nP, rP, Dc, pS, oP, gS, lP, C6, mS, lS, sP, w6, O6, dP, k6, YXe, JXe, P6, I6, pf, L6, fP, XXe, QXe, M6, SS, z6, $6, j6, bP, CP, G6, Lc, si, Z6, ES, bS, X6, Q6, e5, t5, n5, u5, r5, o5, s5, i5, a5, l5, c5, u52, d5, p5, f5, m5, g5, h5, _5, y5, S5, E5, b5, C5, v5, A5, R5, x5, T5, w5, O5, k5, P5, I5, D5, L5, M5, N5, U5, F5, z5, $5, H5, j5, B5, K5, G5, W5, V5, q5, Z5, Y5, J5, X5, Q5, e8, t8, n8, r8, o8, s8, i8, a8, l8, c8, u8, d8, CS, p8, f8, m8, g8, h8, _8, y8, S8, E8, b8, C8, v8, A8, R8, x8, T8, w8, O8, k8, P8, I8, D8, L8, M8, N8, U8, F8, z8, $8, H8, j8, B8, K8, G8, W8, V8, q8, Z8, Y8, J8, X8, Q8, e7, t7, n7, r7, o7, s7, i7, a7, l7, c7, u7, d7, p7, f7, m7, g7, h7, _7, y7, S7, E7, b7, C7, TP, v7, L6e, RP, A7, x7, kP, ff, U6e, F6e, Ua, z6e, $6e, H6e, j6e, PP, IP, vS, DP, w7, LP, O7, k7, P7, AS, RS, xS, I7, MP, NP, D7, G6e, L7, W6e, M7, N7, UP, V6e, U7, F7, z7, $7, H7, j7, B7, q6e, is, wS, Fa, K7, G7, W7, i5e, X7, Q7, HP, $P, BP, tQ, WP, VP, JP, _Q, QP, eI, xQ, Uc, DS, $a, wQ, OQ, kQ, PQ, IQ, DQ, LQ, MQ, NQ, UQ, FQ, zQ, $Q, HQ, jQ, BQ, KQ, GQ, WQ, VQ, qQ, ZQ, YQ, JQ, XQ, QQ, eee, tee, nee, ree, oee, see, iee, aee, lee, cee, uee, dee, pee, fee, mee, gee, hee, _ee, yee, See, Eee, bee, Cee, vee, Aee, Ree, xee, Tee, wee, Oee, kee, Pee, Iee, Dee, Lee, Mee, Nee, Uee, Fee, zee, $ee, Hee, jee, Bee, Kee, Gee, Wee, Vee, qee, Zee, Yee, Jee, Xee, Qee, ete, tte, nte, rte, ote, ste, ite, ate, lte, cte, ute, dte, pte, fte, mte, gte, hte, _te, yte, Ste, Ete, bte, Cte, vte, Ate, Rte, xte, Tte, wte, Ote, kte, Pte, Ite, Dte, Lte, Mte, Nte, Ute, Fte, zte, $te, Hte, jte, Bte, Kte, Gte, Wte, Vte, qte, Zte, Yte, Jte, Xte, Qte, ene, tne, nne, rne, one, sne, ine, ane, lne, cne, une, dne, pne, fne, mne, gne, hne, _ne, yne, Sne, Ene, bne, Cne, vne, Ane, Rne, xne, Tne, wne, One, kne, Pne, Ine, Dne, Lne, Mne, Nne, Une, Fne, zne, $ne, Hne, jne, Bne, Kne, Gne, Wne, Vne, qne, Zne, Yne, Jne, Xne, Qne, ere, tre, nre, rre, ore, sre, ire, are, lre, cre, ure, dre, pre, fre, mre, gre, hre, _re, yre, Sre, Ere, bre, Cre, vre, Are, Rre, xre, Tre, wre, Ore, kre, Pre, Ire, Dre, Lre, Mre, Nre, Ure, Fre, zre, $re, Hre, jre, Bre, Kre, Gre, Wre, Vre, qre, Zre, Yre, Jre, Xre, Qre, eoe, toe, noe, roe, ooe, soe, ioe, aoe, loe, coe, uoe, doe, poe, foe, moe, goe, hoe, _oe, yoe, Soe, Eoe, boe, Coe, voe, Aoe, Roe, xoe, Toe, woe, Ooe, koe, Poe, Ioe, Doe, Loe, Moe, Noe, Uoe, Foe, zoe, $oe, Hoe, joe, Boe, Koe, Goe, Woe, Voe, qoe, Zoe, Yoe, Joe, Xoe, Qoe, ese, tse, nse, rse, ose, sse, ise, ase, lse, cse, use, dse, pse, fse, mse, gse, hse, _se, yse, Sse, Ese, LS, bse, Cse, vse, Ase, Rse, xse, Tse, wse, Ose, kse, Pse, Ise, Dse, Lse, Mse, Nse, Use, Fse, zse, $se, Hse, jse, Bse, Kse, Gse, Wse, Vse, qse, Zse, Yse, Jse, Xse, Qse, eie, tie, nie, rie, oie, sie, iie, aie, lie, cie, uie, die, pie, fie, mie, gie, hie, _ie, yie, Sie, Eie, bie, Cie, vie, Aie, Rie, xie, Tie, wie, Oie, kie, Pie, Iie, Die, Lie, Mie, Nie, Uie, Fie, zie, $ie, Hie, jie, Bie, Kie, Gie, Wie, Vie, qie, Zie, Yie, Jie, Xie, Qie, eae, tae, nae, rae, oae, sae, iae, aae, lae, cae, uae, dae, pae, fae, mae, gae, hae, _ae, yae, Sae, Eae, bae, Cae, vae, Aae, Rae, xae, Tae, wae, Oae, kae, Pae, Iae, Dae, Lae, Mae, Nae, Uae, Fae, zae, $ae, Hae, jae, Bae, Kae, Gae, Wae, Vae, qae, Zae, Yae, Jae, Xae, Qae, ele, tle, nle, rle, ole, sle, ile, ale, lle, cle, ule, dle, ple, fle, mle, gle, hle, _le, yle, Sle, Ele, ble, Cle, vle, Ale, Rle, xle, Tle, wle, Ole, kle, Ple, Ile, Dle, Lle, Mle, Nle, Ule, Fle, zle, $le, Hle, jle, Ble, Kle, Gle, Wle, Vle, qle, Zle, Yle, Jle, MS, Xle, Qle, ece, tce, nce, rce, oce, sce, ice, ace, lce, cce, uce, dce, pce, fce, mce, gce, hce, _ce, yce, Sce, Ece, bce, Cce, vce, Ace, Rce, xce, Tce, wce, Oce, kce, Pce, Ice, Dce, Lce, Mce, Nce, Uce, Fce, zce, $ce, Hce, jce, Bce, Kce, Gce, Wce, Vce, qce, Zce, Yce, Jce, Xce, Qce, eue, tue, nue, rue, oue, sue, iue, aue, lue, cue, uue, due, pue, fue, mue, gue, hue, _ue, yue, Sue, Eue, bue, Cue, vue, Aue, Rue, xue, Tue, wue, Oue, kue, Pue, Iue, Due, Lue, Mue, Nue, Uue, Fue, zue, $ue, Hue, jue, Bue, Kue, Gue, Wue, Vue, que, Zue, Yue, Jue, Xue, Que, ede, tde, nde, rde, ode, sde, ide, ade, lde, cde, ude, dde, pde, fde, mde, gde, hde, _de, yde, Sde, Ede, bde, Cde, vde, Ade, Rde, xde, Tde, wde, Ode, kde, Pde, Ide, Dde, Lde, Mde, Nde, Ude, Fde, zde, $de, Hde, jde, Bde, Kde, Gde, Wde, Vde, qde, Zde, Yde, Jde, Xde, Qde, epe, tpe, npe, rpe, ope, spe, ipe, ape, lpe, cpe, upe, dpe, ppe, fpe, mpe, gpe, hpe, _pe, ype, Spe, Epe, bpe, Cpe, vpe, Ape, Rpe, xpe, Tpe, wpe, Ope, kpe, Ppe, Ipe, Dpe, Lpe, Mpe, Npe, Upe, Fpe, zpe, $pe, Hpe, jpe, Bpe, Kpe, Gpe, Wpe, Vpe, qpe, Zpe, Ype, Jpe, Xpe, Qpe, efe, tfe, nfe, rfe, ofe, sfe, ife, afe, lfe, cfe, ufe, dfe, pfe, ffe, mfe, gfe, hfe, _fe, yfe, Sfe, Efe, bfe, Cfe, vfe, Afe, Rfe, xfe, Tfe, wfe, Ofe, kfe, Pfe, Ife, Dfe, Lfe, Mfe, Nfe, Ufe, Ffe, zfe, $fe, Hfe, jfe, Bfe, Kfe, Gfe, Wfe, Vfe, qfe, Zfe, Yfe, Jfe, Xfe, Qfe, eme, tme, nme, rme, ome, sme, ime, ame, lme, cme, ume, dme, pme, fme, mme, gme, hme, _me, yme, Sme, Eme, bme, Cme, vme, Ame, Rme, xme, Tme, wme, Ome, kme, Pme, Ime, Dme, Lme, Mme, Nme, Ume, Fme, zme, $me, Hme, jme, Bme, Kme, Gme, Wme, Vme, qme, Zme, Yme, Jme, NS, Xme, Qme, ege, tge, nge, rge, oge, sge, ige, age, lge, cge, uge, dge, pge, fge, mge, gge, hge, _ge, yge, Sge, Ege, bge, Cge, vge, Age, Rge, xge, Tge, wge, Oge, kge, Pge, Ige, Dge, Lge, Mge, Nge, Uge, Fge, zge, $ge, Hge, US, jge, Bge, Kge, Gge, Wge, Vge, qge, Zge, Yge, Jge, Xge, Qge, ehe, the, nhe, rhe, ohe, she, ihe, ahe, lhe, che, uhe, dhe, phe, fhe, mhe, ghe, hhe, _he, yhe, She, Ehe, bhe, Che, vhe, Ahe, Rhe, xhe, The, whe, Ohe, khe, Phe, Ihe, Dhe, Lhe, Mhe, Nhe, FS, rI, oI, Uhe, Fhe, zhe, $he, Hhe, jhe, Bhe, Khe, Ghe, Whe, Vhe, qhe, Zhe, Yhe, Jhe, Xhe, Qhe, e_e, t_e, n_e, r_e, o_e, s_e, i_e, a_e, l_e, c_e, u_e, d_e, p_e, f_e, m_e, g_e, h_e, __e, y_e, S_e, E_e, b_e, C_e, v_e, A_e, R_e, x_e, T_e, w_e, O_e, k_e, P_e, I_e, D_e, L_e, M_e, N_e, U_e, F_e, z_e, $_e, H_e, j_e, B_e, K_e, G_e, W_e, V_e, q_e, Z_e, Y_e, J_e, Q_e, Xn, eye, F8e, tye, z8e, nye, iI, rye, oye, lI, cye, uye, dye, _ye, on, vye, Aye, dI, C7e, v7e, ho, kI, PI, Dye, Sf, Lye, jc, Mye, Nye, LI, NI, Fye, VS, zye, $ye, x7e, zI, YS, KI, GI, VI, Hye, qS, ls, Kye, Gye, oD, nE, sD, So, Yc, vn, Zye, oE, sE, iD, aD, wf, Jc, Xc, kf, Qc, Pf, eu, fi, tu, mi, lD, cD, uD, dD, pD, fD, mD, gD, hD, _D, yD, SD, ED, bD, vD, AD, cE, RD, Xye, TD, wD, OD, kD, PD, uE, ID, DD, LD, MD, FD, If, nu, zD, $D, HD, jD, BD, zt, dE, Df, pE, fE, KD, GD, WD, VD, qD, ru, ZD, YD, JD, XD, QD, eL, tL, mE, yr, He, rL, ou, Je, yE, SE, EE, fL, mL, tSe, bE, CE, vE, AE, RE, xE, TE, wE, gL, hL, _L, yL, OE, sSe, kE, PE, IE, DE, LE, ME, NE, Nf, UE, FE, zE, $E, HE, jE, BE, cSe, gE, KE, vL, Uf, GE, WE, VE, qE, ZE, YE, Ff, JE, XE, QE, eb, tb, nb, zf, AL, rb, ob, sb, TL, ab, RL, xL, $f, Hf, dSe, fSe, OL, kL, Sr, FL, ML, zL, lu, hSe, iC, aC, lC, HL, jL, cC, uC, BL, dC, KL, pC, GL, fC, mC, WL, VL, qL, ZL, gC, YL, hC, JL, XL, _C, yC, SC, EC, QL, sC, bC, CC, vC, AC, RC, xC, TC, wC, OC, tM, qf, kC, $L, rM, ASe, Fn, oM, sM, iM, aM, lM, cM, uM, dM, pM, fM, mM, gM, Be, SM, LC, ct, MC, EM, bM, CM, pEe, fEe, Yf, mEe, gEe, hEe, _Ee, yEe, SEe, EEe, bEe, CEe, vEe, AEe, REe, xEe, TEe, wEe, OEe, NC, kEe, vM, PEe, IEe, DEe, LEe, MEe, fu, AM, NEe, UEe, IC, DC, FEe, zEe, qa, TM, HEe, jEe, KEe, wM, em, mu, qEe, ZEe, JEe, OM, Qn, kM, LM, nbe, rbe, abe, lbe, cbe, rm, pbe, At, hbe, BC, BM, Zet, WM, VM, qM, ZM, Cbe, vbe, YM, Abe, Rbe, JM, xbe, Tbe, QM, Ibe, eN, Lbe, nN, Mbe, Nbe, sm, rN, iN, Fbe, aN, $be, jbe, Kbe, Gbe, yu, lN, uN, dN, Xbe, KM, Qbe, eCe, tCe, oCe, iCe, _N, yN, wN, Ytt, ON, OCe, DCe, LN, $Ce, HCe, Cu, BCe, MN, VCe, QCe, ive, uve, VN, pve, fve, _rt, gve, Sve, nv, tv, GN, tU, Fve, Hve, iU, tAe, sAe, iAe, aAe, cAe, Ie, bU, Q, vo, F, zn, fAe, ms, mAe, _m, nn, he, Xa, an, lv, cv, Si, wu, se, br, CU, Oe, gAe, hAe, _Ae, yAe, SAe, EAe, bAe, CAe, vAe, uv, AAe, RAe, xAe, TAe, wAe, OAe, vU, kAe, Ro, el, tl, ym, ku, Sm, Pu, Iu, Em, Ei, xo, bm, Fr, ft, Du, Ao, pv, Lu, To, Cm, vm, nl, Ou, Mu, Nu, bi, Uu, rl, $r, zr, gs, Fu, zu, Am, fv, Rm, $u, wot, H, Oot, kot, Pot, Iot, Dot, Lot, Mot, Not, Uot, Fot, zot, $ot, Hot, jot, xU, Bot, Kot, Got, Wot, Vot, qot, Zot, Yot, Jot, Xot, Qot, est, tst, nst, rst, ost, sst, ist, ast, FAe, zAe, gv, OU, Ss, km, Mt, kU, PU, kst, HAe, jAe, hv, $n, Hu, IU, Yt, tr, nr, Jt, Pm, DU, _v, LU, MU, yv, ju, le, Sv, NU, Pst, Ist, Im, BAe, Dm, KAe, Bu, ol, UU, GAe, WAe, VAe, qAe, ZAe, YAe, Ev, JAe, XAe, bv, Lm, QAe, eRe, Mm, tRe, Ku, Gu, nRe, Wu, sl, rRe, Vu, Nm, Um, Fm, Dst, zm, $m, Hm, FU, zU, $U, Cv, HU, qu, il, jU, oRe, jm, sRe, Bm, iRe, vv, aRe, Km, lRe, cRe, uRe, dRe, pRe, fRe, mRe, gRe, hRe, _Re, Gm, yRe, SRe, Wm, Av, Rv, xv, ERe, bRe, CRe, Tv, vRe, ARe, RRe, xRe, TRe, BU, Vm, wRe, qm, Lst, ORe, al, kRe, Mst, Zu, PRe, wv, IRe, DRe, LRe, MRe, NRe, URe, FRe, Om, zRe, $Re, HRe, Yu, Ov, jRe, BRe, KRe, GRe, WRe, VRe, qRe, ZRe, YRe, JRe, XRe, QRe, exe, txe, nxe, rxe, oxe, sxe, ll, ixe, axe, lxe, Zm, cxe, uxe, dxe, kv, pxe, Nst, Ust, Fst, zst, $st, Hst, ae, WU, qU, VU, ZU, YU, Ym, e0, fxe, mxe, Dv, Cr, gxe, Ju, d0, h0, _0, v0, A0, Sxe, Exe, Mv, Cxe, Fv, Oj, kj, PA, IA, DA, Lj, Dj, aLe, NA, FA, uLe, dd, fLe, Po, SLe, ELe, zA, bLe, xLe, TLe, wLe, OLe, kLe, $j, qj, ILe, DLe, LLe, MLe, Ce, NLe, Wg, Oi, VA, Do, Jj, Xj, Qj, eB, tB, nB, qA, ZA, jA, Bj, jLe, BLe, GLe, rB, BA, Gg, GA, WA, VLe, qLe, Kj, Hs, sB, QLe, YA, iB, uB, eMe, dB, pB, fB, mB, tMe, XA, aB, QA, gB, hB, _B, yB, jn, lMe, SB, dMe, bB, mMe, fd, RB, hMe, Rr, TB, SMe, EMe, Pl, wB, Vg, AMe, Il, RMe, xMe, qg, OB, wMe, OMe, kB, eo, Dl, Zg, DB, NMe, FB, WMe, VMe, $B, HB, jB, BB, Ml, GB, nR, WB, Jg, KB, eNe, Bs, VB, gd, Nl, Xg, tNe, YB, qB, Pi, rK, iK, pNe, hd, _d, to, yd, nh, uK, aK, _Ne, lK, cK, Sd, Ul, rh, oh, dK, CNe, pK, sh, fK, RNe, xNe, TNe, mK, wNe, ONe, ih, Ed, lr, gK, hK, yK, SK, EK, ah, bK, FNe, CK, zNe, $Ne, HNe, vK, BNe, lh, AK, RK, xK, VNe, dn, TK, wK, OK, kK, PK, QNe, eUe, IK, DK, rUe, LK, MK, NK, UK, iUe, aUe, lUe, cUe, uUe, dUe, pUe, fUe, mUe, gUe, hUe, _Ue, yUe, SUe, EUe, bUe, CUe, vUe, AUe, FK, xUe, zK, $K, wUe, HK, OUe, jK, BK, PUe, KK, IUe, DUe, LUe, GK, MUe, NUe, UUe, FUe, WK, zUe, $Ue, HUe, VK, jUe, BUe, KUe, GUe, WUe, VUe, qUe, ZUe, YUe, JUe, XUe, QUe, e0e, t0e, n0e, r0e, Xe, qK, ZK, YK, JK, a0e, l0e, uh, XK, QK, e1, n1, r1, dh, m0e, g0e, h0e, _0e, bd, o1, S0e, Fl, s1, b0e, i1, Di, a1, l1, c1, u1, d1, p1, f1, P0e, I0e, m1, D0e, g1, h1, _1, vyt, U0e, y1, Ayt, iR, F0e, z0e, $0e, Gs, zl, fh, E1, b1, H0e, j0e, B0e, K0e, mh, $l, gh, Ws, aR, hh, _h, G0e, W0e, lR, R1, x1, V0e, uR, k1, P1, I1, D1, L1, Y0e, dR, J0e, Fyt, pR, X0e, fR, mR, Q0e, zyt, eFe, gR, hR, _R, $yt, M1, yR, N1, U1, tFe, nFe, rFe, oFe, iFe, Mi, cFe, $1, Wyt, Vyt, H1, j1, B1, K1, uFe, G1, W1, V1, q1, dFe, pFe, SR, fFe, eSt, tSt, mFe, jl, Vs, gFe, Y1, hFe, _Fe, X1, Q1, eG, yFe, SFe, tG, EFe, bFe, CFe, vFe, bR, CR, RFe, xFe, vR, TFe, Eh, nSt, Cd, wFe, OFe, aSt, rG, PFe, IFe, _St, oG, sG, bSt, CSt, HFe, jFe, $St, BFe, KFe, HSt, JSt, XSt, lG, OR, VFe, YFe, uG, eze, nze, gG, vd, vh, kR, zi, sze, yG, ize, yEt, Ad, $i, bG, Kn, AEt, REt, xEt, aze, AG, wG, $R, dze, $G, pze, fze, mze, gze, hze, BR, HG, jG, fbt, yze, Sze, Eze, Gn, ji, kG, PG, NR, UR, KR, GG, Cze, vze, Rze, GR, xze, Tze, xh, WR, Oze, kze, mbt, Pze, Ize, Dze, Lze, Mze, Nze, qG, Uze, Fze, zze, $ze, ZG, Hze, IG, jze, Bze, YG, Kze, Gze, DG, Wze, Vze, JG, qze, Zze, Yze, Jze, QG, Xze, Qze, e$e, t$e, r$e, o$e, s$e, i$e, a$e, eW, nW, c$e, m$e, xd, VR, gbt, hbt, _bt, h$e, qR, Th, MR, aW, _$e, S$e, lW, E$e, b$e, C$e, v$e, A$e, x$e, w$e, O$e, k$e, P$e, I$e, N$e, ybt, FR, Sbt, U$e, MG, Td, Ebt, bbt, uW, z$e, $$e, H$e, Cbt, j$e, B$e, vbt, Abt, K$e, Rbt, Oh, kh, G$e, YR, Ph, W$e, Ih, Mbt, Nbt, Ubt, Dh, V$e, Z$e, tx, EW, Id, Fh, X$e, xCt, Q$e, eHe, ix, ax, lx, cx, zh, $h, MW, tHe, nHe, aHe, uHe, dHe, Zs, pHe, CW, vW, AW, Nh, UW, fHe, mHe, gHe, hHe, _He, yHe, SHe, EHe, pn, dx, nx, Mh, Bi, AHe, TCt, xHe, Pd, RW, THe, xW, wHe, OHe, Hh, kHe, TW, fx, Bh, Ki, KW, Gl, PHe, Kh, kW, Wl, NHe, Ld, UHe, tV, rV, jHe, XHe, cvt, tje, fV, mV, sje, aje, _V, yV, pje, zvt, $vt, gje, yje, Sje, Kvt, Gvt, eAt, RV, Eje, bje, mAt, Cje, gAt, xV, wV, OV, Js, Lje, FV, Yh, Jh, Md, Tx, zV, $V, HV, Xh, jV, cr, KV, Mo, Fje, zje, yRt, jje, Gje, Vje, sBe, YV, e22, o_, gBe, t2, s_, kx, o2, LBe, UBe, $x, Vi, R2, KBe, GBe, Dx, ZBe, k2, n_, l2, sKe, lKe, z2, bKe, RKe, ec, W2, H2, xKe, wKe, PKe, IKe, $Ke, X2, HKe, jKe, BKe, KKe, VKe, eTt, qKe, tTt, nTt, ZKe, rTt, YKe, oTt, JKe, Wx, XKe, iTt, eq, tq, QKe, nq, rq, e1e, t1e, oq, sq, n1e, r1e, aTt, lTt, c1e, Zx, cq, u1e, uq, a_, d1e, Xx, nc, S1e, c_, mq, gq, Qx, hq, _q, E1e, Sq, u_, rc, d_, b1e, bq, Uo, Cq, vq, A1e, Yd, Jd, R1e, x1e, Aq, gn, T1e, w1e, O1e, Xs, k1e, P1e, xq, Pwt, I1e, Oq, kq, Pq, D1e, L1e, Iq, M1e, N1e, nT, U1e, p_, rT, Dq, oT, iT, F1e, Uq, aT, jq, K1e, Gq, yOt, sGe, cGe, uGe, yGe;
|
|
82583
82732
|
var init_sdk = __esm({
|
|
82584
82733
|
"node_modules/.pnpm/@anthropic-ai+claude-agent-sdk@0.3.292_@anthropic-ai+sdk@0.131.0_zod@4.6.5__@modelconte_9caa915130557974815a7ac66b010e49/node_modules/@anthropic-ai/claude-agent-sdk/sdk.mjs"() {
|
|
82585
82734
|
import_node_module = require("node:module");
|
|
82586
82735
|
import_crypto = require("crypto");
|
|
82587
82736
|
import_crypto2 = require("crypto");
|
|
82588
82737
|
import_path = require("path");
|
|
82589
|
-
|
|
82738
|
+
import_node_fs17 = require("node:fs");
|
|
82590
82739
|
import_node_process4 = require("node:process");
|
|
82591
82740
|
import_fs = require("fs");
|
|
82592
82741
|
import_os = require("os");
|
|
@@ -109047,12 +109196,12 @@ var require_dist2 = __commonJS({
|
|
|
109047
109196
|
throw new Error(`Unknown format "${name}"`);
|
|
109048
109197
|
return f;
|
|
109049
109198
|
};
|
|
109050
|
-
function addFormats(ajv, list,
|
|
109199
|
+
function addFormats(ajv, list, fs29, exportName) {
|
|
109051
109200
|
var _a4;
|
|
109052
109201
|
var _b2;
|
|
109053
109202
|
(_a4 = (_b2 = ajv.opts.code).formats) !== null && _a4 !== void 0 ? _a4 : _b2.formats = (0, codegen_1._)`require("ajv-formats/dist/formats").${exportName}`;
|
|
109054
109203
|
for (const f of list)
|
|
109055
|
-
ajv.addFormat(f,
|
|
109204
|
+
ajv.addFormat(f, fs29[f]);
|
|
109056
109205
|
}
|
|
109057
109206
|
module2.exports = exports2 = formatsPlugin;
|
|
109058
109207
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
@@ -116647,7 +116796,7 @@ function registerCodexCommand(program2, deps) {
|
|
|
116647
116796
|
// src/frontdoor/commands.ts
|
|
116648
116797
|
var import_node_crypto25 = require("node:crypto");
|
|
116649
116798
|
var import_node_path54 = __toESM(require("node:path"), 1);
|
|
116650
|
-
var
|
|
116799
|
+
var import_node_fs21 = __toESM(require("node:fs"), 1);
|
|
116651
116800
|
init_commandDeps();
|
|
116652
116801
|
init_configProfilesStore();
|
|
116653
116802
|
init_schema();
|
|
@@ -116789,17 +116938,17 @@ function parseEntry2(project, entry) {
|
|
|
116789
116938
|
const base = match?.[1];
|
|
116790
116939
|
return base === void 0 ? { project, sessionId: entry, superseded: false, entry } : { project, sessionId: base, superseded: true, entry };
|
|
116791
116940
|
}
|
|
116792
|
-
function listSessions2(
|
|
116941
|
+
function listSessions2(fs29, configDir) {
|
|
116793
116942
|
const found = [];
|
|
116794
|
-
for (const project of
|
|
116943
|
+
for (const project of fs29.readdir(import_node_path35.default.join(configDir, PROJECTS_DIR))) {
|
|
116795
116944
|
const projectDir = import_node_path35.default.join(configDir, PROJECTS_DIR, project);
|
|
116796
116945
|
const entries = /* @__PURE__ */ new Set();
|
|
116797
|
-
for (const name of
|
|
116946
|
+
for (const name of fs29.readdir(projectDir)) {
|
|
116798
116947
|
if (name.endsWith(TRANSCRIPT_SUFFIX)) {
|
|
116799
116948
|
entries.add(name.slice(0, -TRANSCRIPT_SUFFIX.length));
|
|
116800
116949
|
continue;
|
|
116801
116950
|
}
|
|
116802
|
-
const children =
|
|
116951
|
+
const children = fs29.readdir(import_node_path35.default.join(projectDir, name));
|
|
116803
116952
|
if (children.includes(SUBAGENTS_DIR) || children.includes(WORKFLOWS_DIR)) {
|
|
116804
116953
|
entries.add(name);
|
|
116805
116954
|
}
|
|
@@ -116810,9 +116959,9 @@ function listSessions2(fs28, configDir) {
|
|
|
116810
116959
|
}
|
|
116811
116960
|
return found.sort((left, right) => left.project.localeCompare(right.project) || left.entry.localeCompare(right.entry));
|
|
116812
116961
|
}
|
|
116813
|
-
function locateAgents(
|
|
116962
|
+
function locateAgents(fs29, configDir, relativeDir, workflowRunId, report) {
|
|
116814
116963
|
const located = [];
|
|
116815
|
-
for (const name of listDirOrReport(
|
|
116964
|
+
for (const name of listDirOrReport(fs29, configDir, relativeDir, report)) {
|
|
116816
116965
|
if (!name.startsWith(AGENT_FILE_PREFIX) || !name.endsWith(META_SUFFIX)) {
|
|
116817
116966
|
continue;
|
|
116818
116967
|
}
|
|
@@ -116861,17 +117010,17 @@ function toNode(read, children) {
|
|
|
116861
117010
|
function describeFailure(error63) {
|
|
116862
117011
|
return error63 instanceof Error ? error63.message : String(error63);
|
|
116863
117012
|
}
|
|
116864
|
-
function readFileOrReport(
|
|
117013
|
+
function readFileOrReport(fs29, configDir, relative, report) {
|
|
116865
117014
|
try {
|
|
116866
|
-
return
|
|
117015
|
+
return fs29.readFileUtf8(import_node_path35.default.join(configDir, relative));
|
|
116867
117016
|
} catch (error63) {
|
|
116868
117017
|
report({ path: relative, reason: `could not be read: ${describeFailure(error63)}` });
|
|
116869
117018
|
return void 0;
|
|
116870
117019
|
}
|
|
116871
117020
|
}
|
|
116872
|
-
function listDirOrReport(
|
|
117021
|
+
function listDirOrReport(fs29, configDir, relative, report) {
|
|
116873
117022
|
try {
|
|
116874
|
-
return
|
|
117023
|
+
return fs29.readdir(import_node_path35.default.join(configDir, relative));
|
|
116875
117024
|
} catch (error63) {
|
|
116876
117025
|
report({ path: relative, reason: `could not be listed: ${describeFailure(error63)}` });
|
|
116877
117026
|
return [];
|
|
@@ -116894,22 +117043,22 @@ var WorkflowRunFileSchema = external_exports.object({
|
|
|
116894
117043
|
phases: external_exports.array(external_exports.object({ title: external_exports.string() })).default([]),
|
|
116895
117044
|
summary: external_exports.string().optional()
|
|
116896
117045
|
});
|
|
116897
|
-
function summariseSession(
|
|
117046
|
+
function summariseSession(fs29, configDir, ref) {
|
|
116898
117047
|
const sessionRelative = import_node_path35.default.join(PROJECTS_DIR, ref.project, ref.entry);
|
|
116899
117048
|
const subagentsRelative = import_node_path35.default.join(sessionRelative, SUBAGENTS_DIR);
|
|
116900
117049
|
const workflowsUnderSubagents = import_node_path35.default.join(subagentsRelative, WORKFLOWS_DIR);
|
|
116901
117050
|
const isMeta = (name) => name.startsWith(AGENT_FILE_PREFIX) && name.endsWith(META_SUFFIX);
|
|
116902
|
-
let agentCount =
|
|
116903
|
-
for (const runDir of
|
|
117051
|
+
let agentCount = fs29.readdir(import_node_path35.default.join(configDir, subagentsRelative)).filter(isMeta).length;
|
|
117052
|
+
for (const runDir of fs29.readdir(import_node_path35.default.join(configDir, workflowsUnderSubagents))) {
|
|
116904
117053
|
if (runDir.startsWith(WORKFLOW_RUN_PREFIX)) {
|
|
116905
|
-
agentCount +=
|
|
117054
|
+
agentCount += fs29.readdir(import_node_path35.default.join(configDir, workflowsUnderSubagents, runDir)).filter(isMeta).length;
|
|
116906
117055
|
}
|
|
116907
117056
|
}
|
|
116908
|
-
const workflowRunCount =
|
|
116909
|
-
const transcript =
|
|
117057
|
+
const workflowRunCount = fs29.readdir(import_node_path35.default.join(configDir, sessionRelative, WORKFLOWS_DIR)).filter((name) => name.startsWith(WORKFLOW_RUN_PREFIX) && name.endsWith(JSON_SUFFIX)).length;
|
|
117058
|
+
const transcript = fs29.lstat(import_node_path35.default.join(configDir, PROJECTS_DIR, ref.project, `${ref.entry}${TRANSCRIPT_SUFFIX}`));
|
|
116910
117059
|
return { ...ref, agentCount, workflowRunCount, ...transcript === void 0 ? {} : { updatedAt: new Date(transcript.mtimeMs).toISOString() } };
|
|
116911
117060
|
}
|
|
116912
|
-
function readSessionAgentTree(
|
|
117061
|
+
function readSessionAgentTree(fs29, configDir, ref, options = {}) {
|
|
116913
117062
|
const problems = [];
|
|
116914
117063
|
const report = (problem) => {
|
|
116915
117064
|
problems.push(problem);
|
|
@@ -116917,15 +117066,15 @@ function readSessionAgentTree(fs28, configDir, ref, options = {}) {
|
|
|
116917
117066
|
const sessionRelative = import_node_path35.default.join(PROJECTS_DIR, ref.project, ref.entry);
|
|
116918
117067
|
const subagentsRelative = import_node_path35.default.join(sessionRelative, SUBAGENTS_DIR);
|
|
116919
117068
|
const workflowsUnderSubagents = import_node_path35.default.join(subagentsRelative, WORKFLOWS_DIR);
|
|
116920
|
-
const located = locateAgents(
|
|
116921
|
-
for (const runDir of listDirOrReport(
|
|
117069
|
+
const located = locateAgents(fs29, configDir, subagentsRelative, void 0, report);
|
|
117070
|
+
for (const runDir of listDirOrReport(fs29, configDir, workflowsUnderSubagents, report)) {
|
|
116922
117071
|
if (runDir.startsWith(WORKFLOW_RUN_PREFIX)) {
|
|
116923
|
-
located.push(...locateAgents(
|
|
117072
|
+
located.push(...locateAgents(fs29, configDir, import_node_path35.default.join(workflowsUnderSubagents, runDir), runDir, report));
|
|
116924
117073
|
}
|
|
116925
117074
|
}
|
|
116926
117075
|
const agents = /* @__PURE__ */ new Map();
|
|
116927
117076
|
for (const candidate of located) {
|
|
116928
|
-
const text2 = readFileOrReport(
|
|
117077
|
+
const text2 = readFileOrReport(fs29, configDir, candidate.metaPath, report);
|
|
116929
117078
|
if (text2 === void 0) {
|
|
116930
117079
|
continue;
|
|
116931
117080
|
}
|
|
@@ -116937,7 +117086,7 @@ function readSessionAgentTree(fs28, configDir, ref, options = {}) {
|
|
|
116937
117086
|
agents.set(candidate.id, { located: candidate, meta: parsed.data });
|
|
116938
117087
|
}
|
|
116939
117088
|
const teamNames = [...new Set([...agents.values()].flatMap((agent) => agent.meta.teamName === void 0 ? [] : [agent.meta.teamName]))].sort();
|
|
116940
|
-
const parentOf4 = resolveParents(
|
|
117089
|
+
const parentOf4 = resolveParents(fs29, configDir, agents, report);
|
|
116941
117090
|
const childrenOf = /* @__PURE__ */ new Map();
|
|
116942
117091
|
const roots = [];
|
|
116943
117092
|
for (const id2 of agents.keys()) {
|
|
@@ -116960,12 +117109,12 @@ function readSessionAgentTree(fs28, configDir, ref, options = {}) {
|
|
|
116960
117109
|
sessionId: ref.sessionId,
|
|
116961
117110
|
superseded: ref.superseded,
|
|
116962
117111
|
agents: roots.sort().map(build),
|
|
116963
|
-
tasks: readTasks(
|
|
116964
|
-
workflowRuns: readWorkflowRuns(
|
|
117112
|
+
tasks: readTasks(fs29, configDir, ownTaskLists(ref.sessionId), [.../* @__PURE__ */ new Set([...teamNames, ...options.taskListIds ?? []])].filter((id2) => !ownTaskLists(ref.sessionId).includes(id2)), report),
|
|
117113
|
+
workflowRuns: readWorkflowRuns(fs29, configDir, import_node_path35.default.join(sessionRelative, WORKFLOWS_DIR), report),
|
|
116965
117114
|
problems
|
|
116966
117115
|
};
|
|
116967
117116
|
}
|
|
116968
|
-
function resolveParents(
|
|
117117
|
+
function resolveParents(fs29, configDir, agents, report) {
|
|
116969
117118
|
const parentOf4 = /* @__PURE__ */ new Map();
|
|
116970
117119
|
const transcriptCache = /* @__PURE__ */ new Map();
|
|
116971
117120
|
const transcriptOf = (agent) => {
|
|
@@ -116973,7 +117122,7 @@ function resolveParents(fs28, configDir, agents, report) {
|
|
|
116973
117122
|
if (cached2 !== void 0) {
|
|
116974
117123
|
return cached2;
|
|
116975
117124
|
}
|
|
116976
|
-
const text2 = readFileOrReport(
|
|
117125
|
+
const text2 = readFileOrReport(fs29, configDir, agent.located.transcriptPath, report) ?? "";
|
|
116977
117126
|
transcriptCache.set(agent.located.id, text2);
|
|
116978
117127
|
return text2;
|
|
116979
117128
|
};
|
|
@@ -117023,16 +117172,16 @@ function resolveParents(fs28, configDir, agents, report) {
|
|
|
117023
117172
|
function ownTaskLists(sessionId) {
|
|
117024
117173
|
return [sessionId, `${SHORT_SESSION_LIST_PREFIX}${sessionId.slice(0, SHORT_SESSION_ID_LENGTH)}`];
|
|
117025
117174
|
}
|
|
117026
|
-
function readTasks(
|
|
117175
|
+
function readTasks(fs29, configDir, ownLists, sharedLists, report) {
|
|
117027
117176
|
const tasks = [];
|
|
117028
117177
|
[...ownLists, ...sharedLists].forEach((scope, index) => {
|
|
117029
117178
|
const relativeDir = import_node_path35.default.join(TASKS_DIR, scope);
|
|
117030
|
-
for (const name of [...listDirOrReport(
|
|
117179
|
+
for (const name of [...listDirOrReport(fs29, configDir, relativeDir, report)].sort()) {
|
|
117031
117180
|
if (name.startsWith(".") || !name.endsWith(JSON_SUFFIX)) {
|
|
117032
117181
|
continue;
|
|
117033
117182
|
}
|
|
117034
117183
|
const relative = import_node_path35.default.join(relativeDir, name);
|
|
117035
|
-
const text2 = readFileOrReport(
|
|
117184
|
+
const text2 = readFileOrReport(fs29, configDir, relative, report);
|
|
117036
117185
|
const parsed = TaskFileSchema.safeParse(text2 === void 0 ? void 0 : parseJson3(text2));
|
|
117037
117186
|
if (parsed.success) {
|
|
117038
117187
|
tasks.push(index < ownLists.length ? parsed.data : { ...parsed.data, taskList: scope });
|
|
@@ -117043,14 +117192,14 @@ function readTasks(fs28, configDir, ownLists, sharedLists, report) {
|
|
|
117043
117192
|
});
|
|
117044
117193
|
return tasks;
|
|
117045
117194
|
}
|
|
117046
|
-
function readWorkflowRuns(
|
|
117195
|
+
function readWorkflowRuns(fs29, configDir, relativeDir, report) {
|
|
117047
117196
|
const runs = [];
|
|
117048
|
-
for (const name of [...listDirOrReport(
|
|
117197
|
+
for (const name of [...listDirOrReport(fs29, configDir, relativeDir, report)].sort()) {
|
|
117049
117198
|
if (!name.startsWith(WORKFLOW_RUN_PREFIX) || !name.endsWith(JSON_SUFFIX)) {
|
|
117050
117199
|
continue;
|
|
117051
117200
|
}
|
|
117052
117201
|
const relative = import_node_path35.default.join(relativeDir, name);
|
|
117053
|
-
const text2 = readFileOrReport(
|
|
117202
|
+
const text2 = readFileOrReport(fs29, configDir, relative, report);
|
|
117054
117203
|
const parsed = WorkflowRunFileSchema.safeParse(text2 === void 0 ? void 0 : parseJson3(text2));
|
|
117055
117204
|
if (!parsed.success) {
|
|
117056
117205
|
if (text2 !== void 0) {
|
|
@@ -117074,11 +117223,11 @@ var SessionLookupError = class extends CliError {
|
|
|
117074
117223
|
function identityConfigDir(identitiesDir, identity) {
|
|
117075
117224
|
return import_node_path36.default.join(identitiesDir, identity);
|
|
117076
117225
|
}
|
|
117077
|
-
function historyStores(
|
|
117226
|
+
function historyStores(fs29, identitiesDir, identities) {
|
|
117078
117227
|
const byRealPath = /* @__PURE__ */ new Map();
|
|
117079
117228
|
for (const identity of identities) {
|
|
117080
117229
|
const configDir = identityConfigDir(identitiesDir, identity);
|
|
117081
|
-
const real =
|
|
117230
|
+
const real = fs29.realpath(import_node_path36.default.join(configDir, "projects"));
|
|
117082
117231
|
if (real === void 0) {
|
|
117083
117232
|
continue;
|
|
117084
117233
|
}
|
|
@@ -117091,15 +117240,15 @@ function historyStores(fs28, identitiesDir, identities) {
|
|
|
117091
117240
|
}
|
|
117092
117241
|
return [...byRealPath.values()];
|
|
117093
117242
|
}
|
|
117094
|
-
function collectSessionList(
|
|
117243
|
+
function collectSessionList(fs29, identitiesDir, identities, filters) {
|
|
117095
117244
|
const names = filters.identity === void 0 ? identities : identities.filter((name) => name === filters.identity);
|
|
117096
117245
|
if (filters.identity !== void 0 && names.length === 0) {
|
|
117097
117246
|
throw new SessionLookupError(`no identity named "${filters.identity}"`);
|
|
117098
117247
|
}
|
|
117099
117248
|
const sessions = [];
|
|
117100
|
-
for (const store of historyStores(
|
|
117101
|
-
for (const ref of listSessions2(
|
|
117102
|
-
const summary = summariseSession(
|
|
117249
|
+
for (const store of historyStores(fs29, identitiesDir, names)) {
|
|
117250
|
+
for (const ref of listSessions2(fs29, store.configDir)) {
|
|
117251
|
+
const summary = summariseSession(fs29, store.configDir, ref);
|
|
117103
117252
|
if (filters.all === true || summary.agentCount > 0 || summary.workflowRunCount > 0) {
|
|
117104
117253
|
sessions.push({ ...summary, identities: store.identities });
|
|
117105
117254
|
}
|
|
@@ -117107,14 +117256,14 @@ function collectSessionList(fs28, identitiesDir, identities, filters) {
|
|
|
117107
117256
|
}
|
|
117108
117257
|
return sessions.sort((left, right) => (right.updatedAt ?? "").localeCompare(left.updatedAt ?? "") || left.sessionId.localeCompare(right.sessionId));
|
|
117109
117258
|
}
|
|
117110
|
-
function locateSession(
|
|
117259
|
+
function locateSession(fs29, identitiesDir, identities, query, onlyIdentity) {
|
|
117111
117260
|
const names = onlyIdentity === void 0 ? identities : identities.filter((name) => name === onlyIdentity);
|
|
117112
117261
|
if (onlyIdentity !== void 0 && names.length === 0) {
|
|
117113
117262
|
throw new SessionLookupError(`no identity named "${onlyIdentity}"`);
|
|
117114
117263
|
}
|
|
117115
117264
|
const matches = [];
|
|
117116
|
-
for (const store of historyStores(
|
|
117117
|
-
for (const ref of listSessions2(
|
|
117265
|
+
for (const store of historyStores(fs29, identitiesDir, names)) {
|
|
117266
|
+
for (const ref of listSessions2(fs29, store.configDir)) {
|
|
117118
117267
|
if (ref.sessionId.startsWith(query)) {
|
|
117119
117268
|
matches.push({ identities: store.identities, configDir: store.configDir, ref });
|
|
117120
117269
|
}
|
|
@@ -117131,9 +117280,9 @@ function locateSession(fs28, identitiesDir, identities, query, onlyIdentity) {
|
|
|
117131
117280
|
}
|
|
117132
117281
|
throw new SessionLookupError(`"${query}" matches ${String(candidates.length)} sessions: ${candidates.map((match) => `${match.ref.sessionId} (${match.identities.join(", ")})`).join("; ")}; give more of the id or pass --identity`);
|
|
117133
117282
|
}
|
|
117134
|
-
function showSession(
|
|
117135
|
-
const located = locateSession(
|
|
117136
|
-
return { identities: located.identities, tree: readSessionAgentTree(
|
|
117283
|
+
function showSession(fs29, identitiesDir, identities, query, onlyIdentity) {
|
|
117284
|
+
const located = locateSession(fs29, identitiesDir, identities, query, onlyIdentity);
|
|
117285
|
+
return { identities: located.identities, tree: readSessionAgentTree(fs29, located.configDir, located.ref) };
|
|
117137
117286
|
}
|
|
117138
117287
|
|
|
117139
117288
|
// src/frontdoor/commands.ts
|
|
@@ -117179,13 +117328,13 @@ function stateDirOf(paths, pool) {
|
|
|
117179
117328
|
function sessionStatePath(paths, pool, sessionId) {
|
|
117180
117329
|
return import_node_path37.default.join(stateDirOf(paths, pool), `${sessionId}.json`);
|
|
117181
117330
|
}
|
|
117182
|
-
function writeSessionState(
|
|
117183
|
-
|
|
117184
|
-
|
|
117331
|
+
function writeSessionState(fs29, paths, pool, sessionId, state) {
|
|
117332
|
+
fs29.mkdirPrivate(stateDirOf(paths, pool));
|
|
117333
|
+
fs29.writeFilePrivate(sessionStatePath(paths, pool, sessionId), `${JSON.stringify(SessionStateSchema.parse(state))}
|
|
117185
117334
|
`);
|
|
117186
117335
|
}
|
|
117187
|
-
function readSessionState(
|
|
117188
|
-
const raw =
|
|
117336
|
+
function readSessionState(fs29, paths, pool, sessionId) {
|
|
117337
|
+
const raw = fs29.readFileUtf8(sessionStatePath(paths, pool, sessionId));
|
|
117189
117338
|
if (raw === void 0) {
|
|
117190
117339
|
return void 0;
|
|
117191
117340
|
}
|
|
@@ -117196,20 +117345,20 @@ function readSessionState(fs28, paths, pool, sessionId) {
|
|
|
117196
117345
|
return void 0;
|
|
117197
117346
|
}
|
|
117198
117347
|
}
|
|
117199
|
-
function registerSupervised(
|
|
117200
|
-
|
|
117201
|
-
|
|
117348
|
+
function registerSupervised(fs29, paths, session) {
|
|
117349
|
+
fs29.mkdirPrivate(sessionsDirOf(paths, session.pool));
|
|
117350
|
+
fs29.writeFilePrivate(sessionFileOf(paths, session.pool, session.sessionId), `${JSON.stringify(SupervisedSessionSchema.parse(session))}
|
|
117202
117351
|
`);
|
|
117203
117352
|
}
|
|
117204
|
-
function unregisterSupervised(
|
|
117205
|
-
|
|
117206
|
-
|
|
117353
|
+
function unregisterSupervised(fs29, paths, pool, sessionId) {
|
|
117354
|
+
fs29.removeRecursive(sessionFileOf(paths, pool, sessionId));
|
|
117355
|
+
fs29.removeRecursive(sessionStatePath(paths, pool, sessionId));
|
|
117207
117356
|
}
|
|
117208
|
-
function liveSupervised(
|
|
117357
|
+
function liveSupervised(fs29, paths, pool, isRunning) {
|
|
117209
117358
|
const live = [];
|
|
117210
|
-
for (const name of
|
|
117359
|
+
for (const name of fs29.readdir(sessionsDirOf(paths, pool))) {
|
|
117211
117360
|
const file2 = import_node_path37.default.join(sessionsDirOf(paths, pool), name);
|
|
117212
|
-
const raw =
|
|
117361
|
+
const raw = fs29.readFileUtf8(file2);
|
|
117213
117362
|
if (raw === void 0) {
|
|
117214
117363
|
continue;
|
|
117215
117364
|
}
|
|
@@ -117217,13 +117366,13 @@ function liveSupervised(fs28, paths, pool, isRunning) {
|
|
|
117217
117366
|
try {
|
|
117218
117367
|
parsed = SupervisedSessionSchema.safeParse(JSON.parse(raw));
|
|
117219
117368
|
} catch {
|
|
117220
|
-
|
|
117369
|
+
fs29.removeRecursive(file2);
|
|
117221
117370
|
continue;
|
|
117222
117371
|
}
|
|
117223
117372
|
if (parsed.success && isRunning(parsed.data.pid)) {
|
|
117224
117373
|
live.push(parsed.data);
|
|
117225
117374
|
} else {
|
|
117226
|
-
|
|
117375
|
+
fs29.removeRecursive(file2);
|
|
117227
117376
|
}
|
|
117228
117377
|
}
|
|
117229
117378
|
return live;
|
|
@@ -117252,13 +117401,13 @@ var ModelMoveRequestSchema = external_exports.strictObject({
|
|
|
117252
117401
|
/** When the door wrote the request, so a supervisor can tell a fresh request from one left behind. */
|
|
117253
117402
|
at: external_exports.iso.datetime()
|
|
117254
117403
|
});
|
|
117255
|
-
function writeModelMove(
|
|
117256
|
-
|
|
117257
|
-
|
|
117404
|
+
function writeModelMove(fs29, paths, request7) {
|
|
117405
|
+
fs29.mkdirPrivate(paths.modelMovesDir);
|
|
117406
|
+
fs29.writeFilePrivate(import_node_path37.default.join(paths.modelMovesDir, `${request7.sessionId}.json`), `${JSON.stringify(ModelMoveRequestSchema.parse(request7))}
|
|
117258
117407
|
`);
|
|
117259
117408
|
}
|
|
117260
|
-
function readModelMove(
|
|
117261
|
-
const raw =
|
|
117409
|
+
function readModelMove(fs29, paths, sessionId) {
|
|
117410
|
+
const raw = fs29.readFileUtf8(import_node_path37.default.join(paths.modelMovesDir, `${sessionId}.json`));
|
|
117262
117411
|
if (raw === void 0) {
|
|
117263
117412
|
return void 0;
|
|
117264
117413
|
}
|
|
@@ -117268,12 +117417,12 @@ function readModelMove(fs28, paths, sessionId) {
|
|
|
117268
117417
|
return void 0;
|
|
117269
117418
|
}
|
|
117270
117419
|
}
|
|
117271
|
-
function removeModelMove(
|
|
117272
|
-
|
|
117420
|
+
function removeModelMove(fs29, paths, sessionId) {
|
|
117421
|
+
fs29.removeRecursive(import_node_path37.default.join(paths.modelMovesDir, `${sessionId}.json`));
|
|
117273
117422
|
}
|
|
117274
|
-
function supervisedSessionOf(
|
|
117275
|
-
for (const pool of
|
|
117276
|
-
const sessions = liveSupervised(
|
|
117423
|
+
function supervisedSessionOf(fs29, paths, sessionId, isRunning) {
|
|
117424
|
+
for (const pool of fs29.readdir(paths.superviseDir)) {
|
|
117425
|
+
const sessions = liveSupervised(fs29, paths, pool, isRunning);
|
|
117277
117426
|
const found = sessions.find((session) => session.sessionId === sessionId);
|
|
117278
117427
|
if (found !== void 0) {
|
|
117279
117428
|
return found;
|
|
@@ -117331,9 +117480,9 @@ function blendedPricePerMTok(prices, mix) {
|
|
|
117331
117480
|
|
|
117332
117481
|
// src/selection/targetStore.ts
|
|
117333
117482
|
var SEED_LOOKBACK_RECORDS = 500;
|
|
117334
|
-
function createTargetObservationStore(
|
|
117483
|
+
function createTargetObservationStore(fs29, paths) {
|
|
117335
117484
|
let observations = /* @__PURE__ */ new Map();
|
|
117336
|
-
const seeded = readUsageLog(
|
|
117485
|
+
const seeded = readUsageLog(fs29, paths.usageLogDir, {}).records.slice(-SEED_LOOKBACK_RECORDS);
|
|
117337
117486
|
for (const record2 of seeded) {
|
|
117338
117487
|
observations = observeRecord(observations, record2);
|
|
117339
117488
|
}
|
|
@@ -117349,7 +117498,7 @@ function createTargetObservationStore(fs28, paths) {
|
|
|
117349
117498
|
}
|
|
117350
117499
|
|
|
117351
117500
|
// src/update/commands.ts
|
|
117352
|
-
var
|
|
117501
|
+
var import_node_fs16 = __toESM(require("node:fs"), 1);
|
|
117353
117502
|
var import_node_os7 = __toESM(require("node:os"), 1);
|
|
117354
117503
|
var import_node_path40 = __toESM(require("node:path"), 1);
|
|
117355
117504
|
init_package();
|
|
@@ -117384,10 +117533,10 @@ var realUpdatePorts = {
|
|
|
117384
117533
|
}
|
|
117385
117534
|
},
|
|
117386
117535
|
fs: {
|
|
117387
|
-
realpath: (target) =>
|
|
117536
|
+
realpath: (target) => import_node_fs16.default.realpathSync(target),
|
|
117388
117537
|
readFileUtf8: (filePath) => {
|
|
117389
117538
|
try {
|
|
117390
|
-
return
|
|
117539
|
+
return import_node_fs16.default.readFileSync(filePath, "utf8");
|
|
117391
117540
|
} catch (error63) {
|
|
117392
117541
|
if (isEnoent6(error63)) {
|
|
117393
117542
|
return void 0;
|
|
@@ -117397,7 +117546,7 @@ var realUpdatePorts = {
|
|
|
117397
117546
|
},
|
|
117398
117547
|
readFileBytes: (filePath) => {
|
|
117399
117548
|
try {
|
|
117400
|
-
return new Uint8Array(
|
|
117549
|
+
return new Uint8Array(import_node_fs16.default.readFileSync(filePath));
|
|
117401
117550
|
} catch (error63) {
|
|
117402
117551
|
if (isEnoent6(error63)) {
|
|
117403
117552
|
return void 0;
|
|
@@ -117408,7 +117557,7 @@ var realUpdatePorts = {
|
|
|
117408
117557
|
readFileHead: (filePath, length) => {
|
|
117409
117558
|
let descriptor;
|
|
117410
117559
|
try {
|
|
117411
|
-
descriptor =
|
|
117560
|
+
descriptor = import_node_fs16.default.openSync(filePath, "r");
|
|
117412
117561
|
} catch (error63) {
|
|
117413
117562
|
if (isEnoent6(error63)) {
|
|
117414
117563
|
return void 0;
|
|
@@ -117417,21 +117566,21 @@ var realUpdatePorts = {
|
|
|
117417
117566
|
}
|
|
117418
117567
|
try {
|
|
117419
117568
|
const buffer2 = Buffer.alloc(length);
|
|
117420
|
-
const read =
|
|
117569
|
+
const read = import_node_fs16.default.readSync(descriptor, buffer2, 0, length, 0);
|
|
117421
117570
|
return read === 0 ? "" : buffer2.toString("latin1", 0, read);
|
|
117422
117571
|
} finally {
|
|
117423
|
-
|
|
117572
|
+
import_node_fs16.default.closeSync(descriptor);
|
|
117424
117573
|
}
|
|
117425
117574
|
},
|
|
117426
117575
|
writeFileUtf8: (filePath, contents) => {
|
|
117427
|
-
|
|
117576
|
+
import_node_fs16.default.writeFileSync(filePath, contents, "utf8");
|
|
117428
117577
|
},
|
|
117429
117578
|
writeFileBytes: (filePath, contents) => {
|
|
117430
|
-
|
|
117579
|
+
import_node_fs16.default.writeFileSync(filePath, contents);
|
|
117431
117580
|
},
|
|
117432
117581
|
writeFileExclusive: (filePath, contents) => {
|
|
117433
117582
|
try {
|
|
117434
|
-
|
|
117583
|
+
import_node_fs16.default.writeFileSync(filePath, contents, { encoding: "utf8", flag: "wx" });
|
|
117435
117584
|
return true;
|
|
117436
117585
|
} catch (error63) {
|
|
117437
117586
|
if (isErrorWithCode2(error63, "EEXIST")) {
|
|
@@ -117442,7 +117591,7 @@ var realUpdatePorts = {
|
|
|
117442
117591
|
},
|
|
117443
117592
|
unlink: (filePath) => {
|
|
117444
117593
|
try {
|
|
117445
|
-
|
|
117594
|
+
import_node_fs16.default.unlinkSync(filePath);
|
|
117446
117595
|
} catch (error63) {
|
|
117447
117596
|
if (!isEnoent6(error63)) {
|
|
117448
117597
|
throw error63;
|
|
@@ -117450,14 +117599,14 @@ var realUpdatePorts = {
|
|
|
117450
117599
|
}
|
|
117451
117600
|
},
|
|
117452
117601
|
rename: (from, to2) => {
|
|
117453
|
-
|
|
117602
|
+
import_node_fs16.default.renameSync(from, to2);
|
|
117454
117603
|
},
|
|
117455
117604
|
chmod: (filePath, mode) => {
|
|
117456
|
-
|
|
117605
|
+
import_node_fs16.default.chmodSync(filePath, mode);
|
|
117457
117606
|
},
|
|
117458
|
-
mkdtemp: () =>
|
|
117607
|
+
mkdtemp: () => import_node_fs16.default.mkdtempSync(import_node_path40.default.join(import_node_os7.default.tmpdir(), "agent-shim-update-")),
|
|
117459
117608
|
rmRecursive: (targetPath) => {
|
|
117460
|
-
|
|
117609
|
+
import_node_fs16.default.rmSync(targetPath, { recursive: true, force: true });
|
|
117461
117610
|
}
|
|
117462
117611
|
},
|
|
117463
117612
|
// Signal 0 performs the permission and existence checks without delivering anything; EPERM means the process exists but belongs to another user.
|
|
@@ -117530,7 +117679,7 @@ function registerUpdateCommand(program2, deps, ports = realUpdatePorts) {
|
|
|
117530
117679
|
return;
|
|
117531
117680
|
}
|
|
117532
117681
|
const report = await runSelfUpdate(ports, selfUpdateOptions(deps.paths, options.check === true));
|
|
117533
|
-
const doorRestart = options.restartDoor === true && report.action === "updated" ? realRestartFrontDoor(deps.paths, spawnDetachedSupervisor) : void 0;
|
|
117682
|
+
const doorRestart = options.restartDoor === true && report.action === "updated" ? realRestartFrontDoor(deps.paths, spawnDetachedSupervisor, "update-restart") : void 0;
|
|
117534
117683
|
if (options.json === true) {
|
|
117535
117684
|
printJson(doorRestart === void 0 ? report : { ...report, frontdoor: doorRestart });
|
|
117536
117685
|
return;
|
|
@@ -117753,8 +117902,8 @@ var StampsFileSchema = external_exports.strictObject({
|
|
|
117753
117902
|
schemaVersion: external_exports.literal(STAMPS_SCHEMA_VERSION),
|
|
117754
117903
|
handled: external_exports.record(external_exports.string().min(1), external_exports.iso.datetime())
|
|
117755
117904
|
});
|
|
117756
|
-
function readHandled(
|
|
117757
|
-
const raw =
|
|
117905
|
+
function readHandled(fs29, file2) {
|
|
117906
|
+
const raw = fs29.readFileUtf8(file2);
|
|
117758
117907
|
if (raw === void 0) {
|
|
117759
117908
|
return {};
|
|
117760
117909
|
}
|
|
@@ -117767,10 +117916,10 @@ function readHandled(fs28, file2) {
|
|
|
117767
117916
|
const result = StampsFileSchema.safeParse(parsed);
|
|
117768
117917
|
return result.success ? Object.fromEntries(Object.entries(result.data.handled).map(([key, at2]) => [key, Date.parse(at2)])) : {};
|
|
117769
117918
|
}
|
|
117770
|
-
function writeHandled(
|
|
117919
|
+
function writeHandled(fs29, file2, handled) {
|
|
117771
117920
|
const next = { schemaVersion: STAMPS_SCHEMA_VERSION, handled: Object.fromEntries(Object.entries(handled).map(([key, at2]) => [key, new Date(at2).toISOString()])) };
|
|
117772
|
-
|
|
117773
|
-
|
|
117921
|
+
fs29.mkdirPrivate(import_node_path48.default.dirname(file2));
|
|
117922
|
+
fs29.writeFilePrivate(file2, `${JSON.stringify(next, null, 2)}
|
|
117774
117923
|
`);
|
|
117775
117924
|
}
|
|
117776
117925
|
|
|
@@ -118059,8 +118208,12 @@ function createDoorPipelines(deps) {
|
|
|
118059
118208
|
};
|
|
118060
118209
|
}
|
|
118061
118210
|
|
|
118211
|
+
// src/frontdoor/commands.ts
|
|
118212
|
+
init_doorLog();
|
|
118213
|
+
init_replacement();
|
|
118214
|
+
|
|
118062
118215
|
// src/headroom/routingSetting.ts
|
|
118063
|
-
var
|
|
118216
|
+
var import_node_fs18 = __toESM(require("node:fs"), 1);
|
|
118064
118217
|
init_zod();
|
|
118065
118218
|
init_store();
|
|
118066
118219
|
var RoutingChoiceSchema = external_exports.strictObject({
|
|
@@ -118098,7 +118251,7 @@ function createRoutingSettingReader(paths) {
|
|
|
118098
118251
|
return () => {
|
|
118099
118252
|
let key;
|
|
118100
118253
|
try {
|
|
118101
|
-
const stat =
|
|
118254
|
+
const stat = import_node_fs18.default.statSync(paths.headroomRoutingFile);
|
|
118102
118255
|
key = `${String(stat.mtimeMs)}:${String(stat.size)}`;
|
|
118103
118256
|
} catch {
|
|
118104
118257
|
cachedKey = void 0;
|
|
@@ -119746,6 +119899,14 @@ async function listenFrontDoor(server, options = {}) {
|
|
|
119746
119899
|
});
|
|
119747
119900
|
server.closeAllConnections();
|
|
119748
119901
|
});
|
|
119902
|
+
},
|
|
119903
|
+
// The port is released as `server.close` runs, before the first await. From Node 19 `close` also ends the connections that are idle, and a connection that finishes its last response while the server is closing is ended with it, so a request already being served finishes and its client then reconnects to whatever now holds the port.
|
|
119904
|
+
drain: async () => {
|
|
119905
|
+
await new Promise((resolve2) => {
|
|
119906
|
+
server.close(() => {
|
|
119907
|
+
resolve2(void 0);
|
|
119908
|
+
});
|
|
119909
|
+
});
|
|
119749
119910
|
}
|
|
119750
119911
|
};
|
|
119751
119912
|
}
|
|
@@ -120053,6 +120214,10 @@ function realConnectEffects(ports = DOOR_SOURCE_PORTS) {
|
|
|
120053
120214
|
}
|
|
120054
120215
|
resolve2({
|
|
120055
120216
|
port: bound,
|
|
120217
|
+
// The listening socket is released by `close` at once; the connections already accepted are untouched and keep the server's `close` callback pending until they end.
|
|
120218
|
+
stopAccepting: () => {
|
|
120219
|
+
server.close();
|
|
120220
|
+
},
|
|
120056
120221
|
close: async () => {
|
|
120057
120222
|
await new Promise((closeResolve) => {
|
|
120058
120223
|
server.close(() => {
|
|
@@ -120237,7 +120402,7 @@ function realConnectEffects(ports = DOOR_SOURCE_PORTS) {
|
|
|
120237
120402
|
init_claudeShim();
|
|
120238
120403
|
init_store();
|
|
120239
120404
|
init_realPorts();
|
|
120240
|
-
var
|
|
120405
|
+
var import_node_fs20 = __toESM(require("node:fs"), 1);
|
|
120241
120406
|
var import_node_path49 = __toESM(require("node:path"), 1);
|
|
120242
120407
|
init_signIn();
|
|
120243
120408
|
init_load();
|
|
@@ -120420,14 +120585,18 @@ init_supervisor();
|
|
|
120420
120585
|
init_state();
|
|
120421
120586
|
|
|
120422
120587
|
// src/doctorFrontDoor.ts
|
|
120423
|
-
function pushFrontDoor(push, supervisors, registeredPid, liveSessions) {
|
|
120588
|
+
function pushFrontDoor(push, supervisors, registeredPid, liveSessions, draining) {
|
|
120424
120589
|
if (!supervisors.ok) {
|
|
120425
120590
|
push("frontdoor", "warn", `Could not list processes to look for duplicate front door supervisors: ${supervisors.message}.`);
|
|
120426
120591
|
return;
|
|
120427
120592
|
}
|
|
120428
|
-
const
|
|
120593
|
+
const drainingPids = supervisors.pids.filter((pid) => draining.includes(pid));
|
|
120594
|
+
for (const pid of drainingPids) {
|
|
120595
|
+
push("frontdoor", "warn", `Front door supervisor pid ${String(pid)} is draining: it has released its addresses and exits once the connections it carried have ended.`, String(pid));
|
|
120596
|
+
}
|
|
120597
|
+
const pids = supervisors.pids.filter((pid) => !draining.includes(pid));
|
|
120429
120598
|
if (pids.length === 0) {
|
|
120430
|
-
push("frontdoor", "pass", "No front door supervisor is running.");
|
|
120599
|
+
push("frontdoor", "pass", drainingPids.length === 0 ? "No front door supervisor is running." : "No front door supervisor is serving.");
|
|
120431
120600
|
return;
|
|
120432
120601
|
}
|
|
120433
120602
|
const [only, ...rest] = pids;
|
|
@@ -120476,7 +120645,7 @@ function pushFrontDoorListeners(push, readings) {
|
|
|
120476
120645
|
}
|
|
120477
120646
|
|
|
120478
120647
|
// src/frontdoor/listenerReadings.ts
|
|
120479
|
-
var
|
|
120648
|
+
var import_node_fs19 = __toESM(require("node:fs"), 1);
|
|
120480
120649
|
init_probe();
|
|
120481
120650
|
function readFrontDoorListeners(state, supervisorAlive, probes) {
|
|
120482
120651
|
if (!supervisorAlive) {
|
|
@@ -120497,7 +120666,7 @@ function readFrontDoorListeners(state, supervisorAlive, probes) {
|
|
|
120497
120666
|
}
|
|
120498
120667
|
function realFrontDoorListenerProbes(paths) {
|
|
120499
120668
|
return {
|
|
120500
|
-
authenticateProvider: (port) => probeFrontDoorSync(port,
|
|
120669
|
+
authenticateProvider: (port) => probeFrontDoorSync(port, import_node_fs19.default.readFileSync(paths.frontdoorCaCertFile, "utf8")),
|
|
120501
120670
|
connect: probeListenerAcceptSync,
|
|
120502
120671
|
now: () => performance.now()
|
|
120503
120672
|
};
|
|
@@ -120977,7 +121146,7 @@ function runDoctor(params) {
|
|
|
120977
121146
|
}
|
|
120978
121147
|
if (params.frontDoor !== void 0) {
|
|
120979
121148
|
const validated2 = params.frontDoor.state.raw === void 0 ? void 0 : validateJson(FrontDoorStateSchema, params.frontDoor.state);
|
|
120980
|
-
pushFrontDoor(push, params.frontDoor.supervisors, validated2?.ok === true ? validated2.data.supervisorPid : void 0, params.frontDoor.liveSessions);
|
|
121149
|
+
pushFrontDoor(push, params.frontDoor.supervisors, validated2?.ok === true ? validated2.data.supervisorPid : void 0, params.frontDoor.liveSessions, params.frontDoor.draining ?? []);
|
|
120981
121150
|
if (params.frontDoor.listeners !== void 0) {
|
|
120982
121151
|
pushFrontDoorListeners(push, params.frontDoor.listeners);
|
|
120983
121152
|
}
|
|
@@ -121065,7 +121234,7 @@ function formatDoctorReport(report) {
|
|
|
121065
121234
|
}
|
|
121066
121235
|
function realpathOrSelf(target) {
|
|
121067
121236
|
try {
|
|
121068
|
-
return
|
|
121237
|
+
return import_node_fs20.default.realpathSync(target);
|
|
121069
121238
|
} catch {
|
|
121070
121239
|
return target;
|
|
121071
121240
|
}
|
|
@@ -121077,18 +121246,18 @@ function servingDoorListeners(paths) {
|
|
|
121077
121246
|
}
|
|
121078
121247
|
function collectDoctorReport(params) {
|
|
121079
121248
|
const { paths } = params;
|
|
121080
|
-
const identityNames =
|
|
121249
|
+
const identityNames = import_node_fs20.default.existsSync(paths.identitiesDir) ? import_node_fs20.default.readdirSync(paths.identitiesDir, { withFileTypes: true }).filter((entry) => entry.isDirectory() && isIdentityDirectoryName(entry.name)).map((entry) => entry.name).sort() : [];
|
|
121081
121250
|
const identities = identityNames.map((name) => {
|
|
121082
121251
|
const farmRoot = import_node_path49.default.join(paths.identitiesDir, name);
|
|
121083
121252
|
const identityPath = import_node_path49.default.join(farmRoot, "identity.json");
|
|
121084
|
-
return { name, path: identityPath, raw: realFsPort.readFileUtf8(identityPath), farmRoot, credentialsFilePresent:
|
|
121253
|
+
return { name, path: identityPath, raw: realFsPort.readFileUtf8(identityPath), farmRoot, credentialsFilePresent: import_node_fs20.default.existsSync(credentialsFilePath(farmRoot)) };
|
|
121085
121254
|
});
|
|
121086
|
-
const profileNames =
|
|
121255
|
+
const profileNames = import_node_fs20.default.existsSync(paths.configProfilesDir) ? import_node_fs20.default.readdirSync(paths.configProfilesDir, { withFileTypes: true }).filter((entry) => entry.isFile() && entry.name.endsWith(".json")).map((entry) => entry.name.slice(0, -".json".length)).sort() : [];
|
|
121087
121256
|
const configProfiles = profileNames.map((name) => {
|
|
121088
121257
|
const profilePath = import_node_path49.default.join(paths.configProfilesDir, `${name}.json`);
|
|
121089
121258
|
return { name, path: profilePath, raw: realFsPort.readFileUtf8(profilePath) };
|
|
121090
121259
|
});
|
|
121091
|
-
const providerNames =
|
|
121260
|
+
const providerNames = import_node_fs20.default.existsSync(paths.providersDir) ? import_node_fs20.default.readdirSync(paths.providersDir, { withFileTypes: true }).filter((entry) => entry.isFile() && entry.name.endsWith(".json")).map((entry) => entry.name.slice(0, -".json".length)).sort() : [];
|
|
121092
121261
|
const providers = providerNames.map((name) => {
|
|
121093
121262
|
const providerPath = import_node_path49.default.join(paths.providersDir, `${name}.json`);
|
|
121094
121263
|
return { name, path: providerPath, raw: realFsPort.readFileUtf8(providerPath) };
|
|
@@ -121136,7 +121305,7 @@ function collectDoctorReport(params) {
|
|
|
121136
121305
|
categoriesLocal: { path: paths.categoriesLocalFile, raw: realFsPort.readFileUtf8(paths.categoriesLocalFile) },
|
|
121137
121306
|
activeIdentity: { path: paths.activeIdentityFile, raw: realFsPort.readFileUtf8(paths.activeIdentityFile) },
|
|
121138
121307
|
binaryDiscovery,
|
|
121139
|
-
claudeShim: { state: shimState, targetExists: shimState !== void 0 &&
|
|
121308
|
+
claudeShim: { state: shimState, targetExists: shimState !== void 0 && import_node_fs20.default.existsSync(shimState.targetPath) },
|
|
121140
121309
|
rootPath: paths.root,
|
|
121141
121310
|
pathResolution: {
|
|
121142
121311
|
ownExecutablePath,
|
|
@@ -121176,7 +121345,7 @@ function collectDoctorReport(params) {
|
|
|
121176
121345
|
logPath: paths.headroomLogPath
|
|
121177
121346
|
}
|
|
121178
121347
|
},
|
|
121179
|
-
...uid === void 0 ? {} : { frontDoor: { state: { path: paths.frontdoorStateFile, raw: realFsPort.readFileUtf8(paths.frontdoorStateFile) }, supervisors: listFrontDoorSupervisors(realRunPort, uid), liveSessions: listFrontDoorSessions(realFarmFs, paths.frontdoorSessionsDir).filter((session) => realIsProcessRunning(session.pid)), listeners: servingDoorListeners(paths) } }
|
|
121348
|
+
...uid === void 0 ? {} : { frontDoor: { state: { path: paths.frontdoorStateFile, raw: realFsPort.readFileUtf8(paths.frontdoorStateFile) }, supervisors: listFrontDoorSupervisors(realRunPort, uid), liveSessions: listFrontDoorSessions(realFarmFs, paths.frontdoorSessionsDir).filter((session) => realIsProcessRunning(session.pid)), draining: listDrainingFrontDoors(realFarmFs, paths.frontdoorDrainingDir, realIsProcessRunning), listeners: servingDoorListeners(paths) } }
|
|
121180
121349
|
});
|
|
121181
121350
|
return report;
|
|
121182
121351
|
}
|
|
@@ -126882,6 +127051,8 @@ var HeadroomSocketTargetSchema = external_exports.union([external_exports.strict
|
|
|
126882
127051
|
var FrontDoorStatusOutputSchema = external_exports.strictObject({
|
|
126883
127052
|
state: FrontDoorStateSchema,
|
|
126884
127053
|
supervisorAlive: external_exports.boolean(),
|
|
127054
|
+
/** The pids of earlier doors that released their addresses and are finishing the connections they carried: running, but not serving anything new. */
|
|
127055
|
+
draining: external_exports.readonly(external_exports.array(external_exports.number().int().positive())),
|
|
126885
127056
|
sessions: external_exports.readonly(external_exports.array(FrontDoorSessionStatusSchema)),
|
|
126886
127057
|
headroomSocket: HeadroomSocketTargetSchema.optional(),
|
|
126887
127058
|
logPath: external_exports.string(),
|
|
@@ -132785,8 +132956,8 @@ var SELF_HOST_SUBSCRIPTION_TYPE = "max";
|
|
|
132785
132956
|
function isRecord16(value2) {
|
|
132786
132957
|
return typeof value2 === "object" && value2 !== null && !Array.isArray(value2);
|
|
132787
132958
|
}
|
|
132788
|
-
function readJsonObject(
|
|
132789
|
-
const raw =
|
|
132959
|
+
function readJsonObject(fs29, file2) {
|
|
132960
|
+
const raw = fs29.readFileUtf8(file2);
|
|
132790
132961
|
if (raw === void 0) {
|
|
132791
132962
|
return void 0;
|
|
132792
132963
|
}
|
|
@@ -132798,8 +132969,8 @@ function readJsonObject(fs28, file2) {
|
|
|
132798
132969
|
}
|
|
132799
132970
|
return isRecord16(parsed) ? parsed : void 0;
|
|
132800
132971
|
}
|
|
132801
|
-
function readRcSelfHostRecord(
|
|
132802
|
-
const parsed = readJsonObject(
|
|
132972
|
+
function readRcSelfHostRecord(fs29, frontdoorDir) {
|
|
132973
|
+
const parsed = readJsonObject(fs29, import_node_path52.default.join(frontdoorDir, RC_SELF_HOST_RECORD_DIR, RC_SELF_HOST_RECORD_FILE));
|
|
132803
132974
|
if (parsed === void 0) {
|
|
132804
132975
|
return void 0;
|
|
132805
132976
|
}
|
|
@@ -133244,11 +133415,11 @@ function credentialOfJson(parsed) {
|
|
|
133244
133415
|
function sequenceNumOfJson(value2) {
|
|
133245
133416
|
return typeof value2 === "number" && Number.isInteger(value2) && value2 >= 0 ? value2 : void 0;
|
|
133246
133417
|
}
|
|
133247
|
-
function createRcCredentialStore(
|
|
133248
|
-
|
|
133418
|
+
function createRcCredentialStore(fs29, dir) {
|
|
133419
|
+
fs29.mkdirPrivate(dir);
|
|
133249
133420
|
const fileFor = (sessionId) => import_node_path53.default.join(dir, `${sessionId}.json`);
|
|
133250
133421
|
const readParsed = (sessionId) => {
|
|
133251
|
-
const raw =
|
|
133422
|
+
const raw = fs29.readFileUtf8(fileFor(sessionId));
|
|
133252
133423
|
if (raw === void 0) {
|
|
133253
133424
|
return void 0;
|
|
133254
133425
|
}
|
|
@@ -133273,7 +133444,7 @@ function createRcCredentialStore(fs28, dir) {
|
|
|
133273
133444
|
}
|
|
133274
133445
|
const cursor3 = sequenceNumOfJson(readParsed(sessionId)?.highestSequenceNum);
|
|
133275
133446
|
const record2 = { ...credential, ...cursor3 === void 0 ? {} : { highestSequenceNum: cursor3 } };
|
|
133276
|
-
|
|
133447
|
+
fs29.writeFilePrivate(fileFor(sessionId), `${JSON.stringify(record2, null, 2)}
|
|
133277
133448
|
`);
|
|
133278
133449
|
},
|
|
133279
133450
|
readCursor: (sessionId) => {
|
|
@@ -133288,14 +133459,14 @@ function createRcCredentialStore(fs28, dir) {
|
|
|
133288
133459
|
}
|
|
133289
133460
|
const credential = credentialOfJson(readParsed(sessionId));
|
|
133290
133461
|
const record2 = credential === void 0 ? { highestSequenceNum } : { ...credential, highestSequenceNum };
|
|
133291
|
-
|
|
133462
|
+
fs29.writeFilePrivate(fileFor(sessionId), `${JSON.stringify(record2, null, 2)}
|
|
133292
133463
|
`);
|
|
133293
133464
|
},
|
|
133294
133465
|
remove: (sessionId) => {
|
|
133295
133466
|
if (!isSafeSessionId(sessionId)) {
|
|
133296
133467
|
return;
|
|
133297
133468
|
}
|
|
133298
|
-
|
|
133469
|
+
fs29.removeRecursive(fileFor(sessionId));
|
|
133299
133470
|
}
|
|
133300
133471
|
};
|
|
133301
133472
|
}
|
|
@@ -135129,6 +135300,7 @@ function createRcEventFanout() {
|
|
|
135129
135300
|
}
|
|
135130
135301
|
function createRcStreamHub(deps) {
|
|
135131
135302
|
const attachments = /* @__PURE__ */ new Map();
|
|
135303
|
+
let closed = false;
|
|
135132
135304
|
const lastSavedSequenceNums = /* @__PURE__ */ new Map();
|
|
135133
135305
|
const persistCursor = (sessionId) => {
|
|
135134
135306
|
if (deps.saveSequenceNum === void 0) {
|
|
@@ -135287,6 +135459,9 @@ function createRcStreamHub(deps) {
|
|
|
135287
135459
|
};
|
|
135288
135460
|
return {
|
|
135289
135461
|
reconcile: () => {
|
|
135462
|
+
if (closed) {
|
|
135463
|
+
return;
|
|
135464
|
+
}
|
|
135290
135465
|
const live = new Set(deps.trackedSessions());
|
|
135291
135466
|
for (const [sessionId, attachment] of attachments) {
|
|
135292
135467
|
if (!live.has(sessionId)) {
|
|
@@ -135309,6 +135484,7 @@ function createRcStreamHub(deps) {
|
|
|
135309
135484
|
}
|
|
135310
135485
|
},
|
|
135311
135486
|
close: () => {
|
|
135487
|
+
closed = true;
|
|
135312
135488
|
for (const attachment of attachments.values()) {
|
|
135313
135489
|
persistCursor(attachment.sessionId);
|
|
135314
135490
|
const credential = deps.credentialOf(attachment.sessionId);
|
|
@@ -135537,6 +135713,7 @@ function collectFrontDoorStatus(fsPort, socketTrust, paths, isRunning) {
|
|
|
135537
135713
|
return {
|
|
135538
135714
|
state,
|
|
135539
135715
|
supervisorAlive: state.supervisorPid !== void 0 && isRunning(state.supervisorPid),
|
|
135716
|
+
draining: listDrainingFrontDoors(fsPort, paths.frontdoorDrainingDir, isRunning),
|
|
135540
135717
|
sessions: listFrontDoorSessions(fsPort, paths.frontdoorSessionsDir).map((session) => ({ ...session, alive: isRunning(session.pid) })),
|
|
135541
135718
|
headroomSocket: headroomSocketTarget(fsPort, socketTrust, paths),
|
|
135542
135719
|
logPath: paths.frontdoorLogPath,
|
|
@@ -135560,6 +135737,9 @@ function formatFrontDoorStatus(status, caCertPath) {
|
|
|
135560
135737
|
} else {
|
|
135561
135738
|
lines.push(`connect surface: listening on 127.0.0.1:${String(status.state.connectPort)}, CA ${caCertPath}`);
|
|
135562
135739
|
}
|
|
135740
|
+
if (status.draining.length > 0) {
|
|
135741
|
+
lines.push(`draining: ${status.draining.map(String).join(", ")} (finishing connections opened before the last restart; each exits when they have ended)`);
|
|
135742
|
+
}
|
|
135563
135743
|
if (status.headroomSocket === void 0) {
|
|
135564
135744
|
lines.push("headroom hop: the daemon is not serving (sessions asking for headroom fail until it is up)");
|
|
135565
135745
|
} else if (status.headroomSocket.refused === void 0) {
|
|
@@ -135640,11 +135820,6 @@ function respawnInvocation(paths) {
|
|
|
135640
135820
|
}
|
|
135641
135821
|
return { ...selfInvocation(["__frontdoor-supervisor"]), env };
|
|
135642
135822
|
}
|
|
135643
|
-
function appendLog(paths, line) {
|
|
135644
|
-
import_node_fs20.default.mkdirSync(paths.logsDir, { recursive: true });
|
|
135645
|
-
import_node_fs20.default.appendFileSync(paths.frontdoorLogPath, `${(/* @__PURE__ */ new Date()).toISOString()} ${line}
|
|
135646
|
-
`);
|
|
135647
|
-
}
|
|
135648
135823
|
function rcObservingResolver(resolve2, tracker, hub) {
|
|
135649
135824
|
return async (request7) => {
|
|
135650
135825
|
const resolution = await resolve2(request7);
|
|
@@ -135655,13 +135830,13 @@ function rcObservingResolver(resolve2, tracker, hub) {
|
|
|
135655
135830
|
}
|
|
135656
135831
|
function realStatOwnExecutable(watchPath) {
|
|
135657
135832
|
return () => {
|
|
135658
|
-
const st2 =
|
|
135833
|
+
const st2 = import_node_fs21.default.statSync(watchPath, { throwIfNoEntry: false });
|
|
135659
135834
|
return st2?.isFile() !== true ? void 0 : { dev: st2.dev, ino: st2.ino, size: st2.size, mtimeMs: st2.mtimeMs };
|
|
135660
135835
|
};
|
|
135661
135836
|
}
|
|
135662
|
-
function realFrontDoorSupervisorPorts(paths, respawnGeneration) {
|
|
135837
|
+
function realFrontDoorSupervisorPorts(paths, respawnGeneration, retire, trackTunnels) {
|
|
135663
135838
|
const log = (line) => {
|
|
135664
|
-
|
|
135839
|
+
appendDoorLog(paths, `frontdoor ${String(process.pid)}: ${line}`);
|
|
135665
135840
|
};
|
|
135666
135841
|
let directPort = 0;
|
|
135667
135842
|
const rcSelfHost = rcSelfHostFromEnv(process.env);
|
|
@@ -135714,7 +135889,7 @@ function realFrontDoorSupervisorPorts(paths, respawnGeneration) {
|
|
|
135714
135889
|
});
|
|
135715
135890
|
},
|
|
135716
135891
|
log: (line) => {
|
|
135717
|
-
|
|
135892
|
+
appendDoorLog(paths, `frontdoor ${String(process.pid)}: ${line}`);
|
|
135718
135893
|
}
|
|
135719
135894
|
});
|
|
135720
135895
|
const observations = createTargetObservationStore(realFarmFs, paths);
|
|
@@ -135766,7 +135941,13 @@ function realFrontDoorSupervisorPorts(paths, respawnGeneration) {
|
|
|
135766
135941
|
});
|
|
135767
135942
|
const quotaRefresher = createRealQuotaRefresher({ paths, store: usageStore, log });
|
|
135768
135943
|
const anthropicRefresher = createRealAnthropicUsageRefresher({ paths, store: usageStore, cwd: process.cwd(), spawnDaemon: spawnDetachedSupervisor, log });
|
|
135769
|
-
|
|
135944
|
+
const keeperTimers = [];
|
|
135945
|
+
const everyFreshnessInterval = (tick) => {
|
|
135946
|
+
const timer = setInterval(tick, ANTHROPIC_USAGE_FRESHNESS_MS);
|
|
135947
|
+
timer.unref();
|
|
135948
|
+
keeperTimers.push(timer);
|
|
135949
|
+
};
|
|
135950
|
+
everyFreshnessInterval(() => {
|
|
135770
135951
|
try {
|
|
135771
135952
|
const pools = readPools(paths);
|
|
135772
135953
|
refreshStalePoolMembers({ poolNames: Object.keys(pools), pools, loadMembers: (identities) => loadPoolMembers(realFarmFs, paths, identities, Date.now()), refresher: anthropicRefresher }).catch((error63) => {
|
|
@@ -135775,12 +135956,12 @@ function realFrontDoorSupervisorPorts(paths, respawnGeneration) {
|
|
|
135775
135956
|
} catch (error63) {
|
|
135776
135957
|
log(`pool usage refresh failed: ${error63 instanceof Error ? error63.message : String(error63)}`);
|
|
135777
135958
|
}
|
|
135778
|
-
}
|
|
135959
|
+
});
|
|
135779
135960
|
const windowOpener = async (identity) => {
|
|
135780
135961
|
await runChild({ paths, args: ["__open-window", identity], timeoutMs: WINDOW_OPEN_TIMEOUT_MS });
|
|
135781
135962
|
};
|
|
135782
135963
|
let keeperRunning = false;
|
|
135783
|
-
|
|
135964
|
+
everyFreshnessInterval(() => {
|
|
135784
135965
|
if (keeperRunning) {
|
|
135785
135966
|
return;
|
|
135786
135967
|
}
|
|
@@ -135799,12 +135980,12 @@ function realFrontDoorSupervisorPorts(paths, respawnGeneration) {
|
|
|
135799
135980
|
}).finally(() => {
|
|
135800
135981
|
keeperRunning = false;
|
|
135801
135982
|
});
|
|
135802
|
-
}
|
|
135983
|
+
});
|
|
135803
135984
|
const jobRunner = async (name, identity, job) => {
|
|
135804
135985
|
await runChild({ paths, args: ["__run-job", name, identity], timeoutMs: parseDuration(job.timeout) });
|
|
135805
135986
|
};
|
|
135806
135987
|
const runningJobs = /* @__PURE__ */ new Set();
|
|
135807
|
-
|
|
135988
|
+
everyFreshnessInterval(() => {
|
|
135808
135989
|
try {
|
|
135809
135990
|
runJobs({
|
|
135810
135991
|
fs: realFarmFs,
|
|
@@ -135821,7 +136002,7 @@ function realFrontDoorSupervisorPorts(paths, respawnGeneration) {
|
|
|
135821
136002
|
} catch (error63) {
|
|
135822
136003
|
log(`job keeper failed: ${error63 instanceof Error ? error63.message : String(error63)}`);
|
|
135823
136004
|
}
|
|
135824
|
-
}
|
|
136005
|
+
});
|
|
135825
136006
|
const catalogueKeeper = createCatalogueKeeper({
|
|
135826
136007
|
providers: () => listProviders(paths, (name, message) => {
|
|
135827
136008
|
log(`catalogue keeper skipped provider ${name}: ${message}`);
|
|
@@ -135834,7 +136015,7 @@ function realFrontDoorSupervisorPorts(paths, respawnGeneration) {
|
|
|
135834
136015
|
log
|
|
135835
136016
|
});
|
|
135836
136017
|
catalogueKeeper.tick();
|
|
135837
|
-
|
|
136018
|
+
everyFreshnessInterval(catalogueKeeper.tick);
|
|
135838
136019
|
const headroomDecision = createHeadroomDecision(createRoutingSettingReader(paths));
|
|
135839
136020
|
const targetObservations = createTargetObservationStore(realFarmFs, paths);
|
|
135840
136021
|
const recordUsage = (record2) => {
|
|
@@ -135880,7 +136061,7 @@ function realFrontDoorSupervisorPorts(paths, respawnGeneration) {
|
|
|
135880
136061
|
log
|
|
135881
136062
|
});
|
|
135882
136063
|
const onListenerError = (name) => (error63) => {
|
|
135883
|
-
|
|
136064
|
+
appendDoorLog(paths, `frontdoor ${String(process.pid)}: ${name} listener failed: ${error63.message}; exiting`);
|
|
135884
136065
|
process.exit(1);
|
|
135885
136066
|
};
|
|
135886
136067
|
return {
|
|
@@ -135895,7 +136076,7 @@ function realFrontDoorSupervisorPorts(paths, respawnGeneration) {
|
|
|
135895
136076
|
},
|
|
135896
136077
|
isRunning: realIsProcessRunning,
|
|
135897
136078
|
// The turnover check's file identity, over the installed entry resolved once at door start: re-resolving per tick would re-run the PATH scan every second and could theoretically flip between two files, while the entry itself is fixed for as long as this door lives. The existence check prefers the agent-shim sibling only when it is really there (see watchedInstallEntry).
|
|
135898
|
-
statOwnExecutable: realStatOwnExecutable(watchedInstallEntry(realOwnExecutablePath(), (candidate) =>
|
|
136079
|
+
statOwnExecutable: realStatOwnExecutable(watchedInstallEntry(realOwnExecutablePath(), (candidate) => import_node_fs21.default.existsSync(candidate))),
|
|
135899
136080
|
startProviderListener: async (preferredPort) => {
|
|
135900
136081
|
const authority = loadCa();
|
|
135901
136082
|
const rcDial = rcSelfHost ? lateRcEventDial(rcSelfHostDialTarget) : realRcEventDial();
|
|
@@ -135995,7 +136176,9 @@ function realFrontDoorSupervisorPorts(paths, respawnGeneration) {
|
|
|
135995
136176
|
close: async () => {
|
|
135996
136177
|
realFarmFs.removeRecursive(paths.frontdoorControlTokenFile);
|
|
135997
136178
|
await handle.close();
|
|
135998
|
-
}
|
|
136179
|
+
},
|
|
136180
|
+
// The control token is left in place: a successor writes its own over it as it starts, and this door no longer serves the routes that check it.
|
|
136181
|
+
drain: handle.drain
|
|
135999
136182
|
};
|
|
136000
136183
|
},
|
|
136001
136184
|
startConnectListener: async (preferredPort) => {
|
|
@@ -136051,11 +136234,19 @@ function realFrontDoorSupervisorPorts(paths, respawnGeneration) {
|
|
|
136051
136234
|
preferredPort
|
|
136052
136235
|
);
|
|
136053
136236
|
transparentPort = server.transparentPort;
|
|
136237
|
+
trackTunnels(server.openTunnels);
|
|
136054
136238
|
return {
|
|
136055
136239
|
port: server.port,
|
|
136056
136240
|
close: async () => {
|
|
136057
136241
|
rcSelfHostSurface?.close();
|
|
136058
136242
|
await server.close();
|
|
136243
|
+
},
|
|
136244
|
+
drain: async () => {
|
|
136245
|
+
if (transparentCapability !== void 0) {
|
|
136246
|
+
removeFrontDoorSession(realFarmFs, paths.frontdoorSessionsDir, process.pid);
|
|
136247
|
+
}
|
|
136248
|
+
await server.drain();
|
|
136249
|
+
rcSelfHostSurface?.close();
|
|
136059
136250
|
}
|
|
136060
136251
|
};
|
|
136061
136252
|
},
|
|
@@ -136070,7 +136261,7 @@ function realFrontDoorSupervisorPorts(paths, respawnGeneration) {
|
|
|
136070
136261
|
},
|
|
136071
136262
|
onError: onListenerError("direct")
|
|
136072
136263
|
});
|
|
136073
|
-
return { port: handle.port, close: handle.close };
|
|
136264
|
+
return { port: handle.port, close: handle.close, drain: handle.drain };
|
|
136074
136265
|
},
|
|
136075
136266
|
closeRcStreamHub: rcHub.close,
|
|
136076
136267
|
startWatchdog: () => startThreadWatchdog({
|
|
@@ -136089,9 +136280,15 @@ function realFrontDoorSupervisorPorts(paths, respawnGeneration) {
|
|
|
136089
136280
|
// The launch lifecycle publisher over the same backbone the typed API serves: the tick's registry facts go in here, and the door's own register, prune and end moments come out as source-tagged events.
|
|
136090
136281
|
observeLaunchRegistry: createLaunchEventPublisher(doorEvents, () => Date.now()).observe,
|
|
136091
136282
|
doorHealth,
|
|
136283
|
+
retire,
|
|
136284
|
+
stopBackgroundWork: () => {
|
|
136285
|
+
for (const timer of keeperTimers) {
|
|
136286
|
+
clearInterval(timer);
|
|
136287
|
+
}
|
|
136288
|
+
},
|
|
136092
136289
|
checkQuotaExpiry: quotaExpiring.check,
|
|
136093
136290
|
log: (line) => {
|
|
136094
|
-
|
|
136291
|
+
appendDoorLog(paths, line);
|
|
136095
136292
|
}
|
|
136096
136293
|
};
|
|
136097
136294
|
}
|
|
@@ -136116,9 +136313,9 @@ function registerFrontDoorCommand(program2, deps) {
|
|
|
136116
136313
|
);
|
|
136117
136314
|
withExamples(
|
|
136118
136315
|
frontdoor.command("restart").description(
|
|
136119
|
-
"Replace the serving front door with one started from the installed binary, in place: it binds the same ports, so running sessions reach it on their next request.
|
|
136316
|
+
"Replace the serving front door with one started from the installed binary, in place: it binds the same ports, so running sessions reach it on their next request. The old door releases its addresses and keeps carrying the tunnels and responses already open until they end; the sessions it terminates reconnect to the new one. Does nothing when no door is serving."
|
|
136120
136317
|
).option("--json", "Print the result as JSON.").action((options) => {
|
|
136121
|
-
const result = realRestartFrontDoor(paths, spawnDetachedSupervisor);
|
|
136318
|
+
const result = realRestartFrontDoor(paths, spawnDetachedSupervisor, "restart-command");
|
|
136122
136319
|
if (options.json === true) {
|
|
136123
136320
|
printJson(result);
|
|
136124
136321
|
return;
|
|
@@ -136134,17 +136331,29 @@ function registerFrontDoorCommand(program2, deps) {
|
|
|
136134
136331
|
const respawnGeneration = readRespawnGeneration();
|
|
136135
136332
|
Reflect.deleteProperty(process.env, DOOR_AWAIT_PID_ENV);
|
|
136136
136333
|
Reflect.deleteProperty(process.env, DOOR_RESPAWN_GENERATION_ENV);
|
|
136137
|
-
const
|
|
136334
|
+
const retire = new AbortController();
|
|
136335
|
+
let openTunnels = () => 0;
|
|
136336
|
+
const supervisorPorts = realFrontDoorSupervisorPorts(paths, respawnGeneration, retire.signal, (count) => {
|
|
136337
|
+
openTunnels = count;
|
|
136338
|
+
});
|
|
136138
136339
|
const ownPid = process.pid;
|
|
136139
136340
|
process.on("exit", (code) => {
|
|
136140
136341
|
supervisorPorts.log(`frontdoor ${String(ownPid)}: exiting with code ${String(code)}`);
|
|
136141
136342
|
});
|
|
136142
|
-
|
|
136143
|
-
|
|
136144
|
-
|
|
136145
|
-
|
|
136146
|
-
|
|
136147
|
-
|
|
136343
|
+
retireOnSignals(process, {
|
|
136344
|
+
doorPid: ownPid,
|
|
136345
|
+
log: supervisorPorts.log,
|
|
136346
|
+
retire: () => {
|
|
136347
|
+
retire.abort();
|
|
136348
|
+
},
|
|
136349
|
+
exit: deps.exit,
|
|
136350
|
+
facts: () => ({
|
|
136351
|
+
tunnels: openTunnels(),
|
|
136352
|
+
liveSessions: listFrontDoorSessions(realFarmFs, paths.frontdoorSessionsDir).filter((session) => session.pid !== ownPid && realIsProcessRunning(session.pid)).length,
|
|
136353
|
+
protocol: FRONT_DOOR_PROTOCOL,
|
|
136354
|
+
uptimeSeconds: Math.round(process.uptime())
|
|
136355
|
+
})
|
|
136356
|
+
});
|
|
136148
136357
|
if (Number.isInteger(awaited) && awaited > 0) {
|
|
136149
136358
|
const waitedMs = await awaitPidExit(awaited, supervisorPorts);
|
|
136150
136359
|
supervisorPorts.log(`frontdoor ${String(ownPid)}: stalled door ${String(awaited)} released the sticky ports after ${String(waitedMs)}ms`);
|
|
@@ -136170,8 +136379,8 @@ function isAntigravityPayload(payload) {
|
|
|
136170
136379
|
return typeof payload === "object" && payload !== null && "product" in payload && payload.product === "antigravity";
|
|
136171
136380
|
}
|
|
136172
136381
|
var ANTIGRAVITY_SETTINGS_SEGMENTS = [".gemini", "antigravity-cli", "settings.json"];
|
|
136173
|
-
function antigravityStacksWithDefault(
|
|
136174
|
-
const raw =
|
|
136382
|
+
function antigravityStacksWithDefault(fs29, homeDir) {
|
|
136383
|
+
const raw = fs29.readFileUtf8(import_node_path55.default.join(homeDir, ...ANTIGRAVITY_SETTINGS_SEGMENTS));
|
|
136175
136384
|
if (raw === void 0) {
|
|
136176
136385
|
return false;
|
|
136177
136386
|
}
|
|
@@ -146705,7 +146914,7 @@ async function serveMcp(mcp, transport, options = {}) {
|
|
|
146705
146914
|
}
|
|
146706
146915
|
|
|
146707
146916
|
// src/mcp/permissions.ts
|
|
146708
|
-
var
|
|
146917
|
+
var import_node_fs22 = __toESM(require("node:fs"), 1);
|
|
146709
146918
|
var import_node_path57 = __toESM(require("node:path"), 1);
|
|
146710
146919
|
init_zod();
|
|
146711
146920
|
init_store();
|
|
@@ -146722,15 +146931,15 @@ function readStoredMcpPermissions(paths) {
|
|
|
146722
146931
|
}
|
|
146723
146932
|
function writeStoredMcpPermissions(paths, permissions) {
|
|
146724
146933
|
writeJsonAtomic(paths.mcpPermissionsFile, { writes: permissions.writes, remoteControl: permissions.remoteControl, history: permissions.history });
|
|
146725
|
-
|
|
146934
|
+
import_node_fs22.default.chmodSync(paths.mcpPermissionsFile, OWNER_ONLY_MODE);
|
|
146726
146935
|
}
|
|
146727
146936
|
function effectiveMcpPermissions(flags, stored) {
|
|
146728
146937
|
return { writes: flags.writes || stored.writes, remoteControl: flags.remoteControl || stored.remoteControl, history: flags.history || stored.history };
|
|
146729
146938
|
}
|
|
146730
146939
|
function watchMcpPermissions(paths, onChange) {
|
|
146731
146940
|
const directory = import_node_path57.default.dirname(paths.mcpPermissionsFile);
|
|
146732
|
-
|
|
146733
|
-
const watcher =
|
|
146941
|
+
import_node_fs22.default.mkdirSync(directory, { recursive: true });
|
|
146942
|
+
const watcher = import_node_fs22.default.watch(directory, (_event, filename) => {
|
|
146734
146943
|
if (filename === null || filename === import_node_path57.default.basename(paths.mcpPermissionsFile)) {
|
|
146735
146944
|
onChange();
|
|
146736
146945
|
}
|
|
@@ -147044,7 +147253,7 @@ init_credential();
|
|
|
147044
147253
|
init_credentialCache();
|
|
147045
147254
|
|
|
147046
147255
|
// src/identityToken.ts
|
|
147047
|
-
var
|
|
147256
|
+
var import_node_fs23 = __toESM(require("node:fs"), 1);
|
|
147048
147257
|
var import_node_path58 = __toESM(require("node:path"), 1);
|
|
147049
147258
|
init_cliError();
|
|
147050
147259
|
var TOKEN_FILE_MODE = 384;
|
|
@@ -147062,13 +147271,13 @@ function storeIdentityToken(paths, identityName, raw) {
|
|
|
147062
147271
|
throw new UsageError("That is not a claude setup-token token (expected it to start with sk-ant-oat). Run `claude setup-token` and pass its token on standard input.");
|
|
147063
147272
|
}
|
|
147064
147273
|
const dir = identityTokenDir(paths);
|
|
147065
|
-
|
|
147066
|
-
|
|
147274
|
+
import_node_fs23.default.mkdirSync(dir, { recursive: true, mode: TOKEN_DIR_MODE });
|
|
147275
|
+
import_node_fs23.default.chmodSync(dir, TOKEN_DIR_MODE);
|
|
147067
147276
|
const target = identityTokenPath(paths, identityName);
|
|
147068
147277
|
const temp = import_node_path58.default.join(dir, `.${identityName}.${String(process.pid)}.tmp`);
|
|
147069
|
-
|
|
147278
|
+
import_node_fs23.default.writeFileSync(temp, `${token}
|
|
147070
147279
|
`, { mode: TOKEN_FILE_MODE });
|
|
147071
|
-
|
|
147280
|
+
import_node_fs23.default.renameSync(temp, target);
|
|
147072
147281
|
return target;
|
|
147073
147282
|
}
|
|
147074
147283
|
|
|
@@ -147234,7 +147443,7 @@ function registerDoctorCommand(program2, deps) {
|
|
|
147234
147443
|
}
|
|
147235
147444
|
|
|
147236
147445
|
// src/headroom/commands.ts
|
|
147237
|
-
var
|
|
147446
|
+
var import_node_fs24 = __toESM(require("node:fs"), 1);
|
|
147238
147447
|
var import_node_http5 = __toESM(require("node:http"), 1);
|
|
147239
147448
|
var import_node_path59 = __toESM(require("node:path"), 1);
|
|
147240
147449
|
var import_node_child_process9 = require("node:child_process");
|
|
@@ -147459,12 +147668,12 @@ function realSupervisorPorts(paths) {
|
|
|
147459
147668
|
readConfig: () => resolveSupervisorConfig(readGlobalConfig(paths)?.headroom ?? {}),
|
|
147460
147669
|
spawnHeadroom: (socketPath, allowlistFile, settings2) => {
|
|
147461
147670
|
const trust = resolveHeadroomTrustBundle({ caCertFile: paths.frontdoorCaCertFile, bundlesDir: paths.frontdoorCaBundlesDir, inherited: process.env[HEADROOM_CA_BUNDLE], fs: realTrustBundleFs });
|
|
147462
|
-
|
|
147671
|
+
import_node_fs24.default.mkdirSync(paths.logsDir, { recursive: true });
|
|
147463
147672
|
if (trust?.warning !== void 0) {
|
|
147464
|
-
|
|
147673
|
+
import_node_fs24.default.appendFileSync(paths.headroomLogPath, `${(/* @__PURE__ */ new Date()).toISOString()} ${trust.warning}
|
|
147465
147674
|
`);
|
|
147466
147675
|
}
|
|
147467
|
-
const logFd =
|
|
147676
|
+
const logFd = import_node_fs24.default.openSync(paths.headroomLogPath, "a");
|
|
147468
147677
|
try {
|
|
147469
147678
|
const child = (0, import_node_child_process9.spawn)("headroom", headroomProxyArgs(socketPath, allowlistFile, settings2), {
|
|
147470
147679
|
detached: true,
|
|
@@ -147479,12 +147688,12 @@ function realSupervisorPorts(paths) {
|
|
|
147479
147688
|
child.once("exit", (code, signal) => {
|
|
147480
147689
|
ownedHeadroom.delete(pid);
|
|
147481
147690
|
exitedHeadroom.add(pid);
|
|
147482
|
-
|
|
147691
|
+
import_node_fs24.default.appendFileSync(paths.headroomLogPath, `${(/* @__PURE__ */ new Date()).toISOString()} agent-shim headroom supervisor: headroom exited (${signal ?? `code ${String(code)}`})
|
|
147483
147692
|
`);
|
|
147484
147693
|
});
|
|
147485
147694
|
return pid;
|
|
147486
147695
|
} finally {
|
|
147487
|
-
|
|
147696
|
+
import_node_fs24.default.closeSync(logFd);
|
|
147488
147697
|
}
|
|
147489
147698
|
},
|
|
147490
147699
|
stopProcess: (pid) => {
|
|
@@ -147497,7 +147706,7 @@ function realSupervisorPorts(paths) {
|
|
|
147497
147706
|
now: () => Date.now()
|
|
147498
147707
|
});
|
|
147499
147708
|
if (outcome === "still-running") {
|
|
147500
|
-
|
|
147709
|
+
import_node_fs24.default.appendFileSync(
|
|
147501
147710
|
paths.headroomLogPath,
|
|
147502
147711
|
`${(/* @__PURE__ */ new Date()).toISOString()} agent-shim headroom supervisor: pid ${String(pid)} survived SIGKILL within its grace; it is stuck uninterruptibly
|
|
147503
147712
|
`
|
|
@@ -147515,10 +147724,10 @@ function realSupervisorPorts(paths) {
|
|
|
147515
147724
|
};
|
|
147516
147725
|
}
|
|
147517
147726
|
if (result.stdout !== "") {
|
|
147518
|
-
|
|
147727
|
+
import_node_fs24.default.appendFileSync(paths.headroomLogPath, result.stdout);
|
|
147519
147728
|
}
|
|
147520
147729
|
if (result.stderr !== "") {
|
|
147521
|
-
|
|
147730
|
+
import_node_fs24.default.appendFileSync(paths.headroomLogPath, result.stderr);
|
|
147522
147731
|
}
|
|
147523
147732
|
return result.status === 0 ? { ok: true } : { ok: false, error: `uv tool install exited ${String(result.status)}` };
|
|
147524
147733
|
},
|
|
@@ -147528,8 +147737,8 @@ function realSupervisorPorts(paths) {
|
|
|
147528
147737
|
},
|
|
147529
147738
|
installedCommit: readInstalledHeadroomCommit,
|
|
147530
147739
|
log: (line) => {
|
|
147531
|
-
|
|
147532
|
-
|
|
147740
|
+
import_node_fs24.default.mkdirSync(paths.logsDir, { recursive: true });
|
|
147741
|
+
import_node_fs24.default.appendFileSync(paths.headroomLogPath, `${(/* @__PURE__ */ new Date()).toISOString()} ${line}
|
|
147533
147742
|
`);
|
|
147534
147743
|
}
|
|
147535
147744
|
};
|
|
@@ -148036,12 +148245,12 @@ init_translate();
|
|
|
148036
148245
|
init_schema();
|
|
148037
148246
|
init_cliError();
|
|
148038
148247
|
init_providerCatalogue();
|
|
148039
|
-
var
|
|
148248
|
+
var import_node_fs26 = __toESM(require("node:fs"), 1);
|
|
148040
148249
|
init_credential();
|
|
148041
148250
|
init_providerAliases();
|
|
148042
148251
|
|
|
148043
148252
|
// src/providerRename.ts
|
|
148044
|
-
var
|
|
148253
|
+
var import_node_fs25 = __toESM(require("node:fs"), 1);
|
|
148045
148254
|
var import_node_path62 = __toESM(require("node:path"), 1);
|
|
148046
148255
|
init_schema();
|
|
148047
148256
|
init_store();
|
|
@@ -148107,7 +148316,7 @@ function renameProvider(paths, from, to2, ports) {
|
|
|
148107
148316
|
const previousAliases = readProviderAliases(paths);
|
|
148108
148317
|
writeProviderAliases(paths, aliasesAfterRename(previousAliases, from, to2));
|
|
148109
148318
|
try {
|
|
148110
|
-
|
|
148319
|
+
import_node_fs25.default.renameSync(providerJsonPath(paths, from), providerJsonPath(paths, to2));
|
|
148111
148320
|
} catch (error63) {
|
|
148112
148321
|
writeProviderAliases(paths, previousAliases);
|
|
148113
148322
|
throw error63;
|
|
@@ -148127,8 +148336,8 @@ function moveState(paths, from, to2, ports) {
|
|
|
148127
148336
|
`);
|
|
148128
148337
|
moved.push(`usage ${snapshot.identity}`);
|
|
148129
148338
|
}
|
|
148130
|
-
if (
|
|
148131
|
-
|
|
148339
|
+
if (import_node_fs25.default.existsSync(catalogueCachePath(paths, from))) {
|
|
148340
|
+
import_node_fs25.default.renameSync(catalogueCachePath(paths, from), catalogueCachePath(paths, to2));
|
|
148132
148341
|
moved.push("catalogue");
|
|
148133
148342
|
}
|
|
148134
148343
|
const renamed = readProvider(paths, to2);
|
|
@@ -148459,7 +148668,7 @@ function registerProviderCommand(program2, deps) {
|
|
|
148459
148668
|
throw new UsageError(`Provider "${name}" has no catalogue setting. Set one with \`agent-shim provider set ${name} --catalogue-tier <tier>\`.`);
|
|
148460
148669
|
}
|
|
148461
148670
|
const catalogueSetting = found.catalogue;
|
|
148462
|
-
const cache = options.refresh === true ? await refreshCatalogueForReal(paths, name, process.env) : parseCatalogueCache(
|
|
148671
|
+
const cache = options.refresh === true ? await refreshCatalogueForReal(paths, name, process.env) : parseCatalogueCache(import_node_fs26.default.existsSync(catalogueCachePath(paths, name)) ? import_node_fs26.default.readFileSync(catalogueCachePath(paths, name), "utf8") : void 0);
|
|
148463
148672
|
if (cache === void 0) {
|
|
148464
148673
|
throw new UsageError(`No catalogue has been fetched for "${name}" yet: the front door fetches it shortly after it starts, or run \`agent-shim provider models ${name} --refresh\`.`);
|
|
148465
148674
|
}
|
|
@@ -149003,14 +149212,14 @@ function requireIdentity(paths, name) {
|
|
|
149003
149212
|
throw new IdentityNotFoundError(name);
|
|
149004
149213
|
}
|
|
149005
149214
|
}
|
|
149006
|
-
function collectUsageReport(
|
|
149215
|
+
function collectUsageReport(fs29, paths, filters) {
|
|
149007
149216
|
const { identity, provider, sinceMs } = filters;
|
|
149008
149217
|
if (identity !== void 0) {
|
|
149009
149218
|
requireIdentity(paths, identity);
|
|
149010
149219
|
}
|
|
149011
|
-
const log = readUsageLog(
|
|
149220
|
+
const log = readUsageLog(fs29, paths.usageLogDir, sinceMs === void 0 ? {} : { sinceMs });
|
|
149012
149221
|
const records = log.records.filter((record2) => (identity === void 0 || record2.identity === identity) && (provider === void 0 || record2.provider === provider));
|
|
149013
|
-
const snapshots = (identity === void 0 ? listUsageSnapshots(
|
|
149222
|
+
const snapshots = (identity === void 0 ? listUsageSnapshots(fs29, paths.usageSnapshotsDir) : [readUsageSnapshot(fs29, paths.usageSnapshotsDir, identity)].flatMap((snapshot) => snapshot === void 0 ? [] : [snapshot])).map((snapshot) => provider === void 0 ? snapshot : { ...snapshot, providers: Object.fromEntries(Object.entries(snapshot.providers).filter(([name]) => name === provider)) }).filter((snapshot) => Object.keys(snapshot.providers).length > 0);
|
|
149014
149223
|
return {
|
|
149015
149224
|
since: sinceMs === void 0 ? void 0 : new Date(sinceMs).toISOString(),
|
|
149016
149225
|
logDir: paths.usageLogDir,
|
|
@@ -149117,16 +149326,16 @@ function formatUsageReport(report) {
|
|
|
149117
149326
|
}
|
|
149118
149327
|
return lines;
|
|
149119
149328
|
}
|
|
149120
|
-
function collectAccounts(
|
|
149329
|
+
function collectAccounts(fs29, paths, identity, probe) {
|
|
149121
149330
|
if (identity !== void 0) {
|
|
149122
149331
|
requireIdentity(paths, identity);
|
|
149123
149332
|
}
|
|
149124
149333
|
const names = identity === void 0 ? listIdentities(paths).map((entry) => entry.name) : [identity];
|
|
149125
149334
|
return names.map((name) => ({
|
|
149126
149335
|
identity: name,
|
|
149127
|
-
account: readAccountMetadata(
|
|
149128
|
-
signIn: identitySignIn(
|
|
149129
|
-
usage: readUsageSnapshot(
|
|
149336
|
+
account: readAccountMetadata(fs29, paths.identitiesDir, name),
|
|
149337
|
+
signIn: identitySignIn(fs29, probe, { farmRoot: import_node_path63.default.join(paths.identitiesDir, name), hasCredentialBlock: readIdentity(paths, name)?.credential !== void 0 }),
|
|
149338
|
+
usage: readUsageSnapshot(fs29, paths.usageSnapshotsDir, name)
|
|
149130
149339
|
}));
|
|
149131
149340
|
}
|
|
149132
149341
|
function formatAccounts(views) {
|
|
@@ -149476,15 +149685,15 @@ function createRealCompactor(params) {
|
|
|
149476
149685
|
// src/supervise/compactionDeps.ts
|
|
149477
149686
|
var COMPACT_SLOT_STALE_MS = COMPACT_TIMEOUT_MS * 2;
|
|
149478
149687
|
function createCompactionDeps(wiring) {
|
|
149479
|
-
const { paths, fs:
|
|
149688
|
+
const { paths, fs: fs29, pool } = wiring;
|
|
149480
149689
|
return {
|
|
149481
149690
|
shouldCompact: (identity, sessionId) => {
|
|
149482
149691
|
const nowMs = wiring.now();
|
|
149483
|
-
const sessions = liveSupervised(
|
|
149692
|
+
const sessions = liveSupervised(fs29, paths, pool, wiring.isRunning).filter((session) => session.identity === identity).map((session) => ({ sessionId: session.sessionId, state: readSessionState(fs29, paths, pool, session.sessionId) }));
|
|
149484
149693
|
return decideCompaction({
|
|
149485
149694
|
atUtilisation: wiring.policy.compactAtUtilisation,
|
|
149486
|
-
snapshot: readUsageSnapshot(
|
|
149487
|
-
records: () => readUsageLog(
|
|
149695
|
+
snapshot: readUsageSnapshot(fs29, paths.usageSnapshotsDir, identity),
|
|
149696
|
+
records: () => readUsageLog(fs29, paths.usageLogDir, { sinceMs: nowMs - FIVE_HOUR_WINDOW_MS }).records.filter((record2) => record2.identity === identity),
|
|
149488
149697
|
sessions,
|
|
149489
149698
|
sessionId,
|
|
149490
149699
|
nowMs
|
|
@@ -149492,7 +149701,7 @@ function createCompactionDeps(wiring) {
|
|
|
149492
149701
|
},
|
|
149493
149702
|
acquire: (identity) => {
|
|
149494
149703
|
try {
|
|
149495
|
-
const lock = acquireIdentityLock({ identity: `compact-${identity}`, dir: superviseDirOf(paths, pool), fs:
|
|
149704
|
+
const lock = acquireIdentityLock({ identity: `compact-${identity}`, dir: superviseDirOf(paths, pool), fs: fs29, nowMs: wiring.now, pid: wiring.pid, isRunning: wiring.isRunning, sleep: wiring.sleep, maxAttempts: 1, staleAfterMs: COMPACT_SLOT_STALE_MS });
|
|
149496
149705
|
return { release: lock.release };
|
|
149497
149706
|
} catch (error63) {
|
|
149498
149707
|
if (error63 instanceof IdentityLockBusyError) {
|
|
@@ -149503,8 +149712,8 @@ function createCompactionDeps(wiring) {
|
|
|
149503
149712
|
},
|
|
149504
149713
|
compact: wiring.compact,
|
|
149505
149714
|
markCompacted: (sessionId, compacted) => {
|
|
149506
|
-
const previous = readSessionState(
|
|
149507
|
-
writeSessionState(
|
|
149715
|
+
const previous = readSessionState(fs29, paths, pool, sessionId);
|
|
149716
|
+
writeSessionState(fs29, paths, pool, sessionId, {
|
|
149508
149717
|
mark: previous?.mark ?? "idle",
|
|
149509
149718
|
...previous?.contextTokens === void 0 ? {} : { contextTokens: previous.contextTokens },
|
|
149510
149719
|
...compacted ? { compacted: true } : {},
|
|
@@ -149516,12 +149725,12 @@ function createCompactionDeps(wiring) {
|
|
|
149516
149725
|
|
|
149517
149726
|
// src/supervise/limit.ts
|
|
149518
149727
|
init_read();
|
|
149519
|
-
function quotaHitOf(
|
|
149520
|
-
const reason = refusalReason(identity, readUsageSnapshot(
|
|
149728
|
+
function quotaHitOf(fs29, paths, identity, sessionId, sinceMs, nowMs) {
|
|
149729
|
+
const reason = refusalReason(identity, readUsageSnapshot(fs29, paths.usageSnapshotsDir, identity), nowMs);
|
|
149521
149730
|
if (reason === void 0) {
|
|
149522
149731
|
return void 0;
|
|
149523
149732
|
}
|
|
149524
|
-
const { records } = readUsageLog(
|
|
149733
|
+
const { records } = readUsageLog(fs29, paths.usageLogDir, { sinceMs });
|
|
149525
149734
|
for (let index = records.length - 1; index >= 0; index -= 1) {
|
|
149526
149735
|
const record2 = records[index];
|
|
149527
149736
|
if (record2?.sessionId === sessionId && record2.identity === identity && record2.limit?.kind === "quota-exhausted") {
|
|
@@ -149641,7 +149850,7 @@ function createIdentityMover(deps) {
|
|
|
149641
149850
|
|
|
149642
149851
|
// src/supervise/realPorts.ts
|
|
149643
149852
|
var import_node_child_process10 = require("node:child_process");
|
|
149644
|
-
var
|
|
149853
|
+
var import_node_fs27 = __toESM(require("node:fs"), 1);
|
|
149645
149854
|
init_realPorts();
|
|
149646
149855
|
var realSupervisedSpawnPort = {
|
|
149647
149856
|
spawn(command, args, options) {
|
|
@@ -149687,7 +149896,7 @@ var realTimerPort = {
|
|
|
149687
149896
|
function realWatchDirectory(directory, accepts, what, log) {
|
|
149688
149897
|
return (onChange) => {
|
|
149689
149898
|
realFarmFs.mkdirPrivate(directory);
|
|
149690
|
-
const watcher =
|
|
149899
|
+
const watcher = import_node_fs27.default.watch(directory, { persistent: false }, (_event, filename) => {
|
|
149691
149900
|
if (filename === null || accepts(filename)) {
|
|
149692
149901
|
onChange();
|
|
149693
149902
|
}
|