Add Android APK fleet nodes with Crucible UI integration and tests.

APK wrapper registers platform=android via AETHERFORGE_PLATFORM; fleet UI shows robot icons, Android Access Depth probes, and a shortened mining onion timeline.
This commit is contained in:
AetherForge
2026-06-07 02:44:29 -07:00
parent d9f36f182c
commit 50ebfe53cb
89 changed files with 2849 additions and 82 deletions

88
android/build-apk.ps1 Normal file
View File

@@ -0,0 +1,88 @@
# AetherForge Android Agent APK — compile embedded agent + assembleDebug
param(
[string]$ServerUrl = $(if ($env:AETHERFORGE_SERVER_URL) { $env:AETHERFORGE_SERVER_URL } else { "http://127.0.0.1:8989" }),
[string]$WorkerName = $(if ($env:AETHERFORGE_WORKER_NAME) { $env:AETHERFORGE_WORKER_NAME } else { "android-fleet-node" }),
[string]$FleetSecret = $env:AETHERFORGE_FLEET_SECRET,
[string]$BuildId = "android-$(Get-Date -Format 'yyyyMMdd-HHmmss')"
)
$ErrorActionPreference = "Stop"
$Root = Split-Path -Parent $MyInvocation.MyCommand.Path
$RepoRoot = Split-Path -Parent $Root
$AgentDir = Join-Path $RepoRoot "agent"
$AppDir = Join-Path $Root "agent-app"
$AssetsDir = Join-Path $AppDir "src\main\assets"
$AgentAsset = Join-Path $AssetsDir "agent"
$ConfigAsset = Join-Path $AssetsDir "config.json"
$BuiltinPath = Join-Path $AgentDir "config\builtin.go"
$BuiltinBackup = Join-Path $AgentDir "config\builtin.go.android-bak"
$ApkOut = Join-Path $AppDir "build\outputs\apk\debug\aetherforge-agent.apk"
function Restore-Builtin {
if (Test-Path $BuiltinBackup) {
Move-Item -Force $BuiltinBackup $BuiltinPath
}
}
try {
if (-not (Get-Command go -ErrorAction SilentlyContinue)) {
throw "go compiler not found in PATH"
}
Write-Host "==> Baking config (server=$ServerUrl worker=$WorkerName)" -ForegroundColor Cyan
Push-Location (Join-Path $Root "forge")
$bakeArgs = @(
"run", "./cmd/bake",
"-server", $ServerUrl,
"-worker", $WorkerName,
"-build-id", $BuildId,
"-config-out", $ConfigAsset,
"-builtin-out", $BuiltinPath
)
if ($FleetSecret) { $bakeArgs += @("-fleet-secret", $FleetSecret) }
& go @bakeArgs
if ($LASTEXITCODE -ne 0) { throw "bake failed" }
Pop-Location
if (Test-Path $BuiltinPath) {
Copy-Item -Force $BuiltinPath $BuiltinBackup
}
Write-Host "==> Compiling linux/arm64 agent binary" -ForegroundColor Cyan
$env:GOOS = "linux"
$env:GOARCH = "arm64"
$env:CGO_ENABLED = "0"
Push-Location $AgentDir
& go build -trimpath -ldflags "-s -w" -o $AgentAsset .
if ($LASTEXITCODE -ne 0) { throw "go build failed" }
Pop-Location
$size = (Get-Item $AgentAsset).Length
Write-Host " agent binary: $size bytes -> $AgentAsset"
if (-not $env:ANDROID_HOME -and $env:ANDROID_SDK_ROOT) {
$env:ANDROID_HOME = $env:ANDROID_SDK_ROOT
}
if (-not $env:ANDROID_HOME) {
throw "ANDROID_HOME (or ANDROID_SDK_ROOT) is required for Gradle assembleDebug"
}
$gradlew = Join-Path $AppDir "gradlew.bat"
if (-not (Test-Path $gradlew)) {
throw "Gradle wrapper missing. Run: cd android/agent-app && gradle wrapper"
}
Write-Host "==> Gradle assembleDebug" -ForegroundColor Cyan
Push-Location $AppDir
& $gradlew assembleDebug --no-daemon
if ($LASTEXITCODE -ne 0) { throw "gradle assembleDebug failed" }
Pop-Location
if (-not (Test-Path $ApkOut)) {
throw "APK not found at $ApkOut"
}
Write-Host "==> APK ready: $ApkOut" -ForegroundColor Green
}
finally {
Restore-Builtin
}