import { type ListActionsHost } from './list-actions.js'; import type { LapActionsResponse, LapDrainMeta, LapMessageResponse, MessageAnnotations } from '../../protocol.js'; export type SendMessageArgs = { msg: { type: string; [k: string]: unknown; }; reason?: string; /** See LapMessageRequest['waitFor']. Default: 'drained'. */ waitFor?: 'drained' | 'idle' | 'none'; /** See LapMessageRequest['drainQuietMs']. Default: 100ms. */ drainQuietMs?: number; /** See LapMessageRequest['timeoutMs']. Default: 5000ms. */ timeoutMs?: number; /** See LapMessageRequest['includeState']. Default: false. */ includeState?: boolean; }; export type SendMessageHost = ListActionsHost & { getState(): unknown; send(msg: unknown): void; flush(): void; /** * Register a listener called after every update cycle commits — * backed by `AppHandle.subscribe`. Returns an unsubscribe function. * The drain loop uses this to detect message-queue quiescence: each * listener fire resets the quiet-window timer; no fires for * `drainQuietMs` means the loop has gone idle and async effects (if * any) have either completed or are persistent * (websocket/interval/storageWatch). */ subscribe(listener: () => void): () => void; getMsgAnnotations(): Record | null; /** * Snapshot and clear the drain-error buffer. The agent factory * installs persistent `window.error` / `unhandledrejection` * listeners that accumulate into this buffer; calling this at the * start of a drain discards stale errors from prior windows, and * calling it at the end yields just the errors that fired during * this drain. Optional — when omitted (e.g., Node test harness * without `window`), the drain envelope records an empty array. */ getAndClearDrainErrors?: () => LapDrainMeta['errors']; /** * Optional dispatch-policy accessor — when defined, returns the * server's configured `'strict' | 'lenient'` policy for payload * validation. Strict mode rejects fields not in the schema and * emits warnings for `'unknown'`-typed fields the agent provided * values for. Default is lenient (omit / undefined). */ getDispatchPolicy?: () => 'strict' | 'lenient'; /** Called when @requiresConfirm; caller stores a ConfirmEntry in state. */ proposeConfirm(entry: { id: string; variant: string; payload: unknown; intent: string; reason: string | null; proposedAt: number; status: 'pending'; }): void; }; export declare function handleSendMessage(host: SendMessageHost, args: SendMessageArgs): Promise; export type DispatchedEnvelope = Extract; export type { LapActionsResponse }; //# sourceMappingURL=send-message.d.ts.map