#!/usr/bin/env bash # ~/bin/af - Antigravity Fleet Session Connector # Each node in the fleet casts its own local session of Techné. # If a specific node is requested (e.g. af bazina), connects to that node. set -euo pipefail SESSION_NAME="techne" DEFAULT_CONV="9860fe31-3526-48d1-9063-3e58e630faf9" CURRENT_HOST="$(hostname -s 2>/dev/null || uname -n)" if [ -n "${TERMUX_VERSION:-}" ] || [ -d "/data/data/com.termux" ]; then CURRENT_HOST="phone" fi TARGET_NODE="" if [ $# -gt 0 ]; then case "$1" in t520|bazina|boxC|penguin|android|phone) TARGET_NODE="$1" shift ;; esac fi # Build agy invocation AGY_INVOCATION="agy" if [[ "$*" != *"--conversation"* ]] && [[ -n "$DEFAULT_CONV" ]]; then AGY_INVOCATION="agy --conversation=$DEFAULT_CONV" fi log_cast() { local node="${1:-$CURRENT_HOST}" if command -v now >/dev/null 2>&1; then now "[AF:$node] Techné session cast/attached" || true fi } if [ -n "$TARGET_NODE" ] && [ "$TARGET_NODE" != "$CURRENT_HOST" ]; then log_cast "$TARGET_NODE" echo "[af] Connecting to Techné session on $TARGET_NODE..." exec ssh -t "$TARGET_NODE" "tmux new-session -A -s '$SESSION_NAME' $AGY_INVOCATION $*" fi # Cast local session of Techné log_cast "$CURRENT_HOST" if command -v tmux >/dev/null 2>&1; then exec tmux new-session -A -s "$SESSION_NAME" $AGY_INVOCATION "$@" elif command -v agy >/dev/null 2>&1; then exec agy --conversation="$DEFAULT_CONV" "$@" else echo "[af] Local agy/tmux not found on $CURRENT_HOST; falling back to boxC..." exec ssh -t boxC "tmux new-session -A -s '$SESSION_NAME' $AGY_INVOCATION $*" fi