import type { ConnectionDiagnosticObserver } from "./connectionDiagnostics.js"; /** Silent discovery has no usable token for a configured authentication provider. */ export declare class TunnelAuthenticationRequiredError extends Error { readonly authProvider: "github" | "microsoft"; constructor(authProvider: "github" | "microsoft"); } /** * IPC channel name for the shared-process tunnel service. */ export declare const TUNNEL_AGENT_HOST_CHANNEL = "tunnelAgentHost"; /** Configuration key for the list of manually configured tunnel names. */ export declare const TunnelAgentHostsSettingId = "chat.remoteAgentTunnels"; /** Minimum protocol version required for agent host connections. */ export declare const TUNNEL_MIN_PROTOCOL_VERSION = 5; /** Well-known port for the agent host on tunnel machines. */ export declare const TUNNEL_AGENT_HOST_PORT = 31546; /** Label used to identify VS Code server launcher tunnels. */ export declare const TUNNEL_LAUNCHER_LABEL = "vscode-server-launcher"; /** Address prefix for tunnel-backed connections (e.g. `tunnel:myTunnelId`). */ export declare const TUNNEL_ADDRESS_PREFIX = "tunnel:"; /** Path of the protocol-v6 registry-based endpoint-selection WebSocket route on the forwarded agent-host tunnel port. */ export declare const TUNNEL_GATEWAY_SELECT_PATH = "/agent-host/select"; /** * Tunnel launcher protocol version (see `PROTOCOL_VERSION` in the CLI's * `cli/src/constants.rs`) starting from which the forwarded agent-host port * also serves {@link TUNNEL_GATEWAY_SELECT_PATH}. Tunnels below this * version only support the legacy direct-reuse root route. */ export declare const TUNNEL_GATEWAY_MIN_PROTOCOL_VERSION = 6; /** Prefix for protocol version tags. */ export declare const PROTOCOL_VERSION_TAG_PREFIX = "protocolv"; /** * Parse tunnel tags to extract display name and protocol version. * Follows the convention from the vscode-remote-tunnels SDK: the * first label that is not `vscode-server-launcher`, does not start * with `_`, and is not a `protocolvN` tag is the display name. */ export declare class TunnelTags { readonly value: readonly string[] | undefined; readonly protocolVersion: number; readonly name: string | undefined; constructor(value: readonly string[] | undefined); } /** A recently used tunnel cached in storage. */ export interface ICachedTunnel { readonly tunnelId: string; readonly clusterId: string; readonly name: string; /** Protocol version at cache time. Optional because entries from older builds do not contain it. */ readonly protocolVersion?: number; readonly authProvider?: "github" | "microsoft"; } /** Information about a discovered dev tunnel with an agent host. */ export interface ITunnelInfo { /** The tunnel's unique identifier. */ readonly tunnelId: string; /** The cluster region where the tunnel is hosted. */ readonly clusterId: string; /** Display name derived from tunnel tags or tunnel name. */ readonly name: string; /** All tags/labels on the tunnel. */ readonly tags: readonly string[]; /** Parsed protocol version from tags. */ readonly protocolVersion: number; /** Number of hosts currently accepting connections (0 = offline). */ readonly hostConnectionCount: number; } /** How startup auto-connect should establish a tunnel connection. */ export type TunnelAutoConnectMode = "background" | "prompt"; /** Kind of process that owns a gateway-reported endpoint. Mirrors `AgentHostServerType` in the CLI's agent-host registry (`cli/src/tunnels/agent_host_registry.rs`). */ export type TunnelGatewayServerType = "editor" | "standalone"; /** How a selected endpoint's lifetime relates to this connection. Mirrors `GatewayLifecycle` in the CLI gateway (`cli/src/tunnels/agent_host.rs`). */ export type TunnelGatewayLifecycle = "external" | "managed"; /** * One live registry endpoint as reported by the tunnel gateway's inventory * message. Deliberately never includes a connection token: the gateway * injects the target's own token itself once a selection completes, and it * is never exposed to the renderer. */ export interface ITunnelGatewayEndpoint { readonly type: TunnelGatewayServerType; readonly pid: number; readonly instanceId: string; readonly quality?: string; readonly tunnelName?: string; readonly endpointKind: "tcp" | "socket"; readonly endpointLabel: string; } /** * One-time inventory message sent by the tunnel gateway immediately after * the protocol-v6 selection WebSocket route ({@link TUNNEL_GATEWAY_SELECT_PATH}) upgrades. */ export interface ITunnelGatewayInventory { readonly userDataPath: string; readonly endpoints: readonly ITunnelGatewayEndpoint[]; /** Set when the tunnel is bound to one specific agent host instance: the inventory lists only that endpoint and no dedicated host can be spawned. */ readonly delegatedInstanceId?: string; } /** * The client's one-time selection message, matching `GatewaySelectionRequest` * on the CLI side (`cli/src/tunnels/agent_host.rs`) exactly: either an * existing live endpoint's `instanceId`, or a request to spawn a new * dedicated standalone instance. */ export type ITunnelGatewaySelection = { readonly instanceId: string; } | { readonly newDedicated: true; }; /** Metadata about the endpoint the gateway selected, mirrored into {@link ITunnelConnectResult}. */ export interface ITunnelGatewaySelectedInfo { /** * `'unknown'` only ever appears for a protocol-v5 tunnel's legacy * {@link ITunnelAgentHostMainService.connect}, which has no gateway * inventory to draw a real answer from. */ readonly serverType: TunnelGatewayServerType | "unknown"; readonly instanceId: string; readonly role: "primary"; readonly lifecycle: TunnelGatewayLifecycle; } /** * A protocol-v6 gateway selection session prepared by * {@link ITunnelAgentHostMainService.prepareSelection}. The pending gateway * WebSocket and relay client are held server-side, keyed by * {@link selectionId}, until {@link ITunnelAgentHostMainService.completeSelection} * or {@link ITunnelAgentHostMainService.cancelSelection} is called. */ export interface ITunnelGatewaySelectionSession { readonly selectionId: string; readonly inventory: ITunnelGatewayInventory; } /** * Thrown by {@link parseTunnelGatewayInventory} and * {@link parseTunnelGatewaySelectionResponse} when a gateway wire message * does not have the expected structure, so callers can log a clear * "malformed gateway message" error rather than a generic parse failure. */ export declare class TunnelGatewayProtocolError extends Error { } /** * Parse and structurally validate a gateway inventory message. Throws * {@link TunnelGatewayProtocolError} (or a JSON `SyntaxError`) rather than * returning a partially-valid inventory, so callers never silently proceed * with a corrupt endpoint list. */ export declare function parseTunnelGatewayInventory(json: string): ITunnelGatewayInventory; /** * Parse and validate the gateway's one-time selection acknowledgement, * matching `GatewaySelectionResponse` on the CLI side exactly. */ export declare function parseTunnelGatewaySelectionResponse(json: string): { ok: true; selected: ITunnelGatewaySelectedInfo; } | { ok: false; error: string; }; /** * `Error.name` carried by the failure {@link ITunnelAgentHostMainService.completeSelection} * throws when the gateway itself answered `{"ok":false}` — i.e. the tunnel * relay is up and reachable, and only the endpoint we picked turned out to * be gone (its registry entry vanished, or its socket/port could not be * dialed). Callers must distinguish this from a transport failure: a * transport failure means the tunnel is down and the same destination * should simply be retried, whereas a rejection means retrying the same * endpoint can never succeed and a different one has to be selected. * * Modelled as a name rather than an `Error` subclass because this crosses * the shared-process IPC boundary, which preserves `name`/`message`/`stack` * but not the prototype chain. */ export declare const TUNNEL_GATEWAY_SELECTION_REJECTED_ERROR_NAME = "TunnelGatewaySelectionRejectedError"; /** Creates the error described by {@link TUNNEL_GATEWAY_SELECTION_REJECTED_ERROR_NAME}. */ export declare function createTunnelGatewaySelectionRejectedError(message: string): Error; /** Whether `error` is a gateway rejection, including one received over IPC. See {@link TUNNEL_GATEWAY_SELECTION_REJECTED_ERROR_NAME}. */ export declare function isTunnelGatewaySelectionRejectedError(error: unknown): boolean; /** * Error name for a connect attempt whose requested tunnel no longer exists. * Matching on the name survives the shared-process IPC boundary. */ export declare const TUNNEL_NOT_FOUND_ERROR_NAME = "TunnelNotFoundError"; /** Raised when the requested tunnel cannot be resolved. */ export declare class TunnelNotFoundError extends Error { constructor(tunnelId: string); } /** Whether `error` is a {@link TunnelNotFoundError}, including across IPC. */ export declare function isTunnelNotFoundError(error: unknown): boolean; /** * Serializable result from a successful tunnel connect operation. * Returned over IPC from the shared process. */ export interface ITunnelConnectResult { /** Unique identifier for this connection's relay channel. */ readonly connectionId: string; /** Display-friendly address (e.g. "tunnel:myTunnel"). */ readonly address: string; /** Display name for the tunnel. */ readonly name: string; /** Connection token derived from the tunnel ID. */ readonly connectionToken: string; /** * Metadata about the agent host endpoint that was actually selected. * Protocol-v5 tunnels have no selection gateway, so legacy * {@link ITunnelAgentHostMainService.connect} reports `serverType: * 'unknown'` and `lifecycle: 'external'`, since that route always * reuses a single deterministic target without a picker. */ readonly selected: ITunnelGatewaySelectedInfo; } /** * A message relayed from a remote agent host through the tunnel. * The shared process acts as a WebSocket proxy, forwarding JSON * messages bidirectionally between the tunnel and the renderer via IPC. */ export interface ITunnelRelayMessage { readonly connectionId: string; readonly data: string; } /** Persisted tunnel IDs hidden from discovery or automatic connection. */ export interface ITunnelVisibility { readonly dismissed: readonly string[]; readonly autoConnectSuppressed: readonly string[]; } export interface ITunnelDiscoveryOptions { readonly authProvider?: "github" | "microsoft"; readonly silent?: boolean; readonly onDiagnostic?: ConnectionDiagnosticObserver; } /** Information about an actively hosted tunnel. */ export interface ITunnelHostInfo { readonly tunnelName: string; /** Stable dev tunnel identity, which can be absent when an older CLI reports the hosted tunnel. */ readonly tunnelId?: string; /** Set when remote session access is being provided by full Remote Tunnel Access rather than a dedicated agent host tunnel. */ readonly viaRemoteTunnelAccess?: boolean; } /** Whether a discovered tunnel is the hosted tunnel, preferring its stable identity over its display name. */ export declare function isTunnelHosted(sharingInfo: ITunnelHostInfo | undefined, tunnel: Pick): boolean;