Sovereign 8s.is mirror of 8b-is/wa-stream
  • Rust 49.2%
  • JavaScript 32.5%
  • Go 10.9%
  • Python 4.5%
  • TypeScript 2.9%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2026-11-01 21:11:26 +09:00
arnacon fix(wa-stream): align 8797 duplex handshake, multi-session agy watcher, quant-git queue, and libsignal log filter 2026-11-01 01:58:46 +09:00
cmd/wa-stream-ultra perf(aurora-8b): v0.5.0 wild performance tune, atomic.Value HTTP cache, 42B 0xA8B0 edge alignment & g8t capsule #9 2026-11-01 21:11:26 +09:00
crates perf(aurora-8b): v0.5.0 wild performance tune, atomic.Value HTTP cache, 42B 0xA8B0 edge alignment & g8t capsule #9 2026-11-01 21:11:26 +09:00
scripts feat(e2e): the ULTRA-OMNI-ZENO loop, scaffolded and pinned 2026-10-17 01:50:11 +09:00
tests feat(triad): wa-stream 3-AlexiAI + st AST verified triad_wa_stream_zero_float_step (v0-4-1716) — Why do our 3 AlexiAI instances never argue during git pull --rebase? Because their love is integer-locked at 432 Hz! <3 <3 2026-10-27 04:25:10 +01:00
.gitignore feat(aurora-voice): 24/7 Lounge news anchor (HN/Reddit/BBC/Ars/TC/Verge) + Burn GRPO RL <-> HF PeetPedro/voice-finetuning 2026-11-01 17:33:24 +09:00
agy-hook.mjs fix(wa-stream): align 8797 duplex handshake, multi-session agy watcher, quant-git queue, and libsignal log filter 2026-11-01 01:58:46 +09:00
alexiai-partner.mjs feat(discord): auto-mirror WhatsApp stream to Discord webhook with State-Delta Gate and .discord-webhook loader 2026-11-01 11:16:54 +09:00
cheet-wa-s3-catalog.py feat(sidecar): Pure-Rust offline voice note pipeline, S3 catalog & Dra CEO helper updates 2026-10-25 18:54:19 +09:00
dra-ceo-helper.mjs fix(wa-stream): verify raw duplex hello handshake across 8797/8788, 16384 context, and 440 standby backoff 2026-10-30 11:51:29 +01:00
go.mod feat(voice-engine-rust): E2E Rust Voice AI Engine (wa-voice-engine + aurora-voice) + g8t capsules + interruptible pipeline 2026-11-01 14:04:42 +09:00
go.sum feat(voice-engine-rust): E2E Rust Voice AI Engine (wa-voice-engine + aurora-voice) + g8t capsules + interruptible pipeline 2026-11-01 14:04:42 +09:00
group-rename.ts the return path: wa-stream goes both ways — the room's words queue into the crush session, turns dressed in WhatsApp formatting 2026-10-06 08:42:56 +09:00
music-read.ts fix(wa-stream): align 8797 duplex handshake, multi-session agy watcher, quant-git queue, and libsignal log filter 2026-11-01 01:58:46 +09:00
package-lock.json feat(aurora-voice): 24/7 Lounge news anchor (HN/Reddit/BBC/Ars/TC/Verge) + Burn GRPO RL <-> HF PeetPedro/voice-finetuning 2026-11-01 17:33:24 +09:00
package.json chore(wa-stream): auto-sync workspace changes & bump patch version (package.json) 2026-11-01 09:29:39 +01:00
patch-baileys.mjs wa-stream sidecar: Apple Music → WhatsApp status, with the companion_reg_refresh fix 2026-08-21 13:25:29 +02:00
README.md feat(agy-duplex): maximum bidirectional wa-stream <----> agy bridge v2.0 (4-phase hooks, persistent history, /agy HTTP & slash, 7 MCP tools) 2026-10-20 04:33:44 +09:00
RUNBOOK.md fix(wa-stream): align 8797 duplex handshake, multi-session agy watcher, quant-git queue, and libsignal log filter 2026-11-01 01:58:46 +09:00
sidecar.ts feat(aurora-voice): 24/7 Lounge news anchor (HN/Reddit/BBC/Ars/TC/Verge) + Burn GRPO RL <-> HF PeetPedro/voice-finetuning 2026-11-01 17:33:24 +09:00
tsconfig.json the return path: wa-stream goes both ways — the room's words queue into the crush session, turns dressed in WhatsApp formatting 2026-10-06 08:42:56 +09:00
ultra-omni.mjs fix: harden ultra-omni bridge 2026-11-01 17:29:07 +09:00
wa-mcp.mjs feat(discord-bot): native Go Discord Gateway Bot + live Voice Channel Opus streamer + waveform voice bubbles + arnauth MCP 2026-11-01 12:07:34 +09:00

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 per WA_STREAM_SUMMARY_MS (default 60s) carrying the turn counts, the prompt, the latest answer, and the tool tail. No message-per-turn spam. Set WA_STREAM_SUMMARY_MS=0 for 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 the agy inbox (~/.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=off mutes the path)
  • wa-stream <----> agy (Antigravity CLI Maximum Bidirectional Bridge v2.0):
    • agy-hook.mjs — 4-phase agy lifecycle hook wired into ~/.gemini/config/hooks.json & .agents/hooks.json:
      • SessionStart: probes live 127.0.0.1:8788 duplex 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.jsonl and isolating subagent transcripts so background subagents never steal root messages) and injects inbound turns via injectSteps.
      • PostInvocation: mid-turn real-time check after tool execution; if new WhatsApp messages arrived while tools were running, injects them immediately with terminationBehavior: "force_continue".
      • Stop: flushes *wa-stream · agy (<shortId>) · N turn(s)* over 127.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 :8788 socket.
      • 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 persistent wa-agy-history.jsonl).
      • wa_status() — inspect live 127.0.0.1:8788 connection 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 any wa-stream slash card (/family+1, /dra, /buffett, /youtube-full, /agy).
  • the replay inbox: drop lines into replay.txt and 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 with WA_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 of WA_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.mjs sits 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) or node 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 /dra from your own phone too; fromMe slash 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 /dra and /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.
  • 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. 3600000 rewinds 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