@elizaos/app-core 2.0.0-beta.3 → 2.0.3-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/agent-bridge.d.ts +27 -0
- package/agent-bridge.d.ts.map +1 -0
- package/agent-bridge.js +26 -0
- package/api/__tests__/sandbox-test-helpers.js +1 -1
- package/api/auth/audit.d.ts +1 -1
- package/api/auth/audit.js +1 -1
- package/api/auth/auth-context.d.ts +1 -1
- package/api/auth/auth-context.js +1 -1
- package/api/auth/bootstrap-token.d.ts +1 -1
- package/api/auth/bootstrap-token.js +2 -2
- package/api/auth/index.d.ts +9 -10
- package/api/auth/index.d.ts.map +1 -1
- package/api/auth/index.js +9 -10
- package/api/auth/passwords.js +2 -2
- package/api/auth/sensitive-rate-limit.d.ts +1 -4
- package/api/auth/sensitive-rate-limit.d.ts.map +1 -1
- package/api/auth/sensitive-rate-limit.js +6 -6
- package/api/auth/sessions.d.ts +1 -1
- package/api/auth/sessions.js +2 -2
- package/api/auth-bootstrap-routes.d.ts +7 -14
- package/api/auth-bootstrap-routes.d.ts.map +1 -1
- package/api/auth-bootstrap-routes.js +14 -27
- package/api/auth-pairing-routes.d.ts +17 -0
- package/api/auth-pairing-routes.d.ts.map +1 -0
- package/api/auth-pairing-routes.js +299 -0
- package/api/auth-session-routes.d.ts +2 -2
- package/api/auth-session-routes.d.ts.map +1 -1
- package/api/auth-session-routes.js +36 -15
- package/api/auth.d.ts +13 -20
- package/api/auth.d.ts.map +1 -1
- package/api/auth.js +32 -27
- package/api/automations-compat-routes.d.ts +1 -1
- package/api/automations-compat-routes.d.ts.map +1 -1
- package/api/automations-compat-routes.js +5 -5
- package/api/background-tasks-routes.d.ts +4 -0
- package/api/background-tasks-routes.d.ts.map +1 -0
- package/api/background-tasks-routes.js +63 -0
- package/api/catalog-routes.d.ts +1 -1
- package/api/catalog-routes.js +3 -3
- package/api/cloud-pair-route.d.ts +26 -0
- package/api/cloud-pair-route.d.ts.map +1 -0
- package/api/cloud-pair-route.js +222 -0
- package/api/cloud-voice-routes.d.ts +52 -0
- package/api/cloud-voice-routes.d.ts.map +1 -0
- package/api/cloud-voice-routes.js +50 -0
- package/api/compat-route-shared.d.ts +14 -7
- package/api/compat-route-shared.d.ts.map +1 -1
- package/api/compat-route-shared.js +27 -188
- package/api/credential-resolver.d.ts +2 -2
- package/api/credential-resolver.d.ts.map +1 -1
- package/api/credential-resolver.js +8 -2
- package/api/database-rows-compat-routes.d.ts +1 -1
- package/api/database-rows-compat-routes.d.ts.map +1 -1
- package/api/database-rows-compat-routes.js +69 -31
- package/api/dev-boot-history.d.ts +26 -0
- package/api/dev-boot-history.d.ts.map +1 -0
- package/api/dev-boot-history.js +69 -0
- package/api/dev-compat-routes.d.ts +6 -1
- package/api/dev-compat-routes.d.ts.map +1 -1
- package/api/dev-compat-routes.js +127 -4
- package/api/dev-console-log.d.ts +2 -2
- package/api/dev-console-log.d.ts.map +1 -1
- package/api/dev-console-log.js +8 -5
- package/api/dev-route-catalog.d.ts +58 -0
- package/api/dev-route-catalog.d.ts.map +1 -0
- package/api/dev-route-catalog.js +477 -0
- package/api/dev-stack.d.ts.map +1 -1
- package/api/dev-stack.js +6 -9
- package/api/drop-status-compat-route.d.ts +3 -0
- package/api/drop-status-compat-route.d.ts.map +1 -0
- package/api/drop-status-compat-route.js +12 -0
- package/api/first-run-routes.d.ts +4 -0
- package/api/first-run-routes.d.ts.map +1 -0
- package/api/first-run-routes.js +208 -0
- package/api/first-run-tts-route.d.ts +19 -0
- package/api/first-run-tts-route.d.ts.map +1 -0
- package/api/first-run-tts-route.js +59 -0
- package/api/internal-routes.d.ts +23 -0
- package/api/internal-routes.d.ts.map +1 -0
- package/api/internal-routes.js +203 -0
- package/api/ios-local-agent-transport.d.ts +36 -0
- package/api/ios-local-agent-transport.d.ts.map +1 -0
- package/api/ios-local-agent-transport.js +566 -0
- package/api/onboarding-voice-lines.d.ts +23 -0
- package/api/onboarding-voice-lines.d.ts.map +1 -0
- package/api/onboarding-voice-lines.js +8 -0
- package/api/perf-instrument.d.ts +43 -0
- package/api/perf-instrument.d.ts.map +1 -0
- package/api/perf-instrument.js +113 -0
- package/api/response.d.ts.map +1 -1
- package/api/response.js +14 -14
- package/api/runtime-mode-routes.d.ts +1 -1
- package/api/runtime-mode-routes.d.ts.map +1 -1
- package/api/runtime-mode-routes.js +2 -2
- package/api/secrets-inventory-routes.js +2 -2
- package/api/secrets-manager-routes.d.ts +1 -1
- package/api/secrets-manager-routes.d.ts.map +1 -1
- package/api/secrets-manager-routes.js +9 -10
- package/api/sensitive-request-routes.d.ts +2 -2
- package/api/sensitive-request-routes.js +5 -5
- package/api/server-config-filter.d.ts.map +1 -1
- package/api/server-config-filter.js +0 -1
- package/api/server-cors.d.ts.map +1 -1
- package/api/server-cors.js +13 -2
- package/api/server-first-run-helpers.d.ts +26 -0
- package/api/server-first-run-helpers.d.ts.map +1 -0
- package/api/server-first-run-helpers.js +268 -0
- package/api/server-security.js +1 -1
- package/api/server-startup.d.ts.map +1 -1
- package/api/server-startup.js +3 -4
- package/api/server-wallet-trade.js +1 -1
- package/api/server.d.ts +11 -11
- package/api/server.d.ts.map +1 -1
- package/api/server.js +227 -139
- package/api/setup-contract.d.ts +63 -0
- package/api/setup-contract.d.ts.map +1 -0
- package/api/setup-contract.js +39 -0
- package/api/training-benchmarks.d.ts +97 -0
- package/api/training-benchmarks.d.ts.map +1 -0
- package/api/training-benchmarks.js +329 -0
- package/api/workbench-compat-routes.d.ts +1 -1
- package/api/workbench-compat-routes.js +2 -2
- package/benchmark/cerebras-autowire.d.ts +28 -0
- package/benchmark/cerebras-autowire.d.ts.map +1 -0
- package/benchmark/cerebras-autowire.js +62 -0
- package/benchmark/lifeops-bench-handler.d.ts +36 -0
- package/benchmark/lifeops-bench-handler.d.ts.map +1 -1
- package/benchmark/lifeops-bench-handler.js +63 -1
- package/benchmark/lifeops-fake-backend.d.ts +39 -0
- package/benchmark/lifeops-fake-backend.d.ts.map +1 -1
- package/benchmark/lifeops-fake-backend.js +993 -21
- package/benchmark/mock-plugin.d.ts.map +1 -1
- package/benchmark/mock-plugin.js +0 -24
- package/benchmark/plugin.d.ts +2 -1
- package/benchmark/plugin.d.ts.map +1 -1
- package/benchmark/plugin.js +989 -68
- package/benchmark/replay-capture.d.ts +2 -2
- package/benchmark/replay-capture.d.ts.map +1 -1
- package/benchmark/replay-capture.js +3 -3
- package/benchmark/server-utils.d.ts +164 -11
- package/benchmark/server-utils.d.ts.map +1 -1
- package/benchmark/server-utils.js +625 -62
- package/benchmark/server.d.ts.map +1 -1
- package/benchmark/server.js +1962 -118
- package/boot-profile.d.ts +3 -0
- package/boot-profile.d.ts.map +1 -0
- package/boot-profile.js +30 -0
- package/browser.d.ts +23 -1
- package/browser.d.ts.map +1 -1
- package/browser.js +20 -1
- package/cli/argv.js +1 -1
- package/cli/banner.js +1 -1
- package/cli/command-format.js +2 -2
- package/cli/doctor/checks.d.ts.map +1 -1
- package/cli/doctor/checks.js +6 -6
- package/cli/plugins-cli.d.ts.map +1 -1
- package/cli/plugins-cli.js +82 -32
- package/cli/profile.d.ts.map +1 -1
- package/cli/profile.js +5 -4
- package/cli/program/build-program.js +4 -4
- package/cli/program/command-registry.d.ts.map +1 -1
- package/cli/program/command-registry.js +13 -11
- package/cli/program/help.js +5 -5
- package/cli/program/preaction.js +5 -5
- package/cli/program/register.auth.d.ts +27 -1
- package/cli/program/register.auth.d.ts.map +1 -1
- package/cli/program/register.auth.js +193 -12
- package/cli/program/register.capability-router.d.ts +29 -0
- package/cli/program/register.capability-router.d.ts.map +1 -0
- package/cli/program/register.capability-router.js +568 -0
- package/cli/program/register.config.js +1 -1
- package/cli/program/register.configure.d.ts.map +1 -1
- package/cli/program/register.configure.js +1 -1
- package/cli/program/register.dashboard.d.ts.map +1 -1
- package/cli/program/register.dashboard.js +17 -8
- package/cli/program/register.db.d.ts.map +1 -1
- package/cli/program/register.db.js +3 -4
- package/cli/program/register.doctor.js +7 -7
- package/cli/program/register.setup.d.ts.map +1 -1
- package/cli/program/register.setup.js +14 -10
- package/cli/program/register.start.d.ts.map +1 -1
- package/cli/program/register.start.js +5 -3
- package/cli/program/register.subclis.js +3 -3
- package/cli/program/register.update.d.ts +6 -0
- package/cli/program/register.update.d.ts.map +1 -1
- package/cli/program/register.update.js +58 -6
- package/cli/program.d.ts +1 -1
- package/cli/program.js +1 -1
- package/cli/run-main.js +4 -4
- package/config/app-config.d.ts +2 -0
- package/config/app-config.d.ts.map +1 -0
- package/config/app-config.js +1 -0
- package/connectors/capacitor-jsc.d.ts.map +1 -1
- package/connectors/capacitor-jsc.js +16 -10
- package/connectors/capacitor-quickjs.d.ts.map +1 -1
- package/connectors/capacitor-quickjs.js +18 -13
- package/connectors/capacitor-sqlite.d.ts.map +1 -1
- package/connectors/capacitor-sqlite.js +27 -12
- package/dispatch/approval-queue.d.ts +37 -0
- package/dispatch/approval-queue.d.ts.map +1 -0
- package/dispatch/approval-queue.js +25 -0
- package/dispatch/channel-registry.d.ts +30 -0
- package/dispatch/channel-registry.d.ts.map +1 -0
- package/dispatch/channel-registry.js +22 -0
- package/dispatch/connector-registry.d.ts +39 -0
- package/dispatch/connector-registry.d.ts.map +1 -0
- package/dispatch/connector-registry.js +24 -0
- package/dispatch/index.d.ts +14 -0
- package/dispatch/index.d.ts.map +1 -0
- package/dispatch/index.js +13 -0
- package/dispatch/send-policy.d.ts +36 -0
- package/dispatch/send-policy.d.ts.map +1 -0
- package/dispatch/send-policy.js +16 -0
- package/entry.js +28 -11
- package/first-run/first-run-config.d.ts +55 -0
- package/first-run/first-run-config.d.ts.map +1 -0
- package/first-run/first-run-config.js +178 -0
- package/first-run/runtime-target.d.ts +4 -0
- package/first-run/runtime-target.d.ts.map +1 -0
- package/first-run/runtime-target.js +13 -0
- package/index.d.ts +46 -34
- package/index.d.ts.map +1 -1
- package/index.js +53 -33
- package/package.json +166 -51
- package/packaging/PUBLISHING_GUIDE.md +20 -20
- package/packaging/debian/apt-repo-config/README.md +18 -0
- package/packaging/debian/apt-repo-config/conf/distributions +11 -0
- package/packaging/flatpak/README.md +26 -16
- package/packaging/flatpak/ai.elizaos.App.metainfo.xml +17 -12
- package/packaging/flatpak/ai.elizaos.App.store.yml +5 -5
- package/packaging/flatpak/ai.elizaos.App.yml +10 -24
- package/packaging/flatpak/elizaos-app-wrapper.store.sh +2 -2
- package/packaging/flatpak/generate-sources.sh +74 -0
- package/packaging/flatpak/node-sources.json +7930 -0
- package/packaging/inno/build-inno.ps1 +34 -9
- package/packaging/msix/AppxManifest.store.xml +1 -1
- package/packaging/msix/README.md +39 -19
- package/packaging/msix/build-msix.ps1 +44 -14
- package/packaging/snap/snapcraft.yaml +22 -21
- package/packaging/test-packaging.sh +2 -2
- package/permissions/types.d.ts +1 -1
- package/permissions/types.js +1 -1
- package/platform/elizaos-agent-browser-stub.d.ts +143 -0
- package/platform/elizaos-agent-browser-stub.d.ts.map +1 -0
- package/platform/elizaos-agent-browser-stub.js +157 -0
- package/platform/elizaos-plugin-elizacloud-browser-stub.d.ts +34 -0
- package/platform/elizaos-plugin-elizacloud-browser-stub.d.ts.map +1 -0
- package/platform/elizaos-plugin-elizacloud-browser-stub.js +51 -0
- package/platform/empty-node-module.d.ts +148 -0
- package/platform/empty-node-module.d.ts.map +1 -1
- package/platform/empty-node-module.js +140 -3
- package/platform/ios-runtime-backends.d.ts +83 -0
- package/platform/ios-runtime-backends.d.ts.map +1 -0
- package/platform/ios-runtime-backends.js +133 -0
- package/platform/ios-runtime-bridge.d.ts +15 -0
- package/platform/ios-runtime-bridge.d.ts.map +1 -0
- package/platform/ios-runtime-bridge.js +526 -0
- package/platform/native-library-policy.d.ts +23 -0
- package/platform/native-library-policy.d.ts.map +1 -0
- package/platform/native-library-policy.js +112 -0
- package/platform/native-plugin-entrypoints.d.ts +19 -0
- package/platform/native-plugin-entrypoints.d.ts.map +1 -0
- package/platform/native-plugin-entrypoints.js +29 -0
- package/platforms/android/README.md +68 -10
- package/platforms/android/app/build.gradle +291 -3
- package/platforms/android/app/capacitor.build.gradle +18 -1
- package/platforms/android/app/proguard-rules.pro +17 -2
- package/platforms/android/app/src/androidTest/java/ai/elizaos/app/ElizaOsInstrumentedTest.java +1 -1
- package/platforms/android/app/src/main/AndroidManifest.xml +335 -18
- package/platforms/android/app/src/main/assets/runners/eliza-tasks.js +177 -0
- package/platforms/android/app/src/main/elizavoice-jni/CMakeLists.txt +100 -0
- package/platforms/android/app/src/main/elizavoice-jni/elizavoice-jni.cpp +1629 -0
- package/platforms/android/app/src/main/java/ai/elizaos/app/AgentPlugin.java +111 -171
- package/platforms/android/app/src/main/java/ai/elizaos/app/AndroidVirtualizationBridge.java +284 -0
- package/platforms/android/app/src/main/java/ai/elizaos/app/BatteryOptimizationPlugin.java +95 -0
- package/platforms/android/app/src/main/java/ai/elizaos/app/ElizaAccessibilityService.java +55 -0
- package/platforms/android/app/src/main/java/ai/elizaos/app/ElizaAgentService.java +1283 -141
- package/platforms/android/app/src/main/java/ai/elizaos/app/ElizaAndroidSystemBridge.java +83 -0
- package/platforms/android/app/src/main/java/ai/elizaos/app/ElizaAssistActivity.java +50 -1
- package/platforms/android/app/src/main/java/ai/elizaos/app/ElizaBionicInferenceServer.java +740 -0
- package/platforms/android/app/src/main/java/ai/elizaos/app/ElizaBootReceiver.java +90 -8
- package/platforms/android/app/src/main/java/ai/elizaos/app/ElizaBrowserActivity.java +2 -2
- package/platforms/android/app/src/main/java/ai/elizaos/app/ElizaCalendarActivity.java +1 -1
- package/platforms/android/app/src/main/java/ai/elizaos/app/ElizaCameraActivity.java +1 -1
- package/platforms/android/app/src/main/java/ai/elizaos/app/ElizaClockActivity.java +2 -2
- package/platforms/android/app/src/main/java/ai/elizaos/app/ElizaContactsActivity.java +1 -1
- package/platforms/android/app/src/main/java/ai/elizaos/app/ElizaDialActivity.java +1 -1
- package/platforms/android/app/src/main/java/ai/elizaos/app/ElizaInCallService.java +1 -1
- package/platforms/android/app/src/main/java/ai/elizaos/app/ElizaMmsReceiver.java +1 -1
- package/platforms/android/app/src/main/java/ai/elizaos/app/ElizaNativeBridge.java +22 -0
- package/platforms/android/app/src/main/java/ai/elizaos/app/ElizaNotificationListenerService.java +45 -0
- package/platforms/android/app/src/main/java/ai/elizaos/app/ElizaQuickActionsWidgetProvider.java +68 -0
- package/platforms/android/app/src/main/java/ai/elizaos/app/ElizaShareActivity.java +132 -0
- package/platforms/android/app/src/main/java/ai/elizaos/app/ElizaSmsComposeActivity.java +1 -1
- package/platforms/android/app/src/main/java/ai/elizaos/app/ElizaSmsGatewayService.java +268 -0
- package/platforms/android/app/src/main/java/ai/elizaos/app/ElizaSmsReceiver.java +12 -1
- package/platforms/android/app/src/main/java/ai/elizaos/app/ElizaTasksWorker.java +194 -0
- package/platforms/android/app/src/main/java/ai/elizaos/app/ElizaVoiceCaptureService.java +198 -0
- package/platforms/android/app/src/main/java/ai/elizaos/app/ElizaVoiceNative.java +255 -0
- package/platforms/android/app/src/main/java/ai/elizaos/app/ElizaVoicePlugin.java +505 -0
- package/platforms/android/app/src/main/java/ai/elizaos/app/ElizaVoiceTileService.java +39 -0
- package/platforms/android/app/src/main/java/ai/elizaos/app/ElizaWorkScheduler.java +60 -0
- package/platforms/android/app/src/main/java/ai/elizaos/app/GatewayConnectionService.java +53 -19
- package/platforms/android/app/src/main/java/ai/elizaos/app/MainActivity.java +160 -33
- package/platforms/android/app/src/main/java/ai/elizaos/app/ResourceProbePlugin.java +169 -0
- package/platforms/android/app/src/main/java/ai/elizaos/app/VoiceCapturePlugin.java +119 -0
- package/platforms/android/app/src/main/res/drawable/eliza_widget_background.xml +10 -0
- package/platforms/android/app/src/main/res/drawable/eliza_widget_button_background.xml +13 -0
- package/platforms/android/app/src/main/res/drawable/splash.png +0 -0
- package/platforms/android/app/src/main/res/drawable-land-hdpi/splash.png +0 -0
- package/platforms/android/app/src/main/res/drawable-land-mdpi/splash.png +0 -0
- package/platforms/android/app/src/main/res/drawable-land-xhdpi/splash.png +0 -0
- package/platforms/android/app/src/main/res/drawable-land-xxhdpi/splash.png +0 -0
- package/platforms/android/app/src/main/res/drawable-land-xxxhdpi/splash.png +0 -0
- package/platforms/android/app/src/main/res/drawable-port-hdpi/splash.png +0 -0
- package/platforms/android/app/src/main/res/drawable-port-mdpi/splash.png +0 -0
- package/platforms/android/app/src/main/res/drawable-port-xhdpi/splash.png +0 -0
- package/platforms/android/app/src/main/res/drawable-port-xxhdpi/splash.png +0 -0
- package/platforms/android/app/src/main/res/drawable-port-xxxhdpi/splash.png +0 -0
- package/platforms/android/app/src/main/res/layout/eliza_quick_actions_widget.xml +86 -0
- package/platforms/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml +2 -1
- package/platforms/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml +2 -1
- package/platforms/android/app/src/main/res/mipmap-hdpi/ic_launcher.png +0 -0
- package/platforms/android/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png +0 -0
- package/platforms/android/app/src/main/res/mipmap-hdpi/ic_launcher_monochrome.png +0 -0
- package/platforms/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png +0 -0
- package/platforms/android/app/src/main/res/mipmap-mdpi/ic_launcher.png +0 -0
- package/platforms/android/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png +0 -0
- package/platforms/android/app/src/main/res/mipmap-mdpi/ic_launcher_monochrome.png +0 -0
- package/platforms/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png +0 -0
- package/platforms/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png +0 -0
- package/platforms/android/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png +0 -0
- package/platforms/android/app/src/main/res/mipmap-xhdpi/ic_launcher_monochrome.png +0 -0
- package/platforms/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png +0 -0
- package/platforms/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png +0 -0
- package/platforms/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png +0 -0
- package/platforms/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_monochrome.png +0 -0
- package/platforms/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png +0 -0
- package/platforms/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png +0 -0
- package/platforms/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png +0 -0
- package/platforms/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_monochrome.png +0 -0
- package/platforms/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png +0 -0
- package/platforms/android/app/src/main/res/values/android_app_actions.xml +48 -0
- package/platforms/android/app/src/main/res/values/colors.xml +12 -0
- package/platforms/android/app/src/main/res/values/ic_launcher_background.xml +2 -2
- package/platforms/android/app/src/main/res/values/strings.xml +2 -2
- package/platforms/android/app/src/main/res/values/styles.xml +28 -1
- package/platforms/android/app/src/main/res/xml/eliza_accessibility_service.xml +9 -0
- package/platforms/android/app/src/main/res/xml/eliza_quick_actions_widget.xml +13 -0
- package/platforms/android/app/src/main/res/xml/shortcuts.xml +121 -0
- package/platforms/android/build.gradle +2 -2
- package/platforms/android/capacitor-cordova-android-plugins/build.gradle +9 -3
- package/platforms/android/capacitor-cordova-android-plugins/cordova.variables.gradle +6 -2
- package/platforms/android/capacitor-cordova-android-plugins/src/main/AndroidManifest.xml +7 -2
- package/platforms/android/capacitor-cordova-android-plugins/src/main/java/.gitkeep +0 -1
- package/platforms/android/capacitor.settings.gradle +66 -16
- package/platforms/android/gradle.properties +1 -0
- package/platforms/android/update-manifest/generate-manifest.mjs +97 -0
- package/platforms/android/update-manifest/schema.json +26 -0
- package/platforms/apple-store-entitlements.reviewed.json +155 -0
- package/platforms/electrobun/.generated/brand-config.json +3 -2
- package/platforms/electrobun/LICENSE +21 -0
- package/platforms/electrobun/README.md +15 -1
- package/platforms/electrobun/assets/appIcon.icns +0 -0
- package/platforms/electrobun/assets/appIcon.ico +0 -0
- package/platforms/electrobun/assets/appIcon.iconset/icon_128x128.png +0 -0
- package/platforms/electrobun/assets/appIcon.iconset/icon_128x128@2x.png +0 -0
- package/platforms/electrobun/assets/appIcon.iconset/icon_16x16.png +0 -0
- package/platforms/electrobun/assets/appIcon.iconset/icon_16x16@2x.png +0 -0
- package/platforms/electrobun/assets/appIcon.iconset/icon_256x256.png +0 -0
- package/platforms/electrobun/assets/appIcon.iconset/icon_256x256@2x.png +0 -0
- package/platforms/electrobun/assets/appIcon.iconset/icon_32x32.png +0 -0
- package/platforms/electrobun/assets/appIcon.iconset/icon_32x32@2x.png +0 -0
- package/platforms/electrobun/assets/appIcon.iconset/icon_512x512.png +0 -0
- package/platforms/electrobun/assets/brand-config.json +6 -6
- package/platforms/electrobun/biome.json +9 -9
- package/platforms/electrobun/docs/capability-collapse-matrix.json +318 -0
- package/platforms/electrobun/docs/capability-collapse-matrix.md +129 -0
- package/platforms/electrobun/docs/capability-routing.md +86 -0
- package/platforms/electrobun/docs/database-boot-policy.md +90 -0
- package/platforms/electrobun/docs/riscv64-port.md +175 -0
- package/platforms/electrobun/docs/startup-first-run-cleanup.md +18 -0
- package/platforms/electrobun/docs/trace-first-annotations.md +52 -0
- package/platforms/electrobun/docs/ui-boundary-audit.json +580 -0
- package/platforms/electrobun/docs/ui-boundary-audit.md +257 -0
- package/platforms/electrobun/electrobun.config.ts +591 -364
- package/platforms/electrobun/entitlements/JUSTIFICATIONS.md +141 -0
- package/platforms/electrobun/entitlements/README.md +34 -6
- package/platforms/electrobun/entitlements/mas-bun.entitlements +15 -0
- package/platforms/electrobun/entitlements/mas.entitlements +6 -4
- package/platforms/electrobun/native/macos/window-effects.mm +1526 -0
- package/platforms/electrobun/package.json +21 -13
- package/platforms/electrobun/remotes/fs/README.md +70 -0
- package/platforms/electrobun/remotes/fs/electrobun.config.ts +38 -0
- package/platforms/electrobun/remotes/fs/package.json +12 -0
- package/platforms/electrobun/remotes/fs/plugin.json +25 -0
- package/platforms/electrobun/remotes/fs/src/bun/errors.ts +57 -0
- package/platforms/electrobun/remotes/fs/src/bun/file-limits.ts +50 -0
- package/platforms/electrobun/remotes/fs/src/bun/fs-service.ts +389 -0
- package/platforms/electrobun/remotes/fs/src/bun/path-guard.ts +270 -0
- package/platforms/electrobun/remotes/fs/src/bun/protocol.ts +149 -0
- package/platforms/electrobun/remotes/fs/src/bun/worker.ts +174 -0
- package/platforms/electrobun/remotes/fs/src/dev/phase5-smoke.ts +171 -0
- package/platforms/electrobun/remotes/fs/src/web/index.html +8 -0
- package/platforms/electrobun/remotes/git/README.md +75 -0
- package/platforms/electrobun/remotes/git/electrobun.config.ts +44 -0
- package/platforms/electrobun/remotes/git/package.json +12 -0
- package/platforms/electrobun/remotes/git/plugin.json +31 -0
- package/platforms/electrobun/remotes/git/src/bun/errors.ts +69 -0
- package/platforms/electrobun/remotes/git/src/bun/git-command.ts +156 -0
- package/platforms/electrobun/remotes/git/src/bun/git-service.ts +446 -0
- package/platforms/electrobun/remotes/git/src/bun/operation-history.ts +124 -0
- package/platforms/electrobun/remotes/git/src/bun/protocol.ts +252 -0
- package/platforms/electrobun/remotes/git/src/bun/worker.ts +316 -0
- package/platforms/electrobun/remotes/git/src/dev/phase7-smoke.ts +141 -0
- package/platforms/electrobun/remotes/git/src/web/index.html +8 -0
- package/platforms/electrobun/remotes/local-model/README.md +138 -0
- package/platforms/electrobun/remotes/local-model/electrobun.config.ts +46 -0
- package/platforms/electrobun/remotes/local-model/package.json +12 -0
- package/platforms/electrobun/remotes/local-model/plugin.json +33 -0
- package/platforms/electrobun/remotes/local-model/src/bun/download-state.ts +115 -0
- package/platforms/electrobun/remotes/local-model/src/bun/eliza1-catalog.ts +405 -0
- package/platforms/electrobun/remotes/local-model/src/bun/errors.ts +74 -0
- package/platforms/electrobun/remotes/local-model/src/bun/hf-eliza1-client.ts +169 -0
- package/platforms/electrobun/remotes/local-model/src/bun/local-inference-api-client.ts +245 -0
- package/platforms/electrobun/remotes/local-model/src/bun/model-service.ts +490 -0
- package/platforms/electrobun/remotes/local-model/src/bun/protocol.ts +301 -0
- package/platforms/electrobun/remotes/local-model/src/bun/worker.ts +248 -0
- package/platforms/electrobun/remotes/local-model/src/dev/phase8-smoke.ts +116 -0
- package/platforms/electrobun/remotes/local-model/src/web/index.html +13 -0
- package/platforms/electrobun/remotes/pty/README.md +65 -0
- package/platforms/electrobun/remotes/pty/electrobun.config.ts +47 -0
- package/platforms/electrobun/remotes/pty/package.json +12 -0
- package/platforms/electrobun/remotes/pty/plugin.json +34 -0
- package/platforms/electrobun/remotes/pty/src/bun/errors.ts +57 -0
- package/platforms/electrobun/remotes/pty/src/bun/output-buffer.ts +127 -0
- package/platforms/electrobun/remotes/pty/src/bun/protocol.ts +192 -0
- package/platforms/electrobun/remotes/pty/src/bun/pty-service.ts +562 -0
- package/platforms/electrobun/remotes/pty/src/bun/worker.ts +218 -0
- package/platforms/electrobun/remotes/pty/src/dev/phase6-smoke.ts +127 -0
- package/platforms/electrobun/remotes/pty/src/web/index.html +8 -0
- package/platforms/electrobun/remotes/runtime/README.md +370 -0
- package/platforms/electrobun/remotes/runtime/electrobun.config.ts +48 -0
- package/platforms/electrobun/remotes/runtime/package.json +14 -0
- package/platforms/electrobun/remotes/runtime/plugin.json +30 -0
- package/platforms/electrobun/remotes/runtime/src/bun/api-client.ts +620 -0
- package/platforms/electrobun/remotes/runtime/src/bun/errors.ts +45 -0
- package/platforms/electrobun/remotes/runtime/src/bun/log-buffer.ts +33 -0
- package/platforms/electrobun/remotes/runtime/src/bun/protocol.ts +366 -0
- package/platforms/electrobun/remotes/runtime/src/bun/route-discovery.ts +419 -0
- package/platforms/electrobun/remotes/runtime/src/bun/runtime-manager.ts +423 -0
- package/platforms/electrobun/remotes/runtime/src/bun/sse-parser.ts +99 -0
- package/platforms/electrobun/remotes/runtime/src/bun/stream-manager.ts +887 -0
- package/platforms/electrobun/remotes/runtime/src/bun/worker.ts +1231 -0
- package/platforms/electrobun/remotes/runtime/src/dev/phase1-smoke.ts +34 -0
- package/platforms/electrobun/remotes/runtime/src/dev/phase2-smoke.ts +91 -0
- package/platforms/electrobun/remotes/runtime/src/dev/phase3-smoke.ts +137 -0
- package/platforms/electrobun/remotes/runtime/src/web/index.css +187 -0
- package/platforms/electrobun/remotes/runtime/src/web/index.html +76 -0
- package/platforms/electrobun/remotes/runtime/src/web/index.ts +192 -0
- package/platforms/electrobun/remotes/surface/README.md +201 -0
- package/platforms/electrobun/remotes/surface/electrobun.config.ts +38 -0
- package/platforms/electrobun/remotes/surface/package.json +12 -0
- package/platforms/electrobun/remotes/surface/plugin.json +28 -0
- package/platforms/electrobun/remotes/surface/src/bun/worker.ts +132 -0
- package/platforms/electrobun/remotes/surface/src/dev/phase4-smoke.ts +566 -0
- package/platforms/electrobun/remotes/surface/src/protocol/event-types.ts +84 -0
- package/platforms/electrobun/remotes/surface/src/protocol/runtime-client.ts +673 -0
- package/platforms/electrobun/remotes/surface/src/web/app.ts +595 -0
- package/platforms/electrobun/remotes/surface/src/web/index.css +460 -0
- package/platforms/electrobun/remotes/surface/src/web/index.html +466 -0
- package/platforms/electrobun/remotes/surface/src/web/index.ts +5 -0
- package/platforms/electrobun/remotes/surface/src/web/render.ts +455 -0
- package/platforms/electrobun/remotes/surface/src/web/state.ts +427 -0
- package/platforms/electrobun/scripts/build-macos-effects.sh +4 -0
- package/platforms/electrobun/scripts/ensure-build-folder.ts +28 -0
- package/platforms/electrobun/scripts/local-adhoc-sign-macos.ts +159 -159
- package/platforms/electrobun/scripts/postwrap-diagnostics.ts +424 -339
- package/platforms/electrobun/scripts/postwrap-sign-runtime-macos.ts +302 -271
- package/platforms/electrobun/scripts/smoke-test-windows.ps1 +17 -16
- package/platforms/electrobun/scripts/smoke-test.sh +5 -7
- package/platforms/electrobun/scripts/sync-web-assets.mjs +13 -13
- package/platforms/electrobun/scripts/verify-rpc-handlers.ts +109 -110
- package/platforms/electrobun/scripts/verify-windows-installer-proof.ps1 +3 -8
- package/platforms/electrobun/src/__stubs__/bun-ffi.ts +31 -31
- package/platforms/electrobun/src/__stubs__/electrobun-bun.ts +1 -1
- package/platforms/electrobun/src/agent-ready-state.ts +8 -8
- package/platforms/electrobun/src/agent-reset-from-main.test.ts +162 -0
- package/platforms/electrobun/src/agent-reset-from-main.ts +62 -62
- package/platforms/electrobun/src/agent-status-rpc.test.ts +95 -0
- package/platforms/electrobun/src/agent-status-rpc.ts +156 -0
- package/platforms/electrobun/src/api-base.test.ts +247 -0
- package/platforms/electrobun/src/api-base.ts +202 -93
- package/platforms/electrobun/src/application-menu-action-registry.ts +9 -9
- package/platforms/electrobun/src/application-menu.ts +341 -348
- package/platforms/electrobun/src/background-notice.ts +36 -36
- package/platforms/electrobun/src/boot-progress.test.ts +188 -0
- package/platforms/electrobun/src/boot-progress.ts +111 -0
- package/platforms/electrobun/src/brand-config.test.ts +39 -0
- package/platforms/electrobun/src/brand-config.ts +141 -129
- package/platforms/electrobun/src/bridge/browser-tabs-renderer-registry.ts +28 -28
- package/platforms/electrobun/src/bridge/electrobun-boot-config.ts +42 -0
- package/platforms/electrobun/src/bridge/electrobun-crypto-ready.ts +120 -0
- package/platforms/electrobun/src/bridge/electrobun-direct-rpc.ts +342 -357
- package/platforms/electrobun/src/bridge/electrobun-stub.ts +13 -13
- package/platforms/electrobun/src/browser-workspace-bridge-server.ts +285 -243
- package/platforms/electrobun/src/cloud-auth-window.ts +136 -136
- package/platforms/electrobun/src/cloud-disconnect-from-main.ts +90 -90
- package/platforms/electrobun/src/config-and-auth-rpc.test.ts +256 -0
- package/platforms/electrobun/src/config-and-auth-rpc.ts +302 -0
- package/platforms/electrobun/src/conversations-and-character-rpc.test.ts +185 -0
- package/platforms/electrobun/src/conversations-and-character-rpc.ts +131 -0
- package/platforms/electrobun/src/dashboard-rpc.test.ts +200 -0
- package/platforms/electrobun/src/dashboard-rpc.ts +344 -0
- package/platforms/electrobun/src/database/database-lock.ts +141 -0
- package/platforms/electrobun/src/database/database-mode.ts +149 -0
- package/platforms/electrobun/src/database/database-recovery.ts +72 -0
- package/platforms/electrobun/src/database/database-snapshot.ts +190 -0
- package/platforms/electrobun/src/database/database.test.ts +196 -0
- package/platforms/electrobun/src/database/index.ts +5 -0
- package/platforms/electrobun/src/database/pglite-paths.ts +100 -0
- package/platforms/electrobun/src/desktop-deep-link-events.test.ts +30 -0
- package/platforms/electrobun/src/desktop-deep-link-events.ts +17 -0
- package/platforms/electrobun/src/desktop-http-request.test.ts +102 -73
- package/platforms/electrobun/src/desktop-http-request.ts +97 -85
- package/platforms/electrobun/src/desktop-pill-config.test.ts +27 -0
- package/platforms/electrobun/src/desktop-pill-config.ts +40 -0
- package/platforms/electrobun/src/desktop-test-bridge-server.ts +232 -204
- package/platforms/electrobun/src/desktop-tray-config.test.ts +87 -0
- package/platforms/electrobun/src/desktop-tray-config.ts +84 -0
- package/platforms/electrobun/src/devtools-layout.ts +41 -41
- package/platforms/electrobun/src/diagnostic-format.test.ts +71 -0
- package/platforms/electrobun/src/diagnostic-format.ts +75 -36
- package/platforms/electrobun/src/dynamic-view-rpc-schema.test.ts +37 -0
- package/platforms/electrobun/src/dynamic-views/README.md +44 -0
- package/platforms/electrobun/src/dynamic-views/demo/agent-run-trace.html +135 -0
- package/platforms/electrobun/src/dynamic-views/errors.ts +29 -0
- package/platforms/electrobun/src/dynamic-views/host.test.ts +353 -0
- package/platforms/electrobun/src/dynamic-views/host.ts +332 -0
- package/platforms/electrobun/src/dynamic-views/index.ts +57 -0
- package/platforms/electrobun/src/dynamic-views/kiosk-canvas.ts +89 -0
- package/platforms/electrobun/src/dynamic-views/registry.test.ts +139 -0
- package/platforms/electrobun/src/dynamic-views/registry.ts +196 -0
- package/platforms/electrobun/src/dynamic-views/session-manager.test.ts +355 -0
- package/platforms/electrobun/src/dynamic-views/session-manager.ts +348 -0
- package/platforms/electrobun/src/dynamic-views/types.ts +105 -0
- package/platforms/electrobun/src/electrobun-boot-config.test.ts +50 -0
- package/platforms/electrobun/src/electrobun-config.test.ts +62 -0
- package/platforms/electrobun/src/electrobun-crypto-ready.test.ts +65 -0
- package/platforms/electrobun/src/electrobun-window-options.ts +25 -0
- package/platforms/electrobun/src/extension-rpc.test.ts +88 -0
- package/platforms/electrobun/src/extension-rpc.ts +102 -0
- package/platforms/electrobun/src/fatal-shutdown.test.ts +12 -16
- package/platforms/electrobun/src/fatal-shutdown.ts +1 -1
- package/platforms/electrobun/src/first-party-remotes.test.ts +169 -0
- package/platforms/electrobun/src/first-party-remotes.ts +297 -0
- package/platforms/electrobun/src/first-run-rpc.test.ts +192 -0
- package/platforms/electrobun/src/first-run-rpc.ts +146 -0
- package/platforms/electrobun/src/floating-chat-window.ts +181 -181
- package/platforms/electrobun/src/inbox-rpc.test.ts +123 -0
- package/platforms/electrobun/src/inbox-rpc.ts +158 -0
- package/platforms/electrobun/src/index.ts +2608 -2098
- package/platforms/electrobun/src/kiosk-mode.ts +50 -0
- package/platforms/electrobun/src/launch/index.ts +4 -0
- package/platforms/electrobun/src/launch/launch-dynamic-view.ts +37 -0
- package/platforms/electrobun/src/launch/launch-orchestrator.test.ts +224 -0
- package/platforms/electrobun/src/launch/launch-orchestrator.ts +456 -0
- package/platforms/electrobun/src/launch/launch-store.test.ts +97 -0
- package/platforms/electrobun/src/launch/launch-store.ts +134 -0
- package/platforms/electrobun/src/launch/types.ts +103 -0
- package/platforms/electrobun/src/launch/views/launch-diagnostics.html +205 -0
- package/platforms/electrobun/src/lifecycle/agent-ready-publish.test.ts +50 -0
- package/platforms/electrobun/src/lifecycle/agent-ready-publish.ts +27 -0
- package/platforms/electrobun/src/lifecycle/api-base-owner.test.ts +83 -0
- package/platforms/electrobun/src/lifecycle/api-base-owner.ts +63 -31
- package/platforms/electrobun/src/lifecycle/desktop-session-prime.ts +44 -44
- package/platforms/electrobun/src/logger.ts +14 -14
- package/platforms/electrobun/src/main-window-runtime.ts +83 -83
- package/platforms/electrobun/src/main-window-session.test.ts +109 -0
- package/platforms/electrobun/src/main-window-session.ts +87 -51
- package/platforms/electrobun/src/menu-reset-from-main.ts +158 -158
- package/platforms/electrobun/src/native/agent-env.test.ts +52 -0
- package/platforms/electrobun/src/native/agent-runtime-layout.test.ts +42 -0
- package/platforms/electrobun/src/native/agent-state-dir.test.ts +91 -0
- package/platforms/electrobun/src/native/agent.ts +2133 -1682
- package/platforms/electrobun/src/native/auth-bridge.test.ts +67 -0
- package/platforms/electrobun/src/native/auth-bridge.ts +464 -360
- package/platforms/electrobun/src/native/browser-workspace.ts +723 -471
- package/platforms/electrobun/src/native/camera.ts +50 -50
- package/platforms/electrobun/src/native/canvas.ts +444 -445
- package/platforms/electrobun/src/native/credentials.ts +678 -616
- package/platforms/electrobun/src/native/desktop-window.test.ts +416 -0
- package/platforms/electrobun/src/native/desktop.ts +2200 -2156
- package/platforms/electrobun/src/native/editor-bridge.ts +201 -201
- package/platforms/electrobun/src/native/file-watcher.ts +154 -154
- package/platforms/electrobun/src/native/gateway.ts +179 -180
- package/platforms/electrobun/src/native/gpu-window.ts +256 -256
- package/platforms/electrobun/src/native/index.ts +82 -74
- package/platforms/electrobun/src/native/location.test.ts +44 -0
- package/platforms/electrobun/src/native/location.ts +90 -80
- package/platforms/electrobun/src/native/loopback-port.ts +60 -60
- package/platforms/electrobun/src/native/mac-window-effects.ts +166 -104
- package/platforms/electrobun/src/native/music-player.ts +38 -38
- package/platforms/electrobun/src/native/permissions-shared.ts +249 -150
- package/platforms/electrobun/src/native/permissions.ts +301 -208
- package/platforms/electrobun/src/native/power-state.ts +129 -129
- package/platforms/electrobun/src/native/remote-plugin-host.test.ts +1394 -0
- package/platforms/electrobun/src/native/remote-plugin-host.ts +1541 -0
- package/platforms/electrobun/src/native/screencapture.ts +667 -573
- package/platforms/electrobun/src/native/steward.ts +207 -204
- package/platforms/electrobun/src/native/swabble.ts +68 -324
- package/platforms/electrobun/src/native/talkmode.ts +253 -422
- package/platforms/electrobun/src/native/webgpu-browser-support.test.ts +18 -0
- package/platforms/electrobun/src/native/webgpu-browser-support.ts +165 -147
- package/platforms/electrobun/src/native-onboarding.ts +270 -0
- package/platforms/electrobun/src/onboarding-overlay-window.ts +141 -0
- package/platforms/electrobun/src/persisted-deployment.ts +91 -0
- package/platforms/electrobun/src/pill-window.test.ts +91 -0
- package/platforms/electrobun/src/pill-window.ts +99 -0
- package/platforms/electrobun/src/preload-validation.ts +44 -44
- package/platforms/electrobun/src/preload.js +1 -1
- package/platforms/electrobun/src/print-electrobun-dev-settings-banner.ts +120 -120
- package/platforms/electrobun/src/renderer-api-proxy.test.ts +73 -0
- package/platforms/electrobun/src/renderer-api-proxy.ts +86 -0
- package/platforms/electrobun/src/renderer-static.test.ts +53 -0
- package/platforms/electrobun/src/renderer-static.ts +144 -57
- package/platforms/electrobun/src/rpc-handler-slices.ts +121 -0
- package/platforms/electrobun/src/rpc-handlers.test.ts +267 -0
- package/platforms/electrobun/src/rpc-handlers.ts +1306 -913
- package/platforms/electrobun/src/rpc-parse-utils.ts +57 -0
- package/platforms/electrobun/src/rpc-port-resolver.test.ts +45 -0
- package/platforms/electrobun/src/rpc-port-resolver.ts +31 -0
- package/platforms/electrobun/src/rpc-schema.ts +2556 -1619
- package/platforms/electrobun/src/runtime-layout.ts +105 -105
- package/platforms/electrobun/src/runtime-permissions.ts +95 -95
- package/platforms/electrobun/src/runtime-rpc.test.ts +126 -0
- package/platforms/electrobun/src/runtime-rpc.ts +237 -0
- package/platforms/electrobun/src/screenshot-dev-server.ts +87 -87
- package/platforms/electrobun/src/settings-mutations-rpc.test.ts +193 -0
- package/platforms/electrobun/src/settings-mutations-rpc.ts +220 -0
- package/platforms/electrobun/src/startup-trace.ts +274 -270
- package/platforms/electrobun/src/subscription-rpc.test.ts +89 -0
- package/platforms/electrobun/src/subscription-rpc.ts +192 -0
- package/platforms/electrobun/src/surface-windows.test.ts +355 -0
- package/platforms/electrobun/src/surface-windows.ts +410 -410
- package/platforms/electrobun/src/trace/README.md +73 -0
- package/platforms/electrobun/src/trace/errors.ts +21 -0
- package/platforms/electrobun/src/trace/index.ts +40 -0
- package/platforms/electrobun/src/trace/trace-dynamic-view.ts +40 -0
- package/platforms/electrobun/src/trace/trace-host-requests.ts +473 -0
- package/platforms/electrobun/src/trace/trace-service.test.ts +186 -0
- package/platforms/electrobun/src/trace/trace-service.ts +324 -0
- package/platforms/electrobun/src/trace/trace-store.test.ts +141 -0
- package/platforms/electrobun/src/trace/trace-store.ts +551 -0
- package/platforms/electrobun/src/trace/types.ts +250 -0
- package/platforms/electrobun/src/trace/views/agent-run-trace.html +311 -0
- package/platforms/electrobun/src/types/web-speech.d.ts +28 -28
- package/platforms/electrobun/src/types.ts +5 -5
- package/platforms/electrobun/src/update-availability.test.ts +72 -0
- package/platforms/electrobun/src/update-availability.ts +90 -0
- package/platforms/electrobun/src/update-rpc.test.ts +83 -0
- package/platforms/electrobun/src/update-rpc.ts +123 -0
- package/platforms/electrobun/src/voice/README.md +184 -0
- package/platforms/electrobun/src/voice/errors.ts +42 -0
- package/platforms/electrobun/src/voice/index.ts +78 -0
- package/platforms/electrobun/src/voice/types.ts +316 -0
- package/platforms/electrobun/src/voice/voice-host-requests.ts +259 -0
- package/platforms/electrobun/src/voice/voice-latency-budget.test.ts +66 -0
- package/platforms/electrobun/src/voice/voice-latency-budget.ts +243 -0
- package/platforms/electrobun/src/voice/voice-live-validation.test.ts +357 -0
- package/platforms/electrobun/src/voice/voice-live-validation.ts +838 -0
- package/platforms/electrobun/src/voice/voice-pipeline.ts +250 -0
- package/platforms/electrobun/src/voice/voice-playback-adapter.ts +31 -0
- package/platforms/electrobun/src/voice/voice-runtime-adapter.test.ts +213 -0
- package/platforms/electrobun/src/voice/voice-runtime-adapter.ts +687 -0
- package/platforms/electrobun/src/voice/voice-service.test.ts +587 -0
- package/platforms/electrobun/src/voice/voice-service.ts +1067 -0
- package/platforms/electrobun/src/voice/voice-stream-coordinator.test.ts +115 -0
- package/platforms/electrobun/src/voice/voice-stream-coordinator.ts +270 -0
- package/platforms/electrobun/src/voice/voice-trace.ts +97 -0
- package/platforms/electrobun/src/voice/voice-tts-chunker.test.ts +91 -0
- package/platforms/electrobun/src/voice/voice-tts-chunker.ts +194 -0
- package/platforms/electrobun/src/windows-cef-profile.ts +88 -88
- package/platforms/electrobun/tsconfig.json +88 -12
- package/platforms/electrobun/update-channels.json +22 -0
- package/platforms/electrobun/vitest.electrobun.config.ts +72 -42
- package/platforms/ios/App/App/App.entitlements +4 -0
- package/platforms/ios/App/App/AppDelegate.swift +80 -18
- package/platforms/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-ios-marketing-1024.png +0 -0
- package/platforms/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-ipad-20x20@1x.png +0 -0
- package/platforms/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-ipad-20x20@2x.png +0 -0
- package/platforms/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-ipad-29x29@1x.png +0 -0
- package/platforms/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-ipad-29x29@2x.png +0 -0
- package/platforms/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-ipad-40x40@1x.png +0 -0
- package/platforms/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-ipad-40x40@2x.png +0 -0
- package/platforms/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-ipad-76x76@1x.png +0 -0
- package/platforms/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-ipad-76x76@2x.png +0 -0
- package/platforms/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-ipad-83_5x83_5@2x.png +0 -0
- package/platforms/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-iphone-20x20@2x.png +0 -0
- package/platforms/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-iphone-20x20@3x.png +0 -0
- package/platforms/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-iphone-29x29@2x.png +0 -0
- package/platforms/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-iphone-29x29@3x.png +0 -0
- package/platforms/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-iphone-40x40@2x.png +0 -0
- package/platforms/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-iphone-40x40@3x.png +0 -0
- package/platforms/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-iphone-60x60@2x.png +0 -0
- package/platforms/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-iphone-60x60@3x.png +0 -0
- package/platforms/ios/App/App/Base.lproj/LaunchScreen.storyboard +4 -9
- package/platforms/ios/App/App/ComputerUseBridge.swift +589 -0
- package/platforms/ios/App/App/DeviceActivityMonitorExtension/DeviceActivityMonitorExtension.entitlements +12 -0
- package/platforms/ios/App/App/DeviceActivityMonitorExtension/DeviceActivityMonitorExtension.swift +34 -0
- package/platforms/ios/App/App/DeviceActivityMonitorExtension/Info.plist +29 -0
- package/platforms/ios/App/App/DeviceActivityReportExtension/DeviceActivityReportExtension.entitlements +12 -0
- package/platforms/ios/App/App/DeviceActivityReportExtension/DeviceActivityReportExtension.swift +53 -0
- package/platforms/ios/App/App/DeviceActivityReportExtension/Info.plist +27 -0
- package/platforms/ios/App/App/ElizaAppIntents.swift +183 -0
- package/platforms/ios/App/App/ElizaIntentPlugin.swift +342 -5
- package/platforms/ios/App/App/Info.plist +17 -1
- package/platforms/ios/App/App/runners/eliza-tasks.js +177 -0
- package/platforms/ios/App/App.xcodeproj/project.pbxproj +262 -6
- package/platforms/ios/App/BroadcastExtension/SampleHandler.swift +100 -0
- package/platforms/ios/App/Podfile +5 -0
- package/platforms/ios/App/Podfile.lock +83 -59
- package/register-runtime-hooks.js +11 -5
- package/registry/index.d.ts +1 -5
- package/registry/index.d.ts.map +1 -1
- package/registry/index.js +10 -68
- package/runtime/android-avf-microdroid-bridge.d.ts +29 -0
- package/runtime/android-avf-microdroid-bridge.d.ts.map +1 -0
- package/runtime/android-avf-microdroid-bridge.js +149 -0
- package/runtime/api-dev-settings-banner.d.ts.map +1 -1
- package/runtime/api-dev-settings-banner.js +5 -13
- package/runtime/app-core-runtime-hooks.d.ts +21 -0
- package/runtime/app-core-runtime-hooks.d.ts.map +1 -0
- package/runtime/app-core-runtime-hooks.js +10 -0
- package/runtime/autonomy-policy.d.ts +2 -0
- package/runtime/autonomy-policy.d.ts.map +1 -0
- package/runtime/autonomy-policy.js +4 -0
- package/runtime/bundled-fused-lib.d.ts +36 -0
- package/runtime/bundled-fused-lib.d.ts.map +1 -0
- package/runtime/bundled-fused-lib.js +77 -0
- package/runtime/channel-plugin-map.d.ts +1 -5
- package/runtime/channel-plugin-map.d.ts.map +1 -1
- package/runtime/channel-plugin-map.js +11 -31
- package/runtime/desktop/AppWindowRenderer.d.ts +17 -0
- package/runtime/desktop/AppWindowRenderer.d.ts.map +1 -0
- package/runtime/desktop/AppWindowRenderer.js +360 -0
- package/runtime/desktop/DesktopSurfaceNavigationRuntime.d.ts +2 -0
- package/runtime/desktop/DesktopSurfaceNavigationRuntime.d.ts.map +1 -0
- package/runtime/desktop/DesktopSurfaceNavigationRuntime.js +41 -0
- package/runtime/desktop/DesktopTrayRuntime.d.ts +2 -0
- package/runtime/desktop/DesktopTrayRuntime.d.ts.map +1 -0
- package/runtime/desktop/DesktopTrayRuntime.js +174 -0
- package/runtime/desktop/DetachedShellRoot.d.ts +10 -0
- package/runtime/desktop/DetachedShellRoot.d.ts.map +1 -0
- package/runtime/desktop/DetachedShellRoot.js +111 -0
- package/runtime/desktop/index.d.ts +6 -0
- package/runtime/desktop/index.d.ts.map +1 -0
- package/runtime/desktop/index.js +5 -0
- package/runtime/desktop/tray-menu.d.ts +20 -0
- package/runtime/desktop/tray-menu.d.ts.map +1 -0
- package/runtime/desktop/tray-menu.js +143 -0
- package/runtime/dev-server.d.ts +1 -1
- package/runtime/dev-server.d.ts.map +1 -1
- package/runtime/dev-server.js +104 -19
- package/runtime/eliza.d.ts +75 -1
- package/runtime/eliza.d.ts.map +1 -1
- package/runtime/eliza.js +606 -122
- package/runtime/ensure-text-to-speech-handler.d.ts.map +1 -1
- package/runtime/ensure-text-to-speech-handler.js +10 -3
- package/runtime/mobile-safe-runtime.d.ts +181 -2
- package/runtime/mobile-safe-runtime.d.ts.map +1 -1
- package/runtime/mobile-safe-runtime.js +1019 -12
- package/runtime/mode/remote-forwarder.d.ts.map +1 -1
- package/runtime/mode/remote-forwarder.js +2 -2
- package/runtime/mode/route-mode-guard.d.ts +2 -3
- package/runtime/mode/route-mode-guard.d.ts.map +1 -1
- package/runtime/mode/route-mode-guard.js +4 -5
- package/runtime/mode/route-mode-matrix.d.ts +1 -1
- package/runtime/mode/route-mode-matrix.d.ts.map +1 -1
- package/runtime/mode/route-mode-matrix.js +14 -1
- package/runtime/mode/runtime-mode.d.ts +1 -1
- package/runtime/mode/runtime-mode.js +1 -1
- package/runtime/runtime-bootstrap-policy.d.ts.map +1 -1
- package/runtime/runtime-bootstrap-policy.js +14 -2
- package/runtime/telegram-standalone-handler.d.ts.map +1 -1
- package/runtime/telegram-standalone-handler.js +10 -9
- package/runtime/tts-cache-wiring.d.ts +29 -0
- package/runtime/tts-cache-wiring.d.ts.map +1 -0
- package/runtime/tts-cache-wiring.js +114 -0
- package/runtime/voice-warmup.d.ts +66 -0
- package/runtime/voice-warmup.d.ts.map +1 -0
- package/runtime/voice-warmup.js +101 -0
- package/scripts/android-sms-gateway-template.test.mjs +1014 -0
- package/scripts/aosp/README.md +29 -16
- package/scripts/aosp/compile-libllama-zig-pin.test.mjs +147 -0
- package/scripts/aosp/compile-libllama.mjs +1750 -267
- package/scripts/aosp/compile-libllama.test.mjs +133 -0
- package/scripts/aosp/compile-shim.mjs +68 -19
- package/scripts/aosp/deploy-pixel.mjs +405 -0
- package/scripts/aosp/lib/load-variant-config.mjs +3 -3
- package/scripts/aosp/llama-cpp-patches/README.md +8 -8
- package/scripts/aosp/llama-cpp-patches/apply-patches.mjs +23 -6
- package/scripts/aosp/llama-cpp-patches/polarquant/README.md +37 -0
- package/scripts/aosp/llama-cpp-patches/qjl/README.md +37 -0
- package/scripts/aosp/seccomp-shim/sigsys-handler-arm64.c +169 -0
- package/scripts/aosp/seccomp-shim/sigsys-handler-riscv64.c +217 -0
- package/scripts/aosp/smoke-cuttlefish.mjs +34 -4
- package/scripts/aosp/stage-default-models.mjs +59 -35
- package/scripts/aosp/stage-default-models.test.mjs +23 -0
- package/scripts/aosp/variant-config-schema.ts +2 -2
- package/scripts/assert-required-bundled-packages.test.ts +555 -0
- package/scripts/audit-apple-store-sandbox.mjs +146 -0
- package/scripts/audit-live-test-surface.mjs +5 -2
- package/scripts/build-capacitor-app.mjs +21 -0
- package/scripts/build-flatpak.mjs +5 -5
- package/scripts/build-helpers/arm64-simd.mjs +72 -0
- package/scripts/build-helpers/omnivoice-merged.mjs +87 -0
- package/scripts/build-helpers/verify-fused-symbols.mjs +600 -0
- package/scripts/build-helpers/verify-fused-symbols.test.mjs +0 -0
- package/scripts/build-image.sh +1 -1
- package/scripts/build-llama-cpp-mtp.mjs +488 -0
- package/scripts/build-native-plugins.mjs +230 -18
- package/scripts/build-patched-electrobun-cli.mjs +68 -10
- package/scripts/build-win.mjs +1 -1
- package/scripts/bun-riscv64/Dockerfile +418 -0
- package/scripts/bun-riscv64/README.md +316 -0
- package/scripts/bun-riscv64/build.sh +469 -0
- package/scripts/bun-riscv64/bun-patches/0001-config-add-riscv64-arch.patch +74 -0
- package/scripts/bun-riscv64/bun-patches/0002-flags-add-riscv64-march-mabi.patch +16 -0
- package/scripts/bun-riscv64/bun-patches/0003-zig-add-riscv64-target-triple-and-cpu.patch +26 -0
- package/scripts/bun-riscv64/bun-patches/0004-webkit-force-local-mode-on-riscv64.patch +33 -0
- package/scripts/bun-riscv64/bun-patches/0005-tinycc-disable-on-riscv64.patch +16 -0
- package/scripts/bun-riscv64/bun-patches/0006-build-add-riscv64-cli-validation.patch +15 -0
- package/scripts/bun-riscv64/bun-patches/0007-deps-per-dep-riscv64-checks.patch +24 -0
- package/scripts/bun-riscv64/bun-patches/0008-source-stabilize-riscv64-musl-build.patch +226 -0
- package/scripts/bun-riscv64/bun-patches/0009-disable-wasm-streaming-hooks-for-c-loop.patch +162 -0
- package/scripts/bun-riscv64/bun-patches/0010-disable-inspector-profiler-for-riscv64-c-loop.patch +80 -0
- package/scripts/bun-riscv64/bun-patches/0011-process-arch-add-riscv64.patch +23 -0
- package/scripts/bun-riscv64/bun-patches/0012-cpu-features-add-riscv64-fallback.patch +13 -0
- package/scripts/bun-riscv64/bun-patches/0013-disable-console-inspector-hooks-for-riscv64-c-loop.patch +43 -0
- package/scripts/bun-riscv64/bun-patches/0014-disable-custom-inspector-dispatchers-on-riscv64.patch +127 -0
- package/scripts/bun-riscv64/bun-patches/0015-disable-jsc-profiler-builtins-on-riscv64.patch +75 -0
- package/scripts/bun-riscv64/bun-patches/0016-node-vm-disable-jit-cached-data-on-riscv64-c-loop.patch +96 -0
- package/scripts/bun-riscv64/bun-patches/0017-disable-performance-domjit-signature-on-riscv64-c-loop.patch +34 -0
- package/scripts/bun-riscv64/bun-patches/0018-fix-serialized-script-identifier-big-endian-path.patch +19 -0
- package/scripts/bun-riscv64/bun-patches/0019-add-wtf-timer-fire-bridge-for-c-loop.patch +24 -0
- package/scripts/bun-riscv64/bun-patches/0020-run-riscv64-smoke-test-under-qemu.patch +13 -0
- package/scripts/bun-riscv64/bun-patches/0021-fix-riscv64-linux-open-flags.patch +25 -0
- package/scripts/bun-riscv64/bun-patches/0022-zlib-riscv64-generic-kernels.patch +25 -0
- package/scripts/bun-riscv64/bun-patches/README.md +127 -0
- package/scripts/bun-riscv64/bun-version.json +202 -0
- package/scripts/bun-riscv64/run-build.sh +162 -0
- package/scripts/bun-riscv64/rust-core/0001-riscv64-rust-core-port.patch +868 -0
- package/scripts/bun-riscv64/rust-core/0002-second-wave-riscv64-source-gaps.patch +130 -0
- package/scripts/bun-riscv64/rust-core/0003-third-wave-riscv64-crash-handler-gaps.patch +78 -0
- package/scripts/bun-riscv64/rust-core/0004-rust-target-cpu-riscv64.patch +39 -0
- package/scripts/bun-riscv64/rust-core/0005-fifth-wave-riscv64-source-gaps.patch +96 -0
- package/scripts/bun-riscv64/rust-core/0006-cpp-wasm-and-inspector-guards-riscv64.patch +91 -0
- package/scripts/bun-riscv64/rust-core/0007-bun-alloc-max-align-t-riscv64.patch +36 -0
- package/scripts/bun-riscv64/rust-core/0008-workspace-lints-warn-not-deny-riscv64.patch +75 -0
- package/scripts/bun-riscv64/rust-core/0009-zigglobalobject-wasm-streaming-guards-riscv64.patch +109 -0
- package/scripts/bun-riscv64/rust-core/0010-tcc-externs-stub-on-riscv64.patch +62 -0
- package/scripts/bun-riscv64/rust-core/0011-clippy-ptr-cast-lints-warn-riscv64.patch +61 -0
- package/scripts/bun-riscv64/rust-core/README.md +80 -0
- package/scripts/bun-riscv64/rust-core/webkit-patches/0003-disable-dfg-ftl-on-riscv64.patch +60 -0
- package/scripts/bun-riscv64/rust-core/webkit-patches/0004-riscv64-do-not-force-wasm-in-c-loop.patch +31 -0
- package/scripts/bun-riscv64/rust-core/webkit-patches/0005-domjit-effect-allow-no-dfg-c-loop.patch +40 -0
- package/scripts/bun-riscv64/rust-core/webkit-patches/0006-disable-usewasm-when-webassembly-compiled-out.patch +33 -0
- package/scripts/bun-riscv64/rust-core/webkit-patches/0007-restore-dropped-includes-and-llint-fwd-decl.patch +31 -0
- package/scripts/bun-riscv64/validate.sh +264 -0
- package/scripts/bun-riscv64/webkit-patches/0001-cherry-pick-llint-riscv64.recipe +155 -0
- package/scripts/bun-riscv64/webkit-patches/0002-cherry-pick-baseline-jit-riscv64.recipe +40 -0
- package/scripts/bun-riscv64/webkit-patches/0003-disable-dfg-ftl-on-riscv64.patch +60 -0
- package/scripts/bun-riscv64/webkit-patches/0004-riscv64-do-not-force-wasm-in-c-loop.patch +31 -0
- package/scripts/bun-riscv64/webkit-patches/0005-domjit-effect-allow-no-dfg-c-loop.patch +40 -0
- package/scripts/bun-riscv64/webkit-patches/0006-disable-usewasm-when-webassembly-compiled-out.patch +33 -0
- package/scripts/bun-riscv64/webkit-patches/0007-restore-dropped-includes-and-llint-fwd-decl.patch +72 -0
- package/scripts/bun-riscv64/webkit-patches/README.md +146 -0
- package/scripts/check-homepage-public-readiness.mjs +353 -0
- package/scripts/check-homepage-release-data.mjs +110 -0
- package/scripts/check-i18n.mjs +1 -1
- package/scripts/check-real-local-chat.ts +147 -0
- package/scripts/check-real-local-provisioning.ts +104 -0
- package/scripts/check-real-local-reset.ts +249 -0
- package/scripts/check-sms-gateway-completion-audit.mjs +428 -0
- package/scripts/check-sms-gateway-readiness.mjs +266 -0
- package/scripts/clean-repo.mjs +5 -5
- package/scripts/codesign-mas.mjs +222 -16
- package/scripts/collect-docker-runtime-deps.mjs +229 -0
- package/scripts/continue-sms-gateway-work.mjs +121 -0
- package/scripts/copy-runtime-node-modules.ts +1050 -195
- package/scripts/deploy-cloud-api-production-gateway.mjs +52 -0
- package/scripts/desktop-build.mjs +965 -98
- package/scripts/dev-platform.mjs +346 -102
- package/scripts/dev-startup-smoke.mjs +248 -0
- package/scripts/dev-ui.mjs +418 -176
- package/scripts/disable-local-eliza-workspace.mjs +35 -0
- package/scripts/docker-ci-smoke.sh +465 -96
- package/scripts/docker-entrypoint.sh +62 -1
- package/scripts/docker-entrypoint.test.ts +283 -0
- package/scripts/ensure-avatars.mjs +2 -2
- package/scripts/ensure-electrobun-core.mjs +1 -1
- package/scripts/ensure-generated-core-proto-js.mjs +1 -1
- package/scripts/ensure-type-package-aliases.mjs +62 -5
- package/scripts/ensure-vision-deps.mjs +20 -1
- package/scripts/entry.ts +1 -1
- package/scripts/ffi-stub/Makefile +64 -0
- package/scripts/ffi-stub/README.md +391 -0
- package/scripts/ffi-stub/asr-ffi-smoke.ts +139 -0
- package/scripts/ffi-stub/ffi-stub.c +539 -0
- package/scripts/ffi-stub/ffi.h +538 -0
- package/scripts/ffi-stub/libelizainference_stub.so +0 -0
- package/scripts/ffi-stub/tts-stream-ffi-smoke.ts +349 -0
- package/scripts/generate-first-run-voicelines.mjs +194 -0
- package/scripts/generate-plugin-index.js +4 -3
- package/scripts/generate-static-asset-manifest.mjs +1 -1
- package/scripts/i18n-dynamic-keys.json +5 -5
- package/scripts/init-submodules.mjs +2 -2
- package/scripts/install-android-sms-gateway.md +177 -0
- package/scripts/install-android-sms-gateway.mjs +1088 -0
- package/scripts/ios-xcframework/README.md +74 -72
- package/scripts/ios-xcframework/build-xcframework.mjs +204 -43
- package/scripts/ios-xcframework/run-physical-device-smoke.mjs +1943 -0
- package/scripts/ios-xcframework/runtime-symbol-shim.c +450 -0
- package/scripts/kernel-patches/cpu-polar-kernels.mjs +441 -0
- package/scripts/kernel-patches/cpu-simd-kernels.mjs +253 -0
- package/scripts/kernel-patches/cpu-thread-parallelism.mjs +368 -0
- package/scripts/kernel-patches/cuda-kernels.mjs +117 -0
- package/scripts/kernel-patches/metal-kernels.mjs +1698 -109
- package/scripts/kernel-patches/server-omnivoice-route.mjs +718 -0
- package/scripts/kernel-patches/server-structured-output.mjs +279 -0
- package/scripts/kernel-patches/vulkan-dispatch-log.mjs +166 -0
- package/scripts/kernel-patches/vulkan-dispatch-log.test.mjs +50 -0
- package/scripts/kernel-patches/vulkan-dispatch-patches/01-vulkan-shaders-gen.patch +30 -16
- package/scripts/kernel-patches/vulkan-dispatch-patches/02-ggml-vulkan-pipelines.patch +75 -30
- package/scripts/kernel-patches/vulkan-kernels.mjs +800 -49
- package/scripts/lib/agent-source-watcher.mjs +173 -0
- package/scripts/lib/agent-source-watcher.test.mjs +184 -0
- package/scripts/lib/api-supervisor.mjs +78 -9
- package/scripts/lib/api-supervisor.test.mjs +121 -0
- package/scripts/lib/app-dir.mjs +2 -16
- package/scripts/lib/apple-entitlement-audit.mjs +655 -0
- package/scripts/lib/apple-entitlement-audit.test.mjs +144 -0
- package/scripts/lib/artifact-staleness.d.mts +33 -0
- package/scripts/lib/artifact-staleness.mjs +122 -0
- package/scripts/lib/artifact-staleness.test.mts +98 -0
- package/scripts/lib/bun-version-guard.mjs +13 -13
- package/scripts/lib/capacitor-plugin-build-needed.mjs +4 -3
- package/scripts/lib/capacitor-plugin-names.mjs +30 -14
- package/scripts/lib/desktop-preflight.mjs +9 -5
- package/scripts/lib/desktop-startup-embedding-warmup-policy.mjs +51 -0
- package/scripts/lib/desktop-startup-embedding-warmup-policy.test.mjs +55 -0
- package/scripts/lib/duet-bridge.d.mts +63 -0
- package/scripts/lib/duet-bridge.mjs +193 -0
- package/scripts/lib/ios-plist-url-scheme.mjs +80 -0
- package/scripts/lib/mobile-build-decisions.mjs +97 -0
- package/scripts/lib/node-path-env.mjs +4 -2
- package/scripts/lib/orchestrator-desktop-dev-banner.mjs +12 -3
- package/scripts/lib/patch-bun-exports.mjs +90 -27
- package/scripts/lib/patch-bun-exports.test.mjs +79 -0
- package/scripts/lib/renderer-build-action.mjs +35 -0
- package/scripts/lib/renderer-build-action.test.mjs +70 -0
- package/scripts/lib/renderer-build-manifest.d.mts +65 -0
- package/scripts/lib/renderer-build-manifest.mjs +257 -0
- package/scripts/lib/renderer-build-manifest.test.mts +277 -0
- package/scripts/lib/stage-android-agent.mjs +757 -99
- package/scripts/lib/sync-eliza-env-aliases.mjs +3 -25
- package/scripts/lib/ui-smoke-stub-decision.mjs +33 -0
- package/scripts/lib/ui-smoke-stub-decision.test.mjs +46 -0
- package/scripts/lib/verify-ondevice-artifact.d.mts +16 -0
- package/scripts/lib/verify-ondevice-artifact.mjs +61 -0
- package/scripts/lib/verify-ondevice-artifact.test.mts +98 -0
- package/scripts/lib/vite-renderer-dist-stale.mjs +5 -0
- package/scripts/lib/voice-latency-report.mjs +154 -0
- package/scripts/lib/websocket-pending-queue.ts +92 -0
- package/scripts/lifeops-prompt-benchmark.ts +21 -12
- package/scripts/link-docker-local-app-packages.mjs +109 -36
- package/scripts/local-stt-bench.ts +192 -0
- package/scripts/maintain-cloud-api-production-gateway.mjs +54 -0
- package/scripts/mas-smoke.mjs +459 -0
- package/scripts/mas-smoke.test.mjs +220 -0
- package/scripts/mobile-auth-simulator-smoke.mjs +0 -1
- package/scripts/normalize-eliza-capture.ts +97 -0
- package/scripts/omnivoice-fuse/prepare.mjs +2543 -23
- package/scripts/pack-upstreams.mjs +65 -5
- package/scripts/package-electrobun-linux.mjs +303 -0
- package/scripts/patch-deps.mjs +5 -3
- package/scripts/patches/llama-asr-word-timestamps.patch +218 -0
- package/scripts/playwright-ui-live-stack.ts +588 -157
- package/scripts/playwright-ui-smoke-api-stub.mjs +3495 -111
- package/scripts/pre-review-local.mjs +2 -2
- package/scripts/prepare-ios-cocoapods.sh +41 -3
- package/scripts/release-check.ts +180 -84
- package/scripts/relink-workspace-packages-to-dist.mjs +21 -4
- package/scripts/rt.mjs +16 -1
- package/scripts/run-biome-check.mjs +1 -1
- package/scripts/run-coding-agent-e2e.mjs +3 -3
- package/scripts/run-eliza-app-core-script.mjs +34 -0
- package/scripts/run-local-plugin-live-smoke.mjs +66 -2
- package/scripts/run-mobile-build-android-app-actions.test.mjs +426 -0
- package/scripts/run-mobile-build-brand-separation.test.mts +33 -0
- package/scripts/run-mobile-build-ios-engine-gate.test.mjs +85 -0
- package/scripts/run-mobile-build-mtp-staleness.test.mts +198 -0
- package/scripts/run-mobile-build.mjs +5082 -610
- package/scripts/run-node-runtime.mjs +184 -7
- package/scripts/run-node-runtime.test.mjs +167 -0
- package/scripts/run-node-tsx.mjs +80 -33
- package/scripts/run-node.mjs +41 -1
- package/scripts/run-production-build.mjs +34 -27
- package/scripts/run-release-check.mjs +19 -0
- package/scripts/run-release-contract-suite.mjs +107 -14
- package/scripts/run-ui-smoke-playwright-suite.mjs +0 -2
- package/scripts/runtime-package-manifest.ts +21 -3
- package/scripts/serve-real-local-agent.ts +72 -0
- package/scripts/setup-upstreams.mjs +42 -1
- package/scripts/sms-gateway-status.mjs +194 -0
- package/scripts/stage-android-agent.test.mjs +97 -0
- package/scripts/stage-desktop-fused-lib.mjs +453 -0
- package/scripts/stage-elizavoice-lib.mjs +363 -0
- package/scripts/startup-integration-script-drift.test.ts +82 -4
- package/scripts/streaming-pipeline-bench.ts +543 -0
- package/scripts/sync-homepage-porkbun-dns.mjs +262 -0
- package/scripts/test-sms-gateway-software.mjs +100 -0
- package/scripts/type-audit.mjs +1 -1
- package/scripts/validate-bluebubbles-outbound.mjs +293 -0
- package/scripts/validate-cdn-assets.mjs +15 -7
- package/scripts/validate-regression-matrix.mjs +109 -8
- package/scripts/verify-android-sms-gateway-e2e.mjs +362 -0
- package/scripts/verify-bluebubbles-gateway-e2e.mjs +191 -0
- package/scripts/verify-bluebubbles-inbound-readiness.mjs +88 -0
- package/scripts/verify-cloud-api-production-deploy.mjs +87 -0
- package/scripts/verify-cloud-sms-onboarding-flow.mjs +336 -0
- package/scripts/verify-ondevice-artifact.mjs +111 -0
- package/scripts/voice/freeze-voice.mjs +521 -0
- package/scripts/voice-attribution-smoke.ts +644 -0
- package/scripts/voice-create-profile.mjs +379 -0
- package/scripts/voice-duet.mjs +1355 -0
- package/scripts/voice-e2e-hardware.ts +877 -0
- package/scripts/voice-interactive.mjs +1721 -0
- package/scripts/voice-latency-report.mjs +96 -0
- package/scripts/voice-latency-report.test.ts +176 -0
- package/scripts/voice-preset/build-default-voice-preset.mjs +249 -0
- package/scripts/voice-preset/build-onboarding-voice.mjs +281 -0
- package/scripts/watch-sms-gateway-readiness.mjs +303 -0
- package/scripts/write-homepage-release-data.mjs +458 -26
- package/security/agent-vault-id.d.ts +2 -2
- package/security/agent-vault-id.js +1 -1
- package/security/hydrate-wallet-keys-from-platform-store.d.ts.map +1 -1
- package/security/hydrate-wallet-keys-from-platform-store.js +23 -14
- package/security/platform-secure-store-node.d.ts +3 -3
- package/security/platform-secure-store-node.js +3 -3
- package/security/wallet-os-store-actions.d.ts +0 -9
- package/security/wallet-os-store-actions.d.ts.map +1 -1
- package/security/wallet-os-store-actions.js +3 -10
- package/services/account-pool.d.ts +23 -14
- package/services/account-pool.d.ts.map +1 -1
- package/services/account-pool.js +86 -24
- package/services/account-usage.d.ts.map +1 -1
- package/services/account-usage.js +2 -5
- package/services/ambient-audio/consent.d.ts +9 -0
- package/services/ambient-audio/consent.d.ts.map +1 -0
- package/services/ambient-audio/consent.js +28 -0
- package/services/ambient-audio/index.d.ts +7 -0
- package/services/ambient-audio/index.d.ts.map +1 -0
- package/services/ambient-audio/index.js +4 -0
- package/services/ambient-audio/replay-buffer.d.ts +14 -0
- package/services/ambient-audio/replay-buffer.d.ts.map +1 -0
- package/services/ambient-audio/replay-buffer.js +66 -0
- package/services/ambient-audio/response-gate.d.ts +3 -0
- package/services/ambient-audio/response-gate.d.ts.map +1 -0
- package/services/ambient-audio/response-gate.js +33 -0
- package/services/ambient-audio/service.d.ts +22 -0
- package/services/ambient-audio/service.d.ts.map +1 -0
- package/services/ambient-audio/service.js +47 -0
- package/services/ambient-audio/types.d.ts +42 -0
- package/services/ambient-audio/types.d.ts.map +1 -0
- package/services/app-updates/update-policy.d.ts +64 -0
- package/services/app-updates/update-policy.d.ts.map +1 -0
- package/services/app-updates/update-policy.js +228 -0
- package/services/auth-store.d.ts +37 -1
- package/services/auth-store.d.ts.map +1 -1
- package/services/auth-store.js +59 -26
- package/services/cloud-jwks-store.d.ts +3 -3
- package/services/cloud-jwks-store.d.ts.map +1 -1
- package/services/cloud-jwks-store.js +5 -8
- package/services/coding-account-bridge.d.ts +71 -0
- package/services/coding-account-bridge.d.ts.map +1 -0
- package/services/coding-account-bridge.js +267 -0
- package/services/connector-target-catalog.d.ts +11 -4
- package/services/connector-target-catalog.d.ts.map +1 -1
- package/services/connector-target-catalog.js +7 -4
- package/services/credential-tunnel-service.d.ts +66 -0
- package/services/credential-tunnel-service.d.ts.map +1 -0
- package/services/credential-tunnel-service.js +227 -0
- package/services/github-credentials.d.ts +1 -1
- package/services/github-credentials.js +1 -1
- package/services/inference-abort.d.ts +47 -0
- package/services/inference-abort.d.ts.map +1 -0
- package/services/inference-abort.js +76 -0
- package/services/persistence.d.ts +2 -3
- package/services/persistence.d.ts.map +1 -1
- package/services/persistence.js +2 -3
- package/services/phrase-chunked-tts.d.ts +136 -0
- package/services/phrase-chunked-tts.d.ts.map +1 -0
- package/services/phrase-chunked-tts.js +208 -0
- package/services/sandbox-registry.d.ts +78 -0
- package/services/sandbox-registry.d.ts.map +1 -0
- package/services/sandbox-registry.js +323 -0
- package/services/secrets-manager-installer.d.ts +8 -1
- package/services/secrets-manager-installer.d.ts.map +1 -1
- package/services/secrets-manager-installer.js +27 -2
- package/services/sensitive-requests/cloud-link-adapter.d.ts +15 -0
- package/services/sensitive-requests/cloud-link-adapter.d.ts.map +1 -0
- package/services/sensitive-requests/cloud-link-adapter.js +73 -0
- package/services/sensitive-requests/index.d.ts +27 -0
- package/services/sensitive-requests/index.d.ts.map +1 -0
- package/services/sensitive-requests/index.js +51 -0
- package/services/sensitive-requests/instruct-dm-only-adapter.d.ts +14 -0
- package/services/sensitive-requests/instruct-dm-only-adapter.d.ts.map +1 -0
- package/services/sensitive-requests/instruct-dm-only-adapter.js +22 -0
- package/services/sensitive-requests/owner-app-inline-adapter.d.ts +3 -0
- package/services/sensitive-requests/owner-app-inline-adapter.d.ts.map +1 -0
- package/services/sensitive-requests/owner-app-inline-adapter.js +146 -0
- package/services/sensitive-requests/owner-app-oauth-adapter.d.ts +3 -0
- package/services/sensitive-requests/owner-app-oauth-adapter.d.ts.map +1 -0
- package/services/sensitive-requests/owner-app-oauth-adapter.js +156 -0
- package/services/sensitive-requests/public-link-adapter.d.ts +14 -0
- package/services/sensitive-requests/public-link-adapter.d.ts.map +1 -0
- package/services/sensitive-requests/public-link-adapter.js +86 -0
- package/services/sensitive-requests/tunnel-link-adapter.d.ts +17 -0
- package/services/sensitive-requests/tunnel-link-adapter.d.ts.map +1 -0
- package/services/sensitive-requests/tunnel-link-adapter.js +38 -0
- package/services/steward-credentials.d.ts +1 -1
- package/services/steward-credentials.d.ts.map +1 -1
- package/services/steward-credentials.js +10 -6
- package/services/steward-sidecar/health-check.d.ts.map +1 -1
- package/services/steward-sidecar/health-check.js +4 -3
- package/services/steward-sidecar/process-management.d.ts +1 -1
- package/services/steward-sidecar/process-management.d.ts.map +1 -1
- package/services/steward-sidecar/process-management.js +9 -3
- package/services/steward-sidecar/types.d.ts +1 -1
- package/services/steward-sidecar/types.d.ts.map +1 -1
- package/services/steward-sidecar/wallet-setup.d.ts +1 -1
- package/services/steward-sidecar/wallet-setup.d.ts.map +1 -1
- package/services/steward-sidecar/wallet-setup.js +8 -7
- package/services/steward-sidecar.d.ts +5 -5
- package/services/steward-sidecar.d.ts.map +1 -1
- package/services/steward-sidecar.js +27 -19
- package/services/task-host-capabilities.d.ts +60 -0
- package/services/task-host-capabilities.d.ts.map +1 -0
- package/services/task-host-capabilities.js +122 -0
- package/services/tool-call-cache/index.d.ts +2 -2
- package/services/tool-call-cache/index.d.ts.map +1 -1
- package/services/tool-call-cache/index.js +1 -1
- package/services/trigger-event-bridge.js +1 -1
- package/services/tunnel-to-mobile/index.d.ts +2 -0
- package/services/tunnel-to-mobile/index.d.ts.map +1 -0
- package/services/tunnel-to-mobile/index.js +1 -0
- package/services/tunnel-to-mobile/tunnel-to-mobile-client.d.ts +105 -0
- package/services/tunnel-to-mobile/tunnel-to-mobile-client.d.ts.map +1 -0
- package/services/tunnel-to-mobile/tunnel-to-mobile-client.js +190 -0
- package/services/vault-bootstrap.d.ts.map +1 -1
- package/services/vault-bootstrap.js +52 -21
- package/services/vault-mirror.d.ts +1 -1
- package/services/vault-mirror.d.ts.map +1 -1
- package/services/vault-mirror.js +29 -6
- package/services/voice-profiles/diarization-pipeline.d.ts +6 -0
- package/services/voice-profiles/diarization-pipeline.d.ts.map +1 -0
- package/services/voice-profiles/diarization-pipeline.js +20 -0
- package/services/voice-profiles/index.d.ts +12 -0
- package/services/voice-profiles/index.d.ts.map +1 -0
- package/services/voice-profiles/index.js +5 -0
- package/services/voice-profiles/nickname-evaluator.d.ts +14 -0
- package/services/voice-profiles/nickname-evaluator.d.ts.map +1 -0
- package/services/voice-profiles/nickname-evaluator.js +46 -0
- package/services/voice-profiles/owner-confidence.d.ts +10 -0
- package/services/voice-profiles/owner-confidence.d.ts.map +1 -0
- package/services/voice-profiles/owner-confidence.js +38 -0
- package/services/voice-profiles/private-challenge.d.ts +20 -0
- package/services/voice-profiles/private-challenge.d.ts.map +1 -0
- package/services/voice-profiles/private-challenge.js +44 -0
- package/services/voice-profiles/store.d.ts +21 -0
- package/services/voice-profiles/store.d.ts.map +1 -0
- package/services/voice-profiles/store.js +50 -0
- package/services/voice-profiles/types.d.ts +38 -0
- package/services/voice-profiles/types.d.ts.map +1 -0
- package/services/voice-profiles/types.js +1 -0
- package/styles/electrobun-mac-window-drag.css +4 -4
- package/test/helpers/__tests__/live-agent-test.smoke.test.ts +43 -70
- package/test/helpers/browser-mocks.ts +2 -2
- package/test/helpers/conditional-tests.ts +2 -2
- package/test/helpers/live-agent-test.ts +537 -551
- package/test/helpers/live-provider.test.ts +95 -5
- package/test/helpers/live-provider.ts +234 -56
- package/test/helpers/live-runtime-server.ts +4 -4
- package/test/helpers/pglite-runtime.ts +1 -1
- package/test/helpers/real-runtime.ts +72 -20
- package/test/helpers/trajectory-harness.ts +11 -7
- package/test/scripts/start-eliza-live.ts +9 -0
- package/test/scripts/test-parallel.mjs +1 -1
- package/test/scripts/test-root-unit.mjs +6 -7
- package/test/scripts/websocket-pending-queue.test.ts +119 -0
- package/test-support/test-helpers.d.ts +0 -33
- package/test-support/test-helpers.d.ts.map +1 -1
- package/test-support/test-helpers.js +81 -189
- package/ui-compat.d.ts +14 -2
- package/ui-compat.d.ts.map +1 -1
- package/ui-compat.js +23 -3
- package/api/auth-pairing-compat-routes.d.ts +0 -17
- package/api/auth-pairing-compat-routes.d.ts.map +0 -1
- package/api/auth-pairing-compat-routes.js +0 -301
- package/api/local-inference-compat-routes.d.ts +0 -16
- package/api/local-inference-compat-routes.d.ts.map +0 -1
- package/api/local-inference-compat-routes.js +0 -617
- package/api/onboarding-compat-routes.d.ts +0 -4
- package/api/onboarding-compat-routes.d.ts.map +0 -1
- package/api/onboarding-compat-routes.js +0 -207
- package/api/plugins-compat-routes.d.ts +0 -103
- package/api/plugins-compat-routes.d.ts.map +0 -1
- package/api/plugins-compat-routes.js +0 -1181
- package/api/server-onboarding-compat.d.ts +0 -31
- package/api/server-onboarding-compat.d.ts.map +0 -1
- package/api/server-onboarding-compat.js +0 -283
- package/benchmark/cua-routes.d.ts +0 -10
- package/benchmark/cua-routes.d.ts.map +0 -1
- package/benchmark/cua-routes.js +0 -179
- package/benchmark/mock-plugin-base.d.ts +0 -9
- package/benchmark/mock-plugin-base.d.ts.map +0 -1
- package/benchmark/mock-plugin-base.js +0 -325
- package/cli/parse-duration.d.ts +0 -5
- package/cli/parse-duration.d.ts.map +0 -1
- package/cli/parse-duration.js +0 -27
- package/patches/llama-cpp-capacitor@0.1.5.patch +0 -2387
- package/platform/agent-browser-stub.d.ts +0 -27
- package/platform/agent-browser-stub.d.ts.map +0 -1
- package/platform/agent-browser-stub.js +0 -16
- package/platforms/android/app/src/androidTest/java/com/getcapacitor/myapp/ExampleInstrumentedTest.java +0 -26
- package/platforms/android/app/src/main/res/drawable/ic_launcher_background.xml +0 -170
- package/platforms/android/app/src/main/res/drawable-v24/ic_launcher_foreground.xml +0 -34
- package/platforms/android/app/src/test/java/com/getcapacitor/myapp/ExampleUnitTest.java +0 -18
- package/platforms/electrobun/assets/appIcon.iconset/icon_512x512@2x.png +0 -0
- package/platforms/electrobun/assets/appIcon.png +0 -0
- package/platforms/electrobun/scripts/build-whisper-universal.sh +0 -137
- package/platforms/electrobun/scripts/build-whisper.sh +0 -95
- package/platforms/electrobun/scripts/ensure-whisper-model.sh +0 -93
- package/platforms/electrobun/src/libMacWindowEffects.dylib +0 -0
- package/platforms/electrobun/src/native/whisper.ts +0 -280
- package/platforms/ios/App/App/Assets.xcassets/Splash.imageset/splash-2732x2732-1.png +0 -0
- package/platforms/ios/App/App/Assets.xcassets/Splash.imageset/splash-2732x2732-2.png +0 -0
- package/platforms/ios/App/App/Assets.xcassets/Splash.imageset/splash-2732x2732.png +0 -0
- package/registry/generate-apps.d.ts +0 -2
- package/registry/generate-apps.d.ts.map +0 -1
- package/registry/generate-apps.js +0 -338
- package/registry/generate.d.ts +0 -2
- package/registry/generate.d.ts.map +0 -1
- package/registry/generate.js +0 -506
- package/registry/loader.d.ts +0 -27
- package/registry/loader.d.ts.map +0 -1
- package/registry/loader.js +0 -111
- package/registry/schema.d.ts +0 -989
- package/registry/schema.d.ts.map +0 -1
- package/registry/schema.js +0 -264
- package/runtime/embedding-manager-support.d.ts +0 -77
- package/runtime/embedding-manager-support.d.ts.map +0 -1
- package/runtime/embedding-manager-support.js +0 -309
- package/runtime/embedding-presets.d.ts +0 -5
- package/runtime/embedding-presets.d.ts.map +0 -1
- package/runtime/embedding-presets.js +0 -47
- package/runtime/embedding-warmup-policy.d.ts +0 -13
- package/runtime/embedding-warmup-policy.d.ts.map +0 -1
- package/runtime/embedding-warmup-policy.js +0 -33
- package/runtime/ensure-local-inference-handler.d.ts +0 -25
- package/runtime/ensure-local-inference-handler.d.ts.map +0 -1
- package/runtime/ensure-local-inference-handler.js +0 -389
- package/runtime/mobile-local-inference-gate.d.ts +0 -21
- package/runtime/mobile-local-inference-gate.d.ts.map +0 -1
- package/runtime/mobile-local-inference-gate.js +0 -24
- package/scripts/aosp/avd-test.mjs +0 -403
- package/scripts/aosp/boot-validate.mjs +0 -536
- package/scripts/aosp/build-aosp.mjs +0 -448
- package/scripts/aosp/build-bootanimation.mjs +0 -178
- package/scripts/aosp/capture-screens.mjs +0 -325
- package/scripts/aosp/e2e-validate.mjs +0 -225
- package/scripts/aosp/lint-init-rc.mjs +0 -258
- package/scripts/aosp/llama-shim/eliza_llama_shim.c +0 -276
- package/scripts/aosp/sim.mjs +0 -277
- package/scripts/aosp/sync-to-aosp.mjs +0 -134
- package/scripts/aosp/validate.mjs +0 -1273
- package/scripts/build-llama-cpp-dflash.mjs +0 -1866
- package/scripts/generate-onboarding-voicelines.mjs +0 -194
- package/scripts/generated/static-asset-manifest.json +0 -4
- package/scripts/normalize-parallax-capture.ts +0 -97
- package/scripts/omnivoice-fuse/Makefile +0 -44
- package/scripts/omnivoice-fuse/README.md +0 -266
- package/scripts/omnivoice-fuse/cmake-graft.mjs +0 -180
- package/scripts/omnivoice-fuse/ffi-stub.c +0 -222
- package/scripts/omnivoice-fuse/ffi.h +0 -158
- package/scripts/omnivoice-fuse/libelizainference_stub.dylib +0 -0
- package/scripts/omnivoice-fuse/verify-symbols.mjs +0 -138
- package/security/cloud-secret-store.d.ts +0 -34
- package/security/cloud-secret-store.d.ts.map +0 -1
- package/security/cloud-secret-store.js +0 -65
- package/security/export-guard.d.ts +0 -34
- package/security/export-guard.d.ts.map +0 -1
- package/security/export-guard.js +0 -127
- package/services/local-inference/__stress__/cache-stress-helpers.d.ts +0 -76
- package/services/local-inference/__stress__/cache-stress-helpers.d.ts.map +0 -1
- package/services/local-inference/__stress__/cache-stress-helpers.js +0 -238
- package/services/local-inference/active-model.d.ts +0 -180
- package/services/local-inference/active-model.d.ts.map +0 -1
- package/services/local-inference/active-model.js +0 -362
- package/services/local-inference/assignments.d.ts +0 -58
- package/services/local-inference/assignments.d.ts.map +0 -1
- package/services/local-inference/assignments.js +0 -179
- package/services/local-inference/backend.d.ts +0 -200
- package/services/local-inference/backend.d.ts.map +0 -1
- package/services/local-inference/backend.js +0 -242
- package/services/local-inference/bundled-models.d.ts +0 -34
- package/services/local-inference/bundled-models.d.ts.map +0 -1
- package/services/local-inference/bundled-models.js +0 -104
- package/services/local-inference/cache-bridge.d.ts +0 -184
- package/services/local-inference/cache-bridge.d.ts.map +0 -1
- package/services/local-inference/cache-bridge.js +0 -333
- package/services/local-inference/catalog.d.ts +0 -57
- package/services/local-inference/catalog.d.ts.map +0 -1
- package/services/local-inference/catalog.js +0 -262
- package/services/local-inference/conversation-registry.d.ts +0 -122
- package/services/local-inference/conversation-registry.d.ts.map +0 -1
- package/services/local-inference/conversation-registry.js +0 -182
- package/services/local-inference/device-bridge.d.ts +0 -139
- package/services/local-inference/device-bridge.d.ts.map +0 -1
- package/services/local-inference/device-bridge.js +0 -774
- package/services/local-inference/dflash-doctor.d.ts +0 -27
- package/services/local-inference/dflash-doctor.d.ts.map +0 -1
- package/services/local-inference/dflash-doctor.js +0 -149
- package/services/local-inference/dflash-server.d.ts +0 -248
- package/services/local-inference/dflash-server.d.ts.map +0 -1
- package/services/local-inference/dflash-server.js +0 -1076
- package/services/local-inference/downloader.d.ts +0 -48
- package/services/local-inference/downloader.d.ts.map +0 -1
- package/services/local-inference/downloader.js +0 -688
- package/services/local-inference/engine.d.ts +0 -282
- package/services/local-inference/engine.d.ts.map +0 -1
- package/services/local-inference/engine.js +0 -743
- package/services/local-inference/external-scanner.d.ts +0 -17
- package/services/local-inference/external-scanner.d.ts.map +0 -1
- package/services/local-inference/external-scanner.js +0 -261
- package/services/local-inference/handler-registry.d.ts +0 -72
- package/services/local-inference/handler-registry.d.ts.map +0 -1
- package/services/local-inference/handler-registry.js +0 -159
- package/services/local-inference/hardware.d.ts +0 -26
- package/services/local-inference/hardware.d.ts.map +0 -1
- package/services/local-inference/hardware.js +0 -139
- package/services/local-inference/hf-search.d.ts +0 -19
- package/services/local-inference/hf-search.d.ts.map +0 -1
- package/services/local-inference/hf-search.js +0 -169
- package/services/local-inference/index.d.ts +0 -10
- package/services/local-inference/index.d.ts.map +0 -1
- package/services/local-inference/index.js +0 -7
- package/services/local-inference/llama-server-metrics.d.ts +0 -108
- package/services/local-inference/llama-server-metrics.d.ts.map +0 -1
- package/services/local-inference/llama-server-metrics.js +0 -175
- package/services/local-inference/manifest/index.d.ts +0 -4
- package/services/local-inference/manifest/index.d.ts.map +0 -1
- package/services/local-inference/manifest/index.js +0 -5
- package/services/local-inference/manifest/schema.d.ts +0 -419
- package/services/local-inference/manifest/schema.d.ts.map +0 -1
- package/services/local-inference/manifest/schema.js +0 -227
- package/services/local-inference/manifest/types.d.ts +0 -23
- package/services/local-inference/manifest/types.d.ts.map +0 -1
- package/services/local-inference/manifest/types.js +0 -5
- package/services/local-inference/manifest/validator.d.ts +0 -43
- package/services/local-inference/manifest/validator.d.ts.map +0 -1
- package/services/local-inference/manifest/validator.js +0 -187
- package/services/local-inference/paths.d.ts +0 -8
- package/services/local-inference/paths.d.ts.map +0 -1
- package/services/local-inference/paths.js +0 -7
- package/services/local-inference/providers.d.ts +0 -61
- package/services/local-inference/providers.d.ts.map +0 -1
- package/services/local-inference/providers.js +0 -334
- package/services/local-inference/ram-budget.d.ts +0 -57
- package/services/local-inference/ram-budget.d.ts.map +0 -1
- package/services/local-inference/ram-budget.js +0 -107
- package/services/local-inference/readiness.d.ts +0 -9
- package/services/local-inference/readiness.d.ts.map +0 -1
- package/services/local-inference/readiness.js +0 -153
- package/services/local-inference/recommendation.d.ts +0 -62
- package/services/local-inference/recommendation.d.ts.map +0 -1
- package/services/local-inference/recommendation.js +0 -309
- package/services/local-inference/registry.d.ts +0 -35
- package/services/local-inference/registry.d.ts.map +0 -1
- package/services/local-inference/registry.js +0 -117
- package/services/local-inference/router-handler.d.ts +0 -51
- package/services/local-inference/router-handler.d.ts.map +0 -1
- package/services/local-inference/router-handler.js +0 -165
- package/services/local-inference/routing-policy.d.ts +0 -55
- package/services/local-inference/routing-policy.d.ts.map +0 -1
- package/services/local-inference/routing-policy.js +0 -195
- package/services/local-inference/routing-preferences.d.ts +0 -8
- package/services/local-inference/routing-preferences.d.ts.map +0 -1
- package/services/local-inference/routing-preferences.js +0 -7
- package/services/local-inference/service.d.ts +0 -88
- package/services/local-inference/service.d.ts.map +0 -1
- package/services/local-inference/service.js +0 -210
- package/services/local-inference/session-pool.d.ts +0 -72
- package/services/local-inference/session-pool.d.ts.map +0 -1
- package/services/local-inference/session-pool.js +0 -125
- package/services/local-inference/types.d.ts +0 -309
- package/services/local-inference/types.d.ts.map +0 -1
- package/services/local-inference/types.js +0 -23
- package/services/local-inference/verify.d.ts +0 -8
- package/services/local-inference/verify.d.ts.map +0 -1
- package/services/local-inference/verify.js +0 -7
- package/services/local-inference/voice/barge-in.d.ts +0 -15
- package/services/local-inference/voice/barge-in.d.ts.map +0 -1
- package/services/local-inference/voice/barge-in.js +0 -20
- package/services/local-inference/voice/engine-bridge.d.ts +0 -256
- package/services/local-inference/voice/engine-bridge.d.ts.map +0 -1
- package/services/local-inference/voice/engine-bridge.js +0 -398
- package/services/local-inference/voice/ffi-bindings.d.ts +0 -114
- package/services/local-inference/voice/ffi-bindings.d.ts.map +0 -1
- package/services/local-inference/voice/ffi-bindings.js +0 -281
- package/services/local-inference/voice/index.d.ts +0 -51
- package/services/local-inference/voice/index.d.ts.map +0 -1
- package/services/local-inference/voice/index.js +0 -50
- package/services/local-inference/voice/lifecycle.d.ts +0 -135
- package/services/local-inference/voice/lifecycle.d.ts.map +0 -1
- package/services/local-inference/voice/lifecycle.js +0 -189
- package/services/local-inference/voice/phoneme-tokenizer.d.ts +0 -58
- package/services/local-inference/voice/phoneme-tokenizer.d.ts.map +0 -1
- package/services/local-inference/voice/phoneme-tokenizer.js +0 -53
- package/services/local-inference/voice/phrase-cache.d.ts +0 -24
- package/services/local-inference/voice/phrase-cache.d.ts.map +0 -1
- package/services/local-inference/voice/phrase-cache.js +0 -32
- package/services/local-inference/voice/phrase-chunker.d.ts +0 -20
- package/services/local-inference/voice/phrase-chunker.d.ts.map +0 -1
- package/services/local-inference/voice/phrase-chunker.js +0 -85
- package/services/local-inference/voice/ring-buffer.d.ts +0 -40
- package/services/local-inference/voice/ring-buffer.d.ts.map +0 -1
- package/services/local-inference/voice/ring-buffer.js +0 -85
- package/services/local-inference/voice/rollback-queue.d.ts +0 -24
- package/services/local-inference/voice/rollback-queue.d.ts.map +0 -1
- package/services/local-inference/voice/rollback-queue.js +0 -49
- package/services/local-inference/voice/scheduler.d.ts +0 -47
- package/services/local-inference/voice/scheduler.d.ts.map +0 -1
- package/services/local-inference/voice/scheduler.js +0 -123
- package/services/local-inference/voice/shared-resources.d.ts +0 -119
- package/services/local-inference/voice/shared-resources.d.ts.map +0 -1
- package/services/local-inference/voice/shared-resources.js +0 -83
- package/services/local-inference/voice/speaker-preset-cache.d.ts +0 -28
- package/services/local-inference/voice/speaker-preset-cache.d.ts.map +0 -1
- package/services/local-inference/voice/speaker-preset-cache.js +0 -44
- package/services/local-inference/voice/types.d.ts +0 -80
- package/services/local-inference/voice/types.d.ts.map +0 -1
- package/services/local-inference/voice/voice-preset-format.d.ts +0 -56
- package/services/local-inference/voice/voice-preset-format.d.ts.map +0 -1
- package/services/local-inference/voice/voice-preset-format.js +0 -184
- package/services/plugin-installer.d.ts +0 -22
- package/services/plugin-installer.d.ts.map +0 -1
- package/services/plugin-installer.js +0 -41
- package/test/helpers/i18n.ts +0 -5
- package/test/helpers/loopback.ts +0 -33
- package/test/helpers/react-test.ts +0 -40
- package/test/helpers/skip-without.ts +0 -53
- package/test/scripts/task-agent-live-smoke.ts +0 -1335
- /package/services/{local-inference/voice → ambient-audio}/types.js +0 -0
|
@@ -29,26 +29,32 @@
|
|
|
29
29
|
// its musl Android targets, so the resulting ABI matches what bun expects
|
|
30
30
|
// when it dlopen()s libllama.so via bun:ffi at runtime.
|
|
31
31
|
//
|
|
32
|
-
//
|
|
33
|
-
// that miss <bit> / <span> shims llama.cpp's CMake feature
|
|
32
|
+
// Arm64/aarch64-musl is pinned to zig 0.13.x. Earlier versions ship older
|
|
33
|
+
// libc++ headers that miss <bit> / <span> shims llama.cpp's CMake feature
|
|
34
|
+
// checks rely on, and newer host toolchains have regressed this lane (zig
|
|
35
|
+
// 0.16's lld SIGSEGVs the aarch64-linux-musl link). Keep that target on the
|
|
36
|
+
// tested 0.13 line until the upstream linker crash is cleared.
|
|
34
37
|
//
|
|
35
|
-
// llama.cpp pin (matches
|
|
36
|
-
//
|
|
37
|
-
//
|
|
38
|
+
// llama.cpp pin (matches the fork the runtime loads via
|
|
39
|
+
// plugins/plugin-aosp-local-inference/src/aosp-local-inference-bootstrap.ts):
|
|
40
|
+
// fork: https://github.com/elizaOS/llama.cpp
|
|
41
|
+
// tag: v1.0.0-eliza (the kernel-complete v0.4.0-eliza tree,
|
|
42
|
+
// re-tagged on the elizaOS org rename)
|
|
38
43
|
// commit: 08032d57e15574f2a7ca19fc3f29510c8673d590
|
|
39
44
|
//
|
|
40
|
-
//
|
|
41
|
-
// on top of
|
|
42
|
-
// linux-x64-cuda host target (the AOSP arm64 path stays
|
|
43
|
-
// but the pin is shared so both AOSP and host build paths
|
|
44
|
-
// identical kernel sources.
|
|
45
|
+
// This tree adds the W4-B CUDA QJL + PolarQuant Q4 + TBQ3_TCQ kernels
|
|
46
|
+
// on top of the earlier eliza-lineage tags. The CUDA paths only matter
|
|
47
|
+
// for the linux-x64-cuda host target (the AOSP arm64 path stays
|
|
48
|
+
// CPU-only), but the pin is shared so both AOSP and host build paths
|
|
49
|
+
// land on identical kernel sources. A rebase onto a newer upstream is a
|
|
50
|
+
// deferred effort — see docs/porting/upstream-rebase-plan.md.
|
|
45
51
|
//
|
|
46
|
-
// v0.2.0-
|
|
47
|
-
// CLI surface (--spec-type
|
|
48
|
-
// / n_drafted_accepted_total Prometheus counters) on top of v0.1.0-
|
|
52
|
+
// v0.2.0-eliza (subset of this pin) added MTP speculative decoding
|
|
53
|
+
// CLI surface (--spec-type mtp, --spec-draft-n-min/max, n_drafted_total
|
|
54
|
+
// / n_drafted_accepted_total Prometheus counters) on top of v0.1.0-eliza.
|
|
49
55
|
//
|
|
50
56
|
// Why this fork (not stock ggml-org/llama.cpp b8198):
|
|
51
|
-
// The
|
|
57
|
+
// The Eliza fork composes four techniques onto upstream b8198:
|
|
52
58
|
//
|
|
53
59
|
// - TBQ3_0 (slot 43) + TBQ4_0 (slot 44) — 3-bit / 4-bit TurboQuant V-cache.
|
|
54
60
|
// Cherry-picked from apothic/llama.cpp-1bit-turboquant @ b2b5273.
|
|
@@ -62,7 +68,7 @@
|
|
|
62
68
|
// W1-B's Polar series. Bumped from upstream slot 45 to 47 because
|
|
63
69
|
// slot 46 is now QJL.
|
|
64
70
|
// - Metal kernel sources (.metal) for TBQ3_0/TBQ4_0/TBQ3_TCQ/QJL/Polar
|
|
65
|
-
// under ggml/src/ggml-metal/
|
|
71
|
+
// under ggml/src/ggml-metal/eliza-kernels/. Source-only landing —
|
|
66
72
|
// dispatcher wiring is the next agent's job.
|
|
67
73
|
//
|
|
68
74
|
// The CPU implementations of all four techniques (NEON for arm64, AVX2
|
|
@@ -82,23 +88,27 @@
|
|
|
82
88
|
// adapter never called it anyway).
|
|
83
89
|
//
|
|
84
90
|
// Output (per ABI):
|
|
85
|
-
//
|
|
86
|
-
//
|
|
87
|
-
//
|
|
88
|
-
//
|
|
89
|
-
//
|
|
90
|
-
//
|
|
91
|
+
// packages/app/android/app/src/main/assets/agent/{abi}/libllama.so
|
|
92
|
+
// packages/app/android/app/src/main/assets/agent/{abi}/libggml.so
|
|
93
|
+
// packages/app/android/app/src/main/assets/agent/{abi}/libggml-cpu.so
|
|
94
|
+
// packages/app/android/app/src/main/assets/agent/{abi}/libggml-base.so
|
|
95
|
+
// packages/app/android/app/src/main/assets/agent/{abi}/llama-server (MTP spec-decode HTTP server)
|
|
96
|
+
// (with --target *-fused: libelizainference.so — the fused FFI lib)
|
|
91
97
|
//
|
|
92
98
|
// libllama.so has NEEDED entries on the entire libggml family (see
|
|
93
99
|
// `readelf -d`); the dynamic linker resolves them from the per-ABI asset
|
|
94
100
|
// dir via the LD_LIBRARY_PATH ElizaAgentService.java sets at process
|
|
95
|
-
// launch. ABIs: arm64-v8a (real phones)
|
|
101
|
+
// launch. ABIs: arm64-v8a (real phones), x86_64 (cuttlefish + emulators),
|
|
102
|
+
// and riscv64 (cf_riscv64_phone + future riscv64 hardware).
|
|
96
103
|
//
|
|
97
|
-
//
|
|
98
|
-
//
|
|
99
|
-
//
|
|
100
|
-
//
|
|
101
|
-
//
|
|
104
|
+
// libllama.so + the libggml*.so family are NOT loaded directly by any TS
|
|
105
|
+
// adapter anymore — the runtime loads the fused libelizainference.so. But
|
|
106
|
+
// the fused lib `target_link_libraries(elizainference PUBLIC llama)` against
|
|
107
|
+
// the SHARED libllama.so, so libllama.so + libggml*.so remain runtime
|
|
108
|
+
// DT_NEEDED dependencies of libelizainference.so and MUST keep building +
|
|
109
|
+
// staging. The old bun:ffi struct-by-value shims (libeliza-llama-shim.so +
|
|
110
|
+
// libeliza-llama-speculative-shim.so), consumed by the now-deleted
|
|
111
|
+
// aosp-llama-adapter.ts, have been retired from this builder.
|
|
102
112
|
//
|
|
103
113
|
// Approximate build cost on a modern Linux x86_64 builder (16 cores, NVMe):
|
|
104
114
|
// - llama.cpp clone: ~30 s, ~150 MB working tree.
|
|
@@ -152,9 +162,11 @@
|
|
|
152
162
|
// call (Commandment 8: don't hide broken pipelines behind fallbacks).
|
|
153
163
|
//
|
|
154
164
|
// Repo-root resolution:
|
|
155
|
-
// The script defaults `--assets-dir` to
|
|
156
|
-
// `<repoRoot>/
|
|
157
|
-
//
|
|
165
|
+
// The script defaults `--assets-dir` to the first app shell found under
|
|
166
|
+
// `<repoRoot>/packages/app`, `<repoRoot>/apps/app`, or
|
|
167
|
+
// `<repoRoot>/eliza/packages/app`, then appends
|
|
168
|
+
// `android/app/src/main/assets/agent`. `--cache-dir` defaults to
|
|
169
|
+
// `~/.cache/eliza-android-agent/llama-cpp-<tag>`.
|
|
158
170
|
// `<repoRoot>` is derived from this script's location: walk up from
|
|
159
171
|
// `eliza/packages/app-core/scripts/aosp/` to the host repo root by
|
|
160
172
|
// default, but when the parent host repo invokes this via the
|
|
@@ -167,6 +179,13 @@ import os from "node:os";
|
|
|
167
179
|
import path from "node:path";
|
|
168
180
|
import process from "node:process";
|
|
169
181
|
import { fileURLToPath } from "node:url";
|
|
182
|
+
import { androidArm64SimdCmakeFlags } from "../build-helpers/arm64-simd.mjs";
|
|
183
|
+
import {
|
|
184
|
+
fusedCmakeBuildTargets,
|
|
185
|
+
fusedExtraCmakeFlags,
|
|
186
|
+
} from "../build-helpers/omnivoice-merged.mjs";
|
|
187
|
+
import { verifyFusedSymbols } from "../build-helpers/verify-fused-symbols.mjs";
|
|
188
|
+
import { patchVulkanKernels } from "../kernel-patches/vulkan-kernels.mjs";
|
|
170
189
|
import { resolveRepoRootFromImportMeta } from "../lib/repo-root.mjs";
|
|
171
190
|
import { main as compileShimMain } from "./compile-shim.mjs";
|
|
172
191
|
|
|
@@ -177,11 +196,19 @@ const here = path.dirname(fileURLToPath(import.meta.url));
|
|
|
177
196
|
// inside the elizaOS source checkout it's the elizaOS repo root.
|
|
178
197
|
const repoRoot = resolveRepoRootFromImportMeta(import.meta.url);
|
|
179
198
|
|
|
180
|
-
//
|
|
181
|
-
//
|
|
182
|
-
// (
|
|
183
|
-
//
|
|
184
|
-
//
|
|
199
|
+
// elizaOS/llama.cpp @ 33c888a7b. Composes TBQ (apothic) +
|
|
200
|
+
// QJL (W1-A) + Q4_POLAR (W1-B) + Metal sources (W1-D) + MTP spec-decode
|
|
201
|
+
// (W2) + W3-B fused CPU kernels + W4-B CUDA QJL/Polar/TBQ3_TCQ kernels onto
|
|
202
|
+
// upstream b9213. See docs/porting/unified-fork-strategy.md for the full
|
|
203
|
+
// migration story.
|
|
204
|
+
//
|
|
205
|
+
// The fork ships in-tree as the git submodule at
|
|
206
|
+
// plugins/plugin-local-inference/native/llama.cpp (next to the MTP build at
|
|
207
|
+
// scripts/build-llama-cpp-mtp.mjs — same pinned commit so both build paths
|
|
208
|
+
// land on identical kernels). When that
|
|
209
|
+
// submodule is initialized this path defaults to it (no clone needed); pass
|
|
210
|
+
// `--src-dir` to point at another checkout, or `--cache-dir` to force a
|
|
211
|
+
// standalone clone of `${LLAMA_CPP_REMOTE}` at `${LLAMA_CPP_TAG}`.
|
|
185
212
|
//
|
|
186
213
|
// Pre-2026-05-09 the AOSP path consumed apothic/llama.cpp-1bit-turboquant
|
|
187
214
|
// directly and applied vendored QJL + PolarQuant patch series via
|
|
@@ -189,11 +216,77 @@ const repoRoot = resolveRepoRootFromImportMeta(import.meta.url);
|
|
|
189
216
|
// flow is now replaced by a single canonical fork — the patches are
|
|
190
217
|
// baked in. apply-patches.mjs is kept around for one release as a
|
|
191
218
|
// rollback path; see scripts/aosp/llama-cpp-patches/README.md.
|
|
192
|
-
export const LLAMA_CPP_TAG = "
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
219
|
+
export const LLAMA_CPP_TAG = "v1.2.0-eliza";
|
|
220
|
+
// Must track the `plugins/plugin-local-inference/native/llama.cpp` submodule
|
|
221
|
+
// gitlink on develop. The old pin `33c888a7be` predated the Mali flash-attn
|
|
222
|
+
// subgroup-race fix (the `VK_VENDOR_ID_ARM` `disable_subgroups` branch), so the
|
|
223
|
+
// fused Vulkan lib built from it SIGABRTed mid-decode on Mali GPUs (#9508). This
|
|
224
|
+
// commit is a forward descendant that bakes the mitigation in; the
|
|
225
|
+
// `verify-fused-symbols` gate enforces the marker is present post-build.
|
|
226
|
+
export const LLAMA_CPP_COMMIT = "32a7911dced6230ce544c43a6399f5bd721cab90";
|
|
227
|
+
export const LLAMA_CPP_REMOTE = "https://github.com/elizaOS/llama.cpp.git";
|
|
196
228
|
export const MIN_ZIG_VERSION = "0.13.0";
|
|
229
|
+
export const AARCH64_MUSL_ZIG_MIN_VERSION = "0.13.0";
|
|
230
|
+
export const AARCH64_MUSL_ZIG_MAX_VERSION_EXCLUSIVE = "0.14.0";
|
|
231
|
+
// Floor for the RVV-on riscv64 build. Zig 0.13's bundled LLVM rejects the
|
|
232
|
+
// GCC-style `-march=rv64gcv*` ISA string the vendored llama.cpp's
|
|
233
|
+
// ggml-cpu/CMakeLists hard-codes when GGML_RVV / GGML_RV_ZFH / etc. are ON;
|
|
234
|
+
// zig 0.14+ accepts it. Below this floor we hard-disable RVV + Zfh + Zvfh +
|
|
235
|
+
// Zicbop + Zihintpause + Zvfbfwma + XTheadVector + Zba + SpaceMit so the
|
|
236
|
+
// MARCH_STR collapses to plain `rv64gc` (which Zig 0.13's argv filter then
|
|
237
|
+
// strips, since the `riscv64-linux-musl` triple already implies rv64gc/lp64d).
|
|
238
|
+
// At or above this floor we leave the upstream defaults ON, the filter
|
|
239
|
+
// becomes a no-op, and the vendored RVV intrinsic kernels (q4_0/q4_1/q5_0/
|
|
240
|
+
// q5_1/q8_0/q8_1/q4_K/q5_K/q6_K/q8_K/iq*/tq1_0/tq2_0/mxfp4 in
|
|
241
|
+
// ggml/src/ggml-cpu/arch/riscv/quants.c) light up.
|
|
242
|
+
export const MIN_ZIG_RVV_VERSION = "0.14.0";
|
|
243
|
+
|
|
244
|
+
// Pinned zig series (MAJOR.MINOR) for the aarch64/x86_64 `*-linux-musl`
|
|
245
|
+
// cross-link that produces the Android/cuttlefish + fused (libelizainference)
|
|
246
|
+
// libs. zig 0.16 bundles an LLVM whose `lld` SIGSEGVs while linking the
|
|
247
|
+
// aarch64-linux-musl shared object — a host-toolchain regression that aborts
|
|
248
|
+
// the link with no actionable diagnostic (it looks like an OOM / random crash,
|
|
249
|
+
// not a config error). zig 0.13.x links these targets cleanly, so we pin the
|
|
250
|
+
// series rather than only enforcing a floor: a newer-is-fine `>=` check would
|
|
251
|
+
// silently route an operator's `brew install zig` (0.16) straight into the
|
|
252
|
+
// SIGSEGV. This is intentionally a series pin, not an exact-patch pin — any
|
|
253
|
+
// 0.13.x patch release links fine. The riscv64 RVV path keeps its own
|
|
254
|
+
// MIN_ZIG_RVV_VERSION floor (it needs 0.14+ for the RVV ISA string) and is a
|
|
255
|
+
// distinct musl triple, so it is exempt from this pin (see
|
|
256
|
+
// `assertZigPinForTargets`). An operator who has independently verified their
|
|
257
|
+
// zig's lld links aarch64-linux-musl can override with
|
|
258
|
+
// ELIZA_ALLOW_UNPINNED_ZIG=1, but the default refuses the broken toolchain.
|
|
259
|
+
export const PINNED_ZIG_SERIES_FOR_MUSL_LINK = "0.13";
|
|
260
|
+
// zig triples whose lld link is covered by the 0.13.x pin above. riscv64 is
|
|
261
|
+
// deliberately absent: its RVV build path requires 0.14+ and is gated by
|
|
262
|
+
// MIN_ZIG_RVV_VERSION instead.
|
|
263
|
+
export const PINNED_ZIG_LINK_TRIPLES = Object.freeze([
|
|
264
|
+
"aarch64-linux-musl",
|
|
265
|
+
"x86_64-linux-musl",
|
|
266
|
+
]);
|
|
267
|
+
export const ALLOW_UNPINNED_ZIG_ENV = "ELIZA_ALLOW_UNPINNED_ZIG";
|
|
268
|
+
|
|
269
|
+
// The in-repo submodule checkout of the fork.
|
|
270
|
+
// `repoRoot` resolves to the repo root that contains a top-level package.json.
|
|
271
|
+
const LLAMA_CPP_SUBMODULE_DIR = path.join(
|
|
272
|
+
repoRoot,
|
|
273
|
+
"plugins",
|
|
274
|
+
"plugin-local-inference",
|
|
275
|
+
"native",
|
|
276
|
+
"llama.cpp",
|
|
277
|
+
);
|
|
278
|
+
// True when the submodule is checked out (has a worktree). When so, the AOSP
|
|
279
|
+
// cross-compile defaults its source dir to it instead of cloning.
|
|
280
|
+
export function llamaCppSubmodulePresent() {
|
|
281
|
+
try {
|
|
282
|
+
return (
|
|
283
|
+
fs.existsSync(path.join(LLAMA_CPP_SUBMODULE_DIR, ".git")) &&
|
|
284
|
+
fs.existsSync(path.join(LLAMA_CPP_SUBMODULE_DIR, "CMakeLists.txt"))
|
|
285
|
+
);
|
|
286
|
+
} catch {
|
|
287
|
+
return false;
|
|
288
|
+
}
|
|
289
|
+
}
|
|
197
290
|
|
|
198
291
|
export const ABI_TARGETS = [
|
|
199
292
|
{
|
|
@@ -206,21 +299,354 @@ export const ABI_TARGETS = [
|
|
|
206
299
|
zigTarget: "x86_64-linux-musl",
|
|
207
300
|
cmakeProcessor: "x86_64",
|
|
208
301
|
},
|
|
302
|
+
{
|
|
303
|
+
androidAbi: "riscv64",
|
|
304
|
+
zigTarget: "riscv64-linux-musl",
|
|
305
|
+
cmakeProcessor: "riscv64",
|
|
306
|
+
},
|
|
209
307
|
];
|
|
210
308
|
|
|
309
|
+
/**
|
|
310
|
+
* Map a list of Android ABI directory names (`arm64-v8a` | `x86_64` |
|
|
311
|
+
* `riscv64`) to the distinct zig cross-link triples (`zigTarget`) they build
|
|
312
|
+
* through. Used to decide which targets the zig-series pin applies to. Throws
|
|
313
|
+
* on an unknown ABI rather than silently dropping it.
|
|
314
|
+
*
|
|
315
|
+
* Exported for tests.
|
|
316
|
+
*
|
|
317
|
+
* @param {readonly string[]} abis
|
|
318
|
+
* @returns {string[]}
|
|
319
|
+
*/
|
|
320
|
+
export function zigTriplesForAbis(abis) {
|
|
321
|
+
const triples = new Set();
|
|
322
|
+
for (const abi of abis) {
|
|
323
|
+
const target = ABI_TARGETS.find((t) => t.androidAbi === abi);
|
|
324
|
+
if (!target) {
|
|
325
|
+
throw new Error(
|
|
326
|
+
`[compile-libllama] unknown Android ABI ${abi}; expected one of ${ABI_TARGETS.map(
|
|
327
|
+
(t) => t.androidAbi,
|
|
328
|
+
).join(", ")}.`,
|
|
329
|
+
);
|
|
330
|
+
}
|
|
331
|
+
triples.add(target.zigTarget);
|
|
332
|
+
}
|
|
333
|
+
return [...triples];
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
// `*-fused` android targets that are wired to real AOSP artifacts.
|
|
337
|
+
// Membership in this set is the only way the fused (omnivoice-grafted) build
|
|
338
|
+
// path activates from this script — there is no env-var shortcut and no
|
|
339
|
+
// implicit upgrade from a non-fused `--abi` invocation.
|
|
340
|
+
export const FUSED_ANDROID_TARGETS = Object.freeze([
|
|
341
|
+
"android-arm64-cpu-fused",
|
|
342
|
+
"android-x86_64-cpu-fused",
|
|
343
|
+
"android-riscv64-cpu-fused",
|
|
344
|
+
]);
|
|
345
|
+
|
|
346
|
+
// Extra cmake targets whose build failure must STILL abort the run. Only the
|
|
347
|
+
// fused `elizainference` lib (libelizainference.so) is bundled into the APK;
|
|
348
|
+
// every other extra target is a standalone CLI driver that ships nothing, so a
|
|
349
|
+
// compile break in one of those (e.g. the fork's stale omnivoice-tts.cpp) must
|
|
350
|
+
// not fail a build whose required libs are otherwise good.
|
|
351
|
+
const CRITICAL_EXTRA_TARGETS = new Set(["elizainference"]);
|
|
352
|
+
|
|
353
|
+
/**
|
|
354
|
+
* Parse one of the `android-<arch>-<backend>[-fused]` target strings used by
|
|
355
|
+
* the mtp build script into the pieces this script needs (the Android ABI
|
|
356
|
+
* + the fused/backend flags). Throws on unsupported triples — there is no
|
|
357
|
+
* implicit translation; the operator either asks for one of the known
|
|
358
|
+
* triples or gets a hard error.
|
|
359
|
+
*
|
|
360
|
+
* Exported for tests.
|
|
361
|
+
*/
|
|
362
|
+
export function parseAndroidTarget(target) {
|
|
363
|
+
if (typeof target !== "string" || target.length === 0) {
|
|
364
|
+
throw new Error(`[compile-libllama] target must be a non-empty string`);
|
|
365
|
+
}
|
|
366
|
+
const fused = target.endsWith("-fused");
|
|
367
|
+
const base = fused ? target.slice(0, -"-fused".length) : target;
|
|
368
|
+
const match = /^android-(arm64|x86_64|riscv64)-(cpu|vulkan)$/.exec(base);
|
|
369
|
+
if (!match) {
|
|
370
|
+
throw new Error(
|
|
371
|
+
`[compile-libllama] unsupported --target ${target}. ` +
|
|
372
|
+
`Supported: ${[
|
|
373
|
+
"android-arm64-cpu",
|
|
374
|
+
"android-arm64-cpu-fused",
|
|
375
|
+
"android-x86_64-cpu",
|
|
376
|
+
"android-x86_64-cpu-fused",
|
|
377
|
+
"android-riscv64-cpu",
|
|
378
|
+
"android-riscv64-cpu-fused",
|
|
379
|
+
].join(", ")}`,
|
|
380
|
+
);
|
|
381
|
+
}
|
|
382
|
+
const [, arch, backend] = match;
|
|
383
|
+
// Android Vulkan is wired for arm64 only (the GPU device target). The
|
|
384
|
+
// GGML_VULKAN CMake flags + NDK glslc/headers + libggml-vulkan.so staging +
|
|
385
|
+
// the eliza-1 qjl/polar Vulkan kernel patches are applied in the build path
|
|
386
|
+
// when backend === "vulkan" (see resolveVulkanBuildConfig / the build fn).
|
|
387
|
+
if (backend === "vulkan" && arch !== "arm64") {
|
|
388
|
+
throw new Error(
|
|
389
|
+
`[compile-libllama] unsupported --target ${target}: Android Vulkan is ` +
|
|
390
|
+
`only wired for arm64 (the GPU device target). Use android-arm64-vulkan ` +
|
|
391
|
+
`or android-${arch}-cpu${fused ? "-fused" : ""}.`,
|
|
392
|
+
);
|
|
393
|
+
}
|
|
394
|
+
// Map the parsed arch token to the Android ABI directory name. arm64 →
|
|
395
|
+
// arm64-v8a (only Android ABI for aarch64); x86_64 and riscv64 share
|
|
396
|
+
// their name with the parsed token.
|
|
397
|
+
let androidAbi;
|
|
398
|
+
if (arch === "x86_64") androidAbi = "x86_64";
|
|
399
|
+
else if (arch === "riscv64") androidAbi = "riscv64";
|
|
400
|
+
else androidAbi = "arm64-v8a";
|
|
401
|
+
return { target, arch, backend, fused, androidAbi };
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
export function resolveAndroidNdkHostDir(
|
|
405
|
+
prebuiltRoot,
|
|
406
|
+
{ platform = os.platform(), arch = os.arch(), entries } = {},
|
|
407
|
+
) {
|
|
408
|
+
const dirs =
|
|
409
|
+
entries ??
|
|
410
|
+
(fs.existsSync(prebuiltRoot) ? fs.readdirSync(prebuiltRoot) : []);
|
|
411
|
+
const hostDirs = dirs
|
|
412
|
+
.filter((d) => /^(linux|darwin|windows)-(x86_64|aarch64|arm64)$/.test(d))
|
|
413
|
+
.sort();
|
|
414
|
+
const hostPrefix =
|
|
415
|
+
platform === "win32"
|
|
416
|
+
? "windows"
|
|
417
|
+
: platform === "linux" || platform === "darwin"
|
|
418
|
+
? platform
|
|
419
|
+
: null;
|
|
420
|
+
if (!hostPrefix) return null;
|
|
421
|
+
|
|
422
|
+
const preferredArch =
|
|
423
|
+
arch === "x64" ? "x86_64" : arch === "arm64" ? "arm64" : arch;
|
|
424
|
+
const archCandidates =
|
|
425
|
+
preferredArch === "arm64"
|
|
426
|
+
? ["arm64", "aarch64", "x86_64"]
|
|
427
|
+
: [preferredArch, "x86_64"];
|
|
428
|
+
return (
|
|
429
|
+
archCandidates
|
|
430
|
+
.map((candidate) => `${hostPrefix}-${candidate}`)
|
|
431
|
+
.find((candidate) => hostDirs.includes(candidate)) ??
|
|
432
|
+
hostDirs.find((candidate) => candidate.startsWith(`${hostPrefix}-`)) ??
|
|
433
|
+
null
|
|
434
|
+
);
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
export function resolveHomebrewFormulaIncludeDirs(
|
|
438
|
+
formula,
|
|
439
|
+
prefixes = ["/opt/homebrew", "/usr/local"],
|
|
440
|
+
) {
|
|
441
|
+
const includeDirs = [];
|
|
442
|
+
for (const prefix of prefixes) {
|
|
443
|
+
includeDirs.push(path.join(prefix, "opt", formula, "include"));
|
|
444
|
+
const cellar = path.join(prefix, "Cellar", formula);
|
|
445
|
+
if (!fs.existsSync(cellar)) continue;
|
|
446
|
+
for (const version of fs.readdirSync(cellar).sort(compareSemver)) {
|
|
447
|
+
includeDirs.push(path.join(cellar, version, "include"));
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
return includeDirs;
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
/**
|
|
454
|
+
* GGML_VULKAN CMake flags for the android-arm64 Vulkan backend. Points cmake at
|
|
455
|
+
* the NDK's host `glslc` (the shader compiler ggml-vulkan's codegen invokes),
|
|
456
|
+
* the Vulkan headers, and the aarch64 Vulkan loader stub. ggml-vulkan dlopen()s
|
|
457
|
+
* the device's real libvulkan.so at runtime; the NDK stub only satisfies the
|
|
458
|
+
* link. Throws (fail-closed) if any NDK Vulkan prerequisite is missing, so the
|
|
459
|
+
* build never silently falls back to CPU for a Vulkan target.
|
|
460
|
+
*/
|
|
461
|
+
export function resolveAndroidVulkanCmakeFlags({
|
|
462
|
+
androidApi = 31,
|
|
463
|
+
stagingDir,
|
|
464
|
+
} = {}) {
|
|
465
|
+
const sdk = process.env.ANDROID_HOME || process.env.ANDROID_SDK_ROOT;
|
|
466
|
+
if (!sdk) {
|
|
467
|
+
throw new Error(
|
|
468
|
+
"[compile-libllama] ANDROID_HOME/ANDROID_SDK_ROOT is required for the " +
|
|
469
|
+
"android Vulkan build (NDK glslc + Vulkan headers + loader).",
|
|
470
|
+
);
|
|
471
|
+
}
|
|
472
|
+
const ndkRoot = path.join(sdk, "ndk");
|
|
473
|
+
const ndks = fs.existsSync(ndkRoot)
|
|
474
|
+
? fs
|
|
475
|
+
.readdirSync(ndkRoot)
|
|
476
|
+
.filter((d) => /^\d+\./.test(d))
|
|
477
|
+
.sort(compareSemver)
|
|
478
|
+
: [];
|
|
479
|
+
if (ndks.length === 0) {
|
|
480
|
+
throw new Error(
|
|
481
|
+
`[compile-libllama] No NDK found under ${ndkRoot}; install one for the Vulkan build.`,
|
|
482
|
+
);
|
|
483
|
+
}
|
|
484
|
+
const ndk = path.join(ndkRoot, ndks[ndks.length - 1]);
|
|
485
|
+
// Resolve the NDK host-prebuilt dir from the actual host, not a hardcoded
|
|
486
|
+
// `linux-x86_64` — the same NDK ships `darwin-x86_64` on macOS hosts, so
|
|
487
|
+
// hardcoding linux made the Android Vulkan build Linux-only (#9508).
|
|
488
|
+
const prebuiltRoot = path.join(ndk, "toolchains/llvm/prebuilt");
|
|
489
|
+
const hostDir = resolveAndroidNdkHostDir(prebuiltRoot);
|
|
490
|
+
if (!hostDir) {
|
|
491
|
+
throw new Error(
|
|
492
|
+
`[compile-libllama] No NDK host toolchain under ${prebuiltRoot} ` +
|
|
493
|
+
`(need a host-matching linux/darwin/windows prebuilt).`,
|
|
494
|
+
);
|
|
495
|
+
}
|
|
496
|
+
const sysroot = path.join(prebuiltRoot, hostDir, "sysroot");
|
|
497
|
+
const glslc = path.join(
|
|
498
|
+
ndk,
|
|
499
|
+
"shader-tools",
|
|
500
|
+
hostDir,
|
|
501
|
+
os.platform() === "win32" ? "glslc.exe" : "glslc",
|
|
502
|
+
);
|
|
503
|
+
const libBase = path.join(sysroot, "usr/lib/aarch64-linux-android");
|
|
504
|
+
const apis = fs.existsSync(libBase)
|
|
505
|
+
? fs
|
|
506
|
+
.readdirSync(libBase)
|
|
507
|
+
.filter((d) => /^\d+$/.test(d))
|
|
508
|
+
.map(Number)
|
|
509
|
+
.filter((n) => n >= androidApi)
|
|
510
|
+
.sort((a, b) => a - b)
|
|
511
|
+
: [];
|
|
512
|
+
if (apis.length === 0) {
|
|
513
|
+
throw new Error(
|
|
514
|
+
`[compile-libllama] No aarch64 libvulkan.so >= API ${androidApi} under ${libBase}.`,
|
|
515
|
+
);
|
|
516
|
+
}
|
|
517
|
+
const libVulkan = path.join(libBase, String(apis[0]), "libvulkan.so");
|
|
518
|
+
|
|
519
|
+
// ggml-vulkan.cpp includes <vulkan/vulkan.hpp> (the C++ Vulkan-Hpp bindings).
|
|
520
|
+
// The NDK sysroot ships only the C headers (vulkan.h / vulkan_core.h) + the
|
|
521
|
+
// libvulkan.so loader, NOT the C++ wrapper. Vulkan headers are pure API
|
|
522
|
+
// declarations (arch-independent); only the loader is arch-specific. So we
|
|
523
|
+
// stage a complete host Vulkan-Hpp header set (vulkan.hpp + the structs/enums/
|
|
524
|
+
// handles/funcs/raii partials it pulls in) into an ISOLATED include root and
|
|
525
|
+
// point Vulkan_INCLUDE_DIR there. Staging only the `vulkan/` subtree keeps the
|
|
526
|
+
// musl/zig cross-compile from ever seeing host glibc headers via a wide -I.
|
|
527
|
+
const headerCandidates = [
|
|
528
|
+
process.env.VULKAN_SDK && path.join(process.env.VULKAN_SDK, "include"),
|
|
529
|
+
"/usr/include",
|
|
530
|
+
"/usr/local/include",
|
|
531
|
+
...resolveHomebrewFormulaIncludeDirs("vulkan-headers"),
|
|
532
|
+
].filter(Boolean);
|
|
533
|
+
const hostVulkanDir = headerCandidates
|
|
534
|
+
.map((d) => path.join(d, "vulkan"))
|
|
535
|
+
.find((d) => fs.existsSync(path.join(d, "vulkan.hpp")));
|
|
536
|
+
if (!hostVulkanDir) {
|
|
537
|
+
throw new Error(
|
|
538
|
+
"[compile-libllama] vulkan/vulkan.hpp (C++ Vulkan-Hpp bindings) not found. " +
|
|
539
|
+
"ggml-vulkan needs it; install the Vulkan headers (e.g. `apt install " +
|
|
540
|
+
"libvulkan-dev`) or set VULKAN_SDK. Searched: " +
|
|
541
|
+
headerCandidates.join(", "),
|
|
542
|
+
);
|
|
543
|
+
}
|
|
544
|
+
const incRoot = stagingDir
|
|
545
|
+
? path.resolve(stagingDir)
|
|
546
|
+
: path.join(os.tmpdir(), "eliza-vulkan-headers");
|
|
547
|
+
const stagedVulkan = path.join(incRoot, "vulkan");
|
|
548
|
+
fs.rmSync(stagedVulkan, { recursive: true, force: true });
|
|
549
|
+
fs.mkdirSync(incRoot, { recursive: true });
|
|
550
|
+
fs.cpSync(hostVulkanDir, stagedVulkan, { recursive: true });
|
|
551
|
+
// vulkan_core.h `#include <vk_video/...>` the video-codec extension headers,
|
|
552
|
+
// which live in a sibling `vk_video/` dir next to `vulkan/`. Stage it too so
|
|
553
|
+
// the single -I<incRoot> resolves both.
|
|
554
|
+
const hostVkVideoDir = path.join(path.dirname(hostVulkanDir), "vk_video");
|
|
555
|
+
if (fs.existsSync(hostVkVideoDir)) {
|
|
556
|
+
const stagedVkVideo = path.join(incRoot, "vk_video");
|
|
557
|
+
fs.rmSync(stagedVkVideo, { recursive: true, force: true });
|
|
558
|
+
fs.cpSync(hostVkVideoDir, stagedVkVideo, { recursive: true });
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
// ggml-vulkan.cpp also `#include <spirv/unified1/spirv.hpp>` (SPIR-V Headers,
|
|
562
|
+
// for shader reflection). The NDK bundles SPIRV-Headers under shaderc; prefer
|
|
563
|
+
// those (they match the glslc/shaderc toolchain version), else fall back to a
|
|
564
|
+
// host spirv-headers install. Stage the `spirv/` subtree into the same root.
|
|
565
|
+
const spirvCandidates = [
|
|
566
|
+
path.join(
|
|
567
|
+
ndk,
|
|
568
|
+
"sources/third_party/shaderc/third_party/spirv-tools/external/spirv-headers/include",
|
|
569
|
+
),
|
|
570
|
+
process.env.VULKAN_SDK && path.join(process.env.VULKAN_SDK, "include"),
|
|
571
|
+
"/usr/include",
|
|
572
|
+
"/usr/local/include",
|
|
573
|
+
...resolveHomebrewFormulaIncludeDirs("spirv-headers"),
|
|
574
|
+
].filter(Boolean);
|
|
575
|
+
const hostSpirvRoot = spirvCandidates.find((d) =>
|
|
576
|
+
fs.existsSync(path.join(d, "spirv/unified1/spirv.hpp")),
|
|
577
|
+
);
|
|
578
|
+
if (!hostSpirvRoot) {
|
|
579
|
+
throw new Error(
|
|
580
|
+
"[compile-libllama] spirv/unified1/spirv.hpp (SPIRV-Headers) not found. " +
|
|
581
|
+
"ggml-vulkan needs it; expected it under the NDK shaderc third_party " +
|
|
582
|
+
"tree or a host spirv-headers install. Searched: " +
|
|
583
|
+
spirvCandidates.join(", "),
|
|
584
|
+
);
|
|
585
|
+
}
|
|
586
|
+
const stagedSpirv = path.join(incRoot, "spirv");
|
|
587
|
+
fs.rmSync(stagedSpirv, { recursive: true, force: true });
|
|
588
|
+
fs.cpSync(path.join(hostSpirvRoot, "spirv"), stagedSpirv, {
|
|
589
|
+
recursive: true,
|
|
590
|
+
});
|
|
591
|
+
|
|
592
|
+
for (const [name, p] of [
|
|
593
|
+
["vulkan/vulkan.hpp", path.join(stagedVulkan, "vulkan.hpp")],
|
|
594
|
+
["glslc", glslc],
|
|
595
|
+
["libvulkan.so", libVulkan],
|
|
596
|
+
]) {
|
|
597
|
+
if (!fs.existsSync(p)) {
|
|
598
|
+
throw new Error(
|
|
599
|
+
`[compile-libllama] android Vulkan build prerequisite ${name} missing: ${p}`,
|
|
600
|
+
);
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
return [
|
|
604
|
+
"-DGGML_VULKAN=ON",
|
|
605
|
+
`-DVulkan_INCLUDE_DIR=${incRoot}`,
|
|
606
|
+
`-DVulkan_GLSLC_EXECUTABLE=${glslc}`,
|
|
607
|
+
`-DVulkan_LIBRARY=${libVulkan}`,
|
|
608
|
+
];
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
export function resolveDefaultAndroidAssetsDir({ root = repoRoot } = {}) {
|
|
612
|
+
const appRelativeCandidates = [
|
|
613
|
+
path.join("packages", "app"),
|
|
614
|
+
path.join("apps", "app"),
|
|
615
|
+
path.join("eliza", "packages", "app"),
|
|
616
|
+
];
|
|
617
|
+
for (const appRelative of appRelativeCandidates) {
|
|
618
|
+
const appRoot = path.join(root, appRelative);
|
|
619
|
+
if (
|
|
620
|
+
fs.existsSync(path.join(appRoot, "android")) ||
|
|
621
|
+
fs.existsSync(path.join(appRoot, "package.json"))
|
|
622
|
+
) {
|
|
623
|
+
return path.join(
|
|
624
|
+
appRoot,
|
|
625
|
+
"android",
|
|
626
|
+
"app",
|
|
627
|
+
"src",
|
|
628
|
+
"main",
|
|
629
|
+
"assets",
|
|
630
|
+
"agent",
|
|
631
|
+
);
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
return path.join(
|
|
635
|
+
root,
|
|
636
|
+
"packages",
|
|
637
|
+
"app",
|
|
638
|
+
"android",
|
|
639
|
+
"app",
|
|
640
|
+
"src",
|
|
641
|
+
"main",
|
|
642
|
+
"assets",
|
|
643
|
+
"agent",
|
|
644
|
+
);
|
|
645
|
+
}
|
|
646
|
+
|
|
211
647
|
export function parseArgs(argv) {
|
|
212
648
|
const args = {
|
|
213
|
-
androidAssetsDir:
|
|
214
|
-
repoRoot,
|
|
215
|
-
"apps",
|
|
216
|
-
"app",
|
|
217
|
-
"android",
|
|
218
|
-
"app",
|
|
219
|
-
"src",
|
|
220
|
-
"main",
|
|
221
|
-
"assets",
|
|
222
|
-
"agent",
|
|
223
|
-
),
|
|
649
|
+
androidAssetsDir: resolveDefaultAndroidAssetsDir(),
|
|
224
650
|
cacheDir: path.join(
|
|
225
651
|
os.homedir(),
|
|
226
652
|
".cache",
|
|
@@ -228,9 +654,25 @@ export function parseArgs(argv) {
|
|
|
228
654
|
`llama-cpp-${LLAMA_CPP_TAG}`,
|
|
229
655
|
),
|
|
230
656
|
abis: ABI_TARGETS.map((t) => t.androidAbi),
|
|
657
|
+
// Optional explicit --target=android-<arch>-<backend>[-fused] triples
|
|
658
|
+
// (see parseAndroidTarget). When present, this list takes precedence
|
|
659
|
+
// over --abi (which is the legacy bulk-build entry point that produces
|
|
660
|
+
// CPU-only libllama.so for one or both ABIs, no fusion).
|
|
661
|
+
targets: [],
|
|
231
662
|
skipIfPresent: false,
|
|
232
663
|
jobs: Math.max(1, Math.min(os.cpus().length, 8)),
|
|
233
664
|
srcDir: null,
|
|
665
|
+
cacheDirExplicit: false,
|
|
666
|
+
dryRun: false,
|
|
667
|
+
// Optional source dir of prebuilt LiteRT-LM `.litertlm` text artifacts to
|
|
668
|
+
// stage into the on-device bundle assets (`models/text/`), parallel to the
|
|
669
|
+
// `.so`/.gguf staging. Defaults to ELIZA_LITERTLM_DIR; absent ⇒ no-op (the
|
|
670
|
+
// GGUF-only default bundle is byte-identical).
|
|
671
|
+
litertlmDir:
|
|
672
|
+
process.env.ELIZA_LITERTLM_DIR &&
|
|
673
|
+
process.env.ELIZA_LITERTLM_DIR.trim().length > 0
|
|
674
|
+
? path.resolve(process.env.ELIZA_LITERTLM_DIR.trim())
|
|
675
|
+
: null,
|
|
234
676
|
};
|
|
235
677
|
|
|
236
678
|
const readFlagValue = (flag, index) => {
|
|
@@ -248,10 +690,14 @@ export function parseArgs(argv) {
|
|
|
248
690
|
i += 1;
|
|
249
691
|
} else if (arg === "--cache-dir") {
|
|
250
692
|
args.cacheDir = path.resolve(readFlagValue(arg, i));
|
|
693
|
+
args.cacheDirExplicit = true;
|
|
251
694
|
i += 1;
|
|
252
695
|
} else if (arg === "--src-dir") {
|
|
253
696
|
args.srcDir = path.resolve(readFlagValue(arg, i));
|
|
254
697
|
i += 1;
|
|
698
|
+
} else if (arg === "--litertlm-dir") {
|
|
699
|
+
args.litertlmDir = path.resolve(readFlagValue(arg, i));
|
|
700
|
+
i += 1;
|
|
255
701
|
} else if (arg === "--abi") {
|
|
256
702
|
const value = readFlagValue(arg, i);
|
|
257
703
|
const valid = ABI_TARGETS.map((t) => t.androidAbi);
|
|
@@ -262,6 +708,15 @@ export function parseArgs(argv) {
|
|
|
262
708
|
}
|
|
263
709
|
args.abis = [value];
|
|
264
710
|
i += 1;
|
|
711
|
+
} else if (arg === "--target") {
|
|
712
|
+
const value = readFlagValue(arg, i);
|
|
713
|
+
// Validates the triple and records it. Resolved further below.
|
|
714
|
+
args.targets.push(parseAndroidTarget(value));
|
|
715
|
+
i += 1;
|
|
716
|
+
} else if (arg.startsWith("--target=")) {
|
|
717
|
+
args.targets.push(parseAndroidTarget(arg.slice("--target=".length)));
|
|
718
|
+
} else if (arg === "--dry-run") {
|
|
719
|
+
args.dryRun = true;
|
|
265
720
|
} else if (arg === "--jobs" || arg === "-j") {
|
|
266
721
|
const value = Number.parseInt(readFlagValue(arg, i), 10);
|
|
267
722
|
if (!Number.isFinite(value) || value <= 0) {
|
|
@@ -275,12 +730,32 @@ export function parseArgs(argv) {
|
|
|
275
730
|
console.log(
|
|
276
731
|
"Usage: node eliza/packages/app-core/scripts/aosp/compile-libllama.mjs " +
|
|
277
732
|
"[--assets-dir <PATH>] [--cache-dir <PATH>] [--src-dir <PATH>] " +
|
|
278
|
-
"[--abi <arm64-v8a|x86_64>] [--
|
|
279
|
-
"
|
|
280
|
-
"
|
|
281
|
-
"
|
|
282
|
-
"
|
|
283
|
-
"
|
|
733
|
+
"[--abi <arm64-v8a|x86_64|riscv64>] [--target <android-<arch>-<backend>[-fused]>] " +
|
|
734
|
+
"[--litertlm-dir <PATH>] [--jobs <N>] [--skip-if-present] [--dry-run]\n" +
|
|
735
|
+
" --litertlm-dir <PATH> Stage prebuilt LiteRT-LM .litertlm text artifacts from\n" +
|
|
736
|
+
" PATH into the on-device bundle assets (models/text/), parallel\n" +
|
|
737
|
+
" to the .so/.gguf staging. Defaults to ELIZA_LITERTLM_DIR.\n" +
|
|
738
|
+
" Omit ⇒ GGUF-only bundle (the default).\n" +
|
|
739
|
+
" --target <TRIPLE> Build a single target: android-{arm64,x86_64,riscv64}-cpu[-fused].\n" +
|
|
740
|
+
" riscv64 requires NDK r27+ (first stable NDK with a real\n" +
|
|
741
|
+
" riscv64-linux-android sysroot); older NDKs will fail the\n" +
|
|
742
|
+
" compiler probe before any TU compiles.\n" +
|
|
743
|
+
" Android Vulkan targets fail closed until GGML_VULKAN\n" +
|
|
744
|
+
" flags and Vulkan backend artifact staging are wired.\n" +
|
|
745
|
+
" -fused enables the omnivoice graft (same as mtp's\n" +
|
|
746
|
+
" *-fused desktop targets) — one binary serving text +\n" +
|
|
747
|
+
" POST /v1/audio/speech.\n" +
|
|
748
|
+
" --dry-run Print the cmake invocation + graft steps + expected\n" +
|
|
749
|
+
" output layout WITHOUT running cmake/ndk. Honored for\n" +
|
|
750
|
+
" every --target.\n" +
|
|
751
|
+
" --src-dir <PATH> Use an existing llama.cpp checkout instead of the\n" +
|
|
752
|
+
" in-repo submodule / a fresh clone. The directory's HEAD\n" +
|
|
753
|
+
" is used as-is; the pinned LLAMA_CPP_TAG/COMMIT is ignored.\n" +
|
|
754
|
+
` Default source: the git submodule plugins/plugin-local-inference/native/llama.cpp\n` +
|
|
755
|
+
` (elizaOS/llama.cpp @ ${LLAMA_CPP_TAG}) when initialized;\n` +
|
|
756
|
+
` otherwise a standalone clone under --cache-dir.\n` +
|
|
757
|
+
" --cache-dir <PATH> Force the standalone-clone path even when the submodule\n" +
|
|
758
|
+
" is present.",
|
|
284
759
|
);
|
|
285
760
|
process.exit(0);
|
|
286
761
|
} else {
|
|
@@ -288,6 +763,14 @@ export function parseArgs(argv) {
|
|
|
288
763
|
}
|
|
289
764
|
}
|
|
290
765
|
|
|
766
|
+
// Default the source dir to the in-repo submodule when it is initialized and
|
|
767
|
+
// the caller did not point us elsewhere (--src-dir) or force a standalone
|
|
768
|
+
// clone (--cache-dir). Keeps both build paths (mtp + AOSP) on the exact
|
|
769
|
+
// same pinned commit.
|
|
770
|
+
if (!args.srcDir && !args.cacheDirExplicit && llamaCppSubmodulePresent()) {
|
|
771
|
+
args.srcDir = LLAMA_CPP_SUBMODULE_DIR;
|
|
772
|
+
}
|
|
773
|
+
|
|
291
774
|
return args;
|
|
292
775
|
}
|
|
293
776
|
|
|
@@ -354,6 +837,210 @@ export function probeZig({
|
|
|
354
837
|
return version;
|
|
355
838
|
}
|
|
356
839
|
|
|
840
|
+
/**
|
|
841
|
+
* Extract the MAJOR.MINOR series from a zig version string. `0.13.0` -> `0.13`,
|
|
842
|
+
* `0.13.0-dev.46+abc` -> `0.13`. Returns `null` for an unparseable input so
|
|
843
|
+
* callers can decide how to treat a missing/garbage version.
|
|
844
|
+
*
|
|
845
|
+
* Exported for tests.
|
|
846
|
+
*
|
|
847
|
+
* @param {string} version
|
|
848
|
+
* @returns {string | null}
|
|
849
|
+
*/
|
|
850
|
+
export function zigSeries(version) {
|
|
851
|
+
if (typeof version !== "string") return null;
|
|
852
|
+
const parts = version
|
|
853
|
+
.replace(/^v/, "")
|
|
854
|
+
.split(/[-+]/)[0]
|
|
855
|
+
.split(".")
|
|
856
|
+
.map((n) => Number.parseInt(n, 10));
|
|
857
|
+
if (
|
|
858
|
+
parts.length < 2 ||
|
|
859
|
+
!Number.isFinite(parts[0]) ||
|
|
860
|
+
!Number.isFinite(parts[1])
|
|
861
|
+
) {
|
|
862
|
+
return null;
|
|
863
|
+
}
|
|
864
|
+
return `${parts[0]}.${parts[1]}`;
|
|
865
|
+
}
|
|
866
|
+
|
|
867
|
+
/**
|
|
868
|
+
* Enforce the zig-series pin (PINNED_ZIG_SERIES_FOR_MUSL_LINK) for any requested
|
|
869
|
+
* target whose link goes through one of PINNED_ZIG_LINK_TRIPLES (the
|
|
870
|
+
* aarch64/x86_64 `*-linux-musl` Android / fused libs). zig 0.16's bundled lld
|
|
871
|
+
* SIGSEGVs that link, so a plain `>=` floor is not enough — we must reject a
|
|
872
|
+
* newer-but-broken toolchain too. riscv64-only target sets are exempt (their
|
|
873
|
+
* RVV path needs 0.14+, gated separately by MIN_ZIG_RVV_VERSION).
|
|
874
|
+
*
|
|
875
|
+
* Pure + deterministic: takes the detected version + the resolved triple list +
|
|
876
|
+
* env, throws on a pin violation, returns nothing on success. No side effects.
|
|
877
|
+
*
|
|
878
|
+
* Exported for tests.
|
|
879
|
+
*
|
|
880
|
+
* @param {object} params
|
|
881
|
+
* @param {string} params.version zig version string from probeZig().
|
|
882
|
+
* @param {readonly string[]} params.zigTriples the `zigTarget` triples the run
|
|
883
|
+
* will cross-link (e.g. ["aarch64-linux-musl"]).
|
|
884
|
+
* @param {NodeJS.ProcessEnv} [params.env]
|
|
885
|
+
*/
|
|
886
|
+
export function assertZigPinForTargets({
|
|
887
|
+
version,
|
|
888
|
+
zigTriples,
|
|
889
|
+
env = process.env,
|
|
890
|
+
}) {
|
|
891
|
+
const pinnedTriples = zigTriples.filter((t) =>
|
|
892
|
+
PINNED_ZIG_LINK_TRIPLES.includes(t),
|
|
893
|
+
);
|
|
894
|
+
if (pinnedTriples.length === 0) {
|
|
895
|
+
// No pinned-link triple in this run (e.g. riscv64-only) — nothing to pin.
|
|
896
|
+
return;
|
|
897
|
+
}
|
|
898
|
+
if (env[ALLOW_UNPINNED_ZIG_ENV] === "1") {
|
|
899
|
+
console.warn(
|
|
900
|
+
`[compile-libllama] ${ALLOW_UNPINNED_ZIG_ENV}=1 set; skipping the zig ` +
|
|
901
|
+
`${PINNED_ZIG_SERIES_FOR_MUSL_LINK}.x pin for ${pinnedTriples.join(", ")} ` +
|
|
902
|
+
`(zig ${version}). Only safe if you have verified this zig's lld links ` +
|
|
903
|
+
`aarch64-linux-musl without SIGSEGV.`,
|
|
904
|
+
);
|
|
905
|
+
return;
|
|
906
|
+
}
|
|
907
|
+
const series = zigSeries(version);
|
|
908
|
+
if (series !== PINNED_ZIG_SERIES_FOR_MUSL_LINK) {
|
|
909
|
+
throw new Error(
|
|
910
|
+
`[compile-libllama] zig ${version} (series ${series ?? "unknown"}) is not ` +
|
|
911
|
+
`the pinned zig ${PINNED_ZIG_SERIES_FOR_MUSL_LINK}.x required to link ` +
|
|
912
|
+
`${pinnedTriples.join(", ")}.\n` +
|
|
913
|
+
`zig 0.16's bundled lld SIGSEGVs the aarch64-linux-musl link, aborting ` +
|
|
914
|
+
`the fused/Android build with no actionable diagnostic; zig 0.13.x links ` +
|
|
915
|
+
`it cleanly. Install zig ${PINNED_ZIG_SERIES_FOR_MUSL_LINK}.x and re-run:\n` +
|
|
916
|
+
` download the 0.13.x tarball from https://ziglang.org/download/ and put ` +
|
|
917
|
+
`\`zig\` on PATH (the package-manager \`zig\` is frequently 0.16).\n` +
|
|
918
|
+
`If you have independently verified your zig's lld links ` +
|
|
919
|
+
`aarch64-linux-musl, override with ${ALLOW_UNPINNED_ZIG_ENV}=1.`,
|
|
920
|
+
);
|
|
921
|
+
}
|
|
922
|
+
}
|
|
923
|
+
|
|
924
|
+
/**
|
|
925
|
+
* Decide the riscv64 build plan based on the detected Zig version + env knobs.
|
|
926
|
+
* Pure: takes the version string + env, returns a structured plan. No side
|
|
927
|
+
* effects.
|
|
928
|
+
*
|
|
929
|
+
* Returns one of:
|
|
930
|
+
* { rvv: false, allVariants: false, zigVersion, reason: "zig-too-old" }
|
|
931
|
+
* — Zig < MIN_ZIG_RVV_VERSION. Scalar parity; the riscv64ArgFilter in
|
|
932
|
+
* ensureZigDrivers strips `-march=rv64gc*` and the resulting binary is
|
|
933
|
+
* a plain rv64gc/lp64d build.
|
|
934
|
+
*
|
|
935
|
+
* { rvv: true, allVariants: false, zigVersion, reason: "zig-supports-rvv" }
|
|
936
|
+
* — Zig >= MIN_ZIG_RVV_VERSION. RVV + Zfh + Zvfh + Zicbop + Zihintpause
|
|
937
|
+
* ON (the upstream llama.cpp defaults). Resulting libggml-cpu.so requires
|
|
938
|
+
* RVV-capable hardware at runtime; SIGILLs on a scalar core.
|
|
939
|
+
*
|
|
940
|
+
* { rvv: true, allVariants: true, zigVersion, reason: "all-variants-opt-in" }
|
|
941
|
+
* — Zig >= MIN_ZIG_RVV_VERSION AND env ELIZA_GGML_CPU_ALL_VARIANTS=1.
|
|
942
|
+
* Builds GGML_BACKEND_DL + GGML_CPU_ALL_VARIANTS so two
|
|
943
|
+
* libggml-cpu-riscv64_{0,v}.so variants ship; runtime picks via
|
|
944
|
+
* riscv_hwprobe (`ggml-cpu/arch/riscv/cpu-feats.cpp`). Opt-in until the
|
|
945
|
+
* Android loader story for the DL-backend dispatch is verified end-to-end
|
|
946
|
+
* across arm64/x86_64 — flipping that on by default would change the
|
|
947
|
+
* artifact list for non-riscv64 ABIs too.
|
|
948
|
+
*
|
|
949
|
+
* { rvv: false, allVariants: false, zigVersion: null, reason: "zig-not-detected" }
|
|
950
|
+
* — Probe failed (used in dry-run mode where zig may legitimately not be
|
|
951
|
+
* on PATH). Falls back to scalar so the dry-run plan reflects the
|
|
952
|
+
* conservative default.
|
|
953
|
+
*
|
|
954
|
+
* Exported for tests.
|
|
955
|
+
*/
|
|
956
|
+
export function resolveRiscv64BuildPlan({
|
|
957
|
+
zigVersion = null,
|
|
958
|
+
probe = probeZig,
|
|
959
|
+
env = process.env,
|
|
960
|
+
isDryRun = false,
|
|
961
|
+
} = {}) {
|
|
962
|
+
let version = zigVersion;
|
|
963
|
+
if (version === null) {
|
|
964
|
+
if (isDryRun) {
|
|
965
|
+
try {
|
|
966
|
+
version = probe();
|
|
967
|
+
} catch {
|
|
968
|
+
return {
|
|
969
|
+
rvv: false,
|
|
970
|
+
allVariants: false,
|
|
971
|
+
zigVersion: null,
|
|
972
|
+
reason: "zig-not-detected",
|
|
973
|
+
};
|
|
974
|
+
}
|
|
975
|
+
} else {
|
|
976
|
+
version = probe();
|
|
977
|
+
}
|
|
978
|
+
}
|
|
979
|
+
if (compareSemver(version, MIN_ZIG_RVV_VERSION) < 0) {
|
|
980
|
+
return {
|
|
981
|
+
rvv: false,
|
|
982
|
+
allVariants: false,
|
|
983
|
+
zigVersion: version,
|
|
984
|
+
reason: "zig-too-old",
|
|
985
|
+
};
|
|
986
|
+
}
|
|
987
|
+
const allVariantsOptIn = env.ELIZA_GGML_CPU_ALL_VARIANTS === "1";
|
|
988
|
+
return {
|
|
989
|
+
rvv: true,
|
|
990
|
+
allVariants: allVariantsOptIn,
|
|
991
|
+
zigVersion: version,
|
|
992
|
+
reason: allVariantsOptIn ? "all-variants-opt-in" : "zig-supports-rvv",
|
|
993
|
+
};
|
|
994
|
+
}
|
|
995
|
+
|
|
996
|
+
/**
|
|
997
|
+
* Map a riscv64 build plan to the cmake -D flags that select the right
|
|
998
|
+
* GGML_RVV / GGML_RV_ZFH / etc. combination. Returns an empty array for
|
|
999
|
+
* non-riscv64 ABIs.
|
|
1000
|
+
*
|
|
1001
|
+
* Exported for tests.
|
|
1002
|
+
*/
|
|
1003
|
+
export function riscv64CmakeFlagsForPlan({ abi, plan }) {
|
|
1004
|
+
if (abi !== "riscv64") return [];
|
|
1005
|
+
if (plan.rvv === false) {
|
|
1006
|
+
return [
|
|
1007
|
+
"-DGGML_RVV=OFF",
|
|
1008
|
+
"-DGGML_RV_ZFH=OFF",
|
|
1009
|
+
"-DGGML_RV_ZVFH=OFF",
|
|
1010
|
+
"-DGGML_RV_ZICBOP=OFF",
|
|
1011
|
+
"-DGGML_RV_ZIHINTPAUSE=OFF",
|
|
1012
|
+
"-DGGML_RV_ZVFBFWMA=OFF",
|
|
1013
|
+
"-DGGML_XTHEADVECTOR=OFF",
|
|
1014
|
+
"-DGGML_RV_ZBA=OFF",
|
|
1015
|
+
"-DGGML_CPU_RISCV64_SPACEMIT=OFF",
|
|
1016
|
+
];
|
|
1017
|
+
}
|
|
1018
|
+
// RVV-on. Leave the vendored llama.cpp defaults (ON) for RVV / Zfh / Zvfh /
|
|
1019
|
+
// Zicbop / Zihintpause. Keep Zvfbfwma / XTheadVector / Zba / SpaceMit off
|
|
1020
|
+
// unless explicitly opted in — they're hardware-specific extensions that
|
|
1021
|
+
// SIGILL on generic RVV cores.
|
|
1022
|
+
const flags = [
|
|
1023
|
+
"-DGGML_RVV=ON",
|
|
1024
|
+
"-DGGML_RV_ZFH=ON",
|
|
1025
|
+
"-DGGML_RV_ZVFH=ON",
|
|
1026
|
+
"-DGGML_RV_ZICBOP=ON",
|
|
1027
|
+
"-DGGML_RV_ZIHINTPAUSE=ON",
|
|
1028
|
+
"-DGGML_RV_ZVFBFWMA=OFF",
|
|
1029
|
+
"-DGGML_XTHEADVECTOR=OFF",
|
|
1030
|
+
"-DGGML_RV_ZBA=OFF",
|
|
1031
|
+
"-DGGML_CPU_RISCV64_SPACEMIT=OFF",
|
|
1032
|
+
];
|
|
1033
|
+
if (plan.allVariants) {
|
|
1034
|
+
// GGML_CPU_ALL_VARIANTS implies GGML_BACKEND_DL and builds per-variant
|
|
1035
|
+
// libggml-cpu-riscv64_{0,v}.so; the loader picks via riscv_hwprobe.
|
|
1036
|
+
// GGML_NATIVE is incompatible with GGML_BACKEND_DL in this mode (see
|
|
1037
|
+
// ggml/src/ggml-cpu/CMakeLists.txt:491-494), so the existing
|
|
1038
|
+
// `-DGGML_NATIVE=OFF` we pass must stay OFF (it does).
|
|
1039
|
+
flags.push("-DGGML_BACKEND_DL=ON", "-DGGML_CPU_ALL_VARIANTS=ON");
|
|
1040
|
+
}
|
|
1041
|
+
return flags;
|
|
1042
|
+
}
|
|
1043
|
+
|
|
357
1044
|
function run(command, args, { cwd, env = process.env } = {}) {
|
|
358
1045
|
const result = spawnSync(command, args, {
|
|
359
1046
|
cwd,
|
|
@@ -397,6 +1084,7 @@ export function ensureLlamaCppCheckout({
|
|
|
397
1084
|
log(`[compile-libllama] Reusing cached llama.cpp checkout at ${cacheDir}`);
|
|
398
1085
|
patchLlamaCppSourceForMusl({ srcDir: cacheDir, log });
|
|
399
1086
|
applyVendoredPatches({ srcDir: cacheDir, log });
|
|
1087
|
+
assertSwaSpecDecodeFallback({ srcDir: cacheDir });
|
|
400
1088
|
return cacheDir;
|
|
401
1089
|
}
|
|
402
1090
|
if (!fs.existsSync(path.join(cacheDir, ".git"))) {
|
|
@@ -424,6 +1112,16 @@ export function ensureLlamaCppCheckout({
|
|
|
424
1112
|
cwd: cacheDir,
|
|
425
1113
|
});
|
|
426
1114
|
}
|
|
1115
|
+
// The pinned commit is authoritative and may NOT be the tag tip — the moving
|
|
1116
|
+
// LLAMA_CPP_TAG and LLAMA_CPP_COMMIT can diverge (e.g. the commit lives on a
|
|
1117
|
+
// feature branch while the tag was re-pointed at a release). A
|
|
1118
|
+
// `--branch <tag>` shallow clone only carries the tag's commit, so a bare
|
|
1119
|
+
// `git checkout <commit>` then fails with "unable to read tree". Fetch the
|
|
1120
|
+
// exact pinned commit by sha first (GitHub serves any ref-reachable sha) so
|
|
1121
|
+
// the working tree always lands on LLAMA_CPP_COMMIT, never the tag.
|
|
1122
|
+
spawn("git", ["fetch", "--depth", "1", "origin", LLAMA_CPP_COMMIT], {
|
|
1123
|
+
cwd: cacheDir,
|
|
1124
|
+
});
|
|
427
1125
|
spawn("git", ["checkout", "--detach", LLAMA_CPP_COMMIT], {
|
|
428
1126
|
cwd: cacheDir,
|
|
429
1127
|
});
|
|
@@ -441,7 +1139,7 @@ export function ensureLlamaCppCheckout({
|
|
|
441
1139
|
* and across partial-failure re-runs.
|
|
442
1140
|
*
|
|
443
1141
|
* Patches under `llama-cpp-patches/qjl/` add `GGML_TYPE_QJL1_256` (=46),
|
|
444
|
-
* the QJL kernel sources vendored from `packages/native
|
|
1142
|
+
* the QJL kernel sources vendored from `packages/native/plugins/qjl-cpu/`,
|
|
445
1143
|
* the type-traits + op-dispatch wiring, and the `tests/test-qjl-cache.cpp`
|
|
446
1144
|
* synthetic-graph test.
|
|
447
1145
|
*
|
|
@@ -449,7 +1147,7 @@ export function ensureLlamaCppCheckout({
|
|
|
449
1147
|
* `polarquant` series under the same directory exists but conflicts with
|
|
450
1148
|
* `qjl` over the GGML_TYPE_COUNT tag (PolarQuant claims id 45, QJL
|
|
451
1149
|
* claims 46) and is owned by a separate landing. When that series is
|
|
452
|
-
*
|
|
1150
|
+
* merged with QJL, append it here.
|
|
453
1151
|
*
|
|
454
1152
|
* Order is:
|
|
455
1153
|
* 1. checkout -> 2. patchLlamaCppSourceForMusl -> 3. applyVendoredPatches.
|
|
@@ -478,6 +1176,30 @@ export function applyVendoredPatches({
|
|
|
478
1176
|
spawn("node", [applierPath, "--repo", srcDir, "--series", "qjl"], {});
|
|
479
1177
|
}
|
|
480
1178
|
|
|
1179
|
+
function sourceContainsSwaSpecDecodeFallback(srcDir) {
|
|
1180
|
+
const serverContextPath = path.join(
|
|
1181
|
+
srcDir,
|
|
1182
|
+
"tools",
|
|
1183
|
+
"server",
|
|
1184
|
+
"server-context.cpp",
|
|
1185
|
+
);
|
|
1186
|
+
if (!fs.existsSync(serverContextPath)) return false;
|
|
1187
|
+
const source = fs.readFileSync(serverContextPath, "utf8");
|
|
1188
|
+
return (
|
|
1189
|
+
source.includes("seq_rm probe failed but model declares SWA") &&
|
|
1190
|
+
source.includes("llama_model_n_swa(model_tgt) > 0") &&
|
|
1191
|
+
source.includes("ctx_tgt_seq_rm_type = COMMON_CONTEXT_SEQ_RM_TYPE_FULL")
|
|
1192
|
+
);
|
|
1193
|
+
}
|
|
1194
|
+
|
|
1195
|
+
function assertSwaSpecDecodeFallback({ srcDir }) {
|
|
1196
|
+
if (sourceContainsSwaSpecDecodeFallback(srcDir)) return;
|
|
1197
|
+
throw new Error(
|
|
1198
|
+
`[compile-libllama] checkout ${srcDir} lacks the SWA-aware seq_rm fallback ` +
|
|
1199
|
+
`required for --spec-type mtp on SWA target bodies (elizaOS/eliza#7635).`,
|
|
1200
|
+
);
|
|
1201
|
+
}
|
|
1202
|
+
|
|
481
1203
|
/**
|
|
482
1204
|
* Ensure `ggml/src/ggml.c` has the `<execinfo.h>` include gated on
|
|
483
1205
|
* `__GLIBC__`. musl libc does not ship `execinfo.h`, so a bare `__linux__`
|
|
@@ -598,7 +1320,12 @@ export function patchLlamaCppSourceForMusl({ srcDir, log = console.log }) {
|
|
|
598
1320
|
*
|
|
599
1321
|
* Exported for unit testing.
|
|
600
1322
|
*/
|
|
601
|
-
export function ensureZigDrivers({
|
|
1323
|
+
export function ensureZigDrivers({
|
|
1324
|
+
cacheDir,
|
|
1325
|
+
abi,
|
|
1326
|
+
zigBin = "zig",
|
|
1327
|
+
riscv64MarchPassthrough = false,
|
|
1328
|
+
}) {
|
|
602
1329
|
const target = ABI_TARGETS.find((t) => t.androidAbi === abi);
|
|
603
1330
|
if (!target) {
|
|
604
1331
|
throw new Error(`[compile-libllama] Unknown ABI: ${abi}`);
|
|
@@ -607,18 +1334,99 @@ export function ensureZigDrivers({ cacheDir, abi, zigBin = "zig" }) {
|
|
|
607
1334
|
fs.mkdirSync(driverDir, { recursive: true });
|
|
608
1335
|
const ccPath = path.join(driverDir, "zig-cc");
|
|
609
1336
|
const cxxPath = path.join(driverDir, "zig-cxx");
|
|
1337
|
+
|
|
1338
|
+
// riscv64 needs an extra arg-filtering step on Zig 0.13. The vendored
|
|
1339
|
+
// llama.cpp's ggml-cpu CMakeLists hardcodes `-march=rv64gc -mabi=lp64d`
|
|
1340
|
+
// (and adds extension suffixes when GGML_RVV / GGML_RV_ZFH / etc. are ON).
|
|
1341
|
+
// Zig 0.13's bundled LLVM doesn't accept `-march=rv64gc` as a GCC-style
|
|
1342
|
+
// ISA string — it tries to translate it to `-mcpu=` and bails with
|
|
1343
|
+
// "unknown CPU: 'rv64gc'". The triple `riscv64-linux-musl` already
|
|
1344
|
+
// selects the rv64gc/lp64d baseline as Zig's triple-derived CPU, so
|
|
1345
|
+
// stripping these flags is byte-for-byte equivalent to the intended
|
|
1346
|
+
// build when RVV is OFF.
|
|
1347
|
+
//
|
|
1348
|
+
// On Zig 0.14+ (`riscv64MarchPassthrough=true`) we leave every
|
|
1349
|
+
// `-march=` / `-mabi=` flag alone: Zig 0.14's LLVM accepts the
|
|
1350
|
+
// GCC-style ISA string with the full `_zfh_zvfh_zicbop_zihintpause`
|
|
1351
|
+
// extension suffix, which is exactly what flips the RVV intrinsic
|
|
1352
|
+
// codepaths on in ggml/src/ggml-cpu/arch/riscv/quants.c.
|
|
1353
|
+
//
|
|
1354
|
+
// Filter logic: walk the argv via the POSIX `set --` idiom (no eval —
|
|
1355
|
+
// CMake escapes embedded quotes in -DGGML_VERSION=\"0.12.0\", and a
|
|
1356
|
+
// naive `eval exec "..."` collapses them and the C preprocessor sees
|
|
1357
|
+
// `0.12.0` as a malformed numeric literal). Each non-stripped arg is
|
|
1358
|
+
// re-pushed onto $@ in place; the final `exec "$zig" cc ... "$@"`
|
|
1359
|
+
// forwards the whole array with every quote and space preserved.
|
|
1360
|
+
const riscv64ArgFilter =
|
|
1361
|
+
abi === "riscv64" && !riscv64MarchPassthrough
|
|
1362
|
+
? "_n=$#\n" +
|
|
1363
|
+
"i=0\n" +
|
|
1364
|
+
"while [ $i -lt $_n ]; do\n" +
|
|
1365
|
+
" arg=$1\n" +
|
|
1366
|
+
" shift\n" +
|
|
1367
|
+
" i=$((i+1))\n" +
|
|
1368
|
+
' case "$arg" in\n' +
|
|
1369
|
+
" -march=rv64gc|-march=rv64gc_*) ;;\n" +
|
|
1370
|
+
" -mabi=lp64d|-mabi=lp64) ;;\n" +
|
|
1371
|
+
' *) set -- "$@" "$arg" ;;\n' +
|
|
1372
|
+
" esac\n" +
|
|
1373
|
+
"done\n"
|
|
1374
|
+
: null;
|
|
1375
|
+
|
|
1376
|
+
// arm64: the ggml-cpu CMakeLists emits the GCC-style ISA string
|
|
1377
|
+
// `-march=armv8.2-a+dotprod+fp16+i8mm` (from GGML_CPU_ARM_ARCH). Zig 0.13's
|
|
1378
|
+
// bundled LLVM rejects that for the aarch64 target — it tries to translate
|
|
1379
|
+
// `armv8.2-a` to a `-mcpu=` value and dies with "unknown CPU: 'armv8.2'"
|
|
1380
|
+
// (the same class of breakage the riscv64 filter handles). Zig instead
|
|
1381
|
+
// speaks `-mcpu=<cpu>+<feature>` with its OWN feature names. Rewrite the
|
|
1382
|
+
// GCC `-march=armv8.x-a+...` into the equivalent zig `-mcpu=generic+...`:
|
|
1383
|
+
// dotprod→dotprod, i8mm→i8mm, fp16→fullfp16. This sets exactly the same
|
|
1384
|
+
// __ARM_FEATURE_DOTPROD / __ARM_FEATURE_MATMUL_INT8 /
|
|
1385
|
+
// __ARM_FEATURE_FP16_VECTOR_ARITHMETIC macros (verified), so the live QJL
|
|
1386
|
+
// NEON-dotprod / i8mm / fp16 kernel bodies survive preprocessing and the
|
|
1387
|
+
// ggml ARM-feature configure probes pass. Any other `-march=` is passed
|
|
1388
|
+
// through untouched (there shouldn't be one for arm64).
|
|
1389
|
+
const arm64ArgFilter =
|
|
1390
|
+
abi === "arm64-v8a"
|
|
1391
|
+
? "_n=$#\n" +
|
|
1392
|
+
"i=0\n" +
|
|
1393
|
+
"while [ $i -lt $_n ]; do\n" +
|
|
1394
|
+
" arg=$1\n" +
|
|
1395
|
+
" shift\n" +
|
|
1396
|
+
" i=$((i+1))\n" +
|
|
1397
|
+
' case "$arg" in\n' +
|
|
1398
|
+
" -march=armv8.*-a+*)\n" +
|
|
1399
|
+
' _feats=""\n' +
|
|
1400
|
+
` case "$arg" in *+dotprod*) _feats="\${_feats}+dotprod" ;; esac\n` +
|
|
1401
|
+
` case "$arg" in *+i8mm*) _feats="\${_feats}+i8mm" ;; esac\n` +
|
|
1402
|
+
` case "$arg" in *+fp16*) _feats="\${_feats}+fullfp16" ;; esac\n` +
|
|
1403
|
+
` set -- "$@" "-mcpu=generic\${_feats}" ;;\n` +
|
|
1404
|
+
' *) set -- "$@" "$arg" ;;\n' +
|
|
1405
|
+
" esac\n" +
|
|
1406
|
+
"done\n"
|
|
1407
|
+
: null;
|
|
1408
|
+
|
|
1409
|
+
const argFilter = riscv64ArgFilter ?? arm64ArgFilter;
|
|
1410
|
+
const exec =
|
|
1411
|
+
argFilter !== null
|
|
1412
|
+
? (subcmd) =>
|
|
1413
|
+
argFilter +
|
|
1414
|
+
`exec "${zigBin}" ${subcmd} --target=${target.zigTarget} "$@"\n`
|
|
1415
|
+
: (subcmd) =>
|
|
1416
|
+
`exec "${zigBin}" ${subcmd} --target=${target.zigTarget} "$@"\n`;
|
|
1417
|
+
|
|
610
1418
|
// Quote zigBin so a path with spaces still works. The driver runs under
|
|
611
1419
|
// /bin/sh which is POSIX-portable across Linux, macOS, Alpine.
|
|
612
1420
|
const ccBody =
|
|
613
1421
|
"#!/bin/sh\n" +
|
|
614
1422
|
"# Auto-generated by eliza/packages/app-core/scripts/aosp/compile-libllama.mjs.\n" +
|
|
615
1423
|
"# Do not edit — regenerated on every build.\n" +
|
|
616
|
-
|
|
1424
|
+
exec("cc");
|
|
617
1425
|
const cxxBody =
|
|
618
1426
|
"#!/bin/sh\n" +
|
|
619
1427
|
"# Auto-generated by eliza/packages/app-core/scripts/aosp/compile-libllama.mjs.\n" +
|
|
620
1428
|
"# Do not edit — regenerated on every build.\n" +
|
|
621
|
-
|
|
1429
|
+
exec("c++");
|
|
622
1430
|
fs.writeFileSync(ccPath, ccBody, "utf8");
|
|
623
1431
|
fs.writeFileSync(cxxPath, cxxBody, "utf8");
|
|
624
1432
|
fs.chmodSync(ccPath, 0o755);
|
|
@@ -653,6 +1461,12 @@ export function buildLibllamaForAbi({
|
|
|
653
1461
|
zigBin = "zig",
|
|
654
1462
|
log = console.log,
|
|
655
1463
|
spawn = run,
|
|
1464
|
+
// Optional pass-through hooks used by the explicit-triple path
|
|
1465
|
+
// (`mainTargets`) to layer in the fused omnivoice flags + targets without
|
|
1466
|
+
// forking this helper. The non-fused bulk --abi path defaults both to
|
|
1467
|
+
// empty so its behavior stays byte-for-byte identical.
|
|
1468
|
+
extraCmakeFlags = [],
|
|
1469
|
+
extraBuildTargets = [],
|
|
656
1470
|
}) {
|
|
657
1471
|
const target = ABI_TARGETS.find((t) => t.androidAbi === abi);
|
|
658
1472
|
if (!target) {
|
|
@@ -661,10 +1475,87 @@ export function buildLibllamaForAbi({
|
|
|
661
1475
|
const buildDir = path.join(srcDir, `build-${abi}`);
|
|
662
1476
|
fs.mkdirSync(buildDir, { recursive: true });
|
|
663
1477
|
|
|
1478
|
+
// riscv64: gate the RVV-on path on the detected Zig version. The vendored
|
|
1479
|
+
// llama.cpp defaults GGML_RVV / GGML_RV_ZFH / GGML_RV_ZVFH / GGML_RV_ZICBOP
|
|
1480
|
+
// / GGML_RV_ZIHINTPAUSE to ON, which builds the `-march=rv64gcv_zfh_zvfh_
|
|
1481
|
+
// zicbop_zihintpause` ISA string. Zig 0.13's bundled LLVM doesn't accept
|
|
1482
|
+
// that as a -march value (it tries to translate it to -mcpu= and fails
|
|
1483
|
+
// with "unknown CPU"); Zig 0.14+ does. resolveRiscv64BuildPlan() reads the
|
|
1484
|
+
// probed version and tells us which lane to take:
|
|
1485
|
+
// - rvv=false (Zig < 0.14) -> scalar parity. Force every RVV / Zfh /
|
|
1486
|
+
// Zvfh / Zicbop / Zihintpause / Zvfbfwma / XTheadVector option OFF so
|
|
1487
|
+
// MARCH_STR collapses to plain `rv64gc`. The driver-script argv
|
|
1488
|
+
// filter then strips `-march=rv64gc -mabi=lp64d` (Zig already implies
|
|
1489
|
+
// them via the triple).
|
|
1490
|
+
// - rvv=true (Zig >= 0.14) -> upstream defaults. The full
|
|
1491
|
+
// `-march=rv64gcv_zfh_zvfh_zicbop_zihintpause -mabi=lp64d` string
|
|
1492
|
+
// passes straight through to Zig 0.14's LLVM; quants.c's intrinsic
|
|
1493
|
+
// codepaths light up.
|
|
1494
|
+
// - allVariants (env ELIZA_GGML_CPU_ALL_VARIANTS=1) -> additionally
|
|
1495
|
+
// enable GGML_BACKEND_DL + GGML_CPU_ALL_VARIANTS so the build emits
|
|
1496
|
+
// libggml-cpu-riscv64_{0,v}.so siblings and the loader picks via
|
|
1497
|
+
// riscv_hwprobe at runtime. Opt-in until the Android DL-loader
|
|
1498
|
+
// plumbing for arm64/x86_64 is also verified.
|
|
1499
|
+
const riscv64Plan =
|
|
1500
|
+
abi === "riscv64"
|
|
1501
|
+
? resolveRiscv64BuildPlan({ env: process.env })
|
|
1502
|
+
: { rvv: false, allVariants: false, zigVersion: null, reason: "n/a" };
|
|
1503
|
+
if (abi === "riscv64") {
|
|
1504
|
+
log(
|
|
1505
|
+
`[compile-libllama] riscv64 plan: zig=${riscv64Plan.zigVersion ?? "unknown"} ` +
|
|
1506
|
+
`rvv=${riscv64Plan.rvv ? "ON" : "OFF"} ` +
|
|
1507
|
+
`all-variants=${riscv64Plan.allVariants ? "ON" : "OFF"} ` +
|
|
1508
|
+
`reason=${riscv64Plan.reason}`,
|
|
1509
|
+
);
|
|
1510
|
+
}
|
|
1511
|
+
const riscv64BuildFlags = riscv64CmakeFlagsForPlan({
|
|
1512
|
+
abi,
|
|
1513
|
+
plan: riscv64Plan,
|
|
1514
|
+
});
|
|
1515
|
+
|
|
1516
|
+
// x86_64: the mobile x86_64 ABI only ever runs on cuttlefish / the Android
|
|
1517
|
+
// x86_64 emulator (both KVM-backed by an AVX2-class host, and our emulator
|
|
1518
|
+
// recipe boots with `-cpu host`). GGML_NATIVE=OFF leaves the build at the
|
|
1519
|
+
// baseline x86_64 ISA, which has two problems: (1) ggml's own AVX2 kernels
|
|
1520
|
+
// stay off, and (2) — fatal — the vendored QJL kernels gate their AVX2
|
|
1521
|
+
// implementations on `__AVX2__` while `qjl_dispatch.c` references
|
|
1522
|
+
// `qjl_quantize_rows_avx2` (and the score/projection AVX2 entry points)
|
|
1523
|
+
// unconditionally, so a baseline build links with an UNDEFINED symbol and
|
|
1524
|
+
// `dlopen(libllama.so)` fails at runtime with
|
|
1525
|
+
// `Error relocating libggml-cpu.so.0: qjl_quantize_rows_avx2: symbol not
|
|
1526
|
+
// found`. Turning on the standard ggml AVX2/FMA/F16C/AVX feature flags
|
|
1527
|
+
// defines `__AVX2__` for the ggml-cpu translation units (QJL included) so
|
|
1528
|
+
// those entry points are actually compiled. Runtime CPU dispatch still picks
|
|
1529
|
+
// scalar vs AVX2 per-call, but the symbols now exist.
|
|
1530
|
+
const x86_64BuildFlags =
|
|
1531
|
+
abi === "x86_64"
|
|
1532
|
+
? ["-DGGML_AVX=ON", "-DGGML_AVX2=ON", "-DGGML_FMA=ON", "-DGGML_F16C=ON"]
|
|
1533
|
+
: [];
|
|
1534
|
+
|
|
1535
|
+
// arm64-v8a: GGML_NATIVE=OFF leaves the cross-build at the bare armv8-a
|
|
1536
|
+
// baseline, which keeps ggml's dotprod/i8mm/fp16 NEON kernels AND the eliza
|
|
1537
|
+
// QJL NEON-dotprod kernel dead. Pin the armv8.2-a+dotprod+fp16+i8mm floor and
|
|
1538
|
+
// flip the QJL dispatch define so the Pixel-class Tensor G4 actually runs the
|
|
1539
|
+
// accelerated paths. See build-helpers/arm64-simd.mjs for the full rationale.
|
|
1540
|
+
const arm64BuildFlags = androidArm64SimdCmakeFlags(abi);
|
|
1541
|
+
if (arm64BuildFlags.length > 0) {
|
|
1542
|
+
log(
|
|
1543
|
+
`[compile-libllama] arm64 SIMD floor: ${arm64BuildFlags.join(" ")} ` +
|
|
1544
|
+
`(dotprod/i8mm/fp16 + QJL NEON-dotprod dispatch)`,
|
|
1545
|
+
);
|
|
1546
|
+
}
|
|
1547
|
+
|
|
664
1548
|
// Per-ABI driver scripts that wrap `zig cc --target=<triple>` so cmake's
|
|
665
1549
|
// single-binary compiler probe works. See ensureZigDrivers() for why
|
|
666
|
-
// passing `--target=` via CMAKE_C_FLAGS doesn't work on its own.
|
|
667
|
-
|
|
1550
|
+
// passing `--target=` via CMAKE_C_FLAGS doesn't work on its own. When
|
|
1551
|
+
// RVV is on, the riscv64 driver passes `-march=rv64gc*` through to Zig
|
|
1552
|
+
// 0.14+ instead of filtering it out.
|
|
1553
|
+
const { ccPath, cxxPath } = ensureZigDrivers({
|
|
1554
|
+
cacheDir,
|
|
1555
|
+
abi,
|
|
1556
|
+
zigBin,
|
|
1557
|
+
riscv64MarchPassthrough: riscv64Plan.rvv,
|
|
1558
|
+
});
|
|
668
1559
|
|
|
669
1560
|
log(
|
|
670
1561
|
`[compile-libllama] Configuring llama.cpp for ${abi} (${target.zigTarget}) in ${buildDir}`,
|
|
@@ -680,9 +1571,10 @@ export function buildLibllamaForAbi({
|
|
|
680
1571
|
"-DBUILD_SHARED_LIBS=ON",
|
|
681
1572
|
"-DLLAMA_BUILD_EXAMPLES=OFF",
|
|
682
1573
|
"-DLLAMA_BUILD_TESTS=OFF",
|
|
683
|
-
// llama-server is required for the AOSP
|
|
684
|
-
// (target + drafter share one process;
|
|
685
|
-
// binary and routes inference over the
|
|
1574
|
+
// llama-server is required for the AOSP MTP speculative-decode path
|
|
1575
|
+
// (target + drafter share one process; the AOSP local-inference
|
|
1576
|
+
// bootstrap spawns this binary and routes inference over the
|
|
1577
|
+
// OpenAI-compatible HTTP API). The
|
|
686
1578
|
// server target also pulls in the JSON/HTTP common-lib pieces, but adds
|
|
687
1579
|
// ~1.5 MB stripped per ABI; small price relative to the spec-decode
|
|
688
1580
|
// throughput win.
|
|
@@ -699,6 +1591,9 @@ export function buildLibllamaForAbi({
|
|
|
699
1591
|
// device of the target ABI. The default tunes for the build host's
|
|
700
1592
|
// native cpu, which is wrong for a cross-build.
|
|
701
1593
|
"-DGGML_NATIVE=OFF",
|
|
1594
|
+
...riscv64BuildFlags,
|
|
1595
|
+
...x86_64BuildFlags,
|
|
1596
|
+
...arm64BuildFlags,
|
|
702
1597
|
// Don't bake in an absolute RUNPATH to the build tree. The default
|
|
703
1598
|
// CMAKE_BUILD_RPATH points at the per-ABI build dir, which is a
|
|
704
1599
|
// path-leak in shipped APKs and adds dead lookup entries at runtime.
|
|
@@ -709,6 +1604,11 @@ export function buildLibllamaForAbi({
|
|
|
709
1604
|
"-DCMAKE_SKIP_INSTALL_RPATH=TRUE",
|
|
710
1605
|
"-DCMAKE_BUILD_WITH_INSTALL_RPATH=TRUE",
|
|
711
1606
|
"-DCMAKE_INSTALL_RPATH=",
|
|
1607
|
+
// `extraCmakeFlags` carries the omnivoice fused-build flags
|
|
1608
|
+
// (-DELIZA_FUSE_OMNIVOICE=ON, etc.) when the explicit-triple
|
|
1609
|
+
// path asked for a fused build. Empty for the non-fused bulk
|
|
1610
|
+
// --abi path.
|
|
1611
|
+
...extraCmakeFlags,
|
|
712
1612
|
],
|
|
713
1613
|
{},
|
|
714
1614
|
);
|
|
@@ -720,17 +1620,99 @@ export function buildLibllamaForAbi({
|
|
|
720
1620
|
{},
|
|
721
1621
|
);
|
|
722
1622
|
|
|
1623
|
+
// Build any extra cmake targets the caller asked for — for fused builds
|
|
1624
|
+
// this is omnivoice-core + libelizainference + llama-omnivoice-server +
|
|
1625
|
+
// the bench/completion drivers (see fusedCmakeBuildTargets()). We filter
|
|
1626
|
+
// out `llama` + `llama-server` upstream (the dedicated build steps below
|
|
1627
|
+
// already handle those), so the extra-target invocation only adds NEW
|
|
1628
|
+
// CMake target names. The non-fused path passes an empty list.
|
|
1629
|
+
//
|
|
1630
|
+
// Targets are filtered against what the configured build tree actually
|
|
1631
|
+
// exposes. The eliza llama.cpp fork's target set drifts from the script's
|
|
1632
|
+
// pinned expectations — e.g. `llama-speculative-simple` is an upstream
|
|
1633
|
+
// example the fork drops in favour of MTP spec-decode. A
|
|
1634
|
+
// requested-but-absent *auxiliary* target must not abort the whole
|
|
1635
|
+
// libllama build: the libllama.so + libggml*.so family is the critical
|
|
1636
|
+
// output and is fully built by the `llama` target above. We warn on the
|
|
1637
|
+
// gap and continue. A target that *exists* but fails to build still
|
|
1638
|
+
// hard-errors via `spawn()`.
|
|
1639
|
+
if (extraBuildTargets.length > 0) {
|
|
1640
|
+
const helpProbe = spawnSync(
|
|
1641
|
+
"cmake",
|
|
1642
|
+
["--build", buildDir, "--target", "help"],
|
|
1643
|
+
{ encoding: "utf8" },
|
|
1644
|
+
);
|
|
1645
|
+
const availableTargets = new Set(
|
|
1646
|
+
(helpProbe.stdout || "")
|
|
1647
|
+
.split("\n")
|
|
1648
|
+
.map((line) => line.replace(/^\.\.\.\s*/, "").trim())
|
|
1649
|
+
.filter(Boolean),
|
|
1650
|
+
);
|
|
1651
|
+
for (const extraTarget of extraBuildTargets) {
|
|
1652
|
+
if (availableTargets.size > 0 && !availableTargets.has(extraTarget)) {
|
|
1653
|
+
log(
|
|
1654
|
+
`[compile-libllama] Skipping extra cmake target ${extraTarget} for ${abi} — ` +
|
|
1655
|
+
`not defined in this llama.cpp checkout (auxiliary target; libllama.so is unaffected).`,
|
|
1656
|
+
);
|
|
1657
|
+
continue;
|
|
1658
|
+
}
|
|
1659
|
+
log(
|
|
1660
|
+
`[compile-libllama] Building extra cmake target ${extraTarget} for ${abi}`,
|
|
1661
|
+
);
|
|
1662
|
+
try {
|
|
1663
|
+
spawn(
|
|
1664
|
+
"cmake",
|
|
1665
|
+
["--build", buildDir, "--target", extraTarget, "-j", String(jobs)],
|
|
1666
|
+
{},
|
|
1667
|
+
);
|
|
1668
|
+
} catch (err) {
|
|
1669
|
+
// The fused libelizainference.so (`elizainference` target) is the only
|
|
1670
|
+
// extra target the APK actually bundles, and `verifyFusedSymbols`
|
|
1671
|
+
// enforces it after this loop — so it stays fatal. The rest are
|
|
1672
|
+
// standalone CLI drivers (omnivoice-tts / omnivoice-codec / llama-cli /
|
|
1673
|
+
// llama-bench / llama-completion / llama-mtmd-cli) that ship nothing
|
|
1674
|
+
// into the APK. The pinned fork's `omnivoice-tts.cpp` currently calls a
|
|
1675
|
+
// removed `backend_init("LM")` overload (backend.h only exposes
|
|
1676
|
+
// `backend_init_auto()`), so that driver fails to compile while
|
|
1677
|
+
// libelizainference.so builds fine. Don't let a broken auxiliary CLI
|
|
1678
|
+
// abort the build that produces the lib we need; warn and continue.
|
|
1679
|
+
if (CRITICAL_EXTRA_TARGETS.has(extraTarget)) throw err;
|
|
1680
|
+
log(
|
|
1681
|
+
`[compile-libllama] WARN: auxiliary cmake target ${extraTarget} failed to build for ${abi}; ` +
|
|
1682
|
+
`continuing — it bundles nothing into the APK and libllama.so/libelizainference.so are unaffected. ` +
|
|
1683
|
+
`Cause: ${err instanceof Error ? err.message : String(err)}`,
|
|
1684
|
+
);
|
|
1685
|
+
}
|
|
1686
|
+
}
|
|
1687
|
+
}
|
|
1688
|
+
|
|
723
1689
|
// llama-server target. Built in a second --target invocation so a future
|
|
724
1690
|
// operator can disable it via a flag without touching the libllama target.
|
|
725
1691
|
// The target name is `llama-server` on the apothic fork (verified against
|
|
726
1692
|
// the upstream b8198 examples/server/CMakeLists.txt: `add_executable(
|
|
727
1693
|
// ${TARGET} server.cpp ...)` with `set(TARGET llama-server)`).
|
|
1694
|
+
//
|
|
1695
|
+
// Non-fatal for the library build: llama-server is the optional AOSP
|
|
1696
|
+
// MTP/spec-decode HTTP path, but the required in-process libs below
|
|
1697
|
+
// (libllama.so/libggml*.so and, for fused targets, libelizainference.so) are
|
|
1698
|
+
// verified separately. On the musl cross-link this target can fail to resolve
|
|
1699
|
+
// its httplib/OpenSSL deps (undefined `httplib::*` / `SSLClient` symbols).
|
|
1700
|
+
// In that case stage-android-agent warns about the missing server and runtime
|
|
1701
|
+
// falls back to the non-MTP path instead of losing the whole native build.
|
|
728
1702
|
log(`[compile-libllama] Compiling llama-server for ${abi} with -j${jobs}`);
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
1703
|
+
try {
|
|
1704
|
+
spawn(
|
|
1705
|
+
"cmake",
|
|
1706
|
+
["--build", buildDir, "--target", "llama-server", "-j", String(jobs)],
|
|
1707
|
+
{},
|
|
1708
|
+
);
|
|
1709
|
+
} catch (err) {
|
|
1710
|
+
log(
|
|
1711
|
+
`[compile-libllama] WARN: llama-server failed to build for ${abi}; ` +
|
|
1712
|
+
`continuing — it bundles nothing into the APK and libllama.so/libelizainference.so are unaffected. ` +
|
|
1713
|
+
`Cause: ${err instanceof Error ? err.message : String(err)}`,
|
|
1714
|
+
);
|
|
1715
|
+
}
|
|
734
1716
|
|
|
735
1717
|
// libllama.so and the ggml shared-library family are all transitive build
|
|
736
1718
|
// products of the `llama` target. b4500's NEEDED chain (verified via
|
|
@@ -741,53 +1723,73 @@ export function buildLibllamaForAbi({
|
|
|
741
1723
|
// libllama.so so the dynamic linker resolves the whole graph from the
|
|
742
1724
|
// per-ABI asset dir at runtime (LD_LIBRARY_PATH set by
|
|
743
1725
|
// ElizaAgentService.java).
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
`libllama.so has NEEDED entries for the ggml family; without co-copying ` +
|
|
755
|
-
`them the runtime dlopen will fail. Check that BUILD_SHARED_LIBS=ON took effect.`,
|
|
756
|
-
);
|
|
757
|
-
}
|
|
1726
|
+
// Static-fuse (BUILD_SHARED_LIBS=OFF — the `*-fused` targets): llama/ggml/
|
|
1727
|
+
// mtmd build as STATIC `.a` archives folded into a self-contained
|
|
1728
|
+
// libelizainference.so (no DT_NEEDED on libllama.so/libggml*.so). So the
|
|
1729
|
+
// legacy co-copy of the shared libllama.so + ggml family is both impossible
|
|
1730
|
+
// (.so don't exist) and unnecessary (nothing dlopens them) — skip it. The
|
|
1731
|
+
// non-fused (BUILD_SHARED_LIBS=ON) bulk `--abi` path keeps staging the shared
|
|
1732
|
+
// family verbatim for its libllama.so-loading consumers.
|
|
1733
|
+
const isStaticFused = extraCmakeFlags.some((f) =>
|
|
1734
|
+
/BUILD_SHARED_LIBS\s*=\s*OFF/i.test(String(f)),
|
|
1735
|
+
);
|
|
758
1736
|
|
|
759
1737
|
fs.mkdirSync(abiAssetDir, { recursive: true });
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
const dst = path.join(abiAssetDir, path.basename(src));
|
|
764
|
-
fs.copyFileSync(src, dst);
|
|
765
|
-
return dst;
|
|
766
|
-
});
|
|
767
|
-
|
|
768
|
-
// The apothic fork builds with SONAME chains: libllama.so has
|
|
769
|
-
// SONAME=libllama.so.0 and NEEDED entries pointing at SONAME (e.g.
|
|
770
|
-
// "libggml.so.0"), not at the unversioned filename. The dynamic linker
|
|
771
|
-
// matches NEEDED against on-disk SONAME, so we must ship a copy at
|
|
772
|
-
// libfoo.so.0 (or the linker fails to resolve and dlopen returns NULL).
|
|
773
|
-
// We do NOT ship the .so.X.Y.Z versioned tail — only the SONAME alias
|
|
774
|
-
// that NEEDED references.
|
|
775
|
-
//
|
|
776
|
-
// Cost: ~5MB per ABI of duplicated content (the .so and .so.0 are
|
|
777
|
-
// identical). APK build dedupes identical files automatically; even
|
|
778
|
-
// without dedup this is well under the per-ABI .so budget.
|
|
1738
|
+
let llamaOut = null;
|
|
1739
|
+
let ggmlOuts = [];
|
|
1740
|
+
let runtimeSiblingOuts = [];
|
|
779
1741
|
const sonameAliases = [];
|
|
780
|
-
|
|
781
|
-
const
|
|
782
|
-
if (
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
sonameAliases.push(aliasPath);
|
|
786
|
-
log(
|
|
787
|
-
`[compile-libllama] Copied ${path.basename(out)} -> ${soname} ` +
|
|
788
|
-
`(NEEDED-resolution alias for ${abi}).`,
|
|
1742
|
+
if (!isStaticFused) {
|
|
1743
|
+
const builtLlama = locateBuiltLib(buildDir, "libllama.so");
|
|
1744
|
+
if (!builtLlama) {
|
|
1745
|
+
throw new Error(
|
|
1746
|
+
`[compile-libllama] Could not locate built libllama.so anywhere under ${buildDir}.`,
|
|
789
1747
|
);
|
|
790
1748
|
}
|
|
1749
|
+
const builtGgmlLibs = locateBuiltGgmlLibs(buildDir);
|
|
1750
|
+
if (builtGgmlLibs.length === 0) {
|
|
1751
|
+
throw new Error(
|
|
1752
|
+
`[compile-libllama] Could not locate any libggml*.so under ${buildDir}. ` +
|
|
1753
|
+
`libllama.so has NEEDED entries for the ggml family; without co-copying ` +
|
|
1754
|
+
`them the runtime dlopen will fail. Check that BUILD_SHARED_LIBS=ON took effect.`,
|
|
1755
|
+
);
|
|
1756
|
+
}
|
|
1757
|
+
const builtRuntimeSiblingLibs = ["libllama-common.so", "libmtmd.so"]
|
|
1758
|
+
.map((name) => locateBuiltLib(buildDir, name))
|
|
1759
|
+
.filter(Boolean);
|
|
1760
|
+
|
|
1761
|
+
llamaOut = path.join(abiAssetDir, "libllama.so");
|
|
1762
|
+
fs.copyFileSync(builtLlama, llamaOut);
|
|
1763
|
+
ggmlOuts = builtGgmlLibs.map((src) => {
|
|
1764
|
+
const dst = path.join(abiAssetDir, path.basename(src));
|
|
1765
|
+
fs.copyFileSync(src, dst);
|
|
1766
|
+
return dst;
|
|
1767
|
+
});
|
|
1768
|
+
runtimeSiblingOuts = builtRuntimeSiblingLibs.map((src) => {
|
|
1769
|
+
const dst = path.join(abiAssetDir, path.basename(src));
|
|
1770
|
+
fs.copyFileSync(src, dst);
|
|
1771
|
+
return dst;
|
|
1772
|
+
});
|
|
1773
|
+
|
|
1774
|
+
// The apothic fork builds with SONAME chains: libllama.so has
|
|
1775
|
+
// SONAME=libllama.so.0 and NEEDED entries pointing at SONAME (e.g.
|
|
1776
|
+
// "libggml.so.0"), not at the unversioned filename. The dynamic linker
|
|
1777
|
+
// matches NEEDED against on-disk SONAME, so we must ship a copy at
|
|
1778
|
+
// libfoo.so.0 (or the linker fails to resolve and dlopen returns NULL).
|
|
1779
|
+
// We do NOT ship the .so.X.Y.Z versioned tail — only the SONAME alias
|
|
1780
|
+
// that NEEDED references.
|
|
1781
|
+
for (const out of [llamaOut, ...ggmlOuts, ...runtimeSiblingOuts]) {
|
|
1782
|
+
const soname = readSoname(out);
|
|
1783
|
+
if (soname && soname !== path.basename(out)) {
|
|
1784
|
+
const aliasPath = path.join(abiAssetDir, soname);
|
|
1785
|
+
fs.copyFileSync(out, aliasPath);
|
|
1786
|
+
sonameAliases.push(aliasPath);
|
|
1787
|
+
log(
|
|
1788
|
+
`[compile-libllama] Copied ${path.basename(out)} -> ${soname} ` +
|
|
1789
|
+
`(NEEDED-resolution alias for ${abi}).`,
|
|
1790
|
+
);
|
|
1791
|
+
}
|
|
1792
|
+
}
|
|
791
1793
|
}
|
|
792
1794
|
|
|
793
1795
|
// Locate + stage the llama-server binary. cmake puts it under
|
|
@@ -810,12 +1812,66 @@ export function buildLibllamaForAbi({
|
|
|
810
1812
|
} else {
|
|
811
1813
|
log(
|
|
812
1814
|
`[compile-libllama] WARN: llama-server binary not found under ${buildDir}/bin/ or ${buildDir}/. ` +
|
|
813
|
-
`
|
|
1815
|
+
`MTP speculative decode on AOSP requires it; rebuild with -DLLAMA_BUILD_SERVER=ON.`,
|
|
814
1816
|
);
|
|
815
1817
|
}
|
|
816
1818
|
|
|
817
|
-
|
|
1819
|
+
// Stage the fused-build artifacts when they are present: libelizainference.so
|
|
1820
|
+
// (the SHARED target the cmake graft declares) plus the legacy CLI smoke
|
|
1821
|
+
// target llama-omnivoice-server. We do NOT throw when these are missing —
|
|
1822
|
+
// a non-fused build (extraBuildTargets empty) won't produce them, and the
|
|
1823
|
+
// caller is responsible for invoking `verifyFusedSymbols` only on fused
|
|
1824
|
+
// targets. Mirrors the mtp install-loop's conditional copy of the same
|
|
1825
|
+
// pair.
|
|
1826
|
+
const fusedLibSrcCandidates = [
|
|
1827
|
+
path.join(buildDir, "libelizainference.so"),
|
|
1828
|
+
path.join(buildDir, "src", "libelizainference.so"),
|
|
1829
|
+
path.join(buildDir, "bin", "libelizainference.so"),
|
|
1830
|
+
];
|
|
1831
|
+
const fusedLibSrc =
|
|
1832
|
+
fusedLibSrcCandidates.find((c) => fs.existsSync(c)) ??
|
|
1833
|
+
locateBuiltLib(buildDir, "libelizainference.so");
|
|
1834
|
+
let fusedLibOut = null;
|
|
1835
|
+
if (fusedLibSrc) {
|
|
1836
|
+
fusedLibOut = path.join(abiAssetDir, "libelizainference.so");
|
|
1837
|
+
fs.copyFileSync(fusedLibSrc, fusedLibOut);
|
|
1838
|
+
log(
|
|
1839
|
+
`[compile-libllama] Copied libelizainference.so for ${abi} (${(fs.statSync(fusedLibOut).size / (1024 * 1024)).toFixed(2)} MB).`,
|
|
1840
|
+
);
|
|
1841
|
+
}
|
|
1842
|
+
// Under static-fuse the self-contained libelizainference.so is the ONLY
|
|
1843
|
+
// shipped native lib (no libllama.so/libggml*.so), so its absence is fatal.
|
|
1844
|
+
if (isStaticFused && !fusedLibOut) {
|
|
1845
|
+
throw new Error(
|
|
1846
|
+
`[compile-libllama] static-fuse build for ${abi} produced no libelizainference.so ` +
|
|
1847
|
+
`under ${buildDir}. The fused self-contained lib is the only artifact this ` +
|
|
1848
|
+
`target ships — verify the elizainference cmake target built.`,
|
|
1849
|
+
);
|
|
1850
|
+
}
|
|
1851
|
+
const fusedServerSrcCandidates = [
|
|
1852
|
+
path.join(buildDir, "bin", "llama-omnivoice-server"),
|
|
1853
|
+
path.join(buildDir, "llama-omnivoice-server"),
|
|
1854
|
+
];
|
|
1855
|
+
const fusedServerSrc = fusedServerSrcCandidates.find((c) => fs.existsSync(c));
|
|
1856
|
+
let fusedServerOut = null;
|
|
1857
|
+
if (fusedServerSrc) {
|
|
1858
|
+
fusedServerOut = path.join(abiAssetDir, "llama-omnivoice-server");
|
|
1859
|
+
fs.copyFileSync(fusedServerSrc, fusedServerOut);
|
|
1860
|
+
fs.chmodSync(fusedServerOut, 0o755);
|
|
1861
|
+
log(
|
|
1862
|
+
`[compile-libllama] Copied llama-omnivoice-server for ${abi} (${(fs.statSync(fusedServerOut).size / (1024 * 1024)).toFixed(2)} MB).`,
|
|
1863
|
+
);
|
|
1864
|
+
}
|
|
1865
|
+
|
|
1866
|
+
const stripTargets = [
|
|
1867
|
+
...ggmlOuts,
|
|
1868
|
+
...runtimeSiblingOuts,
|
|
1869
|
+
llamaOut,
|
|
1870
|
+
...sonameAliases,
|
|
1871
|
+
].filter(Boolean); // llamaOut is null under static-fuse (no shared libllama.so)
|
|
818
1872
|
if (llamaServerOut) stripTargets.push(llamaServerOut);
|
|
1873
|
+
if (fusedLibOut) stripTargets.push(fusedLibOut);
|
|
1874
|
+
if (fusedServerOut) stripTargets.push(fusedServerOut);
|
|
819
1875
|
for (const out of stripTargets) {
|
|
820
1876
|
const sizeBefore = fs.statSync(out).size;
|
|
821
1877
|
const stripped = stripBinary({ filePath: out, zigBin, log });
|
|
@@ -833,130 +1889,16 @@ export function buildLibllamaForAbi({
|
|
|
833
1889
|
);
|
|
834
1890
|
}
|
|
835
1891
|
}
|
|
836
|
-
// Re-chmod
|
|
1892
|
+
// Re-chmod executables after strip — system strip may reset perms.
|
|
837
1893
|
if (llamaServerOut) fs.chmodSync(llamaServerOut, 0o755);
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
* the full rationale.
|
|
847
|
-
*
|
|
848
|
-
* Linkage:
|
|
849
|
-
* - Compiled with the same per-ABI zig driver used for llama.cpp
|
|
850
|
-
* (musl-linked, matches the bun-on-Android runtime ABI).
|
|
851
|
-
* - NEEDED-links libllama.so via `-L<abiAssetDir> -lllama`. Runtime
|
|
852
|
-
* resolution comes through the per-ABI LD_LIBRARY_PATH that the
|
|
853
|
-
* privileged AOSP system app's agent service sets — same mechanism
|
|
854
|
-
* libllama.so uses to find libggml*.so.
|
|
855
|
-
* - RUNPATH stripped (`-Wl,--disable-new-dtags` + no -rpath) so we don't
|
|
856
|
-
* bake in a build-host path.
|
|
857
|
-
*
|
|
858
|
-
* Output: `<abiAssetDir>/libeliza-llama-shim.so`, stripped to ~10-30 KB.
|
|
859
|
-
*
|
|
860
|
-
* Exported for tests so we can assert the compile invocation arguments
|
|
861
|
-
* without running zig end-to-end.
|
|
862
|
-
*/
|
|
863
|
-
export function buildShimForAbi({
|
|
864
|
-
cacheDir,
|
|
865
|
-
abi,
|
|
866
|
-
abiAssetDir,
|
|
867
|
-
shimSourcePath = path.join(here, "llama-shim", "eliza_llama_shim.c"),
|
|
868
|
-
llamaIncludeDir,
|
|
869
|
-
zigBin = "zig",
|
|
870
|
-
log = console.log,
|
|
871
|
-
spawn = run,
|
|
872
|
-
}) {
|
|
873
|
-
if (!fs.existsSync(shimSourcePath)) {
|
|
874
|
-
throw new Error(
|
|
875
|
-
`[compile-libllama] Shim source not found at ${shimSourcePath}. ` +
|
|
876
|
-
`Restore eliza/packages/app-core/scripts/aosp/llama-shim/eliza_llama_shim.c.`,
|
|
877
|
-
);
|
|
878
|
-
}
|
|
879
|
-
if (!fs.existsSync(llamaIncludeDir)) {
|
|
880
|
-
throw new Error(
|
|
881
|
-
`[compile-libllama] llama.h include dir missing at ${llamaIncludeDir}. ` +
|
|
882
|
-
`Did the llama.cpp checkout fail?`,
|
|
883
|
-
);
|
|
884
|
-
}
|
|
885
|
-
const llamaSo = path.join(abiAssetDir, "libllama.so");
|
|
886
|
-
if (!fs.existsSync(llamaSo)) {
|
|
887
|
-
throw new Error(
|
|
888
|
-
`[compile-libllama] Cannot link shim: ${llamaSo} is missing. ` +
|
|
889
|
-
`Run buildLibllamaForAbi() before buildShimForAbi().`,
|
|
890
|
-
);
|
|
891
|
-
}
|
|
892
|
-
|
|
893
|
-
const { ccPath } = ensureZigDrivers({ cacheDir, abi, zigBin });
|
|
894
|
-
const shimOut = path.join(abiAssetDir, "libeliza-llama-shim.so");
|
|
895
|
-
|
|
896
|
-
// llama.h transitively includes ggml.h, which lives under ggml/include/
|
|
897
|
-
// in the llama.cpp tree (separate from the llama include dir). We pass
|
|
898
|
-
// both -I flags so the compiler resolves the full header chain.
|
|
899
|
-
const ggmlIncludeDir = path.resolve(llamaIncludeDir, "..", "ggml", "include");
|
|
900
|
-
if (!fs.existsSync(path.join(ggmlIncludeDir, "ggml.h"))) {
|
|
901
|
-
throw new Error(
|
|
902
|
-
`[compile-libllama] ggml.h missing under ${ggmlIncludeDir}. ` +
|
|
903
|
-
`llama.h transitively includes it; the layout of the cached ` +
|
|
904
|
-
`llama.cpp checkout may have changed.`,
|
|
905
|
-
);
|
|
906
|
-
}
|
|
907
|
-
|
|
908
|
-
log(
|
|
909
|
-
`[compile-libllama] Compiling libeliza-llama-shim.so for ${abi} (NEEDED libllama.so)`,
|
|
910
|
-
);
|
|
911
|
-
// -fPIC + -shared: build a position-independent shared object.
|
|
912
|
-
// -O2: matches llama.cpp's release optimization level.
|
|
913
|
-
// -I<include>: pick up llama.h from the cached llama.cpp checkout, and
|
|
914
|
-
// ggml.h from the ggml/include sibling.
|
|
915
|
-
// -L<abiAssetDir> -lllama: resolve libllama.so for the link step. The
|
|
916
|
-
// resulting .so has NEEDED libllama.so; runtime resolution is via
|
|
917
|
-
// LD_LIBRARY_PATH set by ElizaAgentService.java.
|
|
918
|
-
// -Wl,--disable-new-dtags + no -rpath: don't bake a RUNPATH that points
|
|
919
|
-
// at the build-host cache dir.
|
|
920
|
-
spawn(
|
|
921
|
-
ccPath,
|
|
922
|
-
[
|
|
923
|
-
"-shared",
|
|
924
|
-
"-fPIC",
|
|
925
|
-
"-O2",
|
|
926
|
-
`-I${llamaIncludeDir}`,
|
|
927
|
-
`-I${ggmlIncludeDir}`,
|
|
928
|
-
`-L${abiAssetDir}`,
|
|
929
|
-
"-Wl,--disable-new-dtags",
|
|
930
|
-
"-o",
|
|
931
|
-
shimOut,
|
|
932
|
-
shimSourcePath,
|
|
933
|
-
"-lllama",
|
|
934
|
-
],
|
|
935
|
-
{},
|
|
936
|
-
);
|
|
937
|
-
|
|
938
|
-
if (!fs.existsSync(shimOut)) {
|
|
939
|
-
throw new Error(
|
|
940
|
-
`[compile-libllama] Shim compile reported success but ${shimOut} is missing.`,
|
|
941
|
-
);
|
|
942
|
-
}
|
|
943
|
-
const sizeBefore = fs.statSync(shimOut).size;
|
|
944
|
-
const stripped = stripBinary({ filePath: shimOut, zigBin, log });
|
|
945
|
-
if (stripped) {
|
|
946
|
-
const sizeAfter = fs.statSync(shimOut).size;
|
|
947
|
-
if (sizeAfter === 0) {
|
|
948
|
-
throw new Error(
|
|
949
|
-
`[compile-libllama] Strip produced an empty libeliza-llama-shim.so ` +
|
|
950
|
-
`(was ${sizeBefore} bytes). This is the zig objcopy in-place ` +
|
|
951
|
-
`truncation bug — the script is supposed to strip out-of-place.`,
|
|
952
|
-
);
|
|
953
|
-
}
|
|
954
|
-
log(
|
|
955
|
-
`[compile-libllama] Stripped libeliza-llama-shim.so for ${abi} ` +
|
|
956
|
-
`(${sizeBefore} -> ${sizeAfter} bytes).`,
|
|
957
|
-
);
|
|
958
|
-
}
|
|
959
|
-
return shimOut;
|
|
1894
|
+
if (fusedServerOut) fs.chmodSync(fusedServerOut, 0o755);
|
|
1895
|
+
return {
|
|
1896
|
+
llama: llamaOut,
|
|
1897
|
+
ggml: ggmlOuts,
|
|
1898
|
+
llamaServer: llamaServerOut,
|
|
1899
|
+
elizainference: fusedLibOut,
|
|
1900
|
+
omnivoiceServer: fusedServerOut,
|
|
1901
|
+
};
|
|
960
1902
|
}
|
|
961
1903
|
|
|
962
1904
|
/**
|
|
@@ -1175,6 +2117,60 @@ function locateBuiltLib(buildDir, soName) {
|
|
|
1175
2117
|
* Falls back to system `strip --strip-all <file>` (in-place safe on
|
|
1176
2118
|
* GNU coreutils) if `zig objcopy` is missing or errors.
|
|
1177
2119
|
*/
|
|
2120
|
+
// Cache of the resolved llvm-strip path (from the Android NDK toolchain).
|
|
2121
|
+
// Set once on first call so we don't re-walk the NDK dir for every artifact.
|
|
2122
|
+
let _ndkLlvmStripPathCache;
|
|
2123
|
+
function locateNdkLlvmStrip() {
|
|
2124
|
+
if (_ndkLlvmStripPathCache !== undefined) return _ndkLlvmStripPathCache;
|
|
2125
|
+
// Honor the same env-var ladder as build-llama-cpp-mtp's resolveAndroidNdk()
|
|
2126
|
+
// so operators with a custom NDK location get a consistent answer in both
|
|
2127
|
+
// scripts.
|
|
2128
|
+
const envRoots = [
|
|
2129
|
+
process.env.ANDROID_NDK_HOME,
|
|
2130
|
+
process.env.ANDROID_NDK_ROOT,
|
|
2131
|
+
process.env.ANDROID_NDK,
|
|
2132
|
+
].filter((v) => typeof v === "string" && v.length > 0);
|
|
2133
|
+
const sdkRoots = [
|
|
2134
|
+
process.env.ANDROID_HOME,
|
|
2135
|
+
process.env.ANDROID_SDK_ROOT,
|
|
2136
|
+
path.join(os.homedir(), "Library", "Android", "sdk"),
|
|
2137
|
+
path.join(os.homedir(), "Android", "Sdk"),
|
|
2138
|
+
].filter((v) => typeof v === "string" && v.length > 0);
|
|
2139
|
+
const candidateNdks = [...envRoots];
|
|
2140
|
+
for (const sdk of sdkRoots) {
|
|
2141
|
+
const ndkDir = path.join(sdk, "ndk");
|
|
2142
|
+
if (!fs.existsSync(ndkDir)) continue;
|
|
2143
|
+
const versions = fs
|
|
2144
|
+
.readdirSync(ndkDir, { withFileTypes: true })
|
|
2145
|
+
.filter((e) => e.isDirectory())
|
|
2146
|
+
.map((e) => e.name)
|
|
2147
|
+
.sort();
|
|
2148
|
+
if (versions.length > 0) {
|
|
2149
|
+
candidateNdks.push(path.join(ndkDir, versions[versions.length - 1]));
|
|
2150
|
+
}
|
|
2151
|
+
}
|
|
2152
|
+
const hosts = ["linux-x86_64", "darwin-arm64", "darwin-x86_64"];
|
|
2153
|
+
for (const ndk of candidateNdks) {
|
|
2154
|
+
for (const host of hosts) {
|
|
2155
|
+
const cand = path.join(
|
|
2156
|
+
ndk,
|
|
2157
|
+
"toolchains",
|
|
2158
|
+
"llvm",
|
|
2159
|
+
"prebuilt",
|
|
2160
|
+
host,
|
|
2161
|
+
"bin",
|
|
2162
|
+
"llvm-strip",
|
|
2163
|
+
);
|
|
2164
|
+
if (fs.existsSync(cand)) {
|
|
2165
|
+
_ndkLlvmStripPathCache = cand;
|
|
2166
|
+
return cand;
|
|
2167
|
+
}
|
|
2168
|
+
}
|
|
2169
|
+
}
|
|
2170
|
+
_ndkLlvmStripPathCache = null;
|
|
2171
|
+
return null;
|
|
2172
|
+
}
|
|
2173
|
+
|
|
1178
2174
|
function stripBinary({ filePath, zigBin, log }) {
|
|
1179
2175
|
const tmpPath = `${filePath}.stripped`;
|
|
1180
2176
|
const zigStripResult = spawnSync(
|
|
@@ -1209,38 +2205,267 @@ function stripBinary({ filePath, zigBin, log }) {
|
|
|
1209
2205
|
`error=${zigStripResult.error?.message ?? "none"}); falling back to system strip.`,
|
|
1210
2206
|
);
|
|
1211
2207
|
}
|
|
1212
|
-
// Fallback: system strip. GNU coreutils strip is in-place safe.
|
|
2208
|
+
// Fallback 1: system strip. GNU coreutils strip is in-place safe.
|
|
2209
|
+
// x86_64-binutils doesn't grok riscv64 ELF or aarch64 ELF, so on a
|
|
2210
|
+
// mismatched host this returns non-zero — fall through to llvm-strip.
|
|
1213
2211
|
const systemStripResult = spawnSync("strip", ["--strip-all", filePath], {
|
|
1214
2212
|
stdio: ["ignore", "pipe", "pipe"],
|
|
1215
2213
|
});
|
|
1216
2214
|
if (systemStripResult.status === 0) return true;
|
|
2215
|
+
// Fallback 2: NDK's llvm-strip handles every Android ABI (arm64-v8a,
|
|
2216
|
+
// x86_64, riscv64) including cross-host. This is the production path
|
|
2217
|
+
// for riscv64 until Zig 0.14's objcopy lands across all build hosts.
|
|
2218
|
+
const llvmStrip = locateNdkLlvmStrip();
|
|
2219
|
+
if (llvmStrip) {
|
|
2220
|
+
const llvmStripResult = spawnSync(llvmStrip, ["--strip-all", filePath], {
|
|
2221
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
2222
|
+
});
|
|
2223
|
+
if (llvmStripResult.status === 0) return true;
|
|
2224
|
+
log(
|
|
2225
|
+
`[compile-libllama] DEBUG: NDK llvm-strip (${llvmStrip}) failed ` +
|
|
2226
|
+
`(status=${llvmStripResult.status}, error=${llvmStripResult.error?.message ?? "none"}).`,
|
|
2227
|
+
);
|
|
2228
|
+
}
|
|
1217
2229
|
log(
|
|
1218
2230
|
`[compile-libllama] WARN: could not strip ${filePath}; shipping with debug symbols.`,
|
|
1219
2231
|
);
|
|
1220
2232
|
return false;
|
|
1221
2233
|
}
|
|
1222
2234
|
|
|
2235
|
+
/**
|
|
2236
|
+
* No-op shim retained for backward compatibility with callers that still
|
|
2237
|
+
* import `applyOmnivoiceGraft`. H2.c collapsed the W3-3 deprecation runway:
|
|
2238
|
+
* the legacy clone-and-graft path is gone; OmniVoice is built exclusively
|
|
2239
|
+
* from the merged in-fork tree at `tools/omnivoice/`.
|
|
2240
|
+
*
|
|
2241
|
+
* Returns a minimal info object so log lines that surface fields like
|
|
2242
|
+
* `commit` or `sourceCount` keep their shape; the merged tree's source
|
|
2243
|
+
* count is fixed at build time and recorded by `verifyFusedSymbols`.
|
|
2244
|
+
*/
|
|
2245
|
+
export function applyOmnivoiceGraft({ srcDir: _srcDir, log = console.log }) {
|
|
2246
|
+
log(
|
|
2247
|
+
"[compile-libllama] omnivoice: merged in-fork path (legacy graft removed)",
|
|
2248
|
+
);
|
|
2249
|
+
return { mode: "merged", source: "tools/omnivoice" };
|
|
2250
|
+
}
|
|
2251
|
+
|
|
2252
|
+
/**
|
|
2253
|
+
* Stage prebuilt LiteRT-LM `.litertlm` text artifacts into the on-device
|
|
2254
|
+
* bundle assets, parallel to the `.so` libs this script stages and the `.gguf`
|
|
2255
|
+
* models `stage-default-models.mjs` stages. The destination is
|
|
2256
|
+
* `<androidAssetsDir>/models/text/` — the same `text/` subdir the GGUF text
|
|
2257
|
+
* weights land in (`models/text/eliza-1-<tier>-128k.gguf`) and the path the
|
|
2258
|
+
* C-side `llm_backend_select` / `find_litertlm_artifact` probes at runtime
|
|
2259
|
+
* (`<bundleRoot>/text/*.litertlm`, see
|
|
2260
|
+
* `tools/omnivoice/src/backends/litert-backend.cpp`).
|
|
2261
|
+
*
|
|
2262
|
+
* GGUF stays the default: when no `litertlmDir` is configured (no
|
|
2263
|
+
* `--litertlm-dir` / `ELIZA_LITERTLM_DIR`) or the dir holds no `.litertlm`,
|
|
2264
|
+
* this is a no-op and the bundle is byte-identical to a GGUF-only build. A
|
|
2265
|
+
* configured dir that does not exist is a hard error (the operator asked for
|
|
2266
|
+
* LiteRT staging but pointed us at nothing — don't silently ship GGUF-only).
|
|
2267
|
+
*
|
|
2268
|
+
* `.litertlm` artifacts are model files, arch-independent like the GGUFs, so
|
|
2269
|
+
* they are staged ONCE into the shared `models/text/` dir — not per-ABI.
|
|
2270
|
+
*
|
|
2271
|
+
* Exported for unit tests.
|
|
2272
|
+
*/
|
|
2273
|
+
export function stageLitertlmArtifacts({
|
|
2274
|
+
litertlmDir,
|
|
2275
|
+
androidAssetsDir,
|
|
2276
|
+
log = console.log,
|
|
2277
|
+
dryRun = false,
|
|
2278
|
+
}) {
|
|
2279
|
+
if (!litertlmDir) return [];
|
|
2280
|
+
if (!fs.existsSync(litertlmDir)) {
|
|
2281
|
+
throw new Error(
|
|
2282
|
+
`[compile-libllama] --litertlm-dir ${litertlmDir} does not exist. ` +
|
|
2283
|
+
`Point it at a directory of prebuilt .litertlm artifacts, or omit it to ` +
|
|
2284
|
+
`ship the GGUF-only bundle.`,
|
|
2285
|
+
);
|
|
2286
|
+
}
|
|
2287
|
+
const artifacts = fs
|
|
2288
|
+
.readdirSync(litertlmDir, { withFileTypes: true })
|
|
2289
|
+
.filter((e) => e.isFile() && e.name.endsWith(".litertlm"))
|
|
2290
|
+
.map((e) => e.name);
|
|
2291
|
+
if (artifacts.length === 0) {
|
|
2292
|
+
log(
|
|
2293
|
+
`[compile-libllama] No .litertlm artifacts under ${litertlmDir}; LiteRT ` +
|
|
2294
|
+
`staging is a no-op (GGUF-only bundle).`,
|
|
2295
|
+
);
|
|
2296
|
+
return [];
|
|
2297
|
+
}
|
|
2298
|
+
const textDir = path.join(androidAssetsDir, "models", "text");
|
|
2299
|
+
if (dryRun) {
|
|
2300
|
+
log(
|
|
2301
|
+
`[compile-libllama] (dry-run) would stage ${artifacts.length} .litertlm ` +
|
|
2302
|
+
`artifact(s) into ${textDir}: ${artifacts.join(", ")}`,
|
|
2303
|
+
);
|
|
2304
|
+
return artifacts.map((name) => path.join(textDir, name));
|
|
2305
|
+
}
|
|
2306
|
+
fs.mkdirSync(textDir, { recursive: true });
|
|
2307
|
+
const staged = [];
|
|
2308
|
+
for (const name of artifacts) {
|
|
2309
|
+
const src = path.join(litertlmDir, name);
|
|
2310
|
+
const dst = path.join(textDir, name);
|
|
2311
|
+
fs.copyFileSync(src, dst);
|
|
2312
|
+
staged.push(dst);
|
|
2313
|
+
log(
|
|
2314
|
+
`[compile-libllama] Staged LiteRT artifact ${name} -> ${dst} ` +
|
|
2315
|
+
`(${(fs.statSync(dst).size / (1024 * 1024)).toFixed(2)} MB).`,
|
|
2316
|
+
);
|
|
2317
|
+
}
|
|
2318
|
+
return staged;
|
|
2319
|
+
}
|
|
2320
|
+
|
|
2321
|
+
/**
|
|
2322
|
+
* Print the dry-run plan for one `android-<arch>-<backend>[-fused]` target:
|
|
2323
|
+
* the cmake invocation, the post-cmake build target list, the graft steps
|
|
2324
|
+
* (for fused targets), the expected output file layout, and the post-build
|
|
2325
|
+
* verify step (for fused targets). Mirrors the structure of the mtp build
|
|
2326
|
+
* script's --dry-run output so the two paths read the same.
|
|
2327
|
+
*
|
|
2328
|
+
* Exported for tests so the dry-run rendering can be asserted without going
|
|
2329
|
+
* through the CLI entry point.
|
|
2330
|
+
*/
|
|
2331
|
+
export function describeAndroidTargetDryRun({
|
|
2332
|
+
target,
|
|
2333
|
+
srcDir,
|
|
2334
|
+
cacheDir,
|
|
2335
|
+
abiAssetDir,
|
|
2336
|
+
jobs,
|
|
2337
|
+
log = console.log,
|
|
2338
|
+
}) {
|
|
2339
|
+
const parsed = parseAndroidTarget(target.target ?? target);
|
|
2340
|
+
const abiTarget = ABI_TARGETS.find((t) => t.androidAbi === parsed.androidAbi);
|
|
2341
|
+
if (!abiTarget) {
|
|
2342
|
+
throw new Error(
|
|
2343
|
+
`[compile-libllama] No ABI mapping for ${parsed.androidAbi}`,
|
|
2344
|
+
);
|
|
2345
|
+
}
|
|
2346
|
+
const buildDir = path.join(srcDir, `build-${parsed.androidAbi}`);
|
|
2347
|
+
const ccPath = path.join(cacheDir, "zig-driver", parsed.androidAbi, "zig-cc");
|
|
2348
|
+
const cxxPath = path.join(
|
|
2349
|
+
cacheDir,
|
|
2350
|
+
"zig-driver",
|
|
2351
|
+
parsed.androidAbi,
|
|
2352
|
+
"zig-cxx",
|
|
2353
|
+
);
|
|
2354
|
+
log(`[compile-libllama] (dry-run) target=${parsed.target}`);
|
|
2355
|
+
log(` zig-target=${abiTarget.zigTarget} android-abi=${parsed.androidAbi}`);
|
|
2356
|
+
log(` src=${srcDir}`);
|
|
2357
|
+
log(` build=${buildDir}`);
|
|
2358
|
+
log(` install=${abiAssetDir}`);
|
|
2359
|
+
if (parsed.androidAbi === "arm64-v8a") {
|
|
2360
|
+
log(
|
|
2361
|
+
` zig requirement: ${AARCH64_MUSL_ZIG_MIN_VERSION} <= version < ` +
|
|
2362
|
+
`${AARCH64_MUSL_ZIG_MAX_VERSION_EXCLUSIVE} (aarch64-linux-musl pin)`,
|
|
2363
|
+
);
|
|
2364
|
+
}
|
|
2365
|
+
if (parsed.fused) {
|
|
2366
|
+
log(` omnivoice: merged in-fork path (tools/omnivoice/)`);
|
|
2367
|
+
}
|
|
2368
|
+
const cmakeFlags = [
|
|
2369
|
+
"-S",
|
|
2370
|
+
srcDir,
|
|
2371
|
+
"-B",
|
|
2372
|
+
buildDir,
|
|
2373
|
+
"-DCMAKE_BUILD_TYPE=Release",
|
|
2374
|
+
"-DBUILD_SHARED_LIBS=ON",
|
|
2375
|
+
"-DLLAMA_BUILD_EXAMPLES=OFF",
|
|
2376
|
+
"-DLLAMA_BUILD_TESTS=OFF",
|
|
2377
|
+
"-DLLAMA_BUILD_SERVER=ON",
|
|
2378
|
+
"-DLLAMA_CURL=OFF",
|
|
2379
|
+
`-DCMAKE_C_COMPILER=${ccPath}`,
|
|
2380
|
+
`-DCMAKE_CXX_COMPILER=${cxxPath}`,
|
|
2381
|
+
"-DCMAKE_C_COMPILER_LAUNCHER=",
|
|
2382
|
+
"-DCMAKE_CXX_COMPILER_LAUNCHER=",
|
|
2383
|
+
"-DCMAKE_SYSTEM_NAME=Linux",
|
|
2384
|
+
`-DCMAKE_SYSTEM_PROCESSOR=${abiTarget.cmakeProcessor}`,
|
|
2385
|
+
"-DGGML_NATIVE=OFF",
|
|
2386
|
+
];
|
|
2387
|
+
// riscv64 build flags must show up in dry-run output too — the real
|
|
2388
|
+
// buildLibllamaForAbi() resolves these from the detected Zig version and
|
|
2389
|
+
// operators reading the dry-run plan should see the byte-exact list that
|
|
2390
|
+
// will be passed. resolveRiscv64BuildPlan() falls back to scalar when zig
|
|
2391
|
+
// is not installed (dry-run is allowed on toolchain-less boxes), so the
|
|
2392
|
+
// plan reported here mirrors what a build invocation would actually emit
|
|
2393
|
+
// on the same host.
|
|
2394
|
+
if (parsed.androidAbi === "riscv64") {
|
|
2395
|
+
const plan = resolveRiscv64BuildPlan({ env: process.env, isDryRun: true });
|
|
2396
|
+
log(
|
|
2397
|
+
` riscv64 plan: zig=${plan.zigVersion ?? "unknown"} ` +
|
|
2398
|
+
`rvv=${plan.rvv ? "ON" : "OFF"} ` +
|
|
2399
|
+
`all-variants=${plan.allVariants ? "ON" : "OFF"} ` +
|
|
2400
|
+
`reason=${plan.reason}`,
|
|
2401
|
+
);
|
|
2402
|
+
cmakeFlags.push(
|
|
2403
|
+
...riscv64CmakeFlagsForPlan({ abi: parsed.androidAbi, plan }),
|
|
2404
|
+
);
|
|
2405
|
+
}
|
|
2406
|
+
// arm64-v8a SIMD floor (dotprod/i8mm/fp16 + QJL NEON-dotprod dispatch) — the
|
|
2407
|
+
// real buildLibllamaForAbi() emits these too; surface them in the dry-run.
|
|
2408
|
+
cmakeFlags.push(...androidArm64SimdCmakeFlags(parsed.androidAbi));
|
|
2409
|
+
cmakeFlags.push(
|
|
2410
|
+
"-DCMAKE_SKIP_BUILD_RPATH=TRUE",
|
|
2411
|
+
"-DCMAKE_SKIP_INSTALL_RPATH=TRUE",
|
|
2412
|
+
"-DCMAKE_BUILD_WITH_INSTALL_RPATH=TRUE",
|
|
2413
|
+
"-DCMAKE_INSTALL_RPATH=",
|
|
2414
|
+
);
|
|
2415
|
+
if (parsed.fused) {
|
|
2416
|
+
cmakeFlags.push(...fusedExtraCmakeFlags());
|
|
2417
|
+
}
|
|
2418
|
+
log(` cmake ${cmakeFlags.join(" ")}`);
|
|
2419
|
+
const buildTargets = parsed.fused
|
|
2420
|
+
? fusedCmakeBuildTargets()
|
|
2421
|
+
: ["llama", "llama-server"];
|
|
2422
|
+
log(
|
|
2423
|
+
` cmake --build ${buildDir} --target ${buildTargets.join(" ")} -j ${jobs}`,
|
|
2424
|
+
);
|
|
2425
|
+
log(` expected output layout under ${abiAssetDir}:`);
|
|
2426
|
+
log(` libllama.so libggml*.so llama-server`);
|
|
2427
|
+
if (parsed.fused) {
|
|
2428
|
+
log(
|
|
2429
|
+
` libelizainference.so omnivoice-tts omnivoice-codec (merged-tree artifacts)`,
|
|
2430
|
+
);
|
|
2431
|
+
log(
|
|
2432
|
+
` verifyFusedSymbols outDir=${abiAssetDir} target=${parsed.target} (post-build)`,
|
|
2433
|
+
);
|
|
2434
|
+
}
|
|
2435
|
+
}
|
|
2436
|
+
|
|
1223
2437
|
export async function main(argv = process.argv.slice(2)) {
|
|
1224
2438
|
const args = parseArgs(argv);
|
|
1225
2439
|
|
|
1226
|
-
//
|
|
1227
|
-
|
|
1228
|
-
|
|
2440
|
+
// If --target was passed, the caller is asking for the mtp-style
|
|
2441
|
+
// explicit-triple build path. --abi still drives the legacy bulk-build
|
|
2442
|
+
// (cpu only, no fusion) entry point so existing callers keep working.
|
|
2443
|
+
if (args.targets.length > 0) {
|
|
2444
|
+
return mainTargets(args);
|
|
2445
|
+
}
|
|
2446
|
+
|
|
2447
|
+
// Probe toolchain first so we fail loudly before doing any work. Skip in
|
|
2448
|
+
// dry-run mode — operators on a box without zig still want to inspect what
|
|
2449
|
+
// the build WOULD do.
|
|
2450
|
+
if (!args.dryRun) {
|
|
2451
|
+
const zigVersion = probeZig();
|
|
2452
|
+
console.log(`[compile-libllama] Found zig ${zigVersion}`);
|
|
2453
|
+
assertZigPinForTargets({
|
|
2454
|
+
version: zigVersion,
|
|
2455
|
+
zigTriples: zigTriplesForAbis(args.abis),
|
|
2456
|
+
});
|
|
2457
|
+
} else {
|
|
2458
|
+
console.log(`[compile-libllama] (dry-run) skipping zig toolchain probe`);
|
|
2459
|
+
}
|
|
1229
2460
|
|
|
1230
2461
|
let allPresent = true;
|
|
1231
2462
|
for (const abi of args.abis) {
|
|
1232
2463
|
const llama = path.join(args.androidAssetsDir, abi, "libllama.so");
|
|
1233
2464
|
const ggml = path.join(args.androidAssetsDir, abi, "libggml.so");
|
|
1234
|
-
const shim = path.join(
|
|
1235
|
-
args.androidAssetsDir,
|
|
1236
|
-
abi,
|
|
1237
|
-
"libeliza-llama-shim.so",
|
|
1238
|
-
);
|
|
1239
2465
|
const llamaServer = path.join(args.androidAssetsDir, abi, "llama-server");
|
|
1240
2466
|
if (
|
|
1241
2467
|
!fs.existsSync(llama) ||
|
|
1242
2468
|
!fs.existsSync(ggml) ||
|
|
1243
|
-
!fs.existsSync(shim) ||
|
|
1244
2469
|
!fs.existsSync(llamaServer)
|
|
1245
2470
|
) {
|
|
1246
2471
|
allPresent = false;
|
|
@@ -1253,6 +2478,31 @@ export async function main(argv = process.argv.slice(2)) {
|
|
|
1253
2478
|
);
|
|
1254
2479
|
return;
|
|
1255
2480
|
}
|
|
2481
|
+
if (args.dryRun) {
|
|
2482
|
+
console.log(
|
|
2483
|
+
"[compile-libllama] (dry-run) bulk --abi mode requested; emit dry-run for each ABI as a non-fused android-<arch>-cpu target",
|
|
2484
|
+
);
|
|
2485
|
+
const srcDirForDry =
|
|
2486
|
+
args.srcDir ??
|
|
2487
|
+
(llamaCppSubmodulePresent() ? LLAMA_CPP_SUBMODULE_DIR : args.cacheDir);
|
|
2488
|
+
for (const abi of args.abis) {
|
|
2489
|
+
// arm64-v8a is the only ANDROID_ABI that doesn't share its name with
|
|
2490
|
+
// the `android-<arch>-cpu` triple's <arch> token; x86_64 and riscv64
|
|
2491
|
+
// map 1:1 to the same string in both spellings. Keep this in sync
|
|
2492
|
+
// with parseAndroidTarget()'s arch→ABI mapping.
|
|
2493
|
+
const arch = abi === "arm64-v8a" ? "arm64" : abi;
|
|
2494
|
+
const target = `android-${arch}-cpu`;
|
|
2495
|
+
const abiAssetDir = path.join(args.androidAssetsDir, abi);
|
|
2496
|
+
describeAndroidTargetDryRun({
|
|
2497
|
+
target,
|
|
2498
|
+
srcDir: srcDirForDry,
|
|
2499
|
+
cacheDir: args.cacheDir,
|
|
2500
|
+
abiAssetDir,
|
|
2501
|
+
jobs: args.jobs,
|
|
2502
|
+
});
|
|
2503
|
+
}
|
|
2504
|
+
return;
|
|
2505
|
+
}
|
|
1256
2506
|
|
|
1257
2507
|
let srcDir;
|
|
1258
2508
|
let srcDescription;
|
|
@@ -1260,19 +2510,42 @@ export async function main(argv = process.argv.slice(2)) {
|
|
|
1260
2510
|
if (!fs.existsSync(path.join(args.srcDir, "CMakeLists.txt"))) {
|
|
1261
2511
|
throw new Error(
|
|
1262
2512
|
`[compile-libllama] --src-dir ${args.srcDir} does not contain a CMakeLists.txt; ` +
|
|
1263
|
-
`expected a llama.cpp
|
|
2513
|
+
`expected a llama.cpp checkout.`,
|
|
1264
2514
|
);
|
|
1265
2515
|
}
|
|
1266
2516
|
srcDir = args.srcDir;
|
|
2517
|
+
const isSubmodule =
|
|
2518
|
+
path.resolve(srcDir) === path.resolve(LLAMA_CPP_SUBMODULE_DIR);
|
|
1267
2519
|
let headRef = "(unknown)";
|
|
1268
2520
|
try {
|
|
1269
|
-
|
|
2521
|
+
// A submodule's `.git` is a file (`gitdir: ...`), not a dir, so resolve
|
|
2522
|
+
// HEAD via `git rev-parse` rather than reading `.git/HEAD` directly.
|
|
2523
|
+
const out = spawnSync("git", ["-C", srcDir, "rev-parse", "HEAD"], {
|
|
2524
|
+
encoding: "utf8",
|
|
2525
|
+
});
|
|
2526
|
+
if (out.status === 0) headRef = out.stdout.trim();
|
|
1270
2527
|
} catch {}
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
2528
|
+
if (isSubmodule) {
|
|
2529
|
+
// The in-repo submodule is pinned by the eliza repo's gitlink. Discard
|
|
2530
|
+
// the source patches a prior build left behind (tracked + untracked)
|
|
2531
|
+
// before re-applying them, so a fresh artifact starts from the pristine
|
|
2532
|
+
// submodule tree. Never detach/fetch — `bun install` keeps it pinned.
|
|
2533
|
+
console.log(
|
|
2534
|
+
`[compile-libllama] Using the in-repo llama.cpp submodule ${srcDir} ` +
|
|
2535
|
+
`(HEAD: ${headRef}); resetting prior source patches.`,
|
|
2536
|
+
);
|
|
2537
|
+
run("git", ["-C", srcDir, "checkout", "--", "."], {});
|
|
2538
|
+
run("git", ["-C", srcDir, "clean", "-fdx"], {});
|
|
2539
|
+
assertSwaSpecDecodeFallback({ srcDir });
|
|
2540
|
+
srcDescription = `submodule plugins/plugin-local-inference/native/llama.cpp @ ${headRef.slice(0, 12)}`;
|
|
2541
|
+
} else {
|
|
2542
|
+
console.log(
|
|
2543
|
+
`[compile-libllama] Using --src-dir ${srcDir} (HEAD: ${headRef}); ` +
|
|
2544
|
+
`pinned tag ${LLAMA_CPP_TAG} ignored.`,
|
|
2545
|
+
);
|
|
2546
|
+
assertSwaSpecDecodeFallback({ srcDir });
|
|
2547
|
+
srcDescription = `external src-dir ${srcDir}`;
|
|
2548
|
+
}
|
|
1276
2549
|
} else {
|
|
1277
2550
|
srcDir = ensureLlamaCppCheckout({
|
|
1278
2551
|
cacheDir: args.cacheDir,
|
|
@@ -1284,6 +2557,12 @@ export async function main(argv = process.argv.slice(2)) {
|
|
|
1284
2557
|
|
|
1285
2558
|
for (const abi of args.abis) {
|
|
1286
2559
|
const abiAssetDir = path.join(args.androidAssetsDir, abi);
|
|
2560
|
+
// Builds + stages libllama.so + the libggml*.so family + llama-server.
|
|
2561
|
+
// libllama.so + libggml*.so are runtime DT_NEEDED dependencies of the
|
|
2562
|
+
// fused libelizainference.so (the fork's `elizainference` target does
|
|
2563
|
+
// `target_link_libraries(elizainference PUBLIC llama)` with
|
|
2564
|
+
// BUILD_SHARED_LIBS=ON), so they stay required even though no TS adapter
|
|
2565
|
+
// dlopens libllama.so directly anymore.
|
|
1287
2566
|
buildLibllamaForAbi({
|
|
1288
2567
|
srcDir,
|
|
1289
2568
|
cacheDir: args.cacheDir,
|
|
@@ -1293,17 +2572,6 @@ export async function main(argv = process.argv.slice(2)) {
|
|
|
1293
2572
|
log: console.log,
|
|
1294
2573
|
spawn: run,
|
|
1295
2574
|
});
|
|
1296
|
-
// Compile the bun:ffi struct-by-value shim against the freshly built
|
|
1297
|
-
// libllama.so. Has to come AFTER the llama build because it links
|
|
1298
|
-
// against -lllama from <abiAssetDir>.
|
|
1299
|
-
buildShimForAbi({
|
|
1300
|
-
cacheDir: args.cacheDir,
|
|
1301
|
-
abi,
|
|
1302
|
-
abiAssetDir,
|
|
1303
|
-
llamaIncludeDir: path.join(srcDir, "include"),
|
|
1304
|
-
log: console.log,
|
|
1305
|
-
spawn: run,
|
|
1306
|
-
});
|
|
1307
2575
|
}
|
|
1308
2576
|
|
|
1309
2577
|
// Cross-compile the SIGSYS-handler shim + loader-wrap for x86_64. ARM64
|
|
@@ -1318,12 +2586,227 @@ export async function main(argv = process.argv.slice(2)) {
|
|
|
1318
2586
|
// the production-landing checklist.
|
|
1319
2587
|
await compileShimMain(["--skip-if-present"]);
|
|
1320
2588
|
|
|
2589
|
+
// Stage any prebuilt LiteRT-LM `.litertlm` text artifacts into the shared
|
|
2590
|
+
// on-device bundle assets (arch-independent, so once — not per ABI). No-op
|
|
2591
|
+
// unless --litertlm-dir / ELIZA_LITERTLM_DIR is configured; GGUF stays default.
|
|
2592
|
+
stageLitertlmArtifacts({
|
|
2593
|
+
litertlmDir: args.litertlmDir,
|
|
2594
|
+
androidAssetsDir: args.androidAssetsDir,
|
|
2595
|
+
});
|
|
2596
|
+
|
|
1321
2597
|
console.log(
|
|
1322
|
-
`[compile-libllama] Built libllama.so +
|
|
2598
|
+
`[compile-libllama] Built libllama.so + libggml*.so + llama-server for ` +
|
|
1323
2599
|
`${args.abis.join(", ")} (${srcDescription}).`,
|
|
1324
2600
|
);
|
|
1325
2601
|
}
|
|
1326
2602
|
|
|
2603
|
+
/**
|
|
2604
|
+
* Explicit-triple entry point: runs the build for one or more
|
|
2605
|
+
* `android-<arch>-<backend>[-fused]` targets. Mirrors the mtp build
|
|
2606
|
+
* script's `--target` semantics one-for-one so an operator running the
|
|
2607
|
+
* desktop fused build and the mobile fused build invokes the two scripts
|
|
2608
|
+
* with the same target string.
|
|
2609
|
+
*
|
|
2610
|
+
* Build flow per target:
|
|
2611
|
+
* 1. Resolve the llama.cpp source tree (--src-dir / in-repo submodule /
|
|
2612
|
+
* standalone clone — same logic as the bulk --abi path).
|
|
2613
|
+
* 2. For `*-fused`: the merged in-fork tree at `tools/omnivoice/`
|
|
2614
|
+
* already declares the omnivoice + elizainference targets; just add
|
|
2615
|
+
* the CMake flags via `fusedExtraCmakeFlags()`.
|
|
2616
|
+
* 3. Run `buildLibllamaForAbi()` (which also configures + links the
|
|
2617
|
+
* llama-server target — required for fused so omnivoice_lib links
|
|
2618
|
+
* into the same binary).
|
|
2619
|
+
* 4. For `*-fused`: run `verifyFusedSymbols()` against the install dir,
|
|
2620
|
+
* asserting libelizainference.so carries `llama_*` + `ov_*` +
|
|
2621
|
+
* `eliza_inference_*` exports.
|
|
2622
|
+
*
|
|
2623
|
+
* Dry-run prints what each step WOULD do without touching the filesystem
|
|
2624
|
+
* or running cmake / the NDK.
|
|
2625
|
+
*/
|
|
2626
|
+
export async function mainTargets(args) {
|
|
2627
|
+
// Resolve the source dir up front so dry-run can report a real path.
|
|
2628
|
+
let srcDir;
|
|
2629
|
+
let srcDescription;
|
|
2630
|
+
if (args.srcDir) {
|
|
2631
|
+
if (
|
|
2632
|
+
!args.dryRun &&
|
|
2633
|
+
!fs.existsSync(path.join(args.srcDir, "CMakeLists.txt"))
|
|
2634
|
+
) {
|
|
2635
|
+
throw new Error(
|
|
2636
|
+
`[compile-libllama] --src-dir ${args.srcDir} does not contain a CMakeLists.txt; ` +
|
|
2637
|
+
`expected a llama.cpp checkout.`,
|
|
2638
|
+
);
|
|
2639
|
+
}
|
|
2640
|
+
srcDir = args.srcDir;
|
|
2641
|
+
const isSubmodule =
|
|
2642
|
+
path.resolve(srcDir) === path.resolve(LLAMA_CPP_SUBMODULE_DIR);
|
|
2643
|
+
srcDescription = isSubmodule
|
|
2644
|
+
? `submodule plugins/plugin-local-inference/native/llama.cpp`
|
|
2645
|
+
: `external src-dir ${srcDir}`;
|
|
2646
|
+
if (!args.dryRun) assertSwaSpecDecodeFallback({ srcDir });
|
|
2647
|
+
} else if (args.dryRun) {
|
|
2648
|
+
// In a dry run with no --src-dir and no submodule, just describe the
|
|
2649
|
+
// intended cache path; we never clone in dry-run.
|
|
2650
|
+
srcDir = args.cacheDir;
|
|
2651
|
+
srcDescription = `cache ${args.cacheDir} (would clone ${LLAMA_CPP_TAG})`;
|
|
2652
|
+
} else {
|
|
2653
|
+
srcDir = ensureLlamaCppCheckout({
|
|
2654
|
+
cacheDir: args.cacheDir,
|
|
2655
|
+
log: console.log,
|
|
2656
|
+
spawn: run,
|
|
2657
|
+
});
|
|
2658
|
+
srcDescription = `llama.cpp ${LLAMA_CPP_TAG} / ${LLAMA_CPP_COMMIT.slice(0, 12)}`;
|
|
2659
|
+
}
|
|
2660
|
+
|
|
2661
|
+
// omnivoice.cpp clone lives at <cacheRoot>/omnivoice.cpp; we use the parent
|
|
2662
|
+
// of the llama.cpp cache dir so both clones live under one cache root, the
|
|
2663
|
+
// same shape the mtp build path uses (cacheRoot=path.dirname(args.cacheDir)).
|
|
2664
|
+
const omnivoiceCacheRoot = path.dirname(args.cacheDir);
|
|
2665
|
+
|
|
2666
|
+
if (!args.dryRun) {
|
|
2667
|
+
const zigVersion = probeZig();
|
|
2668
|
+
console.log(`[compile-libllama] Found zig ${zigVersion}`);
|
|
2669
|
+
assertZigPinForTargets({
|
|
2670
|
+
version: zigVersion,
|
|
2671
|
+
zigTriples: zigTriplesForAbis(args.targets.map((t) => t.androidAbi)),
|
|
2672
|
+
});
|
|
2673
|
+
} else {
|
|
2674
|
+
console.log(`[compile-libllama] (dry-run) skipping zig toolchain probe`);
|
|
2675
|
+
}
|
|
2676
|
+
|
|
2677
|
+
for (const parsed of args.targets) {
|
|
2678
|
+
const abiAssetDir = path.join(args.androidAssetsDir, parsed.androidAbi);
|
|
2679
|
+
if (args.dryRun) {
|
|
2680
|
+
describeAndroidTargetDryRun({
|
|
2681
|
+
target: parsed.target,
|
|
2682
|
+
srcDir,
|
|
2683
|
+
cacheDir: args.cacheDir,
|
|
2684
|
+
abiAssetDir,
|
|
2685
|
+
jobs: args.jobs,
|
|
2686
|
+
});
|
|
2687
|
+
if (parsed.fused) {
|
|
2688
|
+
console.log(
|
|
2689
|
+
` fused-graft cacheRoot=${omnivoiceCacheRoot} (omnivoice.cpp clone)`,
|
|
2690
|
+
);
|
|
2691
|
+
}
|
|
2692
|
+
continue;
|
|
2693
|
+
}
|
|
2694
|
+
|
|
2695
|
+
// Pre-cmake: run the omnivoice graft for fused targets. Same call
|
|
2696
|
+
// sequence as the mtp linux-x64-cpu-fused path; the graft is
|
|
2697
|
+
// toolchain-agnostic (CMake snippet + source layout).
|
|
2698
|
+
let omnivoiceInfo = null;
|
|
2699
|
+
if (parsed.fused) {
|
|
2700
|
+
omnivoiceInfo = applyOmnivoiceGraft({
|
|
2701
|
+
srcDir,
|
|
2702
|
+
omnivoiceCacheRoot,
|
|
2703
|
+
log: console.log,
|
|
2704
|
+
});
|
|
2705
|
+
}
|
|
2706
|
+
|
|
2707
|
+
// Vulkan target: graft the eliza-1 qjl/polar Vulkan compute shaders +
|
|
2708
|
+
// ggml-vulkan dispatch patches into the source, and assemble the
|
|
2709
|
+
// GGML_VULKAN CMake flags (NDK glslc + headers + aarch64 loader). The
|
|
2710
|
+
// libggml-vulkan.so the build emits is glob-staged alongside the rest of
|
|
2711
|
+
// the libggml family by buildLibllamaForAbi.
|
|
2712
|
+
let vulkanCmakeFlags = [];
|
|
2713
|
+
if (parsed.backend === "vulkan") {
|
|
2714
|
+
console.log(
|
|
2715
|
+
`[compile-libllama] Patching eliza-1 Vulkan kernels into ${srcDir} for ${parsed.target}`,
|
|
2716
|
+
);
|
|
2717
|
+
patchVulkanKernels(srcDir, { target: parsed.target });
|
|
2718
|
+
vulkanCmakeFlags = resolveAndroidVulkanCmakeFlags({
|
|
2719
|
+
stagingDir: path.join(args.cacheDir, "vulkan-headers"),
|
|
2720
|
+
});
|
|
2721
|
+
}
|
|
2722
|
+
|
|
2723
|
+
// The existing per-ABI build helper handles the cmake configure +
|
|
2724
|
+
// build + per-ABI install for libllama + ggml + llama-server. We
|
|
2725
|
+
// reuse it as-is; the fused cmake flags + extra targets are applied
|
|
2726
|
+
// below via a thin override hook so the non-fused path stays
|
|
2727
|
+
// byte-for-byte identical.
|
|
2728
|
+
buildLibllamaForAbi({
|
|
2729
|
+
srcDir,
|
|
2730
|
+
cacheDir: args.cacheDir,
|
|
2731
|
+
abi: parsed.androidAbi,
|
|
2732
|
+
abiAssetDir,
|
|
2733
|
+
jobs: args.jobs,
|
|
2734
|
+
log: console.log,
|
|
2735
|
+
spawn: run,
|
|
2736
|
+
// The fused path needs `-DELIZA_FUSE_OMNIVOICE=ON` on the configure
|
|
2737
|
+
// line and the omnivoice-core + libelizainference + fused
|
|
2738
|
+
// llama-server targets on the build line. Pass-through hooks let
|
|
2739
|
+
// the caller layer those in without forking the helper. The Vulkan
|
|
2740
|
+
// target adds GGML_VULKAN=ON + the NDK toolchain paths and asks the
|
|
2741
|
+
// build to also produce ggml-vulkan (libggml-vulkan.so).
|
|
2742
|
+
extraCmakeFlags: [
|
|
2743
|
+
...(parsed.fused ? fusedExtraCmakeFlags() : []),
|
|
2744
|
+
...vulkanCmakeFlags,
|
|
2745
|
+
],
|
|
2746
|
+
extraBuildTargets: [
|
|
2747
|
+
...(parsed.fused
|
|
2748
|
+
? fusedCmakeBuildTargets().filter(
|
|
2749
|
+
(t) => t !== "llama" && t !== "llama-server",
|
|
2750
|
+
)
|
|
2751
|
+
: []),
|
|
2752
|
+
...(parsed.backend === "vulkan" ? ["ggml-vulkan"] : []),
|
|
2753
|
+
],
|
|
2754
|
+
});
|
|
2755
|
+
|
|
2756
|
+
// Post-build: for fused targets prove libelizainference.so exports both
|
|
2757
|
+
// `llama_*` and `ov_*` (and the eliza_inference ABI surface). Hard error
|
|
2758
|
+
// on a half-fused artifact — same contract as the mtp build path.
|
|
2759
|
+
if (parsed.fused) {
|
|
2760
|
+
const verification = verifyFusedSymbols({
|
|
2761
|
+
outDir: abiAssetDir,
|
|
2762
|
+
target: parsed.target,
|
|
2763
|
+
});
|
|
2764
|
+
console.log(
|
|
2765
|
+
`[compile-libllama] omnivoice symbol-verify: ` +
|
|
2766
|
+
`library=${verification.library} ` +
|
|
2767
|
+
`llama=${verification.llamaSymbolCount} ` +
|
|
2768
|
+
`omnivoice=${verification.omnivoiceSymbolCount} ` +
|
|
2769
|
+
`abi=${verification.abiSymbolCount}`,
|
|
2770
|
+
);
|
|
2771
|
+
if (omnivoiceInfo) {
|
|
2772
|
+
console.log(
|
|
2773
|
+
`[compile-libllama] omnivoice mode=${omnivoiceInfo.mode ?? "merged"} source=${omnivoiceInfo.source ?? "tools/omnivoice"}`,
|
|
2774
|
+
);
|
|
2775
|
+
}
|
|
2776
|
+
}
|
|
2777
|
+
}
|
|
2778
|
+
|
|
2779
|
+
if (args.dryRun) {
|
|
2780
|
+
stageLitertlmArtifacts({
|
|
2781
|
+
litertlmDir: args.litertlmDir,
|
|
2782
|
+
androidAssetsDir: args.androidAssetsDir,
|
|
2783
|
+
dryRun: true,
|
|
2784
|
+
});
|
|
2785
|
+
console.log(
|
|
2786
|
+
`[compile-libllama] (dry-run) plan complete: ${args.targets.length} target(s) (${srcDescription}).`,
|
|
2787
|
+
);
|
|
2788
|
+
return;
|
|
2789
|
+
}
|
|
2790
|
+
|
|
2791
|
+
// SIGSYS-handler shim only needed when an x86_64 ABI was built (matches
|
|
2792
|
+
// the bulk --abi path's behavior — see the comment in main()).
|
|
2793
|
+
if (args.targets.some((t) => t.androidAbi === "x86_64")) {
|
|
2794
|
+
await compileShimMain(["--skip-if-present"]);
|
|
2795
|
+
}
|
|
2796
|
+
|
|
2797
|
+
// Stage any prebuilt LiteRT-LM `.litertlm` text artifacts into the shared
|
|
2798
|
+
// on-device bundle assets (once — arch-independent). No-op unless
|
|
2799
|
+
// --litertlm-dir / ELIZA_LITERTLM_DIR is configured; GGUF stays the default.
|
|
2800
|
+
stageLitertlmArtifacts({
|
|
2801
|
+
litertlmDir: args.litertlmDir,
|
|
2802
|
+
androidAssetsDir: args.androidAssetsDir,
|
|
2803
|
+
});
|
|
2804
|
+
|
|
2805
|
+
console.log(
|
|
2806
|
+
`[compile-libllama] Built ${args.targets.map((t) => t.target).join(", ")} (${srcDescription}).`,
|
|
2807
|
+
);
|
|
2808
|
+
}
|
|
2809
|
+
|
|
1327
2810
|
const isMain =
|
|
1328
2811
|
process.argv[1] &&
|
|
1329
2812
|
path.resolve(process.argv[1]) === fileURLToPath(import.meta.url);
|