import type { MessageSegment } from '../types/message.types'; import type { WireCommandOverride } from '../utils/slash-dispatch-utils'; import type { ChatAttachment } from '../utils/chat-attachment-markdown'; /** * Stream function signature. The optional `signal` is created fresh per * `streamMessage` call so the underlying fetch can be aborted cleanly when * the user clicks Stop. Without the signal, abort would only stop yielding * chunks at the iterator boundary while the upstream Anthropic request * continued running (and billing). * * `extraOptions` carries per-call extras (currently `commandOverride` for * the inline-card "Discuss" affordance per v6.1 §B.2.8). Kept generic so * future per-call wire fields don't bloat the signature. */ export interface StreamFnExtraOptions { commandOverride?: WireCommandOverride; /** Out-of-band signal for the post-approval / post-reject * server-driven turn. When set, the streamFn routes to * `/api/chat/agent/confirm-tool` instead of `/api/docs/chat` and * encodes the action on the request body. The server emits a * `decision_resolved` leading frame that the chat-shell uses to * flip the SOURCE approval card (different assistant message than * the one being streamed into), then — on approve + write tool — * pipes the auto-continuation Sonnet response as standard chat SSE * frames into a NEW assistant turn. The CLIENT does not orchestrate * the auto-continuation; it just renders frames. */ approvalAction?: { proposalId: string; action: 'approve' | 'reject'; }; /** Chat-attachment payload riding alongside the user's text — the * staged attachments produced by `useChatAttachments`. Server-side, * `runDocsChat` strips the embedded `/api/storage/view/chat-attachments/...` * markdown lines from the user's text and replaces them with * Anthropic image content blocks (raw signed URLs). * * Wire format: `storagePath` + `viewToken` only — NEVER a `url` * field. Server validates against `ChatAttachmentSchema` and rejects * malformed shapes. */ pendingAttachments?: ChatAttachment[]; } export type StreamFn = (message: string, signal?: AbortSignal, extra?: StreamFnExtraOptions) => AsyncGenerator; interface UseSSEOptions { useMock?: boolean; debugMode?: boolean; /** Custom stream function — when provided, bypasses the mock fallback */ streamFn?: StreamFn; } export declare function useSSE({ useMock, debugMode, streamFn }?: UseSSEOptions): { streamMessage: (message: string, extra?: StreamFnExtraOptions) => AsyncGenerator; isStreaming: boolean; error: string | null; abort: () => void; reset: () => void; }; export {}; //# sourceMappingURL=use-sse.d.ts.map