claude-use 9.12.0 → 9.13.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 CHANGED
@@ -24790,6 +24790,36 @@ var init_versionDiscovery = __esm({
24790
24790
  }
24791
24791
  });
24792
24792
 
24793
+ // src/frontdoor/supervisorProcesses.ts
24794
+ function parseFrontDoorSupervisorPids(psOutput) {
24795
+ const pids = [];
24796
+ for (const line of psOutput.split("\n")) {
24797
+ const [pidText, ...argumentsList] = line.trim().split(/\s+/);
24798
+ const pid = Number(pidText);
24799
+ if (Number.isInteger(pid) && pid > 0 && argumentsList.includes(FRONT_DOOR_SUPERVISOR_ARGUMENT)) {
24800
+ pids.push(pid);
24801
+ }
24802
+ }
24803
+ return pids.sort((a10, b) => a10 - b);
24804
+ }
24805
+ function listFrontDoorSupervisors(run, uid) {
24806
+ const result = run.run("ps", ["-U", String(uid), "-o", "pid=,command="]);
24807
+ if (result.status === null) {
24808
+ return { ok: false, message: "ps could not be run" };
24809
+ }
24810
+ if (result.status !== 0) {
24811
+ return { ok: false, message: `ps exited ${String(result.status)}${result.stderr.trim() === "" ? "" : `: ${result.stderr.trim()}`}` };
24812
+ }
24813
+ return { ok: true, pids: parseFrontDoorSupervisorPids(result.stdout) };
24814
+ }
24815
+ var FRONT_DOOR_SUPERVISOR_ARGUMENT;
24816
+ var init_supervisorProcesses = __esm({
24817
+ "src/frontdoor/supervisorProcesses.ts"() {
24818
+ "use strict";
24819
+ FRONT_DOOR_SUPERVISOR_ARGUMENT = "__frontdoor-supervisor";
24820
+ }
24821
+ });
24822
+
24793
24823
  // node_modules/.pnpm/trilean@1.7.1/node_modules/trilean/dist/complex.js
24794
24824
  var complexFromPolar;
24795
24825
  var init_complex = __esm({
@@ -27321,7 +27351,7 @@ function listFrontDoorSessions(fs22, sessionsDir) {
27321
27351
  try {
27322
27352
  const parsed = FrontDoorSessionSchema.safeParse(JSON.parse(fs22.readFileUtf8(import_node_path6.default.join(sessionsDir, name)) ?? ""));
27323
27353
  if (parsed.success) {
27324
- sessions.push({ pid: parsed.data.pid, startedAt: parsed.data.startedAt });
27354
+ sessions.push({ pid: parsed.data.pid, startedAt: parsed.data.startedAt, ...parsed.data.supervisorPid === void 0 ? {} : { supervisorPid: parsed.data.supervisorPid } });
27325
27355
  }
27326
27356
  } catch {
27327
27357
  continue;
@@ -27366,7 +27396,7 @@ var init_state2 = __esm({
27366
27396
  import_node_path6 = __toESM(require("node:path"), 1);
27367
27397
  init_zod();
27368
27398
  FRONT_DOOR_PROTOCOL = 3;
27369
- FrontDoorSessionSchema = external_exports.strictObject({ pid: external_exports.number().int().positive(), startedAt: external_exports.number(), token: external_exports.string().min(1) });
27399
+ FrontDoorSessionSchema = external_exports.strictObject({ pid: external_exports.number().int().positive(), startedAt: external_exports.number(), token: external_exports.string().min(1), supervisorPid: external_exports.number().int().positive().optional() });
27370
27400
  FrontDoorStateSchema = external_exports.strictObject({
27371
27401
  /**
27372
27402
  * The launcher-to-door wire protocol this supervisor speaks, written once it is serving; absent in state written by a release that predates the field, which `ensureFrontDoor` reads as protocol 0. A launcher replaces a door whose protocol is lower than its own (see `FRONT_DOOR_PROTOCOL`).
@@ -27799,9 +27829,15 @@ async function runSupervisor(initialConfig, ports, options = {}) {
27799
27829
  await ports.sleep(HEADROOM_POLL_MS);
27800
27830
  }
27801
27831
  }
27832
+ function currentHeadroomAllowlistInputs(fs22, paths) {
27833
+ return {
27834
+ providers: readAllProviders(fs22, paths.providersDir).map((entry) => entry.provider),
27835
+ frontDoorOrigin: frontDoorOrigin(readFrontDoorState(fs22, paths.frontdoorStateFile))
27836
+ };
27837
+ }
27802
27838
  function currentHeadroomAllowlist(fs22, paths) {
27803
- const providers = readAllProviders(fs22, paths.providersDir).map((entry) => entry.provider);
27804
- return headroomAllowlist(headroomUpstreams(providers, frontDoorOrigin(readFrontDoorState(fs22, paths.frontdoorStateFile))));
27839
+ const inputs = currentHeadroomAllowlistInputs(fs22, paths);
27840
+ return headroomAllowlist(headroomUpstreams(inputs.providers, inputs.frontDoorOrigin));
27805
27841
  }
27806
27842
  function allowlistOf(ports) {
27807
27843
  return currentHeadroomAllowlist(ports.fs, ports.paths);
@@ -27866,6 +27902,10 @@ function realIsProcessZombie(pid) {
27866
27902
  function realIsProcessRunning(pid) {
27867
27903
  return realIsProcessAlive(pid) && !realIsProcessZombie(pid);
27868
27904
  }
27905
+ function realIsFrontDoorSupervisor(pid) {
27906
+ const result = (0, import_node_child_process2.spawnSync)("ps", ["-o", "pid=,command=", "-p", String(pid)], { encoding: "utf8" });
27907
+ return result.status === 0 && parseFrontDoorSupervisorPids(result.stdout).includes(pid);
27908
+ }
27869
27909
  function expandHome(filePath) {
27870
27910
  return filePath.startsWith("~/") ? import_node_path8.default.join(import_node_os2.default.homedir(), filePath.slice(1)) : filePath;
27871
27911
  }
@@ -28080,6 +28120,7 @@ var init_realPorts = __esm({
28080
28120
  import_node_sea = require("node:sea");
28081
28121
  init_load();
28082
28122
  init_versionDiscovery();
28123
+ init_supervisorProcesses();
28083
28124
  init_ensure();
28084
28125
  init_supervisor();
28085
28126
  init_state();
@@ -33243,7 +33284,7 @@ var init_package = __esm({
33243
33284
  "package.json"() {
33244
33285
  package_default = {
33245
33286
  name: "claude-use",
33246
- version: "9.12.0",
33287
+ version: "9.13.0",
33247
33288
  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.",
33248
33289
  license: "MIT",
33249
33290
  author: "Joseph Mearman <joseph@mearman.co.uk>",
@@ -34113,7 +34154,7 @@ function assessIdentity(member, nowMs) {
34113
34154
  );
34114
34155
  if (blockedUntil > nowMs) {
34115
34156
  if (unified.overageStatus === "allowed") {
34116
- return { candidate: { ...base, class: "pay-per-use", reasons: [`plan exhausted until ${new Date(blockedUntil).toISOString()}, continues as extra usage`, ...windowReasons, ...planReasons] } };
34157
+ return { candidate: { ...base, class: "pay-per-use", planReturnsAtMs: blockedUntil, reasons: [`plan exhausted until ${new Date(blockedUntil).toISOString()} (in ${formatAge(blockedUntil - nowMs)}), continues as extra usage`, ...windowReasons, ...planReasons] } };
34117
34158
  }
34118
34159
  return { candidate: { ...base, class: "ineligible", blockedUntilMs: blockedUntil, reasons: [`refused until ${new Date(blockedUntil).toISOString()} (in ${formatAge(blockedUntil - nowMs)})`, ...unified.fallbackAvailable === true ? ["a fallback is on offer, so requests for some models may still be served"] : [], ...windowReasons, ...overageReasons, ...planReasons] } };
34119
34160
  }
@@ -34228,7 +34269,8 @@ function rankPool(input2) {
34228
34269
  return {
34229
34270
  candidates: ordered,
34230
34271
  ...pick2 === void 0 ? { ...earliestReturn === void 0 ? {} : { earliestReturn } } : { pick: pick2 },
34231
- ...movedOff === void 0 || pick2 === void 0 ? {} : { movedOff }
34272
+ ...movedOff === void 0 || pick2 === void 0 ? {} : { movedOff },
34273
+ ...pick2?.planReturnsAtMs === void 0 ? {} : { planReturn: { identity: pick2.identity, atMs: pick2.planReturnsAtMs } }
34232
34274
  };
34233
34275
  }
34234
34276
  var MS_PER_SECOND3, MS_PER_HOUR2, HOURS_PER_DAY2, FIVE_HOURS, PROMPT_CACHE_TTL_HOURS, PERCENT, SEVEN_DAYS, FIVE_HOUR_WINDOW_MS, SEVEN_DAY_WINDOW_MS, PROMPT_CACHE_TTL_MS, CLASS_ORDER;
@@ -61034,32 +61076,50 @@ function ensureFrontDoor(params) {
61034
61076
  let replaced = false;
61035
61077
  const distrusted = /* @__PURE__ */ new Set();
61036
61078
  let lastRejection;
61079
+ const verifyWithRetry = (port) => {
61080
+ let verdict = ports.verifyListener(port);
61081
+ for (let attempt = 1; !verdict.ok && attempt < FRONTDOOR_PROBE_ATTEMPTS; attempt += 1) {
61082
+ ports.sleep(FRONTDOOR_LAUNCHER_POLL_MS);
61083
+ verdict = ports.verifyListener(port);
61084
+ }
61085
+ return verdict;
61086
+ };
61087
+ const stopAndAwaitExit = (supervisorPid, failure2) => {
61088
+ ports.stopSupervisor(supervisorPid);
61089
+ while (ports.isRunning(supervisorPid)) {
61090
+ if (ports.now() >= deadline) {
61091
+ throw new FrontDoorStartError(`${failure2}. Daemon log: ${paths.frontdoorLogPath}`);
61092
+ }
61093
+ ports.sleep(FRONTDOOR_LAUNCHER_POLL_MS);
61094
+ }
61095
+ };
61037
61096
  for (; ; ) {
61038
61097
  const state = readFrontDoorState(ports.fs, paths.frontdoorStateFile);
61039
61098
  const supervisorPid = state?.supervisorPid;
61040
61099
  if (supervisorPid !== void 0 && !distrusted.has(supervisorPid) && ports.isRunning(supervisorPid)) {
61041
61100
  if (state?.port !== void 0 && state.connectPort !== void 0) {
61042
- const verdict = ports.verifyListener(state.port);
61101
+ const verdict = verifyWithRetry(state.port);
61043
61102
  if (verdict.ok && !replaced && !spawned && (params.replace === true || (state.protocol ?? 0) < FRONT_DOOR_PROTOCOL)) {
61044
- ports.stopSupervisor(supervisorPid);
61045
- while (ports.isRunning(supervisorPid)) {
61046
- if (ports.now() >= deadline) {
61047
- throw new FrontDoorStartError(`the front door (pid ${String(supervisorPid)}, protocol ${String(state.protocol ?? 0)}; this launcher speaks protocol ${String(FRONT_DOOR_PROTOCOL)}) was asked to be replaced and did not exit. Daemon log: ${paths.frontdoorLogPath}`);
61048
- }
61049
- ports.sleep(FRONTDOOR_LAUNCHER_POLL_MS);
61050
- }
61103
+ stopAndAwaitExit(
61104
+ supervisorPid,
61105
+ `the front door (pid ${String(supervisorPid)}, protocol ${String(state.protocol ?? 0)}; this launcher speaks protocol ${String(FRONT_DOOR_PROTOCOL)}) was asked to be replaced and did not exit`
61106
+ );
61051
61107
  replaced = true;
61052
61108
  continue;
61053
61109
  }
61054
61110
  if (verdict.ok) {
61055
61111
  const token = (0, import_node_crypto10.randomUUID)();
61056
- writeFrontDoorSession(ports.fs, paths.frontdoorSessionsDir, { pid: params.launcherPid, startedAt: ports.now(), token });
61112
+ writeFrontDoorSession(ports.fs, paths.frontdoorSessionsDir, { pid: params.launcherPid, startedAt: ports.now(), token, supervisorPid });
61057
61113
  return { port: state.port, connectPort: state.connectPort, token };
61058
61114
  }
61059
61115
  lastRejection = `the listener on 127.0.0.1:${String(state.port)} (recorded for pid ${String(supervisorPid)}) failed authentication: ${verdict.reason}`;
61060
61116
  if (spawned) {
61061
61117
  throw new FrontDoorStartError(`${lastRejection}; refusing to send this session's credentials to it. Daemon log: ${paths.frontdoorLogPath}`);
61062
61118
  }
61119
+ if (ports.isFrontDoorSupervisor(supervisorPid)) {
61120
+ stopAndAwaitExit(supervisorPid, `the front door (pid ${String(supervisorPid)}) stopped answering and did not exit when asked to`);
61121
+ continue;
61122
+ }
61063
61123
  distrusted.add(supervisorPid);
61064
61124
  continue;
61065
61125
  }
@@ -61107,7 +61167,7 @@ function restartFrontDoor(params) {
61107
61167
  }
61108
61168
  return { action: "restarted", previousPid, pid };
61109
61169
  }
61110
- var import_node_crypto10, FRONTDOOR_START_TIMEOUT_MS, FRONTDOOR_LAUNCHER_POLL_MS, FrontDoorStartError;
61170
+ var import_node_crypto10, FRONTDOOR_START_TIMEOUT_MS, FRONTDOOR_LAUNCHER_POLL_MS, FRONTDOOR_PROBE_ATTEMPTS, FrontDoorStartError;
61111
61171
  var init_ensure2 = __esm({
61112
61172
  "src/frontdoor/ensure.ts"() {
61113
61173
  "use strict";
@@ -61117,6 +61177,7 @@ var init_ensure2 = __esm({
61117
61177
  init_state2();
61118
61178
  FRONTDOOR_START_TIMEOUT_MS = 3e4;
61119
61179
  FRONTDOOR_LAUNCHER_POLL_MS = 100;
61180
+ FRONTDOOR_PROBE_ATTEMPTS = 3;
61120
61181
  FrontDoorStartError = class extends CliError {
61121
61182
  constructor(message) {
61122
61183
  super(message);
@@ -61242,6 +61303,7 @@ function realEnsurePorts(paths, spawnDaemon) {
61242
61303
  now: () => Date.now(),
61243
61304
  sleep: realSleepSync,
61244
61305
  spawnSupervisor: (layout) => spawnDaemon(layout, "__frontdoor-supervisor", layout.frontdoorLogPath),
61306
+ isFrontDoorSupervisor: realIsFrontDoorSupervisor,
61245
61307
  stopSupervisor: (pid) => {
61246
61308
  process.kill(pid, "SIGTERM");
61247
61309
  },
@@ -62128,7 +62190,12 @@ function resolvePoolLaunch(params) {
62128
62190
  if (graph.ranking.candidates.length === 0) {
62129
62191
  return { ok: false, message: `agent-shim: no member of pool "${poolName}" is an existing identity.` };
62130
62192
  }
62131
- const { pick: pick2, earliestReturn, movedOff } = graph.ranking;
62193
+ const { pick: pick2, earliestReturn, movedOff, planReturn } = graph.ranking;
62194
+ if (pick2 !== void 0 && params.wait && planReturn !== void 0) {
62195
+ log.info(`agent-shim: pool "${poolName}" would continue ${planReturn.identity} on extra usage; waiting until ${new Date(planReturn.atMs).toISOString()} for its plan window`);
62196
+ params.sleep(Math.max(planReturn.atMs - nowMs, 0));
62197
+ continue;
62198
+ }
62132
62199
  if (pick2 !== void 0) {
62133
62200
  if (params.recordPick) {
62134
62201
  recordStickyPick(params.usageFs, params.paths.usagePicksFile, params.cwd, pick2.identity, nowMs);
@@ -112271,16 +112338,27 @@ async function runFrontDoorSupervisor(idleShutdownMinutes, ports, options = {})
112271
112338
  ports.log(`agent-shim frontdoor supervisor ${String(ports.ownPid)}: front door on 127.0.0.1:${String(http8.port)}, CONNECT surface on 127.0.0.1:${String(connect3.port)}`);
112272
112339
  let idleSince;
112273
112340
  let ticks = 0;
112341
+ const supersedingOwner = () => {
112342
+ const owner = readFrontDoorState(fs22, paths.frontdoorStateFile)?.supervisorPid;
112343
+ return owner !== void 0 && owner !== ports.ownPid && ports.isRunning(owner) ? owner : void 0;
112344
+ };
112345
+ let supersededBy;
112346
+ let served;
112274
112347
  const binaryReplaced = () => {
112275
112348
  const current = ports.statOwnExecutable();
112276
112349
  return current !== void 0 && servingBinary !== void 0 && (current.dev !== servingBinary.dev || current.ino !== servingBinary.ino || current.size !== servingBinary.size || current.mtimeMs !== servingBinary.mtimeMs);
112277
112350
  };
112278
- const shutdown = async () => {
112351
+ const closeServing = async () => {
112279
112352
  await direct.close();
112280
112353
  await connect3.close();
112281
112354
  await http8.close();
112282
112355
  ports.closeRcStreamHub();
112283
- writeFrontDoorState(fs22, paths.frontdoorStateFile, sticky());
112356
+ };
112357
+ const shutdown = async () => {
112358
+ await closeServing();
112359
+ if (supersedingOwner() === void 0) {
112360
+ writeFrontDoorState(fs22, paths.frontdoorStateFile, sticky());
112361
+ }
112284
112362
  return 0;
112285
112363
  };
112286
112364
  for (; ; ) {
@@ -112293,7 +112371,28 @@ async function runFrontDoorSupervisor(idleShutdownMinutes, ports, options = {})
112293
112371
  ports.observeLaunchRegistry(listed, pruned);
112294
112372
  ports.checkQuotaExpiry();
112295
112373
  const prunedPids = new Set(pruned);
112296
- if (listed.filter((session) => !prunedPids.has(session.pid)).length === 0) {
112374
+ const live = listed.filter((session) => !prunedPids.has(session.pid));
112375
+ if (supersededBy === void 0) {
112376
+ supersededBy = supersedingOwner();
112377
+ if (supersededBy !== void 0) {
112378
+ 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`);
112379
+ ports.doorHealth.superseded(supersededBy);
112380
+ await ports.sleep(FRONTDOOR_POLL_MS);
112381
+ continue;
112382
+ }
112383
+ } else {
112384
+ const owner = supersededBy;
112385
+ served = (served ?? live.filter((session) => session.pid !== ports.ownPid && session.pid !== owner && (session.supervisorPid === void 0 || session.supervisorPid === ports.ownPid))).filter((own2) => live.some((session) => session.pid === own2.pid && session.startedAt === own2.startedAt));
112386
+ if (served.length === 0) {
112387
+ ports.log("agent-shim frontdoor supervisor: the sessions this superseded door served have ended; closing the front door and exiting");
112388
+ ports.doorHealth.drained();
112389
+ await closeServing();
112390
+ return 0;
112391
+ }
112392
+ await ports.sleep(FRONTDOOR_POLL_MS);
112393
+ continue;
112394
+ }
112395
+ if (live.length === 0) {
112297
112396
  if (ticks > 1 && binaryReplaced()) {
112298
112397
  ports.log("agent-shim frontdoor supervisor: the installed binary changed and no sessions are live; turning the door over for the next launch");
112299
112398
  ports.doorHealth.binaryTurnover();
@@ -114616,7 +114715,55 @@ init_credential();
114616
114715
  init_credentialCache();
114617
114716
  init_realCredentialCache();
114618
114717
  init_source();
114718
+
114719
+ // src/headroom/allowlistDrift.ts
114720
+ init_state();
114721
+ function diagnoseAllowlistDrift(params) {
114722
+ const { recordedHash, providers, frontDoorOrigin: frontDoorOrigin2 } = params;
114723
+ if (recordedHash === void 0 || recordedHash === hashAllowlist(headroomAllowlist(headroomUpstreams(providers, frontDoorOrigin2)))) {
114724
+ return void 0;
114725
+ }
114726
+ const originIsInput = providers.length > 0 && frontDoorOrigin2 !== void 0;
114727
+ if (!originIsInput) {
114728
+ return ["provider-files"];
114729
+ }
114730
+ return recordedHash === hashAllowlist(headroomAllowlist(headroomUpstreams(providers, void 0))) ? ["front-door-origin"] : ["provider-files", "front-door-origin"];
114731
+ }
114732
+
114733
+ // src/doctorReport.ts
114619
114734
  init_state();
114735
+ init_supervisor();
114736
+ init_state2();
114737
+
114738
+ // src/doctorFrontDoor.ts
114739
+ function pushFrontDoor(push, supervisors, registeredPid) {
114740
+ if (!supervisors.ok) {
114741
+ push("frontdoor", "warn", `Could not list processes to look for duplicate front door supervisors: ${supervisors.message}.`);
114742
+ return;
114743
+ }
114744
+ const { pids } = supervisors;
114745
+ if (pids.length === 0) {
114746
+ push("frontdoor", "pass", "No front door supervisor is running.");
114747
+ return;
114748
+ }
114749
+ const [only, ...rest] = pids;
114750
+ if (only !== void 0 && rest.length === 0) {
114751
+ push("frontdoor", "pass", `One front door supervisor is running (pid ${String(only)}).`);
114752
+ return;
114753
+ }
114754
+ const serving = registeredPid !== void 0 && pids.includes(registeredPid) ? `The front door state file names pid ${String(registeredPid)} as the serving supervisor.` : "The front door state file names no running supervisor.";
114755
+ for (const pid of pids.filter((candidate) => candidate !== registeredPid)) {
114756
+ push(
114757
+ "frontdoor",
114758
+ "fail",
114759
+ `Front door supervisor pid ${String(pid)} is running beside ${String(pids.length - 1)} other(s). ${serving} Stop it with \`kill ${String(pid)}\`; launches still connected to it lose their door.`,
114760
+ String(pid)
114761
+ );
114762
+ }
114763
+ }
114764
+
114765
+ // src/doctorReport.ts
114766
+ init_supervisorProcesses();
114620
114767
  init_legacy();
114621
114768
  init_providersStore();
114622
114769
  init_guard();
@@ -114639,7 +114786,8 @@ var DOCTOR_SECTIONS = [
114639
114786
  "global-config",
114640
114787
  "categories-local",
114641
114788
  "active-identity",
114642
- "headroom"
114789
+ "headroom",
114790
+ "frontdoor"
114643
114791
  ];
114644
114792
  function refinePathShadow(status, ownExecutablePath, realpath) {
114645
114793
  if (status.status !== "shadowed") {
@@ -115035,6 +115183,17 @@ function runDoctor(params) {
115035
115183
  `Headroom daemon is up on unix socket ${state.socketPath} (supervisor ${String(state.supervisorPid)}, daemon ${String(state.headroomPid)}).`
115036
115184
  );
115037
115185
  }
115186
+ const allowlist = params.headroom.allowlist;
115187
+ if (supervisorAlive && headroomAlive && state.socketPath !== void 0 && allowlist?.driftInputs?.includes("front-door-origin") === true) {
115188
+ const origin = allowlist.frontDoorOrigin ?? "";
115189
+ const certainty = allowlist.driftInputs.includes("provider-files") ? "may exclude" : "excludes";
115190
+ push(
115191
+ "headroom",
115192
+ "fail",
115193
+ `Headroom daemon ${String(state.headroomPid)} was started with an allowlist that ${certainty} the serving front door's direct origin ${origin}, so it refuses every request a provider launch sends back through the door. Its supervisor restarts it once no launch is registered against it; \`agent-shim headroom status\` lists the registered launches, and \`--no-headroom\` launches are unaffected.`,
115194
+ String(state.headroomPid)
115195
+ );
115196
+ }
115038
115197
  if (state.lastError !== void 0 && supervisorAlive) {
115039
115198
  push("headroom", "warn", `Headroom recorded a previous error: ${state.lastError}`);
115040
115199
  }
@@ -115047,6 +115206,10 @@ function runDoctor(params) {
115047
115206
  }
115048
115207
  }
115049
115208
  }
115209
+ if (params.frontDoor !== void 0) {
115210
+ const validated2 = params.frontDoor.state.raw === void 0 ? void 0 : validateJson(FrontDoorStateSchema, params.frontDoor.state);
115211
+ pushFrontDoor(push, params.frontDoor.supervisors, validated2?.ok === true ? validated2.data.supervisorPid : void 0);
115212
+ }
115050
115213
  if (params.activeIdentity.raw === void 0) {
115051
115214
  push("active-identity", "pass", "No active identity set.");
115052
115215
  } else {
@@ -115076,6 +115239,7 @@ var SECTION_TITLES = {
115076
115239
  "directory-rules": "Directory rules",
115077
115240
  "global-config": "Global config",
115078
115241
  headroom: "Headroom daemon",
115242
+ frontdoor: "Front door",
115079
115243
  "categories-local": "categories.local.json",
115080
115244
  "active-identity": "Active identity"
115081
115245
  };
@@ -115093,6 +115257,7 @@ var SECTION_ORDER = [
115093
115257
  "directory-rules",
115094
115258
  "global-config",
115095
115259
  "headroom",
115260
+ "frontdoor",
115096
115261
  "categories-local",
115097
115262
  "active-identity"
115098
115263
  ];
@@ -115170,6 +115335,9 @@ function collectDoctorReport(params) {
115170
115335
  shimState.targetPath,
115171
115336
  realpathOrSelf
115172
115337
  );
115338
+ const uid = process.getuid?.();
115339
+ const allowlistInputs = currentHeadroomAllowlistInputs(realFarmFs, paths);
115340
+ const servingHeadroom = resolveServingHeadroomState(realFarmFs, { stateFile: paths.headroomStateFile, legacyStateFile: paths.headroomLegacyStateFile }, realIsProcessRunning);
115173
115341
  const report = runDoctor({
115174
115342
  env: params.env,
115175
115343
  credentialCache: realCredentialCacheEnv(paths),
@@ -115208,8 +115376,13 @@ function collectDoctorReport(params) {
115208
115376
  const statePath = resolved?.path ?? paths.headroomStateFile;
115209
115377
  return { path: statePath, raw: realFarmFs.readFileUtf8(statePath) };
115210
115378
  })(),
115211
- isRunning: realIsProcessRunning
115212
- }
115379
+ isRunning: realIsProcessRunning,
115380
+ allowlist: {
115381
+ driftInputs: diagnoseAllowlistDrift({ recordedHash: servingHeadroom?.state.allowlistHash, ...allowlistInputs }),
115382
+ frontDoorOrigin: allowlistInputs.frontDoorOrigin
115383
+ }
115384
+ },
115385
+ ...uid === void 0 ? {} : { frontDoor: { state: { path: paths.frontdoorStateFile, raw: realFsPort.readFileUtf8(paths.frontdoorStateFile) }, supervisors: listFrontDoorSupervisors(realRunPort, uid) } }
115213
115386
  });
115214
115387
  return report;
115215
115388
  }
@@ -123659,7 +123832,9 @@ var DoorHealthEventSchema = external_exports.discriminatedUnion("kind", [
123659
123832
  external_exports.strictObject({ kind: external_exports.literal("generation"), pid: external_exports.number().int().positive(), providerPort: external_exports.number().int().positive(), connectPort: external_exports.number().int().positive(), directPort: external_exports.number().int().positive(), observedAt: external_exports.number() }),
123660
123833
  external_exports.strictObject({ kind: external_exports.literal("listenerFailed"), pid: external_exports.number().int().positive(), listener: external_exports.enum(["provider", "connect", "direct"]), message: external_exports.string(), observedAt: external_exports.number() }),
123661
123834
  external_exports.strictObject({ kind: external_exports.literal("binaryTurnover"), pid: external_exports.number().int().positive(), observedAt: external_exports.number() }),
123662
- external_exports.strictObject({ kind: external_exports.literal("idleShutdown"), pid: external_exports.number().int().positive(), observedAt: external_exports.number() })
123835
+ external_exports.strictObject({ kind: external_exports.literal("idleShutdown"), pid: external_exports.number().int().positive(), observedAt: external_exports.number() }),
123836
+ external_exports.strictObject({ kind: external_exports.literal("superseded"), pid: external_exports.number().int().positive(), ownerPid: external_exports.number().int().positive(), observedAt: external_exports.number() }),
123837
+ external_exports.strictObject({ kind: external_exports.literal("drained"), pid: external_exports.number().int().positive(), observedAt: external_exports.number() })
123663
123838
  ]);
123664
123839
  var QuotaExpiringEventSchema = external_exports.strictObject({
123665
123840
  identity: external_exports.string().min(1),
@@ -123914,6 +124089,12 @@ function createDoorHealthPublisher(hub, now, pid) {
123914
124089
  },
123915
124090
  binaryTurnover: () => {
123916
124091
  publisher.publish({ kind: "binaryTurnover", pid, observedAt: now() });
124092
+ },
124093
+ superseded: (ownerPid) => {
124094
+ publisher.publish({ kind: "superseded", pid, ownerPid, observedAt: now() });
124095
+ },
124096
+ drained: () => {
124097
+ publisher.publish({ kind: "drained", pid, observedAt: now() });
123917
124098
  }
123918
124099
  };
123919
124100
  }
@@ -139066,7 +139247,9 @@ init_state();
139066
139247
  init_supervisor();
139067
139248
  function collectHeadroomStatus(fsPort, paths, isRunning) {
139068
139249
  const state = resolveServingHeadroomState(fsPort, { stateFile: paths.headroomStateFile, legacyStateFile: paths.headroomLegacyStateFile }, isRunning)?.state ?? {};
139069
- const allowlist = currentHeadroomAllowlist(fsPort, paths);
139250
+ const inputs = currentHeadroomAllowlistInputs(fsPort, paths);
139251
+ const allowlist = headroomAllowlist(headroomUpstreams(inputs.providers, inputs.frontDoorOrigin));
139252
+ const allowlistDriftInputs = diagnoseAllowlistDrift({ recordedHash: state.allowlistHash, providers: inputs.providers, frontDoorOrigin: inputs.frontDoorOrigin });
139070
139253
  const settings2 = settingsOf(readGlobalConfig(paths)?.headroom ?? {});
139071
139254
  return {
139072
139255
  state,
@@ -139077,13 +139260,27 @@ function collectHeadroomStatus(fsPort, paths, isRunning) {
139077
139260
  alive: isRunning(session.pid)
139078
139261
  })),
139079
139262
  allowlist,
139080
- allowlistDrifted: state.allowlistHash !== void 0 && state.allowlistHash !== hashAllowlist(allowlist),
139263
+ allowlistDrifted: allowlistDriftInputs !== void 0,
139264
+ frontDoorOrigin: inputs.frontDoorOrigin,
139265
+ allowlistDriftInputs,
139081
139266
  settings: settings2,
139082
139267
  settingsDrifted: state.settingsHash !== void 0 && state.settingsHash !== hashSettings(settings2),
139083
139268
  logPath: paths.headroomLogPath,
139084
139269
  logExists: fsPort.readFileUtf8(paths.headroomLogPath) !== void 0
139085
139270
  };
139086
139271
  }
139272
+ function describeAllowlistDrift(status) {
139273
+ const inputs = status.allowlistDriftInputs ?? [];
139274
+ if (!inputs.includes("front-door-origin")) {
139275
+ return "DRIFTED: current provider files differ from the running daemon's allowlist; a restart is pending";
139276
+ }
139277
+ const origin = status.frontDoorOrigin ?? "";
139278
+ const consequence = "provider launches through headroom are refused until the daemon restarts, which waits for the launches registered against it to end";
139279
+ if (!inputs.includes("provider-files")) {
139280
+ return `DRIFTED: the daemon was started before the serving front door's direct origin ${origin} existed, so its allowlist excludes it; ${consequence}`;
139281
+ }
139282
+ return `DRIFTED: the provider files or the serving front door's direct origin ${origin} changed since the daemon started, so its allowlist may exclude the door; ${consequence}`;
139283
+ }
139087
139284
  function formatHeadroomStatus(status) {
139088
139285
  const lines = [];
139089
139286
  if (status.state.supervisorPid === void 0) {
@@ -139100,7 +139297,7 @@ function formatHeadroomStatus(status) {
139100
139297
  `headroom: pid ${String(status.state.headroomPid)} (${status.headroomAlive ? "alive" : "NOT running"}), listening on unix socket ${status.state.socketPath}` + (status.state.version === void 0 ? "" : `, ${status.state.version}`)
139101
139298
  );
139102
139299
  }
139103
- const drift = status.allowlistDrifted ? " (DRIFTED: current provider files differ from the running daemon's allowlist; a restart is pending)" : "";
139300
+ const drift = status.allowlistDrifted ? ` (${describeAllowlistDrift(status)})` : "";
139104
139301
  lines.push(`allowlist: ${status.allowlist.join(", ")}${drift}`);
139105
139302
  const configured = Object.entries(status.settings).map(([name, value2]) => `${name} ${String(value2)}`);
139106
139303
  const settingsDrift = status.settingsDrifted ? " (DRIFTED: the configured settings differ from the running daemon's; a restart is pending)" : "";