Skip to content

Add Named Pipe transport to nodespace CLI for Windows support - #2610

Merged
mstomar125 merged 2 commits into
mainfrom
issue-1452-windows-pipe-cli
Sep 14, 2026
Merged

mstomar125 merged 2 commits into
mainfrom
issue-1452-windows-pipe-cli

Conversation

@mstomar125

Copy link
Copy Markdown
Contributor

Summary

The nodespace CLI only supported Unix Domain Socket transport (#[cfg(unix)]) — run() on Windows returned an anyhow::bail! stub, so the CLI could never connect to nodespaced on Windows. The daemon side already had Named Pipe transport (tokio::net::windows::named_pipe, added in #1440), listening on \\.\pipe\nodespace-daemon. This adds the matching client-side transport.

  • dial_channel() is now platform-gated internally: UnixStream on Unix (unchanged), tokio::net::windows::named_pipe::ClientOptions on Windows — mirroring the desktop app's existing client-side pipe transport (packages/desktop-app/src-tauri/src/services/grpc_client.rs) and the daemon's server-side pipe setup (packages/daemon/src/main.rs).
  • connect() / connect_import() / connect_session() / connect_local_agent() / connect_database() and the run() dispatch are a single, non-duplicated cross-platform implementation — they only call dial_channel(&sock), so the platform branch lives in exactly one place instead of being copy-pasted per helper.
  • resolve_pipe_name(override_: Option<&str>) -> String resolves --socket → NODESPACED_SOCKET env → default \\.\pipe\nodespace-daemon, the Windows counterpart of the existing Unix-only resolve_socket_path() — kept separate rather than unified since the two transports resolve differently (Unix probes several build-variant socket files on disk; the pipe namespace is machine-global with nothing to probe).
  • Removed the #[cfg(windows)] anyhow::bail! stub; there is now one run() for both platforms.
  • Regenerated packages/skill/references/cli.md (generated from the CLI's own clap definitions) for the updated --socket flag help text.
  • Added #[cfg(windows)] unit tests for resolve_pipe_name's override/env/default resolution order.

Closes #1452.

Real Windows verification

I have real SSH access to an actual Windows 11 machine (build 26200) on the same Tailscale network this session, specifically to build and test this for real rather than only cross-referencing docs.

Environment gap hit and how it was worked around: nodespace-cli's binary cannot currently be linked on this Windows box, because it depends on nodespace-daemon (for re-exported client types), which has a mandatory (non-optional, default-on-feature) dependency on nodespace-nlp-engine → llama-cpp-2/llama-cpp-sys-2, which needs bindgen, which needs libclang — not installed on this machine, and installing LLVM was blocked by this session's safety classifier (the same class of restriction that blocked setting up git-push credentials on this box — installing a new heavy toolchain judged too sensitive to route around silently). This is a real, pre-existing environment gap, unrelated to this change (the GNU Rust toolchain's own C compiler, mingw64 gcc, was present and used successfully once put on PATH, fixing a separate libsql-ffi build error along the way).

Given that, I isolated and verified the actual new/changed transport code end-to-end for real, instead of only reasoning about it:

  1. Built the real, unmodified nodespace-daemon/nodespace-cli as far as they'd go, confirming exactly where the pre-existing libclang gap bites (not related to this change):

    thread 'main' (8144) panicked at ...\bindgen-0.72.1\lib.rs:616:27:
    Unable to find libclang: "couldn't find any valid shared libraries matching: ['clang.dll', 'libclang.dll'] ..."
    
  2. Wrote a small standalone harness crate (pipe-verify, not part of the workspace, never committed) containing a byte-for-byte copy of:

    • the new resolve_pipe_name() and the Windows dial_channel() from packages/cli/src/lib.rs (client side), and
    • the NamedPipeConn/ServerOptions Named Pipe server plumbing from packages/daemon/src/main.rs (server side, serving the standard tonic-health gRPC service instead of the full daemon service graph, which is what pulls in nlp-engine).

    This builds cleanly on the Windows box with the GNU toolchain (no bindgen/libclang needed — tonic/tokio/hyper-util/tower only) and exercises the exact same tokio::net::windows::named_pipe::ClientOptions::open() → hyper_util::rt::TokioIo → tonic::transport::Endpoint::connect_with_connector wiring this PR adds, against the exact same ServerOptions::new().first_pipe_instance(false).create(&name) / server.connect() pattern the real daemon uses.

  3. Ran both for real, over SSH, on the Windows box:

    === Starting pipe-server.exe (background) ===
    === Running pipe-client.exe (foreground, real output below) ===
    [client] Resolved pipe name: \\.\pipe\nodespace-daemon
    [client] Dialing nodespaced over Named Pipe at \\.\pipe\nodespace-daemon ...
    [client] Connected. Channel established over Named Pipe transport.
    [client] Real gRPC round trip over Named Pipe succeeded. HealthCheckResponse = HealthCheckResponse { status: Serving }
    CLIENT_EXIT=0
    === Server stdout log ===
    [server] Starting verification pipe server on \\.\pipe\nodespace-daemon
    [server] Health service marked SERVING
    [server] gRPC server listening (Named Pipe) -- waiting for one client call
    [server] Client connected over Named Pipe
    === Server stderr log ===
    === Done ===
    

    This is a genuine client process connecting to a genuine server process over a real Windows Named Pipe, completing a real gRPC unary RPC round trip — using this PR's actual transport-dialing code, unmodified.

  4. Only the MSVC target was not evaluated (Visual Studio Build Tools / cl.exe is not installed on this box and installing it was out of scope per the task's own guidance) — CI/release Windows builds should confirm the MSVC target separately; nothing in this change is toolchain-specific (tokio::net::windows::named_pipe behaves identically under both ABIs).

Test plan

  • bun run test baseline: 240 files / 4951 tests passed
  • bun run test:all: full unit + browser + Rust suite, no new failures
  • bun run quality:fix: cargo fmt + cargo clippy --all-targets -D warnings -D clippy::unused-async clean
  • macOS/Linux path unaffected — cargo build -p nodespace-cli and cargo test -p nodespace-cli --lib (107 tests) still pass unchanged on the Unix side
  • Windows Named Pipe client transport verified end-to-end for real on a physical Windows 11 machine (see above) — genuine connect + genuine gRPC round trip, not a simulation

🤖 Generated with Claude Code

The nodespace CLI's run()/connect*() helpers were gated #[cfg(unix)]
around a Unix Domain Socket-only transport, with a Windows run()
falling straight to anyhow::bail!. Add a Windows Named Pipe client
transport that dials the same \\.\pipe\nodespace-daemon pipe the
daemon already serves (packages/daemon/src/main.rs, added in #1440),
mirroring the desktop app's own client-side pipe transport
(packages/desktop-app/src-tauri/src/services/grpc_client.rs).

- dial_channel() is now platform-gated internally (UnixStream on
  Unix, tokio::net::windows::named_pipe::ClientOptions on Windows)
  behind one shared signature, so connect()/connect_import()/
  connect_session()/connect_local_agent()/connect_database() and the
  run() dispatch stay a single, non-duplicated cross-platform
  implementation rather than parallel per-platform copies.
- resolve_pipe_name() resolves --socket/NODESPACED_SOCKET/default on
  Windows, mirroring resolve_socket_path()'s Unix-only override chain.
- Regenerated packages/skill/references/cli.md for the updated
  --socket flag help text.

Closes #1452.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Named Pipe transport to nodespace CLI for Windows support

1 participant