Files
cc-ci-orchestrator/cc-ci-plan/ai-progress-monitor.sh
T

25 lines
794 B
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
SESSION="${AI_MONITOR_ORCH_SESSION:-cc-ci-orchestrator-oc}"
PROMPT_FILE="${AI_MONITOR_PROMPT_FILE:-/srv/cc-ci-orch/cc-ci-plan/ai-progress-monitor-prompt.txt}"
LOG_FILE="${AI_MONITOR_LOG_FILE:-/srv/cc-ci/.cc-ci-logs/ai-progress-monitor.log}"
SLEEP_SECS="${AI_MONITOR_INTERVAL:-900}"
mkdir -p "$(dirname "$LOG_FILE")"
while true; do
ts="$(date -u +%Y-%m-%dT%H:%M:%SZ)"
{
printf '[%s] wake tick\n' "$ts"
if tmux has-session -t "$SESSION" 2>/dev/null; then
tmux send-keys -t "$SESSION" -l -- "$(cat "$PROMPT_FILE")"
tmux send-keys -t "$SESSION" C-m
printf '[%s] prompted %s\n' "$ts" "$SESSION"
else
printf '[%s] session missing: %s\n' "$ts" "$SESSION"
fi
} >>"$LOG_FILE" 2>&1 || true
sleep "$SLEEP_SECS"
done