refactor: two binaries — amesh (CLI) + amesh-agent (server superset) - #13
Merged
Conversation
… start in CLI One package, one binary, one install: - amesh shell <device> [-c cmd] — remote shell client (oclif command) - amesh agent start [--allow-root] [--idle-timeout] — daemon (oclif command) - All existing commands unchanged Removed @authmesh/shell package entirely. Shell cipher, handshake, frame, agent, and shell client code now lives in @authmesh/cli. 15 tests moved from shell package to CLI (shell-cipher: 8, frame: 7). Updated: ADR-011, landing page guide + use case, grant command text. All commands now use `amesh` prefix: `amesh shell`, `amesh agent start`.
Security fixes:
- B2: PTY output now wrapped in JSON {type:'data',payload:...} (was raw base64 — broken)
- C2: Bootstrap response whitelist fields (prevent JSON injection)
- M2: Frame parser rejects unknown frame types
- M3: Shell session OTC uses crypto.randomUUID() (was Math.random)
- L3: Idle timeout min bound (min: 1 minute)
Doc fixes:
- shell-client.ts error message: amesh-agent → amesh agent start
- CLAUDE.md: CLI description includes shell/agent/grant
- README.md: CLI package table includes shell/agent/grant
- CLI README: added shell, agent start, grant to commands list
- ADR-011: removed self-contradicting rejected alternative
- Removed ghost packages/agent/ directory
…sion
C1 fix — Agent registration now requires proof of key ownership:
1. Agent sends { type: 'agent', deviceId, publicKey }
2. Relay responds with { type: 'agent_challenge', challenge: randomUUID }
3. Agent signs challenge with private key, sends { type: 'agent_challenge_response', sig }
4. Relay verifies ECDSA-P256 signature against claimed publicKey
5. Only then registers the agent
An attacker who knows the publicKey cannot forge the signature.
Relay imports verifyMessage from @authmesh/core for verification.
H1 fix — Single session enforcement:
- Replaced maxSessions=5 + per-controller tracking with simple boolean flag
- sessionActive set before handshake, cleared in .finally()
- No race condition, no counter leaks, no session cross-contamination
Also: fixed Dockerfile.relay for consolidated workspace (removed shell ref)
Two separate packages, two separate binaries: - @authmesh/cli (amesh): init, listen, invite, list, revoke, grant, provision, shell - @authmesh/agent (amesh-agent): superset — all CLI commands + agent daemon CLI has no daemon code. Agent is a full copy of CLI + agent start command. ~400 lines of shared protocol code duplicated (shell-cipher, handshake, frame). Updated: README packages table, remote shell guide install section, agent README.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Final package architecture: two separate binaries, two separate npm packages.
amesh(@authmesh/cli) — controller binary:amesh-agent(@authmesh/agent) — server binary (superset of CLI):Install:
Security fixes included
Doc updates
amesh agent startnotamesh-agent startAfter merge
npm deprecate @authmesh/shell "Renamed. Use @authmesh/cli (controller) or @authmesh/agent (server)"Test plan
bun run build— 7 packages build (core, keystore, cli, agent, sdk, relay, landpage)