import { Logger } from "./logger.cjs"; import { AGUIEvent, AGUIFixture, AGUIFixtureMatch, AGUIMessage, AGUIReasoningEncryptedValueSubtype, AGUIRunAgentInput } from "./agui-types.cjs"; import * as http$1 from "node:http"; //#region src/agui-handler.d.ts /** * Extract the content of the last message with role "user" from the input. * Walks structured content arrays (e.g. `[{type:"text", text:"..."}, {type:"document", ...}]`) * and joins their text parts. Returns `""` when no user message is present or has no text. */ declare function extractLastUserMessage(input: AGUIRunAgentInput): string; /** * Return the absolute last message if it has role "tool", otherwise null. */ declare function getLastMessageIfToolResult(input: AGUIRunAgentInput): AGUIMessage | null; /** * Check whether an input matches a fixture's match criteria. * All specified criteria must pass (AND logic). */ declare function matchesFixture(input: AGUIRunAgentInput, match: AGUIFixtureMatch): boolean; /** * Find the first fixture whose match criteria pass for the given input. */ declare function findFixture(input: AGUIRunAgentInput, fixtures: AGUIFixture[]): AGUIFixture | null; interface AGUIBuildOpts { threadId?: string; runId?: string; parentRunId?: string; /** For tool call builder: include a result event */ result?: string; } /** * Build a complete text message response sequence. * [RUN_STARTED, TEXT_MESSAGE_START, TEXT_MESSAGE_CONTENT, TEXT_MESSAGE_END, RUN_FINISHED] */ declare function buildTextResponse(text: string, opts?: AGUIBuildOpts): AGUIEvent[]; /** * Build a text chunk response (single chunk, no start/end envelope). * [RUN_STARTED, TEXT_MESSAGE_CHUNK, RUN_FINISHED] */ declare function buildTextChunkResponse(text: string, opts?: AGUIBuildOpts): AGUIEvent[]; /** * Build a tool call response sequence. * [RUN_STARTED, TOOL_CALL_START, TOOL_CALL_ARGS, TOOL_CALL_END, (TOOL_CALL_RESULT)?, RUN_FINISHED] */ declare function buildToolCallResponse(toolName: string, args: string, opts?: AGUIBuildOpts): AGUIEvent[]; /** * Build a state snapshot response. * [RUN_STARTED, STATE_SNAPSHOT, RUN_FINISHED] */ declare function buildStateUpdate(snapshot: unknown, opts?: AGUIBuildOpts): AGUIEvent[]; /** * Build a state delta response (JSON Patch). * [RUN_STARTED, STATE_DELTA, RUN_FINISHED] */ declare function buildStateDelta(patches: unknown[], opts?: AGUIBuildOpts): AGUIEvent[]; /** * Build a messages snapshot response. * [RUN_STARTED, MESSAGES_SNAPSHOT, RUN_FINISHED] */ declare function buildMessagesSnapshot(messages: AGUIMessage[], opts?: AGUIBuildOpts): AGUIEvent[]; /** * Build a reasoning response sequence. * [RUN_STARTED, REASONING_START, REASONING_MESSAGE_START, REASONING_MESSAGE_CONTENT, * REASONING_MESSAGE_END, REASONING_END, RUN_FINISHED] */ declare function buildReasoningResponse(text: string, opts?: AGUIBuildOpts): AGUIEvent[]; /** * Build an activity snapshot response. * [RUN_STARTED, ACTIVITY_SNAPSHOT, RUN_FINISHED] */ declare function buildActivityResponse(messageId: string, activityType: string, content: Record, opts?: AGUIBuildOpts): AGUIEvent[]; /** * Build an error response. * [RUN_STARTED, RUN_ERROR] (no RUN_FINISHED — the run errored) */ declare function buildErrorResponse(message: string, code?: string, opts?: AGUIBuildOpts): AGUIEvent[]; /** * Build a step-wrapped text response. * [RUN_STARTED, STEP_STARTED, TEXT_MESSAGE_START, TEXT_MESSAGE_CONTENT, * TEXT_MESSAGE_END, STEP_FINISHED, RUN_FINISHED] */ declare function buildStepWithText(stepName: string, text: string, opts?: AGUIBuildOpts): AGUIEvent[]; /** * Combine multiple builder outputs into a single run. * Strips RUN_STARTED/RUN_FINISHED from each input, wraps all inner events * in one RUN_STARTED...RUN_FINISHED pair. */ declare function buildCompositeResponse(builderOutputs: AGUIEvent[][], opts?: AGUIBuildOpts): AGUIEvent[]; /** * Build an activity delta response (JSON Patch on an activity). * [RUN_STARTED, ACTIVITY_DELTA, RUN_FINISHED] */ declare function buildActivityDelta(messageId: string, activityType: string, patch: unknown[], opts?: AGUIBuildOpts): AGUIEvent[]; /** * Build a tool call chunk response (single chunk, no start/end envelope). * [RUN_STARTED, TOOL_CALL_CHUNK, RUN_FINISHED] */ declare function buildToolCallChunk(delta: string, opts?: AGUIBuildOpts & { toolCallId?: string; toolCallName?: string; parentMessageId?: string; }): AGUIEvent[]; /** * Build a raw event response. * [RUN_STARTED, RAW, RUN_FINISHED] */ declare function buildRawEvent(event: unknown, source?: string, opts?: AGUIBuildOpts): AGUIEvent[]; /** * Build a custom event response. * [RUN_STARTED, CUSTOM, RUN_FINISHED] */ declare function buildCustomEvent(name: string, value: unknown, opts?: AGUIBuildOpts): AGUIEvent[]; /** * Build a reasoning message chunk response (single chunk, no start/end envelope). * [RUN_STARTED, REASONING_MESSAGE_CHUNK, RUN_FINISHED] */ declare function buildReasoningChunk(delta: string, opts?: AGUIBuildOpts & { messageId?: string; }): AGUIEvent[]; /** * Build a reasoning encrypted value event response. * [RUN_STARTED, REASONING_ENCRYPTED_VALUE, RUN_FINISHED] */ declare function buildReasoningEncryptedValue(subtype: AGUIReasoningEncryptedValueSubtype, entityId: string, encryptedValue: string, opts?: AGUIBuildOpts): AGUIEvent[]; /** * Write AG-UI events as an SSE stream to an HTTP response. * Sets appropriate headers, serializes each event as `data: {...}\n\n`, * and optionally delays between events. */ declare function writeAGUIEventStream(res: http$1.ServerResponse, events: AGUIEvent[], opts?: { delayMs?: number; signal?: AbortSignal; logger?: Logger; }): Promise; //# sourceMappingURL=agui-handler.d.ts.map //#endregion export { AGUIBuildOpts, buildActivityDelta, buildActivityResponse, buildCompositeResponse, buildCustomEvent, buildErrorResponse, buildMessagesSnapshot, buildRawEvent, buildReasoningChunk, buildReasoningEncryptedValue, buildReasoningResponse, buildStateDelta, buildStateUpdate, buildStepWithText, buildTextChunkResponse, buildTextResponse, buildToolCallChunk, buildToolCallResponse, extractLastUserMessage, findFixture, getLastMessageIfToolResult, matchesFixture, writeAGUIEventStream }; //# sourceMappingURL=agui-handler.d.cts.map