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

1.3 KB
Raw Blame
import { ZED_CONFIG } from "../constants/oauth";

/**
 * Zed IDE credential bridge — import_token flow only.
 *
 * Zed stores AI provider API keys (Anthropic, OpenAI, Google, …) in the OS
 * keychain. OmniRoute reads them via POST /api/providers/zed/import (keychain)
 * or POST /api/providers/zed/manual-import (Docker / paste fallback).
 *
 * There is no standard OAuth browser flow for "zed" itself.  Registering it
 * here with flowType "import_token" prevents getProvider("zed") from throwing
 * "Unknown provider: zed" when the OAuth capability endpoint is probed, and
 * lets generateAuthData() return a clean { supported: false, error } instead
 * of a 500.  The actual import UI lives at
 *   /dashboard/providers/zed  →  ZedImportCard component.
 */
export const zed = {
  config: ZED_CONFIG,
  flowType: "import_token" as const,

  validateImportToken(token: string): { valid: boolean; reason?: string } {
    const trimmed = (token ?? "").trim();
    if (!trimmed) return { valid: false, reason: "Token is empty" };
    if (trimmed.length < 8) return { valid: false, reason: "Token is too short" };
    return { valid: true };
  },

  mapTokens(tokens: { accessToken: string }) {
    return {
      accessToken: tokens.accessToken,
      refreshToken: null,
      expiresIn: null as number | null,
    };
  },
};