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
TypeScript a2aai-agentsai-gatewayanthropicclaudeclaude-codeclinecodexcopilotcursordeepseekfree-aigeminikimillm-gatewaymcpopenaiopenai-proxyqwentoken-saver
fix: allow multiple Codex accounts from same workspace (Team/Business)
diegosouzapwbc55911d0f0c
diff --git a/src/lib/db/providers.ts b/src/lib/db/providers.tsindex 3a7c173645..6400816003 100644--- a/src/lib/db/providers.ts+++ b/src/lib/db/providers.ts@@ -52,14 +52,25 @@ export async function createProviderConnection(data: any) {// For Codex, check for existing connection with same workspaceconst workspaceId = data.providerSpecificData?.workspaceId;if (data.provider === "codex" && workspaceId) {- // Check for existing connection with same provider + workspace ONLY- // Do NOT fall back to email check - this allows multiple workspaces per email+ // For Codex, check for existing connection with same workspace AND email+ // A single workspace can have multiple users (Team/Business plans)+ // We need both workspace + email uniqueness to allow multiple accountsexisting = db.prepare(- "SELECT * FROM provider_connections WHERE provider = ? AND auth_type = 'oauth' AND json_extract(provider_specific_data, '$.workspaceId') = ?"+ "SELECT * FROM provider_connections WHERE provider = ? AND auth_type = 'oauth' AND json_extract(provider_specific_data, '$.workspaceId') = ? AND email = ?")- .get(data.provider, workspaceId);- // For Codex with workspaceId, don't fall back to email check+ .get(data.provider, workspaceId, data.email);++ // If no match with workspace+email, also check workspace-only for backward compat+ // (old connections without email should still be updated, not duplicated)+ if (!existing) {+ existing = db+ .prepare(+ "SELECT * FROM provider_connections WHERE provider = ? AND auth_type = 'oauth' AND json_extract(provider_specific_data, '$.workspaceId') = ? AND (email IS NULL OR email = '')"+ )+ .get(data.provider, workspaceId);+ }+ // For Codex with workspaceId, don't fall back to email-only check// This allows creating new connections for different workspaces} else {// For other providers (or Codex without workspaceId), use email check