/** * Anthropic Messages codec. Pure request/response translation between the * Anthropic Messages wire and the gateway's OpenAI Chat Completions core. * Streaming translation lives in `anthropic-stream.ts`; HTTP handling lives * in `anthropic.ts`. */ import type { OpenAiChatResponse } from "../providers/protocol.js"; import type { AnthropicRequest } from "./anthropic-wire.js"; import type { ExecutedSearch, ServerToolLoopEvent } from "./server-tool-loop.js"; export type { AnthropicRequest } from "./anthropic-wire.js"; /** * Whether an Anthropic tool is *server-executed* (run by Anthropic's backend, * e.g. `web_search_20250305` / `code_execution_*`). Nothing behind this gateway * can execute those, so advertising them to the upstream model would only produce * calls nobody answers. Everything else — plain client tools (no `type` / * `custom`) and Anthropic-defined client tools (`bash_*`, `text_editor_*`, * `computer_*`), all of which the caller executes via ordinary `tool_use` * blocks — is projected through. */ export declare function isAnthropicServerTool(tool: { type?: string; }): boolean; /** A server web search tool declaration (`web_search_20250305` et al.) — the * one server tool the gateway can honor via its own web-search executor. */ export declare function isAnthropicWebSearchTool(tool: { type?: string; }): boolean; /** The name the gateway-executed web search tool is projected under chat-side. */ export declare const WEB_SEARCH_TOOL_NAME = "web_search"; /** Options gating server-executed tool projection (on iff an executor exists). */ export type AnthropicTranslationOptions = { serverTools?: boolean; }; type OpenAiResponse = OpenAiChatResponse; export declare function thinkingValidationError(body: AnthropicRequest): string | undefined; /** * Translate an Anthropic Messages request to an OpenAI Chat Completions body. * The upstream model is always the backend's own model (Claude Code sends a * `claude-*` id the local server would not recognise); the requested id is * only echoed back in the response. */ export declare function anthropicToChat(body: AnthropicRequest, backendModel: string | undefined, options?: AnthropicTranslationOptions): Record; export declare function mapStopReason(finishReason: string | null | undefined): string; export declare function chatToAnthropicMessage(openai: OpenAiResponse, model: string, searches?: readonly ExecutedSearch[], events?: readonly ServerToolLoopEvent[]): Record; export declare function countTokensEstimate(body: AnthropicRequest): number;