feat: add gateway daemon runtime selector

This commit is contained in:
Peter Steinberger
2026-01-06 23:27:58 +01:00
parent 18c43fe462
commit 707f7918bc
17 changed files with 191 additions and 23 deletions

View File

@@ -28,7 +28,7 @@ The Gateway WebSocket stays loopback-only (`ws://127.0.0.1:18789`). Android talk
Bridge is enabled by default (disable via `CLAWDBOT_BRIDGE_ENABLED=0`).
```bash
pnpm clawdbot gateway --port 18789 --verbose
clawdbot gateway --port 18789 --verbose
```
Confirm in logs you see something like:

View File

@@ -49,7 +49,7 @@ Some features are platform-specific:
The gateway is just shuffling messages around. A Raspberry Pi 4 can run it. For the CLI, prefer the Node runtime (most stable):
```bash
pnpm clawdbot gateway
clawdbot gateway
```
### How do I install on Linux without Homebrew?
@@ -187,7 +187,7 @@ OAuth needs the callback to reach the machine running the CLI. Options:
5. **Start gateway:**
```bash
pnpm clawdbot gateway
clawdbot gateway
```
**Note:** WhatsApp may notice the IP change and require re-authentication. If so, run `pnpm clawdbot login` again. Stop the old instance before starting the new one to avoid conflicts.
@@ -221,7 +221,7 @@ Key considerations:
#!/bin/bash
npm install -g pnpm
cd /app
pnpm clawdbot gateway
clawdbot gateway
```
**Container command:**
@@ -238,13 +238,19 @@ Yes! The terminal QR code login works fine over SSH. For long-running operation:
- Use `pm2`, `systemd`, or a `launchd` plist to keep the gateway running.
- Consider Tailscale for secure remote access.
### I'm seeing `InvalidPnpmLockfile: failed to migrate lockfile: 'pnpm-lock.yaml'`
This can be ignored. This is simply a package manager warning when using PNPM and BUN.
It often shows up when switching between `pnpm install` and `bun install`. If installs/build/tests work, you can safely ignore it.
### bun binary vs Node runtime?
Clawdbot can run as:
- **bun binary (macOS app)** — Single executable, easy distribution, auto-restarts via launchd
- **Node runtime** (`pnpm clawdbot gateway`) — More stable for WhatsApp
- **Node runtime** (`clawdbot gateway`) — More stable for WhatsApp
If you see WebSocket errors like `ws.WebSocket 'upgrade' event is not implemented`, use Node instead of the bun binary. Bun's WebSocket implementation has edge cases that can break WhatsApp (Baileys).
If you see WebSocket errors like `ws.WebSocket 'upgrade' event is not implemented`, use Node instead of the bun binary. Bun's WebSocket implementation has edge cases that can break WhatsApp (Baileys) and can corrupt memory on reconnect. Baileys: https://github.com/WhiskeySockets/Baileys
**For stability:** Use launchd (macOS) or the Clawdbot.app — they handle process supervision (auto-restart on crash).

View File

@@ -14,11 +14,11 @@ Last updated: 2025-12-09
## How to run (local)
```bash
pnpm clawdbot gateway --port 18789
clawdbot gateway --port 18789
# for full debug/trace logs in stdio:
pnpm clawdbot gateway --port 18789 --verbose
clawdbot gateway --port 18789 --verbose
# if the port is busy, terminate listeners then start:
pnpm clawdbot gateway --force
clawdbot gateway --force
# dev loop (auto-reload on TS changes):
pnpm gateway:watch
```

View File

@@ -64,6 +64,7 @@ What youll choose:
- **Auth**: Anthropic OAuth or OpenAI OAuth (recommended), API key (optional), or skip for now
- **Providers**: WhatsApp QR login, bot tokens, etc.
- **Daemon**: optional background install (launchd/systemd/Task Scheduler)
- **Runtime**: Node (recommended; required for WhatsApp) or Bun (faster, but incompatible with WhatsApp)
Wizard doc: https://docs.clawd.bot/wizard
@@ -79,11 +80,19 @@ Headless/server tip: do OAuth on a normal machine first, then copy `oauth.json`
If the wizard didnt start it for you:
```bash
bun run clawdbot gateway --port 18789 --verbose
# If you installed the CLI (npm/pnpm link --global):
clawdbot gateway --port 18789 --verbose
# From this repo:
node dist/entry.js gateway --port 18789 --verbose
```
Dashboard (local loopback): `http://127.0.0.1:18789/`
⚠️ **WhatsApp + Bun warning:** Baileys (WhatsApp Web library) uses a WebSocket
path that is currently incompatible with Bun and can cause memory corruption on
reconnect. If you use WhatsApp, run the Gateway with **Node** until this is
resolved. Baileys: https://github.com/WhiskeySockets/Baileys
## 5) Pair + connect your first chat surface
### WhatsApp (QR login)

View File

@@ -34,7 +34,7 @@ The Gateway WebSocket stays loopback-only (`ws://127.0.0.1:18789`). The iOS node
Bridge is enabled by default (disable via `CLAWDBOT_BRIDGE_ENABLED=0`).
```bash
pnpm clawdbot gateway --port 18789 --verbose
clawdbot gateway --port 18789 --verbose
```
Confirm in logs you see something like:

View File

@@ -76,7 +76,7 @@ Send these as standalone messages so they register.
## Inspecting
- `pnpm clawdbot status` — shows store path and recent sessions.
- `pnpm clawdbot sessions --json` — dumps every entry (filter with `--active <minutes>`).
- `pnpm clawdbot gateway call sessions.list --params '{}'` — fetch sessions from the running gateway (use `--url`/`--token` for remote gateway access).
- `clawdbot gateway call sessions.list --params '{}'` — fetch sessions from the running gateway (use `--url`/`--token` for remote gateway access).
- Send `/status` as a standalone message in chat to see whether the agent is reachable, how much of the session context is used, current thinking/verbose toggles, and when your WhatsApp web creds were last refreshed (helps spot relink needs).
- Send `/compact` (optional instructions) as a standalone message to summarize older context and free up window space.
- JSONL transcripts can be opened directly to review full turns.

View File

@@ -121,7 +121,7 @@ Then reinstall deps + restart:
```bash
pnpm install
pnpm build
pnpm clawdbot gateway restart
clawdbot gateway restart
```
If you want to go back to latest later:

View File

@@ -81,6 +81,7 @@ It does **not** install or change anything on the remote host.
- May prompt for sudo (writes `/var/lib/systemd/linger`); it tries without sudo first.
- Windows: Scheduled Task
- Runs on user logon; headless/system services are not configured by default.
- **Runtime selection:** Node (recommended; required for WhatsApp) or Bun (faster, but incompatible with WhatsApp).
7) **Health check**
- Starts the Gateway (if needed) and runs `clawdbot health`.
@@ -120,6 +121,8 @@ clawdbot onboard --non-interactive \
--anthropic-api-key "$ANTHROPIC_API_KEY" \
--gateway-port 18789 \
--gateway-bind loopback \
--install-daemon \
--daemon-runtime node \
--skip-skills
```