455 Commits

Author SHA1 Message Date
2729408ef3 Merge branch 'master' of https://github.com/decolua/9router
Some checks failed
Deploy GitBook to 9router.github.io / build-deploy (push) Has been cancelled
# Conflicts:
#	open-sse/utils/usageTracking.js
2026-06-29 10:10:13 +07:00
Joseph Yaksich
4a54824f7f fix(param-support): handle strip rules without match/drop
Cloudflare AI rule only sets flattenContent. Treat missing match as
provider-wide and missing drop as empty list to avoid crash. Fixes #1960.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-26 17:20:09 +07:00
Sutarto Jordan Chrisfivo
639f1204d0 fix(antigravity): retry transient upstream failures
Retry short-lived 5xx/capacity errors (500/502/503/504 + message
patterns) with bounded backoff capped at 15s; honor Retry-After/reset
hints and skip when wait is too long. Keep 400 non-retryable. Enable the
retry hook for 500 alongside existing 429/503.

Deduplicate sanitized Antigravity tool names before emitting the single
functionDeclarations group to avoid upstream "Tool names must be unique"
rejections.

Add Headroom size diagnostics and phantom-savings warning when reported
token delta does not shrink the outbound payload.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-26 17:19:46 +07:00
ntdung6868
3a866fe18d fix(reasoning): preserve effort through Codex translations
Carry Claude reasoning_effort/reasoning into OpenAI Chat, map into
OpenAI Responses reasoning.effort, and keep request-level effort
(incl. xhigh) across tool-result turns instead of collapsing to high.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-26 12:06:35 +07:00
suryacagur
940a35e009 feat(blackbox): overhaul provider catalog + WebUI test support
- registry: baseUrl -> /v1/chat/completions, 10 latest models with
  upstreamModelId prefix, add thinkingConfig + serviceKinds
- capabilities: rename claude-opus-4.6 -> 4.8, bump claude-sonnet-4.6
  maxOutput 64k -> 128k
- testUtils: add blackbox case to testApiKeyConnection (GET /models)
- ollama: add minimax-m3 model

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-26 12:03:58 +07:00
Stevanus Pangau
a4f44e3e12 feat(kiro): add external_idp CLIProxyAPI import for Microsoft SSO
Import Kiro accounts authenticated via Microsoft Entra/365 SSO using
CLIProxyAPI JSON. Adds external_idp refresh path (form-encoded OAuth2,
Microsoft login host allowlist), TokenType: EXTERNAL_IDP header for
runtime and usage/quota requests, dashboard import UI, and unit tests.
Scoped to authMethod === "external_idp"; existing Kiro auth unchanged.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-26 11:42:05 +07:00
Brokenc0de
49a3ec7a72 fix(capabilities): mark Claude Opus 4.7 (dashed id) as 1M context
Registry exposes the dashed id claude-opus-4-7; matchPattern treats "."
as a literal, so it missed the dotted pattern and fell through to the
generic claude opus entry (200k / claude-budget). Add an exact entry so
it resolves to 1M context + adaptive thinking, plus a unit test covering
the dashed Opus ids.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-26 11:40:28 +07:00
Brokenc0de
ab5ec52f28 feat(providers): add Venice AI provider
OpenAI-compatible apikey provider (chat/embedding/image) with dynamic
model discovery via modelsFetcher + passthroughModels. No executor needed.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-26 11:37:44 +07:00
EdisonPVE
eb9728d084 fix(kiro): report 1M context window for claude-opus-4.8
Add 1M context capability overrides for claude-opus-4.8 and -thinking
variants, and use the resolved capability contextWindow (fallback 200k)
instead of the hardcoded 200k estimate in the Kiro executor.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-26 11:22:26 +07:00
Ankit
d4d11357ab fix(headroom): translate openai-responses input through OpenAI for compression
Codex (openai-responses) body.input holds Responses items, not OpenAI
messages. Translate input -> OpenAI -> compress -> back to input so the
Responses contract is preserved. Fixes #1998

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-26 11:12:10 +07:00
Sutarto Jordan Chrisfivo
fb543a1f39 fix(headroom): clarify token diagnostics vs provider billing
Distinguish Headroom-reported token deltas from outbound payload size,
scrub credentials in logs, and warn on phantom savings when compressed
JSON barely shrinks. Refs #1998

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-26 11:12:07 +07:00
Rex
d1e98d9a60 fix(codebuddy): only send reasoning params when client requests reasoning
Forcing reasoning_effort:"medium" + reasoning_summary:"auto" on plain
requests tripped CodeBuddy's content filter and returned an error (#2071).
Make reasoning params opt-in: only set reasoning_summary when the client
sent an explicit reasoning_effort; none/off still drops it.

Fixes #2071

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-26 10:51:16 +07:00
nguyenha935
dae69a3916 fix(gemini): support native TTS generateContent endpoint
Pass Gemini AUDIO/TTS generateContent requests through to Google's native
v1beta endpoint instead of converting to chat, with per-credential fallback
(504 timeout, 502 fetch failure). Accept client keys from Bearer,
x-goog-api-key, or ?key= while forwarding only the configured Gemini
credential upstream. Expose native v1beta model names and rewrites, and add
Gemini 3.1 Flash TTS to the catalogs.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-26 10:50:13 +07:00
caiqinzhou
1980178d02 feat(github): resolve Copilot model catalog from upstream
Fetch the live model list from the Copilot /models endpoint and surface
it through /v1/models, replacing the hardcoded github entry so newly
shipped models appear without a code change. Catalog is cached per
credential and the Copilot token is refreshed on 401/403 before retry.

Also raise the connectivity-test budget to max_tokens:16, since Claude on
Copilot emits no choices at max_tokens:1 and produced a false negative.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-26 10:38:09 +07:00
tenglong
e544bfceae fix(codex): preserve Responses text format
Add "text" to Codex Responses API allowlist so text.format.json_schema
reaches upstream for structured outputs instead of being stripped.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-26 10:37:29 +07:00
Joseph Yaksich
c842dc8f07 fix: preserve forced streaming for json clients
Keep provider-required streaming when client prefers JSON. The
Accept: application/json branch no longer flips stream back to false
for forceStream providers, fixing 400 errors on stream-only providers
(e.g. Command Code) for Hermes / Claude Code / other JSON clients.

Fixes #2031

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-26 10:37:23 +07:00
nguyenha935
ce844899ed fix(tts): resolve Gemini TTS models from catalog
Resolve Gemini TTS models from shared TTS catalog and provider registry
with a safe fallback, fixing requests resolving to models/undefined when
ttsConfig.models is empty. Add gemini-3.1-flash-tts-preview to catalogs.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-26 10:32:34 +07:00
qianze
c22f11de38 fix(stream): prevent non-JSON SSE lines and duplicate [DONE] from breaking clients
- Passthrough: skip non-JSON data lines instead of forwarding raw garbage
- Translate: stop emitting redundant [DONE] sentinel (message_stop terminates)
- Add streamDoneSent flag to prevent duplicate [DONE] across transform + flush
- Warn on unexpected upstream Content-Type for streaming responses

PR #2046 by @qianze0628

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-26 10:22:53 +07:00
Mink Nguyen
0d21668917 Fix usage logging dedupe and reduce stats churn
- batch console log buffer events and support batched SSE log messages
- debounce usage stats update/pending events to reduce UI/runtime churn
- avoid awaiting request-success bookkeeping before returning provider responses
- deduplicate identical usage writes in usageHistory/daily aggregates
- reduce default logger verbosity from DEBUG to INFO (overridable via LOG_LEVEL)

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-26 10:22:20 +07:00
decolua
ec096d2add fix(usage): stop double-counting streaming usage at source
logUsage now only logs to console; DB write removed. Streaming usage is
recorded once via saveUsageStats (onStreamComplete), eliminating duplicate
usageHistory rows that inflated dashboard totals.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-26 10:22:10 +07:00
Mink Nguyen
c4f80d30d8 fix provider thinking compatibility
- claude: handle DeepSeek thinking blocks defensively, unsigned placeholder; fix kept-vs-seen thinking detection
- gemini: clamp unsupported max/xhigh thinking levels to high
- testUtils: probe Cloud Code Assist for gemini-cli/antigravity with 401 refresh retry
- tests: add translator regression coverage

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-26 10:12:48 +07:00
decolua
d9b9a192ef Fix AG 2026-06-21 18:01:33 +07:00
decolua
d4ecad24d3 fix(antigravity): add kind:image to image models so they show in media-providers UI
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-21 17:59:51 +07:00
Nautilaceae
5306bd904e feat(antigravity): native image generation support
Add image generation for Antigravity provider via gemini-3.1-flash-image
and gemini-3-pro-image, exposed through Text to Image UI and
/v1/images/generations.

- registry: serviceKinds ['llm','image'] + image model entries
- executor: image model detection + image_gen request envelope
- chatCore: force stream=false for image models (generateContent)
- nonStreamingHandler: parse inlineData -> markdown image
- imageGenerationCore: useExecutor fast-path for executor delegation
- imageProviders/antigravity: image adapter with image input support
- usage/google: image models in quota whitelist

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-21 17:54:32 +07:00
swatker
b4d2754d32 fix: enable vision capability for MiniMax-M3
The pattern matcher marked *minimax-m3* as vision: false, causing
9Router to strip image attachments before forwarding upstream. This
broke Claude Code / Cursor / Cline vision flows when routing through
MiniMax-M3.

Scoped vision: true to *minimax-m3* only. M2.7 and the catch-all
*minimax* pattern remain vision: false: those models are text-only
(per MiniMax docs / NVIDIA NIM model card), so forcing vision there
would send images to a model that errors instead of degrading.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-21 17:50:08 +07:00
decolua
36153fedbd fix(mimo-free): add Chrome User-Agent rotation to bypass anti-abuse gate
Fixes #1933 — upstream returns 403 "Illegal access" on the chat endpoint
when requests lack a browser-like User-Agent. Mirror OmniRoute mimocode
executor: rotate across 3 Chrome UA strings on both bootstrap and chat.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-21 16:51:47 +07:00
decolua
7baf293ccb fix(cloudflare-ai): flatten content-part arrays to string to avoid oneOf 400 (#1926)
Workers AI rejects OpenAI content-part array shape; flatten text parts
to a plain string per message before sending.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-21 16:46:21 +07:00
decolua
45240c19e5 fix(translator): normalize tools to Anthropic-native shape for non-Anthropic providers
Strip `type` field and fold `function.{name,description,parameters}` into
top-level {name, description, input_schema} before forwarding to Claude-format
endpoints. MiniMax (and other Anthropic-compatible providers) reject tools
carrying a `type` field with error code 2013 ("invalid tool type").

Refs #1939

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-21 16:26:17 +07:00
Janu Yoga
8321032e36 feat(codebuddy-cn): add API key auth + credit quota tracker
Two additions on top of the merged CodeBuddy CN OAuth provider:

1. API key auth — connect with a direct API key (sent as
   Authorization: Bearer), not only via OAuth device-code flow.
   - registry: add authModes ["oauth","apikey"] + hasOAuth; combined Bearer
     auth already forwards the key, token-refresh skips key connections.
   - providers POST: accept dual-auth providers (authModes includes
     "apikey") that live under category "oauth" — previously rejected as
     "Invalid provider". Also fixes the same latent gap for xai.

2. Quota tracker — surface CodeBuddy CN credit balance on the usage
   dashboard for both OAuth and API-key connections.
   - registry: add transport.usage.url (Tencent billing endpoint) +
     features.usage/usageApikey so the connection is quota-eligible.
   - new CN-scoped handler services/usage/codebuddy-cn.js: POST the billing
     meter endpoint, unwrap data.Response.Data.Accounts[]. The payload mixes
     two credit types that must not be merged:
       * refill/base ("基础体验包") — recurring allowance; cycle resets well
         before the resource expires (CycleEndTime << DeductionEndTime).
         Reads the *Cycle* balance, resetAt = next refresh. Cadence-labelled.
       * bonus ("活动赠送包") — one-shot credits that expire at CycleEndTime.
         Reads the plain Capacity balance. Labelled "Bonus Pack N".
     One quota row per package, soonest-expiring first.
   - register handler under "codebuddy-cn" in USAGE_HANDLERS.

Frontend needs no change — USAGE_SUPPORTED_PROVIDERS/USAGE_APIKEY_PROVIDERS
and the generic parseQuotaData branch already cover this shape.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-21 16:12:20 +07:00
Janu Yoga
791705ae7a feat(codebuddy-cn): add short model prefix alias "cbcn"
codebuddy-cn shipped without a short alias, making its model prefix the
longest of any provider (codebuddy-cn/glm-5.2). Add alias + uiAlias
"cbcn" so the prefix becomes cbcn/glm-5.2, consistent with qoder (qd),
kiro (kr), codex (cx). "cbcn" = CodeBuddy CN; reserves "cbai" for a
future codebuddy-ai (intl) provider.

Backward-compatible: full id codebuddy-cn/... still resolves (resolver
matches both id and alias).

Also regenerate tests/__baseline__/alias-baseline.json: idToAlias entry
codebuddy-cn now maps to cbcn, and cbcn joins the sorted modelKeys list.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-21 16:02:38 +07:00
Sutarto Jordan Chrisfivo
ed68bcedf8 fix(codex): preserve custom tools during request normalization
Add CODEX_PASSTHROUGH_TOOL_TYPES allowlist so Responses-native freeform
tools (e.g. grammar-backed apply_patch) survive normalizeCodexTools and
reach the upstream Codex Responses API intact.

Refs #1907

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-21 16:01:45 +07:00
decolua
13abe7f7f6 Fix AG 2026-06-21 15:58:38 +07:00
decolua
401d93bd5c fix(claude haiku): update handling of unsupported adaptive thinking and output_config.effort 2026-06-20 16:29:15 +07:00
mustafabozkaya
f6c2f7cae3 fix(gemini): preserve 'pattern' in antigravity tool schema translation
Remove "pattern" from UNSUPPORTED_SCHEMA_CONSTRAINTS so glob/grep tool
schemas keep the required "pattern" property for the antigravity provider.

Fixes decolua/9router#1368

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-20 15:31:22 +07:00
warelik
86162eeb8f fix(combo/fusion): flatten Anthropic-style tool messages in panel calls
flattenToolHistory only recognized OpenAI-style tool calls. Anthropic-compatible clients (Claude Code, /v1/messages) send tool invocations and results as tool_use/tool_result blocks inside the message content array. Since panel calls strip the tools definitions (#1859), the panel expert models received structured tool history without schemas, causing them to fail or misbehave (leading to empty responses and 503 errors).

Extend flattenToolHistory to recognize and flatten tool_use and tool_result blocks in the content array into prose text, keeping panel expert execution robust and independent of the client API format.

PR decolua/9router#1910

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-20 15:19:31 +07:00
nguyenha935
8efacc1147 feat(opencode-go): align Go models with official endpoints
Update OpenCode Go model catalog to match the official Go docs.
Route Qwen 3.7 and MiniMax models through /v1/messages with
Anthropic-compatible headers instead of OpenAI-compatible chat.
Keep GLM, Kimi, DeepSeek, and MiMo on /chat/completions; use
kimi-k2.7-code because the live Go API rejects kimi-k2.7 for chat
while the docs config example uses the code model ID.

PR #1931 by nguyenha935

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-20 15:09:11 +07:00
decolua
637dd7ae66 feat(ponytail): introduce "Ponytail" feature for minimalistic code generation 2026-06-20 15:08:11 +07:00
decolua
b55cf36d2e feat(headroom): add proxy lifecycle management + dashboard UI
Build on the optional Headroom Token Saver from Carmelo Campos
(PR: feat: add optional Headroom token saver). Add managed start/stop
of the local headroom proxy from the dashboard, install detection,
status probing, and a simplified Token Saver UI.

- detect headroom CLI + python>=3.10, probe proxy /health
- spawn/stop proxy as a detached, pid-tracked process
- /api/headroom/{status,start,stop} routes, gated local-only in dashboardGuard
- one-click Start/Stop Headroom modal, no manual config needed
- claude<->openai shape conversion for /v1/compress via 9router translators

Thanks to Carmelo Campos (@carmelogunsroses) for the original Headroom integration.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-20 10:09:50 +07:00
Janu Yoga
efd20be8d8 feat(provider): add CodeBuddy CN provider (copilot.tencent.com)
Add Tencent CodeBuddy CN (codebuddy-cn) OAuth provider with full support:
OAuth login (GET poll with state query param), token refresh, 15-model
catalog, /v2 inference endpoint, forced streaming, OpenAI-style reasoning,
and per-model capabilities. Renamed from codebuddy to codebuddy-cn to allow
a future codebuddy-ai variant.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-19 15:33:26 +07:00
1cf55126f5 fix(qoder): remove orphaned code causing build failure
Removed leftover code from incomplete edit that caused syntax error.
2026-06-19 09:40:48 +07:00
ba4ee30122 fix(qoder): detect errors in SSE envelope to trigger failover
- Made wrapQoderSSE async to peek at first chunk before streaming
- Parse first SSE line to check for error envelope (statusCodeValue !== 200)
- If error detected, return error Response with proper HTTP status code
- This triggers chatCore's !providerResponse.ok check and failover logic
- Fixes issue where qoder 403 quota errors were wrapped as successful streams

Before: qoder errors appeared as stream content with finish_reason: 'stop'
After: qoder errors return proper HTTP error codes, triggering provider failover
2026-06-19 08:47:25 +07:00
bef54d5f12 fix: merge logUsage + saveUsageStats to prevent duplicate usage stats for streaming requests
- Enhanced saveUsageStats to include cache tokens (cache_read, cache_creation), reasoning tokens, and estimated flag
- Replaced logUsage calls in stream.js with saveUsageStats (2 locations)
- Removed duplicate saveUsageStats call from streamingHandler.js onStreamComplete
- Removed logUsage function and unused imports from usageTracking.js
- Each streaming request now writes exactly 1 usage record instead of 2
2026-06-19 08:43:10 +07:00
decolua
7354c5e5f4 # v0.5.3 (2026-06-18)
## Fixes
- **Kiro**: honor thinking effort budgets
- **AG/Kiro/Xiaomi**: provider fixes
- **Combo/Fusion**: flatten tool history in panel calls to prevent 503
- **LLM selector**: show custom vision models in selector and model list
- **Image**: prevent compatible nodes from shadowing provider aliases
2026-06-18 17:36:08 +07:00
EdisonPVE
2ff11246ae fix(kiro): honor thinking effort budgets
Resolve the Kiro thinking budget from client intent (OpenAI reasoning_effort,
OpenAI Responses reasoning.effort, Claude output_config.effort, and Claude
thinking.budget_tokens) by reusing the shared thinkingUnified extractThinking
parser, then inject the resolved budget into the Kiro thinking system prefix.
Explicit none/off/disabled stops the prefix injection; synthetic -thinking
aliases keep the default budget.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-18 15:14:42 +07:00
decolua
3f9382dee4 Fix AG, Kiro, Xiaomi Provider 2026-06-18 14:58:00 +07:00
WARELIK
9ab14e7714 fix(combo/fusion): flatten tool history in panel calls to prevent 503
Panel models in the fusion strategy must answer in prose. When the request
carried tools or prior tool_calls/tool messages, agentic panel models kept
emitting tool_calls instead of prose, so extractPanelText() returned empty
and the engine fell into the 503 "All fusion panel models failed" branch.

Panel fan-out now strips tools/tool_choice and flattens tool turns into
assistant prose (instead of dropping them), so panels keep the context but
cannot loop on tools. The judge still receives the unmodified history.

Co-authored-by: warelik <warelik@WARELIK-MB.local>
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-18 09:55:08 +07:00
Sutarto Jordan Chrisfivo
5e5e78d3e8 fix: show custom vision models in LLM selector and model list
Expose user-added imageToText custom models as vision-capable chat
models in the default LLM selector and /v1/models, map custom service
kinds to runtime capabilities, and keep typed filtering for
/v1/models/{kind}.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-18 09:13:27 +07:00
decolua
79df34cad7 fix: giảm spam 429 từ Claude OAuth usage endpoint
- claudeAutoPing: cache resetAt in-mem, bỏ qua poll usage cho tới gần reset
- ProviderLimits: throttle auto-refresh Claude 3 phút, nút bấm tay vẫn refresh ngay
- claude.js: 429 ở OAuth usage → cooldown 3 phút, fallback legacy (không ảnh hưởng chat)

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-17 11:42:20 +07:00
decolua
c7d07448c5 fix(image): pin DNS-resolved IP to prevent SSRF via DNS rebinding (GHSA-cmhj-wh2f-9cgx)
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-17 11:02:04 +07:00
fjia
7ae9fff663 fix(executors): strip params unsupported by provider/model
Add config-driven stripUnsupportedParams helper and use it in the default and github executors. Removes the deprecated temperature param for claude-opus-4 models (Anthropic 400) and consolidates github's scattered capability checks into one rule table.

Fixes #1748

Co-Authored-By: fjia <fjia@suntekcorps.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-17 10:34:53 +07:00