/** * Provider-specific transcript validation. * * Validates that every assistant message containing tool_calls has exactly * matching tool result messages, with no missing, duplicate, or orphaned IDs. * * Two separate protocols: * - Chat Completions: uses `tool_call_id` pairing * - Responses API: uses `call_id` pairing */ import type { Message, ToolResultMessage } from "../types.js"; export interface TranscriptValidationError { code: "INVALID_TOOL_TRANSCRIPT"; missingToolCallIds: string[]; duplicateToolCallIds: string[]; orphanToolResultIds: string[]; duplicateCallIds: string[]; provider: string; model: string; messageIndex: number; protocol: "chat-completions" | "responses"; } export interface TranscriptValidationSuccess { ok: true; } export type TranscriptValidationResult = TranscriptValidationSuccess | TranscriptValidationError; export declare function assertValidChatCompletionsPayload(payload: unknown, provider: string, model: string): void; export declare function assertValidResponsesPayload(payload: unknown, provider: string, model: string): void; /** * Validate a transcript for Chat Completions protocol. * For every assistant message with tool_calls, checks: * - Each tool call has a non-empty unique ID * - Exactly one tool result message responds to each ID * - No duplicate tool result messages * - No orphan tool result messages (result without a preceding tool call) * - All required tool results occur before the next user or assistant message * - Tool calls from different assistant turns are not merged * - A tool result appears in the uninterrupted span following its originating assistant */ export declare function validateChatCompletionsTranscript(messages: readonly unknown[], provider: string, model: string): TranscriptValidationResult; /** * Validate a transcript for Responses API protocol. * Uses function_call.call_id and function_call_output.call_id pairing. * Validates independently from Chat Completions - no protocol mixing. * * Each assistant's function calls form a span that must be resolved before * the next assistant or user message begins a new span. */ export declare function validateResponsesTranscript(messages: readonly unknown[], provider: string, model: string): TranscriptValidationResult; /** * Validate tool call/result span integrity in a raw agent message array. * Checks that every assistant message with tool_calls has all matching * tool result messages before the next non-tool-result message. * * This operates on the raw AgentMessage[] level (which includes toolResult * and non-LLM messages) before convertToLlm. */ export declare function validateToolSpanIntegrity(messages: Message[]): { valid: boolean; missingToolCallIds: string[]; orphanToolResultIds: string[]; }; /** * Classify an unresolved tool call after an interrupt or resume. */ export type UnresolvedToolCallClassification = "DURABLE_RESULT_AVAILABLE" | "DEFINITELY_NOT_EXECUTED" | "EXECUTION_OUTCOME_UNKNOWN"; /** * Classify the status of an unresolved tool call based on available state. * * @param toolCallId - The tool call ID to classify * @param pendingToolCalls - Set of tool call IDs still pending execution * @param persistedResults - Map of tool call IDs to their persisted result messages * @param executionLog - Optional set of tool call IDs confirmed to have started execution */ export declare function classifyUnresolvedToolCall(toolCallId: string, pendingToolCalls: Set, persistedResults: Map, executionLog?: Set): UnresolvedToolCallClassification; //# sourceMappingURL=transcript-validation.d.ts.map