import type Anthropic from "@anthropic-ai/sdk"; import type { TraceMeta } from "@use-crux/core"; import type { AdapterResponse, CruxFinishReason, NativeAssistantTurn, NativeResponseMetadata } from "@use-crux/core/adapter"; /** Anthropic message shape returned by `messages.parse()`. */ export type AnthropicParsedMessage = Anthropic.Message & { readonly parsed_output?: unknown; }; /** Extract plain assistant text from Anthropic content blocks. */ export declare function extractText(message: Pick): string; /** * Normalize an Anthropic response message into Crux's adapter response shape. * * The message codec owns assistant text/tool-call extraction. This module adds * the response-level metadata that does not belong to transcript translation: * parsed structured output, token usage, finish reason, ids, and model ids. */ export declare function extractAdapterResponse(result: AnthropicParsedMessage): AdapterResponse; /** Read response metadata that is not owned by Anthropic transcript conversion. */ export declare function anthropicResponseMeta(result: AnthropicParsedMessage): NativeResponseMetadata; /** * Normalize an Anthropic `stop_reason` into the provider-neutral finish reason. * * `end_turn`/`stop_sequence` are normal completions, `max_tokens` is a length * cap, `tool_use` is a completed tool-call turn, and `refusal` is a model-side * refusal. Anything unmapped (e.g. `pause_turn`) becomes `unknown`; an absent * reason stays `undefined`. */ export declare function mapAnthropicStopReason(stopReason: string | null | undefined): CruxFinishReason | undefined; /** * Build stream-completion metadata for an Anthropic final message. * * Extends the response metadata with the completed tool calls read from the * final message so the shared stream path captures the same tool-call shape a * non-streaming `generate()` would have produced — no partial fragments. */ export declare function anthropicStreamCompletionMeta(result: AnthropicParsedMessage): TraceMeta; /** Prefer Anthropic parsed structured output over transcript text when present. */ export declare function anthropicResponseText(result: AnthropicParsedMessage, assistant: NativeAssistantTurn): string;