import { Event } from "../../../sessions/sessions.web.main.internal.js"; import { ITunnelDiscoveryOptions, ITunnelInfo, TunnelAutoConnectMode, ICachedTunnel, ITunnelVisibility, type ITunnelConnectResult, type ITunnelGatewaySelection, type ITunnelGatewaySelectionSession, type ITunnelRelayMessage } from "./tunnelAgentHost.js"; export declare const ITunnelAgentHostService: import("../../instantiation/common/instantiation.js").ServiceIdentifier; /** * Renderer-side service that manages dev tunnel agent host connections. * Uses the shared-process {@link ITunnelAgentHostMainService} for * actual tunnel SDK operations and registers connections with * {@link IRemoteAgentHostService}. */ export interface ITunnelAgentHostService { readonly _serviceBrand: undefined; /** Fires when the set of available tunnels changes. */ readonly onDidChangeTunnels: Event; /** * Enumerate available dev tunnels with agent host support. * Resolves to an empty array only when no tunnels should authoritatively be * exposed, such as after successful empty discovery or when discovery is * disabled. Rejects when discovery cannot complete, including when * authentication is unavailable. {@link options.silent} suppresses * authentication prompts but does not convert failures to empty results. * An explicit auth provider takes precedence over cached provider selection. */ listTunnels(options?: ITunnelDiscoveryOptions): Promise; /** * Determine whether startup auto-connect can run silently or must first ask * the user to choose an agent-host location. */ getAutoConnectMode(tunnel: ITunnelInfo): TunnelAutoConnectMode; /** * Connect to a tunnel's agent host and register the connection * with {@link IRemoteAgentHostService}. * * @param tunnel The tunnel to connect to. * @param authProvider Optional auth provider to use. If omitted, uses cached/last known. * @param options.userInitiated Whether this connection was explicitly * requested by the user (default `true`). When `false` (background/auto * connect), a protocol-v6 gateway selection must never prompt. Background * connections may prompt only when {@link getAutoConnectMode} returns * `'prompt'`; otherwise they reuse the saved preference silently. */ connect(tunnel: ITunnelInfo, authProvider?: "github" | "microsoft", options?: { readonly userInitiated?: boolean; }): Promise; /** Whether {@link deleteTunnel} is supported by this implementation. */ readonly canDeleteTunnels: boolean; /** Delete a dev tunnel and remove it from the local tunnel cache. */ deleteTunnel(tunnel: ITunnelInfo, authProvider?: "github" | "microsoft"): Promise; /** * Disconnect from a tunnel agent host. */ disconnect(address: string): Promise; /** Get the list of recently used (cached) tunnels. */ getCachedTunnels(): ICachedTunnel[]; /** Cache a tunnel as recently used. */ cacheTunnel(tunnel: ITunnelInfo, authProvider?: "github" | "microsoft"): void; /** Remove a tunnel from the cache. */ removeCachedTunnel(tunnelId: string): void; /** Whether the user dismissed this tunnel from the remote-host picker. */ isTunnelDismissed(tunnelId: string): boolean; /** Persisted visibility decisions, including IDs absent from the current cache and discovery results. */ getTunnelVisibility(): ITunnelVisibility; /** Persist that the user dismissed this tunnel from the remote-host picker. */ dismissTunnel(tunnelId: string): void; /** Clear a previous picker-dismissal after the user explicitly reconnects this tunnel. */ clearTunnelDismissal(tunnelId: string): void; /** Whether startup/background auto-connect should skip this tunnel, because this machine hosts it. */ isAutoConnectSuppressed(tunnelId: string): boolean; /** Remember that startup/background auto-connect must skip this tunnel, because this machine hosts it. */ suppressAutoConnect(tunnelId: string): void; /** Clear a previous auto-connect suppression once this machine no longer hosts the tunnel. */ clearAutoConnectSuppression(tunnelId: string): void; /** * Determine which auth provider has an existing cached session. * When {@link silent} is true, does not prompt the user. * Returns `undefined` if no cached session is available. */ getAuthProvider(options?: { silent?: boolean; }): Promise<"github" | "microsoft" | undefined>; /** Requests the configured tunnel permissions without connecting to a host. */ signIn?(authProvider: "github" | "microsoft"): Promise; } /** * Main-process (shared process) service that manages dev tunnel * connections. The renderer calls this over IPC and handles registration * with {@link IRemoteAgentHostService} locally. */ export declare const ITunnelAgentHostMainService: import("../../instantiation/common/instantiation.js").ServiceIdentifier; export interface ITunnelAgentHostMainService { readonly _serviceBrand: undefined; /** Fires when a message is received from a remote agent host via the tunnel relay. */ readonly onDidRelayMessage: Event; /** Fires with a connection ID while that tunnel relay receives part of a message. */ readonly onDidRelayActivity: Event; /** Fires when a relay connection to a remote agent host closes. */ readonly onDidRelayClose: Event; /** * List dev tunnels associated with the user's account that have * the `vscode-server-launcher` label and a protocol version tag * of at least {@link TUNNEL_MIN_PROTOCOL_VERSION}. * * @param token The user's access token (GitHub or Microsoft). * @param authProvider The auth provider that issued the token. * @param additionalTunnelNames Optional tunnel names to look up * in addition to the account-wide enumeration. */ listTunnels(token: string, authProvider: "github" | "microsoft", additionalTunnelNames?: string[]): Promise; /** Delete a dev tunnel and close any associated relay connections. */ deleteTunnel(token: string, authProvider: "github" | "microsoft", tunnelId: string, clusterId: string): Promise; /** * Connect to a tunnel's agent host via the dev tunnels relay and * begin relaying WebSocket messages through IPC. * * @param token The user's access token (GitHub or Microsoft). * @param authProvider The auth provider that issued the token. * @param tunnelId The tunnel ID to connect to. * @param clusterId The cluster region of the tunnel. */ connect(token: string, authProvider: "github" | "microsoft", tunnelId: string, clusterId: string): Promise; /** * Prepare a protocol-v6 registry-based endpoint selection: connects the * dev tunnel relay and opens the gateway's selection WebSocket route * ({@link TUNNEL_GATEWAY_SELECT_PATH}), returning its one-time inventory * of live agent host endpoints. The gateway WebSocket and relay client * are held pending (keyed by the returned `selectionId`) until * {@link completeSelection} or {@link cancelSelection} is called. * * Returns `undefined` when the tunnel's advertised protocol version is * below {@link TUNNEL_GATEWAY_MIN_PROTOCOL_VERSION}: callers must fall * back to the legacy {@link connect} in that case, which preserves the * v5 direct-reuse behavior with no picker. * * @param token The user's access token (GitHub or Microsoft). * @param authProvider The auth provider that issued the token. * @param tunnelId The tunnel ID to connect to. * @param clusterId The cluster region of the tunnel. */ prepareSelection(token: string, authProvider: "github" | "microsoft", tunnelId: string, clusterId: string): Promise; /** * Complete a selection previously started with {@link prepareSelection}: * sends the selection message over the pending gateway WebSocket, awaits * its ready acknowledgement, and registers the resulting relay * connection the same way {@link connect} does. * * Rejects with an error named {@link TUNNEL_GATEWAY_SELECTION_REJECTED_ERROR_NAME} * when the gateway answered but refused the selection, and with any * other error when the tunnel transport itself failed. Either way the * pending session is consumed and disposed, so retrying requires a fresh * {@link prepareSelection}. */ completeSelection(selectionId: string, selection: ITunnelGatewaySelection): Promise; /** * Cancel and dispose a pending selection without completing it (e.g. * the user dismissed the picker). Safe to call even if `selectionId` is * unknown or was already completed/cancelled. */ cancelSelection(selectionId: string): Promise; /** * Send a message to a remote agent host through the tunnel relay. */ relaySend(connectionId: string, message: string): Promise; /** * Disconnect a tunnel relay connection. */ disconnect(connectionId: string): Promise; }