- Moved all agent loop scripts into source control (bin/) - claude-loop.sh, gemini-loop.sh, timmy-orchestrator.sh - workforce-manager.py, agent-dispatch.sh, nexus-merge-bot.sh - ops dashboard scripts (ops-panel, ops-helpers, ops-gitea) - monitoring scripts (timmy-status, timmy-loopstat) - deploy.sh: one-command overlay onto ~/.hermes/ - Updated README with sidecar architecture docs - All loops now target the-nexus + autolora only
77 lines
3.6 KiB
Bash
Executable File
77 lines
3.6 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# ── Claudemax Watchdog ─────────────────────────────────────────────────
|
|
# Ensures claude-loop.sh stays alive in the timmy-loop tmux session.
|
|
# Run via cron every 5 minutes. Zero LLM cost — pure bash.
|
|
#
|
|
# Also replenishes the backlog when issues run low by filing
|
|
# template issues from a seed list.
|
|
# ───────────────────────────────────────────────────────────────────────
|
|
|
|
set -uo pipefail
|
|
export PATH="/opt/homebrew/bin:$HOME/.local/bin:$HOME/.hermes/bin:/usr/local/bin:$PATH"
|
|
|
|
SESSION="timmy-loop"
|
|
LOOP_PANE="1.1"
|
|
LOG="$HOME/.hermes/logs/claudemax-watchdog.log"
|
|
GITEA_URL="http://143.198.27.163:3000"
|
|
GITEA_TOKEN=$(cat "$HOME/.hermes/gitea_token_vps" 2>/dev/null)
|
|
REPO_API="$GITEA_URL/api/v1/repos/rockachopa/Timmy-time-dashboard"
|
|
MIN_OPEN_ISSUES=10
|
|
|
|
log() { echo "[$(date '+%Y-%m-%d %H:%M:%S')] CLAUDEMAX: $*" >> "$LOG"; }
|
|
|
|
# ── 1. Is the tmux session alive? ──────────────────────────────────────
|
|
if ! tmux has-session -t "$SESSION" 2>/dev/null; then
|
|
log "Session $SESSION not found. Starting dashboard..."
|
|
bash "$HOME/.hermes/bin/start-dashboard.sh"
|
|
sleep 3
|
|
fi
|
|
|
|
# ── 2. Is claude-loop running in the loop pane? ───────────────────────
|
|
PANE_CMD=$(tmux list-panes -t "$SESSION:${LOOP_PANE%%.*}" -F '#{pane_index}:#{pane_current_command}' 2>/dev/null \
|
|
| grep "^${LOOP_PANE##*.}:" | cut -d: -f2)
|
|
|
|
CLAUDE_RUNNING=$(pgrep -f "claude-loop.sh" 2>/dev/null | head -1)
|
|
|
|
if [ -z "$CLAUDE_RUNNING" ]; then
|
|
log "claude-loop not running. Restarting in pane $LOOP_PANE..."
|
|
# Clear any dead shell
|
|
tmux send-keys -t "$SESSION:$LOOP_PANE" C-c 2>/dev/null
|
|
sleep 1
|
|
tmux send-keys -t "$SESSION:$LOOP_PANE" "bash ~/.hermes/bin/claude-loop.sh 2" Enter
|
|
log "Restarted claude-loop.sh with 2 workers"
|
|
else
|
|
log "claude-loop alive (PID $CLAUDE_RUNNING)"
|
|
fi
|
|
|
|
# ── 3. Backlog depth check ─────────────────────────────────────────────
|
|
OPEN_COUNT=$(curl -s --max-time 10 -H "Authorization: token $GITEA_TOKEN" \
|
|
"$REPO_API/issues?state=open&type=issues&limit=1" 2>/dev/null \
|
|
| python3 -c "import sys,json; print(len(json.loads(sys.stdin.read())))" 2>/dev/null || echo 0)
|
|
|
|
log "Open issues: $OPEN_COUNT (minimum: $MIN_OPEN_ISSUES)"
|
|
|
|
if [ "$OPEN_COUNT" -lt "$MIN_OPEN_ISSUES" ]; then
|
|
log "Backlog running low! Filing replenishment issues..."
|
|
# Source the backlog generator
|
|
bash "$HOME/.hermes/bin/claudemax-replenish.sh" 2>&1 | while read -r line; do log "$line"; done
|
|
fi
|
|
|
|
# ── 5. Auto-deploy Matrix if new commits ──────────────────────────────
|
|
bash "$HOME/.hermes/bin/autodeploy-matrix.sh" 2>&1 | while read -r line; do log "$line"; done
|
|
|
|
log "Watchdog complete."
|
|
|
|
# ── 4. Is gemini-loop running? ────────────────────────────────────────
|
|
GEMINI_RUNNING=$(pgrep -f "gemini-loop.sh" 2>/dev/null | head -1)
|
|
|
|
if [ -z "$GEMINI_RUNNING" ]; then
|
|
log "gemini-loop not running. Restarting..."
|
|
tmux send-keys -t "ops:1.2" C-c 2>/dev/null
|
|
sleep 1
|
|
tmux send-keys -t "ops:1.2" "bash ~/.hermes/bin/gemini-loop.sh 1" Enter
|
|
log "Restarted gemini-loop.sh with 1 worker"
|
|
else
|
|
log "gemini-loop alive (PID $GEMINI_RUNNING)"
|
|
fi
|