peppa/scripts/install-launchd.sh
Асель 967f70ac09 Add runner: tmux sessions, Claude hook ingestion and watchdog
- startSession: trusts the workspace in ~/.claude.json, runs interactive
  claude in tmux with PEPPA_SESSION_ID, remain-on-exit for crash status
- answerAndDeliver: PM answers go into the terminal (permission menu keys,
  approval -> task status + instruction, free text via bracketed paste)
- peppa-hook: session-start/prompt/notification/stop/session-end update
  session status and raise PM questions; never fails the Claude session
- watchdog: detects dead panes, vanished sessions, stalls, usage limits;
  launchd agent under caffeinate (scripts/install-launchd.sh)
- CLI: peppa session start|list|send|attach|stop, peppa watchdog

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 19:28:07 +05:00

33 lines
1.4 KiB
Bash
Executable File

#!/usr/bin/env bash
# Installs the Peppa watchdog as a launchd agent (starts at login, restarts on crash).
# caffeinate -i keeps the Mac from idle-sleeping while the watchdog runs.
# Remove: launchctl bootout gui/$(id -u)/quest.telecom.peppa.watchdog && rm the plist.
set -euo pipefail
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
LABEL=quest.telecom.peppa.watchdog
PLIST="$HOME/Library/LaunchAgents/$LABEL.plist"
mkdir -p "$HOME/Library/LaunchAgents" "$HOME/.peppa"
cat > "$PLIST" <<PLIST
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key><string>$LABEL</string>
<key>ProgramArguments</key>
<array>
<string>/usr/bin/caffeinate</string><string>-i</string>
<string>$ROOT/packages/cli/bin/peppa</string><string>watchdog</string>
</array>
<key>EnvironmentVariables</key>
<dict><key>PATH</key><string>$HOME/.local/bin:/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin</string></dict>
<key>RunAtLoad</key><true/>
<key>KeepAlive</key><true/>
<key>StandardOutPath</key><string>$HOME/.peppa/watchdog.log</string>
<key>StandardErrorPath</key><string>$HOME/.peppa/watchdog.log</string>
</dict>
</plist>
PLIST
launchctl bootout "gui/$(id -u)/$LABEL" 2>/dev/null || true
launchctl bootstrap "gui/$(id -u)" "$PLIST"
echo "watchdog installed: $PLIST (log: ~/.peppa/watchdog.log)"