import { type Cause, Effect, Option } from 'effect'; import { type Request, type Response } from 'foldkit/devtools-protocol'; /** * A WebSocket client to the Foldkit Vite plugin's DevTools relay. * * Sends typed `Request`s and resolves with the matching `Response`. The * `sendRequest` Effect fails with `TimeoutException` when no response arrives * within the request timeout window, or with `Error` when no relay is * connected or the send throws. Either way, no pending entry leaks. * * The client manages its own connection lifecycle in a background fiber: * the initial connect is retried with exponential backoff, and any later * disconnect (e.g. when the user restarts the Vite dev server) reconnects * via the same loop. The MCP server can stay live across dev-server * restarts and even when no dev server has started yet — `sendRequest` * returns a clear "not connected" error in that window, and tools should * surface it to the agent so the user can start a dev server and retry. * * Pending response correlators live in a client-owned Ref, not on the * socket, so they survive reconnects: in-flight requests time out and * future requests succeed once the new socket is open. */ export type WebSocketClient = Readonly<{ sendRequest: (request: typeof Request.Type, maybeRuntimeId: Option.Option) => Effect.Effect; close: Effect.Effect; }>; /** * Construct a WebSocket client that maintains its connection to the Foldkit * Vite plugin's DevTools relay in the background. The Effect succeeds * immediately with a client whose connection state evolves over time. The * initial connect is retried with exponential backoff; later disconnects * reconnect via the same loop. `sendRequest` fails with a clear "not * connected" error while no relay is reachable. */ export declare const connectWebSocketClient: (url: string) => Effect.Effect; //# sourceMappingURL=webSocketClient.d.ts.map