tuxevil-rotator 4.3.0 → 4.4.1
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/CHANGELOG.md +33 -0
- package/README.md +5 -2
- package/package.json +5 -1
- package/src/access-evidence.ts +153 -0
- package/src/access-probe.ts +85 -0
- package/src/admin-auth.ts +4 -1
- package/src/auto-access-shadow.ts +11 -0
- package/src/auto-model-access.ts +185 -0
- package/src/auto-output-health.ts +12 -0
- package/src/auto-routing-evaluation.ts +80 -0
- package/src/auto-routing-quality.ts +308 -0
- package/src/auto-routing.ts +403 -26
- package/src/compat.ts +223 -36
- package/src/compression/index.ts +6 -6
- package/src/compression/lite.ts +3 -9
- package/src/compression/rtk/index.ts +0 -3
- package/src/config-defaults.ts +7 -0
- package/src/dashboard.ts +5 -0
- package/src/db-store.ts +10 -0
- package/src/index.ts +2 -0
- package/src/model-access-api.ts +74 -0
- package/src/model-access.ts +56 -0
- package/src/ollama-output-gate.ts +18 -0
- package/src/onboarding.ts +1 -1
- package/src/provider-catalog-evidence.ts +26 -0
- package/src/providers/google-antigravity/dynamic-catalog.ts +8 -0
- package/src/providers/google-antigravity/quota.ts +3 -0
- package/src/providers/ollama/context-window.ts +13 -0
- package/src/providers/ollama/quota.ts +4 -0
- package/src/providers/ollama/translators.ts +19 -2
- package/src/providers/openai-codex/compat.ts +5 -1
- package/src/providers/openai-codex/credentials.ts +22 -6
- package/src/providers/openai-codex/index.ts +9 -1
- package/src/providers/openai-codex/quota.ts +19 -6
- package/src/providers/opencode-zen/forward.ts +1 -1
- package/src/providers/opencode-zen/quota.ts +2 -0
- package/src/proxy.ts +78 -3
- package/src/quota-observation.ts +26 -0
- package/src/quota-pools.ts +322 -0
- package/src/rotator.ts +151 -38
- package/src/settings-repository.ts +1 -0
- package/src/telemetry.ts +3 -1
- package/src/types.ts +28 -0
- package/src/usage-limits-auth.ts +24 -0
- package/src/usage-limits.ts +148 -0
- package/src/validators.ts +26 -0
- package/src/web/components/icons.tsx +15 -0
- package/src/web/components/overlays.tsx +4 -0
- package/src/web/components/ui.tsx +9 -9
- package/src/web/lib/playground.ts +35 -0
- package/src/web/lib/pool-navigation.ts +4 -0
- package/src/web/lib/pools.ts +2 -243
- package/src/web/pages/AccountDetail.tsx +2 -1
- package/src/web/pages/ModelAccess.tsx +88 -0
- package/src/web/pages/Models.tsx +2 -0
- package/src/web/pages/Overview.tsx +26 -9
- package/src/web/pages/Playground.tsx +1132 -551
- package/src/web/pages/Transcription.tsx +304 -170
- package/src/web/state/api.ts +3 -0
- package/src/web/styles/app.css +501 -45
|
@@ -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
|
+
}
|
package/src/web/pages/Models.tsx
CHANGED
|
@@ -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.
|
|
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.
|
|
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.
|
|
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={
|
|
407
|
-
<span class="num">{
|
|
417
|
+
<Meter value={capacity} label={`${pool.name}: ${capacityHint}`} />
|
|
418
|
+
<span class="num">{capacity === null ? "—" : `${capacity}%`}</span>
|
|
408
419
|
</div>
|
|
409
|
-
{pool.
|
|
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
|
-
{
|
|
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.
|
|
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}
|