/**
 * Anthropic tool_use adapter.
 *
 * Converts ToolDefinition[] into the format expected by Anthropic's
 * Messages API `tools` parameter (name, description, input_schema).
 */
/**
 * Transform tool definitions into Anthropic tool_use format.
 */
export function toAnthropic(definitions) {
    const toolLookup = new Map();
    const tools = definitions.map((def) => {
        toolLookup.set(def.name, def);
        return {
            name: def.name,
            description: def.description,
            input_schema: def.inputSchema,
        };
    });
    const handleToolUse = async (name, input) => {
        const def = toolLookup.get(name);
        if (!def) {
            return { content: JSON.stringify({ error: `Unknown tool: ${name}`, exitCode: 1 }) };
        }
        const result = await def.execute(input);
        return { content: JSON.stringify(result) };
    };
    return { tools, handleToolUse };
}
