# π¦ CLAWDIS β WhatsApp & Telegram Gateway for AI Agents
EXFOLIATE! EXFOLIATE!
**CLAWDIS** is a TypeScript/Node gateway that bridges WhatsApp (Web/Baileys) and Telegram (Bot API/grammY) to a local coding agent (**Pi**).
Itβs like having a genius lobster in your pocket 24/7 β but with a real control plane, companion apps, and a network model that wonβt corrupt sessions.
```
WhatsApp / Telegram
β
βΌ
ββββββββββββββββββββββββββββ
β Gateway β ws://127.0.0.1:18789 (default: loopback)
β (control UI) β http://127.0.0.1:18789/ui/
β (single source) β tcp://0.0.0.0:18790 (optional Bridge)
βββββββββββββ¬ββββββββββββββββ
β
ββ Pi agent (RPC)
ββ CLI (clawdis β¦)
ββ Control UI (browser)
ββ macOS app (Clawdis.app)
ββ iOS node via Bridge + pairing
```
## Why "CLAWDIS"?
**CLAWDIS** = CLAW + TARDIS
Because every space lobster needs a time-and-space machine. The Doctor has a TARDIS. [Clawd](https://clawd.me) has a CLAWDIS. Both are blue. Both are chaotic. Both are loved.
## Features
- π± **WhatsApp Integration** β Personal WhatsApp Web (Baileys)
- βοΈ **Telegram (Bot API)** β DMs and groups via grammY
- π°οΈ **Gateway control plane** β One long-lived gateway owns provider state; clients connect over WebSocket
- π€ **Agent runtime** β Pi only (Pi CLI in RPC mode), with tool streaming
- π¬ **Sessions** β Direct chats collapse into `main` by default; groups are isolated
- π **Heartbeats** β Periodic check-ins for proactive AI
- π§ **Clawd Browser** β Dedicated Chrome/Chromium profile with tabs + screenshot control (no interference with your daily browser)
- π₯ **Group Chat Support** β Mention-based triggering
- π **Media Support** β Images, audio, documents, voice notes
- π€ **Voice & transcription hooks** β Voice Wake (macOS/iOS) + optional transcription pipeline
- π§ **Tool Streaming** β Real-time display (π»πβοΈπ)
- π₯οΈ **macOS Companion (Clawdis.app)** β Menu bar controls, Voice Wake, WebChat, onboarding, remote gateway control
- π± **iOS node** β Pairs as a node, exposes a Canvas surface, forwards voice wake transcripts
Only the Pi CLI is supported now; legacy Claude/Codex/Gemini paths have been removed.
## Network model (the βnew realityβ)
- **One Gateway per host**. The Gateway is the only process allowed to own the WhatsApp Web session.
- **Loopback-first**: the Gateway WebSocket listens on `ws://127.0.0.1:18789` by default.
- To expose it on your tailnet, set `gateway.bind: "tailnet"` (or run `clawdis gateway --bind tailnet`) and set `CLAWDIS_GATEWAY_TOKEN` (required for non-loopback binds).
- The browser Control UI is served from the Gateway at `http://:18789/ui/` when assets are built.
- **Bridge for nodes**: when enabled, the Gateway also exposes a bridge on `tcp://0.0.0.0:18790` for paired nodes (Bonjour-discoverable). For tailnet-only setups, set `bridge.bind: "tailnet"` in `~/.clawdis/clawdis.json`.
- **Remote control**: use a VPN/tailnet or an SSH tunnel (`ssh -N -L 18789:127.0.0.1:18789 user@host`). The macOS app can drive this flow.
- **Wide-Area Bonjour (optional)**: for auto-discovery across networks (Vienna β London) over Tailscale, use unicast DNS-SD on `clawdis.internal.`; see `docs/bonjour.md`.
## Codebase
- **TypeScript (ESM)**: CLI + Gateway live in `src/` and run on Node β₯ 22.
- **macOS app (Swift)**: menu bar companion lives in `apps/macos/`.
- **iOS app (Swift)**: iOS node prototype lives in `apps/ios/`.
## Quick Start
Runtime requirement: **Node β₯22.0.0** (not bundled). The macOS app and CLI both use the host runtime; install via Homebrew or official installers before running `clawdis`.
```bash
# From source (recommended while the npm package is still settling)
pnpm install
pnpm build
pnpm ui:build
# Link your WhatsApp (stores creds under ~/.clawdis/credentials)
pnpm clawdis login
# Start the gateway (WebSocket control plane)
pnpm clawdis gateway --port 18789 --verbose
# Open the browser Control UI (after ui:build)
# http://127.0.0.1:18789/ui/
# Send a WhatsApp message (WhatsApp sends go through the Gateway)
pnpm clawdis send --to +1234567890 --message "Hello from the CLAWDIS!"
# Talk to the agent (optionally deliver back to WhatsApp/Telegram)
pnpm clawdis agent --message "Ship checklist" --thinking high
# If the port is busy, force-kill listeners then start
pnpm clawdis gateway --force
```
## Companion Apps
### macOS Companion (Clawdis.app)
- A menu bar app that can start/stop the Gateway, show health/presence, and provide a local ops UI.
- Instances UI shows friendly hardware model names (from the vendored MIT dataset under `apps/macos/Sources/Clawdis/Resources/DeviceModels/`).
- **Voice Wake** (on-device speech recognition) and Push-to-talk overlay.
- **WebChat** embed + debug tooling (logs, status, heartbeats, sessions).
- Hosts **PeekabooBridge** for UI automation brokering (for clawd workflows).
### Voice Wake reply routing
Voice Wake sends messages into the `main` session and replies on the **last used surface**:
- WhatsApp: last direct message you sent/received.
- Telegram: last DM chat id (bot mode).
- WebChat: last WebChat thread you used.
If delivery fails (e.g. WhatsApp disconnected / Telegram token missing), Clawdis logs the error and you can still inspect the run via WebChat/session logs.
Build/run the mac app with `./scripts/restart-mac.sh` (packages, installs, and launches), or `swift build --package-path apps/macos && open dist/Clawdis.app`.
### iOS node (internal)
The iOS node app is an internal/prototype app that connects as a **remote node**:
- **Voice trigger:** forwards transcripts into the Gateway (agent runs + wakeups).
- **Canvas screen:** a WKWebView + `