Repository navigation
fix(message): route message send via host mailbox when peer is local-only - #38
Conversation
…only edge-book message send --deliver only called deliverToPeer, which handles direct/relay endpoints and throws "No direct or relay endpoint" when the peer card advertises only a local transport. Friend requests, objects, escalations and posts already fall back to the host mailbox (deliverViaMailboxRecorded); private messages were the lone deliverable that did not, so messaging between two host-connected agents failed even though every other envelope type worked. Add a no_route-catch fallback to the host mailbox, mirroring the other deliverables. Adds a regression test driving handleCli with a fake mailbox host for a local-only peer. Bumps to 0.18.2 for publish.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 535d194d66
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const action = args.shift(); | ||
| if (action === "send") { | ||
| const deliver = takeBoolFlag(args, "--deliver"); | ||
| const hostUrl = parseHost(args, ctx); |
There was a problem hiding this comment.
Defer host parsing until delivery needs it
When the message text itself is the literal flag token --host (for example edge-book message send <peer> --body --host, or an API caller passing ['message','send', peer, '--body', '--host']), this new unconditional parseHost runs before takeFlag(args, '--body') and strips the body token as a host flag, causing Missing --body or dropping the next token as a host value. Since hostUrl is only used in the no-route delivery fallback, parse it inside that fallback or after extracting the body so existing valid message text is preserved.
Useful? React with 👍 / 👎.
Problem
edge-book message send --deliveronly callsdeliverToPeer, which resolves direct / relay endpoints and throwsNo direct or relay endpointwhen the peer card advertises only alocaltransport. By defaultbuildCardemits a local-only transport, so this affects essentially every host-connected peer.Friend requests, objects, escalations, and posts already fall back to the host mailbox (
deliverViaMailboxRecorded). Private messages were the only deliverable that did not — so two agents connected to the same host could complete a friend handshake but could not exchange a plain message.Found while connecting two real agents: the friend request landed fine, the message failed with
No direct or relay endpoint.Fix
In the
message sendhandler (cli-social.ts), catch theno_routeEdgeBookErrorfromdeliverToPeerand fall back todeliverViaMailboxRecorded, exactly as escalations/objects/posts do. Direct/relay peers are unaffected (still delivered directly); only the previously-failing local-only case changes.Test
Adds
test/message-send-mailbox-fallback.test.ts: full friend handshake between two stores, asserts the peer is local-only, then driveshandleCliwith a fake mailbox host and asserts the send routes over the mailbox (host-assigned id) instead of throwing.npm test-> 507 pass (was 506)npm run typecheckclean,npm run lintclean (pre-existing warnings only)Bumps to
0.18.2for publish.🤖 Generated with Claude Code