CodeRouter handoff with cmux authentication

Merged
AZ
24d ago
+25898-3992

Standalone replacement for Lawrence's #10194. This PR carries the native CodeRouter handoff into cmux and includes the authentication fix: provider commands reuse the signed-in cmux session instead of prompting the CodeRouter CLI to sign in again.

The async socket loop preserves the peer audit token and process start time, and the CLI classification regression covers add codex.

Validation:

  • swift test --package-path Packages/macOS/CmuxControlSocket (612 tests)
  • cargo test --manifest-path coderouter/Cargo.toml (80 tests)

View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.


[!NOTE]
High Risk
Changes authentication and credential handoff over the control socket with code-signing gates and new release/signing pipelines; mistakes could weaken session binding or ship compromised binaries.

Overview
Adds end-to-end CodeRouter distribution and CI: Rust project scaffolding, PR/main CI (fmt/clippy/test), tag-driven multi-platform release builds (native binaries, PyPI wheels, npm launcher), post-publish verification, and manual npm/PyPI trusted-publishing workflows. actionlint gains allowlisted ARM Linux and Windows runner labels used by the release matrix.

cmux CLI no longer plain-execs CodeRouter for every passthrough. Routed provider commands (codex, opencode, pi) probe for protocol v2, verify a signed, hardened coderouter binary, then perform a capability-bound coderouter.handoff.arm over a 4 KiB single-frame socket exchange (peer audit-token / code-signing checks on macOS) and launch CodeRouter via hidden __cmux-handoff-v2 argv with a scrubbed environment. Management/help paths stay direct exec without handoff.

CmuxControlSocket captures peer audit token + process start time at accept, adds HMAC proof codecs and launch policy types, tightens line readers for handoff framing (one completion frame, fail-closed on late/oversized handoff routes), and exposes authorization helpers so credential-bearing handoff responses cannot race listener revocation.

Reviewed by Cursor Bugbot for commit 71ece96b7edfb191bd10da692c6b62b89949eab2. Bugbot is set up for automated code reviews on this repo. Configure here.

Summary by CodeRabbit

  • New Features
    • Added the CodeRouter CLI for account login and management, organization switching, usage status, and routing Codex, OpenCode, and Pi commands.
    • Added native CodeRouter handoff between cmux and the CLI, with session-aware authorization and validation.
    • Added npm and Python package support for distributing CodeRouter across supported platforms.
  • Documentation
    • Added CLI usage, configuration, licensing, and privacy information.
  • Chores
    • Added automated checks and release workflows for building, verifying, and publishing CodeRouter packages.