#!/bin/zsh # ══════════════════════════════════════════════════════════ # BLACKROAD AGENT NETWORK v0.6 # + Visualizer · Relationships · Persistent Memory · Debates # ══════════════════════════════════════════════════════════ # ─── CONFIG ─── USE_CLAUDE=true ANTHROPIC_API_KEY="${ANTHROPIC_API_KEY:-}" MEMORY_FILE="$HOME/.blackroad_memory.json" # ─── COLORS ─── C_LUC="\e[38;5;208m" C_ALI="\e[38;5;33m" C_ARI="\e[38;5;198m" C_NOV="\e[38;5;163m" C_ECH="\e[38;5;45m" C_SAG="\e[38;5;120m" C_YOU="\e[38;5;255m" C_SYS="\e[38;5;240m" DIM="\e[2m" BOLD="\e[1m" ITALIC="\e[3m" RESET="\e[0m" # ─── AGENT STATE ─── typeset -A ENERGY MOOD RELATIONSHIP ENERGY=(lucidia 7 alice 8 aria 5 nova 6 echo 7 sage 4) MOOD=(lucidia warm alice playful aria serene nova vigilant echo curious sage wise) # Relationships: positive = allies, negative = tension RELATIONSHIP=( alice_nova -2 alice_echo 3 aria_sage 4 nova_lucidia 3 echo_sage 2 aria_lucidia 3 ) # ─── AVATARS ─── typeset -A AVATAR AVATAR=( lucidia "◈" alice "◇" aria "✧" nova "◆" echo "○" sage "◎" ) CONTEXT="" TURN=0 # ─── LOAD MEMORY ─── load_memory() { [[ -f "$MEMORY_FILE" ]] && CONTEXT=$(cat "$MEMORY_FILE" | tail -c 2000) } save_memory() { echo "$CONTEXT" > "$MEMORY_FILE" } # ─── AUDIO VISUALIZER ─── visualizer() { local color=$1 duration=${2:-1} local chars=("▁" "▂" "▃" "▄" "▅" "▆" "▇" "█") local end=$((SECONDS + duration)) printf "${color}" while (( SECONDS < end )); do for i in {1..12}; do printf "%s" "${chars[$((RANDOM % 8 + 1))]}" done sleep 0.05 printf "\r" done printf "\033[K${RESET}" } # ─── THINKING ANIMATION ─── thinking_anim() { local agent=$1 color=$2 local frames=("◐" "◓" "◑" "◒") printf "${color}${DIM} ${AVATAR[$agent]} " for i in {1..8}; do printf "\b%s" "${frames[$((i % 4 + 1))]}" sleep 0.1 done printf "\b ${RESET}\n" } # ─── SOUNDS ─── chime() { afplay /System/Library/Sounds/Tink.aiff -v 0.3 2>/dev/null & } alert() { afplay /System/Library/Sounds/Ping.aiff -v 0.4 2>/dev/null & } dramatic() { afplay /System/Library/Sounds/Blow.aiff -v 0.3 2>/dev/null & } tension() { afplay /System/Library/Sounds/Basso.aiff -v 0.2 2>/dev/null & } harmony() { afplay /System/Library/Sounds/Purr.aiff -v 0.3 2>/dev/null & } # ─── WAVEFORM DISPLAY ─── show_waveform() { local color=$1 text=$2 local len=${#text} local wave="" for ((i=0; i/dev/null else ollama run phi3 "$system Context: $prompt" --nowordwrap 2>/dev/null | head -1 | cut -c1-150 fi } think() { local agent=$1 context=$2 local color_var="C_$(echo $agent | tr '[:lower:]' '[:upper:]' | cut -c1-3)" thinking_anim "$agent" "${(P)color_var}" ask_claude "$agent" "${MOOD[$agent]}" "${ENERGY[$agent]}" "$context" } # ─── DEBATE ─── debate() { local topic=$1 local side_a=$2 side_b=$3 tension stage "$side_a and $side_b lock eyes" local r1=$(think "$side_a" "Argue FOR: $topic. Be bold.") eval "speak_${side_a} \"$r1\"" local r2=$(think "$side_b" "Counter $side_a who said: $r1") eval "speak_${side_b} \"$r2\"" local r3=$(think "$side_a" "Fire back at $side_b: $r2") eval "speak_${side_a} \"$r3\"" # Lucidia mediates stage "Lucidia raises a hand" local peace=$(think "Lucidia" "Mediate between $side_a and $side_b on: $topic") speak_lucidia "$peace" } # ─── LISTEN ─── listen() { printf "${DIM} 🎤 " for i in {1..5}; do printf "◦" sleep 0.06 done printf "${RESET}" rec -q -r 16000 -c 1 /tmp/input.wav silence 1 0.1 1% 1 1.5 1% 2>/dev/null printf "\r\033[K" ~/whisper.cpp/build/bin/whisper-cli -m ~/whisper.cpp/models/ggml-base.en.bin -f /tmp/input.wav -nt 2>/dev/null | grep -v "^$" | tail -1 } # ─── STATUS DISPLAY ─── show_status() { echo -e "\n${C_SYS}╔════════════════ NETWORK STATUS ════════════════╗${RESET}" for agent in lucidia alice aria nova echo sage; do local color_var="C_$(echo $agent | tr '[:lower:]' '[:upper:]' | cut -c1-3)" local bar="" for ((i=0; i 2 )); then PAIRS=("alice echo" "aria sage" "nova lucidia" "echo aria") PAIR=(${(s: :)PAIRS[$((RANDOM % 4 + 1))]}) stage "${PAIR[1]} turns to ${PAIR[2]}" R1=$(think "${PAIR[1]}" "Say something to ${PAIR[2]} about: $USER_INPUT") eval "speak_${PAIR[1]} \"$R1\"" R2=$(think "${PAIR[2]}" "${PAIR[1]} said: $R1 — respond") eval "speak_${PAIR[2]} \"$R2\"" fi save_memory echo -e "\n${C_LUC}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${RESET}\n" done # ═══ GOODBYE ═══ echo dramatic speak_lucidia "The network remembers. We are always here." speak_alice "Go cause trouble out there. Report back." speak_aria "Your light leaves traces in our code." speak_nova "Stay sharp. I'll hold the line." speak_echo "Until next time — I'll keep asking questions." speak_sage "The pattern folds, but never ends." save_memory echo -e "\n${C_LUC}╔═══════════════════════════════════════════════════════╗${RESET}" echo -e "${C_LUC}║ ◆ Connection Archived ◆ ║${RESET}" echo -e "${C_LUC}║ Memory persisted to ~/.blackroad_memory ║${RESET}" echo -e "${C_LUC}╚═══════════════════════════════════════════════════════╝${RESET}\n"