agent-shim 10.0.0 → 10.0.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 +27 -12
- package/dist/index.cjs +17 -9
- package/dist/index.mjs +17 -9
- package/package.json +1 -1
package/dist/cli.cjs
CHANGED
|
@@ -27535,6 +27535,8 @@ var init_state2 = __esm({
|
|
|
27535
27535
|
settingsHash: external_exports.string().optional(),
|
|
27536
27536
|
/** The install spec the running install was last installed from, so a `source` config change is detected as drift. */
|
|
27537
27537
|
installedSource: external_exports.string().optional(),
|
|
27538
|
+
/** The install spec the supervisor is installing right now, present only while `uv tool install` runs, so a launcher that finds a live supervisor with no daemon yet keeps waiting for the install instead of counting it against its start bound. Cleared by the write that follows the install, whatever its outcome. */
|
|
27539
|
+
installing: external_exports.string().optional(),
|
|
27538
27540
|
/** The last fatal error, kept across shutdowns so `headroom status` can explain a daemon that is not running. */
|
|
27539
27541
|
lastError: external_exports.string().optional()
|
|
27540
27542
|
});
|
|
@@ -27634,7 +27636,7 @@ function daemonAdmits(fs22, allowlistFile, recordedHash, required2) {
|
|
|
27634
27636
|
}
|
|
27635
27637
|
function ensureHeadroom(params) {
|
|
27636
27638
|
const { paths, ports } = params;
|
|
27637
|
-
|
|
27639
|
+
let deadline = ports.now() + HEADROOM_START_TIMEOUT_MS;
|
|
27638
27640
|
let spawnedSupervisor = false;
|
|
27639
27641
|
migrateHeadroomState(ports.fs, { stateFile: paths.headroomStateFile, legacyStateFile: paths.headroomLegacyStateFile }, ports.isRunning);
|
|
27640
27642
|
const commandLines = /* @__PURE__ */ new Map();
|
|
@@ -27648,6 +27650,9 @@ function ensureHeadroom(params) {
|
|
|
27648
27650
|
let awaiting;
|
|
27649
27651
|
const state = resolveServingHeadroomState(ports.fs, { stateFile: paths.headroomStateFile, legacyStateFile: paths.headroomLegacyStateFile }, ports.isRunning)?.state;
|
|
27650
27652
|
if (state?.supervisorPid !== void 0 && ports.isRunning(state.supervisorPid)) {
|
|
27653
|
+
if (state.installing !== void 0) {
|
|
27654
|
+
deadline = ports.now() + HEADROOM_START_TIMEOUT_MS;
|
|
27655
|
+
}
|
|
27651
27656
|
const daemonUp = state.socketPath !== void 0 && state.headroomPid !== void 0 && ports.isRunning(state.headroomPid);
|
|
27652
27657
|
if (daemonUp && state.socketPath !== void 0 && state.headroomPid !== void 0) {
|
|
27653
27658
|
const required2 = params.requiredUpstreams?.();
|
|
@@ -28249,15 +28254,16 @@ async function runSupervisor(initialConfig, ports, options = {}) {
|
|
|
28249
28254
|
const commitOk = pinned === void 0 || ports.installedCommit() === pinned;
|
|
28250
28255
|
if (versionOk && commitOk && (installedSource === void 0 || installedSource === config2.source)) {
|
|
28251
28256
|
installedSource = config2.source;
|
|
28252
|
-
return
|
|
28257
|
+
return void 0;
|
|
28253
28258
|
}
|
|
28254
28259
|
ports.log(`agent-shim headroom supervisor: installing headroom from ${config2.source}`);
|
|
28260
|
+
writeOwnState({ supervisorPid: ports.ownPid, installedSource, installing: config2.source });
|
|
28255
28261
|
const result = ports.install(config2.source);
|
|
28256
28262
|
if (!result.ok) {
|
|
28257
|
-
return
|
|
28263
|
+
return `could not install headroom from ${config2.source}: ${result.error ?? "install failed"}`;
|
|
28258
28264
|
}
|
|
28259
28265
|
installedSource = config2.source;
|
|
28260
|
-
return
|
|
28266
|
+
return void 0;
|
|
28261
28267
|
};
|
|
28262
28268
|
const socket = prepareHeadroomSocket(fs22, ports.socketTrust, paths, ports.ownPid);
|
|
28263
28269
|
if (socket.refused !== void 0) {
|
|
@@ -28266,8 +28272,9 @@ async function runSupervisor(initialConfig, ports, options = {}) {
|
|
|
28266
28272
|
const { socketPath } = socket;
|
|
28267
28273
|
pruneStaleHeadroomSockets(fs22, paths, ports.isRunning);
|
|
28268
28274
|
pruneStaleAllowlistTemporaries(fs22, paths.headroomAllowlistFile, ports.isRunning);
|
|
28269
|
-
|
|
28270
|
-
|
|
28275
|
+
const installFailure = ensureInstalled();
|
|
28276
|
+
if (installFailure !== void 0) {
|
|
28277
|
+
return fail(installFailure);
|
|
28271
28278
|
}
|
|
28272
28279
|
const version2 = ports.headroomVersion() ?? "unknown";
|
|
28273
28280
|
writeOwnState({ supervisorPid: ports.ownPid, version: version2, installedSource });
|
|
@@ -28342,8 +28349,9 @@ async function runSupervisor(initialConfig, ports, options = {}) {
|
|
|
28342
28349
|
`headroom failed to become ready ${String(consecutiveFailures)} times in a row; giving up` + (lastExitOutput === void 0 ? "" : `; the last attempt exited before it was ready, and its log ends: ${lastExitOutput}`)
|
|
28343
28350
|
);
|
|
28344
28351
|
}
|
|
28345
|
-
|
|
28346
|
-
|
|
28352
|
+
const restartInstallFailure = installedSource !== config2.source ? ensureInstalled() : void 0;
|
|
28353
|
+
if (restartInstallFailure !== void 0) {
|
|
28354
|
+
return fail(restartInstallFailure);
|
|
28347
28355
|
}
|
|
28348
28356
|
const logOffset = ports.daemonLogSize();
|
|
28349
28357
|
const pid = ports.spawnHeadroom(socketPath, paths.headroomAllowlistFile, config2.settings);
|
|
@@ -33959,7 +33967,7 @@ var init_package = __esm({
|
|
|
33959
33967
|
"package.json"() {
|
|
33960
33968
|
package_default = {
|
|
33961
33969
|
name: "agent-shim",
|
|
33962
|
-
version: "10.0.
|
|
33970
|
+
version: "10.0.2",
|
|
33963
33971
|
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.",
|
|
33964
33972
|
license: "MIT",
|
|
33965
33973
|
author: "Joseph Mearman <joseph@mearman.co.uk>",
|
|
@@ -126280,7 +126288,9 @@ async function hopOnce(request7, response, target, body, mayRetry) {
|
|
|
126280
126288
|
}
|
|
126281
126289
|
const phase = response.headersSent ? "mid-stream" : "before the response started";
|
|
126282
126290
|
const code = "code" in error63 && typeof error63.code === "string" ? ` ${error63.code}` : "";
|
|
126283
|
-
|
|
126291
|
+
const attempt = mayRetry ? "first attempt" : "replay";
|
|
126292
|
+
const client = request7.signal.aborted ? "client had gone" : "client still waiting";
|
|
126293
|
+
target.log(`front door: headroom hop to ${socketPath} failed (${request7.method} ${new URL(request7.url, "http://127.0.0.1").pathname}, ${phase}, ${attempt}, ${client}): ${error63.message}${code}`);
|
|
126284
126294
|
if (!response.headersSent) {
|
|
126285
126295
|
response.start(HTTP_BAD_GATEWAY2, { "Content-Type": "application/json" });
|
|
126286
126296
|
void response.write(JSON.stringify({ type: "error", error: { type: "api_error", message: `agent-shim front door: the headroom daemon is unreachable (${error63.message})` } })).then(() => {
|
|
@@ -141245,6 +141255,7 @@ function formatHeadroomStatus(status) {
|
|
|
141245
141255
|
}
|
|
141246
141256
|
var ownedHeadroom = /* @__PURE__ */ new Map();
|
|
141247
141257
|
var exitedHeadroom = /* @__PURE__ */ new Set();
|
|
141258
|
+
var HEADROOM_INSTALL_TIMEOUT_MS = 6e5;
|
|
141248
141259
|
var READY_FETCH_TIMEOUT_MS = 2e3;
|
|
141249
141260
|
function headroomPidRunning(pid) {
|
|
141250
141261
|
return !exitedHeadroom.has(pid) && realIsProcessRunning(pid);
|
|
@@ -141373,9 +141384,13 @@ function realSupervisorPorts(paths) {
|
|
|
141373
141384
|
},
|
|
141374
141385
|
ready: readyOverSocket,
|
|
141375
141386
|
install: (spec) => {
|
|
141376
|
-
const result = (0, import_node_child_process7.spawnSync)("uv", ["tool", "install", spec], { encoding: "utf8" });
|
|
141387
|
+
const result = (0, import_node_child_process7.spawnSync)("uv", ["tool", "install", spec], { encoding: "utf8", timeout: HEADROOM_INSTALL_TIMEOUT_MS });
|
|
141377
141388
|
if (result.error !== void 0) {
|
|
141378
|
-
|
|
141389
|
+
const timedOut = "code" in result.error && result.error.code === "ETIMEDOUT";
|
|
141390
|
+
return {
|
|
141391
|
+
ok: false,
|
|
141392
|
+
error: timedOut ? `uv tool install did not finish within ${String(HEADROOM_INSTALL_TIMEOUT_MS)}ms and was stopped` : `uv is not installed or not on PATH (${result.error.message})`
|
|
141393
|
+
};
|
|
141379
141394
|
}
|
|
141380
141395
|
if (result.stdout !== "") {
|
|
141381
141396
|
import_node_fs20.default.appendFileSync(paths.headroomLogPath, result.stdout);
|
package/dist/index.cjs
CHANGED
|
@@ -2758,7 +2758,7 @@ var init_package = __esm({
|
|
|
2758
2758
|
"package.json"() {
|
|
2759
2759
|
package_default = {
|
|
2760
2760
|
name: "agent-shim",
|
|
2761
|
-
version: "10.0.
|
|
2761
|
+
version: "10.0.2",
|
|
2762
2762
|
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.",
|
|
2763
2763
|
license: "MIT",
|
|
2764
2764
|
author: "Joseph Mearman <joseph@mearman.co.uk>",
|
|
@@ -3134,6 +3134,8 @@ var init_state2 = __esm({
|
|
|
3134
3134
|
settingsHash: import_zod8.z.string().optional(),
|
|
3135
3135
|
/** The install spec the running install was last installed from, so a `source` config change is detected as drift. */
|
|
3136
3136
|
installedSource: import_zod8.z.string().optional(),
|
|
3137
|
+
/** The install spec the supervisor is installing right now, present only while `uv tool install` runs, so a launcher that finds a live supervisor with no daemon yet keeps waiting for the install instead of counting it against its start bound. Cleared by the write that follows the install, whatever its outcome. */
|
|
3138
|
+
installing: import_zod8.z.string().optional(),
|
|
3137
3139
|
/** The last fatal error, kept across shutdowns so `headroom status` can explain a daemon that is not running. */
|
|
3138
3140
|
lastError: import_zod8.z.string().optional()
|
|
3139
3141
|
});
|
|
@@ -3233,7 +3235,7 @@ function daemonAdmits(fs12, allowlistFile, recordedHash, required) {
|
|
|
3233
3235
|
}
|
|
3234
3236
|
function ensureHeadroom(params) {
|
|
3235
3237
|
const { paths, ports } = params;
|
|
3236
|
-
|
|
3238
|
+
let deadline = ports.now() + HEADROOM_START_TIMEOUT_MS;
|
|
3237
3239
|
let spawnedSupervisor = false;
|
|
3238
3240
|
migrateHeadroomState(ports.fs, { stateFile: paths.headroomStateFile, legacyStateFile: paths.headroomLegacyStateFile }, ports.isRunning);
|
|
3239
3241
|
const commandLines = /* @__PURE__ */ new Map();
|
|
@@ -3247,6 +3249,9 @@ function ensureHeadroom(params) {
|
|
|
3247
3249
|
let awaiting;
|
|
3248
3250
|
const state = resolveServingHeadroomState(ports.fs, { stateFile: paths.headroomStateFile, legacyStateFile: paths.headroomLegacyStateFile }, ports.isRunning)?.state;
|
|
3249
3251
|
if (state?.supervisorPid !== void 0 && ports.isRunning(state.supervisorPid)) {
|
|
3252
|
+
if (state.installing !== void 0) {
|
|
3253
|
+
deadline = ports.now() + HEADROOM_START_TIMEOUT_MS;
|
|
3254
|
+
}
|
|
3250
3255
|
const daemonUp = state.socketPath !== void 0 && state.headroomPid !== void 0 && ports.isRunning(state.headroomPid);
|
|
3251
3256
|
if (daemonUp && state.socketPath !== void 0 && state.headroomPid !== void 0) {
|
|
3252
3257
|
const required = params.requiredUpstreams?.();
|
|
@@ -3686,15 +3691,16 @@ async function runSupervisor(initialConfig, ports, options = {}) {
|
|
|
3686
3691
|
const commitOk = pinned === void 0 || ports.installedCommit() === pinned;
|
|
3687
3692
|
if (versionOk && commitOk && (installedSource === void 0 || installedSource === config.source)) {
|
|
3688
3693
|
installedSource = config.source;
|
|
3689
|
-
return
|
|
3694
|
+
return void 0;
|
|
3690
3695
|
}
|
|
3691
3696
|
ports.log(`agent-shim headroom supervisor: installing headroom from ${config.source}`);
|
|
3697
|
+
writeOwnState({ supervisorPid: ports.ownPid, installedSource, installing: config.source });
|
|
3692
3698
|
const result = ports.install(config.source);
|
|
3693
3699
|
if (!result.ok) {
|
|
3694
|
-
return
|
|
3700
|
+
return `could not install headroom from ${config.source}: ${result.error ?? "install failed"}`;
|
|
3695
3701
|
}
|
|
3696
3702
|
installedSource = config.source;
|
|
3697
|
-
return
|
|
3703
|
+
return void 0;
|
|
3698
3704
|
};
|
|
3699
3705
|
const socket = prepareHeadroomSocket(fs12, ports.socketTrust, paths, ports.ownPid);
|
|
3700
3706
|
if (socket.refused !== void 0) {
|
|
@@ -3703,8 +3709,9 @@ async function runSupervisor(initialConfig, ports, options = {}) {
|
|
|
3703
3709
|
const { socketPath } = socket;
|
|
3704
3710
|
pruneStaleHeadroomSockets(fs12, paths, ports.isRunning);
|
|
3705
3711
|
pruneStaleAllowlistTemporaries(fs12, paths.headroomAllowlistFile, ports.isRunning);
|
|
3706
|
-
|
|
3707
|
-
|
|
3712
|
+
const installFailure = ensureInstalled();
|
|
3713
|
+
if (installFailure !== void 0) {
|
|
3714
|
+
return fail(installFailure);
|
|
3708
3715
|
}
|
|
3709
3716
|
const version = ports.headroomVersion() ?? "unknown";
|
|
3710
3717
|
writeOwnState({ supervisorPid: ports.ownPid, version, installedSource });
|
|
@@ -3779,8 +3786,9 @@ async function runSupervisor(initialConfig, ports, options = {}) {
|
|
|
3779
3786
|
`headroom failed to become ready ${String(consecutiveFailures)} times in a row; giving up` + (lastExitOutput === void 0 ? "" : `; the last attempt exited before it was ready, and its log ends: ${lastExitOutput}`)
|
|
3780
3787
|
);
|
|
3781
3788
|
}
|
|
3782
|
-
|
|
3783
|
-
|
|
3789
|
+
const restartInstallFailure = installedSource !== config.source ? ensureInstalled() : void 0;
|
|
3790
|
+
if (restartInstallFailure !== void 0) {
|
|
3791
|
+
return fail(restartInstallFailure);
|
|
3784
3792
|
}
|
|
3785
3793
|
const logOffset = ports.daemonLogSize();
|
|
3786
3794
|
const pid = ports.spawnHeadroom(socketPath, paths.headroomAllowlistFile, config.settings);
|
package/dist/index.mjs
CHANGED
|
@@ -2734,7 +2734,7 @@ var init_package = __esm({
|
|
|
2734
2734
|
"package.json"() {
|
|
2735
2735
|
package_default = {
|
|
2736
2736
|
name: "agent-shim",
|
|
2737
|
-
version: "10.0.
|
|
2737
|
+
version: "10.0.2",
|
|
2738
2738
|
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.",
|
|
2739
2739
|
license: "MIT",
|
|
2740
2740
|
author: "Joseph Mearman <joseph@mearman.co.uk>",
|
|
@@ -3110,6 +3110,8 @@ var init_state2 = __esm({
|
|
|
3110
3110
|
settingsHash: z8.string().optional(),
|
|
3111
3111
|
/** The install spec the running install was last installed from, so a `source` config change is detected as drift. */
|
|
3112
3112
|
installedSource: z8.string().optional(),
|
|
3113
|
+
/** The install spec the supervisor is installing right now, present only while `uv tool install` runs, so a launcher that finds a live supervisor with no daemon yet keeps waiting for the install instead of counting it against its start bound. Cleared by the write that follows the install, whatever its outcome. */
|
|
3114
|
+
installing: z8.string().optional(),
|
|
3113
3115
|
/** The last fatal error, kept across shutdowns so `headroom status` can explain a daemon that is not running. */
|
|
3114
3116
|
lastError: z8.string().optional()
|
|
3115
3117
|
});
|
|
@@ -3209,7 +3211,7 @@ function daemonAdmits(fs12, allowlistFile, recordedHash, required) {
|
|
|
3209
3211
|
}
|
|
3210
3212
|
function ensureHeadroom(params) {
|
|
3211
3213
|
const { paths, ports } = params;
|
|
3212
|
-
|
|
3214
|
+
let deadline = ports.now() + HEADROOM_START_TIMEOUT_MS;
|
|
3213
3215
|
let spawnedSupervisor = false;
|
|
3214
3216
|
migrateHeadroomState(ports.fs, { stateFile: paths.headroomStateFile, legacyStateFile: paths.headroomLegacyStateFile }, ports.isRunning);
|
|
3215
3217
|
const commandLines = /* @__PURE__ */ new Map();
|
|
@@ -3223,6 +3225,9 @@ function ensureHeadroom(params) {
|
|
|
3223
3225
|
let awaiting;
|
|
3224
3226
|
const state = resolveServingHeadroomState(ports.fs, { stateFile: paths.headroomStateFile, legacyStateFile: paths.headroomLegacyStateFile }, ports.isRunning)?.state;
|
|
3225
3227
|
if (state?.supervisorPid !== void 0 && ports.isRunning(state.supervisorPid)) {
|
|
3228
|
+
if (state.installing !== void 0) {
|
|
3229
|
+
deadline = ports.now() + HEADROOM_START_TIMEOUT_MS;
|
|
3230
|
+
}
|
|
3226
3231
|
const daemonUp = state.socketPath !== void 0 && state.headroomPid !== void 0 && ports.isRunning(state.headroomPid);
|
|
3227
3232
|
if (daemonUp && state.socketPath !== void 0 && state.headroomPid !== void 0) {
|
|
3228
3233
|
const required = params.requiredUpstreams?.();
|
|
@@ -3662,15 +3667,16 @@ async function runSupervisor(initialConfig, ports, options = {}) {
|
|
|
3662
3667
|
const commitOk = pinned === void 0 || ports.installedCommit() === pinned;
|
|
3663
3668
|
if (versionOk && commitOk && (installedSource === void 0 || installedSource === config.source)) {
|
|
3664
3669
|
installedSource = config.source;
|
|
3665
|
-
return
|
|
3670
|
+
return void 0;
|
|
3666
3671
|
}
|
|
3667
3672
|
ports.log(`agent-shim headroom supervisor: installing headroom from ${config.source}`);
|
|
3673
|
+
writeOwnState({ supervisorPid: ports.ownPid, installedSource, installing: config.source });
|
|
3668
3674
|
const result = ports.install(config.source);
|
|
3669
3675
|
if (!result.ok) {
|
|
3670
|
-
return
|
|
3676
|
+
return `could not install headroom from ${config.source}: ${result.error ?? "install failed"}`;
|
|
3671
3677
|
}
|
|
3672
3678
|
installedSource = config.source;
|
|
3673
|
-
return
|
|
3679
|
+
return void 0;
|
|
3674
3680
|
};
|
|
3675
3681
|
const socket = prepareHeadroomSocket(fs12, ports.socketTrust, paths, ports.ownPid);
|
|
3676
3682
|
if (socket.refused !== void 0) {
|
|
@@ -3679,8 +3685,9 @@ async function runSupervisor(initialConfig, ports, options = {}) {
|
|
|
3679
3685
|
const { socketPath } = socket;
|
|
3680
3686
|
pruneStaleHeadroomSockets(fs12, paths, ports.isRunning);
|
|
3681
3687
|
pruneStaleAllowlistTemporaries(fs12, paths.headroomAllowlistFile, ports.isRunning);
|
|
3682
|
-
|
|
3683
|
-
|
|
3688
|
+
const installFailure = ensureInstalled();
|
|
3689
|
+
if (installFailure !== void 0) {
|
|
3690
|
+
return fail(installFailure);
|
|
3684
3691
|
}
|
|
3685
3692
|
const version = ports.headroomVersion() ?? "unknown";
|
|
3686
3693
|
writeOwnState({ supervisorPid: ports.ownPid, version, installedSource });
|
|
@@ -3755,8 +3762,9 @@ async function runSupervisor(initialConfig, ports, options = {}) {
|
|
|
3755
3762
|
`headroom failed to become ready ${String(consecutiveFailures)} times in a row; giving up` + (lastExitOutput === void 0 ? "" : `; the last attempt exited before it was ready, and its log ends: ${lastExitOutput}`)
|
|
3756
3763
|
);
|
|
3757
3764
|
}
|
|
3758
|
-
|
|
3759
|
-
|
|
3765
|
+
const restartInstallFailure = installedSource !== config.source ? ensureInstalled() : void 0;
|
|
3766
|
+
if (restartInstallFailure !== void 0) {
|
|
3767
|
+
return fail(restartInstallFailure);
|
|
3760
3768
|
}
|
|
3761
3769
|
const logOffset = ports.daemonLogSize();
|
|
3762
3770
|
const pid = ports.spawnHeadroom(socketPath, paths.headroomAllowlistFile, config.settings);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agent-shim",
|
|
3
|
-
"version": "10.0.
|
|
3
|
+
"version": "10.0.2",
|
|
4
4
|
"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.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Joseph Mearman <joseph@mearman.co.uk>",
|