Add social feed, cooperative parties, guild goals, and operations recovery

This commit is contained in:
Codex
2026-09-22 17:43:07 -04:00
parent 5bee808492
commit 46935c791e
17 changed files with 477 additions and 12 deletions
+42
View File
@@ -0,0 +1,42 @@
#!/usr/bin/env python3
"""Install current-user runtime recovery and telemetry. Enable lingering for boot startup."""
from pathlib import Path
import shutil,subprocess
repo=Path(__file__).resolve().parents[2]
units=Path.home()/'.config/systemd/user';units.mkdir(parents=True,exist_ok=True)
node=shutil.which('node');python=shutil.which('python3');assert node and python
(units/'azerothai-runtime.service').write_text(f'''[Unit]
Description=AzerothAI web runtime
After=network-online.target
[Service]
WorkingDirectory={repo}
ExecStart={node} {repo}/scripts/start-local-runtime.mjs --lan
Restart=always
RestartSec=5
StandardOutput=journal
StandardError=journal
[Install]
WantedBy=default.target
''')
(units/'azerothai-operations.service').write_text(f'''[Unit]
Description=AzerothAI telemetry and transport retention
After=azerothai-runtime.service
[Service]
Type=oneshot
WorkingDirectory={repo}
ExecStart=/usr/bin/sg docker -c "{python} {repo}/scripts/operations-agent.py"
TimeoutStartSec=50
''')
(units/'azerothai-operations.timer').write_text('''[Unit]
Description=AzerothAI one-minute health sampling
[Timer]
OnBootSec=90
OnUnitActiveSec=60
[Install]
WantedBy=timers.target
''')
subprocess.run(['systemctl','--user','daemon-reload'],check=True)
# Runtime is enabled but started separately after handing over its existing process.
subprocess.run(['systemctl','--user','enable','azerothai-runtime.service','azerothai-operations.timer'],check=True)
subprocess.run(['systemctl','--user','start','azerothai-operations.timer'],check=True)
print('User services installed. Start the runtime after stopping its previous unmanaged process.')
+32
View File
@@ -0,0 +1,32 @@
# Run as Richard at logon; no administrator password or API tokens are stored here.
$ErrorActionPreference = 'Continue'
$mutex = New-Object System.Threading.Mutex($false, 'Local\AzerothAIRecovery')
if (-not $mutex.WaitOne(0)) { exit }
$ssh = 'C:\Users\richard\Tools\MinGit\usr\bin\ssh.exe'
$key = 'C:\Users\richard\.ssh\id_ed25519_azerothai'
$ollama = 'C:\Users\richard\Tools\Ollama\ollama.exe'
$logRoot = 'C:\Users\richard\Tools\AzerothAI'
New-Item -ItemType Directory -Force $logRoot | Out-Null
while ($true) {
try {
try { Invoke-RestMethod http://127.0.0.1:11434/api/tags -TimeoutSec 3 | Out-Null }
catch {
if (-not (Get-Process ollama -ErrorAction SilentlyContinue)) {
Start-Process $ollama -ArgumentList 'serve' -WindowStyle Hidden
}
}
$tunnel = Get-CimInstance Win32_Process -Filter "Name='ssh.exe'" | Where-Object { $_.CommandLine -like '*127.0.0.1:11434:127.0.0.1:11434*' }
if (-not $tunnel) {
Start-Process $ssh -ArgumentList @('-N','-o','BatchMode=yes','-o','StrictHostKeyChecking=yes','-o','ExitOnForwardFailure=yes','-o','ServerAliveInterval=15','-o','ServerAliveCountMax=3','-i',$key,'-R','127.0.0.1:11434:127.0.0.1:11434','endami@192.168.62.129') -WindowStyle Hidden
}
$os = Get-CimInstance Win32_OperatingSystem
$cpu = (Get-CimInstance Win32_Processor | Measure-Object LoadPercentage -Average).Average
$disk = Get-CimInstance Win32_LogicalDisk -Filter "DeviceID='C:'"
$sample = @{host='windows';at=[DateTimeOffset]::UtcNow.ToUnixTimeSeconds();cpuPercent=[double]$cpu;memoryTotalMB=$os.TotalVisibleMemorySize/1024;memoryAvailableMB=$os.FreePhysicalMemory/1024;diskFreeGB=$disk.FreeSpace/1GB;maintenance='Model and SSH tunnel recovery active at Windows logon'} | ConvertTo-Json -Compress
$encoded = [Convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes($sample))
& $ssh -o BatchMode=yes -o ConnectTimeout=8 -o StrictHostKeyChecking=yes -i $key endami@192.168.62.129 "python3 /home/endami/AzerothAI/scripts/operations-agent.py --windows $encoded" 2>&1 | Out-File -Append "$logRoot\recovery.log"
} catch { $_.Exception.Message | Out-File -Append "$logRoot\recovery.log" }
$log = Get-Item "$logRoot\recovery.log" -ErrorAction SilentlyContinue
if ($log -and $log.Length -gt 1MB) { Move-Item -Force $log.FullName "$logRoot\recovery.previous.log" }
Start-Sleep -Seconds 60
}