The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): surface Tailscale SSH browser checks
Cad from Arcae4956f5a122b
diff --git a/apps/desktop/electron/ssh-connection.test.ts b/apps/desktop/electron/ssh-connection.test.tsindex f0e33cae236..9c14060f6eb 100644--- a/apps/desktop/electron/ssh-connection.test.ts+++ b/apps/desktop/electron/ssh-connection.test.ts@@ -263,6 +263,16 @@ function fakeChild({ code = 0, signal = null, stdout = '', stderr = '', errorEve}if (hang) {+ process.nextTick(() => {+ if (stdout) {+ child.stdout.emit('data', Buffer.from(stdout))+ }++ if (stderr) {+ child.stderr.emit('data', Buffer.from(stderr))+ }+ })+return child // never emits close → drives the timeout path}@@ -473,6 +483,35 @@ test('open() surfaces a classified auth error', async () => {)})+test('open() turns a Tailscale browser-check timeout into safe interactive-auth guidance', async () => {+ const checkUrl = 'https://login.tailscale.com/a/example-one-time-check'++ const spawnFn = scriptedSpawn(args => {+ if (args.includes('check')) {+ return { code: 255 }+ }++ return {+ hang: true,+ stderr: `# Tailscale SSH requires an additional check.\n# To authenticate, visit: ${checkUrl}\n`+ }+ })++ const conn = new SshConnection({ host: 'box', user: 'me' }, { spawnFn, controlDir: '/tmp/d', connectTimeoutMs: 20 })++ await assert.rejects(+ () => conn.open(),+ (err: any) => {+ assert.equal(err.kind, SSH_ERROR.INTERACTIVE_AUTH)+ assert.match(err.message, /Tailscale SSH requires an interactive browser check/)+ assert.match(err.message, /ssh me@box true/)+ assert.doesNotMatch(err.message, /login\.tailscale\.com|example-one-time-check/)++ return true+ }+ )+})+test('exec() returns stdout on success and rejects (classified) on failure', async () => {const okSpawn = scriptedSpawn([{ code: 0, stdout: 'Linux\n' }])const conn = new SshConnection({ host: 'box', user: 'me' }, { spawnFn: okSpawn, controlDir: '/tmp/d' })diff --git a/apps/desktop/electron/ssh-connection.ts b/apps/desktop/electron/ssh-connection.tsindex f2e3ab364d1..f1be22c50b1 100644--- a/apps/desktop/electron/ssh-connection.ts+++ b/apps/desktop/electron/ssh-connection.ts@@ -397,6 +397,7 @@ function forwardSpec(localPort, remotePort, remoteHost = '127.0.0.1') {const SSH_ERROR = {UNREACHABLE: 'unreachable',AUTH_FAILED: 'auth-failed',+ INTERACTIVE_AUTH: 'interactive-auth',HOST_KEY_CHANGED: 'host-key-changed',TIMEOUT: 'timeout',UNKNOWN: 'unknown'@@ -415,6 +416,12 @@ function classifySshError(stderr) {return SSH_ERROR.HOST_KEY_CHANGED}+ if (+ /Tailscale SSH requires an additional check|To authenticate, visit:\s*https:\/\/login\.tailscale\.com\//i.test(text)+ ) {+ return SSH_ERROR.INTERACTIVE_AUTH+ }+if (/Permission denied|Too many authentication failures|no matching host key|publickey|password|keyboard-interactive/i.test(text@@ -453,6 +460,16 @@ function sshErrorMessage(kind, conn, stderr?) {`ssh-agent first (e.g. \`ssh-add ~/.ssh/id_ed25519\`), or set an IdentityFile in ` +`~/.ssh/config. Original error: ${String(stderr || '').trim()}`)+ case SSH_ERROR.INTERACTIVE_AUTH: {+ const portArg = conn.port && conn.port !== 22 ? ` -p ${conn.port}` : ''++ return (+ `Tailscale SSH requires an interactive browser check for ${host}. ` ++ `Hermes Desktop runs SSH non-interactively. In Terminal, run ` ++ `\`ssh${portArg} ${host} true\`, complete the browser check, then retry. ` ++ `If checks recur, use a key-authenticated OpenSSH route or adjust the tailnet SSH check policy.`+ )+ }case SSH_ERROR.UNREACHABLE:return `Could not reach ${host} over SSH. Check the host, port, and your network. Original error: ${String(stderr || '').trim()}`@@ -514,6 +531,10 @@ function runSsh(args, { timeoutMs, spawnFn = spawn, stdin = 'ignore', stdinData,const err: any = new Error(`ssh timed out after ${timeoutMs}ms`)err.kind = SSH_ERROR.TIMEOUT+ // Keep only a safe classification of buffered stderr. Tailscale's+ // browser-check line carries a one-time URL that must not escape through+ // Desktop errors or lifecycle logs.+ err.stderrKind = classifySshError(stderr)signal?.removeEventListener('abort', onAbort)reject(err)}, timeoutMs)@@ -712,8 +733,11 @@ class SshConnection {}if (stderrOrErr && stderrOrErr.kind === SSH_ERROR.TIMEOUT) {- const err: any = new Error(sshErrorMessage(SSH_ERROR.TIMEOUT, this))- err.kind = SSH_ERROR.TIMEOUT+ const kind =+ stderrOrErr.stderrKind === SSH_ERROR.INTERACTIVE_AUTH ? SSH_ERROR.INTERACTIVE_AUTH : SSH_ERROR.TIMEOUT++ const err: any = new Error(sshErrorMessage(kind, this))+ err.kind = kindreturn err}