import { once } from "@sayknow-cli/utils"; import type { ModelManagerOptions } from "../model-manager"; import { fetchCodexModels } from "../utils/discovery/codex"; // --------------------------------------------------------------------------- // OpenAI code provider // --------------------------------------------------------------------------- export interface OpenAICodexModelManagerConfig { accessToken?: string; accountId?: string; clientVersion?: string; } export function openaiCodexModelManagerOptions( config: OpenAICodexModelManagerConfig = {}, ): ModelManagerOptions<"openai-codex-responses"> { const { accessToken, accountId, clientVersion } = config; return { providerId: "openai-codex", ...(accessToken ? { fetchDynamicModels: async () => { const result = await fetchCodexModels({ accessToken, accountId, clientVersion }); return result?.models ?? null; }, } : undefined), }; } // --------------------------------------------------------------------------- // Cursor // --------------------------------------------------------------------------- export interface CursorModelManagerConfig { apiKey?: string; baseUrl?: string; clientVersion?: string; } export function cursorModelManagerOptions(config: CursorModelManagerConfig = {}): ModelManagerOptions<"cursor-agent"> { const { apiKey, baseUrl, clientVersion } = config; return { providerId: "cursor", ...(apiKey ? { fetchDynamicModels: async () => { const { fetchCursorUsableModels } = await cursorDiscovery(); return fetchCursorUsableModels({ apiKey, baseUrl, clientVersion }); }, } : undefined), }; } const cursorDiscovery = once(() => import("../utils/discovery/cursor")); // --------------------------------------------------------------------------- // Zai // --------------------------------------------------------------------------- export interface ZaiModelManagerConfig {} export function zaiModelManagerOptions(_config: ZaiModelManagerConfig = {}): ModelManagerOptions<"anthropic-messages"> { return { providerId: "zai" }; } // --------------------------------------------------------------------------- // GLM ZCode (unofficial Z.AI OAuth) // --------------------------------------------------------------------------- export interface GlmZcodeModelManagerConfig {} export function glmZcodeModelManagerOptions( _config: GlmZcodeModelManagerConfig = {}, ): ModelManagerOptions<"anthropic-messages"> { return { providerId: "glm-zcode" }; }