import { Event } from "@codingame/monaco-vscode-api/vscode/vs/base/common/event"; import { IDisposable } from "@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle"; import type { ProtocolMessage, AhpServerNotification, JsonRpcNotification, JsonRpcResponse, JsonRpcRequest } from "@codingame/monaco-vscode-api/vscode/vs/platform/agentHost/common/state/sessionProtocol"; /** * A bidirectional transport for protocol messages. Implementations handle * serialization, framing, and connection management. */ export interface IProtocolTransport extends IDisposable { /** Fires when a message is received from the remote end. */ readonly onMessage: Event; /** Fires when the transport connection closes. */ readonly onClose: Event; /** * Send a message to the remote end. * * Accepts: * - `ProtocolMessage` — fully-typed client↔server messages. * - `AhpServerNotification` — server→client notifications. * - `JsonRpcResponse` — dynamically-constructed success/error responses. */ send(message: ProtocolMessage | AhpServerNotification | JsonRpcNotification | JsonRpcResponse | JsonRpcRequest): void; } /** * A client-side transport that requires an explicit connection step * before messages can be exchanged. */ export interface IClientTransport extends IProtocolTransport { /** Establish the underlying connection (e.g. open a WebSocket). */ connect(): Promise; } /** Type guard for transports that require an explicit connection step. */ export declare function isClientTransport(transport: IProtocolTransport): transport is IClientTransport; /** * Server-side transport that accepts multiple client connections. * Each connected client gets its own {@link IProtocolTransport}. */ export interface IProtocolServer extends IDisposable { /** Fires when a new client connects. */ readonly onConnection: Event; /** The port or address the server is listening on. */ readonly address: string | undefined; }