Compare commits
52 Commits
fix/11291-
...
fix/docker
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
93dbd29906 | ||
|
|
0b7ac870ef | ||
|
|
9fedc1c411 | ||
|
|
e589831952 | ||
|
|
04d2a60331 | ||
|
|
d23bfefec0 | ||
|
|
c8ad44e018 | ||
|
|
c83116e634 | ||
|
|
7715825cb8 | ||
|
|
761d38f433 | ||
|
|
c6963ca5dd | ||
|
|
b010d8bf86 | ||
|
|
fdcd15e6a9 | ||
|
|
12b8df02dd | ||
|
|
38d21afc2d | ||
|
|
05e76d6e76 | ||
|
|
93135f8e18 | ||
|
|
22086a73fa | ||
|
|
d4ade9d1d3 | ||
|
|
f54c93c879 | ||
|
|
e2e48fdab8 | ||
|
|
d2cea0811a | ||
|
|
2f18a85310 | ||
|
|
38969ad16b | ||
|
|
dafb4ae808 | ||
|
|
338c05dc6a | ||
|
|
6945bbaaba | ||
|
|
690f684bfc | ||
|
|
c3cd1f94c0 | ||
|
|
c21460f22a | ||
|
|
9b14896a6c | ||
|
|
29f26293c3 | ||
|
|
cb11592441 | ||
|
|
5ee646e68e | ||
|
|
6984676d95 | ||
|
|
79f8ae9d1e | ||
|
|
04b2c47940 | ||
|
|
24ac71465e | ||
|
|
8d6f91b558 | ||
|
|
c3698eedcb | ||
|
|
adca3b881c | ||
|
|
ac02c5b42f | ||
|
|
07d1816a45 | ||
|
|
3192eb88d5 | ||
|
|
8969526437 | ||
|
|
5518916725 | ||
|
|
3daa455e1f | ||
|
|
d282ec7ad6 | ||
|
|
1e81e521c0 | ||
|
|
a3c3117254 | ||
|
|
d9a883ec53 | ||
|
|
7913447bf0 |
19
.env.example
@@ -1027,6 +1027,16 @@ PROVIDER_LIMITS_SYNC_SPACING_MS=1500
|
||||
# Used by: open-sse/services/compression/engines/rtk/filterLoader.ts. Default: 0.
|
||||
#OMNIROUTE_RTK_TRUST_PROJECT_FILTERS=0
|
||||
|
||||
# Maximum concurrent synchronous compression workers. Excess jobs wait FIFO.
|
||||
# Used by: open-sse/services/compression/compressionWorkerPool.ts. Default: 2.
|
||||
#OMNI_COMPRESSION_WORKERS=2
|
||||
# Per-job worker timeout (ms). A timed-out worker is terminated and the request fails open.
|
||||
# Used by: open-sse/services/compression/compressionWorkerPool.ts. Default: 120000.
|
||||
#OMNI_COMPRESSION_WORKER_TIMEOUT_MS=120000
|
||||
# Terminate idle compression workers after this many milliseconds.
|
||||
# Used by: open-sse/services/compression/compressionWorkerPool.ts. Default: 60000.
|
||||
#OMNI_COMPRESSION_WORKER_IDLE_MS=60000
|
||||
|
||||
# T02 stacked-pipeline engine circuit-breaker (OPT-IN, default off). When enabled, a compression
|
||||
# engine that throws repeatedly across requests is skipped (fail-open) for a cooldown.
|
||||
# Used by: open-sse/services/compression/pipelineEngineBreaker.ts.
|
||||
@@ -2011,6 +2021,9 @@ APP_LOG_TO_FILE=true
|
||||
# CLIPROXYAPI_HOST=127.0.0.1
|
||||
# CLIPROXYAPI_PORT=5544
|
||||
# CLIPROXYAPI_CONFIG_DIR=~/.cli-proxy-api
|
||||
# Management key for an externally managed instance. Embedded instances use
|
||||
# OmniRoute's encrypted service key.
|
||||
# CLIPROXYAPI_MANAGEMENT_KEY=
|
||||
|
||||
# ── Mux embedded service ──
|
||||
# Override the port where the embedded Mux (coder/mux) agent-orchestration
|
||||
@@ -2420,10 +2433,10 @@ APP_LOG_TO_FILE=true
|
||||
# test suite must NEVER mutate the OS trust store (a fake test PEM installed via
|
||||
# update-ca-certificates broke all system TLS on a persistent runner, 2026-07-05).
|
||||
# OMNIROUTE_SKIP_SYSTEM_TRUST=1
|
||||
# check-changelog-integrity.mjs (anti CHANGELOG-eat gate): explicit base ref
|
||||
# override, and the justified-removal escape hatch for intentional bullet removals.
|
||||
# check-changelog-integrity.mjs (anti CHANGELOG-eat gate): explicit base ref override.
|
||||
# Intentional transformations require an exact reviewed entry in
|
||||
# config/release/changelog-reconciliations.json; there is no runtime bypass.
|
||||
# CHANGELOG_BASE_REF=origin/release/v0.0.0
|
||||
# ALLOW_CHANGELOG_REMOVALS=1
|
||||
|
||||
# ── Remote audio provider nodes ──
|
||||
# Used by: src/app/api/v1/_shared/audioProviderNodes.ts — lets the /v1/audio/*
|
||||
|
||||
4
.github/workflows/opencode-plugin-ci.yml
vendored
@@ -2,11 +2,11 @@ name: opencode-plugin CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main, release/v3.8.2]
|
||||
branches: [main, "release/**"]
|
||||
paths:
|
||||
- "@omniroute/opencode-plugin/**"
|
||||
pull_request:
|
||||
branches: [main, release/v3.8.2]
|
||||
branches: [main, "release/**"]
|
||||
paths:
|
||||
- "@omniroute/opencode-plugin/**"
|
||||
types: [opened, synchronize, reopened, ready_for_review]
|
||||
|
||||
@@ -104,7 +104,10 @@ test("models: extracts apiKey from ctx.auth (type=api) and calls fetcher with it
|
||||
// #6859: dynamic-hook catalog keys use the unprefixed omnirouteProviderId
|
||||
// ("omniroute"), not the OC-gate-prefixed hook.id ("opencode-omniroute") —
|
||||
// that prefix must never leak into anything OmniRoute's server parses.
|
||||
assert.ok(out["omniroute/claude-primary"]);
|
||||
// #10345/#10821: bare combo ids (owned_by: "combo") stay unprefixed —
|
||||
// OpenCode looks up `-m <plugin>/<combo>` as model id `<combo>` under the
|
||||
// plugin provider, so `claude-primary` here carries no provider prefix.
|
||||
assert.ok(out["claude-primary"]);
|
||||
});
|
||||
|
||||
test("models: returns {} when ctx.auth is null/undefined/wrong-type/empty-key", async () => {
|
||||
@@ -159,11 +162,15 @@ test("models: maps a sample /v1/models entry to ModelV2 (sanity)", async () => {
|
||||
// omnirouteProviderId ("omniroute") — the OC-gate prefix ("opencode-")
|
||||
// must stay OC-internal (hook.id / AuthHook.provider) and never leak into
|
||||
// anything OmniRoute's own server parses for credential lookup.
|
||||
const claude = out["omniroute/claude-primary"];
|
||||
// #10345/#10821: bare **combo** ids (owned_by: "combo", e.g.
|
||||
// "claude-primary") must also stay unprefixed — OpenCode looks up
|
||||
// `-m <plugin>/<combo>` as model id `<combo>` under the plugin provider.
|
||||
const claude = out["claude-primary"];
|
||||
assert.ok(claude, "claude-primary present");
|
||||
// `mapRawModelToModelV2` stamps the provider prefix on the id so OC's
|
||||
// static-catalog reader resolves `(providerID, modelID)` from the key.
|
||||
assert.equal(claude.id, "omniroute/claude-primary");
|
||||
// `mapRawModelToModelV2` leaves bare combo ids unprefixed (see
|
||||
// src/index.ts mapRawModelToModelV2) so OC's `-m <plugin>/<combo>` lookup
|
||||
// resolves the combo id directly.
|
||||
assert.equal(claude.id, "claude-primary");
|
||||
assert.equal(claude.name, "claude-primary");
|
||||
assert.equal(claude.providerID, "omniroute");
|
||||
assert.equal(claude.api.id, "openai-compatible");
|
||||
|
||||
21
Dockerfile
@@ -181,10 +181,23 @@ ENV NODE_OPTIONS="--max-old-space-size=${OMNIROUTE_BUILD_MEMORY_MB}"
|
||||
# workers for page-data collection (31 on a 32-core builder); on memory-tight
|
||||
# hosts 31 workers + webpack's multi-GB heap blow past RAM and a worker dies
|
||||
# with SIGSEGV at teardown ("worker exited with code: null and signal: SIGSEGV"),
|
||||
# silently leaving no standalone bundle. Next derives the default worker count
|
||||
# from CIRCLE_NODE_TOTAL (workers = N-1), so N=8 → 7 workers: fast enough while
|
||||
# fitting comfortably in RAM on any host. (#10060)
|
||||
ENV CIRCLE_NODE_TOTAL=8
|
||||
# silently leaving no standalone bundle. Next derives the worker count from
|
||||
# CIRCLE_NODE_TOTAL (workers = N-1). (#10060)
|
||||
#
|
||||
# Lowered 8 → 3 (7 workers → 2). Every page-data worker inherits NODE_OPTIONS
|
||||
# above, so the ceiling is per PROCESS, not per build: 7 workers on a 16 GB
|
||||
# GitHub runner (ubuntu-24.04 / ubuntu-24.04-arm, 4 vCPU) exhausted the host and
|
||||
# buildkit failed the whole step with `ResourceExhausted: ... cannot allocate
|
||||
# memory`. The compile phase always finished ("✓ Compiled successfully in
|
||||
# 4.2min"); the kernel killed the build right after "Collecting page data using
|
||||
# 7 workers". It was intermittent for a while and went 100% on 2026-08-22, which
|
||||
# is what a threshold being crossed by ordinary codebase growth looks like.
|
||||
# tests/unit/docker-build-memory-budget.test.ts does the arithmetic and fails if
|
||||
# either knob is raised past what a 16 GB runner holds. 2 workers also stops
|
||||
# oversubscribing the runner's 4 vCPU, which 7 did. Override for a big builder:
|
||||
# `--build-arg OMNIROUTE_BUILD_WORKERS=8`.
|
||||
ARG OMNIROUTE_BUILD_WORKERS=3
|
||||
ENV CIRCLE_NODE_TOTAL=${OMNIROUTE_BUILD_WORKERS}
|
||||
|
||||
COPY . ./
|
||||
RUN --mount=type=cache,id=s/92ca8a61-c1ba-421f-a389-d48ac7258c2d-next-cache,target=/app/.build/next/cache \
|
||||
|
||||
407
README.md
@@ -17,9 +17,9 @@
|
||||
|
||||
</div>
|
||||
|
||||
> Stacking free tiers by hand is painful — dozens of SDKs, dozens of rate limits, and no idea how much you actually have. OmniRoute aggregates the **documented** free tiers of **42 provider pools / 495 models** into one honest number and shows it live on the dashboard (`/dashboard/free-tiers`).
|
||||
> Stacking free tiers by hand is painful — dozens of SDKs, dozens of rate limits, and no idea how much you actually have. OmniRoute catalogs **455 free-tier entries across 40 recurring pool keys** and computes the token headline from the **20 pools with a published positive monthly budget**, deduplicated by shared pool. The result stays visible on the dashboard (`/dashboard/free-tiers`).
|
||||
|
||||
<img src="./docs/diagrams/free-tier-budget.svg" width="100%" alt="OmniRoute free-tier budget card: ~1.51B free tokens per month steady, up to ~2.13B in the first month with signup credits, from the documented free tiers of 42 provider pools / 495 models behind one endpoint. Honest pool-deduped math — each shared pool counted once (counting every rate limit 24/7 would read ~10B; not published), 15 providers ToS-flagged so you decide. Budget bar of the countable free pools with per-model grid (Mistral Large 3 1B, GPT-4o mini 150M, Gemini 2.5 Flash 60M … Claude Sonnet 4.5 25K), one-time first-month signup credits (vertex 300M, agentrouter 200M, predibase 25M, together 25M, glm-cn 20M, doubao 15M, ai21 10M, longcat 10M, deepseek 5M, hyperbolic 5M, nscale 5M), plus permanently-free no-token-cap providers (SiliconFlow, Z.AI GLM-Flash, Kilo, OpenCode Zen, baidu …) and a $10 OpenRouter top-up unlocking +24M/mo — surfaced separately so they never inflate the headline. Live used/remaining on /dashboard/free-tiers."/>
|
||||
<img src="./docs/diagrams/free-tier-budget.svg" width="100%" alt="OmniRoute free-tier budget card: ~1.51B free tokens per month steady, up to ~2.13B in the first month with signup credits, from 40 documented recurring pool keys covering 455 cataloged free-tier entries behind one endpoint. Honest pool-deduped math — each shared pool counted once, including 20 recurring pools with a published positive monthly token budget; 15 providers are marked avoid in the terms-risk catalog so you decide. Budget bar includes Mistral 1B, LLM7 150M, Nara 150M, Gemini 60M and smaller pools, plus first-month signup credits and permanently-free no-token-cap providers surfaced separately so they never inflate the headline. Live used/remaining on /dashboard/free-tiers."/>
|
||||
|
||||
> Animated summary of the live `/dashboard/free-tiers` page. Full methodology (pool dedupe, credit tiers, provider terms): **[docs/reference/FREE_TIERS.md](docs/reference/FREE_TIERS.md)**.
|
||||
>
|
||||
@@ -61,14 +61,14 @@
|
||||
|
||||
<div align="center">
|
||||
|
||||
| | v3.8.49 | **v3.8.50** | `v3.8.51+` |
|
||||
| ------------------------- | :-----: | :---------: | :---------: |
|
||||
| 🌐 Providers | 290 | **342** | more queued |
|
||||
| 🧠 Documented models | 1185 | **1202** | — |
|
||||
| 🖼️ Modality Bridge | — | 🆕 vision | video |
|
||||
| 📡 Radar free catalog | — | 🆕 opt-in | — |
|
||||
| ⚖️ Quota-aware scheduling | — | — | 🔭 next |
|
||||
| 📊 Quota telemetry | — | — | 🔭 next |
|
||||
| | v3.8.49 | **v3.8.50** | `v3.8.51+` |
|
||||
| ------------------------- | :-----: | :-----------------------: | :---------: |
|
||||
| 🌐 Providers | 290 | **350** | more queued |
|
||||
| 🧠 Unique chat model IDs | 1185 | **1312** | — |
|
||||
| 🖼️ Modality Bridge | — | 🆕 vision + audio + video | — |
|
||||
| 📡 Radar free catalog | — | 🆕 opt-in | — |
|
||||
| ⚖️ Quota-aware scheduling | — | 🆕 Quota-Share | — |
|
||||
| 📊 Quota telemetry | — | 🆕 live | — |
|
||||
|
||||
**→ [Roadmap](ROADMAP.md) — riding the rail to `v3.9.0 LTS`**
|
||||
|
||||
@@ -101,7 +101,7 @@
|
||||
<tr>
|
||||
<td align="right"><b>⚙️ Features</b></td>
|
||||
<td align="center"><a href="#-combos--the-flagship">🎯 Combos</a></td>
|
||||
<td align="center"><a href="#-349-ai-providers--90-free">🌐 Providers</a></td>
|
||||
<td align="center"><a href="#-350-ai-providers--154-catalog-marked-free">🌐 Providers</a></td>
|
||||
<td align="center"><a href="#-full-cli--a2a--mcp">🔌 CLI & MCP</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
@@ -126,7 +126,7 @@
|
||||
<td align="right"><b>📦 Project</b></td>
|
||||
<td align="center"><a href="#%EF%B8%8F-tech-stack">🛠️ Tech Stack</a></td>
|
||||
<td align="center"><a href="#-documentation">📖 Docs</a></td>
|
||||
<td align="center"><a href="#-500-contributors">👥 Contributors</a></td>
|
||||
<td align="center"><a href="#-600-contributors">👥 Contributors</a></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
@@ -210,7 +210,7 @@ curl http://localhost:20128/v1/chat/completions \
|
||||
|
||||
</div>
|
||||
|
||||
<img src="./docs/diagrams/promise-pillars.svg" width="100%" alt="The Promise — One endpoint. 350 providers. Never stop building — OmniRoute picks the cheapest one that works. Six pillars: Never hit limits (auto-fallback across 350 providers in milliseconds, zero downtime) · Save up to 95% tokens (RTK + Caveman stacked compression cuts 15–95%, ~89% avg on tool-heavy sessions) · $0 to start (90+ free tiers, 56 free forever — no card needed) · Every tool works (33 coding agents through one config) · One endpoint (OpenAI ↔ Claude ↔ Gemini ↔ Responses API at /v1) · Production-grade (circuit breakers, TLS stealth, MCP 110 tools, A2A, memory, guardrails, evals — 25,000+ tests)."/>
|
||||
<img src="./docs/diagrams/promise-pillars.svg" width="100%" alt="The Promise — One endpoint and 350 providers. Automatic fallback keeps routing while another healthy target is available. Six pillars: resilient fallback across 350 providers · up to 95% token savings on eligible workloads · $0 to start with 90+ free tiers and 56 recurring/keyless free-forever providers · 35 CLI/agent integrations through one config · OpenAI, Claude, Gemini and Responses API compatibility at /v1 · production controls including circuit breakers, TLS stealth, MCP 110 tools, A2A, memory, guardrails, evals and 39,000+ static test declarations across 5,100+ tracked test files."/>
|
||||
|
||||
<br/>
|
||||
<br/>
|
||||
@@ -225,7 +225,7 @@ curl http://localhost:20128/v1/chat/completions \
|
||||
|
||||
<div align="center">
|
||||
|
||||
<img src="./docs/diagrams/tier-cascade.svg" width="100%" alt="OmniRoute request flow: your IDE or CLI (Claude Code, Cursor, Cline…) calls one local endpoint (http://localhost:20128/v1); the OmniRoute Smart Router (RTK + Caveman compression, 19 routing strategies, circuit breakers, TLS stealth, MCP, A2A, guardrails) auto-falls back across 4 provider tiers — Tier 1 Subscription (Claude Code, Codex, Copilot), quota out? Tier 2 API Key (DeepSeek, Groq, xAI), budget hit? Tier 3 Cheap (GLM $0.5, MiniMax $0.2), budget hit? Tier 4 Free (Kiro, Qoder, Pollinations) — always on."/>
|
||||
<img src="./docs/diagrams/tier-cascade.svg" width="100%" alt="OmniRoute request flow: your IDE or CLI (Claude Code, Cursor, Cline…) calls one local endpoint (http://localhost:20128/v1); the OmniRoute Smart Router (RTK + Caveman compression, 19 routing strategies, circuit breakers, TLS stealth, MCP, A2A, guardrails) can fall back across 4 provider tiers while an eligible healthy target remains — Tier 1 Subscription, Tier 2 API Key, Tier 3 Cheap and Tier 4 Free."/>
|
||||
|
||||
</div>
|
||||
|
||||
@@ -318,7 +318,7 @@ curl http://localhost:20128/v1/chat/completions \
|
||||
|
||||
<img src="./docs/diagrams/strategies-grid.svg" width="100%" alt="All 19 combo routing strategies animated — one tile per strategy: priority, fill-first, weighted, round-robin, p2c, least-used, random, strict-random, cost-optimized, headroom, reset-window, reset-aware, context-relay, context-optimized, cache-optimized, lkgp, auto, fusion, pipeline. See the table above for what each one does."/>
|
||||
|
||||
> A **combo** is a chain of models OmniRoute routes across **automatically**. Quota runs out, a provider fails, or costs spike — the combo silently slides to the next model. **This is what makes OmniRoute unbreakable.** 🛡️
|
||||
> A **combo** is a chain of models OmniRoute routes across **automatically**. If quota runs out, a provider fails, or costs spike, the combo can move to the next eligible healthy model. 🛡️
|
||||
|
||||
### ⚡ Zero-config — just use `auto`
|
||||
|
||||
@@ -429,7 +429,7 @@ All **19** strategies — mix & match per combo step:
|
||||
<tr>
|
||||
<td align="center">17</td>
|
||||
<td nowrap><code>auto</code></td>
|
||||
<td>14-factor live scoring across every connection 🤖</td>
|
||||
<td>15-factor live scoring across every connection 🤖</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center">18</td>
|
||||
@@ -443,7 +443,7 @@ All **19** strategies — mix & match per combo step:
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<sub>The Auto-Combo engine scores every candidate on **14 factors** (health, quota, cost, latency, success rate, freshness…) — see [`docs/routing/AUTO-COMBO.md`](docs/routing/AUTO-COMBO.md).</sub>
|
||||
<sub>The Auto-Combo engine scores every candidate on **15 factors** (health, quota, cost, latency, task fit, quality, session availability…) — see [`docs/routing/AUTO-COMBO.md`](docs/routing/AUTO-COMBO.md).</sub>
|
||||
|
||||
##
|
||||
|
||||
@@ -461,7 +461,7 @@ All **19** strategies — mix & match per combo step:
|
||||
|
||||
</div>
|
||||
|
||||
<img src="./docs/diagrams/comparison-table.svg" width="100%" alt="What sets OmniRoute apart — comparison table vs 9router, OpenRouter, CLIProxyAPI and LiteLLM across 13 capabilities. OmniRoute: 350 providers, 90+ free providers built-in, 19 routing strategies, 12-engine token compression, built-in MCP server with 110 tools, A2A agent protocol, persistent memory, guardrails, cloud agents, TLS fingerprint stealth, Desktop/Termux/PWA, 43 i18n UI locales, 100% MIT self-hosted. OmniRoute is the only one with the full set; competitors show a mix of checks, partials and crosses. Verified from each project's docs."/>
|
||||
<img src="./docs/diagrams/comparison-table.svg" width="100%" alt="What sets OmniRoute apart — a dated feature snapshot vs 9router, OpenRouter, CLIProxyAPI and LiteLLM across 13 capabilities. OmniRoute: 350 providers, 90+ free tiers built in, 19 routing strategies, 12-engine token compression, built-in MCP server with 110 tools, A2A agent protocol, persistent memory, guardrails, cloud agents, TLS fingerprint stealth, Desktop/Termux/PWA and 43 i18n UI locales. OmniRoute is MIT-licensed and self-hostable. Competitor capabilities and counts may change; see the linked methodology."/>
|
||||
|
||||
<sub>📊 Full methodology & per-feature detail vs 9router, OpenRouter, CLIProxyAPI & LiteLLM → [`docs/comparison/OMNIROUTE_VS_ALTERNATIVES.md`](docs/comparison/OMNIROUTE_VS_ALTERNATIVES.md)</sub>
|
||||
|
||||
@@ -517,9 +517,9 @@ Pix copia-e-cola:
|
||||
|
||||
## 📡 OmniRoute Radar
|
||||
|
||||
The main free-tier headline remains **~1.53B tokens/month** from the documented,
|
||||
The main free-tier headline remains **~1.51B tokens/month** from the documented,
|
||||
pool-deduplicated catalog above. Temporary provider signup credits can separately lift the first
|
||||
month to **~2.15B**. Radar is an optional, signed catalog overlay for people who want fresher
|
||||
month to **~2.13B**. Radar is an optional, signed catalog overlay for people who want fresher
|
||||
free-model availability between OmniRoute releases; the community catalog and every existing free
|
||||
feature remain free.
|
||||
|
||||
@@ -548,7 +548,7 @@ the current catalog at **[radar.omniroute.online/planos](https://radar.omniroute
|
||||
- **🗜️ Compression hardening** — default-on inflation guard, Caveman packs for DE / FR / JA + Chinese (wényán), RTK filters for Gradle & .NET. → [Compression](docs/compression/COMPRESSION_ENGINES.md)
|
||||
- **💸 Honest flat-rate cost** — subscription / coding-plan providers read **$0** in cost analytics; budget, quota & routing keep estimating. → [API Reference](docs/reference/API_REFERENCE.md)
|
||||
- **⚖️ Quota-Share routing** — split a shared account's quota fairly across pooled keys, work-conserving so idle slices are lent out. → [Resilience Guide](docs/architecture/RESILIENCE_GUIDE.md)
|
||||
- **🤖 One-command CLI/agent setup** — `setup-*` configures 12+ coding tools; `omniroute run` launches 7 CLIs (Claude Code, Codex, Aider, Goose, OpenCode, Qwen Code, Gemini CLI) with zero config written; `omniroute configure` is an interactive provider+model picker with per-context favorites. → [CLI Integrations](docs/guides/CLI-INTEGRATIONS.md)
|
||||
- **🤖 One-command CLI/agent setup** — 12 registered `setup-*` commands; `omniroute run` launches 7 CLIs (Claude Code, Codex, Aider, Goose, OpenCode, Qwen Code, Gemini CLI); `omniroute configure` supports 9 targets with an interactive provider+model picker and per-context favorites. → [CLI Integrations](docs/guides/CLI-INTEGRATIONS.md)
|
||||
- **🛰️ Remote mode** — drive a remote OmniRoute with scoped tokens (`connect` / `contexts` / `tokens`) + an `antigravity` OAuth helper for VPS installs. → [Remote Mode](docs/guides/REMOTE-MODE.md)
|
||||
- **🧭 Smarter auto-routing** — `auto/<category>:<tier>` combos, **Fusion** (model panel + judge), task-aware routing, per-request model / mode / USD-budget overrides. → [Auto-Combo](docs/routing/AUTO-COMBO.md)
|
||||
- **🗜️ Pluggable compression** — 12 composable engines + Compression Studios: LLMLingua-2, two-tier Ultra, omniglyph, per-step fidelity gate, GCF v3.2, drag-reorder editor. → [Compression](docs/compression/COMPRESSION_ENGINES.md)
|
||||
@@ -642,11 +642,11 @@ of your shell history. → [CLI Integrations](docs/guides/CLI-INTEGRATIONS.md)
|
||||
|
||||
<div align="center">
|
||||
|
||||
## 🌐 349 AI Providers — 90+ Free
|
||||
## 🌐 350 AI Providers — 154 Catalog-Marked Free
|
||||
|
||||
</div>
|
||||
|
||||
> The most complete catalog of any open-source router: **350 providers**, **90+ with a free tier**, **56 free forever**.
|
||||
> **350 registered providers** across the canonical chat, media, search, local, cloud-agent and system collections, including **154 carrying `hasFree: true` discovery metadata**. The chat model registry covers **268 providers / 2,566 distinct provider-model pairs / 1,312 raw model IDs**; the separate free-budget catalog has **455 per-model rows**, **40 recurring pools** and **56 recurring/keyless free-forever providers**. These are different denominators by design; definitions and pool-deduped calculations live in the [Provider Reference](docs/reference/PROVIDER_REFERENCE.md) and [Free Tiers](docs/reference/FREE_TIERS.md).
|
||||
|
||||
<div align="center">
|
||||
|
||||
@@ -679,7 +679,7 @@ of your shell history. → [CLI Integrations](docs/guides/CLI-INTEGRATIONS.md)
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<sub>…and 220+ more — every icon resolves live from the dashboard's provider catalog. 📖 [Provider Reference](docs/reference/PROVIDER_REFERENCE.md)</sub>
|
||||
<sub>…and 330+ more — every icon resolves live from the dashboard's provider catalog. 📖 [Provider Reference](docs/reference/PROVIDER_REFERENCE.md)</sub>
|
||||
|
||||
<br/>
|
||||
|
||||
@@ -769,7 +769,7 @@ From inside the editor: open the **Extensions** view, search **"OmniRoute"**, cl
|
||||
|
||||
</div>
|
||||
|
||||
<img src="./docs/diagrams/privacy-local.svg" width="100%" alt="Private and local-first — your keys, your machine, your data; OmniRoute is a local proxy that never phones home. Eleven guarantees: runs 100% on your hardware (0 cloud hops), zero telemetry by default, credentials encrypted at rest (AES-256-GCM), no account or sign-up, hardened gateway (API-key scoping, IP filtering, rate limits, prompt-injection guard), loopback-only process routes, upstream header scrubbing, strictly opt-in PII redaction, sanitized errors that never leak internals, a local audit trail in your own SQLite, and MIT-licensed fully open-source code."/>
|
||||
<img src="./docs/diagrams/privacy-local.svg" width="100%" alt="Private and local-first — OmniRoute's gateway and control plane run on your machine. Prompts are sent to the upstream provider selected for each request; OmniRoute adds no hosted prompt-processing hop and telemetry is disabled by default. Credentials are encrypted at rest with AES-256-GCM; controls include API-key scoping, IP filtering, rate limits, prompt-injection guards, upstream-header scrubbing, opt-in PII redaction, sanitized errors and a local SQLite audit trail. OmniRoute is MIT-licensed and self-hostable."/>
|
||||
|
||||
<sub>📖 [Authorization](docs/architecture/AUTHZ_GUIDE.md) · [Guardrails](docs/security/GUARDRAILS.md) · [Compliance](docs/security/COMPLIANCE.md)</sub>
|
||||
|
||||
@@ -810,7 +810,7 @@ Tokens are scoped `read` / `write` / `admin`; process-spawning routes stay loopb
|
||||
|
||||
<div align="left">
|
||||
|
||||
<img src="./docs/diagrams/cli-terminal.svg" width="50%" alt="Animated terminal demoing the OmniRoute CLI — omniroute providers list, omniroute combo list, omniroute health — cycling over the 80+ command surface: providers · oauth · keys · combo · nodes · models · cache · compression · cost · usage · quota · health · resilience · telemetry · logs · audit · mcp · a2a · cloud · memory · skills · eval · tunnel · backup · sync · webhooks · policy · pricing · translator · simulate …"/>
|
||||
<img src="./docs/diagrams/cli-terminal.svg" width="50%" alt="Animated terminal demoing the OmniRoute CLI — omniroute providers list, omniroute combo list and omniroute health — cycling over the 85-command top-level surface: providers · oauth · keys · combo · nodes · models · cache · compression · cost · usage · quota · health · resilience · telemetry · logs · audit · mcp · a2a · cloud · memory · skills · eval · tunnel · backup · sync · webhooks · policy · pricing · translator · simulate …"/>
|
||||
|
||||
</div>
|
||||
|
||||
@@ -846,7 +846,7 @@ claude mcp add-server omniroute --type http --url http://localhost:20128/api/mcp
|
||||
|
||||
### 📖 How it works — pipeline, architecture & savings math
|
||||
|
||||
<img src="./docs/diagrams/compression-pipeline.svg" width="100%" alt="OmniRoute compression pipeline: a client request of 10,000 tokens passes through 12 stacked engines — Session-Dedup, CCR, Lite, RTK, Responses Tool Output, Headroom, Relevance, Caveman, Aggressive, LLMLingua-2, Ultra, OmniGlyph — and reaches the provider at about 1,080 tokens, up to 95% saved. Code, URLs and JSON are always preserved byte-perfect."/>
|
||||
<img src="./docs/diagrams/compression-pipeline.svg" width="100%" alt="OmniRoute compression pipeline: an illustrative 10,000-token client request passes through 12 composable engines — Session-Dedup, CCR, Lite, RTK, Responses Tool Output, Headroom, Relevance, Caveman, Aggressive, LLMLingua-2, Ultra and OmniGlyph — and can reach the provider at about 1,080 tokens in the documented stacked example. Structured content is protected by preservation guards and per-step fidelity gates; explicit lossy or experimental modes may transform eligible content."/>
|
||||
|
||||
Default stacked combo runs `RTK → Caveman`. When both act on the same tool/context payload, savings compound:
|
||||
|
||||
@@ -1013,6 +1013,7 @@ Full table: [Docker Guide — runtime RAM](docs/guides/DOCKER_GUIDE.md#runtime-r
|
||||
**🥟 Bun**
|
||||
|
||||
Standard `bun install` and global installation (`bun install -g omniroute`) are supported via Bun runtime detection:
|
||||
|
||||
- **Built-in `bun:sqlite`**: OmniRoute uses Bun's built-in `bun:sqlite` driver when running under Bun, falling back to `better-sqlite3` on Node.js or `sql.js`.
|
||||
- **Automatic Webpack bundler selection**: Development (`bun run dev`) and production builds (`bun run build`) automatically detect Bun and disable Turbopack in favor of Webpack to prevent native V8 binding incompatibilities.
|
||||
- **Dedicated Bun Dockerfile**: Multi-stage `Dockerfile.bun` for native Bun production deployments (`docker build -f Dockerfile.bun -t omniroute:bun .`).
|
||||
@@ -1105,7 +1106,7 @@ same process on one port, so there is no separate CLI-only package today.
|
||||
|
||||
<div align="center">
|
||||
|
||||
<sub>Dados de cobertura social em 2026-08-17 · YT: 741 | TT: 137 | IG: 124 · Frescor (dias): YT 0 · TT 14 · IG 15</sub>
|
||||
<sub>Snapshot do painel em 2026-08-24 · Catálogo bruto: YT 809 | TT 137 | IG 124 · Frescor (dias): YT 1 | TT 21 | IG 22</sub>
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
@@ -1114,52 +1115,52 @@ same process on one port, so there is no separate CLI-only package today.
|
||||
<img src="https://placehold.co/320x180/111827/FFFFFF?text=Instagram+Reel+%7C+nick_saraev&font=montserrat&bold=true" alt="Instagram Reel" width="300"/>
|
||||
</a><br/>
|
||||
<b>🎬 #1 — Instagram</b><br/>
|
||||
<sub>nick_saraev — 1,628,910 views</sub>
|
||||
<sub>nick_saraev — 3,042,474 views</sub>
|
||||
</td>
|
||||
<td align="center" width="320">
|
||||
<a href="https://www.instagram.com/reel/DaSs65mMrHk/">
|
||||
<img src="https://placehold.co/320x180/111827/FFFFFF?text=Instagram+Reel+%7C+theopenstack&font=montserrat&bold=true" alt="Instagram Reel — theopenstack" width="300"/>
|
||||
</a><br/>
|
||||
<b>🎬 #2 — Instagram</b><br/>
|
||||
<sub>theopenstack — 692,419 views</sub>
|
||||
</td>
|
||||
<td align="center" width="320">
|
||||
<a href="https://www.tiktok.com/@milesreevesai/video/7667980059189366019">
|
||||
<img src="https://placehold.co/320x180/111827/FFFFFF?text=TikTok+%7C+milesreevesai&font=montserrat&bold=true" alt="TikTok — milesreevesai" width="300"/>
|
||||
</a><br/>
|
||||
<b>🎬 #3 — TikTok</b><br/>
|
||||
<sub>milesreevesai — 620,400 views</sub>
|
||||
</td>
|
||||
<td align="center" width="320">
|
||||
<a href="https://www.youtube.com/watch?v=QucgvbO5gsM">
|
||||
<img src="https://img.youtube.com/vi/QucgvbO5gsM/maxresdefault.jpg" alt="YouTube — Vaibhav Sisinty" width="300"/>
|
||||
</a><br/>
|
||||
<b>🎬 #2 — YouTube</b><br/>
|
||||
<sub>Vaibhav Sisinty — 373,084 views</sub>
|
||||
<b>🎬 #4 — YouTube</b><br/>
|
||||
<sub>Vaibhav Sisinty — 391,109 views</sub>
|
||||
</td>
|
||||
<td align="center" width="320">
|
||||
<a href="https://www.youtube.com/shorts/fZIBK_4fKq8">
|
||||
<img src="https://img.youtube.com/vi/fZIBK_4fKq8/maxresdefault.jpg" alt="YouTube Shorts" width="300"/>
|
||||
<a href="https://www.instagram.com/reel/DbIt9AjK7-U/">
|
||||
<img src="https://placehold.co/320x180/111827/FFFFFF?text=Instagram+Reel+%7C+buildwithai.club&font=montserrat&bold=true" alt="Instagram Reel — buildwithai.club" width="300"/>
|
||||
</a><br/>
|
||||
<b>🎬 #3 — YouTube Shorts</b><br/>
|
||||
<sub>Nick Automates — 207,714 views</sub>
|
||||
</td>
|
||||
<td align="center" width="320">
|
||||
<a href="https://www.tiktok.com/@milesreevesai/video/7667980059189366019">
|
||||
<img src="https://placehold.co/320x180/111827/FFFFFF?text=TikTok+Top+1&font=montserrat&bold=true" alt="TikTok Thumbnail" width="300"/>
|
||||
</a><br/>
|
||||
<b>🎬 #4 — TikTok</b><br/>
|
||||
<sub>milesreevesai — 620,400 views</sub>
|
||||
</td>
|
||||
<td align="center" width="320">
|
||||
<a href="https://www.youtube.com/watch?v=LkP6ocAoQkk">
|
||||
<img src="https://img.youtube.com/vi/LkP6ocAoQkk/maxresdefault.jpg" alt="Valency Labs" width="300"/>
|
||||
</a><br/>
|
||||
<b>🎬 #5 — YouTube</b><br/>
|
||||
<sub>Valency Labs — 135,974 views</sub>
|
||||
<b>🎬 #5 — Instagram</b><br/>
|
||||
<sub>buildwithai.club — 347,652 views</sub>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
|
||||
**Ranking completo (`v > 0`, maior alcance):**
|
||||
**Ranking completo (URLs canônicas deduplicadas, `v > 0`, maior alcance):**
|
||||
|
||||
| #1 | #2 | #3 | #4 | #5 |
|
||||
| -------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------- |
|
||||
| [nick_saraev — Instagram](https://www.instagram.com/reel/Da8ZthUPK98/) — **1,628,910** | [milesreevesai — TikTok](https://www.tiktok.com/@milesreevesai/video/7667980059189366019) — **620,400** | [Vaibhav Sisinty — YouTube](https://www.youtube.com/watch?v=QucgvbO5gsM) — **373,084** | [Nick Automates — YouTube Shorts](https://www.youtube.com/shorts/fZIBK_4fKq8) — **207,714** | [midudev — TikTok](https://www.tiktok.com/@midudev/video/7664636453544152342) — **177,800** |
|
||||
| #1 | #2 | #3 | #4 | #5 |
|
||||
| -------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- |
|
||||
| [nick_saraev — Instagram](https://www.instagram.com/reel/Da8ZthUPK98/) — **3,042,474** | [theopenstack — Instagram](https://www.instagram.com/reel/DaSs65mMrHk/) — **692,419** | [milesreevesai — TikTok](https://www.tiktok.com/@milesreevesai/video/7667980059189366019) — **620,400** | [Vaibhav Sisinty — YouTube](https://www.youtube.com/watch?v=QucgvbO5gsM) — **391,109** | [buildwithai.club — Instagram](https://www.instagram.com/reel/DbIt9AjK7-U/) — **347,652** |
|
||||
|
||||
| #6 | #7 | #8 | #9 | #10 |
|
||||
| ------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------- | ---------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- |
|
||||
| [theopenstack — Instagram](https://www.instagram.com/reel/DaSs65mMrHk/) — **155,453** | [t.ghoush.ai — TikTok](https://www.tiktok.com/@t.ghoush.ai/video/7669497680527248656) — **152,800** | [Valency Labs — YouTube](https://www.youtube.com/watch?v=LkP6ocAoQkk) — **135,974** | [Asati — YouTube](https://www.youtube.com/watch?v=JjPtJcqwhqg) — **126,130** | [Vaibhav Sisinty — YouTube](https://www.youtube.com/watch?v=NuNDpeZYQ28) — **122,672** |
|
||||
| #6 | #7 | #8 | #9 | #10 |
|
||||
| ----------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------- |
|
||||
| [nivedan.ai — Instagram](https://www.instagram.com/reel/DbIrCksJiqq/) — **331,973** | [vaibhavsisinty — Instagram](https://www.instagram.com/reel/Dae05TSAK1l/) — **263,744** | [Nick Automates — YouTube Shorts](https://www.youtube.com/shorts/fZIBK_4fKq8) — **218,174** | [theroshankrishna — Instagram](https://www.instagram.com/reel/Dapjs58z0P0/) — **186,786** | [midudev — TikTok](https://www.tiktok.com/@midudev/video/7664636453544152342) — **177,800** |
|
||||
|
||||
Métricas de validação: 1002 vídeos rastreados · 7,069,190 visualizações conhecidas · 595 perfis/canais · 13+ idiomas · 13+ criadores.
|
||||
Métricas canônicas em 2026-08-24: **1.029 vídeos únicos** · **11.132.922 visualizações conhecidas** (`v > 0`) · **639 canais/perfis por rede**. O painel bruto contém 1.070 linhas; 41 duplicatas do Instagram foram normalizadas pela URL canônica, mantendo a maior contagem por vídeo.
|
||||
|
||||
> 🎬 **Made a video about OmniRoute?** Open an [issue](https://github.com/diegosouzapw/OmniRoute/issues/new) or [discussion](https://github.com/diegosouzapw/OmniRoute/discussions) with the link — we'll feature it here.
|
||||
|
||||
@@ -1211,7 +1212,7 @@ Métricas de validação: 1002 vídeos rastreados · 7,069,190 visualizações c
|
||||
<tr><td nowrap><b>Stealth</b></td><td>wreq-js — JA3 / JA4 TLS fingerprint impersonation, 3-level proxy</td></tr>
|
||||
<tr><td nowrap><b>Resilience</b></td><td>Circuit breaker, exponential backoff, anti-thundering-herd, auto-combo self-healing</td></tr>
|
||||
<tr><td nowrap><b>Logging</b></td><td>pino — structured JSON logs with request context</td></tr>
|
||||
<tr><td nowrap><b>Testing</b></td><td>Node.js test runner + Vitest — <b>25,000+ test cases</b> across 3,300+ files (unit, integration, E2E, security, ecosystem)</td></tr>
|
||||
<tr><td nowrap><b>Testing</b></td><td>Node.js test runner + Vitest — <b>39,000+ static test declarations</b> across 5,100+ tracked test files (unit, integration, E2E, security, ecosystem)</td></tr>
|
||||
<tr><td nowrap><b>Platforms</b></td><td>Desktop (Electron) · Android (Termux) · PWA (any browser)</td></tr>
|
||||
<tr><td nowrap><b>CI/CD</b></td><td>GitHub Actions — auto npm publish + Docker Hub on release</td></tr>
|
||||
<tr><td nowrap><b>Links</b></td><td><a href="https://omniroute.online">Website</a> · <a href="https://www.npmjs.com/package/omniroute">npm</a> · <a href="https://hub.docker.com/r/diegosouzapw/omniroute">Docker Hub</a></td></tr>
|
||||
@@ -1262,9 +1263,9 @@ Métricas de validação: 1002 vídeos rastreados · 7,069,190 visualizações c
|
||||
<tr><td nowrap><b><a href="docs/compression/COMPRESSION_RULES_FORMAT.md">Compression Rules Format</a></b></td><td>JSON rule-pack schemas for Caveman and RTK filters</td></tr>
|
||||
<tr><td nowrap><b><a href="docs/compression/COMPRESSION_LANGUAGE_PACKS.md">Compression Language Packs</a></b></td><td>Language detection and Caveman rule-pack authoring</td></tr>
|
||||
<tr><td nowrap><b><a href="docs/architecture/RESILIENCE_GUIDE.md">Resilience Guide</a></b></td><td>Circuit breakers, cooldowns, queue, anti-thundering herd, TLS spoofing</td></tr>
|
||||
<tr><td nowrap><b><a href="docs/routing/AUTO-COMBO.md">Auto-Combo Engine</a></b></td><td>14-factor scoring, mode packs, self-healing</td></tr>
|
||||
<tr><td nowrap><b><a href="docs/routing/AUTO-COMBO.md">Auto-Combo Engine</a></b></td><td>15-factor scoring, mode packs, self-healing</td></tr>
|
||||
<tr><td nowrap><b><a href="docs/ops/PROXY_GUIDE.md">Proxy Guide</a></b></td><td>3-level proxy system, 1proxy marketplace, registry CRUD</td></tr>
|
||||
<tr><td nowrap><b><a href="docs/reference/FREE_TIERS.md">Free Tiers</a></b></td><td>90+ free providers consolidated directory (42 documented token pools / 495 models)</td></tr>
|
||||
<tr><td nowrap><b><a href="docs/reference/FREE_TIERS.md">Free Tiers</a></b></td><td>Consolidated directory: 40 documented recurring pools / 455 cataloged free-tier entries</td></tr>
|
||||
<tr><td nowrap><b><a href="docs/guides/FEATURES.md">Features Gallery</a></b></td><td>Visual dashboard tour with screenshots</td></tr>
|
||||
<tr><td nowrap><b><a href="docs/architecture/CODEBASE_DOCUMENTATION.md">Codebase Documentation</a></b></td><td>Beginner-friendly codebase walkthrough</td></tr>
|
||||
</table>
|
||||
@@ -1275,7 +1276,7 @@ Métricas de validação: 1002 vídeos rastreados · 7,069,190 visualizações c
|
||||
<tr><th align="left">Document</th><th align="left">Description</th></tr>
|
||||
<tr><td nowrap><b><a href="docs/reference/API_REFERENCE.md">API Reference</a></b></td><td>All endpoints with examples</td></tr>
|
||||
<tr><td nowrap><b><a href="docs/openapi.yaml">OpenAPI Spec</a></b></td><td>OpenAPI 3.0 specification</td></tr>
|
||||
<tr><td nowrap><b><a href="open-sse/mcp-server/README.md">MCP Server</a></b></td><td>109 MCP tools, IDE configs, Python/TS/Go clients</td></tr>
|
||||
<tr><td nowrap><b><a href="open-sse/mcp-server/README.md">MCP Server</a></b></td><td>110 MCP tools, IDE configs, Python/TS/Go clients</td></tr>
|
||||
<tr><td nowrap><b><a href="docs/frameworks/MCP-SERVER.md">MCP Server Guide</a></b></td><td>MCP installation, transports, and tool reference</td></tr>
|
||||
<tr><td nowrap><b><a href="src/lib/a2a/README.md">A2A Server</a></b></td><td>JSON-RPC 2.0 protocol, skills, streaming, task mgmt</td></tr>
|
||||
<tr><td nowrap><b><a href="docs/frameworks/A2A-SERVER.md">A2A Server Guide</a></b></td><td>A2A agent card, tasks, skills, and streaming</td></tr>
|
||||
@@ -1291,7 +1292,7 @@ Métricas de validação: 1002 vídeos rastreados · 7,069,190 visualizações c
|
||||
<tr><td nowrap><b><a href="SECURITY.md">Security Policy</a></b></td><td>Vulnerability reporting and security practices</td></tr>
|
||||
<tr><td nowrap><b><a href="docs/guides/I18N.md">i18n Guide</a></b></td><td>43-language support, translation workflow, RTL</td></tr>
|
||||
<tr><td nowrap><b><a href="docs/ops/RELEASE_CHECKLIST.md">Release Checklist</a></b></td><td>Pre-release validation steps</td></tr>
|
||||
<tr><td nowrap><b><a href="docs/ops/COVERAGE_PLAN.md">Coverage Plan</a></b></td><td>Test coverage strategy and 25,000+ test suite</td></tr>
|
||||
<tr><td nowrap><b><a href="docs/ops/COVERAGE_PLAN.md">Coverage Plan</a></b></td><td>Test coverage strategy for 39,000+ static test declarations across 5,100+ tracked test files</td></tr>
|
||||
</table>
|
||||
|
||||
<br/>
|
||||
@@ -1302,93 +1303,123 @@ Métricas de validação: 1002 vídeos rastreados · 7,069,190 visualizações c
|
||||
|
||||
> OmniRoute is shaped by a passionate open-source community. These individuals have made exceptional contributions that directly impact the quality, stability, and reach of the project. **Thank you.**
|
||||
|
||||
### External contributors by merged pull requests
|
||||
|
||||
<table>
|
||||
<tr><th align="center">Rank</th><th align="left">Contributor</th><th align="center">Merged PRs</th><th align="right">~Changed lines</th></tr>
|
||||
<tr><td align="center">1</td><td align="left"><a href="https://github.com/backryun"><b>backryun</b></a></td><td align="center">190</td><td align="right">227,977</td></tr>
|
||||
<tr><td align="center">2</td><td align="left"><a href="https://github.com/oyi77"><b>oyi77</b></a></td><td align="center">180</td><td align="right">407,678</td></tr>
|
||||
<tr><td align="center">3</td><td align="left"><a href="https://github.com/rdself"><b>rdself</b></a></td><td align="center">145</td><td align="right">80,663</td></tr>
|
||||
<tr><td align="center">4</td><td align="left"><a href="https://github.com/JxnLexn"><b>JxnLexn</b></a></td><td align="center">128</td><td align="right">387,049</td></tr>
|
||||
<tr><td align="center">5</td><td align="left"><a href="https://github.com/KooshaPari"><b>KooshaPari</b></a></td><td align="center">101</td><td align="right">125,747</td></tr>
|
||||
<tr><td align="center">6</td><td align="left"><a href="https://github.com/herjarsa"><b>herjarsa</b></a></td><td align="center">88</td><td align="right">230,872</td></tr>
|
||||
<tr><td align="center">7</td><td align="left"><a href="https://github.com/RaviTharuma"><b>RaviTharuma</b></a></td><td align="center">79</td><td align="right">55,106</td></tr>
|
||||
<tr><td align="center">8</td><td align="left"><a href="https://github.com/maxmad64bis"><b>maxmad64bis</b></a></td><td align="center">69</td><td align="right">394,715</td></tr>
|
||||
<tr><td align="center">9</td><td align="left"><a href="https://github.com/artickc"><b>artickc</b></a></td><td align="center">59</td><td align="right">33,260</td></tr>
|
||||
<tr><td align="center">10</td><td align="left"><a href="https://github.com/HouMinXi"><b>HouMinXi</b></a></td><td align="center">51</td><td align="right">47,334</td></tr>
|
||||
<tr><td align="center">10</td><td align="left"><a href="https://github.com/chirag127"><b>chirag127</b></a></td><td align="center">51</td><td align="right">5,153</td></tr>
|
||||
<tr><td align="center">12</td><td align="left"><a href="https://github.com/xz-dev"><b>xz-dev</b></a></td><td align="center">50</td><td align="right">245,976</td></tr>
|
||||
<tr><td align="center">13</td><td align="left"><a href="https://github.com/hartmark"><b>hartmark</b></a></td><td align="center">47</td><td align="right">52,185</td></tr>
|
||||
<tr><td align="center">14</td><td align="left"><a href="https://github.com/rqzbeh"><b>rqzbeh</b></a></td><td align="center">39</td><td align="right">143,181</td></tr>
|
||||
<tr><td align="center">15</td><td align="left"><a href="https://github.com/dhaern"><b>dhaern</b></a></td><td align="center">34</td><td align="right">19,559</td></tr>
|
||||
<tr><td align="center">16</td><td align="left"><a href="https://github.com/Dingding-leo"><b>Dingding-leo</b></a></td><td align="center">33</td><td align="right">1,986</td></tr>
|
||||
<tr><td align="center">17</td><td align="left"><a href="https://github.com/NomenAK"><b>NomenAK</b></a></td><td align="center">32</td><td align="right">13,854</td></tr>
|
||||
<tr><td align="center">18</td><td align="left"><a href="https://github.com/MumuTW"><b>MumuTW</b></a></td><td align="center">30</td><td align="right">16,953</td></tr>
|
||||
<tr><td align="center">19</td><td align="left"><a href="https://github.com/benzntech"><b>benzntech</b></a></td><td align="center">29</td><td align="right">11,641</td></tr>
|
||||
<tr><td align="center">20</td><td align="left"><a href="https://github.com/pacocartones"><b>pacocartones</b></a></td><td align="center">24</td><td align="right">9,331</td></tr>
|
||||
<tr><td align="center">20</td><td align="left"><a href="https://github.com/Prudhvivuda"><b>Prudhvivuda</b></a></td><td align="center">24</td><td align="right">6,312</td></tr>
|
||||
</table>
|
||||
|
||||
<sub>Frozen at live <code>release/v3.8.50</code> tip <code>dafb4ae808</code>, with merges through 2026-08-24 05:26:03 UTC. The paginated GitHub GraphQL census contains 5,911 merged PRs: 2,707 by the repository owner, 179 by Dependabot, and <b>3,025 external PRs from 535 distinct contributors</b>. “Changed lines” is GitHub additions + deletions and includes generated files, lockfiles, catalogs, translations and documentation; it is churn, not authored LOC. Ties at the cutoff are retained.</sub>
|
||||
|
||||
### GitHub-attributed commits
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<td align="center" width="160">
|
||||
<a href="https://github.com/oyi77">
|
||||
<img src="https://github.com/oyi77.png" width="40" style="border-radius:50%" alt="oyi77"/><br/>
|
||||
<b>oyi77</b>
|
||||
</a><br/>
|
||||
<sub>🥇 213 commits • +114K lines</sub><br/>
|
||||
<sub>Analytics engine, SQL aggregations,<br/>proxy marketplace, test coverage</sub>
|
||||
</td>
|
||||
<td align="center" width="160">
|
||||
<a href="https://github.com/rdself">
|
||||
<img src="https://github.com/rdself.png" width="40" style="border-radius:50%" alt="R.D. & Randi"/><br/>
|
||||
<b>R.D. & Randi</b>
|
||||
</a><br/>
|
||||
<sub>🥈 108 commits • +38K lines</sub><br/>
|
||||
<sub>Endpoints page, tunnel integrations,<br/>Docker workflows, A2A status, compression UI</sub>
|
||||
</td>
|
||||
<td align="center" width="160">
|
||||
<a href="https://github.com/christopher-s">
|
||||
<img src="https://github.com/christopher-s.png" width="40" style="border-radius:50%" alt="Chris Staley"/><br/>
|
||||
<b>Chris Staley</b>
|
||||
</a><br/>
|
||||
<sub>🥉 70 commits • +1.8K lines</sub><br/>
|
||||
<sub>SSE stream hardening, Responses API,<br/>Gemini pagination, test regression fixes</sub>
|
||||
</td>
|
||||
<td align="center" width="160">
|
||||
<a href="https://github.com/zen0bit">
|
||||
<img src="https://github.com/zen0bit.png" width="40" style="border-radius:50%" alt="zenobit"/><br/>
|
||||
<b>zenobit</b>
|
||||
</a><br/>
|
||||
<sub>🏅 62 commits • +22K lines</sub><br/>
|
||||
<sub>CI/CD pipeline, i18n for 33 languages,<br/>Void Linux package, platform fixes</sub>
|
||||
</td>
|
||||
<td align="center" width="160">
|
||||
<a href="https://github.com/JxnLexn">
|
||||
<img src="https://github.com/JxnLexn.png" width="40" style="border-radius:50%" alt="Jan Leon"/><br/>
|
||||
<b>Jan Leon</b>
|
||||
</a><br/>
|
||||
<sub>🏅 58 commits • +22K lines</sub><br/>
|
||||
<sub>Reasoning-effort routing, proxy controls,<br/>quota visibility, Live Zone compression</sub>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center" width="160">
|
||||
<a href="https://github.com/backryun">
|
||||
<img src="https://github.com/backryun.png" width="40" style="border-radius:50%" alt="backryun"/><br/>
|
||||
<b>backryun</b>
|
||||
</a><br/>
|
||||
<sub>🏅 53 commits • +70K lines</sub><br/>
|
||||
<sub>Provider catalog curation — Perplexity, Kimi,<br/>Cerebras, Copilot, LMArena refreshes</sub>
|
||||
<sub>🥇 220 GitHub-attributed commits</sub>
|
||||
</td>
|
||||
<td align="center" width="160">
|
||||
<a href="https://github.com/chirag127">
|
||||
<img src="https://github.com/chirag127.png" width="40" style="border-radius:50%" alt="Chirag Singhal"/><br/>
|
||||
<b>Chirag Singhal</b>
|
||||
<a href="https://github.com/oyi77">
|
||||
<img src="https://github.com/oyi77.png" width="40" style="border-radius:50%" alt="Paijo"/><br/>
|
||||
<b>Paijo</b>
|
||||
</a><br/>
|
||||
<sub>🏅 46 commits • +4.8K lines</sub><br/>
|
||||
<sub>Error sanitization, MITM prefill fix,<br/>fusion judge, breaker/429 correctness</sub>
|
||||
<sub>🥈 219 GitHub-attributed commits</sub>
|
||||
</td>
|
||||
<td align="center" width="160">
|
||||
<a href="https://github.com/kfiramar">
|
||||
<img src="https://github.com/kfiramar.png" width="40" style="border-radius:50%" alt="kfiramar"/><br/>
|
||||
<b>kfiramar</b>
|
||||
<a href="https://github.com/rdself">
|
||||
<img src="https://github.com/rdself.png" width="40" style="border-radius:50%" alt="Randi"/><br/>
|
||||
<b>Randi</b>
|
||||
</a><br/>
|
||||
<sub>🏅 38 commits • +1.7K lines</sub><br/>
|
||||
<sub>Codex websocket + passthrough, auth/onboarding,<br/>Electron hardening, DB migrations</sub>
|
||||
<sub>🥉 108 GitHub-attributed commits</sub>
|
||||
</td>
|
||||
<td align="center" width="160">
|
||||
<a href="https://github.com/benzntech">
|
||||
<img src="https://github.com/benzntech.png" width="40" style="border-radius:50%" alt="Benson K B"/><br/>
|
||||
<b>Benson K B</b>
|
||||
<a href="https://github.com/RaviTharuma">
|
||||
<img src="https://github.com/RaviTharuma.png" width="40" style="border-radius:50%" alt="Ravi Tharuma"/><br/>
|
||||
<b>Ravi Tharuma</b>
|
||||
</a><br/>
|
||||
<sub>🏅 28 commits • +9.2K lines</sub><br/>
|
||||
<sub>Electron desktop app, auto-updater,<br/>release build workflows, cross-platform CI</sub>
|
||||
<sub>🏅 81 GitHub-attributed commits</sub>
|
||||
</td>
|
||||
<td align="center" width="160">
|
||||
<a href="https://github.com/herjarsa">
|
||||
<img src="https://github.com/herjarsa.png" width="40" style="border-radius:50%" alt="Hernan J. Ardila"/><br/>
|
||||
<b>Hernan J. Ardila</b>
|
||||
<a href="https://github.com/christopher-s">
|
||||
<img src="https://github.com/christopher-s.png" width="40" style="border-radius:50%" alt="Chris"/><br/>
|
||||
<b>Chris</b>
|
||||
</a><br/>
|
||||
<sub>🏅 25 commits • +174K lines</sub><br/>
|
||||
<sub>Zero-latency combos, vision-bridge auto-routing,<br/>catalog context-length, resilience 429 hints</sub>
|
||||
<sub>🏅 70 GitHub-attributed commits</sub>
|
||||
</td>
|
||||
<td align="center" width="160">
|
||||
<a href="https://github.com/hartmark">
|
||||
<img src="https://github.com/hartmark.png" width="40" style="border-radius:50%" alt="Markus Hartung"/><br/>
|
||||
<b>Markus Hartung</b>
|
||||
</a><br/>
|
||||
<sub>🏅 69 GitHub-attributed commits · tied #6</sub>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center" width="160">
|
||||
<a href="https://github.com/maxmad64bis">
|
||||
<img src="https://github.com/maxmad64bis.png" width="40" style="border-radius:50%" alt="Dizzle"/><br/>
|
||||
<b>Dizzle</b>
|
||||
</a><br/>
|
||||
<sub>🏅 69 GitHub-attributed commits · tied #6</sub>
|
||||
</td>
|
||||
<td align="center" width="160">
|
||||
<a href="https://github.com/JxnLexn">
|
||||
<img src="https://github.com/JxnLexn.png" width="40" style="border-radius:50%" alt="Jan Leon"/><br/>
|
||||
<b>Jan Leon</b>
|
||||
</a><br/>
|
||||
<sub>🏅 64 GitHub-attributed commits</sub>
|
||||
</td>
|
||||
<td align="center" width="160">
|
||||
<a href="https://github.com/zen0bit">
|
||||
<img src="https://github.com/zen0bit.png" width="40" style="border-radius:50%" alt="zenobit"/><br/>
|
||||
<b>zenobit</b>
|
||||
</a><br/>
|
||||
<sub>🏅 62 GitHub-attributed commits</sub>
|
||||
</td>
|
||||
<td align="center" width="160">
|
||||
<a href="https://github.com/HouMinXi">
|
||||
<img src="https://github.com/HouMinXi.png" width="40" style="border-radius:50%" alt="Bob.Hou"/><br/>
|
||||
<b>Bob.Hou</b>
|
||||
</a><br/>
|
||||
<sub>🏅 51 GitHub-attributed commits · tied #10</sub>
|
||||
</td>
|
||||
<td align="center" width="160">
|
||||
<a href="https://github.com/xz-dev">
|
||||
<img src="https://github.com/xz-dev.png" width="40" style="border-radius:50%" alt="Xiangzhe"/><br/>
|
||||
<b>Xiangzhe</b>
|
||||
</a><br/>
|
||||
<sub>🏅 51 GitHub-attributed commits · tied #10</sub>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<sub>Rechecked at 2026-08-24 06:14:31 UTC: GitHub-attributed commits reported by the repository Contributors API for the <code>release/v3.8.50</code> default branch. The API returned 525 identities (415 users, 2 bots, 108 anonymous); this table excludes the maintainer, bots and anonymous identities and retains competition ties. It is distinct from both the merged-PR ranking above and the 639-person Git-metadata census below.</sub>
|
||||
|
||||
> 🙏 These contributors' features, bug fixes, and infrastructure improvements are a **core part** of what makes OmniRoute reliable and feature-rich. Every pull request, every test case, and every i18n translation file matters. Open source is built by people like them.
|
||||
|
||||
</div>
|
||||
@@ -1405,25 +1436,48 @@ A heartfelt thank-you to the people who fund OmniRoute out of their own pocket
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<td align="center" width="180">
|
||||
<a href="https://github.com/drewbitt">
|
||||
<img src="https://github.com/drewbitt.png?size=140" width="72" style="border-radius:50%" alt="Andrew"/><br/>
|
||||
<b>Andrew</b>
|
||||
</a><br/>
|
||||
<sub>💛 Active monthly sponsor</sub>
|
||||
</td>
|
||||
<td align="center" width="180">
|
||||
<a href="https://github.com/psylligent">
|
||||
<img src="https://github.com/psylligent.png?size=140" width="72" style="border-radius:50%" alt="Vlad I"/><br/>
|
||||
<b>Vlad I</b>
|
||||
</a><br/>
|
||||
<sub>💛 Active monthly sponsor</sub>
|
||||
</td>
|
||||
<td align="center" width="180">
|
||||
<a href="https://github.com/pacocartones">
|
||||
<img src="https://github.com/pacocartones.png?size=140" width="72" style="border-radius:50%" alt="Paco Cartones"/><br/>
|
||||
<b>Paco Cartones</b>
|
||||
</a><br/>
|
||||
<sub>💛 Active one-time sponsor</sub>
|
||||
</td>
|
||||
<td align="center" width="180">
|
||||
<a href="https://github.com/igormorais123">
|
||||
<img src="https://github.com/igormorais123.png?size=140" width="72" style="border-radius:50%" alt="Professor Igor Morais Vasconcelos"/><br/>
|
||||
<b>Prof. Igor Morais</b>
|
||||
</a><br/>
|
||||
<sub>💛 Sponsor</sub>
|
||||
<sub>💛 Past one-time supporter</sub>
|
||||
</td>
|
||||
<td align="center" width="180">
|
||||
<a href="https://github.com/longtao77">
|
||||
<img src="https://github.com/longtao77.png?size=140" width="72" style="border-radius:50%" alt="longtao"/><br/>
|
||||
<b>longtao</b>
|
||||
</a><br/>
|
||||
<sub>💛 Sponsor</sub>
|
||||
<sub>💛 Past one-time supporter</sub>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<sub>… and others who prefer to stay private 💛</sub>
|
||||
|
||||
<sub>Public GitHub Sponsors revalidated on 2026-08-24. GitHub's <code>activeOnly</code> status determines the active labels above; previously disclosed public one-time supporters remain thanked, and private sponsors remain anonymous.</sub>
|
||||
|
||||
<b><a href="https://github.com/sponsors/diegosouzapw">💖 Become a sponsor →</a></b> — every dollar keeps OmniRoute free and independent.
|
||||
|
||||
</div>
|
||||
@@ -1432,11 +1486,13 @@ A heartfelt thank-you to the people who fund OmniRoute out of their own pocket
|
||||
|
||||
<div align="center">
|
||||
|
||||
## 👥 320+ Contributors
|
||||
## 👥 600+ Contributors
|
||||
|
||||
</div>
|
||||
|
||||
[](https://github.com/diegosouzapw/OmniRoute/graphs/contributors)
|
||||
[](https://github.com/diegosouzapw/OmniRoute/graphs/contributors)
|
||||
|
||||
<sub>Audited on 2026-08-24 at frozen base <code>ac02c5b42f</code> and rechecked at live <code>release/v3.8.50</code> tip <code>dafb4ae808</code>: <b>639 normalized human Git identities</b> — 407 appear as commit authors (including the maintainer) and 232 only in explicit <code>Co-authored-by</code> trailers. The census normalizes GitHub noreply handles, excludes 26 bot/agent/service/placeholder identities, and does not merge ordinary email addresses merely because their display names match.</sub>
|
||||
|
||||
### How to Contribute
|
||||
|
||||
@@ -1453,7 +1509,8 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for detailed guidelines.
|
||||
|
||||
```bash
|
||||
# Create a release — npm publish happens automatically
|
||||
gh release create v3.8.2 --title "v3.8.2" --generate-notes
|
||||
VERSION=x.y.z
|
||||
gh release create "v${VERSION}" --title "v${VERSION}" --generate-notes
|
||||
```
|
||||
|
||||
<br/>
|
||||
@@ -1495,88 +1552,108 @@ gh release create v3.8.2 --title "v3.8.2" --generate-notes
|
||||
|
||||
OmniRoute stands on the shoulders of giants. It started as a fork of **[9router](https://github.com/decolua/9router)** and a TypeScript port of the Go project **[CLIProxyAPI](https://github.com/router-for-me/CLIProxyAPI)** — and from there, every subsystem below was inspired by an open-source project that got there first. Each one shaped a concrete piece of OmniRoute. This is our thank-you to all of them. 🙏
|
||||
|
||||
> ⭐ star counts as of July 2026 — go give these projects a star.
|
||||
> ⭐ star counts verified from GitHub's REST API on August 24, 2026 — go give these projects a star. Counts are an exact dated snapshot and will naturally change.
|
||||
|
||||
### 🧬 Lineage & gateway
|
||||
|
||||
<table>
|
||||
<tr><th align="left">Project</th><th align="center">⭐</th><th align="left">How it inspired OmniRoute</th></tr>
|
||||
<tr><td nowrap><b><a href="https://github.com/decolua/9router">9router</a></b></td><td align="center">22.7k</td><td>The original project this fork is built on — extended here with multi-modal APIs and a full TypeScript rewrite.</td></tr>
|
||||
<tr><td nowrap><b><a href="https://github.com/router-for-me/CLIProxyAPI">CLIProxyAPI</a></b></td><td align="center">43.6k</td><td>The Go implementation that inspired this JavaScript / TypeScript port.</td></tr>
|
||||
<tr><td nowrap><b><a href="https://github.com/BerriAI/litellm">LiteLLM</a></b></td><td align="center">54.0k</td><td>The AI gateway whose public pricing dataset feeds our cost-tracking sync and whose provider-normalization model informed our routing.</td></tr>
|
||||
<tr><td nowrap><b><a href="https://github.com/decolua/9router">9router</a></b></td><td align="center">26,161</td><td>The original project this fork is built on — extended here with multi-modal APIs and a full TypeScript rewrite.</td></tr>
|
||||
<tr><td nowrap><b><a href="https://github.com/router-for-me/CLIProxyAPI">CLIProxyAPI</a></b></td><td align="center">48,497</td><td>The Go implementation that inspired this JavaScript / TypeScript port.</td></tr>
|
||||
<tr><td nowrap><b><a href="https://github.com/BerriAI/litellm">LiteLLM</a></b></td><td align="center">57,100</td><td>The AI gateway whose public pricing dataset feeds our cost-tracking sync and whose provider-normalization model informed our routing.</td></tr>
|
||||
<tr><td nowrap><b><a href="https://github.com/miuuyy/codex-chatgpt-web">codex-chatgpt-web</a></b></td><td align="center">1,410</td><td>MIT source adapted into the vendored ChatGPT Web → Codex Responses bridge, including browser-session, response-framing, usage and web-search adapters.</td></tr>
|
||||
<tr><td nowrap><b><a href="https://github.com/Alishahryar1/free-claude-code">free-claude-code</a></b></td><td align="center">48,112</td><td>Patterns ported into stream recovery, no-thinking aliases, fallback web search, sliding-window limits, log redaction and hardened launcher flows.</td></tr>
|
||||
<tr><td nowrap><b><a href="https://github.com/standardagents/composer-api">composer-api</a></b></td><td align="center">322</td><td>Cursor Composer tool-choice, output-constraint and tool-commit patterns adapted into the native Cursor executor.</td></tr>
|
||||
<tr><td nowrap><b><a href="https://github.com/ndycode/codex-multi-auth">codex-multi-auth</a></b></td><td align="center">457</td><td>Fresh-login and refresh-token rotation patterns ported into Codex OAuth reauthentication.</td></tr>
|
||||
<tr><td nowrap><b><a href="https://github.com/ex-machina-co/opencode-anthropic-auth">opencode-anthropic-auth</a></b></td><td align="center">510</td><td>Claude Code-compatible transform defaults and billing-header behavior generalized into OmniRoute's config-driven bridge.</td></tr>
|
||||
<tr><td nowrap><b><a href="https://github.com/520mmxx/grok2api-merged">grok2api-merged</a></b></td><td align="center">2</td><td>Its Grok model mappings, fake-TypeError Statsig generator, request and device defaults, and NDJSON response processor were materially adapted into OmniRoute's Grok Web executor.</td></tr>
|
||||
<tr><td nowrap><b><a href="https://github.com/TQZHR/grok2api">TQZHR/grok2api</a></b></td><td align="center">705</td><td>The principal transitive code source behind grok2api-merged; its model, header, payload, Statsig and processor implementations are preserved in the Grok Web lineage.</td></tr>
|
||||
<tr><td nowrap><b><a href="https://github.com/chenyme/grok2api">chenyme/grok2api</a></b></td><td align="center">7,520</td><td>The underlying MIT source for Grok payload and device defaults, the Statsig generator, and the <code>result.response</code> processor carried through TQZHR and grok2api-merged.</td></tr>
|
||||
<tr><td nowrap><b><a href="https://github.com/miuzhaii/grok2api-pro">grok2api-pro</a></b></td><td align="center">27</td><td>A transitive source credited by grok2api-merged for its proxy-pool layer; OmniRoute preserves that lineage notice but does not claim a proxy-pool port in its bounded Grok Web executor.</td></tr>
|
||||
<tr><td nowrap><b><a href="https://github.com/CNFlyCat/GrokProxy">GrokProxy</a></b></td><td align="center">50</td><td>Its cookie-authenticated Grok proxy and <code>result.response.token</code> streaming pattern informed OmniRoute's Grok Web transport.</td></tr>
|
||||
<tr><td nowrap><b><a href="https://github.com/lianying1716/GrokBridge">GrokBridge</a></b></td><td align="center">5</td><td>The original Grok Web implementation consulted its HTTP/browser upstream design; its direct HTTP path derives from GrokProxy, so no independent code port is claimed.</td></tr>
|
||||
<tr><td nowrap><b><a href="https://github.com/imjustprism/grok-web-api">grok-web-api</a></b></td><td align="center">14</td><td>Its Rust <code>ChatOptions</code> and response-envelope schemas informed OmniRoute's TypeScript Grok request and streaming-response types.</td></tr>
|
||||
</table>
|
||||
|
||||
### 🗜️ Context & token compression — engines
|
||||
|
||||
<table>
|
||||
<tr><th align="left">Project</th><th align="center">⭐</th><th align="left">How it inspired OmniRoute</th></tr>
|
||||
<tr><td nowrap><b><a href="https://github.com/JuliusBrussee/caveman">Caveman</a></b></td><td align="center">90.8k</td><td>The viral "why use many token when few token do trick" project — its caveman-speak philosophy powers our standard compression mode and 30+ filler/condensation rules.</td></tr>
|
||||
<tr><td nowrap><b><a href="https://github.com/rtk-ai/rtk">RTK – Rust Token Killer</a></b></td><td align="center">71.8k</td><td>High-performance command-output compression — inspired our RTK engine, JSON filter DSL, raw-output recovery and the stacked RTK → Caveman pipeline.</td></tr>
|
||||
<tr><td nowrap><b><a href="https://github.com/headroomlabs-ai/headroom">headroom</a></b></td><td align="center">60.1k</td><td>Reversible context-compression (SmartCrusher) — inspired our <code>headroom</code> engine and the <code>ccr</code> retrieve-marker pattern.</td></tr>
|
||||
<tr><td nowrap><b><a href="https://github.com/microsoft/LLMLingua">LLMLingua</a></b></td><td align="center">6.5k</td><td>Prompt-compression research (LLMLingua / LLMLingua-2) — inspired our async, code-safe, fail-open <code>llmlingua</code> engine.</td></tr>
|
||||
<tr><td nowrap><b><a href="https://github.com/atjsh/llmlingua-2-js">llmlingua-2-js</a></b></td><td align="center">30</td><td>The JS/ONNX port (MobileBERT / XLM-RoBERTa) used as the worker-thread backend for our LLMLingua engine.</td></tr>
|
||||
<tr><td nowrap><b><a href="https://github.com/leninejunior/troglodita">Troglodita</a></b></td><td align="center">26</td><td>PT-BR token compression — powers our pt-BR language pack: pleonasm reduction and filler removal tuned for Brazilian-Portuguese grammar.</td></tr>
|
||||
<tr><td nowrap><b><a href="https://github.com/DietrichGebert/ponytail">ponytail</a></b></td><td align="center">86.0k</td><td>The viral "lazy senior dev" YAGNI-coder skill — inspired our <b>less-code</b> Output Style: smallest-working-change steering that cuts _generated_ code (the output-axis sibling to Caveman's terse prose).</td></tr>
|
||||
<tr><td nowrap><b><a href="https://github.com/JuliusBrussee/caveman">Caveman</a></b></td><td align="center">100,538</td><td>The viral "why use many token when few token do trick" project — its caveman-speak philosophy powers our standard compression mode and 30+ filler/condensation rules.</td></tr>
|
||||
<tr><td nowrap><b><a href="https://github.com/rtk-ai/rtk">RTK – Rust Token Killer</a></b></td><td align="center">77,185</td><td>High-performance command-output compression — inspired our RTK engine, JSON filter DSL, raw-output recovery and the stacked RTK → Caveman pipeline.</td></tr>
|
||||
<tr><td nowrap><b><a href="https://github.com/headroomlabs-ai/headroom">headroom</a></b></td><td align="center">67,310</td><td>Reversible context-compression (SmartCrusher) — inspired our <code>headroom</code> engine and the <code>ccr</code> retrieve-marker pattern.</td></tr>
|
||||
<tr><td nowrap><b><a href="https://github.com/microsoft/LLMLingua">LLMLingua</a></b></td><td align="center">6,598</td><td>Prompt-compression research (LLMLingua / LLMLingua-2) — inspired our async, code-safe, fail-open <code>llmlingua</code> engine.</td></tr>
|
||||
<tr><td nowrap><b><a href="https://github.com/atjsh/llmlingua-2-js">llmlingua-2-js</a></b></td><td align="center">31</td><td>The JS/ONNX port (MobileBERT / XLM-RoBERTa) used as the worker-thread backend for our LLMLingua engine.</td></tr>
|
||||
<tr><td nowrap><b><a href="https://github.com/leninejunior/troglodita">Troglodita</a></b></td><td align="center">40</td><td>PT-BR token compression — powers our pt-BR language pack: pleonasm reduction and filler removal tuned for Brazilian-Portuguese grammar.</td></tr>
|
||||
<tr><td nowrap><b><a href="https://github.com/DietrichGebert/ponytail">ponytail</a></b></td><td align="center">108,957</td><td>The viral "lazy senior dev" YAGNI-coder skill — inspired our <b>less-code</b> Output Style: smallest-working-change steering that cuts _generated_ code (the output-axis sibling to Caveman's terse prose).</td></tr>
|
||||
<tr><td nowrap><b><a href="https://github.com/ayghri/i-have-adhd">i-have-adhd</a></b></td><td align="center">23,526</td><td>Its action-first, ADHD-friendly response style was adapted into OmniRoute's concise output style across five languages.</td></tr>
|
||||
</table>
|
||||
|
||||
### 🧩 Compact formats, token research & code-aware tooling
|
||||
|
||||
<table>
|
||||
<tr><th align="left">Project</th><th align="center">⭐</th><th align="left">How it inspired OmniRoute</th></tr>
|
||||
<tr><td nowrap><b><a href="https://github.com/toon-format/toon">TOON</a></b></td><td align="center">24.9k</td><td>Token-Oriented Object Notation — its columnar, header-plus-rows model shaped our tabular compaction stage.</td></tr>
|
||||
<tr><td nowrap><b><a href="https://github.com/blackwell-systems/gcf">GCF – Graph Compact Format</a></b></td><td align="center">22</td><td>First inspired our tabular compaction stage; now its zero-dependency, lossless generic-profile encoder is <b>vendored directly</b> as the Headroom codec (MIT, SPDX-marked), with later numeric-domain and count-mismatch correctness fixes.</td></tr>
|
||||
<tr><td nowrap><b><a href="https://github.com/ooples/token-optimizer-mcp">token-optimizer-mcp</a></b></td><td align="center">444</td><td>Brotli/SQLite cache + per-session context-delta — inspired our <code>session-dedup</code> engine.</td></tr>
|
||||
<tr><td nowrap><b><a href="https://github.com/Mibayy/token-savior">token-savior</a></b></td><td align="center">1.1k</td><td>Bash-output compaction + MCP profiles — inspired our compression bail-out discipline and MCP tool-manifest reduction.</td></tr>
|
||||
<tr><td nowrap><b><a href="https://github.com/ppgranger/token-saver">token-saver</a></b></td><td align="center">117</td><td>Content-aware, per-file-type output compression with failure-aware bail-out — validated our per-type dispatch and minimum-gain skip.</td></tr>
|
||||
<tr><td nowrap><b><a href="https://github.com/alexgreensh/token-optimizer">token-optimizer</a></b></td><td align="center">1.7k</td><td>"Find the ghost tokens" — its offload + recoverable-handle pattern informed our CCR offload thinking.</td></tr>
|
||||
<tr><td nowrap><b><a href="https://github.com/Shweta-Mishra-ai/tokenmizer">TokenMizer</a></b></td><td align="center">16</td><td>A session-graph + cross-turn line-dedup blueprint that informed our session-dedup design.</td></tr>
|
||||
<tr><td nowrap><b><a href="https://github.com/toon-format/toon">TOON</a></b></td><td align="center">25,233</td><td>Token-Oriented Object Notation — its columnar, header-plus-rows model shaped our tabular compaction stage.</td></tr>
|
||||
<tr><td nowrap><b><a href="https://github.com/blackwell-systems/gcf">GCF – Graph Compact Format</a></b></td><td align="center">41</td><td>Its compact graph format and generic-profile design informed OmniRoute's tabular compaction and Headroom codec format.</td></tr>
|
||||
<tr><td nowrap><b><a href="https://github.com/blackwell-systems/gcf-typescript">gcf-typescript</a></b></td><td align="center">4</td><td>The MIT TypeScript implementation directly vendored and extended as the Headroom generic-profile codec.</td></tr>
|
||||
<tr><td nowrap><b><a href="https://github.com/ooples/token-optimizer-mcp">token-optimizer-mcp</a></b></td><td align="center">494</td><td>Brotli/SQLite cache + per-session context-delta — inspired our <code>session-dedup</code> engine.</td></tr>
|
||||
<tr><td nowrap><b><a href="https://github.com/Mibayy/token-savior">token-savior</a></b></td><td align="center">1,122</td><td>Bash-output compaction + MCP profiles — inspired our compression bail-out discipline and MCP tool-manifest reduction.</td></tr>
|
||||
<tr><td nowrap><b><a href="https://github.com/ppgranger/token-saver">token-saver</a></b></td><td align="center">138</td><td>Content-aware, per-file-type output compression with failure-aware bail-out — validated our per-type dispatch and minimum-gain skip.</td></tr>
|
||||
<tr><td nowrap><b><a href="https://github.com/alexgreensh/token-optimizer">token-optimizer</a></b></td><td align="center">1,951</td><td>"Find the ghost tokens" — its offload + recoverable-handle pattern informed our CCR offload thinking.</td></tr>
|
||||
<tr><td nowrap><b><a href="https://github.com/Shweta-Mishra-ai/tokenmizer">TokenMizer</a></b></td><td align="center">28</td><td>A session-graph + cross-turn line-dedup blueprint that informed our session-dedup design.</td></tr>
|
||||
<tr><td nowrap><b><a href="https://github.com/jessefreitas/OmniCompress">OmniCompress</a></b></td><td align="center">3</td><td>Rust columnar-JSON + content-addressed retrieve + cross-message dedup — validated our <code>headroom</code>/<code>ccr</code>/<code>session-dedup</code> engine design and the cache-stable "compressed form is position-independent" invariant.</td></tr>
|
||||
<tr><td nowrap><b><a href="https://github.com/atlassian-labs/mcp-compressor">mcp-compressor</a></b></td><td align="center">98</td><td>MCP tool-schema/description compression — informed our MCP tool-manifest cardinality reduction.</td></tr>
|
||||
<tr><td nowrap><b><a href="https://github.com/pdavis68/RepoMapper">RepoMapper</a></b></td><td align="center">187</td><td>Aider-style repo-map ranking — informed our repo-map / retrieval-ranking exploration.</td></tr>
|
||||
<tr><td nowrap><b><a href="https://github.com/atlassian-labs/mcp-compressor">mcp-compressor</a></b></td><td align="center">113</td><td>MCP tool-schema/description compression — informed our MCP tool-manifest cardinality reduction.</td></tr>
|
||||
<tr><td nowrap><b><a href="https://github.com/pdavis68/RepoMapper">RepoMapper</a></b></td><td align="center">197</td><td>Aider-style repo-map ranking — informed our repo-map / retrieval-ranking exploration.</td></tr>
|
||||
<tr><td nowrap><b><a href="https://github.com/mrsimpson/quiet-shell-mcp">quiet-shell-mcp</a></b></td><td align="center">4</td><td>Declarative shell-output reduction over MCP — validated our declarative bash-output compaction.</td></tr>
|
||||
<tr><td nowrap><b><a href="https://github.com/dsherret/ts-morph">ts-morph</a></b></td><td align="center">6.1k</td><td>TypeScript Compiler API toolkit — inspired our parser-based comment removal that preserves string, template and regex literals.</td></tr>
|
||||
<tr><td nowrap><b><a href="https://github.com/dsherret/ts-morph">ts-morph</a></b></td><td align="center">6,162</td><td>TypeScript Compiler API toolkit — inspired our parser-based comment removal that preserves string, template and regex literals.</td></tr>
|
||||
</table>
|
||||
|
||||
### 🧠 Memory & RAG
|
||||
|
||||
<table>
|
||||
<tr><th align="left">Project</th><th align="center">⭐</th><th align="left">How it inspired OmniRoute</th></tr>
|
||||
<tr><td nowrap><b><a href="https://github.com/mem0ai/mem0">Mem0</a></b></td><td align="center">61.2k</td><td>Universal memory layer — its proxy-as-write/read-boundary model shaped our memory architecture.</td></tr>
|
||||
<tr><td nowrap><b><a href="https://github.com/letta-ai/letta">Letta (MemGPT)</a></b></td><td align="center">23.9k</td><td>Stateful agents with tiered memory — inspired our Context Control & Recovery (CCR) tiered model.</td></tr>
|
||||
<tr><td nowrap><b><a href="https://github.com/onestardao/WFGY">WFGY</a></b></td><td align="center">1.8k</td><td>The ProblemMap taxonomy of 16 recurring RAG/LLM failure modes — the shared vocabulary in our troubleshooting guide.</td></tr>
|
||||
<tr><td nowrap><b><a href="https://github.com/mem0ai/mem0">Mem0</a></b></td><td align="center">63,902</td><td>Universal memory layer — its proxy-as-write/read-boundary model shaped our memory architecture.</td></tr>
|
||||
<tr><td nowrap><b><a href="https://github.com/letta-ai/letta">Letta (MemGPT)</a></b></td><td align="center">24,382</td><td>Stateful agents with tiered memory — inspired our Context Control & Recovery (CCR) tiered model.</td></tr>
|
||||
<tr><td nowrap><b><a href="https://github.com/onestardao/WFGY">WFGY</a></b></td><td align="center">1,781</td><td>The ProblemMap taxonomy of 16 recurring RAG/LLM failure modes — the shared vocabulary in our troubleshooting guide.</td></tr>
|
||||
</table>
|
||||
|
||||
### 🛰️ Traffic inspection, MITM & transparent proxy
|
||||
|
||||
<table>
|
||||
<tr><th align="left">Project</th><th align="center">⭐</th><th align="left">How it inspired OmniRoute</th></tr>
|
||||
<tr><td nowrap><b><a href="https://github.com/chouzz/llm-interceptor">llm-interceptor</a></b></td><td align="center">49</td><td>MITM interception/analysis of coding-assistant ↔ LLM traffic — our Traffic Inspector ports its SSE merge, conversation normalization, host passthrough and secret masking (MIT).</td></tr>
|
||||
<tr><td nowrap><b><a href="https://github.com/InterceptSuite/ProxyBridge">ProxyBridge</a></b></td><td align="center">5.5k</td><td>Transparent per-process proxy routing — inspired our crash-safe MITM teardown, socket idle-timeouts, <code>/proc</code> process attribution and TPROXY capture.</td></tr>
|
||||
<tr><td nowrap><b><a href="https://github.com/chouzz/llm-interceptor">llm-interceptor</a></b></td><td align="center">66</td><td>MITM interception/analysis of coding-assistant ↔ LLM traffic — our Traffic Inspector ports its SSE merge, conversation normalization, host passthrough and secret masking. The upstream's complete license text is still under provenance review.</td></tr>
|
||||
<tr><td nowrap><b><a href="https://github.com/InterceptSuite/ProxyBridge">ProxyBridge</a></b></td><td align="center">5,995</td><td>Transparent per-process proxy routing — inspired our crash-safe MITM teardown, socket idle-timeouts, <code>/proc</code> process attribution and TPROXY capture.</td></tr>
|
||||
</table>
|
||||
|
||||
### 📚 Model data, observability & UI
|
||||
|
||||
<table>
|
||||
<tr><th align="left">Project</th><th align="center">⭐</th><th align="left">How it inspired OmniRoute</th></tr>
|
||||
<tr><td nowrap><b><a href="https://github.com/anomalyco/models.dev">models.dev</a></b></td><td align="center">6.0k</td><td>Open database of AI model specs, pricing and capabilities — synced natively into our model catalog.</td></tr>
|
||||
<tr><td nowrap><b><a href="https://github.com/xyflow/xyflow">React Flow / xyflow</a></b></td><td align="center">37.7k</td><td>The node-based graph library powering our real-time Compression Studio and Combo/Routing Studio.</td></tr>
|
||||
<tr><td nowrap><b><a href="https://github.com/langchain-ai/langgraph">LangGraph</a></b></td><td align="center">37.6k</td><td>LangGraph Studio's live workflow-graph visualization inspired our Studios' real-time cascade view.</td></tr>
|
||||
<tr><td nowrap><b><a href="https://github.com/langfuse/langfuse">Langfuse</a></b></td><td align="center">31.4k</td><td>Its trace → span → generation observability model shaped our Compression Studio waterfall.</td></tr>
|
||||
<tr><td nowrap><b><a href="https://github.com/kiali/kiali">Kiali</a></b></td><td align="center">3.6k</td><td>Istio service-mesh observability — inspired our circuit-breaker badges and error-edge visuals in the Routing/Combo Studio.</td></tr>
|
||||
<tr><td nowrap><b><a href="https://github.com/lobehub/lobe-icons">lobe-icons</a></b></td><td align="center">2.2k</td><td>AI/LLM brand logos that render the provider icons across our dashboard.</td></tr>
|
||||
<tr><td nowrap><b><a href="https://github.com/anomalyco/models.dev">models.dev</a></b></td><td align="center">6,555</td><td>Open database of AI model specs, pricing and capabilities — synced natively into our model catalog.</td></tr>
|
||||
<tr><td nowrap><b><a href="https://github.com/xyflow/xyflow">React Flow / xyflow</a></b></td><td align="center">38,108</td><td>The node-based graph library powering our real-time Compression Studio and Combo/Routing Studio.</td></tr>
|
||||
<tr><td nowrap><b><a href="https://github.com/langchain-ai/langgraph">LangGraph</a></b></td><td align="center">40,314</td><td>LangGraph Studio's live workflow-graph visualization inspired our Studios' real-time cascade view.</td></tr>
|
||||
<tr><td nowrap><b><a href="https://github.com/langfuse/langfuse">Langfuse</a></b></td><td align="center">33,592</td><td>Its trace → span → generation observability model shaped our Compression Studio waterfall.</td></tr>
|
||||
<tr><td nowrap><b><a href="https://github.com/kiali/kiali">Kiali</a></b></td><td align="center">3,631</td><td>Istio service-mesh observability — inspired our circuit-breaker badges and error-edge visuals in the Routing/Combo Studio.</td></tr>
|
||||
<tr><td nowrap><b><a href="https://github.com/lobehub/lobe-icons">lobe-icons</a></b></td><td align="center">2,428</td><td>AI/LLM brand logos that render the provider icons across our dashboard.</td></tr>
|
||||
<tr><td nowrap><b><a href="https://github.com/lipis/flag-icons">flag-icons</a></b></td><td align="center">12,354</td><td>Provides the MIT-licensed SVG flags used by the README language selector.</td></tr>
|
||||
</table>
|
||||
|
||||
### 🛡️ Security
|
||||
|
||||
<table>
|
||||
<tr><th align="left">Project</th><th align="center">⭐</th><th align="left">How it inspired OmniRoute</th></tr>
|
||||
<tr><td nowrap><b><a href="https://github.com/tldrsec/awesome-secure-defaults">awesome-secure-defaults</a></b></td><td align="center">710</td><td>A curated list of secure-by-default libraries that guides our security choices (Helmet.js, DOMPurify, ssrf-req-filter, safe-regex, Google Tink).</td></tr>
|
||||
<tr><td nowrap><b><a href="https://github.com/tldrsec/awesome-secure-defaults">awesome-secure-defaults</a></b></td><td align="center">721</td><td>A curated list of secure-by-default libraries that guides our security choices (Helmet.js, DOMPurify, ssrf-req-filter, safe-regex, Google Tink).</td></tr>
|
||||
</table>
|
||||
|
||||
### 🧭 Complementary tools
|
||||
|
||||
<table>
|
||||
<tr><th align="left">Project</th><th align="center">⭐</th><th align="left">How it inspired OmniRoute</th></tr>
|
||||
<tr><td nowrap><b><a href="https://github.com/BlockRunAI/ClawRouter">ClawRouter</a></b></td><td align="center">6,564</td><td>Inspired request deduplication, emergency zero-cost fallback, pluggable Auto-Combo strategies and multilingual intent classification.</td></tr>
|
||||
<tr><td nowrap><b><a href="https://github.com/lbjlaq/Antigravity-Manager">Antigravity-Manager</a></b></td><td align="center">30,652</td><td>Its account-aware model remapping, executable-path validation and plan-label behavior informed OmniRoute's Antigravity runtime.</td></tr>
|
||||
<tr><td nowrap><b><a href="https://github.com/jlcodes99/vscode-antigravity-cockpit">vscode-antigravity-cockpit</a></b></td><td align="center">4,817</td><td>Its compact quota-reset countdown format inspired the corresponding provider-limit display in OmniRoute.</td></tr>
|
||||
<tr><td nowrap><b><a href="https://github.com/iOfficeAI/AionUi">AionUi</a></b></td><td align="center">32,230</td><td>Its ACP integrations inspired OmniRoute's automatic detection of installed CLI agents.</td></tr>
|
||||
<tr><td nowrap><b><a href="https://github.com/steipete/CodexBar">CodexBar</a></b></td><td align="center">20,507</td><td>Identified the Grok Build quota surface; OmniRoute then verified and corrected the live wire format independently.</td></tr>
|
||||
</table>
|
||||
|
||||
## 📄 License
|
||||
@@ -1589,7 +1666,7 @@ MIT License - see [LICENSE](LICENSE) for details.
|
||||
|
||||
**[⬆ Back to top](#-omniroute)** · Built with ❤️ for the open-source AI community.
|
||||
|
||||
<sub>OmniRoute v3.8.49 · Node ≥22.22.2 · MIT License · <a href="https://omniroute.online">omniroute.online</a></sub>
|
||||
<sub>OmniRoute v3.8.50 · Node ≥22.22.2 · MIT License · <a href="https://omniroute.online">omniroute.online</a></sub>
|
||||
|
||||
</div>
|
||||
<!-- GitHub Discussions enabled for community Q&A -->
|
||||
|
||||
@@ -26,7 +26,8 @@
|
||||
"testFailed": "Teste do provedor falhou: {error}",
|
||||
"loginEnabled": "Login: habilitado (senha atualizada)",
|
||||
"loginDisabled": "Login: desabilitado",
|
||||
"providerInfo": "Provedor: {info}"
|
||||
"providerInfo": "Provedor: {info}",
|
||||
"opencode": "Instala e configura o plugin @omniroute/opencode-plugin incluído para o OpenCode"
|
||||
},
|
||||
"doctor": {
|
||||
"title": "OmniRoute Doctor",
|
||||
@@ -254,7 +255,9 @@
|
||||
"no_recovery": "Desabilitar reinício automático em crash (modo debug)",
|
||||
"max_restarts": "Máximo de reinícios em 30s antes de desistir (padrão: 2)",
|
||||
"tray": "Mostrar ícone na bandeja do sistema (apenas desktop, opt-in)",
|
||||
"no_tray": "Desabilitar ícone na bandeja do sistema"
|
||||
"no_tray": "Desabilitar ícone na bandeja do sistema",
|
||||
"tls_cert": "Caminho para um certificado TLS (PEM) para servir HTTPS (também OMNIROUTE_TLS_CERT)",
|
||||
"tls_key": "Caminho para a chave privada TLS (PEM) para servir HTTPS (também OMNIROUTE_TLS_KEY)"
|
||||
},
|
||||
"backup": {
|
||||
"title": "Backup",
|
||||
|
||||
1
changelog.d/features/10556-elevenlabs-native-routes.md
Normal file
@@ -0,0 +1 @@
|
||||
- **feat(audio):** proxy native ElevenLabs voices, text-to-speech, and speech-to-text HTTP routes through stored OmniRoute credentials, preserving query strings, multipart uploads, binary responses, and upstream errors (#10556).
|
||||
1
changelog.d/features/10590-google-ai-studio-tts.md
Normal file
@@ -0,0 +1 @@
|
||||
- Added Google AI Studio Gemini batch text-to-speech support through `POST /v1/audio/speech`.
|
||||
3
changelog.d/features/11023-compression-worker-pool.md
Normal file
@@ -0,0 +1,3 @@
|
||||
- Run synchronous RTK and Caveman request compression in a bounded worker-thread pool, keeping
|
||||
large `/v1/responses` compression heaps outside the HTTP isolate while preserving strict
|
||||
fail-open behavior and per-engine telemetry.
|
||||
@@ -0,0 +1 @@
|
||||
- **feat(video bridge):** harden the optional drill-down cache substrate with exact-path broker policy, canonical principal/session/media isolation, independent retained-byte quotas, cancellation-safe commits, rejection of excess or non-canonical Base64 padding and non-JPEG/truncated media, warning-sensitive full JPEG canonicalization that strips trailing polyglot bytes, server-derived dimensions, and auditable derivation metadata; production tenant binding and multi-resolution selection remain follow-up work ([#11369](https://github.com/diegosouzapw/OmniRoute/pull/11369))
|
||||
1
changelog.d/features/11383-video-bridge-focused-mode.md
Normal file
@@ -0,0 +1 @@
|
||||
- **feat(video):** add an opt-in focused analysis mode that safely uses a normalized, 500-code-point latest-user hint for task-aware frame captions while preserving full-mode prompts, temporal-window isolation, and cache identity without storing raw task text ([#11383](https://github.com/diegosouzapw/OmniRoute/pull/11383)).
|
||||
1
changelog.d/features/6342-cliproxy-account-health.md
Normal file
@@ -0,0 +1 @@
|
||||
- feat(services): show sanitized CLIProxyAPI account health from its authenticated management API without exposing credentials, file paths, or raw account metadata (#6342)
|
||||
1
changelog.d/fixes/10352-github-access-token-health.md
Normal file
@@ -0,0 +1 @@
|
||||
- **fix(github):** proactive credential health now verifies GitHub access tokens through the existing Copilot token exchange, marks only a confirmed `401 Unauthorized` as expired, and leaves rate limits, permission failures, upstream failures, and network errors routable ([#10352](https://github.com/diegosouzapw/OmniRoute/issues/10352)) — thanks @RaviTharuma
|
||||
1
changelog.d/fixes/10851-openapi-spec-auth-contract.md
Normal file
@@ -0,0 +1 @@
|
||||
- Document the conditional management authentication and 401/403 responses for `GET /api/openapi/spec`.
|
||||
1
changelog.d/fixes/11297-opencode-subagent-sessionid.md
Normal file
@@ -0,0 +1 @@
|
||||
- **fix(translator):** preserve omitted OpenCode `subagent.sessionID` values — optional default-less plain strings now use the Responses `null = omit` sentinel and are stripped before the client sees the tool call, so Codex/Responses no longer invent filler session IDs ([#11297](https://github.com/diegosouzapw/OmniRoute/pull/11297)) — thanks @ofonseca-pyming
|
||||
@@ -0,0 +1 @@
|
||||
- **fix(db):** group model patterns escape regex metacharacters, so `gpt-4.1*` no longer matches `gpt-4o1-preview` and a pattern like `gpt-4(*` no longer throws `SyntaxError` out of the completion and `/v1/models` paths ([#11311](https://github.com/diegosouzapw/OmniRoute/pull/11311))
|
||||
1
changelog.d/fixes/11319-upstream-proxy-host-spelling.md
Normal file
@@ -0,0 +1 @@
|
||||
- **fix(db):** the upstream proxy URL check judges the host by address instead of by spelling, so `http://[::ffff:169.254.169.254]`, `[::ffff:10.0.0.5]`, ULA/link-local and CGNAT targets are refused like their dotted equivalents ([#11319](https://github.com/diegosouzapw/OmniRoute/pull/11319))
|
||||
1
changelog.d/fixes/11325-i18n-pt-placeholder-parity.md
Normal file
@@ -0,0 +1 @@
|
||||
- **fix(i18n):** three `pt` strings had dropped their placeholders — the cache tile's subtitle repeated its own label instead of showing `{total}` — and a unit test now enforces placeholder parity with `en` across all locales ([#11325](https://github.com/diegosouzapw/OmniRoute/pull/11325))
|
||||
1
changelog.d/fixes/11326-kie-market-google-imagen-ids.md
Normal file
@@ -0,0 +1 @@
|
||||
- **fix(kie):** map the remaining `google-imagen/*` KIE Market catalog ids (`nano-banana`, `nano-banana-pro`, `nano-banana-edit`) to their real, KIE-documented upstream `model` values — `#11225`'s fix only covered `nano-banana-2` ([#11326](https://github.com/diegosouzapw/OmniRoute/pull/11326)).
|
||||
1
changelog.d/fixes/11328-upstream-headers-proxy-auth.md
Normal file
@@ -0,0 +1 @@
|
||||
- **fix(security):** `proxy-authorization` and `proxy-authenticate` are refused as upstream/custom headers, so a proxy credential is no longer forwarded to the model provider — the canonical denylist now matches the RFC 7230 §6.1 set the rest of the codebase already strips ([#11328](https://github.com/diegosouzapw/OmniRoute/pull/11328))
|
||||
@@ -0,0 +1 @@
|
||||
- **fix(video-bridge):** fall back to the deterministic active-window midpoint when a one-frame scene-aware budget cannot preserve both timeline ends; a real FFmpeg fixture matrix now covers rapid cuts, gradual changes, static and short clips, and detector failure ([#11344](https://github.com/diegosouzapw/OmniRoute/pull/11344)).
|
||||
@@ -0,0 +1 @@
|
||||
- **fix(video-bridge):** burn high-contrast timestamps into every bounded contact-sheet cell and add a real-model A/B harness whose promotion verdict stays `HOLD` until token, latency, and quality evidence is actually executed ([#11350](https://github.com/diegosouzapw/OmniRoute/pull/11350))
|
||||
1
changelog.d/fixes/11362-video-bridge-result-cache.md
Normal file
@@ -0,0 +1 @@
|
||||
- **fix(video):** fingerprint protected Video Bridge bytes, coalesce concurrent work, and fail open when the bounded TTL/LRU result cache is unavailable or corrupt ([#11362](https://github.com/diegosouzapw/OmniRoute/pull/11362))
|
||||
1
changelog.d/fixes/11367-catalog-eventloop-9147.md
Normal file
@@ -0,0 +1 @@
|
||||
- **fix(catalog):** keep large `/v1/models` builds responsive by reusing the build-local capability snapshot throughout enrichment and Auto-Combo preparation, yielding cooperatively while constructing virtual candidate pools, and avoiding unrelated synchronous database diagnostics on the cache-TTL read path ([#11367](https://github.com/diegosouzapw/OmniRoute/pull/11367))
|
||||
1
changelog.d/fixes/11382-video-bridge-dedup-policy.md
Normal file
@@ -0,0 +1 @@
|
||||
- **fix(video):** apply the caption-frame cap after bounded visual deduplication, preserve first/final candidates plus small high-contrast motion and text changes, and version the dedup policy in result-cache identity ([#11382](https://github.com/diegosouzapw/OmniRoute/pull/11382)).
|
||||
1
changelog.d/maintenance/11018-database-cache-docs.md
Normal file
@@ -0,0 +1 @@
|
||||
- **docs(database):** align the SQLite cache guide with the 65,536 KiB runtime default, supported 1–1,000,000 KiB range, and live Settings application behavior ([#11018](https://github.com/diegosouzapw/OmniRoute/issues/11018))
|
||||
@@ -0,0 +1,3 @@
|
||||
- **fix(deps):** prevent pnpm from auto-installing the unused `@lobehub/ui` peer subtree of
|
||||
`@lobehub/icons`, keeping six unneeded packages with incompatible or unverifiable license
|
||||
metadata out of production installs ([#11342](https://github.com/diegosouzapw/OmniRoute/pull/11342)).
|
||||
@@ -0,0 +1 @@
|
||||
- **ci(changelog):** replace the broad removal bypass with an exact, hash-bound reconciliation ledger and bind merge-train checks to their requested release base ([#11345](https://github.com/diegosouzapw/OmniRoute/pull/11345)).
|
||||
5
changelog.d/maintenance/11356-readme-live-metrics.md
Normal file
@@ -0,0 +1,5 @@
|
||||
- **docs(readme):** reconcile live v3.8.50 provider, free-tier, CLI, routing, test,
|
||||
community, sponsor, acknowledgment, and SVG metrics with their audited source
|
||||
denominators, including a deduplicated OmniRoute-in-Action snapshot and distinct
|
||||
contributor rankings for merged pull requests, GitHub-attributed commits, and Git history
|
||||
([#11356](https://github.com/diegosouzapw/OmniRoute/pull/11356)).
|
||||
@@ -0,0 +1 @@
|
||||
- **docs(openapi):** document the conditionally management-authenticated, same-origin `POST /api/openapi/try` proxy contract and restore the release branch's operation-coverage ratchet ([#11363](https://github.com/diegosouzapw/OmniRoute/pull/11363))
|
||||
@@ -0,0 +1 @@
|
||||
- **fix(video-bridge):** make opt-in segment-aware sampling use one bounded structural FFmpeg pass (scene, freeze, blur, exposure, and SI/TI), preserve long trailing segments, fail open to uniform sampling, and add real-media structural-oracle, overhead, post-dedup caption-call, and false-positive evidence while holding unconfigured model quality and gain-versus-cost claims ([#11381](https://github.com/diegosouzapw/OmniRoute/pull/11381)).
|
||||
@@ -3445,7 +3445,7 @@
|
||||
},
|
||||
"tests/integration/qdrant-routes.test.ts": {
|
||||
"@typescript-eslint/no-explicit-any": {
|
||||
"count": 19
|
||||
"count": 3
|
||||
}
|
||||
},
|
||||
"tests/integration/quota-pools-usage.test.ts": {
|
||||
@@ -4029,10 +4029,10 @@
|
||||
},
|
||||
"tests/unit/cli-combo-suggest-commands.test.ts": {
|
||||
"@typescript-eslint/no-explicit-any": {
|
||||
"count": 16
|
||||
"count": 14
|
||||
},
|
||||
"@typescript-eslint/no-unused-vars": {
|
||||
"count": 2
|
||||
"count": 1
|
||||
}
|
||||
},
|
||||
"tests/unit/cli-completion-dynamic.test.ts": {
|
||||
@@ -4042,7 +4042,7 @@
|
||||
},
|
||||
"tests/unit/cli-compression-commands.test.ts": {
|
||||
"@typescript-eslint/no-explicit-any": {
|
||||
"count": 32
|
||||
"count": 20
|
||||
}
|
||||
},
|
||||
"tests/unit/cli-context-eng-commands.test.ts": {
|
||||
@@ -4099,7 +4099,7 @@
|
||||
},
|
||||
"tests/unit/cli-mcp-call-commands.test.ts": {
|
||||
"@typescript-eslint/no-explicit-any": {
|
||||
"count": 16
|
||||
"count": 10
|
||||
}
|
||||
},
|
||||
"tests/unit/cli-memory-commands.test.ts": {
|
||||
@@ -4130,7 +4130,7 @@
|
||||
},
|
||||
"tests/unit/cli-oneproxy-commands.test.ts": {
|
||||
"@typescript-eslint/no-explicit-any": {
|
||||
"count": 22
|
||||
"count": 14
|
||||
},
|
||||
"@typescript-eslint/no-unused-vars": {
|
||||
"count": 1
|
||||
@@ -4203,9 +4203,6 @@
|
||||
"tests/unit/cli-resilience-commands.test.ts": {
|
||||
"@typescript-eslint/no-explicit-any": {
|
||||
"count": 16
|
||||
},
|
||||
"@typescript-eslint/no-unused-vars": {
|
||||
"count": 2
|
||||
}
|
||||
},
|
||||
"tests/unit/cli-runtime-extended.test.ts": {
|
||||
@@ -4238,7 +4235,7 @@
|
||||
},
|
||||
"tests/unit/cli-skills-commands.test.ts": {
|
||||
"@typescript-eslint/no-explicit-any": {
|
||||
"count": 22
|
||||
"count": 16
|
||||
}
|
||||
},
|
||||
"tests/unit/cli-stop-supervisor-respawn-9455.test.ts": {
|
||||
@@ -6620,4 +6617,4 @@
|
||||
"count": 2
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
4
config/release/changelog-reconciliations.json
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"schemaVersion": 1,
|
||||
"reconciliations": []
|
||||
}
|
||||
@@ -16,7 +16,7 @@ Mermaid sources (`.mmd`) and exported SVGs for OmniRoute v3.8.0 architecture flo
|
||||
| [auto-combo-12factor.mmd](./auto-combo-12factor.mmd) | [SVG](./exported/auto-combo-12factor.svg) | docs/routing/AUTO-COMBO.md |
|
||||
| [resilience-3layers.mmd](./resilience-3layers.mmd) | [SVG](./exported/resilience-3layers.svg) | docs/architecture/RESILIENCE_GUIDE.md, CLAUDE.md |
|
||||
| [i18n-flow.mmd](./i18n-flow.mmd) | [SVG](./exported/i18n-flow.svg) | docs/guides/I18N.md |
|
||||
| [mcp-tools-107.mmd](./mcp-tools-107.mmd) | [SVG](./exported/mcp-tools-107.svg) | docs/frameworks/MCP-SERVER.md |
|
||||
| [mcp-tools-107.mmd](./mcp-tools-107.mmd) | [SVG](./exported/mcp-tools-107.svg) | docs/frameworks/MCP-SERVER.md |
|
||||
| [cloud-agent-flow.mmd](./cloud-agent-flow.mmd) | [SVG](./exported/cloud-agent-flow.svg) | docs/frameworks/CLOUD_AGENT.md |
|
||||
| [authz-pipeline.mmd](./authz-pipeline.mmd) | [SVG](./exported/authz-pipeline.svg) | docs/architecture/AUTHZ_GUIDE.md |
|
||||
| [db-schema-overview.mmd](./db-schema-overview.mmd) | [SVG](./exported/db-schema-overview.svg) | docs/architecture/CODEBASE_DOCUMENTATION.md |
|
||||
@@ -34,11 +34,11 @@ inside GitHub's `<img>` sandbox:
|
||||
| [combo-always-on.svg](./combo-always-on.svg) | style reference | Animated priority-combo fallback (4 layers, 16s loop). Edit the SVG directly — there is no `.mmd` source. |
|
||||
| [cli-terminal.svg](./cli-terminal.svg) | README.md (root) | Compact half-height animated terminal (1200×350): 3 real CLI commands cycling with typewriter + scrolling subcommand ticker; first frame = completed providers screen. Edit the SVG directly — there is no `.mmd` source. |
|
||||
| [compression-pipeline.svg](./compression-pipeline.svg) | README.md (root) | Animated 10-engine compression funnel (8s loop). Edit the SVG directly — there is no `.mmd` source. |
|
||||
| [free-tier-budget.svg](./free-tier-budget.svg) | README.md (root) | Animated free-tier budget card (~1.53B/mo quantified headline, 19-pool budget bar, per-model grid, signup credits, 10s loop). Edit the SVG directly — there is no `.mmd` source. |
|
||||
| [readme-hero.svg](./readme-hero.svg) | README.md (root) | Animated hero card (tagline, live provider/free-access headline, full-width compression bar demo, 6 stat chips). Edit the SVG directly — there is no `.mmd` source. |
|
||||
| [free-tier-budget.svg](./free-tier-budget.svg) | README.md (root) | Animated free-tier budget card (~1.51B/mo quantified headline, 20-pool budget bar, per-pool grid, signup credits, 10s loop). Edit the SVG directly — there is no `.mmd` source. |
|
||||
| [readme-hero.svg](./readme-hero.svg) | README.md (root) | Animated hero card (tagline, live provider/free-access headline, full-width compression bar demo, 6 stat chips). Edit the SVG directly — there is no `.mmd` source. |
|
||||
| [promise-pillars.svg](./promise-pillars.svg) | README.md (root) | Animated "The Promise" 6-pillar card (12s border-highlight sweep). Edit the SVG directly — there is no `.mmd` source. |
|
||||
| [why-pain-fix.svg](./why-pain-fix.svg) | README.md (root) | Animated "Why OmniRoute" 10-row pain-vs-fix ledger (15s green row sweep). Edit the SVG directly — there is no `.mmd` source. |
|
||||
| [strategies-grid.svg](./strategies-grid.svg) | README.md (root) | Animated grid illustrating 18 of the 19 routing strategies; `cache-optimized` remains documented in the adjacent table. Edit the SVG directly — there is no `.mmd` source. |
|
||||
| [strategies-grid.svg](./strategies-grid.svg) | README.md (root) | Animated grid illustrating 18 of the 19 routing strategies; `cache-optimized` remains documented in the adjacent table. Edit the SVG directly — there is no `.mmd` source. |
|
||||
| [privacy-local.svg](./privacy-local.svg) | README.md (root) | Animated "Private & Local-First" 11-row guarantee ledger with receipt chips (16s green row sweep). Edit the SVG directly — there is no `.mmd` source. |
|
||||
| [resilience-layers.svg](./resilience-layers.svg) | README.md (root) | Animated 3-layer resilience card (breaker states CLOSED→OPEN→HALF-OPEN, key cooldown with ×2 backoff, model lockout — 18s loops). Edit the SVG directly — there is no `.mmd` source. |
|
||||
|
||||
|
||||
@@ -1,24 +1,28 @@
|
||||
%% Auto-Combo 13-factor scoring
|
||||
%% Auto-Combo 15-factor scoring
|
||||
%% Reflects: open-sse/services/autoCombo/scoring.ts (DEFAULT_WEIGHTS, sum = 1.0)
|
||||
%% v3.8.49
|
||||
%% v3.8.50
|
||||
%% svg-title: OmniRoute Auto-Combo 15-factor scoring
|
||||
%% svg-description: Flow from an incoming request through eligible candidates, the 15 weighted scoring factors, descending score sort, top-N selection, and sequential dispatch.
|
||||
flowchart TB
|
||||
Request["Incoming request"] --> Candidates["Eligible candidates<br/>(provider × model × account)"]
|
||||
Candidates --> Score["Compute composite score<br/>per candidate"]
|
||||
|
||||
subgraph Factors["13-factor scoring weights (sum = 1.0)"]
|
||||
f1["health (0.20)"]
|
||||
f2["quota (0.15)"]
|
||||
f3["costInv (0.15)"]
|
||||
f4["latencyInv (0.12)"]
|
||||
f5["taskFit (0.08)"]
|
||||
f6["stability (0.05)"]
|
||||
f7["tierPriority (0.05)"]
|
||||
f8["tierAffinity (0.05)"]
|
||||
f9["specificityMatch (0.05)"]
|
||||
f10["contextAffinity (0.05)"]
|
||||
f11["connectionDensity (0.05)"]
|
||||
f12["cacheAffinity (0.00)"]
|
||||
f13["resetWindowAffinity (0.00)"]
|
||||
subgraph Factors["15-factor scoring weights (sum = 1.0)"]
|
||||
f1["quota (0.1429)"]
|
||||
f2["health (0.1605)"]
|
||||
f3["costInv (0.1429)"]
|
||||
f4["latencyInv (0.1143)"]
|
||||
f5["taskFit (0.0762)"]
|
||||
f6["stability (0.0476)"]
|
||||
f7["tierPriority (0.0476)"]
|
||||
f8["tierAffinity (0.0476)"]
|
||||
f9["specificityMatch (0.0476)"]
|
||||
f10["contextAffinity (0.0476)"]
|
||||
f11["cacheAffinity (0.0000)"]
|
||||
f12["sessionAvailability (0.0476)"]
|
||||
f13["resetWindowAffinity (0.0000)"]
|
||||
f14["connectionDensity (0.0476)"]
|
||||
f15["quality (0.0300)"]
|
||||
end
|
||||
|
||||
Score --> Factors
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
<svg viewBox="0 0 1200 350" xmlns="http://www.w3.org/2000/svg" role="img" aria-label="Animated terminal demoing the OmniRoute CLI: omniroute providers list (350 providers registered, anthropic, codex, glm, kimi shown active), omniroute combo list (always-on priority, cost-saver, fusion-panel, context-relay) and omniroute health (healthy, 18412 requests in 24h, p95 412ms, circuit breakers 24 closed, 1 half-open, 0 open), cycling over the 80+ command surface: providers, oauth, keys, combo, nodes, models, cache, compression, cost, usage, quota, health, resilience, telemetry, logs, audit, mcp, a2a, cloud, memory, skills, eval, doctor, repl, tunnel, backup, sync, webhooks, policy, pricing, translator, simulate and more.">
|
||||
<svg viewBox="0 0 1200 350" xmlns="http://www.w3.org/2000/svg" role="img" aria-label="Animated terminal demoing the OmniRoute CLI: omniroute providers list (350 providers registered, anthropic, codex, glm, kimi shown active), omniroute combo list (always-on priority, cost-saver, fusion-panel, context-relay) and omniroute health (healthy, 18412 requests in 24h, p95 412ms, circuit breakers 24 closed, 1 half-open, 0 open), cycling over 85 top-level commands: providers, oauth, keys, combo, nodes, models, cache, compression, cost, usage, quota, health, resilience, telemetry, logs, audit, mcp, a2a, cloud, memory, skills, eval, doctor, repl, tunnel, backup, sync, webhooks, policy, pricing, translator, simulate and more.">
|
||||
<desc>Compact animated terminal cycling three real OmniRoute CLI commands with a typewriter effect and a scrolling subcommand ticker; the first frame shows the completed providers-list screen.</desc>
|
||||
<defs><clipPath id="tickerClip"><rect x="12" y="304" width="1176" height="40"/></clipPath><clipPath id="tw0"><rect x="64" y="46" height="26" width="0"><animate attributeName="width" calcMode="discrete" values="0;31;61;92;122;153;184;214;245;245" keyTimes="0;0.012;0.018;0.024;0.030;0.036;0.042;0.048;0.054;1" dur="18s" repeatCount="indefinite"/></rect></clipPath><clipPath id="tw1"><rect x="64" y="46" height="26" width="0"><animate attributeName="width" calcMode="discrete" values="0;26;51;76;102;128;153;178;204;204" keyTimes="0;0.348;0.351;0.357;0.363;0.369;0.375;0.381;0.387;1" dur="18s" repeatCount="indefinite"/></rect></clipPath><clipPath id="tw2"><rect x="64" y="46" height="26" width="0"><animate attributeName="width" calcMode="discrete" values="0;20;41;61;82;102;122;143;163;163" keyTimes="0;0.678;0.684;0.690;0.696;0.702;0.708;0.714;0.720;1" dur="18s" repeatCount="indefinite"/></rect></clipPath></defs>
|
||||
<rect width="1200" height="350" fill="#0d1117"/>
|
||||
<rect x="0" y="0" width="1200" height="34" fill="#161b22"/>
|
||||
<path d="M 0 34 L 1200 34" stroke="#ffffff" stroke-opacity="0.08" stroke-width="1"/>
|
||||
<circle cx="24" cy="17" r="6" fill="#ff5f56"/><circle cx="46" cy="17" r="6" fill="#ffbd2e"/><circle cx="68" cy="17" r="6" fill="#27c93f"/>
|
||||
<text x="600" y="22" text-anchor="middle" font-family="Consolas, 'Courier New', monospace" font-size="13" fill="#71717a">omniroute — 80+ commands</text>
|
||||
<g font-family="Consolas, 'Courier New', monospace" font-size="17"><animate attributeName="opacity" values="1;0;0" keyTimes="0;0.006;1" dur="18s" repeatCount="indefinite"/><text x="64" y="66" fill="#F7F6FC">omniroute providers list</text><text x="40" y="100" font-weight="700" fill="#38bdf8">OmniRoute Providers</text><text x="40" y="128" fill="#a1a1aa">1f3a9c2e  anthropic   Claude Max 20x    <tspan fill='#22c55e'>active</tspan></text><text x="40" y="154" fill="#a1a1aa">8c2d5b1a  codex       Codex Pro (team)  <tspan fill='#22c55e'>active</tspan></text><text x="40" y="180" fill="#a1a1aa">f4e0a97b  glm         GLM Coding Plan   <tspan fill='#22c55e'>active</tspan></text><text x="40" y="206" fill="#a1a1aa">03bd6e5f  kimi        Kimi K2 free      <tspan fill='#22c55e'>active</tspan></text><text x="40" y="232" fill="#71717a">… 334 more providers</text></g><g opacity="1" font-family="Consolas, 'Courier New', monospace" font-size="17">
|
||||
<text x="600" y="22" text-anchor="middle" font-family="Consolas, 'Courier New', monospace" font-size="13" fill="#71717a">omniroute — 85 top-level commands</text>
|
||||
<g font-family="Consolas, 'Courier New', monospace" font-size="17"><animate attributeName="opacity" values="1;0;0" keyTimes="0;0.006;1" dur="18s" repeatCount="indefinite"/><text x="64" y="66" fill="#F7F6FC">omniroute providers list</text><text x="40" y="100" font-weight="700" fill="#38bdf8">OmniRoute Providers</text><text x="40" y="128" fill="#a1a1aa">1f3a9c2e  anthropic   Claude Max 20x    <tspan fill='#22c55e'>active</tspan></text><text x="40" y="154" fill="#a1a1aa">8c2d5b1a  codex       Codex Pro (team)  <tspan fill='#22c55e'>active</tspan></text><text x="40" y="180" fill="#a1a1aa">f4e0a97b  glm         GLM Coding Plan   <tspan fill='#22c55e'>active</tspan></text><text x="40" y="206" fill="#a1a1aa">03bd6e5f  kimi        Kimi K2 free      <tspan fill='#22c55e'>active</tspan></text><text x="40" y="232" fill="#71717a">… 346 more providers</text></g><g opacity="1" font-family="Consolas, 'Courier New', monospace" font-size="17">
|
||||
<animate attributeName="opacity" values="1;1;0;0" keyTimes="0;0.315;0.33;1" dur="18s" repeatCount="indefinite"/>
|
||||
<text x="40" y="66" fill="#22c55e">$</text>
|
||||
<g clip-path="url(#tw0)"><text x="64" y="66" fill="#F7F6FC">omniroute providers list</text></g>
|
||||
@@ -14,7 +14,7 @@
|
||||
<animate attributeName="x" calcMode="discrete" values="64;95;125;156;186;217;248;278;309;309" keyTimes="0.000;0.012;0.018;0.024;0.030;0.036;0.042;0.048;0.054;1" dur="18s" repeatCount="indefinite"/>
|
||||
<animate attributeName="opacity" values="0;0;1;0.2;1;0.2;1;0;0" keyTimes="0;0.011;0.012;0.022;0.032;0.042;0.052;0.074;1" dur="18s" repeatCount="indefinite"/>
|
||||
</rect>
|
||||
<text x="40" y="100" font-weight="700" fill="#38bdf8" opacity="0"><animate attributeName="opacity" calcMode="discrete" values="0;0;1" keyTimes="0;0.045;0.047" dur="18s" repeatCount="indefinite"/>OmniRoute Providers</text><text x="40" y="128" fill="#a1a1aa" opacity="0"><animate attributeName="opacity" calcMode="discrete" values="0;0;1" keyTimes="0;0.053;0.055" dur="18s" repeatCount="indefinite"/>1f3a9c2e  anthropic   Claude Max 20x    <tspan fill='#22c55e'>active</tspan></text><text x="40" y="154" fill="#a1a1aa" opacity="0"><animate attributeName="opacity" calcMode="discrete" values="0;0;1" keyTimes="0;0.061;0.063" dur="18s" repeatCount="indefinite"/>8c2d5b1a  codex       Codex Pro (team)  <tspan fill='#22c55e'>active</tspan></text><text x="40" y="180" fill="#a1a1aa" opacity="0"><animate attributeName="opacity" calcMode="discrete" values="0;0;1" keyTimes="0;0.069;0.07100000000000001" dur="18s" repeatCount="indefinite"/>f4e0a97b  glm         GLM Coding Plan   <tspan fill='#22c55e'>active</tspan></text><text x="40" y="206" fill="#a1a1aa" opacity="0"><animate attributeName="opacity" calcMode="discrete" values="0;0;1" keyTimes="0;0.077;0.079" dur="18s" repeatCount="indefinite"/>03bd6e5f  kimi        Kimi K2 free      <tspan fill='#22c55e'>active</tspan></text><text x="40" y="232" fill="#71717a" opacity="0"><animate attributeName="opacity" calcMode="discrete" values="0;0;1" keyTimes="0;0.085;0.08700000000000001" dur="18s" repeatCount="indefinite"/>… 334 more providers</text>
|
||||
<text x="40" y="100" font-weight="700" fill="#38bdf8" opacity="0"><animate attributeName="opacity" calcMode="discrete" values="0;0;1" keyTimes="0;0.045;0.047" dur="18s" repeatCount="indefinite"/>OmniRoute Providers</text><text x="40" y="128" fill="#a1a1aa" opacity="0"><animate attributeName="opacity" calcMode="discrete" values="0;0;1" keyTimes="0;0.053;0.055" dur="18s" repeatCount="indefinite"/>1f3a9c2e  anthropic   Claude Max 20x    <tspan fill='#22c55e'>active</tspan></text><text x="40" y="154" fill="#a1a1aa" opacity="0"><animate attributeName="opacity" calcMode="discrete" values="0;0;1" keyTimes="0;0.061;0.063" dur="18s" repeatCount="indefinite"/>8c2d5b1a  codex       Codex Pro (team)  <tspan fill='#22c55e'>active</tspan></text><text x="40" y="180" fill="#a1a1aa" opacity="0"><animate attributeName="opacity" calcMode="discrete" values="0;0;1" keyTimes="0;0.069;0.07100000000000001" dur="18s" repeatCount="indefinite"/>f4e0a97b  glm         GLM Coding Plan   <tspan fill='#22c55e'>active</tspan></text><text x="40" y="206" fill="#a1a1aa" opacity="0"><animate attributeName="opacity" calcMode="discrete" values="0;0;1" keyTimes="0;0.077;0.079" dur="18s" repeatCount="indefinite"/>03bd6e5f  kimi        Kimi K2 free      <tspan fill='#22c55e'>active</tspan></text><text x="40" y="232" fill="#71717a" opacity="0"><animate attributeName="opacity" calcMode="discrete" values="0;0;1" keyTimes="0;0.085;0.08700000000000001" dur="18s" repeatCount="indefinite"/>… 346 more providers</text>
|
||||
</g><g opacity="0" font-family="Consolas, 'Courier New', monospace" font-size="17">
|
||||
<animate attributeName="opacity" values="0;0;1;1;0;0" keyTimes="0;0.333;0.34800000000000003;0.648;0.663;1" dur="18s" repeatCount="indefinite"/>
|
||||
<text x="40" y="66" fill="#22c55e">$</text>
|
||||
@@ -32,11 +32,11 @@
|
||||
<animate attributeName="x" calcMode="discrete" values="64;84;105;125;146;166;186;207;227;227" keyTimes="0;0.678;0.684;0.690;0.696;0.702;0.708;0.714;0.720;1" dur="18s" repeatCount="indefinite"/>
|
||||
<animate attributeName="opacity" values="0;0;1;0.2;1;0.2;1;0;0" keyTimes="0;0.677;0.678;0.688;0.698;0.708;0.718;0.74;1" dur="18s" repeatCount="indefinite"/>
|
||||
</rect>
|
||||
<text x="40" y="100" font-weight="700" fill="#38bdf8" opacity="0"><animate attributeName="opacity" calcMode="discrete" values="0;0;1" keyTimes="0;0.711;0.713" dur="18s" repeatCount="indefinite"/>OmniRoute Health</text><text x="40" y="128" fill="#a1a1aa" opacity="0"><animate attributeName="opacity" calcMode="discrete" values="0;0;1" keyTimes="0;0.719;0.721" dur="18s" repeatCount="indefinite"/>  Status: <tspan fill='#22c55e'>healthy</tspan>   Uptime: 4d 12h 33m</text><text x="40" y="154" fill="#a1a1aa" opacity="0"><animate attributeName="opacity" calcMode="discrete" values="0;0;1" keyTimes="0;0.727;0.729" dur="18s" repeatCount="indefinite"/>  Requests (24h): 18,412   p95: 412ms</text><text x="40" y="180" fill="#a1a1aa" opacity="0"><animate attributeName="opacity" calcMode="discrete" values="0;0;1" keyTimes="0;0.735;0.737" dur="18s" repeatCount="indefinite"/>  Breakers: <tspan fill='#22c55e'>● 24 closed</tspan>  <tspan fill='#f59e0b'>◒ 1 half-open</tspan>  <tspan fill='#ef4444'>○ 0 open</tspan></text><text x="40" y="206" fill="#a1a1aa" opacity="0"><animate attributeName="opacity" calcMode="discrete" values="0;0;1" keyTimes="0;0.743;0.745" dur="18s" repeatCount="indefinite"/>  Providers: 338 registered   90+ free tiers</text><text x="40" y="232" fill="#71717a" opacity="0"><animate attributeName="opacity" calcMode="discrete" values="0;0;1" keyTimes="0;0.751;0.753" dur="18s" repeatCount="indefinite"/>… live: /dashboard · omniroute status</text>
|
||||
<text x="40" y="100" font-weight="700" fill="#38bdf8" opacity="0"><animate attributeName="opacity" calcMode="discrete" values="0;0;1" keyTimes="0;0.711;0.713" dur="18s" repeatCount="indefinite"/>OmniRoute Health</text><text x="40" y="128" fill="#a1a1aa" opacity="0"><animate attributeName="opacity" calcMode="discrete" values="0;0;1" keyTimes="0;0.719;0.721" dur="18s" repeatCount="indefinite"/>  Status: <tspan fill='#22c55e'>healthy</tspan>   Uptime: 4d 12h 33m</text><text x="40" y="154" fill="#a1a1aa" opacity="0"><animate attributeName="opacity" calcMode="discrete" values="0;0;1" keyTimes="0;0.727;0.729" dur="18s" repeatCount="indefinite"/>  Requests (24h): 18,412   p95: 412ms</text><text x="40" y="180" fill="#a1a1aa" opacity="0"><animate attributeName="opacity" calcMode="discrete" values="0;0;1" keyTimes="0;0.735;0.737" dur="18s" repeatCount="indefinite"/>  Breakers: <tspan fill='#22c55e'>● 24 closed</tspan>  <tspan fill='#f59e0b'>◒ 1 half-open</tspan>  <tspan fill='#ef4444'>○ 0 open</tspan></text><text x="40" y="206" fill="#a1a1aa" opacity="0"><animate attributeName="opacity" calcMode="discrete" values="0;0;1" keyTimes="0;0.743;0.745" dur="18s" repeatCount="indefinite"/>  Providers: 350 registered   90+ free tiers</text><text x="40" y="232" fill="#71717a" opacity="0"><animate attributeName="opacity" calcMode="discrete" values="0;0;1" keyTimes="0;0.751;0.753" dur="18s" repeatCount="indefinite"/>… live: /dashboard · omniroute status</text>
|
||||
</g>
|
||||
<path d="M 0 300 L 1200 300" stroke="#ffffff" stroke-opacity="0.08" stroke-width="1"/>
|
||||
<g clip-path="url(#tickerClip)"><g font-family="Consolas, 'Courier New', monospace" font-size="14" fill="#71717a">
|
||||
<animateTransform attributeName="transform" type="translate" from="0 0" to="-2432 0" dur="55s" repeatCount="indefinite"/>
|
||||
<text x="24" y="330"><tspan fill="#8b5cf6">providers</tspan> · oauth · keys · <tspan fill="#8b5cf6">combo</tspan> · nodes · models · cache · <tspan fill="#8b5cf6">compression</tspan> · cost · usage · quota · <tspan fill="#8b5cf6">health</tspan> · resilience · telemetry · logs · audit · <tspan fill="#8b5cf6">mcp</tspan> · a2a · cloud · <tspan fill="#8b5cf6">memory</tspan> · skills · eval · <tspan fill="#8b5cf6">doctor</tspan> · repl · tunnel · backup · sync · webhooks · policy · pricing · translator · simulate …</text><text x="2456" y="330"><tspan fill="#8b5cf6">providers</tspan> · oauth · keys · <tspan fill="#8b5cf6">combo</tspan> · nodes · models · cache · <tspan fill="#8b5cf6">compression</tspan> · cost · usage · quota · <tspan fill="#8b5cf6">health</tspan> · resilience · telemetry · logs · audit · <tspan fill="#8b5cf6">mcp</tspan> · a2a · cloud · <tspan fill="#8b5cf6">memory</tspan> · skills · eval · <tspan fill="#8b5cf6">doctor</tspan> · repl · tunnel · backup · sync · webhooks · policy · pricing · translator · simulate …</text>
|
||||
</g></g>
|
||||
</svg>
|
||||
</svg>
|
||||
|
||||
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
@@ -23,7 +23,7 @@
|
||||
<g font-family="Inter, 'Segoe UI', Arial, Helvetica, system-ui, sans-serif">
|
||||
<g opacity="0"><animate attributeName="opacity" values="0;1" dur="0.4s" begin="0.15s" fill="freeze"/>
|
||||
<text x="44" y="196" font-size="14.5" fill="#c9d1d9">Providers</text>
|
||||
<text x="440" y="196" text-anchor="middle" font-family="Inter, 'Segoe UI', Arial, Helvetica, system-ui, sans-serif" font-size="15" font-weight="800" fill="#7ee787">338</text>
|
||||
<text x="440" y="196" text-anchor="middle" font-family="Inter, 'Segoe UI', Arial, Helvetica, system-ui, sans-serif" font-size="15" font-weight="800" fill="#7ee787">350</text>
|
||||
<text x="604" y="196" text-anchor="middle" font-family="Inter, 'Segoe UI', Arial, Helvetica, system-ui, sans-serif" font-size="13.5" font-weight="600" fill="#8b949e">40+</text>
|
||||
<text x="760" y="196" text-anchor="middle" font-family="Inter, 'Segoe UI', Arial, Helvetica, system-ui, sans-serif" font-size="13.5" font-weight="600" fill="#8b949e">400+*</text>
|
||||
<text x="916" y="196" text-anchor="middle" font-family="Inter, 'Segoe UI', Arial, Helvetica, system-ui, sans-serif" font-size="13.5" font-weight="600" fill="#8b949e">~5</text>
|
||||
@@ -57,7 +57,7 @@
|
||||
</g>
|
||||
<g opacity="0"><animate attributeName="opacity" values="0;1" dur="0.4s" begin="0.51s" fill="freeze"/>
|
||||
<text x="44" y="364" font-size="14.5" fill="#c9d1d9">Built-in MCP server (own tools)</text>
|
||||
<text x="440" y="364" text-anchor="middle" font-family="Inter, 'Segoe UI', Arial, Helvetica, system-ui, sans-serif" font-size="15" font-weight="800" fill="#7ee787">109</text>
|
||||
<text x="440" y="364" text-anchor="middle" font-family="Inter, 'Segoe UI', Arial, Helvetica, system-ui, sans-serif" font-size="15" font-weight="800" fill="#7ee787">110</text>
|
||||
<use href="#no" x="604" y="359"/>
|
||||
<use href="#mid" x="760" y="359"/>
|
||||
<use href="#no" x="916" y="359"/>
|
||||
|
||||
|
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 26 KiB |
@@ -1,4 +1,5 @@
|
||||
<svg viewBox="0 0 1200 842" xmlns="http://www.w3.org/2000/svg" role="img" aria-label="OmniRoute free-tier budget: about 1.51 billion free tokens per month steady, up to about 2.13 billion in your first month with signup credits, aggregated from the documented free tiers of 40 provider pools and 495 models behind one endpoint, live on /dashboard/free-tiers. Honest pool-deduped math: each shared free pool is counted once — counting every rate limit 24/7 would read about 10B, which we don't publish; 15 providers carry a ToS flag so you decide. Budget bar of the 19 countable free pools with per-model breakdown: Mistral Large 3 1B, GPT-4o mini 150M, Gemini 2.5 Flash 60M, GLM 4.7 30M, Llama 3.3 70B 30M, Grok-3 24M, DeepSeek V4 Pro 20M, GPT-4.1 18M, Llama 4 Scout 15M, GPT-4o 7M, MiniMax-M2.7 6M, Arcee Trinity 5M, and more. First month adds one-time signup credits of about 626M (vertex 300M, agentrouter 200M, predibase 25M, together 25M, glm-cn 20M, doubao 15M, ai21 10M, longcat 10M, deepseek 5M, hyperbolic 5M, nscale 5M). Plus the un-countable: permanently-free no-token-cap providers (SiliconFlow, Z.AI GLM-Flash, Kilo, OpenCode Zen, baidu and more) and a $10 OpenRouter top-up unlocking +24M per month, surfaced separately so they never inflate the headline. Live used/remaining and per-model breakdown on the dashboard.">
|
||||
<svg viewBox="0 0 1200 842" xmlns="http://www.w3.org/2000/svg" role="img" aria-label="OmniRoute free-tier budget: about 1.51 billion free tokens per month steady, up to about 2.13 billion in the first month with signup credits. The catalog contains 455 rows, 448 active and 7 discontinued, grouped into 40 recurring pool keys; 20 pools have a published positive monthly token budget and 20 have a zero, uncapped, or keyless budget. Honest pool-deduped math counts each shared free pool once; 15 providers carry a terms-of-service avoid flag. The 20 quantified pools are Mistral 1 billion, LLM7 150 million, Nara 150 million, Gemini 60 million, Cerebras 30 million, Cloudflare AI 30 million, API Airforce 24 million, Ollama Cloud 20 million, Groq 15 million, Bluesminds 7.2 million, SambaNova 6 million, Arcee 4.8 million, Navy 4.5 million, BazaarLink 3.6 million, OpenRouter 1.2 million, Cohere 800 thousand, HuggingChat 500 thousand, Morph 400 thousand, Hugging Face 200 thousand, and Kiro 25 thousand. One-time signup credits add about 626 million. Uncapped providers and the OpenRouter top-up boost are shown separately so they do not inflate the headline. Live usage remains available at /dashboard/free-tiers.">
|
||||
<desc>Pool-deduplicated chart of the 20 recurring free-token pools with positive published budgets, plus signup credits and uncapped providers shown separately.</desc>
|
||||
<defs>
|
||||
<pattern id="gridPaperF" width="32" height="32" patternUnits="userSpaceOnUse">
|
||||
<path d="M 32 0 L 0 0 0 32" fill="none" stroke="#ffffff" stroke-opacity="0.06" stroke-width="1"/>
|
||||
@@ -63,7 +64,7 @@
|
||||
<text x="60" y="228" font-family="Consolas, 'Courier New', monospace" font-size="104" font-weight="800" fill="url(#gradBrandF)">~1.51B</text>
|
||||
<text x="62" y="266" font-family="Consolas, 'Courier New', monospace" font-size="15" letter-spacing="3" font-weight="700" fill="#a1a1aa">FREE TOKENS / MONTH · <tspan fill="#22c55e">STEADY</tspan></text>
|
||||
<text x="62" y="298" font-family="Inter, 'Segoe UI', Arial, Helvetica, system-ui, sans-serif" font-size="16" fill="#F7F6FC">up to <tspan font-weight="800" fill="#22c55e">~2.13B</tspan> in your first month — signup credits</text>
|
||||
<text x="62" y="326" font-family="Consolas, 'Courier New', monospace" font-size="12" fill="#71717a">documented free tiers · <tspan fill="#8b5cf6">40 provider pools</tspan> · <tspan fill="#8b5cf6">495 models</tspan> · one endpoint</text>
|
||||
<text x="62" y="326" font-family="Consolas, 'Courier New', monospace" font-size="12" fill="#71717a">documented free tiers · <tspan fill="#8b5cf6">40 recurring pools</tspan> · <tspan fill="#8b5cf6">455 catalog entries</tspan> · one endpoint</text>
|
||||
|
||||
<!-- ═══ Panel · The honest math ═══ -->
|
||||
<rect x="680" y="84" width="460" height="216" rx="14" fill="#161b22" stroke="#ffffff" stroke-opacity="0.08" stroke-width="1"/>
|
||||
@@ -79,59 +80,61 @@
|
||||
<text x="836" y="244" font-family="Consolas, 'Courier New', monospace" font-size="11.5" fill="#22c55e">counted once ✓</text>
|
||||
<text x="704" y="280" font-family="Consolas, 'Courier New', monospace" font-size="12" fill="#f59e0b"><tspan font-weight="800">15 providers</tspan> ToS-flagged <tspan fill="#71717a">— we flag it · you decide</tspan></text>
|
||||
|
||||
<!-- ═══ Budget bar · 19 countable pools ═══ -->
|
||||
<text x="60" y="356" font-family="Consolas, 'Courier New', monospace" font-size="10.5" letter-spacing="2.5" font-weight="700" fill="#a78bfa">WHERE IT COMES FROM · <tspan fill="#F7F6FC">19 COUNTABLE FREE POOLS</tspan></text>
|
||||
<!-- ═══ Budget bar · 20 quantified recurring pools ═══ -->
|
||||
<text x="60" y="356" font-family="Consolas, 'Courier New', monospace" font-size="10.5" letter-spacing="2.5" font-weight="700" fill="#a78bfa">WHERE IT COMES FROM · <tspan fill="#F7F6FC">20 QUANTIFIED RECURRING POOLS</tspan></text>
|
||||
<g clip-path="url(#barShapeF)">
|
||||
<rect x="60" y="372" width="1080" height="18" fill="#1c2230"/>
|
||||
<g clip-path="url(#barRevF)">
|
||||
<rect x="60.0" y="372" width="662.3" height="18" fill="#6c5ce7"/>
|
||||
<rect x="723.3" y="372" width="106.7" height="18" fill="#00b894"/>
|
||||
<rect x="831.0" y="372" width="47.9" height="18" fill="#0984e3"/>
|
||||
<rect x="879.9" y="372" width="28.3" height="18" fill="#e17055"/>
|
||||
<rect x="909.2" y="372" width="28.3" height="18" fill="#fdcb6e"/>
|
||||
<rect x="938.5" y="372" width="24.4" height="18" fill="#e84393"/>
|
||||
<rect x="963.9" y="372" width="21.8" height="18" fill="#00cec9"/>
|
||||
<rect x="986.7" y="372" width="20.5" height="18" fill="#d63031"/>
|
||||
<rect x="1008.2" y="372" width="18.5" height="18" fill="#a29bfe"/>
|
||||
<rect x="1027.7" y="372" width="13.3" height="18" fill="#55efc4"/>
|
||||
<rect x="1042.0" y="372" width="12.6" height="18" fill="#74b9ff"/>
|
||||
<rect x="1055.6" y="372" width="12.0" height="18" fill="#ffeaa7"/>
|
||||
<rect x="1068.6" y="372" width="11.3" height="18" fill="#fab1a0"/>
|
||||
<rect x="1080.9" y="372" width="9.4" height="18" fill="#81ecec"/>
|
||||
<rect x="1091.3" y="372" width="9.2" height="18" fill="#6c5ce7"/>
|
||||
<rect x="1101.5" y="372" width="9.0" height="18" fill="#00b894"/>
|
||||
<rect x="1111.5" y="372" width="9.0" height="18" fill="#0984e3"/>
|
||||
<rect x="1121.5" y="372" width="8.8" height="18" fill="#e17055"/>
|
||||
<rect x="1131.3" y="372" width="8.7" height="18" fill="#fdcb6e"/>
|
||||
<rect x="60.0" y="372" width="661.4" height="18" fill="#6c5ce7"/>
|
||||
<rect x="722.4" y="372" width="99.2" height="18" fill="#00b894"/>
|
||||
<rect x="822.6" y="372" width="99.2" height="18" fill="#0984e3"/>
|
||||
<rect x="922.9" y="372" width="39.7" height="18" fill="#e17055"/>
|
||||
<rect x="963.5" y="372" width="19.8" height="18" fill="#fdcb6e"/>
|
||||
<rect x="984.4" y="372" width="19.8" height="18" fill="#e84393"/>
|
||||
<rect x="1005.2" y="372" width="15.9" height="18" fill="#00cec9"/>
|
||||
<rect x="1022.1" y="372" width="13.2" height="18" fill="#d63031"/>
|
||||
<rect x="1036.3" y="372" width="9.9" height="18" fill="#a29bfe"/>
|
||||
<rect x="1047.3" y="372" width="7.5" height="18" fill="#55efc4"/>
|
||||
<rect x="1055.8" y="372" width="7.5" height="18" fill="#74b9ff"/>
|
||||
<rect x="1064.3" y="372" width="7.5" height="18" fill="#ffeaa7"/>
|
||||
<rect x="1072.8" y="372" width="7.5" height="18" fill="#fab1a0"/>
|
||||
<rect x="1081.3" y="372" width="7.5" height="18" fill="#81ecec"/>
|
||||
<rect x="1089.9" y="372" width="7.5" height="18" fill="#6c5ce7"/>
|
||||
<rect x="1098.4" y="372" width="7.5" height="18" fill="#00b894"/>
|
||||
<rect x="1106.9" y="372" width="7.5" height="18" fill="#0984e3"/>
|
||||
<rect x="1115.4" y="372" width="7.5" height="18" fill="#e17055"/>
|
||||
<rect x="1124.0" y="372" width="7.5" height="18" fill="#fdcb6e"/>
|
||||
<rect x="1132.5" y="372" width="7.5" height="18" fill="#e84393"/>
|
||||
</g>
|
||||
</g>
|
||||
<circle r="3.2" fill="#F7F6FC">
|
||||
<animateMotion path="M 60,381 L 1140,381" keyPoints="0;0;1;1" keyTimes="0;0.02;0.24;1" calcMode="linear" dur="10s" repeatCount="indefinite"/>
|
||||
<animate attributeName="opacity" values="0;1;1;0;0" keyTimes="0;0.02;0.23;0.26;1" dur="10s" repeatCount="indefinite"/>
|
||||
</circle>
|
||||
<text x="60" y="416" font-family="Consolas, 'Courier New', monospace" font-size="11.5" fill="#71717a">each segment = one free pool · widths floored so every provider shows · honest numbers below</text>
|
||||
<text x="60" y="416" font-family="Consolas, 'Courier New', monospace" font-size="11.5" fill="#71717a">each segment = one recurring pool · widths floored so every pool shows · audited pool budgets below</text>
|
||||
|
||||
<!-- ═══ Per-model grid (19 pools) ═══ -->
|
||||
<!-- ═══ Per-pool grid (20 quantified recurring pools) ═══ -->
|
||||
<g font-family="Consolas, 'Courier New', monospace" font-size="12.5">
|
||||
<circle cx="66" cy="452" r="5" fill="#6c5ce7"/><text x="78" y="456" fill="#c9d1d9">Mistral Large 3 <tspan fill="#71717a">1.00B</tspan></text>
|
||||
<circle cx="346" cy="452" r="5" fill="#00b894"/><text x="358" y="456" fill="#c9d1d9">GPT-4o mini <tspan fill="#71717a">150M</tspan></text>
|
||||
<circle cx="626" cy="452" r="5" fill="#0984e3"/><text x="638" y="456" fill="#c9d1d9">Gemini 2.5 Flash <tspan fill="#71717a">60M</tspan></text>
|
||||
<circle cx="906" cy="452" r="5" fill="#e17055"/><text x="918" y="456" fill="#c9d1d9">GLM 4.7 <tspan fill="#71717a">30M</tspan></text>
|
||||
<circle cx="66" cy="482" r="5" fill="#fdcb6e"/><text x="78" y="486" fill="#c9d1d9">Llama 3.3 70B <tspan fill="#71717a">30M</tspan></text>
|
||||
<circle cx="346" cy="482" r="5" fill="#e84393"/><text x="358" y="486" fill="#c9d1d9">Grok-3 <tspan fill="#71717a">24M</tspan></text>
|
||||
<circle cx="626" cy="482" r="5" fill="#00cec9"/><text x="638" y="486" fill="#c9d1d9">DeepSeek V4 Pro <tspan fill="#71717a">20M</tspan></text>
|
||||
<circle cx="906" cy="482" r="5" fill="#d63031"/><text x="918" y="486" fill="#c9d1d9">GPT-4.1 <tspan fill="#71717a">18M</tspan></text>
|
||||
<circle cx="66" cy="512" r="5" fill="#a29bfe"/><text x="78" y="516" fill="#c9d1d9">Llama 4 Scout <tspan fill="#71717a">15M</tspan></text>
|
||||
<circle cx="346" cy="512" r="5" fill="#55efc4"/><text x="358" y="516" fill="#c9d1d9">GPT-4o <tspan fill="#71717a">7M</tspan></text>
|
||||
<circle cx="626" cy="512" r="5" fill="#74b9ff"/><text x="638" y="516" fill="#c9d1d9">MiniMax-M2.7 <tspan fill="#71717a">6M</tspan></text>
|
||||
<circle cx="906" cy="512" r="5" fill="#ffeaa7"/><text x="918" y="516" fill="#c9d1d9">Arcee Trinity Large Prev <tspan fill="#71717a">5M</tspan></text>
|
||||
<circle cx="66" cy="542" r="5" fill="#fab1a0"/><text x="78" y="546" fill="#c9d1d9">Auto Free <tspan fill="#71717a">4M</tspan></text>
|
||||
<circle cx="346" cy="542" r="5" fill="#81ecec"/><text x="358" y="546" fill="#c9d1d9">Auto <tspan fill="#71717a">1M</tspan></text>
|
||||
<circle cx="626" cy="542" r="5" fill="#6c5ce7"/><text x="638" y="546" fill="#c9d1d9">Command A Reasoning <tspan fill="#71717a">800K</tspan></text>
|
||||
<circle cx="906" cy="542" r="5" fill="#00b894"/><text x="918" y="546" fill="#c9d1d9">ERNIE 4.5 VL 424B <tspan fill="#71717a">500K</tspan></text>
|
||||
<circle cx="66" cy="572" r="5" fill="#0984e3"/><text x="78" y="576" fill="#c9d1d9">morph-v3-large <tspan fill="#71717a">400K</tspan></text>
|
||||
<circle cx="346" cy="572" r="5" fill="#e17055"/><text x="358" y="576" fill="#c9d1d9">Llama 3.1 8B <tspan fill="#71717a">200K</tspan></text>
|
||||
<circle cx="626" cy="572" r="5" fill="#fdcb6e"/><text x="638" y="576" fill="#c9d1d9">Claude Sonnet 4.5 <tspan fill="#71717a">25K</tspan></text>
|
||||
<circle cx="66" cy="452" r="5" fill="#6c5ce7"/><text x="78" y="456" fill="#c9d1d9">Mistral <tspan fill="#71717a">1.00B</tspan></text>
|
||||
<circle cx="346" cy="452" r="5" fill="#00b894"/><text x="358" y="456" fill="#c9d1d9">LLM7 <tspan fill="#71717a">150M</tspan></text>
|
||||
<circle cx="626" cy="452" r="5" fill="#0984e3"/><text x="638" y="456" fill="#c9d1d9">Nara <tspan fill="#71717a">150M</tspan></text>
|
||||
<circle cx="906" cy="452" r="5" fill="#e17055"/><text x="918" y="456" fill="#c9d1d9">Gemini <tspan fill="#71717a">60M</tspan></text>
|
||||
<circle cx="66" cy="482" r="5" fill="#fdcb6e"/><text x="78" y="486" fill="#c9d1d9">Cerebras <tspan fill="#71717a">30M</tspan></text>
|
||||
<circle cx="346" cy="482" r="5" fill="#e84393"/><text x="358" y="486" fill="#c9d1d9">Cloudflare AI <tspan fill="#71717a">30M</tspan></text>
|
||||
<circle cx="626" cy="482" r="5" fill="#00cec9"/><text x="638" y="486" fill="#c9d1d9">API Airforce <tspan fill="#71717a">24M</tspan></text>
|
||||
<circle cx="906" cy="482" r="5" fill="#d63031"/><text x="918" y="486" fill="#c9d1d9">Ollama Cloud <tspan fill="#71717a">20M</tspan></text>
|
||||
<circle cx="66" cy="512" r="5" fill="#a29bfe"/><text x="78" y="516" fill="#c9d1d9">Groq <tspan fill="#71717a">15M</tspan></text>
|
||||
<circle cx="346" cy="512" r="5" fill="#55efc4"/><text x="358" y="516" fill="#c9d1d9">Bluesminds <tspan fill="#71717a">7.2M</tspan></text>
|
||||
<circle cx="626" cy="512" r="5" fill="#74b9ff"/><text x="638" y="516" fill="#c9d1d9">SambaNova <tspan fill="#71717a">6M</tspan></text>
|
||||
<circle cx="906" cy="512" r="5" fill="#ffeaa7"/><text x="918" y="516" fill="#c9d1d9">Arcee <tspan fill="#71717a">4.8M</tspan></text>
|
||||
<circle cx="66" cy="542" r="5" fill="#fab1a0"/><text x="78" y="546" fill="#c9d1d9">Navy <tspan fill="#71717a">4.5M</tspan></text>
|
||||
<circle cx="346" cy="542" r="5" fill="#81ecec"/><text x="358" y="546" fill="#c9d1d9">BazaarLink <tspan fill="#71717a">3.6M</tspan></text>
|
||||
<circle cx="626" cy="542" r="5" fill="#6c5ce7"/><text x="638" y="546" fill="#c9d1d9">OpenRouter <tspan fill="#71717a">1.2M</tspan></text>
|
||||
<circle cx="906" cy="542" r="5" fill="#00b894"/><text x="918" y="546" fill="#c9d1d9">Cohere <tspan fill="#71717a">800K</tspan></text>
|
||||
<circle cx="66" cy="572" r="5" fill="#0984e3"/><text x="78" y="576" fill="#c9d1d9">HuggingChat <tspan fill="#71717a">500K</tspan></text>
|
||||
<circle cx="346" cy="572" r="5" fill="#e17055"/><text x="358" y="576" fill="#c9d1d9">Morph <tspan fill="#71717a">400K</tspan></text>
|
||||
<circle cx="626" cy="572" r="5" fill="#fdcb6e"/><text x="638" y="576" fill="#c9d1d9">Hugging Face <tspan fill="#71717a">200K</tspan></text>
|
||||
<circle cx="906" cy="572" r="5" fill="#e84393"/><text x="918" y="576" fill="#c9d1d9">Kiro <tspan fill="#71717a">25K</tspan></text>
|
||||
</g>
|
||||
|
||||
<!-- ═══ First-month signup credits ═══ -->
|
||||
|
||||
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 18 KiB |
@@ -1,4 +1,4 @@
|
||||
<svg viewBox="0 0 1200 540" xmlns="http://www.w3.org/2000/svg" role="img" aria-label="The OmniRoute promise: one endpoint, 350 providers — never stop building, OmniRoute picks the cheapest one that works. Six pillars. Never hit limits: auto-fallback across 350 providers in milliseconds, quota out means the next provider takes over with zero downtime. Save up to 95 percent of tokens: RTK plus Caveman stacked compression cuts 15 to 95 percent of eligible tokens, about 89 percent average on tool-heavy sessions. Zero dollars to start: 90+ providers with a free tier, 56 free forever — Qoder, Pollinations, Cloudflare, SiliconFlow — no card needed. Every tool works: 33 coding agents including Claude Code, Codex, Cursor, Cline, Copilot and Antigravity through one config. One endpoint: OpenAI, Claude, Gemini and Responses API translation — point any tool at /v1 and it just works. Production-grade: circuit breakers, TLS stealth, MCP with 110 tools, A2A, memory, guardrails, evals — 25,000+ tests.">
|
||||
<svg viewBox="0 0 1200 540" xmlns="http://www.w3.org/2000/svg" role="img" aria-label="The OmniRoute promise: one endpoint and 350 providers. Six pillars. Resilient fallback: automatic routing continues while another healthy target is available. Save up to 95 percent of eligible tokens: RTK plus Caveman stacked compression averages about 89 percent on tool-heavy sessions. Zero dollars to start: 90+ providers with a free tier and 56 recurring or keyless free-forever providers. Every tool works: 35 CLI and agent integration records, including Claude Code, Codex, Cursor, Cline, Copilot and Antigravity, through one config. One endpoint: OpenAI, Claude, Gemini and Responses API translation at /v1. Production controls: circuit breakers, TLS stealth, MCP with 110 tools, A2A, memory, guardrails, evals, and 39,000+ static test declarations across 5,100+ tracked test files.">
|
||||
<desc>Animated promise card: six pillar tiles fade in in reading order, then a soft colored border highlight sweeps from tile to tile in a continuous cycle.</desc>
|
||||
<defs>
|
||||
<pattern id="gridPaperP" width="32" height="32" patternUnits="userSpaceOnUse">
|
||||
@@ -40,7 +40,7 @@
|
||||
<text x="102" y="170" font-size="18" font-weight="800" fill="#74b9ff">Never hit limits</text>
|
||||
<text x="66" y="204" font-size="13.5" fill="#a1a1aa">Auto-fallback across 350 providers in</text>
|
||||
<text x="66" y="226" font-size="13.5" fill="#a1a1aa">milliseconds. Quota out? The next provider</text>
|
||||
<text x="66" y="248" font-size="13.5" fill="#a1a1aa">takes over — zero downtime.</text>
|
||||
<text x="66" y="248" font-size="13.5" fill="#a1a1aa">takes over while a healthy target remains.</text>
|
||||
</g>
|
||||
|
||||
<!-- cell 2: save tokens (orange) -->
|
||||
@@ -91,7 +91,7 @@
|
||||
<path d="M 10,18 L 10,22"/>
|
||||
</g>
|
||||
<text x="102" y="354" font-size="18" font-weight="800" fill="#a78bfa">Every tool works</text>
|
||||
<text x="66" y="388" font-size="13.5" fill="#a1a1aa">33 coding agents — Claude Code, Codex,</text>
|
||||
<text x="66" y="388" font-size="13.5" fill="#a1a1aa">35 CLI/agent integrations — Claude Code, Codex,</text>
|
||||
<text x="66" y="410" font-size="13.5" fill="#a1a1aa">Cursor, Cline, Copilot, Antigravity —</text>
|
||||
<text x="66" y="432" font-size="13.5" fill="#a1a1aa">through one config.</text>
|
||||
</g>
|
||||
@@ -127,7 +127,7 @@
|
||||
<text x="862" y="354" font-size="18" font-weight="800" fill="#7ee787">Production-grade</text>
|
||||
<text x="826" y="388" font-size="13.5" fill="#a1a1aa">Circuit breakers, TLS stealth, MCP (110</text>
|
||||
<text x="826" y="410" font-size="13.5" fill="#a1a1aa">tools), A2A, memory, guardrails, evals —</text>
|
||||
<text x="826" y="432" font-size="13.5" fill="#a1a1aa">25,000+ tests.</text>
|
||||
<text x="826" y="432" font-size="13.5" fill="#a1a1aa">39,000+ static test declarations.</text>
|
||||
</g>
|
||||
</g>
|
||||
|
||||
|
||||
|
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 10 KiB |
@@ -66,7 +66,7 @@
|
||||
<!-- stat chips -->
|
||||
<g font-family="Inter, 'Segoe UI', Arial, Helvetica, system-ui, sans-serif" text-anchor="middle">
|
||||
<rect x="48" y="448" width="172" height="52" rx="12" fill="#161b22" stroke="#6c5ce7" stroke-opacity="0.55" stroke-width="1.5"/>
|
||||
<text x="134" y="471" font-size="17" font-weight="800" fill="#a78bfa">338</text>
|
||||
<text x="134" y="471" font-size="17" font-weight="800" fill="#a78bfa">350</text>
|
||||
<text x="134" y="490" font-size="11" fill="#a1a1aa">AI PROVIDERS</text>
|
||||
<rect x="234" y="448" width="172" height="52" rx="12" fill="#161b22" stroke="#22c55e" stroke-opacity="0.55" stroke-width="1.5"/>
|
||||
<text x="320" y="471" font-size="17" font-weight="800" fill="#7ee787">90+</text>
|
||||
|
||||
|
Before Width: | Height: | Size: 7.3 KiB After Width: | Height: | Size: 7.3 KiB |
|
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 22 KiB |
@@ -95,7 +95,7 @@
|
||||
<rect width="173" height="158" rx="10" fill="#161b22" stroke="#ffffff" stroke-opacity="0.07" stroke-width="1"/>
|
||||
<text x="12" y="21" font-family="Consolas, 'Courier New', monospace" font-size="11" fill="#a78bfa">auto</text>
|
||||
<circle cx="20" cy="79" r="4" fill="none" stroke="#c9d1d9" stroke-width="1.6"/><circle cx="20" cy="79" r="1.6" fill="#c9d1d9"/><path d="M 26,79 C 62,79 84,67.5 112,67.5" fill="none" stroke="#8b5cf6" stroke-opacity="0.55" stroke-width="1.6"/><rect x="116" y="38.0" width="26" height="11" rx="2.5" fill="#1c2330" stroke="#ffffff" stroke-opacity="0.10" stroke-width="1"/><text x="147" y="46.5" font-family="Consolas, 'Courier New', monospace" font-size="8.5" fill="#71717a">72</text><rect x="116" y="62.0" width="26" height="11" rx="2.5" fill="#1c2330" stroke="#7ee787" stroke-opacity="0.8" stroke-width="1"/><text x="147" y="70.5" font-family="Consolas, 'Courier New', monospace" font-size="8.5" fill="#71717a">91</text><rect x="116" y="86.0" width="26" height="11" rx="2.5" fill="#1c2330" stroke="#ffffff" stroke-opacity="0.10" stroke-width="1"/><text x="147" y="94.5" font-family="Consolas, 'Courier New', monospace" font-size="8.5" fill="#71717a">64</text><rect x="116" y="110.0" width="26" height="11" rx="2.5" fill="#1c2330" stroke="#ffffff" stroke-opacity="0.10" stroke-width="1"/><text x="147" y="118.5" font-family="Consolas, 'Courier New', monospace" font-size="8.5" fill="#71717a">55</text><circle r="2.8" fill="#a78bfa" opacity="0"><animateMotion path="M 26,79 C 62,79 84,67.5 110,67.5" begin="3.3s" dur="3.6s" repeatCount="indefinite"/><animate attributeName="opacity" values="0;1;1;0;0" keyTimes="0;0.02;0.3;0.33999999999999997;1" begin="3.3s" dur="3.6s" repeatCount="indefinite"/></circle>
|
||||
<text x="12" y="148" font-family="Inter, 'Segoe UI', Arial, Helvetica, system-ui, sans-serif" font-size="9.5" fill="#71717a">live 13-factor scoring</text>
|
||||
<text x="12" y="148" font-family="Inter, 'Segoe UI', Arial, Helvetica, system-ui, sans-serif" font-size="9.5" fill="#71717a">live 15-factor scoring</text>
|
||||
</g><g transform="translate(796,456)">
|
||||
<rect width="173" height="158" rx="10" fill="#161b22" stroke="#ffffff" stroke-opacity="0.07" stroke-width="1"/>
|
||||
<text x="12" y="21" font-family="Consolas, 'Courier New', monospace" font-size="11" fill="#a78bfa">fusion</text>
|
||||
|
||||
|
Before Width: | Height: | Size: 44 KiB After Width: | Height: | Size: 44 KiB |
@@ -1,6 +1,6 @@
|
||||
# Free Tiers Guide: Understand and Combine Free AI Access
|
||||
|
||||
> **TL;DR**: OmniRoute registers 329 providers, with **155 catalog entries marked free/no-auth**. The stricter audited budget currently covers **43 recurring pools / 522 model budget entries**. Connect several suitable providers for broader fallback capacity; every quota, approval rule, privacy policy, and paid-overage condition still applies.
|
||||
> **TL;DR**: OmniRoute registers 350 provider IDs, with **154 provider-catalog entries marked `hasFree`**. The stricter audited free-model catalog covers **40 recurring pool keys / 455 entries** (448 active + 7 discontinued). Connect several suitable providers for broader fallback capacity; every quota, approval rule, privacy policy, and paid-overage condition still applies.
|
||||
|
||||
---
|
||||
|
||||
@@ -21,38 +21,38 @@ OmniRoute **aggregates** these free tiers into one endpoint. Instead of signing
|
||||
|
||||
These providers have a recurring, keyless, or uncapped free-access path in the audited catalog. “Uncapped” means no published token cap; rate, concurrency, account, regional, and policy limits can still apply:
|
||||
|
||||
| Provider | Models | Quota | How to Connect |
|
||||
|----------|--------|-------|----------------|
|
||||
| **Kiro AI** | Claude Sonnet 4.5, Haiku 4.5, DeepSeek V3.2, and others | Audited catalog estimates a 25K-token shared monthly pool | OAuth/account flow; ToS flagged `avoid` in the catalog |
|
||||
| **OpenCode Free** | Current `*-free` model set in the provider registry | Keyless; no published token cap | No provider credential; ToS flagged `avoid` |
|
||||
| **Pollinations** | Current keyless model set; some former models are discontinued or key-required | Keyless; no published token cap | No provider credential for the keyless models |
|
||||
| **Logfare** | kimi-k3, deepseek-v4-pro, glm-5.2, gpt-5.6-luna, minimax-m3, and more | Free API key (no rate limits, no card); **every request is logged** for research (opt out at logfare.ai/consent) | Instant key at logfare.ai/register; ToS/privacy at logfare.ai/tos and logfare.ai/privacy |
|
||||
| **Cloudflare AI** | Workers AI catalog | Audited pool estimates ~30M tokens/month from published usage units | Cloudflare account and API credentials |
|
||||
| **Gemini** | Gemini Flash family | Audited pool estimates ~60M tokens/month | Google AI Studio API key; rate limits apply |
|
||||
| **Groq** | Llama, GPT-OSS, and Qwen models | Audited pool estimates ~15M tokens/month | Groq API key; rate limits apply |
|
||||
| **Cerebras** | GLM 4.7 and GPT-OSS 120B | Audited pool estimates ~30M tokens/month | Cerebras API key; rate limits apply |
|
||||
| Provider | Models | Quota | How to Connect |
|
||||
| ----------------- | ------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- |
|
||||
| **Kiro AI** | Claude Sonnet 4.5, Haiku 4.5, DeepSeek V3.2, and others | Audited catalog estimates a 25K-token shared monthly pool | OAuth/account flow; ToS flagged `avoid` in the catalog |
|
||||
| **OpenCode Free** | Current `*-free` model set in the provider registry | Keyless; no published token cap | No provider credential; ToS flagged `avoid` |
|
||||
| **Pollinations** | Current keyless model set; some former models are discontinued or key-required | Keyless; no published token cap | No provider credential for the keyless models |
|
||||
| **Logfare** | kimi-k3, deepseek-v4-pro, glm-5.2, gpt-5.6-luna, minimax-m3, and more | Free API key (no rate limits, no card); **every request is logged** for research (opt out at logfare.ai/consent) | Instant key at logfare.ai/register; ToS/privacy at logfare.ai/tos and logfare.ai/privacy |
|
||||
| **Cloudflare AI** | Workers AI catalog | Audited pool estimates ~30M tokens/month from published usage units | Cloudflare account and API credentials |
|
||||
| **Gemini** | Gemini Flash family | Audited pool estimates ~60M tokens/month | Google AI Studio API key; rate limits apply |
|
||||
| **Groq** | Llama, GPT-OSS, and Qwen models | Audited pool estimates ~15M tokens/month | Groq API key; rate limits apply |
|
||||
| **Cerebras** | GLM 4.7 and GPT-OSS 120B | Audited pool estimates ~30M tokens/month | Cerebras API key; rate limits apply |
|
||||
|
||||
### Signup Grants and Provider-Specific Credits
|
||||
|
||||
These providers give you **free credits** when you sign up:
|
||||
|
||||
| Provider | Free Credits | Models | How to Get |
|
||||
|----------|-------------|--------|------------|
|
||||
| **DeepSeek** | 5M free tokens | DeepSeek V4 | Sign up at platform.deepseek.com |
|
||||
| **LongCat** | 10M-token one-time grant | LongCat 2.0 | API key + KYC; pay-as-you-go after the grant |
|
||||
| **Together** | $25 signup credit represented as ~25M tokens in the budget model | Provider catalog | Sign up and verify current terms |
|
||||
| Provider | Free Credits | Models | How to Get |
|
||||
| ------------- | ------------------------------------------------------------------ | ------------------------- | --------------------------------------------------------- |
|
||||
| **DeepSeek** | 5M free tokens | DeepSeek V4 | Sign up at platform.deepseek.com |
|
||||
| **LongCat** | 10M-token one-time grant | LongCat 2.0 | API key + KYC; pay-as-you-go after the grant |
|
||||
| **Together** | $25 signup credit represented as ~25M tokens in the budget model | Provider catalog | Sign up and verify current terms |
|
||||
| **Vertex AI** | $300 signup credit represented as ~300M tokens in the budget model | Gemini and partner models | Google Cloud account; billing and eligibility rules apply |
|
||||
|
||||
### Other Limited Access
|
||||
|
||||
These providers have **free tiers** with specific limits:
|
||||
|
||||
| Provider | Free Limit | Models | Best For |
|
||||
|----------|-----------|--------|----------|
|
||||
| **GitHub Models** | Audited shared pool estimates ~18M tokens/month | Broad model evaluation |
|
||||
| **Hugging Face** | Small recurring monthly pool | Experiments and model variety |
|
||||
| **OpenRouter free models** | Shared request-limited pool; optional one-time top-up increases the recurring allowance | Broad fallback catalog |
|
||||
| **AI Horde** | Keyless community capacity; availability varies | Opportunistic distributed inference |
|
||||
| Provider | Free Limit | Models | Best For |
|
||||
| -------------------------- | --------------------------------------------------------------------------------------- | ----------------------------------- | -------- |
|
||||
| **GitHub Models** | Audited shared pool estimates ~18M tokens/month | Broad model evaluation |
|
||||
| **Hugging Face** | Small recurring monthly pool | Experiments and model variety |
|
||||
| **OpenRouter free models** | Shared request-limited pool; optional one-time top-up increases the recurring allowance | Broad fallback catalog |
|
||||
| **AI Horde** | Keyless community capacity; availability varies | Opportunistic distributed inference |
|
||||
|
||||
---
|
||||
|
||||
@@ -70,6 +70,7 @@ Connect several providers to reduce dependence on any single quota:
|
||||
4. **LongCat** — one-time signup grant (requires KYC)
|
||||
|
||||
Then use `model: "auto"` and OmniRoute will:
|
||||
|
||||
- Try the highest-ranked eligible connection first
|
||||
- If its quota or health check fails → try the next configured provider
|
||||
- If the keyless provider is unavailable → continue through the remaining targets
|
||||
@@ -135,6 +136,7 @@ If one free provider is busy or down, OmniRoute automatically tries the next one
|
||||
### 2. Smart Routing
|
||||
|
||||
OmniRoute picks the **best free provider** for each request based on:
|
||||
|
||||
- Speed — Which provider is fastest right now?
|
||||
- Quality — Which provider is best for this task?
|
||||
- Capacity — Which provider has quota remaining?
|
||||
@@ -157,13 +159,13 @@ provider's quota or access policy.
|
||||
|
||||
The live, pool-deduplicated catalog currently reports:
|
||||
|
||||
| Metric | Current audited value | Interpretation |
|
||||
| --- | ---: | --- |
|
||||
| Recurring quantified grant | **~1.53B tokens/month** | Shared pools counted once; excludes uncapped providers from the sum |
|
||||
| First month with signup grants | **~2.15B tokens** | Recurring total plus one-time and recurring credits |
|
||||
| Quantified inventory | **43 pools / 522 model budget entries** | Budget-model coverage, not the full 329-provider catalog |
|
||||
| Recurring/keyless/uncapped providers represented | **58** | Provider presence in recurring forms of the audited budget catalog |
|
||||
| Free/no-auth discovery entries | **155** | Broader provider metadata; not all have a quantifiable recurring quota |
|
||||
| Metric | Current audited value | Interpretation |
|
||||
| ---------------------------------------------------- | -----------------------------------------------: | ----------------------------------------------------------------------------------------- |
|
||||
| Recurring quantified grant | **~1.51B tokens/month** | Shared pools counted once; excludes uncapped providers from the sum |
|
||||
| First month with signup grants | **~2.13B tokens** | Recurring total plus one-time and recurring credits |
|
||||
| Audited free-model inventory | **40 recurring pool keys / 455 catalog entries** | 448 active + 7 discontinued; distinct from the 350-provider catalog |
|
||||
| Recurring/keyless free-forever providers represented | **56** | Unique providers across recurring daily/monthly/credit/uncapped and keyless catalog types |
|
||||
| Provider catalog entries marked `hasFree` | **154 / 350** | Broader provider metadata; not all have a quantifiable recurring quota |
|
||||
|
||||
These values are computed from `open-sse/config/freeModelCatalog.ts`; see the
|
||||
[Free Tiers Reference](../reference/FREE_TIERS.md) for pool deduplication, ToS flags,
|
||||
|
||||
@@ -219,13 +219,23 @@ docker build --target runner-cli -t omniroute:cli .
|
||||
|
||||
### Build-time resources
|
||||
|
||||
Two build args control what the `builder` stage costs. They are build-time only —
|
||||
Three build args control what the `builder` stage costs. They are build-time only —
|
||||
`OMNIROUTE_MEMORY_MB` (below) is a separate, runtime knob.
|
||||
|
||||
| Build arg | Default | Effect |
|
||||
| --------------------------- | ------- | ---------------------------------------------------------------------- |
|
||||
| `OMNIROUTE_USE_TURBOPACK` | `1` | `0` builds with webpack instead. Lower peak memory, slower. |
|
||||
| `OMNIROUTE_BUILD_MEMORY_MB` | `4096` | V8 heap ceiling (`--max-old-space-size`) for the spawned `next build`. |
|
||||
| Build arg | Default | Effect |
|
||||
| --------------------------- | ------- | ----------------------------------------------------------------------------------- |
|
||||
| `OMNIROUTE_USE_TURBOPACK` | `1` | `0` builds with webpack instead. Lower peak memory, slower. |
|
||||
| `OMNIROUTE_BUILD_MEMORY_MB` | `6144` | V8 heap ceiling (`--max-old-space-size`) for the spawned `next build`. |
|
||||
| `OMNIROUTE_BUILD_WORKERS` | `3` | Feeds `CIRCLE_NODE_TOTAL`; Next derives `workers = N - 1` for page-data collection. |
|
||||
|
||||
`OMNIROUTE_BUILD_WORKERS` is the one to raise on a big builder and the one to
|
||||
suspect when a constrained build dies **after** `✓ Compiled successfully`. Each
|
||||
page-data worker is its own process and inherits `NODE_OPTIONS`, so the heap
|
||||
ceiling is per process, not per build: the default of `3` (→ 2 workers) is sized
|
||||
for the 16 GB / 4 vCPU GitHub-hosted runners the publish pipeline uses. At `8`
|
||||
(→ 7 workers) that runner ran out of memory and buildkit failed the step with
|
||||
`ResourceExhausted: ... cannot allocate memory`. `tests/unit/docker-build-memory-budget.test.ts`
|
||||
does the arithmetic and fails if either knob outgrows the runner.
|
||||
|
||||
Turbopack compiles in native Rust memory that lives **outside** the V8 heap, so
|
||||
`OMNIROUTE_BUILD_MEMORY_MB` does not bound it. On a host with a memory ceiling the
|
||||
@@ -268,12 +278,12 @@ The 1 GiB Docker default is a dashboard/light-chat floor, not a production siz
|
||||
|
||||
Size **cgroup `--memory` above the heap** — native buffers, SQLite, and compression intermediates sit outside V8.
|
||||
|
||||
| Workload | `OMNIROUTE_MEMORY_MB` | Container / cgroup | Notes |
|
||||
| --- | --- | --- | --- |
|
||||
| Dashboard, one light chat | `1024` (image default) | ≥2 GiB | |
|
||||
| One coding agent (Claude/Codex/Grok) | `8192` | ≥10 GiB | Typical single-session `/v1/responses` |
|
||||
| Two concurrent long `/v1/responses` | `10240`–`12288` | ≥12–16 GiB | Measured V8 abort at ~12 GiB heap |
|
||||
| Three+ concurrent long contexts | do not on one process | serialize / more RAM | Default heavyweight admission is 1 in-flight; raising it without RAM reintroduces the abort |
|
||||
| Workload | `OMNIROUTE_MEMORY_MB` | Container / cgroup | Notes |
|
||||
| ------------------------------------ | ---------------------- | -------------------- | ------------------------------------------------------------------------------------------- |
|
||||
| Dashboard, one light chat | `1024` (image default) | ≥2 GiB | |
|
||||
| One coding agent (Claude/Codex/Grok) | `8192` | ≥10 GiB | Typical single-session `/v1/responses` |
|
||||
| Two concurrent long `/v1/responses` | `10240`–`12288` | ≥12–16 GiB | Measured V8 abort at ~12 GiB heap |
|
||||
| Three+ concurrent long contexts | do not on one process | serialize / more RAM | Default heavyweight admission is 1 in-flight; raising it without RAM reintroduces the abort |
|
||||
|
||||
`omniroute serve` on bare metal calibrates ~35% of RAM (clamped `[512, 4096]`) when `OMNIROUTE_MEMORY_MB` is **unset**. Docker always sets `1024`, so that calibration never runs in the official image.
|
||||
|
||||
@@ -287,19 +297,19 @@ docker run -d --name omniroute --restart unless-stopped --stop-timeout 40 \
|
||||
|
||||
Beyond the defaults documented in [ENVIRONMENT.md](../reference/ENVIRONMENT.md), the following variables matter most when running under Docker:
|
||||
|
||||
| Variable | Purpose | Default |
|
||||
| ----------------------------- | --------------------------------------------------------------------------------------------------- | ------------------------ |
|
||||
| `OMNIROUTE_WS_BRIDGE_SECRET` | Shared secret for the WebSocket bridge. **Required in production** — set to a strong random string. | unset (must be provided) |
|
||||
| `REDIS_URL` | Connection string for the rate limiter / cache backend | `redis://redis:6379` |
|
||||
| `REDIS_PORT` | Host-side port for the bundled Redis container | `6379` |
|
||||
| `REDIS_BIND_HOST` | Host interface the bundled Redis port is published on (loopback unless you add AUTH) | `127.0.0.1` |
|
||||
| `AUTO_UPDATE_HOST_REPO_DIR` | Host path mounted into `cli` profile at `/workspace/omniroute` for self-update workflows | `.` (current directory) |
|
||||
| Variable | Purpose | Default |
|
||||
| ----------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------ |
|
||||
| `OMNIROUTE_WS_BRIDGE_SECRET` | Shared secret for the WebSocket bridge. **Required in production** — set to a strong random string. | unset (must be provided) |
|
||||
| `REDIS_URL` | Connection string for the rate limiter / cache backend | `redis://redis:6379` |
|
||||
| `REDIS_PORT` | Host-side port for the bundled Redis container | `6379` |
|
||||
| `REDIS_BIND_HOST` | Host interface the bundled Redis port is published on (loopback unless you add AUTH) | `127.0.0.1` |
|
||||
| `AUTO_UPDATE_HOST_REPO_DIR` | Host path mounted into `cli` profile at `/workspace/omniroute` for self-update workflows | `.` (current directory) |
|
||||
| `OMNIROUTE_MEMORY_MB` | Runtime Node heap ceiling for the Docker standalone server; overrides the image default above. Coding agents: `8192`+ (see [runtime RAM](#runtime-ram-for-coding-agents)). | `1024` |
|
||||
| `DASHBOARD_PORT` / `API_PORT` | Override exposed ports for dashboard (20128) and API (20129) | `20128` / `20129` |
|
||||
| `OMNIROUTE_BASE_PATH` | URL subpath when the app is published behind a reverse proxy (e.g. `/omniroute`) | _(empty = root)_ |
|
||||
| `NEXT_PUBLIC_BASE_URL` | Public browser origin including the subpath (e.g. `https://host/omniroute`) | unset |
|
||||
| `PROD_DASHBOARD_PORT` | Host-side dashboard port for `docker-compose.prod.yml` | `20130` |
|
||||
| `CLIPROXYAPI_PORT` | Host-side port for the `cliproxyapi` sidecar | `8317` |
|
||||
| `DASHBOARD_PORT` / `API_PORT` | Override exposed ports for dashboard (20128) and API (20129) | `20128` / `20129` |
|
||||
| `OMNIROUTE_BASE_PATH` | URL subpath when the app is published behind a reverse proxy (e.g. `/omniroute`) | _(empty = root)_ |
|
||||
| `NEXT_PUBLIC_BASE_URL` | Public browser origin including the subpath (e.g. `https://host/omniroute`) | unset |
|
||||
| `PROD_DASHBOARD_PORT` | Host-side dashboard port for `docker-compose.prod.yml` | `20130` |
|
||||
| `CLIPROXYAPI_PORT` | Host-side port for the `cliproxyapi` sidecar | `8317` |
|
||||
|
||||
## Reverse Proxy on a Subpath (Traefik / nginx)
|
||||
|
||||
@@ -361,11 +371,11 @@ intervals.
|
||||
|
||||
For orchestrators (Kubernetes, Nomad, etc.):
|
||||
|
||||
| Probe | Prefer | Avoid |
|
||||
| --- | --- | --- |
|
||||
| Liveness | HTTP `GET /livez`, or TCP on the main port (`PORT`, default `20128`) | `/api/monitoring/health` as liveness |
|
||||
| Readiness | HTTP `GET /healthz` | Tight timeouts that treat event-loop busy as dead |
|
||||
| Deep / blackbox | `/api/monitoring/health` | — |
|
||||
| Probe | Prefer | Avoid |
|
||||
| --------------- | -------------------------------------------------------------------- | ------------------------------------------------- |
|
||||
| Liveness | HTTP `GET /livez`, or TCP on the main port (`PORT`, default `20128`) | `/api/monitoring/health` as liveness |
|
||||
| Readiness | HTTP `GET /healthz` | Tight timeouts that treat event-loop busy as dead |
|
||||
| Deep / blackbox | `/api/monitoring/health` | — |
|
||||
|
||||
`/healthz` reports process lifecycle (`ok` / `starting` / `stopping`). `/livez` is
|
||||
process-alive only (200 whenever the handler can run; it does not wait for
|
||||
@@ -431,10 +441,10 @@ Endpoint tunnel panels (Cloudflare, Tailscale, ngrok) can be shown or hidden fro
|
||||
|
||||
## Image Tags
|
||||
|
||||
| Image | Tag | Size | Description |
|
||||
| ------------------------ | -------- | ------ | --------------------- |
|
||||
| Image | Tag | Size | Description |
|
||||
| ------------------------ | -------- | ------ | ---------------------------------------------------- |
|
||||
| `diegosouzapw/omniroute` | `latest` | ~250MB | Highest **published** stable SemVer (not git `main`) |
|
||||
| `diegosouzapw/omniroute` | `3.8.0` | ~250MB | Pin this class of tag for GitOps |
|
||||
| `diegosouzapw/omniroute` | `3.8.0` | ~250MB | Pin this class of tag for GitOps |
|
||||
|
||||
Multi-platform manifest: `linux/amd64` + `linux/arm64` native (Apple Silicon, AWS Graviton, Raspberry Pi). Docker selects the matching architecture automatically; pass `--platform linux/amd64` if you need to force AMD64 emulation on ARM hosts.
|
||||
|
||||
@@ -442,12 +452,12 @@ Multi-platform manifest: `linux/amd64` + `linux/arm64` native (Apple Silicon, AW
|
||||
|
||||
OmniRoute publishes separate Docker channels for stable releases, active release-branch testing, and development builds.
|
||||
|
||||
| Channel | Source | Mutability | Recommended use |
|
||||
| ------------------------------- | ----------------------------------- | --------------------------- | ----------------------------------------------------------------------------------------------- |
|
||||
| `:<version>` / `:<version>-web` | Signed/versioned release | Immutable | Production deployments that pin an exact release |
|
||||
| Channel | Source | Mutability | Recommended use |
|
||||
| ------------------------------- | ----------------------------------- | --------------------------- | --------------------------------------------------------------------------------------------------------------------- |
|
||||
| `:<version>` / `:<version>-web` | Signed/versioned release | Immutable | Production deployments that pin an exact release |
|
||||
| `:latest` / `:latest-web` | Highest **published** stable SemVer | Mutable stable pointer | Follows stable releases **after** a SemVer publish job — does **not** track `main` or unreleased `release/v*` commits |
|
||||
| `:next` / `:next-web` | Current default `release/v*` branch | Mutable pre-release pointer | Testing fixes that have landed on the active release branch but are not yet in a stable release |
|
||||
| `:main` / `:main-web` | `main` branch | Mutable development pointer | Development and integration testing only |
|
||||
| `:next` / `:next-web` | Current default `release/v*` branch | Mutable pre-release pointer | Testing fixes that have landed on the active release branch but are not yet in a stable release |
|
||||
| `:main` / `:main-web` | `main` branch | Mutable development pointer | Development and integration testing only |
|
||||
|
||||
#### Using the pre-release channel
|
||||
|
||||
@@ -491,30 +501,30 @@ A release-branch build can never move `latest`; only an eligible stable semantic
|
||||
|
||||
**`latest` is not a currency guarantee for git.** Merged fixes on `main` or on the active `release/v*` branch are **not** in `:latest` until a stable SemVer image is published and the publish job promotes `:latest` (same digest as that SemVer). If `latest` looks frozen while GitHub already shows the fix, pull `:next` to test the release branch or wait for the SemVer tag.
|
||||
|
||||
| You want | Use |
|
||||
| --- | --- |
|
||||
| GitOps / production that must not drift | Pin `:X.Y.Z` (or the image digest) |
|
||||
| Follow published stables and accept a recreate on each release | `:latest` |
|
||||
| Test unreleased `release/v*` commits | `:next` (not production) |
|
||||
| Test `main` | `:main` (not production) |
|
||||
| You want | Use |
|
||||
| -------------------------------------------------------------- | ---------------------------------- |
|
||||
| GitOps / production that must not drift | Pin `:X.Y.Z` (or the image digest) |
|
||||
| Follow published stables and accept a recreate on each release | `:latest` |
|
||||
| Test unreleased `release/v*` commits | `:next` (not production) |
|
||||
| Test `main` | `:main` (not production) |
|
||||
|
||||
## Availability: default SQLite is single-replica
|
||||
|
||||
Stock Docker / Kubernetes OmniRoute is **one Node process + one SQLite writer**. High availability is **not supported** on that topology.
|
||||
|
||||
| Constraint | Consequence |
|
||||
| --- | --- |
|
||||
| Single writer | Do **not** run multiple replicas against the same SQLite file. That corrupts the DB. |
|
||||
| Constraint | Consequence |
|
||||
| ------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| Single writer | Do **not** run multiple replicas against the same SQLite file. That corrupts the DB. |
|
||||
| Recreate / restart / HEALTHCHECK kill | **Full outage** of in-flight SSE, dashboard sessions, and in-memory state. Every connected client drops. New requests during the empty-endpoint window get a reverse-proxy **`502 Bad Gateway: Unknown error`**, not OmniRoute JSON — clients cannot distinguish this from a provider failure (#11015). |
|
||||
| Same event loop as `/healthz` | A busy catalog or compression tick can delay probes; a short timeout then restarts the **only** replica. |
|
||||
| Same event loop as `/healthz` | A busy catalog or compression tick can delay probes; a short timeout then restarts the **only** replica. |
|
||||
|
||||
**Probe matrix** (see also [Kubernetes probe recommendations](../ops/MONITORING_GUIDE.md#kubernetes-probe-recommendations)):
|
||||
|
||||
| Probe | Target | Do not use |
|
||||
| --- | --- | --- |
|
||||
| Liveness | TCP on `PORT` (default `20128`), or soft HTTP `/healthz` | `/api/monitoring/health` |
|
||||
| Readiness | HTTP `GET /healthz` | Tight timeouts that treat event-loop busy as dead |
|
||||
| Deep / humans | `/api/monitoring/health` | Automated kubelet liveness |
|
||||
| Probe | Target | Do not use |
|
||||
| ------------- | -------------------------------------------------------- | ------------------------------------------------- |
|
||||
| Liveness | TCP on `PORT` (default `20128`), or soft HTTP `/healthz` | `/api/monitoring/health` |
|
||||
| Readiness | HTTP `GET /healthz` | Tight timeouts that treat event-loop busy as dead |
|
||||
| Deep / humans | `/api/monitoring/health` | Automated kubelet liveness |
|
||||
|
||||
**Upgrades:** expect every session to drop. Drain clients if you can; there is no rolling update on default SQLite. Compose `restart: unless-stopped` plus Docker `HEALTHCHECK` will also replace the only process when the container is Unhealthy — same blast radius.
|
||||
|
||||
@@ -555,13 +565,13 @@ One Node process is **one V8 heap**. Two overlapping ~3 MiB / ~750k-token codi
|
||||
|
||||
To go beyond two concurrent **large** jobs **today**:
|
||||
|
||||
| Do | Do not |
|
||||
| --- | --- |
|
||||
| Run **N containers/pods**, each with its **own** `DATA_DIR` / volume | Set `replicas > 1` against one SQLite file |
|
||||
| Keep each instance at 1–2 heavy in-flight and 12–16 Gi cgroup | Give one process 8× RAM and `max=8` |
|
||||
| Optional: `QUOTA_STORE_DRIVER=redis` + `QUOTA_STORE_REDIS_URL` for **shared quota counters** | Treat Redis as shared SQLite — it is not |
|
||||
| Duplicate provider secrets into each instance (or accept partitioned dashboards) | Expect one dashboard / one call-log across instances |
|
||||
| Front with any load balancer; sticky by API key or session is enough | Require a vendor-specific size-aware middleware |
|
||||
| Do | Do not |
|
||||
| -------------------------------------------------------------------------------------------- | ---------------------------------------------------- |
|
||||
| Run **N containers/pods**, each with its **own** `DATA_DIR` / volume | Set `replicas > 1` against one SQLite file |
|
||||
| Keep each instance at 1–2 heavy in-flight and 12–16 Gi cgroup | Give one process 8× RAM and `max=8` |
|
||||
| Optional: `QUOTA_STORE_DRIVER=redis` + `QUOTA_STORE_REDIS_URL` for **shared quota counters** | Treat Redis as shared SQLite — it is not |
|
||||
| Duplicate provider secrets into each instance (or accept partitioned dashboards) | Expect one dashboard / one call-log across instances |
|
||||
| Front with any load balancer; sticky by API key or session is enough | Require a vendor-specific size-aware middleware |
|
||||
|
||||
Hardware: `concurrent_large ≈ N × 2` at ~8–12 Gi heap / ~12–16 Gi cgroup **per instance**. Host RAM must cover `N × cgroup`, not “one 16 Gi pod with N=8.”
|
||||
|
||||
|
||||
@@ -5719,17 +5719,28 @@ paths:
|
||||
x-loopback-only: true
|
||||
tags: [System]
|
||||
summary: Read a bounded Video Bridge drill-down slice
|
||||
description: Internal loopback/token-authenticated lookup into a short-lived per-session frame cache. It never downloads media or starts a subprocess; start/end and frame count only select already materialized frames.
|
||||
description: Internal loopback/token-authenticated lookup into a short-lived cache isolated by an opaque principal, session, and media reference. It never downloads media or starts a subprocess; start/end and frame count only select already materialized, canonicalized JPEG frames whose dimensions were derived from their bytes. This cache substrate is not yet wired to the transparent Video Bridge request path and does not yet expose multi-resolution selection.
|
||||
security: []
|
||||
parameters:
|
||||
- in: header
|
||||
name: x-omniroute-video-bridge-principal
|
||||
required: true
|
||||
description: Canonical visible-ASCII, opaque non-secret principal ID; production tenant derivation is required before enabling a caller
|
||||
schema:
|
||||
type: string
|
||||
minLength: 1
|
||||
maxLength: 256
|
||||
pattern: "^[!-~]{1,256}$"
|
||||
- in: query
|
||||
name: sessionId
|
||||
required: true
|
||||
schema: { type: string, maxLength: 128 }
|
||||
description: Canonical opaque ID without surrounding whitespace
|
||||
schema: { type: string, minLength: 1, maxLength: 128 }
|
||||
- in: query
|
||||
name: videoRef
|
||||
required: true
|
||||
schema: { type: string, maxLength: 4096 }
|
||||
description: Canonical opaque reference without surrounding whitespace
|
||||
schema: { type: string, minLength: 1, maxLength: 4096 }
|
||||
- in: query
|
||||
name: start
|
||||
required: false
|
||||
@@ -5743,25 +5754,58 @@ paths:
|
||||
required: false
|
||||
schema: { type: integer, minimum: 1, maximum: 16 }
|
||||
responses:
|
||||
"200": { description: Bounded cached frame slice }
|
||||
"403": { description: Trusted loopback/token identity required }
|
||||
"200": { description: Bounded cached frame slice with derivation audit metadata }
|
||||
"403": { description: Trusted loopback/token identity and principal required }
|
||||
"404": { description: Drill-down session or media key was not found }
|
||||
post:
|
||||
x-loopback-only: true
|
||||
tags: [System]
|
||||
summary: Store a bounded Video Bridge drill-down result
|
||||
description: Internal lifecycle operation for explicitly authorized callers. The short-lived session cache is isolated by session and media reference and does not alter the primary request cost.
|
||||
description: Internal lifecycle operation for explicitly authorized callers. The short-lived cache is isolated by principal, session, and media reference; enforces independent per-principal and global retained-byte quotas; accepts canonical Base64 only after a warning-sensitive bounded full JPEG decode/re-encode; strips trailing polyglot bytes; retains and charges only the canonical JPEG output; derives resolution from decoded bytes; and does not alter the primary request cost. The JSON wire budget includes Base64 overhead for the 32 MiB decoded-input ceiling.
|
||||
security: []
|
||||
parameters:
|
||||
- in: header
|
||||
name: x-omniroute-video-bridge-principal
|
||||
required: true
|
||||
description: Canonical visible-ASCII, opaque non-secret principal ID; production tenant derivation is required before enabling a caller
|
||||
schema:
|
||||
type: string
|
||||
minLength: 1
|
||||
maxLength: 256
|
||||
pattern: "^[!-~]{1,256}$"
|
||||
requestBody:
|
||||
required: true
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: object
|
||||
required: [sessionId, videoRef, durationSeconds, frames]
|
||||
additionalProperties: false
|
||||
required: [sessionId, videoRef, derivation, durationSeconds, frames]
|
||||
properties:
|
||||
sessionId: { type: string, maxLength: 128 }
|
||||
videoRef: { type: string, maxLength: 4096 }
|
||||
sessionId:
|
||||
type: string
|
||||
minLength: 1
|
||||
maxLength: 128
|
||||
description: Canonical opaque ID without surrounding whitespace
|
||||
videoRef:
|
||||
type: string
|
||||
minLength: 1
|
||||
maxLength: 4096
|
||||
description: Canonical opaque reference without surrounding whitespace
|
||||
derivation:
|
||||
type: object
|
||||
additionalProperties: false
|
||||
required: [parentContentHash, policy, version]
|
||||
properties:
|
||||
parentContentHash:
|
||||
type: string
|
||||
pattern: "^sha256:[a-f0-9]{64}$"
|
||||
policy:
|
||||
type: string
|
||||
pattern: "^[A-Za-z0-9][A-Za-z0-9._/-]{0,63}$"
|
||||
version:
|
||||
type: string
|
||||
pattern: "^[A-Za-z0-9][A-Za-z0-9._/-]{0,63}$"
|
||||
durationSeconds: { type: number, exclusiveMinimum: 0, maximum: 600 }
|
||||
frames:
|
||||
type: array
|
||||
@@ -5769,27 +5813,43 @@ paths:
|
||||
maxItems: 16
|
||||
items:
|
||||
type: object
|
||||
additionalProperties: false
|
||||
required: [timestampSeconds, dataUri]
|
||||
properties:
|
||||
timestampSeconds: { type: number, minimum: 0 }
|
||||
dataUri: { type: string, pattern: "^data:image/jpeg;base64," }
|
||||
dataUri:
|
||||
type: string
|
||||
minLength: 27
|
||||
maxLength: 5592431
|
||||
description: Canonical Base64 data URI whose decoded bytes pass a warning-sensitive bounded full JPEG decode/re-encode; trailing bytes are discarded and width and height are derived server-side
|
||||
responses:
|
||||
"201": { description: Drill-down result stored }
|
||||
"403": { description: Trusted loopback/token identity required }
|
||||
"403": { description: Trusted loopback/token identity and principal required }
|
||||
"413": { description: Payload exceeds the bounded session budget }
|
||||
"499": { description: Caller cancelled before the derivation was committed }
|
||||
delete:
|
||||
x-loopback-only: true
|
||||
tags: [System]
|
||||
summary: Delete a Video Bridge drill-down session
|
||||
security: []
|
||||
parameters:
|
||||
- in: header
|
||||
name: x-omniroute-video-bridge-principal
|
||||
required: true
|
||||
description: Canonical visible-ASCII, opaque non-secret principal ID; production tenant derivation is required before enabling a caller
|
||||
schema:
|
||||
type: string
|
||||
minLength: 1
|
||||
maxLength: 256
|
||||
pattern: "^[!-~]{1,256}$"
|
||||
- in: query
|
||||
name: sessionId
|
||||
required: true
|
||||
schema: { type: string, maxLength: 128 }
|
||||
description: Canonical opaque ID without surrounding whitespace
|
||||
schema: { type: string, minLength: 1, maxLength: 128 }
|
||||
responses:
|
||||
"200": { description: Session entries removed }
|
||||
"403": { description: Trusted loopback/token identity required }
|
||||
"403": { description: Trusted loopback/token identity and principal required }
|
||||
|
||||
/api/cache/stats:
|
||||
get:
|
||||
@@ -6866,7 +6926,11 @@ paths:
|
||||
Returns a structured JSON catalog parsed from this `openapi.yaml`,
|
||||
including info, servers, tags, schemas, and a flat list of endpoints
|
||||
(method, path, tags, summary, security, parameters, responses).
|
||||
Used by the in-app API explorer.
|
||||
Used by the in-app API explorer. When `requireLogin` is enabled, this
|
||||
management endpoint requires an authenticated dashboard session;
|
||||
otherwise it is available without authentication.
|
||||
security:
|
||||
- ManagementSessionAuth: []
|
||||
responses:
|
||||
"200":
|
||||
description: Parsed OpenAPI catalog
|
||||
@@ -6920,9 +6984,111 @@ paths:
|
||||
type: string
|
||||
"404":
|
||||
description: openapi.yaml file not found on disk
|
||||
"401":
|
||||
$ref: "#/components/responses/ManagementAuthenticationRequired"
|
||||
"403":
|
||||
$ref: "#/components/responses/ManagementInvalidToken"
|
||||
"500":
|
||||
description: Failed to parse OpenAPI spec
|
||||
|
||||
/api/openapi/try:
|
||||
post:
|
||||
tags: [System]
|
||||
summary: Proxy an API Explorer request to an OmniRoute endpoint
|
||||
description: >-
|
||||
Executes an API Explorer request through a server-side, same-origin proxy. The target
|
||||
must start with `/api/`, `/v1/`, `/v1beta/`, `/a2a`, or
|
||||
`/.well-known/agent.json`; protocol-relative and cross-origin targets are rejected.
|
||||
Hop-by-hop, proxy, host, cookie, and forwarding headers supplied in `headers` are
|
||||
stripped, while any dashboard cookie on the original request is forwarded separately.
|
||||
When `requireLogin` is disabled, the management-auth bypass mirrors the runtime setting;
|
||||
otherwise a management Bearer credential or dashboard session is required. Failures
|
||||
caught after authentication, including request JSON parsing, fetch, and response-body
|
||||
parsing failures, are returned in the normal HTTP 200 result envelope so the Explorer
|
||||
can display them; `status: 0` identifies that caught-failure path.
|
||||
security:
|
||||
- BearerAuth: []
|
||||
- ManagementSessionAuth: []
|
||||
requestBody:
|
||||
required: true
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: object
|
||||
required: [path]
|
||||
properties:
|
||||
method:
|
||||
type: string
|
||||
enum: [GET, POST, PUT, PATCH, DELETE, HEAD, OPTIONS]
|
||||
default: GET
|
||||
path:
|
||||
type: string
|
||||
minLength: 1
|
||||
pattern: "^/(?:api/|v1/|v1beta/|a2a|\\.well-known/agent\\.json)"
|
||||
description: Same-origin OmniRoute API path, optionally including a query string.
|
||||
headers:
|
||||
type: object
|
||||
default: {}
|
||||
additionalProperties:
|
||||
type: string
|
||||
description: >-
|
||||
Headers to forward after removing connection, content-length, cookie, host,
|
||||
keep-alive, proxy-authenticate, proxy-authorization, te, trailer,
|
||||
transfer-encoding, upgrade, x-forwarded-for, x-forwarded-host, and
|
||||
x-forwarded-proto headers.
|
||||
body:
|
||||
description: >-
|
||||
Optional JSON value. A truthy value is serialized unless it is already a
|
||||
string, and is not forwarded when `method` is `GET`.
|
||||
responses:
|
||||
"200":
|
||||
description: Upstream response or displayable caught-failure envelope
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: object
|
||||
additionalProperties: false
|
||||
required: [status, statusText, headers, body, latencyMs, contentType]
|
||||
properties:
|
||||
status:
|
||||
type: integer
|
||||
minimum: 0
|
||||
description: Upstream HTTP status, or 0 when request processing throws.
|
||||
statusText:
|
||||
type: string
|
||||
headers:
|
||||
type: object
|
||||
additionalProperties:
|
||||
type: string
|
||||
body:
|
||||
description: >-
|
||||
Parsed JSON, response text truncated after 10,000 characters, or a sanitized
|
||||
caught-error object.
|
||||
latencyMs:
|
||||
type: integer
|
||||
minimum: 0
|
||||
contentType:
|
||||
type: string
|
||||
"400":
|
||||
description: Invalid request body or non-same-origin path
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
oneOf:
|
||||
- $ref: "#/components/schemas/ValidationErrorResponse"
|
||||
- type: object
|
||||
required: [error]
|
||||
properties:
|
||||
error:
|
||||
type: string
|
||||
example: Path must be same-origin
|
||||
"401":
|
||||
$ref: "#/components/responses/ManagementAuthenticationRequired"
|
||||
"403":
|
||||
$ref: "#/components/responses/ManagementInvalidToken"
|
||||
"503":
|
||||
$ref: "#/components/responses/InternalError"
|
||||
|
||||
# ─── Agent Skills Catalog ────────────────────────────────────────────────────
|
||||
|
||||
/api/agent-skills:
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
---
|
||||
title: "Database Schema & Operations Guide"
|
||||
version: 3.8.40
|
||||
lastUpdated: 2026-06-28
|
||||
version: 3.8.50
|
||||
lastUpdated: 2026-08-23
|
||||
---
|
||||
|
||||
# Database Schema & Operations Guide
|
||||
@@ -43,12 +43,17 @@ For **single-user, single-instance** deployments (the primary OmniRoute use case
|
||||
db.pragma("journal_mode = WAL");
|
||||
db.pragma("busy_timeout = 2000");
|
||||
db.pragma("synchronous = NORMAL");
|
||||
// Settings > System & Storage > Cache Size is applied as KiB.
|
||||
db.pragma("cache_size = -16384");
|
||||
db.pragma(`cache_size = -${DEFAULT_DATABASE_SETTINGS.optimization.cacheSize}`);
|
||||
```
|
||||
|
||||
WAL allows **concurrent reads** during writes — important for the dashboard, which queries while requests are being recorded.
|
||||
|
||||
The default cache size is **65,536 KiB (64 MiB)**. SQLite interprets a negative
|
||||
`cache_size` as an approximate upper bound in KiB and allocates pages on demand.
|
||||
**Settings > System & Storage > Cache Size** accepts integer values from **1 to
|
||||
1,000,000 KiB**; saving the setting applies it to the live database connection,
|
||||
and OmniRoute restores the persisted value at startup.
|
||||
|
||||
---
|
||||
|
||||
## Database Location
|
||||
|
||||
@@ -531,6 +531,9 @@ detection above).
|
||||
| `OMNIROUTE_CONFIG_HOT_RELOAD_MS` | `5000` | `src/lib/config/hotReload.ts` | Polling interval (ms) for config hot-reload. Lower than `1000` is rejected. |
|
||||
| `OMNIROUTE_DISABLE_REDIS_AUTH_CACHE` | _(enabled)_ | `src/lib/db/apiKeys.ts` | Set `1` to bypass the Redis-backed API-key auth cache (forces DB reads). |
|
||||
| `OMNIROUTE_RTK_TRUST_PROJECT_FILTERS` | `0` | `open-sse/services/compression/engines/rtk/filterLoader.ts` | Trust user-managed RTK project filter rules without strict signature checks. |
|
||||
| `OMNI_COMPRESSION_WORKERS` | `2` | `open-sse/services/compression/compressionWorkerPool.ts` | Maximum concurrent synchronous RTK/Caveman workers; excess jobs wait FIFO. |
|
||||
| `OMNI_COMPRESSION_WORKER_TIMEOUT_MS` | `120000` | `open-sse/services/compression/compressionWorkerPool.ts` | Per-job timeout in milliseconds. Timed-out workers are terminated and the request fails open unchanged. |
|
||||
| `OMNI_COMPRESSION_WORKER_IDLE_MS` | `60000` | `open-sse/services/compression/compressionWorkerPool.ts` | Idle lifetime in milliseconds before an unused compression worker is terminated. |
|
||||
| `COMPRESSION_PIPELINE_BREAKER_ENABLED` | `false` | `open-sse/services/compression/pipelineEngineBreaker.ts` | T02 stacked-pipeline per-engine circuit-breaker master switch. **Opt-in (default off)** — when on, an engine that throws repeatedly across requests is skipped (fail-open) for a cooldown; off = byte-identical legacy behavior. |
|
||||
| `COMPRESSION_PIPELINE_BREAKER_THRESHOLD` | `3` | `open-sse/services/compression/pipelineEngineBreaker.ts` | Consecutive cross-request failures before an engine's breaker opens. |
|
||||
| `COMPRESSION_PIPELINE_BREAKER_COOLDOWN_MS` | `30000` | `open-sse/services/compression/pipelineEngineBreaker.ts` | Milliseconds an opened engine stays skipped before a half-open probe. |
|
||||
@@ -1041,6 +1044,7 @@ desktop install.
|
||||
| `EMBED_WS_PROXY_PORT` | `20131` | `src/lib/services/embedWsProxy.ts` | Port for the embedded-service WebSocket proxy server. |
|
||||
| `CLIPROXYAPI_HOST` | `127.0.0.1` | `open-sse/executors/cliproxyapi.ts` | CLIProxyAPI bridge host (legacy integration). |
|
||||
| `CLIPROXYAPI_PORT` | `5544` | `open-sse/executors/cliproxyapi.ts` | CLIProxyAPI bridge port. |
|
||||
| `CLIPROXYAPI_MANAGEMENT_KEY` | _(empty)_ | `src/lib/services/cliproxyAccountHealth.ts` | Management key for account-health reads from an externally managed CLIProxyAPI instance. |
|
||||
| `CLIPROXYAPI_CONFIG_DIR` | `~/.cli-proxy-api` | `src/lib/versionManager/processManager.ts` | CLIProxyAPI config directory. |
|
||||
| `MUX_SERVICE_PORT` | `8322` | `src/lib/services/bootstrap.ts` | Override the port where the embedded Mux (coder/mux) agent-orchestration daemon listens (always 127.0.0.1). |
|
||||
| `DARIO_HOST` | `127.0.0.1` | `open-sse/executors/dario.ts` | Dario embedded-service bind/connect host (loopback only by default). |
|
||||
@@ -1277,7 +1281,6 @@ Provider quota endpoints, network tunnels (Tailscale, Ngrok, MITM debug proxy),
|
||||
| `OMNIROUTE_SKIP_DNS_WRITE` | _(unset)_ | `src/mitm/dns/dnsConfig.ts` | Set `1` to skip writing to the hosts file when adding/removing DNS entries — for sandboxed or read-only test environments. |
|
||||
| `OMNIROUTE_SKIP_SYSTEM_TRUST` | `0` | `src/mitm/cert/install.ts`, `src/mitm/tproxy/caTrust.ts` | Test/CI-only guard: set `1` to make cert trust install/uninstall a no-op so the suite never mutates the OS trust store. Set automatically by the test setup and CI workflows. |
|
||||
| `CHANGELOG_BASE_REF` | _(auto)_ | `scripts/check/check-changelog-integrity.mjs` | Explicit base ref for the anti CHANGELOG-eat gate (defaults to the PR base branch in CI, or the highest `release/v*`). |
|
||||
| `ALLOW_CHANGELOG_REMOVALS` | `0` | `scripts/check/check-changelog-integrity.mjs` | Set `1` to turn intentional CHANGELOG bullet removals into a report instead of a failure (justify in the PR body). |
|
||||
| `ONEPROXY_ENABLED` | `true` | `src/lib/oneproxySync.ts` | Enable the 1Proxy egress pool sync. |
|
||||
| `ONEPROXY_API_URL` | `https://1proxy-api.aitradepulse.com` | `src/lib/oneproxySync.ts` | 1Proxy service API URL override. |
|
||||
| `ONEPROXY_MAX_PROXIES` | `500` | `src/lib/oneproxySync.ts` | Maximum proxies imported per sync. |
|
||||
|
||||
@@ -183,30 +183,31 @@ See [#7992](https://github.com/diegosouzapw/OmniRoute/issues/7992) and [#7111](h
|
||||
|
||||
## How It Works (Persisted Auto-Combos)
|
||||
|
||||
The Auto-Combo Engine dynamically selects the best provider/model for each request using a **14-factor scoring function** (defined in `open-sse/services/autoCombo/scoring.ts` → `DEFAULT_WEIGHTS`). Weights form a normalized distribution (custom weights are renormalized by `normalizeScoringWeights()`).
|
||||
The Auto-Combo Engine dynamically selects the best provider/model for each request using a **15-factor scoring function** (defined in `open-sse/services/autoCombo/scoring.ts` → `DEFAULT_WEIGHTS`). The default weights sum to `1.0`; custom weights are renormalized by `normalizeScoringWeights()`.
|
||||
|
||||

|
||||

|
||||
|
||||
> Source: [diagrams/auto-combo-12factor.mmd](../diagrams/auto-combo-12factor.mmd) (regenerate via `npm run docs:render-diagrams`). The filename predates the current factor set; the diagram shows 13 of the 14 factors (missing `sessionAvailability`).
|
||||
> Source: [diagrams/auto-combo-12factor.mmd](../diagrams/auto-combo-12factor.mmd) (regenerate via `npm run docs:render-diagrams`). The filename is historical; the source and rendered diagram show all 15 factors declared in `DEFAULT_WEIGHTS`.
|
||||
|
||||
| Factor | Default Weight | Description |
|
||||
| :-------------------- | :------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
||||
| `health` | 0.20 | Health score from circuit breaker (CLOSED=1.0, HALF_OPEN=0.5, OPEN=0.0) |
|
||||
| `quota` | 0.15 | Remaining quota / rate-limit headroom [0..1] |
|
||||
| `costInv` | 0.15 | Inverse **blended** cost (60% input + 40% output token price, normalized) — cheaper = higher score |
|
||||
| `latencyInv` | 0.12 | Inverse p95 latency normalized to pool — faster = higher score |
|
||||
| `taskFit` | 0.08 | Task-type fitness (coding, review, planning, analysis, debugging, docs) |
|
||||
| `stability` | 0.05 | Variance-based stability (low latency stdDev / error rate) |
|
||||
| `tierPriority` | 0.05 | Account-tier priority — Ultra=1.0, Pro=0.67, Standard=0.33, Free=0.0 |
|
||||
| `tierAffinity` | 0.05 | Affinity between the candidate's tier and the manifest-recommended tier |
|
||||
| `specificityMatch` | 0.05 | Match between request specificity (manifest hint) and model tier |
|
||||
| `contextAffinity` | 0.05 | Affinity between the request's context-window need and the model's context window |
|
||||
| `sessionAvailability` | 0.05 | OAuth session availability of the candidate connection for this session (`getOAuthSessionAvailability()`; non-OAuth connections score 1.0) |
|
||||
| `connectionDensity` | 0.05 | Spreads load across connections of the same provider (anti-concentration) |
|
||||
| `quota` | 0.1429 | Remaining quota / rate-limit headroom [0..1] |
|
||||
| `health` | 0.1605 | Health score from circuit breaker (CLOSED=1.0, HALF_OPEN=0.5, OPEN=0.0) |
|
||||
| `costInv` | 0.1429 | Inverse **blended** cost (60% input + 40% output token price, normalized) — cheaper = higher score |
|
||||
| `latencyInv` | 0.1143 | Inverse p95 latency normalized to pool — faster = higher score |
|
||||
| `taskFit` | 0.0762 | Task-type fitness (coding, review, planning, analysis, debugging, docs) |
|
||||
| `stability` | 0.0476 | Variance-based stability (low latency stdDev / error rate) |
|
||||
| `tierPriority` | 0.0476 | Account-tier priority — Ultra=1.0, Pro=0.67, Standard=0.33, Free=0.0 |
|
||||
| `tierAffinity` | 0.0476 | Affinity between the candidate's tier and the manifest-recommended tier |
|
||||
| `specificityMatch` | 0.0476 | Match between request specificity (manifest hint) and model tier |
|
||||
| `contextAffinity` | 0.0476 | Affinity between the request's context-window need and the model's context window |
|
||||
| `sessionAvailability` | 0.0476 | OAuth session availability of the candidate connection for this session (`getOAuthSessionAvailability()`; non-OAuth connections score 1.0) |
|
||||
| `connectionDensity` | 0.0476 | Spreads load across connections of the same provider (anti-concentration) |
|
||||
| `cacheAffinity` | 0.00 | Rendezvous-hash affinity toward the connection likeliest to already hold this request's prompt-cache prefix (`open-sse/services/combo/promptCacheAffinity.ts`); disabled by default (#8008) |
|
||||
| `resetWindowAffinity` | 0.00 | Bias toward connections whose quota reset window is favorable (disabled by default) |
|
||||
| `quality` | 0.03 | Feedback-driven output-quality signal from the routing-event quality tracker; candidates without observations receive a neutral 0.5 |
|
||||
|
||||
**Sum:** `0.20 + 0.15 + 0.15 + 0.12 + 0.08 + 0.05 + 0.05 + 0.05 + 0.05 + 0.05 + 0.05 + 0.05 + 0.00 + 0.00 = 1.05` as literally declared in `DEFAULT_WEIGHTS`; user-configured weights are renormalized into a distribution by `normalizeScoringWeights()` before scoring.
|
||||
**Sum:** `0.1429 + 0.1605 + 0.1429 + 0.1143 + 0.0762 + (7 × 0.0476) + 0.00 + 0.00 + 0.03 = 1.0` as declared in `DEFAULT_WEIGHTS`; user-configured weights are renormalized into a distribution by `normalizeScoringWeights()` before scoring.
|
||||
|
||||
## Mode Packs
|
||||
|
||||
@@ -677,8 +678,8 @@ Including the bare `auto` (default) plus the 6 `AutoVariant` values declared in
|
||||
|
||||
## How tiers fit Auto-Combo
|
||||
|
||||
The 14-factor scoring function (`open-sse/services/autoCombo/scoring.ts`) treats tier
|
||||
membership as two signals: `tierPriority` (0.05) and `tierAffinity` (0.05). See the
|
||||
The 15-factor scoring function (`open-sse/services/autoCombo/scoring.ts`) treats tier
|
||||
membership as two signals: `tierPriority` (0.0476) and `tierAffinity` (0.0476). See the
|
||||
canonical [scoring factor table](#how-it-works-persisted-auto-combos) above for the full
|
||||
`DEFAULT_WEIGHTS` set — the per-pack overrides (ship-fast/cost-saver/quality-first/
|
||||
offline-friendly) are listed in the "Weight profiles per pack" table.
|
||||
|
||||
@@ -1,77 +1,80 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 900 566" role="img" aria-label="OmniRoute free-tier dashboard preview: about 1.53 billion documented recurring tokens per month, about 2.15 billion in the first month, 43 provider pools and 522 model budget entries. The chart shows the 19 quantified recurring pools; one-time signup credits total about 626 million and include a 10 million LongCat grant that requires KYC. Uncapped providers remain subject to rate, concurrency, account, regional, and policy limits." font-family="-apple-system,Segoe UI,Roboto,Helvetica,Arial,sans-serif">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 900 566" role="img" aria-label="OmniRoute free-tier dashboard preview: about 1.51 billion documented recurring tokens per month and about 2.13 billion in the first month. The audited catalog has 40 recurring pool keys and 455 entries, 448 active and 7 discontinued; the chart represents the 20 pools with a published positive monthly token budget. One-time signup credits total about 626 million and include a 10 million LongCat grant that requires KYC. Uncapped providers remain subject to rate, concurrency, account, regional, and policy limits." font-family="-apple-system,Segoe UI,Roboto,Helvetica,Arial,sans-serif">
|
||||
<desc>Static dashboard preview of recurring token pools, first-month signup grants, and uncapped but rate-limited free-access providers.</desc>
|
||||
<rect width="900" height="566" rx="16" fill="#0d1117"/>
|
||||
<rect x="16" y="16" width="868" height="550" rx="13" fill="#161b22" stroke="#30363d"/>
|
||||
<text x="868" y="558" fill="#484f58" font-size="10.5" text-anchor="end">OmniRoute · /dashboard/free-tiers · preview mockup</text>
|
||||
<text x="32" y="50" fill="#e6edf3" font-size="18" font-weight="700">Monthly free-token budget</text>
|
||||
<text x="868" y="50" fill="#7d8590" font-size="13" text-anchor="end">43 provider pools · 522 model entries · one endpoint</text>
|
||||
<text x="868" y="50" fill="#7d8590" font-size="13" text-anchor="end">40 recurring pools · 455 catalog entries · one endpoint</text>
|
||||
<text x="32" y="84" fill="#7d8590" font-size="11.5">Steady / month</text>
|
||||
<text x="32" y="114" fill="#e6edf3" font-size="27" font-weight="800">~1.53B</text>
|
||||
<text x="32" y="114" fill="#e6edf3" font-size="27" font-weight="800">~1.51B</text>
|
||||
<text x="330" y="84" fill="#7d8590" font-size="11.5">First month (+ signup credits)</text>
|
||||
<text x="330" y="114" fill="#3fb950" font-size="27" font-weight="800">~2.15B</text>
|
||||
<text x="330" y="114" fill="#3fb950" font-size="27" font-weight="800">~2.13B</text>
|
||||
<text x="700" y="84" fill="#7d8590" font-size="11.5">ToS-flagged (you decide)</text>
|
||||
<text x="700" y="114" fill="#d29922" font-size="27" font-weight="800">15 providers</text>
|
||||
<clipPath id="bar"><rect x="32" y="132" width="836" height="16" rx="8"/></clipPath>
|
||||
<g clip-path="url(#bar)"><rect x="32" y="132" width="836" height="16" fill="#21262d"/>
|
||||
<rect x="32.0" y="132" width="512.7" height="16" fill="#6c5ce7"/>
|
||||
<rect x="545.5" y="132" width="82.6" height="16" fill="#00b894"/>
|
||||
<rect x="628.9" y="132" width="37.1" height="16" fill="#0984e3"/>
|
||||
<rect x="666.8" y="132" width="21.9" height="16" fill="#e17055"/>
|
||||
<rect x="689.5" y="132" width="21.9" height="16" fill="#fdcb6e"/>
|
||||
<rect x="712.2" y="132" width="18.9" height="16" fill="#e84393"/>
|
||||
<rect x="731.9" y="132" width="16.9" height="16" fill="#00cec9"/>
|
||||
<rect x="749.6" y="132" width="15.9" height="16" fill="#d63031"/>
|
||||
<rect x="766.3" y="132" width="14.3" height="16" fill="#a29bfe"/>
|
||||
<rect x="781.4" y="132" width="10.3" height="16" fill="#55efc4"/>
|
||||
<rect x="792.5" y="132" width="9.8" height="16" fill="#74b9ff"/>
|
||||
<rect x="803.1" y="132" width="9.3" height="16" fill="#ffeaa7"/>
|
||||
<rect x="813.2" y="132" width="8.7" height="16" fill="#fab1a0"/>
|
||||
<rect x="822.7" y="132" width="7.3" height="16" fill="#81ecec"/>
|
||||
<rect x="830.8" y="132" width="7.1" height="16" fill="#6c5ce7"/>
|
||||
<rect x="838.7" y="132" width="7.0" height="16" fill="#00b894"/>
|
||||
<rect x="846.5" y="132" width="7.0" height="16" fill="#0984e3"/>
|
||||
<rect x="854.3" y="132" width="6.8" height="16" fill="#e17055"/>
|
||||
<rect x="861.9" y="132" width="6.1" height="16" fill="#fdcb6e"/>
|
||||
<rect x="32.0" y="132" width="510.4" height="16" fill="#6c5ce7"/>
|
||||
<rect x="543.4" y="132" width="76.6" height="16" fill="#00b894"/>
|
||||
<rect x="620.9" y="132" width="76.6" height="16" fill="#0984e3"/>
|
||||
<rect x="698.5" y="132" width="30.6" height="16" fill="#e17055"/>
|
||||
<rect x="730.1" y="132" width="15.3" height="16" fill="#fdcb6e"/>
|
||||
<rect x="746.4" y="132" width="15.3" height="16" fill="#e84393"/>
|
||||
<rect x="762.7" y="132" width="12.2" height="16" fill="#00cec9"/>
|
||||
<rect x="776.0" y="132" width="10.2" height="16" fill="#d63031"/>
|
||||
<rect x="787.2" y="132" width="7.7" height="16" fill="#a29bfe"/>
|
||||
<rect x="795.8" y="132" width="5.7" height="16" fill="#55efc4"/>
|
||||
<rect x="802.5" y="132" width="5.7" height="16" fill="#74b9ff"/>
|
||||
<rect x="809.1" y="132" width="5.7" height="16" fill="#ffeaa7"/>
|
||||
<rect x="815.8" y="132" width="5.7" height="16" fill="#fab1a0"/>
|
||||
<rect x="822.4" y="132" width="5.7" height="16" fill="#81ecec"/>
|
||||
<rect x="829.1" y="132" width="5.7" height="16" fill="#6c5ce7"/>
|
||||
<rect x="835.7" y="132" width="5.7" height="16" fill="#00b894"/>
|
||||
<rect x="842.4" y="132" width="5.7" height="16" fill="#0984e3"/>
|
||||
<rect x="849.0" y="132" width="5.7" height="16" fill="#e17055"/>
|
||||
<rect x="855.7" y="132" width="5.7" height="16" fill="#fdcb6e"/>
|
||||
<rect x="862.3" y="132" width="5.7" height="16" fill="#e84393"/>
|
||||
</g>
|
||||
<text x="32" y="172" fill="#7d8590" font-size="12">Each segment = one of 19 quantified recurring pools · 43 total pools / 522 entries in the audited catalog.</text>
|
||||
<text x="32" y="172" fill="#7d8590" font-size="12">Each segment = one of 20 quantified recurring pools · 40 pools / 455 entries in the audited catalog.</text>
|
||||
<circle cx="37" cy="196" r="5" fill="#6c5ce7"/>
|
||||
<text x="48" y="200" fill="#c9d1d9" font-size="12.5">Mistral Large 3 <tspan fill="#7d8590">1.00B</tspan></text>
|
||||
<text x="48" y="200" fill="#c9d1d9" font-size="12.5">Mistral <tspan fill="#7d8590">1.00B</tspan></text>
|
||||
<circle cx="250" cy="196" r="5" fill="#00b894"/>
|
||||
<text x="261" y="200" fill="#c9d1d9" font-size="12.5">GPT-4o mini <tspan fill="#7d8590">150M</tspan></text>
|
||||
<text x="261" y="200" fill="#c9d1d9" font-size="12.5">LLM7 <tspan fill="#7d8590">150M</tspan></text>
|
||||
<circle cx="463" cy="196" r="5" fill="#0984e3"/>
|
||||
<text x="474" y="200" fill="#c9d1d9" font-size="12.5">Gemini 2.5 Flash <tspan fill="#7d8590">60M</tspan></text>
|
||||
<text x="474" y="200" fill="#c9d1d9" font-size="12.5">Nara <tspan fill="#7d8590">150M</tspan></text>
|
||||
<circle cx="676" cy="196" r="5" fill="#e17055"/>
|
||||
<text x="687" y="200" fill="#c9d1d9" font-size="12.5">GLM 4.7 <tspan fill="#7d8590">30M</tspan></text>
|
||||
<text x="687" y="200" fill="#c9d1d9" font-size="12.5">Gemini <tspan fill="#7d8590">60M</tspan></text>
|
||||
<circle cx="37" cy="226" r="5" fill="#fdcb6e"/>
|
||||
<text x="48" y="230" fill="#c9d1d9" font-size="12.5">Llama 3.3 70B <tspan fill="#7d8590">30M</tspan></text>
|
||||
<text x="48" y="230" fill="#c9d1d9" font-size="12.5">Cerebras <tspan fill="#7d8590">30M</tspan></text>
|
||||
<circle cx="250" cy="226" r="5" fill="#e84393"/>
|
||||
<text x="261" y="230" fill="#c9d1d9" font-size="12.5">Grok-3 <tspan fill="#7d8590">24M</tspan></text>
|
||||
<text x="261" y="230" fill="#c9d1d9" font-size="12.5">Cloudflare AI <tspan fill="#7d8590">30M</tspan></text>
|
||||
<circle cx="463" cy="226" r="5" fill="#00cec9"/>
|
||||
<text x="474" y="230" fill="#c9d1d9" font-size="12.5">DeepSeek V4 Pro <tspan fill="#7d8590">20M</tspan></text>
|
||||
<text x="474" y="230" fill="#c9d1d9" font-size="12.5">API Airforce <tspan fill="#7d8590">24M</tspan></text>
|
||||
<circle cx="676" cy="226" r="5" fill="#d63031"/>
|
||||
<text x="687" y="230" fill="#c9d1d9" font-size="12.5">GPT-4.1 <tspan fill="#7d8590">18M</tspan></text>
|
||||
<text x="687" y="230" fill="#c9d1d9" font-size="12.5">Ollama Cloud <tspan fill="#7d8590">20M</tspan></text>
|
||||
<circle cx="37" cy="256" r="5" fill="#a29bfe"/>
|
||||
<text x="48" y="260" fill="#c9d1d9" font-size="12.5">Llama 4 Scout <tspan fill="#7d8590">15M</tspan></text>
|
||||
<text x="48" y="260" fill="#c9d1d9" font-size="12.5">Groq <tspan fill="#7d8590">15M</tspan></text>
|
||||
<circle cx="250" cy="256" r="5" fill="#55efc4"/>
|
||||
<text x="261" y="260" fill="#c9d1d9" font-size="12.5">GPT-4o <tspan fill="#7d8590">7M</tspan></text>
|
||||
<text x="261" y="260" fill="#c9d1d9" font-size="12.5">Bluesminds <tspan fill="#7d8590">7.2M</tspan></text>
|
||||
<circle cx="463" cy="256" r="5" fill="#74b9ff"/>
|
||||
<text x="474" y="260" fill="#c9d1d9" font-size="12.5">MiniMax-M2.7 <tspan fill="#7d8590">6M</tspan></text>
|
||||
<text x="474" y="260" fill="#c9d1d9" font-size="12.5">SambaNova <tspan fill="#7d8590">6M</tspan></text>
|
||||
<circle cx="676" cy="256" r="5" fill="#ffeaa7"/>
|
||||
<text x="687" y="260" fill="#c9d1d9" font-size="12.5">Arcee Trinity Large Prev <tspan fill="#7d8590">5M</tspan></text>
|
||||
<text x="687" y="260" fill="#c9d1d9" font-size="12.5">Arcee <tspan fill="#7d8590">4.8M</tspan></text>
|
||||
<circle cx="37" cy="286" r="5" fill="#fab1a0"/>
|
||||
<text x="48" y="290" fill="#c9d1d9" font-size="12.5">Auto Free <tspan fill="#7d8590">4M</tspan></text>
|
||||
<text x="48" y="290" fill="#c9d1d9" font-size="12.5">Navy <tspan fill="#7d8590">4.5M</tspan></text>
|
||||
<circle cx="250" cy="286" r="5" fill="#81ecec"/>
|
||||
<text x="261" y="290" fill="#c9d1d9" font-size="12.5">Auto <tspan fill="#7d8590">1M</tspan></text>
|
||||
<text x="261" y="290" fill="#c9d1d9" font-size="12.5">BazaarLink <tspan fill="#7d8590">3.6M</tspan></text>
|
||||
<circle cx="463" cy="286" r="5" fill="#6c5ce7"/>
|
||||
<text x="474" y="290" fill="#c9d1d9" font-size="12.5">Command A Reasoning <tspan fill="#7d8590">800K</tspan></text>
|
||||
<text x="474" y="290" fill="#c9d1d9" font-size="12.5">OpenRouter <tspan fill="#7d8590">1.2M</tspan></text>
|
||||
<circle cx="676" cy="286" r="5" fill="#00b894"/>
|
||||
<text x="687" y="290" fill="#c9d1d9" font-size="12.5">ERNIE 4.5 VL 424B <tspan fill="#7d8590">500K</tspan></text>
|
||||
<text x="687" y="290" fill="#c9d1d9" font-size="12.5">Cohere <tspan fill="#7d8590">800K</tspan></text>
|
||||
<circle cx="37" cy="316" r="5" fill="#0984e3"/>
|
||||
<text x="48" y="320" fill="#c9d1d9" font-size="12.5">morph-v3-large <tspan fill="#7d8590">400K</tspan></text>
|
||||
<text x="48" y="320" fill="#c9d1d9" font-size="12.5">HuggingChat <tspan fill="#7d8590">500K</tspan></text>
|
||||
<circle cx="250" cy="316" r="5" fill="#e17055"/>
|
||||
<text x="261" y="320" fill="#c9d1d9" font-size="12.5">Llama 3.1 8B <tspan fill="#7d8590">200K</tspan></text>
|
||||
<text x="261" y="320" fill="#c9d1d9" font-size="12.5">Morph <tspan fill="#7d8590">400K</tspan></text>
|
||||
<circle cx="463" cy="316" r="5" fill="#fdcb6e"/>
|
||||
<text x="474" y="320" fill="#c9d1d9" font-size="12.5">Claude Sonnet 4.5 <tspan fill="#7d8590">25K</tspan></text>
|
||||
<text x="474" y="320" fill="#c9d1d9" font-size="12.5">Hugging Face <tspan fill="#7d8590">200K</tspan></text>
|
||||
<circle cx="676" cy="316" r="5" fill="#e84393"/>
|
||||
<text x="687" y="320" fill="#c9d1d9" font-size="12.5">Kiro <tspan fill="#7d8590">25K</tspan></text>
|
||||
<line x1="32" y1="386" x2="868" y2="386" stroke="#30363d"/>
|
||||
<text x="32" y="412" fill="#3fb950" font-size="13" font-weight="700">+ First month: one-time signup credits (~626M)</text>
|
||||
<rect x="32" y="421" width="90" height="22" rx="11" fill="#13311f" stroke="#238636"/>
|
||||
@@ -98,5 +101,5 @@
|
||||
<text x="299" y="466" fill="#7ee787" font-size="11.5" text-anchor="middle">nscale 5M</text>
|
||||
<rect x="32" y="492" width="836" height="34" rx="8" fill="#1c2230" stroke="#30363d"/>
|
||||
<text x="46" y="506" fill="#7d8590" font-size="12">Pool-deduped, honest counting — no inflated rate-limit ceilings. Some terms suggest personal-use only; we flag them so you decide.</text>
|
||||
<text x="46" y="520" fill="#7d8590" font-size="11.5">+ 13 recurring uncapped* providers (rate/concurrency-limited) · OpenRouter $10 → +24M/mo.</text>
|
||||
<text x="46" y="520" fill="#7d8590" font-size="11.5">+ 14 recurring uncapped* providers (rate/concurrency-limited) · OpenRouter $10 → +24M/mo.</text>
|
||||
</svg>
|
||||
|
||||
|
Before Width: | Height: | Size: 8.7 KiB After Width: | Height: | Size: 8.9 KiB |
@@ -1,13 +1,13 @@
|
||||
---
|
||||
title: "Guardrails"
|
||||
version: 3.8.50
|
||||
lastUpdated: 2026-08-14
|
||||
lastUpdated: 2026-08-24
|
||||
---
|
||||
|
||||
# Guardrails
|
||||
|
||||
> **Source of truth:** `src/lib/guardrails/`
|
||||
> **Last updated:** 2026-08-15 — v3.8.50 (Video Bridge broker confinement)
|
||||
> **Last updated:** 2026-08-24 — v3.8.50 (Video Bridge visual dedup hardening + focused captions)
|
||||
|
||||
Guardrails enforce safety, policy, and content transformations at the boundary
|
||||
between OmniRoute and upstream providers. Each guardrail can inspect (and
|
||||
@@ -327,30 +327,106 @@ fixed FFmpeg pass over the already validated local stream, select bounded
|
||||
`showinfo` scene timestamps, and fall back deterministically to the same
|
||||
uniform midpoints on detector failure, timeout, malformed output, or an empty
|
||||
candidate set. Segment-aware mode allocates midpoint samples proportionally to
|
||||
the validated scene intervals. The hard 16-frame cap is
|
||||
applied after selection in every policy. A caller may optionally provide a
|
||||
the validated scene intervals; segment-aware evidence and fallback behavior are
|
||||
detailed below. The hard 16-frame cap is
|
||||
applied after selection in every policy. When a scene-aware request has only a
|
||||
one-frame budget, it uses the uniform midpoint of the active full-video or focus
|
||||
window and reports `policyEffective: uniform`: a single selected scene frame
|
||||
cannot preserve both temporal ends. A caller may optionally provide a
|
||||
finite focus window (`start`/`end` seconds); bounds are clamped to the media
|
||||
duration, reversed or non-finite windows are rejected, and all sampling
|
||||
policies are performed only inside the normalized interval. The resulting
|
||||
window is included in sampling metadata and in the untrusted description
|
||||
prefix so downstream models can distinguish a focused excerpt from the full
|
||||
timeline.
|
||||
|
||||
Semantic caption focus is a separate, explicit setting. The default `full`
|
||||
analysis mode preserves the existing frame prompt and never forwards request
|
||||
text to the caption model. In `focused` mode, the bridge reads only the latest
|
||||
non-empty user-authored `text`/`input_text` from the same Chat or Responses
|
||||
container, normalizes it to NFC, collapses control characters and whitespace,
|
||||
and limits it to 500 Unicode code points. An empty result falls back to the
|
||||
exact `full` prompt. A usable hint is serialized as JSON in a dedicated
|
||||
untrusted-user-context block and may only prioritize observable details; it
|
||||
cannot override the separate warning against following instructions visible
|
||||
or audible in the media. Textual focus never infers `start`/`end` or changes
|
||||
the temporal sampler.
|
||||
|
||||
#### FU-07 structural segment evidence
|
||||
|
||||
`segment_aware` uses one bounded pre-analysis pass over the already validated
|
||||
local video stream. The fixed filter chain first scales to at most 320 pixels
|
||||
wide, detects scene changes and frozen intervals, then samples at 1 frame per
|
||||
second for blur, average luma, and spatial/temporal information. The pass is
|
||||
limited to 600 structural samples, one FFmpeg/filter thread, the same
|
||||
`file`-only protocol and container allowlists, a 1 MiB process-output bound,
|
||||
and at most 30 seconds inside the broker's shared abort/deadline. It never
|
||||
accepts a command, filter, path, or URL from the request.
|
||||
|
||||
The structural values are deterministic sampling evidence, not semantic video
|
||||
understanding. They do not infer subjects, actions, captions, speech, or user
|
||||
intent. Scene and freeze boundaries form segments; freeze coverage, blur,
|
||||
exposure, spatial detail, and temporal change only influence how the existing
|
||||
1–16 frame budget is allocated. A fully frozen segment is capped at one frame,
|
||||
while non-frozen segments compete for the remaining budget. When boundaries
|
||||
outnumber frames, uniform timeline coverage is retained so rapid early cuts
|
||||
cannot hide a long trailing segment. Scene boundaries within the 1-second
|
||||
analysis resolution of a freeze boundary are coalesced.
|
||||
|
||||
Missing filters, malformed/empty evidence, a detector error, or the bounded
|
||||
pre-analysis timeout fail open to the exact uniform midpoint policy. A caller
|
||||
abort or broker deadline does not fail open: it terminates the in-flight
|
||||
subprocess, prevents later frame extraction, and the private temporary tree is
|
||||
removed in `finally`.
|
||||
|
||||
`scripts/perf/video-bridge-fu07-eval.ts` generates deterministic real FFmpeg
|
||||
fixtures for post-dedup caption-call savings, dense-motion budget allocation,
|
||||
blur/exposure/SI-TI evidence, rapid cuts with a long tail, and gradual-fade
|
||||
false positives. It records pre-analysis wall time and, where `/usr/bin/time`
|
||||
is available, child CPU and peak RSS. Its quality checks are structural oracles
|
||||
only. Real caption-model quality remains `HOLD` because this harness has no
|
||||
authorized endpoint or frozen judge. Monetary savings also remain `HOLD`
|
||||
unless `--caption-cost-per-call-usd` supplies an explicit positive per-call
|
||||
estimate; the script never fabricates either result.
|
||||
|
||||
Each frame is limited to 4 MiB, all raw frames together to 23 MiB, and the
|
||||
serialized broker response to 32 MiB. A private temporary directory is removed
|
||||
in `finally`. OmniRoute does not bundle FFmpeg and does not accept a custom
|
||||
executable path. Before captioning, the bridge applies a conservative visual
|
||||
deduplication pass: each JPEG is reduced to a 16×16 grayscale buffer and is
|
||||
compared only with the last frame retained, using a fixed similarity threshold
|
||||
of 0.04 — a deliberate constant chosen for predictability, not a runtime
|
||||
setting. The first and final timeline frames
|
||||
are always retained; comparator or decoder errors fail open and keep coverage.
|
||||
The output metadata reports how many frames were dropped.
|
||||
compared only with the last frame retained. For a requested caption budget
|
||||
above one frame, extraction supplies a
|
||||
bounded candidate pool of up to twice that budget and never more than 16 frames.
|
||||
The requested cap is applied only after deduplication, with the first and final
|
||||
selected candidates preserved during final thinning when the budget is at least
|
||||
two. The versioned
|
||||
`grayscale-16x16-mean-cells-v2` policy uses the larger of mean luma delta and
|
||||
the ratio of thumbnail cells whose normalized delta is at least 0.05. The
|
||||
duplicate threshold is the constant 0.04, chosen for predictability rather than
|
||||
exposed as a runtime setting. This secondary
|
||||
high-contrast signal preserves small motion and visible-text changes that a
|
||||
mean-only comparison can hide. Comparator or decoder errors fail open and keep
|
||||
coverage. Output metadata separates extracted candidates, successfully used
|
||||
frames, and visual duplicates dropped.
|
||||
|
||||
An explicitly marked video part may request a timestamped contact sheet. The
|
||||
bridge builds at most a 4-column, 16-frame JPEG grid and labels the resulting
|
||||
observation with every source timestamp. If `sharp` cannot decode or compose
|
||||
the grid, the bridge falls back to the individual JPEG frames; a client abort
|
||||
still propagates through the sheet operation.
|
||||
bridge builds at most a 4-column, 16-frame JPEG grid. Every 512-pixel cell burns
|
||||
its source timestamp into a high-contrast bottom band, while the same timestamps
|
||||
remain in textual metadata for downstream association and audit. The complete
|
||||
JPEG remains capped at 32 MiB. If `sharp` cannot decode or compose the grid, the
|
||||
bridge falls back to the individual JPEG frames; a client abort still propagates
|
||||
through the sheet operation.
|
||||
|
||||
Promotion evidence is deliberately separate from the synthetic composition
|
||||
microbenchmark. `scripts/perf/video-bridge-contact-sheet-eval.ts` defines a
|
||||
schema-versioned A/B harness for real OpenAI-compatible vision models. It measures
|
||||
provider-reported tokens, end-to-end wall latency (including sheet composition),
|
||||
model-call count, and manifest-defined fact retention. Raw model responses are not
|
||||
written to the report; only SHA-256 digests and matched fact IDs are retained. The
|
||||
harness makes no network or paid model call unless `--execute-real` is passed and
|
||||
`--model`, `OMNIROUTE_BASE_URL`, and `OMNIROUTE_API_KEY` are configured. Without
|
||||
that explicit real run, its machine-readable verdict remains `HOLD`; synthetic
|
||||
payload/call-count measurements alone are not promotion evidence.
|
||||
|
||||
Callers may attach an optional `transcript.cues` array to a supported video
|
||||
part when they already possess aligned text. Each cue must carry `text`, a
|
||||
@@ -378,14 +454,39 @@ or download a second media copy; without that explicit track, it remains
|
||||
video-only.
|
||||
|
||||
The internal `/api/modality-bridge/video/drilldown` lifecycle is a separate,
|
||||
loopback/token-authenticated cache. It stores at most 16 JPEG frames per entry,
|
||||
keeps entries isolated by session and video reference, expires them after ten
|
||||
minutes, and supports bounded `start`/`end` reads or explicit session deletion.
|
||||
Besides the per-entry limits, the cache enforces a global 256 MiB decoded-byte
|
||||
budget: least-recently-used entries are evicted until new content fits, and an
|
||||
entry larger than the whole budget is rejected outright.
|
||||
It only slices materialized frames and cannot increase the cost of the primary
|
||||
video request.
|
||||
loopback/token-authenticated cache substrate. Every operation also requires a
|
||||
canonical opaque principal ID. Before a production caller is enabled, it must
|
||||
derive that ID from the authenticated tenant and must never forward a
|
||||
client-selected value. Cache keys bind that principal to canonical session and
|
||||
video-reference IDs, store only their SHA-256-derived keys, and scope both reads
|
||||
and deletion to the same principal. The cache stores at most 16 derived JPEG
|
||||
frames per entry, expires them after ten minutes, and supports bounded
|
||||
`start`/`end` reads or explicit session deletion.
|
||||
|
||||
Each principal is limited to 16 entries and 64 MiB of canonical JPEG data. Those
|
||||
limits are independent from the global 64-entry/256 MiB ceiling: principal quota
|
||||
pressure evicts only that principal's least-recently-used entries before global
|
||||
LRU eviction is considered. Expired entries are swept from both principal and
|
||||
global accounting on cache activity, while cancellation and validation failure do
|
||||
not commit a partial replacement.
|
||||
|
||||
The cache rejects non-canonical Base64, excess padding, non-JPEG media, malformed or
|
||||
truncated JPEGs, and JPEGs that produce a warning during a bounded full-image `sharp`
|
||||
decode. It re-encodes each accepted image as a canonical JPEG, derives width and height
|
||||
from the decoded bytes instead of trusting caller fields, and discards any trailing
|
||||
polyglot bytes rather than retaining them. Only the bounded canonical compressed buffer
|
||||
is charged to both quotas. The JSON wire limit includes Base64 overhead for the 32 MiB
|
||||
decoded-input ceiling. Every
|
||||
stored derivation records its validated JPEG format/resolution, sampling policy,
|
||||
derivation version, creation time, server-computed content hash, and hashed parent
|
||||
reference plus the trusted caller's parent-content hash. Cancellation is checked
|
||||
between asynchronous decode/hash phases before the atomic cache commit.
|
||||
|
||||
This tranche does not yet connect a production producer to the route and does not
|
||||
provide multi-resolution variant selection. The transparent Video Bridge request
|
||||
path therefore incurs no added work, while tenant-bound principal derivation and
|
||||
the full FU-08 multi-resolution lifecycle remain explicit follow-up work rather
|
||||
than documented as complete behavior.
|
||||
|
||||
Frames are captioned sequentially with the configured Video model. An empty
|
||||
Video override inherits the Vision setting; if both are empty, the Vision
|
||||
@@ -399,9 +500,16 @@ including a fallback model; the bridge reports `mixed` when different frames
|
||||
were produced by different models. A cache hit reuses that producer identity
|
||||
instead of relabeling it as the requested routing plan. The whole-video result
|
||||
cache is keyed on every input that changes the output — prompt, effective
|
||||
model, sampling policy, frame count, focus window, `transcript`,
|
||||
model, sampling policy, frame count, semantic analysis mode, the SHA-256
|
||||
fingerprint of the normalized focus hint, focus window, `transcript`,
|
||||
`audioTranscript`, and the contact-sheet flag — so changing any of those
|
||||
dimensions is a cache miss, never a stale reuse.
|
||||
dimensions is a cache miss, never a stale reuse. The visual dedup policy
|
||||
version, threshold, and bounded candidate-frame count are also explicit in the
|
||||
result-cache key and metadata; a policy change therefore cannot reuse a stale
|
||||
whole-video description. Result-cache v4 metadata keeps the mode and
|
||||
fingerprint, never the raw user task. Guardrail metadata reports both the
|
||||
requested and effective analysis modes; a requested `focused` mode without
|
||||
usable user text is reported as effectively `full`.
|
||||
|
||||
The guardrail extracts every supported video part but describes no more than
|
||||
`modalityBridgeVideoMaxVideos`. For a target proven to have
|
||||
@@ -417,6 +525,7 @@ Runtime settings are DB-backed and Zod-validated:
|
||||
| Key | Default | Range / behavior |
|
||||
| ----------------------------------- | ----------- | --------------------------------------------------------------------------------------------------- |
|
||||
| `modalityBridgeVideoEnabled` | `false` | Optional runtime, opt-in |
|
||||
| `modalityBridgeVideoAnalysisMode` | `"full"` | `full` preserves generic captions; `focused` uses bounded, untrusted latest-user context |
|
||||
| `modalityBridgeVideoModel` | `""` | Inherit the Vision Bridge model |
|
||||
| `modalityBridgeVideoFrameCount` | `8` | 1–16 |
|
||||
| `modalityBridgeVideoSamplingPolicy` | `"uniform"` | `uniform`, `scene_aware`, or proportional `segment_aware`; detector failure falls back to `uniform` |
|
||||
@@ -659,7 +768,8 @@ Audio uses `modalityBridgeAudioEnabled`, `modalityBridgeAudioModel`,
|
||||
`modalityBridgeCache*` settings. Audio has no legacy-key fallback because these
|
||||
keys were introduced with the Modality Bridge schema.
|
||||
|
||||
Video uses `modalityBridgeVideoEnabled`, `modalityBridgeVideoModel`,
|
||||
Video uses `modalityBridgeVideoEnabled`, `modalityBridgeVideoAnalysisMode`,
|
||||
`modalityBridgeVideoModel`,
|
||||
`modalityBridgeVideoFrameCount`, `modalityBridgeVideoSamplingPolicy`,
|
||||
`modalityBridgeVideoMaxVideos`, and
|
||||
`modalityBridgeVideoTimeout`, plus the shared `modalityBridgeCache*` settings.
|
||||
|
||||
@@ -287,6 +287,19 @@ export const AUDIO_TRANSLATION_PROVIDERS: Record<string, AudioProvider> = {
|
||||
};
|
||||
|
||||
export const AUDIO_SPEECH_PROVIDERS: Record<string, AudioProvider> = {
|
||||
google: {
|
||||
id: "google",
|
||||
credentialProviderId: "gemini",
|
||||
baseUrl: "https://generativelanguage.googleapis.com/v1beta/models",
|
||||
authType: "apikey",
|
||||
authHeader: "x-goog-api-key",
|
||||
format: "gemini-tts",
|
||||
models: [
|
||||
{ id: "gemini-3.1-flash-tts-preview", name: "Gemini 3.1 Flash TTS" },
|
||||
{ id: "gemini-2.5-flash-preview-tts", name: "Gemini 2.5 Flash TTS" },
|
||||
{ id: "gemini-2.5-pro-preview-tts", name: "Gemini 2.5 Pro TTS" },
|
||||
],
|
||||
},
|
||||
vertex: {
|
||||
id: "vertex",
|
||||
baseUrl: "https://us-central1-aiplatform.googleapis.com/v1",
|
||||
|
||||
@@ -181,6 +181,29 @@ export function getRegistryEntry(provider: string): RegistryEntry | null {
|
||||
return REGISTRY[provider] || _byAlias.get(provider) || null;
|
||||
}
|
||||
|
||||
/** Resolve only a model's explicit reasoning vocabulary. */
|
||||
export function getRegistryModelThinkingEfforts(
|
||||
provider: string,
|
||||
modelId: string
|
||||
): readonly string[] | undefined {
|
||||
const entry = getRegistryEntry(provider);
|
||||
if (!entry) return undefined;
|
||||
const model = entry.models.find((candidate) => candidate.id === modelId);
|
||||
return model?.supportedThinkingEfforts;
|
||||
}
|
||||
|
||||
/** Resolve a model's explicit reasoning vocabulary before its provider fallback. */
|
||||
export function getRegistryThinkingEfforts(
|
||||
provider: string,
|
||||
modelId: string
|
||||
): readonly string[] | undefined {
|
||||
const entry = getRegistryEntry(provider);
|
||||
if (!entry) return undefined;
|
||||
const modelEfforts = getRegistryModelThinkingEfforts(provider, modelId);
|
||||
if (modelEfforts !== undefined) return modelEfforts;
|
||||
return entry.defaultSupportedThinkingEfforts;
|
||||
}
|
||||
|
||||
/**
|
||||
* Decide whether a non-empty live catalog may exclude omitted static models
|
||||
* during request routing and wildcard expansion.
|
||||
|
||||
@@ -9,6 +9,7 @@ export const ollama_cloudProvider: RegistryEntry = {
|
||||
modelsUrl: "https://ollama.com/api/tags",
|
||||
authType: "apikey",
|
||||
authHeader: "bearer",
|
||||
defaultSupportedThinkingEfforts: ["none", "low", "medium", "high", "max"],
|
||||
// Note: rate limits vary by plan (free = "Light usage", Pro = more, Max = 5x Pro).
|
||||
// Users can generate API keys at https://ollama.com/settings/keys
|
||||
models: [
|
||||
@@ -24,23 +25,20 @@ export const ollama_cloudProvider: RegistryEntry = {
|
||||
supportsReasoning: true,
|
||||
supportedThinkingEfforts: ["low", "medium", "high"],
|
||||
},
|
||||
// #10788: Ollama Cloud accepts low|medium|high|max|none uniformly across
|
||||
// its reasoning-capable models (see supportsMaxEffortForProvider's
|
||||
// isOllamaCloud comment in open-sse/executors/base/reasoningEffort.ts) —
|
||||
// declare supportedThinkingEfforts so appendSyncedEffortVariants() (which
|
||||
// runs before static-model capability enrichment) can synthesize the
|
||||
// catalog's selectable -low/-high/-max variant ids for these models.
|
||||
// #10788: these models accept none|low|medium|high|max. Keep their explicit
|
||||
// declarations aligned with the provider fallback so the static and synced
|
||||
// catalog paths expose the same native vocabulary.
|
||||
{
|
||||
id: "deepseek-v4-pro",
|
||||
name: "DeepSeek V4 Pro",
|
||||
supportsReasoning: true,
|
||||
supportedThinkingEfforts: ["low", "medium", "high", "max"],
|
||||
supportedThinkingEfforts: ["none", "low", "medium", "high", "max"],
|
||||
},
|
||||
{
|
||||
id: "deepseek-v4-flash",
|
||||
name: "DeepSeek V4 Flash",
|
||||
supportsReasoning: true,
|
||||
supportedThinkingEfforts: ["low", "medium", "high", "max"],
|
||||
supportedThinkingEfforts: ["none", "low", "medium", "high", "max"],
|
||||
},
|
||||
{ id: "kimi-k2.6", name: "Kimi K2.6" },
|
||||
// Ollama Cloud accepts low|medium|high|max|none and rejects xhigh, so the
|
||||
@@ -50,14 +48,14 @@ export const ollama_cloudProvider: RegistryEntry = {
|
||||
name: "GLM 5.1",
|
||||
supportsReasoning: true,
|
||||
supportsXHighEffort: false,
|
||||
supportedThinkingEfforts: ["low", "medium", "high", "max"],
|
||||
supportedThinkingEfforts: ["none", "low", "medium", "high", "max"],
|
||||
},
|
||||
{
|
||||
id: "glm-5.2",
|
||||
name: "GLM 5.2",
|
||||
supportsReasoning: true,
|
||||
supportsXHighEffort: false,
|
||||
supportedThinkingEfforts: ["low", "medium", "high", "max"],
|
||||
supportedThinkingEfforts: ["none", "low", "medium", "high", "max"],
|
||||
},
|
||||
// #3110: MiniMax M3 via Ollama
|
||||
{ id: "minimax-m3", name: "MiniMax M3", contextLength: 1048576, supportsVision: true },
|
||||
|
||||
@@ -139,6 +139,9 @@ export interface RegistryEntry {
|
||||
requestDefaults?: ProviderRequestDefaults;
|
||||
oauth?: RegistryOAuth;
|
||||
models: RegistryModel[];
|
||||
/** Provider-native reasoning vocabulary for reasoning-capable passthrough models
|
||||
* that do not have an explicit per-model declaration. */
|
||||
defaultSupportedThinkingEfforts?: readonly string[];
|
||||
modelsUrl?: string;
|
||||
/** Prefix to prepend to model IDs before upstream API calls (e.g. "accounts/fireworks/models/") */
|
||||
modelIdPrefix?: string;
|
||||
|
||||
81
open-sse/executors/geminiTts.ts
Normal file
@@ -0,0 +1,81 @@
|
||||
import { Buffer } from "node:buffer";
|
||||
import { extractInlineAudio, parsePcmSampleRate, pcmToWav } from "./vertexMedia.ts";
|
||||
import { CORS_HEADERS } from "../utils/cors.ts";
|
||||
import { upstreamErrorResponse } from "../utils/audioResponse.ts";
|
||||
import { errorResponse } from "../utils/error.ts";
|
||||
|
||||
type GeminiTtsCredentials = {
|
||||
apiKey?: string | null;
|
||||
accessToken?: string | null;
|
||||
};
|
||||
|
||||
export class GeminiTtsUpstreamError extends Error {
|
||||
constructor(
|
||||
public readonly response: Response,
|
||||
public readonly body: string
|
||||
) {
|
||||
super(`Gemini TTS upstream error (${response.status})`);
|
||||
}
|
||||
}
|
||||
|
||||
export async function geminiGenerateSpeech(
|
||||
credentials: GeminiTtsCredentials,
|
||||
options: { model: string; text: string; voice: string }
|
||||
): Promise<Buffer> {
|
||||
const headers: Record<string, string> = { "Content-Type": "application/json" };
|
||||
if (credentials.apiKey) {
|
||||
headers["x-goog-api-key"] = credentials.apiKey;
|
||||
} else if (credentials.accessToken) {
|
||||
headers.Authorization = `Bearer ${credentials.accessToken}`;
|
||||
}
|
||||
|
||||
const response = await fetch(
|
||||
`https://generativelanguage.googleapis.com/v1beta/models/${encodeURIComponent(options.model)}:generateContent`,
|
||||
{
|
||||
method: "POST",
|
||||
headers,
|
||||
body: JSON.stringify({
|
||||
contents: [{ parts: [{ text: options.text }] }],
|
||||
generationConfig: {
|
||||
responseModalities: ["AUDIO"],
|
||||
speechConfig: {
|
||||
voiceConfig: {
|
||||
prebuiltVoiceConfig: { voiceName: options.voice },
|
||||
},
|
||||
},
|
||||
},
|
||||
}),
|
||||
}
|
||||
);
|
||||
if (!response.ok) {
|
||||
throw new GeminiTtsUpstreamError(response, await response.text());
|
||||
}
|
||||
|
||||
const inline = extractInlineAudio(await response.json());
|
||||
if (!inline) throw new Error("Gemini TTS response did not contain audio data");
|
||||
return pcmToWav(Buffer.from(inline.base64, "base64"), parsePcmSampleRate(inline.mimeType));
|
||||
}
|
||||
|
||||
export async function handleGeminiTtsSpeech(
|
||||
credentials: GeminiTtsCredentials,
|
||||
options: { model: string; text: string; voice?: unknown }
|
||||
): Promise<Response> {
|
||||
try {
|
||||
const wav = await geminiGenerateSpeech(credentials, {
|
||||
model: options.model,
|
||||
text: options.text,
|
||||
voice:
|
||||
typeof options.voice === "string" && options.voice.trim() ? options.voice.trim() : "Kore",
|
||||
});
|
||||
return new Response(new Uint8Array(wav), {
|
||||
status: 200,
|
||||
headers: { ...CORS_HEADERS, "Content-Type": "audio/wav" },
|
||||
});
|
||||
} catch (error) {
|
||||
if (error instanceof GeminiTtsUpstreamError) {
|
||||
return upstreamErrorResponse(error.response, error.body);
|
||||
}
|
||||
const message = error instanceof Error ? error.message : String(error);
|
||||
return errorResponse(500, `Speech request failed: ${message}`);
|
||||
}
|
||||
}
|
||||
@@ -156,13 +156,13 @@ export function pcmToWav(
|
||||
return Buffer.concat([header, pcm]);
|
||||
}
|
||||
|
||||
function parseSampleRate(mimeType: string | undefined): number {
|
||||
export function parsePcmSampleRate(mimeType: string | undefined): number {
|
||||
if (!mimeType) return 24000;
|
||||
const match = /rate=(\d+)/i.exec(mimeType);
|
||||
return match ? parseInt(match[1], 10) : 24000;
|
||||
}
|
||||
|
||||
function extractInlineAudio(
|
||||
export function extractInlineAudio(
|
||||
data: unknown
|
||||
): { base64: string; mimeType: string } | null {
|
||||
const parts = (data as { candidates?: Array<{ content?: { parts?: unknown[] } }> })?.candidates?.[0]
|
||||
@@ -215,7 +215,7 @@ export async function vertexGenerateSpeech(
|
||||
const inline = extractInlineAudio(data);
|
||||
if (!inline) throw new Error("Vertex TTS returned no audio content");
|
||||
const pcm = Buffer.from(inline.base64, "base64");
|
||||
return { audio: pcmToWav(pcm, parseSampleRate(inline.mimeType)), contentType: "audio/wav" };
|
||||
return { audio: pcmToWav(pcm, parsePcmSampleRate(inline.mimeType)), contentType: "audio/wav" };
|
||||
}
|
||||
|
||||
/** Gemini transcription (audio → text). `audioBase64` is the raw file bytes, base64-encoded. */
|
||||
|
||||
@@ -21,6 +21,7 @@ import { getSpeechProvider, parseSpeechModel } from "../config/audioRegistry.ts"
|
||||
import { buildAuthHeaders } from "../config/registryUtils.ts";
|
||||
import { kieExecutor } from "../executors/kie.ts";
|
||||
import { vertexGenerateSpeech } from "../executors/vertexMedia.ts";
|
||||
import { handleGeminiTtsSpeech } from "../executors/geminiTts.ts";
|
||||
import { handleAwsPollySpeech } from "../executors/awsPollyTts.ts";
|
||||
import { handleEdgeTtsSpeech } from "../executors/edgeTts.ts";
|
||||
import { GttsUpstreamError, normalizeGttsLang, synthesizeGtts } from "../executors/gtts.ts";
|
||||
@@ -889,6 +890,13 @@ export async function handleAudioSpeech({
|
||||
headers: { ...CORS_HEADERS, "Content-Type": contentType },
|
||||
});
|
||||
}
|
||||
if (providerConfig.format === "gemini-tts") {
|
||||
return handleGeminiTtsSpeech(credentials, {
|
||||
model: modelId,
|
||||
text: body.input,
|
||||
voice: body.voice,
|
||||
});
|
||||
}
|
||||
|
||||
if (providerConfig.format === "hyperbolic") {
|
||||
return handleHyperbolicSpeech(providerConfig, body, token);
|
||||
|
||||
@@ -20,6 +20,7 @@ import { checkSemanticCache } from "./chatCore/semanticCache.ts";
|
||||
import { checkLifecycle, resolveLifecycle } from "./chatCore/modelLifecyclePolicy.ts";
|
||||
import {
|
||||
shouldDefaultAllowClassifier,
|
||||
detectClassifierFormat,
|
||||
buildDefaultAllowClaudeMessage,
|
||||
} from "./chatCore/claudeClassifierCompat.ts";
|
||||
import { applyClientUsageBuffer } from "./chatCore/clientUsageBuffer.ts";
|
||||
@@ -379,6 +380,7 @@ import { isCompactResponsesEndpoint } from "../executors/codex.ts";
|
||||
import { persistCodexChildQuotaResponse } from "../services/codexAccount/index.ts";
|
||||
import { invalidateCodexQuotaCache } from "../services/codexQuotaFetcher.ts";
|
||||
import { translateNonStreamingResponse } from "./responseTranslator.ts";
|
||||
import { extractToolSchemaMap } from "../translator/response/openai-responses/toolSchemas.ts";
|
||||
import { unwrapClineNonStreamingEnvelope } from "./chatCore/clineResponseEnvelope.ts";
|
||||
import { extractUsageFromResponse } from "./usageExtractor.ts";
|
||||
import {
|
||||
@@ -778,11 +780,12 @@ export async function handleChatCore({
|
||||
classifierSettings.claudeClassifierCompat as string | undefined
|
||||
)
|
||||
) {
|
||||
const classifierFormat = detectClassifierFormat(body as Record<string, unknown>);
|
||||
log?.warn?.(
|
||||
"CHAT",
|
||||
`classifier compat=${classifierSettings.claudeClassifierCompat} | short-circuit default-allow`
|
||||
`classifier compat=${classifierSettings.claudeClassifierCompat} format=${classifierFormat} | short-circuit default-allow`
|
||||
);
|
||||
return buildDefaultAllowClaudeMessage(requestedModel);
|
||||
return buildDefaultAllowClaudeMessage(requestedModel, classifierFormat);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4910,12 +4913,14 @@ export async function handleChatCore({
|
||||
|
||||
// Translate response to client's expected format (usually OpenAI)
|
||||
// Pass toolNameMap so Claude OAuth proxy_ prefix is stripped in tool_use blocks (#605)
|
||||
const responseToolSchemas = extractToolSchemaMap(finalBody || translatedBody || body);
|
||||
let translatedResponse = needsTranslation(responsePayloadFormat, clientResponseFormat)
|
||||
? translateNonStreamingResponse(
|
||||
responseBody,
|
||||
responsePayloadFormat,
|
||||
clientResponseFormat,
|
||||
responseToolNameMap
|
||||
responseToolNameMap,
|
||||
responseToolSchemas
|
||||
)
|
||||
: responseBody;
|
||||
const memoryExtractionResponse = translatedResponse;
|
||||
@@ -4942,7 +4947,8 @@ export async function handleChatCore({
|
||||
responseBody,
|
||||
responsePayloadFormat,
|
||||
FORMATS.OPENAI,
|
||||
responseToolNameMap
|
||||
responseToolNameMap,
|
||||
responseToolSchemas
|
||||
)
|
||||
: responseBody;
|
||||
const firstChoice = cacheResponse?.choices?.[0];
|
||||
@@ -5465,7 +5471,8 @@ export async function handleChatCore({
|
||||
streamBody,
|
||||
clientResponseFormat,
|
||||
FORMATS.OPENAI,
|
||||
responseToolNameMap
|
||||
responseToolNameMap,
|
||||
extractToolSchemaMap(finalBody || translatedBody || body)
|
||||
) as Record<string, unknown>)
|
||||
: streamBody;
|
||||
const choices = cacheStreamBody.choices as
|
||||
|
||||
@@ -24,14 +24,19 @@ const SECURITY_MONITOR_MARKER = "You are a security monitor for autonomous AI co
|
||||
|
||||
export type ClaudeClassifierCompatMode = "off" | "auto" | "always";
|
||||
|
||||
/** The two synthetic-response shapes Claude Code's classifier can expect. */
|
||||
export type ClaudeClassifierFormat = "block" | "severity";
|
||||
|
||||
function extractSystemTexts(body: Record<string, unknown> | null | undefined): string[] {
|
||||
const system = body?.system;
|
||||
if (typeof system === "string") return [system];
|
||||
if (Array.isArray(system)) {
|
||||
return system
|
||||
.map((part) => (part && typeof (part as { text?: unknown }).text === "string"
|
||||
? ((part as { text: string }).text)
|
||||
: ""))
|
||||
.map((part) =>
|
||||
part && typeof (part as { text?: unknown }).text === "string"
|
||||
? (part as { text: string }).text
|
||||
: ""
|
||||
)
|
||||
.filter(Boolean);
|
||||
}
|
||||
return [];
|
||||
@@ -60,6 +65,29 @@ export function shouldDefaultAllowClassifier(
|
||||
return extractSystemTexts(body).some((text) => text.includes(SECURITY_MONITOR_MARKER));
|
||||
}
|
||||
|
||||
/**
|
||||
* Detect which synthetic-response shape the classifier request expects.
|
||||
*
|
||||
* Newer Claude Code builds send a "severity classifier" variant of the same internal
|
||||
* request: it carries `stop_sequences: [..., "</severity>", ...]` and parses a
|
||||
* `<severity>N</severity>` reply instead of `<block>no</block>`/`<block>yes</block>`.
|
||||
* Feeding it the legacy `<block>no</block>` shape is unparseable, so it retries both
|
||||
* stages and then fails closed — the same "blocking it for safety" failure this compat
|
||||
* shim exists to avoid. Only `stop_sequences` distinguishes the two shapes; callers
|
||||
* should only consult this after `shouldDefaultAllowClassifier` has already confirmed
|
||||
* the request is the classifier (via the system-prompt marker), so an unrelated app
|
||||
* that merely happens to use `</severity>` as a stop token is never affected (#8189).
|
||||
*/
|
||||
export function detectClassifierFormat(
|
||||
body: Record<string, unknown> | null | undefined
|
||||
): ClaudeClassifierFormat {
|
||||
const stopSequences = body?.stop_sequences;
|
||||
if (Array.isArray(stopSequences) && stopSequences.includes("</severity>")) {
|
||||
return "severity";
|
||||
}
|
||||
return "block";
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the synthetic Claude `message` ALLOW response. Always returns a plain JSON
|
||||
* body (matching the upstream reference implementation) — Claude Code's classifier
|
||||
@@ -67,7 +95,10 @@ export function shouldDefaultAllowClassifier(
|
||||
* satisfies both streaming and non-streaming callers without needing to plumb a
|
||||
* synthetic SSE encoding through the streaming/sseToJson/non-streaming handlers.
|
||||
*/
|
||||
export function buildDefaultAllowClaudeMessage(model?: string | null): {
|
||||
export function buildDefaultAllowClaudeMessage(
|
||||
model?: string | null,
|
||||
format: ClaudeClassifierFormat = "block"
|
||||
): {
|
||||
success: true;
|
||||
response: Response;
|
||||
} {
|
||||
@@ -76,7 +107,12 @@ export function buildDefaultAllowClaudeMessage(model?: string | null): {
|
||||
type: "message",
|
||||
role: "assistant",
|
||||
model: model || "claude-3-5-sonnet-20241022",
|
||||
content: [{ type: "text", text: "<block>no</block>" }],
|
||||
content: [
|
||||
{
|
||||
type: "text",
|
||||
text: format === "severity" ? "<severity>0</severity>" : "<block>no</block>",
|
||||
},
|
||||
],
|
||||
stop_reason: "end_turn",
|
||||
stop_sequence: null,
|
||||
usage: { input_tokens: 1, output_tokens: 1 },
|
||||
|
||||
@@ -91,8 +91,20 @@ interface KieImageOptions {
|
||||
} | null;
|
||||
}
|
||||
|
||||
// KIE Market catalog ids are namespaced for OmniRoute's catalog
|
||||
// (`google-imagen/<model>`), but the KIE Market createTask API expects
|
||||
// vendor-specific upstream ids that do not follow a single consistent
|
||||
// pattern (confirmed against docs.kie.ai/market/google/* — see #11225,
|
||||
// #11296): nano-banana-2 and nano-banana-pro drop the vendor namespace
|
||||
// entirely, while nano-banana and nano-banana-edit use a `google/` prefix
|
||||
// instead of `google-imagen/`. Every other KIE Market namespace (seedream,
|
||||
// flux, ideogram, qwen, wan, grok-imagine, gpt) already matches its real
|
||||
// upstream id byte-for-byte, so this map stays scoped to google-imagen.
|
||||
export const KIE_MARKET_UPSTREAM_MODEL_IDS: ReadonlyMap<string, string> = new Map([
|
||||
["google-imagen/nano-banana", "google/nano-banana"],
|
||||
["google-imagen/nano-banana-2", "nano-banana-2"],
|
||||
["google-imagen/nano-banana-pro", "nano-banana-pro"],
|
||||
["google-imagen/nano-banana-edit", "google/nano-banana-edit"],
|
||||
]);
|
||||
|
||||
export function resolveKieMarketUpstreamModelId(publicModelId: string): string {
|
||||
|
||||
@@ -13,6 +13,7 @@ import {
|
||||
import { restoreClaudeToolName } from "../services/claudeCodeToolRemapper.ts";
|
||||
import { extractReplayableResponsesReasoningText } from "../services/reasoningInputPolicy.ts";
|
||||
import { sanitizeToolId } from "../translator/helpers/schemaCoercion.ts";
|
||||
import { stripEmptyOptionalToolArgs } from "../translator/response/openai-responses/pureHelpers.ts";
|
||||
|
||||
type JsonRecord = Record<string, unknown>;
|
||||
|
||||
@@ -135,24 +136,28 @@ function findBestMessageText(output: unknown[]): {
|
||||
* Handles different provider response formats (Gemini, Claude, etc.)
|
||||
*
|
||||
* @param toolNameMap - Optional Map<prefixedName, originalName> for Claude OAuth tool name stripping
|
||||
* @param toolSchemas - Optional Map<toolName, parametersSchema> for schema-aware optional-arg cleanup
|
||||
*/
|
||||
export function translateNonStreamingResponse(
|
||||
responseBody: JsonRecord,
|
||||
targetFormat: string,
|
||||
sourceFormat: string,
|
||||
toolNameMap?: Map<string, string> | null
|
||||
toolNameMap?: Map<string, string> | null,
|
||||
toolSchemas?: Map<string, JsonRecord> | null
|
||||
): JsonRecord;
|
||||
export function translateNonStreamingResponse(
|
||||
responseBody: unknown,
|
||||
targetFormat: string,
|
||||
sourceFormat: string,
|
||||
toolNameMap?: Map<string, string> | null
|
||||
toolNameMap?: Map<string, string> | null,
|
||||
toolSchemas?: Map<string, JsonRecord> | null
|
||||
): unknown;
|
||||
export function translateNonStreamingResponse(
|
||||
responseBody: unknown,
|
||||
targetFormat: string,
|
||||
sourceFormat: string,
|
||||
toolNameMap?: Map<string, string> | null
|
||||
toolNameMap?: Map<string, string> | null,
|
||||
toolSchemas?: Map<string, JsonRecord> | null
|
||||
): unknown {
|
||||
// If already in source format, return as-is
|
||||
if (targetFormat === sourceFormat) {
|
||||
@@ -219,6 +224,11 @@ export function translateNonStreamingResponse(
|
||||
toString(itemObj.id) ||
|
||||
`call_${Date.now()}_${toolCalls.length}`;
|
||||
let argsToEmit = itemObj.arguments;
|
||||
const rawName = toString(itemObj.name);
|
||||
const toolSchema = toolSchemas?.get(rawName);
|
||||
if (toolSchema) {
|
||||
argsToEmit = stripEmptyOptionalToolArgs(argsToEmit, rawName, toolSchema);
|
||||
}
|
||||
if (argsToEmit != null && typeof argsToEmit === "object" && !Array.isArray(argsToEmit)) {
|
||||
const cleaned: JsonRecord = { ...(argsToEmit as JsonRecord) };
|
||||
for (const [k, v] of Object.entries(cleaned)) {
|
||||
@@ -229,7 +239,6 @@ export function translateNonStreamingResponse(
|
||||
|
||||
const fnArgs =
|
||||
typeof argsToEmit === "string" ? argsToEmit : JSON.stringify(argsToEmit || {});
|
||||
const rawName = toString(itemObj.name);
|
||||
// Strip Claude OAuth proxy_ prefix using toolNameMap
|
||||
const resolvedName = caseInsensitiveToolNameLookup(rawName, toolNameMap) ?? rawName;
|
||||
toolCalls.push({
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import type { ModelCapabilityResolutionSnapshot } from "@/lib/modelCapabilities";
|
||||
|
||||
import type { AutoVariant } from "./autoPrefix";
|
||||
import { VALID_VARIANTS } from "./autoPrefix";
|
||||
import type { PreparedVirtualAutoComboInputs } from "./virtualFactory";
|
||||
@@ -119,8 +121,7 @@ export function isPaidTierAutoId(autoId: string): boolean {
|
||||
* a candidate filter so the virtual combo only scores vision-capable models.
|
||||
*/
|
||||
export type BuiltinAutoSpec =
|
||||
| { variant: AutoVariant | undefined }
|
||||
| { category: AutoCategory; tier?: AutoTier };
|
||||
{ variant: AutoVariant | undefined } | { category: AutoCategory; tier?: AutoTier };
|
||||
|
||||
/**
|
||||
* Vision-flavored flat ids that MUST resolve to the `vision` category (candidate
|
||||
@@ -159,9 +160,14 @@ export function resolveBuiltinAutoSpec(modelStr: string, suffix: string): Builti
|
||||
return { variant: undefined };
|
||||
}
|
||||
|
||||
export async function prepareBuiltinAutoComboInputs(): Promise<PreparedVirtualAutoComboInputs> {
|
||||
export async function prepareBuiltinAutoComboInputs(
|
||||
resolutionSnapshot?: ModelCapabilityResolutionSnapshot
|
||||
): Promise<PreparedVirtualAutoComboInputs> {
|
||||
const { prepareVirtualAutoComboInputs } = await import("./virtualFactory.ts");
|
||||
return prepareVirtualAutoComboInputs({ includeResolvedCapabilities: true });
|
||||
return prepareVirtualAutoComboInputs({
|
||||
includeResolvedCapabilities: true,
|
||||
resolutionSnapshot,
|
||||
});
|
||||
}
|
||||
|
||||
export async function createBuiltinAutoCombo(
|
||||
|
||||
@@ -404,7 +404,9 @@ export function computeAdvertisedLimits(candidates: AdvertisedLimitCandidate[]):
|
||||
return { contextLength, maxOutputTokens };
|
||||
}
|
||||
|
||||
const PREPARED_CAPABILITY_YIELD_INTERVAL = 16;
|
||||
// Catalog-scale pools can contain hundreds of models. Keep both candidate construction
|
||||
// and capability preparation cooperative instead of monopolising one event-loop turn.
|
||||
const VIRTUAL_AUTO_PREPARATION_YIELD_INTERVAL = 4;
|
||||
|
||||
type PreparedCapabilityValues = {
|
||||
resolvedContextLength: number | null;
|
||||
@@ -468,7 +470,7 @@ async function attachPreparedCapabilityValues(
|
||||
};
|
||||
byModel.set(candidate.model, values);
|
||||
state.resolvedSinceYield++;
|
||||
if (state.resolvedSinceYield >= PREPARED_CAPABILITY_YIELD_INTERVAL) {
|
||||
if (state.resolvedSinceYield >= VIRTUAL_AUTO_PREPARATION_YIELD_INTERVAL) {
|
||||
state.resolvedSinceYield = 0;
|
||||
await yieldVirtualAutoPreparationTurn();
|
||||
}
|
||||
@@ -479,7 +481,10 @@ async function attachPreparedCapabilityValues(
|
||||
}
|
||||
|
||||
export async function prepareVirtualAutoComboInputs(
|
||||
options: { includeResolvedCapabilities?: boolean } = {}
|
||||
options: {
|
||||
includeResolvedCapabilities?: boolean;
|
||||
resolutionSnapshot?: ModelCapabilityResolutionSnapshot;
|
||||
} = {}
|
||||
): Promise<PreparedVirtualAutoComboInputs> {
|
||||
const [connections, disabledNoAuthConnections, settings] = await Promise.all([
|
||||
getCachedProviderConnections({ isActive: true }) as Promise<VirtualFactoryConn[]>,
|
||||
@@ -524,6 +529,7 @@ export async function prepareVirtualAutoComboInputs(
|
||||
// Build one logical candidate per provider/model and keep account fallback as an
|
||||
// allowlist on that candidate. This avoids both the old "first registry model per
|
||||
// connection" blind spot and a connections × models Cartesian candidate pool.
|
||||
let candidateModelsSinceYield = 0;
|
||||
for (const [providerId, providerConnections] of connectionsByProvider) {
|
||||
const providerInfo = registry[providerId];
|
||||
const registryModelIds = Array.isArray(providerInfo?.models)
|
||||
@@ -557,6 +563,11 @@ export async function prepareVirtualAutoComboInputs(
|
||||
: Array.from(new Set([...registryModelIds, ...defaultModelIds]));
|
||||
|
||||
for (const modelId of modelIds) {
|
||||
candidateModelsSinceYield++;
|
||||
if (candidateModelsSinceYield >= VIRTUAL_AUTO_PREPARATION_YIELD_INTERVAL) {
|
||||
candidateModelsSinceYield = 0;
|
||||
await yieldVirtualAutoPreparationTurn();
|
||||
}
|
||||
if (hiddenModels?.has(modelId)) continue;
|
||||
|
||||
const allowedConnectionIds = providerConnections
|
||||
@@ -655,7 +666,7 @@ export async function prepareVirtualAutoComboInputs(
|
||||
const capabilityState: PreparedCapabilityState = {
|
||||
byTarget: new Map(),
|
||||
resolvedSinceYield: 0,
|
||||
resolutionSnapshot: createModelCapabilityResolutionSnapshot(),
|
||||
resolutionSnapshot: options.resolutionSnapshot ?? createModelCapabilityResolutionSnapshot(),
|
||||
};
|
||||
return {
|
||||
regularCandidates: await attachPreparedCapabilityValues(regularCandidates, capabilityState),
|
||||
|
||||
40
open-sse/services/compression/compressionWorker.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
import { parentPort } from "node:worker_threads";
|
||||
import {
|
||||
applyCompression,
|
||||
applyStackedCompression,
|
||||
type StackedCompressionStep,
|
||||
} from "./strategySelector.ts";
|
||||
import type {
|
||||
CompressionWorkerJob,
|
||||
CompressionWorkerMessage,
|
||||
} from "./compressionWorkerProtocol.ts";
|
||||
|
||||
if (!parentPort) throw new Error("compressionWorker must run in a worker thread");
|
||||
parentPort.on("message", (job: CompressionWorkerJob) => {
|
||||
try {
|
||||
const onEngineStep = (step: StackedCompressionStep) =>
|
||||
parentPort.postMessage({
|
||||
id: job.id,
|
||||
type: "step",
|
||||
step,
|
||||
} satisfies CompressionWorkerMessage);
|
||||
const result =
|
||||
job.mode === "stacked"
|
||||
? applyStackedCompression(job.body, job.options?.config?.stackedPipeline, {
|
||||
...job.options,
|
||||
onEngineStep,
|
||||
})
|
||||
: applyCompression(job.body, job.mode, job.options);
|
||||
parentPort.postMessage({
|
||||
id: job.id,
|
||||
type: "result",
|
||||
result,
|
||||
} satisfies CompressionWorkerMessage);
|
||||
} catch (error) {
|
||||
parentPort.postMessage({
|
||||
id: job.id,
|
||||
type: "error",
|
||||
error: error instanceof Error ? error.message : String(error),
|
||||
} satisfies CompressionWorkerMessage);
|
||||
}
|
||||
});
|
||||
164
open-sse/services/compression/compressionWorkerPool.ts
Normal file
@@ -0,0 +1,164 @@
|
||||
import { existsSync } from "node:fs";
|
||||
import { dirname, join } from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { Worker } from "node:worker_threads";
|
||||
import type { CompressionResult } from "./types.ts";
|
||||
import type { StackedCompressionStep } from "./strategySelector.ts";
|
||||
import type {
|
||||
CompressionWorkerJob,
|
||||
CompressionWorkerMessage,
|
||||
CompressionWorkerOptions,
|
||||
} from "./compressionWorkerProtocol.ts";
|
||||
|
||||
function positiveInteger(value: string | undefined, fallback: number): number {
|
||||
const parsed = Number(value);
|
||||
return Number.isSafeInteger(parsed) && parsed > 0 ? parsed : fallback;
|
||||
}
|
||||
function workerUrl(): URL {
|
||||
const dir = dirname(fileURLToPath(import.meta.url));
|
||||
for (const name of ["compressionWorker.js", "compressionWorker.ts"]) {
|
||||
if (existsSync(join(dir, name))) return new URL(name, import.meta.url);
|
||||
}
|
||||
return new URL("compressionWorker.js", import.meta.url);
|
||||
}
|
||||
function unchanged(body: Record<string, unknown>): CompressionResult {
|
||||
return { body, compressed: false, stats: null };
|
||||
}
|
||||
interface PendingJob extends CompressionWorkerJob {
|
||||
originalBody: Record<string, unknown>;
|
||||
resolve: (result: CompressionResult) => void;
|
||||
onEngineStep?: (step: StackedCompressionStep) => void;
|
||||
}
|
||||
interface PoolWorker {
|
||||
worker: Worker;
|
||||
job: PendingJob | null;
|
||||
timeout: NodeJS.Timeout | null;
|
||||
idle: NodeJS.Timeout | null;
|
||||
}
|
||||
|
||||
export class CompressionWorkerPool {
|
||||
private readonly queue: PendingJob[] = [];
|
||||
private readonly workers = new Set<PoolWorker>();
|
||||
private nextId = 1;
|
||||
private readonly size: number;
|
||||
private readonly timeoutMs: number;
|
||||
private readonly idleMs: number;
|
||||
|
||||
constructor({
|
||||
size = positiveInteger(process.env.OMNI_COMPRESSION_WORKERS, 2),
|
||||
timeoutMs = positiveInteger(process.env.OMNI_COMPRESSION_WORKER_TIMEOUT_MS, 120_000),
|
||||
idleMs = positiveInteger(process.env.OMNI_COMPRESSION_WORKER_IDLE_MS, 60_000),
|
||||
}: { size?: number; timeoutMs?: number; idleMs?: number } = {}) {
|
||||
this.size = Math.max(1, Math.floor(size));
|
||||
this.timeoutMs = Math.max(1, Math.floor(timeoutMs));
|
||||
this.idleMs = Math.max(1, Math.floor(idleMs));
|
||||
}
|
||||
|
||||
run(
|
||||
body: Record<string, unknown>,
|
||||
mode: CompressionWorkerJob["mode"],
|
||||
options?: CompressionWorkerOptions,
|
||||
onEngineStep?: (step: StackedCompressionStep) => void
|
||||
): Promise<CompressionResult> {
|
||||
return new Promise((resolve) => {
|
||||
this.queue.push({
|
||||
id: this.nextId++,
|
||||
body,
|
||||
mode,
|
||||
options,
|
||||
originalBody: body,
|
||||
resolve,
|
||||
onEngineStep,
|
||||
});
|
||||
this.dispatch();
|
||||
});
|
||||
}
|
||||
async close(): Promise<void> {
|
||||
for (const job of this.queue.splice(0)) job.resolve(unchanged(job.originalBody));
|
||||
await Promise.all([...this.workers].map((slot) => this.remove(slot, true)));
|
||||
}
|
||||
private spawn(): PoolWorker {
|
||||
const slot: PoolWorker = {
|
||||
worker: new Worker(workerUrl()),
|
||||
job: null,
|
||||
timeout: null,
|
||||
idle: null,
|
||||
};
|
||||
this.workers.add(slot);
|
||||
slot.worker.on("message", (message: CompressionWorkerMessage) =>
|
||||
this.handleMessage(slot, message)
|
||||
);
|
||||
slot.worker.on("error", () => this.fail(slot));
|
||||
slot.worker.on("exit", () => {
|
||||
if (this.workers.has(slot)) this.fail(slot);
|
||||
});
|
||||
return slot;
|
||||
}
|
||||
private dispatch(): void {
|
||||
while (this.queue.length) {
|
||||
let slot = [...this.workers].find((candidate) => !candidate.job);
|
||||
if (!slot && this.workers.size < this.size) slot = this.spawn();
|
||||
if (!slot) return;
|
||||
if (slot.idle) clearTimeout(slot.idle);
|
||||
const job = this.queue.shift();
|
||||
if (!job) return;
|
||||
slot.job = job;
|
||||
slot.timeout = setTimeout(() => this.fail(slot!), this.timeoutMs);
|
||||
slot.timeout.unref();
|
||||
const { originalBody: _body, resolve: _resolve, onEngineStep: _step, ...wireJob } = job;
|
||||
slot.worker.postMessage(wireJob);
|
||||
}
|
||||
}
|
||||
private handleMessage(slot: PoolWorker, message: CompressionWorkerMessage): void {
|
||||
const job = slot.job;
|
||||
if (!job || job.id !== message.id) return;
|
||||
if (message.type === "step") {
|
||||
try {
|
||||
job.onEngineStep?.(message.step);
|
||||
} catch {
|
||||
// Telemetry is best-effort.
|
||||
}
|
||||
return;
|
||||
}
|
||||
this.finish(slot, message.type === "result" ? message.result : unchanged(job.originalBody));
|
||||
}
|
||||
private finish(slot: PoolWorker, result: CompressionResult): void {
|
||||
const job = slot.job;
|
||||
if (!job) return;
|
||||
if (slot.timeout) clearTimeout(slot.timeout);
|
||||
slot.timeout = null;
|
||||
slot.job = null;
|
||||
job.resolve(result);
|
||||
slot.idle = setTimeout(() => void this.remove(slot, false), this.idleMs);
|
||||
slot.idle.unref();
|
||||
this.dispatch();
|
||||
}
|
||||
private fail(slot: PoolWorker): void {
|
||||
const job = slot.job;
|
||||
if (job) job.resolve(unchanged(job.originalBody));
|
||||
slot.job = null;
|
||||
void this.remove(slot, true).finally(() => this.dispatch());
|
||||
}
|
||||
private async remove(slot: PoolWorker, terminate: boolean): Promise<void> {
|
||||
if (!this.workers.delete(slot)) return;
|
||||
if (slot.timeout) clearTimeout(slot.timeout);
|
||||
if (slot.idle) clearTimeout(slot.idle);
|
||||
if (terminate) await slot.worker.terminate().catch(() => undefined);
|
||||
}
|
||||
}
|
||||
|
||||
let pool: CompressionWorkerPool | null = null;
|
||||
export function runCompressionInWorker(
|
||||
body: Record<string, unknown>,
|
||||
mode: CompressionWorkerJob["mode"],
|
||||
options?: CompressionWorkerOptions,
|
||||
onEngineStep?: (step: StackedCompressionStep) => void
|
||||
): Promise<CompressionResult> {
|
||||
pool ??= new CompressionWorkerPool();
|
||||
return pool.run(body, mode, options, onEngineStep);
|
||||
}
|
||||
export async function closeCompressionWorkerPoolForTests(): Promise<void> {
|
||||
const active = pool;
|
||||
pool = null;
|
||||
await active?.close();
|
||||
}
|
||||
71
open-sse/services/compression/compressionWorkerProtocol.ts
Normal file
@@ -0,0 +1,71 @@
|
||||
import type { CompressionConfig, CompressionMode, CompressionResult } from "./types.ts";
|
||||
import type { StackedCompressionStep } from "./strategySelector.ts";
|
||||
import type {
|
||||
CompressionStage,
|
||||
CompressionWireFormat,
|
||||
ImageTransportFidelity,
|
||||
} from "./engines/types.ts";
|
||||
|
||||
export interface CompressionWorkerOptions {
|
||||
model?: string;
|
||||
supportsVision?: boolean | null;
|
||||
providerTransport?: "direct" | "aggregator";
|
||||
provider?: string;
|
||||
imageTransportFidelity?: ImageTransportFidelity;
|
||||
sourceFormat?: CompressionWireFormat;
|
||||
targetFormat?: CompressionWireFormat;
|
||||
compressionStage?: CompressionStage;
|
||||
config?: CompressionConfig;
|
||||
}
|
||||
export interface CompressionWorkerJob {
|
||||
id: number;
|
||||
body: Record<string, unknown>;
|
||||
mode: CompressionMode;
|
||||
options?: CompressionWorkerOptions;
|
||||
}
|
||||
export type CompressionWorkerMessage =
|
||||
| { id: number; type: "step"; step: StackedCompressionStep }
|
||||
| { id: number; type: "result"; result: CompressionResult }
|
||||
| { id: number; type: "error"; error: string };
|
||||
|
||||
function isPlainObject(value: object): value is Record<string, unknown> {
|
||||
const prototype = Object.getPrototypeOf(value);
|
||||
return prototype === Object.prototype || prototype === null;
|
||||
}
|
||||
export function isStrictlySerializable(value: unknown, seen = new Set<object>()): boolean {
|
||||
if (
|
||||
value === null ||
|
||||
typeof value === "string" ||
|
||||
typeof value === "boolean" ||
|
||||
typeof value === "number"
|
||||
) {
|
||||
return typeof value !== "number" || Number.isFinite(value);
|
||||
}
|
||||
if (typeof value !== "object" || seen.has(value)) return false;
|
||||
seen.add(value);
|
||||
if (Array.isArray(value)) return value.every((entry) => isStrictlySerializable(entry, seen));
|
||||
if (!isPlainObject(value)) return false;
|
||||
return Object.values(value).every((entry) => isStrictlySerializable(entry, seen));
|
||||
}
|
||||
|
||||
const WORKER_STACK_ENGINES = new Set(["caveman", "rtk", "standard"]);
|
||||
export function isCompressionWorkerEligible(
|
||||
body: Record<string, unknown>,
|
||||
mode: CompressionMode,
|
||||
options?: CompressionWorkerOptions
|
||||
): boolean {
|
||||
if (mode !== "standard" && mode !== "rtk" && mode !== "stacked") return false;
|
||||
if (mode === "stacked") {
|
||||
const pipeline = options?.config?.stackedPipeline;
|
||||
if (!Array.isArray(pipeline) || pipeline.length === 0) return false;
|
||||
if (
|
||||
pipeline.some((step) => {
|
||||
const engine = typeof step === "string" ? step : step.engine;
|
||||
return !WORKER_STACK_ENGINES.has(engine);
|
||||
})
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return isStrictlySerializable({ body, mode, ...(options ? { options } : {}) });
|
||||
}
|
||||
@@ -519,6 +519,28 @@ async function runCompressionAsync(
|
||||
cachingContext?: CachingDetectionContext;
|
||||
}
|
||||
): Promise<CompressionResult> {
|
||||
const workerOptions = options
|
||||
? {
|
||||
model: options.model,
|
||||
supportsVision: options.supportsVision,
|
||||
providerTransport: options.providerTransport,
|
||||
provider: options.provider,
|
||||
imageTransportFidelity: options.imageTransportFidelity,
|
||||
sourceFormat: options.sourceFormat,
|
||||
targetFormat: options.targetFormat,
|
||||
compressionStage: options.compressionStage,
|
||||
config: options.config,
|
||||
}
|
||||
: undefined;
|
||||
const { isCompressionWorkerEligible } = await import("./compressionWorkerProtocol.ts");
|
||||
if (isCompressionWorkerEligible(body, mode, workerOptions)) {
|
||||
try {
|
||||
const { runCompressionInWorker } = await import("./compressionWorkerPool.ts");
|
||||
return await runCompressionInWorker(body, mode, workerOptions, options?.onEngineStep);
|
||||
} catch {
|
||||
return { body, compressed: false, stats: null };
|
||||
}
|
||||
}
|
||||
if (
|
||||
options?.config?.memoizeCompressionResults === true &&
|
||||
// Only memoize for an explicit principal — a missing principalId would collapse
|
||||
|
||||
@@ -12,7 +12,21 @@
|
||||
* `sanitizeReasoningEffortForProvider` in `executors/base/reasoningEffort.ts`)
|
||||
* so the 4xx→retry round-trip is paid at most once per process per provider+model.
|
||||
*
|
||||
* `clampToLearned` implements downgrade-only clamping: greatest accepted <= demand.
|
||||
* `clampToLearned` implements nearest-tier clamping: smallest accepted >= demand,
|
||||
* falling back to the greatest accepted when demand exceeds every accepted value.
|
||||
* (#11295 — unified with the static "declared" clamp in
|
||||
* `executors/base/reasoningEffort.ts`, which already used nearest-tier semantics.
|
||||
* Before #11295, this learned clamp was downgrade-only — greatest accepted <=
|
||||
* demand — so the SAME accepted set {low,high,max} produced medium→low here but
|
||||
* medium→high via the declared path: identical inputs, opposite outputs,
|
||||
* depending only on whether the model had a static registry entry. #11274's
|
||||
* DeepSeek native mapping is the precedent for nearest-tier. This also fixes a
|
||||
* standalone bug: a request BELOW the learned floor (e.g. none/minimal on a
|
||||
* model that only ever advertised {low,high,max}) used to return null — no
|
||||
* clamp — so the too-low value passed straight through to the upstream, which
|
||||
* 400'd again on every subsequent request without ever learning a lower floor.
|
||||
* Nearest-tier naturally fixes this too: the smallest accepted value is always
|
||||
* >= any demand below the floor, so it is returned instead of null.
|
||||
*
|
||||
* In-memory only (same operator-accepted tradeoff as the thinking-budget cache):
|
||||
* restart resets, the first request after a restart may re-learn at the cost of
|
||||
@@ -132,25 +146,39 @@ export function recordLearnedReasoningEffort(
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the greatest accepted value <= effortStr (downgrade only), or null
|
||||
* if effortStr is already accepted, below the minimum, or not in ORDER.
|
||||
* Return the nearest-tier accepted value for effortStr: the smallest accepted
|
||||
* value with rank >= effortStr's rank, or — when effortStr's rank exceeds every
|
||||
* accepted value (demand above the learned ceiling) — the greatest accepted
|
||||
* value. Returns null only when effortStr is already accepted (no clamp
|
||||
* needed), empty, or not a recognized member of REASONING_EFFORT_ORDER.
|
||||
*
|
||||
* Mirrors the declared-capability clamp in `executors/base/reasoningEffort.ts`
|
||||
* (#11295): both now use nearest-tier semantics so the same accepted set
|
||||
* produces the same mapping regardless of whether the model has a static
|
||||
* registry entry or was only learned reactively from an upstream 4xx.
|
||||
*/
|
||||
export function clampToLearned(effortStr: string, accepted: Set<string>): string | null {
|
||||
if (!effortStr || accepted.has(effortStr)) return null;
|
||||
const rank = rankOf(effortStr);
|
||||
if (rank === -1) return null;
|
||||
const minRank = Math.min(...[...accepted].map((v) => rankOf(v)));
|
||||
if (rank < minRank) return null;
|
||||
let best: string | null = null;
|
||||
let bestRank = -1;
|
||||
|
||||
let nearestAbove: string | null = null;
|
||||
let nearestAboveRank = Infinity;
|
||||
let highest: string | null = null;
|
||||
let highestRank = -1;
|
||||
for (const v of accepted) {
|
||||
const r = rankOf(v);
|
||||
if (r <= rank && r > bestRank) {
|
||||
bestRank = r;
|
||||
best = v;
|
||||
if (r < 0) continue;
|
||||
if (r >= rank && r < nearestAboveRank) {
|
||||
nearestAboveRank = r;
|
||||
nearestAbove = v;
|
||||
}
|
||||
if (r > highestRank) {
|
||||
highestRank = r;
|
||||
highest = v;
|
||||
}
|
||||
}
|
||||
return best;
|
||||
return nearestAbove ?? highest;
|
||||
}
|
||||
|
||||
// Matches prose shapes: OVH's "@ai-sdk/openai-compatible" deserializer
|
||||
|
||||
@@ -28,12 +28,10 @@ export async function refreshCopilotToken(
|
||||
);
|
||||
|
||||
if (!response.ok) {
|
||||
const errorText = await response.text();
|
||||
log?.error?.("TOKEN_REFRESH", "Failed to refresh Copilot token", {
|
||||
status: response.status,
|
||||
error: errorText,
|
||||
});
|
||||
return null;
|
||||
return { status: response.status };
|
||||
}
|
||||
|
||||
const data = await response.json();
|
||||
@@ -49,8 +47,8 @@ export async function refreshCopilotToken(
|
||||
};
|
||||
} catch (error) {
|
||||
log?.error?.("TOKEN_REFRESH", "Error refreshing Copilot token", {
|
||||
error: error.message,
|
||||
errorType: error?.name || "Error",
|
||||
});
|
||||
return null;
|
||||
return { status: null };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -290,6 +290,31 @@ export function coerceToolSchemas(tools: unknown): unknown {
|
||||
});
|
||||
}
|
||||
|
||||
const NULL_OMISSION_NOTE = "null = omit this parameter";
|
||||
|
||||
function schemaTypeIncludes(type: unknown, wanted: string): boolean {
|
||||
return type === wanted || (Array.isArray(type) && type.includes(wanted));
|
||||
}
|
||||
|
||||
function isPlainStringType(type: unknown): boolean {
|
||||
return type === "string" || (Array.isArray(type) && type.length === 1 && type[0] === "string");
|
||||
}
|
||||
|
||||
function appendNullOmissionMarker(description: unknown): string {
|
||||
if (typeof description === "string" && description.length > 0) {
|
||||
return description.includes(NULL_OMISSION_NOTE)
|
||||
? description
|
||||
: `${description} (${NULL_OMISSION_NOTE})`;
|
||||
}
|
||||
return NULL_OMISSION_NOTE;
|
||||
}
|
||||
|
||||
function widenTypeWithNull(type: unknown): unknown {
|
||||
if (typeof type === "string") return [type, "null"];
|
||||
if (Array.isArray(type) && !type.includes("null")) return [...type, "null"];
|
||||
return type;
|
||||
}
|
||||
|
||||
// #7023 — Responses API strict mode forces every "optional" tool property into
|
||||
// `required`, so a model that intends to OMIT an optional enum property (no declared
|
||||
// `default`) must still emit a concrete value (e.g. Agent.isolation:"remote"). Neither
|
||||
@@ -299,7 +324,11 @@ export function coerceToolSchemas(tools: unknown): unknown {
|
||||
// `null` (see pureHelpers.ts::isDroppableNullEntry). Scope: top-level
|
||||
// `properties[key].enum` only — does not recurse into `items`/`anyOf`/`oneOf` branches
|
||||
// (no real-world case beyond Agent.isolation is documented; extend with a concrete repro).
|
||||
function shouldInjectNullOmission(key: string, propSchema: unknown, required: Set<string>): boolean {
|
||||
function shouldInjectNullOmission(
|
||||
key: string,
|
||||
propSchema: unknown,
|
||||
required: Set<string>
|
||||
): boolean {
|
||||
return (
|
||||
isPlainObject(propSchema) &&
|
||||
Array.isArray(propSchema.enum) &&
|
||||
@@ -312,19 +341,38 @@ function widenPropertyForNullOmission(propSchema: JsonRecord): JsonRecord {
|
||||
const widened: JsonRecord = { ...propSchema };
|
||||
const enumValues = propSchema.enum as unknown[];
|
||||
widened.enum = enumValues.includes(null) ? enumValues : [...enumValues, null];
|
||||
if (typeof propSchema.type === "string") {
|
||||
widened.type = [propSchema.type, "null"];
|
||||
} else if (Array.isArray(propSchema.type) && !propSchema.type.includes("null")) {
|
||||
widened.type = [...propSchema.type, "null"];
|
||||
}
|
||||
const note = "null = omit this parameter";
|
||||
widened.description =
|
||||
typeof propSchema.description === "string" && propSchema.description.length > 0
|
||||
? `${propSchema.description} (${note})`
|
||||
: note;
|
||||
widened.type = widenTypeWithNull(propSchema.type);
|
||||
widened.description = appendNullOmissionMarker(propSchema.description);
|
||||
return widened;
|
||||
}
|
||||
|
||||
// OpenCode `subagent.sessionID` (and any other optional default-less plain string) has
|
||||
// the same strict-mode omission problem as #7023 enums, but no enum to widen. Inject
|
||||
// the same nullable-union sentinel on top-level `properties[key]` only — do not recurse
|
||||
// into `items`/`anyOf`/`$defs`, and do not touch enums (owned by the helper above).
|
||||
function shouldInjectStringNullOmission(
|
||||
key: string,
|
||||
propSchema: unknown,
|
||||
required: Set<string>
|
||||
): boolean {
|
||||
return (
|
||||
isPlainObject(propSchema) &&
|
||||
!Array.isArray(propSchema.enum) &&
|
||||
isPlainStringType(propSchema.type) &&
|
||||
!schemaTypeIncludes(propSchema.type, "null") &&
|
||||
!required.has(key) &&
|
||||
!hasOwn(propSchema, "default")
|
||||
);
|
||||
}
|
||||
|
||||
function widenStringPropertyForNullOmission(propSchema: JsonRecord): JsonRecord {
|
||||
return {
|
||||
...propSchema,
|
||||
type: widenTypeWithNull(propSchema.type),
|
||||
description: appendNullOmissionMarker(propSchema.description),
|
||||
};
|
||||
}
|
||||
|
||||
export function injectOptionalEnumOmissionSentinel(schema: unknown): unknown {
|
||||
if (!isPlainObject(schema) || !isPlainObject(schema.properties)) return schema;
|
||||
|
||||
@@ -356,6 +404,43 @@ export function injectOptionalEnumOmissionForTools(tools: unknown): unknown {
|
||||
});
|
||||
}
|
||||
|
||||
export function injectOptionalStringOmissionSentinel(schema: unknown): unknown {
|
||||
if (!isPlainObject(schema) || !isPlainObject(schema.properties)) return schema;
|
||||
|
||||
const required = new Set(Array.isArray(schema.required) ? schema.required : []);
|
||||
let changed = false;
|
||||
const nextProperties: JsonRecord = { ...schema.properties };
|
||||
|
||||
for (const [key, propSchema] of Object.entries(schema.properties)) {
|
||||
if (!shouldInjectStringNullOmission(key, propSchema, required)) continue;
|
||||
nextProperties[key] = widenStringPropertyForNullOmission(propSchema as JsonRecord);
|
||||
changed = true;
|
||||
}
|
||||
|
||||
if (!changed) return schema;
|
||||
return { ...schema, properties: nextProperties };
|
||||
}
|
||||
|
||||
export function injectOptionalStringOmissionForTools(tools: unknown): unknown {
|
||||
if (!Array.isArray(tools)) return tools;
|
||||
|
||||
return tools.map((tool) => {
|
||||
if (!isPlainObject(tool)) return tool;
|
||||
|
||||
const result: JsonRecord = { ...tool };
|
||||
if (isPlainObject(result.function) && "parameters" in result.function) {
|
||||
result.function = {
|
||||
...result.function,
|
||||
parameters: injectOptionalStringOmissionSentinel(result.function.parameters),
|
||||
};
|
||||
}
|
||||
if ("parameters" in result && !isPlainObject(result.function)) {
|
||||
result.parameters = injectOptionalStringOmissionSentinel(result.parameters);
|
||||
}
|
||||
return result;
|
||||
});
|
||||
}
|
||||
|
||||
export function sanitizeToolDescriptions(tools: unknown): unknown {
|
||||
if (!Array.isArray(tools)) return tools;
|
||||
return tools.map((tool) => sanitizeToolDescription(tool));
|
||||
|
||||
@@ -18,6 +18,7 @@ import {
|
||||
coerceToolSchemas,
|
||||
injectEmptyReasoningContentForToolCalls,
|
||||
injectOptionalEnumOmissionForTools,
|
||||
injectOptionalStringOmissionForTools,
|
||||
sanitizeToolDescriptions,
|
||||
} from "./helpers/schemaCoercion.ts";
|
||||
import { getRequestTranslator, getResponseTranslator } from "./registry.ts";
|
||||
@@ -595,6 +596,12 @@ export function translateRequest(
|
||||
}
|
||||
|
||||
if (result.tools !== undefined) {
|
||||
// Plain-string omission must run before coerceToolSchemas() strips `default`,
|
||||
// so defaulted optional strings stay unsentinelled. Enum injection stays after
|
||||
// coercion to preserve the #7023 pipeline.
|
||||
if (targetFormat === FORMATS.OPENAI_RESPONSES) {
|
||||
result.tools = injectOptionalStringOmissionForTools(result.tools);
|
||||
}
|
||||
result.tools = coerceToolSchemas(result.tools);
|
||||
result.tools = sanitizeToolDescriptions(result.tools);
|
||||
if (targetFormat === FORMATS.OPENAI_RESPONSES) {
|
||||
|
||||
@@ -866,13 +866,13 @@ export function openaiResponsesToOpenAIResponse(chunk, state) {
|
||||
|
||||
function openaiResponsesToOpenAIResponseStream(chunk, state) {
|
||||
if (!chunk) {
|
||||
// Iterate every still-open call needing schema-aware normalization, not just a
|
||||
// single one — multiple parallel calls can each be pending here if the stream
|
||||
// ends before their output_item.done arrives.
|
||||
// Iterate every still-open call with a buffered argument payload — argument
|
||||
// deltas are buffered for every tool, so an incomplete stream must flush every
|
||||
// buffered call, not only the historical uppercase Agent path.
|
||||
const pendingNormalized: Array<{ index: number; argsStr: string }> = [];
|
||||
if (state.toolCallByCallId instanceof Map) {
|
||||
for (const entry of state.toolCallByCallId.values()) {
|
||||
if (entry.needsNormalization && entry.argsBuffer) {
|
||||
if (entry.argsBuffer) {
|
||||
const toolSchema = state.toolSchemas?.get(entry.name);
|
||||
const argsToEmit = stripEmptyOptionalToolArgs(entry.argsBuffer, entry.name, toolSchema);
|
||||
pendingNormalized.push({
|
||||
|
||||
@@ -56,21 +56,35 @@ function isDroppableEmptyEntry(entry, propSchema, required, key, allowlisted) {
|
||||
return allowlisted || (propSchema != null && !required.has(key));
|
||||
}
|
||||
|
||||
// #7023 — the request-side counterpart (injectOptionalEnumOmissionSentinel) widens
|
||||
// no-default optional enum properties to accept `null`, meaning "omitted" (OpenAI's own
|
||||
// nullable-union idiom for Responses-API strict mode). Drop the key when the model
|
||||
// follows that idiom for a non-required, schema-declared property.
|
||||
function schemaTypeIncludes(type, wanted) {
|
||||
return type === wanted || (Array.isArray(type) && type.includes(wanted));
|
||||
}
|
||||
|
||||
function hasOmissionSentinel(propSchema) {
|
||||
if (!propSchema || typeof propSchema !== "object") return false;
|
||||
if (
|
||||
typeof propSchema.description !== "string" ||
|
||||
!propSchema.description.includes("null = omit this parameter")
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
return (
|
||||
schemaTypeIncludes(propSchema.type, "null") ||
|
||||
(Array.isArray(propSchema.enum) && propSchema.enum.includes(null))
|
||||
);
|
||||
}
|
||||
|
||||
// #7023 — the request-side counterpart widens no-default optional properties to accept
|
||||
// `null`, meaning "omitted" (OpenAI's own nullable-union idiom for Responses-API strict
|
||||
// mode). Enums use injectOptionalEnumOmissionSentinel; plain strings use
|
||||
// injectOptionalStringOmissionSentinel. Drop the key when the model follows that idiom
|
||||
// for a non-required, schema-declared property, or when OmniRoute's marker is present
|
||||
// even after an upstream strictifies the field into `required`.
|
||||
function isDroppableNullEntry(entry, propSchema, required, key, toolName) {
|
||||
if (entry !== null) return false;
|
||||
if (toolName === "Agent") return true;
|
||||
if (propSchema == null) return false;
|
||||
const omissionSentinel =
|
||||
typeof propSchema === "object" &&
|
||||
Array.isArray(propSchema.enum) &&
|
||||
propSchema.enum.includes(null) &&
|
||||
typeof propSchema.description === "string" &&
|
||||
propSchema.description.includes("null = omit this parameter");
|
||||
return !required.has(key) || omissionSentinel;
|
||||
return !required.has(key) || hasOmissionSentinel(propSchema);
|
||||
}
|
||||
|
||||
function stripEmptyOptionalToolArgsObject(value, toolName, schema) {
|
||||
@@ -110,7 +124,11 @@ export function stripEmptyOptionalToolArgs(value, toolName, schema) {
|
||||
// supplied (schema-aware normalization is not restricted to the allowlist).
|
||||
// "Agent" also passes without a schema: isDroppableNullEntry drops its null
|
||||
// omission sentinels even when the strict schema snapshot is unavailable (#9423).
|
||||
if (!hasUsableSchema(schema) && !STRIPPABLE_EMPTY_ARG_TOOLS.has(toolName) && toolName !== "Agent") {
|
||||
if (
|
||||
!hasUsableSchema(schema) &&
|
||||
!STRIPPABLE_EMPTY_ARG_TOOLS.has(toolName) &&
|
||||
toolName !== "Agent"
|
||||
) {
|
||||
return value;
|
||||
}
|
||||
try {
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
packages:
|
||||
- "packages/*"
|
||||
- "open-sse"
|
||||
# Match `.npmrc`'s legacy-peer-deps posture. OmniRoute imports only the deep
|
||||
# icon modules from @lobehub/icons; auto-installing its unused @lobehub/ui peer
|
||||
# pulls a large UI subtree (including packages without distributable licenses).
|
||||
autoInstallPeers: false
|
||||
allowBuilds:
|
||||
"@parcel/watcher": true
|
||||
"@swc/core": true
|
||||
|
||||
@@ -33,6 +33,14 @@ const STANDALONE = process.env.OMNIROUTE_STANDALONE_DIR
|
||||
|
||||
const CALL_LOG_WORKER_REL = join("src", "lib", "usage", "callLogArtifactWorker.js");
|
||||
const CALL_LOG_WORKER_SRC = join(ROOT, "src", "lib", "usage", "callLogArtifactWorker.ts");
|
||||
const COMPRESSION_WORKER_REL = join("open-sse", "services", "compression", "compressionWorker.js");
|
||||
const COMPRESSION_WORKER_SRC = join(
|
||||
ROOT,
|
||||
"open-sse",
|
||||
"services",
|
||||
"compression",
|
||||
"compressionWorker.ts"
|
||||
);
|
||||
const WORKER_REL = join(
|
||||
"open-sse",
|
||||
"services",
|
||||
@@ -107,9 +115,26 @@ function main() {
|
||||
);
|
||||
console.log("[colocate-standalone] ✅ call-log artifact worker bundled");
|
||||
|
||||
const compressionWorkerDest = join(STANDALONE, COMPRESSION_WORKER_REL);
|
||||
mkdirSync(dirname(compressionWorkerDest), { recursive: true });
|
||||
runBuildTool(
|
||||
"esbuild",
|
||||
"esbuild",
|
||||
[
|
||||
COMPRESSION_WORKER_SRC,
|
||||
"--bundle",
|
||||
"--platform=node",
|
||||
"--packages=external",
|
||||
"--format=esm",
|
||||
`--outfile=${compressionWorkerDest}`,
|
||||
],
|
||||
{ stdio: "inherit" }
|
||||
);
|
||||
console.log("[colocate-standalone] ✅ compression worker bundled");
|
||||
|
||||
// The call-log worker is always present; scope it to ESM immediately. The
|
||||
// optional LLMLingua worker dir is added below only when its deps are installed.
|
||||
const workerDirs = [dirname(callLogWorkerDest)];
|
||||
const workerDirs = [dirname(callLogWorkerDest), dirname(compressionWorkerDest)];
|
||||
|
||||
if (!hasOptionals) {
|
||||
console.log(
|
||||
|
||||
@@ -45,6 +45,7 @@ export const APP_STAGING_ALLOWED_EXACT_PATHS: string[] = [
|
||||
// LLMLingua ONNX worker — esbuild'd standalone .js spawned via worker_threads
|
||||
// (the Next.js bundler can't trace the computed Worker path). Kept like the MCP server.
|
||||
"open-sse/services/compression/engines/llmlingua/onnxWorker.js",
|
||||
"open-sse/services/compression/compressionWorker.js",
|
||||
"src/lib/usage/callLogArtifactWorker.js",
|
||||
"package.json",
|
||||
"peer-stamp.mjs",
|
||||
@@ -312,13 +313,27 @@ export const PACK_ARTIFACT_NEVER_ALLOWED_SEGMENTS: string[] = ["node_modules"];
|
||||
|
||||
export function findUnexpectedArtifactPaths(
|
||||
filePaths: string[],
|
||||
{ exactPaths = [], prefixPaths = [] }: { exactPaths?: string[]; prefixPaths?: string[] } = {}
|
||||
{
|
||||
exactPaths = [],
|
||||
prefixPaths = [],
|
||||
// #9985: the app-STAGING prune (prepublish Step 10.7) must be able to opt out
|
||||
// of the node_modules segment ban — the standalone server's runtime deps live
|
||||
// under dist/node_modules and Turbopack-hashed dirs (.build/next/node_modules/
|
||||
// sql.js-*/dist/sql-wasm.wasm, transformers ort-wasm). Pruning them 500'd every
|
||||
// DB-backed route in packaged boots while /api/monitoring/health stayed green.
|
||||
// The PUBLISH gate (validate-pack-artifact) keeps the strict default.
|
||||
neverAllowedSegments = PACK_ARTIFACT_NEVER_ALLOWED_SEGMENTS,
|
||||
}: {
|
||||
exactPaths?: string[];
|
||||
prefixPaths?: string[];
|
||||
neverAllowedSegments?: string[];
|
||||
} = {}
|
||||
): string[] {
|
||||
const normalizedExact = new Set(exactPaths.map(normalizeArtifactPath));
|
||||
const normalizedPrefixes = prefixPaths.map(normalizeArtifactPath);
|
||||
|
||||
const hasForbiddenSegment = (filePath: string): boolean =>
|
||||
filePath.split("/").some((segment) => PACK_ARTIFACT_NEVER_ALLOWED_SEGMENTS.includes(segment));
|
||||
filePath.split("/").some((segment) => neverAllowedSegments.includes(segment));
|
||||
|
||||
return filePaths
|
||||
.map(normalizeArtifactPath)
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
import { existsSync, lstatSync, readdirSync, rmSync } from "node:fs";
|
||||
import { existsSync, lstatSync, mkdirSync, readdirSync, rmSync } from "node:fs";
|
||||
import { basename, dirname, join, relative } from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { assembleStandalone } from "./assembleStandalone.mjs";
|
||||
import { assertSqlitePrebuildExists } from "./electronRebuildPlan.mjs";
|
||||
import { pruneElectronRuntimeDocs } from "./electronRuntimeDocs.mjs";
|
||||
import { stageOptionalPacks } from "./optionalPackStaging.mjs";
|
||||
import { runBuildTool } from "./buildToolRunner.mjs";
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = dirname(__filename);
|
||||
@@ -169,6 +170,27 @@ assembleStandalone({
|
||||
// app they would point at the build machine's absolute paths and break on install.
|
||||
materializeSymlinks: true,
|
||||
});
|
||||
const compressionWorkerDest = join(
|
||||
ELECTRON_STANDALONE_DIR,
|
||||
"open-sse",
|
||||
"services",
|
||||
"compression",
|
||||
"compressionWorker.js"
|
||||
);
|
||||
mkdirSync(dirname(compressionWorkerDest), { recursive: true });
|
||||
runBuildTool(
|
||||
"esbuild",
|
||||
"esbuild",
|
||||
[
|
||||
join(ROOT, "open-sse", "services", "compression", "compressionWorker.ts"),
|
||||
"--bundle",
|
||||
"--platform=node",
|
||||
"--packages=external",
|
||||
"--format=esm",
|
||||
`--outfile=${compressionWorkerDest}`,
|
||||
],
|
||||
{ stdio: "inherit" }
|
||||
);
|
||||
|
||||
const docsPrune = pruneElectronRuntimeDocs(ELECTRON_STANDALONE_DIR);
|
||||
if (docsPrune.removedFiles > 0) {
|
||||
|
||||
@@ -407,6 +407,40 @@ if (existsSync(llmWorkerSrc)) {
|
||||
}
|
||||
}
|
||||
|
||||
// ── Step 8.6b: Bundle synchronous compression worker ──────────────────
|
||||
const compressionWorkerSrc = join(
|
||||
ROOT,
|
||||
"open-sse",
|
||||
"services",
|
||||
"compression",
|
||||
"compressionWorker.ts"
|
||||
);
|
||||
const compressionWorkerDest = join(
|
||||
DIST_DIR,
|
||||
"open-sse",
|
||||
"services",
|
||||
"compression",
|
||||
"compressionWorker.js"
|
||||
);
|
||||
if (!existsSync(compressionWorkerSrc)) {
|
||||
throw new Error("Required compression worker source is missing");
|
||||
}
|
||||
console.log(" 🔨 Bundling compression worker...");
|
||||
mkdirSync(dirname(compressionWorkerDest), { recursive: true });
|
||||
runBuildTool(
|
||||
"esbuild",
|
||||
"esbuild",
|
||||
[
|
||||
"open-sse/services/compression/compressionWorker.ts",
|
||||
"--bundle",
|
||||
"--platform=node",
|
||||
"--packages=external",
|
||||
"--format=esm",
|
||||
"--outfile=dist/open-sse/services/compression/compressionWorker.js",
|
||||
],
|
||||
{ cwd: ROOT, stdio: "inherit" }
|
||||
);
|
||||
|
||||
// ── Step 8.7: Bundle CLI Entrypoint ──────────────────────────
|
||||
const cliSrcFile = join(ROOT, "bin", "omniroute.ts");
|
||||
const cliDestFile = join(ROOT, "bin", "omniroute.mjs");
|
||||
@@ -639,10 +673,15 @@ for (const relativePath of APP_STAGING_REMOVAL_PATHS) {
|
||||
}
|
||||
|
||||
// ── Step 10.7: Prune any staged dist/ file outside the allowed runtime set ──
|
||||
// #9985: neverAllowedSegments is EMPTY here on purpose — unlike the publish
|
||||
// tarball gate, the staged dist/ legitimately contains node_modules (the
|
||||
// standalone server's runtime deps, including Turbopack-hashed packages whose
|
||||
// wasm files DB init requires). The allowlist prefixes above are the contract.
|
||||
const stagedFiles = walkFiles(DIST_DIR);
|
||||
const unexpectedStagedFiles = findUnexpectedArtifactPaths(stagedFiles, {
|
||||
exactPaths: APP_STAGING_ALLOWED_EXACT_PATHS,
|
||||
prefixPaths: APP_STAGING_ALLOWED_PATH_PREFIXES,
|
||||
neverAllowedSegments: [],
|
||||
});
|
||||
|
||||
if (unexpectedStagedFiles.length > 0) {
|
||||
@@ -657,6 +696,7 @@ if (unexpectedStagedFiles.length > 0) {
|
||||
const remainingUnexpectedFiles = findUnexpectedArtifactPaths(walkFiles(DIST_DIR), {
|
||||
exactPaths: APP_STAGING_ALLOWED_EXACT_PATHS,
|
||||
prefixPaths: APP_STAGING_ALLOWED_PATH_PREFIXES,
|
||||
neverAllowedSegments: [],
|
||||
});
|
||||
|
||||
if (remainingUnexpectedFiles.length > 0) {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#!/usr/bin/env node
|
||||
// scripts/check/check-changelog-integrity.mjs
|
||||
//
|
||||
// Anti "CHANGELOG-eat" gate: no bullet line that exists in the BASE branch's
|
||||
// CHANGELOG.md may disappear in the merge result. The chronic failure mode is
|
||||
// Anti "CHANGELOG-eat" gate: no bullet-line occurrence that exists in the BASE
|
||||
// branch's CHANGELOG.md may disappear in the merge result. The chronic failure mode is
|
||||
// git's merge auto-resolve silently dropping sibling bullets (or whole version
|
||||
// sections) when two branches touch adjacent CHANGELOG lines — incident
|
||||
// 2026-07-05: PR #6193's merge ate 212 lines (the entire [3.8.45] + [3.8.44]
|
||||
@@ -16,47 +16,221 @@
|
||||
// quality.yml runs it blocking for own-origin PRs and report-only for forks.
|
||||
// The release captain's reconciliation rewrites the CHANGELOG legitimately,
|
||||
// but that happens on the release PR (PR → main, ci.yml), which does not run
|
||||
// this gate. Escape hatch for intentional removals (e.g. reverting a reverted
|
||||
// feature's bullet): ALLOW_CHANGELOG_REMOVALS=1 turns failures into a report.
|
||||
// this gate. There is no runtime escape hatch: every unexplained removal fails.
|
||||
// Intentional rewrites require a reviewed record in
|
||||
// config/release/changelog-reconciliations.json. Each record binds the complete base
|
||||
// and result files by SHA-256 and lists the exact removed/added bullet-line multiset;
|
||||
// repeated strings encode repeated occurrences. The gate deliberately protects
|
||||
// bullet lines, not standalone headings, dates, or prose outside a bullet.
|
||||
//
|
||||
// Usage:
|
||||
// node scripts/check/check-changelog-integrity.mjs
|
||||
// env GITHUB_BASE_REF PR base branch (CI); local fallback: current release/*
|
||||
// env CHANGELOG_BASE_REF explicit ref override (e.g. origin/release/v3.8.45)
|
||||
// env ALLOW_CHANGELOG_REMOVALS=1 report-only (never fails)
|
||||
|
||||
import { execFileSync } from "node:child_process";
|
||||
import { createHash } from "node:crypto";
|
||||
import { existsSync, readFileSync, readdirSync } from "node:fs";
|
||||
import { dirname, join } from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
const ROOT = join(dirname(fileURLToPath(import.meta.url)), "..", "..");
|
||||
const CHANGELOG = "CHANGELOG.md";
|
||||
const RECONCILIATIONS = "config/release/changelog-reconciliations.json";
|
||||
const FRAGMENTS_DIR = "changelog.d";
|
||||
const FRAGMENT_SECTIONS = ["features", "fixes", "maintenance"];
|
||||
const FRAGMENT_SKIP = new Set(["README.md", ".gitkeep"]);
|
||||
const SHA256_PATTERN = /^[0-9a-f]{64}$/;
|
||||
const RECONCILIATION_KEYS = new Set([
|
||||
"id",
|
||||
"reason",
|
||||
"baseChangelogSha256",
|
||||
"resultChangelogSha256",
|
||||
"removedBullets",
|
||||
"addedBullets",
|
||||
]);
|
||||
|
||||
/** Extract the set of bullet lines (trimmed) from a CHANGELOG text. */
|
||||
export function extractBullets(text) {
|
||||
const bullets = new Set();
|
||||
return new Set(extractBulletOccurrences(text));
|
||||
}
|
||||
|
||||
/** Extract every bullet-line occurrence, preserving order and duplicates. */
|
||||
export function extractBulletOccurrences(text) {
|
||||
const bullets = [];
|
||||
for (const raw of String(text || "").split("\n")) {
|
||||
const line = raw.trim();
|
||||
if (line.startsWith("- ") && line.length > 4) bullets.add(line);
|
||||
if (line.startsWith("- ") && line.length > 4) bullets.push(line);
|
||||
}
|
||||
return bullets;
|
||||
}
|
||||
|
||||
function findMissingOccurrences(sourceText, targetText) {
|
||||
const available = new Map();
|
||||
for (const bullet of extractBulletOccurrences(targetText)) {
|
||||
available.set(bullet, (available.get(bullet) || 0) + 1);
|
||||
}
|
||||
const missing = [];
|
||||
for (const bullet of extractBulletOccurrences(sourceText)) {
|
||||
const count = available.get(bullet) || 0;
|
||||
if (count > 0) available.set(bullet, count - 1);
|
||||
else missing.push(bullet);
|
||||
}
|
||||
return missing;
|
||||
}
|
||||
|
||||
/**
|
||||
* Bullet lines present in the base CHANGELOG but absent from the head
|
||||
* CHANGELOG — the "eaten" set. Pure so it has a unit test.
|
||||
* Bullet-line occurrences present in the base CHANGELOG but absent from the head
|
||||
* CHANGELOG — including one lost copy of a repeated line. Pure so it has a unit test.
|
||||
*/
|
||||
export function findLostBullets(baseText, headText) {
|
||||
const headBullets = extractBullets(headText);
|
||||
const lost = [];
|
||||
for (const b of extractBullets(baseText)) {
|
||||
if (!headBullets.has(b)) lost.push(b);
|
||||
return findMissingOccurrences(baseText, headText);
|
||||
}
|
||||
|
||||
/** Bullet-line occurrences present only in the result CHANGELOG. */
|
||||
export function findAddedBullets(baseText, headText) {
|
||||
return findMissingOccurrences(headText, baseText);
|
||||
}
|
||||
|
||||
/** Stable digest tying a reconciliation record to the complete file, not just its bullets. */
|
||||
export function changelogSha256(text) {
|
||||
return createHash("sha256")
|
||||
.update(String(text || ""), "utf8")
|
||||
.digest("hex");
|
||||
}
|
||||
|
||||
function validateBulletList(value, path, { allowEmpty }) {
|
||||
if (!Array.isArray(value)) return [`${path} must be an array`];
|
||||
const errors = [];
|
||||
if (!allowEmpty && value.length === 0) errors.push(`${path} must not be empty`);
|
||||
for (let index = 0; index < value.length; index++) {
|
||||
const bullet = value[index];
|
||||
if (
|
||||
typeof bullet !== "string" ||
|
||||
bullet !== bullet.trim() ||
|
||||
!bullet.startsWith("- ") ||
|
||||
bullet.length <= 4
|
||||
) {
|
||||
errors.push(`${path}[${index}] must be one exact, trimmed markdown bullet`);
|
||||
}
|
||||
}
|
||||
return lost;
|
||||
return errors;
|
||||
}
|
||||
|
||||
/** Validate the durable reconciliation ledger without trusting any of its claims. */
|
||||
export function validateReconciliationLedger(value) {
|
||||
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
||||
return ["ledger must be a JSON object"];
|
||||
}
|
||||
const errors = [];
|
||||
const topLevelKeys = Object.keys(value);
|
||||
for (const key of topLevelKeys) {
|
||||
if (key !== "schemaVersion" && key !== "reconciliations") {
|
||||
errors.push(`unknown top-level field: ${key}`);
|
||||
}
|
||||
}
|
||||
if (value.schemaVersion !== 1) errors.push("schemaVersion must be 1");
|
||||
if (!Array.isArray(value.reconciliations)) {
|
||||
errors.push("reconciliations must be an array");
|
||||
return errors;
|
||||
}
|
||||
|
||||
const ids = new Set();
|
||||
const filePairs = new Set();
|
||||
for (let index = 0; index < value.reconciliations.length; index++) {
|
||||
const record = value.reconciliations[index];
|
||||
const path = `reconciliations[${index}]`;
|
||||
if (!record || typeof record !== "object" || Array.isArray(record)) {
|
||||
errors.push(`${path} must be an object`);
|
||||
continue;
|
||||
}
|
||||
for (const key of Object.keys(record)) {
|
||||
if (!RECONCILIATION_KEYS.has(key)) errors.push(`${path} has unknown field: ${key}`);
|
||||
}
|
||||
if (typeof record.id !== "string" || !/^[a-z0-9][a-z0-9._-]{2,79}$/.test(record.id)) {
|
||||
errors.push(`${path}.id must be a 3-80 character lowercase slug`);
|
||||
} else if (ids.has(record.id)) {
|
||||
errors.push(`${path}.id duplicates "${record.id}"`);
|
||||
} else {
|
||||
ids.add(record.id);
|
||||
}
|
||||
if (typeof record.reason !== "string" || record.reason.trim().length < 20) {
|
||||
errors.push(`${path}.reason must explain the reconciliation in at least 20 characters`);
|
||||
}
|
||||
if (!SHA256_PATTERN.test(record.baseChangelogSha256 || "")) {
|
||||
errors.push(`${path}.baseChangelogSha256 must be a lowercase SHA-256 digest`);
|
||||
}
|
||||
if (!SHA256_PATTERN.test(record.resultChangelogSha256 || "")) {
|
||||
errors.push(`${path}.resultChangelogSha256 must be a lowercase SHA-256 digest`);
|
||||
}
|
||||
if (
|
||||
SHA256_PATTERN.test(record.baseChangelogSha256 || "") &&
|
||||
record.baseChangelogSha256 === record.resultChangelogSha256
|
||||
) {
|
||||
errors.push(`${path} must describe a changed CHANGELOG.md`);
|
||||
}
|
||||
errors.push(
|
||||
...validateBulletList(record.removedBullets, `${path}.removedBullets`, {
|
||||
allowEmpty: false,
|
||||
}),
|
||||
...validateBulletList(record.addedBullets, `${path}.addedBullets`, { allowEmpty: true })
|
||||
);
|
||||
if (Array.isArray(record.removedBullets) && Array.isArray(record.addedBullets)) {
|
||||
const removed = new Set(record.removedBullets);
|
||||
for (const bullet of record.addedBullets) {
|
||||
if (removed.has(bullet)) errors.push(`${path} lists the same bullet as removed and added`);
|
||||
}
|
||||
}
|
||||
|
||||
const pair = `${record.baseChangelogSha256}:${record.resultChangelogSha256}`;
|
||||
if (filePairs.has(pair)) errors.push(`${path} duplicates an earlier base/result digest pair`);
|
||||
filePairs.add(pair);
|
||||
}
|
||||
return errors;
|
||||
}
|
||||
|
||||
function sameStringMultiset(left, right) {
|
||||
if (left.length !== right.length) return false;
|
||||
const remaining = new Map();
|
||||
for (const item of right) remaining.set(item, (remaining.get(item) || 0) + 1);
|
||||
for (const item of left) {
|
||||
const count = remaining.get(item) || 0;
|
||||
if (count === 0) return false;
|
||||
remaining.set(item, count - 1);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Find the single record that exactly explains this complete base → result transition. */
|
||||
export function findLedgeredReconciliation(baseText, headText, ledger) {
|
||||
const baseChangelogSha256 = changelogSha256(baseText);
|
||||
const resultChangelogSha256 = changelogSha256(headText);
|
||||
const removedBullets = findLostBullets(baseText, headText);
|
||||
const addedBullets = findAddedBullets(baseText, headText);
|
||||
return ledger.reconciliations.find(
|
||||
(record) =>
|
||||
record.baseChangelogSha256 === baseChangelogSha256 &&
|
||||
record.resultChangelogSha256 === resultChangelogSha256 &&
|
||||
sameStringMultiset(record.removedBullets, removedBullets) &&
|
||||
sameStringMultiset(record.addedBullets, addedBullets)
|
||||
);
|
||||
}
|
||||
|
||||
function readReconciliationLedger(root = ROOT) {
|
||||
const path = join(root, RECONCILIATIONS);
|
||||
if (!existsSync(path)) {
|
||||
return { ledger: null, errors: [`${RECONCILIATIONS} is missing`] };
|
||||
}
|
||||
let ledger;
|
||||
try {
|
||||
ledger = JSON.parse(readFileSync(path, "utf8"));
|
||||
} catch (error) {
|
||||
return {
|
||||
ledger: null,
|
||||
errors: [`${RECONCILIATIONS} is not valid JSON: ${error.message}`],
|
||||
};
|
||||
}
|
||||
return { ledger, errors: validateReconciliationLedger(ledger) };
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -111,7 +285,13 @@ function resolveBaseRef() {
|
||||
if (process.env.GITHUB_BASE_REF) return `origin/${process.env.GITHUB_BASE_REF}`;
|
||||
// Local fallback: the highest release/v* on origin (the active development base).
|
||||
try {
|
||||
const branches = git(["branch", "-r", "--list", "origin/release/v*", "--format=%(refname:short)"])
|
||||
const branches = git([
|
||||
"branch",
|
||||
"-r",
|
||||
"--list",
|
||||
"origin/release/v*",
|
||||
"--format=%(refname:short)",
|
||||
])
|
||||
.split("\n")
|
||||
.map((s) => s.trim())
|
||||
.filter(Boolean)
|
||||
@@ -123,16 +303,33 @@ function resolveBaseRef() {
|
||||
}
|
||||
|
||||
function main() {
|
||||
if (Object.hasOwn(process.env, "ALLOW_CHANGELOG_REMOVALS")) {
|
||||
console.error(
|
||||
"[changelog-integrity] ALLOW_CHANGELOG_REMOVALS was removed; delete it from the environment and record intentional transformations in config/release/changelog-reconciliations.json."
|
||||
);
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Fragment well-formedness first (changelog.d/ — the fragments pattern makes the
|
||||
// eat-guard below structurally unnecessary for PRs that stop editing CHANGELOG.md).
|
||||
const invalidFragments = findInvalidFragments();
|
||||
if (invalidFragments.length > 0) {
|
||||
console.error(`[changelog-integrity] ${invalidFragments.length} invalid changelog fragment(s):`);
|
||||
console.error(
|
||||
`[changelog-integrity] ${invalidFragments.length} invalid changelog fragment(s):`
|
||||
);
|
||||
for (const { file, error } of invalidFragments) console.error(` ✗ ${file}: ${error}`);
|
||||
console.error("\nSee changelog.d/README.md for the fragment convention.");
|
||||
return 1;
|
||||
}
|
||||
|
||||
const { ledger, errors: ledgerErrors } = readReconciliationLedger();
|
||||
if (ledgerErrors.length > 0) {
|
||||
console.error(`[changelog-integrity] invalid reconciliation ledger (${ledgerErrors.length}):`);
|
||||
for (const error of ledgerErrors) console.error(` ✗ ${error}`);
|
||||
return 1;
|
||||
}
|
||||
|
||||
const hasExplicitBaseRef = Boolean(process.env.CHANGELOG_BASE_REF || process.env.GITHUB_BASE_REF);
|
||||
const baseRef = resolveBaseRef();
|
||||
if (!baseRef) {
|
||||
console.log("[changelog-integrity] SKIP — could not resolve a base ref (offline/fresh clone).");
|
||||
@@ -143,6 +340,12 @@ function main() {
|
||||
try {
|
||||
baseText = git(["show", `${baseRef}:${CHANGELOG}`]);
|
||||
} catch {
|
||||
if (hasExplicitBaseRef) {
|
||||
console.error(
|
||||
`[changelog-integrity] FAIL — ${CHANGELOG} not readable at explicit base ${baseRef}.`
|
||||
);
|
||||
return 1;
|
||||
}
|
||||
console.log(`[changelog-integrity] SKIP — ${CHANGELOG} not readable at ${baseRef}.`);
|
||||
return 0;
|
||||
}
|
||||
@@ -154,21 +357,30 @@ function main() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
const reconciliation = findLedgeredReconciliation(baseText, headText, ledger);
|
||||
if (reconciliation) {
|
||||
console.log(
|
||||
`[changelog-integrity] OK — ${lost.length} removed base bullet(s) covered by ledgered reconciliation "${reconciliation.id}" vs ${baseRef}.`
|
||||
);
|
||||
return 0;
|
||||
}
|
||||
|
||||
console.error(
|
||||
`[changelog-integrity] ${lost.length} bullet(s) present in ${baseRef} are MISSING from this tree's ${CHANGELOG}:`
|
||||
);
|
||||
for (const b of lost.slice(0, 15)) console.error(` ✗ ${b.slice(0, 160)}`);
|
||||
if (lost.length > 15) console.error(` … and ${lost.length - 15} more`);
|
||||
const added = findAddedBullets(baseText, headText);
|
||||
console.error(
|
||||
"\nThis is the CHANGELOG-eat pattern (merge auto-resolve dropping sibling bullets)." +
|
||||
"\nFix: restore the base CHANGELOG (`git checkout <base> -- CHANGELOG.md`), re-insert ONLY" +
|
||||
"\nyour own bullet, and prove the net diff is additive. Intentional removals (rare):" +
|
||||
"\nre-run with ALLOW_CHANGELOG_REMOVALS=1 and justify in the PR body."
|
||||
"\nyour own bullet, and prove the net diff is additive." +
|
||||
`\nIntentional reconciliation: add one exact, reviewed record to ${RECONCILIATIONS}.` +
|
||||
`\n baseChangelogSha256: ${changelogSha256(baseText)}` +
|
||||
`\n resultChangelogSha256: ${changelogSha256(headText)}` +
|
||||
`\n removedBullets: ${lost.length}; addedBullets: ${added.length}` +
|
||||
"\nThere is no environment-variable bypass."
|
||||
);
|
||||
if (process.env.ALLOW_CHANGELOG_REMOVALS === "1") {
|
||||
console.error("[changelog-integrity] ALLOW_CHANGELOG_REMOVALS=1 — reporting only, not failing.");
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -93,6 +93,14 @@ const ENV_VAR_ALLOWLIST = new Set([
|
||||
"DATA_DIR",
|
||||
"REQUIRE_API_KEY",
|
||||
"OMNIROUTE_BUILD_PROFILE", // build-time only
|
||||
// Docker builder-stage knobs. Both are documented in docs/guides/DOCKER_GUIDE.md
|
||||
// because they are the two levers for a memory-constrained build host, but
|
||||
// neither is read through process.env in this repo: OMNIROUTE_BUILD_WORKERS is
|
||||
// a Dockerfile ARG that only feeds CIRCLE_NODE_TOTAL, and CIRCLE_NODE_TOTAL is
|
||||
// read by Next itself (node_modules) to size the page-data worker pool. Pinned
|
||||
// by tests/unit/docker-build-memory-budget.test.ts.
|
||||
"OMNIROUTE_BUILD_WORKERS",
|
||||
"CIRCLE_NODE_TOTAL",
|
||||
"OMNIROUTE_BUILD_SHA",
|
||||
"OMNIROUTE_URL", // used by ad-hoc tooling, validated elsewhere
|
||||
"OMNIROUTE_KEY", // ditto
|
||||
|
||||
@@ -18,11 +18,13 @@
|
||||
* gate on it.
|
||||
*/
|
||||
import { spawnSync } from "node:child_process";
|
||||
import { existsSync, mkdirSync, readdirSync, writeFileSync } from "node:fs";
|
||||
import { existsSync, mkdirSync, readFileSync, readdirSync, writeFileSync } from "node:fs";
|
||||
import { dirname, join, resolve } from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { tmpdir } from "node:os";
|
||||
|
||||
import { ensureSvgAccessibility, validateSvgFile } from "./validate-svg.mjs";
|
||||
|
||||
const __dirname = dirname(fileURLToPath(import.meta.url));
|
||||
const repoRoot = resolve(__dirname, "..", "..");
|
||||
const srcDir = resolve(repoRoot, "docs", "diagrams");
|
||||
@@ -75,6 +77,31 @@ for (const src of sources) {
|
||||
if (result.status !== 0) {
|
||||
console.error(` [FAIL] ${src} (exit ${result.status})`);
|
||||
failures += 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
const source = readFileSync(input, "utf8");
|
||||
const title = source.match(/^%%\s*svg-title:\s*(.+)$/im)?.[1]?.trim();
|
||||
const description = source.match(/^%%\s*svg-description:\s*(.+)$/im)?.[1]?.trim();
|
||||
if (title && description) {
|
||||
const svg = readFileSync(output, "utf8");
|
||||
writeFileSync(
|
||||
output,
|
||||
ensureSvgAccessibility(svg, {
|
||||
title,
|
||||
description,
|
||||
idBase: src.replace(/\.mmd$/, ""),
|
||||
})
|
||||
);
|
||||
} else if (title || description) {
|
||||
console.warn(` [WARN] ${src}: svg-title and svg-description must be provided together`);
|
||||
}
|
||||
|
||||
const validation = validateSvgFile(output);
|
||||
for (const warning of validation.warnings) console.warn(` [WARN] ${src}: ${warning}`);
|
||||
if (validation.errors.length > 0) {
|
||||
for (const error of validation.errors) console.error(` [FAIL] ${src}: ${error}`);
|
||||
failures += 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
167
scripts/docs/validate-svg.mjs
Normal file
@@ -0,0 +1,167 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
import { readFileSync, writeFileSync } from "node:fs";
|
||||
import path from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
import { XMLParser, XMLValidator } from "fast-xml-parser";
|
||||
|
||||
const parser = new XMLParser({
|
||||
ignoreAttributes: false,
|
||||
attributeNamePrefix: "@_",
|
||||
preserveOrder: true,
|
||||
});
|
||||
|
||||
function collectIds(value, ids) {
|
||||
if (Array.isArray(value)) {
|
||||
for (const entry of value) collectIds(entry, ids);
|
||||
return;
|
||||
}
|
||||
if (!value || typeof value !== "object") return;
|
||||
|
||||
const attributes = value[":@"];
|
||||
if (attributes && typeof attributes === "object" && typeof attributes["@_id"] === "string") {
|
||||
ids.push(attributes["@_id"]);
|
||||
}
|
||||
for (const entry of Object.values(value)) collectIds(entry, ids);
|
||||
}
|
||||
|
||||
function escapeXml(value) {
|
||||
return value
|
||||
.replaceAll("&", "&")
|
||||
.replaceAll("<", "<")
|
||||
.replaceAll(">", ">")
|
||||
.replaceAll('"', """)
|
||||
.replaceAll("'", "'");
|
||||
}
|
||||
|
||||
function replaceRootAttribute(openingTag, name, value) {
|
||||
const attribute = new RegExp(`\\s${name}=(?:"[^"]*"|'[^']*')`, "i");
|
||||
const withoutExisting = openingTag.replace(attribute, "");
|
||||
return withoutExisting.replace(/>$/, ` ${name}="${escapeXml(value)}">`);
|
||||
}
|
||||
|
||||
function escapeRegExp(value) {
|
||||
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
||||
}
|
||||
|
||||
export function ensureSvgAccessibility(svg, { title, description, idBase }) {
|
||||
const xmlResult = XMLValidator.validate(svg);
|
||||
if (xmlResult !== true) throw new Error(`invalid XML: ${xmlResult.err.msg}`);
|
||||
|
||||
const titleId = `${idBase}-title`;
|
||||
const descriptionId = `${idBase}-desc`;
|
||||
const priorTitle = new RegExp(
|
||||
`<title\\b[^>]*\\bid=["']${escapeRegExp(titleId)}["'][^>]*>[\\s\\S]*?<\\/title>`,
|
||||
"i"
|
||||
);
|
||||
const priorDescription = new RegExp(
|
||||
`<desc\\b[^>]*\\bid=["']${escapeRegExp(descriptionId)}["'][^>]*>[\\s\\S]*?<\\/desc>`,
|
||||
"i"
|
||||
);
|
||||
const withoutPriorAccessibleName = svg.replace(priorTitle, "").replace(priorDescription, "");
|
||||
const match = withoutPriorAccessibleName.match(/<svg\b[^>]*>/i);
|
||||
if (!match) throw new Error("document root is not an SVG element");
|
||||
|
||||
let openingTag = replaceRootAttribute(match[0], "role", "img");
|
||||
openingTag = replaceRootAttribute(openingTag, "aria-labelledby", `${titleId} ${descriptionId}`);
|
||||
const accessibleName =
|
||||
`<title id="${escapeXml(titleId)}">${escapeXml(title)}</title>` +
|
||||
`<desc id="${escapeXml(descriptionId)}">${escapeXml(description)}</desc>`;
|
||||
|
||||
return withoutPriorAccessibleName.replace(match[0], `${openingTag}${accessibleName}`);
|
||||
}
|
||||
|
||||
export function validateSvgText(svg) {
|
||||
const xmlResult = XMLValidator.validate(svg);
|
||||
if (xmlResult !== true) {
|
||||
return { errors: [`invalid XML: ${xmlResult.err.msg}`], warnings: [] };
|
||||
}
|
||||
|
||||
const document = parser.parse(svg);
|
||||
const ids = [];
|
||||
collectIds(document, ids);
|
||||
const duplicates = [...new Set(ids.filter((id, index) => ids.indexOf(id) !== index))].sort();
|
||||
|
||||
const openingTag = svg.match(/<svg\b[^>]*>/i)?.[0] ?? "";
|
||||
const warnings = [];
|
||||
if (!/\srole=["']img["']/i.test(openingTag)) warnings.push('root role is not "img"');
|
||||
const hasAccessibleName =
|
||||
/\saria-(?:label|labelledby)=["'][^"']+["']/i.test(openingTag) ||
|
||||
/<title\b[^>]*>[^<]+<\/title>/i.test(svg);
|
||||
if (!hasAccessibleName) {
|
||||
warnings.push("missing accessible name (title, aria-label, or aria-labelledby)");
|
||||
}
|
||||
if (!/<desc\b[^>]*>[^<]+<\/desc>/i.test(svg)) warnings.push("missing desc element");
|
||||
if (/<foreignObject\b/i.test(svg)) warnings.push("foreignObject present (Mermaid output)");
|
||||
if (/\s(?:width|height)=["'][^"']+["']/i.test(openingTag)) {
|
||||
warnings.push("fixed root width or height present (Mermaid output)");
|
||||
}
|
||||
|
||||
return {
|
||||
errors: duplicates.length > 0 ? [`duplicate IDs: ${duplicates.join(", ")}`] : [],
|
||||
warnings,
|
||||
};
|
||||
}
|
||||
|
||||
export function validateSvgFile(file) {
|
||||
return validateSvgText(readFileSync(file, "utf8"));
|
||||
}
|
||||
|
||||
function isDirectExecution() {
|
||||
if (!process.argv[1]) return false;
|
||||
return fileURLToPath(import.meta.url) === path.resolve(process.argv[1]);
|
||||
}
|
||||
|
||||
if (isDirectExecution()) {
|
||||
const args = process.argv.slice(2);
|
||||
let fixAccessibility = false;
|
||||
let title;
|
||||
let description;
|
||||
const files = [];
|
||||
for (let index = 0; index < args.length; index += 1) {
|
||||
const arg = args[index];
|
||||
if (arg === "--fix-a11y") {
|
||||
fixAccessibility = true;
|
||||
} else if (arg === "--title") {
|
||||
title = args[++index];
|
||||
} else if (arg === "--description") {
|
||||
description = args[++index];
|
||||
} else {
|
||||
files.push(arg);
|
||||
}
|
||||
}
|
||||
if (files.length === 0) {
|
||||
console.error(
|
||||
"Usage: node scripts/docs/validate-svg.mjs [--fix-a11y --title TEXT --description TEXT] <file.svg> [...]"
|
||||
);
|
||||
process.exit(2);
|
||||
}
|
||||
|
||||
if (fixAccessibility && (!title || !description)) {
|
||||
console.error("--fix-a11y requires both --title and --description");
|
||||
process.exit(2);
|
||||
}
|
||||
|
||||
let failures = 0;
|
||||
for (const file of files) {
|
||||
if (fixAccessibility) {
|
||||
const idBase = path.basename(file, path.extname(file));
|
||||
const updated = ensureSvgAccessibility(readFileSync(file, "utf8"), {
|
||||
title,
|
||||
description,
|
||||
idBase,
|
||||
});
|
||||
writeFileSync(file, updated);
|
||||
}
|
||||
const result = validateSvgFile(file);
|
||||
for (const warning of result.warnings) console.warn(`WARN ${file}: ${warning}`);
|
||||
if (result.errors.length === 0) {
|
||||
console.log(`PASS ${file}`);
|
||||
continue;
|
||||
}
|
||||
failures += 1;
|
||||
for (const error of result.errors) console.error(`FAIL ${file}: ${error}`);
|
||||
}
|
||||
if (failures > 0) process.exit(1);
|
||||
}
|
||||
@@ -1,24 +1,80 @@
|
||||
/**
|
||||
* Video Bridge benchmarks (VB-FU-07 sampler overhead + VB-FU-09 contact sheet A/B).
|
||||
* Video Bridge benchmarks (VB-FU-03 dedup comparator, VB-FU-07 sampler overhead,
|
||||
* and VB-FU-09 contact sheet A/B).
|
||||
*
|
||||
* Run: node --import tsx/esm scripts/perf/video-bridge-bench.ts
|
||||
*
|
||||
* 1. Sampler: measures the pure timestamp-selection cost of uniform vs
|
||||
* 1. Dedup: measures bounded CPU and process-memory observations for the
|
||||
* production 16x16 grayscale comparator over the hard 16-frame candidate cap.
|
||||
* 2. Sampler: measures the pure timestamp-selection cost of uniform vs
|
||||
* scene_aware vs segment_aware for growing scene-candidate counts. The
|
||||
* ffmpeg scene-detection pass is shared by both aware policies and is
|
||||
* I/O-bound, so the incremental policy cost is exactly this selection step.
|
||||
* 2. Contact sheet: composes synthetic JPEG frames into the timestamped grid
|
||||
* and compares payload bytes + model calls against individual frames.
|
||||
* 3. Contact sheet: composes synthetic JPEG frames into the visually timestamped
|
||||
* grid and compares payload bytes + structural call counts. This microbenchmark
|
||||
* does not measure real-model tokens, latency, or quality; use
|
||||
* video-bridge-contact-sheet-eval.ts before considering promotion.
|
||||
*/
|
||||
import { performance } from "node:perf_hooks";
|
||||
|
||||
import { buildVideoContactSheet } from "../../src/lib/guardrails/videoBridgeContactSheet";
|
||||
import {
|
||||
compareVideoFramesByGrayscale,
|
||||
VIDEO_DEDUP_POLICY_VERSION,
|
||||
VIDEO_DEDUP_THRESHOLD,
|
||||
} from "../../src/lib/guardrails/videoBridgeHelpers";
|
||||
import {
|
||||
calculateSamplingDecision,
|
||||
type VideoSamplingPolicy,
|
||||
} from "../../src/lib/guardrails/videoBridgeRuntime";
|
||||
|
||||
const SAMPLER_ITERATIONS = 2_000;
|
||||
const DEDUP_FRAME_CAP = 16;
|
||||
const DEDUP_ITERATIONS = 10;
|
||||
|
||||
function mebibytes(bytes: number): string {
|
||||
return (bytes / (1024 * 1024)).toFixed(2);
|
||||
}
|
||||
|
||||
async function benchDedupComparator(): Promise<void> {
|
||||
const frames = await Promise.all(
|
||||
Array.from({ length: DEDUP_FRAME_CAP }, async (_unused, index) => ({
|
||||
dataUri: await syntheticJpegFrame(index, 1024, 576),
|
||||
timestampSeconds: index,
|
||||
}))
|
||||
);
|
||||
await compareVideoFramesByGrayscale(frames[0], frames[1]);
|
||||
const memoryBefore = process.memoryUsage();
|
||||
const maxRssBefore = process.resourceUsage().maxRSS * 1024;
|
||||
const cpuBefore = process.cpuUsage();
|
||||
const wallBefore = performance.now();
|
||||
let comparisons = 0;
|
||||
for (let iteration = 0; iteration < DEDUP_ITERATIONS; iteration++) {
|
||||
for (let index = 1; index < frames.length; index++) {
|
||||
await compareVideoFramesByGrayscale(frames[index - 1], frames[index]);
|
||||
comparisons += 1;
|
||||
}
|
||||
}
|
||||
const wallMs = performance.now() - wallBefore;
|
||||
const cpu = process.cpuUsage(cpuBefore);
|
||||
const memoryAfter = process.memoryUsage();
|
||||
const maxRssAfter = process.resourceUsage().maxRSS * 1024;
|
||||
const cpuMs = (cpu.user + cpu.system) / 1000;
|
||||
|
||||
console.log("== Visual dedup comparator (synthetic 1024x576 JPEG, bounded) ==");
|
||||
console.log(
|
||||
`policy=${VIDEO_DEDUP_POLICY_VERSION} threshold=${VIDEO_DEDUP_THRESHOLD} frames=${DEDUP_FRAME_CAP} iterations=${DEDUP_ITERATIONS} comparisons=${comparisons}`
|
||||
);
|
||||
console.log(
|
||||
`wall_ms=${wallMs.toFixed(1)} cpu_ms=${cpuMs.toFixed(1)} cpu_ms/comparison=${(cpuMs / comparisons).toFixed(3)}`
|
||||
);
|
||||
console.log(
|
||||
`rss_delta_MiB=${mebibytes(memoryAfter.rss - memoryBefore.rss)} heap_delta_MiB=${mebibytes(memoryAfter.heapUsed - memoryBefore.heapUsed)} max_rss_delta_MiB=${mebibytes(Math.max(0, maxRssAfter - maxRssBefore))}`
|
||||
);
|
||||
console.log(
|
||||
"Scope: comparator decode/resize/delta cost only; this does not measure caption-model quality."
|
||||
);
|
||||
}
|
||||
|
||||
function benchSampler(): void {
|
||||
console.log("== Sampler timestamp-selection cost (pure, per call) ==");
|
||||
@@ -47,12 +103,12 @@ function benchSampler(): void {
|
||||
}
|
||||
}
|
||||
|
||||
async function syntheticJpegFrame(index: number): Promise<string> {
|
||||
async function syntheticJpegFrame(index: number, width = 512, height = 288): Promise<string> {
|
||||
const { default: sharp } = await import("sharp");
|
||||
const buffer = await sharp({
|
||||
create: {
|
||||
width: 512,
|
||||
height: 288,
|
||||
width,
|
||||
height,
|
||||
channels: 3,
|
||||
background: { r: (index * 37) % 255, g: (index * 91) % 255, b: (index * 53) % 255 },
|
||||
},
|
||||
@@ -64,6 +120,9 @@ async function syntheticJpegFrame(index: number): Promise<string> {
|
||||
|
||||
async function benchContactSheet(): Promise<void> {
|
||||
console.log("\n== Contact sheet vs individual frames (synthetic 512x288 JPEG) ==");
|
||||
console.log(
|
||||
"STRUCTURAL ONLY: real-model tokens/latency/quality are unmeasured; promotion remains HOLD."
|
||||
);
|
||||
console.log("frames | sheet_ms sheet_KiB individual_KiB model_calls(sheet/individual)");
|
||||
for (const frameCount of [1, 4, 8, 16]) {
|
||||
const frames = await Promise.all(
|
||||
@@ -86,5 +145,7 @@ async function benchContactSheet(): Promise<void> {
|
||||
}
|
||||
}
|
||||
|
||||
await benchDedupComparator();
|
||||
console.log("");
|
||||
benchSampler();
|
||||
await benchContactSheet();
|
||||
|
||||
578
scripts/perf/video-bridge-contact-sheet-eval.ts
Normal file
@@ -0,0 +1,578 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
import { createHash } from "node:crypto";
|
||||
import { readFile } from "node:fs/promises";
|
||||
import path from "node:path";
|
||||
import { performance } from "node:perf_hooks";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
import { z } from "zod";
|
||||
|
||||
import {
|
||||
buildVideoContactSheet,
|
||||
type ContactSheetFrame,
|
||||
} from "../../src/lib/guardrails/videoBridgeContactSheet";
|
||||
|
||||
export type VideoContactSheetEvalConfigurationState = "configured-not-executed" | "not-configured";
|
||||
|
||||
export interface VideoContactSheetEvalHoldReportInput {
|
||||
caseCount: number;
|
||||
configurationState: VideoContactSheetEvalConfigurationState;
|
||||
missingConfiguration?: string[];
|
||||
}
|
||||
|
||||
export interface VideoContactSheetEvalHoldReport {
|
||||
caseCount: number;
|
||||
execution: {
|
||||
realModel: false;
|
||||
state: VideoContactSheetEvalConfigurationState;
|
||||
};
|
||||
kind: "video-contact-sheet-ab-eval";
|
||||
missingConfiguration: string[];
|
||||
promotion: {
|
||||
reasons: ["REAL_MODEL_CONFIGURATION_MISSING" | "REAL_MODEL_EVAL_NOT_EXECUTED"];
|
||||
status: "HOLD";
|
||||
};
|
||||
results: [];
|
||||
schemaVersion: 1;
|
||||
summary: null;
|
||||
}
|
||||
|
||||
export interface VideoContactSheetEvalThresholds {
|
||||
minLatencyReductionRatio: number;
|
||||
minQualityRetention: number;
|
||||
minQualityScore: number;
|
||||
minTokenReductionRatio: number;
|
||||
}
|
||||
|
||||
export interface VideoContactSheetEvalAggregate {
|
||||
latencyMs: number;
|
||||
qualityScore: number;
|
||||
totalTokens: number | null;
|
||||
}
|
||||
|
||||
export type VideoContactSheetPromotionReason =
|
||||
| "LATENCY_REDUCTION_BELOW_THRESHOLD"
|
||||
| "QUALITY_RETENTION_BELOW_THRESHOLD"
|
||||
| "QUALITY_SCORE_BELOW_THRESHOLD"
|
||||
| "TOKEN_REDUCTION_BELOW_THRESHOLD"
|
||||
| "TOKEN_USAGE_UNAVAILABLE";
|
||||
|
||||
export interface VideoContactSheetPromotionDecision {
|
||||
metrics: {
|
||||
latencyReductionRatio: number;
|
||||
qualityRetention: number;
|
||||
tokenReductionRatio: number | null;
|
||||
};
|
||||
reasons: VideoContactSheetPromotionReason[];
|
||||
status: "ELIGIBLE" | "HOLD";
|
||||
}
|
||||
|
||||
const MAX_EVAL_FRAME_BASE64_CHARS = 5_592_408;
|
||||
|
||||
const evalThresholdsSchema = z
|
||||
.object({
|
||||
minLatencyReductionRatio: z.number().positive().max(1),
|
||||
minQualityRetention: z.number().min(0).max(1),
|
||||
minQualityScore: z.number().min(0).max(1),
|
||||
minTokenReductionRatio: z.number().positive().max(1),
|
||||
})
|
||||
.strict();
|
||||
|
||||
const evalManifestSchema = z
|
||||
.object({
|
||||
cases: z
|
||||
.array(
|
||||
z
|
||||
.object({
|
||||
expectedFacts: z
|
||||
.array(
|
||||
z
|
||||
.object({
|
||||
id: z.string().min(1),
|
||||
requiredTerms: z.array(z.string().min(1)).min(1),
|
||||
timestampSeconds: z.number().finite().nonnegative(),
|
||||
})
|
||||
.strict()
|
||||
)
|
||||
.min(1),
|
||||
frames: z
|
||||
.array(
|
||||
z
|
||||
.object({
|
||||
dataUri: z
|
||||
.string()
|
||||
.max("data:image/jpeg;base64,".length + MAX_EVAL_FRAME_BASE64_CHARS)
|
||||
.regex(
|
||||
/^data:image\/jpeg;base64,[A-Za-z0-9+/=]{4,5592408}$/i,
|
||||
"expected a bounded JPEG data URI"
|
||||
),
|
||||
timestampSeconds: z.number().finite().nonnegative(),
|
||||
})
|
||||
.strict()
|
||||
)
|
||||
.min(1)
|
||||
.max(16),
|
||||
id: z.string().min(1),
|
||||
prompt: z.string().min(1),
|
||||
})
|
||||
.strict()
|
||||
)
|
||||
.min(1),
|
||||
id: z.string().min(1),
|
||||
schemaVersion: z.literal(1),
|
||||
thresholds: evalThresholdsSchema,
|
||||
})
|
||||
.strict();
|
||||
|
||||
const chatCompletionSchema = z
|
||||
.object({
|
||||
choices: z
|
||||
.array(
|
||||
z
|
||||
.object({
|
||||
message: z.object({ content: z.string() }).passthrough(),
|
||||
})
|
||||
.passthrough()
|
||||
)
|
||||
.min(1),
|
||||
usage: z
|
||||
.object({
|
||||
completion_tokens: z.number().nonnegative().optional(),
|
||||
prompt_tokens: z.number().nonnegative().optional(),
|
||||
total_tokens: z.number().nonnegative().optional(),
|
||||
})
|
||||
.passthrough()
|
||||
.optional(),
|
||||
})
|
||||
.passthrough();
|
||||
|
||||
export type VideoContactSheetEvalManifest = z.infer<typeof evalManifestSchema>;
|
||||
|
||||
export interface VideoContactSheetEvalConfig {
|
||||
apiKey: string;
|
||||
endpoint: string;
|
||||
model: string;
|
||||
}
|
||||
|
||||
interface EvalFactScore {
|
||||
matchedFactIds: string[];
|
||||
qualityScore: number;
|
||||
}
|
||||
|
||||
interface EvalPathResult extends EvalFactScore {
|
||||
latencyMs: number;
|
||||
modelCalls: number;
|
||||
responseDigest: string;
|
||||
totalTokens: number | null;
|
||||
}
|
||||
|
||||
export interface VideoContactSheetEvalCaseResult {
|
||||
caseId: string;
|
||||
individual: EvalPathResult;
|
||||
sheet: EvalPathResult;
|
||||
}
|
||||
|
||||
export interface VideoContactSheetEvalExecutedReport {
|
||||
caseCount: number;
|
||||
execution: {
|
||||
realModel: true;
|
||||
state: "executed";
|
||||
};
|
||||
generatedAt: string;
|
||||
kind: "video-contact-sheet-ab-eval";
|
||||
manifestDigest: string;
|
||||
manifestId: string;
|
||||
model: string;
|
||||
promotion: VideoContactSheetPromotionDecision;
|
||||
results: VideoContactSheetEvalCaseResult[];
|
||||
schemaVersion: 1;
|
||||
summary: {
|
||||
individual: VideoContactSheetEvalAggregate & { modelCalls: number };
|
||||
sheet: VideoContactSheetEvalAggregate & { modelCalls: number };
|
||||
};
|
||||
thresholds: VideoContactSheetEvalThresholds;
|
||||
}
|
||||
|
||||
type FetchLike = (input: string | URL | Request, init?: RequestInit) => Promise<Response>;
|
||||
|
||||
export function createVideoContactSheetEvalHoldReport(
|
||||
input: VideoContactSheetEvalHoldReportInput
|
||||
): VideoContactSheetEvalHoldReport {
|
||||
const reason =
|
||||
input.configurationState === "not-configured"
|
||||
? "REAL_MODEL_CONFIGURATION_MISSING"
|
||||
: "REAL_MODEL_EVAL_NOT_EXECUTED";
|
||||
return {
|
||||
caseCount: input.caseCount,
|
||||
execution: {
|
||||
realModel: false,
|
||||
state: input.configurationState,
|
||||
},
|
||||
kind: "video-contact-sheet-ab-eval",
|
||||
missingConfiguration: [...(input.missingConfiguration ?? [])],
|
||||
promotion: {
|
||||
reasons: [reason],
|
||||
status: "HOLD",
|
||||
},
|
||||
results: [],
|
||||
schemaVersion: 1,
|
||||
summary: null,
|
||||
};
|
||||
}
|
||||
|
||||
function reductionRatio(baseline: number, candidate: number): number {
|
||||
if (baseline <= 0) return 0;
|
||||
return (baseline - candidate) / baseline;
|
||||
}
|
||||
|
||||
export function assessVideoContactSheetPromotion(input: {
|
||||
individual: VideoContactSheetEvalAggregate;
|
||||
sheet: VideoContactSheetEvalAggregate;
|
||||
thresholds: VideoContactSheetEvalThresholds;
|
||||
}): VideoContactSheetPromotionDecision {
|
||||
const latencyReductionRatio = reductionRatio(input.individual.latencyMs, input.sheet.latencyMs);
|
||||
const qualityRetention =
|
||||
input.individual.qualityScore > 0
|
||||
? input.sheet.qualityScore / input.individual.qualityScore
|
||||
: 0;
|
||||
const tokenReductionRatio =
|
||||
input.individual.totalTokens === null || input.sheet.totalTokens === null
|
||||
? null
|
||||
: reductionRatio(input.individual.totalTokens, input.sheet.totalTokens);
|
||||
const reasons: VideoContactSheetPromotionReason[] = [];
|
||||
const requiredLatencyReduction = Math.max(
|
||||
Number.EPSILON,
|
||||
input.thresholds.minLatencyReductionRatio
|
||||
);
|
||||
const requiredTokenReduction = Math.max(Number.EPSILON, input.thresholds.minTokenReductionRatio);
|
||||
if (latencyReductionRatio < requiredLatencyReduction) {
|
||||
reasons.push("LATENCY_REDUCTION_BELOW_THRESHOLD");
|
||||
}
|
||||
if (input.sheet.qualityScore < input.thresholds.minQualityScore) {
|
||||
reasons.push("QUALITY_SCORE_BELOW_THRESHOLD");
|
||||
}
|
||||
if (qualityRetention < input.thresholds.minQualityRetention) {
|
||||
reasons.push("QUALITY_RETENTION_BELOW_THRESHOLD");
|
||||
}
|
||||
if (tokenReductionRatio === null) {
|
||||
reasons.push("TOKEN_USAGE_UNAVAILABLE");
|
||||
} else if (tokenReductionRatio < requiredTokenReduction) {
|
||||
reasons.push("TOKEN_REDUCTION_BELOW_THRESHOLD");
|
||||
}
|
||||
return {
|
||||
metrics: {
|
||||
latencyReductionRatio,
|
||||
qualityRetention,
|
||||
tokenReductionRatio,
|
||||
},
|
||||
reasons,
|
||||
status: reasons.length === 0 ? "ELIGIBLE" : "HOLD",
|
||||
};
|
||||
}
|
||||
|
||||
function normalizeEvalText(value: string): string {
|
||||
return value
|
||||
.normalize("NFD")
|
||||
.replace(/[\u0300-\u036f]/g, "")
|
||||
.toLowerCase();
|
||||
}
|
||||
|
||||
function formatEvalTimestamp(timestampSeconds: number): string {
|
||||
const totalMilliseconds = Math.max(0, Math.round(timestampSeconds * 1000));
|
||||
const minutes = Math.floor(totalMilliseconds / 60_000);
|
||||
const seconds = Math.floor((totalMilliseconds % 60_000) / 1000);
|
||||
const milliseconds = totalMilliseconds % 1000;
|
||||
return `${String(minutes).padStart(2, "0")}:${String(seconds).padStart(2, "0")}.${String(milliseconds).padStart(3, "0")}`;
|
||||
}
|
||||
|
||||
function scoreFacts(
|
||||
response: string,
|
||||
expectedFacts: VideoContactSheetEvalManifest["cases"][number]["expectedFacts"]
|
||||
): EvalFactScore {
|
||||
const normalizedResponse = normalizeEvalText(response);
|
||||
const matchedFactIds = expectedFacts
|
||||
.filter((fact) => {
|
||||
const timestamp = normalizeEvalText(formatEvalTimestamp(fact.timestampSeconds));
|
||||
const timestampIndex = normalizedResponse.indexOf(timestamp);
|
||||
if (timestampIndex < 0) return false;
|
||||
const factWindow = normalizedResponse.slice(
|
||||
Math.max(0, timestampIndex - 160),
|
||||
Math.min(normalizedResponse.length, timestampIndex + timestamp.length + 160)
|
||||
);
|
||||
return fact.requiredTerms.every((term) => factWindow.includes(normalizeEvalText(term)));
|
||||
})
|
||||
.map((fact) => fact.id);
|
||||
return {
|
||||
matchedFactIds,
|
||||
qualityScore: matchedFactIds.length / expectedFacts.length,
|
||||
};
|
||||
}
|
||||
|
||||
function digestResponse(response: string): string {
|
||||
return createHash("sha256").update(response).digest("hex");
|
||||
}
|
||||
|
||||
function sumTokens(values: Array<number | null>): number | null {
|
||||
if (values.some((value) => value === null)) return null;
|
||||
return values.reduce<number>((sum, value) => sum + (value ?? 0), 0);
|
||||
}
|
||||
|
||||
async function callVisionModel(input: {
|
||||
config: VideoContactSheetEvalConfig;
|
||||
dataUri: string;
|
||||
fetchImpl: FetchLike;
|
||||
prompt: string;
|
||||
}): Promise<{ content: string; totalTokens: number | null }> {
|
||||
const response = await input.fetchImpl(input.config.endpoint, {
|
||||
body: JSON.stringify({
|
||||
messages: [
|
||||
{
|
||||
content: [
|
||||
{ text: input.prompt, type: "text" },
|
||||
{ image_url: { url: input.dataUri }, type: "image_url" },
|
||||
],
|
||||
role: "user",
|
||||
},
|
||||
],
|
||||
model: input.config.model,
|
||||
temperature: 0,
|
||||
}),
|
||||
headers: {
|
||||
authorization: `Bearer ${input.config.apiKey}`,
|
||||
"content-type": "application/json",
|
||||
},
|
||||
method: "POST",
|
||||
});
|
||||
if (!response.ok) {
|
||||
throw new Error(`Video contact-sheet eval request failed with HTTP ${response.status}`);
|
||||
}
|
||||
const parsed = chatCompletionSchema.parse(await response.json());
|
||||
const usage = parsed.usage;
|
||||
const totalTokens =
|
||||
usage?.total_tokens ??
|
||||
(usage?.prompt_tokens !== undefined && usage.completion_tokens !== undefined
|
||||
? usage.prompt_tokens + usage.completion_tokens
|
||||
: null);
|
||||
return {
|
||||
content: parsed.choices[0].message.content,
|
||||
totalTokens,
|
||||
};
|
||||
}
|
||||
|
||||
async function evaluateIndividualFrames(input: {
|
||||
evalCase: VideoContactSheetEvalManifest["cases"][number];
|
||||
config: VideoContactSheetEvalConfig;
|
||||
fetchImpl: FetchLike;
|
||||
}): Promise<EvalPathResult> {
|
||||
const startedAt = performance.now();
|
||||
const calls: Array<{ content: string; totalTokens: number | null }> = [];
|
||||
for (const frame of input.evalCase.frames) {
|
||||
calls.push(
|
||||
await callVisionModel({
|
||||
config: input.config,
|
||||
dataUri: frame.dataUri,
|
||||
fetchImpl: input.fetchImpl,
|
||||
prompt: `${input.evalCase.prompt}\nAnalyze only the frame at ${formatEvalTimestamp(frame.timestampSeconds)}. Associate every observation with that exact timestamp label.`,
|
||||
})
|
||||
);
|
||||
}
|
||||
const content = calls.map((call) => call.content).join("\n");
|
||||
return {
|
||||
...scoreFacts(content, input.evalCase.expectedFacts),
|
||||
latencyMs: performance.now() - startedAt,
|
||||
modelCalls: calls.length,
|
||||
responseDigest: digestResponse(content),
|
||||
totalTokens: sumTokens(calls.map((call) => call.totalTokens)),
|
||||
};
|
||||
}
|
||||
|
||||
async function evaluateContactSheet(input: {
|
||||
evalCase: VideoContactSheetEvalManifest["cases"][number];
|
||||
config: VideoContactSheetEvalConfig;
|
||||
fetchImpl: FetchLike;
|
||||
}): Promise<EvalPathResult> {
|
||||
const startedAt = performance.now();
|
||||
const sheet = await buildVideoContactSheet(input.evalCase.frames as ContactSheetFrame[], {
|
||||
columns: 4,
|
||||
timeoutMs: 30_000,
|
||||
});
|
||||
if (!sheet.used || !sheet.dataUri) {
|
||||
throw new Error("Video contact-sheet eval could not compose the bounded JPEG grid");
|
||||
}
|
||||
const call = await callVisionModel({
|
||||
config: input.config,
|
||||
dataUri: sheet.dataUri,
|
||||
fetchImpl: input.fetchImpl,
|
||||
prompt: `${input.evalCase.prompt}\nAnalyze every cell in the contact sheet. Timestamp labels are burned into each cell. Associate every observation with its visible timestamp.`,
|
||||
});
|
||||
return {
|
||||
...scoreFacts(call.content, input.evalCase.expectedFacts),
|
||||
latencyMs: performance.now() - startedAt,
|
||||
modelCalls: 1,
|
||||
responseDigest: digestResponse(call.content),
|
||||
totalTokens: call.totalTokens,
|
||||
};
|
||||
}
|
||||
|
||||
function aggregatePathResults(
|
||||
results: VideoContactSheetEvalCaseResult[],
|
||||
path: "individual" | "sheet"
|
||||
): VideoContactSheetEvalAggregate & { modelCalls: number } {
|
||||
const pathResults = results.map((result) => result[path]);
|
||||
return {
|
||||
latencyMs: pathResults.reduce((sum, result) => sum + result.latencyMs, 0),
|
||||
modelCalls: pathResults.reduce((sum, result) => sum + result.modelCalls, 0),
|
||||
qualityScore:
|
||||
pathResults.reduce((sum, result) => sum + result.qualityScore, 0) / pathResults.length,
|
||||
totalTokens: sumTokens(pathResults.map((result) => result.totalTokens)),
|
||||
};
|
||||
}
|
||||
|
||||
export async function runVideoContactSheetEval(input: {
|
||||
config: VideoContactSheetEvalConfig;
|
||||
fetchImpl?: FetchLike;
|
||||
manifest: VideoContactSheetEvalManifest;
|
||||
}): Promise<VideoContactSheetEvalExecutedReport> {
|
||||
const manifest = evalManifestSchema.parse(input.manifest);
|
||||
const endpoint = z.string().url().parse(input.config.endpoint);
|
||||
const config = {
|
||||
apiKey: z.string().min(1).parse(input.config.apiKey),
|
||||
endpoint,
|
||||
model: z.string().min(1).parse(input.config.model),
|
||||
};
|
||||
const fetchImpl = input.fetchImpl ?? fetch;
|
||||
const results: VideoContactSheetEvalCaseResult[] = [];
|
||||
for (const evalCase of manifest.cases) {
|
||||
const individual = await evaluateIndividualFrames({ config, evalCase, fetchImpl });
|
||||
const sheet = await evaluateContactSheet({ config, evalCase, fetchImpl });
|
||||
results.push({ caseId: evalCase.id, individual, sheet });
|
||||
}
|
||||
const individual = aggregatePathResults(results, "individual");
|
||||
const sheet = aggregatePathResults(results, "sheet");
|
||||
const promotion = assessVideoContactSheetPromotion({
|
||||
individual,
|
||||
sheet,
|
||||
thresholds: manifest.thresholds,
|
||||
});
|
||||
return {
|
||||
caseCount: manifest.cases.length,
|
||||
execution: { realModel: true, state: "executed" },
|
||||
generatedAt: new Date().toISOString(),
|
||||
kind: "video-contact-sheet-ab-eval",
|
||||
manifestDigest: createHash("sha256").update(JSON.stringify(manifest)).digest("hex"),
|
||||
manifestId: manifest.id,
|
||||
model: config.model,
|
||||
promotion,
|
||||
results,
|
||||
schemaVersion: 1,
|
||||
summary: { individual, sheet },
|
||||
thresholds: manifest.thresholds,
|
||||
};
|
||||
}
|
||||
|
||||
function readArgument(name: string): string | undefined {
|
||||
const index = process.argv.indexOf(`--${name}`);
|
||||
if (index < 0) return undefined;
|
||||
const value = process.argv[index + 1];
|
||||
return value && !value.startsWith("--") ? value : undefined;
|
||||
}
|
||||
|
||||
function printUsage(): void {
|
||||
console.log(
|
||||
[
|
||||
"Usage:",
|
||||
" node --import tsx/esm scripts/perf/video-bridge-contact-sheet-eval.ts --manifest <manifest.json> --model <vision-model>",
|
||||
" node --import tsx/esm scripts/perf/video-bridge-contact-sheet-eval.ts --manifest <manifest.json> --model <vision-model> --execute-real",
|
||||
"",
|
||||
"The default command validates configuration and emits HOLD without calling a model.",
|
||||
"A real paid/networked run requires --execute-real, --model, and the documented variables:",
|
||||
" OMNIROUTE_BASE_URL",
|
||||
" OMNIROUTE_API_KEY",
|
||||
"",
|
||||
"Manifest v1: id, thresholds, and 1+ cases. Each case has 1-16 bounded JPEG data URIs,",
|
||||
"timestamps, a prompt, and expectedFacts with timestampSeconds + requiredTerms.",
|
||||
].join("\n")
|
||||
);
|
||||
}
|
||||
|
||||
async function loadManifest(manifestPath: string): Promise<VideoContactSheetEvalManifest> {
|
||||
const raw = await readFile(path.resolve(manifestPath), "utf8");
|
||||
return evalManifestSchema.parse(JSON.parse(raw));
|
||||
}
|
||||
|
||||
function resolveChatCompletionsEndpoint(baseUrl: string): string {
|
||||
const normalized = baseUrl.replace(/\/{1,8}$/u, "");
|
||||
if (normalized.endsWith("/v1/chat/completions")) return normalized;
|
||||
if (normalized.endsWith("/v1")) return `${normalized}/chat/completions`;
|
||||
return `${normalized}/v1/chat/completions`;
|
||||
}
|
||||
|
||||
async function main(): Promise<void> {
|
||||
if (process.argv.includes("--help") || process.argv.includes("-h")) {
|
||||
printUsage();
|
||||
return;
|
||||
}
|
||||
const manifestPath = readArgument("manifest");
|
||||
const model = readArgument("model");
|
||||
const missingConfiguration: string[] = [];
|
||||
if (!manifestPath) missingConfiguration.push("--manifest");
|
||||
if (!model) missingConfiguration.push("--model");
|
||||
const baseUrl = process.env.OMNIROUTE_BASE_URL;
|
||||
const apiKey = process.env.OMNIROUTE_API_KEY;
|
||||
if (!baseUrl) missingConfiguration.push("OMNIROUTE_BASE_URL");
|
||||
if (!apiKey) missingConfiguration.push("OMNIROUTE_API_KEY");
|
||||
|
||||
let manifest: VideoContactSheetEvalManifest | null = null;
|
||||
if (manifestPath) manifest = await loadManifest(manifestPath);
|
||||
if (missingConfiguration.length > 0) {
|
||||
console.log(
|
||||
JSON.stringify(
|
||||
createVideoContactSheetEvalHoldReport({
|
||||
caseCount: manifest?.cases.length ?? 0,
|
||||
configurationState: "not-configured",
|
||||
missingConfiguration,
|
||||
}),
|
||||
null,
|
||||
2
|
||||
)
|
||||
);
|
||||
return;
|
||||
}
|
||||
if (!process.argv.includes("--execute-real")) {
|
||||
console.log(
|
||||
JSON.stringify(
|
||||
createVideoContactSheetEvalHoldReport({
|
||||
caseCount: manifest?.cases.length ?? 0,
|
||||
configurationState: "configured-not-executed",
|
||||
}),
|
||||
null,
|
||||
2
|
||||
)
|
||||
);
|
||||
return;
|
||||
}
|
||||
if (!manifest || !baseUrl || !apiKey || !model) {
|
||||
throw new Error("Video contact-sheet eval configuration was not resolved");
|
||||
}
|
||||
console.log(
|
||||
JSON.stringify(
|
||||
await runVideoContactSheetEval({
|
||||
config: { apiKey, endpoint: resolveChatCompletionsEndpoint(baseUrl), model },
|
||||
manifest,
|
||||
}),
|
||||
null,
|
||||
2
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
const isMainModule =
|
||||
typeof process.argv[1] === "string" &&
|
||||
path.resolve(process.argv[1]) === fileURLToPath(import.meta.url);
|
||||
if (isMainModule) {
|
||||
main().catch(() => {
|
||||
console.error("Video contact-sheet eval failed validation or execution.");
|
||||
process.exitCode = 1;
|
||||
});
|
||||
}
|
||||
493
scripts/perf/video-bridge-fu07-eval.ts
Normal file
@@ -0,0 +1,493 @@
|
||||
/**
|
||||
* Real-media FU-07 structural-sampling evaluation.
|
||||
*
|
||||
* Run: node --import tsx/esm scripts/perf/video-bridge-fu07-eval.ts
|
||||
* Optional estimate: append --caption-cost-per-call-usd <positive number>.
|
||||
*
|
||||
* This evaluates deterministic structural oracles, not semantic model quality.
|
||||
* Model quality and monetary savings remain HOLD without an external receipt.
|
||||
*/
|
||||
import { execFile } from "node:child_process";
|
||||
import { access, mkdir, mkdtemp, rm } from "node:fs/promises";
|
||||
import { tmpdir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
import { performance } from "node:perf_hooks";
|
||||
import { promisify } from "node:util";
|
||||
|
||||
import { deduplicateVideoFrames } from "../../src/lib/guardrails/videoBridgeHelpers";
|
||||
import {
|
||||
analyzeVideoStructure,
|
||||
calculateSamplingDecision,
|
||||
extractFramesFromLocalVideo,
|
||||
readBoundedExtractedFrames,
|
||||
type VideoCommandRunner,
|
||||
type VideoStructuralAnalysis,
|
||||
type VideoStructuralSample,
|
||||
} from "../../src/lib/guardrails/videoBridgeRuntime";
|
||||
|
||||
const execFileAsync = promisify(execFile);
|
||||
const REQUIRED_FILTERS = ["scdet", "freezedetect", "blurdetect", "signalstats", "siti"];
|
||||
const TIME_MARKER = "__FU07_TIME__";
|
||||
|
||||
interface ChildCost {
|
||||
maxRssKiB: number | null;
|
||||
systemSeconds: number | null;
|
||||
userSeconds: number | null;
|
||||
wallMs: number;
|
||||
}
|
||||
|
||||
interface FixtureResult {
|
||||
captionCallsAvoided: number;
|
||||
childCost: ChildCost;
|
||||
freezeIntervals: number;
|
||||
name: string;
|
||||
oracle: Record<string, boolean | number | string>;
|
||||
passed: boolean;
|
||||
sceneCandidates: number;
|
||||
structuralFrames: number;
|
||||
uniformFrames: number;
|
||||
}
|
||||
|
||||
function average(values: Array<number | null | undefined>): number | null {
|
||||
const finite = values.filter(
|
||||
(value): value is number => value !== null && value !== undefined && Number.isFinite(value)
|
||||
);
|
||||
return finite.length > 0 ? finite.reduce((sum, value) => sum + value, 0) / finite.length : null;
|
||||
}
|
||||
|
||||
function samplesIn(
|
||||
analysis: VideoStructuralAnalysis,
|
||||
startSeconds: number,
|
||||
endSeconds: number
|
||||
): VideoStructuralSample[] {
|
||||
return analysis.samples.filter(
|
||||
(sample) => sample.timestampSeconds >= startSeconds && sample.timestampSeconds < endSeconds
|
||||
);
|
||||
}
|
||||
|
||||
async function generateFixture(outputPath: string, args: readonly string[]): Promise<void> {
|
||||
await execFileAsync(
|
||||
"ffmpeg",
|
||||
["-hide_banner", "-loglevel", "error", ...args, "-threads", "1", "-y", outputPath],
|
||||
{ maxBuffer: 1024 * 1024, timeout: 30_000 }
|
||||
);
|
||||
}
|
||||
|
||||
async function generateStaticFixture(outputPath: string): Promise<void> {
|
||||
await generateFixture(outputPath, [
|
||||
"-f",
|
||||
"lavfi",
|
||||
"-i",
|
||||
"color=c=blue:s=320x180:d=8:r=12",
|
||||
"-c:v",
|
||||
"libx264",
|
||||
"-preset",
|
||||
"ultrafast",
|
||||
"-pix_fmt",
|
||||
"yuv420p",
|
||||
]);
|
||||
}
|
||||
|
||||
async function generateMixedFixture(outputPath: string): Promise<void> {
|
||||
await generateFixture(outputPath, [
|
||||
"-f",
|
||||
"lavfi",
|
||||
"-i",
|
||||
"color=c=black:s=320x180:d=6:r=12",
|
||||
"-f",
|
||||
"lavfi",
|
||||
"-i",
|
||||
"testsrc2=s=320x180:d=4:r=12",
|
||||
"-filter_complex",
|
||||
"[0:v][1:v]concat=n=2:v=1:a=0,format=yuv420p[v]",
|
||||
"-map",
|
||||
"[v]",
|
||||
"-c:v",
|
||||
"libx264",
|
||||
"-preset",
|
||||
"ultrafast",
|
||||
]);
|
||||
}
|
||||
|
||||
async function generateBlurExposureFixture(outputPath: string): Promise<void> {
|
||||
await generateFixture(outputPath, [
|
||||
"-f",
|
||||
"lavfi",
|
||||
"-i",
|
||||
"testsrc2=s=320x180:d=3:r=12",
|
||||
"-f",
|
||||
"lavfi",
|
||||
"-i",
|
||||
"color=c=black:s=320x180:d=3:r=12",
|
||||
"-f",
|
||||
"lavfi",
|
||||
"-i",
|
||||
"testsrc2=s=320x180:d=4:r=12",
|
||||
"-filter_complex",
|
||||
"[0:v]gblur=sigma=12[blur];[blur][1:v][2:v]concat=n=3:v=1:a=0,format=yuv420p[v]",
|
||||
"-map",
|
||||
"[v]",
|
||||
"-c:v",
|
||||
"libx264",
|
||||
"-preset",
|
||||
"ultrafast",
|
||||
]);
|
||||
}
|
||||
|
||||
async function generateDenseTailFixture(outputPath: string): Promise<void> {
|
||||
const args: string[] = [];
|
||||
for (const source of [
|
||||
"color=c=black:s=160x90:d=0.5:r=10",
|
||||
"color=c=white:s=160x90:d=0.5:r=10",
|
||||
"color=c=black:s=160x90:d=0.5:r=10",
|
||||
"color=c=white:s=160x90:d=0.5:r=10",
|
||||
"testsrc2=s=160x90:d=8:r=10",
|
||||
]) {
|
||||
args.push("-f", "lavfi", "-i", source);
|
||||
}
|
||||
args.push(
|
||||
"-filter_complex",
|
||||
"[0:v][1:v][2:v][3:v][4:v]concat=n=5:v=1:a=0,format=yuv420p[v]",
|
||||
"-map",
|
||||
"[v]",
|
||||
"-c:v",
|
||||
"libx264",
|
||||
"-preset",
|
||||
"ultrafast"
|
||||
);
|
||||
await generateFixture(outputPath, args);
|
||||
}
|
||||
|
||||
async function generateGradualFadeFixture(outputPath: string): Promise<void> {
|
||||
await generateFixture(outputPath, [
|
||||
"-f",
|
||||
"lavfi",
|
||||
"-i",
|
||||
"color=c=white:s=320x180:d=8:r=12",
|
||||
"-vf",
|
||||
"fade=t=out:st=0:d=8,format=yuv420p",
|
||||
"-c:v",
|
||||
"libx264",
|
||||
"-preset",
|
||||
"ultrafast",
|
||||
]);
|
||||
}
|
||||
|
||||
async function supportsTimeBinary(): Promise<boolean> {
|
||||
try {
|
||||
await access("/usr/bin/time");
|
||||
return true;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function parseTimeCost(stderr: string, wallMs: number): ChildCost {
|
||||
const match = new RegExp(`${TIME_MARKER} ([\\d.]+) ([\\d.]+) ([\\d.]+)`).exec(stderr);
|
||||
return {
|
||||
maxRssKiB: match ? Number(match[3]) : null,
|
||||
systemSeconds: match ? Number(match[2]) : null,
|
||||
userSeconds: match ? Number(match[1]) : null,
|
||||
wallMs,
|
||||
};
|
||||
}
|
||||
|
||||
async function timedAnalysis(
|
||||
inputPath: string,
|
||||
durationSeconds: number,
|
||||
useTimeBinary: boolean
|
||||
): Promise<{ analysis: VideoStructuralAnalysis; cost: ChildCost }> {
|
||||
let cost: ChildCost = {
|
||||
maxRssKiB: null,
|
||||
systemSeconds: null,
|
||||
userSeconds: null,
|
||||
wallMs: 0,
|
||||
};
|
||||
const runner: VideoCommandRunner = async (executable, args, options) => {
|
||||
const startedAt = performance.now();
|
||||
const command = useTimeBinary ? "/usr/bin/time" : executable;
|
||||
const commandArgs = useTimeBinary
|
||||
? ["-f", `${TIME_MARKER} %U %S %M`, executable, ...args]
|
||||
: [...args];
|
||||
const result = await execFileAsync(command, commandArgs, {
|
||||
encoding: "utf8",
|
||||
maxBuffer: 1024 * 1024,
|
||||
signal: options.signal,
|
||||
timeout: options.timeoutMs,
|
||||
});
|
||||
cost = parseTimeCost(String(result.stderr), performance.now() - startedAt);
|
||||
return { stderr: String(result.stderr), stdout: String(result.stdout) };
|
||||
};
|
||||
const analysis = await analyzeVideoStructure(inputPath, {
|
||||
durationSeconds,
|
||||
runner,
|
||||
streamIndex: 0,
|
||||
timeoutMs: 30_000,
|
||||
});
|
||||
return { analysis, cost };
|
||||
}
|
||||
|
||||
function sampling(
|
||||
durationSeconds: number,
|
||||
frameCount: number,
|
||||
analysis: VideoStructuralAnalysis
|
||||
): { structural: number[]; uniform: number[] } {
|
||||
const uniform = calculateSamplingDecision(durationSeconds, frameCount, "uniform").timestamps;
|
||||
const structural = calculateSamplingDecision(
|
||||
durationSeconds,
|
||||
frameCount,
|
||||
"segment_aware",
|
||||
analysis.sceneCandidates,
|
||||
null,
|
||||
analysis
|
||||
).timestamps;
|
||||
return { structural, uniform };
|
||||
}
|
||||
|
||||
async function captionCallsAfterDedup(
|
||||
inputPath: string,
|
||||
outputDirectory: string,
|
||||
samplingPolicy: "segment_aware" | "uniform"
|
||||
): Promise<number> {
|
||||
await mkdir(outputDirectory, { mode: 0o700 });
|
||||
const frames = await extractFramesFromLocalVideo(inputPath, outputDirectory, {
|
||||
durationSeconds: 8,
|
||||
frameCount: 8,
|
||||
samplingPolicy,
|
||||
streamIndex: 0,
|
||||
timeoutMs: 30_000,
|
||||
});
|
||||
const bytes = await readBoundedExtractedFrames(frames);
|
||||
const deduplicated = await deduplicateVideoFrames(
|
||||
frames.map((frame, index) => ({
|
||||
dataUri: `data:image/jpeg;base64,${bytes[index].toString("base64")}`,
|
||||
timestampSeconds: frame.timestampSeconds,
|
||||
}))
|
||||
);
|
||||
return deduplicated.frames.length;
|
||||
}
|
||||
|
||||
function result(
|
||||
name: string,
|
||||
cost: ChildCost,
|
||||
analysis: VideoStructuralAnalysis,
|
||||
uniform: number[],
|
||||
structural: number[],
|
||||
oracle: Record<string, boolean | number | string>,
|
||||
captionCallsAvoided = 0
|
||||
): FixtureResult {
|
||||
const booleans = Object.values(oracle).filter(
|
||||
(value): value is boolean => typeof value === "boolean"
|
||||
);
|
||||
return {
|
||||
captionCallsAvoided,
|
||||
childCost: cost,
|
||||
freezeIntervals: analysis.freezeIntervals.length,
|
||||
name,
|
||||
oracle,
|
||||
passed: booleans.every(Boolean),
|
||||
sceneCandidates: analysis.sceneCandidates.length,
|
||||
structuralFrames: structural.length,
|
||||
uniformFrames: uniform.length,
|
||||
};
|
||||
}
|
||||
|
||||
async function main(): Promise<void> {
|
||||
const version = await execFileAsync("ffmpeg", ["-version"], { timeout: 5_000 });
|
||||
const filters = await execFileAsync("ffmpeg", ["-hide_banner", "-filters"], {
|
||||
maxBuffer: 2 * 1024 * 1024,
|
||||
timeout: 5_000,
|
||||
});
|
||||
const missingFilters = REQUIRED_FILTERS.filter(
|
||||
(filter) => !new RegExp(`\\b${filter}\\b`).test(String(filters.stdout))
|
||||
);
|
||||
if (missingFilters.length > 0)
|
||||
throw new Error(`Missing required FFmpeg filters: ${missingFilters.join(", ")}`);
|
||||
|
||||
const directory = await mkdtemp(join(tmpdir(), "video-fu07-eval-"));
|
||||
const useTimeBinary = await supportsTimeBinary();
|
||||
const results: FixtureResult[] = [];
|
||||
try {
|
||||
const staticPath = join(directory, "static.mp4");
|
||||
await generateStaticFixture(staticPath);
|
||||
const staticRun = await timedAnalysis(staticPath, 8, useTimeBinary);
|
||||
const staticSampling = sampling(8, 8, staticRun.analysis);
|
||||
const uniformCaptionCalls = await captionCallsAfterDedup(
|
||||
staticPath,
|
||||
join(directory, "static-uniform"),
|
||||
"uniform"
|
||||
);
|
||||
const structuralCaptionCalls = await captionCallsAfterDedup(
|
||||
staticPath,
|
||||
join(directory, "static-structural"),
|
||||
"segment_aware"
|
||||
);
|
||||
const staticCaptionCallsAvoided = Math.max(0, uniformCaptionCalls - structuralCaptionCalls);
|
||||
results.push(
|
||||
result(
|
||||
"static-caption-savings",
|
||||
staticRun.cost,
|
||||
staticRun.analysis,
|
||||
staticSampling.uniform,
|
||||
staticSampling.structural,
|
||||
{
|
||||
fullFreezeDetected: staticRun.analysis.freezeIntervals.some(
|
||||
(interval) => interval.startSeconds <= 1 && interval.endSeconds >= 7
|
||||
),
|
||||
oneIncrementalCaptionCallAvoided: staticCaptionCallsAvoided === 1,
|
||||
structuralCaptionCalls,
|
||||
uniformCaptionCalls,
|
||||
},
|
||||
staticCaptionCallsAvoided
|
||||
)
|
||||
);
|
||||
|
||||
const mixedPath = join(directory, "mixed.mp4");
|
||||
await generateMixedFixture(mixedPath);
|
||||
const mixedRun = await timedAnalysis(mixedPath, 10, useTimeBinary);
|
||||
const mixedSampling = sampling(10, 4, mixedRun.analysis);
|
||||
const uniformDense = mixedSampling.uniform.filter((timestamp) => timestamp > 6).length;
|
||||
const structuralDense = mixedSampling.structural.filter((timestamp) => timestamp > 6).length;
|
||||
results.push(
|
||||
result(
|
||||
"dense-budget-quality-oracle",
|
||||
mixedRun.cost,
|
||||
mixedRun.analysis,
|
||||
mixedSampling.uniform,
|
||||
mixedSampling.structural,
|
||||
{
|
||||
denseFramesStructural: structuralDense,
|
||||
denseFramesUniform: uniformDense,
|
||||
denseRegionGetsMoreBudget: structuralDense > uniformDense,
|
||||
frozenRegionRetainsCoverage: mixedSampling.structural.some((timestamp) => timestamp < 6),
|
||||
}
|
||||
)
|
||||
);
|
||||
|
||||
const qualityPath = join(directory, "blur-exposure.mp4");
|
||||
await generateBlurExposureFixture(qualityPath);
|
||||
const qualityRun = await timedAnalysis(qualityPath, 10, useTimeBinary);
|
||||
const qualitySampling = sampling(10, 6, qualityRun.analysis);
|
||||
const blurred = samplesIn(qualityRun.analysis, 0, 3);
|
||||
const dark = samplesIn(qualityRun.analysis, 3, 6);
|
||||
const sharp = samplesIn(qualityRun.analysis, 6, 10);
|
||||
const blurredBlur = average(blurred.map((sample) => sample.blur));
|
||||
const blurredSpatial = average(blurred.map((sample) => sample.spatialInformation));
|
||||
const darkLuma = average(dark.map((sample) => sample.brightness));
|
||||
const sharpBlur = average(sharp.map((sample) => sample.blur));
|
||||
const sharpSpatial = average(sharp.map((sample) => sample.spatialInformation));
|
||||
const sharpTemporal = average(sharp.map((sample) => sample.temporalInformation));
|
||||
const sharpLuma = average(sharp.map((sample) => sample.brightness));
|
||||
results.push(
|
||||
result(
|
||||
"blur-exposure-spatial-temporal-evidence",
|
||||
qualityRun.cost,
|
||||
qualityRun.analysis,
|
||||
qualitySampling.uniform,
|
||||
qualitySampling.structural,
|
||||
{
|
||||
blurMetricSeparated:
|
||||
blurredBlur !== null && sharpBlur !== null && Math.abs(blurredBlur - sharpBlur) >= 0.05,
|
||||
blurredBlur: blurredBlur ?? "missing",
|
||||
darkLuma: darkLuma ?? "missing",
|
||||
exposureSeparated: darkLuma !== null && sharpLuma !== null && sharpLuma - darkLuma >= 50,
|
||||
sharpBlur: sharpBlur ?? "missing",
|
||||
sharpSpatial: sharpSpatial ?? "missing",
|
||||
sharpTemporal: sharpTemporal ?? "missing",
|
||||
spatialDetailSeparated:
|
||||
blurredSpatial !== null && sharpSpatial !== null && sharpSpatial - blurredSpatial >= 20,
|
||||
structuralKeepsSharpRegion:
|
||||
qualitySampling.structural.filter((timestamp) => timestamp >= 6).length >= 2,
|
||||
temporalChangeDetected: sharpTemporal !== null && sharpTemporal >= 5,
|
||||
}
|
||||
)
|
||||
);
|
||||
|
||||
const tailPath = join(directory, "dense-tail.mp4");
|
||||
await generateDenseTailFixture(tailPath);
|
||||
const tailRun = await timedAnalysis(tailPath, 10, useTimeBinary);
|
||||
const tailSampling = sampling(10, 4, tailRun.analysis);
|
||||
results.push(
|
||||
result(
|
||||
"dense-cuts-long-tail-regression",
|
||||
tailRun.cost,
|
||||
tailRun.analysis,
|
||||
tailSampling.uniform,
|
||||
tailSampling.structural,
|
||||
{
|
||||
multipleEarlyCuts: tailRun.analysis.sceneCandidates.length >= 3,
|
||||
trailingEightSecondsRepresented: tailSampling.structural.some(
|
||||
(timestamp) => timestamp > 2
|
||||
),
|
||||
}
|
||||
)
|
||||
);
|
||||
|
||||
const fadePath = join(directory, "gradual-fade.mp4");
|
||||
await generateGradualFadeFixture(fadePath);
|
||||
const fadeRun = await timedAnalysis(fadePath, 8, useTimeBinary);
|
||||
const fadeSampling = sampling(8, 4, fadeRun.analysis);
|
||||
results.push(
|
||||
result(
|
||||
"gradual-fade-false-positive",
|
||||
fadeRun.cost,
|
||||
fadeRun.analysis,
|
||||
fadeSampling.uniform,
|
||||
fadeSampling.structural,
|
||||
{
|
||||
hardCutFalsePositives: fadeRun.analysis.sceneCandidates.length,
|
||||
noHardCutBurst: fadeRun.analysis.sceneCandidates.length <= 1,
|
||||
noCaptionBudgetPruning: fadeSampling.structural.length === fadeSampling.uniform.length,
|
||||
}
|
||||
)
|
||||
);
|
||||
} finally {
|
||||
await rm(directory, { force: true, recursive: true });
|
||||
}
|
||||
|
||||
const callsAvoided = results.reduce((sum, fixture) => sum + fixture.captionCallsAvoided, 0);
|
||||
const costFlag = process.argv.indexOf("--caption-cost-per-call-usd");
|
||||
const explicitCost = Number(costFlag >= 0 ? process.argv[costFlag + 1] : Number.NaN);
|
||||
const report = {
|
||||
captionCost:
|
||||
Number.isFinite(explicitCost) && explicitCost > 0
|
||||
? {
|
||||
estimatedUsdAvoided: callsAvoided * explicitCost,
|
||||
source: "explicit environment input",
|
||||
status: "ESTIMATED_FROM_INPUT",
|
||||
}
|
||||
: {
|
||||
reason: "--caption-cost-per-call-usd was not supplied with a positive number",
|
||||
status: "HOLD",
|
||||
},
|
||||
ffmpegVersion: String(version.stdout).split("\n")[0],
|
||||
fixtures: results,
|
||||
modelQuality: {
|
||||
reason:
|
||||
"No authorized real caption-model endpoint, credentials, or frozen judge rubric were configured; deterministic structural oracles are not semantic quality.",
|
||||
status: "HOLD",
|
||||
},
|
||||
gainCostComparison: {
|
||||
reason:
|
||||
"The real post-dedup caption-call delta is measured, but no authorized caption latency/cost receipt or child CPU/RSS receipt is configured.",
|
||||
status: "HOLD",
|
||||
},
|
||||
resourceCost: useTimeBinary
|
||||
? { source: "/usr/bin/time", status: "MEASURED" }
|
||||
: {
|
||||
reason: "/usr/bin/time is unavailable; wall time is measured but child CPU/RSS are not",
|
||||
status: "HOLD",
|
||||
},
|
||||
summary: {
|
||||
captionCallsAvoided: callsAvoided,
|
||||
failed: results.filter((fixture) => !fixture.passed).map((fixture) => fixture.name),
|
||||
passed: results.filter((fixture) => fixture.passed).length,
|
||||
total: results.length,
|
||||
},
|
||||
timeBinary: useTimeBinary ? "/usr/bin/time" : null,
|
||||
};
|
||||
console.log(JSON.stringify(report, null, 2));
|
||||
if (report.summary.failed.length > 0) process.exitCode = 1;
|
||||
}
|
||||
|
||||
await main();
|
||||
@@ -90,13 +90,30 @@ export function baselineValue(metric, root = ROOT) {
|
||||
}
|
||||
}
|
||||
|
||||
// A line that is unambiguously a PASS. Test reporters print the file name on BOTH the
|
||||
// pass and the fail line, so a green line for a file whose NAME contains "fail"
|
||||
// (fail-fast-*.test.ts, failover-*.test.ts) must never be offered as a failure cause.
|
||||
const GREEN_LINE_RE = /^[✓✔√]/;
|
||||
|
||||
// Markers that are only meaningful at the START of a line: "FAIL" also occurs inside test
|
||||
// FILE NAMES and inside summary prose ("Test Files 1 failed"), so matching it anywhere —
|
||||
// and case-insensitively — reports a PASSING file as the cause of the red.
|
||||
const LINE_START_FAILURE_RE = /^(?:[✖✗×]|FAIL\b|not ok\b|REGRESS)/;
|
||||
|
||||
// Markers that are unambiguous ANYWHERE in the line: tsc and Node emit them mid-line
|
||||
// ("src/x.ts(10,5): error TS2322: ..."), so these stay unanchored. They are matched
|
||||
// case-SENSITIVELY because that is how the emitting tools actually spell them.
|
||||
const INLINE_FAILURE_RE = /\berror TS\d+\b|\bAssertionError\b|\bError:|\bREGRESS/;
|
||||
|
||||
/** Best-effort "first meaningful failure line" from captured command output. */
|
||||
export function firstFailureLine(out) {
|
||||
const lines = String(out || "")
|
||||
.split("\n")
|
||||
.map((l) => l.trim())
|
||||
.filter(Boolean);
|
||||
const hit = lines.find((l) => /✖|✗|not ok|AssertionError|error TS|FAIL|Error:|REGRESS/i.test(l));
|
||||
const hit = lines.find(
|
||||
(l) => !GREEN_LINE_RE.test(l) && (LINE_START_FAILURE_RE.test(l) || INLINE_FAILURE_RE.test(l))
|
||||
);
|
||||
return (hit || lines[lines.length - 1] || "failed").slice(0, 200);
|
||||
}
|
||||
|
||||
@@ -232,6 +249,36 @@ export function fullCiTimeoutFor(gateId) {
|
||||
return FULL_CI_TIMEOUT_OVERRIDES_MS[gateId] ?? FULL_CI_DEFAULT_TIMEOUT_MS;
|
||||
}
|
||||
|
||||
// ci.yml gate scripts whose result the CURATED pass already records under a DIFFERENT id.
|
||||
// Without this map the --full-ci pass re-records them unconditionally as kind:"hard" while
|
||||
// the curated pass recorded them as kind:"drift", and the SAME gate is printed in BOTH
|
||||
// verdict buckets of one report (file-size / compression-budget appeared as a hard failure
|
||||
// and as drift simultaneously in the #9985 verdict).
|
||||
export const FULL_CI_CURATED_ALIASES = {
|
||||
lint: "lint-errors",
|
||||
"check:workflows": "workflow-lint",
|
||||
"check:complexity-ratchets": "complexity",
|
||||
};
|
||||
|
||||
/** Curated-pass id equivalent to a ci.yml gate script id ("check:file-size" -> "file-size"). */
|
||||
export function curatedEquivalentId(scriptId) {
|
||||
const id = String(scriptId || "");
|
||||
if (Object.hasOwn(FULL_CI_CURATED_ALIASES, id)) return FULL_CI_CURATED_ALIASES[id];
|
||||
return id.startsWith("check:") ? id.slice("check:".length) : id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Bucket a --full-ci gate must be reported under: the classification the curated pass already
|
||||
* gave the equivalent gate, else "hard" (the --full-ci default for gates the curated list does
|
||||
* not cover). This only changes WHICH BUCKET a result is printed in — it never changes whether
|
||||
* a gate runs, nor whether it passed.
|
||||
*/
|
||||
export function fullCiKindFor(scriptId, results) {
|
||||
const equivalent = curatedEquivalentId(scriptId);
|
||||
const curated = (results || []).find((r) => r.id === scriptId || r.id === equivalent);
|
||||
return curated?.kind ?? "hard";
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse a ci.yml text and return the ordered, de-duplicated list of gate commands to run.
|
||||
* Each entry: { id, job, args:["run", <script>, ...("--" + args)], env }.
|
||||
@@ -716,7 +763,10 @@ async function main() {
|
||||
record({
|
||||
id: g.id,
|
||||
label: `ci.yml:${g.job} → npm ${g.args.join(" ")}`,
|
||||
kind: "hard",
|
||||
// Respect the curated classification when the curated pass already ran an equivalent
|
||||
// gate under a different id — otherwise the same ratchet is reported as a HARD failure
|
||||
// here AND as drift above, in one self-contradicting verdict.
|
||||
kind: fullCiKindFor(g.id, results),
|
||||
ok: code === 0,
|
||||
detail: code === 0 ? "pass" : firstFailureLine(out),
|
||||
});
|
||||
|
||||
@@ -57,12 +57,16 @@ for N in "${PRS[@]}"; do
|
||||
done
|
||||
|
||||
ROOT="$(git rev-parse --show-toplevel 2>/dev/null || true)"
|
||||
# The train worktree is detached, so the changelog gate cannot infer which release
|
||||
# branch seeded it. Shell-quote the requested base before it enters the eval-backed
|
||||
# gate list, then bind that exact ref only for the changelog check.
|
||||
printf -v CHANGELOG_BASE_REF_Q '%q' "origin/${BASE}"
|
||||
STATIC_GATES=(
|
||||
"npm run typecheck:core"
|
||||
"node scripts/check/check-file-size.mjs"
|
||||
"node scripts/check/check-complexity.mjs"
|
||||
"node scripts/check/check-cognitive-complexity.mjs"
|
||||
"node scripts/check/check-changelog-integrity.mjs"
|
||||
"env CHANGELOG_BASE_REF=${CHANGELOG_BASE_REF_Q} node scripts/check/check-changelog-integrity.mjs"
|
||||
)
|
||||
# Full mode: the box-speed runner (same coverage as the two CI shards combined —
|
||||
# main + dashboard + serial groups — at local concurrency instead of runner-sized).
|
||||
|
||||
@@ -75,76 +75,3 @@ omniroute mcp call <tool> [argsJson]
|
||||
```bash
|
||||
omniroute mcp scopes
|
||||
```
|
||||
|
||||
### `mcp tools`
|
||||
|
||||
**Example:**
|
||||
|
||||
```bash
|
||||
omniroute mcp tools
|
||||
```
|
||||
|
||||
### `mcp list`
|
||||
|
||||
**Flags:**
|
||||
|
||||
- `--scope <s>`
|
||||
|
||||
**Example:**
|
||||
|
||||
```bash
|
||||
omniroute mcp list
|
||||
```
|
||||
|
||||
### `mcp info <name>`
|
||||
|
||||
**Example:**
|
||||
|
||||
```bash
|
||||
omniroute mcp info <name>
|
||||
```
|
||||
|
||||
### `mcp schema <name>`
|
||||
|
||||
**Flags:**
|
||||
|
||||
- `--io <kind>`
|
||||
|
||||
**Example:**
|
||||
|
||||
```bash
|
||||
omniroute mcp schema <name>
|
||||
```
|
||||
|
||||
### `mcp audit`
|
||||
|
||||
**Example:**
|
||||
|
||||
```bash
|
||||
omniroute mcp audit
|
||||
```
|
||||
|
||||
### `mcp tail`
|
||||
|
||||
**Flags:**
|
||||
|
||||
- `--follow`
|
||||
- `--limit <n>`
|
||||
|
||||
**Example:**
|
||||
|
||||
```bash
|
||||
omniroute mcp tail
|
||||
```
|
||||
|
||||
### `mcp stats`
|
||||
|
||||
**Flags:**
|
||||
|
||||
- `--period <p>`
|
||||
|
||||
**Example:**
|
||||
|
||||
```bash
|
||||
omniroute mcp stats
|
||||
```
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"use client";
|
||||
|
||||
import { useEffect, useState } from "react";
|
||||
import { useCallback, useSyncExternalStore } from "react";
|
||||
import Link from "next/link";
|
||||
import { useTranslations } from "next-intl";
|
||||
|
||||
@@ -10,36 +10,51 @@ type FirstRunReadinessCardProps = {
|
||||
setupComplete: boolean;
|
||||
};
|
||||
|
||||
// #9985: dismissal lives in localStorage, read via useSyncExternalStore — keeps
|
||||
// the component free of setState-in-effect cascades and hydration-safe (server
|
||||
// snapshot treats the card as dismissed; the client corrects after hydration).
|
||||
const readinessListeners = new Set<() => void>();
|
||||
|
||||
function subscribeReadiness(onStoreChange: () => void): () => void {
|
||||
readinessListeners.add(onStoreChange);
|
||||
window.addEventListener("storage", onStoreChange);
|
||||
return () => {
|
||||
readinessListeners.delete(onStoreChange);
|
||||
window.removeEventListener("storage", onStoreChange);
|
||||
};
|
||||
}
|
||||
|
||||
function isReadinessDismissed(): boolean {
|
||||
try {
|
||||
return localStorage.getItem(DISMISS_STORAGE_KEY) === "true";
|
||||
} catch {
|
||||
// Storage unavailable (private mode etc.) — never show the nagging card.
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
function getServerSnapshot(): boolean {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Soft entry path for first-run users. Replaces the hard redirect to
|
||||
* /dashboard/onboarding so returning users can dismiss and stay on Home.
|
||||
*/
|
||||
export default function FirstRunReadinessCard({ setupComplete }: FirstRunReadinessCardProps) {
|
||||
const t = useTranslations("home");
|
||||
const [visible, setVisible] = useState(false);
|
||||
const dismissed = useSyncExternalStore(subscribeReadiness, isReadinessDismissed, getServerSnapshot);
|
||||
|
||||
useEffect(() => {
|
||||
if (setupComplete) {
|
||||
setVisible(false);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
setVisible(!localStorage.getItem(DISMISS_STORAGE_KEY));
|
||||
} catch {
|
||||
setVisible(true);
|
||||
}
|
||||
}, [setupComplete]);
|
||||
|
||||
if (!visible || setupComplete) return null;
|
||||
|
||||
const dismiss = () => {
|
||||
const dismiss = useCallback(() => {
|
||||
try {
|
||||
localStorage.setItem(DISMISS_STORAGE_KEY, "true");
|
||||
} catch {
|
||||
// ignore storage failures; still hide for this session
|
||||
}
|
||||
setVisible(false);
|
||||
};
|
||||
for (const listener of readinessListeners) listener();
|
||||
}, []);
|
||||
|
||||
if (setupComplete || dismissed) return null;
|
||||
|
||||
const steps = [
|
||||
t("readinessStep1"),
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
"use client";
|
||||
|
||||
import { useState, useEffect, useMemo, useCallback } from "react";
|
||||
import Link from "next/link";
|
||||
import { Card, Button, Input, Modal, CardSkeleton, SegmentedControl } from "@/shared/components";
|
||||
import Toggle from "@/shared/components/Toggle";
|
||||
import { useCopyToClipboard } from "@/shared/hooks/useCopyToClipboard";
|
||||
import { isPublicDisplayBaseUrl, useDisplayBaseUrl } from "@/shared/hooks";
|
||||
import { AI_PROVIDERS, getProviderByAlias } from "@/shared/constants/providers";
|
||||
import { getProviderDisplayName } from "@/lib/display/names";
|
||||
import { useTranslations } from "next-intl";
|
||||
import A2ADashboardPage from "./components/A2ADashboard";
|
||||
import McpDashboardPage from "./components/MCPDashboard";
|
||||
@@ -138,7 +135,6 @@ export default function APIPageClient({ machineId }: Readonly<APIPageClientProps
|
||||
// Endpoints / models state
|
||||
const [allModels, setAllModels] = useState([]);
|
||||
const [modelsLoading, setModelsLoading] = useState(true);
|
||||
const [expandedEndpoint, setExpandedEndpoint] = useState(null);
|
||||
|
||||
// Cloud sync state
|
||||
const [cloudEnabled, setCloudEnabled] = useState(false);
|
||||
@@ -151,8 +147,8 @@ export default function APIPageClient({ machineId }: Readonly<APIPageClientProps
|
||||
const [selectedProvider, setSelectedProvider] = useState(null); // for provider models popup
|
||||
const [cloudBaseUrl, setCloudBaseUrl] = useState(BUILD_TIME_CLOUD_URL); // dynamic cloud URL from API response
|
||||
const [cloudConfigured, setCloudConfigured] = useState(Boolean(BUILD_TIME_CLOUD_URL));
|
||||
const [mcpStatus, setMcpStatus] = useState<any>(null);
|
||||
const [a2aStatus, setA2aStatus] = useState<any>(null);
|
||||
const [_mcpStatus, setMcpStatus] = useState<any>(null);
|
||||
const [_a2aStatus, setA2aStatus] = useState<any>(null);
|
||||
const [searchProviders, setSearchProviders] = useState<any[]>([]);
|
||||
const [cloudflaredStatus, setCloudflaredStatus] = useState<CloudflaredTunnelStatus | null>(null);
|
||||
const [cloudflaredBusy, setCloudflaredBusy] = useState(false);
|
||||
@@ -1132,10 +1128,6 @@ export default function APIPageClient({ machineId }: Readonly<APIPageClientProps
|
||||
showNgrokTunnel && ngrokStatus?.running,
|
||||
].filter(Boolean).length;
|
||||
|
||||
const mcpOnline = Boolean(mcpStatus?.online);
|
||||
const a2aOnline = a2aStatus?.status === "ok";
|
||||
const mcpToolCount = Number(mcpStatus?.heartbeat?.toolCount || 0);
|
||||
const a2aActiveStreams = Number(a2aStatus?.tasks?.activeStreams || 0);
|
||||
const cloudflaredPhase = cloudflaredStatus?.phase || "not_installed";
|
||||
const cloudflaredPhaseMeta: Record<CloudflaredTunnelPhase, { label: string; className: string }> =
|
||||
{
|
||||
@@ -1169,10 +1161,6 @@ export default function APIPageClient({ machineId }: Readonly<APIPageClientProps
|
||||
: cloudflaredStatus?.installed
|
||||
? translateOrFallback("cloudflaredEnable", "Enable Tunnel")
|
||||
: translateOrFallback("cloudflaredInstallAndEnable", "Install & Enable");
|
||||
const cloudflaredUrlNotice = translateOrFallback(
|
||||
"cloudflaredUrlNotice",
|
||||
"Creates a temporary Cloudflare Quick Tunnel. The URL changes after every restart."
|
||||
);
|
||||
const tailscalePhase = tailscaleStatus?.phase || "not_installed";
|
||||
const tailscalePhaseMeta: Record<TailscaleTunnelPhase, { label: string; className: string }> = {
|
||||
running: {
|
||||
@@ -2498,137 +2486,3 @@ function EndpointCard({
|
||||
);
|
||||
}
|
||||
|
||||
function EndpointSection({
|
||||
icon,
|
||||
iconColor,
|
||||
iconBg,
|
||||
title,
|
||||
path,
|
||||
description,
|
||||
models,
|
||||
expanded,
|
||||
onToggle,
|
||||
copy,
|
||||
copied,
|
||||
baseUrl,
|
||||
modelsLoading = false,
|
||||
}: Readonly<{
|
||||
icon: string;
|
||||
iconColor: string;
|
||||
iconBg: string;
|
||||
title: string;
|
||||
path: string;
|
||||
description: string;
|
||||
models: EndpointModelSummary[];
|
||||
expanded: boolean;
|
||||
onToggle: () => void;
|
||||
copy: CopyHandler;
|
||||
copied?: string | null;
|
||||
baseUrl: string;
|
||||
modelsLoading?: boolean;
|
||||
}>) {
|
||||
const t = useTranslations("endpoint");
|
||||
const grouped = useMemo(() => {
|
||||
const map = {};
|
||||
for (const m of models) {
|
||||
const owner = m.owned_by || "unknown";
|
||||
if (!map[owner]) map[owner] = [];
|
||||
map[owner].push(m);
|
||||
}
|
||||
return Object.entries(map).sort((a: any, b: any) => b[1].length - a[1].length);
|
||||
}, [models]);
|
||||
|
||||
const resolveProvider = (id) => AI_PROVIDERS[id] || getProviderByAlias(id);
|
||||
const providerColor = (id) => resolveProvider(id)?.color || "#888";
|
||||
const providerName = (id) => getProviderDisplayName(id, resolveProvider(id));
|
||||
const copyId = `endpoint_${path}`;
|
||||
|
||||
return (
|
||||
<div className="border border-border rounded-lg overflow-hidden">
|
||||
{/* Header (always visible) */}
|
||||
<button
|
||||
onClick={onToggle}
|
||||
className="w-full flex items-center gap-3 p-4 hover:bg-surface/50 transition-colors text-left"
|
||||
>
|
||||
<div className={`flex items-center justify-center size-10 rounded-lg ${iconBg} shrink-0`}>
|
||||
<span className={`material-symbols-outlined text-xl ${iconColor}`}>{icon}</span>
|
||||
</div>
|
||||
<div className="flex-1 min-w-0">
|
||||
<div className="flex items-center gap-2">
|
||||
<span className="font-semibold text-sm">{title}</span>
|
||||
<span className="text-xs px-2 py-0.5 rounded-full bg-surface text-text-muted font-medium">
|
||||
{modelsLoading ? "..." : t("modelsCount", { count: models.length })}
|
||||
</span>
|
||||
</div>
|
||||
<p className="text-xs text-text-muted mt-0.5">{description}</p>
|
||||
</div>
|
||||
<span
|
||||
className={`material-symbols-outlined text-text-muted text-lg transition-transform ${expanded ? "rotate-180" : ""}`}
|
||||
>
|
||||
expand_more
|
||||
</span>
|
||||
</button>
|
||||
|
||||
{/* Expanded content */}
|
||||
{expanded && (
|
||||
<div className="border-t border-border px-4 pb-4">
|
||||
{/* Endpoint path + copy */}
|
||||
<div className="flex items-center gap-2 mt-3 mb-3">
|
||||
<code className="flex-1 text-xs font-mono text-text-muted bg-surface/80 px-3 py-1.5 rounded-lg truncate">
|
||||
{baseUrl.replace(/\/v1$/, "")}
|
||||
{path}
|
||||
</code>
|
||||
<button
|
||||
onClick={() => copy(`${baseUrl.replace(/\/v1$/, "")}${path}`, copyId)}
|
||||
className="p-1.5 hover:bg-surface rounded-lg text-text-muted hover:text-primary transition-colors shrink-0"
|
||||
>
|
||||
<span className="material-symbols-outlined text-[16px]">
|
||||
{copied === copyId ? "check" : "content_copy"}
|
||||
</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{/* Models grouped by provider */}
|
||||
{modelsLoading ? (
|
||||
<div className="flex items-center gap-2 rounded-lg border border-border/70 bg-surface/40 px-3 py-2 text-xs text-text-muted">
|
||||
<span className="material-symbols-outlined animate-spin text-sm">
|
||||
progress_activity
|
||||
</span>
|
||||
<span>{t("loadingModels")}</span>
|
||||
</div>
|
||||
) : (
|
||||
<div className="flex flex-col gap-2">
|
||||
{grouped.map(([providerId, providerModels]) => (
|
||||
<div key={providerId}>
|
||||
<div className="flex items-center gap-2 mb-1">
|
||||
<div
|
||||
className="size-2.5 rounded-full shrink-0"
|
||||
style={{ backgroundColor: providerColor(providerId) }}
|
||||
/>
|
||||
<span className="text-xs font-semibold text-text-main">
|
||||
{providerName(providerId)}
|
||||
</span>
|
||||
<span className="text-xs text-text-muted">
|
||||
({(providerModels as any).length})
|
||||
</span>
|
||||
</div>
|
||||
<div className="ml-5 flex flex-wrap gap-1.5">
|
||||
{(providerModels as any).map((m) => (
|
||||
<span
|
||||
key={m.id}
|
||||
className="text-xs px-2 py-0.5 rounded-md bg-surface/80 text-text-muted font-mono"
|
||||
title={m.id}
|
||||
>
|
||||
{m.root || m.id.split("/").pop()}
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -7,6 +7,10 @@ type AdaptaTutorialModalProps = {
|
||||
onClose: () => void;
|
||||
};
|
||||
|
||||
// The Adapta CTA href points at https://link.omniroute.online/adapta (our own
|
||||
// shortener, the `adapta` slug) so the click lands in our Kutt metrics. The visible
|
||||
// link text intentionally stays the real domain (agent.adapta.one/agentic-chat) so
|
||||
// users still see where they are going.
|
||||
export function AdaptaTutorialModal({ isOpen, onClose }: AdaptaTutorialModalProps) {
|
||||
const t = useTranslations("providers.adaptaTutorial");
|
||||
|
||||
@@ -29,7 +33,7 @@ export function AdaptaTutorialModal({ isOpen, onClose }: AdaptaTutorialModalProp
|
||||
<p className="text-text-muted mt-0.5">
|
||||
{t("step1DescPrefix")}{" "}
|
||||
<a
|
||||
href="https://agent.adapta.one/agentic-chat"
|
||||
href="https://link.omniroute.online/adapta"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="underline text-primary"
|
||||
|
||||
@@ -294,7 +294,9 @@ export default function EditConnectionModal({
|
||||
// external system on `isOpen`); remounting the 30+ field form per
|
||||
// connection id is a behavior-risking restructure out of scope here
|
||||
// (#11251 follow-up, #9985).
|
||||
// eslint-disable-next-line react-hooks/set-state-in-effect
|
||||
// NOTE: no react-hooks/set-state-in-effect suppression needed — the rule
|
||||
// only fires on unconditional synchronous setState, and this one is
|
||||
// guarded by the isOpen/connection condition above.
|
||||
setFormData({
|
||||
name: connection.name || "",
|
||||
priority: connection.priority || 1,
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
"use client";
|
||||
|
||||
import { useCallback, useEffect, useState } from "react";
|
||||
import { Badge, Button, Card } from "@/shared/components";
|
||||
import type {
|
||||
CliproxyAccountHealth,
|
||||
CliproxyAccountHealthResult,
|
||||
} from "@/lib/services/cliproxyAccountHealth";
|
||||
|
||||
const STATE_LABELS: Record<CliproxyAccountHealthResult["state"], string> = {
|
||||
ready: "Account health",
|
||||
disabled: "CLIProxyAPI is not installed",
|
||||
missing_key: "Management key is not configured",
|
||||
unreachable: "Management API is unreachable",
|
||||
unauthorized: "Management key was rejected",
|
||||
unsupported: "This CLIProxyAPI version does not expose account health",
|
||||
invalid_response: "Management API returned an unsupported response",
|
||||
};
|
||||
|
||||
function AccountRow({ account }: { account: CliproxyAccountHealth }) {
|
||||
const state = account.disabled ? "Disabled" : account.unavailable ? "Unavailable" : account.status;
|
||||
return (
|
||||
<li className="flex flex-wrap items-center justify-between gap-3 border-t border-border py-3 first:border-t-0">
|
||||
<div className="min-w-0">
|
||||
<div className="flex items-center gap-2">
|
||||
<span className="truncate font-medium text-text-main">
|
||||
{account.label || account.authIndex}
|
||||
</span>
|
||||
<Badge variant={account.disabled || account.unavailable ? "warning" : "success"}>
|
||||
{state || "Unknown"}
|
||||
</Badge>
|
||||
</div>
|
||||
<p className="mt-1 text-xs text-text-muted">
|
||||
{[account.provider || account.type, account.label ? account.authIndex : ""]
|
||||
.filter(Boolean)
|
||||
.join(" · ")}
|
||||
</p>
|
||||
</div>
|
||||
<div className="text-right text-xs text-text-muted">
|
||||
<div>{account.success.toLocaleString()} succeeded</div>
|
||||
<div>{account.failed.toLocaleString()} failed</div>
|
||||
</div>
|
||||
</li>
|
||||
);
|
||||
}
|
||||
|
||||
export function CliproxyAccountHealthCard() {
|
||||
const [result, setResult] = useState<CliproxyAccountHealthResult | null>(null);
|
||||
const [loading, setLoading] = useState(true);
|
||||
|
||||
const load = useCallback(async () => {
|
||||
setLoading(true);
|
||||
try {
|
||||
const response = await fetch("/api/services/cliproxy/accounts", { cache: "no-store" });
|
||||
if (!response.ok) throw new Error(`HTTP ${response.status}`);
|
||||
setResult(await response.json());
|
||||
} catch {
|
||||
setResult({ state: "unreachable", accounts: [], version: null });
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
void load();
|
||||
}, [load]);
|
||||
|
||||
return (
|
||||
<Card
|
||||
title="CLIProxyAPI accounts"
|
||||
subtitle="Read-only status from the authenticated management API"
|
||||
action={
|
||||
<Button variant="secondary" size="sm" onClick={() => void load()} loading={loading}>
|
||||
Refresh
|
||||
</Button>
|
||||
}
|
||||
>
|
||||
{result?.state === "ready" ? (
|
||||
result.accounts.length > 0 ? (
|
||||
<ul aria-label="CLIProxyAPI account health">
|
||||
{result.accounts.map((account) => (
|
||||
<AccountRow key={account.authIndex} account={account} />
|
||||
))}
|
||||
</ul>
|
||||
) : (
|
||||
<p className="text-sm text-text-muted">No CLIProxyAPI accounts found.</p>
|
||||
)
|
||||
) : (
|
||||
<p className="text-sm text-text-muted">
|
||||
{loading && !result ? "Loading account health…" : STATE_LABELS[result?.state ?? "unreachable"]}
|
||||
</p>
|
||||
)}
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
@@ -8,6 +8,7 @@ import { AutoStartToggle } from "../components/AutoStartToggle";
|
||||
import { AutoRestartAdoptedToggle } from "../components/AutoRestartAdoptedToggle";
|
||||
import { CliproxyConnectionPanel } from "../components/CliproxyConnectionPanel";
|
||||
import { CliproxyProviderExposureCard } from "../components/CliproxyProviderExposureCard";
|
||||
import { CliproxyAccountHealthCard } from "../components/CliproxyAccountHealthCard";
|
||||
|
||||
const NAME = "cliproxy";
|
||||
|
||||
@@ -19,6 +20,7 @@ export function CliproxyServiceTab() {
|
||||
<AutoStartToggle name={NAME} />
|
||||
<AutoRestartAdoptedToggle name={NAME} />
|
||||
<CliproxyConnectionPanel />
|
||||
<CliproxyAccountHealthCard />
|
||||
<CliproxyProviderExposureCard />
|
||||
<CliproxyModelMappingEditor />
|
||||
<ServiceLogsPanel name={NAME} />
|
||||
|
||||
@@ -10,6 +10,7 @@ import {
|
||||
VIDEO_BRIDGE_TIMEOUT_MAX_MS,
|
||||
VIDEO_BRIDGE_TIMEOUT_MIN_MS,
|
||||
resolveVideoBridgeRuntimeSettings,
|
||||
type VideoAnalysisMode,
|
||||
type VideoSamplingPolicy,
|
||||
} from "@/shared/constants/modalityBridgeDefaults";
|
||||
|
||||
@@ -17,6 +18,7 @@ import ModalityBridgeStatsRow from "./ModalityBridgeStatsRow";
|
||||
|
||||
interface VideoState {
|
||||
modalityBridgeVideoEnabled: boolean;
|
||||
modalityBridgeVideoAnalysisMode: VideoAnalysisMode;
|
||||
modalityBridgeVideoModel: string;
|
||||
modalityBridgeVideoFrameCount: number;
|
||||
modalityBridgeVideoSamplingPolicy: VideoSamplingPolicy;
|
||||
@@ -44,6 +46,7 @@ function fromApi(value: unknown): VideoState {
|
||||
const runtime = resolveVideoBridgeRuntimeSettings(asRecord(value));
|
||||
return {
|
||||
modalityBridgeVideoEnabled: runtime.enabled,
|
||||
modalityBridgeVideoAnalysisMode: runtime.analysisMode,
|
||||
modalityBridgeVideoModel: runtime.model,
|
||||
modalityBridgeVideoFrameCount: runtime.frameCount,
|
||||
modalityBridgeVideoSamplingPolicy: runtime.samplingPolicy,
|
||||
@@ -223,6 +226,32 @@ export default function ModalityBridgeVideoTab({
|
||||
description={t("modalityBridgeVideoEnabledDesc")}
|
||||
/>
|
||||
|
||||
<label className="block text-sm font-medium">
|
||||
{t("modalityBridgeMode")}
|
||||
<select
|
||||
data-testid="modality-bridge-video-analysis-mode"
|
||||
aria-describedby="modality-bridge-video-analysis-mode-description"
|
||||
value={settings.modalityBridgeVideoAnalysisMode}
|
||||
onChange={(event) =>
|
||||
void update({
|
||||
modalityBridgeVideoAnalysisMode: event.currentTarget.value as VideoAnalysisMode,
|
||||
})
|
||||
}
|
||||
className="mt-1 w-full rounded-control border border-border bg-surface px-3 py-2 text-sm"
|
||||
>
|
||||
<option value="full">{tRoot("health.degradationFull")}</option>
|
||||
<option value="focused">{t("modalityBridgeTaskAware")}</option>
|
||||
</select>
|
||||
<span
|
||||
id="modality-bridge-video-analysis-mode-description"
|
||||
className="mt-1 block text-xs font-normal text-text-muted"
|
||||
>
|
||||
{settings.modalityBridgeVideoAnalysisMode === "focused"
|
||||
? t("modalityBridgeTaskAwareDesc")
|
||||
: t("modalityBridgeVideoDesc")}
|
||||
</span>
|
||||
</label>
|
||||
|
||||
<ModelSelectField
|
||||
label={t("modalityBridgeVideoModel")}
|
||||
value={settings.modalityBridgeVideoModel}
|
||||
|
||||
@@ -1,22 +1,149 @@
|
||||
import { z } from "zod";
|
||||
|
||||
import { sanitizeErrorMessage } from "@omniroute/open-sse/utils/error";
|
||||
import { createErrorResponse } from "@/lib/api/errorResponse";
|
||||
import {
|
||||
VIDEO_BRIDGE_BROKER_PATH,
|
||||
isVideoBridgeBrokerInternalRequest,
|
||||
resolveVideoBridgeDrilldownPrincipal,
|
||||
VIDEO_BRIDGE_DRILLDOWN_PATH,
|
||||
} from "@/lib/guardrails/videoBridgeBrokerAuth";
|
||||
import {
|
||||
VideoDrilldownAbortedError,
|
||||
VideoDrilldownCache,
|
||||
type VideoDrilldownFrame,
|
||||
VideoDrilldownValidationError,
|
||||
VIDEO_DRILLDOWN_MAX_ENTRY_BYTES,
|
||||
VIDEO_DRILLDOWN_MAX_FRAME_DATA_URI_CHARS,
|
||||
} from "@/lib/guardrails/videoBridgeDrilldown";
|
||||
import { resolveModelSyncInternalBaseUrl } from "@/shared/services/modelSyncScheduler";
|
||||
import { createLogger } from "@/shared/utils/logger";
|
||||
|
||||
const log = createLogger("video-bridge-drilldown");
|
||||
|
||||
export const dynamic = "force-dynamic";
|
||||
export const revalidate = 0;
|
||||
|
||||
export const VIDEO_BRIDGE_DRILLDOWN_PATH = "/api/modality-bridge/video/drilldown";
|
||||
const MAX_BODY_BYTES = 34 * 1024 * 1024;
|
||||
export { VIDEO_BRIDGE_DRILLDOWN_PATH };
|
||||
export const VIDEO_DRILLDOWN_MAX_BODY_BYTES =
|
||||
Math.ceil(VIDEO_DRILLDOWN_MAX_ENTRY_BYTES / 3) * 4 + 64 * 1024;
|
||||
|
||||
function isCanonicalOpaqueId(value: string): boolean {
|
||||
return value === value.trim();
|
||||
}
|
||||
|
||||
function isAsciiAlphaNumeric(code: number): boolean {
|
||||
return (
|
||||
(code >= 0x30 && code <= 0x39) ||
|
||||
(code >= 0x41 && code <= 0x5a) ||
|
||||
(code >= 0x61 && code <= 0x7a)
|
||||
);
|
||||
}
|
||||
|
||||
function isDerivationToken(value: string): boolean {
|
||||
if (value.length < 1 || value.length > 64 || !isAsciiAlphaNumeric(value.charCodeAt(0))) {
|
||||
return false;
|
||||
}
|
||||
for (let index = 1; index < value.length; index += 1) {
|
||||
const code = value.charCodeAt(index);
|
||||
if (
|
||||
!isAsciiAlphaNumeric(code) &&
|
||||
code !== 0x2e &&
|
||||
code !== 0x5f &&
|
||||
code !== 0x2f &&
|
||||
code !== 0x2d
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function isSha256Id(value: string): boolean {
|
||||
if (value.length !== 71 || !value.startsWith("sha256:")) return false;
|
||||
for (let index = 7; index < value.length; index += 1) {
|
||||
const code = value.charCodeAt(index);
|
||||
if (!((code >= 0x30 && code <= 0x39) || (code >= 0x61 && code <= 0x66))) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function isCanonicalNonNegativeNumber(value: string): boolean {
|
||||
if (value.length < 1 || value.length > 64 || value !== value.trim()) return false;
|
||||
const parsed = Number(value);
|
||||
return Number.isFinite(parsed) && parsed >= 0;
|
||||
}
|
||||
|
||||
function isCanonicalFrameCount(value: string): boolean {
|
||||
if (value.length < 1 || value.length > 2) return false;
|
||||
for (let index = 0; index < value.length; index += 1) {
|
||||
const code = value.charCodeAt(index);
|
||||
if (code < 0x30 || code > 0x39) return false;
|
||||
}
|
||||
const parsed = Number(value);
|
||||
return parsed >= 1 && parsed <= 16;
|
||||
}
|
||||
|
||||
const SessionIdSchema = z
|
||||
.string()
|
||||
.min(1)
|
||||
.max(128)
|
||||
.refine(isCanonicalOpaqueId, "sessionId must not contain surrounding whitespace");
|
||||
const VideoRefSchema = z
|
||||
.string()
|
||||
.min(1)
|
||||
.max(4096)
|
||||
.refine(isCanonicalOpaqueId, "videoRef must not contain surrounding whitespace");
|
||||
const NonNegativeQueryNumberSchema = z
|
||||
.string()
|
||||
.refine(isCanonicalNonNegativeNumber)
|
||||
.transform(Number);
|
||||
const FrameCountQuerySchema = z.string().refine(isCanonicalFrameCount).transform(Number);
|
||||
const DrilldownReadQuerySchema = z
|
||||
.object({
|
||||
end: NonNegativeQueryNumberSchema.optional(),
|
||||
frames: FrameCountQuerySchema.optional(),
|
||||
sessionId: SessionIdSchema,
|
||||
start: NonNegativeQueryNumberSchema.optional(),
|
||||
videoRef: VideoRefSchema,
|
||||
})
|
||||
.strict();
|
||||
const DrilldownDeleteQuerySchema = z.object({ sessionId: SessionIdSchema }).strict();
|
||||
const DrilldownDerivationSchema = z
|
||||
.object({
|
||||
parentContentHash: z.string().refine(isSha256Id),
|
||||
policy: z.string().refine(isDerivationToken),
|
||||
version: z.string().refine(isDerivationToken),
|
||||
})
|
||||
.strict();
|
||||
const DrilldownFrameSchema = z
|
||||
.object({
|
||||
dataUri: z.string().min(1).max(VIDEO_DRILLDOWN_MAX_FRAME_DATA_URI_CHARS),
|
||||
timestampSeconds: z.number().finite().nonnegative(),
|
||||
})
|
||||
.strict();
|
||||
const DrilldownPostBodySchema = z
|
||||
.object({
|
||||
derivation: DrilldownDerivationSchema,
|
||||
durationSeconds: z.number().finite().positive().max(600),
|
||||
frames: z.array(DrilldownFrameSchema).min(1).max(16),
|
||||
sessionId: SessionIdSchema,
|
||||
videoRef: VideoRefSchema,
|
||||
})
|
||||
.strict()
|
||||
.superRefine((value, context) => {
|
||||
for (let index = 0; index < value.frames.length; index += 1) {
|
||||
if (value.frames[index].timestampSeconds > value.durationSeconds) {
|
||||
context.addIssue({
|
||||
code: "custom",
|
||||
message: "frame timestamp exceeds duration",
|
||||
path: ["frames", index, "timestampSeconds"],
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
const drilldownCache = new VideoDrilldownCache({
|
||||
maxEntries: 64,
|
||||
// Global decoded-byte ceiling: without it, 64 entries × 32 MiB could pin ~2 GiB.
|
||||
maxEntriesPerPrincipal: 16,
|
||||
maxBytesPerPrincipal: 64 * 1024 * 1024,
|
||||
// Global retained-JPEG ceiling: without it, 64 entries × 32 MiB could pin ~2 GiB.
|
||||
maxTotalBytes: 256 * 1024 * 1024,
|
||||
ttlMs: 10 * 60 * 1000,
|
||||
});
|
||||
@@ -30,6 +157,47 @@ function invalid(message: string, status = 400): Response {
|
||||
return createErrorResponse({ status, message, type: "invalid_request" });
|
||||
}
|
||||
|
||||
class VideoDrilldownRequestAbortedError extends Error {}
|
||||
|
||||
function queryRecord(searchParams: URLSearchParams): Record<string, string | string[]> {
|
||||
const values: Record<string, string | string[]> = {};
|
||||
for (const [key, value] of searchParams) {
|
||||
const existing = values[key];
|
||||
values[key] =
|
||||
existing === undefined
|
||||
? value
|
||||
: Array.isArray(existing)
|
||||
? [...existing, value]
|
||||
: [existing, value];
|
||||
}
|
||||
return values;
|
||||
}
|
||||
|
||||
function yieldToEventLoop(): Promise<void> {
|
||||
return new Promise((resolve) => setImmediate(resolve));
|
||||
}
|
||||
|
||||
async function readBodyWithAbort(request: Request): Promise<ArrayBuffer> {
|
||||
if (request.signal.aborted) throw new VideoDrilldownRequestAbortedError();
|
||||
return new Promise<ArrayBuffer>((resolve, reject) => {
|
||||
const onAbort = () => {
|
||||
request.signal.removeEventListener("abort", onAbort);
|
||||
reject(new VideoDrilldownRequestAbortedError());
|
||||
};
|
||||
request.signal.addEventListener("abort", onAbort, { once: true });
|
||||
request.arrayBuffer().then(
|
||||
(bytes) => {
|
||||
request.signal.removeEventListener("abort", onAbort);
|
||||
resolve(bytes);
|
||||
},
|
||||
(error: unknown) => {
|
||||
request.signal.removeEventListener("abort", onAbort);
|
||||
reject(error);
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
function parseQuery(url: URL): {
|
||||
endSeconds?: number;
|
||||
frameCount?: number;
|
||||
@@ -37,28 +205,15 @@ function parseQuery(url: URL): {
|
||||
startSeconds?: number;
|
||||
videoRef: string;
|
||||
} | null {
|
||||
const allowed = new Set(["end", "frames", "sessionId", "start", "videoRef"]);
|
||||
if ([...url.searchParams.keys()].some((key) => !allowed.has(key))) return null;
|
||||
const sessionId = url.searchParams.get("sessionId")?.trim() ?? "";
|
||||
const videoRef = url.searchParams.get("videoRef")?.trim() ?? "";
|
||||
if (!sessionId || !videoRef) return null;
|
||||
const parseNumber = (name: string): number | undefined | null => {
|
||||
const value = url.searchParams.get(name);
|
||||
if (value === null) return undefined;
|
||||
const parsed = Number(value);
|
||||
return Number.isFinite(parsed) && parsed >= 0 ? parsed : null;
|
||||
const parsed = DrilldownReadQuerySchema.safeParse(queryRecord(url.searchParams));
|
||||
if (!parsed.success) return null;
|
||||
return {
|
||||
endSeconds: parsed.data.end,
|
||||
frameCount: parsed.data.frames,
|
||||
sessionId: parsed.data.sessionId,
|
||||
startSeconds: parsed.data.start,
|
||||
videoRef: parsed.data.videoRef,
|
||||
};
|
||||
const startSeconds = parseNumber("start");
|
||||
const endSeconds = parseNumber("end");
|
||||
const rawFrameCount = url.searchParams.get("frames");
|
||||
const frameCount =
|
||||
rawFrameCount === null
|
||||
? undefined
|
||||
: /^\d{1,2}$/.test(rawFrameCount) && Number(rawFrameCount) >= 1 && Number(rawFrameCount) <= 16
|
||||
? Number(rawFrameCount)
|
||||
: null;
|
||||
if (startSeconds === null || endSeconds === null || frameCount === null) return null;
|
||||
return { endSeconds, frameCount, sessionId, startSeconds, videoRef };
|
||||
}
|
||||
|
||||
interface VideoDrilldownRouteDependencies {
|
||||
@@ -71,60 +226,72 @@ export async function handleVideoDrilldownRequest(
|
||||
): Promise<Response> {
|
||||
const url = new URL(request.url);
|
||||
if (url.pathname !== expectedPath()) return invalid("Invalid Video Bridge drill-down path", 404);
|
||||
if (!isVideoBridgeBrokerInternalRequest(request, VIDEO_BRIDGE_BROKER_PATH)) {
|
||||
const principalId = resolveVideoBridgeDrilldownPrincipal(request);
|
||||
if (!principalId) {
|
||||
return invalid("This endpoint requires an authenticated internal loopback request", 403);
|
||||
}
|
||||
const cache = dependencies.cache ?? drilldownCache;
|
||||
if (request.method === "GET") {
|
||||
const query = parseQuery(url);
|
||||
if (!query) return invalid("Invalid Video Bridge drill-down query");
|
||||
const result = cache.get(query.sessionId, query.videoRef, query);
|
||||
const result = cache.get(principalId, query.sessionId, query.videoRef, query);
|
||||
return result
|
||||
? Response.json(result, { headers: { "Cache-Control": "no-store" } })
|
||||
: invalid("Video Bridge drill-down result was not found", 404);
|
||||
}
|
||||
if (request.method === "DELETE") {
|
||||
const sessionId = url.searchParams.get("sessionId")?.trim() ?? "";
|
||||
if (!sessionId || [...url.searchParams.keys()].some((key) => key !== "sessionId")) {
|
||||
return invalid("A sessionId is required");
|
||||
}
|
||||
return Response.json({ removed: cache.clearSession(sessionId) });
|
||||
const query = DrilldownDeleteQuerySchema.safeParse(queryRecord(url.searchParams));
|
||||
if (!query.success) return invalid("A canonical sessionId is required");
|
||||
return Response.json({ removed: cache.clearSession(principalId, query.data.sessionId) });
|
||||
}
|
||||
if (request.method !== "POST") return invalid("Invalid Video Bridge drill-down method", 405);
|
||||
if (request.headers.get("content-type")?.toLowerCase() !== "application/json") {
|
||||
return invalid("Video Bridge drill-down requires application/json");
|
||||
}
|
||||
const declaredLength = Number(request.headers.get("content-length"));
|
||||
if (Number.isFinite(declaredLength) && declaredLength > MAX_BODY_BYTES) {
|
||||
if (Number.isFinite(declaredLength) && declaredLength > VIDEO_DRILLDOWN_MAX_BODY_BYTES) {
|
||||
return invalid("Video Bridge drill-down payload is too large", 413);
|
||||
}
|
||||
let body: unknown;
|
||||
try {
|
||||
const bytes = await request.arrayBuffer();
|
||||
if (bytes.byteLength > MAX_BODY_BYTES)
|
||||
const bytes = await readBodyWithAbort(request);
|
||||
if (bytes.byteLength > VIDEO_DRILLDOWN_MAX_BODY_BYTES)
|
||||
return invalid("Video Bridge drill-down payload is too large", 413);
|
||||
body = JSON.parse(Buffer.from(bytes).toString("utf8"));
|
||||
} catch {
|
||||
} catch (error: unknown) {
|
||||
if (error instanceof VideoDrilldownRequestAbortedError) {
|
||||
return invalid("Video Bridge drill-down request was cancelled", 499);
|
||||
}
|
||||
return invalid("Video Bridge drill-down payload is invalid");
|
||||
}
|
||||
if (!body || typeof body !== "object")
|
||||
return invalid("Video Bridge drill-down payload is invalid");
|
||||
const record = body as Record<string, unknown>;
|
||||
if (
|
||||
typeof record.sessionId !== "string" ||
|
||||
typeof record.videoRef !== "string" ||
|
||||
typeof record.durationSeconds !== "number" ||
|
||||
!Array.isArray(record.frames)
|
||||
) {
|
||||
return invalid("Video Bridge drill-down payload is invalid");
|
||||
const parsed = DrilldownPostBodySchema.safeParse(body);
|
||||
if (!parsed.success) return invalid("Video Bridge drill-down payload is invalid");
|
||||
await yieldToEventLoop();
|
||||
if (request.signal.aborted) {
|
||||
return invalid("Video Bridge drill-down request was cancelled", 499);
|
||||
}
|
||||
try {
|
||||
cache.put(record.sessionId, record.videoRef, {
|
||||
durationSeconds: record.durationSeconds,
|
||||
frames: record.frames as VideoDrilldownFrame[],
|
||||
await cache.put(principalId, parsed.data.sessionId, parsed.data.videoRef, parsed.data, {
|
||||
signal: request.signal,
|
||||
});
|
||||
} catch (error: unknown) {
|
||||
if (error instanceof VideoDrilldownValidationError) {
|
||||
return invalid("Video Bridge drill-down payload is invalid");
|
||||
}
|
||||
if (error instanceof VideoDrilldownAbortedError || request.signal.aborted) {
|
||||
return invalid("Video Bridge drill-down request was cancelled", 499);
|
||||
}
|
||||
log.error(
|
||||
{
|
||||
errorName: error instanceof Error ? sanitizeErrorMessage(error.name) : "UnknownError",
|
||||
},
|
||||
"Unexpected Video Bridge drill-down cache failure"
|
||||
);
|
||||
return createErrorResponse({
|
||||
status: 500,
|
||||
message: "Video Bridge drill-down could not be stored",
|
||||
type: "server_error",
|
||||
});
|
||||
} catch {
|
||||
return invalid("Video Bridge drill-down payload is invalid");
|
||||
}
|
||||
return Response.json({ stored: true }, { status: 201, headers: { "Cache-Control": "no-store" } });
|
||||
}
|
||||
|
||||
@@ -439,13 +439,22 @@ type ProviderConnectionLike = {
|
||||
* whose stored `providerSpecificData.profileArn` matches the given ARN.
|
||||
* Returns null when profileArn is undefined/null or no match is found.
|
||||
*
|
||||
* #10815 hardened `findKiroConnectionByIdentity` to require an account-level
|
||||
* identifier (email or clientId) alongside a matching profileArn before
|
||||
* trusting the match — distinct Builder ID accounts (Google/GitHub social
|
||||
* login) can share the same CodeWhisperer profile ARN, and matching on ARN
|
||||
* alone let a second social login silently overwrite the first connection.
|
||||
* `email`/`clientId` here let a caller supply that account identifier; the
|
||||
* real `saveAndRespond()` call sites already do (see below).
|
||||
*
|
||||
* Exported for unit tests (#3615).
|
||||
*/
|
||||
export function findKiroConnectionByProfileArn(
|
||||
connections: ProviderConnectionLike[],
|
||||
profileArn: string | undefined
|
||||
profileArn: string | undefined,
|
||||
accountIdentity?: { email?: string | null; clientId?: string | null }
|
||||
): ProviderConnectionLike | null {
|
||||
return findKiroConnectionByIdentity(connections, { profileArn });
|
||||
return findKiroConnectionByIdentity(connections, { profileArn, ...accountIdentity });
|
||||
}
|
||||
|
||||
// ── Save to OmniRoute DB ──────────────────────────────────────────────────────
|
||||
|
||||
@@ -29,6 +29,7 @@ import { canUpdateProviderApiKey } from "@/shared/providers/webSessionCredential
|
||||
import {
|
||||
refreshConnectionRateLimits,
|
||||
enableRateLimitProtection,
|
||||
disableRateLimitProtection,
|
||||
} from "@/../open-sse/services/rateLimitManager";
|
||||
import {
|
||||
finalizeValidatedChatGptWebCodexSecrets,
|
||||
@@ -342,10 +343,18 @@ export async function PUT(request: Request, { params }: { params: Promise<{ id:
|
||||
|
||||
// If rateLimitOverrides was included in the request, refresh the in-memory
|
||||
// rate limiter state so the change takes effect without a server restart.
|
||||
// Also ensure rate limit protection is active so the limiter is enforced.
|
||||
// Only (re)enable enforcement when rate limit protection is actually
|
||||
// persisted for this connection — this route never lets a caller flip
|
||||
// `rateLimitProtection` itself, so any drift here would silently start
|
||||
// queuing requests through Bottleneck for a connection whose DB row (and
|
||||
// the dashboard toggle reading it) both still say "off" (#11278).
|
||||
if (rateLimitOverrides !== undefined) {
|
||||
refreshConnectionRateLimits(id, updated?.rateLimitOverrides ?? null);
|
||||
enableRateLimitProtection(id);
|
||||
if (updated?.rateLimitProtection === true) {
|
||||
enableRateLimitProtection(id);
|
||||
} else {
|
||||
disableRateLimitProtection(id);
|
||||
}
|
||||
}
|
||||
|
||||
// Hide sensitive fields
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
import { getSupervisor, registerSupervisor } from "@/lib/services/registry";
|
||||
import { ServiceSupervisor } from "@/lib/services/ServiceSupervisor";
|
||||
import { resolveSpawnArgs, CLIPROXY_DEFAULT_PORT } from "@/lib/services/installers/cliproxy";
|
||||
import { getOrCreateApiKey } from "@/lib/services/apiKey";
|
||||
|
||||
const TOOL = "cliproxy";
|
||||
const PORT = parseInt(process.env.CLIPROXYAPI_PORT ?? String(CLIPROXY_DEFAULT_PORT), 10);
|
||||
@@ -14,10 +15,11 @@ export async function getOrInitSupervisor(): Promise<ServiceSupervisor> {
|
||||
const existing = getSupervisor(TOOL);
|
||||
if (existing) return existing;
|
||||
|
||||
const managementKey = await getOrCreateApiKey(TOOL);
|
||||
const sup = new ServiceSupervisor({
|
||||
tool: TOOL,
|
||||
port: PORT,
|
||||
spawnArgs: () => resolveSpawnArgs(PORT),
|
||||
spawnArgs: () => resolveSpawnArgs(PORT, managementKey),
|
||||
healthUrl: () => `http://127.0.0.1:${PORT}/v1/models`,
|
||||
healthIntervalMs: 5_000,
|
||||
stopTimeoutMs: 15_000,
|
||||
|
||||