claude-use 9.12.1 → 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);
@@ -27867,8 +27903,8 @@ function realIsProcessRunning(pid) {
27867
27903
  return realIsProcessAlive(pid) && !realIsProcessZombie(pid);
27868
27904
  }
27869
27905
  function realIsFrontDoorSupervisor(pid) {
27870
- const result = (0, import_node_child_process2.spawnSync)("ps", ["-o", "command=", "-p", String(pid)], { encoding: "utf8" });
27871
- return result.status === 0 && result.stdout.split(/\s+/).includes(FRONT_DOOR_SUPERVISOR_SUBCOMMAND);
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);
27872
27908
  }
27873
27909
  function expandHome(filePath) {
27874
27910
  return filePath.startsWith("~/") ? import_node_path8.default.join(import_node_os2.default.homedir(), filePath.slice(1)) : filePath;
@@ -28072,7 +28108,7 @@ function realResolveClaudeBinary(isOwnBinary) {
28072
28108
  function realInstalledClaudeVersions() {
28073
28109
  return installedVersions(listVersionsDir(defaultVersionsDir()));
28074
28110
  }
28075
- var import_node_child_process2, import_node_crypto4, import_node_fs3, import_node_os2, import_node_path8, import_node_sea, realFsPort, OWNER_ONLY_DIR_MODE, OWNER_ONLY_FILE_MODE, PERMISSION_BITS, realFarmFs, INT32_BYTE_LENGTH, FRONT_DOOR_SUPERVISOR_SUBCOMMAND, realRunPort, MACOS_GUI_SESSION_MANAGER, realCredentialPort, SOCKET_PERMISSION_BITS, realHeadroomSocketTrust, realSpawnPort, realProcPort, realLogPort, EXECUTE_BITS_MASK, WINDOWS_DEFAULT_PATHEXT;
28111
+ var import_node_child_process2, import_node_crypto4, import_node_fs3, import_node_os2, import_node_path8, import_node_sea, realFsPort, OWNER_ONLY_DIR_MODE, OWNER_ONLY_FILE_MODE, PERMISSION_BITS, realFarmFs, INT32_BYTE_LENGTH, realRunPort, MACOS_GUI_SESSION_MANAGER, realCredentialPort, SOCKET_PERMISSION_BITS, realHeadroomSocketTrust, realSpawnPort, realProcPort, realLogPort, EXECUTE_BITS_MASK, WINDOWS_DEFAULT_PATHEXT;
28076
28112
  var init_realPorts = __esm({
28077
28113
  "src/realPorts.ts"() {
28078
28114
  "use strict";
@@ -28084,6 +28120,7 @@ var init_realPorts = __esm({
28084
28120
  import_node_sea = require("node:sea");
28085
28121
  init_load();
28086
28122
  init_versionDiscovery();
28123
+ init_supervisorProcesses();
28087
28124
  init_ensure();
28088
28125
  init_supervisor();
28089
28126
  init_state();
@@ -28213,7 +28250,6 @@ var init_realPorts = __esm({
28213
28250
  }
28214
28251
  };
28215
28252
  INT32_BYTE_LENGTH = 4;
28216
- FRONT_DOOR_SUPERVISOR_SUBCOMMAND = "__frontdoor-supervisor";
28217
28253
  realRunPort = {
28218
28254
  run(command, args) {
28219
28255
  const result = (0, import_node_child_process2.spawnSync)(command, [...args], { encoding: "utf8" });
@@ -33248,7 +33284,7 @@ var init_package = __esm({
33248
33284
  "package.json"() {
33249
33285
  package_default = {
33250
33286
  name: "claude-use",
33251
- version: "9.12.1",
33287
+ version: "9.13.0",
33252
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.",
33253
33289
  license: "MIT",
33254
33290
  author: "Joseph Mearman <joseph@mearman.co.uk>",
@@ -34118,7 +34154,7 @@ function assessIdentity(member, nowMs) {
34118
34154
  );
34119
34155
  if (blockedUntil > nowMs) {
34120
34156
  if (unified.overageStatus === "allowed") {
34121
- 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] } };
34122
34158
  }
34123
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] } };
34124
34160
  }
@@ -34233,7 +34269,8 @@ function rankPool(input2) {
34233
34269
  return {
34234
34270
  candidates: ordered,
34235
34271
  ...pick2 === void 0 ? { ...earliestReturn === void 0 ? {} : { earliestReturn } } : { pick: pick2 },
34236
- ...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 } }
34237
34274
  };
34238
34275
  }
34239
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;
@@ -61072,7 +61109,7 @@ function ensureFrontDoor(params) {
61072
61109
  }
61073
61110
  if (verdict.ok) {
61074
61111
  const token = (0, import_node_crypto10.randomUUID)();
61075
- 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 });
61076
61113
  return { port: state.port, connectPort: state.connectPort, token };
61077
61114
  }
61078
61115
  lastRejection = `the listener on 127.0.0.1:${String(state.port)} (recorded for pid ${String(supervisorPid)}) failed authentication: ${verdict.reason}`;
@@ -62153,7 +62190,12 @@ function resolvePoolLaunch(params) {
62153
62190
  if (graph.ranking.candidates.length === 0) {
62154
62191
  return { ok: false, message: `agent-shim: no member of pool "${poolName}" is an existing identity.` };
62155
62192
  }
62156
- 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
+ }
62157
62199
  if (pick2 !== void 0) {
62158
62200
  if (params.recordPick) {
62159
62201
  recordStickyPick(params.usageFs, params.paths.usagePicksFile, params.cwd, pick2.identity, nowMs);
@@ -112296,16 +112338,27 @@ async function runFrontDoorSupervisor(idleShutdownMinutes, ports, options = {})
112296
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)}`);
112297
112339
  let idleSince;
112298
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;
112299
112347
  const binaryReplaced = () => {
112300
112348
  const current = ports.statOwnExecutable();
112301
112349
  return current !== void 0 && servingBinary !== void 0 && (current.dev !== servingBinary.dev || current.ino !== servingBinary.ino || current.size !== servingBinary.size || current.mtimeMs !== servingBinary.mtimeMs);
112302
112350
  };
112303
- const shutdown = async () => {
112351
+ const closeServing = async () => {
112304
112352
  await direct.close();
112305
112353
  await connect3.close();
112306
112354
  await http8.close();
112307
112355
  ports.closeRcStreamHub();
112308
- 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
+ }
112309
112362
  return 0;
112310
112363
  };
112311
112364
  for (; ; ) {
@@ -112318,7 +112371,28 @@ async function runFrontDoorSupervisor(idleShutdownMinutes, ports, options = {})
112318
112371
  ports.observeLaunchRegistry(listed, pruned);
112319
112372
  ports.checkQuotaExpiry();
112320
112373
  const prunedPids = new Set(pruned);
112321
- 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) {
112322
112396
  if (ticks > 1 && binaryReplaced()) {
112323
112397
  ports.log("agent-shim frontdoor supervisor: the installed binary changed and no sessions are live; turning the door over for the next launch");
112324
112398
  ports.doorHealth.binaryTurnover();
@@ -114641,7 +114715,55 @@ init_credential();
114641
114715
  init_credentialCache();
114642
114716
  init_realCredentialCache();
114643
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
114644
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();
114645
114767
  init_legacy();
114646
114768
  init_providersStore();
114647
114769
  init_guard();
@@ -114664,7 +114786,8 @@ var DOCTOR_SECTIONS = [
114664
114786
  "global-config",
114665
114787
  "categories-local",
114666
114788
  "active-identity",
114667
- "headroom"
114789
+ "headroom",
114790
+ "frontdoor"
114668
114791
  ];
114669
114792
  function refinePathShadow(status, ownExecutablePath, realpath) {
114670
114793
  if (status.status !== "shadowed") {
@@ -115060,6 +115183,17 @@ function runDoctor(params) {
115060
115183
  `Headroom daemon is up on unix socket ${state.socketPath} (supervisor ${String(state.supervisorPid)}, daemon ${String(state.headroomPid)}).`
115061
115184
  );
115062
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
+ }
115063
115197
  if (state.lastError !== void 0 && supervisorAlive) {
115064
115198
  push("headroom", "warn", `Headroom recorded a previous error: ${state.lastError}`);
115065
115199
  }
@@ -115072,6 +115206,10 @@ function runDoctor(params) {
115072
115206
  }
115073
115207
  }
115074
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
+ }
115075
115213
  if (params.activeIdentity.raw === void 0) {
115076
115214
  push("active-identity", "pass", "No active identity set.");
115077
115215
  } else {
@@ -115101,6 +115239,7 @@ var SECTION_TITLES = {
115101
115239
  "directory-rules": "Directory rules",
115102
115240
  "global-config": "Global config",
115103
115241
  headroom: "Headroom daemon",
115242
+ frontdoor: "Front door",
115104
115243
  "categories-local": "categories.local.json",
115105
115244
  "active-identity": "Active identity"
115106
115245
  };
@@ -115118,6 +115257,7 @@ var SECTION_ORDER = [
115118
115257
  "directory-rules",
115119
115258
  "global-config",
115120
115259
  "headroom",
115260
+ "frontdoor",
115121
115261
  "categories-local",
115122
115262
  "active-identity"
115123
115263
  ];
@@ -115195,6 +115335,9 @@ function collectDoctorReport(params) {
115195
115335
  shimState.targetPath,
115196
115336
  realpathOrSelf
115197
115337
  );
115338
+ const uid = process.getuid?.();
115339
+ const allowlistInputs = currentHeadroomAllowlistInputs(realFarmFs, paths);
115340
+ const servingHeadroom = resolveServingHeadroomState(realFarmFs, { stateFile: paths.headroomStateFile, legacyStateFile: paths.headroomLegacyStateFile }, realIsProcessRunning);
115198
115341
  const report = runDoctor({
115199
115342
  env: params.env,
115200
115343
  credentialCache: realCredentialCacheEnv(paths),
@@ -115233,8 +115376,13 @@ function collectDoctorReport(params) {
115233
115376
  const statePath = resolved?.path ?? paths.headroomStateFile;
115234
115377
  return { path: statePath, raw: realFarmFs.readFileUtf8(statePath) };
115235
115378
  })(),
115236
- isRunning: realIsProcessRunning
115237
- }
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) } }
115238
115386
  });
115239
115387
  return report;
115240
115388
  }
@@ -123684,7 +123832,9 @@ var DoorHealthEventSchema = external_exports.discriminatedUnion("kind", [
123684
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() }),
123685
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() }),
123686
123834
  external_exports.strictObject({ kind: external_exports.literal("binaryTurnover"), pid: external_exports.number().int().positive(), observedAt: external_exports.number() }),
123687
- 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() })
123688
123838
  ]);
123689
123839
  var QuotaExpiringEventSchema = external_exports.strictObject({
123690
123840
  identity: external_exports.string().min(1),
@@ -123939,6 +124089,12 @@ function createDoorHealthPublisher(hub, now, pid) {
123939
124089
  },
123940
124090
  binaryTurnover: () => {
123941
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() });
123942
124098
  }
123943
124099
  };
123944
124100
  }
@@ -139091,7 +139247,9 @@ init_state();
139091
139247
  init_supervisor();
139092
139248
  function collectHeadroomStatus(fsPort, paths, isRunning) {
139093
139249
  const state = resolveServingHeadroomState(fsPort, { stateFile: paths.headroomStateFile, legacyStateFile: paths.headroomLegacyStateFile }, isRunning)?.state ?? {};
139094
- 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 });
139095
139253
  const settings2 = settingsOf(readGlobalConfig(paths)?.headroom ?? {});
139096
139254
  return {
139097
139255
  state,
@@ -139102,13 +139260,27 @@ function collectHeadroomStatus(fsPort, paths, isRunning) {
139102
139260
  alive: isRunning(session.pid)
139103
139261
  })),
139104
139262
  allowlist,
139105
- allowlistDrifted: state.allowlistHash !== void 0 && state.allowlistHash !== hashAllowlist(allowlist),
139263
+ allowlistDrifted: allowlistDriftInputs !== void 0,
139264
+ frontDoorOrigin: inputs.frontDoorOrigin,
139265
+ allowlistDriftInputs,
139106
139266
  settings: settings2,
139107
139267
  settingsDrifted: state.settingsHash !== void 0 && state.settingsHash !== hashSettings(settings2),
139108
139268
  logPath: paths.headroomLogPath,
139109
139269
  logExists: fsPort.readFileUtf8(paths.headroomLogPath) !== void 0
139110
139270
  };
139111
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
+ }
139112
139284
  function formatHeadroomStatus(status) {
139113
139285
  const lines = [];
139114
139286
  if (status.state.supervisorPid === void 0) {
@@ -139125,7 +139297,7 @@ function formatHeadroomStatus(status) {
139125
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}`)
139126
139298
  );
139127
139299
  }
139128
- 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)})` : "";
139129
139301
  lines.push(`allowlist: ${status.allowlist.join(", ")}${drift}`);
139130
139302
  const configured = Object.entries(status.settings).map(([name, value2]) => `${name} ${String(value2)}`);
139131
139303
  const settingsDrift = status.settingsDrifted ? " (DRIFTED: the configured settings differ from the running daemon's; a restart is pending)" : "";