#!/bin/bash
# Wait until the iMac agent Claude (tmux session 2) is back up and listening.
TMUX=/opt/homebrew/bin/tmux
for i in $(seq 1 40); do
  c=$("$TMUX" capture-pane -t 2 -p 2>/dev/null)
  if echo "$c" | grep -q "Listening for channel messages"; then echo "UP_LISTENING"; exit 0; fi
  if echo "$c" | grep -q "bypass permissions on"; then echo "UP_PROMPT"; exit 0; fi
  sleep 3
done
echo "TIMEOUT"
exit 3
