agent-shim 11.66.1 → 11.66.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.cjs +80 -15
- package/dist/index.cjs +21 -15
- package/dist/index.mjs +21 -15
- package/dist/types/index.d.ts +866 -866
- package/package.json +1 -1
package/dist/cli.cjs
CHANGED
|
@@ -28806,6 +28806,22 @@ function daemonAdmits(fs31, allowlistFile, recordedHash, required2) {
|
|
|
28806
28806
|
const served = parseAllowlistFile(content);
|
|
28807
28807
|
return recordedHash === hashAllowlistFile(content) && required2.every((upstream) => served.includes(upstream));
|
|
28808
28808
|
}
|
|
28809
|
+
function startSupervisorUnderLock(params) {
|
|
28810
|
+
const { paths, ports } = params;
|
|
28811
|
+
ports.fs.mkdirp(paths.headroomDir);
|
|
28812
|
+
const created = ports.fs.writeFileExclusive(paths.headroomLockFile, `${JSON.stringify({ pid: params.holderPid, at: ports.now() })}
|
|
28813
|
+
`);
|
|
28814
|
+
if (created) {
|
|
28815
|
+
ports.spawnSupervisor(paths);
|
|
28816
|
+
return "spawned";
|
|
28817
|
+
}
|
|
28818
|
+
const lock = readStartLock(ports.fs, paths.headroomLockFile);
|
|
28819
|
+
if (lock === void 0 || !ports.isRunning(lock.pid)) {
|
|
28820
|
+
ports.fs.removeRecursive(paths.headroomLockFile);
|
|
28821
|
+
return "cleared-stale-lock";
|
|
28822
|
+
}
|
|
28823
|
+
return "held";
|
|
28824
|
+
}
|
|
28809
28825
|
function ensureHeadroom(params) {
|
|
28810
28826
|
const { paths, ports } = params;
|
|
28811
28827
|
let deadline = ports.now() + HEADROOM_START_TIMEOUT_MS;
|
|
@@ -28851,21 +28867,11 @@ function ensureHeadroom(params) {
|
|
|
28851
28867
|
);
|
|
28852
28868
|
}
|
|
28853
28869
|
} else if (!spawnedSupervisor) {
|
|
28854
|
-
|
|
28855
|
-
|
|
28856
|
-
paths.headroomLockFile,
|
|
28857
|
-
`${JSON.stringify({ pid: params.launcherPid, at: ports.now() })}
|
|
28858
|
-
`
|
|
28859
|
-
);
|
|
28860
|
-
if (created) {
|
|
28861
|
-
ports.spawnSupervisor(paths);
|
|
28870
|
+
const started = startSupervisorUnderLock({ paths, holderPid: params.launcherPid, ports });
|
|
28871
|
+
if (started === "spawned") {
|
|
28862
28872
|
spawnedSupervisor = true;
|
|
28863
|
-
} else {
|
|
28864
|
-
|
|
28865
|
-
if (lock === void 0 || !ports.isRunning(lock.pid)) {
|
|
28866
|
-
ports.fs.removeRecursive(paths.headroomLockFile);
|
|
28867
|
-
continue;
|
|
28868
|
-
}
|
|
28873
|
+
} else if (started === "cleared-stale-lock") {
|
|
28874
|
+
continue;
|
|
28869
28875
|
}
|
|
28870
28876
|
}
|
|
28871
28877
|
if (ports.now() >= deadline) {
|
|
@@ -37176,7 +37182,7 @@ var init_package = __esm({
|
|
|
37176
37182
|
"package.json"() {
|
|
37177
37183
|
package_default = {
|
|
37178
37184
|
name: "agent-shim",
|
|
37179
|
-
version: "11.66.
|
|
37185
|
+
version: "11.66.2",
|
|
37180
37186
|
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.",
|
|
37181
37187
|
license: "MIT",
|
|
37182
37188
|
author: "Joseph Mearman <joseph@mearman.co.uk>",
|
|
@@ -119239,6 +119245,50 @@ function showSession(fs31, identitiesDir, identities, query, onlyIdentity) {
|
|
|
119239
119245
|
// src/frontdoor/commands.ts
|
|
119240
119246
|
init_realPorts();
|
|
119241
119247
|
|
|
119248
|
+
// src/headroom/keeper.ts
|
|
119249
|
+
init_ensure();
|
|
119250
|
+
init_state2();
|
|
119251
|
+
function createHeadroomKeeper(deps) {
|
|
119252
|
+
const { paths, ports, log } = deps;
|
|
119253
|
+
let lastAttemptAt;
|
|
119254
|
+
const releaseOwnLock = () => {
|
|
119255
|
+
if (readStartLock(ports.fs, paths.headroomLockFile)?.pid === deps.ownPid) {
|
|
119256
|
+
ports.fs.removeRecursive(paths.headroomLockFile);
|
|
119257
|
+
}
|
|
119258
|
+
};
|
|
119259
|
+
const tick = () => {
|
|
119260
|
+
const state = resolveServingHeadroomState(ports.fs, { stateFile: paths.headroomStateFile, legacyStateFile: paths.headroomLegacyStateFile }, ports.isRunning)?.state;
|
|
119261
|
+
const supervisorPid = state?.supervisorPid;
|
|
119262
|
+
const orphans = listSessions(ports.fs, paths.headroomSessionsDir).filter((session) => ports.isRunning(session.pid) && !ports.isRunning(session.supervisorPid));
|
|
119263
|
+
if (supervisorPid !== void 0 && ports.isRunning(supervisorPid)) {
|
|
119264
|
+
lastAttemptAt = void 0;
|
|
119265
|
+
releaseOwnLock();
|
|
119266
|
+
for (const session of orphans) {
|
|
119267
|
+
writeSession(ports.fs, paths.headroomSessionsDir, { ...session, supervisorPid });
|
|
119268
|
+
}
|
|
119269
|
+
if (orphans.length > 0) {
|
|
119270
|
+
log(`front door: re-registered ${String(orphans.length)} launcher(s) against headroom supervisor ${String(supervisorPid)}`);
|
|
119271
|
+
}
|
|
119272
|
+
return { kind: "serving", rebound: orphans.map((session) => session.pid) };
|
|
119273
|
+
}
|
|
119274
|
+
if (orphans.length === 0) {
|
|
119275
|
+
return { kind: "idle" };
|
|
119276
|
+
}
|
|
119277
|
+
if (lastAttemptAt !== void 0 && ports.now() - lastAttemptAt < HEADROOM_START_TIMEOUT_MS) {
|
|
119278
|
+
return { kind: "backing-off", waiting: orphans.length };
|
|
119279
|
+
}
|
|
119280
|
+
releaseOwnLock();
|
|
119281
|
+
lastAttemptAt = ports.now();
|
|
119282
|
+
const start = startSupervisorUnderLock({ paths, holderPid: deps.ownPid, ports });
|
|
119283
|
+
log(`front door: headroom supervisor is not running and ${String(orphans.length)} launcher(s) are registered against it (${start})`);
|
|
119284
|
+
return { kind: "starting", start, waiting: orphans.length };
|
|
119285
|
+
};
|
|
119286
|
+
return { tick };
|
|
119287
|
+
}
|
|
119288
|
+
|
|
119289
|
+
// src/frontdoor/commands.ts
|
|
119290
|
+
init_supervisor();
|
|
119291
|
+
|
|
119242
119292
|
// src/supervise/registry.ts
|
|
119243
119293
|
var import_node_path36 = __toESM(require("node:path"), 1);
|
|
119244
119294
|
init_zod();
|
|
@@ -139424,6 +139474,21 @@ function realFrontDoorSupervisorPorts(paths, respawnGeneration, lifecycle, track
|
|
|
139424
139474
|
timer.unref();
|
|
139425
139475
|
keeperTimers.push(timer);
|
|
139426
139476
|
};
|
|
139477
|
+
const headroomKeeper = createHeadroomKeeper({
|
|
139478
|
+
paths,
|
|
139479
|
+
ownPid: process.pid,
|
|
139480
|
+
ports: { fs: realFarmFs, now: () => Date.now(), isRunning: realIsProcessRunning, spawnSupervisor: (layout) => spawnDetachedSupervisor(layout, "__headroom-supervisor", layout.headroomLogPath) },
|
|
139481
|
+
log
|
|
139482
|
+
});
|
|
139483
|
+
const headroomKeeperTimer = setInterval(() => {
|
|
139484
|
+
try {
|
|
139485
|
+
headroomKeeper.tick();
|
|
139486
|
+
} catch (error63) {
|
|
139487
|
+
log(`headroom keeper failed: ${error63 instanceof Error ? error63.message : String(error63)}`);
|
|
139488
|
+
}
|
|
139489
|
+
}, HEADROOM_POLL_MS);
|
|
139490
|
+
headroomKeeperTimer.unref();
|
|
139491
|
+
keeperTimers.push(headroomKeeperTimer);
|
|
139427
139492
|
everyFreshnessInterval(() => {
|
|
139428
139493
|
try {
|
|
139429
139494
|
const pools = readPools(paths);
|
package/dist/index.cjs
CHANGED
|
@@ -4751,7 +4751,7 @@ var init_package = __esm({
|
|
|
4751
4751
|
"package.json"() {
|
|
4752
4752
|
package_default = {
|
|
4753
4753
|
name: "agent-shim",
|
|
4754
|
-
version: "11.66.
|
|
4754
|
+
version: "11.66.2",
|
|
4755
4755
|
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.",
|
|
4756
4756
|
license: "MIT",
|
|
4757
4757
|
author: "Joseph Mearman <joseph@mearman.co.uk>",
|
|
@@ -5241,6 +5241,22 @@ function daemonAdmits(fs14, allowlistFile, recordedHash, required) {
|
|
|
5241
5241
|
const served = parseAllowlistFile(content);
|
|
5242
5242
|
return recordedHash === hashAllowlistFile(content) && required.every((upstream) => served.includes(upstream));
|
|
5243
5243
|
}
|
|
5244
|
+
function startSupervisorUnderLock(params) {
|
|
5245
|
+
const { paths, ports } = params;
|
|
5246
|
+
ports.fs.mkdirp(paths.headroomDir);
|
|
5247
|
+
const created = ports.fs.writeFileExclusive(paths.headroomLockFile, `${JSON.stringify({ pid: params.holderPid, at: ports.now() })}
|
|
5248
|
+
`);
|
|
5249
|
+
if (created) {
|
|
5250
|
+
ports.spawnSupervisor(paths);
|
|
5251
|
+
return "spawned";
|
|
5252
|
+
}
|
|
5253
|
+
const lock = readStartLock(ports.fs, paths.headroomLockFile);
|
|
5254
|
+
if (lock === void 0 || !ports.isRunning(lock.pid)) {
|
|
5255
|
+
ports.fs.removeRecursive(paths.headroomLockFile);
|
|
5256
|
+
return "cleared-stale-lock";
|
|
5257
|
+
}
|
|
5258
|
+
return "held";
|
|
5259
|
+
}
|
|
5244
5260
|
function ensureHeadroom(params) {
|
|
5245
5261
|
const { paths, ports } = params;
|
|
5246
5262
|
let deadline = ports.now() + HEADROOM_START_TIMEOUT_MS;
|
|
@@ -5286,21 +5302,11 @@ function ensureHeadroom(params) {
|
|
|
5286
5302
|
);
|
|
5287
5303
|
}
|
|
5288
5304
|
} else if (!spawnedSupervisor) {
|
|
5289
|
-
|
|
5290
|
-
|
|
5291
|
-
paths.headroomLockFile,
|
|
5292
|
-
`${JSON.stringify({ pid: params.launcherPid, at: ports.now() })}
|
|
5293
|
-
`
|
|
5294
|
-
);
|
|
5295
|
-
if (created) {
|
|
5296
|
-
ports.spawnSupervisor(paths);
|
|
5305
|
+
const started = startSupervisorUnderLock({ paths, holderPid: params.launcherPid, ports });
|
|
5306
|
+
if (started === "spawned") {
|
|
5297
5307
|
spawnedSupervisor = true;
|
|
5298
|
-
} else {
|
|
5299
|
-
|
|
5300
|
-
if (lock === void 0 || !ports.isRunning(lock.pid)) {
|
|
5301
|
-
ports.fs.removeRecursive(paths.headroomLockFile);
|
|
5302
|
-
continue;
|
|
5303
|
-
}
|
|
5308
|
+
} else if (started === "cleared-stale-lock") {
|
|
5309
|
+
continue;
|
|
5304
5310
|
}
|
|
5305
5311
|
}
|
|
5306
5312
|
if (ports.now() >= deadline) {
|
package/dist/index.mjs
CHANGED
|
@@ -4727,7 +4727,7 @@ var init_package = __esm({
|
|
|
4727
4727
|
"package.json"() {
|
|
4728
4728
|
package_default = {
|
|
4729
4729
|
name: "agent-shim",
|
|
4730
|
-
version: "11.66.
|
|
4730
|
+
version: "11.66.2",
|
|
4731
4731
|
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.",
|
|
4732
4732
|
license: "MIT",
|
|
4733
4733
|
author: "Joseph Mearman <joseph@mearman.co.uk>",
|
|
@@ -5218,6 +5218,22 @@ function daemonAdmits(fs14, allowlistFile, recordedHash, required) {
|
|
|
5218
5218
|
const served = parseAllowlistFile(content);
|
|
5219
5219
|
return recordedHash === hashAllowlistFile(content) && required.every((upstream) => served.includes(upstream));
|
|
5220
5220
|
}
|
|
5221
|
+
function startSupervisorUnderLock(params) {
|
|
5222
|
+
const { paths, ports } = params;
|
|
5223
|
+
ports.fs.mkdirp(paths.headroomDir);
|
|
5224
|
+
const created = ports.fs.writeFileExclusive(paths.headroomLockFile, `${JSON.stringify({ pid: params.holderPid, at: ports.now() })}
|
|
5225
|
+
`);
|
|
5226
|
+
if (created) {
|
|
5227
|
+
ports.spawnSupervisor(paths);
|
|
5228
|
+
return "spawned";
|
|
5229
|
+
}
|
|
5230
|
+
const lock = readStartLock(ports.fs, paths.headroomLockFile);
|
|
5231
|
+
if (lock === void 0 || !ports.isRunning(lock.pid)) {
|
|
5232
|
+
ports.fs.removeRecursive(paths.headroomLockFile);
|
|
5233
|
+
return "cleared-stale-lock";
|
|
5234
|
+
}
|
|
5235
|
+
return "held";
|
|
5236
|
+
}
|
|
5221
5237
|
function ensureHeadroom(params) {
|
|
5222
5238
|
const { paths, ports } = params;
|
|
5223
5239
|
let deadline = ports.now() + HEADROOM_START_TIMEOUT_MS;
|
|
@@ -5263,21 +5279,11 @@ function ensureHeadroom(params) {
|
|
|
5263
5279
|
);
|
|
5264
5280
|
}
|
|
5265
5281
|
} else if (!spawnedSupervisor) {
|
|
5266
|
-
|
|
5267
|
-
|
|
5268
|
-
paths.headroomLockFile,
|
|
5269
|
-
`${JSON.stringify({ pid: params.launcherPid, at: ports.now() })}
|
|
5270
|
-
`
|
|
5271
|
-
);
|
|
5272
|
-
if (created) {
|
|
5273
|
-
ports.spawnSupervisor(paths);
|
|
5282
|
+
const started = startSupervisorUnderLock({ paths, holderPid: params.launcherPid, ports });
|
|
5283
|
+
if (started === "spawned") {
|
|
5274
5284
|
spawnedSupervisor = true;
|
|
5275
|
-
} else {
|
|
5276
|
-
|
|
5277
|
-
if (lock === void 0 || !ports.isRunning(lock.pid)) {
|
|
5278
|
-
ports.fs.removeRecursive(paths.headroomLockFile);
|
|
5279
|
-
continue;
|
|
5280
|
-
}
|
|
5285
|
+
} else if (started === "cleared-stale-lock") {
|
|
5286
|
+
continue;
|
|
5281
5287
|
}
|
|
5282
5288
|
}
|
|
5283
5289
|
if (ports.now() >= deadline) {
|