import { IDisposable } from "../../../base/common/lifecycle.js"; import { IObservable } from "../../../base/common/observable.js"; import { Event } from "../../../sessions/sessions.web.main.internal.js"; import { IAgentConnection } from "./agentService.js"; import { IRemoteConnectionDiagnosticEvent } from "./connectionDiagnostics.js"; import { IRemoteAgentHostPendingConnection, IRemoteAgentHostConnectionInfo, IRemoteAgentHostEntry, IRemoteAgentHostConnectionFactory } from "./remoteAgentHostService.js"; import { IVscodeUpgradeResult } from "./state/protocolUpgrade.js"; export declare const IRemoteAgentHostService: import("../../instantiation/common/instantiation.js").ServiceIdentifier; /** * Owns factory-built remote agent host connections, including handshake, status, * retry, and disposal. Each connection is identified by address and exposed as an {@link IAgentConnection}. */ export interface IRemoteAgentHostService { readonly _serviceBrand: undefined; getConnectionDiagnostics(): readonly IRemoteConnectionDiagnosticEvent[]; /** In-flight setup and protocol connection attempts for enabled, configured hosts; excludes removed or disposed hosts even if setup has not settled. */ readonly pendingConnections: readonly IRemoteAgentHostPendingConnection[]; /** Signals that consumers should re-read pendingConnections, including after configuration reconciliation; the catalog may be unchanged. */ readonly onDidChangePendingConnections: Event; /** Fires when remote connections change; client-local renames only fire {@link onDidChangeDisplayName}. */ readonly onDidChangeConnections: Event; /** Fires with the normalized address when its client-local display name changes. */ readonly onDidChangeDisplayName: Event; /** Gets the client-local display-name override, or undefined to use the configured or discovered name. */ getDisplayNameOverride(address: string): string | undefined; /** Sets a machine-local display-name override. An empty or undefined name restores the default. */ setDisplayName(address: string, name: string | undefined): void; /** Delegates local labels to an inventory owner with its own account/profile persistence. */ registerDisplayName(address: string, name: IObservable, setName: (name: string | undefined) => void): IDisposable; /** * Known remote addresses with metadata. This is a status catalog, not a * liveness list: an entry is retained after a failed dial so its * {@link IRemoteAgentHostConnectionInfo.status} — and its disconnect reason — * stay observable. Callers asking "is this host usable?" must test `status` * (see `RemoteAgentHostConnectionStatus.isConnected`) rather than presence. */ readonly connections: readonly IRemoteAgentHostConnectionInfo[]; /** All remote agent host entries exposed by registered factories, regardless of connection status. */ readonly configuredEntries: readonly IRemoteAgentHostEntry[]; /** Fires when the configured entries change, independently of connection attempts. */ readonly onDidChangeConfiguredEntries: Event; /** Registers a factory for one connection kind. Throws if that kind already has one. */ registerConnectionFactory(factory: IRemoteAgentHostConnectionFactory): IDisposable; /** * Get a per-connection {@link IAgentConnection} for subscribing to * state, dispatching actions, creating sessions, etc. * * Returns `undefined` if no active connection exists for the address. */ getConnection(address: string): IAgentConnection | undefined; /** * Get a per-connection {@link IAgentConnection} by its sanitized * connection authority (as produced by `agentHostAuthority`), rather than * its raw address. Useful for callers that only have the authority * component of a remote session URI scheme (`remote--`). * * Returns `undefined` if no active connection matches the authority. */ getConnectionByAuthority(authority: string): IAgentConnection | undefined; /** Waits for a configured remote host to establish a connection. */ waitForConnection(address: string): Promise; /** * Disconnects an active remote host connection by address. */ removeRemoteAgentHost(address: string): Promise; /** * Forcefully reconnect to a configured remote host. * Tears down any existing connection and starts a fresh connect attempt * with reset backoff. */ reconnect(address: string, userInitiated?: boolean): void; /** * Skips a pending reconnect backoff for this address and retries at once. * Prefers the protocol client's in-place retry, which preserves session * state, and falls back to a fresh dial when there is no client to accelerate. */ reconnectNow(address: string): void; /** * Force the protocol client at `address` (if any) to treat its * transport as closed. Used by services that learn about a * connection loss out-of-band — e.g. the SSH service receiving an * `onDidCloseConnection` IPC event from the shared process — to * make sure the renderer-side client doesn't sit in `Connected` * waiting on its watchdog. The watchdog is a `setTimeout` and * Chromium aggressively throttles those in backgrounded windows, * so we can't rely on it as the sole death-detection path. * * No-op if no active entry exists for the address, or if the * existing client has already transitioned out of `Connected`. */ notifyConnectionClosed(address: string): void; /** * Look up the {@link IRemoteAgentHostEntry} for a given address. * Entries are supplied by registered connection factories. */ getEntryByAddress(address: string): IRemoteAgentHostEntry | undefined; /** * Ask the remote agent host to upgrade itself via its hosting CLI. * * Sends the host-advertised JSON-RPC method (typically * `_vscodeUpgrade`) on the existing transport — even when the handshake * has not completed (e.g. the host was just rejected for protocol * incompatibility). The hosting CLI receives the signal, checks for a * newer build, and kills+respawns the server on success. The caller * SHOULD then reconnect to re-attempt the handshake. * * Resolves with the host's status payload describing what happened * (whether an upgrade was needed, whether it was started); rejects on * transport failure, timeout, or a JSON-RPC error response. */ triggerServerUpgrade(address: string, method: string): Promise; }