865 Commits

Author SHA1 Message Date
decolua
dd1e0f9bcc refactor(registry): B2 migrate to LiteLLM-style schema — unified models[] with kind field
- 71 registry files: flat `media.*Config.models` → `models[]` with `kind` field
- `media` wrapper removed → serviceKinds, *Config fields promoted top-level
- `type` field renamed to `kind` (llm/image/tts/stt/embedding/embedding/video/music)
- providers/index.js: PROVIDER_MEDIA now built from flat top-level media fields
- shared/constants/providers.js: buildProviderEntry reads flat top-level media fields
- route /v1/models: modelKind() uses kind||type; removed subConfig merge block
- models/info route: removed sub-config fallback lookup (all models in PROVIDER_MODELS)
- ttsProviders/index.js: synthesizeViaConfig reads tts models from PROVIDER_MODELS
- test-models route, helpers.js, validate route: kind||type compat
- Baselines: PROVIDERS 62/62 , Alias 90/90 

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-14 14:32:59 +07:00
decolua
e53ce79abb refactor(open-sse): B1 consolidate media endpoint URLs into registry
- image/embed/tts/search base URLs derive from media.*Config.baseUrl /
  searchViaChat.endpoint (single source); handlers read PROVIDER_MEDIA.
- ~18 hardcoded endpoints moved: bfl/fal/stability/runway/hf/gemini/
  cloudflare/recraft/sdwebui/comfyui/nanobanana image, voyage embed,
  gemini/openrouter tts, chatSearch endpoints.
- Byte-identical: PROVIDERS 62 + alias 90 baselines, image buildUrl outputs.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-14 13:58:12 +07:00
decolua
bb9e9aa91f refactor(open-sse): registry consolidation + DRY media/oauth/adhoc cleanup
- Single-source registry: oauth clientId/tokenUrl, usage URLs, image/embed
  configs, search defaultModel, codex fixedPort, google token url derive.
- Remove 29 unused OmniRoute providers (registry 100→71); media intact.
- De-adhoc: codex literals → registry format/oauth flags; reasoningInject,
  image/embed openrouter headers + xai bodyFields config-driven.
- Add REGISTRY_TEMPLATE.js + expand PROVIDER_DEFAULTS/schema JSDoc.
- Baselines updated; PROVIDERS 62 + alias 90 byte-for-byte, golden snapshots.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-14 13:15:48 +07:00
decolua
9105dd0e25 refactor(open-sse): #11 — dedupe client-facing SSE_HEADERS_CORS
Gom block SSE headers + CORS lặp ở streamingHandler + responsesHandler
vào sseConstants.SSE_HEADERS_CORS. Codex format-routing giữ nguyên
(logic-driven theo kim chỉ nam DATA/LOGIC docs 07).

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-13 22:06:59 +07:00
decolua
4da1d6dad4 refactor(open-sse): D1c — forceStream hardcode → PROVIDERS schema (#5)
chatCore providerRequiresStreaming: switch provider-name →
PROVIDERS[provider].forceStream. Thêm forceStream:true vào registry
openai/codex/commandcode. verify-providers allowlist added-fields
(forceStream/urlSuffix verified bằng golden + runtime test riêng).

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-13 22:05:01 +07:00
decolua
ad2a3e5de3 refactor(open-sse): D1a/D1b — URL quirks → schema urlSuffix + clean debug logs
buildUrl: switch provider-name → config-driven. ?beta=true thành
urlSuffix per registry (claude/glm/kimi/minimax/minimax-cn/kimi-coding);
gemini path dùng format==="gemini"; accountId substitution giữ generic.
Xóa console.log('[DEBUG]') trong refreshCline.
Golden url-header 142 pass (byte-for-byte URL).

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-13 22:00:57 +07:00
decolua
72ce515709 refactor(open-sse): dedupe Google OAuth client credentials (#4)
clientId/clientSecret của antigravity + gemini bị lặp 3 nơi
(registry, usage.js, src/lib/oauth). Gom vào shared.js
(ANTIGRAVITY_OAUTH_CLIENT, GOOGLE_OAUTH_CLIENT), các file spread vào.
Byte-for-byte: PROVIDERS/alias/oauth-url equal, golden 142 pass.
Thêm test guard nội dung + alias resolution.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-13 21:53:14 +07:00
decolua
d4b95380b1 refactor(open-sse): usage.js dispatcher switch → USAGE_HANDLERS registry
Gộp switch 13 nhánh getUsageForProvider thành 1 registry object
(provider → handler), mỗi handler giữ nguyên signature/args qua ctx.
Behavior giữ nguyên (ollama vẫn chỉ nhận accessToken như cũ).
Thêm tests/unit/usage-dispatch.test.js guard dispatch.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-13 21:46:13 +07:00
decolua
6ee4555821 refactor(open-sse): DRY SSE primitives into utils/sseConstants.js
Gom SSE_DONE + SSE_HEADERS + SSE_HEADERS_NO_BUFFER vào 1 file không
phụ thuộc (tránh kéo usageDb vào executor). Áp cho kiro, cursor, qoder,
github, commandcode, perplexity-web, grok-web. Byte-for-byte verified
(headers/DONE giữ nguyên; biến thể no-buffer dùng const riêng).

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-13 21:42:59 +07:00
decolua
0a8d92a6ba refactor(open-sse): #8 unify token refresh dispatch — 2 switch → 1 registry
- REFRESH_HANDLERS map (provider → handler) replaces two parallel switch blocks
- getAccessToken keeps gemini→Google + null default; refreshTokenByProvider keeps
  generic refreshAccessToken default (gemini intentionally not special-cased)
- Add token-refresh-dispatch.test.js guarding null-guards + defaults
- Existing xai/codex refresh tests still pass

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-13 21:32:52 +07:00
decolua
633b66dcb6 refactor(translator): P4 concern #5 buildUsage — apply to kiro/ollama/commandcode
- Replace 3 inline {prompt,completion,total} usage objects with buildUsage()
- Preserves ?? vs total fallback semantics (commandcode)
- Golden tests pass, identical output

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-13 21:27:22 +07:00
decolua
252bf56a9f refactor(translator): P4 concern #2 encodeDataUri — dedupe base64 data-uri building
- imageHelper.encodeDataUri(mime, base64) replaces 5 inline `data:${m};base64,${d}` templates
- Applied to gemini/claude/antigravity request + gemini response translators
- Golden tests pass, identical output

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-13 21:23:32 +07:00
decolua
4cc667253a refactor(translator): P4 concern #6 finishReasonMap — switch-by-format, default common
- concerns/finishReasonMap.js: toOpenAIFinish/fromOpenAIFinish, switch special formats, default passthrough
- Replace 3 inline switch maps (claude→oai, oai→claude, commandcode→oai)
- Golden translator tests pass, behavior identical

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-13 21:20:22 +07:00
decolua
d2b0960bf7 refactor(open-sse): P3§7 model defaults schema — centralize type/quotaFamily/strip/targetFormat
- Add providers/models/schema.js (MODEL_DEFAULTS + field resolvers)
- Accessors getModelTargetFormat/QuotaFamily/Strip use shared default resolvers
- getModelType keeps null contract unchanged; behavior verified equal
- No catalog forced into registry (models stay self-contained per docs decision)

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-13 21:13:37 +07:00
decolua
5a042840fd refactor(open-sse): P3 provider registry — split into providers/registry/{id}.js
- 100 registry files: transport + models co-located per provider (Mongoose-style)
- providers/shared.js: shared Claude headers + OS/arch helpers (deduped)
- providers/models/helpers.js: withCodexReviewModels (kept dynamic)
- providers/index.js builds PROVIDERS + PROVIDER_MODELS = old API (content byte-for-byte)
- config/providers.js + providerModels.js → barrel re-export, keep accessors + runtime helpers
- Verified: PROVIDERS/MODELS/OAuth/alias byte-for-byte, golden translator tests pass, 0 new regression

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-13 21:08:37 +07:00
decolua
7134dd71db refactor(open-sse): P2 alias single-source — derive OAuth alias→id from OAUTH_ALIASES
- Export OAUTH_ALIASES as canonical id→alias source
- model.js derives 16 OAuth alias→id pairs instead of hardcoding (mmf kept out to preserve behavior)
- Add verify-alias.mjs byte-for-byte guard (133 tokens), all equal

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-13 20:48:11 +07:00
decolua
1432ac61d7 fix(open-sse): remove dead duplicate opencode provider entry
Two `opencode` keys existed; the first (localhost:4096) was silently overridden
by the later one (opencode.ai, noAuth). Drop the dead entry. Resolved PROVIDERS
output unchanged (verified byte-for-byte).

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-13 20:41:41 +07:00
decolua
bb597cbced refactor(open-sse): source mimo-free/opencode base URL from PROVIDERS
CHAT_URL and opencode buildUrl base now read from PROVIDERS instead of repeating
the literal. Values identical; providers byte-for-byte + gate clean.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-13 20:40:43 +07:00
decolua
64182c0484 refactor(open-sse): merge beta-url case + single-source refresh URLs (D)
buildUrl: fold kimi-coding into the shared ?beta=true case. refreshCline/
refreshKimiCoding now read URL (and kimi-coding clientId) from PROVIDERS instead
of hardcoded strings. Extend verify-oauth-urls with refresh/clientId snapshot;
URLs byte-for-byte equal, golden + gate clean.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-13 20:33:38 +07:00
decolua
22f6c42738 refactor(open-sse): single-source OAuth token URLs via PROVIDERS (C2)
OAUTH_ENDPOINTS.{openai,anthropic,iflow}.token now reference PROVIDERS.*.tokenUrl
(values identical) so each backend token URL is declared once. qwen left as-is
(its appConstants/PROVIDERS values intentionally differ). Add verify-oauth-urls
script; URLs byte-for-byte equal, gate clean.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-13 20:22:36 +07:00
decolua
6597b81e5e refactor(open-sse): add reasoningDelta helper, dedup thinking deltas (B4)
Centralize the reasoning_content delta shape (optional assistant role) used by
claude/gemini/kiro/codex/commandcode response translators. Keeps the cross-format
convention consistent for future translators. Output byte-for-byte identical;
golden + gate clean. Ollama left as-is (mutates existing delta object).

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-13 18:21:46 +07:00
decolua
997860aa1f refactor(open-sse): dedup fallback tool_call id helper (B3)
Add fallbackToolCallId() and apply to kiro/ollama/openai-responses response
translators (identical id shape). Leave commandcode (different order) and
request-side gemini/antigravity (random suffix) untouched. Golden + gate clean.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-13 18:12:40 +07:00
decolua
f4c39042a0 refactor(open-sse): dedup format default in PROVIDERS via resolver (C1)
Wrap PROVIDERS in defineProviders() that appends format:"openai" when omitted,
removing 72 repeated `format:"openai"` lines. Output stays byte-for-byte
identical (verified by tests/__baseline__/verify-providers.mjs deep-equal
against snapshot). No runtime fields added; consumers unchanged.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-13 17:57:51 +07:00
decolua
3a26d5fb40 refactor(open-sse): remove dead buildProviderUrl/Headers path (A1)
These translate-path builders had no runtime consumers: the translator route
uses executor.buildUrl/buildHeaders, and the barrel re-exports were unused.
Removing them eliminates the parallel URL/header build path (single source of
truth = executors). Drop their private helpers and the now-unused clineAuth
import. Golden executor snapshots + gate: no regression.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-13 17:34:39 +07:00
decolua
cc1f4f6c53 test(open-sse): golden lock provider.js translate-path (A1-prep)
Snapshot buildProviderUrl/buildProviderHeaders/getTargetFormat for all providers
before merging the translate-path with executor URL/header builders.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-13 17:19:56 +07:00
decolua
39278e9613 refactor(open-sse): extract buildUsage helper, dedup token-details (B2)
Add helpers/usageHelper.js for conditional prompt/completion token details.
Apply to gemini/codex/claude response translators; keep each provider's token
math intact. No behavior change; golden + gate: no regression.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-13 17:18:15 +07:00
decolua
34ea763d80 refactor(open-sse): add provider/model schema skeleton (C-prep)
New unwired modules providers/schema.js + models/schema.js with PROVIDER_DEFAULTS,
ENDPOINT_DEFAULTS, resolveProvider, MODEL_DEFAULTS, resolveModel (3-tier merge).
Foundation for upcoming registry tasks; no runtime wiring yet.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-13 17:05:42 +07:00
decolua
17202f7111 refactor(open-sse): extract chunkBuilder, dedup chat.completion.chunk (B1)
Add helpers/chunkBuilder.js; apply to claude/gemini/kiro/ollama/commandcode/
openai-responses response translators. Caller supplies id/created/model so each
keeps exact id-generation + usage semantics. Extend golden response stream to
openai-responses (codex). No behavior change; gate: no regression.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-13 17:05:42 +07:00
decolua
0e34358e74 test(open-sse): extend golden response stream to kiro/ollama (T0.5)
Lock chunk/usage/tool/thinking/finish behavior for kiro + ollama before
chunkBuilder refactor. Sanitize volatile stream/tool ids.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-13 16:47:25 +07:00
decolua
b87cf0c96a refactor(open-sse): extract safeParseJSON util, dedup tryParseJSON (B5)
Consolidate two tryParseJSON variants into helpers/jsonUtil.js with explicit
fallback param. Preserve exact per-call semantics: openai-to-claude passthrough
(fallback=str), geminiHelper null. geminiHelper keeps tryParseJSON re-export.
No behavior change; gate: no regression.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-13 16:45:10 +07:00
decolua
87fe069e9e refactor(open-sse): remove reverse coupling open-sse -> src (E2)
Move clineAuth into open-sse/shared (src re-exports back). Add standalone
open-sse/shared/machineId for codex session hashing (no @/lib/dataDir).
sttCore receives sttConfig via param instead of importing AI_PROVIDERS.
No behavior change; gate: no regression (26 known-fails unchanged).

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-13 16:35:07 +07:00
decolua
8f0a9ff9d4 test(open-sse): add P0 golden tests (url/header, response stream, request body)
Lock current behavior before refactor: buildUrl/buildHeaders per default-executor
provider, translateResponse streaming (claude/gemini), translateRequest body
(openai->claude/gemini/kiro). Sanitize volatile fields (tokens, kimi device-id,
kiro conversationId, timestamps) for stable snapshots.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-13 16:22:00 +07:00
decolua
9532ec804e chore(refactor): snapshot test baseline + no-regression gate truoc refactor open-sse
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-13 16:13:40 +07:00
decolua
23da7b1fe3 Update ChangeLog 2026-06-13 15:42:40 +07:00
decolua
515e2cc430 v0.4.77 (2026-06-13)
Features
Vercel AI Gateway: support embeddings, images and credit usage (#1183)
Add MiMo Free no-auth provider (#1789)
Vertex: support ADC authorized_user credential
Cowork: re-enable Claude Cowork with preset-only stdio MCP
Codex: bulk add accounts via JSON (#1719)
Kiro: enable multi-endpoint failover for GenerateAssistantResponse (#1722)
Fixes
Security: re-auth on DB export/import + SSRF guard on web fetch
Auth: real client IP rate-limiting + remote default-password guard
Cerebras/Mistral: strip unsupported client_metadata from downstream requests (#1742)
SiliconFlow: update baseUrl .cn → .com + curate verified model list (#1760)
Gemini-to-OpenAI: route unsigned thought parts to reasoning_content (#1752)
Claude-to-OpenAI: strip Anthropic billing header from system prompt (#1765)
Anthropic-compatible: send Bearer auth for third-party gateways (#1795)
Usage-stats: avoid partial stats on initial SSE race (#1767)
Proxy: use export default in proxy.js for Next.js 16 middleware detection
Claude passthrough: add body normalization
GitHub Copilot: refresh missing/expired token on models discovery (#1727) + add mappable gpt-5-mini/gpt-5.4-nano slots for Copilot MITM (#1653)
Kiro: auto-resolve profileArn to prevent 403 on IDC login, enhance profile ARN resolution, update endpoint to runtime.us-east-1.kiro.dev (#1713)
Tunnel: detect system-installed Tailscale via dual-socket probe (#1723) + non-blocking probes to prevent UI freeze
CommandCode: force stream=true in transformRequest (#1706)
Qoder: increase timeouts for reasoning models and improve stream handling
Dashboard: show provider node name instead of connection name in topology (#1770) + show explicit kind="llm" combos on combos page (#1684)
Docs
README: add Indonesian 9Router tutorial video (#1709)
2026-06-13 15:41:13 +07:00
decolua
05e483c02e fix(provider-topology): update label assignment to include nodeName
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-13 11:43:18 +07:00
saurabh321gupta
d652300e9e fix(cerebras,mistral): strip unsupported client_metadata from downstream requests
Cerebras returns 400 (wrong_api_format) and Mistral returns 422
(extra_forbidden) when the forwarded body contains client_metadata.
Remove it for these two providers before sending downstream.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-13 11:43:12 +07:00
decolua
0c7c9de00a fix(security): re-auth on DB export/import + SSRF guard on web fetch
- /api/settings/database now requires current password (header for GET,
  body for POST) in addition to session; CLI-token requests exempt
- add verifyDashboardPassword helper reusing login bcrypt check
- profile UI prompts password via modal before export/import
- /v1/web/fetch rejects internal/private/metadata targets via assertPublicUrl

Refs GHSA-qvfm-67h2-2qfx, GHSA-qj3v-64wj-q825

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-13 11:40:35 +07:00
Phuc Le
e6bac77696 fix(siliconflow): update baseUrl .cn -> .com + curate verified model list
Switch all siliconflow endpoints from api.siliconflow.cn to .com (chat,
validate, test, models) — the .cn host rejected valid .com-issued keys.
Replace the model list with 13 strong models verified live against the API.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-13 11:37:36 +07:00
Ngô Tấn Tài
b33cbb0280 feat(vercel-ai-gateway): support embeddings, images and credit usage
Extend Vercel AI Gateway beyond chat: add OpenAI-compatible embeddings
and image generation endpoints, credit balance fetch on the usage
dashboard, retry on 429, and models catalog fetcher.

Thinking/reasoning mapping is omitted pending a project-wide refactor.

Co-authored-by: Ngô Tấn Tài <tantai@newnol.io.vn>
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-13 10:54:51 +07:00
Giang Truong Vu
d9b030011f fix(gemini-to-openai): route unsigned thought parts to reasoning_content
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-13 10:34:42 +07:00
weimaozhen
564f2ece0d fix(usage-stats): avoid partial stats on initial SSE race
Skip creating partial stats from SSE before the initial REST load
completes, keeping real-time merges limited to existing full stats.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-13 10:23:56 +07:00
Fadjrir Herlambang
b40e96d0ef feat(provider): add MiMo Free no-auth provider
Bootstrap → JWT → chat flow with auto-retry. Inject the MiMoCode
system marker required to pass the upstream 403 anti-abuse gate,
derive JWT expiry from the exp claim, and use a stable per-machine
fingerprint as the bootstrap client.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-13 10:14:21 +07:00
weimaozhen
0aaa5ab3c2 fix(claude-to-openai): strip Anthropic billing header from system prompt
Remove dynamic x-anthropic-billing-header lines from Claude system prompts
when translating to OpenAI format to keep prompt prefixes stable and improve
prompt cache hits.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-13 10:05:12 +07:00
zocomputer
bbc204b601 fix: use export default in proxy.js for Next.js 16 middleware detection
Next.js 16 requires a default export to register middleware. The named
re-export produced an empty middleware manifest, so the auth guard never
ran and the dashboard showed a white "Loading..." page.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-13 09:57:20 +07:00
Duong Thai Hoa Tong
9406bd1806 feat(vertex): support ADC authorized_user credential
Accept Google Application Default Credentials (authorized_user) in the
Vertex apiKey field as an alternative to Service Account JSON, for orgs
that block SA key creation. Refreshes a Bearer token via the existing
refreshGoogleToken flow and requires a project_id (quota_project_id or
providerSpecificData.projectId). SA JSON and raw key flows unchanged.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-13 09:55:29 +07:00
hodtien
b977bf7414 fix(anthropic-compatible): send Bearer auth for third-party gateways
Third-party Anthropic-compatible gateways that require Authorization: Bearer
(in addition to x-api-key) returned 401 missing_api_key on the forward path.
For non-official upstreams, also send Bearer <apiKey> alongside x-api-key.
Official api.anthropic.com behavior is unchanged.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-13 09:45:59 +07:00
decolua
b309261166 enhance Kiro profile ARN resolution 2026-06-13 09:28:55 +07:00
decolua
4443903900 fix: add normalization for Claude passthrough bodies 2026-06-08 15:37:01 +07:00
decolua
f8b73faf5d feat(cowork): re-enable Claude Cowork with preset-only stdio MCP
Restore Cowork feature while closing the RCE vector: drop user-defined
stdio commands so only hard-coded preset plugins (browsermcp) may spawn.
Custom MCP now accepts remote URL only. Routes stay gated to localhost.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-08 15:35:37 +07:00