import { Event } from "../../../base/common/event.js"; import { Disposable } from "../../../base/common/lifecycle.js"; import { ILogService } from "../../log/common/log.service.js"; import { AgentHostClientConnectionKind } from "./agentHostTelemetry.js"; import { AhpJsonlLogger } from "./ahpJsonlLogger.js"; import { ReconnectingTransport } from "./reconnectingTransport.js"; import type { AhpServerNotification, JsonRpcNotification, JsonRpcRequest, JsonRpcResponse, ProtocolMessage } from "./state/sessionProtocol.js"; import { type IProtocolTransport } from "./state/sessionTransport.js"; /** * A message relayed from a remote agent host through a tunnel managed * by the shared process. The shared process acts as a WebSocket proxy, * forwarding JSON messages bidirectionally via IPC. */ export interface IRelayMessage { readonly connectionId: string; readonly data: string; } /** * Minimal IPC surface needed by {@link RelayTransport} to pump frames * between the renderer and a shared-process-owned tunnel. Structural — * any main-service interface exposing these members satisfies it. */ export interface IRelayChannel { readonly onDidRelayMessage: Event; /** Fires with a connection ID while that relay receives part of a message. Local relays use {@link Event.None}. */ readonly onDidRelayActivity: Event; readonly onDidRelayClose: Event; relaySend(connectionId: string, message: string): Promise; } /** * Handle for a relay channel established by a {@link ReconnectingRelayTransport}. */ export interface IRelayConnectionHandle { /** Identifier of the freshly established relay channel. */ readonly connectionId: string; /** Releases a late-established relay after its logical client has closed. */ close?(): Promise; } /** * A protocol transport that relays messages through a shared-process * tunnel via IPC, instead of using a direct WebSocket connection. * * The shared process manages the actual underlying transport (WebSocket * over SSH, WSL stdio, etc.) and forwards messages bidirectionally * through this IPC channel. */ export declare class RelayTransport extends Disposable implements IProtocolTransport { protected _connectionId: string | undefined; private readonly _channel; private readonly _ahpLogger; protected readonly _logService: ILogService; protected readonly _logPrefix: string; readonly clientConnectionKind: AgentHostClientConnectionKind; private readonly _onMessage; readonly onMessage: Event; private readonly _onDidReceiveData; readonly onDidReceiveData: Event; private readonly _onClose; readonly onClose: Event; private _malformedFrames; private _closeFired; constructor(_connectionId: string | undefined, _channel: IRelayChannel, _ahpLogger: AhpJsonlLogger | undefined, _logService: ILogService, _logPrefix: string, clientConnectionKind: AgentHostClientConnectionKind); send(message: ProtocolMessage | AhpServerNotification | JsonRpcNotification | JsonRpcResponse | JsonRpcRequest): void; private _fireClose; } /** * A relay transport that establishes and owns its shared-process relay channel on connect. */ export declare class ReconnectingRelayTransport extends ReconnectingTransport { constructor(establish: () => Promise, channel: IRelayChannel, createAhpLogger: (connectionId: string) => AhpJsonlLogger | undefined, logService: ILogService, logPrefix: string, clientConnectionKind: AgentHostClientConnectionKind); }