import { LanguageModel, ModelMessage, Tool, UIMessageChunk } from 'ai'; /** Tool call captured from the stream; passed to onStepFinish so the consumer can patch assistant messages when the API omits tool calls (e.g. Azure Responses). */ export interface StepToolCall { toolCallId: string; toolName: string; input: object; } export interface CreateStreamCompletionParams { /** Full conversation history including the latest user message. Caller is responsible for appending it (existing session) or having it already in the list (new session). */ messages: ModelMessage[]; /** Prepended to messages as a system message so the model receives instructions. */ systemPrompt: string; tools: Record; abortSignal?: AbortSignal; maxSteps?: number; temperature?: number; /** Optional model override (e.g. for tests). When not provided, getLlmClient() is used. */ model?: LanguageModel; /** Assistant interface name forwarded to startUserAction for quota tracking (e.g. 'STUDIO-ASSISTANT', 'ANALYTICS-ASSISTANT'). */ interfaceName?: string; /** * Called after each step with only the new messages from this step (so consumer can persist/append without re-sending the full history). * stepToolCalls are from the stream so consumer can patch when API omits tool calls in response.messages. */ onStepFinish?: (args: { newMessages: ModelMessage[]; stepToolCalls: StepToolCall[]; }) => void | Promise; /** Called after each text delta with the new text. */ onTextDelta?: (text: string) => void; /** Called after each tool call with the tool call details. */ onToolCall?: (toolCall: StepToolCall) => void; /** Called after each step with the usage details (token counts). */ onStepUsage?: (usage?: { inputTokens: number; outputTokens: number; }) => void; /** Called after the stream finishes. */ onFinish?: () => void; /** Called if an error occurs. */ onError?: (error: Error) => void; } /** * Runs a multi-turn streaming chat completion: builds the request from messages + system prompt, * calls the AI SDK streamText, and reports progress via callbacks. Core calls startUserAction/endUserAction * and maps 429 to QuotaExceededError so the consumer can show "quota exceeded" without depending on core. */ export declare function createStreamCompletion(params: CreateStreamCompletionParams): Promise; export interface CreateChatUIMessageStreamParams { messages: ModelMessage[]; systemPrompt: string; tools: Record; abortSignal?: AbortSignal; maxSteps?: number; temperature?: number; model?: LanguageModel; /** Assistant interface name forwarded to startUserAction for quota tracking (e.g. 'STUDIO-ASSISTANT', 'ANALYTICS-ASSISTANT'). */ interfaceName?: string; onStepUsage?: (usage: { inputTokens: number; outputTokens: number; }) => void; } /** * Runs streamText and returns a UIMessage stream for useChat transports. * Shares quota tracking and streamText configuration with createStreamCompletion. */ export declare function createChatUIMessageStream(params: CreateChatUIMessageStreamParams): Promise>;