feat: Phase 0+1 — repo sync, pino, lint fixes, core components

Phase 0:
- Synced latest live-status.js from workspace (9928 bytes)
- Fixed 43 lint issues: empty catch blocks, console statements
- Added pino dependency
- Created src/tool-labels.json with all known tool mappings
- make check passes

Phase 1 (Core Components):
- src/config.js: env-var config with validation, throws on missing required vars
- src/logger.js: pino singleton with child loggers, level validation
- src/circuit-breaker.js: CLOSED/OPEN/HALF_OPEN state machine with callbacks
- src/tool-labels.js: exact/prefix/regex tool->label resolver with external override
- src/status-box.js: Mattermost post manager (keepAlive, throttle, retry, circuit breaker)
- src/status-formatter.js: pure SessionState->text formatter (nested, compact)
- src/health.js: HTTP health endpoint + metrics
- src/status-watcher.js: JSONL file watcher (inotify, compaction detection, idle detection)

Tests:
- test/unit/config.test.js: 7 tests
- test/unit/circuit-breaker.test.js: 12 tests
- test/unit/logger.test.js: 5 tests
- test/unit/status-formatter.test.js: 20 tests
- test/unit/tool-labels.test.js: 15 tests

All 59 unit tests pass. make check clean.
This commit is contained in:
sol
2026-03-07 17:26:53 +00:00
parent b3ec2c61db
commit 43cfebee96
21 changed files with 2691 additions and 287 deletions

View File

@@ -6,17 +6,21 @@ Creates a single "status box" post and updates it repeatedly — no chat spam.
## Usage
### Create a status box
```bash
live-status --channel <CHANNEL_ID> create "🚀 **Task Started:** Initializing..."
```
Returns the `POST_ID` (26-char string). **Capture it.**
### Create in a thread
```bash
live-status --channel <CHANNEL_ID> --reply-to <ROOT_POST_ID> create "🚀 Starting..."
```
### Update the status box
```bash
live-status update <POST_ID> "🚀 **Task Running**
\`\`\`
@@ -26,6 +30,7 @@ live-status update <POST_ID> "🚀 **Task Running**
```
### Mark complete
```bash
live-status update <POST_ID> "✅ **Task Complete**
\`\`\`
@@ -36,6 +41,7 @@ live-status update <POST_ID> "✅ **Task Complete**
```
### Delete a status box
```bash
live-status delete <POST_ID>
```
@@ -43,32 +49,36 @@ live-status delete <POST_ID>
## Multi-Agent Support
When multiple agents share a channel, each creates its **own** status box:
```bash
# Agent A
BOX_A=$(live-status --channel $CH --agent god-agent create "🤖 God Agent working...")
# Agent B
BOX_B=$(live-status --channel $CH --agent nutrition-agent create "🥗 Nutrition Agent working...")
```
Each agent updates only its own box by ID. No conflicts.
## Options
| Flag | Purpose |
|---|---|
| `--channel ID` | Target channel (or set `MM_CHANNEL_ID`) |
| `--reply-to ID` | Post as thread reply (sets `root_id`) |
| `--agent NAME` | Use bot token mapped to this agent in openclaw.json |
| `--token TOKEN` | Explicit bot token (overrides everything) |
| `--host HOST` | Mattermost hostname |
| Flag | Purpose |
| --------------- | --------------------------------------------------- |
| `--channel ID` | Target channel (or set `MM_CHANNEL_ID`) |
| `--reply-to ID` | Post as thread reply (sets `root_id`) |
| `--agent NAME` | Use bot token mapped to this agent in openclaw.json |
| `--token TOKEN` | Explicit bot token (overrides everything) |
| `--host HOST` | Mattermost hostname |
## Auto-Detection
The tool reads `openclaw.json` automatically for:
- **Host** — from `mattermost.baseUrl`
- **Token** — from `mattermost.accounts` (mapped via `--agent` or defaults)
- No env vars or manual config needed in most cases.
## Protocol
1. **Always** capture the `POST_ID` from `create`.
2. **Always** append to previous log (maintain full history in the message).
3. **Use code blocks** for technical logs.