Skip to content

armgit / herdr

Public Imported from GitHub
0

the runtime your coding agents live on

fix: allow best-effort Windows ARM64 remote connections (#4752)

akbashf0bb7827e4a1
diff --git a/docs/next/website/src/content/docs/ja/persistence-remote.mdx b/docs/next/website/src/content/docs/ja/persistence-remote.mdx
index ae695ab3f..d67a78691 100644
--- a/docs/next/website/src/content/docs/ja/persistence-remote.mdx
+++ b/docs/next/website/src/content/docs/ja/persistence-remote.mdx
@@ -69,7 +69,7 @@ Host workbox
herdr --remote workbox
```
-リモートアタッチと保存済み SSH マシンは、Linux、macOS、Windows のクライアントから、x86_64 または aarch64 の Linux/macOS ホスト、および x86_64 の Windows ホストへの接続に対応します。両端が安定したエンドポイント世代に対応していれば、バージョンは一致しなくても構いません。Linux/macOS ではリモートの `PATH` 上の互換バイナリを優先し、次に一般的な直接インストール、Homebrew、mise、Nix のパスを確認します。Windows では `PATH` と現在有効な管理対象リリースを確認します。互換バイナリがなければ、対話的な実行はインストールや更新の確認を求め、非対話的な実行はホストを変更せず失敗します。Linux/macOS では `~/.local/bin/herdr` に、Windows ではアプリローカル ConPTY ランタイムを含む完全なパッケージをインストールします。リモートの `PATH` に `~/.local/bin` がない場合は警告します。
+リモートアタッチと保存済み SSH マシンは、Linux、macOS、Windows のクライアントから、x86_64 または aarch64 の Linux/macOS ホスト、および x86_64 の Windows ホストへの接続に対応します。Windows ARM64 ホストは、Windows の x64 エミュレーションで x64 ビルドを実行するベストエフォート対応です。不具合や問題が発生する可能性があります。ホストが ARM64 を報告した場合、明示的なリモートアタッチと保存済みマシンのセットアップ時にエミュレーションの注意書きを表示します。両端が安定したエンドポイント世代に対応していれば、バージョンは一致しなくても構いません。Linux/macOS ではリモートの `PATH` 上の互換バイナリを優先し、次に一般的な直接インストール、Homebrew、mise、Nix のパスを確認します。Windows では `PATH` と現在有効な管理対象リリースを確認します。互換バイナリがなければ、対話的な実行はインストールや更新の確認を求め、非対話的な実行はホストを変更せず失敗します。Linux/macOS では `~/.local/bin/herdr` に、Windows ではアプリローカル ConPTY ランタイムを含む完全なパッケージをインストールします。リモートの `PATH` に `~/.local/bin` がない場合は警告します。
デフォルトでは、`herdr --remote` はユーザーの SSH config を最初に include し、その後にフォールバックのキープアライブ設定を加えた一時的な SSH config を通してリモートセットアップとブリッジを実行します。既存のユーザーのキープアライブ設定が優先されます。Linux と macOS クライアントは接続再利用用のプライベートなアタッチ単位コントロールソケットも使いますが、Windows OpenSSH では使いません。Herdr が生成する設定やコントロールソケットを使わず通常の `ssh` を使うには `[remote].manage_ssh_config = false` を設定してください。
diff --git a/docs/next/website/src/content/docs/persistence-remote.mdx b/docs/next/website/src/content/docs/persistence-remote.mdx
index 0ffa14061..53ce53875 100644
--- a/docs/next/website/src/content/docs/persistence-remote.mdx
+++ b/docs/next/website/src/content/docs/persistence-remote.mdx
@@ -69,7 +69,7 @@ Then attach with:
herdr --remote workbox
```
-Remote attach and saved SSH machines support Linux, macOS, and Windows local clients connecting to Linux or macOS hosts on x86_64 and aarch64, or Windows hosts on x86_64. Local and remote versions do not need to match once both support the stable endpoint generation. On Linux and macOS hosts, Herdr prefers a compatible `herdr` already on the remote `PATH`, then checks common direct, Homebrew, mise, and Nix profile install paths. On Windows hosts, Herdr checks `PATH` and the active managed release. If no compatible binary exists, interactive runs prompt to install or update one; non-interactive runs fail instead of modifying the host. Linux and macOS installs use `~/.local/bin/herdr`; Windows installs use the complete Windows package and its app-local ConPTY runtime. If `~/.local/bin` is not on the remote `PATH`, Herdr warns after install.
+Remote attach and saved SSH machines support Linux, macOS, and Windows local clients connecting to Linux or macOS hosts on x86_64 and aarch64, or Windows hosts on x86_64. Windows ARM64 hosts are supported on a best-effort basis using the x64 build under Windows emulation; bugs and issues are expected. Explicit remote attach and saved-machine setup display an emulation note when the host reports ARM64. Local and remote versions do not need to match once both support the stable endpoint generation. On Linux and macOS hosts, Herdr prefers a compatible `herdr` already on the remote `PATH`, then checks common direct, Homebrew, mise, and Nix profile install paths. On Windows hosts, Herdr checks `PATH` and the active managed release. If no compatible binary exists, interactive runs prompt to install or update one; non-interactive runs fail instead of modifying the host. Linux and macOS installs use `~/.local/bin/herdr`; Windows installs use the complete Windows package and its app-local ConPTY runtime. If `~/.local/bin` is not on the remote `PATH`, Herdr warns after install.
By default, `herdr --remote` runs remote setup and the bridge through a temporary SSH config that includes your SSH config first, then adds fallback keepalive settings. Existing user keepalive settings win. Linux and macOS clients also use a private per-attach control socket for connection reuse; Windows OpenSSH does not. Set `[remote].manage_ssh_config = false` to use plain `ssh` without Herdr's generated config or control socket.
diff --git a/docs/next/website/src/content/docs/zh-cn/persistence-remote.mdx b/docs/next/website/src/content/docs/zh-cn/persistence-remote.mdx
index 6b0be4d8a..90ce9ea96 100644
--- a/docs/next/website/src/content/docs/zh-cn/persistence-remote.mdx
+++ b/docs/next/website/src/content/docs/zh-cn/persistence-remote.mdx
@@ -69,7 +69,7 @@ Host workbox
herdr --remote workbox
```
-远程连接和已保存的 SSH 机器支持 Linux、macOS 和 Windows 客户端,目标可以是 x86_64 或 aarch64 的 Linux/macOS 主机,也可以是 x86_64 的 Windows 主机。只要两端支持稳定端点代数,版本就不必一致。Linux/macOS 上优先使用远程 `PATH` 中兼容的 `herdr`,再检查常见的直接安装、Homebrew、mise 和 Nix profile 路径。Windows 上检查 `PATH` 和当前有效的托管版本。如果没有兼容的二进制文件,交互式运行会询问是否安装或更新;非交互式运行直接失败,不修改主机。Linux/macOS 安装到 `~/.local/bin/herdr`,Windows 安装包含应用本地 ConPTY 运行时的完整软件包。如果 `~/.local/bin` 不在远程 `PATH` 中,Herdr 会发出警告。
+远程连接和已保存的 SSH 机器支持 Linux、macOS 和 Windows 客户端,目标可以是 x86_64 或 aarch64 的 Linux/macOS 主机,也可以是 x86_64 的 Windows 主机。Windows ARM64 主机通过 Windows 的 x64 模拟运行 x64 构建,仅提供尽力而为的支持,可能存在错误和其他问题。当主机报告 ARM64 时,显式远程连接和已保存机器的设置过程会显示模拟运行提示。只要两端支持稳定端点代数,版本就不必一致。Linux/macOS 上优先使用远程 `PATH` 中兼容的 `herdr`,再检查常见的直接安装、Homebrew、mise 和 Nix profile 路径。Windows 上检查 `PATH` 和当前有效的托管版本。如果没有兼容的二进制文件,交互式运行会询问是否安装或更新;非交互式运行直接失败,不修改主机。Linux/macOS 安装到 `~/.local/bin/herdr`,Windows 安装包含应用本地 ConPTY 运行时的完整软件包。如果 `~/.local/bin` 不在远程 `PATH` 中,Herdr 会发出警告。
默认情况下,`herdr --remote` 通过一个临时 SSH 配置运行远程设置和桥接: 先包含你的 SSH 配置,再补充兜底的保活设置。已有的用户保活设置优先。Linux 和 macOS 客户端还会添加一个私有的单次连接 control socket 来复用连接;Windows OpenSSH 不使用此方式。设置 `[remote].manage_ssh_config = false` 可以不用 Herdr 生成的配置或 control socket,而使用普通 `ssh`。
diff --git a/src/remote/attach.rs b/src/remote/attach.rs
index 82caeb9a5..695fcfd90 100644
--- a/src/remote/attach.rs
+++ b/src/remote/attach.rs
@@ -138,7 +138,8 @@ impl SavedSshSetup {
manage,
crate::session::DEFAULT_SESSION_NAME.to_owned(),
);
- let remote_herdr = RemoteHerdr::for_platform(detect_remote_platform(&ssh)?);
+ let remote_herdr =
+ RemoteHerdr::for_platform(detect_remote_platform(&ssh)?.into_setup_platform());
let candidates = remote_binary_candidates(&ssh, &remote_herdr)?;
Ok(Self {
ssh,
@@ -258,6 +259,21 @@ struct RemoteSessionJson {
running: bool,
}
+#[derive(Debug, PartialEq, Eq)]
+struct DetectedRemotePlatform {
+ platform: RemotePlatform,
+ setup_note: Option<&'static str>,
+}
+
+impl DetectedRemotePlatform {
+ fn into_setup_platform(self) -> RemotePlatform {
+ if let Some(note) = self.setup_note {
+ eprintln!("note: {note}");
+ }
+ self.platform
+ }
+}
+
#[derive(Debug, Clone, PartialEq, Eq)]
struct RemotePlatform {
os: &'static str,
@@ -1272,7 +1288,7 @@ pub(super) fn prepare_remote_herdr(
live_handoff_enabled: bool,
require_surface_interest: bool,
) -> io::Result<PreparedRemoteHerdr> {
- let platform = detect_remote_platform(ssh)?;
+ let platform = detect_remote_platform(ssh)?.into_setup_platform();
let remote_herdr = RemoteHerdr::for_platform(platform);
let candidates = remote_binary_candidates(ssh, &remote_herdr)?;
prepare_discovered_remote_herdr(
@@ -1365,7 +1381,7 @@ fn prepare_discovered_remote_herdr(
}
pub(super) fn find_installed_remote_herdr(ssh: &RemoteSsh) -> io::Result<RemoteHerdr> {
- let platform = detect_remote_platform(ssh)?;
+ let platform = detect_remote_platform(ssh)?.platform;
let remote_herdr = RemoteHerdr::for_platform(platform);
let candidates = remote_binary_candidates(ssh, &remote_herdr)?;
for mut candidate in candidates {
@@ -1459,7 +1475,7 @@ pub(super) fn discover_remote_api_metadata(
ssh: &RemoteSsh,
session: &str,
) -> io::Result<crate::client::endpoint::SshMachineMetadata> {
- let platform = detect_remote_platform(ssh)?;
+ let platform = detect_remote_platform(ssh)?.platform;
if !platform.is_windows() {
let output =
ssh.framed_user_shell_output(&posix_remote_api_discovery_command(&platform, session))?;
@@ -1501,7 +1517,7 @@ pub(super) fn discover_remote_api_metadata(
))
}
-fn detect_remote_platform(ssh: &RemoteSsh) -> io::Result<RemotePlatform> {
+fn detect_remote_platform(ssh: &RemoteSsh) -> io::Result<DetectedRemotePlatform> {
let output = ssh.sh_output("uname -s\nuname -m\n")?;
let mut windows_uname_hint = false;
let posix_error = if output.status.success() {
@@ -1510,7 +1526,10 @@ fn detect_remote_platform(ssh: &RemoteSsh) -> io::Result<RemotePlatform> {
let os = lines.next().unwrap_or_default();
let arch = lines.next().unwrap_or_default();
if let Some(platform) = RemotePlatform::from_uname(os, arch) {
- return Ok(platform);
+ return Ok(DetectedRemotePlatform {
+ platform,
+ setup_note: None,
+ });
}
windows_uname_hint = looks_like_windows_uname(os);
io::Error::other(format!(
@@ -1561,20 +1580,27 @@ fn windows_platform_probe_command() -> String {
)
}
-fn parse_windows_platform_probe(stdout: &str) -> Result<Option<RemotePlatform>, String> {
+fn parse_windows_platform_probe(stdout: &str) -> Result<Option<DetectedRemotePlatform>, String> {
let Some(arch) = stdout
.lines()
.find_map(|line| line.trim().strip_prefix("herdr-windows:"))
else {
return Ok(None);
};
- match arch.trim().to_ascii_uppercase().as_str() {
- "AMD64" | "X86_64" => Ok(Some(RemotePlatform {
+ let setup_note = match arch.trim().to_ascii_uppercase().as_str() {
+ "AMD64" | "X86_64" => None,
+ "ARM64" => Some(
+ "Windows ARM64 support is best-effort and uses x64 emulation; bugs and issues are expected.",
+ ),
+ arch => return Err(format!("unsupported remote platform: Windows {arch}")),
+ };
+ Ok(Some(DetectedRemotePlatform {
+ platform: RemotePlatform {
os: "windows",
arch: "x86_64",
- })),
- arch => Err(format!("unsupported remote platform: Windows {arch}")),
- }
+ },
+ setup_note,
+ }))
}
fn remote_binary_candidates(
@@ -4394,21 +4420,41 @@ mod tests {
}
#[test]
- fn windows_platform_probe_accepts_only_x86_64() {
- assert_eq!(
- parse_windows_platform_probe("profile noise\r\nherdr-windows:AMD64\r\n").unwrap(),
- Some(RemotePlatform {
- os: "windows",
- arch: "x86_64",
- })
- );
+ fn windows_platform_probe_preserves_native_and_unsupported_architectures() {
+ for arch in ["AMD64", "x86_64"] {
+ assert_eq!(
+ parse_windows_platform_probe(&format!("profile noise\r\nherdr-windows:{arch}\r\n"))
+ .unwrap(),
+ Some(DetectedRemotePlatform {
+ platform: RemotePlatform {
+ os: "windows",
+ arch: "x86_64",
+ },
+ setup_note: None,
+ })
+ );
+ }
assert_eq!(parse_windows_platform_probe("other output").unwrap(), None);
assert_eq!(
- parse_windows_platform_probe("herdr-windows:ARM64").unwrap_err(),
- "unsupported remote platform: Windows ARM64"
+ parse_windows_platform_probe("herdr-windows:x86").unwrap_err(),
+ "unsupported remote platform: Windows X86"
);
}
+ #[test]
+ fn windows_arm64_probe_selects_x64_package() {
+ let platform = parse_windows_platform_probe("herdr-windows:ARM64")
+ .expect("Windows ARM64 should use the x64 build on a best-effort basis")
+ .expect("the Windows platform marker should be recognized");
+ assert_eq!(platform.platform.asset_key(), "windows-x86_64");
+ let note = platform
+ .setup_note
+ .expect("ARM64 setup must warn about emulation");
+ assert!(note.contains("best-effort"));
+ assert!(note.contains("x64 emulation"));
+ assert!(note.contains("bugs and issues are expected"));
+ }
+
#[test]
fn windows_probe_preserves_transport_and_unsupported_unix_failures() {
let cases = [