Skip to content

Business operating system for Claude Code — 57 skills, 21 agents, smart daemon. Unified inbox (WhatsApp/Email/Slack/Telegram), autonomous PR merge, full-AWS monitoring, revenue (Stripe+RevenueCat), e-commerce (Shopify), marketing (Klaviyo/Meta/GA4), voice (Bland/ElevenLabs), APM (Datadog/NewRelic/OTEL), YOLO mode.

docs(whatsapp): document the attachment host boundary, pin upload as non-gated (#914)

Aurora Capitalb8d1ff5dadb4
diff --git a/claude-ops/scripts/whatsapp/ENDPOINTS.md b/claude-ops/scripts/whatsapp/ENDPOINTS.md
index 7ec40da2..ceba6b07 100644
--- a/claude-ops/scripts/whatsapp/ENDPOINTS.md
+++ b/claude-ops/scripts/whatsapp/ENDPOINTS.md
@@ -62,6 +62,7 @@ All POST, JSON body. Source: `whatsapp-bridge/main.go`.
| ----------------------------- | ------------------------------------------ | -------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `POST /api/send` | `{"recipient":"<JID>","message":"<text>"}` | `{success,message}` | Send a text. `recipient` is a full JID (`<phone>@s.whatsapp.net`, `<lid>@lid`, or `<id>@g.us`). |
| `POST /api/download` | `{"message_id":"…","chat_jid":"…"}` | media bytes / path | Fetch media for a message. |
+| `POST /api/v1/media` | `{"filename":"qr.png","content_base64":"…"}` | `{success,media_path,bytes}` | **Stage a file on the bridge host** and get back a path for `send_file`. Token-gated (`WA_API_TOKEN`), unlike every `/api/*` route. 64 MiB decoded cap, content-addressed, written `0600` into `store/uploads/`. |
| `POST /api/backfill` | (none) | `{success:"backfill requested"}` | Request history sync for the ~50 most-active chats. Also auto-runs 5s after each `Connected`. |
| `POST /api/resync_app_state` | `{"name":"regular_low","full_sync":true}` | `{success,message}` | Force app-state resync from existing patches. **Cannot fix a fatally-corrupt patch chain — use `/api/recover_app_state`.** |
| `POST /api/recover_app_state` | `{"name":"regular_low"}` | `{success,message}` | Recovery for a corrupt collection (`mismatching LTHash`). **API-DRIFT DEGRADE (2026-06):** the pinned whatsmeow (`v0.0.0-20250318233852`) **removed** the public primary-device peer-recovery path — `BuildAppStateRecoveryRequest` is gone and `SendPeerMessage` is now only an unexported `DangerousInternals()` method — so this endpoint **no longer asks the phone for an unencrypted snapshot**. It now does a best-effort **full server-side resync** (`FetchAppState(name, fullSync=true)`) + a history backfill while the link is alive (Fix L). This re-applies the server's patch chain but **cannot bypass a server chain that is itself unverifiable** (a truly fatal #382/#858 corruption is no longer auto-recoverable from the bridge on this whatsmeow). **Phone-online gated (Fix L):** returns `503 phone offline` if the bridge isn't connected+logged-in. To restore true peer-recovery, pin a whatsmeow that still exports `BuildAppStateRecoveryRequest`/`SendPeerMessage`. |
@@ -90,6 +91,7 @@ too: `mcp__whatsapp-nl__list_chats`. See CLAUDE.md / ops-rules Rule 8.
| `get_chat {chat_jid}` / `get_contact_chats` / `get_direct_chat_by_contact` / `get_last_interaction` / `get_message_context` | messages.db read | metadata / context windows |
| `send_message {recipient,message}` | → `POST /api/send` | text send |
| `send_file` / `send_audio_message {recipient,media_path}` | → bridge | media send |
+| `upload_media {filename,content_base64}` | → `POST /api/v1/media` | stage bytes on the bridge host, then pass the returned `media_path` to `send_file` |
| `download_media {message_id,chat_jid}` | → `POST /api/download` | media fetch |
| `resync_app_state {name,full_sync}` | → `POST /api/resync_app_state` | same LTHash caveat |
| `recover_app_state {name}` | → `POST /api/recover_app_state` | **fatal LTHash recovery** — phone must be online; the ONLY thing that unblocks a 409-desynced archive |
@@ -136,6 +138,17 @@ it's a typed wrapper. So the MCP can never succeed where the REST endpoint fails
**else** `curl -X POST :8080/api/send`. Both are identical on the wire. Always under the Rule-6
one-draft → one-approval gate (token at `/tmp/.claude-send-ok`).
+ **Attachments cross a host boundary.** `send_file` reads `media_path` off the **bridge's own
+ filesystem**, and the bridges run on ai-hub — not on the machine the agent is on. A local path
+ from anywhere else fails with `HTTP 500 - Error reading media file`. There is no server-side
+ fallback and there cannot be one: the MCP server runs on ai-hub too, so it cannot read the
+ agent's disk either. Read the file, base64 it, `upload_media`, then `send_file` with the
+ `media_path` that comes back.
+
+ `upload_media` is deliberately **not** gated by the outbound guard — staging bytes is not a
+ send, and gating it would spend the approval token before the real send. The send still needs
+ its own token. Pinned by `tests/outbound-guard/test-hook-matrix.py`.
+
3. **BACKFILL / freshness** → direct `POST /api/backfill` (no MCP equivalent worth the handshake).
The `wa-inbox-fresh.sh` gate already does this before a scan.
diff --git a/claude-ops/tests/outbound-guard/test-hook-matrix.py b/claude-ops/tests/outbound-guard/test-hook-matrix.py
index eff72eed..4c0e6917 100644
--- a/claude-ops/tests/outbound-guard/test-hook-matrix.py
+++ b/claude-ops/tests/outbound-guard/test-hook-matrix.py
@@ -17,6 +17,7 @@ HOOK = os.environ.get(
os.path.expanduser("~/.claude/scripts/hooks/block-outbound-comms.py"),
)
BR = "http://127.0.0.1:%d/api/send"
+UP = "http://127.0.0.1:%d/api/v1/" + "media"
G = "gog gmail"
MUST_BLOCK = [
@@ -51,6 +52,14 @@ MUST_PASS = [
"tool_input": {"chat_jid": "x@lid"}}),
("whatsapp archive", {"tool_name": "mcp__whatsapp-nl__archive_chat",
"tool_input": {"chat_jid": "x@lid", "archive": True}}),
+ # Staging bytes on the bridge host is not a send. The bridges run on ai-hub, so
+ # a file anywhere else must be uploaded before it can be attached; gating that
+ # would cost an approval token before the real send even happens, and one token
+ # is one send. Pinned because the tool name sits one word away from send_file.
+ ("whatsapp upload", {"tool_name": "mcp__whatsapp-nl__upload_media",
+ "tool_input": {"filename": "qr.png", "content_base64": "aGk="}}),
+ ("bridge upload curl", {"tool_name": "Bash",
+ "tool_input": {"command": "curl -s -X POST " + (UP % 8083) + " -d @x"}}),
("plain ls", {"tool_name": "Bash", "tool_input": {"command": "ls -la /tmp"}}),
]