# Live Status v4 Real-time Mattermost progress updates for OpenClaw agent sessions. Version 4 replaces the manual v1 live-status CLI with a transparent infrastructure daemon. Agents no longer need to call `live-status`. The watcher auto-updates Mattermost as they work. ## Architecture Two rendering modes (auto-detected): ### Plugin Mode (preferred) When the Mattermost plugin is installed, updates stream via WebSocket: - Custom post type `custom_livestatus` with terminal-style React rendering - Zero Mattermost post API calls during streaming (no "(edited)" label) - Auto-scroll, collapsible sub-agents, theme-compatible ### REST API Fallback When the plugin is unavailable, updates use the Mattermost REST API: - Blockquote-formatted posts updated via PUT - Shows "(edited)" label (Mattermost API limitation) ``` OpenClaw Gateway Agent Sessions -> writes {uuid}.jsonl as they run status-watcher daemon (SINGLE PROCESS) -> fs.watch + polling fallback on transcript directory -> Multiplexes all active sessions -> Auto-detects plugin (GET /health every 60s) -> Plugin mode: POST/PUT/DELETE to plugin REST endpoint -> Plugin broadcasts via WebSocket to React component -> REST fallback: PUT to Mattermost post API -> Shared HTTP connection pool (keep-alive, maxSockets=4) -> Throttled updates (leading edge + trailing flush, 500ms) -> Circuit breaker for API failure resilience -> Graceful shutdown (SIGTERM -> mark all boxes "interrupted") -> Sub-agent nesting (child sessions under parent status box) Mattermost Plugin (com.openclaw.livestatus) -> Go server: REST API + KV store + WebSocket broadcast -> React webapp: custom post type renderer -> Terminal-style UI with auto-scroll gateway:startup hook -> hooks/status-watcher-hook/handler.js -> Checks PID file; spawns daemon if not running Mattermost API (fallback) -> PUT /api/v4/posts/{id} (in-place edits, unlimited) -> Shared http.Agent (keepAlive, maxSockets=4) -> Circuit breaker: open after 5 failures, 30s cooldown ``` ## Install ### Prerequisites - Node.js 22.x - OpenClaw gateway running - Mattermost bot token ### One-command install ```sh cd /path/to/MATTERMOST_OPENCLAW_LIVESTATUS bash install.sh ``` This installs npm dependencies and deploys the `gateway:startup` hook. The daemon starts automatically on the next gateway restart. ### Manual start (without gateway restart) Set required env vars, then: ```sh node src/watcher-manager.js start ``` ## Configuration All config via environment variables. No hardcoded values. ### Required | Variable | Description | | ---------------- | ----------------------------------------------------- | | `MM_TOKEN` | Mattermost bot token | | `MM_URL` | Mattermost base URL (e.g. `https://slack.solio.tech`) | | `TRANSCRIPT_DIR` | Path to agent sessions directory | | `SESSIONS_JSON` | Path to sessions.json | ### Optional | Variable | Default | Description | | ---------------------------- | ------------------------- | ------------------------------------------ | | `THROTTLE_MS` | `500` | Min interval between Mattermost updates | | `IDLE_TIMEOUT_S` | `60` | Inactivity before marking session complete | | `MAX_SESSION_DURATION_S` | `1800` | Hard timeout per session (30 min) | | `MAX_STATUS_LINES` | `15` | Max lines in status box (oldest dropped) | | `MAX_ACTIVE_SESSIONS` | `20` | Concurrent status box limit | | `MAX_MESSAGE_CHARS` | `15000` | Mattermost post truncation limit | | `HEALTH_PORT` | `9090` | Health endpoint port (0 = disabled) | | `LOG_LEVEL` | `info` | Logging level (pino) | | `PID_FILE` | `/tmp/status-watcher.pid` | PID file location | | `CIRCUIT_BREAKER_THRESHOLD` | `5` | Failures before circuit opens | | `CIRCUIT_BREAKER_COOLDOWN_S` | `30` | Cooldown before half-open probe | | `TOOL_LABELS_FILE` | _(built-in)_ | External tool labels JSON override | | `DEFAULT_CHANNEL` | _none_ | Fallback channel for non-MM sessions | | `PLUGIN_URL` | _none_ | Plugin endpoint URL (enables plugin mode) | | `PLUGIN_SECRET` | _none_ | Shared secret for plugin authentication | | `PLUGIN_ENABLED` | `true` | Enable/disable plugin auto-detection | ## Status Box Format ``` [ACTIVE] main | 38s Reading live-status source code... exec: ls /agents/sessions [OK] Analyzing agent configurations... exec: grep -r live-status [OK] Writing new implementation... Sub-agent: proj035-planner Reading protocol... Analyzing JSONL format... [DONE] 28s Plan ready. Awaiting approval. [DONE] 53s | 12.4k tokens ``` ## Daemon Management ```sh # Start node src/watcher-manager.js start # Stop (graceful shutdown) node src/watcher-manager.js stop # Status node src/watcher-manager.js status # Pass-through via legacy CLI live-status start-watcher live-status stop-watcher # Health check curl http://localhost:9090/health ``` ## Deployment Options ### Hook (default) The `gateway:startup` hook in `hooks/status-watcher-hook/` auto-starts the daemon. No configuration needed beyond deploying the hook. ### systemd ```sh # Copy service file cp deploy/status-watcher.service /etc/systemd/system/ # Create env file cat > /etc/status-watcher.env < label resolver tool-labels.json Built-in tool label defaults live-status.js Legacy CLI (deprecated; backward compat) hooks/ status-watcher-hook/ gateway:startup hook (auto-start daemon) deploy/ status-watcher.service systemd unit file Dockerfile Container deployment test/ unit/ Unit tests (59 tests) integration/ Integration tests (36 tests) ```