735
cliBin = await this._ensureCLIInstalled(sshClient!, platform, reportProgress);
736
};
738
>
// 2. Check for an already-running agent host on the remote first.
739
>
// This prevents accumulating orphaned processes when the SSH
740
>
// connection drops and we reconnect — and avoids paying for
741
>
// platform detection + CLI install on every reconnect.
742
>
let remoteHost: string = '127.0.0.1';
743
>
let remotePort: number | undefined;
744
>
let connectionToken: string | undefined;
745
>
let agentStream: SSHChannel | undefined;
746
>
747
>
reportProgress(localize('sshProgressCheckingAgent', "Checking for existing agent host..."));
748
>
const exec = bindSshExec(sshClient);
749
>
const existingAH = await findRunningAgentHost(exec, this._logService, this._serverDataFolderName, this._quality);
750
>
if (existingAH.kind === 'compatible') {
751
remoteHost = existingAH.host;
752
remotePort = existingAH.port;
753
connectionToken = existingAH.connectionToken;
754
}
756
>
if (remotePort === undefined) {
757
// 3. Need to spawn fresh: resolve the CLI now.
758
await ensureCliResolved();