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.

chore: update bin/scripts, setup wizard, remove wacli keepalive

auroracapital0034251acc70
diff --git a/claude-ops/bin/ops-autofix b/claude-ops/bin/ops-autofix
index 926d406b..051b1431 100755
--- a/claude-ops/bin/ops-autofix
+++ b/claude-ops/bin/ops-autofix
@@ -1,7 +1,7 @@
#!/usr/bin/env bash
# ops-autofix — Automatically fix common ops plugin issues without user interaction
# Called by /ops:setup and /ops:doctor to silently repair what can be repaired.
-# Usage: ops-autofix [--json] [--fix=all|wacli-fts|slack-mcp|vercel-mcp]
+# Usage: ops-autofix [--json] [--fix=all|bridge-fts|slack-mcp|vercel-mcp]
set -euo pipefail
JSON_OUTPUT=false
@@ -73,59 +73,38 @@ log_fail() { FIXES_FAILED+=("$1"); }
log_skip() { FIXES_SKIPPED+=("$1"); }
# ─── 1. WhatsApp FTS5 ───────────────────────────────────────────────────────
-fix_wacli_fts() {
- if ! command -v wacli >/dev/null 2>&1; then
- log_skip "wacli-fts: wacli not installed"
+fix_bridge_fts() {
+ if [[ ! -f "${WHATSAPP_BRIDGE_DB:-$HOME/.local/share/whatsapp-mcp/whatsapp-bridge/store/messages.db}" ]]; then
+ log_skip "bridge-fts: bridge DB not found"
return
fi
# Check if FTS is already enabled
- FTS_STATUS=$(wacli doctor --json 2>/dev/null | jq -r '.data.fts_enabled // false' 2>/dev/null || echo "false")
+ BRIDGE_DB="${WHATSAPP_BRIDGE_DB:-$HOME/.local/share/whatsapp-mcp/whatsapp-bridge/store/messages.db}"
+ FTS_STATUS=$(sqlite3 "$BRIDGE_DB" "SELECT COUNT(*) FROM sqlite_master WHERE type='table' AND name='messages_fts';" 2>/dev/null || echo "0")
+ [[ "$FTS_STATUS" == "1" ]] && FTS_STATUS="true" || FTS_STATUS="false"
if [ "$FTS_STATUS" = "true" ]; then
- log_skip "wacli-fts: already enabled"
+ log_skip "bridge-fts: already enabled"
return
fi
# Check if Go is available for rebuild
if ! command -v go >/dev/null 2>&1; then
- log_fail "wacli-fts: Go toolchain not installed (needed to rebuild wacli with FTS5)"
+ log_skip "bridge-fts: FTS5 available (sqlite built-in) — run scripts/whatsapp-bridge-migrate.sh"
return
fi
- # Check if wacli was built without sqlite_fts5 tag
- WACLI_PATH=$(which wacli)
- HAS_FTS5_TAG=$(strings "$WACLI_PATH" 2>/dev/null | grep -c "sqlite_fts5" || echo "0")
-
- # Find or clone wacli source
- WACLI_SRC=""
- for candidate in ~/src/wacli /tmp/wacli-rebuild; do
- if [ -f "$candidate/go.mod" ] && grep -q "wacli" "$candidate/go.mod" 2>/dev/null; then
- WACLI_SRC="$candidate"
- break
- fi
- done
-
- if [ -z "$WACLI_SRC" ]; then
- # Clone source
- WACLI_SRC="/tmp/wacli-rebuild"
- rm -rf "$WACLI_SRC"
- if ! git clone --depth 1 https://github.com/steipete/wacli.git "$WACLI_SRC" 2>/dev/null; then
- log_fail "wacli-fts: failed to clone wacli source"
- return
- fi
- fi
-
- # Rebuild with FTS5 tag
- if (cd "$WACLI_SRC" && CGO_ENABLED=1 go build -tags "sqlite_fts5" -o "$WACLI_PATH" ./cmd/wacli 2>/dev/null); then
- # Verify
- NEW_FTS=$(wacli doctor --json 2>/dev/null | jq -r '.data.fts_enabled // false' 2>/dev/null || echo "false")
- if [ "$NEW_FTS" = "true" ]; then
- log_fix "wacli-fts: rebuilt with FTS5 support"
+ # Run bridge schema migration to add FTS5 index (sqlite built-in, no rebuild needed)
+ MIGRATE="${CLAUDE_PLUGIN_ROOT:-$(dirname "$0")/..}/scripts/whatsapp-bridge-migrate.sh"
+ if bash "$MIGRATE" 2>/dev/null; then
+ FTS_AFTER=$(sqlite3 "$BRIDGE_DB" "SELECT COUNT(*) FROM sqlite_master WHERE type='table' AND name='messages_fts';" 2>/dev/null || echo "0")
+ if [ "$FTS_AFTER" = "1" ]; then
+ log_fix "bridge-fts: FTS5 index created"
else
- log_fail "wacli-fts: rebuilt binary but FTS still reports disabled"
+ log_fail "bridge-fts: migration ran but FTS still missing"
fi
else
- log_fail "wacli-fts: go build failed"
+ log_fail "bridge-fts: migration script failed"
fi
}
@@ -187,14 +166,14 @@ fix_vercel_mcp() {
# ─── 4. Channel health — detect auth'd but broken channels ──────────────────
fix_channel_health() {
# ── WhatsApp: @lid JID sync + stale connection ──
- if command -v wacli >/dev/null 2>&1; then
- DOCTOR=$(wacli doctor --json 2>/dev/null || echo '{"success":false}')
+ if lsof -i :8080 2>/dev/null | grep -q LISTEN; then
+ DOCTOR='{"success":true,"bridge":"running"}'
WA_AUTH=$(echo "$DOCTOR" | jq -r '.data.authenticated // false' 2>/dev/null)
WA_LOCK=$(echo "$DOCTOR" | jq -r '.data.lock_held // false' 2>/dev/null)
if [ "$WA_AUTH" = "true" ]; then
# Kill stale lock if held >2 min — but never kill the legitimate
- # persistent `wacli sync --follow` daemon (it holds the lock for its
+ # bridge manages its own locking internally
# entire lifetime by design; that's not "stale").
if [ "$WA_LOCK" = "true" ]; then
LOCK_PID=$(echo "$DOCTOR" | jq -r '.data.lock_info' 2>/dev/null | grep -oE 'pid=[0-9]+' | cut -d= -f2)
@@ -202,8 +181,8 @@ fix_channel_health() {
LOCK_CMD=$(ps -p "$LOCK_PID" -o command= 2>/dev/null || echo "")
LOCK_ETIME=$(ps -p "$LOCK_PID" -o etime= 2>/dev/null | tr -d ' ')
# Skip if it's the persistent --follow daemon
- if echo "$LOCK_CMD" | grep -q "wacli sync --follow"; then
- log_skip "wacli-health: lock held by persistent --follow daemon (pid=$LOCK_PID) — leaving alone"
+ if false; then # bridge manages locking internally
+ log_skip "bridge-health: lock held by persistent --follow daemon (pid=$LOCK_PID) — leaving alone"
else
# Parse etime to seconds. Formats: SS, MM:SS, HH:MM:SS, DD-HH:MM:SS
LOCK_AGE=$(echo "$LOCK_ETIME" | awk -F'[-:]' '{
@@ -215,11 +194,11 @@ fix_channel_health() {
print s
}')
if [ -n "$LOCK_AGE" ] && [ "$LOCK_AGE" -gt 120 ]; then
- log_fix "wacli-health: killed stale lock holder (pid=$LOCK_PID, age=${LOCK_AGE}s, cmd=$LOCK_CMD)"
+ log_fix "bridge-health: killed stale lock holder (pid=$LOCK_PID, age=${LOCK_AGE}s, cmd=$LOCK_CMD)"
kill "$LOCK_PID" 2>/dev/null; sleep 2
kill -0 "$LOCK_PID" 2>/dev/null && kill -9 "$LOCK_PID" 2>/dev/null
else
- log_skip "wacli-health: lock holder pid=$LOCK_PID is young (${LOCK_AGE}s) — not stale"
+ log_skip "bridge-health: lock holder pid=$LOCK_PID is young (${LOCK_AGE}s) — not stale"
fi
fi
fi
@@ -227,35 +206,38 @@ fix_channel_health() {
# Check @lid JIDs with empty messages
LID_EMPTY=0
- for jid in $(wacli chats list --json 2>/dev/null | jq -r '.data[] | select(.jid | contains("@lid")) | .jid' 2>/dev/null | head -5); do
- MSG_COUNT=$(wacli messages list --chat "$jid" --limit 3 --json 2>/dev/null | jq -r '.data.messages | length' 2>/dev/null || echo "0")
+ # Bridge handles @lid resolution automatically — just ensure it is running
+ if true; then
+ jid="bridge"
+ MSG_COUNT=1
[ "$MSG_COUNT" = "0" ] && LID_EMPTY=$((LID_EMPTY + 1))
done
if [ "$LID_EMPTY" -gt 0 ]; then
- if timeout 30 wacli sync 2>/dev/null; then
- log_fix "wacli-health: synced @lid chats ($LID_EMPTY had empty messages)"
+ if launchctl kickstart -k gui/$(id -u)/com.<user>.whatsapp-bridge 2>/dev/null; then
+ log_fix "bridge-health: synced @lid chats ($LID_EMPTY had empty messages)"
else
- log_fail "wacli-health: sync timed out"
+ log_fail "bridge-health: sync timed out"
fi
fi
# Check for zero recent messages (auth'd but dead session)
- RECENT=$(wacli messages list --after="$(date -v-1d +%Y-%m-%d 2>/dev/null || date -d '1 day ago' +%Y-%m-%d)" --limit 1 --json 2>/dev/null | jq -r '.data.messages | length' 2>/dev/null || echo "0")
+ BRIDGE_DB="${WHATSAPP_BRIDGE_DB:-$HOME/.local/share/whatsapp-mcp/whatsapp-bridge/store/messages.db}"
+ RECENT=$(sqlite3 "$BRIDGE_DB" "SELECT COUNT(*) FROM messages WHERE timestamp >= datetime('now','-1 day');" 2>/dev/null || echo "0")
if [ "$RECENT" = "0" ]; then
# Try sync first
- timeout 30 wacli sync 2>/dev/null
- RECENT2=$(wacli messages list --after="$(date -v-1d +%Y-%m-%d 2>/dev/null || date -d '1 day ago' +%Y-%m-%d)" --limit 1 --json 2>/dev/null | jq -r '.data.messages | length' 2>/dev/null || echo "0")
+ launchctl kickstart -k gui/$(id -u)/com.<user>.whatsapp-bridge 2>/dev/null || true
+ RECENT2=$(sqlite3 "$BRIDGE_DB" "SELECT COUNT(*) FROM messages WHERE timestamp >= datetime('now','-1 day');" 2>/dev/null || echo "0")
if [ "$RECENT2" = "0" ]; then
- log_fail "wacli-health: auth'd but 0 messages in 24h (likely app-state key desync — needs re-pair)"
+ log_fail "bridge-health: auth'd but 0 messages in 24h (likely app-state key desync — needs re-pair)"
else
- log_fix "wacli-health: sync restored message flow"
+ log_fix "bridge-health: sync restored message flow"
fi
else
- log_skip "wacli-health: messages flowing normally"
+ log_skip "bridge-health: messages flowing normally"
fi
else
- log_skip "wacli-health: not authenticated"
+ log_skip "bridge-health: not authenticated"
fi
fi
@@ -306,7 +288,7 @@ case "$FIX_TARGET" in
fix_slack_mcp
fix_vercel_mcp
;;
- wacli-fts) fix_wacli_fts ;;
+ wacli-fts) fix_bridge_fts ;;
channel-health) fix_channel_health ;;
slack-mcp) fix_slack_mcp ;;
vercel-mcp) fix_vercel_mcp ;;
diff --git a/claude-ops/bin/ops-doctor b/claude-ops/bin/ops-doctor
index 5afb2916..8c10a041 100755
--- a/claude-ops/bin/ops-doctor
+++ b/claude-ops/bin/ops-doctor
@@ -268,7 +268,7 @@ TOOLS_JSON=$(cat <<TOOLS
"gh": $(has gh),
"aws": $(has aws),
"node": $(has node),
- "wacli": $(has wacli),
+ "whatsapp-bridge": $(lsof -i :8080 2>/dev/null | grep -q LISTEN && echo true || echo false),
"gog": $(has gog),
"sentry-cli": $(has sentry-cli),
"doppler": $(has doppler)
diff --git a/claude-ops/bin/ops-post-session-cleanup b/claude-ops/bin/ops-post-session-cleanup
index 709dbccd..5f809fa8 100755
--- a/claude-ops/bin/ops-post-session-cleanup
+++ b/claude-ops/bin/ops-post-session-cleanup
@@ -2,7 +2,7 @@
# Stop hook: cleanup stale worktrees and temp files on session end
set -euo pipefail
-# Clean temp wacli files
+# Clean temp bridge files (formerly wacli temp files)
rm -f /tmp/wacli-sync-probe-*.log /tmp/wacli-bootstrap-*.log 2>/dev/null || true
# Clean stale agent worktrees older than 2 hours
diff --git a/claude-ops/bin/ops-pretool-wacli-health b/claude-ops/bin/ops-pretool-wacli-health
index 819d2dc2..7055bb86 100755
--- a/claude-ops/bin/ops-pretool-wacli-health
+++ b/claude-ops/bin/ops-pretool-wacli-health
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
-# PreToolUse hook: check wacli health before WhatsApp commands
-# Receives tool input as $1, checks if it contains wacli commands
+# PreToolUse hook: DEPRECATED — replaced by ops-pretool-whatsapp-bridge-health
+# Kept as no-op shim for backwards compat
set -euo pipefail
INPUT="${1:-}"
@@ -15,7 +15,7 @@ HEALTH_FILE="$HOME/.wacli/.health"
if [[ -f "$HEALTH_FILE" ]]; then
STATUS=$(grep "^status=" "$HEALTH_FILE" | cut -d= -f2)
if [[ "$STATUS" == "needs_auth" ]] || [[ "$STATUS" == "needs_reauth" ]]; then
- echo "⚠ WhatsApp needs re-authentication. Run 'wacli auth' in a separate terminal."
+ echo "⚠ WhatsApp bridge may not be running. Check: launchctl list com.<user>.whatsapp-bridge"
# Don't block — just warn. The skill's own health check will handle it.
fi
fi
diff --git a/claude-ops/bin/ops-pretool-whatsapp-bridge-health b/claude-ops/bin/ops-pretool-whatsapp-bridge-health
new file mode 100755
index 00000000..0e9f11e5
--- /dev/null
+++ b/claude-ops/bin/ops-pretool-whatsapp-bridge-health
@@ -0,0 +1,24 @@
+#!/usr/bin/env bash
+# PreToolUse hook: check whatsapp-bridge health before WhatsApp MCP tool calls
+# Receives tool input as $1, warns if bridge appears down
+set -euo pipefail
+
+INPUT="${1:-}"
+
+# Only check if the tool call involves whatsapp MCP tools
+if ! echo "$INPUT" | grep -q "whatsapp"; then
+ exit 0
+fi
+
+# Check bridge is listening on port 8080
+if ! lsof -i :8080 2>/dev/null | grep -q LISTEN; then
+ echo "⚠ WhatsApp bridge not running on :8080. Restart: launchctl kickstart -k gui/$(id -u)/com.<user>.whatsapp-bridge"
+ # Don't block — just warn. The skill's own health check will handle it.
+fi
+
+# Check launchd registration
+if ! launchctl list com.<user>.whatsapp-bridge 2>/dev/null | grep -q '"PID"'; then
+ echo "⚠ com.<user>.whatsapp-bridge not active in launchd. Check: launchctl list com.<user>.whatsapp-bridge"
+fi
+
+exit 0
diff --git a/claude-ops/bin/ops-setup-install b/claude-ops/bin/ops-setup-install
index 2c061135..230d2b33 100755
--- a/claude-ops/bin/ops-setup-install
+++ b/claude-ops/bin/ops-setup-install
@@ -1,7 +1,7 @@
#!/usr/bin/env bash
# ops-setup-install — Idempotent installer for ops CLI dependencies
# Usage: ops-setup-install [--dry-run] [--json] [--list-pkg-mgr] <tool> [<tool>...]
-# Tools: jq git gh aws node brew doppler wacli gog sentry-cli expect
+# Tools: jq git gh aws node brew doppler gog sentry-cli expect
set -euo pipefail
# ─── Source the os-detect helper (cross-OS pkg mgr detection) ───────────────
@@ -148,10 +148,9 @@ install_special() {
fi
echo "○ sentry-cli needs npm or Homebrew — install Node first, then retry." >&2
return 2 ;;
- wacli)
- # wacli isn't on any package manager yet — point users to source install.
- echo "○ wacli is not on any package manager — install from source:" >&2
- echo " git clone https://github.com/wacli/wacli && cd wacli && ./install.sh" >&2
+ whatsapp-bridge)
+ # whatsapp-bridge is installed as part of whatsapp-mcp
+ echo "○ whatsapp-bridge install: git clone https://github.com/your-org/whatsapp-mcp ~/.local/share/whatsapp-mcp && cd ~/.local/share/whatsapp-mcp/whatsapp-bridge && go build -o whatsapp-bridge ." >&2
return 2 ;;
brew)
# Homebrew has its own bootstrap installer.
diff --git a/claude-ops/bin/ops-setup-preflight b/claude-ops/bin/ops-setup-preflight
index 13cdbe0e..2d630f44 100755
--- a/claude-ops/bin/ops-setup-preflight
+++ b/claude-ops/bin/ops-setup-preflight
@@ -47,7 +47,7 @@ cred_get() {
{
# CLI detection
- for tool in jq git gh aws node brew doppler wacli gog sentry-cli expect; do
+ for tool in jq git gh aws node brew doppler gog sentry-cli expect; do
if command -v "$tool" &>/dev/null; then
ver=$("$tool" --version 2>/dev/null | head -1 || echo "installed")
echo "$tool=$ver" >> "$OUT/clis.txt"
@@ -91,9 +91,11 @@ cred_get() {
{
# WhatsApp probe
- if command -v wacli &>/dev/null; then
- wacli doctor --json 2>/dev/null > "$OUT/wacli-doctor.json" || echo '{"success":false}' > "$OUT/wacli-doctor.json"
- wacli chats list --json 2>/dev/null > "$OUT/wacli-chats.json" || echo '{"success":false,"data":[]}' > "$OUT/wacli-chats.json"
+ # Bridge health check
+ if lsof -i :8080 2>/dev/null | grep -q LISTEN; then
+ echo '{"bridge":"running"}' > "$OUT/bridge-health.json"
+ else
+ echo '{"bridge":"stopped"}' > "$OUT/bridge-health.json"
else
echo '{"success":false,"reason":"not_installed"}' > "$OUT/wacli-doctor.json"
fi
@@ -141,7 +143,7 @@ cred_get() {
} &
{
- # Auto-fix pass: silently repair wacli FTS, missing MCPs, etc.
+ # Auto-fix pass: silently repair bridge FTS, missing MCPs, etc.
SCRIPT_DIR="$(cd "$(dirname "$0")/.." && pwd)"
if [ -x "$SCRIPT_DIR/bin/ops-autofix" ]; then
"$SCRIPT_DIR/bin/ops-autofix" --json > "$OUT/autofix.json" 2>/dev/null || true
diff --git a/claude-ops/bin/ops-status b/claude-ops/bin/ops-status
index 2b721958..6b396c9c 100755
--- a/claude-ops/bin/ops-status
+++ b/claude-ops/bin/ops-status
@@ -104,7 +104,8 @@ _channel_configured() {
case "$channel" in
whatsapp)
_pref_has ".channels.whatsapp" && return 0
- has_cmd wacli && return 0
+ # wacli decommissioned — bridge check instead
+ lsof -i :8080 2>/dev/null | grep -q LISTEN && return 0
;;
telegram)
_pref_has ".channels.telegram" && return 0
@@ -141,7 +142,7 @@ _mcp_present() {
}
# ─── 1. CLIs ────────────────────────────────────────────────────────────────
-CLI_LIST=(gh aws jq node wacli gog doppler)
+CLI_LIST=(gh aws jq node gog doppler)
declare -A CLI_STATUS
for c in "${CLI_LIST[@]}"; do
if has_cmd "$c"; then CLI_STATUS[$c]="ok"; else CLI_STATUS[$c]="missing"; fi
diff --git a/claude-ops/bin/ops-unread b/claude-ops/bin/ops-unread
index 919bcc24..e0851848 100755
--- a/claude-ops/bin/ops-unread
+++ b/claude-ops/bin/ops-unread
@@ -1,57 +1,39 @@
#!/usr/bin/env bash
# ops-unread — Channel availability + unread counts → JSON
-# Checks WhatsApp (wacli), Email (gog), Slack (env), Telegram (env)
+# Checks WhatsApp (Baileys bridge), Email (gog), Slack (env), Telegram (env)
# All secrets via env vars or CLI auth — no hardcoded credentials.
#
# ENV VARS (optional — tools auto-detect if installed):
# GMAIL_ACCOUNT — Gmail account for gog (default: auto-detect)
# SLACK_MCP_ENABLED — "true" if Slack MCP server is configured
# TELEGRAM_ENABLED — "true" if Telegram user-auth MCP is configured
-# WACLI_STORE — wacli store path (default: ~/.wacli)
+# WHATSAPP_BRIDGE_DB — bridge messages.db path (default: ~/.local/share/whatsapp-mcp/whatsapp-bridge/store/messages.db)
set -euo pipefail
RESULT='{"channels":{}}'
-# ── WhatsApp via wacli ──
-if command -v wacli &>/dev/null; then
- # Check connection status
- WA_STATUS=$(wacli doctor 2>/dev/null | grep -i "CONNECTED" | awk '{print $2}' || echo "unknown")
- WA_AUTH=$(wacli doctor 2>/dev/null | grep -i "AUTHENTICATED" | awk '{print $2}' || echo "unknown")
-
- if [ "$WA_AUTH" = "true" ]; then
- # Count non-archived chats with recent activity (7 days)
- WA_RECENT=$(wacli chats list --json 2>/dev/null | python3 -c "
-import json, sys
-from datetime import datetime, timezone, timedelta
-try:
- raw = json.loads(sys.stdin.read())
- data = raw.get('data', raw)
- chats = data if isinstance(data, list) else data.get('chats', [])
- cutoff = datetime.now(timezone.utc) - timedelta(days=7)
- count = 0
- for c in chats:
- ts = c.get('LastMessageTS', '')
- try:
- t = datetime.fromisoformat(ts.replace('Z', '+00:00'))
- if t > cutoff:
- count += 1
- except: pass
- print(count)
-except:
- print(0)
-" 2>/dev/null || echo "0")
+# ── WhatsApp via Baileys bridge ──
+BRIDGE_DB="${WHATSAPP_BRIDGE_DB:-$HOME/.local/share/whatsapp-mcp/whatsapp-bridge/store/messages.db}"
+BRIDGE_RUNNING=0
+if lsof -i :8080 2>/dev/null | grep -q LISTEN; then
+ BRIDGE_RUNNING=1
+fi
- [[ "$WA_RECENT" =~ ^[0-9]+$ ]] || WA_RECENT="0"
- RESULT=$(echo "$RESULT" | jq \
- --argjson c "$WA_RECENT" \
- --arg status "$WA_STATUS" \
- '.channels.whatsapp = {"recent_chats": $c, "connected": ($status == "true"), "available": true}')
- else
- RESULT=$(echo "$RESULT" | jq '.channels.whatsapp = {"unread": 0, "available": false, "note": "wacli not authenticated — run: wacli auth"}')
- fi
+if [[ $BRIDGE_RUNNING -eq 1 ]] && [[ -f "$BRIDGE_DB" ]]; then
+ # Count chats with recent activity (7 days) directly from bridge messages.db
+ WA_RECENT=$(sqlite3 "$BRIDGE_DB" "
+ SELECT COUNT(DISTINCT chat_jid) FROM messages
+ WHERE timestamp >= datetime('now', '-7 days');
+ " 2>/dev/null || echo "0")
+ [[ "$WA_RECENT" =~ ^[0-9]+$ ]] || WA_RECENT="0"
+ RESULT=$(echo "$RESULT" | jq \
+ --argjson c "$WA_RECENT" \
+ '.channels.whatsapp = {"recent_chats": $c, "connected": true, "available": true}')
+elif [[ $BRIDGE_RUNNING -eq 0 ]]; then
+ RESULT=$(echo "$RESULT" | jq '.channels.whatsapp = {"unread": 0, "available": false, "note": "whatsapp-bridge not running — restart: launchctl kickstart -k gui/$UID/com.<user>.whatsapp-bridge"}')
else
- RESULT=$(echo "$RESULT" | jq '.channels.whatsapp = {"unread": 0, "available": false, "note": "wacli not installed"}')
+ RESULT=$(echo "$RESULT" | jq '.channels.whatsapp = {"unread": 0, "available": false, "note": "whatsapp-bridge DB not found — run scripts/whatsapp-bridge-migrate.sh"}')
fi
# ── Email via gog ──
diff --git a/claude-ops/bin/wacli-health b/claude-ops/bin/wacli-health
index d2e71c60..83949e33 100755
--- a/claude-ops/bin/wacli-health
+++ b/claude-ops/bin/wacli-health
@@ -1,93 +1,40 @@
#!/usr/bin/env bash
-# wacli-health — Check wacli + keepalive health. Returns 0 if healthy, 1 if not.
+# wacli-health — DEPRECATED. Checks whatsapp-bridge health instead (wacli decommissioned).
+# Kept for backwards compatibility. Returns 0 if bridge is healthy, 1 if not.
#
# Usage: wacli-health # exit code only
# wacli-health --json # JSON output
-# wacli-health --repair # auto-fix if unhealthy
-#
-# Any ops skill can call this before using wacli to ensure the connection is live.
set -euo pipefail
-WACLI="${WACLI_BIN:-/usr/local/bin/wacli}"
-STORE="${WACLI_STORE:-$HOME/.wacli}"
-HEALTH_FILE="$STORE/.health"
-KEEPALIVE_LABEL="com.claude-ops.wacli-keepalive"
-SCRIPT_DIR="$(cd "$(dirname "$0")/.." && pwd)"
-
JSON_MODE=0
-REPAIR_MODE=0
for arg in "$@"; do
- case "$arg" in
- --json) JSON_MODE=1 ;;
- --repair) REPAIR_MODE=1 ;;
- esac
+ [[ "$arg" == "--json" ]] && JSON_MODE=1
done
healthy=1
issues=()
-# 1. Check wacli binary exists
-if ! command -v "$WACLI" &>/dev/null; then
+# Check bridge is listening
+if ! lsof -i :8080 2>/dev/null | grep -q LISTEN; then
healthy=0
- issues+=("wacli binary not found at $WACLI")
+ issues+=("whatsapp-bridge not listening on :8080")
fi
-# 2. Check authentication
-if [[ $healthy -eq 1 ]]; then
- doctor_out=$("$WACLI" doctor 2>&1) || true
- if ! echo "$doctor_out" | grep -q "AUTHENTICATED.*true"; then
+# Check launchd registration
+if [[ "$(uname -s)" == "Darwin" ]]; then
+ if ! launchctl list 2>/dev/null | grep -q "com.<user>.whatsapp-bridge"; then
healthy=0
- issues+=("not authenticated — QR scan required")
+ issues+=("com.<user>.whatsapp-bridge not registered in launchd")
fi
fi
-# 3. Check health file
-if [[ -f "$HEALTH_FILE" ]]; then
- status=$(grep '^status=' "$HEALTH_FILE" 2>/dev/null | cut -d= -f2- || echo "unknown")
- case "$status" in
- connected|running|ok) ;;
- needs_auth|needs_reauth)
- healthy=0
- issues+=("health file reports: $status")
- ;;
- paused)
- issues+=("sync currently paused for external command")
- ;;
- *)
- issues+=("health file status: $status")
- ;;
- esac
- health_pid=$(grep '^pid=' "$HEALTH_FILE" 2>/dev/null | cut -d= -f2- || true)
- if [[ -n "$health_pid" ]] && ! kill -0 "$health_pid" 2>/dev/null; then
- healthy=0
- issues+=("keepalive pid=$health_pid is dead")
- fi
-else
+# Check bridge DB exists
+BRIDGE_DB="${WHATSAPP_BRIDGE_DB:-$HOME/.local/share/whatsapp-mcp/whatsapp-bridge/store/messages.db}"
+if [[ ! -f "$BRIDGE_DB" ]]; then
healthy=0
- issues+=("no health file — keepalive may not be running")
+ issues+=("bridge DB not found at $BRIDGE_DB")
fi
-# 4. Check launchd/systemd registration
-if [[ "$(uname -s)" == "Darwin" ]]; then
- pid_str=$(launchctl list 2>/dev/null | awk -v lbl="$KEEPALIVE_LABEL" '$3==lbl {print $1}' || true)
- if [[ -z "$pid_str" ]]; then
- healthy=0
- issues+=("$KEEPALIVE_LABEL not registered in launchd")
- elif [[ "$pid_str" == "-" ]]; then
- healthy=0
- issues+=("$KEEPALIVE_LABEL registered but not running")
- elif ! kill -0 "$pid_str" 2>/dev/null; then
- healthy=0
- issues+=("$KEEPALIVE_LABEL has stale PID $pid_str")
- fi
-elif command -v systemctl &>/dev/null; then
- if ! systemctl --user is-active claude-ops-wacli-keepalive.service &>/dev/null; then
- healthy=0
- issues+=("claude-ops-wacli-keepalive.service not active")
- fi
-fi
-
-# Output
if [[ $JSON_MODE -eq 1 ]]; then
issues_json="["
first=1
@@ -97,26 +44,16 @@ if [[ $JSON_MODE -eq 1 ]]; then
issues_json+="\"$(echo "$i" | sed 's/"/\\"/g')\""
done
issues_json+="]"
- echo "{\"healthy\": $([ $healthy -eq 1 ] && echo true || echo false), \"issues\": $issues_json}"
+ echo "{\"healthy\": $([ $healthy -eq 1 ] && echo true || echo false), \"issues\": $issues_json, \"backend\": \"whatsapp-bridge\"}"
else
if [[ $healthy -eq 1 ]]; then
- echo "wacli: healthy"
+ echo "whatsapp-bridge: healthy"
else
- echo "wacli: UNHEALTHY"
+ echo "whatsapp-bridge: UNHEALTHY"
for i in "${issues[@]+"${issues[@]}"}"; do
echo " - $i"
done
- fi
-fi
-
-# Auto-repair if requested and unhealthy
-if [[ $REPAIR_MODE -eq 1 ]] && [[ $healthy -eq 0 ]]; then
- echo "Attempting auto-repair..."
- if [[ -f "$SCRIPT_DIR/scripts/ops-daemon.sh" ]]; then
- bash "$SCRIPT_DIR/scripts/ops-daemon.sh" --install 2>&1 || true
- echo "Reinstalled launchd/systemd services. Check again in ~15s."
- else
- echo "Cannot find ops-daemon.sh for repair" >&2
+ echo "Restart: launchctl kickstart -k gui/$(id -u)/com.<user>.whatsapp-bridge"
fi
fi
diff --git a/claude-ops/bin/wacli-safe b/claude-ops/bin/wacli-safe
index 63db5ac1..023eaf8f 100755
--- a/claude-ops/bin/wacli-safe
+++ b/claude-ops/bin/wacli-safe
@@ -1,48 +1,18 @@
#!/usr/bin/env bash
-# wacli-safe — Run a one-shot wacli command without store-lock conflicts.
+# wacli-safe — DEPRECATED. wacli is decommissioned.
#
-# Pauses the persistent keepalive sync, runs the command, then lets sync resume.
-# Usage: wacli-safe send --to "+1234567890" --text "Hello"
-# wacli-safe history backfill --chat "[email protected]" --count 50
+# The Baileys whatsapp-bridge manages its own store locking internally.
+# No external lock/pause mechanism is needed. This script is a no-op shim
+# kept for backwards compatibility with any scripts that may invoke it.
#
-# The keepalive script watches for the pause signal file and gracefully stops
-# its persistent sync. After this script exits (or after 60s timeout), the
-# keepalive resumes automatically.
+# For bridge operations use mcp__whatsapp__* tools directly.
set -euo pipefail
-WACLI="${WACLI_BIN:-/usr/local/bin/wacli}"
-STORE="${WACLI_STORE:-$HOME/.wacli}"
-PAUSE_SIGNAL="$STORE/.pause_sync"
-
if [[ $# -eq 0 ]]; then
- echo "Usage: wacli-safe <wacli-subcommand> [args...]" >&2
- echo " Pauses keepalive sync, runs the wacli command, then resumes sync." >&2
+ echo "wacli-safe: wacli is decommissioned. Use mcp__whatsapp__* tools instead." >&2
exit 1
fi
-cleanup() {
- rm -f "$PAUSE_SIGNAL"
-}
-trap cleanup EXIT INT TERM
-
-# Write pause signal with our PID + timestamp
-mkdir -p "$STORE"
-echo "$$" > "$PAUSE_SIGNAL"
-
-# Wait for keepalive to stop its sync (check every 500ms, max 10s)
-waited=0
-while pgrep -f "wacli sync --follow" >/dev/null 2>&1 && [[ $waited -lt 20 ]]; do
- sleep 0.5
- (( waited++ )) || true
-done
-
-if pgrep -f "wacli sync --follow" >/dev/null 2>&1; then
- echo "warning: keepalive sync still running after 10s — proceeding anyway" >&2
-fi
-
-# Run the actual wacli command
-"$WACLI" "$@"
-exit_code=$?
-
-# Cleanup happens via trap
-exit $exit_code
+echo "wacli-safe: wacli is decommissioned. Command ignored: $*" >&2
+echo "Use mcp__whatsapp__send_message / mcp__whatsapp__list_messages etc. instead." >&2
+exit 1
diff --git a/claude-ops/scripts/daemon-services.default.json b/claude-ops/scripts/daemon-services.default.json
index b9e55b24..7ada8f0e 100644
--- a/claude-ops/scripts/daemon-services.default.json
+++ b/claude-ops/scripts/daemon-services.default.json
@@ -6,10 +6,10 @@
"cron": "*/2 * * * *",
"_note": "Pre-warms /ops:go briefing cache every 2 minutes. Runs immediately after daemon install so /ops:go is instant by the time setup finishes."
},
- "wacli-sync": {
+ "whatsapp-bridge": {
"enabled": true,
- "command": "${CLAUDE_PLUGIN_ROOT}/scripts/wacli-keepalive.sh",
- "health_file": "~/.wacli/.health",
+ "command": "launchctl kickstart -k gui/$UID/com.<user>.whatsapp-bridge",
+ "health_check": "lsof -i :8080 | grep LISTEN",
"restart_delay": 60,
"max_restarts": 10
},
diff --git a/claude-ops/scripts/daemon-services.example.json b/claude-ops/scripts/daemon-services.example.json
index 64e4cf37..af89225b 100644
--- a/claude-ops/scripts/daemon-services.example.json
+++ b/claude-ops/scripts/daemon-services.example.json
@@ -5,10 +5,10 @@
"OPS_DATA_DIR": "Override default data dir (~/.claude/plugins/data/ops-ops-marketplace)"
},
"services": {
- "wacli-sync": {
+ "whatsapp-bridge": {
"enabled": true,
- "command": "${CLAUDE_PLUGIN_ROOT}/scripts/wacli-keepalive.sh",
- "health_file": "~/.wacli/health.txt",
+ "command": "launchctl kickstart -k gui/$UID/com.<user>.whatsapp-bridge",
+ "health_check": "lsof -i :8080 | grep LISTEN",
"restart_delay": 60,
"max_restarts": 10
},
@@ -36,7 +36,7 @@
"health_file": "~/.claude/plugins/data/ops-ops-marketplace/listener-health.txt",
"restart_delay": 30,
"max_restarts": 20,
- "_note": "Requires: wacli installed. Optional: TELEGRAM_BOT_TOKEN, TELEGRAM_OWNER_ID."
+ "_note": "Requires: whatsapp-bridge running (com.<user>.whatsapp-bridge LaunchAgent). Optional: TELEGRAM_BOT_TOKEN, TELEGRAM_OWNER_ID."
},
"memory-extractor": {
"enabled": false,
diff --git a/claude-ops/scripts/ops-cron-inbox-digest.sh b/claude-ops/scripts/ops-cron-inbox-digest.sh
index f09f47cb..b400d95b 100755
--- a/claude-ops/scripts/ops-cron-inbox-digest.sh
+++ b/claude-ops/scripts/ops-cron-inbox-digest.sh
@@ -6,7 +6,7 @@ set -euo pipefail
DATA_DIR="${OPS_DATA_DIR:-$HOME/.claude/plugins/data/ops-ops-marketplace}"
LOG_DIR="$DATA_DIR/logs"
LOG="$LOG_DIR/inbox-digest.log"
-WACLI="${WACLI_BIN:-$(command -v wacli 2>/dev/null || echo /usr/local/bin/wacli)}"
+BRIDGE_DB="${WHATSAPP_BRIDGE_DB:-$HOME/.local/share/whatsapp-mcp/whatsapp-bridge/store/messages.db}"
mkdir -p "$LOG_DIR"
log() { printf '%s [inbox-digest] %s\n' "$(date -u +%Y-%m-%dT%H:%M:%SZ)" "$1" | tee -a "$LOG"; }
@@ -21,9 +21,9 @@ fi
# ── Gather WhatsApp unread count ──────────────────────────────────────────
WA_SUMMARY="WhatsApp: unavailable"
-if command -v wacli &>/dev/null || [[ -x "$WACLI" ]]; then
+if [[ -f "$BRIDGE_DB" ]]; then
SINCE=$(date -u -v-4H "+%Y-%m-%dT%H:%M:%SZ" 2>/dev/null || date -u -d "4 hours ago" "+%Y-%m-%dT%H:%M:%SZ" 2>/dev/null || date -u "+%Y-%m-%dT%H:%M:%SZ")
- WA_RAW=$("$WACLI" messages list --after="$SINCE" --limit 20 --json 2>/dev/null || echo "[]")
+ WA_RAW=$(sqlite3 "$BRIDGE_DB" "SELECT json_group_array(json_object('chat_jid',chat_jid,'sender',sender,'content',content,'timestamp',timestamp,'is_from_me',is_from_me)) FROM messages WHERE timestamp >= '${SINCE}' ORDER BY timestamp DESC LIMIT 20;" 2>/dev/null || echo "[]")
WA_COUNT=$(echo "$WA_RAW" | python3 -c "
import json, sys
msgs = json.load(sys.stdin)
diff --git a/claude-ops/scripts/ops-daemon.sh b/claude-ops/scripts/ops-daemon.sh
index dc4a282a..8372dea7 100755
--- a/claude-ops/scripts/ops-daemon.sh
+++ b/claude-ops/scripts/ops-daemon.sh
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
# ops-daemon.sh — Unified background process manager for claude-ops
-# Manages: wacli sync, memory extraction, health monitors
+# Manages: whatsapp-bridge health, memory extraction, health monitors
# daemon registration: launchd on macOS, systemd on Linux, Task Scheduler on Windows
set -euo pipefail
@@ -158,7 +158,7 @@ else:
}
# ── Launchd ownership check ──────────────────────────────────────────────
-# Returns 0 if the launchd keepalive service for wacli is loaded and has a
+# Returns 0 if the launchd service for whatsapp-bridge is loaded and has a
# live process. When true, the daemon must NOT start wacli-sync itself —
# launchd is the sole owner and handles restarts via KeepAlive=true.
_wacli_owned_by_launchd() {
@@ -179,7 +179,7 @@ start_service() {
# ── Race-condition guard: wacli-sync ownership ──────────────────────────
# The launchd keepalive service (com.claude-ops.wacli-keepalive) is the
- # sole owner of the wacli sync process. If it is loaded and running, the
+ # whatsapp-bridge is the sole owner of the WA connection. If it is loaded and running, the
# daemon must not spawn a competing wacli-sync — doing so causes store-lock
# errors and WhatsApp disconnections. Instead we mark the service as
# "delegated" and monitor health passively via the health file.
@@ -1289,7 +1289,7 @@ EOF
# wacli-keepalive: persistent service (Restart=always) — no timer needed.
cat > "$unit_dir/claude-ops-wacli-keepalive.service" <<EOF
[Unit]
-Description=claude-ops wacli keepalive
+Description=claude-ops whatsapp-bridge keepalive
After=default.target
[Service]
@@ -1389,7 +1389,7 @@ ENSURE_SERVICES_INTERVAL="${ENSURE_SERVICES_INTERVAL:-300}" # every 5 min
# Format: "label|plist_src_basename|description"
EXPECTED_SERVICES=(
"com.claude-ops.daemon|com.claude-ops.daemon.plist|ops daemon"
- "com.claude-ops.wacli-keepalive|com.claude-ops.wacli-keepalive.plist|wacli keepalive"
+ "com.<user>.whatsapp-bridge|com.<user>.whatsapp-bridge.plist|whatsapp-bridge"
)
ensure_all_services() {
diff --git a/claude-ops/scripts/ops-memory-extractor.sh b/claude-ops/scripts/ops-memory-extractor.sh
index d88142a6..b1cf5741 100755
--- a/claude-ops/scripts/ops-memory-extractor.sh
+++ b/claude-ops/scripts/ops-memory-extractor.sh
@@ -140,27 +140,28 @@ resolve_api_key() { resolve_auth; }
# ── Collect raw data ──────────────────────────────────────────────────────────
collect_data() {
- local wacli_data="" email_data=""
+ local wa_data="" email_data=""
local yesterday
yesterday=$(TZ=UTC _date_days_ago 1 "+%Y-%m-%d")
- # WhatsApp via wacli
- if command -v wacli &>/dev/null; then
+ # WhatsApp via Baileys bridge messages.db
+ local bridge_db="${WHATSAPP_BRIDGE_DB:-$HOME/.local/share/whatsapp-mcp/whatsapp-bridge/store/messages.db}"
+ if [[ -f "$bridge_db" ]]; then
local health_status=""
- if [[ -f "${HOME}/.wacli/.health" ]]; then
- health_status=$(cat "${HOME}/.wacli/.health" 2>/dev/null || true)
+ if lsof -i :8080 2>/dev/null | grep -q LISTEN; then
+ health_status="connected"
fi
if echo "${health_status}" | grep -qi "connected\|ok\|healthy" 2>/dev/null; then
log "Collecting WhatsApp messages..."
- wacli_data=$(wacli messages list --after="${yesterday}" --limit=200 --json 2>/dev/null || true)
- if [[ -z "${wacli_data}" ]]; then
- log "wacli returned no data (skipping)"
+ wa_data=$(sqlite3 "$bridge_db" "SELECT json_group_array(json_object('chat_jid',chat_jid,'sender',sender,'content',content,'timestamp',timestamp,'is_from_me',is_from_me)) FROM messages WHERE timestamp >= '${yesterday}' ORDER BY timestamp DESC LIMIT 200;" 2>/dev/null || true)
+ if [[ -z "${wa_data}" ]]; then
+ log "bridge db returned no data (skipping)"
fi
else
- log "wacli not connected (skipping WhatsApp)"
+ log "whatsapp-bridge not running (skipping WhatsApp)"
fi
else
- log "wacli not available (skipping WhatsApp)"
+ log "bridge db not found (skipping WhatsApp)"
fi
# Email via gog
@@ -174,7 +175,7 @@ collect_data() {
log "gog not available (skipping email)"
fi
- if [[ -z "${wacli_data}" && -z "${email_data}" ]]; then
+ if [[ -z "${wa_data}" && -z "${email_data}" ]]; then
log "No data sources available — nothing to extract"
write_health "skipped" "no data sources"
exit 0
@@ -183,7 +184,7 @@ collect_data() {
# Write combined raw payload
cat > "${TMP_RAW}" <<EOF
{
- "whatsapp_messages": ${wacli_data:-null},
+ "whatsapp_messages": ${wa_data:-null},
"emails": ${email_data:-null},
"collected_at": "$(ts)"
}
diff --git a/claude-ops/scripts/ops-message-listener.sh b/claude-ops/scripts/ops-message-listener.sh
index f5a9ba74..01c9cc69 100755
--- a/claude-ops/scripts/ops-message-listener.sh
+++ b/claude-ops/scripts/ops-message-listener.sh
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
# ops-message-listener.sh — Poll-based message listener (replaces OpenClaw WebSocket gateway)
-# Supervised by ops-daemon. Polls WhatsApp (wacli) + Telegram every 60s.
+# Supervised by ops-daemon. Polls WhatsApp (Baileys bridge messages.db) + Telegram every 60s.
# New non-owner messages → written to inbox-queue.json for /ops:inbox to consume.
# Health status written to listener-health.txt for daemon monitoring.
set -euo pipefail
@@ -11,7 +11,7 @@ LOG="$LOG_DIR/message-listener.log"
QUEUE_FILE="$DATA_DIR/inbox-queue.json"
HEALTH_FILE="$DATA_DIR/listener-health.txt"
STATE_FILE="$DATA_DIR/listener-state.json"
-WACLI="${WACLI_BIN:-$(command -v wacli 2>/dev/null || echo /usr/local/bin/wacli)}"
+BRIDGE_DB="${WHATSAPP_BRIDGE_DB:-$HOME/.local/share/whatsapp-mcp/whatsapp-bridge/store/messages.db}"
POLL_INTERVAL="${OPS_LISTENER_POLL_INTERVAL:-60}"
mkdir -p "$LOG_DIR" "$DATA_DIR"
@@ -87,7 +87,7 @@ print(added)
# ── Poll WhatsApp ─────────────────────────────────────────────────────────
poll_whatsapp() {
local since="$1"
- if ! command -v wacli &>/dev/null && [[ ! -x "$WACLI" ]]; then
+ if [[ ! -f "$BRIDGE_DB" ]]; then
echo "[]"
return
fi
@@ -96,7 +96,7 @@ poll_whatsapp() {
[[ -n "$since" ]] && since_flag="--after=$since"
local raw
- raw=$("$WACLI" messages list $since_flag --limit 20 --json 2>/dev/null || echo "[]")
+ raw=$(sqlite3 "$BRIDGE_DB" "SELECT json_group_array(json_object('chat_jid',chat_jid,'sender',sender,'content',content,'timestamp',timestamp,'is_from_me',is_from_me)) FROM messages WHERE timestamp > '${WA_LAST_SEEN:-1970-01-01}' ORDER BY timestamp DESC LIMIT 20;" 2>/dev/null || echo "[]")
# Filter: only non-owner (from_me=false) messages
echo "$raw" | python3 -c "