feat: 实现 SSH Remote — 本地 UI + 远程工具执行#339
feat: 实现 SSH Remote — 本地 UI + 远程工具执行#339amDosion wants to merge 1 commit intoclaude-code-best:mainfrom
Conversation
完整实现 `claude ssh <host> [dir]` 功能,支持本地运行 UI 同时在远程 主机上执行工具,API 凭据通过 SSH 反向转发隧道安全传输。 Phase 1 — 本地会话管道: - SSHSessionManager: NDJSON pipe 传输,控制请求路由,权限桥接 - createLocalSSHSession: 本地 --local 模式 e2e 测试入口 - SSHAuthProxy: 本地 HTTP 代理注入认证(Unix socket / TCP+nonce) Phase 2 — 远程连接: - SSHProbe: 单次 SSH 探测远端平台/架构/二进制状态 - SSHDeploy: SCP 上传 + wrapper 脚本 + 验证安装 - createSSHSession: probe → deploy → auth proxy → SSH -R → spawn → init Phase 3 — 重连与 feature flag: - 进程意外退出自动重连(指数退延 2s→15s,最多 3 次) - 重连时追加 --continue 恢复会话历史 - SSH_REMOTE 加入 DEFAULT_BUILD_FEATURES 默认启用
|
Caution Review failedPull request was closed or merged during review 📝 WalkthroughWalkthroughThis PR implements complete SSH remote mode functionality by adding the feature flag, creating authentication proxy infrastructure, implementing remote environment probing and binary deployment, and building the session manager to orchestrate SSH subprocess lifecycle with JSON message handling. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant createSSHSession
participant SSHProbe
participant SSHDeploy
participant SSHAuthProxy
participant SSHProcess
participant RemoteSSH
User->>createSSHSession: Start SSH session
createSSHSession->>SSHProbe: Probe remote environment
SSHProbe->>RemoteSSH: ssh hostname "uname/pwd/command -v"
RemoteSSH-->>SSHProbe: Platform, arch, binary info
SSHProbe-->>createSSHSession: ProbeResult (version, platform, arch)
alt Binary missing or outdated
createSSHSession->>SSHDeploy: Deploy CLI binary
SSHDeploy->>RemoteSSH: scp upload + chmod +x wrapper
RemoteSSH-->>SSHDeploy: Verify with --version
SSHDeploy-->>createSSHSession: Deployment complete
end
createSSHSession->>SSHAuthProxy: Start auth proxy
SSHAuthProxy-->>createSSHSession: Local socket/port + authEnv
createSSHSession->>SSHProcess: Spawn SSH subprocess<br/>(with reverse forwarding + authEnv)
SSHProcess->>RemoteSSH: Connect with forwarding
createSSHSession->>SSHProcess: Read stdout for system:init
SSHProcess->>RemoteSSH: Execute CLI on remote
RemoteSSH->>SSHAuthProxy: Auth request (reverse tunnel)
SSHAuthProxy-->>RemoteSSH: Inject ANTHROPIC_API_KEY
RemoteSSH-->>SSHProcess: system:init message
SSHProcess-->>createSSHSession: remoteCwd + ready
createSSHSession-->>User: SSHSession ready
Estimated code review effort🎯 4 (Complex) | ⏱️ ~75 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
claude ssh <host> [dir]功能:本地运行 REPL UI,远程主机执行工具--continue恢复会话)SSH_REMOTEfeature flag 加入 build 默认启用列表新增文件
src/ssh/SSHAuthProxy.tssrc/ssh/SSHProbe.tssrc/ssh/SSHDeploy.ts修改文件
src/ssh/SSHSessionManager.tssrc/ssh/createSSHSession.tsscripts/defines.tsSSH_REMOTE加入DEFAULT_BUILD_FEATURESTest plan
bun run typecheck零错误claude ssh --local本地 pipe 模式启动成功claude ssh user@host远程连接 + 工具执行🤖 Generated with Claude Code
Summary by CodeRabbit