tuxevil-rotator 4.2.2 → 4.4.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.
Files changed (84) hide show
  1. package/CHANGELOG.md +48 -1
  2. package/README.md +11 -4
  3. package/package.json +2 -1
  4. package/plugins/opencode-discovery/capabilities.d.mts +7 -0
  5. package/plugins/opencode-discovery/capabilities.mjs +54 -0
  6. package/plugins/opencode-discovery/index.d.mts +2 -1
  7. package/plugins/opencode-discovery/index.mjs +6 -1
  8. package/plugins/opencode-discovery/package.json +3 -1
  9. package/src/access-evidence.ts +153 -0
  10. package/src/access-probe.ts +85 -0
  11. package/src/admin-auth.ts +4 -1
  12. package/src/audio-transcription.ts +32 -6
  13. package/src/auto-access-shadow.ts +11 -0
  14. package/src/auto-model-access.ts +185 -0
  15. package/src/auto-output-health.ts +12 -0
  16. package/src/auto-routing-evaluation.ts +80 -0
  17. package/src/auto-routing-quality.ts +308 -0
  18. package/src/auto-routing.ts +403 -26
  19. package/src/cli.ts +3 -3
  20. package/src/compat/model-specs.ts +4 -0
  21. package/src/compat.ts +253 -37
  22. package/src/compression/index.ts +6 -6
  23. package/src/compression/lite.ts +3 -9
  24. package/src/compression/rtk/index.ts +0 -3
  25. package/src/config-defaults.ts +7 -0
  26. package/src/dashboard-app.ts +1 -0
  27. package/src/dashboard.ts +5 -0
  28. package/src/db-store.ts +10 -0
  29. package/src/index.ts +2 -0
  30. package/src/install-agent.ts +211 -129
  31. package/src/install-opencode.ts +80 -18
  32. package/src/model-access-api.ts +74 -0
  33. package/src/model-access.ts +56 -0
  34. package/src/ollama-output-gate.ts +18 -0
  35. package/src/onboarding.ts +1 -1
  36. package/src/provider-catalog-evidence.ts +26 -0
  37. package/src/providers/google-antigravity/catalog.ts +14 -6
  38. package/src/providers/google-antigravity/dynamic-catalog.ts +87 -3
  39. package/src/providers/google-antigravity/forward.ts +4 -2
  40. package/src/providers/google-antigravity/quota.ts +7 -0
  41. package/src/providers/ollama/context-window.ts +13 -0
  42. package/src/providers/ollama/forward.ts +10 -0
  43. package/src/providers/ollama/quota.ts +4 -0
  44. package/src/providers/ollama/translators.ts +19 -2
  45. package/src/providers/openai-codex/catalog.ts +157 -18
  46. package/src/providers/openai-codex/compat.ts +5 -1
  47. package/src/providers/openai-codex/credentials.ts +22 -6
  48. package/src/providers/openai-codex/index.ts +9 -1
  49. package/src/providers/openai-codex/quota.ts +19 -6
  50. package/src/providers/opencode-zen/forward.ts +1 -1
  51. package/src/providers/opencode-zen/quota.ts +2 -0
  52. package/src/proxy.ts +113 -5
  53. package/src/quota-observation.ts +26 -0
  54. package/src/quota-pools.ts +322 -0
  55. package/src/rotator.ts +167 -40
  56. package/src/settings-repository.ts +1 -0
  57. package/src/types.ts +106 -29
  58. package/src/usage-limits-auth.ts +24 -0
  59. package/src/usage-limits.ts +148 -0
  60. package/src/validators.ts +26 -0
  61. package/src/web/app.tsx +4 -0
  62. package/src/web/components/icons.tsx +15 -0
  63. package/src/web/components/overlays.tsx +4 -0
  64. package/src/web/components/ui.tsx +9 -9
  65. package/src/web/lib/audio-recorder.ts +159 -0
  66. package/src/web/lib/colors.ts +4 -0
  67. package/src/web/lib/playground-storage.ts +261 -0
  68. package/src/web/lib/playground.ts +483 -0
  69. package/src/web/lib/pool-navigation.ts +4 -0
  70. package/src/web/lib/pools.ts +2 -243
  71. package/src/web/nav.ts +1 -0
  72. package/src/web/pages/AccountDetail.tsx +2 -1
  73. package/src/web/pages/ModelAccess.tsx +88 -0
  74. package/src/web/pages/Models.tsx +2 -0
  75. package/src/web/pages/Overview.tsx +26 -9
  76. package/src/web/pages/Playground.tsx +1692 -0
  77. package/src/web/pages/Transcription.tsx +562 -0
  78. package/src/web/state/api.ts +6 -0
  79. package/src/web/state/playground-client.ts +136 -0
  80. package/src/web/state/playground.ts +69 -0
  81. package/src/web/state/router.ts +2 -2
  82. package/src/web/state/transcription-client.ts +93 -0
  83. package/src/web/styles/app.css +501 -0
  84. package/tools/telemetry-receiver/receiver.js +59 -46
@@ -1,243 +1,2 @@
1
- // Model-first view of the fleet: one row per quota pool (Claude, Gemini,
2
- // Codex, Ollama session/weekly, …) instead of one card per account.
3
-
4
- import type { AccountTier, ModelQuota } from "../../types.js";
5
- import type {
6
- DashboardAccount,
7
- DashboardOverview,
8
- DashboardRoutingAccount,
9
- DashboardRoutingDiagnostics,
10
- } from "../../dashboard-types.js";
11
- import { isOutOfService, providerRank, providerIds, quotaProvider } from "./status.js";
12
-
13
- /** Rough requests per full quota window, used only to weight pooled capacity. */
14
- const TIER_CAPACITY: Record<string, number> = {
15
- ultra: 2000,
16
- max: 2000,
17
- team: 1500,
18
- pro: 1500,
19
- plus: 1000,
20
- free: 250,
21
- unknown: 250,
22
- };
23
-
24
- export function tierWeight(tier: AccountTier | string | undefined): number {
25
- return TIER_CAPACITY[String(tier || "unknown")] ?? 250;
26
- }
27
-
28
- export type PoolState = "ok" | "low" | "empty" | "blocked";
29
-
30
- export interface PoolMember {
31
- account: DashboardAccount;
32
- quota: ModelQuota;
33
- diagnostic: DashboardRoutingAccount | null;
34
- }
35
-
36
- export interface ModelPool {
37
- key: string;
38
- name: string;
39
- provider: string;
40
- /** In-service accounts that carry this pool. */
41
- members: PoolMember[];
42
- /** Members with quota left. */
43
- withQuota: number;
44
- /** Remaining included quota, weighted by credit allowance or account tier, 0–100. */
45
- capacity: number;
46
- /** Actual included credits, summed across in-service accounts. */
47
- credits: ModelQuota["credits"] | null;
48
- /** The account routing this pool now; null before its first request or after it stops being routable. */
49
- serving: DashboardAccount | null;
50
- /** Eligible accounts after `serving`, the policy's pick first. */
51
- nextUp: DashboardAccount[];
52
- nextResetAt: number | null;
53
- /** Requests per hour over the last hour (estimate). */
54
- burnPerHour: number;
55
- /** Hours until the pool runs dry at the current burn; null when idle. */
56
- hoursLeft: number | null;
57
- breakerUntil: number | null;
58
- diagnostics: DashboardRoutingDiagnostics | null;
59
- state: PoolState;
60
- /** Why nothing is serving, when that is the case. */
61
- blockedReason: string | null;
62
- }
63
-
64
- /** Map a request model id to the quota pool it draws from (best effort). */
65
- export function poolKeyForModel(model: string): string {
66
- const lower = model.toLowerCase();
67
- if (lower === "big-pickle" || lower.endsWith("-free")) return "opencode-zen";
68
- if (lower.includes("claude") || lower.startsWith("gpt-oss-120b")) return "claude";
69
- if (lower.includes("gemini")) return "gemini";
70
- if (/^gpt-\d/.test(lower) || lower.includes("codex")) return "openai-codex";
71
- return "session";
72
- }
73
-
74
- function isRollingFullWindow(quota: ModelQuota, remaining: number): boolean {
75
- // A pool at 100% whose reset is exactly one window away is a rolling
76
- // window that has not started; its "reset" is not a real event.
77
- if (quota.percentRemaining !== 100) return false;
78
- const tolerance = 10 * 60_000;
79
- return (
80
- Math.abs(remaining - 5 * 3_600_000) < tolerance ||
81
- Math.abs(remaining - 7 * 86_400_000) < tolerance
82
- );
83
- }
84
-
85
- export function buildPools(overview: DashboardOverview, now: number): ModelPool[] {
86
- const byKey = new Map<string, { name: string; provider: string; members: PoolMember[] }>();
87
-
88
- for (const account of overview.accounts) {
89
- for (const quota of account.quota || []) {
90
- let pool = byKey.get(quota.modelKey);
91
- if (!pool) {
92
- pool = {
93
- name: quota.displayName || quota.modelKey,
94
- provider: quotaProvider(quota),
95
- members: [],
96
- };
97
- byKey.set(quota.modelKey, pool);
98
- }
99
- if (isOutOfService(account) || account.disabledProviders?.includes(quotaProvider(quota))) continue;
100
- const diag = overview.routingDiagnostics[quota.modelKey];
101
- pool.members.push({
102
- account,
103
- quota,
104
- diagnostic: diag?.accounts.find((d) => d.email === account.email) ?? null,
105
- });
106
- }
107
- }
108
-
109
- const burnByPool: Record<string, number> = {};
110
- for (const [model, requests] of Object.entries(overview.recentRequestsByModel || {})) {
111
- const key = poolKeyForModel(model);
112
- burnByPool[key] = (burnByPool[key] || 0) + requests;
113
- }
114
-
115
- const accountByEmail = new Map(overview.accounts.map((a) => [a.email, a]));
116
- const pools: ModelPool[] = [];
117
-
118
- for (const [key, pool] of byKey) {
119
- const diagnostics = overview.routingDiagnostics[key] ?? null;
120
- let weighted = 0;
121
- let weightTotal = 0;
122
- let remainingRequests = 0;
123
- let withQuota = 0;
124
- let nextResetAt: number | null = null;
125
- let credits: ModelQuota["credits"] | null = null;
126
-
127
- for (const member of pool.members) {
128
- const credit = member.quota.credits;
129
- const weight = credit?.allowanceUsd ?? tierWeight(member.account.tier);
130
- if (credit) {
131
- credits ??= { balanceUsd: 0, allowanceUsd: 0, purchasedUsd: 0 };
132
- credits.balanceUsd += credit.balanceUsd;
133
- credits.allowanceUsd += credit.allowanceUsd;
134
- credits.purchasedUsd += credit.purchasedUsd;
135
- }
136
- const pct = Math.max(0, Math.min(100, member.quota.percentRemaining || 0));
137
- weighted += pct * weight;
138
- weightTotal += weight;
139
- remainingRequests += (pct / 100) * weight;
140
- if (pct > 0 || (credit?.purchasedUsd ?? 0) > 0) withQuota += 1;
141
- if (member.quota.resetTime && member.quota.timerType !== "fresh") {
142
- const resetAt = Date.parse(member.quota.resetTime);
143
- const remaining = resetAt - now;
144
- if (remaining > 0 && !isRollingFullWindow(member.quota, remaining)) {
145
- if (nextResetAt === null || resetAt < nextResetAt) nextResetAt = resetAt;
146
- }
147
- }
148
- }
149
-
150
- // The account routing this pool right now, the same one whose status reads
151
- // Serving. The policy's pick for the next rotation leads nextUp.
152
- const servingEmail = overview.activeAccounts[key] ?? null;
153
- const serving = servingEmail ? accountByEmail.get(servingEmail) ?? null : null;
154
- const selectedEmail = diagnostics?.selectedEmail ?? null;
155
-
156
- const nextUp = (diagnostics?.accounts ?? [])
157
- .filter((d) => !d.rejectedReason && d.email !== servingEmail)
158
- .sort(
159
- (a, b) =>
160
- Number(b.email === selectedEmail) - Number(a.email === selectedEmail) ||
161
- (b.score ?? -Infinity) - (a.score ?? -Infinity),
162
- )
163
- .map((d) => accountByEmail.get(d.email))
164
- .filter((a): a is DashboardAccount => Boolean(a))
165
- .slice(0, 2);
166
-
167
- const capacity = credits && credits.allowanceUsd > 0
168
- ? Math.max(0, Math.min(100, Math.round(credits.balanceUsd / credits.allowanceUsd * 100)))
169
- : weightTotal > 0 ? Math.round(weighted / weightTotal) : 0;
170
- const availableCapacity = credits && credits.allowanceUsd > 0
171
- ? (credits.balanceUsd + credits.purchasedUsd) / credits.allowanceUsd * 100
172
- : capacity;
173
- const burnPerHour = burnByPool[key] || 0;
174
- const hoursLeft = !credits && burnPerHour > 0 ? remainingRequests / burnPerHour : null;
175
- const breaker = overview.circuitBreakers.model[key];
176
- const breakerUntil = breaker && breaker > now ? breaker : null;
177
-
178
- let state: PoolState = "ok";
179
- if (breakerUntil || (pool.members.length > 0 && withQuota === 0)) state = "blocked";
180
- else if (diagnostics && !diagnostics.selectedEmail && diagnostics.availableCandidates === 0)
181
- state = "blocked";
182
- else if (availableCapacity === 0) state = "empty";
183
- else if (availableCapacity < 20) state = "low";
184
-
185
- pools.push({
186
- key,
187
- name: pool.name,
188
- provider: pool.provider,
189
- members: pool.members,
190
- withQuota,
191
- capacity,
192
- credits,
193
- serving,
194
- nextUp,
195
- nextResetAt,
196
- burnPerHour,
197
- hoursLeft,
198
- breakerUntil,
199
- diagnostics,
200
- state,
201
- blockedReason:
202
- state === "blocked"
203
- ? breakerUntil
204
- ? "Circuit breaker open after repeated provider rate limits."
205
- : diagnostics?.reason || "No account has quota left in this pool."
206
- : null,
207
- });
208
- }
209
-
210
- return pools.sort(
211
- (a, b) =>
212
- providerRank(a.provider) - providerRank(b.provider) ||
213
- a.name.localeCompare(b.name),
214
- );
215
- }
216
-
217
- export interface ProviderGroup {
218
- provider: string;
219
- accounts: DashboardAccount[];
220
- pools: ModelPool[];
221
- }
222
-
223
- /** Connected providers remain visible even before their first successful quota poll. */
224
- export function buildProviderGroups(overview: DashboardOverview, now: number): ProviderGroup[] {
225
- const groups = new Map<string, ProviderGroup>();
226
- const ensure = (provider: string): ProviderGroup => {
227
- let group = groups.get(provider);
228
- if (!group) {
229
- group = { provider, accounts: [], pools: [] };
230
- groups.set(provider, group);
231
- }
232
- return group;
233
- };
234
- for (const account of overview.accounts) {
235
- const providers = new Set([
236
- ...providerIds(account),
237
- ...account.quota.map(quotaProvider),
238
- ]);
239
- for (const provider of providers) ensure(provider).accounts.push(account);
240
- }
241
- for (const pool of buildPools(overview, now)) ensure(pool.provider).pools.push(pool);
242
- return [...groups.values()].sort((a, b) => providerRank(a.provider) - providerRank(b.provider));
243
- }
1
+ // Shared pure observability aggregation, usable by the dashboard and future API.
2
+ export * from "../../quota-pools.js";
package/src/web/nav.ts CHANGED
@@ -17,6 +17,7 @@ export const NAV: NavItem[] = [
17
17
  { id: "overview", label: "Overview", icon: "overview", href: BASE, keywords: "home status health models pools" },
18
18
  { id: "accounts", label: "Accounts", icon: "accounts", href: `${BASE}/accounts`, keywords: "providers quota" },
19
19
  { id: "models", label: "Models", icon: "models", href: `${BASE}/models`, keywords: "providers order enable disable catalog" },
20
+ { id: "playground", label: "Playground", icon: "play", href: `${BASE}/playground`, keywords: "chat compare compliance transcription microphone audio test models images" },
20
21
  { id: "requests", label: "Requests", icon: "requests", href: `${BASE}/requests`, keywords: "traffic logs history live" },
21
22
  { id: "usage", label: "Usage", icon: "usage", href: `${BASE}/usage`, keywords: "tokens savings latency heatmap" },
22
23
  { id: "keys", label: "Virtual keys", icon: "keys", href: `${BASE}/keys`, keywords: "api clients" },
@@ -35,7 +35,7 @@ import {
35
35
  StatusPill,
36
36
  } from "../components/ui.js";
37
37
  import { accountMenuItems } from "./Accounts.js";
38
- import { providerPath } from "../state/router.js";
38
+ import { BASE, providerPath } from "../state/router.js";
39
39
 
40
40
  export function AccountDetail({ email, onClose }: { email: string; onClose: () => void }): JSX.Element {
41
41
  const data = overview.value!;
@@ -73,6 +73,7 @@ export function AccountDetail({ email, onClose }: { email: string; onClose: () =
73
73
  </Button>
74
74
  </header>
75
75
 
76
+ <section class="detail-section"><Link href={`${BASE}/models?accessAccount=${encodeURIComponent(account.id ?? "")}#model-access`}>Inspect model access rules</Link></section>
76
77
  <section class={`detail-status tone-${meta.tone}`}>
77
78
  <div class="detail-status-line">
78
79
  <StatusPill status={account.status} />
@@ -0,0 +1,88 @@
1
+ import type { JSX } from "preact";
2
+ import { useEffect, useState } from "preact/hooks";
3
+ import type { AccessReport } from "../../model-access-api.js";
4
+ import { api } from "../state/api.js";
5
+ import { query } from "../state/router.js";
6
+ import { masker } from "../state/store.js";
7
+ import { Panel, Button } from "../components/ui.js";
8
+
9
+ export function ModelAccessPanel(): JSX.Element {
10
+ const [now, setNow] = useState(Date.now());
11
+ useEffect(() => { const timer = setInterval(() => setNow(Date.now()), 30000); return () => clearInterval(timer); }, []);
12
+ const [report, setReport] = useState<AccessReport | null>(null);
13
+ const [accountId, setAccount] = useState(query.value.get("accessAccount") ?? "");
14
+ const [provider, setProvider] = useState("google-antigravity");
15
+ const [plan, setPlan] = useState("");
16
+ const [client, setClient] = useState("unknown");
17
+ const [at, setAt] = useState("");
18
+ const [ruleFilter, setRuleFilter] = useState("");
19
+ const [model, setModel] = useState("gemini-3.8-flash-medium");
20
+ const [decision, setDecision] = useState<AccessReport | null>(null);
21
+ const [decisionKey, setDecisionKey] = useState("");
22
+ const formKey = JSON.stringify([accountId, provider, plan, client, model, at]);
23
+ const [error, setError] = useState("");
24
+ const [busy, setBusy] = useState(false);
25
+ useEffect(() => {
26
+ let active = true;
27
+ api.modelAccess().then(value => { if (active) setReport(value); }).catch(() => { if (active) setError("Access rules could not be loaded."); });
28
+ return () => { active = false; };
29
+ }, []);
30
+ // Clear an earlier decision when its inputs no longer apply.
31
+ useEffect(() => { setDecision(null); }, [accountId, provider, plan, client, model, at]);
32
+ const selected = report?.accounts.find(a => a.id === accountId);
33
+ useEffect(() => {
34
+ if (selected && !selected.providers.includes(provider)) setProvider(selected.providers[0] ?? "google-antigravity");
35
+ }, [selected, provider]);
36
+ const catalog = selected?.providerCatalogs?.find(c => c.provider === provider);
37
+ const catalogFreshness = catalog?.freshness === "fresh" && catalog.expiresAt !== null && catalog.expiresAt <= now ? "stale" : catalog?.freshness;
38
+ const declaredPlan = selected?.providerPlans.find(p => p.provider === provider);
39
+ const effectivePlan = plan || declaredPlan?.plan || selected?.inferredPlan || "unknown";
40
+ const rules = report?.rules.filter(r => r.modelPrefix.toLowerCase().includes(ruleFilter.toLowerCase()) && r.provider === provider && ((effectivePlan === "unknown" || !accountId && !plan) || r.plans.includes(effectivePlan) || r.plans.includes("*"))) ?? [];
41
+ const inspect = async () => {
42
+ setBusy(true); setError("");
43
+ try {
44
+ const params = new URLSearchParams({ provider, model, client });
45
+ if (accountId) params.set("accountId", accountId);
46
+ if (plan) params.set("plan", plan);
47
+ if (at) params.set("at", at);
48
+ const result = await api.modelAccess(params);
49
+ setReport(result); setDecision(result); setDecisionKey(formKey);
50
+ } catch { setError("Check the selected account, provider and model."); }
51
+ finally { setBusy(false); }
52
+ };
53
+ const savePlan = async () => {
54
+ if (!accountId || !plan) return;
55
+ setBusy(true); setError("");
56
+ try { setReport(await api.declareProviderPlan(accountId, provider, plan)); setPlan(""); setDecision(null); }
57
+ catch { setError("Provider plan could not be persisted."); }
58
+ finally { setBusy(false); }
59
+ };
60
+ return <Panel id="model-access" title="Model access" subtitle="Informational rules only. Quota, credentials, capabilities and routing are checked separately.">
61
+ <div class="form-grid">
62
+ <label>Account<select value={accountId} onChange={e => setAccount(e.currentTarget.value)}><option value="">No account — simulate policy</option>{report?.accounts.map(a => <option key={a.id} value={a.id}>{masker.value.email(a.label)}</option>)}</select></label>
63
+ <label>Provider<select value={provider} onChange={e => setProvider(e.currentTarget.value)}>{["google-antigravity", "openai-codex", "ollama", "opencode-zen"].map(p => <option key={p}>{p}</option>)}</select></label>
64
+ <label>Plan assumption<select value={plan} onChange={e => setPlan(e.currentTarget.value)}><option value="">Use known account plan</option>{["unknown", "free", "plus", "pro-trial", "pro-paid", "ultra", "enterprise"].map(p => <option key={p}>{p}</option>)}</select></label>
65
+ <label>Client declaration<select value={client} onChange={e => setClient(e.currentTarget.value)}>{["unknown", "opencode", "other"].map(p => <option key={p}>{p}</option>)}</select></label>
66
+ <label>Policy date (optional)<input type="date" value={at} onInput={e => setAt(e.currentTarget.value)} /></label>
67
+ <label>Model ID<input value={model} onInput={e => setModel(e.currentTarget.value)} maxLength={256} /></label>
68
+ </div>
69
+ <p>Plan: {effectivePlan}. {selected && selected.providers.length > 1 ? "Linked providers need separate plan evidence." : "Pro without billing evidence remains unknown."} Client identity is not verified here.</p>
70
+ <p>{declaredPlan ? `Stored provider declaration: ${declaredPlan.plan}, expires ${new Date(declaredPlan.expiresAt).toISOString()}.` : "No current provider-specific plan declaration."}</p>
71
+ <Button onClick={() => { void savePlan(); }} disabled={busy || !accountId || !plan}>Save provider plan declaration</Button>
72
+ <Button onClick={() => { void inspect(); }} disabled={busy || !report || !model}>{busy ? "Checking…" : "Explain access"}</Button>
73
+ {error && <p role="alert">{error}</p>}
74
+ {decisionKey === formKey && decision?.decision && <div role="status"><strong>{decision.decision.state}</strong><p>{decision.decision.reason}</p><p>Plan source: {decision.planSource}. This result does not grant access.</p><p>Account catalog: {decision.catalogAvailability?.expiresAt != null && decision.catalogAvailability.expiresAt <= now ? "unknown (expired snapshot)" : decision.catalogAvailability?.state ?? "unknown"}.</p></div>}
75
+ {selected && <details><summary>Recent account observations ({selected.observations.filter(o => o.provider === provider).length})</summary>
76
+ <p>Latest result per model and declared client. No plan inference or routing blocks are created.</p>
77
+ <div class="table-wrap"><table><thead><tr><th>Model</th><th>Client</th><th>Result</th><th>HTTP</th><th>Observed</th><th>Expires</th></tr></thead><tbody>{selected.observations.filter(o => o.provider === provider).map(o => <tr key={`${o.provider}/${o.model}/${o.client}`}><td>{o.model}</td><td>{o.client}</td><td>{o.kind === "model-unavailable" ? "Provider rejects this model for this account" : o.kind}</td><td>{o.status ?? "—"}</td><td>{new Date(o.observedAt).toISOString()}</td><td>{new Date(o.expiresAt).toISOString()}</td></tr>)}</tbody></table></div>
78
+ </details>}
79
+ {selected && <details><summary>Provider-advertised models ({catalog?.observedAt == null ? "unknown" : catalog.models.length})</summary>
80
+ <p>{catalog ? `Source: ${catalog.source}. Snapshot: ${catalogFreshness}. Observed: ${catalog.observedAt === null ? "unknown" : new Date(catalog.observedAt).toISOString()}. Valid until: ${catalog.expiresAt === null ? "unknown" : new Date(catalog.expiresAt).toISOString()}.` : "No account-level provider catalog is available for this provider."}</p>
81
+ <p>Advertisement is separate from subscription rules and observed access. Missing or stale data means unknown.</p>
82
+ {catalog && <ul>{catalog.models.map(id => <li key={id}>{id}</li>)}</ul>}
83
+ </details>}
84
+ <label>Filter rule models<input value={ruleFilter} onInput={e => setRuleFilter(e.currentTarget.value)} /></label>
85
+ <div class="table-wrap"><table><thead><tr><th>Model / family</th><th>Plans</th><th>Declared access</th><th>Evidence</th><th>Availability ends</th><th>Notes / source</th></tr></thead><tbody>{rules.map(r => <tr key={r.id}><td>{r.modelPrefix}{r.exact ? " (exact model)" : ""}</td><td>{r.plans.join(", ")}</td><td>{r.state}</td><td>{r.evidence}<br />{r.verifiedAt}<br />Review: {r.reviewAfter}</td><td>{r.validUntil ?? "Not specified"}</td><td>{r.note}<br />{r.source.startsWith("https://") ? <a href={r.source} target="_blank" rel="noreferrer">Source</a> : r.source}</td></tr>)}</tbody></table></div>
86
+ {!report && !error && <p>Loading access rules…</p>}
87
+ </Panel>;
88
+ }
@@ -1,3 +1,4 @@
1
+ import { ModelAccessPanel } from "./ModelAccess.js";
1
2
  // Models: which providers serve traffic, in what order, and which models
2
3
  // clients can call. The provider drawer lives at /dashboard/models/<provider>.
3
4
 
@@ -157,6 +158,7 @@ export function ModelsPage(): JSX.Element {
157
158
  <ProvidersPanel state={state} providers={providers} />
158
159
  <EffortRoutingPanel state={state} change={change} />
159
160
  <ModelsPanel state={state} />
161
+ <ModelAccessPanel />
160
162
  <Drawer open={Boolean(drawerId)} onClose={closeDrawer} label="Provider details">
161
163
  {drawerId &&
162
164
  (drawerSummary ? (
@@ -1,3 +1,4 @@
1
+ import { findPoolTarget } from "../lib/pool-navigation.js";
1
2
  // Overview: is routing working, how long will each model last, and what
2
3
  // needs the operator. Model pools come first; accounts are one click away.
3
4
 
@@ -282,7 +283,7 @@ function AttentionActionButton({ action }: { action: AttentionAction }): JSX.Ele
282
283
  <Button
283
284
  size="sm"
284
285
  variant="ghost"
285
- onClick={() => document.getElementById(`pool-${action.model}`)?.scrollIntoView({ behavior: "smooth", block: "center" })}
286
+ onClick={() => findPoolTarget(document.querySelectorAll<HTMLElement>("[data-pool-model]"), action.model)?.scrollIntoView({ behavior: "smooth", block: "center" })}
286
287
  >
287
288
  Inspect
288
289
  </Button>
@@ -365,7 +366,7 @@ function ProvidersPanel({ providers }: { providers: ProviderGroup[] }): JSX.Elem
365
366
  </thead>
366
367
  <tbody>
367
368
  {providers.flatMap((group) => group.pools.length > 0 ? group.pools.map((pool) => (
368
- <PoolRow key={pool.key} pool={pool} expanded={open === pool.key} onToggle={() => setOpen(open === pool.key ? null : pool.key)} />
369
+ <PoolRow key={pool.id} pool={pool} expanded={open === pool.id} onToggle={() => setOpen(open === pool.id ? null : pool.id)} />
369
370
  )) : [
370
371
  <tr key={group.provider}>
371
372
  <th scope="row">{providerLabel(group.provider)}</th>
@@ -385,11 +386,21 @@ function ProvidersPanel({ providers }: { providers: ProviderGroup[] }): JSX.Elem
385
386
 
386
387
  function PoolRow({ pool, expanded, onToggle }: { pool: ModelPool; expanded: boolean; onToggle: () => void }): JSX.Element {
387
388
  const state = POOL_STATE[pool.state];
389
+ const partial = pool.partialObservation;
390
+ const capacity = pool.observedCapacity ?? partial?.remainingPercent ?? null;
391
+ const basis = partial?.percentageBasis ?? pool.capacityBasis;
392
+ const freshness = partial?.freshness ?? pool.freshness;
393
+ const capacityHint = [
394
+ capacity === null ? "Quota not reported" : `${capacity}% remaining`,
395
+ partial ? `Known subset only: ${pool.quotaCoverage.knownAccounts}/${pool.quotaCoverage.totalAccounts} accounts measured` : "",
396
+ basis === "tier-estimate" ? "Estimated relative capacity" : "",
397
+ freshness === "unknown" ? "Freshness unknown" : freshness === "stale" ? "Stale observation" : "Recent observation",
398
+ ].filter(Boolean).join(" · ");
388
399
  const estimate = estimateText(pool);
389
400
  const name = masker.value.name;
390
401
  return (
391
402
  <>
392
- <tr id={`pool-${pool.key}`} class={`pool-row${expanded ? " is-open" : ""}`}>
403
+ <tr data-pool-model={pool.key} id={`pool-${encodeURIComponent(pool.id)}`} class={`pool-row${expanded ? " is-open" : ""}`}>
393
404
  <th scope="row">
394
405
  <div class="pool-name">
395
406
  <span>{pool.name}</span>
@@ -401,20 +412,25 @@ function PoolRow({ pool, expanded, onToggle }: { pool: ModelPool; expanded: bool
401
412
  </Pill>
402
413
  )}
403
414
  </th>
404
- <td data-label="Remaining">
415
+ <td data-label="Remaining" title={capacityHint}>
405
416
  <div class="pool-capacity">
406
- <Meter value={pool.capacity} label={`${pool.name} pooled ${pool.credits ? "included credits" : "quota"} remaining`} />
407
- <span class="num">{pool.capacity}%</span>
417
+ <Meter value={capacity} label={`${pool.name}: ${capacityHint}`} />
418
+ <span class="num">{capacity === null ? "—" : `${capacity}%`}</span>
408
419
  </div>
409
- {pool.credits && (
420
+ {partial && <div class="cell-sub">Partial · {pool.quotaCoverage.knownAccounts}/{pool.quotaCoverage.totalAccounts} accounts measured</div>}
421
+ {pool.credits && pool.observedCapacity !== null && (
410
422
  <div class="cell-sub num">
411
423
  {formatUsd(pool.credits.balanceUsd)} / {formatUsd(pool.credits.allowanceUsd)} included
412
424
  {pool.credits.purchasedUsd > 0 && <> · {formatUsd(pool.credits.purchasedUsd)} purchased</>}
413
425
  </div>
414
426
  )}
415
427
  <div class="cell-sub">
416
- {pool.withQuota} of {pluralize(pool.members.length, "account")} with quota
428
+ {capacity === null ? (pool.catalogAccessible ? "Catalog accessible · quota unknown" : "Quota unknown")
429
+ : partial ? `${partial.accountsWithQuota}/${pool.quotaCoverage.knownAccounts} measured accounts with quota`
430
+ : `${pool.observedWithQuota} of ${pluralize(pool.members.length, "account")} with quota`}
431
+ {" · "}{pool.eligibleNow ?? "Unknown"} eligible
417
432
  </div>
433
+ {freshness === "stale" && <div class="cell-sub tone-text-warn">Stale observation</div>}
418
434
  </td>
419
435
  <td data-label="Serving">
420
436
  {pool.serving ? (
@@ -451,7 +467,8 @@ function PoolRow({ pool, expanded, onToggle }: { pool: ModelPool; expanded: bool
451
467
  )}
452
468
  </td>
453
469
  <td data-label="Next reset">
454
- <Countdown until={pool.nextResetAt} />
470
+ <Countdown until={pool.observedNextResetAt} />
471
+ {pool.resetBasis === "estimated" && <span class="muted"> (estimated)</span>}
455
472
  </td>
456
473
  <td class={`hide-sm num${estimate.tone ? ` tone-text-${estimate.tone}` : ""}`} title={estimate.title} data-label="Lasts">
457
474
  {estimate.text}