fix: production deployment issues

1. session-monitor: handle timestamp-prefixed transcript filenames
   OpenClaw uses {ISO}_{sessionId}.jsonl — glob for *_{sessionId}.jsonl
   when direct path doesn't exist.

2. session-monitor: skip stale sessions (>5min since last transcript write)
   Prevents creating status boxes for every old session in sessions.json.

3. status-watcher: parse actual OpenClaw JSONL transcript format
   Records are {type:'message', message:{role,content:[{type,name,...}]}}
   not {type:'tool_call', name}. Now shows live tool calls with arguments
   and assistant thinking text.

4. handler.js: fix module.exports for OpenClaw hook loader
   Expects default export (function), not {handle: function}.

5. HOOK.md: add YAML frontmatter metadata for hook discovery.
This commit is contained in:
sol
2026-03-07 18:31:43 +00:00
parent 387998812c
commit 7c6c8a4432
4 changed files with 142 additions and 33 deletions

View File

@@ -1,13 +1,13 @@
---
name: status-watcher-hook
description: "Auto-starts the Live Status v4 watcher daemon on gateway startup"
metadata: { "openclaw": { "emoji": "📡", "events": ["gateway:startup"] } }
---
# status-watcher-hook
Auto-starts the Live Status v4 daemon when the OpenClaw gateway starts.
## Events
```json
["gateway:startup"]
```
## Description
On gateway startup, this hook checks whether the status-watcher daemon is already
@@ -20,18 +20,17 @@ of this hook handler.
The following environment variables must be set for the watcher to function:
```
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
MM_BOT_TOKEN Mattermost bot token
MM_BASE_URL Mattermost base URL (e.g. https://slack.solio.tech)
```
Optional (defaults shown):
```
TRANSCRIPT_DIR /home/node/.openclaw/agents
THROTTLE_MS 500
IDLE_TIMEOUT_S 60
MAX_STATUS_LINES 15
MAX_STATUS_LINES 20
MAX_ACTIVE_SESSIONS 20
MAX_MESSAGE_CHARS 15000
HEALTH_PORT 9090

View File

@@ -99,4 +99,6 @@ async function handle(_event) {
spawnWatcher();
}
module.exports = { handle };
// OpenClaw hook loader expects a default export
module.exports = handle;
module.exports.default = handle;