/** * Processes Responses API output items into consolidated span data. * Extracts message content, reasoning (as events), tool calls, and dispatches * to tool extractors for tool span creation. */ import type { GalileoLogger } from '../../utils/galileo-logger'; import { Message } from '../../types/message.types'; export interface ProcessOutputItemsOptions { outputItems: unknown[]; logger: GalileoLogger; model?: string; originalInput?: unknown; tools?: Record[]; usage?: unknown; statusCode?: number; metadata?: Record; } /** * Convert raw Responses API input items to valid Message objects for LLM span logging. * * The Galileo ingestion API validates every element of `input` as a Message * ({ content: string, role: MessageRole }). Raw Responses API items like * `function_call` and `function_call_output` lack those fields and fail Zod validation. * * Mappings: * type "message" → { role, content } * type "function_call" → { role: "assistant", content: "", tool_calls: [...] } * type "function_call_output" → { role: "tool", content: String(output), tool_call_id } * anything else → { role: "user", content: JSON.stringify(item) } */ export declare function convertInputToMessages(originalInput: unknown): Message[]; /** * Process Responses API output items: consolidate message/reasoning, create tool spans, * and add the main LLM span. Returns the consolidated output for trace conclusion. */ export declare function processOutputItems(options: ProcessOutputItemsOptions): Record; /** * Process function_call and function_call_output items from the input. * Creates tool spans for completed tool executions from previous turns. * * This is called BEFORE processing output items to log tool executions * that were passed in the input (multi-turn conversations). */ export declare function processFunctionCallOutputs(inputItems: unknown[], logger: GalileoLogger): void; /** * Check if output items contain pending function calls (function_call without matching function_call_output). * If pending calls exist, trace should NOT be concluded yet (multi-turn conversation continues). */ export declare function hasPendingFunctionCalls(outputItems: unknown[]): boolean; /** * Check if a response is from the Responses API (has output array). */ export declare function isResponsesApiResponse(response: unknown): boolean;