mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-11-22 16:55:29 +00:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1d7bc5fed7 | ||
|
|
763fdf3135 | ||
|
|
82314562e7 | ||
|
|
69e9bd81e9 | ||
|
|
26f927f798 | ||
|
|
2042dcf991 |
46
CHANGELOG.md
46
CHANGELOG.md
@@ -0,0 +1,46 @@
|
||||
# Changelog
|
||||
|
||||
## [2.3.8] - 2026-03-12
|
||||
|
||||
## [2.3.9] - 2026-03-12
|
||||
|
||||
### Added
|
||||
|
||||
- **/v1/completions**: New legacy OpenAI completions endpoint — accepts both `prompt` string and `messages` array, normalizes to chat format automatically
|
||||
- **EndpointPage**: Now shows all 3 OpenAI-compatible endpoint types: Chat Completions, Responses API, and Legacy Completions
|
||||
- **i18n**: Added `completionsLegacy/completionsLegacyDesc` to 30 language files
|
||||
|
||||
### Fixed
|
||||
|
||||
- **OAuthModal**: Fix `[object Object]` displayed on all OAuth connection errors — properly extract `.message` from error response objects in all 3 `throw new Error(data.error)` calls (exchange, device-code, authorize)
|
||||
- Affects Cline, Codex, GitHub, Qwen, Kiro, and all other OAuth providers
|
||||
|
||||
## [2.3.7] - 2026-03-12
|
||||
|
||||
### Fixed
|
||||
|
||||
- **Cline OAuth**: Add `decodeURIComponent` before base64 decode so URL-encoded auth codes from the callback URL are parsed correctly, fixing "invalid or expired authorization code" errors on remote (LAN IP) setups
|
||||
- **Cline OAuth**: `mapTokens` now populates `name = firstName + lastName || email` so Cline accounts show real user names instead of "Account #ID"
|
||||
- **OAuth account names**: All OAuth exchange flows (exchange, poll, poll-callback) now normalize `name = email` when name is missing, so every OAuth account shows its email as the display label in the Providers dashboard
|
||||
- **OAuth account names**: Removed sequential "Account N" fallback in `db/providers.ts` — accounts with no email/name now use a stable ID-based label via `getAccountDisplayName()` instead of a sequential number that changes when accounts are deleted
|
||||
|
||||
## [2.3.6] - 2026-03-12
|
||||
|
||||
### Fixed
|
||||
|
||||
- **Provider test batch**: Fixed Zod schema to accept `providerId: null` (frontend sends null for non-provider modes); was incorrectly returning "Invalid request" for all batch tests
|
||||
- **Provider test modal**: Fixed `[object Object]` display by normalizing API error objects to strings before rendering in `setTestResults` and `ProviderTestResultsView`
|
||||
- **i18n**: Added missing keys `cliTools.toolDescriptions.opencode`, `cliTools.toolDescriptions.kiro`, `cliTools.guides.opencode`, `cliTools.guides.kiro` to `en.json`
|
||||
- **i18n**: Synchronized 1111 missing keys across all 29 non-English language files using English values as fallbacks
|
||||
|
||||
## [2.3.5] - 2026-03-11
|
||||
|
||||
### Fixed
|
||||
|
||||
- **@swc/helpers**: Added permanent `postinstall` fix to copy `@swc/helpers` into the standalone app's `node_modules` — prevents MODULE_NOT_FOUND crash on global npm installs
|
||||
|
||||
## [2.3.4] - 2026-03-10
|
||||
|
||||
### Added
|
||||
|
||||
- Multiple provider integrations and dashboard improvements
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "omniroute",
|
||||
"version": "2.3.6",
|
||||
"version": "2.3.9",
|
||||
"description": "Smart AI Router with auto fallback — route to FREE & cheap models, zero downtime. Works with Cursor, Cline, Claude Desktop, Codex, and any OpenAI-compatible tool.",
|
||||
"type": "module",
|
||||
"bin": {
|
||||
|
||||
@@ -446,6 +446,27 @@ export default function APIPageClient({ machineId }) {
|
||||
copied={copied}
|
||||
baseUrl={currentEndpoint}
|
||||
/>
|
||||
|
||||
{/* Legacy Completions */}
|
||||
<EndpointSection
|
||||
icon="text_fields"
|
||||
iconColor="text-orange-500"
|
||||
iconBg="bg-orange-500/10"
|
||||
title={t("completionsLegacy") || "Completions (Legacy)"}
|
||||
path="/v1/completions"
|
||||
description={
|
||||
t("completionsLegacyDesc") ||
|
||||
"Legacy OpenAI text completions — accepts both prompt and messages format"
|
||||
}
|
||||
models={endpointData.chat}
|
||||
expanded={expandedEndpoint === "completions"}
|
||||
onToggle={() =>
|
||||
setExpandedEndpoint(expandedEndpoint === "completions" ? null : "completions")
|
||||
}
|
||||
copy={copy}
|
||||
copied={copied}
|
||||
baseUrl={currentEndpoint}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -226,6 +226,12 @@ export async function POST(
|
||||
exchangeTokens(provider, code, redirectUri, codeVerifier, state)
|
||||
);
|
||||
|
||||
// Normalize: if name is missing, use email or displayName as fallback so accounts
|
||||
// always show a real label (e.g. user@gmail.com) instead of "Account #abc123"
|
||||
if (!tokenData.name && (tokenData.email || tokenData.displayName)) {
|
||||
tokenData.name = tokenData.email || tokenData.displayName;
|
||||
}
|
||||
|
||||
// Upsert: update existing connection if same provider+email, else create new
|
||||
const expiresAt = tokenData.expiresIn
|
||||
? new Date(Date.now() + tokenData.expiresIn * 1000).toISOString()
|
||||
@@ -297,6 +303,11 @@ export async function POST(
|
||||
}
|
||||
|
||||
if (result.success) {
|
||||
// Normalize: if name is missing, use email as fallback display label
|
||||
if (!result.tokens.name && (result.tokens.email || result.tokens.displayName)) {
|
||||
result.tokens.name = result.tokens.email || result.tokens.displayName;
|
||||
}
|
||||
|
||||
// Upsert: update existing connection if same provider+email, else create new
|
||||
const expiresAt = result.tokens.expiresIn
|
||||
? new Date(Date.now() + result.tokens.expiresIn * 1000).toISOString()
|
||||
@@ -418,6 +429,11 @@ export async function POST(
|
||||
exchangeTokens(provider, params.code, redirectUri, codeVerifier, params.state)
|
||||
);
|
||||
|
||||
// Normalize: if name is missing, use email as fallback display label
|
||||
if (!tokenData.name && (tokenData.email || tokenData.displayName)) {
|
||||
tokenData.name = tokenData.email || tokenData.displayName;
|
||||
}
|
||||
|
||||
// Upsert: update existing connection if same provider+email, else create new
|
||||
const expiresAt = tokenData.expiresIn
|
||||
? new Date(Date.now() + tokenData.expiresIn * 1000).toISOString()
|
||||
|
||||
97
src/app/api/v1/completions/route.ts
Normal file
97
src/app/api/v1/completions/route.ts
Normal file
@@ -0,0 +1,97 @@
|
||||
import { CORS_ORIGIN, CORS_HEADERS } from "@/shared/utils/cors";
|
||||
import { handleChat } from "@/sse/handlers/chat";
|
||||
import { initTranslators } from "@omniroute/open-sse/translator/index.ts";
|
||||
import { createInjectionGuard } from "@/middleware/promptInjectionGuard";
|
||||
|
||||
let initPromise = null;
|
||||
const injectionGuard = createInjectionGuard();
|
||||
|
||||
function ensureInitialized() {
|
||||
if (!initPromise) {
|
||||
initPromise = Promise.resolve(initTranslators()).then(() => {
|
||||
console.log("[SSE] Translators initialized");
|
||||
});
|
||||
}
|
||||
return initPromise;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle CORS preflight
|
||||
*/
|
||||
export async function OPTIONS() {
|
||||
return new Response(null, {
|
||||
headers: {
|
||||
"Access-Control-Allow-Origin": CORS_ORIGIN,
|
||||
"Access-Control-Allow-Methods": "GET, POST, OPTIONS",
|
||||
"Access-Control-Allow-Headers": "*",
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* POST /v1/completions — Legacy OpenAI Completions API
|
||||
*
|
||||
* Accepts both the modern chat format (messages[]) and the legacy
|
||||
* text-completions format (prompt string). Legacy requests are
|
||||
* automatically normalized to chat/completions format before routing.
|
||||
*
|
||||
* @see https://platform.openai.com/docs/api-reference/completions
|
||||
*/
|
||||
export async function POST(request: Request) {
|
||||
await ensureInitialized();
|
||||
|
||||
// Prompt injection guard
|
||||
try {
|
||||
const cloned = request.clone();
|
||||
const body = await cloned.json().catch(() => null);
|
||||
if (body) {
|
||||
const { blocked, result } = injectionGuard(body);
|
||||
if (blocked) {
|
||||
return new Response(
|
||||
JSON.stringify({
|
||||
error: {
|
||||
message: "Request blocked: potential prompt injection detected",
|
||||
type: "injection_detected",
|
||||
code: "SECURITY_001",
|
||||
detections: result.detections.length,
|
||||
},
|
||||
}),
|
||||
{ status: 400, headers: { ...CORS_HEADERS, "Content-Type": "application/json" } }
|
||||
);
|
||||
}
|
||||
|
||||
// Normalize legacy completions format: { prompt, model } → { messages, model }
|
||||
// If the body has `prompt` but no `messages`, convert to chat format.
|
||||
if (body.prompt !== undefined && !body.messages) {
|
||||
const prompt = Array.isArray(body.prompt) ? body.prompt.join("\n") : String(body.prompt);
|
||||
const normalized = {
|
||||
...body,
|
||||
messages: [{ role: "user", content: prompt }],
|
||||
};
|
||||
delete normalized.prompt;
|
||||
|
||||
const newRequest = new Request(request.url, {
|
||||
method: request.method,
|
||||
headers: request.headers,
|
||||
body: JSON.stringify(normalized),
|
||||
});
|
||||
return await handleChat(newRequest);
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("[SECURITY] Prompt injection guard failed:", error);
|
||||
return new Response(
|
||||
JSON.stringify({
|
||||
error: {
|
||||
message: "Security validation temporarily unavailable",
|
||||
type: "security_guard_unavailable",
|
||||
code: "SECURITY_002",
|
||||
},
|
||||
}),
|
||||
{ status: 503, headers: { ...CORS_HEADERS, "Content-Type": "application/json" } }
|
||||
);
|
||||
}
|
||||
|
||||
// Standard path: body already has messages[] (chat format)
|
||||
return await handleChat(request);
|
||||
}
|
||||
@@ -858,7 +858,9 @@
|
||||
"a2aQuickStartTitle": "البدء السريع",
|
||||
"a2aQuickStartStep1": "اكتشف بطاقة الوكيل على `/.well-known/agent.json`.",
|
||||
"a2aQuickStartStep2": "إرسال طلبات JSON - RPC إلى@@ PH0 @@ باستخدام @@PH1 @@ أو `message/stream`.",
|
||||
"a2aQuickStartStep3": "تتبع المهام والتحكم فيها باستخدام `tasks/get` و `tasks/cancel`."
|
||||
"a2aQuickStartStep3": "تتبع المهام والتحكم فيها باستخدام `tasks/get` و `tasks/cancel`.",
|
||||
"completionsLegacy": "Completions (Legacy)",
|
||||
"completionsLegacyDesc": "Legacy OpenAI text completions — accepts both prompt string and messages array format"
|
||||
},
|
||||
"mcpDashboard": {
|
||||
"loading": "جارٍ تحميل لوحة تحكم MCP...",
|
||||
|
||||
@@ -858,7 +858,9 @@
|
||||
"a2aQuickStartTitle": "Button text: start playing a game",
|
||||
"a2aQuickStartStep1": "Открийте картата на агента на @@PH0 @@.",
|
||||
"a2aQuickStartStep2": "Изпратете JSON - RPC заявки до@@ PH0 @@, като използвате @@ PH1 @@ или @@ PH2 @@.",
|
||||
"a2aQuickStartStep3": "Проследяване и контрол на задачите с помощта на @@ PH0 @@ и @@ PH1 @@."
|
||||
"a2aQuickStartStep3": "Проследяване и контрол на задачите с помощта на @@ PH0 @@ и @@ PH1 @@.",
|
||||
"completionsLegacy": "Completions (Legacy)",
|
||||
"completionsLegacyDesc": "Legacy OpenAI text completions — accepts both prompt string and messages array format"
|
||||
},
|
||||
"mcpDashboard": {
|
||||
"loading": "Зареждане на таблото за управление на MCP...",
|
||||
|
||||
@@ -858,7 +858,9 @@
|
||||
"a2aQuickStartTitle": "Hurtig start",
|
||||
"a2aQuickStartStep1": "Find agentkortet på`/.well-known/agent.json`.",
|
||||
"a2aQuickStartStep2": "Send JSON-RPC-anmodninger til`POST /a2a`vedhjælp af `message/send` eller `message/stream`.",
|
||||
"a2aQuickStartStep3": "Spor og kontroller opgaver ved hjælp af `tasks/get` og `tasks/cancel`."
|
||||
"a2aQuickStartStep3": "Spor og kontroller opgaver ved hjælp af `tasks/get` og `tasks/cancel`.",
|
||||
"completionsLegacy": "Completions (Legacy)",
|
||||
"completionsLegacyDesc": "Legacy OpenAI text completions — accepts both prompt string and messages array format"
|
||||
},
|
||||
"mcpDashboard": {
|
||||
"loading": "Indlæser MCP-dashboard...",
|
||||
|
||||
@@ -858,7 +858,9 @@
|
||||
"a2aQuickStartTitle": "A2A-Schnellstart",
|
||||
"a2aQuickStartStep1": "Entdecken Sie die Agentenkarte unter `/.well-known/agent.json`.",
|
||||
"a2aQuickStartStep2": "Senden Sie JSON-RPC-Anfragen an `POST /a2a` mit `message/send` oder `message/stream`.",
|
||||
"a2aQuickStartStep3": "Verfolgen und steuern Sie Aufgaben mit `tasks/get` und `tasks/cancel`."
|
||||
"a2aQuickStartStep3": "Verfolgen und steuern Sie Aufgaben mit `tasks/get` und `tasks/cancel`.",
|
||||
"completionsLegacy": "Completions (Legacy)",
|
||||
"completionsLegacyDesc": "Legacy OpenAI text completions — accepts both prompt string and messages array format"
|
||||
},
|
||||
"mcpDashboard": {
|
||||
"loading": "MCP-Dashboard wird geladen...",
|
||||
|
||||
@@ -858,7 +858,9 @@
|
||||
"a2aQuickStartTitle": "A2A Quick Start",
|
||||
"a2aQuickStartStep1": "Discover the agent card at `/.well-known/agent.json`.",
|
||||
"a2aQuickStartStep2": "Send JSON-RPC requests to `POST /a2a` using `message/send` or `message/stream`.",
|
||||
"a2aQuickStartStep3": "Track and control tasks using `tasks/get` and `tasks/cancel`."
|
||||
"a2aQuickStartStep3": "Track and control tasks using `tasks/get` and `tasks/cancel`.",
|
||||
"completionsLegacy": "Completions (Legacy)",
|
||||
"completionsLegacyDesc": "Legacy OpenAI text completions — accepts both prompt string and messages array format"
|
||||
},
|
||||
"endpoints": {
|
||||
"tabProxy": "Endpoint Proxy",
|
||||
|
||||
@@ -858,7 +858,9 @@
|
||||
"a2aQuickStartTitle": "Inicio rápido de A2A",
|
||||
"a2aQuickStartStep1": "Descubra la tarjeta de agente en `/.well-known/agent.json`.",
|
||||
"a2aQuickStartStep2": "Envíe solicitudes JSON-RPC a `POST /a2a` usando `message/send` o `message/stream`.",
|
||||
"a2aQuickStartStep3": "Realice un seguimiento y controle las tareas utilizando `tasks/get` y `tasks/cancel`."
|
||||
"a2aQuickStartStep3": "Realice un seguimiento y controle las tareas utilizando `tasks/get` y `tasks/cancel`.",
|
||||
"completionsLegacy": "Completions (Legacy)",
|
||||
"completionsLegacyDesc": "Legacy OpenAI text completions — accepts both prompt string and messages array format"
|
||||
},
|
||||
"mcpDashboard": {
|
||||
"loading": "Cargando el panel de MCP...",
|
||||
|
||||
@@ -858,7 +858,9 @@
|
||||
"a2aQuickStartTitle": "A2A Pikaopas",
|
||||
"a2aQuickStartStep1": "Tutustu agenttikorttiin osoitteessa `/.well-known/agent.json`.",
|
||||
"a2aQuickStartStep2": "Lähetä JSON-RPC-pyynnöt osoitteeseen `POST /a2a` käyttämällä `message/send` tai `message/stream`.",
|
||||
"a2aQuickStartStep3": "Seuraa ja ohjaa tehtäviä käyttämällä `tasks/get` ja `tasks/cancel`."
|
||||
"a2aQuickStartStep3": "Seuraa ja ohjaa tehtäviä käyttämällä `tasks/get` ja `tasks/cancel`.",
|
||||
"completionsLegacy": "Completions (Legacy)",
|
||||
"completionsLegacyDesc": "Legacy OpenAI text completions — accepts both prompt string and messages array format"
|
||||
},
|
||||
"mcpDashboard": {
|
||||
"loading": "Ladataan MCP-hallintapaneelia...",
|
||||
|
||||
@@ -858,7 +858,9 @@
|
||||
"a2aQuickStartTitle": "Démarrage rapide A2A",
|
||||
"a2aQuickStartStep1": "Découvrez la carte d'agent sur `/.well-known/agent.json`.",
|
||||
"a2aQuickStartStep2": "Envoyez des requêtes JSON-RPC à `POST /a2a` en utilisant `message/send` ou `message/stream`.",
|
||||
"a2aQuickStartStep3": "Suivez et contrôlez les tâches à l’aide de `tasks/get` et `tasks/cancel`."
|
||||
"a2aQuickStartStep3": "Suivez et contrôlez les tâches à l’aide de `tasks/get` et `tasks/cancel`.",
|
||||
"completionsLegacy": "Completions (Legacy)",
|
||||
"completionsLegacyDesc": "Legacy OpenAI text completions — accepts both prompt string and messages array format"
|
||||
},
|
||||
"mcpDashboard": {
|
||||
"loading": "Chargement du tableau de bord MCP...",
|
||||
|
||||
@@ -858,7 +858,9 @@
|
||||
"a2aQuickStartTitle": "A2A Quick Start",
|
||||
"a2aQuickStartStep1": "Discover the agent card at `/.well-known/agent.json`.",
|
||||
"a2aQuickStartStep2": "Send JSON-RPC requests to `POST /a2a` using `message/send` or `message/stream`.",
|
||||
"a2aQuickStartStep3": "Track and control tasks using `tasks/get` and `tasks/cancel`."
|
||||
"a2aQuickStartStep3": "Track and control tasks using `tasks/get` and `tasks/cancel`.",
|
||||
"completionsLegacy": "Completions (Legacy)",
|
||||
"completionsLegacyDesc": "Legacy OpenAI text completions — accepts both prompt string and messages array format"
|
||||
},
|
||||
"mcpDashboard": {
|
||||
"loading": "Loading MCP dashboard...",
|
||||
|
||||
@@ -858,7 +858,9 @@
|
||||
"a2aQuickStartTitle": "A2A Quick Start",
|
||||
"a2aQuickStartStep1": "Discover the agent card at `/.well-known/agent.json`.",
|
||||
"a2aQuickStartStep2": "Send JSON-RPC requests to `POST /a2a` using `message/send` or `message/stream`.",
|
||||
"a2aQuickStartStep3": "Kövesse nyomon és vezérelje a feladatokat a `tasks/get` és `tasks/cancel` használatával."
|
||||
"a2aQuickStartStep3": "Kövesse nyomon és vezérelje a feladatokat a `tasks/get` és `tasks/cancel` használatával.",
|
||||
"completionsLegacy": "Completions (Legacy)",
|
||||
"completionsLegacyDesc": "Legacy OpenAI text completions — accepts both prompt string and messages array format"
|
||||
},
|
||||
"mcpDashboard": {
|
||||
"loading": "Loading MCP dashboard...",
|
||||
|
||||
@@ -858,7 +858,9 @@
|
||||
"a2aQuickStartTitle": "A2A Quick Start",
|
||||
"a2aQuickStartStep1": "Discover the agent card at `/.well-known/agent.json`.",
|
||||
"a2aQuickStartStep2": "Send JSON-RPC requests to `POST /a2a` using `message/send` or `message/stream`.",
|
||||
"a2aQuickStartStep3": "Track and control tasks using `tasks/get` and `tasks/cancel`."
|
||||
"a2aQuickStartStep3": "Track and control tasks using `tasks/get` and `tasks/cancel`.",
|
||||
"completionsLegacy": "Completions (Legacy)",
|
||||
"completionsLegacyDesc": "Legacy OpenAI text completions — accepts both prompt string and messages array format"
|
||||
},
|
||||
"mcpDashboard": {
|
||||
"loading": "Loading MCP dashboard...",
|
||||
|
||||
@@ -858,7 +858,9 @@
|
||||
"a2aQuickStartTitle": "A2A Quick Start",
|
||||
"a2aQuickStartStep1": "Discover the agent card at `/.well-known/agent.json`.",
|
||||
"a2aQuickStartStep2": "Send JSON-RPC requests to `POST /a2a` using `message/send` or `message/stream`.",
|
||||
"a2aQuickStartStep3": "Track and control tasks using `tasks/get` and `tasks/cancel`."
|
||||
"a2aQuickStartStep3": "Track and control tasks using `tasks/get` and `tasks/cancel`.",
|
||||
"completionsLegacy": "Completions (Legacy)",
|
||||
"completionsLegacyDesc": "Legacy OpenAI text completions — accepts both prompt string and messages array format"
|
||||
},
|
||||
"mcpDashboard": {
|
||||
"loading": "Loading MCP dashboard...",
|
||||
|
||||
@@ -858,7 +858,9 @@
|
||||
"a2aQuickStartTitle": "A2A Quick Start",
|
||||
"a2aQuickStartStep1": "Discover the agent card at `/.well-known/agent.json`.",
|
||||
"a2aQuickStartStep2": "Send JSON-RPC requests to `POST /a2a` using `message/send` or `message/stream`.",
|
||||
"a2aQuickStartStep3": "Track and control tasks using `tasks/get` and `tasks/cancel`."
|
||||
"a2aQuickStartStep3": "Track and control tasks using `tasks/get` and `tasks/cancel`.",
|
||||
"completionsLegacy": "Completions (Legacy)",
|
||||
"completionsLegacyDesc": "Legacy OpenAI text completions — accepts both prompt string and messages array format"
|
||||
},
|
||||
"mcpDashboard": {
|
||||
"loading": "Loading MCP dashboard...",
|
||||
|
||||
@@ -858,7 +858,9 @@
|
||||
"a2aQuickStartTitle": "A2A Quick Start",
|
||||
"a2aQuickStartStep1": "Discover the agent card at `/.well-known/agent.json`.",
|
||||
"a2aQuickStartStep2": "Send JSON-RPC requests to `POST /a2a` using `message/send` or `message/stream`.",
|
||||
"a2aQuickStartStep3": "Track and control tasks using `tasks/get` and `tasks/cancel`."
|
||||
"a2aQuickStartStep3": "Track and control tasks using `tasks/get` and `tasks/cancel`.",
|
||||
"completionsLegacy": "Completions (Legacy)",
|
||||
"completionsLegacyDesc": "Legacy OpenAI text completions — accepts both prompt string and messages array format"
|
||||
},
|
||||
"mcpDashboard": {
|
||||
"loading": "Loading MCP dashboard...",
|
||||
|
||||
@@ -858,7 +858,9 @@
|
||||
"a2aQuickStartTitle": "A2A Quick Start",
|
||||
"a2aQuickStartStep1": "Discover the agent card at `/.well-known/agent.json`.",
|
||||
"a2aQuickStartStep2": "Send JSON-RPC requests to `POST /a2a` using `message/send` or `message/stream`.",
|
||||
"a2aQuickStartStep3": "Track and control tasks using `tasks/get` and `tasks/cancel`."
|
||||
"a2aQuickStartStep3": "Track and control tasks using `tasks/get` and `tasks/cancel`.",
|
||||
"completionsLegacy": "Completions (Legacy)",
|
||||
"completionsLegacyDesc": "Legacy OpenAI text completions — accepts both prompt string and messages array format"
|
||||
},
|
||||
"mcpDashboard": {
|
||||
"loading": "Loading MCP dashboard...",
|
||||
|
||||
@@ -858,7 +858,9 @@
|
||||
"a2aQuickStartTitle": "A2A Mula Pantas",
|
||||
"a2aQuickStartStep1": "Temui kad ejen di `/.well-known/agent.json`.",
|
||||
"a2aQuickStartStep2": "Hantar permintaan JSON-RPC ke `POST /a2a` menggunakan `message/send` atau `message/stream`.",
|
||||
"a2aQuickStartStep3": "Jejak dan kawal tugas menggunakan `tasks/get` dan `tasks/cancel`."
|
||||
"a2aQuickStartStep3": "Jejak dan kawal tugas menggunakan `tasks/get` dan `tasks/cancel`.",
|
||||
"completionsLegacy": "Completions (Legacy)",
|
||||
"completionsLegacyDesc": "Legacy OpenAI text completions — accepts both prompt string and messages array format"
|
||||
},
|
||||
"mcpDashboard": {
|
||||
"loading": "Loading MCP dashboard...",
|
||||
|
||||
@@ -858,7 +858,9 @@
|
||||
"a2aQuickStartTitle": "A2A Quick Start",
|
||||
"a2aQuickStartStep1": "Discover the agent card at `/.well-known/agent.json`.",
|
||||
"a2aQuickStartStep2": "Send JSON-RPC requests to `POST /a2a` using `message/send` or `message/stream`.",
|
||||
"a2aQuickStartStep3": "Track and control tasks using `tasks/get` and `tasks/cancel`."
|
||||
"a2aQuickStartStep3": "Track and control tasks using `tasks/get` and `tasks/cancel`.",
|
||||
"completionsLegacy": "Completions (Legacy)",
|
||||
"completionsLegacyDesc": "Legacy OpenAI text completions — accepts both prompt string and messages array format"
|
||||
},
|
||||
"mcpDashboard": {
|
||||
"loading": "Loading MCP dashboard...",
|
||||
|
||||
@@ -858,7 +858,9 @@
|
||||
"a2aQuickStartTitle": "A2A hurtigstart",
|
||||
"a2aQuickStartStep1": "Oppdag agentkortet på `/.well-known/agent.json`.",
|
||||
"a2aQuickStartStep2": "Send JSON-RPC-forespørsler til `POST /a2a` ved å bruke `message/send` eller `message/stream`.",
|
||||
"a2aQuickStartStep3": "Spor og kontroller oppgaver ved å bruke `tasks/get` og `tasks/cancel`."
|
||||
"a2aQuickStartStep3": "Spor og kontroller oppgaver ved å bruke `tasks/get` og `tasks/cancel`.",
|
||||
"completionsLegacy": "Completions (Legacy)",
|
||||
"completionsLegacyDesc": "Legacy OpenAI text completions — accepts both prompt string and messages array format"
|
||||
},
|
||||
"mcpDashboard": {
|
||||
"loading": "Laster inn MCP-dashbordet ...",
|
||||
|
||||
@@ -858,7 +858,9 @@
|
||||
"a2aQuickStartTitle": "A2A Quick Start",
|
||||
"a2aQuickStartStep1": "Discover the agent card at `/.well-known/agent.json`.",
|
||||
"a2aQuickStartStep2": "Send JSON-RPC requests to `POST /a2a` using `message/send` or `message/stream`.",
|
||||
"a2aQuickStartStep3": "Subaybayan at kontrolin ang mga gawain gamit ang `tasks/get` at `tasks/cancel`."
|
||||
"a2aQuickStartStep3": "Subaybayan at kontrolin ang mga gawain gamit ang `tasks/get` at `tasks/cancel`.",
|
||||
"completionsLegacy": "Completions (Legacy)",
|
||||
"completionsLegacyDesc": "Legacy OpenAI text completions — accepts both prompt string and messages array format"
|
||||
},
|
||||
"mcpDashboard": {
|
||||
"loading": "Nilo-load ang MCP dashboard...",
|
||||
|
||||
@@ -858,7 +858,9 @@
|
||||
"a2aQuickStartTitle": "A2A Quick Start",
|
||||
"a2aQuickStartStep1": "Discover the agent card at `/.well-known/agent.json`.",
|
||||
"a2aQuickStartStep2": "Send JSON-RPC requests to `POST /a2a` using `message/send` or `message/stream`.",
|
||||
"a2aQuickStartStep3": "Track and control tasks using `tasks/get` and `tasks/cancel`."
|
||||
"a2aQuickStartStep3": "Track and control tasks using `tasks/get` and `tasks/cancel`.",
|
||||
"completionsLegacy": "Completions (Legacy)",
|
||||
"completionsLegacyDesc": "Legacy OpenAI text completions — accepts both prompt string and messages array format"
|
||||
},
|
||||
"mcpDashboard": {
|
||||
"loading": "Loading MCP dashboard...",
|
||||
|
||||
@@ -858,7 +858,9 @@
|
||||
"a2aQuickStartTitle": "A2A Início rápido",
|
||||
"a2aQuickStartStep1": "Descubra o agent card em `/.well-known/agent.json`.",
|
||||
"a2aQuickStartStep2": "Envie requisições JSON-RPC para `POST /a2a` usando `message/send` ou `message/stream`.",
|
||||
"a2aQuickStartStep3": "Acompanhe e controle tarefas com `tasks/get` e `tasks/cancel`."
|
||||
"a2aQuickStartStep3": "Acompanhe e controle tarefas com `tasks/get` e `tasks/cancel`.",
|
||||
"completionsLegacy": "Completions (Legacy)",
|
||||
"completionsLegacyDesc": "Legacy OpenAI text completions — accepts both prompt string and messages array format"
|
||||
},
|
||||
"mcpDashboard": {
|
||||
"loading": "Carregando painel MCP...",
|
||||
|
||||
@@ -858,7 +858,9 @@
|
||||
"a2aQuickStartTitle": "A2A Quick Start",
|
||||
"a2aQuickStartStep1": "Discover the agent card at `/.well-known/agent.json`.",
|
||||
"a2aQuickStartStep2": "Send JSON-RPC requests to `POST /a2a` using `message/send` or `message/stream`.",
|
||||
"a2aQuickStartStep3": "Track and control tasks using `tasks/get` and `tasks/cancel`."
|
||||
"a2aQuickStartStep3": "Track and control tasks using `tasks/get` and `tasks/cancel`.",
|
||||
"completionsLegacy": "Completions (Legacy)",
|
||||
"completionsLegacyDesc": "Legacy OpenAI text completions — accepts both prompt string and messages array format"
|
||||
},
|
||||
"endpoints": {
|
||||
"tabProxy": "Endpoint Proxy",
|
||||
|
||||
@@ -858,7 +858,9 @@
|
||||
"a2aQuickStartTitle": "A2A Quick Start",
|
||||
"a2aQuickStartStep1": "Discover the agent card at `/.well-known/agent.json`.",
|
||||
"a2aQuickStartStep2": "Send JSON-RPC requests to `POST /a2a` using `message/send` or `message/stream`.",
|
||||
"a2aQuickStartStep3": "Track and control tasks using `tasks/get` and `tasks/cancel`."
|
||||
"a2aQuickStartStep3": "Track and control tasks using `tasks/get` and `tasks/cancel`.",
|
||||
"completionsLegacy": "Completions (Legacy)",
|
||||
"completionsLegacyDesc": "Legacy OpenAI text completions — accepts both prompt string and messages array format"
|
||||
},
|
||||
"mcpDashboard": {
|
||||
"loading": "Loading MCP dashboard...",
|
||||
|
||||
@@ -858,7 +858,9 @@
|
||||
"a2aQuickStartTitle": "A2A Quick Start",
|
||||
"a2aQuickStartStep1": "Discover the agent card at `/.well-known/agent.json`.",
|
||||
"a2aQuickStartStep2": "Send JSON-RPC requests to `POST /a2a` using `message/send` or `message/stream`.",
|
||||
"a2aQuickStartStep3": "Track and control tasks using `tasks/get` and `tasks/cancel`."
|
||||
"a2aQuickStartStep3": "Track and control tasks using `tasks/get` and `tasks/cancel`.",
|
||||
"completionsLegacy": "Completions (Legacy)",
|
||||
"completionsLegacyDesc": "Legacy OpenAI text completions — accepts both prompt string and messages array format"
|
||||
},
|
||||
"mcpDashboard": {
|
||||
"loading": "Loading MCP dashboard...",
|
||||
|
||||
@@ -858,7 +858,9 @@
|
||||
"a2aQuickStartTitle": "A2A Quick Start",
|
||||
"a2aQuickStartStep1": "Discover the agent card at `/.well-known/agent.json`.",
|
||||
"a2aQuickStartStep2": "Send JSON-RPC requests to `POST /a2a` using `message/send` or `message/stream`.",
|
||||
"a2aQuickStartStep3": "Track and control tasks using `tasks/get` and `tasks/cancel`."
|
||||
"a2aQuickStartStep3": "Track and control tasks using `tasks/get` and `tasks/cancel`.",
|
||||
"completionsLegacy": "Completions (Legacy)",
|
||||
"completionsLegacyDesc": "Legacy OpenAI text completions — accepts both prompt string and messages array format"
|
||||
},
|
||||
"mcpDashboard": {
|
||||
"loading": "Loading MCP dashboard...",
|
||||
|
||||
@@ -858,7 +858,9 @@
|
||||
"a2aQuickStartTitle": "A2A Quick Start",
|
||||
"a2aQuickStartStep1": "Discover the agent card at `/.well-known/agent.json`.",
|
||||
"a2aQuickStartStep2": "Send JSON-RPC requests to `POST /a2a` using `message/send` or `message/stream`.",
|
||||
"a2aQuickStartStep3": "Track and control tasks using `tasks/get` and `tasks/cancel`."
|
||||
"a2aQuickStartStep3": "Track and control tasks using `tasks/get` and `tasks/cancel`.",
|
||||
"completionsLegacy": "Completions (Legacy)",
|
||||
"completionsLegacyDesc": "Legacy OpenAI text completions — accepts both prompt string and messages array format"
|
||||
},
|
||||
"mcpDashboard": {
|
||||
"loading": "Loading MCP dashboard...",
|
||||
|
||||
@@ -858,7 +858,9 @@
|
||||
"a2aQuickStartTitle": "A2A Quick Start",
|
||||
"a2aQuickStartStep1": "Discover the agent card at `/.well-known/agent.json`.",
|
||||
"a2aQuickStartStep2": "Send JSON-RPC requests to `POST /a2a` using `message/send` or `message/stream`.",
|
||||
"a2aQuickStartStep3": "Track and control tasks using `tasks/get` and `tasks/cancel`."
|
||||
"a2aQuickStartStep3": "Track and control tasks using `tasks/get` and `tasks/cancel`.",
|
||||
"completionsLegacy": "Completions (Legacy)",
|
||||
"completionsLegacyDesc": "Legacy OpenAI text completions — accepts both prompt string and messages array format"
|
||||
},
|
||||
"mcpDashboard": {
|
||||
"loading": "Loading MCP dashboard...",
|
||||
|
||||
@@ -858,7 +858,9 @@
|
||||
"a2aQuickStartTitle": "A2A Quick Start",
|
||||
"a2aQuickStartStep1": "Discover the agent card at `/.well-known/agent.json`.",
|
||||
"a2aQuickStartStep2": "Send JSON-RPC requests to `POST /a2a` using `message/send` or `message/stream`.",
|
||||
"a2aQuickStartStep3": "Track and control tasks using `tasks/get` and `tasks/cancel`."
|
||||
"a2aQuickStartStep3": "Track and control tasks using `tasks/get` and `tasks/cancel`.",
|
||||
"completionsLegacy": "Completions (Legacy)",
|
||||
"completionsLegacyDesc": "Legacy OpenAI text completions — accepts both prompt string and messages array format"
|
||||
},
|
||||
"mcpDashboard": {
|
||||
"loading": "Loading MCP dashboard...",
|
||||
|
||||
@@ -858,7 +858,9 @@
|
||||
"a2aQuickStartTitle": "A2A Quick Start",
|
||||
"a2aQuickStartStep1": "Discover the agent card at `/.well-known/agent.json`.",
|
||||
"a2aQuickStartStep2": "Send JSON-RPC requests to `POST /a2a` using `message/send` or `message/stream`.",
|
||||
"a2aQuickStartStep3": "Track and control tasks using `tasks/get` and `tasks/cancel`."
|
||||
"a2aQuickStartStep3": "Track and control tasks using `tasks/get` and `tasks/cancel`.",
|
||||
"completionsLegacy": "Completions (Legacy)",
|
||||
"completionsLegacyDesc": "Legacy OpenAI text completions — accepts both prompt string and messages array format"
|
||||
},
|
||||
"mcpDashboard": {
|
||||
"loading": "Loading MCP dashboard...",
|
||||
|
||||
@@ -858,7 +858,9 @@
|
||||
"a2aQuickStartTitle": "A2A Quick Start",
|
||||
"a2aQuickStartStep1": "Discover the agent card at `/.well-known/agent.json`.",
|
||||
"a2aQuickStartStep2": "Send JSON-RPC requests to `POST /a2a` using `message/send` or `message/stream`.",
|
||||
"a2aQuickStartStep3": "Track and control tasks using `tasks/get` and `tasks/cancel`."
|
||||
"a2aQuickStartStep3": "Track and control tasks using `tasks/get` and `tasks/cancel`.",
|
||||
"completionsLegacy": "Completions (Legacy)",
|
||||
"completionsLegacyDesc": "Legacy OpenAI text completions — accepts both prompt string and messages array format"
|
||||
},
|
||||
"mcpDashboard": {
|
||||
"loading": "Loading MCP dashboard...",
|
||||
|
||||
@@ -126,18 +126,16 @@ export async function createProviderConnection(data: JsonRecord) {
|
||||
return cleanNulls(merged);
|
||||
}
|
||||
|
||||
// Generate name
|
||||
// Generate name: prefer explicit name, then email, then a stable short-ID label.
|
||||
// Avoid sequential "Account N" — it reassigns when accounts are deleted/reordered.
|
||||
let connectionName = data.name || null;
|
||||
if (!connectionName && data.authType === "oauth") {
|
||||
if (data.email) {
|
||||
connectionName = data.email;
|
||||
} else {
|
||||
const count = db
|
||||
.prepare("SELECT COUNT(*) as cnt FROM provider_connections WHERE provider = ?")
|
||||
.get(data.provider) as JsonRecord | undefined;
|
||||
const cntValue = toNumberOrZero(toRecord(count).cnt);
|
||||
connectionName = `Account ${cntValue + 1}`;
|
||||
connectionName = data.email as string;
|
||||
} else if (data.displayName) {
|
||||
connectionName = data.displayName as string;
|
||||
}
|
||||
// Otherwise leave null — UI will fall back to getAccountDisplayName() → "Account #<id>"
|
||||
}
|
||||
|
||||
// Auto-increment priority
|
||||
|
||||
@@ -13,7 +13,14 @@ export const cline = {
|
||||
},
|
||||
exchangeToken: async (config, code, redirectUri) => {
|
||||
try {
|
||||
// Cline embeds tokens as base64-encoded JSON in the auth code.
|
||||
// The code may be URL-encoded when pasted from the callback URL.
|
||||
let base64 = code;
|
||||
try {
|
||||
base64 = decodeURIComponent(base64);
|
||||
} catch {
|
||||
/* already decoded */
|
||||
}
|
||||
const padding = 4 - (base64.length % 4);
|
||||
if (padding !== 4) {
|
||||
base64 += "=".repeat(padding);
|
||||
@@ -62,16 +69,23 @@ export const cline = {
|
||||
};
|
||||
}
|
||||
},
|
||||
mapTokens: (tokens) => ({
|
||||
accessToken: tokens.access_token,
|
||||
refreshToken: tokens.refresh_token,
|
||||
expiresIn: tokens.expires_at
|
||||
? Math.floor((new Date(tokens.expires_at).getTime() - Date.now()) / 1000)
|
||||
: 3600,
|
||||
email: tokens.email,
|
||||
providerSpecificData: {
|
||||
firstName: tokens.firstName,
|
||||
lastName: tokens.lastName,
|
||||
},
|
||||
}),
|
||||
mapTokens: (tokens) => {
|
||||
const firstName = tokens.firstName || "";
|
||||
const lastName = tokens.lastName || "";
|
||||
const fullName = [firstName, lastName].filter(Boolean).join(" ").trim();
|
||||
return {
|
||||
accessToken: tokens.access_token,
|
||||
refreshToken: tokens.refresh_token,
|
||||
expiresIn: tokens.expires_at
|
||||
? Math.floor((new Date(tokens.expires_at).getTime() - Date.now()) / 1000)
|
||||
: 3600,
|
||||
// Use full name if available, fallback to email so UI shows a real label
|
||||
name: fullName || tokens.email || null,
|
||||
email: tokens.email,
|
||||
providerSpecificData: {
|
||||
firstName: tokens.firstName,
|
||||
lastName: tokens.lastName,
|
||||
},
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
@@ -87,7 +87,13 @@ export default function OAuthModal({
|
||||
});
|
||||
|
||||
const data = await res.json();
|
||||
if (!res.ok) throw new Error(data.error);
|
||||
if (!res.ok) {
|
||||
const errMsg =
|
||||
typeof data.error === "object" && data.error !== null
|
||||
? (data.error as any).message || JSON.stringify(data.error)
|
||||
: data.error || "Exchange failed";
|
||||
throw new Error(errMsg);
|
||||
}
|
||||
|
||||
setStep("success");
|
||||
onSuccess?.();
|
||||
@@ -180,7 +186,13 @@ export default function OAuthModal({
|
||||
|
||||
const res = await fetch(`/api/oauth/${provider}/device-code`);
|
||||
const data = await res.json();
|
||||
if (!res.ok) throw new Error(data.error);
|
||||
if (!res.ok) {
|
||||
const errMsg =
|
||||
typeof data.error === "object" && data.error !== null
|
||||
? (data.error as any).message || JSON.stringify(data.error)
|
||||
: data.error || "Request failed";
|
||||
throw new Error(errMsg);
|
||||
}
|
||||
|
||||
setDeviceData(data);
|
||||
|
||||
@@ -281,7 +293,13 @@ export default function OAuthModal({
|
||||
`/api/oauth/${provider}/authorize?redirect_uri=${encodeURIComponent(redirectUri)}`
|
||||
);
|
||||
const data = await res.json();
|
||||
if (!res.ok) throw new Error(data.error);
|
||||
if (!res.ok) {
|
||||
const errMsg =
|
||||
typeof data.error === "object" && data.error !== null
|
||||
? (data.error as any).message || JSON.stringify(data.error)
|
||||
: data.error || "Authorization failed";
|
||||
throw new Error(errMsg);
|
||||
}
|
||||
|
||||
setAuthData({ ...data, redirectUri });
|
||||
|
||||
|
||||
Reference in New Issue
Block a user