/** * Engine-backed `WorkflowEventFeedBackend` — the production backing * for `createWorkflowEventFeed` (see `workflow-event-feed.ts`). REST * SSE, the JSON-RPC WebSocket session, and the JSON-RPC stdio session * all consume the feed; this module is where the feed meets the * `Engine`'s durable state. * * **Single committed sequence authority.** Replay and live delivery * share the same source of truth — the unified * `replayWorkflowFeed` / `snapshotWorkflowFeedTail` / * `subscribeWorkflowFeedCommits` triple on `Engine`. The subscription * fires only AFTER the storage commit resolves, so an event in the live buffer * is already durable and scannable by `replayWorkflowFeed`. This is the * invariant the feed's atomic-handoff (buffer-then-snapshot-then-replay-then- * drain) relies on. * * The backend is intentionally stateless — it holds only the `Engine` * reference. Listener state lives on the engine and is cleaned up by * the caller's unsubscribe function. * * @module server/engine-event-feed-backend */ import type { RegistryAgnosticEngine } from '../core/engine.ts'; import { type WorkflowEventFeedBackend } from './workflow-event-feed.ts'; /** * Build the production `WorkflowEventFeedBackend`. Call once per * engine instance and share the returned backend across every * transport that needs a feed. Pass the result to `createWorkflowEventFeed()` * to build a `WorkflowEventFeed` for `HandlerOptions.workflowEventFeed`. * * Accepts `RegistryAgnosticEngine` — the same registry-erased engine type * `handleRequest()` and `ServeOptions.engine` accept — so a concretely * narrowed engine from `Engine.create({ workflows })` works here without a * call-site cast. * * @example * ```ts * import { Engine, MemoryStorage } from '@lostgradient/weft'; * import { * createEngineEventFeedBackend, * createWorkflowEventFeed, * } from '@lostgradient/weft/server/handler'; * * const engine = new Engine({ storage: new MemoryStorage() }); * const workflowEventFeed = createWorkflowEventFeed(createEngineEventFeedBackend(engine)); * void workflowEventFeed; * ``` */ export declare function createEngineEventFeedBackend(engine: RegistryAgnosticEngine): WorkflowEventFeedBackend;