claude-use 11.44.2 → 11.44.4

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
@@ -34701,7 +34701,7 @@ var init_package = __esm({
34701
34701
  "package.json"() {
34702
34702
  package_default = {
34703
34703
  name: "claude-use",
34704
- version: "11.44.2",
34704
+ version: "11.44.4",
34705
34705
  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.",
34706
34706
  license: "MIT",
34707
34707
  author: "Joseph Mearman <joseph@mearman.co.uk>",
@@ -34986,7 +34986,7 @@ function parseProviderPath(path65) {
34986
34986
  }
34987
34987
  return { provider: decodeURIComponent(tail.slice(0, slash)), rest: tail.slice(slash) };
34988
34988
  }
34989
- var HEADROOM_SESSION_HEADER, INTERNAL_HEADER_NAMES, IDENTITY_HEADER, SESSION_HEADER, PROVIDER_HEADER, HEADROOM_FLAG_HEADER, ROUTE_BY_NAME_HEADER, PROJECT_ID_HEADER, CLIENT_SESSION_HEADER, HEADROOM_BASE_URL_HEADER, AUTH_HEADER, HOP_SECRET_HEADER, HOP_ID_HEADER, MODEL_CHOICE_HEADER, PROVIDER_PATH_PREFIX;
34989
+ var HEADROOM_SESSION_HEADER, INTERNAL_HEADER_NAMES, IDENTITY_HEADER, SESSION_HEADER, PROVIDER_HEADER, HEADROOM_FLAG_HEADER, ROUTE_BY_NAME_HEADER, PROJECT_ID_HEADER, CLIENT_SESSION_HEADER, HEADROOM_BASE_URL_HEADER, AUTH_HEADER, HOP_SECRET_HEADER, HOP_ID_HEADER, PROVIDER_PATH_PREFIX;
34990
34990
  var init_route = __esm({
34991
34991
  "src/frontdoor/route.ts"() {
34992
34992
  "use strict";
@@ -35015,7 +35015,6 @@ var init_route = __esm({
35015
35015
  AUTH_HEADER = "x-agent-shim-auth";
35016
35016
  HOP_SECRET_HEADER = "x-agent-shim-hop";
35017
35017
  HOP_ID_HEADER = "x-agent-shim-hop-id";
35018
- MODEL_CHOICE_HEADER = "x-agent-shim-model-choice";
35019
35018
  PROVIDER_PATH_PREFIX = "/providers/";
35020
35019
  }
35021
35020
  });
@@ -35316,9 +35315,15 @@ function destinationOf(path65, sessionProvider) {
35316
35315
  }
35317
35316
  return { provider: sessionProvider ?? ANTHROPIC_PROVIDER, endpoint: path65 };
35318
35317
  }
35318
+ function modelChoiceOf(event, servedModel, provider) {
35319
+ if (event.modelChoice !== void 0) return event.modelChoice;
35320
+ if (event.requestedModel === void 0 || servedModel === void 0 || event.requestedModel === servedModel) return void 0;
35321
+ return { requested: event.requestedModel, providers: [provider] };
35322
+ }
35319
35323
  function buildRecord(event, context) {
35320
35324
  const { scan } = context;
35321
35325
  const { provider, endpoint } = destinationOf(event.servedPath, event.session.provider);
35326
+ const choice = modelChoiceOf(event, scan?.model, provider);
35322
35327
  const rateLimitHeaders = rateLimitHeadersOf(event.headers);
35323
35328
  const limit = classifyLimit({ status: event.status, headers: rateLimitHeaders ?? {}, error: scan?.error, nowMs: context.endedAt });
35324
35329
  const requestId = headerValue(event.headers, "request-id");
@@ -35335,8 +35340,8 @@ function buildRecord(event, context) {
35335
35340
  method: event.method,
35336
35341
  endpoint,
35337
35342
  ...scan?.model === void 0 ? {} : { model: scan.model },
35338
- ...event.modelChoice === void 0 ? {} : { requestedModel: event.modelChoice.requested },
35339
- ...event.modelChoice !== void 0 && event.modelChoice.providers.length > 1 ? { candidateProviders: [...event.modelChoice.providers] } : {},
35343
+ ...choice === void 0 ? {} : { requestedModel: choice.requested },
35344
+ ...choice !== void 0 && choice.providers.length > 1 ? { candidateProviders: [...choice.providers] } : {},
35340
35345
  status: event.status,
35341
35346
  latencyMs: Math.max(0, Math.round(context.headAt - event.receivedAt)),
35342
35347
  durationMs: Math.max(0, Math.round(context.endedAt - event.receivedAt)),
@@ -115414,7 +115419,7 @@ function collectCodexStatus(fsPort, paths, isRunning) {
115414
115419
  usageSnapshotPath: codexUsageSnapshotPath(),
115415
115420
  usageSnapshotExists: fsPort.readFileUtf8(codexUsageSnapshotPath()) !== void 0,
115416
115421
  logPath: paths.frontdoorLogPath,
115417
- logExists: fsPort.readFileUtf8(paths.frontdoorLogPath) !== void 0
115422
+ logExists: fsPort.lstat(paths.frontdoorLogPath) !== void 0
115418
115423
  };
115419
115424
  }
115420
115425
  function formatSignIn(signIn) {
@@ -116917,8 +116922,6 @@ function createDoorPipelines(deps) {
116917
116922
  direct: {
116918
116923
  resolveRoute: deps.resolveRoute,
116919
116924
  responseObservers: [],
116920
- // The direct pipeline's responses are consumed by this door's own headroom hop, never by a client, so the noted model choice rides the head home as MODEL_CHOICE_HEADER (see `exposeModelChoiceOnHead`) instead of dying with the observers this pipeline deliberately runs none of.
116921
- exposeModelChoiceOnHead: true,
116922
116925
  admit: admitHop(deps.hopSecret, deps.custody),
116923
116926
  headroomDecision: deps.headroomDecision,
116924
116927
  now: deps.now,
@@ -119376,6 +119379,8 @@ function frontDoorRcControl(transport, token) {
119376
119379
  var HEALTH_TIMEOUT_MS = 2e3;
119377
119380
  var HEALTH_START_BUDGET_MS = 5e3;
119378
119381
  var HEALTH_RETRY_MS = 50;
119382
+ var PREFERRED_PORT_MAX_ATTEMPTS = 6;
119383
+ var PREFERRED_PORT_RETRY_MS = 50;
119379
119384
  function createFrontDoorServer(pipeline, log, tls2, control, apis) {
119380
119385
  const handler = (request7, response) => {
119381
119386
  if (request7.method === "GET" && request7.url === "/healthz") {
@@ -119471,16 +119476,25 @@ async function listenFrontDoor(server, options = {}) {
119471
119476
  resolve2(bound2);
119472
119477
  });
119473
119478
  });
119474
- let bound;
119475
- if (preferredPort !== void 0) {
119476
- try {
119477
- bound = await tryListen(preferredPort);
119478
- } catch {
119479
- bound = await tryListen(0);
119479
+ const bindListener = async () => {
119480
+ if (preferredPort === void 0) {
119481
+ return await tryListen(0);
119480
119482
  }
119481
- } else {
119482
- bound = await tryListen(0);
119483
- }
119483
+ for (let attempt = 1; attempt <= PREFERRED_PORT_MAX_ATTEMPTS; attempt += 1) {
119484
+ try {
119485
+ return await tryListen(preferredPort);
119486
+ } catch {
119487
+ if (attempt === PREFERRED_PORT_MAX_ATTEMPTS) {
119488
+ return await tryListen(0);
119489
+ }
119490
+ await new Promise((resolve2) => {
119491
+ setTimeout(resolve2, PREFERRED_PORT_RETRY_MS);
119492
+ });
119493
+ }
119494
+ }
119495
+ return await tryListen(0);
119496
+ };
119497
+ const bound = await bindListener();
119484
119498
  options.onBound?.(bound);
119485
119499
  if (options.onError !== void 0) {
119486
119500
  server.on("error", options.onError);
@@ -130150,7 +130164,7 @@ function responseHeaders(headers) {
130150
130164
  }
130151
130165
  return result;
130152
130166
  }
130153
- async function applyHeadroomHop(request7, response, upstream, deps, onThread) {
130167
+ async function applyHeadroomHop(request7, response, upstream, deps, onFacts) {
130154
130168
  const target = deps.headroomSocket();
130155
130169
  if (target === void 0) {
130156
130170
  await answerBadGateway(response, "agent-shim front door: the headroom daemon is restarting");
@@ -130186,7 +130200,7 @@ async function applyHeadroomHop(request7, response, upstream, deps, onThread) {
130186
130200
  }
130187
130201
  headers[HOP_SECRET_HEADER] = deps.hopSecret;
130188
130202
  try {
130189
- await forwardThroughHeadroom(request7, response, { socketPath, headers, log: deps.log, onThread });
130203
+ await forwardThroughHeadroom(request7, response, { socketPath, headers, log: deps.log, onFacts });
130190
130204
  } finally {
130191
130205
  if (hopId !== void 0) {
130192
130206
  deps.custody.release(hopId);
@@ -130267,21 +130281,17 @@ async function collectBody(body) {
130267
130281
  });
130268
130282
  });
130269
130283
  }
130270
- function parseModelChoiceHeader(value2) {
130271
- if (value2 === void 0) return void 0;
130272
- let parsed;
130284
+ function requestedModelOf(body) {
130273
130285
  try {
130274
- parsed = JSON.parse(value2);
130286
+ const parsed = JSON.parse(body.toString("utf8"));
130287
+ if (typeof parsed !== "object" || parsed === null || !("model" in parsed) || typeof parsed.model !== "string") return void 0;
130288
+ return parsed.model;
130275
130289
  } catch {
130276
130290
  return void 0;
130277
130291
  }
130278
- if (typeof parsed !== "object" || parsed === null || !("requested" in parsed) || !("providers" in parsed) || typeof parsed.requested !== "string" || !Array.isArray(parsed.providers)) return void 0;
130279
- const providers = [];
130280
- for (const name of parsed.providers) {
130281
- if (typeof name !== "string") return void 0;
130282
- providers.push(name);
130283
- }
130284
- return { requested: parsed.requested, providers };
130292
+ }
130293
+ function hopFactsOf(body) {
130294
+ return { lineage: lineageOf(body), requestedModel: requestedModelOf(body) };
130285
130295
  }
130286
130296
  async function forwardThroughHeadroom(request7, response, target) {
130287
130297
  const collected = await collectBody(request7.body);
@@ -130296,7 +130306,7 @@ async function forwardThroughHeadroom(request7, response, target) {
130296
130306
  return;
130297
130307
  }
130298
130308
  const { body } = collected;
130299
- target.onThread(lineageOf(body));
130309
+ target.onFacts(hopFactsOf(body));
130300
130310
  for (let retriesLeft = HOP_RESET_RETRIES; ; retriesLeft -= 1) {
130301
130311
  const outcome = await hopOnce(request7, response, target, body, retriesLeft > 0);
130302
130312
  if (outcome === "settled") {
@@ -130308,12 +130318,7 @@ async function hopOnce(request7, response, target, body, mayRetry) {
130308
130318
  const { socketPath, headers } = target;
130309
130319
  return await new Promise((resolve2) => {
130310
130320
  const onUpstreamResponse = (upstreamResponse) => {
130311
- const { [MODEL_CHOICE_HEADER]: choiceHeader, ...head } = responseHeaders(upstreamResponse.headers);
130312
- const choice = parseModelChoiceHeader(choiceHeader);
130313
- if (choice !== void 0) {
130314
- response.noteModelChoice?.(choice);
130315
- }
130316
- response.start(upstreamResponse.statusCode ?? HTTP_BAD_GATEWAY2, head);
130321
+ response.start(upstreamResponse.statusCode ?? HTTP_BAD_GATEWAY2, responseHeaders(upstreamResponse.headers));
130317
130322
  response.flush();
130318
130323
  const stream = async () => {
130319
130324
  try {
@@ -130439,10 +130444,9 @@ function createRoutedResponse(response, context) {
130439
130444
  return headersSent;
130440
130445
  },
130441
130446
  start: (status, headers) => {
130442
- const head = deps.exposeModelChoiceOnHead === true && request7.modelChoice.value !== void 0 ? { ...headers, [MODEL_CHOICE_HEADER]: JSON.stringify(request7.modelChoice.value) } : headers;
130443
130447
  for (const observe of deps.responseObservers) {
130444
130448
  try {
130445
- const body = observe({ session, route, method: request7.method, path: request7.path, servedPath: context.servedPath, receivedAt: request7.receivedAt, viaHeadroom: request7.viaHeadroom, lineage: request7.thread.lineage, modelChoice: request7.modelChoice.value, status, headers });
130449
+ const body = observe({ session, route, method: request7.method, path: request7.path, servedPath: context.servedPath, receivedAt: request7.receivedAt, viaHeadroom: request7.viaHeadroom, lineage: request7.thread.lineage, modelChoice: request7.modelChoice.value, requestedModel: request7.requestedModel.value, status, headers });
130446
130450
  if (body !== void 0) {
130447
130451
  bodyObservers.push(body);
130448
130452
  }
@@ -130450,7 +130454,7 @@ function createRoutedResponse(response, context) {
130450
130454
  deps.log(`front door: response observer threw for ${route}: ${describeThrown(error63)}`);
130451
130455
  }
130452
130456
  }
130453
- response.writeHead(status, head);
130457
+ response.writeHead(status, headers);
130454
130458
  headersSent = true;
130455
130459
  },
130456
130460
  noteModelChoice: (choice) => {
@@ -130486,7 +130490,7 @@ function createRoutedResponse(response, context) {
130486
130490
  };
130487
130491
  }
130488
130492
  async function serveRouted(request7, deps) {
130489
- const observed = { method: request7.method, path: pathOf(request7.url), receivedAt: deps.now(), viaHeadroom: false, thread: { lineage: void 0 }, modelChoice: { value: void 0 } };
130493
+ const observed = { method: request7.method, path: pathOf(request7.url), receivedAt: deps.now(), viaHeadroom: false, thread: { lineage: void 0 }, modelChoice: { value: void 0 }, requestedModel: { value: void 0 } };
130490
130494
  const identified = identifyRequest(request7.headers);
130491
130495
  const admission = deps.admit({ url: request7.url, headers: request7.headers, forwardable: identified.forwardableHeaders });
130492
130496
  if (!admission.ok) {
@@ -130521,8 +130525,9 @@ async function serveRouted(request7, deps) {
130521
130525
  const response = createRoutedResponse(request7.response, { deps, session: identified.session, route: resolution.route.name, request: { ...observed, viaHeadroom }, servedPath: pathOf(resolution.request?.url ?? request7.url) });
130522
130526
  try {
130523
130527
  if (viaHeadroom) {
130524
- await applyHeadroomHop(resolution.request ?? routed, response, resolution.route.headroomUpstream, deps.headroom, (lineage) => {
130525
- observed.thread.lineage = lineage;
130528
+ await applyHeadroomHop(resolution.request ?? routed, response, resolution.route.headroomUpstream, deps.headroom, (facts) => {
130529
+ observed.thread.lineage = facts.lineage;
130530
+ observed.requestedModel.value = facts.requestedModel;
130526
130531
  });
130527
130532
  } else {
130528
130533
  await resolution.route.serve(routed, response);
@@ -135233,7 +135238,7 @@ function collectFrontDoorStatus(fsPort, socketTrust, paths, isRunning) {
135233
135238
  sessions: listFrontDoorSessions(fsPort, paths.frontdoorSessionsDir).map((session) => ({ ...session, alive: isRunning(session.pid) })),
135234
135239
  headroomSocket: headroomSocketTarget(fsPort, socketTrust, paths),
135235
135240
  logPath: paths.frontdoorLogPath,
135236
- logExists: fsPort.readFileUtf8(paths.frontdoorLogPath) !== void 0
135241
+ logExists: fsPort.lstat(paths.frontdoorLogPath) !== void 0
135237
135242
  };
135238
135243
  }
135239
135244
  function formatFrontDoorStatus(status, caCertPath) {
@@ -147009,7 +147014,7 @@ function collectHeadroomStatus(fsPort, paths, processes) {
147009
147014
  settings: settings2,
147010
147015
  settingsDrifted: state.settingsHash !== void 0 && state.settingsHash !== hashSettings(settings2),
147011
147016
  logPath: paths.headroomLogPath,
147012
- logExists: fsPort.readFileUtf8(paths.headroomLogPath) !== void 0
147017
+ logExists: fsPort.lstat(paths.headroomLogPath) !== void 0
147013
147018
  };
147014
147019
  }
147015
147020
  function formatHeadroomStatus(status) {
package/dist/index.cjs CHANGED
@@ -3151,7 +3151,7 @@ var init_package = __esm({
3151
3151
  "package.json"() {
3152
3152
  package_default = {
3153
3153
  name: "claude-use",
3154
- version: "11.44.2",
3154
+ version: "11.44.4",
3155
3155
  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.",
3156
3156
  license: "MIT",
3157
3157
  author: "Joseph Mearman <joseph@mearman.co.uk>",
@@ -17729,7 +17729,7 @@ function collectFrontDoorStatus(fsPort, socketTrust, paths, isRunning) {
17729
17729
  sessions: listFrontDoorSessions(fsPort, paths.frontdoorSessionsDir).map((session) => ({ ...session, alive: isRunning(session.pid) })),
17730
17730
  headroomSocket: headroomSocketTarget(fsPort, socketTrust, paths),
17731
17731
  logPath: paths.frontdoorLogPath,
17732
- logExists: fsPort.readFileUtf8(paths.frontdoorLogPath) !== void 0
17732
+ logExists: fsPort.lstat(paths.frontdoorLogPath) !== void 0
17733
17733
  };
17734
17734
  }
17735
17735
  function formatFrontDoorStatus(status, caCertPath) {
package/dist/index.mjs CHANGED
@@ -3127,7 +3127,7 @@ var init_package = __esm({
3127
3127
  "package.json"() {
3128
3128
  package_default = {
3129
3129
  name: "claude-use",
3130
- version: "11.44.2",
3130
+ version: "11.44.4",
3131
3131
  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.",
3132
3132
  license: "MIT",
3133
3133
  author: "Joseph Mearman <joseph@mearman.co.uk>",
@@ -17316,7 +17316,7 @@ function collectFrontDoorStatus(fsPort, socketTrust, paths, isRunning) {
17316
17316
  sessions: listFrontDoorSessions(fsPort, paths.frontdoorSessionsDir).map((session) => ({ ...session, alive: isRunning(session.pid) })),
17317
17317
  headroomSocket: headroomSocketTarget(fsPort, socketTrust, paths),
17318
17318
  logPath: paths.frontdoorLogPath,
17319
- logExists: fsPort.readFileUtf8(paths.frontdoorLogPath) !== void 0
17319
+ logExists: fsPort.lstat(paths.frontdoorLogPath) !== void 0
17320
17320
  };
17321
17321
  }
17322
17322
  function formatFrontDoorStatus(status, caCertPath) {