myapikey 0.28.0 → 0.29.0

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": "myapikey",
3
- "version": "0.28.0",
3
+ "version": "0.29.0",
4
4
  "type": "module",
5
5
  "description": "Personal LLM API gateway & proxy — one address + one API key for all your models. Forwards OpenAI & Anthropic calls to your backends with failover and a circuit breaker. Pure passthrough, no format translation. Self-hosted (CLI + web UI).",
6
6
  "keywords": [
@@ -381,21 +381,26 @@ export function adminApi(store: Store, auth: MiddlewareHandler, openai: Hono, an
381
381
  // successful call per (model, format) from the log tail (newest first,
382
382
  // so the first hit wins). The UI shows this as the model's in-use slot —
383
383
  // after a failover the chip follows the source that really served.
384
+ // Companion map for FAILURES (latest 4xx/5xx per model+format) so the
385
+ // chain popover can flag the slots that recently errored.
384
386
  // Legacy rows carry only the provider NAME; resolve it to the stable id
385
387
  // so they can still match a slot.
386
388
  const byName = new Map(d.providers.map((p) => [p.name, p.id]));
387
- const last = new Map<string, Map<string, LogEntry>>();
389
+ const okLog = new Map<string, Map<string, LogEntry>>();
390
+ const badLog = new Map<string, Map<string, LogEntry>>();
388
391
  for (const row of store.getLogs()) {
389
- if (row.status < 200 || row.status >= 400) continue;
390
392
  const pid = row.providerId ?? (row.provider ? byName.get(row.provider) : undefined);
391
393
  if (!pid) continue;
392
- let perFmt = last.get(row.model);
393
- if (!perFmt) last.set(row.model, (perFmt = new Map()));
394
+ const target = row.status >= 200 && row.status < 400 ? okLog : badLog;
395
+ let perFmt = target.get(row.model);
396
+ if (!perFmt) target.set(row.model, (perFmt = new Map()));
394
397
  if (!perFmt.has(row.format)) perFmt.set(row.format, row);
395
398
  }
399
+ const lastEntries = (src: Map<string, Map<string, LogEntry>>, name: string) =>
400
+ [...src.get(name)?.entries() ?? []];
396
401
  const models = Object.entries(d.models).map(([name, e]) => ({
397
402
  ...projectModel(name, e, byId),
398
- lastRoute: [...last.get(name)?.entries() ?? []].map(([format, row]) => ({
403
+ lastRoute: lastEntries(okLog, name).map(([format, row]) => ({
399
404
  format,
400
405
  providerId: row.providerId ?? byName.get(row.provider) ?? "",
401
406
  // The upstream name that was actually forwarded (a per-slot rewrite,
@@ -403,6 +408,14 @@ export function adminApi(store: Store, auth: MiddlewareHandler, openai: Hono, an
403
408
  model: row.upstreamModel ?? row.model,
404
409
  ts: row.ts,
405
410
  })),
411
+ lastFail: lastEntries(badLog, name).map(([format, row]) => ({
412
+ format,
413
+ providerId: row.providerId ?? byName.get(row.provider) ?? "",
414
+ model: row.upstreamModel ?? row.model,
415
+ status: row.status,
416
+ error: row.error,
417
+ ts: row.ts,
418
+ })),
406
419
  }));
407
420
  return c.json({ models });
408
421
  });