/** * Memory watch stream — business logic extracted from `cleo memory watch --follow`. * * Provides an `AsyncIterable` of brain write events that the CLI handler * can consume and format as SSE-style stdout events. The non-follow (single * poll) path stays thin in the CLI handler via `dispatchFromCli`. * * @module memory/watch-stream * @epic T9833 * @task T10062 */ /** A single brain write event. */ export interface MemoryWatchEvent { [key: string]: unknown; created_at?: string; } /** Options for {@link streamMemoryWatchEvents}. */ export interface MemoryWatchStreamOptions { /** Resume cursor (created_at lower bound from a previous watch call). */ cursor?: string; /** Maximum events per poll (default: 10). */ limit?: number; /** Poll interval in milliseconds (default: 1 000). */ intervalMs?: number; /** * Raw dispatch function — matches `dispatchRaw` from the CLI adapter. * Injected to keep this module decoupled from the CLI layer. */ dispatchRaw: (gateway: 'mutate' | 'query', domain: string, operation: string, params: Record) => Promise<{ success: boolean; data?: unknown; error?: { message?: string; code?: string; }; }>; /** AbortSignal for stopping the stream cleanly. */ signal?: AbortSignal; } /** A yielded item from the watch stream. */ export type MemoryWatchYield = { kind: 'ping'; ts: string; } | { kind: 'events'; events: MemoryWatchEvent[]; nextCursor: string | null; } | { kind: 'error'; message: string; code: string; } | { kind: 'close'; ts: string; }; /** * Stream brain write events as an `AsyncIterable`. * * Yields a `ping` item immediately, then polls `memory.watch` on every * `intervalMs` tick. Yields `events` items (potentially empty) on each poll, * an `error` item on dispatch failure, and a `close` item when the signal * fires or the caller's `for await` loop breaks. * * The caller is responsible for process signal wiring and stdout emission. * * @param opts - Stream configuration */ export declare function streamMemoryWatchEvents(opts: MemoryWatchStreamOptions): AsyncIterable; //# sourceMappingURL=watch-stream.d.ts.map