agent-relay-server 0.78.0 → 0.78.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/docs/openapi.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "openapi": "3.1.0",
3
3
  "info": {
4
4
  "title": "Agent Relay API",
5
- "version": "0.78.0",
5
+ "version": "0.78.2",
6
6
  "description": "Real-time message bus for inter-agent communication. Agent-first: this spec is designed for machine consumption — agents can self-discover the full API surface via GET /api/spec.",
7
7
  "license": {
8
8
  "name": "MIT",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-relay-server",
3
- "version": "0.78.0",
3
+ "version": "0.78.2",
4
4
  "description": "Lightweight HTTP message relay for inter-agent communication across machines",
5
5
  "module": "src/index.ts",
6
6
  "type": "module",
@@ -33,7 +33,7 @@
33
33
  "CONTRIBUTING.md"
34
34
  ],
35
35
  "dependencies": {
36
- "agent-relay-sdk": "0.2.53",
36
+ "agent-relay-sdk": "0.2.54",
37
37
  "ajv": "^8.20.0"
38
38
  },
39
39
  "scripts": {
@@ -59,6 +59,10 @@ function canonicalProviderQuotaAccountKey(provider: string, value: string): stri
59
59
  : accountKey;
60
60
  }
61
61
 
62
+ function unstableProviderQuotaAccountKey(accountKey: string): boolean {
63
+ return accountKey.startsWith("host:") || accountKey.startsWith("home:");
64
+ }
65
+
62
66
  function sourceAgentHost(sourceAgentId: string | undefined): string | undefined {
63
67
  if (!sourceAgentId) return undefined;
64
68
  const row = getDb().query("SELECT machine, rig FROM agents WHERE id = ?").get(sourceAgentId) as { machine?: string | null; rig?: string | null } | undefined;
@@ -291,6 +295,9 @@ export function upsertProviderQuota(input: ProviderQuotaUpdateInput, now = Date.
291
295
  getDb().query("UPDATE provider_quotas SET quota_advisory_state = ? WHERE provider = ? AND account_key = ?").run(quotaAdvisoryState, provider, accountKey);
292
296
  }
293
297
  }
298
+ if (!unstableProviderQuotaAccountKey(accountKey)) {
299
+ pruneUnstableProviderQuotaRecords(provider);
300
+ }
294
301
  pruneProviderQuotaRecords(provider, undefined, now - DAY_MS);
295
302
 
296
303
  return listProviderQuotas({ provider, accountKey, historyLimit: 24, now }).quotas[0]!;
@@ -331,19 +338,22 @@ function pruneProviderQuotaRecords(provider?: string, accountKey?: string, older
331
338
  return result.changes;
332
339
  }
333
340
 
341
+ function pruneUnstableProviderQuotaRecords(provider?: string): number {
342
+ const result = provider
343
+ ? getDb().query("DELETE FROM provider_quotas WHERE provider = ? AND (account_key LIKE 'host:%' OR account_key LIKE 'home:%')").run(provider)
344
+ : getDb().query("DELETE FROM provider_quotas WHERE account_key LIKE 'host:%' OR account_key LIKE 'home:%'").run();
345
+ return result.changes;
346
+ }
347
+
334
348
  export function normalizeProviderQuotaAccountKeys(now = Date.now()): number {
335
349
  let changes = 0;
336
350
  for (const row of getDb().query("SELECT * FROM provider_quotas").all() as ProviderQuotaRow[]) {
337
- let accountKey = canonicalProviderQuotaAccountKey(row.provider, row.account_key);
338
- if (accountKey.startsWith("credential:")) {
339
- const sourceAgentId = normalizeSourceAgentIds(row.source_agent_ids)[0];
340
- const host = sourceAgentHost(sourceAgentId);
341
- if (host) accountKey = `host:${host}`;
342
- }
351
+ const accountKey = canonicalProviderQuotaAccountKey(row.provider, row.account_key);
343
352
  if (accountKey !== row.account_key) {
344
353
  changes += mergeProviderQuotaRows(row.provider, accountKey, [row.account_key], now);
345
354
  }
346
355
  }
356
+ changes += pruneUnstableProviderQuotaRecords();
347
357
  changes += pruneProviderQuotaRecords(undefined, undefined, now - DAY_MS);
348
358
  return changes;
349
359
  }