feat(phase6): docs, lint fixes, STATE.json update

- Fix lint errors in plugin-client.js (unused var, empty block)
- Update README with plugin architecture and env vars
- Update STATE.json to v4.1 IMPLEMENTATION_COMPLETE
- All 96 tests passing, 0 lint errors
This commit is contained in:
sol
2026-03-07 22:14:23 +00:00
parent c724e57276
commit 42755e73ad
4 changed files with 1985 additions and 71 deletions

View File

@@ -7,27 +7,47 @@ Agents no longer need to call `live-status`. The watcher auto-updates Mattermost
## 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 recursive on transcript directory (inotify, Node 22)
-> fs.watch + polling fallback on transcript directory
-> Multiplexes all active sessions
-> SessionState map: sessionKey -> { postId, pendingToolCalls, lines[] }
-> 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 Mattermost updates (leading edge + trailing flush, 500ms)
-> 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
-> Daemon starts automatically with gateway
Mattermost API
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
@@ -89,6 +109,9 @@ All config via environment variables. No hardcoded values.
| `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