diff --git a/client/src/lib/api.ts b/client/src/lib/api.ts index 592ab231..ac93133d 100644 --- a/client/src/lib/api.ts +++ b/client/src/lib/api.ts @@ -1703,27 +1703,31 @@ export const api = { * Coerces the CLI's JSON output (which may be an object) to an array. * @returns `{ mcp }` — {@link CodexMcpServer} items. */ - mcp: async () => { + mcp: async (): Promise<{ mcp: CodexMcpServer[] }> => { const res = await request<{ mcp: unknown }>("/codex-config/mcp"); - return { mcp: Array.isArray(res.mcp) ? res.mcp : [] }; + return { mcp: Array.isArray(res.mcp) ? (res.mcp as CodexMcpServer[]) : [] }; }, /** * GET /api/codex-config/plugins - installed plugins from the codex CLI. * Coerces the CLI's JSON output (which may be an object) to an array. * @returns `{ plugins }` — {@link CodexPlugin} items. */ - plugins: async () => { + plugins: async (): Promise<{ plugins: CodexPlugin[] }> => { const res = await request<{ plugins: unknown }>("/codex-config/plugins"); - return { plugins: Array.isArray(res.plugins) ? res.plugins : [] }; + return { plugins: Array.isArray(res.plugins) ? (res.plugins as CodexPlugin[]) : [] }; }, /** * GET /api/codex-config/marketplaces - registered marketplaces from the codex CLI. * Coerces the CLI's JSON output (which may be an object) to an array. * @returns `{ marketplaces }` — {@link CodexMarketplace} items. */ - marketplaces: async () => { + marketplaces: async (): Promise<{ marketplaces: CodexMarketplace[] }> => { const res = await request<{ marketplaces: unknown }>("/codex-config/marketplaces"); - return { marketplaces: Array.isArray(res.marketplaces) ? res.marketplaces : [] }; + return { + marketplaces: Array.isArray(res.marketplaces) + ? (res.marketplaces as CodexMarketplace[]) + : [], + }; }, /** * POST /api/codex-config/mcp/add - add an MCP server via the `codex` CLI. @@ -3006,15 +3010,15 @@ export interface CodexMarketplace { [key: string]: unknown; } -/** Arguments for POST /api/codex-config/mcp/add. */ -export interface CodexMcpAddArgs { - name: string; - url?: string; - bearerTokenEnvVar?: string; - command?: string; - args?: string[]; - env?: Record; -} +/** + * Arguments for POST /api/codex-config/mcp/add. A union, not one optional-heavy + * shape: `codex mcp add` takes either a URL or a command and rejects both or + * neither, and `env` is stdio-only. Modelling that here turns three of the + * server's `EBADARG` responses into compile errors. + */ +export type CodexMcpAddArgs = + | { name: string; url: string; bearerTokenEnvVar?: string } + | { name: string; command: string; args?: string[]; env?: Record }; /** Arguments for POST /api/codex-config/plugins/action. */ export interface CodexPluginActionArgs {