/** * Codex MCP tool factory — compiles canonical tool definitions into the * descriptors and call results the MCP `tools/list` / `tools/call` surface * needs. * * Codex's MCP client never sees a rolebox-native tool object: it receives a * `{ name, description, inputSchema }` descriptor per tool and sends back * `arguments` for one call. This adapter owns that translation, including the * zod argument validation and the correction-text convention (a failed call is * an `isError` RESULT the model can self-correct from — never a thrown error * and never a protocol error). * * @module */ import { z } from "zod"; import type { IToolFactory } from "../../ports/tool-factory.ts"; import type { CanonicalToolDef, CanonicalToolContext } from "../../types.ts"; /** One entry of an MCP `tools/list` response. */ export interface McpToolDescriptor { name: string; description: string; inputSchema: Record; } /** One MCP content block: model-visible text or an inline base64 image. */ export type McpContentBlock = { type: "text"; text: string; } | { type: "image"; data: string; mimeType: string; }; /** One MCP `tools/call` result — content blocks plus an optional isError flag. */ export interface McpToolCallResult { content: McpContentBlock[]; isError?: boolean; } /** * IToolFactory adapter for the Codex MCP surface. * * `compileAll` both records the canonical definitions (so `call` can resolve a * tool by the server-visible name) and returns the `tools/list` descriptors. * `compile` alone returns an UNNAMED descriptor — MCP tool names come from the * registration key, which `compile` does not receive (same documented * limitation as PiToolFactory.compile). Prefer `compileAll`. */ export declare class CodexMcpToolFactory implements IToolFactory { #private; constructor(defs?: Record); compile(def: CanonicalToolDef): unknown; /** * Compile a record of named canonical tool definitions into MCP descriptors, * recording each definition for {@link call}. The record key is the * server-visible tool name. */ compileAll(defs: Record): Record; /** * Execute one `tools/call`. * * Returns an `isError` result — never throws — for an unknown tool name, a * zod validation failure (with a correction string naming the offending * fields), or a tool body that throws, so a bad call can never escape to the * protocol layer. */ call(name: string, args: unknown, context: CanonicalToolContext): Promise; } //# sourceMappingURL=tool-factory.d.ts.map