agent-shim 11.49.0 → 11.49.1

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
@@ -35927,7 +35927,7 @@ var init_package = __esm({
35927
35927
  "package.json"() {
35928
35928
  package_default = {
35929
35929
  name: "agent-shim",
35930
- version: "11.49.0",
35930
+ version: "11.49.1",
35931
35931
  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.",
35932
35932
  license: "MIT",
35933
35933
  author: "Joseph Mearman <joseph@mearman.co.uk>",
@@ -131106,50 +131106,70 @@ function quotaHeaders(upstream) {
131106
131106
  }
131107
131107
  return headers;
131108
131108
  }
131109
- var EXHAUSTED_PERCENT = "100";
131109
+ var EXHAUSTED_PERCENT = 100;
131110
+ var FULL_PERCENT = 100;
131111
+ var MINUTES_PER_HOUR3 = 60;
131112
+ var FIVE_HOUR_WINDOW_HOURS2 = 5;
131113
+ var HOURS_PER_DAY7 = 24;
131114
+ var DAYS_PER_WEEK3 = 7;
131115
+ var FIVE_HOUR_MINUTES = FIVE_HOUR_WINDOW_HOURS2 * MINUTES_PER_HOUR3;
131116
+ var SEVEN_DAY_MINUTES = DAYS_PER_WEEK3 * HOURS_PER_DAY7 * MINUTES_PER_HOUR3;
131117
+ function windowReadings(upstream, exhausted, quotaError) {
131118
+ let fiveHour;
131119
+ let sevenDay;
131120
+ for (const slot of ["primary", "secondary"]) {
131121
+ const minutes = Number(upstream.get(`x-codex-${slot}-window-minutes`));
131122
+ const used = upstream.get(`x-codex-${slot}-used-percent`);
131123
+ const reset = upstream.get(`x-codex-${slot}-reset-at`);
131124
+ if (used === null || used === "" || reset === null || reset === "") {
131125
+ continue;
131126
+ }
131127
+ const reading = { usedPercent: Number(used), resetAt: reset };
131128
+ if (minutes === FIVE_HOUR_MINUTES) {
131129
+ fiveHour = reading;
131130
+ } else if (minutes === SEVEN_DAY_MINUTES) {
131131
+ sevenDay = reading;
131132
+ }
131133
+ }
131134
+ if (fiveHour === void 0 && sevenDay === void 0 && exhausted) {
131135
+ const reset = upstream.get("x-codex-primary-reset-at") ?? (quotaError?.resets_at === void 0 ? null : String(quotaError.resets_at));
131136
+ if (reset !== null && reset !== "") {
131137
+ sevenDay = { usedPercent: EXHAUSTED_PERCENT, resetAt: reset };
131138
+ }
131139
+ }
131140
+ return { fiveHour, sevenDay };
131141
+ }
131110
131142
  function unifiedQuotaHeaders(upstream, rejected, quotaError) {
131111
131143
  const headers = { "anthropic-ratelimit-unified-status": rejected ? "rejected" : "allowed" };
131112
- const used7d = upstream.get("x-codex-primary-used-percent") ?? (rejected ? EXHAUSTED_PERCENT : null);
131113
- const reset7d = upstream.get("x-codex-primary-reset-at") ?? (quotaError?.resets_at === void 0 ? null : String(quotaError.resets_at));
131114
- if (used7d !== null && reset7d !== null) {
131115
- headers["anthropic-ratelimit-unified-7d-utilization"] = used7d;
131116
- headers["anthropic-ratelimit-unified-7d-reset"] = reset7d;
131117
- headers["anthropic-ratelimit-unified-reset"] = reset7d;
131118
- }
131119
- if (Number(upstream.get("x-codex-secondary-window-minutes")) > 0) {
131120
- const used5h = upstream.get("x-codex-secondary-used-percent");
131121
- const reset5h = upstream.get("x-codex-secondary-reset-at");
131122
- if (used5h !== null && used5h !== "" && reset5h !== null && reset5h !== "") {
131123
- headers["anthropic-ratelimit-unified-5h-utilization"] = used5h;
131124
- headers["anthropic-ratelimit-unified-5h-reset"] = reset5h;
131125
- const overall = headers["anthropic-ratelimit-unified-reset"];
131126
- if (overall !== void 0) {
131127
- headers["anthropic-ratelimit-unified-reset"] = String(Math.min(Number(overall), Number(reset5h)));
131128
- }
131144
+ const { fiveHour, sevenDay } = windowReadings(upstream, rejected, quotaError);
131145
+ const resets = [];
131146
+ for (const [name, reading] of [["7d", sevenDay], ["5h", fiveHour]]) {
131147
+ if (reading !== void 0) {
131148
+ headers[`anthropic-ratelimit-unified-${name}-utilization`] = String(reading.usedPercent / FULL_PERCENT);
131149
+ headers[`anthropic-ratelimit-unified-${name}-reset`] = reading.resetAt;
131150
+ resets.push(Number(reading.resetAt));
131129
131151
  }
131130
131152
  }
131153
+ if (resets.length > 0) {
131154
+ headers["anthropic-ratelimit-unified-reset"] = String(Math.min(...resets));
131155
+ }
131131
131156
  return headers;
131132
131157
  }
131133
131158
  var MS_PER_SECOND11 = 1e3;
131159
+ function snapshotWindow(reading) {
131160
+ return reading === void 0 ? void 0 : { used_percentage: reading.usedPercent, resets_at: new Date(Number(reading.resetAt) * MS_PER_SECOND11).toISOString() };
131161
+ }
131134
131162
  function buildUsageSnapshot(upstream, quotaError, nowMs) {
131135
- const used7 = upstream.get("x-codex-primary-used-percent") ?? (quotaError === void 0 ? null : EXHAUSTED_PERCENT);
131136
- const reset7 = upstream.get("x-codex-primary-reset-at") ?? (quotaError?.resets_at === void 0 ? null : String(quotaError.resets_at));
131137
- const sevenDay = used7 !== null && reset7 !== null ? { used_percentage: Number(used7), resets_at: new Date(Number(reset7) * MS_PER_SECOND11).toISOString() } : void 0;
131138
- let fiveHour;
131139
- if (Number(upstream.get("x-codex-secondary-window-minutes")) > 0) {
131140
- const used5 = upstream.get("x-codex-secondary-used-percent");
131141
- const reset5 = upstream.get("x-codex-secondary-reset-at");
131142
- if (used5 !== null && reset5 !== null) {
131143
- fiveHour = { used_percentage: Number(used5), resets_at: new Date(Number(reset5) * MS_PER_SECOND11).toISOString() };
131144
- }
131145
- }
131146
- if (sevenDay === void 0 && fiveHour === void 0) {
131163
+ const { fiveHour, sevenDay } = windowReadings(upstream, quotaError !== void 0, quotaError);
131164
+ const fiveHourWindow = snapshotWindow(fiveHour);
131165
+ const sevenDayWindow = snapshotWindow(sevenDay);
131166
+ if (sevenDayWindow === void 0 && fiveHourWindow === void 0) {
131147
131167
  return void 0;
131148
131168
  }
131149
131169
  return {
131150
131170
  updated_at: new Date(nowMs).toISOString(),
131151
- ...sevenDay === void 0 ? {} : { seven_day: sevenDay },
131152
- ...fiveHour === void 0 ? {} : { five_hour: fiveHour }
131171
+ ...sevenDayWindow === void 0 ? {} : { seven_day: sevenDayWindow },
131172
+ ...fiveHourWindow === void 0 ? {} : { five_hour: fiveHourWindow }
131153
131173
  };
131154
131174
  }
131155
131175
  function retryAfterSeconds2(upstream, quotaError) {
@@ -136469,7 +136489,7 @@ var realHeadroomGet = async (target, requestPath, timeoutMs) => {
136469
136489
 
136470
136490
  // src/statusline/enrich.ts
136471
136491
  init_quota();
136472
- var FULL_PERCENT = 100;
136492
+ var FULL_PERCENT2 = 100;
136473
136493
  var MS_PER_SECOND16 = 1e3;
136474
136494
  function identityOf(env) {
136475
136495
  const headers = env.ANTHROPIC_CUSTOM_HEADERS;
@@ -136491,7 +136511,16 @@ function identityOf(env) {
136491
136511
  }
136492
136512
  return void 0;
136493
136513
  }
136494
- function windowsOf(states) {
136514
+ function livePercentOf(window, nowMs) {
136515
+ if (window?.utilization === void 0 || !Number.isFinite(window.utilization)) {
136516
+ return void 0;
136517
+ }
136518
+ if (window.resetsAt !== void 0 && Date.parse(window.resetsAt) <= nowMs) {
136519
+ return void 0;
136520
+ }
136521
+ return Math.round(Math.min(1, Math.max(0, window.utilization)) * FULL_PERCENT2);
136522
+ }
136523
+ function windowsOf(states, nowMs) {
136495
136524
  let fiveHourUsed;
136496
136525
  let fiveHourResetAt;
136497
136526
  let sevenDayUsed;
@@ -136501,14 +136530,12 @@ function windowsOf(states) {
136501
136530
  if (unified === void 0) {
136502
136531
  continue;
136503
136532
  }
136504
- const fiveWindow = unified.fiveHour === void 0 ? void 0 : unified.fiveHour.utilization;
136505
- const five = typeof fiveWindow === "number" && Number.isFinite(fiveWindow) ? Math.round(Math.min(1, Math.max(0, fiveWindow)) * FULL_PERCENT) : void 0;
136533
+ const five = livePercentOf(unified.fiveHour, nowMs);
136506
136534
  if (five !== void 0 && (fiveHourUsed === void 0 || five > fiveHourUsed)) {
136507
136535
  fiveHourUsed = five;
136508
136536
  fiveHourResetAt = unified.fiveHour?.resetsAt;
136509
136537
  }
136510
- const sevenWindow = unified.sevenDay === void 0 ? void 0 : unified.sevenDay.utilization;
136511
- const seven = typeof sevenWindow === "number" && Number.isFinite(sevenWindow) ? Math.round(Math.min(1, Math.max(0, sevenWindow)) * FULL_PERCENT) : void 0;
136538
+ const seven = livePercentOf(unified.sevenDay, nowMs);
136512
136539
  if (seven !== void 0 && (sevenDayUsed === void 0 || seven > sevenDayUsed)) {
136513
136540
  sevenDayUsed = seven;
136514
136541
  sevenDayResetAt = unified.sevenDay?.resetsAt;
@@ -136526,7 +136553,7 @@ function payloadWindow(rateLimits, key) {
136526
136553
  }
136527
136554
  const resetsAt = window.resets_at;
136528
136555
  return {
136529
- used: Math.min(FULL_PERCENT, Math.max(0, window.used_percentage)),
136556
+ used: Math.min(FULL_PERCENT2, Math.max(0, window.used_percentage)),
136530
136557
  resetAt: typeof resetsAt === "number" && Number.isFinite(resetsAt) ? new Date(resetsAt * MS_PER_SECOND16).toISOString() : void 0
136531
136558
  };
136532
136559
  }
@@ -136554,7 +136581,7 @@ function antigravityQuotaMapOf(payload) {
136554
136581
  }
136555
136582
  function bucketView(bucket, nowMs) {
136556
136583
  return {
136557
- used: bucket?.remaining_fraction === void 0 || !Number.isFinite(bucket.remaining_fraction) ? void 0 : (1 - Math.min(1, Math.max(0, bucket.remaining_fraction))) * FULL_PERCENT,
136584
+ used: bucket?.remaining_fraction === void 0 || !Number.isFinite(bucket.remaining_fraction) ? void 0 : (1 - Math.min(1, Math.max(0, bucket.remaining_fraction))) * FULL_PERCENT2,
136558
136585
  resetAt: bucket?.reset_in_seconds === void 0 || !Number.isFinite(bucket.reset_in_seconds) ? void 0 : new Date(nowMs + bucket.reset_in_seconds * MS_PER_SECOND16).toISOString()
136559
136586
  };
136560
136587
  }
@@ -136572,7 +136599,7 @@ function antigravityWindowsOf(payload, nowMs) {
136572
136599
  function quotaFamiliesOf(buckets, nowMs) {
136573
136600
  return antigravityFamilyBuckets(buckets).flatMap(({ label, bucket }) => {
136574
136601
  const { used, resetAt } = bucketView(bucket, nowMs);
136575
- return used === void 0 ? [] : [{ measures: label, utilization: used / FULL_PERCENT, resetsAt: resetAt }];
136602
+ return used === void 0 ? [] : [{ measures: label, utilization: used / FULL_PERCENT2, resetsAt: resetAt }];
136576
136603
  });
136577
136604
  }
136578
136605
  function enrichStatuslinePayload(params) {
@@ -136634,7 +136661,7 @@ function enrichStatuslinePayload(params) {
136634
136661
  }
136635
136662
  ])
136636
136663
  );
136637
- summary = { ...summary, ...windowsOf(states), providerAccountEmail: email3, providerAccountSub: sub, providerPlan: plan, providerQuotaWindows, quotaFamilies: quotaFamiliesOf(providerBuckets, params.nowMs) };
136664
+ summary = { ...summary, ...windowsOf(states, params.nowMs), providerAccountEmail: email3, providerAccountSub: sub, providerPlan: plan, providerQuotaWindows, quotaFamilies: quotaFamiliesOf(providerBuckets, params.nowMs) };
136638
136665
  }
136639
136666
  if (summary.provider === void 0) {
136640
136667
  const agyBuckets = antigravityQuotaMapOf(params.payload);
@@ -136758,7 +136785,7 @@ function layoutBarGrid(groups, maxWidth, separator, baseBarCells) {
136758
136785
  // src/statusline/render.ts
136759
136786
  var BAR_WIDTH = 10;
136760
136787
  var SECONDS_PER_MINUTE2 = 60;
136761
- var MINUTES_PER_HOUR3 = 60;
136788
+ var MINUTES_PER_HOUR4 = 60;
136762
136789
  var SECONDS_PER_DAY = 86400;
136763
136790
  var THOUSAND = 1e3;
136764
136791
  var MILLION = 1e6;
@@ -136766,7 +136793,7 @@ var TEN = 10;
136766
136793
  var TWENTY = 20;
136767
136794
  var RESERVED_COLUMNS = 4;
136768
136795
  var SEPARATOR2 = " | ";
136769
- var FULL_PERCENT2 = 100;
136796
+ var FULL_PERCENT3 = 100;
136770
136797
  var ONE_PERCENT = 1;
136771
136798
  var USED_RED_AT = 0.9;
136772
136799
  var USED_YELLOW_AT = 0.7;
@@ -136809,8 +136836,8 @@ function formatDuration(seconds) {
136809
136836
  return "available";
136810
136837
  }
136811
136838
  const days = Math.floor(seconds / SECONDS_PER_DAY);
136812
- const hours = Math.floor(seconds % SECONDS_PER_DAY / (MINUTES_PER_HOUR3 * SECONDS_PER_MINUTE2));
136813
- const minutes = Math.floor(seconds % (MINUTES_PER_HOUR3 * SECONDS_PER_MINUTE2) / SECONDS_PER_MINUTE2);
136839
+ const hours = Math.floor(seconds % SECONDS_PER_DAY / (MINUTES_PER_HOUR4 * SECONDS_PER_MINUTE2));
136840
+ const minutes = Math.floor(seconds % (MINUTES_PER_HOUR4 * SECONDS_PER_MINUTE2) / SECONDS_PER_MINUTE2);
136814
136841
  if (days > 0) {
136815
136842
  return `${String(days)}d ${String(hours)}h`;
136816
136843
  }
@@ -136833,7 +136860,7 @@ function headroomText(stats) {
136833
136860
  }
136834
136861
  function cacheHitText(hitFraction) {
136835
136862
  const clamped = Math.max(0, Math.min(1, hitFraction));
136836
- return ` (Cache: ${statusColor(clamped, false)}${(clamped * FULL_PERCENT2).toFixed(0)}%${RESET})`;
136863
+ return ` (Cache: ${statusColor(clamped, false)}${(clamped * FULL_PERCENT3).toFixed(0)}%${RESET})`;
136837
136864
  }
136838
136865
  function cacheShareText(view) {
136839
136866
  const hitRatio = view.cacheHitRatio;
@@ -136990,7 +137017,7 @@ function renderStatuslineBlock(summary, view, terminalWidth, nowMs) {
136990
137017
  }
136991
137018
  const contextGroup = [];
136992
137019
  if (view.contextUsedPercentage !== void 0) {
136993
- const fraction = Math.max(0, Math.min(1, view.contextUsedPercentage / FULL_PERCENT2));
137020
+ const fraction = Math.max(0, Math.min(1, view.contextUsedPercentage / FULL_PERCENT3));
136994
137021
  const color = statusColor(fraction, true);
136995
137022
  const percent2 = `${color}${view.contextUsedPercentage.toFixed(1)}%${RESET}`;
136996
137023
  const tokens = view.contextTotalTokens !== void 0 && view.contextWindowTokens !== void 0 ? `${formatTokens(view.contextTotalTokens)}/${formatTokens(view.contextWindowTokens)} ` : "";
@@ -137001,7 +137028,7 @@ function renderStatuslineBlock(summary, view, terminalWidth, nowMs) {
137001
137028
  const drawWindow = (label, fraction, resetsAt) => {
137002
137029
  const clamped = Math.max(0, Math.min(1, fraction));
137003
137030
  const color = statusColor(clamped, true);
137004
- quotaGroup.push(barCell(`${label} `, ` ${color}${(fraction * FULL_PERCENT2).toFixed(1)}%${RESET} (${formatDuration(secondsUntil(resetsAt, nowMs))})`, clamped));
137031
+ quotaGroup.push(barCell(`${label} `, ` ${color}${(fraction * FULL_PERCENT3).toFixed(1)}%${RESET} (${formatDuration(secondsUntil(resetsAt, nowMs))})`, clamped));
137005
137032
  };
137006
137033
  if (summary.quotaFamilies.length > 0) {
137007
137034
  for (const window of summary.quotaFamilies) {
@@ -137009,10 +137036,10 @@ function renderStatuslineBlock(summary, view, terminalWidth, nowMs) {
137009
137036
  }
137010
137037
  } else {
137011
137038
  if (summary.fiveHourUsed !== void 0) {
137012
- drawWindow("5h", summary.fiveHourUsed / FULL_PERCENT2, summary.fiveHourResetAt);
137039
+ drawWindow("5h", summary.fiveHourUsed / FULL_PERCENT3, summary.fiveHourResetAt);
137013
137040
  }
137014
137041
  if (summary.sevenDayUsed !== void 0) {
137015
- drawWindow("Wk", summary.sevenDayUsed / FULL_PERCENT2, summary.sevenDayResetAt);
137042
+ drawWindow("Wk", summary.sevenDayUsed / FULL_PERCENT3, summary.sevenDayResetAt);
137016
137043
  }
137017
137044
  if (summary.fiveHourUsed === void 0 && summary.sevenDayUsed === void 0) {
137018
137045
  for (const window of summary.providerQuotaWindows) {
package/dist/index.cjs CHANGED
@@ -4191,7 +4191,7 @@ var init_package = __esm({
4191
4191
  "package.json"() {
4192
4192
  package_default = {
4193
4193
  name: "agent-shim",
4194
- version: "11.49.0",
4194
+ version: "11.49.1",
4195
4195
  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.",
4196
4196
  license: "MIT",
4197
4197
  author: "Joseph Mearman <joseph@mearman.co.uk>",
package/dist/index.mjs CHANGED
@@ -4167,7 +4167,7 @@ var init_package = __esm({
4167
4167
  "package.json"() {
4168
4168
  package_default = {
4169
4169
  name: "agent-shim",
4170
- version: "11.49.0",
4170
+ version: "11.49.1",
4171
4171
  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.",
4172
4172
  license: "MIT",
4173
4173
  author: "Joseph Mearman <joseph@mearman.co.uk>",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-shim",
3
- "version": "11.49.0",
3
+ "version": "11.49.1",
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>",