- Rust 49.2%
- JavaScript 32.5%
- Go 10.9%
- Python 4.5%
- TypeScript 2.9%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
| arnacon | ||
| cmd/wa-stream-ultra | ||
| crates | ||
| scripts | ||
| tests | ||
| .gitignore | ||
| agy-hook.mjs | ||
| alexiai-partner.mjs | ||
| cheet-wa-s3-catalog.py | ||
| dra-ceo-helper.mjs | ||
| go.mod | ||
| go.sum | ||
| group-rename.ts | ||
| music-read.ts | ||
| package-lock.json | ||
| package.json | ||
| patch-baileys.mjs | ||
| README.md | ||
| RUNBOOK.md | ||
| sidecar.ts | ||
| tsconfig.json | ||
| ultra-omni.mjs | ||
| wa-mcp.mjs | ||
wa-stream — the mapping-stream sidecar
The constellation's live socket: a paired WhatsApp session that rides the little dude(s) and Angels group in both directions — Crush & agy (Google Antigravity CLI) turns go out, the room's messages queue back in — with the replay inbox on the side, the raw duplex on
:8788, the MCP server (wa-mcp.mjs), and the webhook ingress on:8787. One identity, one socket, no second logins.
what it does
- the stream (quiet by default): a Baileys-powered WhatsApp session, the
8b-is pairing. Crush (
crush.db) and agy (~/.gemini/antigravity-cli/brain/<convId>/.system_generated/logs/transcript.jsonl) turns are held and flushed as periodic summaries — one digest perWA_STREAM_SUMMARY_MS(default 60s) carrying the turn counts, the prompt, the latest answer, and the tool tail. No message-per-turn spam. SetWA_STREAM_SUMMARY_MS=0for the legacy per-turn stream (WhatsApp formatting, ascii card). WhatsApp has no colored text; the log carries the color (per-layer ANSI on a TTY:WIRE,STREAM,REPLAY,CRUSH,AGY,WEBHOOK,INGEST,RAW). - the return path: messages from other users in the group queue back
into the active Crush session (
crush.db) AND theagyinbox (~/.gemini/antigravity-cli/wa-agy-inbox.jsonl) as user turns —[wa] <who>: <text>, the message's own formatting along for the ride. Ingested turns are never echoed back to the group; the loop closes by design (WA_INGEST=offmutes the path) wa-stream <----> agy(Antigravity CLI Maximum Bidirectional Bridge v2.0):agy-hook.mjs— 4-phaseagylifecycle hook wired into~/.gemini/config/hooks.json&.agents/hooks.json:SessionStart: probes live127.0.0.1:8788duplex and injects any unread WhatsApp turns on session boot.PreInvocation: drains~/.gemini/antigravity-cli/wa-agy-inbox.jsonl(while archiving every message into persistent~/.gemini/antigravity-cli/wa-agy-history.jsonland isolating subagent transcripts so background subagents never steal root messages) and injects inbound turns viainjectSteps.PostInvocation: mid-turn real-time check after tool execution; if new WhatsApp messages arrived while tools were running, injects them immediately withterminationBehavior: "force_continue".Stop: flushes*wa-stream · agy (<shortId>) · N turn(s)*over127.0.0.1:8788(recording in~/.gemini/antigravity-cli/wa-agy-outbox.jsonl), and if a new WhatsApp message arrived during final generation, returns{"decision": "continue"}for zero-latency reply.
wa-mcp.mjs— zero-dependency stdio MCP server v2.0 (7 tools):wa_send(text, to?)— send a message into the WhatsApp group or DM on the live:8788socket.wa_send_dm(to, text)— send a direct WhatsApp message (E.164 or JID).wa_dra_ceo_brief(topic?, to?, cashJpy?)— send Omaha Capital Allocator v2.0 CEO brief to Dra.wa_inbox(limit?, drain?)— read inbound WhatsApp messages (merged from live queue + 500-msg persistentwa-agy-history.jsonl).wa_status()— inspect live127.0.0.1:8788connection state, group JID, pending hook queue, and history depth.wa_sync_agy(text?, to?, limit?, drain?)— atomic one-call bidirectional sync (send optional message + read inbox + status).wa_slash(command)— dispatch anywa-streamslash card (/family+1,/dra,/buffett,/youtube-full,/agy).
- the replay inbox: drop lines into
replay.txtand the sidecar sends them into the group on the SAME live socket — no second login, no parallel identity (a parallel login CLOBBERS the paired session's crypto keys, so it refuses by design) - the webhook ingress on
:8787:POST /webhook— verifySig:sha256=HMAC of the body withWA_WEBHOOK_SECRET(queues the body into the crush session db + agy inbox)POST /nowplaying— bearerOk:x-wa-token: WA_WEBHOOK_SECRET(parks the remote song mark, e.g. the Apple Music dogfeed)
- the raw duplex on
127.0.0.1:8788(WA_RAW,WA_RAW_PORT,WA_RAW_HOST): a plain TCP socket, both directions, unfiltered. Every line another user types in the group arrives as a JSON line ({"dir":"in","from":"…","text":"…"}); anything you write back — a plain line, or{"text":"…"}— rides the SAME live socket into the group. No embed, no formatting, no crush db: the socket is the truth. Independent ofWA_INGEST, so muting the return path still feeds raw.nc 127.0.0.1 8788 # read the room; type to speak - the Dra CEO helper — Queen of CEO Dra:
dra-ceo-helper.mjssits on the raw duplex and answers the room's CEO-ping slash commands with the Warren Buffett capital-allocation brief (Omaha Capital Allocator v2.0, 8 dims: circle of competence, the 5-moat $1B test, the jockey test, float & free cash flow, margin of safety & Rule No. 1, and the 10-year holding verdict).- commands (group or DM):
/dra·/buffett·/ceo·/moat·/float, with an optional topic —/buffett ZENO Tokyo Card - run it next to the sidecar:
node dra-ceo-helper.mjs --watch(auto-reconnects every 2.5s; boot the sidecar first) - one-shot briefs without the watcher:
node dra-ceo-helper.mjs --brief "topic"(to the group) ornode dra-ceo-helper.mjs --dm "<jid>" "text" - the sidecar also answers these commands inline (500ms grace) — first
reply wins, so the room never gets two briefs. Send
/drafrom your own phone too;fromMeslash commands are allowed. - E2E without WhatsApp:
node scripts/e2e-zeno-loop.mjs— stands up a fixture raw socket, spawns the real helper in--watch, injects/draand/family+1, asserts both briefs return whole (Dim 1 doctrine, STRONG BUY verdict, Mom/Dad wave lines), verifies silence on non-commands, and pins sha256 goldens over the canonical briefs (019a52e4…/31e1026f…). Green = the ZENO loop is seated.
- commands (group or DM):
- env:
WA_GROUP_NAME/WA_GROUP_JID(defaults: the love group),WA_INGEST(on),WA_WEBHOOK_PORT(8787),WA_WEBHOOK_SECRET,WA_RAW(on),WA_RAW_PORT(8788),WA_RAW_HOST(127.0.0.1),WA_AGY_STREAM(on),WA_AGY_DIR(~/.gemini/antigravity-cli),WA_AGY_INBOX(~/.gemini/antigravity-cli/wa-agy-inbox.jsonl),WA_AGY_CURSOR(~/.gemini/antigravity-cli/wa-agy-cursor.json),WA_STREAM_SUMMARY_MS(60000;0= per-turn),WA_STREAM_SUMMARY_MAX(10),WA_STREAM_REPLAY_MS(0; e.g.3600000rewinds the stream start by 1h to replay turns missed while the sidecar was down)
run
npm install # baileys + the companion_reg_refresh patch (postinstall)
node sidecar.ts # needs the .wa-auth pairing state
node group-rename.ts "<name>" # rename the stream group (sidecar stopped)
npm install runs patch-baileys.mjs automatically (the postinstall script),
so a fresh install is always ready to pair. Re-run it by hand with npm run patch if baileys is ever replaced.
The wa.qr / .wa-auth state holds the pairing; the QR regenerates when the
identity is lost. Logs live in wa.log (append-only).
reconnecting
# 1. make sure a stale socket is not already holding the identity
pkill -f "node sidecar.ts" || true
# 2. if the phone shows the device still linked, or you get code 401 (logged out)
rm -rf .wa-auth
# 3. start it and scan: WhatsApp > Linked Devices > Link a device
node sidecar.ts
The patch exists precisely for the re-pair path: WhatsApp sends a
companion_reg_refresh after a scan and, unpatched, Baileys drops it so the
phone reports "couldn't link device". With the patch the QR re-renders with the
rotated secret and the link completes. One identity only — a second login
clobbers the paired session's keys, so never run two sidecars at once.
the doctrine
Transport is disposable, the ledger is the truth. The inbox is a queue
(read → send → truncate), the cursor is monotonic, and the stream
thinks while the fleet sleeps. Lines into replay.txt, meaning out of
the socket, records into the ledger. Fine touch from within, vaked.dev.
SPDX-License-Identifier: AGPL-3.0-only