/** * Provider-neutral protocol representation. * * Provider codecs decode into this representation before application logic * consumes the payload. Extensions are deliberately typed and namespaced: * provider-specific data must never be smuggled into a provider-neutral field. */ export type ExtensionField = Readonly<{ namespace: Namespace; value: Value; }>; export type Citation = Readonly<{ url: string; title?: string; startIndex?: number; endIndex?: number; extensions?: readonly ExtensionField[]; }>; export type AnthropicReasoningExtension = ExtensionField<"anthropic.reasoning", Readonly<{ index: number; phase?: "start" | "delta" | "signature" | "stop" | "block"; signature?: string; redacted?: boolean; }>>; export type GoogleReasoningExtension = ExtensionField<"google.reasoning", Readonly<{ index: number; thoughtSignature: string; }>>; export type ResponsesReasoningExtension = ExtensionField<"openai.responses.reasoning", Readonly<{ id?: string; summary?: unknown; content?: unknown; }>>; export type Reasoning = Readonly<{ text?: string; summary?: string; encryptedContent?: string; extensions?: readonly (AnthropicReasoningExtension | GoogleReasoningExtension | ResponsesReasoningExtension | ExtensionField)[]; }>; export type ToolCall = Readonly<{ id: string; name: string; arguments: unknown; execution: "client" | "server"; extensions?: readonly ExtensionField[]; }>; export type ToolCallAssemblyExtension = ExtensionField<"routekit.tool-call-assembly", Readonly<{ index?: number; providerIndex?: number; }>>; export type ToolResult = Readonly<{ toolCallId?: string; content: string; isError: boolean; citations: readonly Citation[]; extensions?: readonly ExtensionField[]; }>; export type ContentPart = Readonly<{ type: "text"; text: string; citations?: readonly Citation[]; }> | Readonly<{ type: "image"; url: string; mediaType?: string; }> | Readonly<{ type: "reasoning"; reasoning: Reasoning; }> | Readonly<{ type: "tool_call"; call: ToolCall; }> | Readonly<{ type: "tool_result"; result: ToolResult; }>; export type ConversationMessage = Readonly<{ role: "system" | "developer" | "user" | "assistant" | "tool"; content: readonly ContentPart[]; extensions?: readonly ExtensionField[]; }>; export type Conversation = Readonly<{ messages: readonly ConversationMessage[]; extensions?: readonly ExtensionField[]; }>; export type Usage = Readonly<{ inputTokens?: number; outputTokens?: number; totalTokens?: number; cachedInputTokens?: number; extensions?: readonly ExtensionField[]; }>; export type OpenAiUsageExtension = ExtensionField<"openai.chat.usage-details", Readonly<{ promptTokens?: Readonly>; completionTokens?: Readonly>; }>>; export declare function extensionValue(extensions: readonly ExtensionField[] | undefined, namespace: Namespace): Value | undefined; export declare function conversationFromOpenAiMessages(messages: readonly Readonly<{ role?: string; content?: unknown; tool_call_id?: string; }>[]): Conversation; export declare function conversationText(message: ConversationMessage): string;