agent-shim 11.72.0 → 11.72.2

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
@@ -37387,7 +37387,7 @@ var init_package = __esm({
37387
37387
  "package.json"() {
37388
37388
  package_default = {
37389
37389
  name: "agent-shim",
37390
- version: "11.72.0",
37390
+ version: "11.72.2",
37391
37391
  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.",
37392
37392
  license: "MIT",
37393
37393
  author: "Joseph Mearman <joseph@mearman.co.uk>",
@@ -38399,36 +38399,71 @@ function readUsageLog(fs31, logDir, options = {}) {
38399
38399
  if (sinceMs !== void 0 && segment.endsAt <= sinceMs) {
38400
38400
  continue;
38401
38401
  }
38402
- const contents = fs31.readFileUtf8(import_node_path26.default.join(logDir, segment.name));
38403
- if (contents === void 0) {
38402
+ const read = readSegment(fs31, logDir, segment);
38403
+ if (read === void 0) {
38404
38404
  continue;
38405
38405
  }
38406
- const lines = contents.split("\n");
38407
- lines.pop();
38408
- for (const line of lines) {
38409
- if (line === "") {
38410
- continue;
38411
- }
38412
- let raw;
38413
- try {
38414
- raw = JSON.parse(line);
38415
- } catch {
38416
- invalidLines += 1;
38417
- continue;
38418
- }
38419
- const parsed = UsageRecordSchema.safeParse(raw);
38420
- if (!parsed.success) {
38421
- invalidLines += 1;
38422
- continue;
38423
- }
38424
- if (sinceMs === void 0 || Date.parse(parsed.data.at) >= sinceMs) {
38425
- records.push(parsed.data);
38406
+ invalidLines += read.invalidLines;
38407
+ for (const record2 of read.records) {
38408
+ if (sinceMs === void 0 || Date.parse(record2.at) >= sinceMs) {
38409
+ records.push(record2);
38426
38410
  }
38427
38411
  }
38428
38412
  }
38429
38413
  records.sort((left, right) => left.at.localeCompare(right.at));
38430
38414
  return { records, invalidLines };
38431
38415
  }
38416
+ function readSegment(fs31, logDir, segment) {
38417
+ const contents = fs31.readFileUtf8(import_node_path26.default.join(logDir, segment.name));
38418
+ if (contents === void 0) {
38419
+ return void 0;
38420
+ }
38421
+ const records = [];
38422
+ let invalidLines = 0;
38423
+ const lines = contents.split("\n");
38424
+ lines.pop();
38425
+ for (const line of lines) {
38426
+ if (line === "") {
38427
+ continue;
38428
+ }
38429
+ let raw;
38430
+ try {
38431
+ raw = JSON.parse(line);
38432
+ } catch {
38433
+ invalidLines += 1;
38434
+ continue;
38435
+ }
38436
+ const parsed = UsageRecordSchema.safeParse(raw);
38437
+ if (!parsed.success) {
38438
+ invalidLines += 1;
38439
+ continue;
38440
+ }
38441
+ records.push(parsed.data);
38442
+ }
38443
+ return { records, invalidLines };
38444
+ }
38445
+ function readRecentUsageRecords(fs31, logDir, count2) {
38446
+ const byDay = /* @__PURE__ */ new Map();
38447
+ for (const segment of listLogSegments(fs31, logDir)) {
38448
+ byDay.set(segment.day, [...byDay.get(segment.day) ?? [], segment]);
38449
+ }
38450
+ const days = [...byDay.values()];
38451
+ let records = [];
38452
+ for (let index = days.length - 1; index >= 0; index -= 1) {
38453
+ const dayRecords = [];
38454
+ for (const segment of days[index] ?? []) {
38455
+ dayRecords.push(...readSegment(fs31, logDir, segment)?.records ?? []);
38456
+ }
38457
+ records = [...dayRecords, ...records];
38458
+ records.sort((left, right) => left.at.localeCompare(right.at));
38459
+ const olderDay = days[index - 1]?.[0];
38460
+ const newestHeld = records[records.length - count2];
38461
+ if (olderDay === void 0 || newestHeld !== void 0 && Date.parse(newestHeld.at) >= olderDay.endsAt) {
38462
+ break;
38463
+ }
38464
+ }
38465
+ return records.slice(-count2);
38466
+ }
38432
38467
  function snapshotPath(snapshotsDir, identity) {
38433
38468
  if (!isIdentityName(identity)) {
38434
38469
  throw new Error(`"${identity}" is not a valid identity name.`);
@@ -119889,7 +119924,7 @@ function blendedPricePerMTok(prices, mix) {
119889
119924
  var SEED_LOOKBACK_RECORDS = 500;
119890
119925
  function createTargetObservationStore(fs31, paths) {
119891
119926
  let observations = /* @__PURE__ */ new Map();
119892
- const seeded = readUsageLog(fs31, paths.usageLogDir, {}).records.slice(-SEED_LOOKBACK_RECORDS);
119927
+ const seeded = readRecentUsageRecords(fs31, paths.usageLogDir, SEED_LOOKBACK_RECORDS);
119893
119928
  for (const record2 of seeded) {
119894
119929
  observations = observeRecord(observations, record2);
119895
119930
  }
@@ -120913,6 +120948,13 @@ function mergeLiveTasks(tree, live) {
120913
120948
 
120914
120949
  // src/frontdoor/rcSessions.ts
120915
120950
  var RC_SESSIONS_PATH_PREFIX = "/v1/code/sessions";
120951
+ function pathnameOf(url2) {
120952
+ return new URL(url2 ?? "/", "http://127.0.0.1").pathname;
120953
+ }
120954
+ function isRcSessionExchange(url2) {
120955
+ const path73 = pathnameOf(url2);
120956
+ return path73 === RC_SESSIONS_PATH_PREFIX || path73.startsWith(`${RC_SESSIONS_PATH_PREFIX}/`);
120957
+ }
120916
120958
  var RC_SESSION_ID_PREFIX = "cse_";
120917
120959
  var RC_IDLE_EXPIRY_MS = 45e3;
120918
120960
  var RC_CREATE_RESPONSE_CAP_BYTES = 8192;
@@ -121077,11 +121119,10 @@ function createRcSessionTracker(deps) {
121077
121119
  };
121078
121120
  const observeExchange = (request7) => {
121079
121121
  const method = (request7.method ?? "").toUpperCase();
121080
- const path73 = new URL(request7.url ?? "/", "http://127.0.0.1").pathname;
121081
- if (!path73.startsWith(RC_SESSIONS_PATH_PREFIX)) {
121122
+ if (!isRcSessionExchange(request7.url)) {
121082
121123
  return void 0;
121083
121124
  }
121084
- const tail = path73.slice(RC_SESSIONS_PATH_PREFIX.length);
121125
+ const tail = pathnameOf(request7.url).slice(RC_SESSIONS_PATH_PREFIX.length);
121085
121126
  const facts = {
121086
121127
  oauthAuthorization: oauthAuthorizationOf(request7.headers),
121087
121128
  anthropicVersion: singleHeader(request7.headers, "anthropic-version"),
@@ -134286,6 +134327,10 @@ async function collectBody(body) {
134286
134327
  resolve3(result);
134287
134328
  }
134288
134329
  };
134330
+ if (body.destroyed) {
134331
+ settle2({ kind: "failed" });
134332
+ return;
134333
+ }
134289
134334
  body.on("data", (chunk2) => {
134290
134335
  if (settled) {
134291
134336
  return;
@@ -134309,6 +134354,9 @@ async function collectBody(body) {
134309
134354
  body.on("error", () => {
134310
134355
  settle2({ kind: "failed" });
134311
134356
  });
134357
+ body.on("close", () => {
134358
+ settle2({ kind: "failed" });
134359
+ });
134312
134360
  });
134313
134361
  }
134314
134362
  function requestedModelOf(body) {
@@ -139201,6 +139249,7 @@ function createRcEventFanout() {
139201
139249
  function createRcStreamHub(deps) {
139202
139250
  const attachments = /* @__PURE__ */ new Map();
139203
139251
  let closed = false;
139252
+ const refusedAuthorizations = /* @__PURE__ */ new Map();
139204
139253
  const lastSavedSequenceNums = /* @__PURE__ */ new Map();
139205
139254
  const persistCursor = (sessionId) => {
139206
139255
  if (deps.saveSequenceNum === void 0) {
@@ -139304,7 +139353,6 @@ function createRcStreamHub(deps) {
139304
139353
  };
139305
139354
  const runLoop = async (attachment) => {
139306
139355
  let retriedUnauthorized = false;
139307
- let refusedAuthorization;
139308
139356
  for (; ; ) {
139309
139357
  if (attachment.isStopped()) {
139310
139358
  return;
@@ -139320,11 +139368,11 @@ function createRcStreamHub(deps) {
139320
139368
  }
139321
139369
  return;
139322
139370
  }
139323
- if (refusedAuthorization !== void 0 && credential.authorization === refusedAuthorization) {
139371
+ if (credential.authorization === refusedAuthorizations.get(attachment.sessionId)) {
139324
139372
  await deps.sleep(deps.backoffMs);
139325
139373
  continue;
139326
139374
  }
139327
- refusedAuthorization = void 0;
139375
+ refusedAuthorizations.delete(attachment.sessionId);
139328
139376
  let outcome;
139329
139377
  try {
139330
139378
  outcome = await attempt(attachment, credential);
@@ -139352,7 +139400,7 @@ function createRcStreamHub(deps) {
139352
139400
  continue;
139353
139401
  }
139354
139402
  deps.log?.(`rc stream ${attachment.sessionId}: the client read stream refused the observed Authorization bearer past one retry; waiting for a fresh one`);
139355
- refusedAuthorization = credential.authorization;
139403
+ refusedAuthorizations.set(attachment.sessionId, credential.authorization);
139356
139404
  await deps.sleep(deps.backoffMs);
139357
139405
  retriedUnauthorized = false;
139358
139406
  }
@@ -139392,6 +139440,7 @@ function createRcStreamHub(deps) {
139392
139440
  attachment.stop();
139393
139441
  }
139394
139442
  attachments.clear();
139443
+ refusedAuthorizations.clear();
139395
139444
  }
139396
139445
  };
139397
139446
  }
@@ -139794,9 +139843,13 @@ function respawnInvocation(paths) {
139794
139843
  function rcObservingResolver(resolve3, tracker, hub) {
139795
139844
  return async (request7) => {
139796
139845
  const resolution = await resolve3(request7);
139797
- return resolution.ok ? { ...resolution, route: observingRoutedRoute(resolution.route, tracker, hub === void 0 ? void 0 : { onExchangeSettled: () => {
139846
+ if (!resolution.ok) {
139847
+ return resolution;
139848
+ }
139849
+ const observing = observingRoutedRoute(resolution.route, tracker, hub === void 0 ? void 0 : { onExchangeSettled: () => {
139798
139850
  hub.reconcile();
139799
- } }) } : resolution;
139851
+ } });
139852
+ return { ...resolution, route: isRcSessionExchange(request7.url) ? { ...observing, headroomEligible: false } : observing };
139800
139853
  };
139801
139854
  }
139802
139855
  function realStatOwnExecutable(watchPath) {
@@ -140022,10 +140075,8 @@ function realFrontDoorSupervisorPorts(paths, respawnGeneration, lifecycle, track
140022
140075
  catalogueKeeper.tick();
140023
140076
  everyFreshnessInterval(catalogueKeeper.tick);
140024
140077
  const headroomDecision = createHeadroomDecision(createRoutingSettingReader(paths));
140025
- const targetObservations = createTargetObservationStore(realFarmFs, paths);
140026
140078
  const recordUsage = (record2) => {
140027
140079
  withQuotaRefresh(usageStore.record, quotaRefresher)(record2);
140028
- targetObservations.observe(record2);
140029
140080
  };
140030
140081
  const usageMiddleware = createUsageMiddleware({
140031
140082
  // Each finished response also tells the per-session headroom decision when the session's cache was last touched and whether it read from it.
package/dist/index.cjs CHANGED
@@ -4762,7 +4762,7 @@ var init_package = __esm({
4762
4762
  "package.json"() {
4763
4763
  package_default = {
4764
4764
  name: "agent-shim",
4765
- version: "11.72.0",
4765
+ version: "11.72.2",
4766
4766
  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.",
4767
4767
  license: "MIT",
4768
4768
  author: "Joseph Mearman <joseph@mearman.co.uk>",
@@ -7606,36 +7606,49 @@ function readUsageLog(fs14, logDir, options = {}) {
7606
7606
  if (sinceMs !== void 0 && segment.endsAt <= sinceMs) {
7607
7607
  continue;
7608
7608
  }
7609
- const contents = fs14.readFileUtf8(import_node_path20.default.join(logDir, segment.name));
7610
- if (contents === void 0) {
7609
+ const read = readSegment(fs14, logDir, segment);
7610
+ if (read === void 0) {
7611
7611
  continue;
7612
7612
  }
7613
- const lines = contents.split("\n");
7614
- lines.pop();
7615
- for (const line of lines) {
7616
- if (line === "") {
7617
- continue;
7618
- }
7619
- let raw;
7620
- try {
7621
- raw = JSON.parse(line);
7622
- } catch {
7623
- invalidLines += 1;
7624
- continue;
7625
- }
7626
- const parsed = UsageRecordSchema.safeParse(raw);
7627
- if (!parsed.success) {
7628
- invalidLines += 1;
7629
- continue;
7630
- }
7631
- if (sinceMs === void 0 || Date.parse(parsed.data.at) >= sinceMs) {
7632
- records.push(parsed.data);
7613
+ invalidLines += read.invalidLines;
7614
+ for (const record of read.records) {
7615
+ if (sinceMs === void 0 || Date.parse(record.at) >= sinceMs) {
7616
+ records.push(record);
7633
7617
  }
7634
7618
  }
7635
7619
  }
7636
7620
  records.sort((left, right) => left.at.localeCompare(right.at));
7637
7621
  return { records, invalidLines };
7638
7622
  }
7623
+ function readSegment(fs14, logDir, segment) {
7624
+ const contents = fs14.readFileUtf8(import_node_path20.default.join(logDir, segment.name));
7625
+ if (contents === void 0) {
7626
+ return void 0;
7627
+ }
7628
+ const records = [];
7629
+ let invalidLines = 0;
7630
+ const lines = contents.split("\n");
7631
+ lines.pop();
7632
+ for (const line of lines) {
7633
+ if (line === "") {
7634
+ continue;
7635
+ }
7636
+ let raw;
7637
+ try {
7638
+ raw = JSON.parse(line);
7639
+ } catch {
7640
+ invalidLines += 1;
7641
+ continue;
7642
+ }
7643
+ const parsed = UsageRecordSchema.safeParse(raw);
7644
+ if (!parsed.success) {
7645
+ invalidLines += 1;
7646
+ continue;
7647
+ }
7648
+ records.push(parsed.data);
7649
+ }
7650
+ return { records, invalidLines };
7651
+ }
7639
7652
  function snapshotPath(snapshotsDir, identity) {
7640
7653
  if (!isIdentityName(identity)) {
7641
7654
  throw new Error(`"${identity}" is not a valid identity name.`);
@@ -13454,6 +13467,13 @@ function mergeLiveTasks(tree, live) {
13454
13467
 
13455
13468
  // src/frontdoor/rcSessions.ts
13456
13469
  var RC_SESSIONS_PATH_PREFIX = "/v1/code/sessions";
13470
+ function pathnameOf(url) {
13471
+ return new URL(url ?? "/", "http://127.0.0.1").pathname;
13472
+ }
13473
+ function isRcSessionExchange(url) {
13474
+ const path42 = pathnameOf(url);
13475
+ return path42 === RC_SESSIONS_PATH_PREFIX || path42.startsWith(`${RC_SESSIONS_PATH_PREFIX}/`);
13476
+ }
13457
13477
  var RC_SESSION_ID_PREFIX = "cse_";
13458
13478
  var RC_IDLE_EXPIRY_MS = 45e3;
13459
13479
  var RC_CREATE_RESPONSE_CAP_BYTES = 8192;
@@ -13618,11 +13638,10 @@ function createRcSessionTracker(deps) {
13618
13638
  };
13619
13639
  const observeExchange = (request4) => {
13620
13640
  const method = (request4.method ?? "").toUpperCase();
13621
- const path42 = new URL(request4.url ?? "/", "http://127.0.0.1").pathname;
13622
- if (!path42.startsWith(RC_SESSIONS_PATH_PREFIX)) {
13641
+ if (!isRcSessionExchange(request4.url)) {
13623
13642
  return void 0;
13624
13643
  }
13625
- const tail = path42.slice(RC_SESSIONS_PATH_PREFIX.length);
13644
+ const tail = pathnameOf(request4.url).slice(RC_SESSIONS_PATH_PREFIX.length);
13626
13645
  const facts = {
13627
13646
  oauthAuthorization: oauthAuthorizationOf(request4.headers),
13628
13647
  anthropicVersion: singleHeader(request4.headers, "anthropic-version"),
@@ -19527,6 +19546,7 @@ function createRcEventFanout() {
19527
19546
  function createRcStreamHub(deps) {
19528
19547
  const attachments = /* @__PURE__ */ new Map();
19529
19548
  let closed = false;
19549
+ const refusedAuthorizations = /* @__PURE__ */ new Map();
19530
19550
  const lastSavedSequenceNums = /* @__PURE__ */ new Map();
19531
19551
  const persistCursor = (sessionId) => {
19532
19552
  if (deps.saveSequenceNum === void 0) {
@@ -19630,7 +19650,6 @@ function createRcStreamHub(deps) {
19630
19650
  };
19631
19651
  const runLoop = async (attachment) => {
19632
19652
  let retriedUnauthorized = false;
19633
- let refusedAuthorization;
19634
19653
  for (; ; ) {
19635
19654
  if (attachment.isStopped()) {
19636
19655
  return;
@@ -19646,11 +19665,11 @@ function createRcStreamHub(deps) {
19646
19665
  }
19647
19666
  return;
19648
19667
  }
19649
- if (refusedAuthorization !== void 0 && credential.authorization === refusedAuthorization) {
19668
+ if (credential.authorization === refusedAuthorizations.get(attachment.sessionId)) {
19650
19669
  await deps.sleep(deps.backoffMs);
19651
19670
  continue;
19652
19671
  }
19653
- refusedAuthorization = void 0;
19672
+ refusedAuthorizations.delete(attachment.sessionId);
19654
19673
  let outcome;
19655
19674
  try {
19656
19675
  outcome = await attempt(attachment, credential);
@@ -19678,7 +19697,7 @@ function createRcStreamHub(deps) {
19678
19697
  continue;
19679
19698
  }
19680
19699
  deps.log?.(`rc stream ${attachment.sessionId}: the client read stream refused the observed Authorization bearer past one retry; waiting for a fresh one`);
19681
- refusedAuthorization = credential.authorization;
19700
+ refusedAuthorizations.set(attachment.sessionId, credential.authorization);
19682
19701
  await deps.sleep(deps.backoffMs);
19683
19702
  retriedUnauthorized = false;
19684
19703
  }
@@ -19718,6 +19737,7 @@ function createRcStreamHub(deps) {
19718
19737
  attachment.stop();
19719
19738
  }
19720
19739
  attachments.clear();
19740
+ refusedAuthorizations.clear();
19721
19741
  }
19722
19742
  };
19723
19743
  }
package/dist/index.mjs CHANGED
@@ -4738,7 +4738,7 @@ var init_package = __esm({
4738
4738
  "package.json"() {
4739
4739
  package_default = {
4740
4740
  name: "agent-shim",
4741
- version: "11.72.0",
4741
+ version: "11.72.2",
4742
4742
  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.",
4743
4743
  license: "MIT",
4744
4744
  author: "Joseph Mearman <joseph@mearman.co.uk>",
@@ -7582,36 +7582,49 @@ function readUsageLog(fs14, logDir, options = {}) {
7582
7582
  if (sinceMs !== void 0 && segment.endsAt <= sinceMs) {
7583
7583
  continue;
7584
7584
  }
7585
- const contents = fs14.readFileUtf8(path20.join(logDir, segment.name));
7586
- if (contents === void 0) {
7585
+ const read = readSegment(fs14, logDir, segment);
7586
+ if (read === void 0) {
7587
7587
  continue;
7588
7588
  }
7589
- const lines = contents.split("\n");
7590
- lines.pop();
7591
- for (const line of lines) {
7592
- if (line === "") {
7593
- continue;
7594
- }
7595
- let raw;
7596
- try {
7597
- raw = JSON.parse(line);
7598
- } catch {
7599
- invalidLines += 1;
7600
- continue;
7601
- }
7602
- const parsed = UsageRecordSchema.safeParse(raw);
7603
- if (!parsed.success) {
7604
- invalidLines += 1;
7605
- continue;
7606
- }
7607
- if (sinceMs === void 0 || Date.parse(parsed.data.at) >= sinceMs) {
7608
- records.push(parsed.data);
7589
+ invalidLines += read.invalidLines;
7590
+ for (const record of read.records) {
7591
+ if (sinceMs === void 0 || Date.parse(record.at) >= sinceMs) {
7592
+ records.push(record);
7609
7593
  }
7610
7594
  }
7611
7595
  }
7612
7596
  records.sort((left, right) => left.at.localeCompare(right.at));
7613
7597
  return { records, invalidLines };
7614
7598
  }
7599
+ function readSegment(fs14, logDir, segment) {
7600
+ const contents = fs14.readFileUtf8(path20.join(logDir, segment.name));
7601
+ if (contents === void 0) {
7602
+ return void 0;
7603
+ }
7604
+ const records = [];
7605
+ let invalidLines = 0;
7606
+ const lines = contents.split("\n");
7607
+ lines.pop();
7608
+ for (const line of lines) {
7609
+ if (line === "") {
7610
+ continue;
7611
+ }
7612
+ let raw;
7613
+ try {
7614
+ raw = JSON.parse(line);
7615
+ } catch {
7616
+ invalidLines += 1;
7617
+ continue;
7618
+ }
7619
+ const parsed = UsageRecordSchema.safeParse(raw);
7620
+ if (!parsed.success) {
7621
+ invalidLines += 1;
7622
+ continue;
7623
+ }
7624
+ records.push(parsed.data);
7625
+ }
7626
+ return { records, invalidLines };
7627
+ }
7615
7628
  function snapshotPath(snapshotsDir, identity) {
7616
7629
  if (!isIdentityName(identity)) {
7617
7630
  throw new Error(`"${identity}" is not a valid identity name.`);
@@ -13039,6 +13052,13 @@ function mergeLiveTasks(tree, live) {
13039
13052
 
13040
13053
  // src/frontdoor/rcSessions.ts
13041
13054
  var RC_SESSIONS_PATH_PREFIX = "/v1/code/sessions";
13055
+ function pathnameOf(url) {
13056
+ return new URL(url ?? "/", "http://127.0.0.1").pathname;
13057
+ }
13058
+ function isRcSessionExchange(url) {
13059
+ const path42 = pathnameOf(url);
13060
+ return path42 === RC_SESSIONS_PATH_PREFIX || path42.startsWith(`${RC_SESSIONS_PATH_PREFIX}/`);
13061
+ }
13042
13062
  var RC_SESSION_ID_PREFIX = "cse_";
13043
13063
  var RC_IDLE_EXPIRY_MS = 45e3;
13044
13064
  var RC_CREATE_RESPONSE_CAP_BYTES = 8192;
@@ -13203,11 +13223,10 @@ function createRcSessionTracker(deps) {
13203
13223
  };
13204
13224
  const observeExchange = (request4) => {
13205
13225
  const method = (request4.method ?? "").toUpperCase();
13206
- const path42 = new URL(request4.url ?? "/", "http://127.0.0.1").pathname;
13207
- if (!path42.startsWith(RC_SESSIONS_PATH_PREFIX)) {
13226
+ if (!isRcSessionExchange(request4.url)) {
13208
13227
  return void 0;
13209
13228
  }
13210
- const tail = path42.slice(RC_SESSIONS_PATH_PREFIX.length);
13229
+ const tail = pathnameOf(request4.url).slice(RC_SESSIONS_PATH_PREFIX.length);
13211
13230
  const facts = {
13212
13231
  oauthAuthorization: oauthAuthorizationOf(request4.headers),
13213
13232
  anthropicVersion: singleHeader(request4.headers, "anthropic-version"),
@@ -19112,6 +19131,7 @@ function createRcEventFanout() {
19112
19131
  function createRcStreamHub(deps) {
19113
19132
  const attachments = /* @__PURE__ */ new Map();
19114
19133
  let closed = false;
19134
+ const refusedAuthorizations = /* @__PURE__ */ new Map();
19115
19135
  const lastSavedSequenceNums = /* @__PURE__ */ new Map();
19116
19136
  const persistCursor = (sessionId) => {
19117
19137
  if (deps.saveSequenceNum === void 0) {
@@ -19215,7 +19235,6 @@ function createRcStreamHub(deps) {
19215
19235
  };
19216
19236
  const runLoop = async (attachment) => {
19217
19237
  let retriedUnauthorized = false;
19218
- let refusedAuthorization;
19219
19238
  for (; ; ) {
19220
19239
  if (attachment.isStopped()) {
19221
19240
  return;
@@ -19231,11 +19250,11 @@ function createRcStreamHub(deps) {
19231
19250
  }
19232
19251
  return;
19233
19252
  }
19234
- if (refusedAuthorization !== void 0 && credential.authorization === refusedAuthorization) {
19253
+ if (credential.authorization === refusedAuthorizations.get(attachment.sessionId)) {
19235
19254
  await deps.sleep(deps.backoffMs);
19236
19255
  continue;
19237
19256
  }
19238
- refusedAuthorization = void 0;
19257
+ refusedAuthorizations.delete(attachment.sessionId);
19239
19258
  let outcome;
19240
19259
  try {
19241
19260
  outcome = await attempt(attachment, credential);
@@ -19263,7 +19282,7 @@ function createRcStreamHub(deps) {
19263
19282
  continue;
19264
19283
  }
19265
19284
  deps.log?.(`rc stream ${attachment.sessionId}: the client read stream refused the observed Authorization bearer past one retry; waiting for a fresh one`);
19266
- refusedAuthorization = credential.authorization;
19285
+ refusedAuthorizations.set(attachment.sessionId, credential.authorization);
19267
19286
  await deps.sleep(deps.backoffMs);
19268
19287
  retriedUnauthorized = false;
19269
19288
  }
@@ -19303,6 +19322,7 @@ function createRcStreamHub(deps) {
19303
19322
  attachment.stop();
19304
19323
  }
19305
19324
  attachments.clear();
19325
+ refusedAuthorizations.clear();
19306
19326
  }
19307
19327
  };
19308
19328
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-shim",
3
- "version": "11.72.0",
3
+ "version": "11.72.2",
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>",