Skip to content

Never stop coding. Free MIT AI gateway: one endpoint, 375 providers (150+ free), 1,400+ models Kimi, Claude, GPT, Gemini, GLM, DeepSeek, MiniMax. Works with Claude Code, Codex, Cursor, OpenCode, Cline & Copilot. Quota-aware auto-fallback, RTK+Caveman compression saves 15-95% tokens, MCP/A2A, Desktop/PWA. Built by 900+ contributors

feat(oauth): complete Windsurf / Devin CLI OAuth + API-token flows

Zhaba133722852143d2c8e65
diff --git a/.env.example b/.env.example
index 0bd7ebd43e..bf131bd5aa 100644
--- a/.env.example
+++ b/.env.example
@@ -393,6 +393,13 @@ ANTIGRAVITY_OAUTH_CLIENT_SECRET=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
# ── GitHub Copilot ──
GITHUB_OAUTH_CLIENT_ID=Iv1.b507a08c87ecfe98
+# ── Windsurf / Devin CLI ──
+# Public Firebase Web API key used by Windsurf's Secure Token Service to refresh
+# short-lived browser-flow tokens. This is a client-side credential embedded in
+# the Windsurf app itself (not a secret). Long-lived import tokens skip this entirely.
+# Source: extracted from Devin CLI binary (devin.exe / model_configs_v2.bin).
+WINDSURF_FIREBASE_API_KEY=AIzaSyBpLTEGSt59AUPKxBb7lIWjSE2ZXQH7mgU
+
# ── GitLab Duo ──
# Register an OAuth app at: https://gitlab.com/-/profile/applications
# Set redirect URI to: http://localhost:20128/callback (or your NEXT_PUBLIC_BASE_URL + /callback)
diff --git a/docs/i18n/ar/CHANGELOG.md b/docs/i18n/ar/CHANGELOG.md
index a5a4011886..9a7df14233 100644
--- a/docs/i18n/ar/CHANGELOG.md
+++ b/docs/i18n/ar/CHANGELOG.md
@@ -15,6 +15,10 @@
### 🐛 Bug Fixes
+- **fix(providers):** strip OpenAI-specific fields in Kiro translator to prevent 400 errors (#2037)
+- **fix(ui):** resolve text contrast issues for zero-config warning banner in light mode (#2050)
+- **fix(core):** inject global system prompt correctly into downstream chat completions pipeline (#2080)
+- **fix(routing):** add missing v1beta rewrites to next.config to resolve 404 on Gemini models endpoint (#2102)
- **fix(cache):** optimize cache_control preservation logic and explicitly align tool schema with upstream Claude Code expectations
- **fix(db):** preserve legacy SQLite database path on Windows to prevent data loss (#1973)
- **fix(settings):** resolve model alias persistence double stringification preventing UI updates (#2018)
diff --git a/docs/i18n/bg/CHANGELOG.md b/docs/i18n/bg/CHANGELOG.md
index 733161f130..630cc13c7f 100644
--- a/docs/i18n/bg/CHANGELOG.md
+++ b/docs/i18n/bg/CHANGELOG.md
@@ -15,6 +15,10 @@
### 🐛 Bug Fixes
+- **fix(providers):** strip OpenAI-specific fields in Kiro translator to prevent 400 errors (#2037)
+- **fix(ui):** resolve text contrast issues for zero-config warning banner in light mode (#2050)
+- **fix(core):** inject global system prompt correctly into downstream chat completions pipeline (#2080)
+- **fix(routing):** add missing v1beta rewrites to next.config to resolve 404 on Gemini models endpoint (#2102)
- **fix(cache):** optimize cache_control preservation logic and explicitly align tool schema with upstream Claude Code expectations
- **fix(db):** preserve legacy SQLite database path on Windows to prevent data loss (#1973)
- **fix(settings):** resolve model alias persistence double stringification preventing UI updates (#2018)
diff --git a/docs/i18n/bn/CHANGELOG.md b/docs/i18n/bn/CHANGELOG.md
index dabaada362..051f3ee785 100644
--- a/docs/i18n/bn/CHANGELOG.md
+++ b/docs/i18n/bn/CHANGELOG.md
@@ -15,6 +15,10 @@
### 🐛 Bug Fixes
+- **fix(providers):** strip OpenAI-specific fields in Kiro translator to prevent 400 errors (#2037)
+- **fix(ui):** resolve text contrast issues for zero-config warning banner in light mode (#2050)
+- **fix(core):** inject global system prompt correctly into downstream chat completions pipeline (#2080)
+- **fix(routing):** add missing v1beta rewrites to next.config to resolve 404 on Gemini models endpoint (#2102)
- **fix(cache):** optimize cache_control preservation logic and explicitly align tool schema with upstream Claude Code expectations
- **fix(db):** preserve legacy SQLite database path on Windows to prevent data loss (#1973)
- **fix(settings):** resolve model alias persistence double stringification preventing UI updates (#2018)
diff --git a/docs/i18n/cs/CHANGELOG.md b/docs/i18n/cs/CHANGELOG.md
index 4c54214645..38e84272c2 100644
--- a/docs/i18n/cs/CHANGELOG.md
+++ b/docs/i18n/cs/CHANGELOG.md
@@ -15,6 +15,10 @@
### 🐛 Bug Fixes
+- **fix(providers):** strip OpenAI-specific fields in Kiro translator to prevent 400 errors (#2037)
+- **fix(ui):** resolve text contrast issues for zero-config warning banner in light mode (#2050)
+- **fix(core):** inject global system prompt correctly into downstream chat completions pipeline (#2080)
+- **fix(routing):** add missing v1beta rewrites to next.config to resolve 404 on Gemini models endpoint (#2102)
- **fix(cache):** optimize cache_control preservation logic and explicitly align tool schema with upstream Claude Code expectations
- **fix(db):** preserve legacy SQLite database path on Windows to prevent data loss (#1973)
- **fix(settings):** resolve model alias persistence double stringification preventing UI updates (#2018)
diff --git a/docs/i18n/da/CHANGELOG.md b/docs/i18n/da/CHANGELOG.md
index 1ee699b1e4..76e4a61351 100644
--- a/docs/i18n/da/CHANGELOG.md
+++ b/docs/i18n/da/CHANGELOG.md
@@ -15,6 +15,10 @@
### 🐛 Bug Fixes
+- **fix(providers):** strip OpenAI-specific fields in Kiro translator to prevent 400 errors (#2037)
+- **fix(ui):** resolve text contrast issues for zero-config warning banner in light mode (#2050)
+- **fix(core):** inject global system prompt correctly into downstream chat completions pipeline (#2080)
+- **fix(routing):** add missing v1beta rewrites to next.config to resolve 404 on Gemini models endpoint (#2102)
- **fix(cache):** optimize cache_control preservation logic and explicitly align tool schema with upstream Claude Code expectations
- **fix(db):** preserve legacy SQLite database path on Windows to prevent data loss (#1973)
- **fix(settings):** resolve model alias persistence double stringification preventing UI updates (#2018)
diff --git a/docs/i18n/de/CHANGELOG.md b/docs/i18n/de/CHANGELOG.md
index ae57bf3ab3..94fecc24de 100644
--- a/docs/i18n/de/CHANGELOG.md
+++ b/docs/i18n/de/CHANGELOG.md
@@ -15,6 +15,10 @@
### 🐛 Bug Fixes
+- **fix(providers):** strip OpenAI-specific fields in Kiro translator to prevent 400 errors (#2037)
+- **fix(ui):** resolve text contrast issues for zero-config warning banner in light mode (#2050)
+- **fix(core):** inject global system prompt correctly into downstream chat completions pipeline (#2080)
+- **fix(routing):** add missing v1beta rewrites to next.config to resolve 404 on Gemini models endpoint (#2102)
- **fix(cache):** optimize cache_control preservation logic and explicitly align tool schema with upstream Claude Code expectations
- **fix(db):** preserve legacy SQLite database path on Windows to prevent data loss (#1973)
- **fix(settings):** resolve model alias persistence double stringification preventing UI updates (#2018)
diff --git a/docs/i18n/es/CHANGELOG.md b/docs/i18n/es/CHANGELOG.md
index 584b0b0711..72aafd4da6 100644
--- a/docs/i18n/es/CHANGELOG.md
+++ b/docs/i18n/es/CHANGELOG.md
@@ -15,6 +15,10 @@
### 🐛 Bug Fixes
+- **fix(providers):** strip OpenAI-specific fields in Kiro translator to prevent 400 errors (#2037)
+- **fix(ui):** resolve text contrast issues for zero-config warning banner in light mode (#2050)
+- **fix(core):** inject global system prompt correctly into downstream chat completions pipeline (#2080)
+- **fix(routing):** add missing v1beta rewrites to next.config to resolve 404 on Gemini models endpoint (#2102)
- **fix(cache):** optimize cache_control preservation logic and explicitly align tool schema with upstream Claude Code expectations
- **fix(db):** preserve legacy SQLite database path on Windows to prevent data loss (#1973)
- **fix(settings):** resolve model alias persistence double stringification preventing UI updates (#2018)
diff --git a/docs/i18n/fa/CHANGELOG.md b/docs/i18n/fa/CHANGELOG.md
index 057c405923..36e8579754 100644
--- a/docs/i18n/fa/CHANGELOG.md
+++ b/docs/i18n/fa/CHANGELOG.md
@@ -15,6 +15,10 @@
### 🐛 Bug Fixes
+- **fix(providers):** strip OpenAI-specific fields in Kiro translator to prevent 400 errors (#2037)
+- **fix(ui):** resolve text contrast issues for zero-config warning banner in light mode (#2050)
+- **fix(core):** inject global system prompt correctly into downstream chat completions pipeline (#2080)
+- **fix(routing):** add missing v1beta rewrites to next.config to resolve 404 on Gemini models endpoint (#2102)
- **fix(cache):** optimize cache_control preservation logic and explicitly align tool schema with upstream Claude Code expectations
- **fix(db):** preserve legacy SQLite database path on Windows to prevent data loss (#1973)
- **fix(settings):** resolve model alias persistence double stringification preventing UI updates (#2018)
diff --git a/docs/i18n/fi/CHANGELOG.md b/docs/i18n/fi/CHANGELOG.md
index d7fe8b9116..48813e0009 100644
--- a/docs/i18n/fi/CHANGELOG.md
+++ b/docs/i18n/fi/CHANGELOG.md
@@ -15,6 +15,10 @@
### 🐛 Bug Fixes
+- **fix(providers):** strip OpenAI-specific fields in Kiro translator to prevent 400 errors (#2037)
+- **fix(ui):** resolve text contrast issues for zero-config warning banner in light mode (#2050)
+- **fix(core):** inject global system prompt correctly into downstream chat completions pipeline (#2080)
+- **fix(routing):** add missing v1beta rewrites to next.config to resolve 404 on Gemini models endpoint (#2102)
- **fix(cache):** optimize cache_control preservation logic and explicitly align tool schema with upstream Claude Code expectations
- **fix(db):** preserve legacy SQLite database path on Windows to prevent data loss (#1973)
- **fix(settings):** resolve model alias persistence double stringification preventing UI updates (#2018)
diff --git a/docs/i18n/fr/CHANGELOG.md b/docs/i18n/fr/CHANGELOG.md
index 97d2de860a..9f744df3e2 100644
--- a/docs/i18n/fr/CHANGELOG.md
+++ b/docs/i18n/fr/CHANGELOG.md
@@ -15,6 +15,10 @@
### 🐛 Bug Fixes
+- **fix(providers):** strip OpenAI-specific fields in Kiro translator to prevent 400 errors (#2037)
+- **fix(ui):** resolve text contrast issues for zero-config warning banner in light mode (#2050)
+- **fix(core):** inject global system prompt correctly into downstream chat completions pipeline (#2080)
+- **fix(routing):** add missing v1beta rewrites to next.config to resolve 404 on Gemini models endpoint (#2102)
- **fix(cache):** optimize cache_control preservation logic and explicitly align tool schema with upstream Claude Code expectations
- **fix(db):** preserve legacy SQLite database path on Windows to prevent data loss (#1973)
- **fix(settings):** resolve model alias persistence double stringification preventing UI updates (#2018)
diff --git a/docs/i18n/gu/CHANGELOG.md b/docs/i18n/gu/CHANGELOG.md
index 8c33126af4..8c01c7410c 100644
--- a/docs/i18n/gu/CHANGELOG.md
+++ b/docs/i18n/gu/CHANGELOG.md
@@ -15,6 +15,10 @@
### 🐛 Bug Fixes
+- **fix(providers):** strip OpenAI-specific fields in Kiro translator to prevent 400 errors (#2037)
+- **fix(ui):** resolve text contrast issues for zero-config warning banner in light mode (#2050)
+- **fix(core):** inject global system prompt correctly into downstream chat completions pipeline (#2080)
+- **fix(routing):** add missing v1beta rewrites to next.config to resolve 404 on Gemini models endpoint (#2102)
- **fix(cache):** optimize cache_control preservation logic and explicitly align tool schema with upstream Claude Code expectations
- **fix(db):** preserve legacy SQLite database path on Windows to prevent data loss (#1973)
- **fix(settings):** resolve model alias persistence double stringification preventing UI updates (#2018)
diff --git a/docs/i18n/he/CHANGELOG.md b/docs/i18n/he/CHANGELOG.md
index 06e11b13ba..6f6d513c04 100644
--- a/docs/i18n/he/CHANGELOG.md
+++ b/docs/i18n/he/CHANGELOG.md
@@ -15,6 +15,10 @@
### 🐛 Bug Fixes
+- **fix(providers):** strip OpenAI-specific fields in Kiro translator to prevent 400 errors (#2037)
+- **fix(ui):** resolve text contrast issues for zero-config warning banner in light mode (#2050)
+- **fix(core):** inject global system prompt correctly into downstream chat completions pipeline (#2080)
+- **fix(routing):** add missing v1beta rewrites to next.config to resolve 404 on Gemini models endpoint (#2102)
- **fix(cache):** optimize cache_control preservation logic and explicitly align tool schema with upstream Claude Code expectations
- **fix(db):** preserve legacy SQLite database path on Windows to prevent data loss (#1973)
- **fix(settings):** resolve model alias persistence double stringification preventing UI updates (#2018)
diff --git a/docs/i18n/hi/CHANGELOG.md b/docs/i18n/hi/CHANGELOG.md
index 89c19e40ae..94293f2d92 100644
--- a/docs/i18n/hi/CHANGELOG.md
+++ b/docs/i18n/hi/CHANGELOG.md
@@ -15,6 +15,10 @@
### 🐛 Bug Fixes
+- **fix(providers):** strip OpenAI-specific fields in Kiro translator to prevent 400 errors (#2037)
+- **fix(ui):** resolve text contrast issues for zero-config warning banner in light mode (#2050)
+- **fix(core):** inject global system prompt correctly into downstream chat completions pipeline (#2080)
+- **fix(routing):** add missing v1beta rewrites to next.config to resolve 404 on Gemini models endpoint (#2102)
- **fix(cache):** optimize cache_control preservation logic and explicitly align tool schema with upstream Claude Code expectations
- **fix(db):** preserve legacy SQLite database path on Windows to prevent data loss (#1973)
- **fix(settings):** resolve model alias persistence double stringification preventing UI updates (#2018)
diff --git a/docs/i18n/hu/CHANGELOG.md b/docs/i18n/hu/CHANGELOG.md
index 79f97153c7..e45a4840ec 100644
--- a/docs/i18n/hu/CHANGELOG.md
+++ b/docs/i18n/hu/CHANGELOG.md
@@ -15,6 +15,10 @@
### 🐛 Bug Fixes
+- **fix(providers):** strip OpenAI-specific fields in Kiro translator to prevent 400 errors (#2037)
+- **fix(ui):** resolve text contrast issues for zero-config warning banner in light mode (#2050)
+- **fix(core):** inject global system prompt correctly into downstream chat completions pipeline (#2080)
+- **fix(routing):** add missing v1beta rewrites to next.config to resolve 404 on Gemini models endpoint (#2102)
- **fix(cache):** optimize cache_control preservation logic and explicitly align tool schema with upstream Claude Code expectations
- **fix(db):** preserve legacy SQLite database path on Windows to prevent data loss (#1973)
- **fix(settings):** resolve model alias persistence double stringification preventing UI updates (#2018)
diff --git a/docs/i18n/id/CHANGELOG.md b/docs/i18n/id/CHANGELOG.md
index 25687c52f7..a4622abef9 100644
--- a/docs/i18n/id/CHANGELOG.md
+++ b/docs/i18n/id/CHANGELOG.md
@@ -15,6 +15,10 @@
### 🐛 Bug Fixes
+- **fix(providers):** strip OpenAI-specific fields in Kiro translator to prevent 400 errors (#2037)
+- **fix(ui):** resolve text contrast issues for zero-config warning banner in light mode (#2050)
+- **fix(core):** inject global system prompt correctly into downstream chat completions pipeline (#2080)
+- **fix(routing):** add missing v1beta rewrites to next.config to resolve 404 on Gemini models endpoint (#2102)
- **fix(cache):** optimize cache_control preservation logic and explicitly align tool schema with upstream Claude Code expectations
- **fix(db):** preserve legacy SQLite database path on Windows to prevent data loss (#1973)
- **fix(settings):** resolve model alias persistence double stringification preventing UI updates (#2018)
diff --git a/docs/i18n/in/CHANGELOG.md b/docs/i18n/in/CHANGELOG.md
index 4dc68a146c..5fff2412bf 100644
--- a/docs/i18n/in/CHANGELOG.md
+++ b/docs/i18n/in/CHANGELOG.md
@@ -15,6 +15,10 @@
### 🐛 Bug Fixes
+- **fix(providers):** strip OpenAI-specific fields in Kiro translator to prevent 400 errors (#2037)
+- **fix(ui):** resolve text contrast issues for zero-config warning banner in light mode (#2050)
+- **fix(core):** inject global system prompt correctly into downstream chat completions pipeline (#2080)
+- **fix(routing):** add missing v1beta rewrites to next.config to resolve 404 on Gemini models endpoint (#2102)
- **fix(cache):** optimize cache_control preservation logic and explicitly align tool schema with upstream Claude Code expectations
- **fix(db):** preserve legacy SQLite database path on Windows to prevent data loss (#1973)
- **fix(settings):** resolve model alias persistence double stringification preventing UI updates (#2018)
diff --git a/docs/i18n/it/CHANGELOG.md b/docs/i18n/it/CHANGELOG.md
index 23603a46bf..16b980bb88 100644
--- a/docs/i18n/it/CHANGELOG.md
+++ b/docs/i18n/it/CHANGELOG.md
@@ -15,6 +15,10 @@
### 🐛 Bug Fixes
+- **fix(providers):** strip OpenAI-specific fields in Kiro translator to prevent 400 errors (#2037)
+- **fix(ui):** resolve text contrast issues for zero-config warning banner in light mode (#2050)
+- **fix(core):** inject global system prompt correctly into downstream chat completions pipeline (#2080)
+- **fix(routing):** add missing v1beta rewrites to next.config to resolve 404 on Gemini models endpoint (#2102)
- **fix(cache):** optimize cache_control preservation logic and explicitly align tool schema with upstream Claude Code expectations
- **fix(db):** preserve legacy SQLite database path on Windows to prevent data loss (#1973)
- **fix(settings):** resolve model alias persistence double stringification preventing UI updates (#2018)
diff --git a/docs/i18n/ja/CHANGELOG.md b/docs/i18n/ja/CHANGELOG.md
index 623fc31eff..eca173462b 100644
--- a/docs/i18n/ja/CHANGELOG.md
+++ b/docs/i18n/ja/CHANGELOG.md
@@ -15,6 +15,10 @@
### 🐛 Bug Fixes
+- **fix(providers):** strip OpenAI-specific fields in Kiro translator to prevent 400 errors (#2037)
+- **fix(ui):** resolve text contrast issues for zero-config warning banner in light mode (#2050)
+- **fix(core):** inject global system prompt correctly into downstream chat completions pipeline (#2080)
+- **fix(routing):** add missing v1beta rewrites to next.config to resolve 404 on Gemini models endpoint (#2102)
- **fix(cache):** optimize cache_control preservation logic and explicitly align tool schema with upstream Claude Code expectations
- **fix(db):** preserve legacy SQLite database path on Windows to prevent data loss (#1973)
- **fix(settings):** resolve model alias persistence double stringification preventing UI updates (#2018)
diff --git a/docs/i18n/ko/CHANGELOG.md b/docs/i18n/ko/CHANGELOG.md
index 33abbb178f..bfc03bbb8e 100644
--- a/docs/i18n/ko/CHANGELOG.md
+++ b/docs/i18n/ko/CHANGELOG.md
@@ -15,6 +15,10 @@
### 🐛 Bug Fixes
+- **fix(providers):** strip OpenAI-specific fields in Kiro translator to prevent 400 errors (#2037)
+- **fix(ui):** resolve text contrast issues for zero-config warning banner in light mode (#2050)
+- **fix(core):** inject global system prompt correctly into downstream chat completions pipeline (#2080)
+- **fix(routing):** add missing v1beta rewrites to next.config to resolve 404 on Gemini models endpoint (#2102)
- **fix(cache):** optimize cache_control preservation logic and explicitly align tool schema with upstream Claude Code expectations
- **fix(db):** preserve legacy SQLite database path on Windows to prevent data loss (#1973)
- **fix(settings):** resolve model alias persistence double stringification preventing UI updates (#2018)
diff --git a/docs/i18n/mr/CHANGELOG.md b/docs/i18n/mr/CHANGELOG.md
index bc787d54a6..32cdb33e35 100644
--- a/docs/i18n/mr/CHANGELOG.md
+++ b/docs/i18n/mr/CHANGELOG.md
@@ -15,6 +15,10 @@
### 🐛 Bug Fixes
+- **fix(providers):** strip OpenAI-specific fields in Kiro translator to prevent 400 errors (#2037)
+- **fix(ui):** resolve text contrast issues for zero-config warning banner in light mode (#2050)
+- **fix(core):** inject global system prompt correctly into downstream chat completions pipeline (#2080)
+- **fix(routing):** add missing v1beta rewrites to next.config to resolve 404 on Gemini models endpoint (#2102)
- **fix(cache):** optimize cache_control preservation logic and explicitly align tool schema with upstream Claude Code expectations
- **fix(db):** preserve legacy SQLite database path on Windows to prevent data loss (#1973)
- **fix(settings):** resolve model alias persistence double stringification preventing UI updates (#2018)
diff --git a/docs/i18n/ms/CHANGELOG.md b/docs/i18n/ms/CHANGELOG.md
index 8eac0b295b..e09d753983 100644
--- a/docs/i18n/ms/CHANGELOG.md
+++ b/docs/i18n/ms/CHANGELOG.md
@@ -15,6 +15,10 @@
### 🐛 Bug Fixes
+- **fix(providers):** strip OpenAI-specific fields in Kiro translator to prevent 400 errors (#2037)
+- **fix(ui):** resolve text contrast issues for zero-config warning banner in light mode (#2050)
+- **fix(core):** inject global system prompt correctly into downstream chat completions pipeline (#2080)
+- **fix(routing):** add missing v1beta rewrites to next.config to resolve 404 on Gemini models endpoint (#2102)
- **fix(cache):** optimize cache_control preservation logic and explicitly align tool schema with upstream Claude Code expectations
- **fix(db):** preserve legacy SQLite database path on Windows to prevent data loss (#1973)
- **fix(settings):** resolve model alias persistence double stringification preventing UI updates (#2018)
diff --git a/docs/i18n/nl/CHANGELOG.md b/docs/i18n/nl/CHANGELOG.md
index a8aabfc653..cf36a71347 100644
--- a/docs/i18n/nl/CHANGELOG.md
+++ b/docs/i18n/nl/CHANGELOG.md
@@ -15,6 +15,10 @@
### 🐛 Bug Fixes
+- **fix(providers):** strip OpenAI-specific fields in Kiro translator to prevent 400 errors (#2037)
+- **fix(ui):** resolve text contrast issues for zero-config warning banner in light mode (#2050)
+- **fix(core):** inject global system prompt correctly into downstream chat completions pipeline (#2080)
+- **fix(routing):** add missing v1beta rewrites to next.config to resolve 404 on Gemini models endpoint (#2102)
- **fix(cache):** optimize cache_control preservation logic and explicitly align tool schema with upstream Claude Code expectations
- **fix(db):** preserve legacy SQLite database path on Windows to prevent data loss (#1973)
- **fix(settings):** resolve model alias persistence double stringification preventing UI updates (#2018)
diff --git a/docs/i18n/no/CHANGELOG.md b/docs/i18n/no/CHANGELOG.md
index 3f49a01660..76efda938b 100644
--- a/docs/i18n/no/CHANGELOG.md
+++ b/docs/i18n/no/CHANGELOG.md
@@ -15,6 +15,10 @@
### 🐛 Bug Fixes
+- **fix(providers):** strip OpenAI-specific fields in Kiro translator to prevent 400 errors (#2037)
+- **fix(ui):** resolve text contrast issues for zero-config warning banner in light mode (#2050)
+- **fix(core):** inject global system prompt correctly into downstream chat completions pipeline (#2080)
+- **fix(routing):** add missing v1beta rewrites to next.config to resolve 404 on Gemini models endpoint (#2102)
- **fix(cache):** optimize cache_control preservation logic and explicitly align tool schema with upstream Claude Code expectations
- **fix(db):** preserve legacy SQLite database path on Windows to prevent data loss (#1973)
- **fix(settings):** resolve model alias persistence double stringification preventing UI updates (#2018)
diff --git a/docs/i18n/phi/CHANGELOG.md b/docs/i18n/phi/CHANGELOG.md
index a58c91fb5e..68add57f30 100644
--- a/docs/i18n/phi/CHANGELOG.md
+++ b/docs/i18n/phi/CHANGELOG.md
@@ -15,6 +15,10 @@
### 🐛 Bug Fixes
+- **fix(providers):** strip OpenAI-specific fields in Kiro translator to prevent 400 errors (#2037)
+- **fix(ui):** resolve text contrast issues for zero-config warning banner in light mode (#2050)
+- **fix(core):** inject global system prompt correctly into downstream chat completions pipeline (#2080)
+- **fix(routing):** add missing v1beta rewrites to next.config to resolve 404 on Gemini models endpoint (#2102)
- **fix(cache):** optimize cache_control preservation logic and explicitly align tool schema with upstream Claude Code expectations
- **fix(db):** preserve legacy SQLite database path on Windows to prevent data loss (#1973)
- **fix(settings):** resolve model alias persistence double stringification preventing UI updates (#2018)
diff --git a/docs/i18n/pl/CHANGELOG.md b/docs/i18n/pl/CHANGELOG.md
index 0c27ebc757..663d3597f0 100644
--- a/docs/i18n/pl/CHANGELOG.md
+++ b/docs/i18n/pl/CHANGELOG.md
@@ -15,6 +15,10 @@
### 🐛 Bug Fixes
+- **fix(providers):** strip OpenAI-specific fields in Kiro translator to prevent 400 errors (#2037)
+- **fix(ui):** resolve text contrast issues for zero-config warning banner in light mode (#2050)
+- **fix(core):** inject global system prompt correctly into downstream chat completions pipeline (#2080)
+- **fix(routing):** add missing v1beta rewrites to next.config to resolve 404 on Gemini models endpoint (#2102)
- **fix(cache):** optimize cache_control preservation logic and explicitly align tool schema with upstream Claude Code expectations
- **fix(db):** preserve legacy SQLite database path on Windows to prevent data loss (#1973)
- **fix(settings):** resolve model alias persistence double stringification preventing UI updates (#2018)
diff --git a/docs/i18n/pt-BR/CHANGELOG.md b/docs/i18n/pt-BR/CHANGELOG.md
index deb79e3b0d..5c3ae2ddd2 100644
--- a/docs/i18n/pt-BR/CHANGELOG.md
+++ b/docs/i18n/pt-BR/CHANGELOG.md
@@ -15,6 +15,10 @@
### 🐛 Bug Fixes
+- **fix(providers):** strip OpenAI-specific fields in Kiro translator to prevent 400 errors (#2037)
+- **fix(ui):** resolve text contrast issues for zero-config warning banner in light mode (#2050)
+- **fix(core):** inject global system prompt correctly into downstream chat completions pipeline (#2080)
+- **fix(routing):** add missing v1beta rewrites to next.config to resolve 404 on Gemini models endpoint (#2102)
- **fix(cache):** optimize cache_control preservation logic and explicitly align tool schema with upstream Claude Code expectations
- **fix(db):** preserve legacy SQLite database path on Windows to prevent data loss (#1973)
- **fix(settings):** resolve model alias persistence double stringification preventing UI updates (#2018)
diff --git a/docs/i18n/pt/CHANGELOG.md b/docs/i18n/pt/CHANGELOG.md
index f925b7651e..cefddbe6a6 100644
--- a/docs/i18n/pt/CHANGELOG.md
+++ b/docs/i18n/pt/CHANGELOG.md
@@ -15,6 +15,10 @@
### 🐛 Bug Fixes
+- **fix(providers):** strip OpenAI-specific fields in Kiro translator to prevent 400 errors (#2037)
+- **fix(ui):** resolve text contrast issues for zero-config warning banner in light mode (#2050)
+- **fix(core):** inject global system prompt correctly into downstream chat completions pipeline (#2080)
+- **fix(routing):** add missing v1beta rewrites to next.config to resolve 404 on Gemini models endpoint (#2102)
- **fix(cache):** optimize cache_control preservation logic and explicitly align tool schema with upstream Claude Code expectations
- **fix(db):** preserve legacy SQLite database path on Windows to prevent data loss (#1973)
- **fix(settings):** resolve model alias persistence double stringification preventing UI updates (#2018)
diff --git a/docs/i18n/ro/CHANGELOG.md b/docs/i18n/ro/CHANGELOG.md
index 95b26b7c07..111fbd3826 100644
--- a/docs/i18n/ro/CHANGELOG.md
+++ b/docs/i18n/ro/CHANGELOG.md
@@ -15,6 +15,10 @@
### 🐛 Bug Fixes
+- **fix(providers):** strip OpenAI-specific fields in Kiro translator to prevent 400 errors (#2037)
+- **fix(ui):** resolve text contrast issues for zero-config warning banner in light mode (#2050)
+- **fix(core):** inject global system prompt correctly into downstream chat completions pipeline (#2080)
+- **fix(routing):** add missing v1beta rewrites to next.config to resolve 404 on Gemini models endpoint (#2102)
- **fix(cache):** optimize cache_control preservation logic and explicitly align tool schema with upstream Claude Code expectations
- **fix(db):** preserve legacy SQLite database path on Windows to prevent data loss (#1973)
- **fix(settings):** resolve model alias persistence double stringification preventing UI updates (#2018)
diff --git a/docs/i18n/ru/CHANGELOG.md b/docs/i18n/ru/CHANGELOG.md
index 219bb905bd..50f161d945 100644
--- a/docs/i18n/ru/CHANGELOG.md
+++ b/docs/i18n/ru/CHANGELOG.md
@@ -15,6 +15,10 @@
### 🐛 Bug Fixes
+- **fix(providers):** strip OpenAI-specific fields in Kiro translator to prevent 400 errors (#2037)
+- **fix(ui):** resolve text contrast issues for zero-config warning banner in light mode (#2050)
+- **fix(core):** inject global system prompt correctly into downstream chat completions pipeline (#2080)
+- **fix(routing):** add missing v1beta rewrites to next.config to resolve 404 on Gemini models endpoint (#2102)
- **fix(cache):** optimize cache_control preservation logic and explicitly align tool schema with upstream Claude Code expectations
- **fix(db):** preserve legacy SQLite database path on Windows to prevent data loss (#1973)
- **fix(settings):** resolve model alias persistence double stringification preventing UI updates (#2018)
diff --git a/docs/i18n/sk/CHANGELOG.md b/docs/i18n/sk/CHANGELOG.md
index a15a801e54..0f23717de4 100644
--- a/docs/i18n/sk/CHANGELOG.md
+++ b/docs/i18n/sk/CHANGELOG.md
@@ -15,6 +15,10 @@
### 🐛 Bug Fixes
+- **fix(providers):** strip OpenAI-specific fields in Kiro translator to prevent 400 errors (#2037)
+- **fix(ui):** resolve text contrast issues for zero-config warning banner in light mode (#2050)
+- **fix(core):** inject global system prompt correctly into downstream chat completions pipeline (#2080)
+- **fix(routing):** add missing v1beta rewrites to next.config to resolve 404 on Gemini models endpoint (#2102)
- **fix(cache):** optimize cache_control preservation logic and explicitly align tool schema with upstream Claude Code expectations
- **fix(db):** preserve legacy SQLite database path on Windows to prevent data loss (#1973)
- **fix(settings):** resolve model alias persistence double stringification preventing UI updates (#2018)
diff --git a/docs/i18n/sv/CHANGELOG.md b/docs/i18n/sv/CHANGELOG.md
index 054939b40e..4a96e4e90c 100644
--- a/docs/i18n/sv/CHANGELOG.md
+++ b/docs/i18n/sv/CHANGELOG.md
@@ -15,6 +15,10 @@
### 🐛 Bug Fixes
+- **fix(providers):** strip OpenAI-specific fields in Kiro translator to prevent 400 errors (#2037)
+- **fix(ui):** resolve text contrast issues for zero-config warning banner in light mode (#2050)
+- **fix(core):** inject global system prompt correctly into downstream chat completions pipeline (#2080)
+- **fix(routing):** add missing v1beta rewrites to next.config to resolve 404 on Gemini models endpoint (#2102)
- **fix(cache):** optimize cache_control preservation logic and explicitly align tool schema with upstream Claude Code expectations
- **fix(db):** preserve legacy SQLite database path on Windows to prevent data loss (#1973)
- **fix(settings):** resolve model alias persistence double stringification preventing UI updates (#2018)
diff --git a/docs/i18n/sw/CHANGELOG.md b/docs/i18n/sw/CHANGELOG.md
index 3e361ecdbc..a804c7ef40 100644
--- a/docs/i18n/sw/CHANGELOG.md
+++ b/docs/i18n/sw/CHANGELOG.md
@@ -15,6 +15,10 @@
### 🐛 Bug Fixes
+- **fix(providers):** strip OpenAI-specific fields in Kiro translator to prevent 400 errors (#2037)
+- **fix(ui):** resolve text contrast issues for zero-config warning banner in light mode (#2050)
+- **fix(core):** inject global system prompt correctly into downstream chat completions pipeline (#2080)
+- **fix(routing):** add missing v1beta rewrites to next.config to resolve 404 on Gemini models endpoint (#2102)
- **fix(cache):** optimize cache_control preservation logic and explicitly align tool schema with upstream Claude Code expectations
- **fix(db):** preserve legacy SQLite database path on Windows to prevent data loss (#1973)
- **fix(settings):** resolve model alias persistence double stringification preventing UI updates (#2018)
diff --git a/docs/i18n/ta/CHANGELOG.md b/docs/i18n/ta/CHANGELOG.md
index 299368152d..df9baec486 100644
--- a/docs/i18n/ta/CHANGELOG.md
+++ b/docs/i18n/ta/CHANGELOG.md
@@ -15,6 +15,10 @@
### 🐛 Bug Fixes
+- **fix(providers):** strip OpenAI-specific fields in Kiro translator to prevent 400 errors (#2037)
+- **fix(ui):** resolve text contrast issues for zero-config warning banner in light mode (#2050)
+- **fix(core):** inject global system prompt correctly into downstream chat completions pipeline (#2080)
+- **fix(routing):** add missing v1beta rewrites to next.config to resolve 404 on Gemini models endpoint (#2102)
- **fix(cache):** optimize cache_control preservation logic and explicitly align tool schema with upstream Claude Code expectations
- **fix(db):** preserve legacy SQLite database path on Windows to prevent data loss (#1973)
- **fix(settings):** resolve model alias persistence double stringification preventing UI updates (#2018)
diff --git a/docs/i18n/te/CHANGELOG.md b/docs/i18n/te/CHANGELOG.md
index c35c2285ac..ce7f96cd67 100644
--- a/docs/i18n/te/CHANGELOG.md
+++ b/docs/i18n/te/CHANGELOG.md
@@ -15,6 +15,10 @@
### 🐛 Bug Fixes
+- **fix(providers):** strip OpenAI-specific fields in Kiro translator to prevent 400 errors (#2037)
+- **fix(ui):** resolve text contrast issues for zero-config warning banner in light mode (#2050)
+- **fix(core):** inject global system prompt correctly into downstream chat completions pipeline (#2080)
+- **fix(routing):** add missing v1beta rewrites to next.config to resolve 404 on Gemini models endpoint (#2102)
- **fix(cache):** optimize cache_control preservation logic and explicitly align tool schema with upstream Claude Code expectations
- **fix(db):** preserve legacy SQLite database path on Windows to prevent data loss (#1973)
- **fix(settings):** resolve model alias persistence double stringification preventing UI updates (#2018)
diff --git a/docs/i18n/th/CHANGELOG.md b/docs/i18n/th/CHANGELOG.md
index c6f0ad1a37..19161f26c4 100644
--- a/docs/i18n/th/CHANGELOG.md
+++ b/docs/i18n/th/CHANGELOG.md
@@ -15,6 +15,10 @@
### 🐛 Bug Fixes
+- **fix(providers):** strip OpenAI-specific fields in Kiro translator to prevent 400 errors (#2037)
+- **fix(ui):** resolve text contrast issues for zero-config warning banner in light mode (#2050)
+- **fix(core):** inject global system prompt correctly into downstream chat completions pipeline (#2080)
+- **fix(routing):** add missing v1beta rewrites to next.config to resolve 404 on Gemini models endpoint (#2102)
- **fix(cache):** optimize cache_control preservation logic and explicitly align tool schema with upstream Claude Code expectations
- **fix(db):** preserve legacy SQLite database path on Windows to prevent data loss (#1973)
- **fix(settings):** resolve model alias persistence double stringification preventing UI updates (#2018)
diff --git a/docs/i18n/tr/CHANGELOG.md b/docs/i18n/tr/CHANGELOG.md
index ae3a94c8ed..258eba87fd 100644
--- a/docs/i18n/tr/CHANGELOG.md
+++ b/docs/i18n/tr/CHANGELOG.md
@@ -15,6 +15,10 @@
### 🐛 Bug Fixes
+- **fix(providers):** strip OpenAI-specific fields in Kiro translator to prevent 400 errors (#2037)
+- **fix(ui):** resolve text contrast issues for zero-config warning banner in light mode (#2050)
+- **fix(core):** inject global system prompt correctly into downstream chat completions pipeline (#2080)
+- **fix(routing):** add missing v1beta rewrites to next.config to resolve 404 on Gemini models endpoint (#2102)
- **fix(cache):** optimize cache_control preservation logic and explicitly align tool schema with upstream Claude Code expectations
- **fix(db):** preserve legacy SQLite database path on Windows to prevent data loss (#1973)
- **fix(settings):** resolve model alias persistence double stringification preventing UI updates (#2018)
diff --git a/docs/i18n/uk-UA/CHANGELOG.md b/docs/i18n/uk-UA/CHANGELOG.md
index d1e855dacc..6116fd2a08 100644
--- a/docs/i18n/uk-UA/CHANGELOG.md
+++ b/docs/i18n/uk-UA/CHANGELOG.md
@@ -15,6 +15,10 @@
### 🐛 Bug Fixes
+- **fix(providers):** strip OpenAI-specific fields in Kiro translator to prevent 400 errors (#2037)
+- **fix(ui):** resolve text contrast issues for zero-config warning banner in light mode (#2050)
+- **fix(core):** inject global system prompt correctly into downstream chat completions pipeline (#2080)
+- **fix(routing):** add missing v1beta rewrites to next.config to resolve 404 on Gemini models endpoint (#2102)
- **fix(cache):** optimize cache_control preservation logic and explicitly align tool schema with upstream Claude Code expectations
- **fix(db):** preserve legacy SQLite database path on Windows to prevent data loss (#1973)
- **fix(settings):** resolve model alias persistence double stringification preventing UI updates (#2018)
diff --git a/docs/i18n/ur/CHANGELOG.md b/docs/i18n/ur/CHANGELOG.md
index 51d28b576f..8131cc5d44 100644
--- a/docs/i18n/ur/CHANGELOG.md
+++ b/docs/i18n/ur/CHANGELOG.md
@@ -15,6 +15,10 @@
### 🐛 Bug Fixes
+- **fix(providers):** strip OpenAI-specific fields in Kiro translator to prevent 400 errors (#2037)
+- **fix(ui):** resolve text contrast issues for zero-config warning banner in light mode (#2050)
+- **fix(core):** inject global system prompt correctly into downstream chat completions pipeline (#2080)
+- **fix(routing):** add missing v1beta rewrites to next.config to resolve 404 on Gemini models endpoint (#2102)
- **fix(cache):** optimize cache_control preservation logic and explicitly align tool schema with upstream Claude Code expectations
- **fix(db):** preserve legacy SQLite database path on Windows to prevent data loss (#1973)
- **fix(settings):** resolve model alias persistence double stringification preventing UI updates (#2018)
diff --git a/docs/i18n/vi/CHANGELOG.md b/docs/i18n/vi/CHANGELOG.md
index 52b084da4d..949f07790b 100644
--- a/docs/i18n/vi/CHANGELOG.md
+++ b/docs/i18n/vi/CHANGELOG.md
@@ -15,6 +15,10 @@
### 🐛 Bug Fixes
+- **fix(providers):** strip OpenAI-specific fields in Kiro translator to prevent 400 errors (#2037)
+- **fix(ui):** resolve text contrast issues for zero-config warning banner in light mode (#2050)
+- **fix(core):** inject global system prompt correctly into downstream chat completions pipeline (#2080)
+- **fix(routing):** add missing v1beta rewrites to next.config to resolve 404 on Gemini models endpoint (#2102)
- **fix(cache):** optimize cache_control preservation logic and explicitly align tool schema with upstream Claude Code expectations
- **fix(db):** preserve legacy SQLite database path on Windows to prevent data loss (#1973)
- **fix(settings):** resolve model alias persistence double stringification preventing UI updates (#2018)
diff --git a/docs/i18n/zh-CN/CHANGELOG.md b/docs/i18n/zh-CN/CHANGELOG.md
index e739c7b20c..98cd0991de 100644
--- a/docs/i18n/zh-CN/CHANGELOG.md
+++ b/docs/i18n/zh-CN/CHANGELOG.md
@@ -15,6 +15,10 @@
### 🐛 Bug Fixes
+- **fix(providers):** strip OpenAI-specific fields in Kiro translator to prevent 400 errors (#2037)
+- **fix(ui):** resolve text contrast issues for zero-config warning banner in light mode (#2050)
+- **fix(core):** inject global system prompt correctly into downstream chat completions pipeline (#2080)
+- **fix(routing):** add missing v1beta rewrites to next.config to resolve 404 on Gemini models endpoint (#2102)
- **fix(cache):** optimize cache_control preservation logic and explicitly align tool schema with upstream Claude Code expectations
- **fix(db):** preserve legacy SQLite database path on Windows to prevent data loss (#1973)
- **fix(settings):** resolve model alias persistence double stringification preventing UI updates (#2018)
diff --git a/open-sse/services/tokenRefresh.ts b/open-sse/services/tokenRefresh.ts
index 5a679e3203..33f0848756 100755
--- a/open-sse/services/tokenRefresh.ts
+++ b/open-sse/services/tokenRefresh.ts
@@ -147,9 +147,16 @@ export async function refreshWindsurfToken(
return null;
}
- // Firebase STS refresh for device-code tokens
- const firebaseApiKey =
- process.env.WINDSURF_FIREBASE_API_KEY || "AIzaSyBpLTEGSt59AUPKxBb7lIWjSE2ZXQH7mgU";
+ // Firebase STS refresh for browser-flow tokens.
+ // Key is read from WINDSURF_FIREBASE_API_KEY env var (set in .env.example).
+ const firebaseApiKey = process.env.WINDSURF_FIREBASE_API_KEY || "";
+ if (!firebaseApiKey) {
+ log?.warn?.(
+ "TOKEN_REFRESH",
+ "WINDSURF_FIREBASE_API_KEY not set — skipping Windsurf Firebase token refresh"
+ );
+ return null;
+ }
const tokenUrl = `https://securetoken.googleapis.com/v1/token?key=${firebaseApiKey}`;
try {
diff --git a/src/app/api/oauth/[provider]/[action]/route.ts b/src/app/api/oauth/[provider]/[action]/route.ts
index 086ef7da83..8bd8b902db 100755
--- a/src/app/api/oauth/[provider]/[action]/route.ts
+++ b/src/app/api/oauth/[provider]/[action]/route.ts
@@ -21,6 +21,7 @@ import { runWithProxyContext } from "@omniroute/open-sse/utils/proxyFetch.ts";
import {
jsonObjectSchema,
oauthExchangeSchema,
+ oauthImportTokenSchema,
oauthPollSchema,
} from "@/shared/validation/schemas";
import { isValidationFailure, validateBody } from "@/shared/validation/helpers";
@@ -30,6 +31,16 @@ import { isAuthRequired, isAuthenticated } from "@/shared/utils/apiAuth";
if (!globalThis.__codexCallbackState) {
globalThis.__codexCallbackState = null;
}
+// Windsurf / Devin CLI PKCE callback server state (separate from Codex)
+if (!globalThis.__windsurfCallbackState) {
+ globalThis.__windsurfCallbackState = null;
+}
+
+/** Providers that use the PKCE browser callback flow (like Codex). */
+const PKCE_CALLBACK_PROVIDERS = new Set(["codex", "windsurf", "devin-cli"]);
+
+/** Providers that allow direct import of a raw API token (no OAuth exchange). */
+const IMPORT_TOKEN_PROVIDERS = new Set(["windsurf", "devin-cli"]);
/**
* Constant-time string comparison to prevent timing-oracle attacks (CWE-208).
@@ -150,40 +161,44 @@ export async function GET(
}
/**
- * Start Codex callback server on port 1455
- * Returns the auth URL and stores codeVerifier for later exchange
+ * Start PKCE callback server for Codex, Windsurf, or Devin CLI.
+ * Codex uses fixed port 1455; Windsurf/Devin CLI use a random free port (port 0).
+ * Returns the auth URL and stores codeVerifier for later exchange.
*/
async function handleStartCallbackServer(provider: string, searchParams: URLSearchParams) {
- if (provider !== "codex") {
+ if (!PKCE_CALLBACK_PROVIDERS.has(provider)) {
return NextResponse.json(
- { error: "Callback server only supported for codex" },
+ { error: `Callback server not supported for provider: ${provider}` },
{ status: 400 }
);
}
+ const isWindsurf = provider === "windsurf" || provider === "devin-cli";
+ const stateKey = isWindsurf ? "__windsurfCallbackState" : "__codexCallbackState";
+
// Clean up existing server if any
- if (globalThis.__codexCallbackState?.close) {
+ if (globalThis[stateKey]?.close) {
try {
- globalThis.__codexCallbackState.close();
+ globalThis[stateKey].close();
} catch (e) {
/* ignore */
}
}
- globalThis.__codexCallbackState = null;
+ globalThis[stateKey] = null;
try {
- // Start temp server on port 1455
+ // Codex: fixed port 1455. Windsurf/Devin CLI: OS-assigned random port (0)
+ const serverPort = isWindsurf ? 0 : 1455;
const { port, close } = await startLocalServer((params) => {
- // Write directly to globalThis so it survives module reloads
- if (globalThis.__codexCallbackState) {
- globalThis.__codexCallbackState.callbackParams = params;
+ if (globalThis[stateKey]) {
+ globalThis[stateKey].callbackParams = params;
}
- }, 1455);
+ }, serverPort);
const redirectUri = `http://localhost:${port}/auth/callback`;
const authData = generateAuthData(provider, redirectUri);
- globalThis.__codexCallbackState = {
+ globalThis[stateKey] = {
callbackParams: null,
close,
port,
@@ -195,13 +210,13 @@ async function handleStartCallbackServer(provider: string, searchParams: URLSear
// Auto-cleanup after 5 minutes
const startedAt = Date.now();
setTimeout(() => {
- if (globalThis.__codexCallbackState?.startedAt === startedAt) {
+ if (globalThis[stateKey]?.startedAt === startedAt) {
try {
close();
} catch (e) {
/* ignore */
}
- globalThis.__codexCallbackState = null;
+ globalThis[stateKey] = null;
}
}, 300000);
@@ -263,6 +278,12 @@ export async function POST(
return NextResponse.json({ error: validation.error }, { status: 400 });
}
body = validation.data;
+ } else if (action === "import-token") {
+ const validation = validateBody(oauthImportTokenSchema, rawBody);
+ if (isValidationFailure(validation)) {
+ return NextResponse.json({ error: validation.error }, { status: 400 });
+ }
+ body = validation.data;
}
if (action === "exchange") {
@@ -454,15 +475,20 @@ export async function POST(
if (action === "poll-callback") {
const { connectionId } = body;
- // Poll for Codex callback server result
- if (provider !== "codex") {
+ // poll-callback is supported for all PKCE callback providers
+ if (!PKCE_CALLBACK_PROVIDERS.has(provider)) {
return NextResponse.json(
- { error: "poll-callback only supported for codex" },
+ {
+ error: `poll-callback only supported for PKCE callback providers: ${[...PKCE_CALLBACK_PROVIDERS].join(", ")}`,
+ },
{ status: 400 }
);
}
- if (!globalThis.__codexCallbackState) {
+ // Windsurf and Devin CLI share __windsurfCallbackState; Codex uses its own slot
+ const stateKey = provider === "codex" ? "__codexCallbackState" : "__windsurfCallbackState";
+
+ if (!globalThis[stateKey]) {
return NextResponse.json({
success: false,
error: "no_server",
@@ -470,13 +496,13 @@ export async function POST(
});
}
- if (!globalThis.__codexCallbackState.callbackParams) {
+ if (!globalThis[stateKey].callbackParams) {
return NextResponse.json({ success: false, pending: true });
}
// Callback received! Extract code and exchange for tokens
- const params = globalThis.__codexCallbackState.callbackParams;
- const { redirectUri, codeVerifier, close } = globalThis.__codexCallbackState;
+ const params = globalThis[stateKey].callbackParams;
+ const { redirectUri, codeVerifier, close } = globalThis[stateKey];
// Clean up server
try {
@@ -484,7 +510,7 @@ export async function POST(
} catch (e) {
/* ignore */
}
- globalThis.__codexCallbackState = null;
+ globalThis[stateKey] = null;
if (params.error) {
return NextResponse.json({
@@ -571,6 +597,76 @@ export async function POST(
}
}
+ if (action === "import-token") {
+ const { token, connectionId } = body;
+
+ if (!IMPORT_TOKEN_PROVIDERS.has(provider)) {
+ return NextResponse.json(
+ {
+ error: `import-token not supported for provider: ${provider}. Supported: ${[...IMPORT_TOKEN_PROVIDERS].join(", ")}`,
+ },
+ { status: 400 }
+ );
+ }
+
+ try {
+ // Map the raw token via the provider's mapTokens() — skips the HTTP exchange entirely.
+ const providerData = getProvider(provider);
+ const tokenData = providerData.mapTokens({ accessToken: token });
+
+ // Normalize: if name is missing, use email as fallback display label
+ if (!tokenData.name && (tokenData.email || tokenData.displayName)) {
+ tokenData.name = tokenData.email || tokenData.displayName;
+ }
+
+ const expiresAt = tokenData.expiresIn
+ ? new Date(Date.now() + tokenData.expiresIn * 1000).toISOString()
+ : null;
+
+ let connection: any;
+ if (tokenData.email) {
+ const existing = await getProviderConnections({ provider });
+ const match = existing.find((c: any) => {
+ if (c.id && safeEqual(connectionId, c.id)) return true;
+ if (!safeEqual(c.email, tokenData.email) || c.authType !== "oauth") return false;
+ return true;
+ });
+ const matchId = typeof match?.id === "string" ? match.id : null;
+ if (matchId) {
+ connection = await updateProviderConnection(matchId, {
+ ...tokenData,
+ expiresAt,
+ testStatus: "active",
+ isActive: true,
+ });
+ }
+ }
+ if (!connection) {
+ connection = await createProviderConnection({
+ provider,
+ authType: "oauth",
+ ...tokenData,
+ expiresAt,
+ testStatus: "active",
+ });
+ }
+
+ await syncToCloudIfEnabled();
+
+ return NextResponse.json({
+ success: true,
+ connection: {
+ id: connection.id,
+ provider: connection.provider,
+ email: connection.email,
+ displayName: connection.displayName,
+ },
+ });
+ } catch (importErr: any) {
+ return NextResponse.json({ success: false, error: importErr.message }, { status: 500 });
+ }
+ }
+
return NextResponse.json({ error: "Unknown action" }, { status: 400 });
} catch (error) {
console.log("OAuth POST error:", error);
diff --git a/src/app/auth/callback/page.tsx b/src/app/auth/callback/page.tsx
new file mode 100644
index 0000000000..4f24ca9e96
--- /dev/null
+++ b/src/app/auth/callback/page.tsx
@@ -0,0 +1,13 @@
+/**
+ * /auth/callback — OAuth callback endpoint for providers that use the
+ * `/auth/callback` path (Windsurf, Devin CLI PKCE flow).
+ *
+ * Reuses the same logic as /callback:
+ * - postMessage to opener (popup mode)
+ * - BroadcastChannel (same-origin tabs)
+ * - localStorage fallback
+ *
+ * On true localhost the random-port callback server intercepts this path first,
+ * so this page is only reached in the LAN / popup-without-callback-server case.
+ */
+export { default } from "@/app/callback/page";
diff --git a/src/lib/oauth/constants/oauth.ts b/src/lib/oauth/constants/oauth.ts
index 304ab4c729..2f0fd83440 100644
--- a/src/lib/oauth/constants/oauth.ts
+++ b/src/lib/oauth/constants/oauth.ts
@@ -264,23 +264,38 @@ export const CURSOR_CONFIG = {
},
};
-// Windsurf (Devin CLI / Codeium) Configuration
-// Authentication supports two methods:
-// 1. Token import: user visits windsurf.com/show-auth-token, copies Codeium API key
-// 2. Device code flow: Codeium's own gRPC device flow (poll-based, no browser redirect needed)
+// Windsurf / Devin CLI Configuration
+//
+// Authentication uses PKCE Authorization Code Flow — same pattern as Codex CLI.
+// Extracted from Devin CLI binary (model_configs_v2.bin + devin.exe strings):
+//
+// Authorize URL: https://app.devin.ai/editor/signin
+// Params: response_type=code, redirect_uri, code_challenge, code_challenge_method=S256
+// Callback path: /auth/callback (local server on random port 127.0.0.1:0)
+// Exchange: POST https://server.codeium.com/<ExchangePKCEAuthorizationCode>
+// via Connect JSON protocol (Content-Type: application/json)
+// Response field: windsurfApiKey → stored as accessToken / WINDSURF_API_KEY
+//
+// Fallback: user can also paste a token from windsurf.com/show-auth-token
export const WINDSURF_CONFIG = {
- // API server for device-code flow and user registration
+ // Browser-based PKCE authorize endpoint (extracted from devin.exe binary)
+ authorizeUrl: "https://app.devin.ai/editor/signin",
+ codeChallengeMethod: "S256" as const,
+ // Local callback server — 0 = OS assigns a free port
+ callbackPort: 0,
+ callbackPath: "/auth/callback",
+ // Token exchange via Windsurf Connect JSON (gRPC-web + JSON)
apiServerUrl: "https://server.codeium.com",
+ exchangePath: "/exa.seat_management_pb.SeatManagementService/ExchangePKCEAuthorizationCode",
// Inference server URL (gRPC-web requests go here)
inferenceUrl: "https://server.self-serve.windsurf.com",
- // User-friendly token page — the "link" integration
+ // Fallback: user visits this page, copies token, pastes it
showAuthTokenUrl: "https://windsurf.com/show-auth-token",
- // Token refresh via Firebase Secure Token Service
- firebaseApiKey:
- process.env.WINDSURF_FIREBASE_API_KEY || "AIzaSyBpLTEGSt59AUPKxBb7lIWjSE2ZXQH7mgU",
+ // Token refresh via Firebase Secure Token Service (for short-lived browser-flow tokens).
+ // Value comes from WINDSURF_FIREBASE_API_KEY env var (set in .env.example).
+ // Long-lived import tokens never need this — refresh is skipped when key is absent.
+ firebaseApiKey: process.env.WINDSURF_FIREBASE_API_KEY || "",
firebaseTokenUrl: "https://securetoken.googleapis.com/v1/token",
- // Auth method flag
- authMethods: ["import", "device-code"] as const,
// IDE identity sent with every gRPC request
ideName: "windsurf",
ideVersion: "3.14.0",
diff --git a/src/lib/oauth/providers/windsurf.ts b/src/lib/oauth/providers/windsurf.ts
index 4a9a573ec1..8990a2a580 100644
--- a/src/lib/oauth/providers/windsurf.ts
+++ b/src/lib/oauth/providers/windsurf.ts
@@ -1,57 +1,120 @@
import { WINDSURF_CONFIG } from "../constants/oauth";
/**
- * Windsurf (Devin CLI / Codeium) OAuth Provider
+ * Windsurf / Devin CLI OAuth Provider
*
- * Supports two authentication methods:
+ * Uses PKCE Authorization Code Flow — same pattern as Codex CLI.
+ * Extracted from Devin CLI binary (devin.exe string analysis):
*
- * 1. **Token Import** (recommended, "link" integration):
- * User visits windsurf.com/show-auth-token after signing into Windsurf,
- * copies their Codeium API token, and pastes it here. The token is stored
- * directly as `accessToken` and sent in gRPC request Metadata.api_key.
+ * 1. OmniRoute starts a local callback server (random port, 127.0.0.1)
+ * 2. Browser opens:
+ * https://app.devin.ai/editor/signin
+ * ?response_type=code
+ * &redirect_uri=http://127.0.0.1:PORT/auth/callback
+ * &code_challenge=<S256_CHALLENGE>
+ * &code_challenge_method=S256
+ * 3. User logs in (Google / GitHub / Windsurf Enterprise)
+ * 4. Browser redirects back to callback server with `code`
+ * 5. Exchange code via Windsurf Connect JSON:
+ * POST https://server.codeium.com/exa.seat_management_pb.SeatManagementService/ExchangePKCEAuthorizationCode
+ * { "code": "...", "codeVerifier": "...", "redirectUri": "..." }
+ * 6. Response: { "windsurfApiKey": "...", "apiServerUrl": "...", ... }
+ * 7. `windsurfApiKey` stored as `accessToken` (= WINDSURF_API_KEY)
*
- * 2. **Device-Code Flow** (via Codeium's gRPC ExtensionServerService):
- * The executor calls StartDeviceFlow → user visits a verification URL →
- * poll GetDeviceFlowState until the Firebase ID token is returned. The
- * Firebase token is then exchanged for a Codeium API key via RegisterUser.
- * This mirrors how `devin auth login` opens a browser link.
- *
- * Token lifetime:
- * - Import tokens (Codeium API keys) are long-lived and do not expire.
- * - Device-code Firebase tokens expire after ~1 hour; the refresh token is
- * persisted and exchanged against Firebase STS for a new ID token when
- * the existing one is near expiry.
+ * Fallback (import_token): user visits windsurf.com/show-auth-token,
+ * copies their API key, and pastes it into the connection form.
*/
export const windsurf = {
config: WINDSURF_CONFIG,
- flowType: "import_token",
+ flowType: "authorization_code_pkce",
+ // Fixed callback path expected by Devin CLI auth flow
+ callbackPath: WINDSURF_CONFIG.callbackPath,
+ // Port 0 = OS assigns a free port (we use the globalThis devin callback state)
+ callbackPort: WINDSURF_CONFIG.callbackPort,
+
+ buildAuthUrl: (
+ config: typeof WINDSURF_CONFIG,
+ redirectUri: string,
+ state: string,
+ codeChallenge: string
+ ) => {
+ const params = new URLSearchParams({
+ response_type: "code",
+ redirect_uri: redirectUri,
+ code_challenge: codeChallenge,
+ code_challenge_method: config.codeChallengeMethod,
+ state,
+ });
+ return `${config.authorizeUrl}?${params.toString()}`;
+ },
+
+ /**
+ * Exchange authorization code for Windsurf API key.
+ * Uses the Windsurf Connect JSON protocol (not standard OAuth token endpoint).
+ */
+ exchangeToken: async (
+ config: typeof WINDSURF_CONFIG,
+ code: string,
+ redirectUri: string,
+ codeVerifier: string
+ ) => {
+ const url = `${config.apiServerUrl}${config.exchangePath}`;
+ const response = await fetch(url, {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json",
+ Accept: "application/json",
+ // Connect protocol version header
+ "Connect-Protocol-Version": "1",
+ },
+ body: JSON.stringify({
+ code,
+ codeVerifier,
+ redirectUri,
+ }),
+ });
+
+ if (!response.ok) {
+ const error = await response.text();
+ throw new Error(`Windsurf token exchange failed (${response.status}): ${error}`);
+ }
+
+ const data = await response.json();
+ return data;
+ },
/**
- * Map imported/exchanged token data to OmniRoute connection fields.
- * Called after the user pastes their token or after a device-code exchange.
+ * Map exchange response to OmniRoute connection fields.
+ * The Windsurf Connect response uses camelCase JSON:
+ * windsurfApiKey, apiServerUrl, devinWebappHost, devinApiUrl
*/
mapTokens: (tokens: {
+ windsurfApiKey?: string;
+ apiServerUrl?: string;
+ devinWebappHost?: string;
+ devinApiUrl?: string;
+ // Fallback import-token fields
accessToken?: string;
apiKey?: string;
refreshToken?: string;
expiresIn?: number;
email?: string;
authMethod?: string;
- firebaseToken?: string;
}) => {
- // Accept either `accessToken` (UI import flow) or `apiKey` (device-code result)
- const token = tokens.accessToken || tokens.apiKey || "";
- const isFirebaseToken = tokens.authMethod === "device-code" || Boolean(tokens.firebaseToken);
+ // PKCE flow: token is in windsurfApiKey
+ const token = tokens.windsurfApiKey || tokens.accessToken || tokens.apiKey || "";
return {
accessToken: token,
+ // Windsurf API keys are long-lived — no refresh token needed
refreshToken: tokens.refreshToken || null,
- expiresIn: tokens.expiresIn || (isFirebaseToken ? 3600 : 0),
+ expiresIn: tokens.expiresIn || 0,
email: tokens.email || null,
providerSpecificData: {
- authMethod: tokens.authMethod || "import",
- // If the original firebase ID token is separate from the API key, store it too
- firebaseToken: tokens.firebaseToken || null,
+ authMethod: tokens.authMethod || (tokens.windsurfApiKey ? "browser" : "import"),
+ apiServerUrl: tokens.apiServerUrl || null,
+ devinWebappHost: tokens.devinWebappHost || null,
+ devinApiUrl: tokens.devinApiUrl || null,
},
};
},
diff --git a/src/shared/components/OAuthModal.tsx b/src/shared/components/OAuthModal.tsx
index 07b36f73f5..8f021c54d4 100644
--- a/src/shared/components/OAuthModal.tsx
+++ b/src/shared/components/OAuthModal.tsx
@@ -9,6 +9,9 @@ import { useCopyToClipboard } from "@/shared/hooks/useCopyToClipboard";
const GOOGLE_OAUTH_PROVIDERS = new Set(["antigravity", "gemini-cli"]);
+/** Providers that use a local callback server on a random port (PKCE browser flow). */
+const PKCE_CALLBACK_SERVER_PROVIDERS = new Set(["codex", "windsurf", "devin-cli"]);
+
type OAuthModalProps = {
isOpen: boolean;
provider?: string;
@@ -41,6 +44,12 @@ export default function OAuthModal({
const [isDeviceCode, setIsDeviceCode] = useState(false);
const [deviceData, setDeviceData] = useState(null);
const [polling, setPolling] = useState(false);
+ // API-key paste mode: for providers that accept a token directly (windsurf, devin-cli)
+ const [showPasteToken, setShowPasteToken] = useState(false);
+ const [pasteToken, setPasteToken] = useState("");
+ const [savingToken, setSavingToken] = useState(false);
+
+ const supportsTokenPaste = provider === "windsurf" || provider === "devin-cli";
const popupRef = useRef(null);
const { copied, copy } = useCopyToClipboard();
const deviceVerificationUrl =
@@ -149,6 +158,42 @@ export default function OAuthModal({
[authData, provider, onSuccess, reauthConnection]
);
+ // Save a raw API token directly (windsurf / devin-cli import-token path)
+ const handleSaveToken = useCallback(async () => {
+ const token = pasteToken.trim();
+ if (!token || !provider) return;
+ setSavingToken(true);
+ setError(null);
+ try {
+ // POST to /exchange with a synthetic "import_token" payload.
+ // The windsurf provider's mapTokens() handles a bare accessToken/apiKey field.
+ const res = await fetch(`/api/oauth/${provider}/import-token`, {
+ method: "POST",
+ headers: { "Content-Type": "application/json" },
+ body: JSON.stringify({
+ token,
+ connectionId: reauthConnection?.id,
+ }),
+ });
+ const data = await res.json();
+ if (!res.ok) {
+ const errMsg =
+ typeof data.error === "object" && data.error !== null
+ ? ((data.error as Record<string, unknown>).message as string) ||
+ JSON.stringify(data.error)
+ : data.error || "Save failed";
+ throw new Error(errMsg);
+ }
+ setStep("success");
+ onSuccess?.();
+ } catch (err) {
+ // Show error inline inside the paste-token form (don't flip to error step)
+ setError(err.message);
+ } finally {
+ setSavingToken(false);
+ }
+ }, [pasteToken, provider, onSuccess, reauthConnection]);
+
// Poll for device code token
const startPolling = useCallback(
async (deviceCode, codeVerifier, interval, extraData) => {
@@ -273,13 +318,14 @@ export default function OAuthModal({
forceManual = true;
}
- // Codex: on localhost use callback server on port 1455,
- // on remote use standard auth code flow (callback server is unreachable)
- if (provider === "codex") {
- if (isLocalhost) {
- // Localhost: use callback server on port 1455 + polling
+ // PKCE callback server providers (Codex, Windsurf, Devin CLI):
+ // On localhost, spin up a local callback server and poll for the result.
+ // Codex uses a fixed port 1455; Windsurf/Devin CLI use a random OS-assigned port.
+ // On remote the server is unreachable — fall through to standard manual flow.
+ if (PKCE_CALLBACK_SERVER_PROVIDERS.has(provider)) {
+ if (isTrueLocalhost) {
try {
- const serverRes = await fetch(`/api/oauth/codex/start-callback-server`);
+ const serverRes = await fetch(`/api/oauth/${provider}/start-callback-server`);
const serverData = await serverRes.json();
if (!serverRes.ok) throw new Error(serverData.error);
@@ -297,7 +343,7 @@ export default function OAuthModal({
for (let i = 0; i < maxAttempts; i++) {
await new Promise((r) => setTimeout(r, 2000));
- const pollRes = await fetch(`/api/oauth/codex/poll-callback`, {
+ const pollRes = await fetch(`/api/oauth/${provider}/poll-callback`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ connectionId: reauthConnection?.id }),
@@ -318,10 +364,10 @@ export default function OAuthModal({
setPolling(false);
throw new Error("Authorization timeout");
- } catch (codexErr) {
+ } catch (pkceErr) {
console.warn(
- "Codex callback server failed, falling back to standard manual flow",
- codexErr
+ `${provider} callback server failed, falling back to manual flow`,
+ pkceErr
);
setPolling(false);
forceManual = true;
@@ -333,6 +379,8 @@ export default function OAuthModal({
// Authorization code flow
// Redirect URI strategy:
// - Codex/OpenAI: always port 1455 (registered in OAuth app)
+ // - Windsurf/Devin CLI (remote fallback): use localhost with OmniRoute port + /auth/callback
+ // (on true localhost the callback server handles it; this is only reached on remote)
// - Google OAuth providers (antigravity, gemini-cli): always localhost, regardless of
// where OmniRoute is hosted — Google only accepts pre-registered localhost URIs with
// the built-in credentials. Remote users must configure their own credentials.
@@ -341,6 +389,11 @@ export default function OAuthModal({
let redirectUri: string;
if (provider === "codex" || provider === "openai") {
redirectUri = "http://localhost:1455/auth/callback";
+ } else if (provider === "windsurf" || provider === "devin-cli") {
+ // Remote fallback: use OmniRoute's port with the /auth/callback path Windsurf expects.
+ // On true localhost this code is never reached (callback server handles the flow above).
+ const port = window.location.port || "20128";
+ redirectUri = `http://localhost:${port}/auth/callback`;
} else if (GOOGLE_OAUTH_PROVIDERS.has(provider)) {
// Google OAuth built-in credentials only accept localhost redirect URIs.
// Even in remote deployments we use localhost — user copies the callback URL manually.
@@ -618,148 +671,210 @@ export default function OAuthModal({
size="lg"
>
<div className="flex flex-col gap-4">
- {/* Waiting Step (Localhost - popup mode) */}
- {step === "waiting" && !isDeviceCode && (
- <div className="text-center py-6">
- <div className="size-16 mx-auto mb-4 rounded-full bg-primary/10 flex items-center justify-center">
- <span className="material-symbols-outlined text-3xl text-primary animate-spin">
- progress_activity
- </span>
+ {/* Paste-token tab toggle (Windsurf / Devin CLI only) */}
+ {supportsTokenPaste && step !== "success" && (
+ <div className="flex gap-2 border-b border-border pb-3">
+ <button
+ className={`text-sm px-3 py-1 rounded-t ${!showPasteToken ? "font-semibold border-b-2 border-primary text-primary" : "text-text-muted"}`}
+ onClick={() => setShowPasteToken(false)}
+ >
+ Browser Login
+ </button>
+ <button
+ className={`text-sm px-3 py-1 rounded-t ${showPasteToken ? "font-semibold border-b-2 border-primary text-primary" : "text-text-muted"}`}
+ onClick={() => setShowPasteToken(true)}
+ >
+ Paste API Key
+ </button>
+ </div>
+ )}
+
+ {/* Paste-token form (Windsurf / Devin CLI) */}
+ {supportsTokenPaste && showPasteToken && step !== "success" && (
+ <div className="flex flex-col gap-3">
+ <p className="text-sm text-text-muted">
+ {provider === "windsurf"
+ ? "Visit windsurf.com/show-auth-token, copy your Windsurf API key, and paste it below."
+ : "Provide your WINDSURF_API_KEY (obtained via `devin auth login` or windsurf.com/show-auth-token)."}
+ </p>
+ <Input
+ value={pasteToken}
+ onChange={(e) => setPasteToken(e.target.value)}
+ placeholder="ws-..."
+ type="password"
+ label="API Key / Token"
+ />
+ {error && <p className="text-sm text-red-500">{error}</p>}
+ <div className="flex gap-2">
+ <Button
+ onClick={handleSaveToken}
+ fullWidth
+ disabled={!pasteToken.trim() || savingToken}
+ >
+ {savingToken ? "Saving…" : "Save Connection"}
+ </Button>
+ <Button onClick={onClose} variant="ghost" fullWidth>
+ Cancel
+ </Button>
</div>
- <h3 className="text-lg font-semibold mb-2">{t("waiting")}</h3>
- <p className="text-sm text-text-muted mb-2">{t("completeAuthInPopup")}</p>
- <p className="text-xs text-text-muted mb-4 opacity-70">{t("popupClosedHint")}</p>
- <Button variant="ghost" onClick={() => setStep("input")}>
- {t("popupBlocked")}
- </Button>
</div>
)}
- {/* Device Code Flow - Waiting */}
- {step === "waiting" && isDeviceCode && deviceData && (
+ {/* OAuth flow steps — hidden when paste-token mode is active */}
+ {(!supportsTokenPaste || !showPasteToken) && (
<>
- <div className="text-center py-4">
- <p className="text-sm text-text-muted mb-4">{t("deviceCodeVisitUrl")}</p>
- <div className="bg-sidebar p-4 rounded-lg mb-4">
- <p className="text-xs text-text-muted mb-1">{t("deviceCodeVerificationUrl")}</p>
- <div className="flex items-center gap-2">
- <code className="flex-1 text-sm break-all">{deviceVerificationUrl}</code>
- <Button
- size="sm"
- variant="ghost"
- icon={copied === "verify_url" ? "check" : "content_copy"}
- onClick={() => copy(deviceVerificationUrl, "verify_url")}
- />
- </div>
- </div>
- <div className="bg-primary/10 p-4 rounded-lg">
- <p className="text-xs text-text-muted mb-1">{t("deviceCodeYourCode")}</p>
- <div className="flex items-center justify-center gap-2">
- <p className="text-2xl font-mono font-bold text-primary">
- {deviceData.user_code}
- </p>
- <Button
- size="sm"
- variant="ghost"
- icon={copied === "user_code" ? "check" : "content_copy"}
- onClick={() => copy(deviceData.user_code, "user_code")}
- />
+ {/* Waiting Step (Localhost - popup mode) */}
+ {step === "waiting" && !isDeviceCode && (
+ <div className="text-center py-6">
+ <div className="size-16 mx-auto mb-4 rounded-full bg-primary/10 flex items-center justify-center">
+ <span className="material-symbols-outlined text-3xl text-primary animate-spin">
+ progress_activity
+ </span>
</div>
- </div>
- </div>
- {polling && (
- <div className="flex items-center justify-center gap-2 text-sm text-text-muted">
- <span className="material-symbols-outlined animate-spin">progress_activity</span>
- {t("deviceCodeWaiting")}
+ <h3 className="text-lg font-semibold mb-2">{t("waiting")}</h3>
+ <p className="text-sm text-text-muted mb-2">{t("completeAuthInPopup")}</p>
+ <p className="text-xs text-text-muted mb-4 opacity-70">{t("popupClosedHint")}</p>
+ <Button variant="ghost" onClick={() => setStep("input")}>
+ {t("popupBlocked")}
+ </Button>
</div>
)}
- </>
- )}
- {/* Manual Input Step */}
- {step === "input" && !isDeviceCode && (
- <>
- <div className="space-y-4">
- {/* Remote/LAN server info for Google OAuth providers */}
- {!isTrueLocalhost && GOOGLE_OAUTH_PROVIDERS.has(provider) && (
- <div className="rounded-lg border border-amber-500/30 bg-amber-500/10 p-3 text-xs text-amber-200">
- <span className="material-symbols-outlined text-sm align-middle mr-1">
- warning
- </span>
- <strong>
- {t.rich("googleOAuthWarning", {
- code: (c) => <code className="font-mono">{c}</code>,
- a: (c) => (
- <a
- href="https://github.com/diegosouzapw/OmniRoute#oauth-on-a-remote-server"
- target="_blank"
- rel="noreferrer"
- className="underline"
- >
- {c}
- </a>
- ),
- })}
- </strong>
+ {/* Device Code Flow - Waiting */}
+ {step === "waiting" && isDeviceCode && deviceData && (
+ <>
+ <div className="text-center py-4">
+ <p className="text-sm text-text-muted mb-4">{t("deviceCodeVisitUrl")}</p>
+ <div className="bg-sidebar p-4 rounded-lg mb-4">
+ <p className="text-xs text-text-muted mb-1">{t("deviceCodeVerificationUrl")}</p>
+ <div className="flex items-center gap-2">
+ <code className="flex-1 text-sm break-all">{deviceVerificationUrl}</code>
+ <Button
+ size="sm"
+ variant="ghost"
+ icon={copied === "verify_url" ? "check" : "content_copy"}
+ onClick={() => copy(deviceVerificationUrl, "verify_url")}
+ />
+ </div>
+ </div>
+ <div className="bg-primary/10 p-4 rounded-lg">
+ <p className="text-xs text-text-muted mb-1">{t("deviceCodeYourCode")}</p>
+ <div className="flex items-center justify-center gap-2">
+ <p className="text-2xl font-mono font-bold text-primary">
+ {deviceData.user_code}
+ </p>
+ <Button
+ size="sm"
+ variant="ghost"
+ icon={copied === "user_code" ? "check" : "content_copy"}
+ onClick={() => copy(deviceData.user_code, "user_code")}
+ />
+ </div>
+ </div>
</div>
- )}
- {/* Generic remote info for other providers */}
- {!isTrueLocalhost && !GOOGLE_OAUTH_PROVIDERS.has(provider) && (
- <div className="rounded-lg border border-blue-500/30 bg-blue-500/10 p-3 text-xs text-blue-200">
- <span className="material-symbols-outlined text-sm align-middle mr-1">info</span>
- {t("remoteAccessInfo")}
+ {polling && (
+ <div className="flex items-center justify-center gap-2 text-sm text-text-muted">
+ <span className="material-symbols-outlined animate-spin">
+ progress_activity
+ </span>
+ {t("deviceCodeWaiting")}
+ </div>
+ )}
+ </>
+ )}
+
+ {/* Manual Input Step */}
+ {step === "input" && !isDeviceCode && (
+ <>
+ <div className="space-y-4">
+ {/* Remote/LAN server info for Google OAuth providers */}
+ {!isTrueLocalhost && GOOGLE_OAUTH_PROVIDERS.has(provider) && (
+ <div className="rounded-lg border border-amber-500/30 bg-amber-500/10 p-3 text-xs text-amber-200">
+ <span className="material-symbols-outlined text-sm align-middle mr-1">
+ warning
+ </span>
+ <strong>
+ {t.rich("googleOAuthWarning", {
+ code: (c) => <code className="font-mono">{c}</code>,
+ a: (c) => (
+ <a
+ href="https://github.com/diegosouzapw/OmniRoute#oauth-on-a-remote-server"
+ target="_blank"
+ rel="noreferrer"
+ className="underline"
+ >
+ {c}
+ </a>
+ ),
+ })}
+ </strong>
+ </div>
+ )}
+ {/* Generic remote info for other providers */}
+ {!isTrueLocalhost && !GOOGLE_OAUTH_PROVIDERS.has(provider) && (
+ <div className="rounded-lg border border-blue-500/30 bg-blue-500/10 p-3 text-xs text-blue-200">
+ <span className="material-symbols-outlined text-sm align-middle mr-1">
+ info
+ </span>
+ {t("remoteAccessInfo")}
+ </div>
+ )}
+ <div>
+ <p className="text-sm font-medium mb-2">{t("step1OpenUrl")}</p>
+ <div className="flex gap-2">
+ <Input
+ value={authData?.authUrl || ""}
+ readOnly
+ className="flex-1 font-mono text-xs"
+ />
+ <Button
+ variant="secondary"
+ icon={copied === "auth_url" ? "check" : "content_copy"}
+ onClick={() => copy(authData?.authUrl, "auth_url")}
+ >
+ {t("copy")}
+ </Button>
+ </div>
+ </div>
+
+ <div>
+ <p className="text-sm font-medium mb-2">{t("step2PasteCallback")}</p>
+ <p className="text-xs text-text-muted mb-2">
+ {t.rich("step2Hint", {
+ code: (c) => <code className="font-mono">{c}</code>,
+ })}
+ </p>
+ <Input
+ value={callbackUrl}
+ onChange={(e) => setCallbackUrl(e.target.value)}
+ placeholder={
+ provider === "claude" || provider === "cline"
+ ? "code#state or /callback?code=..."
+ : placeholderUrl
+ }
+ className="font-mono text-xs"
+ />
+ </div>
</div>
- )}
- <div>
- <p className="text-sm font-medium mb-2">{t("step1OpenUrl")}</p>
+
<div className="flex gap-2">
- <Input
- value={authData?.authUrl || ""}
- readOnly
- className="flex-1 font-mono text-xs"
- />
<Button
- variant="secondary"
- icon={copied === "auth_url" ? "check" : "content_copy"}
- onClick={() => copy(authData?.authUrl, "auth_url")}
+ onClick={handleManualSubmit}
+ fullWidth
+ disabled={!callbackUrl || !authData}
>
- {t("copy")}
+ {t("connect")}
+ </Button>
+ <Button onClick={onClose} variant="ghost" fullWidth>
+ {t("cancel")}
</Button>
</div>
- </div>
-
- <div>
- <p className="text-sm font-medium mb-2">{t("step2PasteCallback")}</p>
- <p className="text-xs text-text-muted mb-2">
- {t.rich("step2Hint", {
- code: (c) => <code className="font-mono">{c}</code>,
- })}
- </p>
- <Input
- value={callbackUrl}
- onChange={(e) => setCallbackUrl(e.target.value)}
- placeholder={
- provider === "claude" || provider === "cline"
- ? "code#state or /callback?code=..."
- : placeholderUrl
- }
- className="font-mono text-xs"
- />
- </div>
- </div>
-
- <div className="flex gap-2">
- <Button onClick={handleManualSubmit} fullWidth disabled={!callbackUrl || !authData}>
- {t("connect")}
- </Button>
- <Button onClick={onClose} variant="ghost" fullWidth>
- {t("cancel")}
- </Button>
- </div>
+ </>
+ )}
</>
)}
- {/* Success Step */}
+ {/* Success Step — shown for both OAuth and paste-token flows */}
{step === "success" && (
<div className="text-center py-6">
<div className="size-16 mx-auto mb-4 rounded-full bg-green-100 dark:bg-green-900/30 flex items-center justify-center">
@@ -777,8 +892,8 @@ export default function OAuthModal({
</div>
)}
- {/* Error Step */}
- {step === "error" && (
+ {/* Error Step — OAuth errors only; paste-token errors shown inline */}
+ {step === "error" && !showPasteToken && (
<div className="text-center py-6">
<div className="size-16 mx-auto mb-4 rounded-full bg-red-100 dark:bg-red-900/30 flex items-center justify-center">
<span className="material-symbols-outlined text-3xl text-red-600">error</span>
diff --git a/src/shared/validation/schemas.ts b/src/shared/validation/schemas.ts
index ae5aeb25cb..aa02f1afd9 100644
--- a/src/shared/validation/schemas.ts
+++ b/src/shared/validation/schemas.ts
@@ -1264,6 +1264,12 @@ export const oauthPollSchema = z.object({
extraData: z.unknown().optional(),
});
+/** Import a raw API token (e.g. WINDSURF_API_KEY) without going through the browser OAuth flow. */
+export const oauthImportTokenSchema = z.object({
+ token: z.string().trim().min(1, "Token is required"),
+ connectionId: z.string().optional(),
+});
+
export const cursorImportSchema = z.object({
accessToken: z.string().trim().min(1, "Access token is required"),
machineId: z.string().trim().optional(),