/** * AG-UI Protocol Adapter * * Two functions that bridge AG-UI events with MCP notifications: * * 1. proxyExternalAgent — connects to an external AG-UI agent, proxies events * back as MCP `ag-ui/event` notifications. * * 2. createAGUIOutputHandler — wraps Photon method execution so that yields * (stream, progress, emit) are translated to AG-UI events and broadcast * as MCP notifications. * * No npm dependencies — uses native fetch + manual SSE parsing. */ import { type RunAgentInput } from './types.js'; type BroadcastFn = (notification: object) => void; /** * Connect to an external AG-UI agent, proxy its SSE events as MCP notifications. * * POST RunAgentInput to agentUrl, parse SSE response, and for each AG-UI event * broadcast it as `{ jsonrpc: '2.0', method: 'ag-ui/event', params: event }`. * * Terminates when RUN_FINISHED or RUN_ERROR is received, or the stream ends. */ export declare function proxyExternalAgent(agentUrl: string, input: RunAgentInput, broadcast: BroadcastFn): Promise; /** * Create an output handler that translates Photon yield values to AG-UI events. * * Mapping: * - Stream chunks (strings) → TEXT_MESSAGE_START/CONTENT/END * - Progress yields → STEP_STARTED/STEP_FINISHED * - Emit yields (custom) → CUSTOM event * - Channel events (patches) → STATE_DELTA * * Returns { outputHandler, finish, error } — call finish() after successful * execution or error() on failure to emit the terminal event. */ export interface AGUIOutputHandlerOptions { /** * When the underlying method declares `@format a2ui`, set this to 'a2ui'. * The handler will map the final result into A2UI v0.9 messages and emit * each as a CUSTOM event named 'a2ui.message' before the STATE_SNAPSHOT. */ outputFormat?: string; } export declare function createAGUIOutputHandler(photonName: string, toolName: string, runId: string, broadcast: BroadcastFn, options?: AGUIOutputHandlerOptions): { outputHandler: (yieldValue: any) => void; finish: (result?: unknown) => void; error: (message: string, classification?: { code?: string; retryable?: boolean; }) => void; }; export {}; //# sourceMappingURL=adapter.d.ts.map