/**
 * OwlCoda Native Request Builder
 *
 * Builds Anthropic Messages API requests from conversation state.
 */
import type { AnthropicMessage, AnthropicMessagesRequest, AnthropicToolDef, Conversation, ConversationTurn } from './types.js';
export interface RequestOptions {
    model: string;
    system: string;
    messages: AnthropicMessage[];
    maxTokens: number;
    temperature?: number;
    tools?: AnthropicToolDef[];
    stream?: boolean;
}
/** Build an Anthropic Messages API request from conversation state. */
export declare function buildRequest(conversation: Conversation, stream?: boolean): AnthropicMessagesRequest;
/** Build a request from explicit options (lower-level). */
export declare function buildRequestFromOptions(opts: RequestOptions): AnthropicMessagesRequest;
/**
 * Repair invalid tool call/result sequencing in persisted conversation history.
 *
 * Rules:
 * - assistant tool_use turns must be followed immediately by a user tool_result turn
 * - if that link is broken, strip the dangling tool_use blocks and keep any assistant text
 * - orphan tool_result user turns are dropped
 */
export declare function sanitizeConversationTurns(turns: ConversationTurn[]): ConversationTurn[];
/**
 * Prepare turns for sending to the provider. Runs the full storage-safe
 * sanitizer plus consecutive-same-role compaction. The compaction is
 * deliberately NOT in the storage path: synthetic test data and benign
 * inspection workflows can keep their literal turn count, and only the
 * provider request — where the API actually rejects consecutive-role
 * messages — pays the merge cost.
 */
export declare function prepareTurnsForRequest(turns: ConversationTurn[]): ConversationTurn[];
export interface ConversationRepairResult {
    turns: ConversationTurn[];
    repaired: boolean;
    warnings: string[];
}
/**
 * Validate conversation history and auto-repair any invalid tool_use/tool_result sequences.
 * Safe to call before every conversation turn — cheap when history is clean.
 */
export declare function validateAndRepairConversation(turns: ConversationTurn[]): ConversationRepairResult;
/** Create a user message with text content. */
export declare function userMessage(text: string): AnthropicMessage;
/** Create a tool result message. */
export declare function toolResultMessage(toolUseId: string, content: string, isError?: boolean): AnthropicMessage;
/** Build tool definitions from native tool metadata. */
export declare function buildToolDef(name: string, description: string, inputSchema: Record<string, unknown>): AnthropicToolDef;
