agent-relay-runner 0.78.8 → 0.78.9

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-relay-runner",
3
- "version": "0.78.8",
3
+ "version": "0.78.9",
4
4
  "description": "Unified provider lifecycle runner for Agent Relay",
5
5
  "type": "module",
6
6
  "bin": {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "agent-relay-runner",
3
3
  "description": "Thin Agent Relay runner bridge for Claude Code",
4
- "version": "0.78.8",
4
+ "version": "0.78.9",
5
5
  "agentRelayContracts": {
6
6
  "providerPluginProtocol": 1
7
7
  }
@@ -1,9 +1,10 @@
1
- import type { RelayHttpClient } from "agent-relay-sdk";
1
+ import type { QuotaState, RelayHttpClient } from "agent-relay-sdk";
2
2
  import { quotaStateFromProbeMetrics } from "agent-relay-sdk/context-probe";
3
3
  import { readRunnerContextProbeState } from "./context-probe-state";
4
4
  import { DEFAULT_PROVIDER_QUOTA_CONFIG, normalizeProviderQuotaConfig, resolveClaudeStatuslineQuotaIdentity } from "./quota";
5
5
 
6
6
  const PASSIVE_QUOTA_CONFIG_REFRESH_MS = 60_000;
7
+ const PASSIVE_QUOTA_SAMPLE_STALE_MS = 10 * 60_000;
7
8
 
8
9
  interface ClaudeQuotaHarvestOptions {
9
10
  agentId: string;
@@ -21,11 +22,11 @@ export class ClaudeQuotaHarvest {
21
22
  async publish(): Promise<void> {
22
23
  if (this.options.provider !== "claude") return;
23
24
  const probeMetrics = readRunnerContextProbeState(this.options.agentId);
24
- const quota = probeMetrics ? quotaStateFromProbeMetrics(probeMetrics) : undefined;
25
+ const now = Date.now();
26
+ const quota = probeMetrics ? freshQuotaFromProbeMetrics(probeMetrics, now) : undefined;
25
27
  if (!quota) return;
26
28
  const config = await this.refreshConfig();
27
29
  if (!config.enabled) return;
28
- const now = Date.now();
29
30
  if (this.lastReportAt !== undefined && now - this.lastReportAt < config.pollIntervalMs) return;
30
31
  const identity = await resolveClaudeStatuslineQuotaIdentity({ env: process.env });
31
32
  if (!identity) return;
@@ -55,3 +56,11 @@ export class ClaudeQuotaHarvest {
55
56
  return this.config;
56
57
  }
57
58
  }
59
+
60
+ function freshQuotaFromProbeMetrics(metrics: NonNullable<ReturnType<typeof readRunnerContextProbeState>>, now: number): QuotaState | undefined {
61
+ if (now - metrics.timestamp > PASSIVE_QUOTA_SAMPLE_STALE_MS) return undefined;
62
+ const quota = quotaStateFromProbeMetrics(metrics);
63
+ if (!quota) return undefined;
64
+ const windows = quota.windows.filter((window) => window.resetsAt === undefined || window.resetsAt > now);
65
+ return windows.length > 0 ? { ...quota, windows, updatedAt: now } : undefined;
66
+ }