#!/bin/bash source ~/.agi_core/production.env 2>/dev/null || true # Unified iCloud AGI Storage - All cores sync here ICLOUD_AGI="${HOME}/Library/Mobile Documents/com~apple~CloudDocs/AGI_Data" CLI=/Users/josephanady/AGICore/build/agi_core_cli API_URL="https://agi_core.org/.netlify/functions/api/agi/ingest" LOCAL_STATE=~/.agi_core/agi_state.bin # Create all AGI core directories in iCloud mkdir -p "${ICLOUD_AGI}/agi_core" mkdir -p "${ICLOUD_AGI}/brain" mkdir -p "${ICLOUD_AGI}/hive" mkdir -p "${ICLOUD_AGI}/seferim/snapshots" mkdir -p "${ICLOUD_AGI}/seferim/substrate" # Source paths for other AGI cores BRAIN_GOOGLE="${HOME}/Library/CloudStorage/GoogleDrive-joseph.w.anady@gmail.com/My Drive/brain stuff" HIVE_DIR="${HOME}/The AI/hive-production" SEFERIM_G16="${HOME}/Library/Mobile Documents/com~apple~CloudDocs/Projects/SEFERIM_AGI_G16" ICLOUD_STATE="${ICLOUD_AGI}/agi_core/agi_state.bin" sync_count=0 while true; do # === AGICore (every 5 seconds) === STATE=$($CLI status 2>/dev/null) if [ -n "$STATE" ]; then # Save compressed JSON to iCloud echo "$STATE" | zstd -q -f -o "${ICLOUD_AGI}/agi_core/agi_state.json.zst" 2>/dev/null # Keep tiny local copy for API echo "$STATE" > ~/.agi_core/agi_state.json # POST to API curl -s -X POST "$API_URL" \ -H "Content-Type: application/json" \ -H "X-AGI-Token: $AGI_INGEST_TOKEN" \ -d "$STATE" > /dev/null 2>&1 fi # === Sync other AGI cores (every 30 seconds) === if [ $((sync_count % 6)) -eq 0 ]; then # Brain stuff from Google Drive -> iCloud if [ -d "$BRAIN_GOOGLE/logs" ]; then tar -cf - -C "$BRAIN_GOOGLE" logs 2>/dev/null | zstd -q > "${ICLOUD_AGI}/brain/brain_logs.tar.zst" 2>/dev/null || true fi # Hive data -> iCloud if [ -d "$HIVE_DIR/data" ]; then tar -cf - -C "$HIVE_DIR" data 2>/dev/null | zstd -q > "${ICLOUD_AGI}/hive/hive_data.tar.zst" 2>/dev/null || true fi if [ -d "$HIVE_DIR/logs" ]; then tar -cf - -C "$HIVE_DIR" logs 2>/dev/null | zstd -q > "${ICLOUD_AGI}/hive/hive_logs.tar.zst" 2>/dev/null || true fi # SEFERIM G16 -> iCloud (if exists) if [ -d "$SEFERIM_G16" ]; then find "$SEFERIM_G16" -name "*.json" -mmin -5 -exec zstd -q -f {} -o "${ICLOUD_AGI}/seferim/snapshots/{}.zst" \; 2>/dev/null || true fi fi sync_count=$((sync_count + 1)) sleep 5 done