import type { IncomingMessage, ServerResponse } from 'node:http'; export type LocalAgentSseRequest = Pick; export type LocalAgentSseResponse = Pick; export type LocalAgentSseReader = { read: () => Promise<{ done: boolean; value?: Uint8Array; }>; cancel: () => Promise; releaseLock: () => void; }; /** Compatibility names retained for existing OpenClaw and Hermes callers. */ export type OpenClawStreamRequest = LocalAgentSseRequest; export type OpenClawStreamResponse = LocalAgentSseResponse; export type OpenClawStreamReader = LocalAgentSseReader; export declare function writeLocalAgentSseChunk(res: LocalAgentSseResponse, chunk: Uint8Array): Promise; export type LocalAgentSseFrameAction = { /** Forward this frame byte-for-byte to the downstream response. */ forward: boolean; /** Stop at this semantic frame and intentionally drop every later byte. */ terminal?: boolean; }; export type LocalAgentSseFrame = { event: Record | null; frame: Uint8Array; separator: Uint8Array; }; export type LocalAgentSseStreamResult = { terminal: boolean; clientGone: boolean; }; /** * Canonical local-agent SSE pump. It owns byte-safe frame splitting, split * separators, malformed/oversized frames, backpressure, cancellation, and * terminal truncation. Integrations customize only semantic frame policy. */ export declare function pipeLocalAgentSseStream(req: LocalAgentSseRequest, res: LocalAgentSseResponse, reader: LocalAgentSseReader, options?: { onFrame?: (frame: LocalAgentSseFrame) => LocalAgentSseFrameAction | Promise; endResponseOnTerminal?: boolean; }): Promise; export type DurableLocalAgentTurn = { text: string; finalEvent: Record; errorEvent?: Record; }; export type DurableLocalAgentTurnCommitResult = { ok: true; finalEvent: Record; } | { ok: false; errorEvent: Record; }; /** * One lifecycle owner for local-agent streams whose terminal acknowledgement * depends on a durable commit. Deltas pass through immediately. Error/final * frames are held, the commit hook is awaited, and only then is the terminal * outcome released. A commit failure emits its replacement error and never a * final acknowledgement. */ export declare function pipeDurableLocalAgentTurnSseStream(req: LocalAgentSseRequest, res: LocalAgentSseResponse, reader: LocalAgentSseReader, commit: (turn: DurableLocalAgentTurn) => Promise): Promise; export declare function writeLocalAgentSseEvent(res: LocalAgentSseResponse, event: Record): Promise; export declare function pipeOpenClawStream(req: OpenClawStreamRequest, res: OpenClawStreamResponse, reader: OpenClawStreamReader): Promise; /** Compatibility binding retained while existing callers migrate names. */ export declare const writeOpenClawStreamChunk: typeof writeLocalAgentSseChunk; //# sourceMappingURL=local-agent-sse.d.ts.map