Files
wehub-resource-sync 426e9eeabd
Voice Workbench / headless workbench (mocked backends) (push) Has been cancelled
Voice Workbench / real acoustic lane (nightly, provisioned only) (push) Has been cancelled
ci / test (push) Has been cancelled
ci / lint-and-format (push) Has been cancelled
ci / build (push) Has been cancelled
ci / dev-startup (push) Has been cancelled
gitleaks / gitleaks (push) Has been cancelled
Markdown Links / Relative Markdown Links (push) Has been cancelled
Quality (Extended) / Homepage Build (PR smoke) (push) Has been cancelled
Quality (Extended) / Comment-only diff guard (push) Has been cancelled
Quality (Extended) / Format + Type Safety Ratchet (push) Has been cancelled
Quality (Extended) / Develop Gate (secret scan + UI determinism) (push) Has been cancelled
Quality (Extended) / Develop Gate (lint) (push) Has been cancelled
Chat shell gestures / Chat shell gesture + parity e2e (push) Has been cancelled
Cloud Gateway Discord / Test (push) Has been cancelled
Benchmark Bridge Tests / benchmark (bunx @biomejs/biome check packages/lifeops-bench/src, benchmark-lint) (push) Has been cancelled
Benchmark Bridge Tests / benchmark (bunx vitest run --config packages/lifeops-bench/vitest.config.ts --root packages/lifeops-bench --passWithNoTests, benchmark-tests) (push) Has been cancelled
Build Agent Image / build-and-push (push) Has been cancelled
Dev Smoke / bun run dev onboarding chat (push) Has been cancelled
Dev Smoke / Vite HMR dependency-level smoke (push) Has been cancelled
Electrobun Submodule Guard / electrobun gitlink is fetchable (push) Has been cancelled
Publish @elizaos/example-code / check_npm (push) Has been cancelled
Publish @elizaos/example-code / publish_npm (push) Has been cancelled
Publish @elizaos/plugin-elizacloud / verify_version (push) Has been cancelled
Publish @elizaos/plugin-elizacloud / publish_npm (push) Has been cancelled
Sandbox Live Smoke / Sandbox live smoke (push) Has been cancelled
Snap Build & Test / Build Snap (amd64) (push) Has been cancelled
Snap Build & Test / Build Snap (arm64) (push) Has been cancelled
Test Packaging / elizaos CLI global-install smoke (node + bun) (push) Has been cancelled
Cloud Gateway Webhook / Test (push) Has been cancelled
Cloud Tests / lint-and-types (push) Has been cancelled
Cloud Tests / unit-tests (push) Has been cancelled
Cloud Tests / integration-tests (push) Has been cancelled
Cloud Tests / e2e-tests (push) Has been cancelled
CodeQL Advanced / Analyze (javascript-typescript) (push) Has been cancelled
Deploy Apps Worker (Product 2) / Determine environment (push) Has been cancelled
Deploy Apps Worker (Product 2) / Deploy apps worker to apps-control host (${{ needs.determine-env.outputs.environment }}) (push) Has been cancelled
Deploy Eliza Provisioning Worker / Determine environment (push) Has been cancelled
Deploy Eliza Provisioning Worker / Deploy worker to Hetzner host (${{ needs.determine-env.outputs.environment }} @ ${{ needs.determine-env.outputs.deployment_sha }}) (push) Has been cancelled
Dev Smoke / Classify changed paths (push) Has been cancelled
supply-chain / sbom (push) Has been cancelled
supply-chain / vulnerability-scan (push) Has been cancelled
Build, Push & Deploy to Phala Cloud / build-and-push (push) Has been cancelled
Test Packaging / Validate Packaging Configs (push) Has been cancelled
Test Packaging / Build & Test PyPI Package (push) Has been cancelled
Test Packaging / PyPI on Python ${{ matrix.python }} (push) Has been cancelled
Test Packaging / Pack & Test JS Tarballs (push) Has been cancelled
UI Fixture E2E / ui-fixture-e2e (push) Has been cancelled
UI Fixture E2E / fixture-e2e (push) Has been cancelled
UI Story Gate / story-gate (push) Has been cancelled
vault-ci / test (macos-latest) (push) Has been cancelled
vault-ci / test (ubuntu-latest) (push) Has been cancelled
vault-ci / test (windows-latest) (push) Has been cancelled
vault-ci / app-core wiring tests (push) Has been cancelled
verify-patches / verify patches/CHECKSUMS.sha256 (push) Has been cancelled
Voice Benchmark Smoke / voice-emotion fixture smoke (push) Has been cancelled
Voice Benchmark Smoke / voiceagentbench fixture smoke (push) Has been cancelled
Voice Benchmark Smoke / voicebench-quality unit smoke (push) Has been cancelled
Voice Benchmark Smoke / voicebench TypeScript unit (no audio) (push) Has been cancelled
Voice Benchmark Smoke / voice bench smoke summary (push) Has been cancelled
Windows CI / windows ([bun run --cwd packages/app-core test bun run --cwd packages/elizaos test bun run --cwd packages/cloud/shared test], app-and-cli) (push) Has been cancelled
Windows CI / windows ([bun run --cwd packages/scenario-runner test bun run --cwd packages/vault test bun run --cwd packages/security test bun run --cwd plugins/plugin-coding-tools test], framework-packages) (push) Has been cancelled
Windows CI / windows ([bun run --cwd plugins/plugin-elizacloud test bun run --cwd plugins/plugin-discord test bun run --cwd plugins/plugin-anthropic test bun run --cwd plugins/plugin-openai test bun run --cwd plugins/plugin-app-control test bun run --cwd plugins/pl… (push) Has been cancelled
Windows CI / windows ([node packages/scripts/run-turbo.mjs run build --filter=@elizaos/core --filter=@elizaos/shared --filter=@elizaos/agent --concurrency=4 node packages/scripts/run-bash-linux-only.mjs scripts/verify-riscv64-buildpaths.sh node packages/scripts/run… (push) Has been cancelled
Windows CI / windows ([node packages/scripts/run-turbo.mjs run typecheck --filter=@elizaos/core --filter=@elizaos/shared --filter=@elizaos/cloud-shared --concurrency=4 bun run --cwd packages/core test bun run --cwd packages/shared test], core-runtime, 75) (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:43:05 +08:00
..

@elizaos/plugin-aosp-local-inference

AOSP-only llama.cpp FFI bindings (via bun:ffi) and local-inference bootstrap for elizaOS mobile builds.

What it does

This package enables on-device inference for Eliza agents running on Android (AOSP). It connects the Bun runtime to a native libllama.so + shim via bun:ffi, and registers the following model type handlers on AgentRuntime:

Model type Backend
TEXT_SMALL / TEXT_LARGE llama.cpp FFI (libllama.so via libeliza-llama-shim.so)
TEXT_EMBEDDING llama.cpp FFI (separate embedding context, disabled by default)
TEXT_TO_SPEECH Fused Kokoro (libelizainference.so) — WAV output at 24 kHz
TRANSCRIPTION ASR via libelizainference.so

All handlers self-gate on ELIZA_LOCAL_LLAMA=1 and are no-ops on non-AOSP platforms. The package is safe to import unconditionally from the mobile agent bundle.

Capabilities

  • Local LLM inference — in-process llama.cpp via bun:ffi; no HTTP server subprocess.
  • Speculative decoding (MTP) — optional in-process MTP drafter via libeliza-llama-speculative-shim.so; auto-paired when a mtp/ drafter GGUF is found in the active model bundle.
  • Custom KV-cache quantization — supports q8_0, tbq3_0, tbq4_0, qjl1_256, q4_polar quant types from the elizaOS/llama.cpp fork (default: K=q8_0, V=f16 for chat).
  • Text-to-speech — Kokoro synthesis via libelizainference.so (eliza_inference_kokoro_*); pre-warm support to amortize first-request latency.
  • Transcription — ASR via libelizainference.so from PCM WAV input or { pcm, sampleRateHz } params.
  • Model auto-download — if no bundled GGUF is found, downloads elizaos/eliza-1 from HuggingFace (opt-out: ELIZA_DISABLE_MODEL_AUTO_DOWNLOAD=1).
  • Cloud fallback — for TEXT_SMALL / TEXT_LARGE, a secondary handler at priority -1 forwards to Eliza Cloud when the local FFI path fails with a recoverable error.

How to enable

This package is loaded by @elizaos/agent's mobile entrypoint and by @elizaos/plugin-local-inference's ensure-local-inference-handler.ts. It is not an elizaOS plugin with auto-discovery — activation requires calling ensureAospLocalInferenceHandlers(runtime) after the agent runtime starts.

Set the following environment variable before launching the bun process (done automatically by ElizaAgentService.java in AOSP builds):

ELIZA_LOCAL_LLAMA=1

The package also auto-activates on process.arch === "riscv64" without requiring the env var (unless ELIZA_DISABLE_FFI_LLAMA=1 is set).

Required native libraries

The following shared libraries must be present in cwd/{abi}/ (where {abi} is arm64-v8a, x86_64, or riscv64). They are compiled by packages/app-core/scripts/aosp/compile-libllama.mjs:

  • libllama.so — elizaOS/llama.cpp fork (v0.1.0-eliza, based on apothic/llama.cpp-1bit-turboquant @ main-b8198-b2b5273)
  • libeliza-llama-shim.so — struct-by-value wrapper (NEEDED-links libllama.so)
  • libeliza-llama-speculative-shim.so — MTP speculative decoding (optional)
  • libelizainference.so — fused Kokoro TTS + ASR (optional, required for voice)

ElizaAgentService.java sets LD_LIBRARY_PATH to the ABI dir before spawning bun.

Required model files

Models are resolved from $ELIZA_STATE_DIR/local-inference/models/ in priority order:

  1. assignments.json + registry.json (managed by the local-inference service)
  2. manifest.json (written by packages/app-core/scripts/aosp/stage-default-models.mjs)
  3. Glob fallback scan for *.gguf matching expected name patterns

Default models auto-downloaded from elizaos/eliza-1 on HuggingFace when not staged:

  • Chat: bundles/2b/text/eliza-1-2b-128k.gguf
  • Embedding: bundles/4b/embedding/eliza-1-embedding.gguf

Key environment variables

Variable Default Purpose
ELIZA_LOCAL_LLAMA Set "1" to activate
ELIZA_DISABLE_FFI_LLAMA Set "1" to force opt-out
ELIZA_LLAMA_THREADS os.cpus().length CPU thread count
ELIZA_LLAMA_N_CTX 4096 Chat context window
ELIZA_LOCAL_EMBEDDING_ENABLED "0" Set "1" to load embedding GGUF
ELIZA_LLAMA_KV_TYPE_K / _V q8_0 / f16 KV-cache quant type
ELIZA_MTP Set "1" for MTP speculative decoding
ELIZA_AOSP_TTS_PREWARM Set "true" to pre-warm TTS at boot
ELIZA_DISABLE_MODEL_AUTO_DOWNLOAD Set "1" to skip HuggingFace download
ELIZA_AOSP_LLAMA_DEBUG_LOG Set "1" for line-delimited debug log

See CLAUDE.md for the full variable reference.

Package layout

src/
  index.ts                          Barrel (bundle-safety sink included)
  aosp-llama-adapter.ts             bun:ffi loader, AospLlamaAdapter class
  aosp-llama-streaming.ts           Streaming-LLM FFI bindings
  aosp-local-inference-bootstrap.ts Model handler registration, TTS, ASR
  aosp-debug-log.ts                 Append-only debug log utility
__tests__/                          bun test suites