feat: implement --onboard flag in multi-agent-mux-create and update AGENT.md onboarding handshake protocol

This commit is contained in:
2026-06-28 10:42:23 +09:00
parent 6e3c866461
commit ef57749e9f
5 changed files with 135 additions and 2 deletions
+63
View File
@@ -826,4 +826,67 @@ start_watchdog() {
echo "$pid"
}
# wait_for_tui_ready <session_name> <agent>
# Gated wait to ensure that the agent's TUI is fully loaded and responsive
# before injecting any keyboard instructions.
wait_for_tui_ready() {
local sess="$1" agent="$2"
local local_tmux="tmux"
if [ -n "${TMUX_SERVER_NAME:-}" ] && [ "$TMUX_SERVER_NAME" != "default" ]; then
local_tmux="tmux -L $TMUX_SERVER_NAME"
fi
echo "🔍 Waiting for $agent TUI to become ready..."
for i in {1..15}; do
local content
content=$($local_tmux capture-pane -p -t "$sess" 2>/dev/null || echo "")
if [ -n "$content" ]; then
case "$agent" in
claude)
if echo "$content" | grep -E -q "Anthropic|Assistant|Chat|Dangerously|dangerously|Enter|Welcome|projects" 2>/dev/null; then
echo "✅ Claude TUI detected ready."
return 0
fi
;;
agy)
if echo "$content" | grep -q "Antigravity" 2>/dev/null; then
echo "✅ Antigravity TUI detected ready."
return 0
fi
;;
hermes)
if echo "$content" | grep -q "Hermes" 2>/dev/null; then
echo "✅ Hermes TUI detected ready."
return 0
fi
;;
cline)
if echo "$content" | grep -E -q "Cline|history|Chat" 2>/dev/null; then
echo "✅ Cline TUI detected ready."
return 0
fi
;;
esac
fi
sleep 1
done
echo "⚠️ Warning: TUI readiness check timed out. Proceeding anyway..."
}
# inject_instructions <session_name> <instructions> [job_id]
# Injects instructions into the tmux session using paste-buffer and C-m.
inject_instructions() {
local sess="$1" instructions="$2" job_id="${3:-onboard}"
local local_tmux="tmux"
if [ -n "${TMUX_SERVER_NAME:-}" ] && [ "$TMUX_SERVER_NAME" != "default" ]; then
local_tmux="tmux -L $TMUX_SERVER_NAME"
fi
$local_tmux set-buffer -b "job_buf_$job_id" "$instructions"
$local_tmux paste-buffer -b "job_buf_$job_id" -t "$sess"
sleep 0.5
$local_tmux send-keys -t "$sess" C-m
$local_tmux delete-buffer -b "job_buf_$job_id"
}