@elizaos/app-core 2.0.0-beta.3 → 2.0.11-beta.6

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.
Files changed (1530) hide show
  1. package/agent-bridge.d.ts +27 -0
  2. package/agent-bridge.d.ts.map +1 -0
  3. package/agent-bridge.js +26 -0
  4. package/api/__tests__/sandbox-test-helpers.js +1 -1
  5. package/api/auth/audit.js +1 -1
  6. package/api/auth/auth-context.js +1 -1
  7. package/api/auth/bootstrap-token.js +2 -2
  8. package/api/auth/index.d.ts +9 -10
  9. package/api/auth/index.d.ts.map +1 -1
  10. package/api/auth/index.js +9 -10
  11. package/api/auth/passwords.js +2 -2
  12. package/api/auth/sensitive-rate-limit.d.ts +1 -4
  13. package/api/auth/sensitive-rate-limit.d.ts.map +1 -1
  14. package/api/auth/sensitive-rate-limit.js +6 -6
  15. package/api/auth/sessions.js +2 -2
  16. package/api/auth-bootstrap-routes.d.ts +6 -13
  17. package/api/auth-bootstrap-routes.d.ts.map +1 -1
  18. package/api/auth-bootstrap-routes.js +14 -27
  19. package/api/auth-pairing-routes.d.ts +17 -0
  20. package/api/auth-pairing-routes.d.ts.map +1 -0
  21. package/api/auth-pairing-routes.js +300 -0
  22. package/api/auth-session-routes.d.ts.map +1 -1
  23. package/api/auth-session-routes.js +36 -15
  24. package/api/auth.d.ts +12 -19
  25. package/api/auth.d.ts.map +1 -1
  26. package/api/auth.js +32 -27
  27. package/api/automations-compat-routes.d.ts.map +1 -1
  28. package/api/automations-compat-routes.js +5 -5
  29. package/api/background-tasks-routes.d.ts +4 -0
  30. package/api/background-tasks-routes.d.ts.map +1 -0
  31. package/api/background-tasks-routes.js +63 -0
  32. package/api/catalog-routes.js +3 -3
  33. package/api/cloud-pair-route.d.ts +26 -0
  34. package/api/cloud-pair-route.d.ts.map +1 -0
  35. package/api/cloud-pair-route.js +222 -0
  36. package/api/cloud-voice-routes.d.ts +52 -0
  37. package/api/cloud-voice-routes.d.ts.map +1 -0
  38. package/api/cloud-voice-routes.js +50 -0
  39. package/api/compat-route-shared.d.ts +2 -2
  40. package/api/compat-route-shared.d.ts.map +1 -1
  41. package/api/compat-route-shared.js +11 -7
  42. package/api/credential-resolver.d.ts +2 -2
  43. package/api/credential-resolver.d.ts.map +1 -1
  44. package/api/credential-resolver.js +8 -2
  45. package/api/database-rows-compat-routes.d.ts.map +1 -1
  46. package/api/database-rows-compat-routes.js +69 -31
  47. package/api/dev-boot-history.d.ts +26 -0
  48. package/api/dev-boot-history.d.ts.map +1 -0
  49. package/api/dev-boot-history.js +69 -0
  50. package/api/dev-compat-routes.d.ts +5 -0
  51. package/api/dev-compat-routes.d.ts.map +1 -1
  52. package/api/dev-compat-routes.js +127 -4
  53. package/api/dev-console-log.d.ts +2 -2
  54. package/api/dev-console-log.d.ts.map +1 -1
  55. package/api/dev-console-log.js +8 -5
  56. package/api/dev-route-catalog.d.ts +58 -0
  57. package/api/dev-route-catalog.d.ts.map +1 -0
  58. package/api/dev-route-catalog.js +447 -0
  59. package/api/dev-stack.d.ts.map +1 -1
  60. package/api/dev-stack.js +6 -9
  61. package/api/first-run-routes.d.ts +4 -0
  62. package/api/first-run-routes.d.ts.map +1 -0
  63. package/api/first-run-routes.js +208 -0
  64. package/api/first-run-tts-route.d.ts +19 -0
  65. package/api/first-run-tts-route.d.ts.map +1 -0
  66. package/api/first-run-tts-route.js +59 -0
  67. package/api/internal-routes.d.ts +23 -0
  68. package/api/internal-routes.d.ts.map +1 -0
  69. package/api/internal-routes.js +203 -0
  70. package/api/ios-local-agent-transport.d.ts +36 -0
  71. package/api/ios-local-agent-transport.d.ts.map +1 -0
  72. package/api/ios-local-agent-transport.js +566 -0
  73. package/api/onboarding-voice-lines.d.ts +23 -0
  74. package/api/onboarding-voice-lines.d.ts.map +1 -0
  75. package/api/onboarding-voice-lines.js +8 -0
  76. package/api/perf-instrument.d.ts +43 -0
  77. package/api/perf-instrument.d.ts.map +1 -0
  78. package/api/perf-instrument.js +113 -0
  79. package/api/response.d.ts.map +1 -1
  80. package/api/response.js +14 -14
  81. package/api/runtime-mode-routes.d.ts.map +1 -1
  82. package/api/runtime-mode-routes.js +2 -2
  83. package/api/secrets-inventory-routes.js +2 -2
  84. package/api/secrets-manager-routes.d.ts +1 -1
  85. package/api/secrets-manager-routes.d.ts.map +1 -1
  86. package/api/secrets-manager-routes.js +9 -10
  87. package/api/sensitive-request-routes.js +5 -5
  88. package/api/server-cors.d.ts.map +1 -1
  89. package/api/server-cors.js +13 -2
  90. package/api/server-first-run-helpers.d.ts +26 -0
  91. package/api/server-first-run-helpers.d.ts.map +1 -0
  92. package/api/server-first-run-helpers.js +271 -0
  93. package/api/server-security.js +1 -1
  94. package/api/server-startup.d.ts.map +1 -1
  95. package/api/server-startup.js +3 -4
  96. package/api/server-wallet-trade.js +1 -1
  97. package/api/server.d.ts +4 -4
  98. package/api/server.d.ts.map +1 -1
  99. package/api/server.js +222 -88
  100. package/api/setup-contract.d.ts +63 -0
  101. package/api/setup-contract.d.ts.map +1 -0
  102. package/api/setup-contract.js +39 -0
  103. package/api/training-benchmarks.d.ts +97 -0
  104. package/api/training-benchmarks.d.ts.map +1 -0
  105. package/api/training-benchmarks.js +307 -0
  106. package/api/workbench-compat-routes.js +2 -2
  107. package/benchmark/cerebras-autowire.d.ts +28 -0
  108. package/benchmark/cerebras-autowire.d.ts.map +1 -0
  109. package/benchmark/cerebras-autowire.js +62 -0
  110. package/benchmark/lifeops-bench-handler.d.ts +36 -0
  111. package/benchmark/lifeops-bench-handler.d.ts.map +1 -1
  112. package/benchmark/lifeops-bench-handler.js +63 -1
  113. package/benchmark/lifeops-fake-backend.d.ts +39 -0
  114. package/benchmark/lifeops-fake-backend.d.ts.map +1 -1
  115. package/benchmark/lifeops-fake-backend.js +993 -21
  116. package/benchmark/mock-plugin.d.ts.map +1 -1
  117. package/benchmark/mock-plugin.js +0 -24
  118. package/benchmark/plugin.d.ts +2 -1
  119. package/benchmark/plugin.d.ts.map +1 -1
  120. package/benchmark/plugin.js +989 -68
  121. package/benchmark/replay-capture.d.ts +2 -2
  122. package/benchmark/replay-capture.d.ts.map +1 -1
  123. package/benchmark/replay-capture.js +3 -3
  124. package/benchmark/server-utils.d.ts +162 -9
  125. package/benchmark/server-utils.d.ts.map +1 -1
  126. package/benchmark/server-utils.js +625 -62
  127. package/benchmark/server.d.ts.map +1 -1
  128. package/benchmark/server.js +1962 -118
  129. package/boot-profile.d.ts +3 -0
  130. package/boot-profile.d.ts.map +1 -0
  131. package/boot-profile.js +30 -0
  132. package/browser.d.ts +23 -1
  133. package/browser.d.ts.map +1 -1
  134. package/browser.js +20 -1
  135. package/cli/argv.js +1 -1
  136. package/cli/banner.js +1 -1
  137. package/cli/command-format.js +2 -2
  138. package/cli/doctor/checks.d.ts.map +1 -1
  139. package/cli/doctor/checks.js +6 -6
  140. package/cli/plugins-cli.d.ts.map +1 -1
  141. package/cli/plugins-cli.js +77 -32
  142. package/cli/profile.d.ts.map +1 -1
  143. package/cli/profile.js +5 -4
  144. package/cli/program/build-program.js +4 -4
  145. package/cli/program/command-registry.d.ts.map +1 -1
  146. package/cli/program/command-registry.js +13 -11
  147. package/cli/program/help.js +5 -5
  148. package/cli/program/preaction.js +5 -5
  149. package/cli/program/register.auth.d.ts.map +1 -1
  150. package/cli/program/register.auth.js +6 -12
  151. package/cli/program/register.capability-router.d.ts +29 -0
  152. package/cli/program/register.capability-router.d.ts.map +1 -0
  153. package/cli/program/register.capability-router.js +568 -0
  154. package/cli/program/register.config.js +1 -1
  155. package/cli/program/register.configure.d.ts.map +1 -1
  156. package/cli/program/register.configure.js +1 -1
  157. package/cli/program/register.dashboard.d.ts.map +1 -1
  158. package/cli/program/register.dashboard.js +6 -7
  159. package/cli/program/register.db.d.ts.map +1 -1
  160. package/cli/program/register.db.js +3 -4
  161. package/cli/program/register.doctor.js +7 -7
  162. package/cli/program/register.setup.d.ts.map +1 -1
  163. package/cli/program/register.setup.js +14 -10
  164. package/cli/program/register.start.d.ts.map +1 -1
  165. package/cli/program/register.start.js +5 -3
  166. package/cli/program/register.subclis.js +3 -3
  167. package/cli/program/register.update.d.ts +6 -0
  168. package/cli/program/register.update.d.ts.map +1 -1
  169. package/cli/program/register.update.js +58 -6
  170. package/cli/program.js +1 -1
  171. package/cli/run-main.js +4 -4
  172. package/config/app-config.d.ts +2 -0
  173. package/config/app-config.d.ts.map +1 -0
  174. package/config/app-config.js +1 -0
  175. package/connectors/capacitor-jsc.d.ts.map +1 -1
  176. package/connectors/capacitor-jsc.js +16 -10
  177. package/connectors/capacitor-quickjs.d.ts.map +1 -1
  178. package/connectors/capacitor-quickjs.js +18 -13
  179. package/connectors/capacitor-sqlite.d.ts.map +1 -1
  180. package/connectors/capacitor-sqlite.js +27 -12
  181. package/dispatch/approval-queue.d.ts +37 -0
  182. package/dispatch/approval-queue.d.ts.map +1 -0
  183. package/dispatch/approval-queue.js +25 -0
  184. package/dispatch/channel-registry.d.ts +30 -0
  185. package/dispatch/channel-registry.d.ts.map +1 -0
  186. package/dispatch/channel-registry.js +22 -0
  187. package/dispatch/connector-registry.d.ts +39 -0
  188. package/dispatch/connector-registry.d.ts.map +1 -0
  189. package/dispatch/connector-registry.js +24 -0
  190. package/dispatch/index.d.ts +14 -0
  191. package/dispatch/index.d.ts.map +1 -0
  192. package/dispatch/index.js +13 -0
  193. package/dispatch/send-policy.d.ts +36 -0
  194. package/dispatch/send-policy.d.ts.map +1 -0
  195. package/dispatch/send-policy.js +16 -0
  196. package/entry.js +28 -11
  197. package/first-run/first-run-config.d.ts +55 -0
  198. package/first-run/first-run-config.d.ts.map +1 -0
  199. package/first-run/first-run-config.js +178 -0
  200. package/first-run/runtime-target.d.ts +4 -0
  201. package/first-run/runtime-target.d.ts.map +1 -0
  202. package/first-run/runtime-target.js +13 -0
  203. package/index.d.ts +16 -3
  204. package/index.d.ts.map +1 -1
  205. package/index.js +57 -33
  206. package/package.json +159 -50
  207. package/packaging/debian/apt-repo-config/README.md +18 -0
  208. package/packaging/debian/apt-repo-config/conf/distributions +11 -0
  209. package/packaging/flatpak/README.md +26 -16
  210. package/packaging/flatpak/ai.elizaos.App.metainfo.xml +17 -12
  211. package/packaging/flatpak/ai.elizaos.App.store.yml +5 -5
  212. package/packaging/flatpak/ai.elizaos.App.yml +10 -24
  213. package/packaging/flatpak/elizaos-app-wrapper.store.sh +2 -2
  214. package/packaging/flatpak/generate-sources.sh +74 -0
  215. package/packaging/flatpak/node-sources.json +7930 -0
  216. package/packaging/inno/build-inno.ps1 +34 -9
  217. package/packaging/msix/AppxManifest.store.xml +1 -1
  218. package/packaging/msix/README.md +39 -19
  219. package/packaging/msix/build-msix.ps1 +44 -14
  220. package/packaging/snap/snapcraft.yaml +22 -21
  221. package/packaging/test-packaging.sh +2 -2
  222. package/permissions/types.d.ts +1 -1
  223. package/permissions/types.js +1 -1
  224. package/platform/elizaos-agent-browser-stub.d.ts +144 -0
  225. package/platform/elizaos-agent-browser-stub.d.ts.map +1 -0
  226. package/platform/elizaos-agent-browser-stub.js +158 -0
  227. package/platform/elizaos-plugin-elizacloud-browser-stub.d.ts +34 -0
  228. package/platform/elizaos-plugin-elizacloud-browser-stub.d.ts.map +1 -0
  229. package/platform/elizaos-plugin-elizacloud-browser-stub.js +51 -0
  230. package/platform/empty-node-module.d.ts +148 -0
  231. package/platform/empty-node-module.d.ts.map +1 -1
  232. package/platform/empty-node-module.js +140 -3
  233. package/platform/ios-runtime-backends.d.ts +83 -0
  234. package/platform/ios-runtime-backends.d.ts.map +1 -0
  235. package/platform/ios-runtime-backends.js +133 -0
  236. package/platform/ios-runtime-bridge.d.ts +15 -0
  237. package/platform/ios-runtime-bridge.d.ts.map +1 -0
  238. package/platform/ios-runtime-bridge.js +527 -0
  239. package/platform/native-library-policy.d.ts +23 -0
  240. package/platform/native-library-policy.d.ts.map +1 -0
  241. package/platform/native-library-policy.js +112 -0
  242. package/platform/native-plugin-entrypoints.d.ts +19 -0
  243. package/platform/native-plugin-entrypoints.d.ts.map +1 -0
  244. package/platform/native-plugin-entrypoints.js +29 -0
  245. package/platforms/android/README.md +68 -10
  246. package/platforms/android/app/build.gradle +268 -3
  247. package/platforms/android/app/capacitor.build.gradle +18 -1
  248. package/platforms/android/app/proguard-rules.pro +17 -2
  249. package/platforms/android/app/src/androidTest/java/ai/elizaos/app/ElizaOsInstrumentedTest.java +1 -1
  250. package/platforms/android/app/src/main/AndroidManifest.xml +334 -17
  251. package/platforms/android/app/src/main/assets/runners/eliza-tasks.js +177 -0
  252. package/platforms/android/app/src/main/elizavoice-jni/CMakeLists.txt +100 -0
  253. package/platforms/android/app/src/main/elizavoice-jni/elizavoice-jni.cpp +1349 -0
  254. package/platforms/android/app/src/main/java/ai/elizaos/app/AgentPlugin.java +111 -171
  255. package/platforms/android/app/src/main/java/ai/elizaos/app/AndroidVirtualizationBridge.java +284 -0
  256. package/platforms/android/app/src/main/java/ai/elizaos/app/BatteryOptimizationPlugin.java +95 -0
  257. package/platforms/android/app/src/main/java/ai/elizaos/app/ElizaAccessibilityService.java +55 -0
  258. package/platforms/android/app/src/main/java/ai/elizaos/app/ElizaAgentService.java +1198 -141
  259. package/platforms/android/app/src/main/java/ai/elizaos/app/ElizaAndroidSystemBridge.java +83 -0
  260. package/platforms/android/app/src/main/java/ai/elizaos/app/ElizaAssistActivity.java +50 -1
  261. package/platforms/android/app/src/main/java/ai/elizaos/app/ElizaBootReceiver.java +90 -8
  262. package/platforms/android/app/src/main/java/ai/elizaos/app/ElizaBrowserActivity.java +2 -2
  263. package/platforms/android/app/src/main/java/ai/elizaos/app/ElizaCalendarActivity.java +1 -1
  264. package/platforms/android/app/src/main/java/ai/elizaos/app/ElizaCameraActivity.java +1 -1
  265. package/platforms/android/app/src/main/java/ai/elizaos/app/ElizaClockActivity.java +2 -2
  266. package/platforms/android/app/src/main/java/ai/elizaos/app/ElizaContactsActivity.java +1 -1
  267. package/platforms/android/app/src/main/java/ai/elizaos/app/ElizaDialActivity.java +1 -1
  268. package/platforms/android/app/src/main/java/ai/elizaos/app/ElizaInCallService.java +1 -1
  269. package/platforms/android/app/src/main/java/ai/elizaos/app/ElizaMmsReceiver.java +1 -1
  270. package/platforms/android/app/src/main/java/ai/elizaos/app/ElizaNativeBridge.java +22 -0
  271. package/platforms/android/app/src/main/java/ai/elizaos/app/ElizaNotificationListenerService.java +45 -0
  272. package/platforms/android/app/src/main/java/ai/elizaos/app/ElizaQuickActionsWidgetProvider.java +68 -0
  273. package/platforms/android/app/src/main/java/ai/elizaos/app/ElizaShareActivity.java +132 -0
  274. package/platforms/android/app/src/main/java/ai/elizaos/app/ElizaSmsComposeActivity.java +1 -1
  275. package/platforms/android/app/src/main/java/ai/elizaos/app/ElizaSmsGatewayService.java +268 -0
  276. package/platforms/android/app/src/main/java/ai/elizaos/app/ElizaSmsReceiver.java +12 -1
  277. package/platforms/android/app/src/main/java/ai/elizaos/app/ElizaTasksWorker.java +194 -0
  278. package/platforms/android/app/src/main/java/ai/elizaos/app/ElizaVoiceCaptureService.java +198 -0
  279. package/platforms/android/app/src/main/java/ai/elizaos/app/ElizaVoiceNative.java +205 -0
  280. package/platforms/android/app/src/main/java/ai/elizaos/app/ElizaVoicePlugin.java +498 -0
  281. package/platforms/android/app/src/main/java/ai/elizaos/app/ElizaVoiceTileService.java +39 -0
  282. package/platforms/android/app/src/main/java/ai/elizaos/app/ElizaWorkScheduler.java +60 -0
  283. package/platforms/android/app/src/main/java/ai/elizaos/app/GatewayConnectionService.java +53 -19
  284. package/platforms/android/app/src/main/java/ai/elizaos/app/MainActivity.java +160 -33
  285. package/platforms/android/app/src/main/java/ai/elizaos/app/ResourceProbePlugin.java +169 -0
  286. package/platforms/android/app/src/main/java/ai/elizaos/app/VoiceCapturePlugin.java +119 -0
  287. package/platforms/android/app/src/main/res/drawable/eliza_widget_background.xml +10 -0
  288. package/platforms/android/app/src/main/res/drawable/eliza_widget_button_background.xml +13 -0
  289. package/platforms/android/app/src/main/res/drawable/splash.png +0 -0
  290. package/platforms/android/app/src/main/res/drawable-land-hdpi/splash.png +0 -0
  291. package/platforms/android/app/src/main/res/drawable-land-mdpi/splash.png +0 -0
  292. package/platforms/android/app/src/main/res/drawable-land-xhdpi/splash.png +0 -0
  293. package/platforms/android/app/src/main/res/drawable-land-xxhdpi/splash.png +0 -0
  294. package/platforms/android/app/src/main/res/drawable-land-xxxhdpi/splash.png +0 -0
  295. package/platforms/android/app/src/main/res/drawable-port-hdpi/splash.png +0 -0
  296. package/platforms/android/app/src/main/res/drawable-port-mdpi/splash.png +0 -0
  297. package/platforms/android/app/src/main/res/drawable-port-xhdpi/splash.png +0 -0
  298. package/platforms/android/app/src/main/res/drawable-port-xxhdpi/splash.png +0 -0
  299. package/platforms/android/app/src/main/res/drawable-port-xxxhdpi/splash.png +0 -0
  300. package/platforms/android/app/src/main/res/layout/eliza_quick_actions_widget.xml +86 -0
  301. package/platforms/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml +2 -1
  302. package/platforms/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml +2 -1
  303. package/platforms/android/app/src/main/res/mipmap-hdpi/ic_launcher.png +0 -0
  304. package/platforms/android/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png +0 -0
  305. package/platforms/android/app/src/main/res/mipmap-hdpi/ic_launcher_monochrome.png +0 -0
  306. package/platforms/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png +0 -0
  307. package/platforms/android/app/src/main/res/mipmap-mdpi/ic_launcher.png +0 -0
  308. package/platforms/android/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png +0 -0
  309. package/platforms/android/app/src/main/res/mipmap-mdpi/ic_launcher_monochrome.png +0 -0
  310. package/platforms/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png +0 -0
  311. package/platforms/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png +0 -0
  312. package/platforms/android/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png +0 -0
  313. package/platforms/android/app/src/main/res/mipmap-xhdpi/ic_launcher_monochrome.png +0 -0
  314. package/platforms/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png +0 -0
  315. package/platforms/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png +0 -0
  316. package/platforms/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png +0 -0
  317. package/platforms/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_monochrome.png +0 -0
  318. package/platforms/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png +0 -0
  319. package/platforms/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png +0 -0
  320. package/platforms/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png +0 -0
  321. package/platforms/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_monochrome.png +0 -0
  322. package/platforms/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png +0 -0
  323. package/platforms/android/app/src/main/res/values/android_app_actions.xml +48 -0
  324. package/platforms/android/app/src/main/res/values/colors.xml +8 -0
  325. package/platforms/android/app/src/main/res/values/ic_launcher_background.xml +2 -2
  326. package/platforms/android/app/src/main/res/values/strings.xml +2 -2
  327. package/platforms/android/app/src/main/res/values/styles.xml +25 -1
  328. package/platforms/android/app/src/main/res/xml/eliza_accessibility_service.xml +9 -0
  329. package/platforms/android/app/src/main/res/xml/eliza_quick_actions_widget.xml +13 -0
  330. package/platforms/android/app/src/main/res/xml/shortcuts.xml +121 -0
  331. package/platforms/android/build.gradle +2 -2
  332. package/platforms/android/capacitor-cordova-android-plugins/build.gradle +9 -3
  333. package/platforms/android/capacitor-cordova-android-plugins/cordova.variables.gradle +6 -2
  334. package/platforms/android/capacitor-cordova-android-plugins/src/main/AndroidManifest.xml +7 -2
  335. package/platforms/android/capacitor-cordova-android-plugins/src/main/java/.gitkeep +0 -1
  336. package/platforms/android/capacitor.settings.gradle +66 -16
  337. package/platforms/android/gradle.properties +1 -0
  338. package/platforms/android/update-manifest/generate-manifest.mjs +97 -0
  339. package/platforms/android/update-manifest/schema.json +26 -0
  340. package/platforms/apple-store-entitlements.reviewed.json +155 -0
  341. package/platforms/electrobun/.generated/brand-config.json +3 -2
  342. package/platforms/electrobun/LICENSE +21 -0
  343. package/platforms/electrobun/README.md +15 -1
  344. package/platforms/electrobun/assets/appIcon.icns +0 -0
  345. package/platforms/electrobun/assets/appIcon.ico +0 -0
  346. package/platforms/electrobun/assets/appIcon.iconset/icon_128x128.png +0 -0
  347. package/platforms/electrobun/assets/appIcon.iconset/icon_128x128@2x.png +0 -0
  348. package/platforms/electrobun/assets/appIcon.iconset/icon_16x16.png +0 -0
  349. package/platforms/electrobun/assets/appIcon.iconset/icon_16x16@2x.png +0 -0
  350. package/platforms/electrobun/assets/appIcon.iconset/icon_256x256.png +0 -0
  351. package/platforms/electrobun/assets/appIcon.iconset/icon_256x256@2x.png +0 -0
  352. package/platforms/electrobun/assets/appIcon.iconset/icon_32x32.png +0 -0
  353. package/platforms/electrobun/assets/appIcon.iconset/icon_32x32@2x.png +0 -0
  354. package/platforms/electrobun/assets/appIcon.iconset/icon_512x512.png +0 -0
  355. package/platforms/electrobun/assets/brand-config.json +6 -6
  356. package/platforms/electrobun/biome.json +9 -9
  357. package/platforms/electrobun/docs/capability-collapse-matrix.json +318 -0
  358. package/platforms/electrobun/docs/capability-collapse-matrix.md +129 -0
  359. package/platforms/electrobun/docs/capability-routing.md +86 -0
  360. package/platforms/electrobun/docs/convergence-audit.json +3505 -0
  361. package/platforms/electrobun/docs/convergence-audit.md +694 -0
  362. package/platforms/electrobun/docs/database-boot-policy.md +90 -0
  363. package/platforms/electrobun/docs/riscv64-port.md +175 -0
  364. package/platforms/electrobun/docs/startup-first-run-cleanup.md +18 -0
  365. package/platforms/electrobun/docs/trace-first-annotations.md +52 -0
  366. package/platforms/electrobun/docs/ui-boundary-audit.json +580 -0
  367. package/platforms/electrobun/docs/ui-boundary-audit.md +257 -0
  368. package/platforms/electrobun/electrobun.config.ts +592 -364
  369. package/platforms/electrobun/entitlements/JUSTIFICATIONS.md +141 -0
  370. package/platforms/electrobun/entitlements/README.md +34 -6
  371. package/platforms/electrobun/entitlements/mas-bun.entitlements +15 -0
  372. package/platforms/electrobun/entitlements/mas.entitlements +6 -4
  373. package/platforms/electrobun/native/macos/window-effects.mm +1522 -0
  374. package/platforms/electrobun/package.json +18 -12
  375. package/platforms/electrobun/remotes/fs/README.md +70 -0
  376. package/platforms/electrobun/remotes/fs/electrobun.config.ts +38 -0
  377. package/platforms/electrobun/remotes/fs/package.json +12 -0
  378. package/platforms/electrobun/remotes/fs/plugin.json +25 -0
  379. package/platforms/electrobun/remotes/fs/src/bun/errors.ts +57 -0
  380. package/platforms/electrobun/remotes/fs/src/bun/file-limits.ts +50 -0
  381. package/platforms/electrobun/remotes/fs/src/bun/fs-service.ts +389 -0
  382. package/platforms/electrobun/remotes/fs/src/bun/path-guard.ts +270 -0
  383. package/platforms/electrobun/remotes/fs/src/bun/protocol.ts +149 -0
  384. package/platforms/electrobun/remotes/fs/src/bun/worker.ts +174 -0
  385. package/platforms/electrobun/remotes/fs/src/dev/phase5-smoke.ts +171 -0
  386. package/platforms/electrobun/remotes/fs/src/web/index.html +8 -0
  387. package/platforms/electrobun/remotes/git/README.md +75 -0
  388. package/platforms/electrobun/remotes/git/electrobun.config.ts +44 -0
  389. package/platforms/electrobun/remotes/git/package.json +12 -0
  390. package/platforms/electrobun/remotes/git/plugin.json +31 -0
  391. package/platforms/electrobun/remotes/git/src/bun/errors.ts +69 -0
  392. package/platforms/electrobun/remotes/git/src/bun/git-command.ts +156 -0
  393. package/platforms/electrobun/remotes/git/src/bun/git-service.ts +446 -0
  394. package/platforms/electrobun/remotes/git/src/bun/operation-history.ts +124 -0
  395. package/platforms/electrobun/remotes/git/src/bun/protocol.ts +252 -0
  396. package/platforms/electrobun/remotes/git/src/bun/worker.ts +316 -0
  397. package/platforms/electrobun/remotes/git/src/dev/phase7-smoke.ts +141 -0
  398. package/platforms/electrobun/remotes/git/src/web/index.html +8 -0
  399. package/platforms/electrobun/remotes/local-model/README.md +138 -0
  400. package/platforms/electrobun/remotes/local-model/electrobun.config.ts +46 -0
  401. package/platforms/electrobun/remotes/local-model/package.json +12 -0
  402. package/platforms/electrobun/remotes/local-model/plugin.json +33 -0
  403. package/platforms/electrobun/remotes/local-model/src/bun/download-state.ts +115 -0
  404. package/platforms/electrobun/remotes/local-model/src/bun/eliza1-catalog.ts +425 -0
  405. package/platforms/electrobun/remotes/local-model/src/bun/errors.ts +74 -0
  406. package/platforms/electrobun/remotes/local-model/src/bun/hf-eliza1-client.ts +169 -0
  407. package/platforms/electrobun/remotes/local-model/src/bun/local-inference-api-client.ts +245 -0
  408. package/platforms/electrobun/remotes/local-model/src/bun/model-service.ts +490 -0
  409. package/platforms/electrobun/remotes/local-model/src/bun/protocol.ts +301 -0
  410. package/platforms/electrobun/remotes/local-model/src/bun/worker.ts +248 -0
  411. package/platforms/electrobun/remotes/local-model/src/dev/phase8-smoke.ts +117 -0
  412. package/platforms/electrobun/remotes/local-model/src/web/index.html +13 -0
  413. package/platforms/electrobun/remotes/pty/README.md +65 -0
  414. package/platforms/electrobun/remotes/pty/electrobun.config.ts +47 -0
  415. package/platforms/electrobun/remotes/pty/package.json +12 -0
  416. package/platforms/electrobun/remotes/pty/plugin.json +34 -0
  417. package/platforms/electrobun/remotes/pty/src/bun/errors.ts +57 -0
  418. package/platforms/electrobun/remotes/pty/src/bun/output-buffer.ts +127 -0
  419. package/platforms/electrobun/remotes/pty/src/bun/protocol.ts +192 -0
  420. package/platforms/electrobun/remotes/pty/src/bun/pty-service.ts +562 -0
  421. package/platforms/electrobun/remotes/pty/src/bun/worker.ts +218 -0
  422. package/platforms/electrobun/remotes/pty/src/dev/phase6-smoke.ts +127 -0
  423. package/platforms/electrobun/remotes/pty/src/web/index.html +8 -0
  424. package/platforms/electrobun/remotes/runtime/README.md +370 -0
  425. package/platforms/electrobun/remotes/runtime/electrobun.config.ts +48 -0
  426. package/platforms/electrobun/remotes/runtime/package.json +14 -0
  427. package/platforms/electrobun/remotes/runtime/plugin.json +30 -0
  428. package/platforms/electrobun/remotes/runtime/src/bun/api-client.ts +620 -0
  429. package/platforms/electrobun/remotes/runtime/src/bun/errors.ts +45 -0
  430. package/platforms/electrobun/remotes/runtime/src/bun/log-buffer.ts +33 -0
  431. package/platforms/electrobun/remotes/runtime/src/bun/protocol.ts +366 -0
  432. package/platforms/electrobun/remotes/runtime/src/bun/route-discovery.ts +419 -0
  433. package/platforms/electrobun/remotes/runtime/src/bun/runtime-manager.ts +423 -0
  434. package/platforms/electrobun/remotes/runtime/src/bun/sse-parser.ts +99 -0
  435. package/platforms/electrobun/remotes/runtime/src/bun/stream-manager.ts +887 -0
  436. package/platforms/electrobun/remotes/runtime/src/bun/worker.ts +1231 -0
  437. package/platforms/electrobun/remotes/runtime/src/dev/phase1-smoke.ts +34 -0
  438. package/platforms/electrobun/remotes/runtime/src/dev/phase2-smoke.ts +86 -0
  439. package/platforms/electrobun/remotes/runtime/src/dev/phase3-smoke.ts +141 -0
  440. package/platforms/electrobun/remotes/runtime/src/web/index.css +187 -0
  441. package/platforms/electrobun/remotes/runtime/src/web/index.html +76 -0
  442. package/platforms/electrobun/remotes/runtime/src/web/index.ts +192 -0
  443. package/platforms/electrobun/remotes/surface/README.md +201 -0
  444. package/platforms/electrobun/remotes/surface/electrobun.config.ts +38 -0
  445. package/platforms/electrobun/remotes/surface/package.json +12 -0
  446. package/platforms/electrobun/remotes/surface/plugin.json +28 -0
  447. package/platforms/electrobun/remotes/surface/src/bun/worker.ts +132 -0
  448. package/platforms/electrobun/remotes/surface/src/dev/phase4-smoke.ts +566 -0
  449. package/platforms/electrobun/remotes/surface/src/protocol/event-types.ts +84 -0
  450. package/platforms/electrobun/remotes/surface/src/protocol/runtime-client.ts +673 -0
  451. package/platforms/electrobun/remotes/surface/src/web/app.ts +595 -0
  452. package/platforms/electrobun/remotes/surface/src/web/index.css +460 -0
  453. package/platforms/electrobun/remotes/surface/src/web/index.html +466 -0
  454. package/platforms/electrobun/remotes/surface/src/web/index.ts +5 -0
  455. package/platforms/electrobun/remotes/surface/src/web/render.ts +455 -0
  456. package/platforms/electrobun/remotes/surface/src/web/state.ts +427 -0
  457. package/platforms/electrobun/scripts/build-macos-effects.sh +4 -0
  458. package/platforms/electrobun/scripts/ensure-build-folder.ts +28 -0
  459. package/platforms/electrobun/scripts/ensure-whisper-gguf.sh +55 -0
  460. package/platforms/electrobun/scripts/ensure-whisper-model.sh +22 -80
  461. package/platforms/electrobun/scripts/generate-convergence-audit.ts +1203 -0
  462. package/platforms/electrobun/scripts/local-adhoc-sign-macos.ts +159 -159
  463. package/platforms/electrobun/scripts/postwrap-diagnostics.ts +424 -339
  464. package/platforms/electrobun/scripts/postwrap-sign-runtime-macos.ts +302 -271
  465. package/platforms/electrobun/scripts/smoke-test-windows.ps1 +17 -16
  466. package/platforms/electrobun/scripts/smoke-test.sh +5 -7
  467. package/platforms/electrobun/scripts/sync-web-assets.mjs +13 -13
  468. package/platforms/electrobun/scripts/verify-rpc-handlers.ts +109 -110
  469. package/platforms/electrobun/scripts/verify-windows-installer-proof.ps1 +3 -8
  470. package/platforms/electrobun/src/__stubs__/bun-ffi.ts +31 -31
  471. package/platforms/electrobun/src/__stubs__/electrobun-bun.ts +1 -1
  472. package/platforms/electrobun/src/agent-ready-state.ts +8 -8
  473. package/platforms/electrobun/src/agent-reset-from-main.test.ts +162 -0
  474. package/platforms/electrobun/src/agent-reset-from-main.ts +62 -62
  475. package/platforms/electrobun/src/agent-status-rpc.test.ts +95 -0
  476. package/platforms/electrobun/src/agent-status-rpc.ts +156 -0
  477. package/platforms/electrobun/src/api-base.test.ts +247 -0
  478. package/platforms/electrobun/src/api-base.ts +202 -93
  479. package/platforms/electrobun/src/application-menu-action-registry.ts +9 -9
  480. package/platforms/electrobun/src/application-menu.ts +348 -348
  481. package/platforms/electrobun/src/background-notice.ts +36 -36
  482. package/platforms/electrobun/src/boot-progress.test.ts +188 -0
  483. package/platforms/electrobun/src/boot-progress.ts +111 -0
  484. package/platforms/electrobun/src/brand-config.test.ts +39 -0
  485. package/platforms/electrobun/src/brand-config.ts +141 -129
  486. package/platforms/electrobun/src/bridge/browser-tabs-renderer-registry.ts +28 -28
  487. package/platforms/electrobun/src/bridge/electrobun-boot-config.ts +42 -0
  488. package/platforms/electrobun/src/bridge/electrobun-crypto-ready.ts +120 -0
  489. package/platforms/electrobun/src/bridge/electrobun-direct-rpc.ts +342 -357
  490. package/platforms/electrobun/src/bridge/electrobun-stub.ts +13 -13
  491. package/platforms/electrobun/src/browser-workspace-bridge-server.ts +285 -243
  492. package/platforms/electrobun/src/cloud-auth-window.ts +136 -136
  493. package/platforms/electrobun/src/cloud-disconnect-from-main.ts +90 -90
  494. package/platforms/electrobun/src/config-and-auth-rpc.test.ts +256 -0
  495. package/platforms/electrobun/src/config-and-auth-rpc.ts +302 -0
  496. package/platforms/electrobun/src/conversations-and-character-rpc.test.ts +185 -0
  497. package/platforms/electrobun/src/conversations-and-character-rpc.ts +131 -0
  498. package/platforms/electrobun/src/dashboard-rpc.test.ts +200 -0
  499. package/platforms/electrobun/src/dashboard-rpc.ts +344 -0
  500. package/platforms/electrobun/src/database/database-lock.ts +141 -0
  501. package/platforms/electrobun/src/database/database-mode.ts +149 -0
  502. package/platforms/electrobun/src/database/database-recovery.ts +72 -0
  503. package/platforms/electrobun/src/database/database-snapshot.ts +190 -0
  504. package/platforms/electrobun/src/database/database.test.ts +196 -0
  505. package/platforms/electrobun/src/database/index.ts +5 -0
  506. package/platforms/electrobun/src/database/pglite-paths.ts +100 -0
  507. package/platforms/electrobun/src/desktop-deep-link-events.test.ts +30 -0
  508. package/platforms/electrobun/src/desktop-deep-link-events.ts +17 -0
  509. package/platforms/electrobun/src/desktop-http-request.test.ts +73 -73
  510. package/platforms/electrobun/src/desktop-http-request.ts +85 -85
  511. package/platforms/electrobun/src/desktop-pill-config.test.ts +27 -0
  512. package/platforms/electrobun/src/desktop-pill-config.ts +40 -0
  513. package/platforms/electrobun/src/desktop-test-bridge-server.ts +204 -204
  514. package/platforms/electrobun/src/desktop-tray-config.test.ts +87 -0
  515. package/platforms/electrobun/src/desktop-tray-config.ts +84 -0
  516. package/platforms/electrobun/src/devtools-layout.ts +41 -41
  517. package/platforms/electrobun/src/diagnostic-format.test.ts +71 -0
  518. package/platforms/electrobun/src/diagnostic-format.ts +75 -36
  519. package/platforms/electrobun/src/dynamic-view-rpc-schema.test.ts +37 -0
  520. package/platforms/electrobun/src/dynamic-views/README.md +44 -0
  521. package/platforms/electrobun/src/dynamic-views/demo/agent-run-trace.html +135 -0
  522. package/platforms/electrobun/src/dynamic-views/errors.ts +29 -0
  523. package/platforms/electrobun/src/dynamic-views/host.test.ts +353 -0
  524. package/platforms/electrobun/src/dynamic-views/host.ts +332 -0
  525. package/platforms/electrobun/src/dynamic-views/index.ts +57 -0
  526. package/platforms/electrobun/src/dynamic-views/kiosk-canvas.ts +89 -0
  527. package/platforms/electrobun/src/dynamic-views/registry.test.ts +139 -0
  528. package/platforms/electrobun/src/dynamic-views/registry.ts +196 -0
  529. package/platforms/electrobun/src/dynamic-views/session-manager.test.ts +355 -0
  530. package/platforms/electrobun/src/dynamic-views/session-manager.ts +348 -0
  531. package/platforms/electrobun/src/dynamic-views/types.ts +105 -0
  532. package/platforms/electrobun/src/electrobun-boot-config.test.ts +50 -0
  533. package/platforms/electrobun/src/electrobun-config.test.ts +62 -0
  534. package/platforms/electrobun/src/electrobun-crypto-ready.test.ts +65 -0
  535. package/platforms/electrobun/src/electrobun-window-options.ts +25 -0
  536. package/platforms/electrobun/src/extension-rpc.test.ts +88 -0
  537. package/platforms/electrobun/src/extension-rpc.ts +102 -0
  538. package/platforms/electrobun/src/fatal-shutdown.test.ts +10 -10
  539. package/platforms/electrobun/src/fatal-shutdown.ts +1 -1
  540. package/platforms/electrobun/src/first-party-remotes.test.ts +169 -0
  541. package/platforms/electrobun/src/first-party-remotes.ts +297 -0
  542. package/platforms/electrobun/src/first-run-rpc.test.ts +192 -0
  543. package/platforms/electrobun/src/first-run-rpc.ts +146 -0
  544. package/platforms/electrobun/src/floating-chat-window.ts +181 -181
  545. package/platforms/electrobun/src/inbox-rpc.test.ts +123 -0
  546. package/platforms/electrobun/src/inbox-rpc.ts +158 -0
  547. package/platforms/electrobun/src/index.ts +2555 -2096
  548. package/platforms/electrobun/src/kiosk-mode.ts +50 -0
  549. package/platforms/electrobun/src/launch/index.ts +4 -0
  550. package/platforms/electrobun/src/launch/launch-dynamic-view.ts +37 -0
  551. package/platforms/electrobun/src/launch/launch-orchestrator.test.ts +224 -0
  552. package/platforms/electrobun/src/launch/launch-orchestrator.ts +456 -0
  553. package/platforms/electrobun/src/launch/launch-store.test.ts +97 -0
  554. package/platforms/electrobun/src/launch/launch-store.ts +134 -0
  555. package/platforms/electrobun/src/launch/types.ts +103 -0
  556. package/platforms/electrobun/src/launch/views/launch-diagnostics.html +205 -0
  557. package/platforms/electrobun/src/lifecycle/agent-ready-publish.test.ts +50 -0
  558. package/platforms/electrobun/src/lifecycle/agent-ready-publish.ts +27 -0
  559. package/platforms/electrobun/src/lifecycle/api-base-owner.ts +42 -31
  560. package/platforms/electrobun/src/lifecycle/desktop-session-prime.ts +44 -44
  561. package/platforms/electrobun/src/logger.ts +14 -14
  562. package/platforms/electrobun/src/main-window-runtime.ts +83 -83
  563. package/platforms/electrobun/src/main-window-session.test.ts +109 -0
  564. package/platforms/electrobun/src/main-window-session.ts +87 -51
  565. package/platforms/electrobun/src/menu-reset-from-main.ts +158 -158
  566. package/platforms/electrobun/src/native/agent-env.test.ts +52 -0
  567. package/platforms/electrobun/src/native/agent-runtime-layout.test.ts +42 -0
  568. package/platforms/electrobun/src/native/agent-state-dir.test.ts +91 -0
  569. package/platforms/electrobun/src/native/agent.ts +2122 -1682
  570. package/platforms/electrobun/src/native/auth-bridge.test.ts +67 -0
  571. package/platforms/electrobun/src/native/auth-bridge.ts +464 -360
  572. package/platforms/electrobun/src/native/browser-workspace.ts +723 -471
  573. package/platforms/electrobun/src/native/camera.ts +50 -50
  574. package/platforms/electrobun/src/native/canvas.ts +444 -445
  575. package/platforms/electrobun/src/native/credentials.ts +673 -616
  576. package/platforms/electrobun/src/native/desktop-window.test.ts +300 -0
  577. package/platforms/electrobun/src/native/desktop.ts +2196 -2156
  578. package/platforms/electrobun/src/native/editor-bridge.ts +201 -201
  579. package/platforms/electrobun/src/native/file-watcher.ts +154 -154
  580. package/platforms/electrobun/src/native/gateway.ts +179 -180
  581. package/platforms/electrobun/src/native/gpu-window.ts +256 -256
  582. package/platforms/electrobun/src/native/index.ts +76 -74
  583. package/platforms/electrobun/src/native/location.test.ts +44 -0
  584. package/platforms/electrobun/src/native/location.ts +90 -80
  585. package/platforms/electrobun/src/native/loopback-port.ts +60 -60
  586. package/platforms/electrobun/src/native/mac-window-effects.ts +166 -104
  587. package/platforms/electrobun/src/native/music-player.ts +38 -38
  588. package/platforms/electrobun/src/native/permissions-shared.ts +249 -150
  589. package/platforms/electrobun/src/native/permissions.ts +301 -208
  590. package/platforms/electrobun/src/native/power-state.ts +129 -129
  591. package/platforms/electrobun/src/native/remote-plugin-host.test.ts +1394 -0
  592. package/platforms/electrobun/src/native/remote-plugin-host.ts +1531 -0
  593. package/platforms/electrobun/src/native/screencapture.ts +667 -573
  594. package/platforms/electrobun/src/native/steward.ts +207 -204
  595. package/platforms/electrobun/src/native/swabble.ts +68 -324
  596. package/platforms/electrobun/src/native/talkmode.ts +253 -422
  597. package/platforms/electrobun/src/native/webgpu-browser-support.test.ts +18 -0
  598. package/platforms/electrobun/src/native/webgpu-browser-support.ts +165 -147
  599. package/platforms/electrobun/src/native/whisper-env.test.ts +71 -0
  600. package/platforms/electrobun/src/native/whisper-env.ts +68 -0
  601. package/platforms/electrobun/src/native-onboarding.ts +270 -0
  602. package/platforms/electrobun/src/onboarding-overlay-window.ts +141 -0
  603. package/platforms/electrobun/src/persisted-deployment.ts +91 -0
  604. package/platforms/electrobun/src/pill-window.test.ts +91 -0
  605. package/platforms/electrobun/src/pill-window.ts +99 -0
  606. package/platforms/electrobun/src/preload-validation.ts +44 -44
  607. package/platforms/electrobun/src/preload.js +1 -1
  608. package/platforms/electrobun/src/print-electrobun-dev-settings-banner.ts +120 -120
  609. package/platforms/electrobun/src/renderer-api-proxy.test.ts +73 -0
  610. package/platforms/electrobun/src/renderer-api-proxy.ts +86 -0
  611. package/platforms/electrobun/src/renderer-static.test.ts +53 -0
  612. package/platforms/electrobun/src/renderer-static.ts +144 -57
  613. package/platforms/electrobun/src/rpc-handler-slices.ts +121 -0
  614. package/platforms/electrobun/src/rpc-handlers.test.ts +267 -0
  615. package/platforms/electrobun/src/rpc-handlers.ts +1306 -913
  616. package/platforms/electrobun/src/rpc-parse-utils.ts +57 -0
  617. package/platforms/electrobun/src/rpc-port-resolver.test.ts +45 -0
  618. package/platforms/electrobun/src/rpc-port-resolver.ts +31 -0
  619. package/platforms/electrobun/src/rpc-schema.ts +2556 -1619
  620. package/platforms/electrobun/src/runtime-layout.ts +105 -105
  621. package/platforms/electrobun/src/runtime-permissions.ts +95 -95
  622. package/platforms/electrobun/src/runtime-rpc.test.ts +126 -0
  623. package/platforms/electrobun/src/runtime-rpc.ts +237 -0
  624. package/platforms/electrobun/src/screenshot-dev-server.ts +87 -87
  625. package/platforms/electrobun/src/settings-mutations-rpc.test.ts +193 -0
  626. package/platforms/electrobun/src/settings-mutations-rpc.ts +220 -0
  627. package/platforms/electrobun/src/startup-trace.ts +274 -270
  628. package/platforms/electrobun/src/subscription-rpc.test.ts +89 -0
  629. package/platforms/electrobun/src/subscription-rpc.ts +192 -0
  630. package/platforms/electrobun/src/surface-windows.test.ts +355 -0
  631. package/platforms/electrobun/src/surface-windows.ts +410 -410
  632. package/platforms/electrobun/src/trace/README.md +73 -0
  633. package/platforms/electrobun/src/trace/errors.ts +21 -0
  634. package/platforms/electrobun/src/trace/index.ts +40 -0
  635. package/platforms/electrobun/src/trace/trace-dynamic-view.ts +40 -0
  636. package/platforms/electrobun/src/trace/trace-host-requests.ts +473 -0
  637. package/platforms/electrobun/src/trace/trace-service.test.ts +186 -0
  638. package/platforms/electrobun/src/trace/trace-service.ts +324 -0
  639. package/platforms/electrobun/src/trace/trace-store.test.ts +141 -0
  640. package/platforms/electrobun/src/trace/trace-store.ts +551 -0
  641. package/platforms/electrobun/src/trace/types.ts +250 -0
  642. package/platforms/electrobun/src/trace/views/agent-run-trace.html +311 -0
  643. package/platforms/electrobun/src/types/web-speech.d.ts +28 -28
  644. package/platforms/electrobun/src/types.ts +5 -5
  645. package/platforms/electrobun/src/update-availability.test.ts +72 -0
  646. package/platforms/electrobun/src/update-availability.ts +90 -0
  647. package/platforms/electrobun/src/update-rpc.test.ts +83 -0
  648. package/platforms/electrobun/src/update-rpc.ts +123 -0
  649. package/platforms/electrobun/src/voice/README.md +184 -0
  650. package/platforms/electrobun/src/voice/errors.ts +42 -0
  651. package/platforms/electrobun/src/voice/index.ts +78 -0
  652. package/platforms/electrobun/src/voice/types.ts +316 -0
  653. package/platforms/electrobun/src/voice/voice-host-requests.ts +259 -0
  654. package/platforms/electrobun/src/voice/voice-latency-budget.test.ts +66 -0
  655. package/platforms/electrobun/src/voice/voice-latency-budget.ts +243 -0
  656. package/platforms/electrobun/src/voice/voice-live-validation.test.ts +352 -0
  657. package/platforms/electrobun/src/voice/voice-live-validation.ts +838 -0
  658. package/platforms/electrobun/src/voice/voice-pipeline.ts +250 -0
  659. package/platforms/electrobun/src/voice/voice-playback-adapter.ts +31 -0
  660. package/platforms/electrobun/src/voice/voice-runtime-adapter.test.ts +213 -0
  661. package/platforms/electrobun/src/voice/voice-runtime-adapter.ts +686 -0
  662. package/platforms/electrobun/src/voice/voice-service.test.ts +561 -0
  663. package/platforms/electrobun/src/voice/voice-service.ts +1027 -0
  664. package/platforms/electrobun/src/voice/voice-stream-coordinator.test.ts +115 -0
  665. package/platforms/electrobun/src/voice/voice-stream-coordinator.ts +270 -0
  666. package/platforms/electrobun/src/voice/voice-trace.ts +97 -0
  667. package/platforms/electrobun/src/voice/voice-tts-chunker.test.ts +91 -0
  668. package/platforms/electrobun/src/voice/voice-tts-chunker.ts +194 -0
  669. package/platforms/electrobun/src/windows-cef-profile.ts +88 -88
  670. package/platforms/electrobun/tsconfig.json +73 -13
  671. package/platforms/electrobun/update-channels.json +22 -0
  672. package/platforms/electrobun/vitest.electrobun.config.ts +72 -42
  673. package/platforms/ios/App/App/App.entitlements +4 -0
  674. package/platforms/ios/App/App/AppDelegate.swift +80 -18
  675. package/platforms/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-ios-marketing-1024.png +0 -0
  676. package/platforms/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-ipad-20x20@1x.png +0 -0
  677. package/platforms/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-ipad-20x20@2x.png +0 -0
  678. package/platforms/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-ipad-29x29@1x.png +0 -0
  679. package/platforms/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-ipad-29x29@2x.png +0 -0
  680. package/platforms/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-ipad-40x40@1x.png +0 -0
  681. package/platforms/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-ipad-40x40@2x.png +0 -0
  682. package/platforms/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-ipad-76x76@1x.png +0 -0
  683. package/platforms/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-ipad-76x76@2x.png +0 -0
  684. package/platforms/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-ipad-83_5x83_5@2x.png +0 -0
  685. package/platforms/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-iphone-20x20@2x.png +0 -0
  686. package/platforms/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-iphone-20x20@3x.png +0 -0
  687. package/platforms/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-iphone-29x29@2x.png +0 -0
  688. package/platforms/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-iphone-29x29@3x.png +0 -0
  689. package/platforms/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-iphone-40x40@2x.png +0 -0
  690. package/platforms/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-iphone-40x40@3x.png +0 -0
  691. package/platforms/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-iphone-60x60@2x.png +0 -0
  692. package/platforms/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-iphone-60x60@3x.png +0 -0
  693. package/platforms/ios/App/App/Base.lproj/LaunchScreen.storyboard +1 -4
  694. package/platforms/ios/App/App/ComputerUseBridge.swift +589 -0
  695. package/platforms/ios/App/App/DeviceActivityMonitorExtension/DeviceActivityMonitorExtension.entitlements +12 -0
  696. package/platforms/ios/App/App/DeviceActivityMonitorExtension/DeviceActivityMonitorExtension.swift +34 -0
  697. package/platforms/ios/App/App/DeviceActivityMonitorExtension/Info.plist +29 -0
  698. package/platforms/ios/App/App/DeviceActivityReportExtension/DeviceActivityReportExtension.entitlements +12 -0
  699. package/platforms/ios/App/App/DeviceActivityReportExtension/DeviceActivityReportExtension.swift +53 -0
  700. package/platforms/ios/App/App/DeviceActivityReportExtension/Info.plist +27 -0
  701. package/platforms/ios/App/App/ElizaAppIntents.swift +183 -0
  702. package/platforms/ios/App/App/ElizaIntentPlugin.swift +342 -5
  703. package/platforms/ios/App/App/Info.plist +17 -1
  704. package/platforms/ios/App/App/runners/eliza-tasks.js +177 -0
  705. package/platforms/ios/App/App.xcodeproj/project.pbxproj +262 -6
  706. package/platforms/ios/App/BroadcastExtension/SampleHandler.swift +100 -0
  707. package/platforms/ios/App/Podfile +5 -0
  708. package/platforms/ios/App/Podfile.lock +83 -59
  709. package/register-runtime-hooks.js +11 -5
  710. package/registry/app-registry.d.ts +14 -0
  711. package/registry/app-registry.d.ts.map +1 -0
  712. package/registry/app-registry.js +29 -0
  713. package/registry/entries/apps/app-polymarket.json +31 -0
  714. package/registry/entries/apps/clawville.json +27 -0
  715. package/registry/entries/apps/companion.json +28 -0
  716. package/registry/entries/apps/database-viewer.json +27 -0
  717. package/registry/entries/apps/defense-of-the-agents.json +27 -0
  718. package/registry/entries/apps/documents.json +30 -0
  719. package/registry/entries/apps/feed.json +27 -0
  720. package/registry/entries/apps/hyperliquid.json +31 -0
  721. package/registry/entries/apps/log-viewer.json +27 -0
  722. package/registry/entries/apps/memory-viewer.json +27 -0
  723. package/registry/entries/apps/model-tester.json +31 -0
  724. package/registry/entries/apps/plugin-viewer.json +27 -0
  725. package/registry/entries/apps/relationship-viewer.json +27 -0
  726. package/registry/entries/apps/runtime-debugger.json +27 -0
  727. package/registry/entries/apps/shopify.json +31 -0
  728. package/registry/entries/apps/skills-viewer.json +27 -0
  729. package/registry/entries/apps/steward.json +31 -0
  730. package/registry/entries/apps/training.json +54 -0
  731. package/registry/entries/apps/trajectory-viewer.json +27 -0
  732. package/registry/entries/apps/vincent.json +31 -0
  733. package/registry/entries/connectors/bluebubbles.json +99 -0
  734. package/registry/entries/connectors/bluesky.json +173 -0
  735. package/registry/entries/connectors/discord.json +119 -0
  736. package/registry/entries/connectors/farcaster.json +174 -0
  737. package/registry/entries/connectors/feishu.json +79 -0
  738. package/registry/entries/connectors/google-chat.json +120 -0
  739. package/registry/entries/connectors/google.json +82 -0
  740. package/registry/entries/connectors/imessage.json +96 -0
  741. package/registry/entries/connectors/instagram.json +64 -0
  742. package/registry/entries/connectors/line.json +86 -0
  743. package/registry/entries/connectors/matrix.json +94 -0
  744. package/registry/entries/connectors/mattermost.json +110 -0
  745. package/registry/entries/connectors/msteams.json +104 -0
  746. package/registry/entries/connectors/nextcloud-talk.json +104 -0
  747. package/registry/entries/connectors/nostr.json +70 -0
  748. package/registry/entries/connectors/signal.json +81 -0
  749. package/registry/entries/connectors/slack.json +102 -0
  750. package/registry/entries/connectors/telegram.json +71 -0
  751. package/registry/entries/connectors/tlon.json +94 -0
  752. package/registry/entries/connectors/twitch.json +110 -0
  753. package/registry/entries/connectors/whatsapp.json +113 -0
  754. package/registry/entries/connectors/x.json +231 -0
  755. package/registry/entries/connectors/zalo.json +112 -0
  756. package/registry/entries/connectors/zalouser.json +122 -0
  757. package/registry/entries/plugins/agent-orchestrator.json +33 -0
  758. package/registry/entries/plugins/agent-skills.json +72 -0
  759. package/registry/entries/plugins/anthropic.json +73 -0
  760. package/registry/entries/plugins/app-control.json +23 -0
  761. package/registry/entries/plugins/auto-trader.json +203 -0
  762. package/registry/entries/plugins/background-runner.json +26 -0
  763. package/registry/entries/plugins/blooio.json +102 -0
  764. package/registry/entries/plugins/browser.json +75 -0
  765. package/registry/entries/plugins/cli.json +40 -0
  766. package/registry/entries/plugins/clipboard.json +44 -0
  767. package/registry/entries/plugins/coding-tools.json +71 -0
  768. package/registry/entries/plugins/commands.json +63 -0
  769. package/registry/entries/plugins/computeruse.json +74 -0
  770. package/registry/entries/plugins/copilot-proxy.json +93 -0
  771. package/registry/entries/plugins/directives.json +63 -0
  772. package/registry/entries/plugins/edge-tts.json +97 -0
  773. package/registry/entries/plugins/elevenlabs.json +169 -0
  774. package/registry/entries/plugins/elizacloud.json +208 -0
  775. package/registry/entries/plugins/evm.json +134 -0
  776. package/registry/entries/plugins/experience.json +34 -0
  777. package/registry/entries/plugins/facewear.json +131 -0
  778. package/registry/entries/plugins/form.json +26 -0
  779. package/registry/entries/plugins/github.json +93 -0
  780. package/registry/entries/plugins/gmail-watch.json +25 -0
  781. package/registry/entries/plugins/goals.json +77 -0
  782. package/registry/entries/plugins/google-genai.json +106 -0
  783. package/registry/entries/plugins/groq.json +93 -0
  784. package/registry/entries/plugins/hedera.json +48 -0
  785. package/registry/entries/plugins/inmemorydb.json +25 -0
  786. package/registry/entries/plugins/linear.json +51 -0
  787. package/registry/entries/plugins/local-inference.json +142 -0
  788. package/registry/entries/plugins/local-storage.json +36 -0
  789. package/registry/entries/plugins/localdb.json +25 -0
  790. package/registry/entries/plugins/mcp.json +44 -0
  791. package/registry/entries/plugins/memory.json +124 -0
  792. package/registry/entries/plugins/minecraft.json +79 -0
  793. package/registry/entries/plugins/moltbook.json +83 -0
  794. package/registry/entries/plugins/music.json +155 -0
  795. package/registry/entries/plugins/mysticism.json +48 -0
  796. package/registry/entries/plugins/nearai.json +82 -0
  797. package/registry/entries/plugins/ngrok.json +69 -0
  798. package/registry/entries/plugins/ollama.json +96 -0
  799. package/registry/entries/plugins/openai.json +189 -0
  800. package/registry/entries/plugins/openrouter.json +188 -0
  801. package/registry/entries/plugins/pdf.json +26 -0
  802. package/registry/entries/plugins/plugin-manager.json +23 -0
  803. package/registry/entries/plugins/prose.json +48 -0
  804. package/registry/entries/plugins/rlm.json +26 -0
  805. package/registry/entries/plugins/roblox.json +88 -0
  806. package/registry/entries/plugins/rss.json +64 -0
  807. package/registry/entries/plugins/s3-storage.json +91 -0
  808. package/registry/entries/plugins/scheduling.json +35 -0
  809. package/registry/entries/plugins/shell.json +94 -0
  810. package/registry/entries/plugins/social-alpha.json +72 -0
  811. package/registry/entries/plugins/tailscale.json +81 -0
  812. package/registry/entries/plugins/tee.json +53 -0
  813. package/registry/entries/plugins/todos.json +26 -0
  814. package/registry/entries/plugins/trajectory-logger.json +33 -0
  815. package/registry/entries/plugins/trust.json +39 -0
  816. package/registry/entries/plugins/tts.json +71 -0
  817. package/registry/entries/plugins/tunnel.json +45 -0
  818. package/registry/entries/plugins/twilio.json +168 -0
  819. package/registry/entries/plugins/vercel-ai-gateway.json +128 -0
  820. package/registry/entries/plugins/video.json +23 -0
  821. package/registry/entries/plugins/vision.json +43 -0
  822. package/registry/entries/plugins/webhooks.json +23 -0
  823. package/registry/entries/plugins/workflow.json +25 -0
  824. package/registry/entries/plugins/xai.json +75 -0
  825. package/registry/index.d.ts +2 -1
  826. package/registry/index.d.ts.map +1 -1
  827. package/registry/index.js +46 -12
  828. package/registry/loader.d.ts +2 -1
  829. package/registry/loader.d.ts.map +1 -1
  830. package/registry/loader.js +49 -2
  831. package/registry/schema.d.ts +244 -34
  832. package/registry/schema.d.ts.map +1 -1
  833. package/registry/schema.js +36 -0
  834. package/runtime/android-avf-microdroid-bridge.d.ts +29 -0
  835. package/runtime/android-avf-microdroid-bridge.d.ts.map +1 -0
  836. package/runtime/android-avf-microdroid-bridge.js +149 -0
  837. package/runtime/api-dev-settings-banner.d.ts.map +1 -1
  838. package/runtime/api-dev-settings-banner.js +5 -13
  839. package/runtime/app-core-runtime-hooks.d.ts +21 -0
  840. package/runtime/app-core-runtime-hooks.d.ts.map +1 -0
  841. package/runtime/app-core-runtime-hooks.js +10 -0
  842. package/runtime/autonomy-policy.d.ts +2 -0
  843. package/runtime/autonomy-policy.d.ts.map +1 -0
  844. package/runtime/autonomy-policy.js +4 -0
  845. package/runtime/desktop/AppWindowRenderer.d.ts +17 -0
  846. package/runtime/desktop/AppWindowRenderer.d.ts.map +1 -0
  847. package/runtime/desktop/AppWindowRenderer.js +360 -0
  848. package/runtime/desktop/DesktopSurfaceNavigationRuntime.d.ts +2 -0
  849. package/runtime/desktop/DesktopSurfaceNavigationRuntime.d.ts.map +1 -0
  850. package/runtime/desktop/DesktopSurfaceNavigationRuntime.js +41 -0
  851. package/runtime/desktop/DesktopTrayRuntime.d.ts +2 -0
  852. package/runtime/desktop/DesktopTrayRuntime.d.ts.map +1 -0
  853. package/runtime/desktop/DesktopTrayRuntime.js +174 -0
  854. package/runtime/desktop/DetachedShellRoot.d.ts +10 -0
  855. package/runtime/desktop/DetachedShellRoot.d.ts.map +1 -0
  856. package/runtime/desktop/DetachedShellRoot.js +111 -0
  857. package/runtime/desktop/index.d.ts +6 -0
  858. package/runtime/desktop/index.d.ts.map +1 -0
  859. package/runtime/desktop/index.js +5 -0
  860. package/runtime/desktop/tray-menu.d.ts +20 -0
  861. package/runtime/desktop/tray-menu.d.ts.map +1 -0
  862. package/runtime/desktop/tray-menu.js +143 -0
  863. package/runtime/dev-server.d.ts +1 -1
  864. package/runtime/dev-server.d.ts.map +1 -1
  865. package/runtime/dev-server.js +93 -17
  866. package/runtime/eliza.d.ts +75 -1
  867. package/runtime/eliza.d.ts.map +1 -1
  868. package/runtime/eliza.js +596 -122
  869. package/runtime/ensure-text-to-speech-handler.d.ts.map +1 -1
  870. package/runtime/ensure-text-to-speech-handler.js +10 -3
  871. package/runtime/mobile-safe-runtime.d.ts +181 -2
  872. package/runtime/mobile-safe-runtime.d.ts.map +1 -1
  873. package/runtime/mobile-safe-runtime.js +1019 -12
  874. package/runtime/mode/remote-forwarder.d.ts.map +1 -1
  875. package/runtime/mode/remote-forwarder.js +2 -2
  876. package/runtime/mode/route-mode-guard.d.ts +1 -2
  877. package/runtime/mode/route-mode-guard.d.ts.map +1 -1
  878. package/runtime/mode/route-mode-guard.js +4 -5
  879. package/runtime/mode/route-mode-matrix.d.ts.map +1 -1
  880. package/runtime/mode/route-mode-matrix.js +14 -1
  881. package/runtime/mode/runtime-mode.d.ts +1 -1
  882. package/runtime/mode/runtime-mode.js +1 -1
  883. package/runtime/runtime-bootstrap-policy.d.ts.map +1 -1
  884. package/runtime/runtime-bootstrap-policy.js +14 -2
  885. package/runtime/telegram-standalone-handler.d.ts.map +1 -1
  886. package/runtime/telegram-standalone-handler.js +10 -9
  887. package/runtime/tts-cache-wiring.d.ts +29 -0
  888. package/runtime/tts-cache-wiring.d.ts.map +1 -0
  889. package/runtime/tts-cache-wiring.js +114 -0
  890. package/runtime/voice-warmup.d.ts +81 -0
  891. package/runtime/voice-warmup.d.ts.map +1 -0
  892. package/runtime/voice-warmup.js +111 -0
  893. package/scripts/android-sms-gateway-template.test.mjs +1014 -0
  894. package/scripts/aosp/README.md +19 -15
  895. package/scripts/aosp/compile-libllama.mjs +1344 -248
  896. package/scripts/aosp/compile-shim.mjs +47 -18
  897. package/scripts/aosp/deploy-pixel.mjs +405 -0
  898. package/scripts/aosp/lib/load-variant-config.mjs +3 -3
  899. package/scripts/aosp/llama-cpp-patches/README.md +8 -8
  900. package/scripts/aosp/llama-cpp-patches/apply-patches.mjs +23 -6
  901. package/scripts/aosp/llama-cpp-patches/polarquant/README.md +37 -0
  902. package/scripts/aosp/llama-cpp-patches/qjl/README.md +37 -0
  903. package/scripts/aosp/seccomp-shim/sigsys-handler-arm64.c +169 -0
  904. package/scripts/aosp/seccomp-shim/sigsys-handler-riscv64.c +217 -0
  905. package/scripts/aosp/smoke-cuttlefish.mjs +34 -4
  906. package/scripts/aosp/stage-default-models.mjs +18 -18
  907. package/scripts/aosp/variant-config-schema.ts +2 -2
  908. package/scripts/assert-required-bundled-packages.test.ts +534 -0
  909. package/scripts/audit-apple-store-sandbox.mjs +146 -0
  910. package/scripts/audit-live-test-surface.mjs +5 -2
  911. package/scripts/build-capacitor-app.mjs +21 -0
  912. package/scripts/build-flatpak.mjs +5 -5
  913. package/scripts/build-helpers/arm64-simd.mjs +72 -0
  914. package/scripts/build-helpers/omnivoice-merged.mjs +87 -0
  915. package/scripts/build-helpers/verify-fused-symbols.mjs +567 -0
  916. package/scripts/build-image.sh +1 -1
  917. package/scripts/build-llama-cpp-mtp.mjs +487 -0
  918. package/scripts/build-native-plugins.mjs +230 -18
  919. package/scripts/build-patched-electrobun-cli.mjs +68 -10
  920. package/scripts/build-win.mjs +1 -1
  921. package/scripts/bun-riscv64/Dockerfile +418 -0
  922. package/scripts/bun-riscv64/README.md +316 -0
  923. package/scripts/bun-riscv64/build.sh +469 -0
  924. package/scripts/bun-riscv64/bun-patches/0001-config-add-riscv64-arch.patch +74 -0
  925. package/scripts/bun-riscv64/bun-patches/0002-flags-add-riscv64-march-mabi.patch +16 -0
  926. package/scripts/bun-riscv64/bun-patches/0003-zig-add-riscv64-target-triple-and-cpu.patch +26 -0
  927. package/scripts/bun-riscv64/bun-patches/0004-webkit-force-local-mode-on-riscv64.patch +33 -0
  928. package/scripts/bun-riscv64/bun-patches/0005-tinycc-disable-on-riscv64.patch +16 -0
  929. package/scripts/bun-riscv64/bun-patches/0006-build-add-riscv64-cli-validation.patch +15 -0
  930. package/scripts/bun-riscv64/bun-patches/0007-deps-per-dep-riscv64-checks.patch +24 -0
  931. package/scripts/bun-riscv64/bun-patches/0008-source-stabilize-riscv64-musl-build.patch +226 -0
  932. package/scripts/bun-riscv64/bun-patches/0009-disable-wasm-streaming-hooks-for-c-loop.patch +162 -0
  933. package/scripts/bun-riscv64/bun-patches/0010-disable-inspector-profiler-for-riscv64-c-loop.patch +80 -0
  934. package/scripts/bun-riscv64/bun-patches/0011-process-arch-add-riscv64.patch +23 -0
  935. package/scripts/bun-riscv64/bun-patches/0012-cpu-features-add-riscv64-fallback.patch +13 -0
  936. package/scripts/bun-riscv64/bun-patches/0013-disable-console-inspector-hooks-for-riscv64-c-loop.patch +43 -0
  937. package/scripts/bun-riscv64/bun-patches/0014-disable-custom-inspector-dispatchers-on-riscv64.patch +127 -0
  938. package/scripts/bun-riscv64/bun-patches/0015-disable-jsc-profiler-builtins-on-riscv64.patch +75 -0
  939. package/scripts/bun-riscv64/bun-patches/0016-node-vm-disable-jit-cached-data-on-riscv64-c-loop.patch +96 -0
  940. package/scripts/bun-riscv64/bun-patches/0017-disable-performance-domjit-signature-on-riscv64-c-loop.patch +34 -0
  941. package/scripts/bun-riscv64/bun-patches/0018-fix-serialized-script-identifier-big-endian-path.patch +19 -0
  942. package/scripts/bun-riscv64/bun-patches/0019-add-wtf-timer-fire-bridge-for-c-loop.patch +24 -0
  943. package/scripts/bun-riscv64/bun-patches/0020-run-riscv64-smoke-test-under-qemu.patch +13 -0
  944. package/scripts/bun-riscv64/bun-patches/0021-fix-riscv64-linux-open-flags.patch +25 -0
  945. package/scripts/bun-riscv64/bun-patches/0022-zlib-riscv64-generic-kernels.patch +25 -0
  946. package/scripts/bun-riscv64/bun-patches/README.md +127 -0
  947. package/scripts/bun-riscv64/bun-version.json +202 -0
  948. package/scripts/bun-riscv64/run-build.sh +162 -0
  949. package/scripts/bun-riscv64/rust-core/0001-riscv64-rust-core-port.patch +868 -0
  950. package/scripts/bun-riscv64/rust-core/0002-second-wave-riscv64-source-gaps.patch +130 -0
  951. package/scripts/bun-riscv64/rust-core/0003-third-wave-riscv64-crash-handler-gaps.patch +78 -0
  952. package/scripts/bun-riscv64/rust-core/0004-rust-target-cpu-riscv64.patch +39 -0
  953. package/scripts/bun-riscv64/rust-core/0005-fifth-wave-riscv64-source-gaps.patch +96 -0
  954. package/scripts/bun-riscv64/rust-core/0006-cpp-wasm-and-inspector-guards-riscv64.patch +91 -0
  955. package/scripts/bun-riscv64/rust-core/0007-bun-alloc-max-align-t-riscv64.patch +36 -0
  956. package/scripts/bun-riscv64/rust-core/0008-workspace-lints-warn-not-deny-riscv64.patch +75 -0
  957. package/scripts/bun-riscv64/rust-core/0009-zigglobalobject-wasm-streaming-guards-riscv64.patch +109 -0
  958. package/scripts/bun-riscv64/rust-core/0010-tcc-externs-stub-on-riscv64.patch +62 -0
  959. package/scripts/bun-riscv64/rust-core/0011-clippy-ptr-cast-lints-warn-riscv64.patch +61 -0
  960. package/scripts/bun-riscv64/rust-core/README.md +80 -0
  961. package/scripts/bun-riscv64/rust-core/webkit-patches/0003-disable-dfg-ftl-on-riscv64.patch +60 -0
  962. package/scripts/bun-riscv64/rust-core/webkit-patches/0004-riscv64-do-not-force-wasm-in-c-loop.patch +31 -0
  963. package/scripts/bun-riscv64/rust-core/webkit-patches/0005-domjit-effect-allow-no-dfg-c-loop.patch +40 -0
  964. package/scripts/bun-riscv64/rust-core/webkit-patches/0006-disable-usewasm-when-webassembly-compiled-out.patch +33 -0
  965. package/scripts/bun-riscv64/rust-core/webkit-patches/0007-restore-dropped-includes-and-llint-fwd-decl.patch +31 -0
  966. package/scripts/bun-riscv64/validate.sh +264 -0
  967. package/scripts/bun-riscv64/webkit-patches/0001-cherry-pick-llint-riscv64.recipe +155 -0
  968. package/scripts/bun-riscv64/webkit-patches/0002-cherry-pick-baseline-jit-riscv64.recipe +40 -0
  969. package/scripts/bun-riscv64/webkit-patches/0003-disable-dfg-ftl-on-riscv64.patch +60 -0
  970. package/scripts/bun-riscv64/webkit-patches/0004-riscv64-do-not-force-wasm-in-c-loop.patch +31 -0
  971. package/scripts/bun-riscv64/webkit-patches/0005-domjit-effect-allow-no-dfg-c-loop.patch +40 -0
  972. package/scripts/bun-riscv64/webkit-patches/0006-disable-usewasm-when-webassembly-compiled-out.patch +33 -0
  973. package/scripts/bun-riscv64/webkit-patches/0007-restore-dropped-includes-and-llint-fwd-decl.patch +72 -0
  974. package/scripts/bun-riscv64/webkit-patches/README.md +146 -0
  975. package/scripts/check-homepage-public-readiness.mjs +353 -0
  976. package/scripts/check-homepage-release-data.mjs +110 -0
  977. package/scripts/check-i18n.mjs +2 -1
  978. package/scripts/check-real-local-chat.ts +147 -0
  979. package/scripts/check-real-local-provisioning.ts +104 -0
  980. package/scripts/check-real-local-reset.ts +249 -0
  981. package/scripts/check-sms-gateway-completion-audit.mjs +428 -0
  982. package/scripts/check-sms-gateway-readiness.mjs +266 -0
  983. package/scripts/clean-repo.mjs +5 -5
  984. package/scripts/codesign-mas.mjs +222 -16
  985. package/scripts/collect-docker-runtime-deps.mjs +229 -0
  986. package/scripts/continue-sms-gateway-work.mjs +121 -0
  987. package/scripts/copy-runtime-node-modules.ts +903 -195
  988. package/scripts/deploy-cloud-api-production-gateway.mjs +52 -0
  989. package/scripts/desktop-build.mjs +655 -101
  990. package/scripts/dev-platform.mjs +346 -102
  991. package/scripts/dev-startup-smoke.mjs +248 -0
  992. package/scripts/dev-ui.mjs +418 -176
  993. package/scripts/disable-local-eliza-workspace.mjs +35 -0
  994. package/scripts/docker-ci-smoke.sh +298 -96
  995. package/scripts/docker-entrypoint.sh +62 -1
  996. package/scripts/docker-entrypoint.test.ts +283 -0
  997. package/scripts/ensure-avatars.mjs +2 -2
  998. package/scripts/ensure-electrobun-core.mjs +1 -1
  999. package/scripts/ensure-generated-core-proto-js.mjs +1 -1
  1000. package/scripts/ensure-type-package-aliases.mjs +62 -5
  1001. package/scripts/ensure-vision-deps.mjs +20 -1
  1002. package/scripts/entry.ts +1 -1
  1003. package/scripts/ffi-stub/Makefile +64 -0
  1004. package/scripts/ffi-stub/README.md +391 -0
  1005. package/scripts/ffi-stub/asr-ffi-smoke.ts +139 -0
  1006. package/scripts/ffi-stub/ffi-stub.c +539 -0
  1007. package/scripts/ffi-stub/ffi.h +538 -0
  1008. package/scripts/ffi-stub/libelizainference_stub.so +0 -0
  1009. package/scripts/ffi-stub/tts-stream-ffi-smoke.ts +349 -0
  1010. package/scripts/generate-first-run-voicelines.mjs +194 -0
  1011. package/scripts/generate-plugin-index.js +4 -3
  1012. package/scripts/generate-static-asset-manifest.mjs +1 -1
  1013. package/scripts/i18n-dynamic-keys.json +5 -5
  1014. package/scripts/init-submodules.mjs +2 -2
  1015. package/scripts/install-android-sms-gateway.md +177 -0
  1016. package/scripts/install-android-sms-gateway.mjs +1088 -0
  1017. package/scripts/ios-xcframework/README.md +74 -72
  1018. package/scripts/ios-xcframework/build-xcframework.mjs +204 -43
  1019. package/scripts/ios-xcframework/run-physical-device-smoke.mjs +1943 -0
  1020. package/scripts/ios-xcframework/runtime-symbol-shim.c +450 -0
  1021. package/scripts/kernel-patches/cpu-polar-kernels.mjs +441 -0
  1022. package/scripts/kernel-patches/cpu-simd-kernels.mjs +253 -0
  1023. package/scripts/kernel-patches/cpu-thread-parallelism.mjs +368 -0
  1024. package/scripts/kernel-patches/cuda-kernels.mjs +117 -0
  1025. package/scripts/kernel-patches/metal-kernels.mjs +1698 -109
  1026. package/scripts/kernel-patches/server-omnivoice-route.mjs +718 -0
  1027. package/scripts/kernel-patches/server-structured-output.mjs +279 -0
  1028. package/scripts/kernel-patches/vulkan-dispatch-log.mjs +166 -0
  1029. package/scripts/kernel-patches/vulkan-dispatch-log.test.mjs +50 -0
  1030. package/scripts/kernel-patches/vulkan-dispatch-patches/01-vulkan-shaders-gen.patch +30 -16
  1031. package/scripts/kernel-patches/vulkan-dispatch-patches/02-ggml-vulkan-pipelines.patch +75 -30
  1032. package/scripts/kernel-patches/vulkan-kernels.mjs +800 -49
  1033. package/scripts/lib/agent-source-watcher.mjs +174 -0
  1034. package/scripts/lib/agent-source-watcher.test.mjs +184 -0
  1035. package/scripts/lib/api-supervisor.mjs +78 -9
  1036. package/scripts/lib/api-supervisor.test.mjs +121 -0
  1037. package/scripts/lib/app-dir.mjs +2 -16
  1038. package/scripts/lib/apple-entitlement-audit.mjs +655 -0
  1039. package/scripts/lib/apple-entitlement-audit.test.mjs +144 -0
  1040. package/scripts/lib/bun-version-guard.mjs +13 -13
  1041. package/scripts/lib/capacitor-plugin-build-needed.mjs +4 -3
  1042. package/scripts/lib/capacitor-plugin-names.mjs +30 -14
  1043. package/scripts/lib/desktop-preflight.mjs +9 -5
  1044. package/scripts/lib/desktop-startup-embedding-warmup-policy.mjs +51 -0
  1045. package/scripts/lib/desktop-startup-embedding-warmup-policy.test.mjs +55 -0
  1046. package/scripts/lib/duet-bridge.d.mts +63 -0
  1047. package/scripts/lib/duet-bridge.mjs +193 -0
  1048. package/scripts/lib/node-path-env.mjs +4 -2
  1049. package/scripts/lib/orchestrator-desktop-dev-banner.mjs +12 -3
  1050. package/scripts/lib/patch-bun-exports.mjs +90 -27
  1051. package/scripts/lib/patch-bun-exports.test.mjs +79 -0
  1052. package/scripts/lib/renderer-build-action.mjs +35 -0
  1053. package/scripts/lib/renderer-build-action.test.mjs +70 -0
  1054. package/scripts/lib/stage-android-agent.mjs +748 -99
  1055. package/scripts/lib/sync-eliza-env-aliases.mjs +3 -25
  1056. package/scripts/lib/ui-smoke-stub-decision.mjs +33 -0
  1057. package/scripts/lib/ui-smoke-stub-decision.test.mjs +46 -0
  1058. package/scripts/lib/vite-renderer-dist-stale.mjs +5 -0
  1059. package/scripts/lib/voice-latency-report.mjs +154 -0
  1060. package/scripts/lifeops-prompt-benchmark.ts +21 -12
  1061. package/scripts/link-docker-local-app-packages.mjs +89 -36
  1062. package/scripts/local-stt-bench.ts +192 -0
  1063. package/scripts/maintain-cloud-api-production-gateway.mjs +54 -0
  1064. package/scripts/mas-smoke.mjs +459 -0
  1065. package/scripts/mas-smoke.test.mjs +220 -0
  1066. package/scripts/mobile-auth-simulator-smoke.mjs +0 -1
  1067. package/scripts/normalize-eliza-capture.ts +97 -0
  1068. package/scripts/omnivoice-fuse/prepare.mjs +2543 -23
  1069. package/scripts/pack-upstreams.mjs +65 -5
  1070. package/scripts/package-electrobun-linux.mjs +303 -0
  1071. package/scripts/patch-deps.mjs +5 -3
  1072. package/scripts/patches/llama-mobile-kokoro-tts.patch +480 -0
  1073. package/scripts/playwright-ui-live-stack.ts +194 -49
  1074. package/scripts/playwright-ui-smoke-api-stub.mjs +3501 -109
  1075. package/scripts/pre-review-local.mjs +2 -2
  1076. package/scripts/prepare-ios-cocoapods.sh +41 -3
  1077. package/scripts/release-check.ts +180 -84
  1078. package/scripts/release-workflow-drift.test.ts +57 -0
  1079. package/scripts/relink-workspace-packages-to-dist.mjs +21 -4
  1080. package/scripts/rt.mjs +16 -1
  1081. package/scripts/run-biome-check.mjs +1 -1
  1082. package/scripts/run-coding-agent-e2e.mjs +3 -3
  1083. package/scripts/run-eliza-app-core-script.mjs +34 -0
  1084. package/scripts/run-local-plugin-live-smoke.mjs +71 -2
  1085. package/scripts/run-mobile-build-android-app-actions.test.mjs +426 -0
  1086. package/scripts/run-mobile-build.mjs +4757 -607
  1087. package/scripts/run-node-runtime.mjs +184 -7
  1088. package/scripts/run-node-runtime.test.mjs +167 -0
  1089. package/scripts/run-node-tsx.mjs +80 -33
  1090. package/scripts/run-node.mjs +41 -1
  1091. package/scripts/run-production-build.mjs +34 -27
  1092. package/scripts/run-release-check.mjs +19 -0
  1093. package/scripts/run-release-contract-suite.mjs +107 -14
  1094. package/scripts/run-ui-smoke-playwright-suite.mjs +0 -2
  1095. package/scripts/runtime-package-manifest.ts +21 -3
  1096. package/scripts/setup-upstreams.mjs +42 -1
  1097. package/scripts/sms-gateway-status.mjs +194 -0
  1098. package/scripts/stage-android-agent.test.mjs +97 -0
  1099. package/scripts/stage-elizavoice-lib.mjs +203 -0
  1100. package/scripts/startup-integration-script-drift.test.ts +82 -4
  1101. package/scripts/streaming-pipeline-bench.ts +543 -0
  1102. package/scripts/sync-homepage-porkbun-dns.mjs +262 -0
  1103. package/scripts/test-sms-gateway-software.mjs +100 -0
  1104. package/scripts/type-audit.mjs +1 -1
  1105. package/scripts/validate-bluebubbles-outbound.mjs +293 -0
  1106. package/scripts/validate-cdn-assets.mjs +15 -7
  1107. package/scripts/validate-regression-matrix.mjs +109 -8
  1108. package/scripts/verify-android-sms-gateway-e2e.mjs +362 -0
  1109. package/scripts/verify-bluebubbles-gateway-e2e.mjs +191 -0
  1110. package/scripts/verify-bluebubbles-inbound-readiness.mjs +88 -0
  1111. package/scripts/verify-cloud-api-production-deploy.mjs +87 -0
  1112. package/scripts/verify-cloud-sms-onboarding-flow.mjs +336 -0
  1113. package/scripts/voice/freeze-voice.mjs +521 -0
  1114. package/scripts/voice-attribution-smoke.ts +538 -0
  1115. package/scripts/voice-create-profile.mjs +379 -0
  1116. package/scripts/voice-duet.mjs +1355 -0
  1117. package/scripts/voice-e2e-hardware.ts +871 -0
  1118. package/scripts/voice-interactive.mjs +1750 -0
  1119. package/scripts/voice-latency-report.mjs +96 -0
  1120. package/scripts/voice-latency-report.test.ts +176 -0
  1121. package/scripts/voice-preset/build-default-voice-preset.mjs +249 -0
  1122. package/scripts/voice-preset/build-onboarding-voice.mjs +281 -0
  1123. package/scripts/watch-sms-gateway-readiness.mjs +303 -0
  1124. package/scripts/write-homepage-release-data.mjs +458 -26
  1125. package/security/agent-vault-id.d.ts +1 -1
  1126. package/security/agent-vault-id.js +1 -1
  1127. package/security/hydrate-wallet-keys-from-platform-store.d.ts.map +1 -1
  1128. package/security/hydrate-wallet-keys-from-platform-store.js +23 -14
  1129. package/security/platform-secure-store-node.d.ts +2 -2
  1130. package/security/platform-secure-store-node.js +3 -3
  1131. package/security/wallet-os-store-actions.d.ts +0 -9
  1132. package/security/wallet-os-store-actions.d.ts.map +1 -1
  1133. package/security/wallet-os-store-actions.js +3 -10
  1134. package/services/account-pool.d.ts +23 -14
  1135. package/services/account-pool.d.ts.map +1 -1
  1136. package/services/account-pool.js +86 -24
  1137. package/services/account-usage.d.ts.map +1 -1
  1138. package/services/account-usage.js +2 -5
  1139. package/services/ambient-audio/consent.d.ts +9 -0
  1140. package/services/ambient-audio/consent.d.ts.map +1 -0
  1141. package/services/ambient-audio/consent.js +28 -0
  1142. package/services/ambient-audio/index.d.ts +7 -0
  1143. package/services/ambient-audio/index.d.ts.map +1 -0
  1144. package/services/ambient-audio/index.js +4 -0
  1145. package/services/ambient-audio/replay-buffer.d.ts +14 -0
  1146. package/services/ambient-audio/replay-buffer.d.ts.map +1 -0
  1147. package/services/ambient-audio/replay-buffer.js +66 -0
  1148. package/services/ambient-audio/response-gate.d.ts +3 -0
  1149. package/services/ambient-audio/response-gate.d.ts.map +1 -0
  1150. package/services/ambient-audio/response-gate.js +33 -0
  1151. package/services/ambient-audio/service.d.ts +22 -0
  1152. package/services/ambient-audio/service.d.ts.map +1 -0
  1153. package/services/ambient-audio/service.js +47 -0
  1154. package/services/ambient-audio/types.d.ts +42 -0
  1155. package/services/ambient-audio/types.d.ts.map +1 -0
  1156. package/services/app-updates/update-policy.d.ts +64 -0
  1157. package/services/app-updates/update-policy.d.ts.map +1 -0
  1158. package/services/app-updates/update-policy.js +228 -0
  1159. package/services/auth-store.d.ts +37 -1
  1160. package/services/auth-store.d.ts.map +1 -1
  1161. package/services/auth-store.js +59 -26
  1162. package/services/cloud-jwks-store.d.ts +3 -3
  1163. package/services/cloud-jwks-store.d.ts.map +1 -1
  1164. package/services/cloud-jwks-store.js +5 -8
  1165. package/services/coding-account-bridge.d.ts +71 -0
  1166. package/services/coding-account-bridge.d.ts.map +1 -0
  1167. package/services/coding-account-bridge.js +267 -0
  1168. package/services/connector-target-catalog.d.ts +10 -3
  1169. package/services/connector-target-catalog.d.ts.map +1 -1
  1170. package/services/connector-target-catalog.js +7 -4
  1171. package/services/credential-tunnel-service.d.ts +66 -0
  1172. package/services/credential-tunnel-service.d.ts.map +1 -0
  1173. package/services/credential-tunnel-service.js +227 -0
  1174. package/services/github-credentials.d.ts +1 -1
  1175. package/services/github-credentials.js +1 -1
  1176. package/services/inference-abort.d.ts +47 -0
  1177. package/services/inference-abort.d.ts.map +1 -0
  1178. package/services/inference-abort.js +76 -0
  1179. package/services/persistence.d.ts +2 -3
  1180. package/services/persistence.d.ts.map +1 -1
  1181. package/services/persistence.js +2 -3
  1182. package/services/phrase-chunked-tts.d.ts +136 -0
  1183. package/services/phrase-chunked-tts.d.ts.map +1 -0
  1184. package/services/phrase-chunked-tts.js +208 -0
  1185. package/services/sandbox-registry.d.ts +78 -0
  1186. package/services/sandbox-registry.d.ts.map +1 -0
  1187. package/services/sandbox-registry.js +323 -0
  1188. package/services/secrets-manager-installer.d.ts +8 -1
  1189. package/services/secrets-manager-installer.d.ts.map +1 -1
  1190. package/services/secrets-manager-installer.js +27 -2
  1191. package/services/sensitive-requests/cloud-link-adapter.d.ts +15 -0
  1192. package/services/sensitive-requests/cloud-link-adapter.d.ts.map +1 -0
  1193. package/services/sensitive-requests/cloud-link-adapter.js +73 -0
  1194. package/services/sensitive-requests/index.d.ts +27 -0
  1195. package/services/sensitive-requests/index.d.ts.map +1 -0
  1196. package/services/sensitive-requests/index.js +51 -0
  1197. package/services/sensitive-requests/instruct-dm-only-adapter.d.ts +14 -0
  1198. package/services/sensitive-requests/instruct-dm-only-adapter.d.ts.map +1 -0
  1199. package/services/sensitive-requests/instruct-dm-only-adapter.js +22 -0
  1200. package/services/sensitive-requests/owner-app-inline-adapter.d.ts +3 -0
  1201. package/services/sensitive-requests/owner-app-inline-adapter.d.ts.map +1 -0
  1202. package/services/sensitive-requests/owner-app-inline-adapter.js +146 -0
  1203. package/services/sensitive-requests/owner-app-oauth-adapter.d.ts +3 -0
  1204. package/services/sensitive-requests/owner-app-oauth-adapter.d.ts.map +1 -0
  1205. package/services/sensitive-requests/owner-app-oauth-adapter.js +156 -0
  1206. package/services/sensitive-requests/public-link-adapter.d.ts +14 -0
  1207. package/services/sensitive-requests/public-link-adapter.d.ts.map +1 -0
  1208. package/services/sensitive-requests/public-link-adapter.js +86 -0
  1209. package/services/sensitive-requests/tunnel-link-adapter.d.ts +17 -0
  1210. package/services/sensitive-requests/tunnel-link-adapter.d.ts.map +1 -0
  1211. package/services/sensitive-requests/tunnel-link-adapter.js +38 -0
  1212. package/services/steward-credentials.d.ts +1 -1
  1213. package/services/steward-credentials.d.ts.map +1 -1
  1214. package/services/steward-credentials.js +10 -6
  1215. package/services/steward-sidecar/health-check.d.ts.map +1 -1
  1216. package/services/steward-sidecar/health-check.js +4 -3
  1217. package/services/steward-sidecar/process-management.d.ts +1 -1
  1218. package/services/steward-sidecar/process-management.d.ts.map +1 -1
  1219. package/services/steward-sidecar/process-management.js +9 -3
  1220. package/services/steward-sidecar/types.d.ts +1 -1
  1221. package/services/steward-sidecar/types.d.ts.map +1 -1
  1222. package/services/steward-sidecar/wallet-setup.d.ts.map +1 -1
  1223. package/services/steward-sidecar/wallet-setup.js +8 -7
  1224. package/services/steward-sidecar.d.ts +2 -2
  1225. package/services/steward-sidecar.d.ts.map +1 -1
  1226. package/services/steward-sidecar.js +27 -19
  1227. package/services/task-host-capabilities.d.ts +60 -0
  1228. package/services/task-host-capabilities.d.ts.map +1 -0
  1229. package/services/task-host-capabilities.js +122 -0
  1230. package/services/tool-call-cache/index.d.ts +2 -2
  1231. package/services/tool-call-cache/index.d.ts.map +1 -1
  1232. package/services/tool-call-cache/index.js +1 -1
  1233. package/services/trigger-event-bridge.js +1 -1
  1234. package/services/tunnel-to-mobile/index.d.ts +2 -0
  1235. package/services/tunnel-to-mobile/index.d.ts.map +1 -0
  1236. package/services/tunnel-to-mobile/index.js +1 -0
  1237. package/services/tunnel-to-mobile/tunnel-to-mobile-client.d.ts +105 -0
  1238. package/services/tunnel-to-mobile/tunnel-to-mobile-client.d.ts.map +1 -0
  1239. package/services/tunnel-to-mobile/tunnel-to-mobile-client.js +190 -0
  1240. package/services/vault-bootstrap.d.ts.map +1 -1
  1241. package/services/vault-bootstrap.js +48 -21
  1242. package/services/vault-mirror.d.ts +1 -1
  1243. package/services/vault-mirror.d.ts.map +1 -1
  1244. package/services/vault-mirror.js +29 -6
  1245. package/services/voice-profiles/diarization-pipeline.d.ts +6 -0
  1246. package/services/voice-profiles/diarization-pipeline.d.ts.map +1 -0
  1247. package/services/voice-profiles/diarization-pipeline.js +20 -0
  1248. package/services/voice-profiles/index.d.ts +12 -0
  1249. package/services/voice-profiles/index.d.ts.map +1 -0
  1250. package/services/voice-profiles/index.js +5 -0
  1251. package/services/voice-profiles/nickname-evaluator.d.ts +14 -0
  1252. package/services/voice-profiles/nickname-evaluator.d.ts.map +1 -0
  1253. package/services/voice-profiles/nickname-evaluator.js +46 -0
  1254. package/services/voice-profiles/owner-confidence.d.ts +10 -0
  1255. package/services/voice-profiles/owner-confidence.d.ts.map +1 -0
  1256. package/services/voice-profiles/owner-confidence.js +38 -0
  1257. package/services/voice-profiles/private-challenge.d.ts +20 -0
  1258. package/services/voice-profiles/private-challenge.d.ts.map +1 -0
  1259. package/services/voice-profiles/private-challenge.js +44 -0
  1260. package/services/voice-profiles/store.d.ts +21 -0
  1261. package/services/voice-profiles/store.d.ts.map +1 -0
  1262. package/services/voice-profiles/store.js +50 -0
  1263. package/services/voice-profiles/types.d.ts +38 -0
  1264. package/services/voice-profiles/types.d.ts.map +1 -0
  1265. package/services/voice-profiles/types.js +1 -0
  1266. package/styles/electrobun-mac-window-drag.css +4 -4
  1267. package/test/helpers/__tests__/live-agent-test.smoke.test.ts +43 -70
  1268. package/test/helpers/browser-mocks.ts +2 -2
  1269. package/test/helpers/conditional-tests.ts +2 -2
  1270. package/test/helpers/i18n.ts +1 -1
  1271. package/test/helpers/live-agent-test.ts +537 -551
  1272. package/test/helpers/live-provider.test.ts +4 -4
  1273. package/test/helpers/live-provider.ts +41 -7
  1274. package/test/helpers/live-runtime-server.ts +4 -4
  1275. package/test/helpers/pglite-runtime.ts +1 -1
  1276. package/test/helpers/real-runtime.ts +54 -15
  1277. package/test/helpers/trajectory-harness.ts +11 -7
  1278. package/test/scripts/start-eliza-live.ts +9 -0
  1279. package/test/scripts/test-parallel.mjs +1 -1
  1280. package/test/scripts/test-root-unit.mjs +6 -7
  1281. package/ui-compat.d.ts +13 -2
  1282. package/ui-compat.d.ts.map +1 -1
  1283. package/ui-compat.js +19 -3
  1284. package/api/auth-pairing-compat-routes.d.ts +0 -17
  1285. package/api/auth-pairing-compat-routes.d.ts.map +0 -1
  1286. package/api/auth-pairing-compat-routes.js +0 -301
  1287. package/api/local-inference-compat-routes.d.ts +0 -16
  1288. package/api/local-inference-compat-routes.d.ts.map +0 -1
  1289. package/api/local-inference-compat-routes.js +0 -617
  1290. package/api/onboarding-compat-routes.d.ts +0 -4
  1291. package/api/onboarding-compat-routes.d.ts.map +0 -1
  1292. package/api/onboarding-compat-routes.js +0 -207
  1293. package/api/plugins-compat-routes.d.ts +0 -103
  1294. package/api/plugins-compat-routes.d.ts.map +0 -1
  1295. package/api/plugins-compat-routes.js +0 -1181
  1296. package/api/server-onboarding-compat.d.ts +0 -31
  1297. package/api/server-onboarding-compat.d.ts.map +0 -1
  1298. package/api/server-onboarding-compat.js +0 -283
  1299. package/benchmark/cua-routes.d.ts +0 -10
  1300. package/benchmark/cua-routes.d.ts.map +0 -1
  1301. package/benchmark/cua-routes.js +0 -179
  1302. package/benchmark/mock-plugin-base.d.ts +0 -9
  1303. package/benchmark/mock-plugin-base.d.ts.map +0 -1
  1304. package/benchmark/mock-plugin-base.js +0 -325
  1305. package/cli/parse-duration.d.ts +0 -5
  1306. package/cli/parse-duration.d.ts.map +0 -1
  1307. package/cli/parse-duration.js +0 -27
  1308. package/patches/llama-cpp-capacitor@0.1.5.patch +0 -2387
  1309. package/platform/agent-browser-stub.d.ts +0 -27
  1310. package/platform/agent-browser-stub.d.ts.map +0 -1
  1311. package/platform/agent-browser-stub.js +0 -16
  1312. package/platforms/android/app/src/androidTest/java/com/getcapacitor/myapp/ExampleInstrumentedTest.java +0 -26
  1313. package/platforms/android/app/src/main/res/drawable/ic_launcher_background.xml +0 -170
  1314. package/platforms/android/app/src/main/res/drawable-v24/ic_launcher_foreground.xml +0 -34
  1315. package/platforms/android/app/src/test/java/com/getcapacitor/myapp/ExampleUnitTest.java +0 -18
  1316. package/platforms/electrobun/assets/appIcon.iconset/icon_512x512@2x.png +0 -0
  1317. package/platforms/electrobun/assets/appIcon.png +0 -0
  1318. package/platforms/electrobun/scripts/build-whisper-universal.sh +0 -137
  1319. package/platforms/electrobun/scripts/build-whisper.sh +0 -95
  1320. package/platforms/electrobun/src/libMacWindowEffects.dylib +0 -0
  1321. package/platforms/electrobun/src/native/whisper.ts +0 -280
  1322. package/platforms/ios/App/App/Assets.xcassets/Splash.imageset/splash-2732x2732-1.png +0 -0
  1323. package/platforms/ios/App/App/Assets.xcassets/Splash.imageset/splash-2732x2732-2.png +0 -0
  1324. package/platforms/ios/App/App/Assets.xcassets/Splash.imageset/splash-2732x2732.png +0 -0
  1325. package/registry/generate-apps.d.ts +0 -2
  1326. package/registry/generate-apps.d.ts.map +0 -1
  1327. package/registry/generate-apps.js +0 -338
  1328. package/registry/generate.d.ts +0 -2
  1329. package/registry/generate.d.ts.map +0 -1
  1330. package/registry/generate.js +0 -506
  1331. package/runtime/embedding-manager-support.d.ts +0 -77
  1332. package/runtime/embedding-manager-support.d.ts.map +0 -1
  1333. package/runtime/embedding-manager-support.js +0 -309
  1334. package/runtime/embedding-presets.d.ts +0 -5
  1335. package/runtime/embedding-presets.d.ts.map +0 -1
  1336. package/runtime/embedding-presets.js +0 -47
  1337. package/runtime/embedding-warmup-policy.d.ts +0 -13
  1338. package/runtime/embedding-warmup-policy.d.ts.map +0 -1
  1339. package/runtime/embedding-warmup-policy.js +0 -33
  1340. package/runtime/ensure-local-inference-handler.d.ts +0 -25
  1341. package/runtime/ensure-local-inference-handler.d.ts.map +0 -1
  1342. package/runtime/ensure-local-inference-handler.js +0 -389
  1343. package/runtime/mobile-local-inference-gate.d.ts +0 -21
  1344. package/runtime/mobile-local-inference-gate.d.ts.map +0 -1
  1345. package/runtime/mobile-local-inference-gate.js +0 -24
  1346. package/scripts/aosp/avd-test.mjs +0 -403
  1347. package/scripts/aosp/boot-validate.mjs +0 -536
  1348. package/scripts/aosp/build-aosp.mjs +0 -448
  1349. package/scripts/aosp/build-bootanimation.mjs +0 -178
  1350. package/scripts/aosp/capture-screens.mjs +0 -325
  1351. package/scripts/aosp/e2e-validate.mjs +0 -225
  1352. package/scripts/aosp/lint-init-rc.mjs +0 -258
  1353. package/scripts/aosp/llama-shim/eliza_llama_shim.c +0 -276
  1354. package/scripts/aosp/sim.mjs +0 -277
  1355. package/scripts/aosp/sync-to-aosp.mjs +0 -134
  1356. package/scripts/aosp/validate.mjs +0 -1273
  1357. package/scripts/build-llama-cpp-dflash.mjs +0 -1866
  1358. package/scripts/generate-onboarding-voicelines.mjs +0 -194
  1359. package/scripts/generated/static-asset-manifest.json +0 -4
  1360. package/scripts/normalize-parallax-capture.ts +0 -97
  1361. package/scripts/omnivoice-fuse/Makefile +0 -44
  1362. package/scripts/omnivoice-fuse/README.md +0 -266
  1363. package/scripts/omnivoice-fuse/cmake-graft.mjs +0 -180
  1364. package/scripts/omnivoice-fuse/ffi-stub.c +0 -222
  1365. package/scripts/omnivoice-fuse/ffi.h +0 -158
  1366. package/scripts/omnivoice-fuse/libelizainference_stub.dylib +0 -0
  1367. package/scripts/omnivoice-fuse/verify-symbols.mjs +0 -138
  1368. package/security/cloud-secret-store.d.ts +0 -34
  1369. package/security/cloud-secret-store.d.ts.map +0 -1
  1370. package/security/cloud-secret-store.js +0 -65
  1371. package/security/export-guard.d.ts +0 -34
  1372. package/security/export-guard.d.ts.map +0 -1
  1373. package/security/export-guard.js +0 -127
  1374. package/services/local-inference/__stress__/cache-stress-helpers.d.ts +0 -76
  1375. package/services/local-inference/__stress__/cache-stress-helpers.d.ts.map +0 -1
  1376. package/services/local-inference/__stress__/cache-stress-helpers.js +0 -238
  1377. package/services/local-inference/active-model.d.ts +0 -180
  1378. package/services/local-inference/active-model.d.ts.map +0 -1
  1379. package/services/local-inference/active-model.js +0 -362
  1380. package/services/local-inference/assignments.d.ts +0 -58
  1381. package/services/local-inference/assignments.d.ts.map +0 -1
  1382. package/services/local-inference/assignments.js +0 -179
  1383. package/services/local-inference/backend.d.ts +0 -200
  1384. package/services/local-inference/backend.d.ts.map +0 -1
  1385. package/services/local-inference/backend.js +0 -242
  1386. package/services/local-inference/bundled-models.d.ts +0 -34
  1387. package/services/local-inference/bundled-models.d.ts.map +0 -1
  1388. package/services/local-inference/bundled-models.js +0 -104
  1389. package/services/local-inference/cache-bridge.d.ts +0 -184
  1390. package/services/local-inference/cache-bridge.d.ts.map +0 -1
  1391. package/services/local-inference/cache-bridge.js +0 -333
  1392. package/services/local-inference/catalog.d.ts +0 -57
  1393. package/services/local-inference/catalog.d.ts.map +0 -1
  1394. package/services/local-inference/catalog.js +0 -262
  1395. package/services/local-inference/conversation-registry.d.ts +0 -122
  1396. package/services/local-inference/conversation-registry.d.ts.map +0 -1
  1397. package/services/local-inference/conversation-registry.js +0 -182
  1398. package/services/local-inference/device-bridge.d.ts +0 -139
  1399. package/services/local-inference/device-bridge.d.ts.map +0 -1
  1400. package/services/local-inference/device-bridge.js +0 -774
  1401. package/services/local-inference/dflash-doctor.d.ts +0 -27
  1402. package/services/local-inference/dflash-doctor.d.ts.map +0 -1
  1403. package/services/local-inference/dflash-doctor.js +0 -149
  1404. package/services/local-inference/dflash-server.d.ts +0 -248
  1405. package/services/local-inference/dflash-server.d.ts.map +0 -1
  1406. package/services/local-inference/dflash-server.js +0 -1076
  1407. package/services/local-inference/downloader.d.ts +0 -48
  1408. package/services/local-inference/downloader.d.ts.map +0 -1
  1409. package/services/local-inference/downloader.js +0 -688
  1410. package/services/local-inference/engine.d.ts +0 -282
  1411. package/services/local-inference/engine.d.ts.map +0 -1
  1412. package/services/local-inference/engine.js +0 -743
  1413. package/services/local-inference/external-scanner.d.ts +0 -17
  1414. package/services/local-inference/external-scanner.d.ts.map +0 -1
  1415. package/services/local-inference/external-scanner.js +0 -261
  1416. package/services/local-inference/handler-registry.d.ts +0 -72
  1417. package/services/local-inference/handler-registry.d.ts.map +0 -1
  1418. package/services/local-inference/handler-registry.js +0 -159
  1419. package/services/local-inference/hardware.d.ts +0 -26
  1420. package/services/local-inference/hardware.d.ts.map +0 -1
  1421. package/services/local-inference/hardware.js +0 -139
  1422. package/services/local-inference/hf-search.d.ts +0 -19
  1423. package/services/local-inference/hf-search.d.ts.map +0 -1
  1424. package/services/local-inference/hf-search.js +0 -169
  1425. package/services/local-inference/index.d.ts +0 -10
  1426. package/services/local-inference/index.d.ts.map +0 -1
  1427. package/services/local-inference/index.js +0 -7
  1428. package/services/local-inference/llama-server-metrics.d.ts +0 -108
  1429. package/services/local-inference/llama-server-metrics.d.ts.map +0 -1
  1430. package/services/local-inference/llama-server-metrics.js +0 -175
  1431. package/services/local-inference/manifest/index.d.ts +0 -4
  1432. package/services/local-inference/manifest/index.d.ts.map +0 -1
  1433. package/services/local-inference/manifest/index.js +0 -5
  1434. package/services/local-inference/manifest/schema.d.ts +0 -419
  1435. package/services/local-inference/manifest/schema.d.ts.map +0 -1
  1436. package/services/local-inference/manifest/schema.js +0 -227
  1437. package/services/local-inference/manifest/types.d.ts +0 -23
  1438. package/services/local-inference/manifest/types.d.ts.map +0 -1
  1439. package/services/local-inference/manifest/types.js +0 -5
  1440. package/services/local-inference/manifest/validator.d.ts +0 -43
  1441. package/services/local-inference/manifest/validator.d.ts.map +0 -1
  1442. package/services/local-inference/manifest/validator.js +0 -187
  1443. package/services/local-inference/paths.d.ts +0 -8
  1444. package/services/local-inference/paths.d.ts.map +0 -1
  1445. package/services/local-inference/paths.js +0 -7
  1446. package/services/local-inference/providers.d.ts +0 -61
  1447. package/services/local-inference/providers.d.ts.map +0 -1
  1448. package/services/local-inference/providers.js +0 -334
  1449. package/services/local-inference/ram-budget.d.ts +0 -57
  1450. package/services/local-inference/ram-budget.d.ts.map +0 -1
  1451. package/services/local-inference/ram-budget.js +0 -107
  1452. package/services/local-inference/readiness.d.ts +0 -9
  1453. package/services/local-inference/readiness.d.ts.map +0 -1
  1454. package/services/local-inference/readiness.js +0 -153
  1455. package/services/local-inference/recommendation.d.ts +0 -62
  1456. package/services/local-inference/recommendation.d.ts.map +0 -1
  1457. package/services/local-inference/recommendation.js +0 -309
  1458. package/services/local-inference/registry.d.ts +0 -35
  1459. package/services/local-inference/registry.d.ts.map +0 -1
  1460. package/services/local-inference/registry.js +0 -117
  1461. package/services/local-inference/router-handler.d.ts +0 -51
  1462. package/services/local-inference/router-handler.d.ts.map +0 -1
  1463. package/services/local-inference/router-handler.js +0 -165
  1464. package/services/local-inference/routing-policy.d.ts +0 -55
  1465. package/services/local-inference/routing-policy.d.ts.map +0 -1
  1466. package/services/local-inference/routing-policy.js +0 -195
  1467. package/services/local-inference/routing-preferences.d.ts +0 -8
  1468. package/services/local-inference/routing-preferences.d.ts.map +0 -1
  1469. package/services/local-inference/routing-preferences.js +0 -7
  1470. package/services/local-inference/service.d.ts +0 -88
  1471. package/services/local-inference/service.d.ts.map +0 -1
  1472. package/services/local-inference/service.js +0 -210
  1473. package/services/local-inference/session-pool.d.ts +0 -72
  1474. package/services/local-inference/session-pool.d.ts.map +0 -1
  1475. package/services/local-inference/session-pool.js +0 -125
  1476. package/services/local-inference/types.d.ts +0 -309
  1477. package/services/local-inference/types.d.ts.map +0 -1
  1478. package/services/local-inference/types.js +0 -23
  1479. package/services/local-inference/verify.d.ts +0 -8
  1480. package/services/local-inference/verify.d.ts.map +0 -1
  1481. package/services/local-inference/verify.js +0 -7
  1482. package/services/local-inference/voice/barge-in.d.ts +0 -15
  1483. package/services/local-inference/voice/barge-in.d.ts.map +0 -1
  1484. package/services/local-inference/voice/barge-in.js +0 -20
  1485. package/services/local-inference/voice/engine-bridge.d.ts +0 -256
  1486. package/services/local-inference/voice/engine-bridge.d.ts.map +0 -1
  1487. package/services/local-inference/voice/engine-bridge.js +0 -398
  1488. package/services/local-inference/voice/ffi-bindings.d.ts +0 -114
  1489. package/services/local-inference/voice/ffi-bindings.d.ts.map +0 -1
  1490. package/services/local-inference/voice/ffi-bindings.js +0 -281
  1491. package/services/local-inference/voice/index.d.ts +0 -51
  1492. package/services/local-inference/voice/index.d.ts.map +0 -1
  1493. package/services/local-inference/voice/index.js +0 -50
  1494. package/services/local-inference/voice/lifecycle.d.ts +0 -135
  1495. package/services/local-inference/voice/lifecycle.d.ts.map +0 -1
  1496. package/services/local-inference/voice/lifecycle.js +0 -189
  1497. package/services/local-inference/voice/phoneme-tokenizer.d.ts +0 -58
  1498. package/services/local-inference/voice/phoneme-tokenizer.d.ts.map +0 -1
  1499. package/services/local-inference/voice/phoneme-tokenizer.js +0 -53
  1500. package/services/local-inference/voice/phrase-cache.d.ts +0 -24
  1501. package/services/local-inference/voice/phrase-cache.d.ts.map +0 -1
  1502. package/services/local-inference/voice/phrase-cache.js +0 -32
  1503. package/services/local-inference/voice/phrase-chunker.d.ts +0 -20
  1504. package/services/local-inference/voice/phrase-chunker.d.ts.map +0 -1
  1505. package/services/local-inference/voice/phrase-chunker.js +0 -85
  1506. package/services/local-inference/voice/ring-buffer.d.ts +0 -40
  1507. package/services/local-inference/voice/ring-buffer.d.ts.map +0 -1
  1508. package/services/local-inference/voice/ring-buffer.js +0 -85
  1509. package/services/local-inference/voice/rollback-queue.d.ts +0 -24
  1510. package/services/local-inference/voice/rollback-queue.d.ts.map +0 -1
  1511. package/services/local-inference/voice/rollback-queue.js +0 -49
  1512. package/services/local-inference/voice/scheduler.d.ts +0 -47
  1513. package/services/local-inference/voice/scheduler.d.ts.map +0 -1
  1514. package/services/local-inference/voice/scheduler.js +0 -123
  1515. package/services/local-inference/voice/shared-resources.d.ts +0 -119
  1516. package/services/local-inference/voice/shared-resources.d.ts.map +0 -1
  1517. package/services/local-inference/voice/shared-resources.js +0 -83
  1518. package/services/local-inference/voice/speaker-preset-cache.d.ts +0 -28
  1519. package/services/local-inference/voice/speaker-preset-cache.d.ts.map +0 -1
  1520. package/services/local-inference/voice/speaker-preset-cache.js +0 -44
  1521. package/services/local-inference/voice/types.d.ts +0 -80
  1522. package/services/local-inference/voice/types.d.ts.map +0 -1
  1523. package/services/local-inference/voice/voice-preset-format.d.ts +0 -56
  1524. package/services/local-inference/voice/voice-preset-format.d.ts.map +0 -1
  1525. package/services/local-inference/voice/voice-preset-format.js +0 -184
  1526. package/services/plugin-installer.d.ts +0 -22
  1527. package/services/plugin-installer.d.ts.map +0 -1
  1528. package/services/plugin-installer.js +0 -41
  1529. package/test/scripts/task-agent-live-smoke.ts +0 -1335
  1530. /package/services/{local-inference/voice → ambient-audio}/types.js +0 -0
@@ -32,23 +32,26 @@
32
32
  // Minimum tested: zig 0.13.0. Earlier versions ship older libc++ headers
33
33
  // that miss <bit> / <span> shims llama.cpp's CMake feature checks rely on.
34
34
  //
35
- // llama.cpp pin (matches plugins/plugin-aosp-local-inference/src/aosp-llama-adapter.ts):
36
- // fork: https://github.com/milady-ai/llama.cpp
37
- // tag: v0.4.0-milady (milady/integration HEAD)
35
+ // llama.cpp pin (matches the fork the runtime loads via
36
+ // plugins/plugin-aosp-local-inference/src/aosp-local-inference-bootstrap.ts):
37
+ // fork: https://github.com/elizaOS/llama.cpp
38
+ // tag: v1.0.0-eliza (the kernel-complete v0.4.0-eliza tree,
39
+ // re-tagged on the elizaOS org rename)
38
40
  // commit: 08032d57e15574f2a7ca19fc3f29510c8673d590
39
41
  //
40
- // v0.4.0-milady adds W4-B CUDA QJL + PolarQuant Q4 + TBQ3_TCQ kernels
41
- // on top of v0.3.0-milady. The CUDA paths only matter for the
42
- // linux-x64-cuda host target (the AOSP arm64 path stays CPU-only),
43
- // but the pin is shared so both AOSP and host build paths land on
44
- // identical kernel sources.
42
+ // This tree adds the W4-B CUDA QJL + PolarQuant Q4 + TBQ3_TCQ kernels
43
+ // on top of the earlier eliza-lineage tags. The CUDA paths only matter
44
+ // for the linux-x64-cuda host target (the AOSP arm64 path stays
45
+ // CPU-only), but the pin is shared so both AOSP and host build paths
46
+ // land on identical kernel sources. A rebase onto a newer upstream is a
47
+ // deferred effort — see docs/porting/upstream-rebase-plan.md.
45
48
  //
46
- // v0.2.0-milady (subset of this pin) added DFlash speculative decoding
47
- // CLI surface (--spec-type dflash, --draft-min-prob alias, n_drafted_total
48
- // / n_drafted_accepted_total Prometheus counters) on top of v0.1.0-milady.
49
+ // v0.2.0-eliza (subset of this pin) added MTP speculative decoding
50
+ // CLI surface (--spec-type mtp, --spec-draft-n-min/max, n_drafted_total
51
+ // / n_drafted_accepted_total Prometheus counters) on top of v0.1.0-eliza.
49
52
  //
50
53
  // Why this fork (not stock ggml-org/llama.cpp b8198):
51
- // The Milady fork composes four techniques onto upstream b8198:
54
+ // The Eliza fork composes four techniques onto upstream b8198:
52
55
  //
53
56
  // - TBQ3_0 (slot 43) + TBQ4_0 (slot 44) — 3-bit / 4-bit TurboQuant V-cache.
54
57
  // Cherry-picked from apothic/llama.cpp-1bit-turboquant @ b2b5273.
@@ -62,7 +65,7 @@
62
65
  // W1-B's Polar series. Bumped from upstream slot 45 to 47 because
63
66
  // slot 46 is now QJL.
64
67
  // - Metal kernel sources (.metal) for TBQ3_0/TBQ4_0/TBQ3_TCQ/QJL/Polar
65
- // under ggml/src/ggml-metal/milady-kernels/. Source-only landing —
68
+ // under ggml/src/ggml-metal/eliza-kernels/. Source-only landing —
66
69
  // dispatcher wiring is the next agent's job.
67
70
  //
68
71
  // The CPU implementations of all four techniques (NEON for arm64, AVX2
@@ -82,23 +85,27 @@
82
85
  // adapter never called it anyway).
83
86
  //
84
87
  // Output (per ABI):
85
- // apps/app/android/app/src/main/assets/agent/{abi}/libllama.so
86
- // apps/app/android/app/src/main/assets/agent/{abi}/libggml.so
87
- // apps/app/android/app/src/main/assets/agent/{abi}/libggml-cpu.so
88
- // apps/app/android/app/src/main/assets/agent/{abi}/libggml-base.so
89
- // apps/app/android/app/src/main/assets/agent/{abi}/libeliza-llama-shim.so
90
- // apps/app/android/app/src/main/assets/agent/{abi}/llama-server (DFlash spec-decode HTTP server)
88
+ // packages/app/android/app/src/main/assets/agent/{abi}/libllama.so
89
+ // packages/app/android/app/src/main/assets/agent/{abi}/libggml.so
90
+ // packages/app/android/app/src/main/assets/agent/{abi}/libggml-cpu.so
91
+ // packages/app/android/app/src/main/assets/agent/{abi}/libggml-base.so
92
+ // packages/app/android/app/src/main/assets/agent/{abi}/llama-server (MTP spec-decode HTTP server)
93
+ // (with --target *-fused: libelizainference.so — the fused FFI lib)
91
94
  //
92
95
  // libllama.so has NEEDED entries on the entire libggml family (see
93
96
  // `readelf -d`); the dynamic linker resolves them from the per-ABI asset
94
97
  // dir via the LD_LIBRARY_PATH ElizaAgentService.java sets at process
95
- // launch. ABIs: arm64-v8a (real phones) and x86_64 (cuttlefish + emulators).
98
+ // launch. ABIs: arm64-v8a (real phones), x86_64 (cuttlefish + emulators),
99
+ // and riscv64 (cf_riscv64_phone + future riscv64 hardware).
96
100
  //
97
- // libeliza-llama-shim.so is the bun:ffi struct-by-value workaround: a
98
- // thin C wrapper (llama-shim/eliza_llama_shim.c next to this script)
99
- // that converts llama.cpp's struct-by-value entry points into
100
- // pointer-style equivalents bun:ffi can speak. NEEDED-links
101
- // libllama.so; resolved from the same asset dir at runtime.
101
+ // libllama.so + the libggml*.so family are NOT loaded directly by any TS
102
+ // adapter anymore the runtime loads the fused libelizainference.so. But
103
+ // the fused lib `target_link_libraries(elizainference PUBLIC llama)` against
104
+ // the SHARED libllama.so, so libllama.so + libggml*.so remain runtime
105
+ // DT_NEEDED dependencies of libelizainference.so and MUST keep building +
106
+ // staging. The old bun:ffi struct-by-value shims (libeliza-llama-shim.so +
107
+ // libeliza-llama-speculative-shim.so), consumed by the now-deleted
108
+ // aosp-llama-adapter.ts, have been retired from this builder.
102
109
  //
103
110
  // Approximate build cost on a modern Linux x86_64 builder (16 cores, NVMe):
104
111
  // - llama.cpp clone: ~30 s, ~150 MB working tree.
@@ -153,7 +160,7 @@
153
160
  //
154
161
  // Repo-root resolution:
155
162
  // The script defaults `--assets-dir` to
156
- // `<repoRoot>/apps/app/android/app/src/main/assets/agent` and
163
+ // `<repoRoot>/packages/app/android/app/src/main/assets/agent` and
157
164
  // `--cache-dir` to `~/.cache/eliza-android-agent/llama-cpp-<tag>`.
158
165
  // `<repoRoot>` is derived from this script's location: walk up from
159
166
  // `eliza/packages/app-core/scripts/aosp/` to the host repo root by
@@ -167,6 +174,13 @@ import os from "node:os";
167
174
  import path from "node:path";
168
175
  import process from "node:process";
169
176
  import { fileURLToPath } from "node:url";
177
+ import { androidArm64SimdCmakeFlags } from "../build-helpers/arm64-simd.mjs";
178
+ import {
179
+ fusedCmakeBuildTargets,
180
+ fusedExtraCmakeFlags,
181
+ } from "../build-helpers/omnivoice-merged.mjs";
182
+ import { verifyFusedSymbols } from "../build-helpers/verify-fused-symbols.mjs";
183
+ import { patchVulkanKernels } from "../kernel-patches/vulkan-kernels.mjs";
170
184
  import { resolveRepoRootFromImportMeta } from "../lib/repo-root.mjs";
171
185
  import { main as compileShimMain } from "./compile-shim.mjs";
172
186
 
@@ -177,11 +191,19 @@ const here = path.dirname(fileURLToPath(import.meta.url));
177
191
  // inside the elizaOS source checkout it's the elizaOS repo root.
178
192
  const repoRoot = resolveRepoRootFromImportMeta(import.meta.url);
179
193
 
180
- // milady-ai/llama.cpp @ v0.4.0-milady (milady/integration HEAD).
181
- // Composes TBQ (apothic) + QJL (W1-A) + Q4_POLAR (W1-B) + Metal sources
182
- // (W1-D) + DFlash spec-decode (W2) + W3-B fused CPU kernels + W4-B CUDA
183
- // QJL/Polar/TBQ3_TCQ kernels onto upstream b8198. See
184
- // docs/porting/unified-fork-strategy.md for the full migration story.
194
+ // elizaOS/llama.cpp @ 33c888a7b. Composes TBQ (apothic) +
195
+ // QJL (W1-A) + Q4_POLAR (W1-B) + Metal sources (W1-D) + MTP spec-decode
196
+ // (W2) + W3-B fused CPU kernels + W4-B CUDA QJL/Polar/TBQ3_TCQ kernels onto
197
+ // upstream b9213. See docs/porting/unified-fork-strategy.md for the full
198
+ // migration story.
199
+ //
200
+ // The fork ships in-tree as the git submodule at
201
+ // plugins/plugin-local-inference/native/llama.cpp (next to the MTP build at
202
+ // scripts/build-llama-cpp-mtp.mjs — same pinned commit so both build paths
203
+ // land on identical kernels). When that
204
+ // submodule is initialized this path defaults to it (no clone needed); pass
205
+ // `--src-dir` to point at another checkout, or `--cache-dir` to force a
206
+ // standalone clone of `${LLAMA_CPP_REMOTE}` at `${LLAMA_CPP_TAG}`.
185
207
  //
186
208
  // Pre-2026-05-09 the AOSP path consumed apothic/llama.cpp-1bit-turboquant
187
209
  // directly and applied vendored QJL + PolarQuant patch series via
@@ -189,11 +211,44 @@ const repoRoot = resolveRepoRootFromImportMeta(import.meta.url);
189
211
  // flow is now replaced by a single canonical fork — the patches are
190
212
  // baked in. apply-patches.mjs is kept around for one release as a
191
213
  // rollback path; see scripts/aosp/llama-cpp-patches/README.md.
192
- export const LLAMA_CPP_TAG = "v0.4.0-milady";
193
- export const LLAMA_CPP_COMMIT = "08032d57e15574f2a7ca19fc3f29510c8673d590";
194
- export const LLAMA_CPP_REMOTE =
195
- "https://github.com/milady-ai/llama.cpp.git";
214
+ export const LLAMA_CPP_TAG = "v1.2.0-eliza";
215
+ export const LLAMA_CPP_COMMIT = "33c888a7be0b0b8ffb54cd3f0e05b4bed20cc52e";
216
+ export const LLAMA_CPP_REMOTE = "https://github.com/elizaOS/llama.cpp.git";
196
217
  export const MIN_ZIG_VERSION = "0.13.0";
218
+ // Floor for the RVV-on riscv64 build. Zig 0.13's bundled LLVM rejects the
219
+ // GCC-style `-march=rv64gcv*` ISA string the vendored llama.cpp's
220
+ // ggml-cpu/CMakeLists hard-codes when GGML_RVV / GGML_RV_ZFH / etc. are ON;
221
+ // zig 0.14+ accepts it. Below this floor we hard-disable RVV + Zfh + Zvfh +
222
+ // Zicbop + Zihintpause + Zvfbfwma + XTheadVector + Zba + SpaceMit so the
223
+ // MARCH_STR collapses to plain `rv64gc` (which Zig 0.13's argv filter then
224
+ // strips, since the `riscv64-linux-musl` triple already implies rv64gc/lp64d).
225
+ // At or above this floor we leave the upstream defaults ON, the filter
226
+ // becomes a no-op, and the vendored RVV intrinsic kernels (q4_0/q4_1/q5_0/
227
+ // q5_1/q8_0/q8_1/q4_K/q5_K/q6_K/q8_K/iq*/tq1_0/tq2_0/mxfp4 in
228
+ // ggml/src/ggml-cpu/arch/riscv/quants.c) light up.
229
+ export const MIN_ZIG_RVV_VERSION = "0.14.0";
230
+
231
+ // The in-repo submodule checkout of the fork.
232
+ // `repoRoot` resolves to the repo root that contains a top-level package.json.
233
+ const LLAMA_CPP_SUBMODULE_DIR = path.join(
234
+ repoRoot,
235
+ "plugins",
236
+ "plugin-local-inference",
237
+ "native",
238
+ "llama.cpp",
239
+ );
240
+ // True when the submodule is checked out (has a worktree). When so, the AOSP
241
+ // cross-compile defaults its source dir to it instead of cloning.
242
+ export function llamaCppSubmodulePresent() {
243
+ try {
244
+ return (
245
+ fs.existsSync(path.join(LLAMA_CPP_SUBMODULE_DIR, ".git")) &&
246
+ fs.existsSync(path.join(LLAMA_CPP_SUBMODULE_DIR, "CMakeLists.txt"))
247
+ );
248
+ } catch {
249
+ return false;
250
+ }
251
+ }
197
252
 
198
253
  export const ABI_TARGETS = [
199
254
  {
@@ -206,13 +261,227 @@ export const ABI_TARGETS = [
206
261
  zigTarget: "x86_64-linux-musl",
207
262
  cmakeProcessor: "x86_64",
208
263
  },
264
+ {
265
+ androidAbi: "riscv64",
266
+ zigTarget: "riscv64-linux-musl",
267
+ cmakeProcessor: "riscv64",
268
+ },
209
269
  ];
210
270
 
271
+ // `*-fused` android targets that are wired to real AOSP artifacts.
272
+ // Membership in this set is the only way the fused (omnivoice-grafted) build
273
+ // path activates from this script — there is no env-var shortcut and no
274
+ // implicit upgrade from a non-fused `--abi` invocation.
275
+ export const FUSED_ANDROID_TARGETS = Object.freeze([
276
+ "android-arm64-cpu-fused",
277
+ "android-x86_64-cpu-fused",
278
+ "android-riscv64-cpu-fused",
279
+ ]);
280
+
281
+ // Extra cmake targets whose build failure must STILL abort the run. Only the
282
+ // fused `elizainference` lib (libelizainference.so) is bundled into the APK;
283
+ // every other extra target is a standalone CLI driver that ships nothing, so a
284
+ // compile break in one of those (e.g. the fork's stale omnivoice-tts.cpp) must
285
+ // not fail a build whose required libs are otherwise good.
286
+ const CRITICAL_EXTRA_TARGETS = new Set(["elizainference"]);
287
+
288
+ /**
289
+ * Parse one of the `android-<arch>-<backend>[-fused]` target strings used by
290
+ * the mtp build script into the pieces this script needs (the Android ABI
291
+ * + the fused/backend flags). Throws on unsupported triples — there is no
292
+ * implicit translation; the operator either asks for one of the known
293
+ * triples or gets a hard error.
294
+ *
295
+ * Exported for tests.
296
+ */
297
+ export function parseAndroidTarget(target) {
298
+ if (typeof target !== "string" || target.length === 0) {
299
+ throw new Error(`[compile-libllama] target must be a non-empty string`);
300
+ }
301
+ const fused = target.endsWith("-fused");
302
+ const base = fused ? target.slice(0, -"-fused".length) : target;
303
+ const match = /^android-(arm64|x86_64|riscv64)-(cpu|vulkan)$/.exec(base);
304
+ if (!match) {
305
+ throw new Error(
306
+ `[compile-libllama] unsupported --target ${target}. ` +
307
+ `Supported: ${[
308
+ "android-arm64-cpu",
309
+ "android-arm64-cpu-fused",
310
+ "android-x86_64-cpu",
311
+ "android-x86_64-cpu-fused",
312
+ "android-riscv64-cpu",
313
+ "android-riscv64-cpu-fused",
314
+ ].join(", ")}`,
315
+ );
316
+ }
317
+ const [, arch, backend] = match;
318
+ // Android Vulkan is wired for arm64 only (the GPU device target). The
319
+ // GGML_VULKAN CMake flags + NDK glslc/headers + libggml-vulkan.so staging +
320
+ // the eliza-1 qjl/polar Vulkan kernel patches are applied in the build path
321
+ // when backend === "vulkan" (see resolveVulkanBuildConfig / the build fn).
322
+ if (backend === "vulkan" && arch !== "arm64") {
323
+ throw new Error(
324
+ `[compile-libllama] unsupported --target ${target}: Android Vulkan is ` +
325
+ `only wired for arm64 (the GPU device target). Use android-arm64-vulkan ` +
326
+ `or android-${arch}-cpu${fused ? "-fused" : ""}.`,
327
+ );
328
+ }
329
+ // Map the parsed arch token to the Android ABI directory name. arm64 →
330
+ // arm64-v8a (only Android ABI for aarch64); x86_64 and riscv64 share
331
+ // their name with the parsed token.
332
+ let androidAbi;
333
+ if (arch === "x86_64") androidAbi = "x86_64";
334
+ else if (arch === "riscv64") androidAbi = "riscv64";
335
+ else androidAbi = "arm64-v8a";
336
+ return { target, arch, backend, fused, androidAbi };
337
+ }
338
+
339
+ /**
340
+ * GGML_VULKAN CMake flags for the android-arm64 Vulkan backend. Points cmake at
341
+ * the NDK's host `glslc` (the shader compiler ggml-vulkan's codegen invokes),
342
+ * the Vulkan headers, and the aarch64 Vulkan loader stub. ggml-vulkan dlopen()s
343
+ * the device's real libvulkan.so at runtime; the NDK stub only satisfies the
344
+ * link. Throws (fail-closed) if any NDK Vulkan prerequisite is missing, so the
345
+ * build never silently falls back to CPU for a Vulkan target.
346
+ */
347
+ export function resolveAndroidVulkanCmakeFlags({
348
+ androidApi = 31,
349
+ stagingDir,
350
+ } = {}) {
351
+ const sdk = process.env.ANDROID_HOME || process.env.ANDROID_SDK_ROOT;
352
+ if (!sdk) {
353
+ throw new Error(
354
+ "[compile-libllama] ANDROID_HOME/ANDROID_SDK_ROOT is required for the " +
355
+ "android Vulkan build (NDK glslc + Vulkan headers + loader).",
356
+ );
357
+ }
358
+ const ndkRoot = path.join(sdk, "ndk");
359
+ const ndks = fs.existsSync(ndkRoot)
360
+ ? fs
361
+ .readdirSync(ndkRoot)
362
+ .filter((d) => /^\d+\./.test(d))
363
+ .sort(compareSemver)
364
+ : [];
365
+ if (ndks.length === 0) {
366
+ throw new Error(
367
+ `[compile-libllama] No NDK found under ${ndkRoot}; install one for the Vulkan build.`,
368
+ );
369
+ }
370
+ const ndk = path.join(ndkRoot, ndks[ndks.length - 1]);
371
+ const sysroot = path.join(
372
+ ndk,
373
+ "toolchains/llvm/prebuilt/linux-x86_64/sysroot",
374
+ );
375
+ const glslc = path.join(ndk, "shader-tools/linux-x86_64/glslc");
376
+ const libBase = path.join(sysroot, "usr/lib/aarch64-linux-android");
377
+ const apis = fs.existsSync(libBase)
378
+ ? fs
379
+ .readdirSync(libBase)
380
+ .filter((d) => /^\d+$/.test(d))
381
+ .map(Number)
382
+ .filter((n) => n >= androidApi)
383
+ .sort((a, b) => a - b)
384
+ : [];
385
+ if (apis.length === 0) {
386
+ throw new Error(
387
+ `[compile-libllama] No aarch64 libvulkan.so >= API ${androidApi} under ${libBase}.`,
388
+ );
389
+ }
390
+ const libVulkan = path.join(libBase, String(apis[0]), "libvulkan.so");
391
+
392
+ // ggml-vulkan.cpp includes <vulkan/vulkan.hpp> (the C++ Vulkan-Hpp bindings).
393
+ // The NDK sysroot ships only the C headers (vulkan.h / vulkan_core.h) + the
394
+ // libvulkan.so loader, NOT the C++ wrapper. Vulkan headers are pure API
395
+ // declarations (arch-independent); only the loader is arch-specific. So we
396
+ // stage a complete host Vulkan-Hpp header set (vulkan.hpp + the structs/enums/
397
+ // handles/funcs/raii partials it pulls in) into an ISOLATED include root and
398
+ // point Vulkan_INCLUDE_DIR there. Staging only the `vulkan/` subtree keeps the
399
+ // musl/zig cross-compile from ever seeing host glibc headers via a wide -I.
400
+ const headerCandidates = [
401
+ process.env.VULKAN_SDK && path.join(process.env.VULKAN_SDK, "include"),
402
+ "/usr/include",
403
+ "/usr/local/include",
404
+ ].filter(Boolean);
405
+ const hostVulkanDir = headerCandidates
406
+ .map((d) => path.join(d, "vulkan"))
407
+ .find((d) => fs.existsSync(path.join(d, "vulkan.hpp")));
408
+ if (!hostVulkanDir) {
409
+ throw new Error(
410
+ "[compile-libllama] vulkan/vulkan.hpp (C++ Vulkan-Hpp bindings) not found. " +
411
+ "ggml-vulkan needs it; install the Vulkan headers (e.g. `apt install " +
412
+ "libvulkan-dev`) or set VULKAN_SDK. Searched: " +
413
+ headerCandidates.join(", "),
414
+ );
415
+ }
416
+ const incRoot = stagingDir
417
+ ? path.resolve(stagingDir)
418
+ : path.join(os.tmpdir(), "eliza-vulkan-headers");
419
+ const stagedVulkan = path.join(incRoot, "vulkan");
420
+ fs.rmSync(stagedVulkan, { recursive: true, force: true });
421
+ fs.mkdirSync(incRoot, { recursive: true });
422
+ fs.cpSync(hostVulkanDir, stagedVulkan, { recursive: true });
423
+ // vulkan_core.h `#include <vk_video/...>` the video-codec extension headers,
424
+ // which live in a sibling `vk_video/` dir next to `vulkan/`. Stage it too so
425
+ // the single -I<incRoot> resolves both.
426
+ const hostVkVideoDir = path.join(path.dirname(hostVulkanDir), "vk_video");
427
+ if (fs.existsSync(hostVkVideoDir)) {
428
+ const stagedVkVideo = path.join(incRoot, "vk_video");
429
+ fs.rmSync(stagedVkVideo, { recursive: true, force: true });
430
+ fs.cpSync(hostVkVideoDir, stagedVkVideo, { recursive: true });
431
+ }
432
+
433
+ // ggml-vulkan.cpp also `#include <spirv/unified1/spirv.hpp>` (SPIR-V Headers,
434
+ // for shader reflection). The NDK bundles SPIRV-Headers under shaderc; prefer
435
+ // those (they match the glslc/shaderc toolchain version), else fall back to a
436
+ // host spirv-headers install. Stage the `spirv/` subtree into the same root.
437
+ const spirvCandidates = [
438
+ path.join(
439
+ ndk,
440
+ "sources/third_party/shaderc/third_party/spirv-tools/external/spirv-headers/include",
441
+ ),
442
+ process.env.VULKAN_SDK && path.join(process.env.VULKAN_SDK, "include"),
443
+ "/usr/include",
444
+ "/usr/local/include",
445
+ ].filter(Boolean);
446
+ const hostSpirvRoot = spirvCandidates.find((d) =>
447
+ fs.existsSync(path.join(d, "spirv/unified1/spirv.hpp")),
448
+ );
449
+ if (!hostSpirvRoot) {
450
+ throw new Error(
451
+ "[compile-libllama] spirv/unified1/spirv.hpp (SPIRV-Headers) not found. " +
452
+ "ggml-vulkan needs it; expected it under the NDK shaderc third_party " +
453
+ "tree or a host spirv-headers install. Searched: " +
454
+ spirvCandidates.join(", "),
455
+ );
456
+ }
457
+ const stagedSpirv = path.join(incRoot, "spirv");
458
+ fs.rmSync(stagedSpirv, { recursive: true, force: true });
459
+ fs.cpSync(path.join(hostSpirvRoot, "spirv"), stagedSpirv, { recursive: true });
460
+
461
+ for (const [name, p] of [
462
+ ["vulkan/vulkan.hpp", path.join(stagedVulkan, "vulkan.hpp")],
463
+ ["glslc", glslc],
464
+ ["libvulkan.so", libVulkan],
465
+ ]) {
466
+ if (!fs.existsSync(p)) {
467
+ throw new Error(
468
+ `[compile-libllama] android Vulkan build prerequisite ${name} missing: ${p}`,
469
+ );
470
+ }
471
+ }
472
+ return [
473
+ "-DGGML_VULKAN=ON",
474
+ `-DVulkan_INCLUDE_DIR=${incRoot}`,
475
+ `-DVulkan_GLSLC_EXECUTABLE=${glslc}`,
476
+ `-DVulkan_LIBRARY=${libVulkan}`,
477
+ ];
478
+ }
479
+
211
480
  export function parseArgs(argv) {
212
481
  const args = {
213
482
  androidAssetsDir: path.join(
214
483
  repoRoot,
215
- "apps",
484
+ "packages",
216
485
  "app",
217
486
  "android",
218
487
  "app",
@@ -228,9 +497,16 @@ export function parseArgs(argv) {
228
497
  `llama-cpp-${LLAMA_CPP_TAG}`,
229
498
  ),
230
499
  abis: ABI_TARGETS.map((t) => t.androidAbi),
500
+ // Optional explicit --target=android-<arch>-<backend>[-fused] triples
501
+ // (see parseAndroidTarget). When present, this list takes precedence
502
+ // over --abi (which is the legacy bulk-build entry point that produces
503
+ // CPU-only libllama.so for one or both ABIs, no fusion).
504
+ targets: [],
231
505
  skipIfPresent: false,
232
506
  jobs: Math.max(1, Math.min(os.cpus().length, 8)),
233
507
  srcDir: null,
508
+ cacheDirExplicit: false,
509
+ dryRun: false,
234
510
  };
235
511
 
236
512
  const readFlagValue = (flag, index) => {
@@ -248,6 +524,7 @@ export function parseArgs(argv) {
248
524
  i += 1;
249
525
  } else if (arg === "--cache-dir") {
250
526
  args.cacheDir = path.resolve(readFlagValue(arg, i));
527
+ args.cacheDirExplicit = true;
251
528
  i += 1;
252
529
  } else if (arg === "--src-dir") {
253
530
  args.srcDir = path.resolve(readFlagValue(arg, i));
@@ -262,6 +539,15 @@ export function parseArgs(argv) {
262
539
  }
263
540
  args.abis = [value];
264
541
  i += 1;
542
+ } else if (arg === "--target") {
543
+ const value = readFlagValue(arg, i);
544
+ // Validates the triple and records it. Resolved further below.
545
+ args.targets.push(parseAndroidTarget(value));
546
+ i += 1;
547
+ } else if (arg.startsWith("--target=")) {
548
+ args.targets.push(parseAndroidTarget(arg.slice("--target=".length)));
549
+ } else if (arg === "--dry-run") {
550
+ args.dryRun = true;
265
551
  } else if (arg === "--jobs" || arg === "-j") {
266
552
  const value = Number.parseInt(readFlagValue(arg, i), 10);
267
553
  if (!Number.isFinite(value) || value <= 0) {
@@ -275,12 +561,28 @@ export function parseArgs(argv) {
275
561
  console.log(
276
562
  "Usage: node eliza/packages/app-core/scripts/aosp/compile-libllama.mjs " +
277
563
  "[--assets-dir <PATH>] [--cache-dir <PATH>] [--src-dir <PATH>] " +
278
- "[--abi <arm64-v8a|x86_64>] [--jobs <N>] [--skip-if-present]\n" +
279
- " --src-dir <PATH> Use an existing llama.cpp / buun-llama-cpp checkout\n" +
280
- " instead of cloning. The directory's HEAD is used as-is;\n" +
281
- " the pinned LLAMA_CPP_TAG/COMMIT in this script is ignored.\n" +
282
- " Use this to build the spiritbuun/buun-llama-cpp fork\n" +
283
- " (TurboQuant KV-cache + DFlash kernels).",
564
+ "[--abi <arm64-v8a|x86_64|riscv64>] [--target <android-<arch>-<backend>[-fused]>] " +
565
+ "[--jobs <N>] [--skip-if-present] [--dry-run]\n" +
566
+ " --target <TRIPLE> Build a single target: android-{arm64,x86_64,riscv64}-cpu[-fused].\n" +
567
+ " riscv64 requires NDK r27+ (first stable NDK with a real\n" +
568
+ " riscv64-linux-android sysroot); older NDKs will fail the\n" +
569
+ " compiler probe before any TU compiles.\n" +
570
+ " Android Vulkan targets fail closed until GGML_VULKAN\n" +
571
+ " flags and Vulkan backend artifact staging are wired.\n" +
572
+ " -fused enables the omnivoice graft (same as mtp's\n" +
573
+ " *-fused desktop targets) — one binary serving text +\n" +
574
+ " POST /v1/audio/speech.\n" +
575
+ " --dry-run Print the cmake invocation + graft steps + expected\n" +
576
+ " output layout WITHOUT running cmake/ndk. Honored for\n" +
577
+ " every --target.\n" +
578
+ " --src-dir <PATH> Use an existing llama.cpp checkout instead of the\n" +
579
+ " in-repo submodule / a fresh clone. The directory's HEAD\n" +
580
+ " is used as-is; the pinned LLAMA_CPP_TAG/COMMIT is ignored.\n" +
581
+ ` Default source: the git submodule plugins/plugin-local-inference/native/llama.cpp\n` +
582
+ ` (elizaOS/llama.cpp @ ${LLAMA_CPP_TAG}) when initialized;\n` +
583
+ ` otherwise a standalone clone under --cache-dir.\n` +
584
+ " --cache-dir <PATH> Force the standalone-clone path even when the submodule\n" +
585
+ " is present.",
284
586
  );
285
587
  process.exit(0);
286
588
  } else {
@@ -288,6 +590,14 @@ export function parseArgs(argv) {
288
590
  }
289
591
  }
290
592
 
593
+ // Default the source dir to the in-repo submodule when it is initialized and
594
+ // the caller did not point us elsewhere (--src-dir) or force a standalone
595
+ // clone (--cache-dir). Keeps both build paths (mtp + AOSP) on the exact
596
+ // same pinned commit.
597
+ if (!args.srcDir && !args.cacheDirExplicit && llamaCppSubmodulePresent()) {
598
+ args.srcDir = LLAMA_CPP_SUBMODULE_DIR;
599
+ }
600
+
291
601
  return args;
292
602
  }
293
603
 
@@ -354,6 +664,126 @@ export function probeZig({
354
664
  return version;
355
665
  }
356
666
 
667
+ /**
668
+ * Decide the riscv64 build plan based on the detected Zig version + env knobs.
669
+ * Pure: takes the version string + env, returns a structured plan. No side
670
+ * effects.
671
+ *
672
+ * Returns one of:
673
+ * { rvv: false, allVariants: false, zigVersion, reason: "zig-too-old" }
674
+ * — Zig < MIN_ZIG_RVV_VERSION. Scalar parity; the riscv64ArgFilter in
675
+ * ensureZigDrivers strips `-march=rv64gc*` and the resulting binary is
676
+ * a plain rv64gc/lp64d build.
677
+ *
678
+ * { rvv: true, allVariants: false, zigVersion, reason: "zig-supports-rvv" }
679
+ * — Zig >= MIN_ZIG_RVV_VERSION. RVV + Zfh + Zvfh + Zicbop + Zihintpause
680
+ * ON (the upstream llama.cpp defaults). Resulting libggml-cpu.so requires
681
+ * RVV-capable hardware at runtime; SIGILLs on a scalar core.
682
+ *
683
+ * { rvv: true, allVariants: true, zigVersion, reason: "all-variants-opt-in" }
684
+ * — Zig >= MIN_ZIG_RVV_VERSION AND env ELIZA_GGML_CPU_ALL_VARIANTS=1.
685
+ * Builds GGML_BACKEND_DL + GGML_CPU_ALL_VARIANTS so two
686
+ * libggml-cpu-riscv64_{0,v}.so variants ship; runtime picks via
687
+ * riscv_hwprobe (`ggml-cpu/arch/riscv/cpu-feats.cpp`). Opt-in until the
688
+ * Android loader story for the DL-backend dispatch is verified end-to-end
689
+ * across arm64/x86_64 — flipping that on by default would change the
690
+ * artifact list for non-riscv64 ABIs too.
691
+ *
692
+ * { rvv: false, allVariants: false, zigVersion: null, reason: "zig-not-detected" }
693
+ * — Probe failed (used in dry-run mode where zig may legitimately not be
694
+ * on PATH). Falls back to scalar so the dry-run plan reflects the
695
+ * conservative default.
696
+ *
697
+ * Exported for tests.
698
+ */
699
+ export function resolveRiscv64BuildPlan({
700
+ zigVersion = null,
701
+ probe = probeZig,
702
+ env = process.env,
703
+ isDryRun = false,
704
+ } = {}) {
705
+ let version = zigVersion;
706
+ if (version === null) {
707
+ if (isDryRun) {
708
+ try {
709
+ version = probe();
710
+ } catch {
711
+ return {
712
+ rvv: false,
713
+ allVariants: false,
714
+ zigVersion: null,
715
+ reason: "zig-not-detected",
716
+ };
717
+ }
718
+ } else {
719
+ version = probe();
720
+ }
721
+ }
722
+ if (compareSemver(version, MIN_ZIG_RVV_VERSION) < 0) {
723
+ return {
724
+ rvv: false,
725
+ allVariants: false,
726
+ zigVersion: version,
727
+ reason: "zig-too-old",
728
+ };
729
+ }
730
+ const allVariantsOptIn = env.ELIZA_GGML_CPU_ALL_VARIANTS === "1";
731
+ return {
732
+ rvv: true,
733
+ allVariants: allVariantsOptIn,
734
+ zigVersion: version,
735
+ reason: allVariantsOptIn ? "all-variants-opt-in" : "zig-supports-rvv",
736
+ };
737
+ }
738
+
739
+ /**
740
+ * Map a riscv64 build plan to the cmake -D flags that select the right
741
+ * GGML_RVV / GGML_RV_ZFH / etc. combination. Returns an empty array for
742
+ * non-riscv64 ABIs.
743
+ *
744
+ * Exported for tests.
745
+ */
746
+ export function riscv64CmakeFlagsForPlan({ abi, plan }) {
747
+ if (abi !== "riscv64") return [];
748
+ if (plan.rvv === false) {
749
+ return [
750
+ "-DGGML_RVV=OFF",
751
+ "-DGGML_RV_ZFH=OFF",
752
+ "-DGGML_RV_ZVFH=OFF",
753
+ "-DGGML_RV_ZICBOP=OFF",
754
+ "-DGGML_RV_ZIHINTPAUSE=OFF",
755
+ "-DGGML_RV_ZVFBFWMA=OFF",
756
+ "-DGGML_XTHEADVECTOR=OFF",
757
+ "-DGGML_RV_ZBA=OFF",
758
+ "-DGGML_CPU_RISCV64_SPACEMIT=OFF",
759
+ ];
760
+ }
761
+ // RVV-on. Leave the vendored llama.cpp defaults (ON) for RVV / Zfh / Zvfh /
762
+ // Zicbop / Zihintpause. Keep Zvfbfwma / XTheadVector / Zba / SpaceMit off
763
+ // unless explicitly opted in — they're hardware-specific extensions that
764
+ // SIGILL on generic RVV cores.
765
+ const flags = [
766
+ "-DGGML_RVV=ON",
767
+ "-DGGML_RV_ZFH=ON",
768
+ "-DGGML_RV_ZVFH=ON",
769
+ "-DGGML_RV_ZICBOP=ON",
770
+ "-DGGML_RV_ZIHINTPAUSE=ON",
771
+ "-DGGML_RV_ZVFBFWMA=OFF",
772
+ "-DGGML_XTHEADVECTOR=OFF",
773
+ "-DGGML_RV_ZBA=OFF",
774
+ "-DGGML_CPU_RISCV64_SPACEMIT=OFF",
775
+ ];
776
+ if (plan.allVariants) {
777
+ // GGML_CPU_ALL_VARIANTS implies GGML_BACKEND_DL and builds per-variant
778
+ // libggml-cpu-riscv64_{0,v}.so; the loader picks via riscv_hwprobe.
779
+ // GGML_NATIVE is incompatible with GGML_BACKEND_DL in this mode (see
780
+ // ggml/src/ggml-cpu/CMakeLists.txt:491-494), so the existing
781
+ // `-DGGML_NATIVE=OFF` we pass must stay OFF (it does).
782
+ flags.push("-DGGML_BACKEND_DL=ON", "-DGGML_CPU_ALL_VARIANTS=ON");
783
+ }
784
+ return flags;
785
+ }
786
+
357
787
  function run(command, args, { cwd, env = process.env } = {}) {
358
788
  const result = spawnSync(command, args, {
359
789
  cwd,
@@ -397,6 +827,7 @@ export function ensureLlamaCppCheckout({
397
827
  log(`[compile-libllama] Reusing cached llama.cpp checkout at ${cacheDir}`);
398
828
  patchLlamaCppSourceForMusl({ srcDir: cacheDir, log });
399
829
  applyVendoredPatches({ srcDir: cacheDir, log });
830
+ assertSwaSpecDecodeFallback({ srcDir: cacheDir });
400
831
  return cacheDir;
401
832
  }
402
833
  if (!fs.existsSync(path.join(cacheDir, ".git"))) {
@@ -441,7 +872,7 @@ export function ensureLlamaCppCheckout({
441
872
  * and across partial-failure re-runs.
442
873
  *
443
874
  * Patches under `llama-cpp-patches/qjl/` add `GGML_TYPE_QJL1_256` (=46),
444
- * the QJL kernel sources vendored from `packages/native-plugins/qjl-cpu/`,
875
+ * the QJL kernel sources vendored from `packages/native/plugins/qjl-cpu/`,
445
876
  * the type-traits + op-dispatch wiring, and the `tests/test-qjl-cache.cpp`
446
877
  * synthetic-graph test.
447
878
  *
@@ -449,7 +880,7 @@ export function ensureLlamaCppCheckout({
449
880
  * `polarquant` series under the same directory exists but conflicts with
450
881
  * `qjl` over the GGML_TYPE_COUNT tag (PolarQuant claims id 45, QJL
451
882
  * claims 46) and is owned by a separate landing. When that series is
452
- * unified with QJL, append it here.
883
+ * merged with QJL, append it here.
453
884
  *
454
885
  * Order is:
455
886
  * 1. checkout -> 2. patchLlamaCppSourceForMusl -> 3. applyVendoredPatches.
@@ -478,6 +909,30 @@ export function applyVendoredPatches({
478
909
  spawn("node", [applierPath, "--repo", srcDir, "--series", "qjl"], {});
479
910
  }
480
911
 
912
+ function sourceContainsSwaSpecDecodeFallback(srcDir) {
913
+ const serverContextPath = path.join(
914
+ srcDir,
915
+ "tools",
916
+ "server",
917
+ "server-context.cpp",
918
+ );
919
+ if (!fs.existsSync(serverContextPath)) return false;
920
+ const source = fs.readFileSync(serverContextPath, "utf8");
921
+ return (
922
+ source.includes("seq_rm probe failed but model declares SWA") &&
923
+ source.includes("llama_model_n_swa(model_tgt) > 0") &&
924
+ source.includes("ctx_tgt_seq_rm_type = COMMON_CONTEXT_SEQ_RM_TYPE_FULL")
925
+ );
926
+ }
927
+
928
+ function assertSwaSpecDecodeFallback({ srcDir }) {
929
+ if (sourceContainsSwaSpecDecodeFallback(srcDir)) return;
930
+ throw new Error(
931
+ `[compile-libllama] checkout ${srcDir} lacks the SWA-aware seq_rm fallback ` +
932
+ `required for --spec-type mtp on SWA target bodies (elizaOS/eliza#7635).`,
933
+ );
934
+ }
935
+
481
936
  /**
482
937
  * Ensure `ggml/src/ggml.c` has the `<execinfo.h>` include gated on
483
938
  * `__GLIBC__`. musl libc does not ship `execinfo.h`, so a bare `__linux__`
@@ -598,7 +1053,12 @@ export function patchLlamaCppSourceForMusl({ srcDir, log = console.log }) {
598
1053
  *
599
1054
  * Exported for unit testing.
600
1055
  */
601
- export function ensureZigDrivers({ cacheDir, abi, zigBin = "zig" }) {
1056
+ export function ensureZigDrivers({
1057
+ cacheDir,
1058
+ abi,
1059
+ zigBin = "zig",
1060
+ riscv64MarchPassthrough = false,
1061
+ }) {
602
1062
  const target = ABI_TARGETS.find((t) => t.androidAbi === abi);
603
1063
  if (!target) {
604
1064
  throw new Error(`[compile-libllama] Unknown ABI: ${abi}`);
@@ -607,18 +1067,99 @@ export function ensureZigDrivers({ cacheDir, abi, zigBin = "zig" }) {
607
1067
  fs.mkdirSync(driverDir, { recursive: true });
608
1068
  const ccPath = path.join(driverDir, "zig-cc");
609
1069
  const cxxPath = path.join(driverDir, "zig-cxx");
1070
+
1071
+ // riscv64 needs an extra arg-filtering step on Zig 0.13. The vendored
1072
+ // llama.cpp's ggml-cpu CMakeLists hardcodes `-march=rv64gc -mabi=lp64d`
1073
+ // (and adds extension suffixes when GGML_RVV / GGML_RV_ZFH / etc. are ON).
1074
+ // Zig 0.13's bundled LLVM doesn't accept `-march=rv64gc` as a GCC-style
1075
+ // ISA string — it tries to translate it to `-mcpu=` and bails with
1076
+ // "unknown CPU: 'rv64gc'". The triple `riscv64-linux-musl` already
1077
+ // selects the rv64gc/lp64d baseline as Zig's triple-derived CPU, so
1078
+ // stripping these flags is byte-for-byte equivalent to the intended
1079
+ // build when RVV is OFF.
1080
+ //
1081
+ // On Zig 0.14+ (`riscv64MarchPassthrough=true`) we leave every
1082
+ // `-march=` / `-mabi=` flag alone: Zig 0.14's LLVM accepts the
1083
+ // GCC-style ISA string with the full `_zfh_zvfh_zicbop_zihintpause`
1084
+ // extension suffix, which is exactly what flips the RVV intrinsic
1085
+ // codepaths on in ggml/src/ggml-cpu/arch/riscv/quants.c.
1086
+ //
1087
+ // Filter logic: walk the argv via the POSIX `set --` idiom (no eval —
1088
+ // CMake escapes embedded quotes in -DGGML_VERSION=\"0.12.0\", and a
1089
+ // naive `eval exec "..."` collapses them and the C preprocessor sees
1090
+ // `0.12.0` as a malformed numeric literal). Each non-stripped arg is
1091
+ // re-pushed onto $@ in place; the final `exec "$zig" cc ... "$@"`
1092
+ // forwards the whole array with every quote and space preserved.
1093
+ const riscv64ArgFilter =
1094
+ abi === "riscv64" && !riscv64MarchPassthrough
1095
+ ? '_n=$#\n' +
1096
+ 'i=0\n' +
1097
+ 'while [ $i -lt $_n ]; do\n' +
1098
+ ' arg=$1\n' +
1099
+ ' shift\n' +
1100
+ ' i=$((i+1))\n' +
1101
+ ' case "$arg" in\n' +
1102
+ ' -march=rv64gc|-march=rv64gc_*) ;;\n' +
1103
+ ' -mabi=lp64d|-mabi=lp64) ;;\n' +
1104
+ ' *) set -- "$@" "$arg" ;;\n' +
1105
+ ' esac\n' +
1106
+ 'done\n'
1107
+ : null;
1108
+
1109
+ // arm64: the ggml-cpu CMakeLists emits the GCC-style ISA string
1110
+ // `-march=armv8.2-a+dotprod+fp16+i8mm` (from GGML_CPU_ARM_ARCH). Zig 0.13's
1111
+ // bundled LLVM rejects that for the aarch64 target — it tries to translate
1112
+ // `armv8.2-a` to a `-mcpu=` value and dies with "unknown CPU: 'armv8.2'"
1113
+ // (the same class of breakage the riscv64 filter handles). Zig instead
1114
+ // speaks `-mcpu=<cpu>+<feature>` with its OWN feature names. Rewrite the
1115
+ // GCC `-march=armv8.x-a+...` into the equivalent zig `-mcpu=generic+...`:
1116
+ // dotprod→dotprod, i8mm→i8mm, fp16→fullfp16. This sets exactly the same
1117
+ // __ARM_FEATURE_DOTPROD / __ARM_FEATURE_MATMUL_INT8 /
1118
+ // __ARM_FEATURE_FP16_VECTOR_ARITHMETIC macros (verified), so the live QJL
1119
+ // NEON-dotprod / i8mm / fp16 kernel bodies survive preprocessing and the
1120
+ // ggml ARM-feature configure probes pass. Any other `-march=` is passed
1121
+ // through untouched (there shouldn't be one for arm64).
1122
+ const arm64ArgFilter =
1123
+ abi === "arm64-v8a"
1124
+ ? '_n=$#\n' +
1125
+ 'i=0\n' +
1126
+ 'while [ $i -lt $_n ]; do\n' +
1127
+ ' arg=$1\n' +
1128
+ ' shift\n' +
1129
+ ' i=$((i+1))\n' +
1130
+ ' case "$arg" in\n' +
1131
+ ' -march=armv8.*-a+*)\n' +
1132
+ ' _feats=""\n' +
1133
+ ' case "$arg" in *+dotprod*) _feats="${_feats}+dotprod" ;; esac\n' +
1134
+ ' case "$arg" in *+i8mm*) _feats="${_feats}+i8mm" ;; esac\n' +
1135
+ ' case "$arg" in *+fp16*) _feats="${_feats}+fullfp16" ;; esac\n' +
1136
+ ' set -- "$@" "-mcpu=generic${_feats}" ;;\n' +
1137
+ ' *) set -- "$@" "$arg" ;;\n' +
1138
+ ' esac\n' +
1139
+ 'done\n'
1140
+ : null;
1141
+
1142
+ const argFilter = riscv64ArgFilter ?? arm64ArgFilter;
1143
+ const exec =
1144
+ argFilter !== null
1145
+ ? (subcmd) =>
1146
+ argFilter +
1147
+ `exec "${zigBin}" ${subcmd} --target=${target.zigTarget} "$@"\n`
1148
+ : (subcmd) =>
1149
+ `exec "${zigBin}" ${subcmd} --target=${target.zigTarget} "$@"\n`;
1150
+
610
1151
  // Quote zigBin so a path with spaces still works. The driver runs under
611
1152
  // /bin/sh which is POSIX-portable across Linux, macOS, Alpine.
612
1153
  const ccBody =
613
1154
  "#!/bin/sh\n" +
614
1155
  "# Auto-generated by eliza/packages/app-core/scripts/aosp/compile-libllama.mjs.\n" +
615
1156
  "# Do not edit — regenerated on every build.\n" +
616
- `exec "${zigBin}" cc --target=${target.zigTarget} "$@"\n`;
1157
+ exec("cc");
617
1158
  const cxxBody =
618
1159
  "#!/bin/sh\n" +
619
1160
  "# Auto-generated by eliza/packages/app-core/scripts/aosp/compile-libllama.mjs.\n" +
620
1161
  "# Do not edit — regenerated on every build.\n" +
621
- `exec "${zigBin}" c++ --target=${target.zigTarget} "$@"\n`;
1162
+ exec("c++");
622
1163
  fs.writeFileSync(ccPath, ccBody, "utf8");
623
1164
  fs.writeFileSync(cxxPath, cxxBody, "utf8");
624
1165
  fs.chmodSync(ccPath, 0o755);
@@ -653,6 +1194,12 @@ export function buildLibllamaForAbi({
653
1194
  zigBin = "zig",
654
1195
  log = console.log,
655
1196
  spawn = run,
1197
+ // Optional pass-through hooks used by the explicit-triple path
1198
+ // (`mainTargets`) to layer in the fused omnivoice flags + targets without
1199
+ // forking this helper. The non-fused bulk --abi path defaults both to
1200
+ // empty so its behavior stays byte-for-byte identical.
1201
+ extraCmakeFlags = [],
1202
+ extraBuildTargets = [],
656
1203
  }) {
657
1204
  const target = ABI_TARGETS.find((t) => t.androidAbi === abi);
658
1205
  if (!target) {
@@ -661,10 +1208,84 @@ export function buildLibllamaForAbi({
661
1208
  const buildDir = path.join(srcDir, `build-${abi}`);
662
1209
  fs.mkdirSync(buildDir, { recursive: true });
663
1210
 
1211
+ // riscv64: gate the RVV-on path on the detected Zig version. The vendored
1212
+ // llama.cpp defaults GGML_RVV / GGML_RV_ZFH / GGML_RV_ZVFH / GGML_RV_ZICBOP
1213
+ // / GGML_RV_ZIHINTPAUSE to ON, which builds the `-march=rv64gcv_zfh_zvfh_
1214
+ // zicbop_zihintpause` ISA string. Zig 0.13's bundled LLVM doesn't accept
1215
+ // that as a -march value (it tries to translate it to -mcpu= and fails
1216
+ // with "unknown CPU"); Zig 0.14+ does. resolveRiscv64BuildPlan() reads the
1217
+ // probed version and tells us which lane to take:
1218
+ // - rvv=false (Zig < 0.14) -> scalar parity. Force every RVV / Zfh /
1219
+ // Zvfh / Zicbop / Zihintpause / Zvfbfwma / XTheadVector option OFF so
1220
+ // MARCH_STR collapses to plain `rv64gc`. The driver-script argv
1221
+ // filter then strips `-march=rv64gc -mabi=lp64d` (Zig already implies
1222
+ // them via the triple).
1223
+ // - rvv=true (Zig >= 0.14) -> upstream defaults. The full
1224
+ // `-march=rv64gcv_zfh_zvfh_zicbop_zihintpause -mabi=lp64d` string
1225
+ // passes straight through to Zig 0.14's LLVM; quants.c's intrinsic
1226
+ // codepaths light up.
1227
+ // - allVariants (env ELIZA_GGML_CPU_ALL_VARIANTS=1) -> additionally
1228
+ // enable GGML_BACKEND_DL + GGML_CPU_ALL_VARIANTS so the build emits
1229
+ // libggml-cpu-riscv64_{0,v}.so siblings and the loader picks via
1230
+ // riscv_hwprobe at runtime. Opt-in until the Android DL-loader
1231
+ // plumbing for arm64/x86_64 is also verified.
1232
+ const riscv64Plan =
1233
+ abi === "riscv64"
1234
+ ? resolveRiscv64BuildPlan({ env: process.env })
1235
+ : { rvv: false, allVariants: false, zigVersion: null, reason: "n/a" };
1236
+ if (abi === "riscv64") {
1237
+ log(
1238
+ `[compile-libllama] riscv64 plan: zig=${riscv64Plan.zigVersion ?? "unknown"} ` +
1239
+ `rvv=${riscv64Plan.rvv ? "ON" : "OFF"} ` +
1240
+ `all-variants=${riscv64Plan.allVariants ? "ON" : "OFF"} ` +
1241
+ `reason=${riscv64Plan.reason}`,
1242
+ );
1243
+ }
1244
+ const riscv64BuildFlags = riscv64CmakeFlagsForPlan({ abi, plan: riscv64Plan });
1245
+
1246
+ // x86_64: the mobile x86_64 ABI only ever runs on cuttlefish / the Android
1247
+ // x86_64 emulator (both KVM-backed by an AVX2-class host, and our emulator
1248
+ // recipe boots with `-cpu host`). GGML_NATIVE=OFF leaves the build at the
1249
+ // baseline x86_64 ISA, which has two problems: (1) ggml's own AVX2 kernels
1250
+ // stay off, and (2) — fatal — the vendored QJL kernels gate their AVX2
1251
+ // implementations on `__AVX2__` while `qjl_dispatch.c` references
1252
+ // `qjl_quantize_rows_avx2` (and the score/projection AVX2 entry points)
1253
+ // unconditionally, so a baseline build links with an UNDEFINED symbol and
1254
+ // `dlopen(libllama.so)` fails at runtime with
1255
+ // `Error relocating libggml-cpu.so.0: qjl_quantize_rows_avx2: symbol not
1256
+ // found`. Turning on the standard ggml AVX2/FMA/F16C/AVX feature flags
1257
+ // defines `__AVX2__` for the ggml-cpu translation units (QJL included) so
1258
+ // those entry points are actually compiled. Runtime CPU dispatch still picks
1259
+ // scalar vs AVX2 per-call, but the symbols now exist.
1260
+ const x86_64BuildFlags =
1261
+ abi === "x86_64"
1262
+ ? ["-DGGML_AVX=ON", "-DGGML_AVX2=ON", "-DGGML_FMA=ON", "-DGGML_F16C=ON"]
1263
+ : [];
1264
+
1265
+ // arm64-v8a: GGML_NATIVE=OFF leaves the cross-build at the bare armv8-a
1266
+ // baseline, which keeps ggml's dotprod/i8mm/fp16 NEON kernels AND the eliza
1267
+ // QJL NEON-dotprod kernel dead. Pin the armv8.2-a+dotprod+fp16+i8mm floor and
1268
+ // flip the QJL dispatch define so the Pixel-class Tensor G4 actually runs the
1269
+ // accelerated paths. See build-helpers/arm64-simd.mjs for the full rationale.
1270
+ const arm64BuildFlags = androidArm64SimdCmakeFlags(abi);
1271
+ if (arm64BuildFlags.length > 0) {
1272
+ log(
1273
+ `[compile-libllama] arm64 SIMD floor: ${arm64BuildFlags.join(" ")} ` +
1274
+ `(dotprod/i8mm/fp16 + QJL NEON-dotprod dispatch)`,
1275
+ );
1276
+ }
1277
+
664
1278
  // Per-ABI driver scripts that wrap `zig cc --target=<triple>` so cmake's
665
1279
  // single-binary compiler probe works. See ensureZigDrivers() for why
666
- // passing `--target=` via CMAKE_C_FLAGS doesn't work on its own.
667
- const { ccPath, cxxPath } = ensureZigDrivers({ cacheDir, abi, zigBin });
1280
+ // passing `--target=` via CMAKE_C_FLAGS doesn't work on its own. When
1281
+ // RVV is on, the riscv64 driver passes `-march=rv64gc*` through to Zig
1282
+ // 0.14+ instead of filtering it out.
1283
+ const { ccPath, cxxPath } = ensureZigDrivers({
1284
+ cacheDir,
1285
+ abi,
1286
+ zigBin,
1287
+ riscv64MarchPassthrough: riscv64Plan.rvv,
1288
+ });
668
1289
 
669
1290
  log(
670
1291
  `[compile-libllama] Configuring llama.cpp for ${abi} (${target.zigTarget}) in ${buildDir}`,
@@ -680,9 +1301,10 @@ export function buildLibllamaForAbi({
680
1301
  "-DBUILD_SHARED_LIBS=ON",
681
1302
  "-DLLAMA_BUILD_EXAMPLES=OFF",
682
1303
  "-DLLAMA_BUILD_TESTS=OFF",
683
- // llama-server is required for the AOSP DFlash speculative-decode path
684
- // (target + drafter share one process; aosp-llama-adapter.ts spawns this
685
- // binary and routes inference over the OpenAI-compatible HTTP API). The
1304
+ // llama-server is required for the AOSP MTP speculative-decode path
1305
+ // (target + drafter share one process; the AOSP local-inference
1306
+ // bootstrap spawns this binary and routes inference over the
1307
+ // OpenAI-compatible HTTP API). The
686
1308
  // server target also pulls in the JSON/HTTP common-lib pieces, but adds
687
1309
  // ~1.5 MB stripped per ABI; small price relative to the spec-decode
688
1310
  // throughput win.
@@ -699,6 +1321,9 @@ export function buildLibllamaForAbi({
699
1321
  // device of the target ABI. The default tunes for the build host's
700
1322
  // native cpu, which is wrong for a cross-build.
701
1323
  "-DGGML_NATIVE=OFF",
1324
+ ...riscv64BuildFlags,
1325
+ ...x86_64BuildFlags,
1326
+ ...arm64BuildFlags,
702
1327
  // Don't bake in an absolute RUNPATH to the build tree. The default
703
1328
  // CMAKE_BUILD_RPATH points at the per-ABI build dir, which is a
704
1329
  // path-leak in shipped APKs and adds dead lookup entries at runtime.
@@ -709,6 +1334,11 @@ export function buildLibllamaForAbi({
709
1334
  "-DCMAKE_SKIP_INSTALL_RPATH=TRUE",
710
1335
  "-DCMAKE_BUILD_WITH_INSTALL_RPATH=TRUE",
711
1336
  "-DCMAKE_INSTALL_RPATH=",
1337
+ // `extraCmakeFlags` carries the omnivoice fused-build flags
1338
+ // (-DELIZA_FUSE_OMNIVOICE=ON, etc.) when the explicit-triple
1339
+ // path asked for a fused build. Empty for the non-fused bulk
1340
+ // --abi path.
1341
+ ...extraCmakeFlags,
712
1342
  ],
713
1343
  {},
714
1344
  );
@@ -720,6 +1350,72 @@ export function buildLibllamaForAbi({
720
1350
  {},
721
1351
  );
722
1352
 
1353
+ // Build any extra cmake targets the caller asked for — for fused builds
1354
+ // this is omnivoice-core + libelizainference + llama-omnivoice-server +
1355
+ // the bench/completion drivers (see fusedCmakeBuildTargets()). We filter
1356
+ // out `llama` + `llama-server` upstream (the dedicated build steps below
1357
+ // already handle those), so the extra-target invocation only adds NEW
1358
+ // CMake target names. The non-fused path passes an empty list.
1359
+ //
1360
+ // Targets are filtered against what the configured build tree actually
1361
+ // exposes. The eliza llama.cpp fork's target set drifts from the script's
1362
+ // pinned expectations — e.g. `llama-speculative-simple` is an upstream
1363
+ // example the fork drops in favour of MTP spec-decode. A
1364
+ // requested-but-absent *auxiliary* target must not abort the whole
1365
+ // libllama build: the libllama.so + libggml*.so family is the critical
1366
+ // output and is fully built by the `llama` target above. We warn on the
1367
+ // gap and continue. A target that *exists* but fails to build still
1368
+ // hard-errors via `spawn()`.
1369
+ if (extraBuildTargets.length > 0) {
1370
+ const helpProbe = spawnSync(
1371
+ "cmake",
1372
+ ["--build", buildDir, "--target", "help"],
1373
+ { encoding: "utf8" },
1374
+ );
1375
+ const availableTargets = new Set(
1376
+ (helpProbe.stdout || "")
1377
+ .split("\n")
1378
+ .map((line) => line.replace(/^\.\.\.\s*/, "").trim())
1379
+ .filter(Boolean),
1380
+ );
1381
+ for (const extraTarget of extraBuildTargets) {
1382
+ if (availableTargets.size > 0 && !availableTargets.has(extraTarget)) {
1383
+ log(
1384
+ `[compile-libllama] Skipping extra cmake target ${extraTarget} for ${abi} — ` +
1385
+ `not defined in this llama.cpp checkout (auxiliary target; libllama.so is unaffected).`,
1386
+ );
1387
+ continue;
1388
+ }
1389
+ log(
1390
+ `[compile-libllama] Building extra cmake target ${extraTarget} for ${abi}`,
1391
+ );
1392
+ try {
1393
+ spawn(
1394
+ "cmake",
1395
+ ["--build", buildDir, "--target", extraTarget, "-j", String(jobs)],
1396
+ {},
1397
+ );
1398
+ } catch (err) {
1399
+ // The fused libelizainference.so (`elizainference` target) is the only
1400
+ // extra target the APK actually bundles, and `verifyFusedSymbols`
1401
+ // enforces it after this loop — so it stays fatal. The rest are
1402
+ // standalone CLI drivers (omnivoice-tts / omnivoice-codec / llama-cli /
1403
+ // llama-bench / llama-completion / llama-mtmd-cli) that ship nothing
1404
+ // into the APK. The pinned fork's `omnivoice-tts.cpp` currently calls a
1405
+ // removed `backend_init("LM")` overload (backend.h only exposes
1406
+ // `backend_init_auto()`), so that driver fails to compile while
1407
+ // libelizainference.so builds fine. Don't let a broken auxiliary CLI
1408
+ // abort the build that produces the lib we need; warn and continue.
1409
+ if (CRITICAL_EXTRA_TARGETS.has(extraTarget)) throw err;
1410
+ log(
1411
+ `[compile-libllama] WARN: auxiliary cmake target ${extraTarget} failed to build for ${abi}; ` +
1412
+ `continuing — it bundles nothing into the APK and libllama.so/libelizainference.so are unaffected. ` +
1413
+ `Cause: ${err instanceof Error ? err.message : String(err)}`,
1414
+ );
1415
+ }
1416
+ }
1417
+ }
1418
+
723
1419
  // llama-server target. Built in a second --target invocation so a future
724
1420
  // operator can disable it via a flag without touching the libllama target.
725
1421
  // The target name is `llama-server` on the apothic fork (verified against
@@ -741,53 +1437,73 @@ export function buildLibllamaForAbi({
741
1437
  // libllama.so so the dynamic linker resolves the whole graph from the
742
1438
  // per-ABI asset dir at runtime (LD_LIBRARY_PATH set by
743
1439
  // ElizaAgentService.java).
744
- const builtLlama = locateBuiltLib(buildDir, "libllama.so");
745
- if (!builtLlama) {
746
- throw new Error(
747
- `[compile-libllama] Could not locate built libllama.so anywhere under ${buildDir}.`,
748
- );
749
- }
750
- const builtGgmlLibs = locateBuiltGgmlLibs(buildDir);
751
- if (builtGgmlLibs.length === 0) {
752
- throw new Error(
753
- `[compile-libllama] Could not locate any libggml*.so under ${buildDir}. ` +
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
- }
1440
+ // Static-fuse (BUILD_SHARED_LIBS=OFF the `*-fused` targets): llama/ggml/
1441
+ // mtmd build as STATIC `.a` archives folded into a self-contained
1442
+ // libelizainference.so (no DT_NEEDED on libllama.so/libggml*.so). So the
1443
+ // legacy co-copy of the shared libllama.so + ggml family is both impossible
1444
+ // (.so don't exist) and unnecessary (nothing dlopens them) — skip it. The
1445
+ // non-fused (BUILD_SHARED_LIBS=ON) bulk `--abi` path keeps staging the shared
1446
+ // family verbatim for its libllama.so-loading consumers.
1447
+ const isStaticFused = extraCmakeFlags.some((f) =>
1448
+ /BUILD_SHARED_LIBS\s*=\s*OFF/i.test(String(f)),
1449
+ );
758
1450
 
759
1451
  fs.mkdirSync(abiAssetDir, { recursive: true });
760
- const llamaOut = path.join(abiAssetDir, "libllama.so");
761
- fs.copyFileSync(builtLlama, llamaOut);
762
- const ggmlOuts = builtGgmlLibs.map((src) => {
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.
779
- const sonameAliases = [];
780
- for (const out of [llamaOut, ...ggmlOuts]) {
781
- const soname = readSoname(out);
782
- if (soname && soname !== path.basename(out)) {
783
- const aliasPath = path.join(abiAssetDir, soname);
784
- fs.copyFileSync(out, aliasPath);
785
- sonameAliases.push(aliasPath);
786
- log(
787
- `[compile-libllama] Copied ${path.basename(out)} -> ${soname} ` +
788
- `(NEEDED-resolution alias for ${abi}).`,
1452
+ let llamaOut = null;
1453
+ let ggmlOuts = [];
1454
+ let runtimeSiblingOuts = [];
1455
+ let sonameAliases = [];
1456
+ if (!isStaticFused) {
1457
+ const builtLlama = locateBuiltLib(buildDir, "libllama.so");
1458
+ if (!builtLlama) {
1459
+ throw new Error(
1460
+ `[compile-libllama] Could not locate built libllama.so anywhere under ${buildDir}.`,
1461
+ );
1462
+ }
1463
+ const builtGgmlLibs = locateBuiltGgmlLibs(buildDir);
1464
+ if (builtGgmlLibs.length === 0) {
1465
+ throw new Error(
1466
+ `[compile-libllama] Could not locate any libggml*.so under ${buildDir}. ` +
1467
+ `libllama.so has NEEDED entries for the ggml family; without co-copying ` +
1468
+ `them the runtime dlopen will fail. Check that BUILD_SHARED_LIBS=ON took effect.`,
789
1469
  );
790
1470
  }
1471
+ const builtRuntimeSiblingLibs = ["libllama-common.so", "libmtmd.so"]
1472
+ .map((name) => locateBuiltLib(buildDir, name))
1473
+ .filter(Boolean);
1474
+
1475
+ llamaOut = path.join(abiAssetDir, "libllama.so");
1476
+ fs.copyFileSync(builtLlama, llamaOut);
1477
+ ggmlOuts = builtGgmlLibs.map((src) => {
1478
+ const dst = path.join(abiAssetDir, path.basename(src));
1479
+ fs.copyFileSync(src, dst);
1480
+ return dst;
1481
+ });
1482
+ runtimeSiblingOuts = builtRuntimeSiblingLibs.map((src) => {
1483
+ const dst = path.join(abiAssetDir, path.basename(src));
1484
+ fs.copyFileSync(src, dst);
1485
+ return dst;
1486
+ });
1487
+
1488
+ // The apothic fork builds with SONAME chains: libllama.so has
1489
+ // SONAME=libllama.so.0 and NEEDED entries pointing at SONAME (e.g.
1490
+ // "libggml.so.0"), not at the unversioned filename. The dynamic linker
1491
+ // matches NEEDED against on-disk SONAME, so we must ship a copy at
1492
+ // libfoo.so.0 (or the linker fails to resolve and dlopen returns NULL).
1493
+ // We do NOT ship the .so.X.Y.Z versioned tail — only the SONAME alias
1494
+ // that NEEDED references.
1495
+ for (const out of [llamaOut, ...ggmlOuts, ...runtimeSiblingOuts]) {
1496
+ const soname = readSoname(out);
1497
+ if (soname && soname !== path.basename(out)) {
1498
+ const aliasPath = path.join(abiAssetDir, soname);
1499
+ fs.copyFileSync(out, aliasPath);
1500
+ sonameAliases.push(aliasPath);
1501
+ log(
1502
+ `[compile-libllama] Copied ${path.basename(out)} -> ${soname} ` +
1503
+ `(NEEDED-resolution alias for ${abi}).`,
1504
+ );
1505
+ }
1506
+ }
791
1507
  }
792
1508
 
793
1509
  // Locate + stage the llama-server binary. cmake puts it under
@@ -810,12 +1526,66 @@ export function buildLibllamaForAbi({
810
1526
  } else {
811
1527
  log(
812
1528
  `[compile-libllama] WARN: llama-server binary not found under ${buildDir}/bin/ or ${buildDir}/. ` +
813
- `DFlash speculative decode on AOSP requires it; rebuild with -DLLAMA_BUILD_SERVER=ON.`,
1529
+ `MTP speculative decode on AOSP requires it; rebuild with -DLLAMA_BUILD_SERVER=ON.`,
1530
+ );
1531
+ }
1532
+
1533
+ // Stage the fused-build artifacts when they are present: libelizainference.so
1534
+ // (the SHARED target the cmake graft declares) plus the legacy CLI smoke
1535
+ // target llama-omnivoice-server. We do NOT throw when these are missing —
1536
+ // a non-fused build (extraBuildTargets empty) won't produce them, and the
1537
+ // caller is responsible for invoking `verifyFusedSymbols` only on fused
1538
+ // targets. Mirrors the mtp install-loop's conditional copy of the same
1539
+ // pair.
1540
+ const fusedLibSrcCandidates = [
1541
+ path.join(buildDir, "libelizainference.so"),
1542
+ path.join(buildDir, "src", "libelizainference.so"),
1543
+ path.join(buildDir, "bin", "libelizainference.so"),
1544
+ ];
1545
+ const fusedLibSrc =
1546
+ fusedLibSrcCandidates.find((c) => fs.existsSync(c)) ??
1547
+ locateBuiltLib(buildDir, "libelizainference.so");
1548
+ let fusedLibOut = null;
1549
+ if (fusedLibSrc) {
1550
+ fusedLibOut = path.join(abiAssetDir, "libelizainference.so");
1551
+ fs.copyFileSync(fusedLibSrc, fusedLibOut);
1552
+ log(
1553
+ `[compile-libllama] Copied libelizainference.so for ${abi} (${(fs.statSync(fusedLibOut).size / (1024 * 1024)).toFixed(2)} MB).`,
1554
+ );
1555
+ }
1556
+ // Under static-fuse the self-contained libelizainference.so is the ONLY
1557
+ // shipped native lib (no libllama.so/libggml*.so), so its absence is fatal.
1558
+ if (isStaticFused && !fusedLibOut) {
1559
+ throw new Error(
1560
+ `[compile-libllama] static-fuse build for ${abi} produced no libelizainference.so ` +
1561
+ `under ${buildDir}. The fused self-contained lib is the only artifact this ` +
1562
+ `target ships — verify the elizainference cmake target built.`,
1563
+ );
1564
+ }
1565
+ const fusedServerSrcCandidates = [
1566
+ path.join(buildDir, "bin", "llama-omnivoice-server"),
1567
+ path.join(buildDir, "llama-omnivoice-server"),
1568
+ ];
1569
+ const fusedServerSrc = fusedServerSrcCandidates.find((c) => fs.existsSync(c));
1570
+ let fusedServerOut = null;
1571
+ if (fusedServerSrc) {
1572
+ fusedServerOut = path.join(abiAssetDir, "llama-omnivoice-server");
1573
+ fs.copyFileSync(fusedServerSrc, fusedServerOut);
1574
+ fs.chmodSync(fusedServerOut, 0o755);
1575
+ log(
1576
+ `[compile-libllama] Copied llama-omnivoice-server for ${abi} (${(fs.statSync(fusedServerOut).size / (1024 * 1024)).toFixed(2)} MB).`,
814
1577
  );
815
1578
  }
816
1579
 
817
- const stripTargets = [...ggmlOuts, llamaOut, ...sonameAliases];
1580
+ const stripTargets = [
1581
+ ...ggmlOuts,
1582
+ ...runtimeSiblingOuts,
1583
+ llamaOut,
1584
+ ...sonameAliases,
1585
+ ].filter(Boolean); // llamaOut is null under static-fuse (no shared libllama.so)
818
1586
  if (llamaServerOut) stripTargets.push(llamaServerOut);
1587
+ if (fusedLibOut) stripTargets.push(fusedLibOut);
1588
+ if (fusedServerOut) stripTargets.push(fusedServerOut);
819
1589
  for (const out of stripTargets) {
820
1590
  const sizeBefore = fs.statSync(out).size;
821
1591
  const stripped = stripBinary({ filePath: out, zigBin, log });
@@ -833,131 +1603,18 @@ export function buildLibllamaForAbi({
833
1603
  );
834
1604
  }
835
1605
  }
836
- // Re-chmod llama-server after strip — system strip may reset perms.
1606
+ // Re-chmod executables after strip — system strip may reset perms.
837
1607
  if (llamaServerOut) fs.chmodSync(llamaServerOut, 0o755);
838
- return { llama: llamaOut, ggml: ggmlOuts, llamaServer: llamaServerOut };
1608
+ if (fusedServerOut) fs.chmodSync(fusedServerOut, 0o755);
1609
+ return {
1610
+ llama: llamaOut,
1611
+ ggml: ggmlOuts,
1612
+ llamaServer: llamaServerOut,
1613
+ elizainference: fusedLibOut,
1614
+ omnivoiceServer: fusedServerOut,
1615
+ };
839
1616
  }
840
1617
 
841
- /**
842
- * Compile `llama-shim/eliza_llama_shim.c` (next to this script) into
843
- * `<abiAssetDir>/libeliza-llama-shim.so`. The shim provides
844
- * pointer-style wrappers around llama.cpp's struct-by-value entry
845
- * points that bun:ffi cannot call directly. See the file's header for
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;
960
- }
961
1618
 
962
1619
  /**
963
1620
  * Find every `libggml*.so` under the build tree. b4500 shipped plain .so
@@ -1175,6 +1832,60 @@ function locateBuiltLib(buildDir, soName) {
1175
1832
  * Falls back to system `strip --strip-all <file>` (in-place safe on
1176
1833
  * GNU coreutils) if `zig objcopy` is missing or errors.
1177
1834
  */
1835
+ // Cache of the resolved llvm-strip path (from the Android NDK toolchain).
1836
+ // Set once on first call so we don't re-walk the NDK dir for every artifact.
1837
+ let _ndkLlvmStripPathCache = undefined;
1838
+ function locateNdkLlvmStrip() {
1839
+ if (_ndkLlvmStripPathCache !== undefined) return _ndkLlvmStripPathCache;
1840
+ // Honor the same env-var ladder as build-llama-cpp-mtp's resolveAndroidNdk()
1841
+ // so operators with a custom NDK location get a consistent answer in both
1842
+ // scripts.
1843
+ const envRoots = [
1844
+ process.env.ANDROID_NDK_HOME,
1845
+ process.env.ANDROID_NDK_ROOT,
1846
+ process.env.ANDROID_NDK,
1847
+ ].filter((v) => typeof v === "string" && v.length > 0);
1848
+ const sdkRoots = [
1849
+ process.env.ANDROID_HOME,
1850
+ process.env.ANDROID_SDK_ROOT,
1851
+ path.join(os.homedir(), "Library", "Android", "sdk"),
1852
+ path.join(os.homedir(), "Android", "Sdk"),
1853
+ ].filter((v) => typeof v === "string" && v.length > 0);
1854
+ const candidateNdks = [...envRoots];
1855
+ for (const sdk of sdkRoots) {
1856
+ const ndkDir = path.join(sdk, "ndk");
1857
+ if (!fs.existsSync(ndkDir)) continue;
1858
+ const versions = fs
1859
+ .readdirSync(ndkDir, { withFileTypes: true })
1860
+ .filter((e) => e.isDirectory())
1861
+ .map((e) => e.name)
1862
+ .sort();
1863
+ if (versions.length > 0) {
1864
+ candidateNdks.push(path.join(ndkDir, versions[versions.length - 1]));
1865
+ }
1866
+ }
1867
+ const hosts = ["linux-x86_64", "darwin-arm64", "darwin-x86_64"];
1868
+ for (const ndk of candidateNdks) {
1869
+ for (const host of hosts) {
1870
+ const cand = path.join(
1871
+ ndk,
1872
+ "toolchains",
1873
+ "llvm",
1874
+ "prebuilt",
1875
+ host,
1876
+ "bin",
1877
+ "llvm-strip",
1878
+ );
1879
+ if (fs.existsSync(cand)) {
1880
+ _ndkLlvmStripPathCache = cand;
1881
+ return cand;
1882
+ }
1883
+ }
1884
+ }
1885
+ _ndkLlvmStripPathCache = null;
1886
+ return null;
1887
+ }
1888
+
1178
1889
  function stripBinary({ filePath, zigBin, log }) {
1179
1890
  const tmpPath = `${filePath}.stripped`;
1180
1891
  const zigStripResult = spawnSync(
@@ -1209,38 +1920,190 @@ function stripBinary({ filePath, zigBin, log }) {
1209
1920
  `error=${zigStripResult.error?.message ?? "none"}); falling back to system strip.`,
1210
1921
  );
1211
1922
  }
1212
- // Fallback: system strip. GNU coreutils strip is in-place safe.
1923
+ // Fallback 1: system strip. GNU coreutils strip is in-place safe.
1924
+ // x86_64-binutils doesn't grok riscv64 ELF or aarch64 ELF, so on a
1925
+ // mismatched host this returns non-zero — fall through to llvm-strip.
1213
1926
  const systemStripResult = spawnSync("strip", ["--strip-all", filePath], {
1214
1927
  stdio: ["ignore", "pipe", "pipe"],
1215
1928
  });
1216
1929
  if (systemStripResult.status === 0) return true;
1930
+ // Fallback 2: NDK's llvm-strip handles every Android ABI (arm64-v8a,
1931
+ // x86_64, riscv64) including cross-host. This is the production path
1932
+ // for riscv64 until Zig 0.14's objcopy lands across all build hosts.
1933
+ const llvmStrip = locateNdkLlvmStrip();
1934
+ if (llvmStrip) {
1935
+ const llvmStripResult = spawnSync(
1936
+ llvmStrip,
1937
+ ["--strip-all", filePath],
1938
+ { stdio: ["ignore", "pipe", "pipe"] },
1939
+ );
1940
+ if (llvmStripResult.status === 0) return true;
1941
+ log(
1942
+ `[compile-libllama] DEBUG: NDK llvm-strip (${llvmStrip}) failed ` +
1943
+ `(status=${llvmStripResult.status}, error=${llvmStripResult.error?.message ?? "none"}).`,
1944
+ );
1945
+ }
1217
1946
  log(
1218
1947
  `[compile-libllama] WARN: could not strip ${filePath}; shipping with debug symbols.`,
1219
1948
  );
1220
1949
  return false;
1221
1950
  }
1222
1951
 
1952
+ /**
1953
+ * No-op shim retained for backward compatibility with callers that still
1954
+ * import `applyOmnivoiceGraft`. H2.c collapsed the W3-3 deprecation runway:
1955
+ * the legacy clone-and-graft path is gone; OmniVoice is built exclusively
1956
+ * from the merged in-fork tree at `tools/omnivoice/`.
1957
+ *
1958
+ * Returns a minimal info object so log lines that surface fields like
1959
+ * `commit` or `sourceCount` keep their shape; the merged tree's source
1960
+ * count is fixed at build time and recorded by `verifyFusedSymbols`.
1961
+ */
1962
+ export function applyOmnivoiceGraft({ srcDir: _srcDir, log = console.log }) {
1963
+ log(
1964
+ "[compile-libllama] omnivoice: merged in-fork path (legacy graft removed)",
1965
+ );
1966
+ return { mode: "merged", source: "tools/omnivoice" };
1967
+ }
1968
+
1969
+ /**
1970
+ * Print the dry-run plan for one `android-<arch>-<backend>[-fused]` target:
1971
+ * the cmake invocation, the post-cmake build target list, the graft steps
1972
+ * (for fused targets), the expected output file layout, and the post-build
1973
+ * verify step (for fused targets). Mirrors the structure of the mtp build
1974
+ * script's --dry-run output so the two paths read the same.
1975
+ *
1976
+ * Exported for tests so the dry-run rendering can be asserted without going
1977
+ * through the CLI entry point.
1978
+ */
1979
+ export function describeAndroidTargetDryRun({
1980
+ target,
1981
+ srcDir,
1982
+ cacheDir,
1983
+ abiAssetDir,
1984
+ jobs,
1985
+ log = console.log,
1986
+ }) {
1987
+ const parsed = parseAndroidTarget(target.target ?? target);
1988
+ const abiTarget = ABI_TARGETS.find((t) => t.androidAbi === parsed.androidAbi);
1989
+ if (!abiTarget) {
1990
+ throw new Error(
1991
+ `[compile-libllama] No ABI mapping for ${parsed.androidAbi}`,
1992
+ );
1993
+ }
1994
+ const buildDir = path.join(srcDir, `build-${parsed.androidAbi}`);
1995
+ const ccPath = path.join(cacheDir, "zig-driver", parsed.androidAbi, "zig-cc");
1996
+ const cxxPath = path.join(
1997
+ cacheDir,
1998
+ "zig-driver",
1999
+ parsed.androidAbi,
2000
+ "zig-cxx",
2001
+ );
2002
+ log(`[compile-libllama] (dry-run) target=${parsed.target}`);
2003
+ log(` zig-target=${abiTarget.zigTarget} android-abi=${parsed.androidAbi}`);
2004
+ log(` src=${srcDir}`);
2005
+ log(` build=${buildDir}`);
2006
+ log(` install=${abiAssetDir}`);
2007
+ if (parsed.fused) {
2008
+ log(` omnivoice: merged in-fork path (tools/omnivoice/)`);
2009
+ }
2010
+ const cmakeFlags = [
2011
+ "-S",
2012
+ srcDir,
2013
+ "-B",
2014
+ buildDir,
2015
+ "-DCMAKE_BUILD_TYPE=Release",
2016
+ "-DBUILD_SHARED_LIBS=ON",
2017
+ "-DLLAMA_BUILD_EXAMPLES=OFF",
2018
+ "-DLLAMA_BUILD_TESTS=OFF",
2019
+ "-DLLAMA_BUILD_SERVER=ON",
2020
+ "-DLLAMA_CURL=OFF",
2021
+ `-DCMAKE_C_COMPILER=${ccPath}`,
2022
+ `-DCMAKE_CXX_COMPILER=${cxxPath}`,
2023
+ "-DCMAKE_C_COMPILER_LAUNCHER=",
2024
+ "-DCMAKE_CXX_COMPILER_LAUNCHER=",
2025
+ "-DCMAKE_SYSTEM_NAME=Linux",
2026
+ `-DCMAKE_SYSTEM_PROCESSOR=${abiTarget.cmakeProcessor}`,
2027
+ "-DGGML_NATIVE=OFF",
2028
+ ];
2029
+ // riscv64 build flags must show up in dry-run output too — the real
2030
+ // buildLibllamaForAbi() resolves these from the detected Zig version and
2031
+ // operators reading the dry-run plan should see the byte-exact list that
2032
+ // will be passed. resolveRiscv64BuildPlan() falls back to scalar when zig
2033
+ // is not installed (dry-run is allowed on toolchain-less boxes), so the
2034
+ // plan reported here mirrors what a build invocation would actually emit
2035
+ // on the same host.
2036
+ if (parsed.androidAbi === "riscv64") {
2037
+ const plan = resolveRiscv64BuildPlan({ env: process.env, isDryRun: true });
2038
+ log(
2039
+ ` riscv64 plan: zig=${plan.zigVersion ?? "unknown"} ` +
2040
+ `rvv=${plan.rvv ? "ON" : "OFF"} ` +
2041
+ `all-variants=${plan.allVariants ? "ON" : "OFF"} ` +
2042
+ `reason=${plan.reason}`,
2043
+ );
2044
+ cmakeFlags.push(
2045
+ ...riscv64CmakeFlagsForPlan({ abi: parsed.androidAbi, plan }),
2046
+ );
2047
+ }
2048
+ // arm64-v8a SIMD floor (dotprod/i8mm/fp16 + QJL NEON-dotprod dispatch) — the
2049
+ // real buildLibllamaForAbi() emits these too; surface them in the dry-run.
2050
+ cmakeFlags.push(...androidArm64SimdCmakeFlags(parsed.androidAbi));
2051
+ cmakeFlags.push(
2052
+ "-DCMAKE_SKIP_BUILD_RPATH=TRUE",
2053
+ "-DCMAKE_SKIP_INSTALL_RPATH=TRUE",
2054
+ "-DCMAKE_BUILD_WITH_INSTALL_RPATH=TRUE",
2055
+ "-DCMAKE_INSTALL_RPATH=",
2056
+ );
2057
+ if (parsed.fused) {
2058
+ cmakeFlags.push(...fusedExtraCmakeFlags());
2059
+ }
2060
+ log(` cmake ${cmakeFlags.join(" ")}`);
2061
+ const buildTargets = parsed.fused
2062
+ ? fusedCmakeBuildTargets()
2063
+ : ["llama", "llama-server"];
2064
+ log(
2065
+ ` cmake --build ${buildDir} --target ${buildTargets.join(" ")} -j ${jobs}`,
2066
+ );
2067
+ log(` expected output layout under ${abiAssetDir}:`);
2068
+ log(` libllama.so libggml*.so llama-server`);
2069
+ if (parsed.fused) {
2070
+ log(
2071
+ ` libelizainference.so omnivoice-tts omnivoice-codec (merged-tree artifacts)`,
2072
+ );
2073
+ log(
2074
+ ` verifyFusedSymbols outDir=${abiAssetDir} target=${parsed.target} (post-build)`,
2075
+ );
2076
+ }
2077
+ }
2078
+
1223
2079
  export async function main(argv = process.argv.slice(2)) {
1224
2080
  const args = parseArgs(argv);
1225
2081
 
1226
- // Probe toolchain first so we fail loudly before doing any work.
1227
- const zigVersion = probeZig();
1228
- console.log(`[compile-libllama] Found zig ${zigVersion}`);
2082
+ // If --target was passed, the caller is asking for the mtp-style
2083
+ // explicit-triple build path. --abi still drives the legacy bulk-build
2084
+ // (cpu only, no fusion) entry point so existing callers keep working.
2085
+ if (args.targets.length > 0) {
2086
+ return mainTargets(args);
2087
+ }
2088
+
2089
+ // Probe toolchain first so we fail loudly before doing any work. Skip in
2090
+ // dry-run mode — operators on a box without zig still want to inspect what
2091
+ // the build WOULD do.
2092
+ if (!args.dryRun) {
2093
+ const zigVersion = probeZig();
2094
+ console.log(`[compile-libllama] Found zig ${zigVersion}`);
2095
+ } else {
2096
+ console.log(`[compile-libllama] (dry-run) skipping zig toolchain probe`);
2097
+ }
1229
2098
 
1230
2099
  let allPresent = true;
1231
2100
  for (const abi of args.abis) {
1232
2101
  const llama = path.join(args.androidAssetsDir, abi, "libllama.so");
1233
2102
  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
2103
  const llamaServer = path.join(args.androidAssetsDir, abi, "llama-server");
1240
2104
  if (
1241
2105
  !fs.existsSync(llama) ||
1242
2106
  !fs.existsSync(ggml) ||
1243
- !fs.existsSync(shim) ||
1244
2107
  !fs.existsSync(llamaServer)
1245
2108
  ) {
1246
2109
  allPresent = false;
@@ -1253,6 +2116,31 @@ export async function main(argv = process.argv.slice(2)) {
1253
2116
  );
1254
2117
  return;
1255
2118
  }
2119
+ if (args.dryRun) {
2120
+ console.log(
2121
+ "[compile-libllama] (dry-run) bulk --abi mode requested; emit dry-run for each ABI as a non-fused android-<arch>-cpu target",
2122
+ );
2123
+ const srcDirForDry =
2124
+ args.srcDir ??
2125
+ (llamaCppSubmodulePresent() ? LLAMA_CPP_SUBMODULE_DIR : args.cacheDir);
2126
+ for (const abi of args.abis) {
2127
+ // arm64-v8a is the only ANDROID_ABI that doesn't share its name with
2128
+ // the `android-<arch>-cpu` triple's <arch> token; x86_64 and riscv64
2129
+ // map 1:1 to the same string in both spellings. Keep this in sync
2130
+ // with parseAndroidTarget()'s arch→ABI mapping.
2131
+ const arch = abi === "arm64-v8a" ? "arm64" : abi;
2132
+ const target = `android-${arch}-cpu`;
2133
+ const abiAssetDir = path.join(args.androidAssetsDir, abi);
2134
+ describeAndroidTargetDryRun({
2135
+ target,
2136
+ srcDir: srcDirForDry,
2137
+ cacheDir: args.cacheDir,
2138
+ abiAssetDir,
2139
+ jobs: args.jobs,
2140
+ });
2141
+ }
2142
+ return;
2143
+ }
1256
2144
 
1257
2145
  let srcDir;
1258
2146
  let srcDescription;
@@ -1260,19 +2148,42 @@ export async function main(argv = process.argv.slice(2)) {
1260
2148
  if (!fs.existsSync(path.join(args.srcDir, "CMakeLists.txt"))) {
1261
2149
  throw new Error(
1262
2150
  `[compile-libllama] --src-dir ${args.srcDir} does not contain a CMakeLists.txt; ` +
1263
- `expected a llama.cpp / buun-llama-cpp checkout.`,
2151
+ `expected a llama.cpp checkout.`,
1264
2152
  );
1265
2153
  }
1266
2154
  srcDir = args.srcDir;
2155
+ const isSubmodule =
2156
+ path.resolve(srcDir) === path.resolve(LLAMA_CPP_SUBMODULE_DIR);
1267
2157
  let headRef = "(unknown)";
1268
2158
  try {
1269
- headRef = fs.readFileSync(path.join(srcDir, ".git", "HEAD"), "utf8").trim();
2159
+ // A submodule's `.git` is a file (`gitdir: ...`), not a dir, so resolve
2160
+ // HEAD via `git rev-parse` rather than reading `.git/HEAD` directly.
2161
+ const out = spawnSync("git", ["-C", srcDir, "rev-parse", "HEAD"], {
2162
+ encoding: "utf8",
2163
+ });
2164
+ if (out.status === 0) headRef = out.stdout.trim();
1270
2165
  } catch {}
1271
- console.log(
1272
- `[compile-libllama] Using --src-dir ${srcDir} (HEAD: ${headRef}); ` +
1273
- `pinned tag ${LLAMA_CPP_TAG} ignored.`,
1274
- );
1275
- srcDescription = `external src-dir ${srcDir}`;
2166
+ if (isSubmodule) {
2167
+ // The in-repo submodule is pinned by the eliza repo's gitlink. Discard
2168
+ // the source patches a prior build left behind (tracked + untracked)
2169
+ // before re-applying them, so a fresh artifact starts from the pristine
2170
+ // submodule tree. Never detach/fetch — `bun install` keeps it pinned.
2171
+ console.log(
2172
+ `[compile-libllama] Using the in-repo llama.cpp submodule ${srcDir} ` +
2173
+ `(HEAD: ${headRef}); resetting prior source patches.`,
2174
+ );
2175
+ run("git", ["-C", srcDir, "checkout", "--", "."], {});
2176
+ run("git", ["-C", srcDir, "clean", "-fdx"], {});
2177
+ assertSwaSpecDecodeFallback({ srcDir });
2178
+ srcDescription = `submodule plugins/plugin-local-inference/native/llama.cpp @ ${headRef.slice(0, 12)}`;
2179
+ } else {
2180
+ console.log(
2181
+ `[compile-libllama] Using --src-dir ${srcDir} (HEAD: ${headRef}); ` +
2182
+ `pinned tag ${LLAMA_CPP_TAG} ignored.`,
2183
+ );
2184
+ assertSwaSpecDecodeFallback({ srcDir });
2185
+ srcDescription = `external src-dir ${srcDir}`;
2186
+ }
1276
2187
  } else {
1277
2188
  srcDir = ensureLlamaCppCheckout({
1278
2189
  cacheDir: args.cacheDir,
@@ -1284,6 +2195,12 @@ export async function main(argv = process.argv.slice(2)) {
1284
2195
 
1285
2196
  for (const abi of args.abis) {
1286
2197
  const abiAssetDir = path.join(args.androidAssetsDir, abi);
2198
+ // Builds + stages libllama.so + the libggml*.so family + llama-server.
2199
+ // libllama.so + libggml*.so are runtime DT_NEEDED dependencies of the
2200
+ // fused libelizainference.so (the fork's `elizainference` target does
2201
+ // `target_link_libraries(elizainference PUBLIC llama)` with
2202
+ // BUILD_SHARED_LIBS=ON), so they stay required even though no TS adapter
2203
+ // dlopens libllama.so directly anymore.
1287
2204
  buildLibllamaForAbi({
1288
2205
  srcDir,
1289
2206
  cacheDir: args.cacheDir,
@@ -1293,17 +2210,6 @@ export async function main(argv = process.argv.slice(2)) {
1293
2210
  log: console.log,
1294
2211
  spawn: run,
1295
2212
  });
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
2213
  }
1308
2214
 
1309
2215
  // Cross-compile the SIGSYS-handler shim + loader-wrap for x86_64. ARM64
@@ -1319,11 +2225,201 @@ export async function main(argv = process.argv.slice(2)) {
1319
2225
  await compileShimMain(["--skip-if-present"]);
1320
2226
 
1321
2227
  console.log(
1322
- `[compile-libllama] Built libllama.so + libeliza-llama-shim.so + llama-server for ` +
2228
+ `[compile-libllama] Built libllama.so + libggml*.so + llama-server for ` +
1323
2229
  `${args.abis.join(", ")} (${srcDescription}).`,
1324
2230
  );
1325
2231
  }
1326
2232
 
2233
+ /**
2234
+ * Explicit-triple entry point: runs the build for one or more
2235
+ * `android-<arch>-<backend>[-fused]` targets. Mirrors the mtp build
2236
+ * script's `--target` semantics one-for-one so an operator running the
2237
+ * desktop fused build and the mobile fused build invokes the two scripts
2238
+ * with the same target string.
2239
+ *
2240
+ * Build flow per target:
2241
+ * 1. Resolve the llama.cpp source tree (--src-dir / in-repo submodule /
2242
+ * standalone clone — same logic as the bulk --abi path).
2243
+ * 2. For `*-fused`: the merged in-fork tree at `tools/omnivoice/`
2244
+ * already declares the omnivoice + elizainference targets; just add
2245
+ * the CMake flags via `fusedExtraCmakeFlags()`.
2246
+ * 3. Run `buildLibllamaForAbi()` (which also configures + links the
2247
+ * llama-server target — required for fused so omnivoice_lib links
2248
+ * into the same binary).
2249
+ * 4. For `*-fused`: run `verifyFusedSymbols()` against the install dir,
2250
+ * asserting libelizainference.so carries `llama_*` + `ov_*` +
2251
+ * `eliza_inference_*` exports.
2252
+ *
2253
+ * Dry-run prints what each step WOULD do without touching the filesystem
2254
+ * or running cmake / the NDK.
2255
+ */
2256
+ export async function mainTargets(args) {
2257
+ // Resolve the source dir up front so dry-run can report a real path.
2258
+ let srcDir;
2259
+ let srcDescription;
2260
+ if (args.srcDir) {
2261
+ if (
2262
+ !args.dryRun &&
2263
+ !fs.existsSync(path.join(args.srcDir, "CMakeLists.txt"))
2264
+ ) {
2265
+ throw new Error(
2266
+ `[compile-libllama] --src-dir ${args.srcDir} does not contain a CMakeLists.txt; ` +
2267
+ `expected a llama.cpp checkout.`,
2268
+ );
2269
+ }
2270
+ srcDir = args.srcDir;
2271
+ const isSubmodule =
2272
+ path.resolve(srcDir) === path.resolve(LLAMA_CPP_SUBMODULE_DIR);
2273
+ srcDescription = isSubmodule
2274
+ ? `submodule plugins/plugin-local-inference/native/llama.cpp`
2275
+ : `external src-dir ${srcDir}`;
2276
+ if (!args.dryRun) assertSwaSpecDecodeFallback({ srcDir });
2277
+ } else if (args.dryRun) {
2278
+ // In a dry run with no --src-dir and no submodule, just describe the
2279
+ // intended cache path; we never clone in dry-run.
2280
+ srcDir = args.cacheDir;
2281
+ srcDescription = `cache ${args.cacheDir} (would clone ${LLAMA_CPP_TAG})`;
2282
+ } else {
2283
+ srcDir = ensureLlamaCppCheckout({
2284
+ cacheDir: args.cacheDir,
2285
+ log: console.log,
2286
+ spawn: run,
2287
+ });
2288
+ srcDescription = `llama.cpp ${LLAMA_CPP_TAG} / ${LLAMA_CPP_COMMIT.slice(0, 12)}`;
2289
+ }
2290
+
2291
+ // omnivoice.cpp clone lives at <cacheRoot>/omnivoice.cpp; we use the parent
2292
+ // of the llama.cpp cache dir so both clones live under one cache root, the
2293
+ // same shape the mtp build path uses (cacheRoot=path.dirname(args.cacheDir)).
2294
+ const omnivoiceCacheRoot = path.dirname(args.cacheDir);
2295
+
2296
+ if (!args.dryRun) {
2297
+ const zigVersion = probeZig();
2298
+ console.log(`[compile-libllama] Found zig ${zigVersion}`);
2299
+ } else {
2300
+ console.log(`[compile-libllama] (dry-run) skipping zig toolchain probe`);
2301
+ }
2302
+
2303
+ for (const parsed of args.targets) {
2304
+ const abiAssetDir = path.join(args.androidAssetsDir, parsed.androidAbi);
2305
+ if (args.dryRun) {
2306
+ describeAndroidTargetDryRun({
2307
+ target: parsed.target,
2308
+ srcDir,
2309
+ cacheDir: args.cacheDir,
2310
+ abiAssetDir,
2311
+ jobs: args.jobs,
2312
+ });
2313
+ if (parsed.fused) {
2314
+ console.log(
2315
+ ` fused-graft cacheRoot=${omnivoiceCacheRoot} (omnivoice.cpp clone)`,
2316
+ );
2317
+ }
2318
+ continue;
2319
+ }
2320
+
2321
+ // Pre-cmake: run the omnivoice graft for fused targets. Same call
2322
+ // sequence as the mtp linux-x64-cpu-fused path; the graft is
2323
+ // toolchain-agnostic (CMake snippet + source layout).
2324
+ let omnivoiceInfo = null;
2325
+ if (parsed.fused) {
2326
+ omnivoiceInfo = applyOmnivoiceGraft({
2327
+ srcDir,
2328
+ omnivoiceCacheRoot,
2329
+ log: console.log,
2330
+ });
2331
+ }
2332
+
2333
+ // Vulkan target: graft the eliza-1 qjl/polar Vulkan compute shaders +
2334
+ // ggml-vulkan dispatch patches into the source, and assemble the
2335
+ // GGML_VULKAN CMake flags (NDK glslc + headers + aarch64 loader). The
2336
+ // libggml-vulkan.so the build emits is glob-staged alongside the rest of
2337
+ // the libggml family by buildLibllamaForAbi.
2338
+ let vulkanCmakeFlags = [];
2339
+ if (parsed.backend === "vulkan") {
2340
+ console.log(
2341
+ `[compile-libllama] Patching eliza-1 Vulkan kernels into ${srcDir} for ${parsed.target}`,
2342
+ );
2343
+ patchVulkanKernels(srcDir, { target: parsed.target });
2344
+ vulkanCmakeFlags = resolveAndroidVulkanCmakeFlags({
2345
+ stagingDir: path.join(args.cacheDir, "vulkan-headers"),
2346
+ });
2347
+ }
2348
+
2349
+ // The existing per-ABI build helper handles the cmake configure +
2350
+ // build + per-ABI install for libllama + ggml + llama-server. We
2351
+ // reuse it as-is; the fused cmake flags + extra targets are applied
2352
+ // below via a thin override hook so the non-fused path stays
2353
+ // byte-for-byte identical.
2354
+ buildLibllamaForAbi({
2355
+ srcDir,
2356
+ cacheDir: args.cacheDir,
2357
+ abi: parsed.androidAbi,
2358
+ abiAssetDir,
2359
+ jobs: args.jobs,
2360
+ log: console.log,
2361
+ spawn: run,
2362
+ // The fused path needs `-DELIZA_FUSE_OMNIVOICE=ON` on the configure
2363
+ // line and the omnivoice-core + libelizainference + fused
2364
+ // llama-server targets on the build line. Pass-through hooks let
2365
+ // the caller layer those in without forking the helper. The Vulkan
2366
+ // target adds GGML_VULKAN=ON + the NDK toolchain paths and asks the
2367
+ // build to also produce ggml-vulkan (libggml-vulkan.so).
2368
+ extraCmakeFlags: [
2369
+ ...(parsed.fused ? fusedExtraCmakeFlags() : []),
2370
+ ...vulkanCmakeFlags,
2371
+ ],
2372
+ extraBuildTargets: [
2373
+ ...(parsed.fused
2374
+ ? fusedCmakeBuildTargets().filter(
2375
+ (t) => t !== "llama" && t !== "llama-server",
2376
+ )
2377
+ : []),
2378
+ ...(parsed.backend === "vulkan" ? ["ggml-vulkan"] : []),
2379
+ ],
2380
+ });
2381
+
2382
+ // Post-build: for fused targets prove libelizainference.so exports both
2383
+ // `llama_*` and `ov_*` (and the eliza_inference ABI surface). Hard error
2384
+ // on a half-fused artifact — same contract as the mtp build path.
2385
+ if (parsed.fused) {
2386
+ const verification = verifyFusedSymbols({
2387
+ outDir: abiAssetDir,
2388
+ target: parsed.target,
2389
+ });
2390
+ console.log(
2391
+ `[compile-libllama] omnivoice symbol-verify: ` +
2392
+ `library=${verification.library} ` +
2393
+ `llama=${verification.llamaSymbolCount} ` +
2394
+ `omnivoice=${verification.omnivoiceSymbolCount} ` +
2395
+ `abi=${verification.abiSymbolCount}`,
2396
+ );
2397
+ if (omnivoiceInfo) {
2398
+ console.log(
2399
+ `[compile-libllama] omnivoice mode=${omnivoiceInfo.mode ?? "merged"} source=${omnivoiceInfo.source ?? "tools/omnivoice"}`,
2400
+ );
2401
+ }
2402
+ }
2403
+ }
2404
+
2405
+ if (args.dryRun) {
2406
+ console.log(
2407
+ `[compile-libllama] (dry-run) plan complete: ${args.targets.length} target(s) (${srcDescription}).`,
2408
+ );
2409
+ return;
2410
+ }
2411
+
2412
+ // SIGSYS-handler shim only needed when an x86_64 ABI was built (matches
2413
+ // the bulk --abi path's behavior — see the comment in main()).
2414
+ if (args.targets.some((t) => t.androidAbi === "x86_64")) {
2415
+ await compileShimMain(["--skip-if-present"]);
2416
+ }
2417
+
2418
+ console.log(
2419
+ `[compile-libllama] Built ${args.targets.map((t) => t.target).join(", ")} (${srcDescription}).`,
2420
+ );
2421
+ }
2422
+
1327
2423
  const isMain =
1328
2424
  process.argv[1] &&
1329
2425
  path.resolve(process.argv[1]) === fileURLToPath(import.meta.url);