Compare commits

..

7 Commits

Author SHA1 Message Date
Diego Rodrigues de Sa e Souza
ae8a7d2dc5 Release v3.7.3 (#1724)
* Update image-model list

* docs: update CHANGELOG.md with merged PR entries for v3.7.3

* chore(release): bump to v3.7.3 — changelog, docs, version sync

* chore(workflow): update generate-release with Phase 2 validation step

---------

Co-authored-by: backryun <bakryun0718@proton.me>
Co-authored-by: diegosouzapw <diegosouzapw@users.noreply.github.com>
2026-04-28 10:03:39 -03:00
Randi
2f1c904d74 Fix light mode active request payload modal (#1714)
Integrated into release/v3.7.3 — fixes light mode payload modal transparency
2026-04-28 08:31:48 -03:00
Slavic Kozyuk
aa535748ef fix(combo): avoid false ALL_ACCOUNTS_INACTIVE on quality failures (#1710)
Integrated into release/v3.7.3 — quality validation regression tests (production fix was already applied)
2026-04-28 08:30:49 -03:00
Randi
42952ee42f fix(combo): fall back across targets on all 400 responses (#1713)
Integrated into release/v3.7.3 — simplifies combo fallback by treating all non-ok responses as target-local failures
2026-04-28 08:28:09 -03:00
Randi
8a0ca60e4b [Urgent] fix: add neutral instructions for bare chat in Codex provider (#1709)
Integrated into release/v3.7.3 — adds neutral instructions fallback for bare Codex chat requests
2026-04-28 08:25:54 -03:00
vanminhph
e6e7f8d402 fix(codex): restore namespace MCP tools + hosted-tool whitelist (regression from #1581) (#1715)
Integrated into release/v3.7.3 — restores Codex namespace MCP tools and hosted-tool whitelist
2026-04-28 08:23:33 -03:00
diegosouzapw
edd6941de4 fix: resolve 5 bugs (#1712 #1719 #1707 #1706 #1704)
- #1712: Strip existing billing headers before injecting to fix prompt cache misses
- #1719: Strip output_config.format for non-Anthropic Claude endpoints
- #1707: Set terminal error state on quality validation failure (false ALL_ACCOUNTS_INACTIVE)
- #1706: Wrap proxy_assignments queries in try-catch for missing table on Electron
- #1704: Fix Windows file URL path resolution in migration runner with cwd fallback
2026-04-28 07:48:19 -03:00
36 changed files with 749 additions and 606 deletions

View File

@@ -213,11 +213,43 @@ Inform the user:
---
## Phase 2: Post-Merge (only after user confirms)
## Phase 2: Post-Merge Validation (Local VPS)
> Run these steps only AFTER the user has merged the PR.
> Run these steps only AFTER the user has merged the PR into `main` and all CI jobs have passed.
### 11. Create Git Tag and GitHub Release (MANDATORY)
### 11. Deploy to Local VPS for Final Validation (MANDATORY)
Before cutting the official git tag and publishing to the world, deploy the `main` branch to the Local VPS for a final homologation test.
```bash
git checkout main
git pull origin main
# Build and pack locally
cd /home/diegosouzapw/dev/proxys/9router && rm -f omniroute-*.tgz && rm -rf .next/cache app/.next/cache && npm run build:cli && rm -rf app/logs app/coverage app/.git app/.app-build-backup* && npm pack --ignore-scripts
# Deploy to LOCAL VPS (192.168.0.15)
scp omniroute-*.tgz root@192.168.0.15:/tmp/
ssh root@192.168.0.15 "npm install -g /tmp/omniroute-*.tgz --ignore-scripts && cd /usr/lib/node_modules/omniroute/app && npm rebuild better-sqlite3 && pm2 delete omniroute 2>/dev/null; pm2 start /root/.omniroute/ecosystem.config.cjs --update-env && pm2 save && echo '✅ Local done'"
# Verify
curl -s -o /dev/null -w "LOCAL: HTTP %{http_code}\n" http://192.168.0.15:20128/
```
### 12. 🛑 STOP — Notify User & Await Final OK
**This is a mandatory stop point.**
Inform the user that the `main` branch is now running on the Local VPS.
Wait for the user to manually test and give the **OK**.
**DO NOT proceed to Phase 3 until the user confirms the local deploy is stable.**
---
## Phase 3: Official Launch
> Run these steps only AFTER the user gives the final OK from the Phase 2 local validation.
### 13. Create Git Tag and GitHub Release (MANDATORY)
// turbo
@@ -239,7 +271,7 @@ gh release create "v$VERSION" --title "v$VERSION" --notes "$NOTES" --target main
> **CRITICAL**: Docker Hub and npm MUST always publish the same version.
> The Docker image is built automatically via GitHub Actions when a new tag is pushed.
> After pushing the tag in step 11-12, **verify the workflow runs**:
> After pushing the tag in step 13, **verify the workflow runs**:
```bash
# Verify the Docker workflow triggered
@@ -247,40 +279,30 @@ gh run list --repo diegosouzapw/OmniRoute --workflow docker-publish.yml --limit
# Wait for the Docker build to complete (usually 5–10 min)
gh run watch --repo diegosouzapw/OmniRoute
# After completion, verify on Docker Hub:
# https://hub.docker.com/r/diegosouzapw/omniroute/tags
```
If the Docker build was not triggered automatically, trigger it manually:
### 15. Publish to NPM (Optional/Automated)
Normally handled by CI, but if manual publish is required:
```bash
gh workflow run docker-publish.yml --repo diegosouzapw/OmniRoute --ref v2.x.y
npm publish
```
### 15. Deploy to BOTH VPS environments (MANDATORY)
### 16. Deploy to AKAMAI VPS (Production)
> Always deploy to **both** environments after every release.
> See `/deploy-vps` workflow for detailed steps.
Now that the release is officially cut, deploy it to the Akamai VPS.
```bash
# Build and pack locally
cd /home/diegosouzapw/dev/proxys/9router && rm -f omniroute-*.tgz && rm -rf .next/cache app/.next/cache && npm run build:cli && rm -rf app/logs app/coverage app/.git app/.app-build-backup* && npm pack --ignore-scripts
# Deploy to LOCAL VPS (192.168.0.15)
scp omniroute-*.tgz root@192.168.0.15:/tmp/
ssh root@192.168.0.15 "npm install -g /tmp/omniroute-*.tgz --ignore-scripts && cd /usr/lib/node_modules/omniroute/app && npm rebuild better-sqlite3 && pm2 delete omniroute 2>/dev/null; pm2 start /root/.omniroute/ecosystem.config.cjs --update-env && pm2 save && echo '✅ Local done'"
# Deploy to AKAMAI VPS (69.164.221.35)
scp omniroute-*.tgz root@69.164.221.35:/tmp/
ssh root@69.164.221.35 "npm install -g /tmp/omniroute-*.tgz --ignore-scripts && cd /usr/lib/node_modules/omniroute/app && npm rebuild better-sqlite3 && pm2 delete omniroute 2>/dev/null; pm2 start /root/.omniroute/ecosystem.config.cjs --update-env && pm2 save && echo '✅ Akamai done'"
# Verify both
curl -s -o /dev/null -w "LOCAL: HTTP %{http_code}\n" http://192.168.0.15:20128/
# Verify
curl -s -o /dev/null -w "AKAMAI: HTTP %{http_code}\n" http://69.164.221.35:20128/
```
### 16. Preserve release branch
### 17. Preserve release branch
```bash
# Branch is kept for historical purposes. Do not delete.

View File

@@ -4,6 +4,26 @@
---
## [3.7.3] — 2026-04-28
### 🐛 Bug Fixes
- **fix(claude):** strip existing billing headers from system array before injecting to prevent Anthropic prompt cache misses — stacked `x-anthropic-billing-header` blocks invalidated prefix matching, causing ~100% cache_create instead of cache_read (#1712)
- **fix(claude):** strip `output_config.format` for non-Anthropic Claude-compatible providers during passthrough — third-party Claude endpoints (MiniMax, DeepSeek via aggregators) reject structured output fields with 400 errors (#1719)
- **fix(combo):** set terminal error state on response quality validation failure — prevents misleading `ALL_ACCOUNTS_INACTIVE` 503 when the real issue is response quality validation (#1707, #1710)
- **fix(combo):** treat combo fallback as target-level orchestration — all non-ok responses (including generic 400s) now fall through to the next target instead of being terminal; removes complex bad-request allowlist regex (#1713)
- **fix(codex):** restore namespace MCP tools and hosted-tool whitelist — regression from #1581 that silently dropped all MCP tool groups and Responses-API hosted tools (#1715)
- **fix(codex):** add neutral instructions for bare chat requests — Codex Responses backend rejects requests without `instructions`, making Codex unusable for normal chat (#1709)
- **fix(proxy):** wrap proxy assignment queries in try-catch for missing `proxy_assignments` table — Electron installs where migration 004 hasn't run no longer crash with `no such table` error (#1706)
- **fix(migration):** improve Windows file URL path resolution in migration runner — adds direct URL path extraction and `process.cwd()` fallback for CI-built bundles with leaked build-time paths (#1704)
- **fix(ui):** fix light mode active request payload modal — add missing `--color-card` theme token, use opaque `bg-surface` instead of translucent `bg-card/70`, add backdrop blur (#1714)
### 🔄 Updates
- **chore(image-models):** refresh image generation model registry — replace stale FLUX aliases with FLUX Kontext / FLUX.2 mappings, remove deprecated FLUX Redux/Depth/Canny variants (#1722)
---
## [3.7.2] — 2026-04-28
### ✨ New Features

View File

@@ -1,7 +1,7 @@
openapi: 3.1.0
info:
title: OmniRoute API
version: 3.7.2
version: 3.7.3
description: |
OmniRoute is a local-first AI API proxy router. It provides an OpenAI-compatible
endpoint that routes requests to multiple AI providers with load balancing,

View File

@@ -1,6 +1,6 @@
{
"name": "omniroute-desktop",
"version": "3.7.2",
"version": "3.7.3",
"description": "OmniRoute Desktop Application",
"main": "main.js",
"author": {

View File

@@ -8,7 +8,7 @@ OmniRoute solves the problem of managing multiple AI provider subscriptions, quo
**Key value:** One endpoint (`http://localhost:20128/v1`), unlimited models, zero downtime, minimal cost.
**Current version:** 3.7.2
**Current version:** 3.7.3
## Tech Stack
@@ -279,7 +279,7 @@ OmniRoute solves the problem of managing multiple AI provider subscriptions, quo
└── .env.example # Environment variable template
```
## Key Features (v3.7.2)
## Key Features (v3.7.3)
### Core Proxy
- **160+ AI providers** with automatic format translation

View File

@@ -1,6 +1,8 @@
// Default instructions for Codex models
// Source: CLIProxyAPI internal/misc/codex_instructions/
export const CODEX_CHAT_DEFAULT_INSTRUCTIONS = "You are a ChatGPT agent.";
export const CODEX_DEFAULT_INSTRUCTIONS = `You are Codex, based on GPT-5. You are running as a coding agent in the Codex CLI on a user's computer.
## General

View File

@@ -37,57 +37,60 @@ interface ImageModelAliasEntry {
const IMAGE_MODEL_ALIASES: Record<string, ImageModelAliasEntry> = {
"flux-kontext": {
provider: "pollinations",
model: "flux-kontext",
name: "FLUX Kontext",
provider: "black-forest-labs",
model: "flux-kontext-pro",
name: "FLUX Kontext Pro",
listInCatalog: true,
inputModalities: ["text", "image"],
},
"flux-kontext-max": {
provider: "together",
model: "black-forest-labs/FLUX.1.1-pro",
provider: "black-forest-labs",
model: "flux-kontext-max",
name: "FLUX Kontext Max",
listInCatalog: true,
inputModalities: ["text", "image"],
},
"flux-redux": {
provider: "together",
model: "black-forest-labs/FLUX.1-redux",
name: "FLUX Redux",
"flux-2-max": {
provider: "black-forest-labs",
model: "flux-2-max",
name: "FLUX.2 Max",
listInCatalog: true,
inputModalities: ["text", "image"],
},
"flux-depth": {
provider: "together",
model: "black-forest-labs/FLUX.1-depth",
name: "FLUX Depth",
"flux-2-pro": {
provider: "black-forest-labs",
model: "flux-2-pro",
name: "FLUX.2 Pro",
listInCatalog: true,
inputModalities: ["text", "image"],
},
"flux-canny": {
provider: "together",
model: "black-forest-labs/FLUX.1-canny",
name: "FLUX Canny",
"flux-2-flex": {
provider: "black-forest-labs",
model: "flux-2-flex",
name: "FLUX.2 Flex",
listInCatalog: true,
inputModalities: ["text", "image"],
},
"flux-dev-lora": {
"flux-2-dev": {
provider: "together",
model: "black-forest-labs/FLUX.1-dev-lora",
name: "FLUX Dev LoRA",
model: "black-forest-labs/FLUX.2-dev",
name: "FLUX.2 Dev",
listInCatalog: true,
inputModalities: ["text", "image"],
},
kontext: {
provider: "pollinations",
model: "flux-kontext",
name: "FLUX Kontext",
provider: "black-forest-labs",
model: "flux-kontext-pro",
name: "FLUX Kontext Pro",
listInCatalog: false,
inputModalities: ["text", "image"],
},
"pollinations/kontext": {
provider: "pollinations",
model: "flux-kontext",
name: "FLUX Kontext",
provider: "black-forest-labs",
model: "flux-kontext-pro",
name: "FLUX Kontext Pro",
listInCatalog: false,
inputModalities: ["text", "image"],
},
};
@@ -110,11 +113,11 @@ export const IMAGE_PROVIDERS: Record<string, ImageProviderConfig> = {
authHeader: "bearer",
format: "openai", // native OpenAI format
models: [
{ id: "gpt-image-1", name: "GPT Image 1" },
{ id: "dall-e-3", name: "DALL-E 3" },
{ id: "dall-e-2", name: "DALL-E 2" },
{ id: "gpt-image-2", name: "GPT Image 2" },
{ id: "gpt-image-1.5", name: "GPT Image 1.5" },
{ id: "gpt-image-1-mini", name: "GPT Image 1 Mini" },
],
supportedSizes: ["1024x1024", "1024x1792", "1792x1024", "256x256", "512x512"],
supportedSizes: ["1024x1024", "1024x1792", "1792x1024"],
},
// Codex exposes image generation only as a Responses-API hosted tool under
@@ -129,11 +132,11 @@ export const IMAGE_PROVIDERS: Record<string, ImageProviderConfig> = {
authHeader: "bearer",
format: "codex-responses",
models: [
{ id: "gpt-5.5", name: "GPT 5.5 (Codex Image)" },
{ id: "gpt-5.4", name: "GPT 5.4 (Codex Image)" },
{ id: "gpt-5.3-codex", name: "GPT 5.3 Codex (Image)" },
{ id: "gpt-5.1-codex-max", name: "GPT 5.1 Codex Max (Image)" },
],
supportedSizes: ["512x512", "1024x1024", "1024x1536", "1536x1024"],
supportedSizes: ["1024x1024", "1024x1536", "1536x1024"],
},
"chatgpt-web": {
@@ -153,7 +156,7 @@ export const IMAGE_PROVIDERS: Record<string, ImageProviderConfig> = {
authType: "apikey",
authHeader: "bearer",
format: "openai",
models: [{ id: "grok-2-image-1212", name: "Grok 2 Image" }],
models: [{ id: "grok-imagine-image", name: "Grok Imagine Image" }],
supportedSizes: ["1024x1024"],
},
@@ -165,32 +168,39 @@ export const IMAGE_PROVIDERS: Record<string, ImageProviderConfig> = {
format: "openai",
models: [
{
id: "black-forest-labs/FLUX.1.1-pro",
name: "FLUX 1.1 Pro",
id: "black-forest-labs/FLUX.2-max",
name: "FLUX.2 Max",
inputModalities: ["text", "image"],
description: "Advanced contextual image editing and image-to-image generation",
},
{ id: "black-forest-labs/FLUX.1-schnell-Free", name: "FLUX 1 Schnell (Free)" },
{ id: "stabilityai/stable-diffusion-xl-base-1.0", name: "SDXL Base 1.0" },
{
id: "black-forest-labs/FLUX.1-redux",
name: "FLUX.1 Redux",
inputModalities: ["text", "image"],
description: "Generate prompt-guided variations from an input image",
},
{
id: "black-forest-labs/FLUX.1-depth",
name: "FLUX.1 Depth",
id: "black-forest-labs/FLUX.2-pro",
name: "FLUX.2 Pro",
inputModalities: ["text", "image"],
description: "Depth-conditioned image generation from an input image",
},
{
id: "black-forest-labs/FLUX.1-canny",
name: "FLUX.1 Canny",
id: "black-forest-labs/FLUX.2-flex",
name: "FLUX.2 Flex",
inputModalities: ["text", "image"],
},
{
id: "black-forest-labs/FLUX.2-dev",
name: "FLUX.2 Dev",
inputModalities: ["text", "image"],
},
{ id: "openai/gpt-image-1.5", name: "GPT Image 1.5", inputModalities: ["text", "image"] },
{ id: "Wan-AI/Wan2.6-image", name: "Wan 2.6 Image", inputModalities: ["text", "image"] },
{
id: "Qwen/Qwen-Image-2.0-Pro",
name: "Qwen Image 2.0 Pro",
inputModalities: ["text", "image"],
},
{ id: "Qwen/Qwen-Image-2.0", name: "Qwen Image 2.0", inputModalities: ["text", "image"] },
{ id: "google/flash-image-3.1", name: "NanoBanana 2", inputModalities: ["text", "image"] },
{
id: "google/gemini-3-pro-image",
name: "NanoBanana Pro",
inputModalities: ["text", "image"],
description: "Canny edge guided image generation from an input image",
},
{ id: "black-forest-labs/FLUX.1-dev-lora", name: "FLUX.1 Dev LoRA" },
],
supportedSizes: ["1024x1024", "512x512"],
},
@@ -202,6 +212,9 @@ export const IMAGE_PROVIDERS: Record<string, ImageProviderConfig> = {
authHeader: "bearer",
format: "openai",
models: [
{ id: "accounts/fireworks/flux-kontext-max", name: "FLUX Kontext Max" },
{ id: "accounts/fireworks/flux-kontext-pro", name: "FLUX Kontext Pro" },
{ id: "accounts/fireworks/flux-1-schnell-fp8", name: "FLUX.1 schnell" },
{ id: "accounts/fireworks/models/flux-1-dev-fp8", name: "FLUX 1 Dev FP8" },
{ id: "accounts/fireworks/models/stable-diffusion-xl-1024-v1-0", name: "SDXL 1024 v1.0" },
],
@@ -218,6 +231,7 @@ export const IMAGE_PROVIDERS: Record<string, ImageProviderConfig> = {
supportedSizes: ["1024x1024"],
},
//Curruntly no models serving
nebius: {
id: "nebius",
baseUrl: "https://api.tokenfactory.nebius.com/v1/images/generations",
@@ -225,11 +239,8 @@ export const IMAGE_PROVIDERS: Record<string, ImageProviderConfig> = {
authType: "apikey",
authHeader: "bearer",
format: "openai",
models: [
{ id: "black-forest-labs/flux-schnell", name: "FLUX.1 Schnell" },
{ id: "black-forest-labs/flux-dev", name: "FLUX.1 Dev" },
],
supportedSizes: ["1024x1024", "512x512"],
models: [{ id: "black-forest-labs/flux-schnell", name: "No Model yet" }],
supportedSizes: ["1024x1024"],
},
hyperbolic: {
@@ -238,13 +249,10 @@ export const IMAGE_PROVIDERS: Record<string, ImageProviderConfig> = {
authType: "apikey",
authHeader: "bearer",
format: "hyperbolic", // custom: uses model_name, returns base64 images
models: [
{ id: "SDXL1.0-base", name: "SDXL 1.0 Base" },
{ id: "SD2", name: "Stable Diffusion 2" },
{ id: "FLUX.1-dev", name: "FLUX.1 Dev" },
],
supportedSizes: ["1024x1024", "512x512"],
models: [{ id: "SDXL1.0-base", name: "No Model yet" }],
supportedSizes: ["1024x1024"],
},
//Curruntly no models serving
nanobanana: {
id: "nanobanana",
@@ -294,12 +302,15 @@ export const IMAGE_PROVIDERS: Record<string, ImageProviderConfig> = {
authHeader: "bearer",
format: "openai",
models: [
{ id: "openai/dall-e-3", name: "DALL-E 3 (via OpenRouter)" },
{ id: "openai/gpt-image-1", name: "GPT Image 1 (via OpenRouter)" },
{ id: "google/imagen-3.0-generate-002", name: "Imagen 3 (via OpenRouter)" },
{ id: "black-forest-labs/FLUX.1-schnell", name: "FLUX.1 Schnell (via OpenRouter)" },
{ id: "openai/gpt-5.4-image-2", name: "GPT Image 2 (via OpenRouter)" },
{ id: "openai/gpt-5-image-mini", name: "GPT Image 1 Mini (via OpenRouter)" },
{ id: "google/gemini-3.1-flash-image-preview", name: "Nano Banana 2 (via OpenRouter)" },
{ id: "google/gemini-3-pro-image-preview", name: "Nano Banana Pro (via OpenRouter)" },
{ id: "black-forest-labs/flux.2-max", name: "FLUX.2 Max (via OpenRouter)" },
{ id: "black-forest-labs/flux.2-pro", name: "FLUX.2 Pro (via OpenRouter)" },
{ id: "black-forest-labs/flux.2-flex", name: "FLUX.2 Flex (via OpenRouter)" },
],
supportedSizes: ["1024x1024", "1024x1792", "1792x1024", "256x256", "512x512"],
supportedSizes: ["1024x1024", "1024x1792", "1792x1024"],
},
pollinations: {
@@ -310,25 +321,14 @@ export const IMAGE_PROVIDERS: Record<string, ImageProviderConfig> = {
authHeader: "bearer",
format: "openai",
models: [
{ id: "klein", name: "FLUX.2 Klein 4B" },
{ id: "flux", name: "Flux Schnell" },
{ id: "zimage", name: "Z-Image Turbo" },
{ id: "klein", name: "FLUX.2 Klein 4B" },
{ id: "gptimage", name: "GPT Image 1 Mini" },
{ id: "qwen-image", name: "Qwen Image Plus" },
{ id: "wan-image", name: "Wan 2.7 Image" },
{
id: "flux-kontext",
name: "FLUX.1 Kontext",
inputModalities: ["text", "image"],
description: "Context-aware image editing with optional source image",
},
{
id: "flux-kontext-max",
name: "FLUX.1 Kontext Max",
inputModalities: ["text", "image"],
description: "Higher quality Kontext editing with optional source image",
},
{ id: "gpt-image-2", name: "GPT Image 2" },
{ id: "gptimage-large", name: "GPT Image 1.5" },
{ id: "gptimage", name: "GPT Image 1 Mini" },
],
supportedSizes: ["1024x1024", "512x512"],
},
@@ -340,17 +340,17 @@ export const IMAGE_PROVIDERS: Record<string, ImageProviderConfig> = {
authHeader: "key",
format: "fal-ai",
models: [
{ id: "fal-ai/flux-pro/v1.1", name: "FLUX.1 Pro v1.1" },
{ id: "fal-ai/flux-pro/v1.1-ultra", name: "FLUX.1 Pro v1.1 Ultra" },
{ id: "fal-ai/flux/schnell", name: "FLUX.1 Schnell" },
{ id: "fal-ai/flux-2-max", name: "FLUX.2 Max" },
{ id: "fal-ai/flux-2-pro", name: "FLUX.2 Pro" },
{ id: "fal-ai/flux-2-flex", name: "FLUX.2 Flex" },
{ id: "bria/text-to-image/3.2", name: "Bria 3.2" },
{ id: "fal-ai/bytedance/seedream/v3/text-to-image", name: "SeeDream V3" },
{ id: "fal-ai/bytedance/seedream/v4.5/text-to-image", name: "SeeDream V4.5" },
{ id: "fal-ai/bytedance/dreamina/v3.1/text-to-image", name: "Dreamina V3.1" },
{ id: "fal-ai/ideogram/v3", name: "Ideogram V3" },
{ id: "fal-ai/imagen4/preview", name: "Imagen 4 Preview" },
{ id: "fal-ai/imagen4/preview/fast", name: "Imagen 4 Preview Fast" },
{ id: "fal-ai/imagen4/preview/ultra", name: "Imagen 4 Preview Ultra" },
{ id: "fal-ai/recraft/v3/text-to-image", name: "Recraft V3 via Fal" },
{ id: "fal-ai/nano-banana-pro", name: "Nano Banana Pro" },
{ id: "fal-ai/nano-banana-2", name: "Nano Banana 2" },
{ id: "fal-ai/recraft/v4/pro/text-to-image", name: "Recraft V4 Pro via Fal" },
{ id: "fal-ai/recraft/v4/text-to-image", name: "Recraft V4 via Fal" },
{ id: "fal-ai/stable-diffusion-v35-medium", name: "Stable Diffusion v3.5 Medium" },
],
supportedSizes: ["1024x1024", "1024x1280", "1280x1024"],
@@ -363,29 +363,26 @@ export const IMAGE_PROVIDERS: Record<string, ImageProviderConfig> = {
authHeader: "bearer",
format: "stability-ai",
models: [
{ id: "sd3", name: "sd3" },
{ id: "sd3-large", name: "sd3-large" },
{ id: "sd3-large-turbo", name: "sd3-large-turbo" },
{ id: "sd3-medium", name: "sd3-medium" },
{ id: "sd3.5-large", name: "sd3.5-large" },
{ id: "sd3.5-large-turbo", name: "sd3.5-large-turbo" },
{ id: "sd3.5-medium", name: "sd3.5-medium" },
{ id: "stable-image-ultra", name: "Stable Image Ultra" },
{ id: "stable-image-core", name: "Stable Image Core" },
{ id: "sd3.5-large-turbo", name: "sd3.5-large-turbo" },
{ id: "sd3.5-large", name: "sd3.5-large" },
{ id: "sd3.5-medium", name: "sd3.5-medium" },
{ id: "sd3.5-flash", name: "sd3.5-flash" },
{ id: "erase", name: "Erase", inputModalities: ["image"] },
{ id: "inpaint", name: "Inpaint", inputModalities: ["text", "image"] },
{ id: "outpaint", name: "Outpaint", inputModalities: ["text", "image"] },
{ id: "erase", name: "Erase", inputModalities: ["image"] },
{ id: "remove-background", name: "Remove Background", inputModalities: ["image"] },
{ id: "search-and-replace", name: "Search and Replace", inputModalities: ["text", "image"] },
{ id: "search-and-recolor", name: "Search and Recolor", inputModalities: ["text", "image"] },
{ id: "remove-background", name: "Remove Background", inputModalities: ["image"] },
{
id: "replace-background-and-relight",
name: "Replace Background and Relight",
inputModalities: ["text", "image"],
},
{ id: "creative", name: "Creative Upscale", inputModalities: ["text", "image"] },
{ id: "fast", name: "Fast Upscale", inputModalities: ["image"] },
{ id: "conservative", name: "Conservative Upscale", inputModalities: ["image"] },
{ id: "creative", name: "Creative Upscale", inputModalities: ["text", "image"] },
{ id: "sketch", name: "Sketch Control", inputModalities: ["text", "image"] },
{ id: "structure", name: "Structure Control", inputModalities: ["text", "image"] },
{ id: "style", name: "Style Control", inputModalities: ["text", "image"] },
@@ -401,16 +398,15 @@ export const IMAGE_PROVIDERS: Record<string, ImageProviderConfig> = {
authHeader: "x-key",
format: "black-forest-labs",
models: [
{ id: "flux-kontext-pro", name: "flux-kontext-pro", inputModalities: ["text", "image"] },
{ id: "flux-kontext-max", name: "flux-kontext-max", inputModalities: ["text", "image"] },
{ id: "flux-pro-1.0-fill", name: "flux-pro-1.0-fill", inputModalities: ["text", "image"] },
{
id: "flux-pro-1.0-expand",
name: "flux-pro-1.0-expand",
inputModalities: ["text", "image"],
},
{ id: "flux-pro-1.1", name: "flux-pro-1.1" },
{ id: "flux-2-max", name: "FLUX.2 Max" },
{ id: "flux-2-pro", name: "FLUX.2 Pro" },
{ id: "flux-2-flex", name: "FLUX.2 Flex" },
{ id: "flux-pro-1.1-ultra", name: "flux-pro-1.1-ultra" },
{ id: "flux-pro-1.1", name: "flux-pro-1.1" },
{ id: "flux-2-klein-9b", name: "flux 2 Klein 9B" },
{ id: "flux-2-klein-4b", name: "flux 2 Klein 4B" },
{ id: "flux-kontext-max", name: "flux-kontext-max", inputModalities: ["text", "image"] },
{ id: "flux-kontext-pro", name: "flux-kontext-pro", inputModalities: ["text", "image"] },
{ id: "flux-dev", name: "flux-dev" },
{ id: "flux-pro", name: "flux-pro" },
],
@@ -424,8 +420,10 @@ export const IMAGE_PROVIDERS: Record<string, ImageProviderConfig> = {
authHeader: "bearer",
format: "recraft",
models: [
{ id: "recraftv2", name: "recraftv2" },
{ id: "recraftv3", name: "recraftv3" },
{ id: "recraftv4_pro", name: "Recraft V4 Pro" },
{ id: "recraftv4", name: "Recraft V4" },
{ id: "recraftv3", name: "Recraft V3" },
{ id: "recraftv2", name: "Recraft V2" },
],
supportedSizes: ["1024x1024", "1024x1280", "1280x1024"],
},

View File

@@ -482,6 +482,18 @@ export class BaseExecutor {
if (Array.isArray(tb.system)) {
const sysBlocks = tb.system as Array<Record<string, unknown>>;
// Fix #1712: Remove any existing billing headers from the client
// to prevent stacking that breaks Anthropic prompt cache prefix matching.
for (let i = sysBlocks.length - 1; i >= 0; i--) {
const block = sysBlocks[i];
if (
block &&
typeof block.text === "string" &&
block.text.startsWith("x-anthropic-billing-header:")
) {
sysBlocks.splice(i, 1);
}
}
const firstSystemCacheControl =
sysBlocks[0] &&
typeof sysBlocks[0] === "object" &&

View File

@@ -5,7 +5,10 @@ import {
setUserAgentHeader,
type ExecuteInput,
} from "./base.ts";
import { CODEX_DEFAULT_INSTRUCTIONS } from "../config/codexInstructions.ts";
import {
CODEX_CHAT_DEFAULT_INSTRUCTIONS,
CODEX_DEFAULT_INSTRUCTIONS,
} from "../config/codexInstructions.ts";
import { PROVIDERS } from "../config/constants.ts";
import { getCodexClientVersion, getCodexUserAgent } from "../config/codexClient.ts";
import { getAccessToken } from "../services/tokenRefresh.ts";
@@ -410,6 +413,23 @@ function stripStoredItemReferences(body: Record<string, unknown>): void {
}
}
// Responses-API hosted tool types that OpenAI/Codex executes server-side.
// These arrive shaped as `{ type, ...params }` with no `function` object and no `name` —
// e.g. Codex CLI injects `{ type: "image_generation", output_format: "png" }` or
// `{ type: "namespace", name: "mcp__atlassian__", tools: [...] }` for MCP tool groups.
// Keep them through `normalizeCodexTools` so upstream can execute them.
const CODEX_HOSTED_TOOL_TYPES: ReadonlySet<string> = new Set([
"image_generation",
"web_search",
"web_search_preview",
"file_search",
"computer",
"computer_use_preview",
"code_interpreter",
"mcp",
"local_shell",
]);
function normalizeCodexTools(body: Record<string, unknown>): void {
if (!Array.isArray(body.tools)) return;
@@ -420,7 +440,33 @@ function normalizeCodexTools(body: Record<string, unknown>): void {
}
const tool = toolValue as Record<string, unknown>;
if (tool.type !== "function") {
const toolType = typeof tool.type === "string" ? tool.type : "";
// Preserve namespace tools (MCP tool groups used by Codex/OpenAI Responses API).
// Codex API supports them natively; register sub-tool names for tool_choice validation.
if (toolType === "namespace") {
if (Array.isArray(tool.tools)) {
for (const st of tool.tools as unknown[]) {
if (st && typeof st === "object" && !Array.isArray(st)) {
const subTool = st as Record<string, unknown>;
const name = typeof subTool.name === "string" ? subTool.name.trim() : "";
if (name) validToolNames.add(name);
}
}
}
return true;
}
if (toolType !== "function") {
const hasFunctionObject = tool.function && typeof tool.function === "object";
const hasName = typeof tool.name === "string";
if (!toolType || hasFunctionObject || hasName) {
return false;
}
if (CODEX_HOSTED_TOOL_TYPES.has(toolType)) {
return true;
}
console.debug(`[Codex] dropping unknown hosted tool type: ${toolType}`);
return false;
}
@@ -994,9 +1040,9 @@ export class CodexExecutor extends BaseExecutor {
body.instructions = "Follow the developer instructions in the conversation.";
}
} else {
// Translated: use CODEX_DEFAULT_INSTRUCTIONS as fallback when no system
// prompt was provided by the client, BUT only if tools are requested.
// Injecting tool instructions on bare requests causes Harmony leaks (#1686).
// Translated: keep the full Codex tool instructions only for tool-capable
// requests. Bare chat requests still need a neutral instructions value
// because the Codex Responses backend rejects requests without it.
const hasTools = Array.isArray(body.tools) && body.tools.length > 0;
if (
!body.instructions ||
@@ -1005,7 +1051,7 @@ export class CodexExecutor extends BaseExecutor {
if (hasTools) {
body.instructions = CODEX_DEFAULT_INSTRUCTIONS;
} else {
delete body.instructions;
body.instructions = CODEX_CHAT_DEFAULT_INSTRUCTIONS;
}
}
}

View File

@@ -1819,6 +1819,21 @@ export async function handleChatCore({
normalizeClaudeUpstreamMessages(translatedBody, { preserveToolResultBlocks: true });
log?.debug?.("FORMAT", `claude passthrough (preserveCache=${preserveCacheControl})`);
// Fix #1719: Strip output_config.format for non-Anthropic Claude-compatible providers.
// Third-party Claude endpoints (MiniMax, DeepSeek via aggregators) reject this field
// with 400 errors since they don't support Anthropic's structured output / json_schema.
if (
provider !== "claude" &&
translatedBody.output_config &&
typeof translatedBody.output_config === "object"
) {
const oc = translatedBody.output_config as Record<string, unknown>;
delete oc.format;
if (Object.keys(oc).length === 0) {
delete translatedBody.output_config;
}
}
} else {
translatedBody = { ...body };

View File

@@ -32,24 +32,29 @@ import {
import { fetchRemoteImage } from "@/shared/network/remoteImageFetch";
const OPENAI_IMAGE_TO_IMAGE_MODELS = new Set([
"black-forest-labs/FLUX.1-redux",
"black-forest-labs/FLUX.1-depth",
"black-forest-labs/FLUX.1-canny",
"black-forest-labs/FLUX.1.1-pro",
"FLUX.1-redux",
"FLUX.1-depth",
"FLUX.1-canny",
"FLUX.1.1-pro",
"black-forest-labs/FLUX.2-max",
"black-forest-labs/FLUX.2-pro",
"black-forest-labs/FLUX.2-flex",
"black-forest-labs/FLUX.2-dev",
"openai/gpt-image-1.5",
"Wan-AI/Wan2.6-image",
"Qwen/Qwen-Image-2.0-Pro",
"Qwen/Qwen-Image-2.0",
"google/flash-image-3.1",
"google/gemini-3-pro-image",
"flux-kontext-max",
"flux-kontext",
"flux-kontext-pro",
]);
const BFL_MODEL_ENDPOINTS = {
"flux-2-max": "/v1/flux-2-max",
"flux-2-pro": "/v1/flux-2-pro",
"flux-2-flex": "/v1/flux-2-flex",
"flux-2-klein-9b": "/v1/flux-2-klein-9b",
"flux-2-klein-4b": "/v1/flux-2-klein-4b",
"flux-kontext-pro": "/v1/flux-kontext-pro",
"flux-kontext-max": "/v1/flux-kontext-max",
"flux-pro-1.0-fill": "/v1/flux-pro-1.0-fill",
"flux-pro-1.0-expand": "/v1/flux-pro-1.0-expand",
"flux-pro-1.1": "/v1/flux-pro-1.1",
"flux-pro-1.1-ultra": "/v1/flux-pro-1.1-ultra",
"flux-dev": "/v1/flux-dev",
@@ -57,22 +62,20 @@ const BFL_MODEL_ENDPOINTS = {
};
const BFL_EDIT_MODELS = new Set([
"flux-2-max",
"flux-2-pro",
"flux-2-flex",
"flux-kontext-pro",
"flux-kontext-max",
"flux-pro-1.0-fill",
"flux-pro-1.0-expand",
]);
const BFL_FAILURE_STATUSES = new Set(["Error", "Failed", "Content Moderated", "Request Moderated"]);
const STABILITY_GENERATION_ENDPOINTS = {
sd3: "/v2beta/stable-image/generate/sd3",
"sd3-large": "/v2beta/stable-image/generate/sd3",
"sd3-large-turbo": "/v2beta/stable-image/generate/sd3",
"sd3-medium": "/v2beta/stable-image/generate/sd3",
"sd3.5-large": "/v2beta/stable-image/generate/sd3",
"sd3.5-large-turbo": "/v2beta/stable-image/generate/sd3",
"sd3.5-medium": "/v2beta/stable-image/generate/sd3",
"sd3.5-flash": "/v2beta/stable-image/generate/sd3",
"stable-image-ultra": "/v2beta/stable-image/generate/ultra",
"stable-image-core": "/v2beta/stable-image/generate/core",
};
@@ -1058,7 +1061,7 @@ async function handleStabilityAIImageGeneration({
try {
if (STABILITY_GENERATION_ENDPOINTS[model]) {
if (model.startsWith("sd3") && model !== "sd3") {
if (model.startsWith("sd3.5")) {
upstreamBody.model = model;
}
@@ -1070,7 +1073,7 @@ async function handleStabilityAIImageGeneration({
upstreamBody.mode = "text-to-image";
}
if (!model.startsWith("sd3") || !imageUrl) {
if (!model.startsWith("sd3.5") || !imageUrl) {
upstreamBody.aspect_ratio = body.aspect_ratio || mapImageSize(body.size);
}

View File

@@ -1,6 +1,6 @@
{
"name": "@omniroute/open-sse",
"version": "3.7.2",
"version": "3.7.3",
"description": "Express SSE sidecar for OmniRoute — handles streaming, protocol translation, and provider orchestration",
"type": "module",
"main": "index.js",

View File

@@ -1016,7 +1016,8 @@ export function checkFallbackError(
};
}
// Generic 400 — same request will likely fail on all accounts; don't fallback.
// Generic 400 is not account-fallback-worthy. Combo routing may still try a
// different provider/model because combo fallback is target-level orchestration.
return { shouldFallback: false, cooldownMs: 0, reason: RateLimitReason.UNKNOWN };
}

View File

@@ -20,7 +20,6 @@ import { fisherYatesShuffle, getNextFromDeck } from "../../src/shared/utils/shuf
import { parseModel } from "./model.ts";
import { applyComboAgentMiddleware, injectModelTag } from "./comboAgentMiddleware.ts";
import { classifyWithConfig, DEFAULT_INTENT_CONFIG } from "./intentClassifier.ts";
import { CONTEXT_OVERFLOW_REGEX } from "./errorClassifier.ts";
import { selectProvider as selectAutoProvider } from "./autoCombo/engine.ts";
import { selectWithStrategy } from "./autoCombo/routerStrategy.ts";
import { getTaskFitness } from "./autoCombo/taskFitness.ts";
@@ -41,16 +40,6 @@ import {
getComboStepWeight,
normalizeComboStep,
} from "../../src/lib/combos/steps.ts";
function isProviderBreakerOpenResponse(
result: Response,
errorBody?: { error?: { code?: string | null } } | null
) {
return (
result.headers.get("x-omniroute-provider-breaker") === "open" ||
errorBody?.error?.code === "provider_circuit_open"
);
}
import {
getConnectionRoutingTags,
matchesRoutingTags,
@@ -60,51 +49,6 @@ import {
// Status codes that should mark round-robin target semaphores as cooling down.
const TRANSIENT_FOR_SEMAPHORE = [429, 502, 503, 504];
const COMBO_BAD_REQUEST_FALLBACK_PATTERNS = [
/\bprohibited_content\b/i,
/request blocked by .*api/i,
/provided message roles? is not valid/i,
/unsupported .*message role/i,
/no such tool available/i,
/unsupported content part type/i,
/tool(?:_call|_use)? .* not (?:available|found)/i,
/third-party apps/i,
CONTEXT_OVERFLOW_REGEX,
// Model not supported/found — permanent model-level error, try next combo target
/no provider supported/i,
/model not found/i,
/model not available/i,
/unsupported model/i,
/model.*has no provider/i,
// Function calling format error — model doesn't support this capability
/function\.?arguments.*(must be|should be|\u5fc5\u987b).*(json|JSON)/i,
/tool.*arguments.*invalid/i,
/function.*parameter.*(invalid|format)/i,
// Input length range error — model-specific context limit
/range of input length/i,
/input length should be/i,
// Transient 400 errors from upstream — should fallback to next combo target
/\u670d\u52a1\u9047\u5230\u4e86\u4e00\u70b9\u5c0f\u72b6\u51b5/i, // ModelScope/Qwen transient error
/\u62b1\u6b49.*?\u654f\u611f\u5185\u5bb9.*?\u8bf7\u68c0\u67e5/i, // ModelScope/Qwen content moderation with context
/\u5185\u5bb9.*?\u654f\u611f.*?(?:\u65e0\u6cd5|\u8fc7\u6ee4)/i, // Content sensitivity block
/\u65e0\u6cd5\u54cd\u5e94.*?\u8bf7\u6c42/i, // "unable to respond to request"
/\u7a0d\u540e\u91cd\u8bd5/i, // "retry later" in Chinese
/temporary.*error/i,
/transient.*error/i,
/service.*unavailable/i,
/please.*try.*again/i,
// Rate limit errors — some providers return 400 instead of 429
/\brate.?-?limit.?(?:exceeded|reached|hit)/i,
/too many requests/i,
/\u8bf7\u6c42\u8fc7\u4e8e\u9891\u7e41/i, // Chinese rate limit message
// Tool call function name errors — model-specific, try next combo target
/\bfunction'?s? name (?:can't|can not|is|has) (?:blank|empty|missing)/i,
/function.*name.*(?:blank|empty|missing)/i,
/tool_call.*name.*(?:blank|empty|missing)/i,
// Anthropic thinking block signature errors — stale/expired signatures cannot be retried (#1696)
/invalid.*signature.*thinking/i,
];
// Patterns that signal all accounts for a provider are rate-limited / exhausted.
// Used to detect 503 responses from handleNoCredentials so combo can fallback.
const ALL_ACCOUNTS_RATE_LIMITED_PATTERNS = [/unavailable/i, /service temporarily unavailable/i];
@@ -748,12 +692,6 @@ function extractPromptForIntent(body) {
return "";
}
export function shouldFallbackComboBadRequest(status, errorText) {
if (status !== 400 || !errorText) return false;
const message = String(errorText);
return COMBO_BAD_REQUEST_FALLBACK_PATTERNS.some((pattern) => pattern.test(message));
}
function mapIntentToTaskType(intent) {
switch (intent) {
case "code":
@@ -1574,6 +1512,7 @@ export async function handleComboChat({
if (result.ok) {
const quality = await validateResponseQuality(result, clientRequestedStream, log);
if (!quality.valid) {
const qualityFailureReason = `Upstream response failed quality validation: ${quality.reason}`;
log.warn(
"COMBO",
`Model ${modelStr} returned 200 but failed quality check: ${quality.reason}`
@@ -1586,6 +1525,10 @@ export async function handleComboChat({
target: toRecordedTarget(target),
});
recordedAttempts++;
// Fix #1707: Set terminal state so the fallback doesn't emit
// misleading ALL_ACCOUNTS_INACTIVE when the real issue is quality.
lastError = `Upstream response failed quality validation: ${quality.reason}`;
if (!lastStatus) lastStatus = 502;
if (i > 0) fallbackCount++;
break; // move to next model
}
@@ -1699,7 +1642,6 @@ export async function handleComboChat({
}
}
const providerBreakerOpen = isProviderBreakerOpenResponse(result, errorBody);
const isStreamReadinessTimeout =
result.status === 504 && isStreamReadinessTimeoutErrorBody(errorBody);
@@ -1718,15 +1660,11 @@ export async function handleComboChat({
return result;
}
if (providerBreakerOpen) {
lastError = errorText || String(result.status);
if (!lastStatus) lastStatus = result.status;
if (i > 0) fallbackCount++;
log.info("COMBO", `Skipping ${modelStr}: provider circuit breaker OPEN for ${provider}`);
break;
}
const { shouldFallback, cooldownMs } = checkFallbackError(
// Combo fallback is target-level orchestration: a non-ok target response is
// treated as local to that target and the combo continues to the next target.
// Error classification is retained only for retry/cooldown pacing; it must
// not decide whether fallback happens, including for generic 400 responses.
const { cooldownMs } = checkFallbackError(
result.status,
errorText,
0,
@@ -1735,27 +1673,6 @@ export async function handleComboChat({
result.headers,
profile
);
const comboBadRequestFallback = shouldFallbackComboBadRequest(result.status, errorText);
if (!shouldFallback && !comboBadRequestFallback) {
log.warn("COMBO", `Model ${modelStr} failed (no fallback)`, { status: result.status });
recordComboRequest(combo.name, modelStr, {
success: false,
latencyMs: Date.now() - startTime,
fallbackCount,
strategy,
target: toRecordedTarget(target),
});
recordedAttempts++;
return result;
}
if (comboBadRequestFallback) {
log.info(
"COMBO",
`Treating provider-scoped 400 from ${modelStr} as model-local failure; trying next combo target`
);
}
// Check if this is a transient error worth retrying on same model
const isTransient =
@@ -1955,6 +1872,7 @@ async function handleRoundRobinCombo({
if (result.ok) {
const quality = await validateResponseQuality(result, clientRequestedStream, log);
if (!quality.valid) {
const qualityFailureReason = `Upstream response failed quality validation: ${quality.reason}`;
log.warn(
"COMBO-RR",
`${modelStr} returned 200 but failed quality check: ${quality.reason}`
@@ -1967,6 +1885,10 @@ async function handleRoundRobinCombo({
target: toRecordedTarget(target),
});
recordedAttempts++;
// Fix #1707: Set terminal state so the fallback doesn't emit
// misleading ALL_ACCOUNTS_INACTIVE when the real issue is quality.
lastError = `Upstream response failed quality validation: ${quality.reason}`;
if (!lastStatus) lastStatus = 502;
if (offset > 0) fallbackCount++;
break; // move to next model
}
@@ -2060,20 +1982,14 @@ async function handleRoundRobinCombo({
}
}
if (isProviderBreakerOpenResponse(result, errorBody as Record<string, unknown> | null)) {
lastError = errorText || String(result.status);
if (!lastStatus) lastStatus = result.status;
if (offset > 0) fallbackCount++;
log.info(
"COMBO-RR",
`Skipping ${modelStr}: provider circuit breaker OPEN for ${provider}`
);
break;
}
const isStreamReadinessTimeout =
result.status === 504 && isStreamReadinessTimeoutErrorBody(errorBody);
const { shouldFallback, cooldownMs } = checkFallbackError(
// Round-robin uses the same target-level fallback rule as other combo
// strategies: non-ok target responses fall through to the next target.
// Classification stays here only to support cooldown/semaphore pacing,
// not to decide whether fallback is allowed.
const { cooldownMs } = checkFallbackError(
result.status,
errorText,
0,
@@ -2082,7 +1998,6 @@ async function handleRoundRobinCombo({
result.headers,
profile
);
const comboBadRequestFallback = shouldFallbackComboBadRequest(result.status, errorText);
const isAllAccountsRateLimited = isAllAccountsRateLimitedResponse(
result.status,
@@ -2097,27 +2012,9 @@ async function handleRoundRobinCombo({
}
if (isAllAccountsRateLimited) {
log.info(
"COMBO",
`All accounts rate-limited for ${modelStr}, falling back to next model`
);
} else if (!shouldFallback && !comboBadRequestFallback) {
log.warn("COMBO-RR", `${modelStr} failed (no fallback)`, { status: result.status });
recordComboRequest(combo.name, modelStr, {
success: false,
latencyMs: Date.now() - startTime,
fallbackCount,
strategy: "round-robin",
target: toRecordedTarget(target),
});
recordedAttempts++;
return result;
}
if (comboBadRequestFallback) {
log.info(
"COMBO-RR",
`Treating provider-scoped 400 from ${modelStr} as model-local failure; trying next model`
`All accounts rate-limited for ${modelStr}, falling back to next model`
);
}

6
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{
"name": "omniroute",
"version": "3.7.2",
"version": "3.7.3",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "omniroute",
"version": "3.7.2",
"version": "3.7.3",
"hasInstallScript": true,
"license": "MIT",
"workspaces": [
@@ -13808,7 +13808,7 @@
},
"open-sse": {
"name": "@omniroute/open-sse",
"version": "3.7.2"
"version": "3.7.3"
}
}
}

View File

@@ -1,6 +1,6 @@
{
"name": "omniroute",
"version": "3.7.2",
"version": "3.7.3",
"description": "Smart AI Router with auto fallback — route to FREE & cheap models, zero downtime. Works with Cursor, Cline, Claude Desktop, Codex, and any OpenAI-compatible tool.",
"type": "module",
"bin": {

View File

@@ -41,6 +41,7 @@
--color-bg-primary: #f9f9fb;
--color-bg-subtle: #f0f0f5;
--color-surface: #ffffff;
--color-card: #ffffff;
--color-sidebar: #f5f5fa;
--color-border: rgba(0, 0, 0, 0.08);
--color-text-main: #1a1a2e;
@@ -61,6 +62,7 @@
--color-bg-primary: #0b0e14;
--color-bg-subtle: #111520;
--color-surface: #161b22;
--color-card: #161b22;
--color-sidebar: #10141e;
--color-border: rgba(255, 255, 255, 0.08);
--color-text-main: #e6e6ef;
@@ -93,6 +95,7 @@
--color-bg-primary: var(--color-bg-primary);
--color-bg-subtle: var(--color-bg-subtle);
--color-surface: var(--color-surface);
--color-card: var(--color-card);
--color-sidebar: var(--color-sidebar);
--color-border: var(--color-border);
--color-text-main: var(--color-text-main);

View File

@@ -33,12 +33,33 @@ function resolveMigrationsDir(): string {
try {
return path.join(path.dirname(fileURLToPath(import.meta.url)), "migrations");
} catch {
// Fall through to a more defensive URL parse below.
// Fall through to more defensive URL parsing below.
}
// Fix #1704: On Windows with global npm installs, import.meta.url may contain
// CI build-time paths (e.g., /home/runner/work/...) that are not valid file://
// URLs on Windows. Extract the path portion directly and normalize it.
const metaUrl = import.meta.url;
if (typeof metaUrl === "string" && metaUrl.startsWith("file://")) {
return path.join(path.dirname(fileURLToPath(metaUrl)), "migrations");
try {
// Strip the file:// prefix and decode, then normalize for the platform
const rawPath = decodeURIComponent(
metaUrl.replace(/^file:\/\/\//, "/").replace(/^file:\/\//, "")
);
return path.join(path.dirname(path.resolve(rawPath)), "migrations");
} catch {
// Fall through to process.cwd fallback
}
}
// Last resort: use process.cwd to find migrations relative to the app root
const cwdFallback = path.join(process.cwd(), "src", "lib", "db", "migrations");
if (fs.existsSync(cwdFallback)) {
return cwdFallback;
}
const appFallback = path.join(process.cwd(), "app", "src", "lib", "db", "migrations");
if (fs.existsSync(appFallback)) {
return appFallback;
}
throw new Error(

View File

@@ -240,32 +240,40 @@ export async function updateProxy(id: string, payload: Partial<ProxyPayload>) {
}
export async function getProxyAssignments(filters?: { proxyId?: string; scope?: string }) {
const db = getDbInstance();
try {
const db = getDbInstance();
if (filters?.proxyId) {
return db
.prepare(
"SELECT id, proxy_id, scope, scope_id, created_at, updated_at FROM proxy_assignments WHERE proxy_id = ? ORDER BY scope, scope_id"
)
.all(filters.proxyId)
.map(mapAssignmentRow);
}
if (filters?.scope) {
return db
.prepare(
"SELECT id, proxy_id, scope, scope_id, created_at, updated_at FROM proxy_assignments WHERE scope = ? ORDER BY scope_id"
)
.all(normalizeScope(filters.scope))
.map(mapAssignmentRow);
}
if (filters?.proxyId) {
return db
.prepare(
"SELECT id, proxy_id, scope, scope_id, created_at, updated_at FROM proxy_assignments WHERE proxy_id = ? ORDER BY scope, scope_id"
"SELECT id, proxy_id, scope, scope_id, created_at, updated_at FROM proxy_assignments ORDER BY scope, scope_id"
)
.all(filters.proxyId)
.all()
.map(mapAssignmentRow);
} catch (error: unknown) {
// Fix #1706: Gracefully handle missing proxy_assignments table on fresh
// Electron installs where migration 004 hasn't run yet.
const msg = error instanceof Error ? error.message : String(error);
if (msg.includes("no such table")) return [];
throw error;
}
if (filters?.scope) {
return db
.prepare(
"SELECT id, proxy_id, scope, scope_id, created_at, updated_at FROM proxy_assignments WHERE scope = ? ORDER BY scope_id"
)
.all(normalizeScope(filters.scope))
.map(mapAssignmentRow);
}
return db
.prepare(
"SELECT id, proxy_id, scope, scope_id, created_at, updated_at FROM proxy_assignments ORDER BY scope, scope_id"
)
.all()
.map(mapAssignmentRow);
}
export async function getProxyWhereUsed(proxyId: string) {
@@ -353,41 +361,16 @@ export async function deleteProxyById(id: string, options?: { force?: boolean })
}
export async function resolveProxyForConnectionFromRegistry(connectionId: string) {
const db = getDbInstance();
try {
const db = getDbInstance();
const accountAssignment = db
.prepare(
"SELECT p.id, p.type, p.host, p.port, p.username, p.password FROM proxy_assignments a JOIN proxy_registry p ON p.id = a.proxy_id WHERE a.scope = 'account' AND a.scope_id = ? LIMIT 1"
)
.get(connectionId);
if (accountAssignment) {
const record = toRecord(accountAssignment);
return {
proxy: {
type: record.type,
host: record.host,
port: record.port,
username: record.username,
password: record.password,
},
level: "account",
levelId: connectionId,
source: "registry",
};
}
const connection = db
.prepare("SELECT provider FROM provider_connections WHERE id = ?")
.get(connectionId) as { provider?: string } | undefined;
if (connection?.provider) {
const providerAssignment = db
const accountAssignment = db
.prepare(
"SELECT p.id, p.type, p.host, p.port, p.username, p.password FROM proxy_assignments a JOIN proxy_registry p ON p.id = a.proxy_id WHERE a.scope = 'provider' AND a.scope_id = ? LIMIT 1"
"SELECT p.id, p.type, p.host, p.port, p.username, p.password FROM proxy_assignments a JOIN proxy_registry p ON p.id = a.proxy_id WHERE a.scope = 'account' AND a.scope_id = ? LIMIT 1"
)
.get(connection.provider);
if (providerAssignment) {
const record = toRecord(providerAssignment);
.get(connectionId);
if (accountAssignment) {
const record = toRecord(accountAssignment);
return {
proxy: {
type: record.type,
@@ -396,35 +379,66 @@ export async function resolveProxyForConnectionFromRegistry(connectionId: string
username: record.username,
password: record.password,
},
level: "provider",
levelId: connection.provider,
level: "account",
levelId: connectionId,
source: "registry",
};
}
}
const globalAssignment = db
.prepare(
"SELECT p.id, p.type, p.host, p.port, p.username, p.password FROM proxy_assignments a JOIN proxy_registry p ON p.id = a.proxy_id WHERE a.scope = 'global' LIMIT 1"
)
.get();
if (globalAssignment) {
const record = toRecord(globalAssignment);
return {
proxy: {
type: record.type,
host: record.host,
port: record.port,
username: record.username,
password: record.password,
},
level: "global",
levelId: null,
source: "registry",
};
}
const connection = db
.prepare("SELECT provider FROM provider_connections WHERE id = ?")
.get(connectionId) as { provider?: string } | undefined;
return null;
if (connection?.provider) {
const providerAssignment = db
.prepare(
"SELECT p.id, p.type, p.host, p.port, p.username, p.password FROM proxy_assignments a JOIN proxy_registry p ON p.id = a.proxy_id WHERE a.scope = 'provider' AND a.scope_id = ? LIMIT 1"
)
.get(connection.provider);
if (providerAssignment) {
const record = toRecord(providerAssignment);
return {
proxy: {
type: record.type,
host: record.host,
port: record.port,
username: record.username,
password: record.password,
},
level: "provider",
levelId: connection.provider,
source: "registry",
};
}
}
const globalAssignment = db
.prepare(
"SELECT p.id, p.type, p.host, p.port, p.username, p.password FROM proxy_assignments a JOIN proxy_registry p ON p.id = a.proxy_id WHERE a.scope = 'global' LIMIT 1"
)
.get();
if (globalAssignment) {
const record = toRecord(globalAssignment);
return {
proxy: {
type: record.type,
host: record.host,
port: record.port,
username: record.username,
password: record.password,
},
level: "global",
levelId: null,
source: "registry",
};
}
return null;
} catch (error: unknown) {
const msg = error instanceof Error ? error.message : String(error);
if (msg.includes("no such table")) return null;
throw error;
}
}
export async function migrateLegacyProxyConfigToRegistry(options?: { force?: boolean }) {
@@ -593,41 +607,47 @@ export async function bulkAssignProxyToScope(
* Priority: provider-level → global → null
*/
export async function resolveProxyForProvider(providerId: string) {
const db = getDbInstance();
try {
const db = getDbInstance();
// Check provider-level proxy
const providerAssignment = db
.prepare(
"SELECT p.id, p.type, p.host, p.port, p.username, p.password FROM proxy_assignments a JOIN proxy_registry p ON p.id = a.proxy_id WHERE a.scope = 'provider' AND a.scope_id = ? LIMIT 1"
)
.get(providerId);
if (providerAssignment) {
const record = toRecord(providerAssignment);
return {
type: record.type,
host: record.host,
port: record.port,
username: record.username,
password: record.password,
};
// Check provider-level proxy
const providerAssignment = db
.prepare(
"SELECT p.id, p.type, p.host, p.port, p.username, p.password FROM proxy_assignments a JOIN proxy_registry p ON p.id = a.proxy_id WHERE a.scope = 'provider' AND a.scope_id = ? LIMIT 1"
)
.get(providerId);
if (providerAssignment) {
const record = toRecord(providerAssignment);
return {
type: record.type,
host: record.host,
port: record.port,
username: record.username,
password: record.password,
};
}
// Check global proxy
const globalAssignment = db
.prepare(
"SELECT p.id, p.type, p.host, p.port, p.username, p.password FROM proxy_assignments a JOIN proxy_registry p ON p.id = a.proxy_id WHERE a.scope = 'global' LIMIT 1"
)
.get();
if (globalAssignment) {
const record = toRecord(globalAssignment);
return {
type: record.type,
host: record.host,
port: record.port,
username: record.username,
password: record.password,
};
}
return null;
} catch (error: unknown) {
const msg = error instanceof Error ? error.message : String(error);
if (msg.includes("no such table")) return null;
throw error;
}
// Check global proxy
const globalAssignment = db
.prepare(
"SELECT p.id, p.type, p.host, p.port, p.username, p.password FROM proxy_assignments a JOIN proxy_registry p ON p.id = a.proxy_id WHERE a.scope = 'global' LIMIT 1"
)
.get();
if (globalAssignment) {
const record = toRecord(globalAssignment);
return {
type: record.type,
host: record.host,
port: record.port,
username: record.username,
password: record.password,
};
}
return null;
}

View File

@@ -67,7 +67,7 @@ export default function ActiveRequestsPanel() {
}
return (
<div className="rounded-xl border border-border bg-card/70">
<div className="rounded-xl border border-border bg-surface">
<div className="flex items-center justify-between gap-4 border-b border-border px-4 py-3">
<div>
<h3 className="text-sm font-semibold uppercase tracking-wide text-text-main">
@@ -120,8 +120,8 @@ export default function ActiveRequestsPanel() {
</div>
{selectedRow && (
<div className="fixed inset-0 z-50 flex items-center justify-center bg-black/60 px-4 py-6">
<div className="flex max-h-[85vh] w-full max-w-5xl flex-col overflow-hidden rounded-2xl border border-border bg-card shadow-2xl">
<div className="fixed inset-0 z-50 flex items-center justify-center bg-black/55 px-4 py-6 backdrop-blur-sm">
<div className="flex max-h-[85vh] w-full max-w-5xl flex-col overflow-hidden rounded-2xl border border-border bg-surface shadow-2xl">
<div className="flex items-start justify-between gap-4 border-b border-border px-5 py-4">
<div>
<h4 className="text-lg font-semibold text-text-main">

View File

@@ -49,6 +49,7 @@ test("chatCore integration: compressContext called proactively when context exce
// Use the same pattern as test 3 which successfully tests compression
const body = {
model,
stream: false,
messages: [
{ role: "system", content: "You are helpful." },
{ role: "user", content: "x".repeat(50000) },
@@ -62,11 +63,12 @@ test("chatCore integration: compressContext called proactively when context exce
};
// Create provider connection
const connectionId = await providersDb.createProviderConnection({
const connection = await providersDb.createProviderConnection({
provider,
apiKey: "test-key",
isActive: true,
});
const connectionId = connection.id;
// Mock fetch to capture the request
let capturedBody: any = null;
@@ -125,6 +127,7 @@ test("chatCore integration: compressContext NOT called when context is below 85%
const smallMessage = "Hello, how are you?";
const body = {
model,
stream: false,
messages: [
{ role: "system", content: "You are helpful." },
{ role: "user", content: smallMessage },
@@ -138,11 +141,12 @@ test("chatCore integration: compressContext NOT called when context is below 85%
);
// Create provider connection
const connectionId = await providersDb.createProviderConnection({
const connection = await providersDb.createProviderConnection({
provider,
apiKey: "test-key",
isActive: true,
});
const connectionId = connection.id;
// Mock fetch to capture the request
let capturedBody: any = null;
@@ -195,6 +199,7 @@ test("chatCore integration: compression preserves message structure", async () =
const body = {
model,
stream: false,
messages: [
{ role: "system", content: "You are helpful." },
{ role: "user", content: "x".repeat(50000) },
@@ -206,11 +211,12 @@ test("chatCore integration: compression preserves message structure", async () =
};
// Create provider connection
const connectionId = await providersDb.createProviderConnection({
const connection = await providersDb.createProviderConnection({
provider,
apiKey: "test-key",
isActive: true,
});
const connectionId = connection.id;
// Mock fetch to capture the request
let capturedBody: any = null;
@@ -267,6 +273,7 @@ test("chatCore integration: compression handles tool messages", async () => {
const longToolOutput = "x".repeat(10000);
const body = {
model,
stream: false,
messages: [
{ role: "system", content: "You are helpful." },
{ role: "user", content: "Run the tool" },
@@ -277,11 +284,12 @@ test("chatCore integration: compression handles tool messages", async () => {
};
// Create provider connection
const connectionId = await providersDb.createProviderConnection({
const connection = await providersDb.createProviderConnection({
provider,
apiKey: "test-key",
isActive: true,
});
const connectionId = connection.id;
// Mock fetch to capture the request
let capturedBody: any = null;
@@ -333,11 +341,12 @@ test("chatCore integration: combo requests run proactive compression before Kiro
const provider = "kiro";
const model = "claude-sonnet-4.5";
const connectionId = await providersDb.createProviderConnection({
const connection = await providersDb.createProviderConnection({
provider,
apiKey: "test-key",
isActive: true,
});
const connectionId = connection.id;
await combosDb.createCombo({
name: "test-kiro-compression-combo",

View File

@@ -257,6 +257,27 @@ describe("API Routes — dashboard and tool consumers", () => {
assertRouteMethods("src/app/api/usage/call-logs/[id]/route.ts", ["GET"]);
});
it("keeps the active request payload modal on opaque theme surfaces", () => {
const activeRequests = readProjectFile("src/shared/components/ActiveRequestsPanel.tsx");
const globals = readProjectFile("src/app/globals.css");
assert.ok(activeRequests, "ActiveRequestsPanel should exist");
assert.ok(globals, "globals.css should exist");
assert.match(globals, /--color-card:\s+#ffffff/);
assert.match(globals, /--color-card:\s+#161b22/);
assert.match(globals, /--color-card:\s+var\(--color-card\)/);
assert.match(activeRequests, /rounded-xl border border-border bg-surface/);
assert.match(activeRequests, /backdrop-blur-sm/);
assert.match(
activeRequests,
/rounded-2xl[^"]*border border-border[^"]*bg-surface[^"]*shadow-2xl/
);
assert.doesNotMatch(activeRequests, /bg-card\/70/);
assert.doesNotMatch(activeRequests, /rounded-2xl[^"]*bg-card/);
assert.doesNotMatch(activeRequests, /shadow-\[/);
assert.doesNotMatch(activeRequests, /border-black\/10/);
});
it("keeps usage quota wired through A2A and MCP tools", () => {
const quotaSkill = readProjectFile("src/lib/a2a/skills/quotaManagement.ts");
const mcpAdvancedTools = readProjectFile("open-sse/mcp-server/tools/advancedTools.ts");

View File

@@ -620,7 +620,8 @@ test("wait-for-cooldown honors upstream Retry-After when enabled", async () => {
assert.equal(result.response.status, 200, JSON.stringify(result.json));
assert.equal(result.json.choices[0].message.content, "wait-for-cooldown via upstream hint");
assert.equal(relay.getState(TOKENS.p3).hits, 2);
const hits = relay.getState(TOKENS.p3).hits;
assert.ok(hits >= 2, `expected at least one retry after cooldown, got ${hits} hits`);
assert.ok(elapsed >= 800, `expected upstream wait >= 800ms, got ${elapsed}ms`);
});
@@ -655,7 +656,8 @@ test("connection cooldown can ignore upstream Retry-After and use the configured
assert.equal(result.response.status, 200, JSON.stringify(result.json));
assert.equal(result.json.choices[0].message.content, "ignored upstream retry hint");
assert.equal(relay.getState(TOKENS.p4).hits, 2);
const hits = relay.getState(TOKENS.p4).hits;
assert.ok(hits >= 2, `expected at least one retry after cooldown, got ${hits} hits`);
assert.ok(
elapsed < 5_000,
`expected ignored upstream hint to avoid a 30s wait, got ${elapsed}ms`

View File

@@ -274,7 +274,7 @@ test("getStaticModelsForProvider returns local image catalogs for image-only pro
assert.ok(models, "xAI should expose local image models");
assert.deepEqual(
models.map((model) => model.id),
["grok-2-image-1212"]
["grok-imagine-image"]
);
});

View File

@@ -115,7 +115,7 @@ test("getTransientBuildPaths leaves _tasks in place by default", () => {
["legacy app snapshot", "local Wine prefix"]
);
assert.equal(
paths.some((entry) => entry.sourcePath === "/repo/_tasks"),
paths.some((entry) => path.basename(entry.sourcePath) === "_tasks"),
false
);
});
@@ -124,7 +124,7 @@ test("getTransientBuildPaths only moves _tasks when explicitly enabled", () => {
const paths = getTransientBuildPaths("/repo", { OMNIROUTE_BUILD_MOVE_TASKS: "1" });
assert.equal(
paths.some((entry) => entry.sourcePath === "/repo/_tasks"),
paths.some((entry) => path.basename(entry.sourcePath) === "_tasks"),
true
);
});
@@ -170,6 +170,6 @@ test("syncStandaloneNativeAssets copies wreq-js native runtime into standalone o
assert.equal(changed, true);
assert.equal(await fs.readFile(destinationNativeFile, "utf8"), "native module bytes");
assert.match(logs[0] ?? "", /wreq-js\/rust/);
assert.match((logs[0] ?? "").replaceAll("\\", "/"), /wreq-js\/rust/);
});
});

View File

@@ -177,14 +177,13 @@ test("handleComboChat context-relay skips unavailable models and falls through t
assert.deepEqual(calls, ["openai/gpt-4o-mini"]);
});
test("handleComboChat context-relay skips targets that report an open provider circuit breaker", async () => {
test("handleComboChat context-relay treats provider circuit breaker responses as ordinary target failures", async () => {
const combo = {
name: "relay-breaker",
strategy: "context-relay",
models: ["codex/gpt-5.4", "openai/gpt-4o-mini"],
config: { maxRetries: 0 },
};
const log = createLog();
const calls = [];
const result = await handleComboChat({
@@ -200,16 +199,13 @@ test("handleComboChat context-relay skips targets that report an open provider c
return okResponse();
},
isModelAvailable: async () => true,
log,
log: createLog(),
settings: null,
allCombos: null,
});
assert.equal(result.ok, true);
assert.deepEqual(calls, ["codex/gpt-5.4", "openai/gpt-4o-mini"]);
assert.ok(
log.entries.some((entry) => String(entry.msg).includes("provider circuit breaker OPEN"))
);
});
test("handleComboChat context-relay persists a handoff when codex quota reaches the warning threshold", async () => {

View File

@@ -14,7 +14,6 @@ const {
validateComboDAG,
resolveNestedComboModels,
handleComboChat,
shouldFallbackComboBadRequest,
} = await import("../../open-sse/services/combo.ts");
const { normalizeComboStep } = await import("../../src/lib/combos/steps.ts");
const { registerStrategy } = await import("../../open-sse/services/autoCombo/routerStrategy.ts");
@@ -246,9 +245,7 @@ test("handleComboChat priority strategy defaults to first model and records succ
isModelAvailable: async () => true,
log: createLog(),
settings: null,
relayOptions: null as any,
allCombos: null,
relayOptions: null,
});
const metrics = getComboMetrics("priority-default");
@@ -324,7 +321,6 @@ test("handleComboChat priority strategy honors composite tier order before fallb
settings: null,
relayOptions: null as any,
allCombos: null,
relayOptions: null,
});
assert.equal(result.ok, true);
@@ -359,7 +355,6 @@ test("handleComboChat weighted strategy selects by weight and falls back in desc
settings: null,
relayOptions: null as any,
allCombos: null,
relayOptions: null,
});
assert.equal(result.ok, true);
@@ -395,7 +390,6 @@ test("handleComboChat weighted strategy falls back to uniform random when all we
settings: null,
relayOptions: null as any,
allCombos: null,
relayOptions: null,
});
assert.equal(result.ok, true);
@@ -429,7 +423,6 @@ test("handleComboChat random strategy uses shuffled model order", async () => {
settings: null,
relayOptions: null as any,
allCombos: null,
relayOptions: null,
});
assert.equal(calls.length, 1);
@@ -474,7 +467,6 @@ test("handleComboChat least-used strategy prefers the model with fewer recorded
settings: null,
relayOptions: null as any,
allCombos: null,
relayOptions: null,
});
assert.equal(calls[0], "model-c");
@@ -498,7 +490,6 @@ test("handleComboChat skips unavailable models and falls through to the next act
settings: null,
relayOptions: null as any,
allCombos: null,
relayOptions: null,
});
assert.equal(result.ok, true);
@@ -527,7 +518,6 @@ test("handleComboChat falls through empty successful responses and records failu
settings: null,
relayOptions: null as any,
allCombos: null,
relayOptions: null,
});
const metrics = getComboMetrics("quality-fallback");
@@ -580,7 +570,6 @@ test("handleComboChat records per-target metrics separately when the same model
settings: null,
relayOptions: null as any,
allCombos: null,
relayOptions: null,
});
const firstStep = normalizeComboStep(combo.models[0], {
@@ -619,7 +608,6 @@ test("handleComboChat preserves the first failure status but surfaces the last e
settings: null,
relayOptions: null as any,
allCombos: null,
relayOptions: null,
});
const payload = (await result.json()) as any;
@@ -650,7 +638,6 @@ test("handleComboChat round-robin rotates sequentially across requests", async (
settings: null,
relayOptions: null as any,
allCombos: null,
relayOptions: null,
});
assert.equal(result.ok, true);
@@ -710,7 +697,6 @@ test("handleComboChat round-robin starts from composite tier default ordering",
settings: null,
relayOptions: null as any,
allCombos: null,
relayOptions: null,
});
assert.equal(result.ok, true);
@@ -750,70 +736,6 @@ test("combo helpers short-circuit safely for missing combos, cycles, and excessi
);
});
test("shouldFallbackComboBadRequest only flags known provider-scoped 400 patterns", () => {
assert.equal(shouldFallbackComboBadRequest(400, "prohibited_content"), true);
assert.equal(shouldFallbackComboBadRequest(400, "unsupported message role"), true);
assert.equal(shouldFallbackComboBadRequest(400, "tool_call weather_lookup not found"), true);
assert.equal(shouldFallbackComboBadRequest(429, "prohibited_content"), false);
assert.equal(shouldFallbackComboBadRequest(400, null), false);
assert.equal(shouldFallbackComboBadRequest(400, "generic bad request"), false);
// Chinese transient errors (ModelScope/Qwen)
assert.equal(
shouldFallbackComboBadRequest(400, "[400]: 抱歉,服务遇到了一点小状况,请您稍后重试。"),
true
);
assert.equal(shouldFallbackComboBadRequest(400, "服务遇到了一点小状况"), true);
assert.equal(shouldFallbackComboBadRequest(400, "请稍后重试"), true);
// Model not supported errors
assert.equal(
shouldFallbackComboBadRequest(
400,
"Model id : XiaomiMiMo/MiMo-V2-Flash , has no provider supported"
),
true
);
assert.equal(shouldFallbackComboBadRequest(400, "no provider supported"), true);
assert.equal(shouldFallbackComboBadRequest(400, "model not found"), true);
assert.equal(shouldFallbackComboBadRequest(400, "model not available"), true);
// Function calling format errors
assert.equal(
shouldFallbackComboBadRequest(400, "function.arguments parameter must be in JSON format"),
true
);
assert.equal(
shouldFallbackComboBadRequest(
400,
'[400]: <400> InternalError.Algo.InvalidParameter: The "function.arguments" parameter of the code model must be in JSON format.'
),
true
);
assert.equal(shouldFallbackComboBadRequest(400, "tool arguments invalid format"), true);
// Input length range errors
assert.equal(
shouldFallbackComboBadRequest(400, "Range of input length should be [1, 98304]"),
true
);
assert.equal(shouldFallbackComboBadRequest(400, "input length should be"), true);
// Content moderation errors (should fallback to next model)
assert.equal(
shouldFallbackComboBadRequest(400, "抱歉,您的内容包含敏感内容,请检查后重试"),
true
);
assert.equal(shouldFallbackComboBadRequest(400, "内容存在敏感信息,无法响应"), true);
assert.equal(shouldFallbackComboBadRequest(400, "无法响应该请求"), true);
// Generic "please check" should NOT match (was too broad before)
assert.equal(shouldFallbackComboBadRequest(400, "请检查您的参数"), false);
// Anthropic thinking block signature errors (#1696)
assert.equal(
shouldFallbackComboBadRequest(
400,
"[400]: messages.31.content.0: Invalid `signature` in `thinking` block"
),
true
);
assert.equal(shouldFallbackComboBadRequest(400, "Invalid signature in thinking block"), true);
});
test("handleComboChat accepts binary and Responses-style 200 bodies but falls through malformed success payloads", async () => {
const binaryResult = await handleComboChat({
body: {},
@@ -833,7 +755,6 @@ test("handleComboChat accepts binary and Responses-style 200 bodies but falls th
settings: null,
relayOptions: null as any,
allCombos: null,
relayOptions: null,
});
assert.equal(binaryResult.ok, true);
@@ -856,7 +777,6 @@ test("handleComboChat accepts binary and Responses-style 200 bodies but falls th
settings: null,
relayOptions: null as any,
allCombos: null,
relayOptions: null,
});
assert.equal(responsesResult.ok, true);
@@ -888,7 +808,6 @@ test("handleComboChat accepts binary and Responses-style 200 bodies but falls th
settings: null,
relayOptions: null as any,
allCombos: null,
relayOptions: null,
});
assert.equal(malformedResult.ok, true);
@@ -914,7 +833,6 @@ test("handleComboChat accepts text-mode SSE payloads as valid non-streaming pass
settings: null,
relayOptions: null as any,
allCombos: null,
relayOptions: null,
});
assert.equal(result.ok, true);
@@ -952,7 +870,6 @@ test("handleComboChat falls through invalid JSON and embedded 200 error bodies b
settings: null,
relayOptions: null as any,
allCombos: null,
relayOptions: null,
});
assert.equal(result.ok, true);
@@ -988,7 +905,6 @@ test("handleComboChat returns the earliest retry-after when all priority targets
},
relayOptions: null as any,
allCombos: null,
relayOptions: null,
});
const payload = (await result.json()) as any;
@@ -1019,7 +935,6 @@ test("handleComboChat returns 404 model_not_found when a combo has no executable
},
relayOptions: null as any,
allCombos: null,
relayOptions: null,
});
const payload = (await result.json()) as any;
@@ -1052,7 +967,6 @@ test("handleComboChat round-robin returns 404 when no models are configured", as
},
relayOptions: null as any,
allCombos: null,
relayOptions: null,
});
const payload = (await result.json()) as any;
@@ -1099,7 +1013,6 @@ test("handleComboChat round-robin falls through semaphore timeouts and malformed
},
relayOptions: null as any,
allCombos: null,
relayOptions: null,
});
assert.equal(result.ok, true);
@@ -1143,7 +1056,6 @@ test("handleComboChat round-robin surfaces retry-after metadata after exhausting
},
relayOptions: null as any,
allCombos: null,
relayOptions: null,
});
const payload = (await result.json()) as any;
@@ -1153,13 +1065,47 @@ test("handleComboChat round-robin surfaces retry-after metadata after exhausting
assert.ok(Number(result.headers.get("Retry-After")) >= 1);
});
test("handleComboChat round-robin keeps generic 400 errors terminal", async () => {
test("handleComboChat falls through generic 400s when a later priority target succeeds", async () => {
const calls: any[] = [];
const result = await handleComboChat({
body: {},
combo: {
name: "rr-terminal-400",
name: "priority-generic-400-recover",
strategy: "priority",
models: ["provider-a/model-a", "provider-b/model-b"],
config: { maxRetries: 0, retryDelayMs: 1 },
},
handleSingleModel: async (_body: any, modelStr: any) => {
calls.push(modelStr);
if (modelStr === "provider-a/model-a") {
return new Response(JSON.stringify({ error: { message: "Instructions are required" } }), {
status: 400,
headers: { "content-type": "application/json" },
});
}
return okResponse({ choices: [{ message: { content: "recovered" } }] });
},
isModelAvailable: async () => true,
log: createLog(),
settings: null,
relayOptions: null as any,
allCombos: null,
});
const payload = (await result.json()) as any;
assert.equal(result.status, 200);
assert.equal(payload.choices[0].message.content, "recovered");
assert.deepEqual(calls, ["provider-a/model-a", "provider-b/model-b"]);
});
test("handleComboChat round-robin falls through generic 400s when a later model succeeds", async () => {
const calls: any[] = [];
const result = await handleComboChat({
body: {},
combo: {
name: "rr-generic-400-recover",
strategy: "round-robin",
models: ["model-a", "model-b"],
},
@@ -1185,15 +1131,13 @@ test("handleComboChat round-robin keeps generic 400 errors terminal", async () =
},
relayOptions: null as any,
allCombos: null,
relayOptions: null,
});
assert.equal(result.status, 400);
assert.deepEqual(calls, ["model-a"]);
assert.match((await result.json()).error.message, /generic bad request/);
assert.equal(result.status, 200);
assert.deepEqual(calls, ["model-a", "model-b"]);
});
test("handleComboChat round-robin falls through provider-scoped 400s and returns the final error payload when no target recovers", async () => {
test("handleComboChat round-robin falls through 400s and returns the final error payload when no target recovers", async () => {
const calls: any[] = [];
const result = await handleComboChat({
@@ -1228,7 +1172,6 @@ test("handleComboChat round-robin falls through provider-scoped 400s and returns
},
relayOptions: null as any,
allCombos: null,
relayOptions: null,
});
const payload = (await result.json()) as any;
@@ -1258,7 +1201,6 @@ test("handleComboChat strict-random uses the shared deck without repeating withi
settings: null,
relayOptions: null as any,
allCombos: null,
relayOptions: null,
});
assert.equal(result.ok, true);
@@ -1293,7 +1235,6 @@ test("handleComboChat cost-optimized orders models by the cheapest configured in
settings: null,
relayOptions: null as any,
allCombos: null,
relayOptions: null,
});
assert.equal(result.ok, true);
@@ -1371,7 +1312,6 @@ test("handleComboChat context-optimized orders models by the largest synced cont
settings: null,
relayOptions: null as any,
allCombos: null,
relayOptions: null,
});
assert.equal(result.ok, true);
@@ -1394,7 +1334,6 @@ test("handleComboChat returns a 503 when every model is unavailable before execu
settings: null,
relayOptions: null as any,
allCombos: null,
relayOptions: null,
});
const payload = (await result.json()) as any;
@@ -1402,15 +1341,15 @@ test("handleComboChat returns a 503 when every model is unavailable before execu
assert.equal(payload.error.code, "ALL_ACCOUNTS_INACTIVE");
});
test("handleComboChat falls through targets that return provider circuit breaker open responses", async () => {
test("handleComboChat treats provider circuit breaker responses as ordinary target failures", async () => {
const calls = [];
const log = createLog();
const result = await handleComboChat({
body: {},
combo: {
name: "provider-breaker-open",
strategy: "priority",
models: ["openai/model-a", "openai/model-b"],
config: { maxRetries: 0 },
},
handleSingleModel: async (_body, modelStr) => {
calls.push(modelStr);
@@ -1420,18 +1359,14 @@ test("handleComboChat falls through targets that return provider circuit breaker
return okResponse();
},
isModelAvailable: async () => true,
log,
log: createLog(),
settings: null,
relayOptions: null as any,
allCombos: null,
relayOptions: null,
});
assert.equal(result.ok, true);
assert.deepEqual(calls, ["openai/model-a", "openai/model-b"]);
assert.ok(
log.entries.some((entry) => String(entry.msg).includes("provider circuit breaker OPEN"))
);
});
test("handleComboChat auto strategy honors LKGP after filtering to tool-capable models", async () => {
@@ -1459,7 +1394,6 @@ test("handleComboChat auto strategy honors LKGP after filtering to tool-capable
settings: null,
relayOptions: null as any,
allCombos: null,
relayOptions: null,
});
assert.equal(result.ok, true);
@@ -1487,7 +1421,6 @@ test("handleComboChat standalone lkgp strategy prioritizes the last known good p
settings: null,
relayOptions: null as any,
allCombos: null,
relayOptions: null,
});
assert.equal(result.ok, true);
@@ -1513,7 +1446,6 @@ test("handleComboChat standalone lkgp strategy falls back to original order when
settings: null,
relayOptions: null as any,
allCombos: null,
relayOptions: null,
});
assert.equal(result.ok, true);
@@ -1535,7 +1467,6 @@ test("handleComboChat standalone lkgp strategy updates LKGP after a successful c
settings: null,
relayOptions: null as any,
allCombos: null,
relayOptions: null,
});
const persistedProvider = await settingsDb.getLKGP(
@@ -1581,7 +1512,6 @@ test("handleComboChat auto strategy falls back to the full pool when tool filter
},
relayOptions: null as any,
allCombos: null,
relayOptions: null,
});
assert.equal(result.ok, true);
@@ -1616,7 +1546,6 @@ test("handleComboChat auto strategy falls back to rules when a custom router str
settings: null,
relayOptions: null as any,
allCombos: null,
relayOptions: null,
});
assert.equal(result.ok, true);
@@ -1651,7 +1580,6 @@ test("handleComboChat auto strategy reads strategyName from combo.config.auto an
settings: null,
relayOptions: null as any,
allCombos: null,
relayOptions: null,
});
assert.equal(result.ok, true);
@@ -1700,7 +1628,6 @@ test("handleComboChat context cache protection pins the model and tags tool-call
settings: null,
relayOptions: null as any,
allCombos: null,
relayOptions: null,
});
const payload = (await result.json()) as any;
@@ -1732,7 +1659,6 @@ test("handleComboChat context cache protection sanitizes streamed text tags from
settings: null,
relayOptions: null as any,
allCombos: null,
relayOptions: null,
});
const text = await result.text();
@@ -1762,7 +1688,6 @@ test("handleComboChat context cache protection injects a hidden tag for tool-cal
settings: null,
relayOptions: null as any,
allCombos: null,
relayOptions: null,
});
const text = await result.text();
@@ -1786,7 +1711,6 @@ test("handleComboChat context cache protection flushes cleanly when a stream end
settings: null,
relayOptions: null as any,
allCombos: null,
relayOptions: null,
});
const text = await result.text();
@@ -1823,9 +1747,8 @@ test("handleComboChat round-robin resolves nested combos and returns inactive wh
assert.equal(payload.error.code, "ALL_ACCOUNTS_INACTIVE");
});
test("handleComboChat round-robin skips targets that return provider circuit breaker open responses", async () => {
test("handleComboChat round-robin treats provider circuit breaker responses as ordinary target failures", async () => {
const calls = [];
const log = createLog();
const result = await handleComboChat({
body: {},
combo: {
@@ -1842,18 +1765,14 @@ test("handleComboChat round-robin skips targets that return provider circuit bre
return okResponse();
},
isModelAvailable: async () => true,
log,
log: createLog(),
settings: null,
relayOptions: null as any,
allCombos: null,
relayOptions: null,
});
assert.equal(result.ok, true);
assert.deepEqual(calls, ["openai/model-a", "openai/model-b"]);
assert.ok(
log.entries.some((entry) => String(entry.msg).includes("provider circuit breaker OPEN"))
);
});
test("handleComboChat round-robin retries a transient failure on the same model before succeeding", async () => {
@@ -1879,14 +1798,13 @@ test("handleComboChat round-robin retries a transient failure on the same model
settings: null,
relayOptions: null as any,
allCombos: null,
relayOptions: null,
});
assert.equal(result.ok, true);
assert.deepEqual(calls, ["model-a", "model-a"]);
});
test("handleComboChat round-robin recovers from provider-scoped 400s when a later model succeeds", async () => {
test("handleComboChat round-robin recovers from 400s when a later model succeeds", async () => {
const calls: any[] = [];
const result = await handleComboChat({
@@ -1915,13 +1833,66 @@ test("handleComboChat round-robin recovers from provider-scoped 400s when a late
settings: null,
relayOptions: null as any,
allCombos: null,
relayOptions: null,
});
assert.equal(result.ok, true);
assert.deepEqual(calls, ["model-a", "model-b"]);
});
test("handleComboChat single-target quality failure returns explicit quality error instead of ALL_ACCOUNTS_INACTIVE", async () => {
const result = await handleComboChat({
body: {},
combo: {
name: "single-target-quality-failure",
strategy: "priority",
models: ["openai/model-a"],
config: { maxRetries: 0 },
},
handleSingleModel: async () =>
new Response('{"choices":[{"message":{"content":"unterminated"}}', {
status: 200,
headers: { "content-type": "application/json" },
}),
isModelAvailable: async () => true,
log: createLog(),
settings: null,
relayOptions: null as any,
allCombos: null,
});
const payload = (await result.json()) as any;
assert.equal(result.status, 502);
assert.match(payload.error.message, /quality validation/i);
assert.notEqual(payload.error.code, "ALL_ACCOUNTS_INACTIVE");
});
test("handleComboChat round-robin single-target quality failure returns explicit quality error instead of ALL_ACCOUNTS_INACTIVE", async () => {
const result = await handleComboChat({
body: {},
combo: {
name: "rr-single-target-quality-failure",
strategy: "round-robin",
models: ["openai/model-a"],
config: { maxRetries: 0, retryDelayMs: 1, concurrencyPerModel: 1, queueTimeoutMs: 5 },
},
handleSingleModel: async () =>
new Response('{"choices":[{"message":{"content":"unterminated"}}', {
status: 200,
headers: { "content-type": "application/json" },
}),
isModelAvailable: async () => true,
log: createLog(),
settings: null,
relayOptions: null as any,
allCombos: null,
});
const payload = (await result.json()) as any;
assert.equal(result.status, 502);
assert.match(payload.error.message, /quality validation/i);
assert.notEqual(payload.error.code, "ALL_ACCOUNTS_INACTIVE");
});
test("handleComboChat falls back to next model when first model returns all-accounts-rate-limited 503", async () => {
const calls: any[] = [];
@@ -1953,7 +1924,6 @@ test("handleComboChat falls back to next model when first model returns all-acco
settings: null,
relayOptions: null as any,
allCombos: null,
relayOptions: null,
});
const payload = (await result.json()) as any;
@@ -1994,7 +1964,6 @@ test("handleComboChat round-robin falls back when all-accounts-rate-limited 503
settings: null,
relayOptions: null as any,
allCombos: null,
relayOptions: null,
});
const payload = (await result.json()) as any;
@@ -2028,7 +1997,6 @@ test("handleComboChat aborts combo when 503 response does NOT contain the unavai
settings: null,
relayOptions: null as any,
allCombos: null,
relayOptions: null,
});
const payload = (await result.json()) as any;

View File

@@ -121,8 +121,10 @@ test("migration infrastructure avoids cwd-based repo tracing fallbacks", () => {
const runnerSource = fs.readFileSync(path.resolve("src/lib/db/migrationRunner.ts"), "utf8");
const dataPathsSource = fs.readFileSync(path.resolve("src/lib/dataPaths.ts"), "utf8");
assert.doesNotMatch(runnerSource, /process\.cwd\(\)/);
// dataPaths must never use process.cwd() — it resolves via import.meta.url
assert.doesNotMatch(dataPathsSource, /process\.cwd\(\)/);
// migrationRunner uses import.meta.url as the primary strategy (process.cwd is
// only a last-resort fallback for Windows/CI-built bundles with leaked paths)
assert.match(runnerSource, /fileURLToPath\(import\.meta\.url\)/);
});

View File

@@ -17,6 +17,7 @@ import {
setThinkingBudgetConfig,
ThinkingMode,
} from "../../open-sse/services/thinkingBudget.ts";
import { CODEX_CHAT_DEFAULT_INSTRUCTIONS } from "../../open-sse/config/codexInstructions.ts";
test.afterEach(() => {
setThinkingBudgetConfig(DEFAULT_THINKING_CONFIG);
@@ -200,6 +201,37 @@ test("CodexExecutor.transformRequest injects default instructions, clamps reason
assert.equal(result.stream_options, undefined);
});
test("CodexExecutor.transformRequest sends neutral instructions for bare chat requests", () => {
const executor = new CodexExecutor();
const body = {
model: "gpt-5.5-medium",
input: [
{
type: "message",
role: "user",
content: [
{
type: "input_text",
text: "Calculate 79530+41475, and reply with the result only.",
},
],
},
],
instructions: "",
stream: false,
};
const result = executor.transformRequest("gpt-5.5-medium", body, false, {
requestEndpointPath: "/responses",
});
assert.equal(result.instructions, CODEX_CHAT_DEFAULT_INSTRUCTIONS);
assert.equal(result.stream, true);
assert.equal(result.model, "gpt-5.5");
assert.equal(result.input.length, 1);
assert.equal(result.tools, undefined);
});
test("CodexExecutor.transformRequest preserves compact requests and native passthrough semantics", () => {
const executor = new CodexExecutor();
const body = {
@@ -353,6 +385,51 @@ test("CodexExecutor.execute falls back to HTTP when websocket transport is unava
}
});
test("CodexExecutor.transformRequest preserves namespace MCP tools and hosted tool types", () => {
// Regression: PR #1581 đã vô tình xoá nhánh `namespace` + whitelist hosted tools
// trong normalizeCodexTools, khiến MCP tool group (vd. mcp__atlassian__) bị strip
// trước khi forward lên Codex Responses API. Test này khoá lại hành vi đúng.
const executor = new CodexExecutor();
const result = executor.transformRequest(
"gpt-5.4",
{
model: "gpt-5.4",
input: [],
tools: [
{ type: "function", name: "exec_command", parameters: { type: "object" } },
{
type: "namespace",
name: "mcp__atlassian__",
description: "Tools in the mcp__atlassian__ namespace.",
tools: [
{ type: "function", name: "jira_get_issue", parameters: { type: "object" } },
{ type: "function", name: "jira_search", parameters: { type: "object" } },
],
},
{ type: "image_generation", output_format: "png" },
{ type: "web_search" },
{ type: "unknown_hosted_tool" },
],
tool_choice: { type: "function", name: "jira_get_issue" },
},
false,
{}
);
const types = (result.tools as Array<Record<string, unknown>>).map((tool) => tool.type);
assert.deepEqual(types, ["function", "namespace", "image_generation", "web_search"]);
const namespaceTool = (result.tools as Array<Record<string, unknown>>).find(
(tool) => tool.type === "namespace"
);
assert.equal((namespaceTool as { name: string }).name, "mcp__atlassian__");
assert.equal(((namespaceTool as { tools: unknown[] }).tools ?? []).length, 2);
// tool_choice trỏ vào sub-tool của namespace phải được giữ nguyên (không bị xoá
// do tên nằm trong namespace.tools[*].name đã được đăng ký vào validToolNames).
assert.deepEqual(result.tool_choice, { type: "function", name: "jira_get_issue" });
});
test("CodexExecutor maps Codex websocket error events to response.failed SSE", () => {
const raw = JSON.stringify({
type: "error",

View File

@@ -13,6 +13,7 @@ const QWEN_CONFIG_PATH = path.join(DUMMY_HOME, ".qwen", "settings.json");
const QWEN_ENV_PATH = path.join(DUMMY_HOME, ".qwen", ".env");
const OPENCODE_CONFIG_PATH = path.join(DUMMY_HOME, ".config", "opencode", "opencode.json");
const originalXDG = process.env.XDG_CONFIG_HOME;
const originalAppData = process.env.APPDATA;
const originalJwtSecret = process.env.JWT_SECRET;
async function createAuthCookie() {
@@ -51,6 +52,7 @@ test.beforeEach(async () => {
// Force XDG_CONFIG_HOME so resolveOpencodeConfigPath resolves to our dummy dir
// (CI runners often have XDG_CONFIG_HOME set, causing path mismatch)
process.env.XDG_CONFIG_HOME = path.join(DUMMY_HOME, ".config");
process.env.APPDATA = path.join(DUMMY_HOME, ".config");
process.env.API_KEY_SECRET = "test-secret";
await fs.mkdir(path.dirname(QWEN_CONFIG_PATH), { recursive: true }).catch(() => {});
});
@@ -59,6 +61,8 @@ test.afterEach(async () => {
await fs.rm(DUMMY_HOME, { recursive: true, force: true }).catch(() => {});
if (originalXDG === undefined) delete process.env.XDG_CONFIG_HOME;
else process.env.XDG_CONFIG_HOME = originalXDG;
if (originalAppData === undefined) delete process.env.APPDATA;
else process.env.APPDATA = originalAppData;
if (originalJwtSecret === undefined) delete process.env.JWT_SECRET;
else process.env.JWT_SECRET = originalJwtSecret;
});

View File

@@ -54,10 +54,10 @@ test("handleImageGeneration routes OpenAI-compatible providers and forwards imag
try {
const result = await handleImageGeneration({
body: {
model: "openai/dall-e-3",
model: "openai/gpt-image-2",
prompt: "city skyline",
n: 2,
size: "1024x1792",
size: "1024x1536",
quality: "hd",
response_format: "url",
style: "vivid",
@@ -70,10 +70,10 @@ test("handleImageGeneration routes OpenAI-compatible providers and forwards imag
assert.equal(captured.url, "https://api.openai.com/v1/images/generations");
assert.equal(captured.headers.Authorization, "Bearer image-key");
assert.deepEqual(captured.body, {
model: "dall-e-3",
model: "gpt-image-2",
prompt: "city skyline",
n: 2,
size: "1024x1792",
size: "1024x1536",
quality: "hd",
response_format: "url",
style: "vivid",
@@ -250,32 +250,32 @@ test("handleImageGeneration treats unknown provider prefixes as invalid image mo
test("image registry resolves flux aliases and exposes planned catalog aliases", () => {
assert.deepEqual(parseImageModel("flux-kontext"), {
provider: "pollinations",
model: "flux-kontext",
provider: "black-forest-labs",
model: "flux-kontext-pro",
});
assert.deepEqual(parseImageModel("pollinations/kontext"), {
provider: "pollinations",
model: "flux-kontext",
provider: "black-forest-labs",
model: "flux-kontext-pro",
});
assert.deepEqual(parseImageModel("flux-redux"), {
assert.deepEqual(parseImageModel("flux-2-dev"), {
provider: "together",
model: "black-forest-labs/FLUX.1-redux",
model: "black-forest-labs/FLUX.2-dev",
});
const modelIds = new Set(getAllImageModels().map((model) => model.id));
const fluxRedux = getAllImageModels().find((model) => model.id === "flux-redux");
const flux2Dev = getAllImageModels().find((model) => model.id === "flux-2-dev");
const fluxKontext = getAllImageModels().find((model) => model.id === "flux-kontext");
for (const alias of [
"flux-kontext",
"flux-kontext-max",
"flux-redux",
"flux-depth",
"flux-canny",
"flux-dev-lora",
"flux-2-max",
"flux-2-pro",
"flux-2-flex",
"flux-2-dev",
]) {
assert.equal(modelIds.has(alias), true, `Expected alias ${alias} in image catalog`);
}
assert.deepEqual(fluxRedux?.inputModalities, ["text", "image"]);
assert.deepEqual(flux2Dev?.inputModalities, ["text", "image"]);
assert.deepEqual(fluxKontext?.inputModalities, ["text", "image"]);
});
@@ -1130,7 +1130,7 @@ test("handleImageGeneration logs OpenAI-compatible upstream failures and transpo
try {
const failed = await handleImageGeneration({
body: {
model: "openai/dall-e-3",
model: "openai/gpt-image-2",
prompt: "broken upstream",
},
credentials: { apiKey: "image-key" },
@@ -1151,7 +1151,7 @@ test("handleImageGeneration logs OpenAI-compatible upstream failures and transpo
try {
const errored = await handleImageGeneration({
body: {
model: "openai/dall-e-3",
model: "openai/gpt-image-2",
prompt: "transport issue",
},
credentials: { apiKey: "image-key" },

View File

@@ -101,7 +101,7 @@ test("v1 image generation POST still requires prompts for text-input models", as
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
model: "openai/dall-e-3",
model: "openai/gpt-image-2",
image_url: "https://example.com/source.png",
}),
})
@@ -109,5 +109,5 @@ test("v1 image generation POST still requires prompts for text-input models", as
const body = (await response.json()) as any;
assert.equal(response.status, 400);
assert.match(body.error.message, /Prompt is required for image model: openai\/dall-e-3/);
assert.match(body.error.message, /Prompt is required for image model: openai\/gpt-image-2/);
});

View File

@@ -464,7 +464,7 @@ test("v1 models catalog includes media, moderation, rerank, video, and music mod
const byId = new Map(body.data.map((item) => [item.id, item]));
assert.equal(response.status, 200);
assert.equal((byId.get("openai/gpt-image-1") as any).type, "image");
assert.equal((byId.get("openai/gpt-image-2") as any).type, "image");
assert.equal((byId.get("openai/whisper-1") as any).type, "audio");
assert.equal((byId.get("openai/whisper-1") as any).subtype, "transcription");
assert.equal((byId.get("openai/omni-moderation-latest") as any).type, "moderation");
@@ -484,10 +484,10 @@ test("v1 models catalog exposes image model input and output modalities for adva
const byId = new Map(body.data.map((item) => [item.id, item]));
assert.equal(response.status, 200);
assert.deepEqual((byId as any).get("flux-redux")?.input_modalities, ["text", "image"]);
(assert as any).deepEqual((byId.get("flux-redux") as any).output_modalities, ["image"]);
(assert as any).equal((byId.get("flux-redux") as any).type, "image");
assert.ok((byId.get("flux-redux") as any).supported_sizes?.includes("1024x1024"));
assert.deepEqual((byId as any).get("flux-2-dev")?.input_modalities, ["text", "image"]);
(assert as any).deepEqual((byId.get("flux-2-dev") as any).output_modalities, ["image"]);
(assert as any).equal((byId.get("flux-2-dev") as any).type, "image");
assert.ok((byId.get("flux-2-dev") as any).supported_sizes?.includes("1024x1024"));
(assert as any).deepEqual((byId.get("topaz/topaz-enhance") as any).input_modalities, ["image"]);
assert.deepEqual((byId.get("topaz/topaz-enhance") as any).output_modalities, ["image"]);
});

View File

@@ -71,10 +71,10 @@ describe("OpenRouter & GitHub registry entries (#960)", () => {
assert.ok(p.models.length >= 2, `Expected ≥2 models, got ${p.models.length}`);
});
it("parses openrouter/openai/dall-e-3 correctly", () => {
const result = parseImageModel("openrouter/openai/dall-e-3");
it("parses openrouter/openai/gpt-5.4-image-2 correctly", () => {
const result = parseImageModel("openrouter/openai/gpt-5.4-image-2");
assert.equal(result.provider, "openrouter");
assert.equal(result.model, "openai/dall-e-3");
assert.equal(result.model, "openai/gpt-5.4-image-2");
});
});
});

View File

@@ -67,7 +67,7 @@ describe("transformToOmniRoute", () => {
litellm_provider: "openai",
mode: "embedding",
},
"openai/dall-e-3": {
"openai/gpt-image-2": {
input_cost_per_token: 0,
output_cost_per_token: 0,
litellm_provider: "openai",

View File

@@ -2,8 +2,7 @@ import test from "node:test";
import assert from "node:assert/strict";
const { checkFallbackError } = await import("../../open-sse/services/accountFallback.ts");
const { handleComboChat, shouldFallbackComboBadRequest } =
await import("../../open-sse/services/combo.ts");
const { handleComboChat } = await import("../../open-sse/services/combo.ts");
const { resetAllCircuitBreakers } = await import("../../src/shared/utils/circuitBreaker.ts");
test.beforeEach(() => {
@@ -141,8 +140,13 @@ test("T24: all inactive accounts return 503 service_unavailable (not 406)", asyn
assert.equal(body.error?.code, "ALL_ACCOUNTS_INACTIVE");
});
test("combo falls through provider-scoped 400s and reaches the next model", async () => {
const log = createLog();
test("combo falls through 400s and reaches the next model", async () => {
const calls = [];
const sequence = [
{ status: 429, message: "No capacity available for model gemini-3.1-pro-preview" },
{ status: 400, message: "bad request" },
{ status: 200 },
];
const result = await handleComboChat({
body: {},
@@ -154,29 +158,29 @@ test("combo falls through provider-scoped 400s and reaches the next model", asyn
{ model: "aio/gemini-3.1-pro-preview-thinking-high", weight: 0 },
{ model: "openrouter/google/gemini-3.1-pro-preview", weight: 0 },
],
config: { maxRetries: 0 },
},
handleSingleModel: async (_body, modelStr) => {
calls.push(modelStr);
const step = sequence[calls.length - 1] || { status: 200 };
if (step.status === 200) {
return new Response(JSON.stringify({ ok: true }), { status: 200 });
}
return new Response(JSON.stringify({ error: { message: step.message } }), {
status: step.status,
headers: { "content-type": "application/json" },
});
},
handleSingleModel: createStatusSequenceHandler([
{ status: 429, message: "No capacity available for model gemini-3.1-pro-preview" },
{ status: 400, message: "request blocked by Gemini API: PROHIBITED_CONTENT" },
{ status: 200 },
]),
isModelAvailable: () => true,
log,
log: createLog(),
settings: null,
allCombos: null,
});
assert.equal(result.ok, true);
const badRequestLog = log.entries.find((entry) => entry.msg.includes("provider-scoped 400"));
assert.ok(badRequestLog);
});
test("combo bad-request fallback helper keeps generic 400s terminal", () => {
assert.equal(shouldFallbackComboBadRequest(400, "request blocked by Gemini API"), true);
assert.equal(
shouldFallbackComboBadRequest(400, "One or more of the provided message roles is not valid"),
true
);
assert.equal(shouldFallbackComboBadRequest(400, "bad request"), false);
assert.equal(shouldFallbackComboBadRequest(422, "request blocked by Gemini API"), false);
assert.deepEqual(calls, [
"free/gemini-3.1-pro-preview",
"aio/gemini-3.1-pro-preview-thinking-high",
"openrouter/google/gemini-3.1-pro-preview",
]);
});