feat(phase5): polish + deployment

- skill/SKILL.md: rewritten to 9 lines — 'status is automatic'
- deploy-to-agents.sh: no AGENTS.md injection; deploys hook + npm install
- install.sh: clean install flow; prints required env vars
- deploy/status-watcher.service: systemd unit file
- deploy/Dockerfile: containerized deployment (node:22-alpine)
- src/live-status.js: deprecation warning + start-watcher/stop-watcher pass-through
- README.md: full docs (architecture, install, config, upgrade guide, troubleshooting)
- make check: 0 errors, 0 format issues
- npm test: 59 unit + 36 integration = 95 tests passing
This commit is contained in:
sol
2026-03-07 17:45:22 +00:00
parent 5bb36150c4
commit 835faa0eab
7 changed files with 476 additions and 160 deletions

View File

@@ -1,69 +1,81 @@
#!/bin/bash
# install.sh — Live Status v4 installer
#
# Installs npm dependencies and deploys the gateway:startup hook.
# The watcher daemon starts automatically on next gateway restart.
#
# Usage: bash install.sh [--workspace DIR]
# OpenClaw Live Status Installer (Wizard Mode)
set -e
echo "=========================================="
echo " OpenClaw Live Status Tool - Installer "
echo "=========================================="
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
WORKSPACE="${1:-/home/node/.openclaw/workspace}"
# 1. Install Binary
echo "[+] Installing binary to /usr/local/bin/live-status..."
cp src/live-status.js /usr/local/bin/live-status
chmod +x /usr/local/bin/live-status
# Parse flags
while [[ "$#" -gt 0 ]]; do
case "$1" in
--workspace) WORKSPACE="$2"; shift 2 ;;
*) shift ;;
esac
done
# 2. Install Skill
echo "[+] Installing skill to /app/skills/live-status..."
mkdir -p /app/skills/live-status
cp skill/SKILL.md /app/skills/live-status/SKILL.md
# 3. Global Agent Configuration (Injection)
echo "[+] Configuring global agent defaults..."
AGENTS_FILE="/home/node/.openclaw/workspace/AGENTS.md"
if [ -f "$AGENTS_FILE" ]; then
if grep -q "Live Status Protocol" "$AGENTS_FILE"; then
echo " > AGENTS.md already configured."
else
echo " > Injecting mandatory protocol into AGENTS.md..."
cat >> "$AGENTS_FILE" <<EOF
## 📡 Live Status Protocol (MANDATORY)
**For ANY multi-step task (e.g., research, downloading, installing, compiling):**
1. **Read Skill:** Load \`/app/skills/live-status/SKILL.md\`.
2. **Initialize:** Run \`live-status create\` with a code block (\`[STATUS] INITIALIZING...\`).
3. **Capture ID:** Store the Post ID returned by \`create\`.
4. **Update:** Frequently run \`live-status update <ID>\` to stream progress.
5. **Complete:** Mark as \`[COMPLETED]\` when done.
**Why:** This provides "Antigravity-style" visibility without spamming channels. Sub-agents MUST use this tool instead of \`message\` for progress reports.
EOF
fi
else
echo " > Warning: AGENTS.md not found. Skipping injection."
fi
# 4. Mattermost Configuration (Wizard)
echo "==================================="
echo " Live Status v4 Installer"
echo "==================================="
echo "Project: $SCRIPT_DIR"
echo "Workspace: $WORKSPACE"
echo ""
echo "[?] Mattermost Configuration Check:"
# Check if the installed tool still has the default placeholder
if grep -q "DEFAULT_TOKEN_PLACEHOLDER" /usr/local/bin/live-status; then
echo " > Default token detected."
read -p " > Enter your Mattermost Bot Token: " NEW_TOKEN
if [[ -n "$NEW_TOKEN" ]]; then
# Replace the placeholder in the INSTALLED binary (not the source)
sed -i "s/DEFAULT_TOKEN_PLACEHOLDER/$NEW_TOKEN/g" /usr/local/bin/live-status
echo " > Token configured successfully."
else
echo " > No token entered. Tool may not function."
fi
else
echo " > Custom token already configured."
fi
# 1. Install npm dependencies
echo "[1/3] Installing npm dependencies..."
cd "$SCRIPT_DIR"
npm install --production
echo " Done."
# 2. Deploy hook
echo "[2/3] Deploying gateway:startup hook..."
HOOKS_DIR="$WORKSPACE/hooks"
mkdir -p "$HOOKS_DIR/status-watcher-hook"
cp -r "$SCRIPT_DIR/hooks/status-watcher-hook/." "$HOOKS_DIR/status-watcher-hook/"
echo " Hook deployed to: $HOOKS_DIR/status-watcher-hook/"
# 3. Print required environment variables
echo "[3/3] Post-install configuration"
echo ""
echo "=========================================="
echo " Installation Complete!"
echo "=========================================="
echo "Usage: live-status create \"...\""
echo "==================================="
echo " Required Environment Variables"
echo "==================================="
echo ""
echo "Set these before the watcher will function:"
echo ""
echo " MM_TOKEN Mattermost bot token"
echo " (find in openclaw.json -> mattermost.accounts)"
echo ""
echo " MM_URL Mattermost base URL"
echo " e.g. https://slack.solio.tech"
echo ""
echo " TRANSCRIPT_DIR Path to agent sessions directory"
echo " e.g. /home/node/.openclaw/agents/main/sessions"
echo ""
echo " SESSIONS_JSON Path to sessions.json"
echo " e.g. /home/node/.openclaw/agents/main/sessions/sessions.json"
echo ""
echo "Optional (shown with defaults):"
echo " THROTTLE_MS=500 Update interval (ms)"
echo " IDLE_TIMEOUT_S=60 Idle before marking session done"
echo " MAX_STATUS_LINES=15 Lines shown in status box"
echo " MAX_ACTIVE_SESSIONS=20 Concurrent session limit"
echo " HEALTH_PORT=9090 Health endpoint port (0=disabled)"
echo " LOG_LEVEL=info Logging level"
echo " PID_FILE=/tmp/status-watcher.pid"
echo ""
echo "==================================="
echo " Installation Complete"
echo "==================================="
echo ""
echo "The watcher starts automatically on next gateway startup."
echo "To start immediately (with env vars set):"
echo " node $SCRIPT_DIR/src/watcher-manager.js start"
echo ""
echo "Health check (once running):"
echo " curl http://localhost:9090/health"