# Conflicts: # CLI/cmux.swift # Sources/ContentView.swift # Sources/GhosttyTerminalView.swift # Sources/Panels/TerminalPanel.swift # Sources/SocketControlSettings.swift # Sources/TabManager.swift # Sources/TerminalController.swift # Sources/Workspace.swift # daemon/remote/README.md # daemon/remote/cmd/cmuxd-remote/main.go # docs/remote-daemon-spec.md # tests_v2/test_ssh_remote_cli_metadata.py |
||
|---|---|---|
| .. | ||
| cmd/cmuxd-remote | ||
| go.mod | ||
| README.md | ||
cmuxd-remote (Go)
Go remote daemon for cmux ssh bootstrap, capability negotiation, and CLI relay.
Commands
cmuxd-remote versioncmuxd-remote serve --stdiocmuxd-remote cli <command> [args...]— relay cmux commands to the local app over the reverse TCP forward
When invoked as cmux (via wrapper/symlink installed during bootstrap), the binary auto-dispatches to the cli subcommand. This is busybox-style argv[0] detection.
RPC methods (newline-delimited JSON over stdio)
hellopingproxy.openproxy.closeproxy.writeproxy.readsession.opensession.closesession.attachsession.resizesession.detachsession.status
Current integration in cmux:
workspace.remote.configurenow bootstraps this binary over SSH when missing.- Client sends
hellobefore enabling remote proxy transport. - Local workspace proxy broker serves SOCKS5 + HTTP CONNECT and tunnels stream traffic through
proxy.*RPC overserve --stdio. - Daemon status/capabilities are exposed in
workspace.remote.status -> remote.daemon(includingsession.resize.min).
workspace.remote.configure contract notes:
port/local_proxy_portaccept integer values and numeric strings; explicitnullclears each field.- Out-of-range values and invalid types return
invalid_params. local_proxy_portis an internal deterministic test hook used by bind-conflict regressions.- SSH option precedence checks are case-insensitive; user overrides for
StrictHostKeyCheckingand control-socket keys prevent default injection.
CLI relay
The cli subcommand (or cmux wrapper/symlink) connects to the local cmux app's socket through an SSH reverse TCP forward and relays commands. It supports both v1 text protocol and v2 JSON-RPC commands.
Socket discovery order:
--socket <path>flagCMUX_SOCKET_PATHenvironment variable~/.cmux/socket_addrfile (written by the app after the reverse relay establishes)
For TCP addresses, the CLI retries for up to 15 seconds on connection refused, re-reading ~/.cmux/socket_addr on each attempt to pick up updated relay ports.
Integration additions for the relay path:
- Bootstrap installs
~/.cmux/bin/cmuxwrapper and keeps a default daemon target (~/.cmux/bin/cmuxd-remote-current). - A background
ssh -N -Rprocess reverse-forwards a TCP port to the local cmux Unix socket. The relay address is written to~/.cmux/socket_addron the remote. - Relay startup writes
~/.cmux/relay/<port>.daemon_pathso the wrapper can route each shell to the correct daemon binary when multiple local cmux instances/versions coexist.