Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
102 changes: 97 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@
"node-pty": "^1.2.0-beta.12",
"open": "^10.1.2",
"playwright-core": "1.59.0-alpha-2026-02-20",
"ssh2": "^1.16.0",
"tas-client": "0.3.1",
"undici": "^7.24.0",
"v8-inspect-profiler": "^0.1.1",
Expand All @@ -148,6 +149,7 @@
"@types/node": "^22.18.10",
"@types/sinon": "^10.0.2",
"@types/sinon-test": "^2.4.2",
"@types/ssh2": "^1.15.4",
"@types/trusted-types": "^2.0.7",
"@types/vscode-notebook-renderer": "^1.72.0",
"@types/wicg-file-system-access": "^2023.10.7",
Expand Down
85 changes: 85 additions & 0 deletions src/vs/platform/agentHost/common/sshRemoteAgentHost.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { Event } from '../../../base/common/event.js';
import { IDisposable } from '../../../base/common/lifecycle.js';
import { createDecorator } from '../../instantiation/common/instantiation.js';

export const ISSHRemoteAgentHostService = createDecorator<ISSHRemoteAgentHostService>('sshRemoteAgentHostService');

export const enum SSHAuthMethod {
/** Use the local SSH agent for key-based auth. */
Agent = 'agent',
/** Authenticate with an explicit private key file. */
KeyFile = 'keyFile',
/** Authenticate with a password. */
Password = 'password',
}

export interface ISSHAgentHostConfig {
/** Remote hostname or IP. */
readonly host: string;
/** SSH port (default 22). */
readonly port?: number;
/** Username on the remote machine. */
readonly username: string;
/** Authentication method. */
readonly authMethod: SSHAuthMethod;
/** Path to the private key file (when {@link authMethod} is KeyFile). */
readonly privateKeyPath?: string;
/** Password string (when {@link authMethod} is Password). */
readonly password?: string;
/** Display name for this connection. */
Comment on lines +30 to +34
Copy link

Copilot AI Mar 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

password is part of ISSHAgentHostConfig, and connection objects expose that config. This makes plaintext credentials retrievable by any consumer of the service/connection list and keeps them in memory longer than needed. Consider keeping secrets out of the exposed config (e.g., omit password from the connection’s config, or store auth material separately and clear it after connect).

Copilot uses AI. Check for mistakes.
readonly name: string;
}

export interface ISSHAgentHostConnection extends IDisposable {
/** The SSH config used to establish this connection. */
readonly config: ISSHAgentHostConfig;
/** The local forwarded address (e.g. `127.0.0.1:54321`) registered with IRemoteAgentHostService. */
readonly localAddress: string;
/** The display name. */
readonly name: string;
/** Fires when this SSH connection is closed or lost. */
readonly onDidClose: Event<void>;
}

/**
* 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 local TCP
* port forward so the sessions app can connect via its standard
* WebSocket transport.
*/
export interface ISSHRemoteAgentHostService {
readonly _serviceBrand: undefined;

/** Fires when the set of active SSH connections changes. */
readonly onDidChangeConnections: Event<void>;

/** 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. Forwards the remote agent host port to a local port
* 5. Registers the local address with {@link IRemoteAgentHostService}
*
* Resolves with the connection handle once the agent host is reachable.
*/
connect(config: ISSHAgentHostConfig): Promise<ISSHAgentHostConnection>;

/**
* Disconnect an SSH-bootstrapped connection by host address.
* Tears down the SSH tunnel, stops the remote agent host, and
* removes the entry from {@link IRemoteAgentHostService}.
*/
disconnect(host: string): Promise<void>;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { InstantiationType, registerSingleton } from '../../instantiation/common/extensions.js';
import { ISSHRemoteAgentHostService } from '../common/sshRemoteAgentHost.js';
import { SSHRemoteAgentHostService } from './sshRemoteAgentHostServiceImpl.js';

registerSingleton(ISSHRemoteAgentHostService, SSHRemoteAgentHostService, InstantiationType.Delayed);
Loading
Loading