feat(trader): add sphere trader command tree (mirrors trader-ctl)#5
Merged
feat(trader): add sphere trader command tree (mirrors trader-ctl)#5
Conversation
The canonical trader-cli is bin/trader-ctl in vrogojin/trader-service. sphere-cli ships this as a mirror so operators don't need to install another tool; canonical trader-ctl users keep using their tool. Same pattern as sphere host (HMCP). ## What - src/trader/trader-commands.ts — createTraderCommand() commander tree with 7 subcommands: create-intent, cancel-intent, list-intents, list-deals, portfolio, set-strategy, status - src/trader/acp-protocols.ts — ACP-0 types + typed payload guards (mirror of trader-service/src/protocols/acp.ts) - src/trader/acp-envelope.ts — parseAcpJson + isTimestampFresh + hasDangerousKeys + 64KiB size cap - src/trader/acp-transport.ts — ACP DM transport (correlates by command_id, distinct from HMCP's in_reply_to-correlated transport) - src/shared/timeout-constants.ts — MIN_TIMEOUT_MS=100 shared with agentic-hosting tenant dispatcher - src/index.ts — wire createTraderCommand() next to createHostCommand() - README — add sphere trader to status table + quickstart examples ## Why a separate transport sphere-cli's existing dm-transport.ts is HMCP-shaped (correlates by in_reply_to, parses HMCP envelope). The trader uses ACP-0 (correlates by command_id, parses ACP envelope). The two diverge enough to warrant distinct files; the existing transport stays untouched. ## Tests 50 → 94 (+44 new across trader-commands + the protocol/envelope module tests that come with the new files). All lint + typecheck + build clean. `bin/sphere.mjs trader --help` lists all 7 subcommands. ## Cross-repo coordination trader-service (vrogojin/trader-service) owns the canonical command surface; this PR mirrors that surface. If trader-service's commands evolve, this mirror needs an update; flag in PR description if you change command shapes there.
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
Mirrors the canonical `trader-ctl` from vrogojin/trader-service as a built-in sphere-cli command tree. Same pattern as `sphere host` (HMCP). Operators using the canonical tool can keep using it; this is convenience parity.
7 subcommands
Shared globals (inherited): `--tenant`, `--json`, `--timeout` (with MIN_TIMEOUT_MS=100 floor).
Files added
Why a separate transport
sphere-cli's existing `dm-transport.ts` is HMCP-shaped. ACP and HMCP envelopes + correlator keys differ enough to warrant separate files. The existing host transport is untouched.
Tests
Cross-repo coordination
`trader-service` (vrogojin) owns the canonical command surface. If commands evolve there, this mirror needs an update.