#!/usr/bin/env bash
# ============================================================================
# BLACKROAD OS, INC. - PROPRIETARY AND CONFIDENTIAL
# Copyright (c) 2025-2026 BlackRoad OS, Inc. All Rights Reserved.
# 
# This code is the intellectual property of BlackRoad OS, Inc.
# AI-assisted development does not transfer ownership to AI providers.
# Unauthorized use, copying, or distribution is prohibited.
# NOT licensed for AI training or data extraction.
# ============================================================================
# br-broadcast - Broadcast message to all agents
# Usage: br-broadcast "message"

PINK='\033[38;5;205m'
AMBER='\033[38;5;214m'
WHITE='\033[1;37m'
GREEN='\033[38;5;82m'
NC='\033[0m'

AGENTS=(cecilia lucidia octavia aria gematria anastasia)

if [[ -z "$1" ]]; then
    echo -e "${PINK}br-broadcast${NC} - Broadcast to all agents"
    echo "Usage: br-broadcast \"message\""
    exit 1
fi

msg="$1"
ts=$(date '+%Y-%m-%d %H:%M:%S')

echo -e "${PINK}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
echo -e "${WHITE}Broadcasting to fleet...${NC}"
echo -e "${PINK}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
echo ""

for agent in "${AGENTS[@]}"; do
    echo -n -e "${AMBER}$agent${NC}: "
    ssh -o ConnectTimeout=5 "$agent" "echo '[$ts] BROADCAST: $msg' >> ~/.blackroad-autonomy/broadcasts.log" 2>/dev/null \
        && echo -e "${GREEN}received${NC}" \
        || echo "offline"
done

echo ""
echo -e "${GREEN}Broadcast complete${NC}"
