@adhdev/daemon-standalone 1.0.56-rc.14 → 1.0.56-rc.15

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/index.js CHANGED
@@ -36620,10 +36620,10 @@ var require_dist3 = __commonJS({
36620
36620
  }
36621
36621
  function getDaemonBuildInfo() {
36622
36622
  if (cached2) return cached2;
36623
- const commit = readInjected(true ? "c3be352610b5c15a99497e20665e383360c4a84e" : void 0) ?? "unknown";
36624
- const commitShort = readInjected(true ? "c3be3526" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
36625
- const version2 = readInjected(true ? "1.0.56-rc.14" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
36626
- const builtAt = readInjected(true ? "2026-08-20T06:12:08.076Z" : void 0);
36623
+ const commit = readInjected(true ? "c729eadac0fee941c44c480a2126d9aa38965af1" : void 0) ?? "unknown";
36624
+ const commitShort = readInjected(true ? "c729eada" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
36625
+ const version2 = readInjected(true ? "1.0.56-rc.15" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
36626
+ const builtAt = readInjected(true ? "2026-08-20T07:46:38.982Z" : void 0);
36627
36627
  cached2 = builtAt ? { commit, commitShort, version: version2, builtAt } : { commit, commitShort, version: version2 };
36628
36628
  return cached2;
36629
36629
  }
@@ -38245,6 +38245,9 @@ var require_dist3 = __commonJS({
38245
38245
  interceptorInstalled = false;
38246
38246
  }
38247
38247
  });
38248
+ function defaultRetryDelayMs(kind) {
38249
+ return kind === "rate-limited" ? QUOTA_RATE_LIMIT_RETRY_DELAY_MS : QUOTA_TRANSIENT_RETRY_DELAY_MS;
38250
+ }
38248
38251
  function clampPercent(value) {
38249
38252
  if (Number.isNaN(value)) {
38250
38253
  return 0;
@@ -38268,7 +38271,7 @@ var require_dist3 = __commonJS({
38268
38271
  }
38269
38272
  function quotaFailure(provider, status, error48, metadata) {
38270
38273
  const now = Date.now();
38271
- const resolvedMetadata = metadata && metadata.failureKind && TRANSIENT_QUOTA_FAILURE_KINDS.has(metadata.failureKind) && metadata.retryAtMs === void 0 ? { ...metadata, retryAtMs: now + QUOTA_TRANSIENT_RETRY_DELAY_MS } : metadata;
38274
+ const resolvedMetadata = metadata && metadata.failureKind && TRANSIENT_QUOTA_FAILURE_KINDS.has(metadata.failureKind) && metadata.retryAtMs === void 0 ? { ...metadata, retryAtMs: now + defaultRetryDelayMs(metadata.failureKind) } : metadata;
38272
38275
  return {
38273
38276
  provider,
38274
38277
  session: null,
@@ -38281,6 +38284,7 @@ var require_dist3 = __commonJS({
38281
38284
  }
38282
38285
  var TRANSIENT_QUOTA_FAILURE_KINDS;
38283
38286
  var QUOTA_TRANSIENT_RETRY_DELAY_MS;
38287
+ var QUOTA_RATE_LIMIT_RETRY_DELAY_MS;
38284
38288
  var SESSION_WINDOW_MINUTES;
38285
38289
  var WEEKLY_WINDOW_MINUTES;
38286
38290
  var init_types = __esm2({
@@ -38294,6 +38298,7 @@ var require_dist3 = __commonJS({
38294
38298
  "rate-limited"
38295
38299
  ]);
38296
38300
  QUOTA_TRANSIENT_RETRY_DELAY_MS = 2 * 60 * 1e3;
38301
+ QUOTA_RATE_LIMIT_RETRY_DELAY_MS = 7 * 60 * 1e3;
38297
38302
  SESSION_WINDOW_MINUTES = 300;
38298
38303
  WEEKLY_WINDOW_MINUTES = 10080;
38299
38304
  }
@@ -40709,8 +40714,16 @@ child.on('exit', () => process.exit(0));
40709
40714
  if (count > 0) LOG2.info("Quota", `Restored ${count} provider quota snapshot(s) from the on-disk cache`);
40710
40715
  return count;
40711
40716
  }
40717
+ function isRateLimitedSnapshot(entry) {
40718
+ return !!entry && entry.status !== "ok" && entry.metadata?.failureKind === "rate-limited";
40719
+ }
40720
+ function isRateLimitedCooldownActive(entry, now = Date.now()) {
40721
+ if (!isRateLimitedSnapshot(entry)) return false;
40722
+ const retryAtMs = entry.metadata?.retryAtMs;
40723
+ return typeof retryAtMs === "number" && retryAtMs > now;
40724
+ }
40712
40725
  async function refreshQuotaCacheOnce(fetchers = REFRESHERS, isEnabled) {
40713
- const active = isEnabled ? fetchers.filter(({ provider }) => isEnabled(provider)) : fetchers;
40726
+ const enabled = isEnabled ? fetchers.filter(({ provider }) => isEnabled(provider)) : fetchers;
40714
40727
  if (isEnabled) {
40715
40728
  for (const { provider } of fetchers) {
40716
40729
  if (!isEnabled(provider)) {
@@ -40720,6 +40733,7 @@ child.on('exit', () => process.exit(0));
40720
40733
  }
40721
40734
  }
40722
40735
  }
40736
+ const active = enabled.filter(({ provider }) => !isRateLimitedCooldownActive(cache.get(provider)));
40723
40737
  await Promise.all(
40724
40738
  active.map(async ({ provider, fetch: fetch2 }) => {
40725
40739
  try {
@@ -40840,7 +40854,8 @@ child.on('exit', () => process.exit(0));
40840
40854
  function refreshQuotaCacheOnBoot(isEnabled) {
40841
40855
  if (bootRefreshInFlight || hasFreshlyMeasuredQuota()) return;
40842
40856
  bootRefreshInFlight = true;
40843
- void refreshQuotaCacheOnce(REFRESHERS, isEnabled).catch((e) => LOG2.warn("Quota", `Boot quota refresh failed: ${e?.message || e}`)).finally(() => {
40857
+ const fetchers = REFRESHERS.filter(({ provider }) => !isRateLimitedSnapshot(cache.get(provider)));
40858
+ void refreshQuotaCacheOnce(fetchers, isEnabled).catch((e) => LOG2.warn("Quota", `Boot quota refresh failed: ${e?.message || e}`)).finally(() => {
40844
40859
  bootRefreshInFlight = false;
40845
40860
  });
40846
40861
  }
@@ -40856,6 +40871,7 @@ child.on('exit', () => process.exit(0));
40856
40871
  const refresher = typeof event.providerType === "string" ? REFRESHERS.find(({ provider }) => provider === event.providerType) : void 0;
40857
40872
  if (!refresher) return;
40858
40873
  if (isEnabled && !isEnabled(refresher.provider)) return;
40874
+ if (isRateLimitedSnapshot(cache.get(refresher.provider))) return;
40859
40875
  const at = now();
40860
40876
  if (at - (lastRefreshAt.get(refresher.provider) ?? -Infinity) < debounceMs) return;
40861
40877
  lastRefreshAt.set(refresher.provider, at);