import { Effect, Option, Schema as S, Scope } from 'effect'; import { type DevToolsStore } from './store.js'; type Hot = NonNullable; /** * Start the browser-side WebSocket bridge that exposes a Foldkit runtime's * DevToolsStore to an external MCP server (via the Vite plugin relay). * * Emits `EventConnected` on startup so the relay tracks this runtime. * Listens on the request channel for `RequestFrame`s targeted at this * connection's id and replies with the matching `ResponseFrame`. Emits * `EventDisconnected` on tab close or HMR module dispose so the relay can * remove this runtime from its connected set. * * `dispatch` enqueues a Message into the runtime's message queue; the bridge * uses it to fulfill `RequestDispatchMessage` after decoding the payload * against a JSON-canonical derivation of `maybeMessageSchema` (via * `Schema.toCodecJson`). The derivation reconstructs runtime values like * `Option`, `Date`, `Map`, and `Set` from their JSON-tagged shapes, so * application Message Schemas using stdlib types Just Work over dispatch * without author-side changes. When `maybeMessageSchema` is `None`, dispatch * requests are rejected with an informative error. * * The bridge also derives a JSON Schema document from `maybeMessageSchema` * once at boot (via `Schema.toJsonSchemaDocument`) to fulfill * `RequestGetMessageSchema`, so MCP clients can discover the exact Message * shapes the runtime accepts without reading the application source. A few * AST nodes (symbol-keyed structs, symbol-indexed records, tuples with * post-rest elements) cause `Schema.toJsonSchemaDocument` to throw; the * derivation is guarded so a failure logs a warning and the schema-discovery * tool returns `None` rather than crashing the bridge. * * Production-safe: callers must check `import.meta.hot` is defined before * invoking this. The function assumes a live HMR connection. */ export declare const startWebSocketBridge: (store: DevToolsStore, hot: Hot, dispatch: (message: unknown) => Effect.Effect, maybeMessageSchema: Option.Option>) => Effect.Effect; export {}; //# sourceMappingURL=webSocketBridge.d.ts.map