Source identity
| Field | Recorded value |
|---|---|
| Source type | GitHub source |
| Original record | Janady13/healer-pro-pack / brain_manager.sh |
| Date | Not specified in source |
| Repository | Janady13/healer-pro-pack |
| Revision | f3c05ff2106f4617f2a81d62a43fe810b86cf9c8 |
| Branch | healer-core |
| Path or archive member | brain_manager.sh |
| Original SHA-256 | 2420c57de890fdbb2c6adeab9bd3ae8760017b682508063dce1d20962b42fb5d |
| Git blob SHA | 430f9fc31a1cc1fefbe60c864c505bff258b5f21 |
| Reading-copy SHA-256 | 2420c57de890fdbb2c6adeab9bd3ae8760017b682508063dce1d20962b42fb5d |
Recovered source transcript
Download complete source text ↓65 lines · 1.9 KB
#!/bin/bash
set -e
ROOT="$(cd "$(dirname "$0")" && pwd)"
LOGS="$ROOT/logs"
PLIST="$HOME/Library/LaunchAgents/com.aihealer.brain.plist"
mkdir -p "$LOGS"
echo "🧠 [AI Brain] Manager starting..."
# STEP 0: Ensure LaunchAgent exists for auto-start
cat > "$PLIST" <<PLIST
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.aihealer.brain</string>
<key>ProgramArguments</key>
<array>
<string>$ROOT/brain_manager.sh</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>StandardOutPath</key>
<string>$LOGS/auto_start.log</string>
<key>StandardErrorPath</key>
<string>$LOGS/auto_start_error.log</string>
</dict>
</plist>
PLIST
launchctl unload "$PLIST" 2>/dev/null || true
launchctl load "$PLIST"
echo "🔁 [AI Brain] Auto-start installed via LaunchAgent."
# STEP 1: Sync repo
cd "$ROOT"
git pull origin healer-core || true
# STEP 2: Launch Healing AI (only if not already running)
if pgrep -f "sub_brains/healing_ai/launch.sh" > /dev/null; then
echo "⚠️ [AI Brain] Healing AI already running, skipping duplicate." | tee -a "$LOGS/healing_ai.log"
else
echo "🚀 [AI Brain] Launching Healing AI..." | tee -a "$LOGS/healing_ai.log"
nohup bash "$ROOT/sub_brains/healing_ai/launch.sh" >> "$LOGS/healing_ai.log" 2>&1 &
fi
# STEP 3: Auto log pusher (hourly)
(
while true; do
cd "$ROOT"
TIMESTAMP=$(date +"%Y-%m-%d %H:%M:%S")
echo "📤 [AI Brain] Pushing logs at $TIMESTAMP" | tee -a "$LOGS/git_push.log"
git add -A
git commit -m "📝 Auto-push logs from $HOSTNAME at $TIMESTAMP" || true
git pull --rebase origin healer-core || true
git push origin healer-core || echo "⚠️ [AI Brain] Git push failed, will retry..."
sleep 3600 # wait 1 hour
done
) &