claude-use 11.11.0 → 11.12.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/README.md CHANGED
@@ -159,6 +159,7 @@ agent-shim frontdoor rc mcp-authenticate --session <cse_id> --server <name> --re
159
159
  agent-shim frontdoor rc mcp-oauth-callback-url --session <cse_id> --server <name> --callback-url <url> [--json]
160
160
  agent-shim frontdoor rc watch [<cse_id>] [--json]
161
161
  agent-shim frontdoor rc selfhost mint <identity> [--force] [--json]
162
+ agent-shim statusline # serve as a statusline entrypoint: enrich the client's stdin payload with the identity's live provider, account and usage windows, then delegate to $AGENT_SHIM_STATUSLINE_CMD or render the built-in line
162
163
  agent-shim usage [--identity <name>] [--provider <name>] [--since <duration>] [--refresh] [--json]
163
164
  agent-shim session list [--identity <name>] [--all] [--json] # sessions that spawned agents or ran workflows, from the transcripts on disk
164
165
  agent-shim session show <session> [--identity <name>] [--json] # one session's subagents, forks, workflow agents, tasks and workflow runs
package/dist/cli.cjs CHANGED
@@ -34093,7 +34093,7 @@ var init_package = __esm({
34093
34093
  "package.json"() {
34094
34094
  package_default = {
34095
34095
  name: "claude-use",
34096
- version: "11.11.0",
34096
+ version: "11.12.0",
34097
34097
  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.",
34098
34098
  license: "MIT",
34099
34099
  author: "Joseph Mearman <joseph@mearman.co.uk>",
@@ -63774,10 +63774,10 @@ function resolveLaunch(params) {
63774
63774
  environment
63775
63775
  };
63776
63776
  }
63777
- function runLaunchPlan(plan, spawn6) {
63777
+ function runLaunchPlan(plan, spawn7) {
63778
63778
  try {
63779
63779
  plan.markChildStarted();
63780
- const result = spawn6.spawnSync(plan.bin, plan.args, { stdio: "inherit", env: plan.env });
63780
+ const result = spawn7.spawnSync(plan.bin, plan.args, { stdio: "inherit", env: plan.env });
63781
63781
  if (result.error !== void 0) {
63782
63782
  throw result.error;
63783
63783
  }
@@ -126844,7 +126844,7 @@ function createQuotaExpiringPublisher(hub, deps) {
126844
126844
  latest.set(snapshot.identity, snapshot);
126845
126845
  });
126846
126846
  const announced = /* @__PURE__ */ new Set();
126847
- const windowsOf = (snapshot) => {
126847
+ const windowsOf2 = (snapshot) => {
126848
126848
  const views = [];
126849
126849
  for (const provider of Object.keys(snapshot.providers).sort()) {
126850
126850
  const unified = snapshot.providers[provider]?.rateLimit?.unified;
@@ -126867,7 +126867,7 @@ function createQuotaExpiringPublisher(hub, deps) {
126867
126867
  if (snapshot === void 0) {
126868
126868
  continue;
126869
126869
  }
126870
- for (const { provider, view } of windowsOf(snapshot)) {
126870
+ for (const { provider, view } of windowsOf2(snapshot)) {
126871
126871
  if (view.utilization >= 1 || view.resetsAtMs <= now || view.resetsAtMs - now >= view.spanMs * QUOTA_EXPIRING_WINDOW_FRACTION) {
126872
126872
  continue;
126873
126873
  }
@@ -127792,11 +127792,13 @@ function resolveAntigravityConfig(config2) {
127792
127792
  }
127793
127793
  };
127794
127794
  }
127795
+ var CONTEXT_MARKER_1M = "[1m]";
127795
127796
  function mapModel2(requested, config2) {
127796
- if (requested.startsWith("gemini-") || requested.startsWith("antigravity-")) {
127797
- return requested;
127797
+ const stripped = requested.toLowerCase().endsWith(CONTEXT_MARKER_1M) ? requested.slice(0, -CONTEXT_MARKER_1M.length) : requested;
127798
+ if (stripped.startsWith("gemini-") || stripped.startsWith("antigravity-")) {
127799
+ return stripped;
127798
127800
  }
127799
- const lower = requested.toLowerCase();
127801
+ const lower = stripped.toLowerCase();
127800
127802
  const tier = ANTIGRAVITY_TIERS.find((candidate) => lower.includes(candidate));
127801
127803
  return tier === void 0 ? config2.defaultModel : config2.models[tier];
127802
127804
  }
@@ -128054,8 +128056,8 @@ function translateRequest2(request7, config2) {
128054
128056
  init_cloudUpstream();
128055
128057
  var MS_PER_SECOND8 = 1e3;
128056
128058
  var DEFAULT_RETRY_AFTER_SECONDS = 60;
128057
- var PERCENT_MULTIPLIER = 100;
128058
- var EXHAUSTED_PERCENT = "100";
128059
+ var FRACTION_DIGITS = 3;
128060
+ var EXHAUSTED_FRACTION = "1.000";
128059
128061
  var GEMINI_5H_KEYS = ["gemini-5h", "gemini_5h", "gemini"];
128060
128062
  var GEMINI_WEEKLY_KEYS = ["gemini-weekly", "gemini_weekly"];
128061
128063
  var THIRD_PARTY_5H_KEYS = ["3p-5h", "claude-5h", "3p_5h", "claude_5h", "claude"];
@@ -128075,7 +128077,7 @@ function calculateUtilization(remainingFraction) {
128075
128077
  }
128076
128078
  const clampedRem = Math.max(0, Math.min(1, remainingFraction));
128077
128079
  const used = Math.max(0, 1 - clampedRem);
128078
- return String(Math.round(used * PERCENT_MULTIPLIER));
128080
+ return used.toFixed(FRACTION_DIGITS);
128079
128081
  }
128080
128082
  function calculateResetTimestamp(nowSec, resetInSeconds) {
128081
128083
  if (resetInSeconds === void 0 || !Number.isFinite(resetInSeconds) || resetInSeconds < 0) {
@@ -128101,9 +128103,6 @@ function parseRetryAfterSeconds(raw, defaultSeconds = DEFAULT_RETRY_AFTER_SECOND
128101
128103
  function unifiedAntigravityQuotaHeaders(params) {
128102
128104
  const rejected = params.rejected === true;
128103
128105
  const nowSec = Math.floor(params.nowMs / MS_PER_SECOND8);
128104
- const headers = {
128105
- "anthropic-ratelimit-unified-status": rejected ? "rejected" : "allowed"
128106
- };
128107
128106
  const modelLower = (params.model ?? "").toLowerCase();
128108
128107
  const isGemini = modelLower.includes("gemini");
128109
128108
  const fiveHourKeys = isGemini ? GEMINI_5H_KEYS : THIRD_PARTY_5H_KEYS;
@@ -128115,6 +128114,12 @@ function unifiedAntigravityQuotaHeaders(params) {
128115
128114
  const reset5h = calculateResetTimestamp(nowSec, b5h?.reset_in_seconds);
128116
128115
  const used7d = calculateUtilization(bWk?.remaining_fraction);
128117
128116
  const reset7d = calculateResetTimestamp(nowSec, bWk?.reset_in_seconds);
128117
+ if (!rejected && used5h === void 0 && reset5h === void 0 && used7d === void 0 && reset7d === void 0) {
128118
+ return {};
128119
+ }
128120
+ const headers = {
128121
+ "anthropic-ratelimit-unified-status": rejected ? "rejected" : "allowed"
128122
+ };
128118
128123
  let earliestResetSec;
128119
128124
  if (used5h !== void 0 && reset5h !== void 0) {
128120
128125
  headers["anthropic-ratelimit-unified-5h-utilization"] = used5h;
@@ -128131,11 +128136,11 @@ function unifiedAntigravityQuotaHeaders(params) {
128131
128136
  const retrySec = params.retryAfterSeconds ?? DEFAULT_RETRY_AFTER_SECONDS;
128132
128137
  const fallbackReset = String(nowSec + retrySec);
128133
128138
  if (headers["anthropic-ratelimit-unified-5h-utilization"] === void 0) {
128134
- headers["anthropic-ratelimit-unified-5h-utilization"] = EXHAUSTED_PERCENT;
128139
+ headers["anthropic-ratelimit-unified-5h-utilization"] = EXHAUSTED_FRACTION;
128135
128140
  headers["anthropic-ratelimit-unified-5h-reset"] = fallbackReset;
128136
128141
  }
128137
128142
  if (headers["anthropic-ratelimit-unified-7d-utilization"] === void 0) {
128138
- headers["anthropic-ratelimit-unified-7d-utilization"] = EXHAUSTED_PERCENT;
128143
+ headers["anthropic-ratelimit-unified-7d-utilization"] = EXHAUSTED_FRACTION;
128139
128144
  headers["anthropic-ratelimit-unified-7d-reset"] = fallbackReset;
128140
128145
  }
128141
128146
  earliestResetSec = earliestResetSec === void 0 ? nowSec + retrySec : Math.min(earliestResetSec, nowSec + retrySec);
@@ -128370,10 +128375,10 @@ function quotaHeaders(upstream) {
128370
128375
  }
128371
128376
  return headers;
128372
128377
  }
128373
- var EXHAUSTED_PERCENT2 = "100";
128378
+ var EXHAUSTED_PERCENT = "100";
128374
128379
  function unifiedQuotaHeaders(upstream, rejected, quotaError) {
128375
128380
  const headers = { "anthropic-ratelimit-unified-status": rejected ? "rejected" : "allowed" };
128376
- const used7d = upstream.get("x-codex-primary-used-percent") ?? (rejected ? EXHAUSTED_PERCENT2 : null);
128381
+ const used7d = upstream.get("x-codex-primary-used-percent") ?? (rejected ? EXHAUSTED_PERCENT : null);
128377
128382
  const reset7d = upstream.get("x-codex-primary-reset-at") ?? (quotaError?.resets_at === void 0 ? null : String(quotaError.resets_at));
128378
128383
  if (used7d !== null && reset7d !== null) {
128379
128384
  headers["anthropic-ratelimit-unified-7d-utilization"] = used7d;
@@ -128396,7 +128401,7 @@ function unifiedQuotaHeaders(upstream, rejected, quotaError) {
128396
128401
  }
128397
128402
  var MS_PER_SECOND9 = 1e3;
128398
128403
  function buildUsageSnapshot(upstream, quotaError, nowMs) {
128399
- const used7 = upstream.get("x-codex-primary-used-percent") ?? (quotaError === void 0 ? null : EXHAUSTED_PERCENT2);
128404
+ const used7 = upstream.get("x-codex-primary-used-percent") ?? (quotaError === void 0 ? null : EXHAUSTED_PERCENT);
128400
128405
  const reset7 = upstream.get("x-codex-primary-reset-at") ?? (quotaError?.resets_at === void 0 ? null : String(quotaError.resets_at));
128401
128406
  const sevenDay = used7 !== null && reset7 !== null ? { used_percentage: Number(used7), resets_at: new Date(Number(reset7) * MS_PER_SECOND9).toISOString() } : void 0;
128402
128407
  let fiveHour;
@@ -128888,10 +128893,12 @@ function createAntigravityRelay(params) {
128888
128893
  frames.length = 0;
128889
128894
  ensureStarted();
128890
128895
  if (chunk.usageMetadata !== void 0) {
128896
+ const cached2 = chunk.usageMetadata.cachedContentTokenCount ?? 0;
128897
+ const promptTotal = chunk.usageMetadata.promptTokenCount ?? usage.input_tokens + cached2;
128891
128898
  usage = {
128892
- input_tokens: chunk.usageMetadata.promptTokenCount ?? usage.input_tokens,
128899
+ input_tokens: Math.max(0, promptTotal - cached2),
128893
128900
  cache_creation_input_tokens: 0,
128894
- cache_read_input_tokens: 0,
128901
+ cache_read_input_tokens: cached2,
128895
128902
  output_tokens: chunk.usageMetadata.candidatesTokenCount ?? usage.output_tokens
128896
128903
  };
128897
128904
  }
@@ -133242,6 +133249,382 @@ function registerFrontDoorCommand(program2, deps) {
133242
133249
  });
133243
133250
  }
133244
133251
 
133252
+ // src/statusline/commands.ts
133253
+ var import_node_child_process7 = require("node:child_process");
133254
+ init_commandDeps();
133255
+ init_realPorts();
133256
+ init_read();
133257
+
133258
+ // src/statusline/enrich.ts
133259
+ var FULL_PERCENT = 100;
133260
+ function identityOf(env) {
133261
+ const headers = env.ANTHROPIC_CUSTOM_HEADERS;
133262
+ if (headers !== void 0) {
133263
+ const match = /x-agent-shim-identity:\s*([A-Za-z0-9@._-]+)/i.exec(headers);
133264
+ if (match !== null) {
133265
+ return match[1];
133266
+ }
133267
+ }
133268
+ const configDir = env.CLAUDE_CONFIG_DIR;
133269
+ if (configDir !== void 0) {
133270
+ const slash = configDir.lastIndexOf("/");
133271
+ const name = slash === -1 ? "" : configDir.slice(slash + 1);
133272
+ const parent = slash === -1 ? "" : configDir.slice(0, slash);
133273
+ const parentSlash = parent.lastIndexOf("/");
133274
+ if (parentSlash !== -1 && parent.slice(parentSlash + 1) === "identities" && name !== "") {
133275
+ return name;
133276
+ }
133277
+ }
133278
+ return void 0;
133279
+ }
133280
+ function windowsOf(states) {
133281
+ let fiveHourUsed;
133282
+ let fiveHourResetAt;
133283
+ let sevenDayUsed;
133284
+ let sevenDayResetAt;
133285
+ for (const state of states) {
133286
+ const unified = state.rateLimit?.unified;
133287
+ if (unified === void 0) {
133288
+ continue;
133289
+ }
133290
+ const fiveWindow = unified.fiveHour === void 0 ? void 0 : unified.fiveHour.utilization;
133291
+ const five = typeof fiveWindow === "number" && Number.isFinite(fiveWindow) ? Math.round(Math.min(1, Math.max(0, fiveWindow)) * FULL_PERCENT) : void 0;
133292
+ if (five !== void 0 && (fiveHourUsed === void 0 || five > fiveHourUsed)) {
133293
+ fiveHourUsed = five;
133294
+ fiveHourResetAt = unified.fiveHour?.resetsAt;
133295
+ }
133296
+ const sevenWindow = unified.sevenDay === void 0 ? void 0 : unified.sevenDay.utilization;
133297
+ const seven = typeof sevenWindow === "number" && Number.isFinite(sevenWindow) ? Math.round(Math.min(1, Math.max(0, sevenWindow)) * FULL_PERCENT) : void 0;
133298
+ if (seven !== void 0 && (sevenDayUsed === void 0 || seven > sevenDayUsed)) {
133299
+ sevenDayUsed = seven;
133300
+ sevenDayResetAt = unified.sevenDay?.resetsAt;
133301
+ }
133302
+ }
133303
+ return { fiveHourUsed, fiveHourResetAt, sevenDayUsed, sevenDayResetAt };
133304
+ }
133305
+ function enrichStatuslinePayload(params) {
133306
+ const identity = identityOf(params.env);
133307
+ let summary = {
133308
+ identity,
133309
+ provider: params.env.AGENT_SHIM_PROVIDER === void 0 || params.env.AGENT_SHIM_PROVIDER === "" ? void 0 : params.env.AGENT_SHIM_PROVIDER,
133310
+ providerAccountEmail: void 0,
133311
+ fiveHourUsed: void 0,
133312
+ fiveHourResetAt: void 0,
133313
+ sevenDayUsed: void 0,
133314
+ sevenDayResetAt: void 0
133315
+ };
133316
+ if (params.snapshot !== void 0) {
133317
+ const scopedName = providerScopedState(params.snapshot, params.env.AGENT_SHIM_PROVIDER);
133318
+ const scopedState = scopedName === void 0 ? void 0 : params.snapshot.providers[scopedName];
133319
+ const states = scopedState === void 0 ? Object.values(params.snapshot.providers) : [scopedState];
133320
+ let email3;
133321
+ for (const state of states) {
133322
+ const candidate = state.quota?.account?.email;
133323
+ if (email3 === void 0 && typeof candidate === "string" && candidate !== "") {
133324
+ email3 = candidate;
133325
+ }
133326
+ }
133327
+ summary = { ...summary, ...windowsOf(states), providerAccountEmail: email3 };
133328
+ }
133329
+ if (typeof params.payload !== "object" || params.payload === null || Array.isArray(params.payload)) {
133330
+ return { payload: params.payload, summary };
133331
+ }
133332
+ const enriched = { agent_shim: summary };
133333
+ for (const [key, value2] of Object.entries(params.payload)) {
133334
+ enriched[key] = value2;
133335
+ }
133336
+ return { payload: enriched, summary };
133337
+ }
133338
+ function providerScopedState(snapshot, providerDisplayName) {
133339
+ if (providerDisplayName === void 0 || providerDisplayName === "") {
133340
+ return void 0;
133341
+ }
133342
+ const wanted = providerDisplayName.toLowerCase();
133343
+ for (const name of Object.keys(snapshot.providers)) {
133344
+ if (name.toLowerCase() === wanted) {
133345
+ return name;
133346
+ }
133347
+ }
133348
+ return void 0;
133349
+ }
133350
+
133351
+ // src/statusline/render.ts
133352
+ var BAR_WIDTH = 10;
133353
+ var SECONDS_PER_MINUTE2 = 60;
133354
+ var MINUTES_PER_HOUR3 = 60;
133355
+ var SECONDS_PER_DAY = 86400;
133356
+ var THOUSAND = 1e3;
133357
+ var MILLION = 1e6;
133358
+ var TEN = 10;
133359
+ var TWENTY = 20;
133360
+ var RESERVED_COLUMNS = 4;
133361
+ var SEPARATOR2 = " | ";
133362
+ var FULL_PERCENT2 = 100;
133363
+ var USED_RED_AT = 0.9;
133364
+ var USED_YELLOW_AT = 0.7;
133365
+ var ESCAPE_CHAR_CODE = 27;
133366
+ var ESCAPE = String.fromCharCode(ESCAPE_CHAR_CODE);
133367
+ var RESET = `${ESCAPE}[0m`;
133368
+ var DIM = `${ESCAPE}[90m`;
133369
+ var GREEN = `${ESCAPE}[32m`;
133370
+ var YELLOW = `${ESCAPE}[33m`;
133371
+ var RED = `${ESCAPE}[31m`;
133372
+ var ANSI_REGEX = new RegExp(`${ESCAPE}\\[[0-9;]*[a-zA-Z]`, "g");
133373
+ function visibleLength(text2) {
133374
+ return text2.replace(ANSI_REGEX, "").length;
133375
+ }
133376
+ function colorize() {
133377
+ return process.env.NO_COLOR === void 0;
133378
+ }
133379
+ function statusColor(fraction, isUsedMetric) {
133380
+ if (!colorize()) {
133381
+ return "";
133382
+ }
133383
+ if (isUsedMetric) {
133384
+ if (fraction >= USED_RED_AT) {
133385
+ return RED;
133386
+ }
133387
+ return fraction >= USED_YELLOW_AT ? YELLOW : GREEN;
133388
+ }
133389
+ if (fraction <= 1 - USED_RED_AT) {
133390
+ return RED;
133391
+ }
133392
+ return fraction <= 1 - USED_YELLOW_AT ? YELLOW : GREEN;
133393
+ }
133394
+ function formatTokens(num) {
133395
+ if (num >= MILLION) {
133396
+ const val = num / MILLION;
133397
+ return val % 1 === 0 ? `${String(Math.round(val))}M` : `${val.toFixed(1)}M`;
133398
+ }
133399
+ if (num >= THOUSAND) {
133400
+ const val = num / THOUSAND;
133401
+ return val >= TEN ? `${String(Math.round(val))}k` : `${val.toFixed(1)}k`;
133402
+ }
133403
+ return String(Math.round(num));
133404
+ }
133405
+ function formatDuration(seconds) {
133406
+ if (seconds === void 0 || seconds <= 0) {
133407
+ return "available";
133408
+ }
133409
+ const days = Math.floor(seconds / SECONDS_PER_DAY);
133410
+ const hours = Math.floor(seconds % SECONDS_PER_DAY / (MINUTES_PER_HOUR3 * SECONDS_PER_MINUTE2));
133411
+ const minutes = Math.floor(seconds % (MINUTES_PER_HOUR3 * SECONDS_PER_MINUTE2) / SECONDS_PER_MINUTE2);
133412
+ if (days > 0) {
133413
+ return `${String(days)}d ${String(hours)}h`;
133414
+ }
133415
+ if (hours > 0) {
133416
+ return `${String(hours)}h ${String(minutes).padStart(2, "0")}m`;
133417
+ }
133418
+ return `${String(minutes)}m`;
133419
+ }
133420
+ function cacheShareText(view) {
133421
+ const hitRatio = view.cacheHitRatio;
133422
+ if (hitRatio !== void 0 && Number.isFinite(hitRatio)) {
133423
+ return ` (Cache: ${(Math.max(0, Math.min(1, hitRatio)) * FULL_PERCENT2).toFixed(0)}%)`;
133424
+ }
133425
+ const promptTotal = (view.cacheReadTokens ?? 0) + (view.freshInputTokens ?? 0);
133426
+ if (promptTotal > 0 && (view.cacheReadTokens ?? 0) > 0) {
133427
+ return ` (Cache: ${((view.cacheReadTokens ?? 0) / promptTotal * FULL_PERCENT2).toFixed(0)}%)`;
133428
+ }
133429
+ return "";
133430
+ }
133431
+ function secondsUntil(resetAt, nowMs) {
133432
+ if (resetAt === void 0) {
133433
+ return void 0;
133434
+ }
133435
+ const resetMs = Date.parse(resetAt);
133436
+ return Number.isNaN(resetMs) ? void 0 : Math.max(0, Math.round((resetMs - nowMs) / THOUSAND));
133437
+ }
133438
+ var Segment = class {
133439
+ constructor(kind, text2 = "", prefix = "", suffix = "", fraction = 0, isUsed = true) {
133440
+ this.kind = kind;
133441
+ this.text = text2;
133442
+ this.prefix = prefix;
133443
+ this.suffix = suffix;
133444
+ this.fraction = fraction;
133445
+ this.isUsed = isUsed;
133446
+ }
133447
+ kind;
133448
+ text;
133449
+ prefix;
133450
+ suffix;
133451
+ fraction;
133452
+ isUsed;
133453
+ baseLength(baseBarWidth) {
133454
+ if (this.kind === "static") {
133455
+ return visibleLength(this.text);
133456
+ }
133457
+ return visibleLength(this.prefix) + baseBarWidth + 2 + visibleLength(this.suffix);
133458
+ }
133459
+ render(barWidth) {
133460
+ if (this.kind === "static") {
133461
+ return this.text;
133462
+ }
133463
+ const clamped = Math.max(0, Math.min(1, this.fraction));
133464
+ const filled = Math.round(clamped * barWidth);
133465
+ const color = statusColor(clamped, this.isUsed);
133466
+ const bar = color === "" ? `[${"\u2588".repeat(filled)}${"\u2591".repeat(barWidth - filled)}]` : `[${color}${"\u2588".repeat(filled)}${DIM}${"\u2591".repeat(barWidth - filled)}${RESET}]`;
133467
+ return `${this.prefix}${bar}${this.suffix}`;
133468
+ }
133469
+ };
133470
+ function renderLineWithExtra(segments, maxWidth, separator, baseBarWidth) {
133471
+ const separatorLength = visibleLength(separator);
133472
+ const bars = segments.filter((segment) => segment.kind === "bar");
133473
+ const lineBase = segments.reduce((total, segment) => total + segment.baseLength(baseBarWidth), 0) + separatorLength * (segments.length - 1);
133474
+ const extra = Math.max(0, maxWidth - lineBase);
133475
+ const extraById = /* @__PURE__ */ new Map();
133476
+ if (bars.length > 0 && extra > 0) {
133477
+ const perBar = Math.floor(extra / bars.length);
133478
+ const remainder = extra % bars.length;
133479
+ bars.forEach((bar, index) => {
133480
+ extraById.set(bar, perBar + (index < remainder ? 1 : 0));
133481
+ });
133482
+ }
133483
+ return segments.map((segment) => segment.render(baseBarWidth + (extraById.get(segment) ?? 0))).join(separator);
133484
+ }
133485
+ function layoutGrouped(group1, group2, maxWidth, fillMode, separator, baseBarWidth) {
133486
+ const separatorLength = visibleLength(separator);
133487
+ const allSegments = [...group1, ...group2];
133488
+ if (allSegments.length === 0) {
133489
+ return "";
133490
+ }
133491
+ const fillUnwrapped = fillMode === "always";
133492
+ const fillWrapped = fillMode === "always" || fillMode === "wrapped";
133493
+ const totalBase = allSegments.reduce((total, segment) => total + segment.baseLength(baseBarWidth), 0) + separatorLength * (allSegments.length - 1);
133494
+ if (totalBase <= maxWidth) {
133495
+ if (fillUnwrapped) {
133496
+ return renderLineWithExtra(allSegments, maxWidth, separator, baseBarWidth);
133497
+ }
133498
+ return allSegments.map((segment) => segment.render(baseBarWidth)).join(separator);
133499
+ }
133500
+ const lines = [group1, group2].map((group) => {
133501
+ if (group.length === 0) {
133502
+ return "";
133503
+ }
133504
+ const groupBase = group.reduce((total, segment) => total + segment.baseLength(baseBarWidth), 0) + separatorLength * (group.length - 1);
133505
+ if (groupBase <= maxWidth) {
133506
+ return fillWrapped ? renderLineWithExtra(group, maxWidth, separator, baseBarWidth) : group.map((segment) => segment.render(baseBarWidth)).join(separator);
133507
+ }
133508
+ return group.map((segment) => fillWrapped ? renderLineWithExtra([segment], maxWidth, separator, baseBarWidth) : segment.render(baseBarWidth)).join("\n");
133509
+ });
133510
+ return lines.filter((line) => line !== "").join("\n");
133511
+ }
133512
+ function renderStatuslineBlock(summary, view, terminalWidth, nowMs) {
133513
+ const header = [];
133514
+ if (view.modelDisplayName !== void 0 && view.modelDisplayName !== "") {
133515
+ header.push(new Segment("static", view.modelDisplayName));
133516
+ }
133517
+ const contextGroup = [];
133518
+ if (view.contextUsedPercentage !== void 0) {
133519
+ const fraction = Math.max(0, Math.min(1, view.contextUsedPercentage / FULL_PERCENT2));
133520
+ const color = statusColor(fraction, true);
133521
+ const percent2 = `${color}${view.contextUsedPercentage.toFixed(1)}%${RESET}`;
133522
+ const tokens = view.contextTotalTokens !== void 0 && view.contextWindowTokens !== void 0 ? `${formatTokens(view.contextTotalTokens)}/${formatTokens(view.contextWindowTokens)} ` : "";
133523
+ const cache = cacheShareText(view);
133524
+ contextGroup.push(new Segment("bar", "", `Ctx ${tokens}`, ` ${percent2}${cache}`, fraction, true));
133525
+ }
133526
+ const quotaGroup = [];
133527
+ if (summary.fiveHourUsed !== void 0) {
133528
+ const fraction = Math.max(0, Math.min(1, summary.fiveHourUsed / FULL_PERCENT2));
133529
+ const color = statusColor(fraction, true);
133530
+ quotaGroup.push(new Segment("bar", "", "5h ", ` ${color}${summary.fiveHourUsed.toFixed(1)}%${RESET} (${formatDuration(secondsUntil(summary.fiveHourResetAt, nowMs))})`, fraction, true));
133531
+ }
133532
+ if (summary.sevenDayUsed !== void 0) {
133533
+ const fraction = Math.max(0, Math.min(1, summary.sevenDayUsed / FULL_PERCENT2));
133534
+ const color = statusColor(fraction, true);
133535
+ quotaGroup.push(new Segment("bar", "", "Wk ", ` ${color}${summary.sevenDayUsed.toFixed(1)}%${RESET} (${formatDuration(secondsUntil(summary.sevenDayResetAt, nowMs))})`, fraction, true));
133536
+ }
133537
+ if (summary.provider !== void 0) {
133538
+ quotaGroup.push(new Segment("static", summary.providerAccountEmail === void 0 ? summary.provider : `${summary.provider} \xB7 ${summary.providerAccountEmail}`));
133539
+ }
133540
+ const width = Math.max(TWENTY, terminalWidth - RESERVED_COLUMNS);
133541
+ const lines = [];
133542
+ if (header.length > 0) {
133543
+ lines.push(header.map((segment) => segment.render(BAR_WIDTH)).join(SEPARATOR2));
133544
+ }
133545
+ const body = layoutGrouped(contextGroup, quotaGroup, width, "always", SEPARATOR2, BAR_WIDTH);
133546
+ if (body !== "") {
133547
+ lines.push(body);
133548
+ }
133549
+ return lines.join("\n");
133550
+ }
133551
+
133552
+ // src/statusline/commands.ts
133553
+ function payloadViewOf(payload) {
133554
+ const empty = { modelDisplayName: void 0, contextUsedPercentage: void 0, contextTotalTokens: void 0, contextWindowTokens: void 0, cacheHitRatio: void 0, cacheReadTokens: void 0, freshInputTokens: void 0 };
133555
+ if (typeof payload !== "object" || payload === null || Array.isArray(payload)) {
133556
+ return empty;
133557
+ }
133558
+ const record2 = {};
133559
+ for (const [key, value2] of Object.entries(payload)) {
133560
+ record2[key] = value2;
133561
+ }
133562
+ const model = record2.model;
133563
+ const displayName = typeof model === "object" && model !== null && !Array.isArray(model) && "display_name" in model && typeof model.display_name === "string" ? model.display_name : void 0;
133564
+ const context = record2.context_window;
133565
+ const ctx = typeof context === "object" && context !== null && !Array.isArray(context) ? context : void 0;
133566
+ const used = ctx !== void 0 && "used_percentage" in ctx && typeof ctx.used_percentage === "number" ? ctx.used_percentage : void 0;
133567
+ const totalIn = ctx !== void 0 && "total_input_tokens" in ctx && typeof ctx.total_input_tokens === "number" ? ctx.total_input_tokens : void 0;
133568
+ const size = ctx !== void 0 && "context_window_size" in ctx && typeof ctx.context_window_size === "number" ? ctx.context_window_size : void 0;
133569
+ const current = ctx !== void 0 && "current_usage" in ctx && typeof ctx.current_usage === "object" && ctx.current_usage !== null && !Array.isArray(ctx.current_usage) ? ctx.current_usage : void 0;
133570
+ const cacheRead = current !== void 0 && "cache_read_input_tokens" in current && typeof current.cache_read_input_tokens === "number" ? current.cache_read_input_tokens : void 0;
133571
+ const fresh = current !== void 0 && "input_tokens" in current && typeof current.input_tokens === "number" ? current.input_tokens : void 0;
133572
+ const promptCache = record2.prompt_cache;
133573
+ const cache = typeof promptCache === "object" && promptCache !== null && !Array.isArray(promptCache) ? promptCache : void 0;
133574
+ const hitRatio = cache !== void 0 && "hit_ratio" in cache && typeof cache.hit_ratio === "number" ? cache.hit_ratio : void 0;
133575
+ return { modelDisplayName: displayName, contextUsedPercentage: used, contextTotalTokens: totalIn, contextWindowTokens: size, cacheHitRatio: hitRatio, cacheReadTokens: cacheRead, freshInputTokens: fresh };
133576
+ }
133577
+ async function readAllStdin() {
133578
+ return await new Promise((resolve2) => {
133579
+ const chunks = [];
133580
+ process.stdin.on("data", (chunk) => {
133581
+ chunks.push(chunk);
133582
+ });
133583
+ process.stdin.on("end", () => {
133584
+ resolve2(Buffer.concat(chunks).toString("utf8"));
133585
+ });
133586
+ process.stdin.resume();
133587
+ });
133588
+ }
133589
+ var DEFAULT_COLUMNS = 80;
133590
+ function registerStatuslineCommand(program2, deps) {
133591
+ withExamples(
133592
+ program2.command("statusline").description("Serve as a statusline entrypoint: read the client's stdin payload, add the identity's live provider, account and usage windows under an agent_shim key, then run the renderer named in AGENT_SHIM_STATUSLINE_CMD or print the built-in line.").action(async () => {
133593
+ const stdin2 = await readAllStdin();
133594
+ let payload;
133595
+ try {
133596
+ payload = JSON.parse(stdin2);
133597
+ } catch {
133598
+ payload = void 0;
133599
+ }
133600
+ const identity = identityOf(process.env);
133601
+ let snapshot;
133602
+ if (identity !== void 0) {
133603
+ try {
133604
+ snapshot = readUsageSnapshot(realFarmFs, deps.paths.usageSnapshotsDir, identity);
133605
+ } catch {
133606
+ snapshot = void 0;
133607
+ }
133608
+ }
133609
+ const { payload: enriched, summary } = enrichStatuslinePayload({ payload, env: process.env, snapshot });
133610
+ const renderer = process.env.AGENT_SHIM_STATUSLINE_CMD;
133611
+ if (renderer !== void 0 && renderer !== "") {
133612
+ const child = (0, import_node_child_process7.spawn)("/bin/sh", ["-c", renderer], { stdio: ["pipe", "inherit", "inherit"] });
133613
+ child.stdin.end(`${JSON.stringify(enriched)}
133614
+ `);
133615
+ child.on("close", (code) => {
133616
+ process.exit(code ?? 0);
133617
+ });
133618
+ return;
133619
+ }
133620
+ const view = payloadViewOf(payload);
133621
+ const columns = Number.parseInt(process.env.COLUMNS ?? "", 10);
133622
+ console.log(renderStatuslineBlock(summary, view, Number.isNaN(columns) ? DEFAULT_COLUMNS : columns, Date.now()));
133623
+ }),
133624
+ ["$ agent-shim statusline # a client's statusline setting names this; it renders or delegates"]
133625
+ );
133626
+ }
133627
+
133245
133628
  // node_modules/.pnpm/@modelcontextprotocol+sdk@1.32.0_supports-color@7.2.0_zod@4.6.5/node_modules/@modelcontextprotocol/sdk/dist/esm/server/stdio.js
133246
133629
  var import_node_process6 = __toESM(require("node:process"), 1);
133247
133630
 
@@ -143320,7 +143703,7 @@ function registerCompletionCommand(program2) {
143320
143703
  }
143321
143704
 
143322
143705
  // src/credentialCommand.ts
143323
- var import_node_child_process7 = require("node:child_process");
143706
+ var import_node_child_process8 = require("node:child_process");
143324
143707
  init_commandDeps();
143325
143708
  init_cliError();
143326
143709
  init_credential();
@@ -143380,7 +143763,7 @@ function realCommandPorts(deps) {
143380
143763
  cache: createRealCredentialCache(deps.paths.root),
143381
143764
  platform: process.platform,
143382
143765
  now: () => Date.now(),
143383
- ssh: (host, remoteCommand, input2) => (0, import_node_child_process7.spawnSync)("ssh", ["--", host, remoteCommand], { input: input2, stdio: ["pipe", "inherit", "inherit"] }).status
143766
+ ssh: (host, remoteCommand, input2) => (0, import_node_child_process8.spawnSync)("ssh", ["--", host, remoteCommand], { input: input2, stdio: ["pipe", "inherit", "inherit"] }).status
143384
143767
  };
143385
143768
  }
143386
143769
  var REMOTE_ROOT_SCRIPT = 'root="${AGENT_SHIM_HOME:-${CLAUDE_USE_HOME:-}}"; if [ -z "$root" ]; then if [ ! -d "$HOME/.agent-shim" ] && [ -d "$HOME/.claude-use" ]; then root="$HOME/.claude-use"; else root="$HOME/.agent-shim"; fi; fi';
@@ -143517,7 +143900,7 @@ function registerDoctorCommand(program2, deps) {
143517
143900
  var import_node_fs22 = __toESM(require("node:fs"), 1);
143518
143901
  var import_node_http4 = __toESM(require("node:http"), 1);
143519
143902
  var import_node_path54 = __toESM(require("node:path"), 1);
143520
- var import_node_child_process8 = require("node:child_process");
143903
+ var import_node_child_process9 = require("node:child_process");
143521
143904
  init_commandDeps();
143522
143905
  init_realFrontDoorPort();
143523
143906
  init_trust();
@@ -143701,7 +144084,7 @@ async function readyOverSocket(socketPath) {
143701
144084
  }
143702
144085
  var HEADROOM_TOOL_NAME = "headroom-ai";
143703
144086
  function readInstalledHeadroomCommit() {
143704
- const toolDir = (0, import_node_child_process8.spawnSync)("uv", ["tool", "dir"], { encoding: "utf8" });
144087
+ const toolDir = (0, import_node_child_process9.spawnSync)("uv", ["tool", "dir"], { encoding: "utf8" });
143705
144088
  if (toolDir.status !== 0) {
143706
144089
  return void 0;
143707
144090
  }
@@ -143745,7 +144128,7 @@ function realSupervisorPorts(paths) {
143745
144128
  }
143746
144129
  const logFd = import_node_fs22.default.openSync(paths.headroomLogPath, "a");
143747
144130
  try {
143748
- const child = (0, import_node_child_process8.spawn)("headroom", headroomProxyArgs(socketPath, allowlistFile, settings2), {
144131
+ const child = (0, import_node_child_process9.spawn)("headroom", headroomProxyArgs(socketPath, allowlistFile, settings2), {
143749
144132
  detached: true,
143750
144133
  stdio: ["ignore", logFd, logFd],
143751
144134
  env: headroomSpawnEnv(process.env, settings2, trust?.path)
@@ -143785,7 +144168,7 @@ function realSupervisorPorts(paths) {
143785
144168
  },
143786
144169
  ready: readyOverSocket,
143787
144170
  install: (spec) => {
143788
- const result = (0, import_node_child_process8.spawnSync)("uv", ["tool", "install", spec], { encoding: "utf8", timeout: HEADROOM_INSTALL_TIMEOUT_MS });
144171
+ const result = (0, import_node_child_process9.spawnSync)("uv", ["tool", "install", spec], { encoding: "utf8", timeout: HEADROOM_INSTALL_TIMEOUT_MS });
143789
144172
  if (result.error !== void 0) {
143790
144173
  const timedOut = "code" in result.error && result.error.code === "ETIMEDOUT";
143791
144174
  return {
@@ -143802,7 +144185,7 @@ function realSupervisorPorts(paths) {
143802
144185
  return result.status === 0 ? { ok: true } : { ok: false, error: `uv tool install exited ${String(result.status)}` };
143803
144186
  },
143804
144187
  headroomVersion: () => {
143805
- const result = (0, import_node_child_process8.spawnSync)("headroom", ["--version"], { encoding: "utf8" });
144188
+ const result = (0, import_node_child_process9.spawnSync)("headroom", ["--version"], { encoding: "utf8" });
143806
144189
  return result.status === 0 ? result.stdout.trim() : void 0;
143807
144190
  },
143808
144191
  installedCommit: readInstalledHeadroomCommit,
@@ -144891,6 +145274,7 @@ function buildProgram(deps) {
144891
145274
  registerConfigureCommand(program2, deps);
144892
145275
  registerDoctorCommand(program2, deps);
144893
145276
  registerShimCommand(program2, deps);
145277
+ registerStatuslineCommand(program2, deps);
144894
145278
  registerHeadroomCommand(program2, deps);
144895
145279
  registerCodexCommand(program2, deps);
144896
145280
  registerFrontDoorCommand(program2, deps);
package/dist/index.cjs CHANGED
@@ -2841,7 +2841,7 @@ var init_package = __esm({
2841
2841
  "package.json"() {
2842
2842
  package_default = {
2843
2843
  name: "claude-use",
2844
- version: "11.11.0",
2844
+ version: "11.12.0",
2845
2845
  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.",
2846
2846
  license: "MIT",
2847
2847
  author: "Joseph Mearman <joseph@mearman.co.uk>",
package/dist/index.mjs CHANGED
@@ -2817,7 +2817,7 @@ var init_package = __esm({
2817
2817
  "package.json"() {
2818
2818
  package_default = {
2819
2819
  name: "claude-use",
2820
- version: "11.11.0",
2820
+ version: "11.12.0",
2821
2821
  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.",
2822
2822
  license: "MIT",
2823
2823
  author: "Joseph Mearman <joseph@mearman.co.uk>",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-use",
3
- "version": "11.11.0",
3
+ "version": "11.12.0",
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>",