@integrity-labs/agt-cli 0.28.822 → 0.28.823

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.
@@ -16,7 +16,7 @@ import {
16
16
  parseEnvIntegrations,
17
17
  shellQuote,
18
18
  summarizeUnanswerablePane
19
- } from "./chunk-KHCJT45W.js";
19
+ } from "./chunk-2MB3SP6H.js";
20
20
  import {
21
21
  BIND_FAILURE_QUARANTINE_THRESHOLD,
22
22
  INTEGRATIONS_SECTION_END,
@@ -71,7 +71,7 @@ import {
71
71
  sessionTranscriptDir,
72
72
  worseConnectivityOutcome,
73
73
  wrapScheduledTaskPrompt
74
- } from "./chunk-5RMHCQ3H.js";
74
+ } from "./chunk-3QZUOZUZ.js";
75
75
  import {
76
76
  parsePsRows
77
77
  } from "./chunk-XWVM4KPK.js";
@@ -6523,13 +6523,18 @@ function exchangeFailureKind(err) {
6523
6523
  }
6524
6524
 
6525
6525
  // src/lib/api-client.ts
6526
- var agtCliVersion = true ? "0.28.822" : "dev";
6526
+ var agtCliVersion = true ? "0.28.823" : "dev";
6527
6527
  var lastConfigHash = null;
6528
6528
  function setConfigHash(hash) {
6529
6529
  lastConfigHash = hash && hash.length > 0 ? hash : null;
6530
6530
  }
6531
6531
  var cachedExchange = null;
6532
6532
  var exchangeInFlight = null;
6533
+ var exchangeForceCount = 0;
6534
+ var consumedExchangeForceCount = 0;
6535
+ function forceNextExchange() {
6536
+ exchangeForceCount += 1;
6537
+ }
6533
6538
  function getCachedClaudeAuthMode() {
6534
6539
  return cachedExchange?.claudeAuthMode ?? null;
6535
6540
  }
@@ -6538,7 +6543,9 @@ function invalidateExchange() {
6538
6543
  lastConfigHash = null;
6539
6544
  }
6540
6545
  async function exchangeApiKey(rawKey, retried = false, opts = {}) {
6541
- if (!opts.forceRefresh && cachedExchange && Date.now() < cachedExchange.expiresAt - 6e4) {
6546
+ const withinMaxAge = opts.maxAgeMs === void 0 || cachedExchange !== null && Date.now() - cachedExchange.fetchedAt < opts.maxAgeMs;
6547
+ const forcePending = exchangeForceCount > consumedExchangeForceCount;
6548
+ if (!opts.forceRefresh && !forcePending && withinMaxAge && cachedExchange && Date.now() < cachedExchange.expiresAt - 6e4) {
6542
6549
  return {
6543
6550
  token: cachedExchange.token,
6544
6551
  hostId: cachedExchange.hostId,
@@ -6555,12 +6562,15 @@ async function exchangeApiKey(rawKey, retried = false, opts = {}) {
6555
6562
  supabaseAnonKey: cachedExchange.supabaseAnonKey
6556
6563
  };
6557
6564
  }
6565
+ const observedForceCount = exchangeForceCount;
6558
6566
  if (exchangeInFlight) {
6559
6567
  return exchangeInFlight;
6560
6568
  }
6561
6569
  exchangeInFlight = doExchange(rawKey, retried);
6562
6570
  try {
6563
- return await exchangeInFlight;
6571
+ const result = await exchangeInFlight;
6572
+ consumedExchangeForceCount = observedForceCount;
6573
+ return result;
6564
6574
  } finally {
6565
6575
  exchangeInFlight = null;
6566
6576
  }
@@ -6651,7 +6661,8 @@ async function attemptExchange(rawKey, retried) {
6651
6661
  userEmail: data.user_email,
6652
6662
  supabaseUrl: data.supabase_url,
6653
6663
  supabaseAnonKey: data.supabase_anon_key,
6654
- expiresAt: new Date(data.expires_at).getTime()
6664
+ expiresAt: new Date(data.expires_at).getTime(),
6665
+ fetchedAt: Date.now()
6655
6666
  };
6656
6667
  return {
6657
6668
  token: data.token,
@@ -10753,6 +10764,7 @@ export {
10753
10764
  isTransientAuthFailure,
10754
10765
  exchangeFailureKind,
10755
10766
  setConfigHash,
10767
+ forceNextExchange,
10756
10768
  getCachedClaudeAuthMode,
10757
10769
  exchangeApiKey,
10758
10770
  mintAgentKey,
@@ -10818,4 +10830,4 @@ export {
10818
10830
  managerInstallSystemUnitCommand,
10819
10831
  managerUninstallSystemUnitCommand
10820
10832
  };
10821
- //# sourceMappingURL=chunk-IVR3UH5Z.js.map
10833
+ //# sourceMappingURL=chunk-5PFBPGBO.js.map