import { Event, URI } from "../../../sessions/sessions.web.main.internal.js"; import { RemoteAgentHostLocationPreference } from "@codingame/monaco-vscode-workbench-service-override/vscode/vs/platform/agentHost/common/remoteAgentHostLocationPreference"; import { ISSHConnectProgress, ISSHAgentHostConnection, ISSHAgentHostConfig, ISSHResolvedConfig, type IRelayMessage, type ISSHConnectResult, type ISSHEndpointSelection, type ISSHEndpointSelectionRequest, type ISSHHostKeysAnnouncement, type ISSHHostKeyVerificationRequest, type ISSHKeyboardInteractiveRequest } from "./sshRemoteAgentHost.js"; export declare const ISSHRemoteAgentHostService: import("../../instantiation/common/instantiation.js").ServiceIdentifier; /** * Manages SSH connections that bootstrap a remote agent host process. * * Each connection SSHs into a remote machine, ensures the VS Code CLI * is installed, starts `code agent-host`, and creates a WebSocket relay * over the SSH channel. Messages are forwarded between the renderer and * the remote agent host via IPC through the shared process. */ export interface ISSHRemoteAgentHostService { readonly _serviceBrand: undefined; /** Fires when the set of active SSH connections changes. */ readonly onDidChangeConnections: Event; /** Progress messages during connect. */ readonly onDidReportConnectProgress: Event; /** Currently active SSH-bootstrapped connections. */ readonly connections: readonly ISSHAgentHostConnection[]; /** * Bootstrap a remote agent host over SSH. * * 1. Opens an SSH connection to the remote host * 2. Downloads and installs the VS Code CLI if needed * 3. Starts `code agent-host` * 4. Creates a WebSocket relay over the SSH channel * 5. Waits for {@link IRemoteAgentHostService} to complete the protocol handshake * * Resolves with the connection handle once the agent host is reachable. */ connect(config: ISSHAgentHostConfig): Promise; /** * Disconnect an SSH-bootstrapped connection by host address. * Tears down the SSH tunnel, stops the remote agent host, and removes its * persisted SSH entry. */ disconnect(host: string): Promise; /** List SSH config host aliases (excluding wildcards). */ listSSHConfigHosts(): Promise; /** * Ensure `~/.ssh/config` exists (creating it with the right permissions if * missing) and return its URI. The parent `~/.ssh` directory is created * with mode 0700 and the config file with mode 0600 on POSIX systems. */ ensureUserSSHConfig(): Promise; /** * List the known SSH configuration file URIs in priority order — typically the * per-user `~/.ssh/config` (always returned, even if it does not yet exist) and * the system-wide `/etc/ssh/ssh_config` (only when present on disk). */ listSSHConfigFiles(): Promise; /** Resolve full SSH config for a host via `ssh -G`. */ resolveSSHConfig(host: string): Promise; /** * Re-establish an SSH tunnel on startup for a previously connected host. * Resolves once the service-owned protocol connection is ready. * * @param userInitiated See {@link ISSHAgentHostConfig.userInitiated}. * Defaults to `true` (picker-eligible) when omitted; background/auto * reconnect callers must pass `false` explicitly to guarantee no picker * ever opens and no `editor` endpoint is ever silently chosen. */ reconnect(sshConfigHost: string, name: string, userInitiated?: boolean): Promise; } /** * Main-process service that performs the actual SSH work. * The renderer calls this over IPC and handles registration * with {@link IRemoteAgentHostService} locally. */ export declare const ISSHRemoteAgentHostMainService: import("../../instantiation/common/instantiation.js").ServiceIdentifier; export interface ISSHRemoteAgentHostMainService { readonly _serviceBrand: undefined; /** Fires when the set of active SSH connections changes. */ readonly onDidChangeConnections: Event; /** Fires when a connection is closed from the shared process side. */ readonly onDidCloseConnection: Event; /** Progress messages during connect (e.g. "Installing CLI..."). */ readonly onDidReportConnectProgress: Event; /** Fires when a message is received from a remote agent host via the SSH relay. */ readonly onDidRelayMessage: Event; /** Fires with a connection ID while that SSH relay receives part of a message. */ readonly onDidRelayActivity: Event; /** Fires when a relay connection to a remote agent host closes. */ readonly onDidRelayClose: Event; /** * Fires when the SSH server requests keyboard-interactive auth (typically * a password prompt). The renderer must answer via {@link respondKeyboardInteractive} * with the same `requestId`, otherwise the auth attempt will hang until the * SSH handshake deadline elapses. */ readonly onDidRequestKeyboardInteractive: Event; /** * Fires when a previously requested keyboard-interactive prompt is no * longer needed (e.g. the underlying SSH connect attempt failed or was * aborted). The renderer should dismiss any UI it opened for `requestId`. */ readonly onDidCancelKeyboardInteractive: Event; /** * Provide responses for a previously fired keyboard-interactive request. * Pass `undefined` when the user cancels the prompt; this aborts the * owning SSH connection attempt. */ respondKeyboardInteractive(requestId: string, responses: readonly string[] | undefined): Promise; /** * Fires when connect() discovers at least one live `editor`-owned * endpoint on the remote and needs the renderer to choose which * live endpoint (or "spawn new") to connect to. The renderer must * answer via {@link respondEndpointSelection} with the same `requestId`. */ readonly onDidRequestEndpointSelection: Event; /** * Fires when a previously requested endpoint selection is no longer * needed (e.g. the owning connect attempt failed or was aborted). The * renderer should dismiss any picker UI it opened for `requestId`. */ readonly onDidCancelEndpointSelection: Event; /** * Provide the user's answer to a previously fired endpoint-selection * request. Pass `undefined` when the user cancels the picker; this * aborts the owning connect attempt with a cancellation error. */ respondEndpointSelection(requestId: string, selection: ISSHEndpointSelection | undefined): Promise; /** * Fires when a server presents a host key during key exchange and the * renderer must decide whether to trust it. Answering is mandatory: until * {@link respondHostKeyVerification} is called with the same `requestId`, * the SSH handshake is suspended. */ readonly onDidRequestHostKeyVerification: Event; /** * Fires when a previously requested host key verification is no longer * needed (e.g. the owning connect attempt failed or was aborted). The * renderer should dismiss any UI it opened for `requestId`. */ readonly onDidCancelHostKeyVerification: Event; /** * Provide the user's trust decision for a previously fired host key * verification request. Passing `false` fails the key exchange, which * tears the connection down before any authentication is attempted. */ respondHostKeyVerification(requestId: string, trusted: boolean): Promise; /** * Fires when a server announces its full set of host keys over an * already-authenticated connection. See {@link ISSHHostKeysAnnouncement} — * these keys are cryptographically proven, so consumers can persist them * without prompting. */ readonly onDidAnnounceHostKeys: Event; /** * Bootstrap a remote agent host over SSH. Returns serializable * connection info for the renderer to register. * * @param expectedConnectionId The caller's current relay lease. When it is * supplied, concurrent renewal of that lease coalesces and a stale lease * resolves to its current replacement. */ connect(config: ISSHAgentHostConfig, expectedConnectionId?: string): Promise; /** * Send a message to a remote agent host through the SSH relay. */ relaySend(connectionId: string, message: string): Promise; /** Release one renderer-owned relay lease; the shared SSH session closes after its final lease is released. */ releaseRelay(connectionId: string): Promise; /** * Disconnect an SSH-bootstrapped connection by host address. */ disconnect(host: string): Promise; /** List SSH config host aliases (excluding wildcards). */ listSSHConfigHosts(): Promise; /** * Ensure `~/.ssh/config` exists (creating it with the right permissions if * missing) and return its URI. */ ensureUserSSHConfig(): Promise; /** List the known SSH configuration file URIs (user config always included). */ listSSHConfigFiles(): Promise; /** Resolve full SSH config for a host via `ssh -G`. */ resolveSSHConfig(host: string): Promise; /** * Re-establish an SSH tunnel for a previously connected host. * Resolves the SSH config alias, connects, and returns fresh * connection info with a new local forwarded port. * * @param userInitiated See {@link ISSHAgentHostConfig.userInitiated}. * Defaults to `true` (picker-eligible) when omitted. * @param preferredAgentLocation See {@link ISSHAgentHostConfig.preferredAgentLocation}. * The renderer computes this from its stored preference for this host's * {@link computeSSHConnectionKey stable key} before calling reconnect. */ reconnect(sshConfigHost: string, name: string, remoteAgentHostCommand?: string, agentForward?: boolean, userInitiated?: boolean, preferredAgentLocation?: RemoteAgentHostLocationPreference, expectedConnectionId?: string): Promise; }