#!/bin/bash

# Script to clear the CLI screen for a specific agent in the swarm.
# This sends Ctrl+L to the target pane.

SESSION_NAME="jetski_swarm"
TARGET=$1 # e.g., agent_1

if [ -z "$TARGET" ]; then
    echo "Usage: $0 <target_agent>"
    echo "Example: $0 agent_1"
    exit 1
fi

# Map target name to tmux window/pane
if [[ "$TARGET" =~ ^agent_([0-9]+)$ ]]; then
    IDX="${BASH_REMATCH[1]}"
    TARGET="grid.$IDX"
elif [ "$TARGET" = "orchestrator" ]; then
    TARGET="grid.0"
fi

# Send Ctrl+L
tmux send-keys -t $SESSION_NAME:$TARGET C-l
echo "Sent Clear Screen command (Ctrl+L) to $TARGET"
