Repository navigation
feat(captain-msg): add two-way captain messaging over Twilio RCS for Business - #42
Merged
Merged
Conversation
…Business Give the captain a text channel to firstmate that his Tesla can read aloud and take dictated replies through, sharing the existing ClickStack/ BetterStack webhook receiver and durable wake-queue plumbing.
…inst the live account Live read-only inspection (messaging.twilio.com, the account's own Messages.json) confirmed the real account has no Messaging Service, uses the corrected 1Password item names, and that Twilio's actual inbound "From" is channel-prefixed (rcs:+<E.164>), which the original inbound From-match would have wrongly rejected. Adds CAPTAIN_MSG_FROM_ADDRESS as an alternative to CAPTAIN_MSG_MESSAGING_SERVICE_SID (exactly one required) and strips the rcs: prefix before comparing inbound From to the configured destination.
Bre77
added a commit
that referenced
this pull request
Jul 29, 2026
…#45) * feat(provenance): label fleet PRs and drop Claude's co-author trailer The captain's commits now carry a single identity everywhere, so fleet work needs metadata-based provenance instead: an "fm" PR label (name configurable via config/pr-label) applied once fm-pr-check.sh records pr=, covering every delivery mode that opens a PR (no-mistakes, direct-PR, fork-only) from one call site, degrading to a stderr warning rather than ever losing a PR. Claude Code injects its own Co-Authored-By trailer regardless of AGENTS.md's no-agent-co-author rule; fm-spawn.sh now scopes --settings '{"attribution":{"commit":""}}' to every claude crewmate/secondmate launch, verified empirically against a real self-drafted commit. Codex and opencode were checked and do not inject an equivalent trailer in firstmate's actual launch shape; pi, grok, and kimi were unavailable to check and are left unverified rather than guessed at. * fix(tests): restore the executable bit on fm-captain-msg.test.sh Committed as mode 100644 by #42/#44, so bin/fm-fork-deliver.sh's local gate (which execs each tests/*.test.sh directly) hits Permission denied; real CI is unaffected since bin/fm-test-run.sh invokes tests via `bash "$script"`.
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.
Intent
bin/fm-captain-msg.shenforces a strict speech contract in the tool itself (plain text only, no URLs, no markdown, no code fences, <=300 chars) before it ever calls Twilio, since every outbound message gets read aloud by a car or headset./captain-msgpath instead of standing up a new daemon, mirroring PR feat(webhooks): add BetterStack status-page webhook route #14's reasoning exactly - the reverse proxy forwards the whole host to one port, so a second listener would be unreachable without an out-of-repo change.bin/fm-clickstack-recv.sh/bin/fm-clickstack-arm.shnow start the shared daemon when any of the three gates is present, and the listener dispatches by path, 404-ing each route independently unless its own gate is present.twilio-python, sincepip/the package itself was not available in this fork's build environment and the daemon deliberately carries no dependencies. Verified byte-for-byte against Twilio's own documented canonical test vector.Frommust additionally match the configured captain number even with a valid signature - defense in depth beyond "this Twilio account sent it."cmd_serveconfig resolution was caught by re-running them and fixed before this PR).bin/fm-captain-msg-lib.sh(config + speech contract + 1Password lookups),bin/fm-captain-msg.sh(the send tool),bin/fm-captain-msg-poll.sh(watcher check shim),bin/fm-captain-msg-arm.sh(always restarts the shared daemon on arm, since the Account Auth Token is fetched fresh from 1Password on every daemon start rather than cached),docs/captain-messaging.md(authority contract, speech contract, setup, config schema),.agents/skills/captain-msg-response/SKILL.md,tests/fm-captain-msg.test.sh.docs/captain-messaging.md): a verified inbound reply carries the captain's authority for routine, reversible actions only, exactly like any other trusted channel - destructive/irreversible/security-sensitive actions still need the captain's explicit word elsewhere.Twilio API key(a Restricted API Key, for outbound sends) andTwilio Auth token(the Account Auth Token, for inbound signature validation) - Twilio always signs webhooks with the Account Auth Token, never an API key secret, so one credential cannot serve both purposes.CAPTAIN_MSG_FROM_ADDRESS, e.g.rcs:teslemetry_fwz8vdzw_agent), which also means the real inboundFromTwilio sends is channel-prefixed (rcs:+<E.164>); the config schema and the inboundFrom-match both account for this (CAPTAIN_MSG_MESSAGING_SERVICE_SIDstays supported as an alternative for an account that has one - exactly one of the two is required).Live verification and smoke test
Read-only inspection of the real account (
messaging.twilio.com/v1/Services, the account's ownMessages.json) confirmed the no-Messaging-Service shape and the corrected 1Password item names above, and surfaced the account's own history: a prior bare-number send with no Messaging Service had failed, whilercs:-prefixed direct addressing succeeded and was read.That evidence is what shaped the final config schema and the inbound-
Fromfix.The live smoke test was run for real with
bin/fm-captain-msg.shagainst the production sender and destination:sent: sid=SM86a3a59bbacd18d013bc58327c8c6ad4 status=queued, later confirmedstatus=delivered.Nothing remains for the captain except pasting the webhook URL into the Twilio console and filling in
config/captain-msg.envon the live instance (bin/fm-captain-msg-arm.sh --show-urlprints the exact URL once armed) - seedocs/captain-messaging.md"Setup".Testing
tests/fm-captain-msg.test.sh(new, 31 cases): speech-contract accept/reject (URLs, markdown, code fences, over-length, empty), send-tool config/argument validation withop/curlmocked (no live Twilio calls), theCAPTAIN_MSG_FROM_ADDRESS/CAPTAIN_MSG_MESSAGING_SERVICE_SIDexactly-one-of contract and their distinct request shapes, the real signature-validation algorithm against a live loopback listener (accept/reject/From-mismatch, with and without thercs:prefix), idempotent inbox naming and atomic writes, the realfm-clickstack-recv.sh-> mocked-1Password -> listener chain, the poll shim, and bootstrap activate/opt-out/incomplete-config reporting.tests/fm-clickstack.test.shandtests/fm-betterstack.test.sh(pre-existing, unmodified): both still fully green, confirming no regression to the two routes already live in production.bin/fm-lint.sh(shellcheck, the CI command): clean.bin/fm-doc-audience-check.sh: clean, withdocs/captain-messaging.mdanddocs/examples/captain-msg.envregistered indocs/documentation-audiences.json.Full narrative / original brief
FORK-ONLY: build firstmate's two-way captain messaging channel over Twilio RCS for Business. The captain provisioned it today: Twilio account credentials are in the 1Password CLI vault item "Twilio", the RCS sender is named "Teslemetry", a business sender with no phone number. His Android runs Google Messages (RCS-capable); his Tesla reads the phone's default messaging app aloud and takes dictated replies - that in-car experience is the product.
Read
data/rcs-twilio-claude-scout/report.mdfirst for the researched integration shape (twilio-python client + RequestValidator, adapt the fork's existing webhook-inbox-wake plumbing, build only thin send/receive surfaces); the RCS Business sender replaces that report's assumed AU mobile number.Build: a send tool with a strict speech contract, an inbound webhook route mirroring the existing ClickStack/BetterStack pattern with Twilio signature validation, an authority-contract doc, colocated tests with no live Twilio calls, and one authorized live smoke send if the destination config exists.
Delivered fork-only, never upstreamed.