@elizaos/plugin-local-inference 2.0.0-beta.1 → 2.0.11-beta.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +83 -0
- package/package.json +81 -15
- package/src/actions/generate-media.d.ts +59 -0
- package/src/actions/generate-media.d.ts.map +1 -0
- package/src/actions/generate-media.ts +647 -0
- package/src/actions/identify-speaker.d.ts +23 -0
- package/src/actions/identify-speaker.d.ts.map +1 -0
- package/src/actions/identify-speaker.ts +171 -0
- package/src/adapters/capacitor-llama/__tests__/compat-behavior.test.ts +218 -0
- package/src/adapters/capacitor-llama/__tests__/index.test.ts +68 -0
- package/src/adapters/capacitor-llama/__tests__/structured-output.test.ts +215 -0
- package/src/adapters/capacitor-llama/__tests__/text-streaming.test.ts +174 -0
- package/src/adapters/capacitor-llama/environment.ts +71 -0
- package/src/adapters/capacitor-llama/index.browser.ts +83 -0
- package/src/adapters/capacitor-llama/index.ts +807 -0
- package/src/adapters/capacitor-llama/loader.ts +109 -0
- package/src/adapters/capacitor-llama/structured-output.ts +165 -0
- package/src/adapters/capacitor-llama/text-streaming.ts +227 -0
- package/src/adapters/capacitor-llama/types.ts +374 -0
- package/src/backends/apple-foundation.ts +127 -0
- package/src/index.d.ts +7 -0
- package/src/index.d.ts.map +1 -0
- package/src/index.ts +54 -0
- package/src/local-inference-routes.d.ts +38 -0
- package/src/local-inference-routes.d.ts.map +1 -0
- package/src/local-inference-routes.test.ts +344 -0
- package/src/local-inference-routes.ts +1543 -0
- package/src/provider.d.ts +21 -0
- package/src/provider.d.ts.map +1 -0
- package/src/provider.ts +1171 -0
- package/src/routes/compat-helpers.d.ts +18 -0
- package/src/routes/compat-helpers.d.ts.map +1 -0
- package/src/routes/compat-helpers.ts +274 -0
- package/src/routes/family-member-route.d.ts +62 -0
- package/src/routes/family-member-route.d.ts.map +1 -0
- package/src/routes/family-member-route.ts +353 -0
- package/src/routes/index.d.ts +19 -0
- package/src/routes/index.d.ts.map +1 -0
- package/src/routes/index.ts +60 -0
- package/src/routes/live-diarization-route.d.ts +26 -0
- package/src/routes/live-diarization-route.d.ts.map +1 -0
- package/src/routes/live-diarization-route.test.ts +213 -0
- package/src/routes/live-diarization-route.ts +122 -0
- package/src/routes/local-inference-asr-route.d.ts +4 -0
- package/src/routes/local-inference-asr-route.d.ts.map +1 -0
- package/src/routes/local-inference-asr-route.test.ts +190 -0
- package/src/routes/local-inference-asr-route.ts +213 -0
- package/src/routes/local-inference-compat-routes.d.ts +16 -0
- package/src/routes/local-inference-compat-routes.d.ts.map +1 -0
- package/src/routes/local-inference-compat-routes.test.ts +423 -0
- package/src/routes/local-inference-compat-routes.ts +782 -0
- package/src/routes/local-inference-tts-route.d.ts +7 -0
- package/src/routes/local-inference-tts-route.d.ts.map +1 -0
- package/src/routes/local-inference-tts-route.test.ts +179 -0
- package/src/routes/local-inference-tts-route.ts +230 -0
- package/src/routes/voice-first-run-routes.d.ts +62 -0
- package/src/routes/voice-first-run-routes.d.ts.map +1 -0
- package/src/routes/voice-first-run-routes.ts +524 -0
- package/src/routes/voice-models-routes.d.ts +62 -0
- package/src/routes/voice-models-routes.d.ts.map +1 -0
- package/src/routes/voice-models-routes.ts +554 -0
- package/src/routes/voice-profile-plugin-routes.d.ts +19 -0
- package/src/routes/voice-profile-plugin-routes.d.ts.map +1 -0
- package/src/routes/voice-profile-plugin-routes.ts +138 -0
- package/src/routes/voice-profiles-management-routes.d.ts +52 -0
- package/src/routes/voice-profiles-management-routes.d.ts.map +1 -0
- package/src/routes/voice-profiles-management-routes.ts +476 -0
- package/src/routes/voice-speaker-profile-routes.d.ts +57 -0
- package/src/routes/voice-speaker-profile-routes.d.ts.map +1 -0
- package/src/routes/voice-speaker-profile-routes.ts +199 -0
- package/src/runtime/aosp-llama-loader-selection.test.ts +80 -0
- package/src/runtime/capacitor-llama.d.ts +25 -0
- package/src/runtime/embedding-manager-support.d.ts +77 -0
- package/src/runtime/embedding-manager-support.d.ts.map +1 -0
- package/src/runtime/embedding-manager-support.ts +497 -0
- package/src/runtime/embedding-presets.d.ts +16 -0
- package/src/runtime/embedding-presets.d.ts.map +1 -0
- package/src/runtime/embedding-presets.ts +81 -0
- package/src/runtime/embedding-warmup-policy.d.ts +14 -0
- package/src/runtime/embedding-warmup-policy.d.ts.map +1 -0
- package/src/runtime/embedding-warmup-policy.test.ts +53 -0
- package/src/runtime/embedding-warmup-policy.ts +48 -0
- package/src/runtime/ensure-local-inference-handler.d.ts +53 -0
- package/src/runtime/ensure-local-inference-handler.d.ts.map +1 -0
- package/src/runtime/ensure-local-inference-handler.test.ts +528 -0
- package/src/runtime/ensure-local-inference-handler.ts +1398 -0
- package/src/runtime/index.d.ts +14 -0
- package/src/runtime/index.d.ts.map +1 -0
- package/src/runtime/index.ts +27 -0
- package/src/runtime/mobile-local-inference-gate.d.ts +31 -0
- package/src/runtime/mobile-local-inference-gate.d.ts.map +1 -0
- package/src/runtime/mobile-local-inference-gate.test.ts +69 -0
- package/src/runtime/mobile-local-inference-gate.ts +44 -0
- package/src/runtime/voice-entity-binding.d.ts +103 -0
- package/src/runtime/voice-entity-binding.d.ts.map +1 -0
- package/src/runtime/voice-entity-binding.transcript.test.ts +69 -0
- package/src/runtime/voice-entity-binding.ts +328 -0
- package/src/services/README.md +71 -0
- package/src/services/__tests__/backend-selector.test.ts +101 -0
- package/src/services/__tests__/checkpoint-manager.test.ts +376 -0
- package/src/services/__tests__/gpu-autotune.test.ts +400 -0
- package/src/services/__tests__/llm-streaming-binding.test.ts +85 -0
- package/src/services/__tests__/planner-grammar.test.ts +372 -0
- package/src/services/__tests__/runtime-target.test.ts +176 -0
- package/src/services/active-model-switch-rollback.test.ts +183 -0
- package/src/services/active-model.d.ts +282 -0
- package/src/services/active-model.d.ts.map +1 -0
- package/src/services/active-model.ts +1213 -0
- package/src/services/asr/errors.d.ts +21 -0
- package/src/services/asr/errors.d.ts.map +1 -0
- package/src/services/asr/errors.ts +50 -0
- package/src/services/asr/hash.d.ts +28 -0
- package/src/services/asr/hash.d.ts.map +1 -0
- package/src/services/asr/hash.ts +49 -0
- package/src/services/asr/index.d.ts +76 -0
- package/src/services/asr/index.d.ts.map +1 -0
- package/src/services/asr/index.ts +178 -0
- package/src/services/asr/types.d.ts +91 -0
- package/src/services/asr/types.d.ts.map +1 -0
- package/src/services/asr/types.ts +95 -0
- package/src/services/assignments.d.ts +71 -0
- package/src/services/assignments.d.ts.map +1 -0
- package/src/services/assignments.test.ts +80 -0
- package/src/services/assignments.ts +230 -0
- package/src/services/backend-selector.ts +95 -0
- package/src/services/backend.d.ts +346 -0
- package/src/services/backend.d.ts.map +1 -0
- package/src/services/backend.ts +612 -0
- package/src/services/bundled-models.d.ts +34 -0
- package/src/services/bundled-models.d.ts.map +1 -0
- package/src/services/bundled-models.ts +129 -0
- package/src/services/cache-bridge.d.ts +206 -0
- package/src/services/cache-bridge.d.ts.map +1 -0
- package/src/services/cache-bridge.test.ts +516 -0
- package/src/services/cache-bridge.ts +423 -0
- package/src/services/catalog.d.ts +10 -0
- package/src/services/catalog.d.ts.map +1 -0
- package/src/services/catalog.test.ts +240 -0
- package/src/services/catalog.ts +27 -0
- package/src/services/checkpoint-client.d.ts +109 -0
- package/src/services/checkpoint-client.d.ts.map +1 -0
- package/src/services/checkpoint-client.ts +258 -0
- package/src/services/checkpoint-manager.ts +474 -0
- package/src/services/cloud-fallback.d.ts +102 -0
- package/src/services/cloud-fallback.d.ts.map +1 -0
- package/src/services/cloud-fallback.ts +230 -0
- package/src/services/conversation-registry.d.ts +142 -0
- package/src/services/conversation-registry.d.ts.map +1 -0
- package/src/services/conversation-registry.test.ts +235 -0
- package/src/services/conversation-registry.ts +264 -0
- package/src/services/desktop-fused-ffi-backend-runtime.d.ts +92 -0
- package/src/services/desktop-fused-ffi-backend-runtime.d.ts.map +1 -0
- package/src/services/desktop-fused-ffi-backend-runtime.ts +333 -0
- package/src/services/device-bridge.d.ts +188 -0
- package/src/services/device-bridge.d.ts.map +1 -0
- package/src/services/device-bridge.ts +1237 -0
- package/src/services/device-resource-metrics.d.ts +149 -0
- package/src/services/device-resource-metrics.d.ts.map +1 -0
- package/src/services/device-resource-metrics.test.ts +98 -0
- package/src/services/device-resource-metrics.ts +346 -0
- package/src/services/device-tier.d.ts +115 -0
- package/src/services/device-tier.d.ts.map +1 -0
- package/src/services/device-tier.test.ts +371 -0
- package/src/services/device-tier.ts +410 -0
- package/src/services/downloader.d.ts +82 -0
- package/src/services/downloader.d.ts.map +1 -0
- package/src/services/downloader.test.ts +724 -0
- package/src/services/downloader.ts +899 -0
- package/src/services/engine-direct-bundle.test.ts +58 -0
- package/src/services/engine-streaming.test.ts +80 -0
- package/src/services/engine.d.ts +534 -0
- package/src/services/engine.d.ts.map +1 -0
- package/src/services/engine.ts +1891 -0
- package/src/services/ensure-local-artifacts.integration.test.ts +273 -0
- package/src/services/ensure-local-artifacts.test.ts +368 -0
- package/src/services/ensure-local-artifacts.ts +351 -0
- package/src/services/external-scanner.d.ts +17 -0
- package/src/services/external-scanner.d.ts.map +1 -0
- package/src/services/external-scanner.ts +312 -0
- package/src/services/ffi-llm-mock.ts +354 -0
- package/src/services/ffi-llm-streaming-abi.ts +442 -0
- package/src/services/ffi-streaming-backend.d.ts +180 -0
- package/src/services/ffi-streaming-backend.d.ts.map +1 -0
- package/src/services/ffi-streaming-backend.ts +382 -0
- package/src/services/ffi-streaming-runner.d.ts +122 -0
- package/src/services/ffi-streaming-runner.d.ts.map +1 -0
- package/src/services/ffi-streaming-runner.test.ts +60 -0
- package/src/services/ffi-streaming-runner.ts +354 -0
- package/src/services/ffi-unload-ordering.test.ts +162 -0
- package/src/services/gpu-autotune.ts +534 -0
- package/src/services/gpu-detect.ts +139 -0
- package/src/services/handler-registry.d.ts +72 -0
- package/src/services/handler-registry.d.ts.map +1 -0
- package/src/services/handler-registry.ts +240 -0
- package/src/services/hardware.d.ts +63 -0
- package/src/services/hardware.d.ts.map +1 -0
- package/src/services/hardware.test.ts +183 -0
- package/src/services/hardware.ts +404 -0
- package/src/services/hf-search.d.ts +26 -0
- package/src/services/hf-search.d.ts.map +1 -0
- package/src/services/hf-search.test.ts +69 -0
- package/src/services/hf-search.ts +420 -0
- package/src/services/image-description-runtime.d.ts +14 -0
- package/src/services/image-description-runtime.d.ts.map +1 -0
- package/src/services/image-description-runtime.test.ts +61 -0
- package/src/services/image-description-runtime.ts +118 -0
- package/src/services/imagegen/aosp-unavailable.d.ts +134 -0
- package/src/services/imagegen/aosp-unavailable.d.ts.map +1 -0
- package/src/services/imagegen/aosp-unavailable.ts +229 -0
- package/src/services/imagegen/backend-selector.d.ts +118 -0
- package/src/services/imagegen/backend-selector.d.ts.map +1 -0
- package/src/services/imagegen/backend-selector.ts +281 -0
- package/src/services/imagegen/coreml-unavailable.d.ts +105 -0
- package/src/services/imagegen/coreml-unavailable.d.ts.map +1 -0
- package/src/services/imagegen/coreml-unavailable.ts +237 -0
- package/src/services/imagegen/errors.d.ts +16 -0
- package/src/services/imagegen/errors.d.ts.map +1 -0
- package/src/services/imagegen/errors.ts +40 -0
- package/src/services/imagegen/index.d.ts +58 -0
- package/src/services/imagegen/index.d.ts.map +1 -0
- package/src/services/imagegen/index.ts +144 -0
- package/src/services/imagegen/mflux.d.ts +74 -0
- package/src/services/imagegen/mflux.d.ts.map +1 -0
- package/src/services/imagegen/mflux.ts +313 -0
- package/src/services/imagegen/sd-cpp.d.ts +180 -0
- package/src/services/imagegen/sd-cpp.d.ts.map +1 -0
- package/src/services/imagegen/sd-cpp.ts +718 -0
- package/src/services/imagegen/tensorrt-unavailable.d.ts +83 -0
- package/src/services/imagegen/tensorrt-unavailable.d.ts.map +1 -0
- package/src/services/imagegen/tensorrt-unavailable.ts +295 -0
- package/src/services/imagegen/types.d.ts +181 -0
- package/src/services/imagegen/types.d.ts.map +1 -0
- package/src/services/imagegen/types.ts +193 -0
- package/src/services/index.d.ts +30 -0
- package/src/services/index.d.ts.map +1 -0
- package/src/services/index.ts +225 -0
- package/src/services/inference-capabilities.d.ts +132 -0
- package/src/services/inference-capabilities.d.ts.map +1 -0
- package/src/services/inference-capabilities.test.ts +75 -0
- package/src/services/inference-capabilities.ts +204 -0
- package/src/services/inference-telemetry.d.ts +59 -0
- package/src/services/inference-telemetry.d.ts.map +1 -0
- package/src/services/inference-telemetry.ts +143 -0
- package/src/services/ios-llama-streaming.ts +248 -0
- package/src/services/kv-spill.d.ts +189 -0
- package/src/services/kv-spill.d.ts.map +1 -0
- package/src/services/kv-spill.test.ts +222 -0
- package/src/services/kv-spill.ts +356 -0
- package/src/services/latency-trace.d.ts +346 -0
- package/src/services/latency-trace.d.ts.map +1 -0
- package/src/services/latency-trace.test.ts +266 -0
- package/src/services/latency-trace.ts +844 -0
- package/src/services/llama-server-metrics.ts +304 -0
- package/src/services/llm-streaming-binding.d.ts +96 -0
- package/src/services/llm-streaming-binding.d.ts.map +1 -0
- package/src/services/llm-streaming-binding.ts +136 -0
- package/src/services/load-args.d.ts +82 -0
- package/src/services/load-args.d.ts.map +1 -0
- package/src/services/load-args.ts +81 -0
- package/src/services/manifest/eliza-1.manifest.v1.json +708 -0
- package/src/services/manifest/index.d.ts +4 -0
- package/src/services/manifest/index.d.ts.map +1 -0
- package/src/services/manifest/index.ts +66 -0
- package/src/services/manifest/manifest.test.ts +693 -0
- package/src/services/manifest/schema.d.ts +715 -0
- package/src/services/manifest/schema.d.ts.map +1 -0
- package/src/services/manifest/schema.ts +655 -0
- package/src/services/manifest/types.d.ts +30 -0
- package/src/services/manifest/types.d.ts.map +1 -0
- package/src/services/manifest/types.ts +55 -0
- package/src/services/manifest/validator.d.ts +66 -0
- package/src/services/manifest/validator.d.ts.map +1 -0
- package/src/services/manifest/validator.ts +569 -0
- package/src/services/memory-arbiter.d.ts +343 -0
- package/src/services/memory-arbiter.d.ts.map +1 -0
- package/src/services/memory-arbiter.test.ts +419 -0
- package/src/services/memory-arbiter.ts +1000 -0
- package/src/services/memory-monitor.d.ts +119 -0
- package/src/services/memory-monitor.d.ts.map +1 -0
- package/src/services/memory-monitor.test.ts +208 -0
- package/src/services/memory-monitor.ts +296 -0
- package/src/services/memory-pressure.d.ts +127 -0
- package/src/services/memory-pressure.d.ts.map +1 -0
- package/src/services/memory-pressure.ts +413 -0
- package/src/services/mtp-doctor.d.ts +13 -0
- package/src/services/mtp-doctor.d.ts.map +1 -0
- package/src/services/mtp-doctor.ts +78 -0
- package/src/services/network-policy.d.ts +127 -0
- package/src/services/network-policy.d.ts.map +1 -0
- package/src/services/network-policy.ts +346 -0
- package/src/services/paths.d.ts +6 -0
- package/src/services/paths.d.ts.map +1 -0
- package/src/services/paths.ts +25 -0
- package/src/services/planner-skeleton.d.ts +124 -0
- package/src/services/planner-skeleton.d.ts.map +1 -0
- package/src/services/planner-skeleton.ts +175 -0
- package/src/services/providers.d.ts +38 -0
- package/src/services/providers.d.ts.map +1 -0
- package/src/services/providers.ts +507 -0
- package/src/services/ram-budget-cache.test.ts +163 -0
- package/src/services/ram-budget.d.ts +110 -0
- package/src/services/ram-budget.d.ts.map +1 -0
- package/src/services/ram-budget.ts +0 -0
- package/src/services/readiness.d.ts +9 -0
- package/src/services/readiness.d.ts.map +1 -0
- package/src/services/readiness.test.ts +87 -0
- package/src/services/readiness.ts +238 -0
- package/src/services/recommendation.d.ts +111 -0
- package/src/services/recommendation.d.ts.map +1 -0
- package/src/services/recommendation.ts +672 -0
- package/src/services/registry.d.ts +35 -0
- package/src/services/registry.d.ts.map +1 -0
- package/src/services/registry.ts +151 -0
- package/src/services/router-handler.d.ts +92 -0
- package/src/services/router-handler.d.ts.map +1 -0
- package/src/services/router-handler.test.ts +45 -0
- package/src/services/router-handler.ts +376 -0
- package/src/services/routing-policy.d.ts +55 -0
- package/src/services/routing-policy.d.ts.map +1 -0
- package/src/services/routing-policy.ts +228 -0
- package/src/services/routing-preferences.d.ts +8 -0
- package/src/services/routing-preferences.d.ts.map +1 -0
- package/src/services/routing-preferences.ts +15 -0
- package/src/services/runtime-target.d.ts +98 -0
- package/src/services/runtime-target.d.ts.map +1 -0
- package/src/services/runtime-target.ts +154 -0
- package/src/services/service.d.ts +128 -0
- package/src/services/service.d.ts.map +1 -0
- package/src/services/service.test.ts +223 -0
- package/src/services/service.ts +735 -0
- package/src/services/session-pool.d.ts +72 -0
- package/src/services/session-pool.d.ts.map +1 -0
- package/src/services/session-pool.ts +153 -0
- package/src/services/structured-output/deterministic-repair.d.ts +23 -0
- package/src/services/structured-output/deterministic-repair.d.ts.map +1 -0
- package/src/services/structured-output/deterministic-repair.test.ts +169 -0
- package/src/services/structured-output/deterministic-repair.ts +443 -0
- package/src/services/structured-output/index.ts +4 -0
- package/src/services/structured-output.d.ts +311 -0
- package/src/services/structured-output.d.ts.map +1 -0
- package/src/services/structured-output.test.ts +483 -0
- package/src/services/structured-output.ts +712 -0
- package/src/services/transcription-priority.test.ts +211 -0
- package/src/services/tts/errors.ts +46 -0
- package/src/services/tts/index.ts +214 -0
- package/src/services/tts/tts-audio-cache.ts +235 -0
- package/src/services/tts/types.ts +157 -0
- package/src/services/types.d.ts +19 -0
- package/src/services/types.d.ts.map +1 -0
- package/src/services/types.ts +55 -0
- package/src/services/verify-on-device.d.ts +34 -0
- package/src/services/verify-on-device.d.ts.map +1 -0
- package/src/services/verify-on-device.test.ts +87 -0
- package/src/services/verify-on-device.ts +127 -0
- package/src/services/verify.d.ts +8 -0
- package/src/services/verify.d.ts.map +1 -0
- package/src/services/verify.ts +13 -0
- package/src/services/vision/aosp-unavailable.d.ts +115 -0
- package/src/services/vision/aosp-unavailable.d.ts.map +1 -0
- package/src/services/vision/aosp-unavailable.ts +163 -0
- package/src/services/vision/capacitor-llama.d.ts +99 -0
- package/src/services/vision/capacitor-llama.d.ts.map +1 -0
- package/src/services/vision/capacitor-llama.ts +255 -0
- package/src/services/vision/cloud-fallback.d.ts +47 -0
- package/src/services/vision/cloud-fallback.d.ts.map +1 -0
- package/src/services/vision/cloud-fallback.test.ts +243 -0
- package/src/services/vision/cloud-fallback.ts +268 -0
- package/src/services/vision/fallback-chain.test.ts +86 -0
- package/src/services/vision/hash.d.ts +71 -0
- package/src/services/vision/hash.d.ts.map +1 -0
- package/src/services/vision/hash.ts +157 -0
- package/src/services/vision/index.d.ts +95 -0
- package/src/services/vision/index.d.ts.map +1 -0
- package/src/services/vision/index.ts +251 -0
- package/src/services/vision/llama-server.d.ts +73 -0
- package/src/services/vision/llama-server.d.ts.map +1 -0
- package/src/services/vision/llama-server.ts +177 -0
- package/src/services/vision/types.d.ts +153 -0
- package/src/services/vision/types.d.ts.map +1 -0
- package/src/services/vision/types.ts +154 -0
- package/src/services/vision/vast-fallback.d.ts +18 -0
- package/src/services/vision/vast-fallback.d.ts.map +1 -0
- package/src/services/vision/vast-fallback.ts +127 -0
- package/src/services/vision-embedding-cache.d.ts +98 -0
- package/src/services/vision-embedding-cache.d.ts.map +1 -0
- package/src/services/vision-embedding-cache.ts +189 -0
- package/src/services/voice/VOICE_WORKBENCH.md +88 -0
- package/src/services/voice/__test-helpers__/fake-ffi.ts +92 -0
- package/src/services/voice/__test-helpers__/synthetic-speech.ts +124 -0
- package/src/services/voice/__tests__/checkpoint-manager.test.ts +241 -0
- package/src/services/voice/__tests__/checkpoint-policy.test.ts +270 -0
- package/src/services/voice/__tests__/eager-context-builder.test.ts +257 -0
- package/src/services/voice/__tests__/eliza1-eot-scorer.test.ts +288 -0
- package/src/services/voice/__tests__/eot-classifier.test.ts +431 -0
- package/src/services/voice/__tests__/optimistic-rollback.test.ts +312 -0
- package/src/services/voice/__tests__/prefill-client.test.ts +266 -0
- package/src/services/voice/__tests__/prefix-preserving-queue.test.ts +208 -0
- package/src/services/voice/__tests__/streaming-asr.test.ts +450 -0
- package/src/services/voice/__tests__/streaming-transcriber.test.ts +339 -0
- package/src/services/voice/__tests__/turn-detector-resolver.test.ts +197 -0
- package/src/services/voice/__tests__/voice-state-machine-prefill.test.ts +275 -0
- package/src/services/voice/__tests__/voice-state-machine.test.ts +354 -0
- package/src/services/voice/audio-frame-consumer.d.ts +212 -0
- package/src/services/voice/audio-frame-consumer.d.ts.map +1 -0
- package/src/services/voice/audio-frame-consumer.test.ts +343 -0
- package/src/services/voice/audio-frame-consumer.ts +491 -0
- package/src/services/voice/barge-in.d.ts +112 -0
- package/src/services/voice/barge-in.d.ts.map +1 -0
- package/src/services/voice/barge-in.test.ts +244 -0
- package/src/services/voice/barge-in.ts +336 -0
- package/src/services/voice/cancellation-coordinator.d.ts +127 -0
- package/src/services/voice/cancellation-coordinator.d.ts.map +1 -0
- package/src/services/voice/cancellation-coordinator.test.ts +196 -0
- package/src/services/voice/cancellation-coordinator.ts +269 -0
- package/src/services/voice/checkpoint-manager.d.ts +199 -0
- package/src/services/voice/checkpoint-manager.d.ts.map +1 -0
- package/src/services/voice/checkpoint-manager.ts +401 -0
- package/src/services/voice/checkpoint-policy.ts +336 -0
- package/src/services/voice/composite-eot-classifier.test.ts +59 -0
- package/src/services/voice/e2e-harness.test.ts +182 -0
- package/src/services/voice/e2e-harness.ts +743 -0
- package/src/services/voice/eager-context-builder.d.ts +170 -0
- package/src/services/voice/eager-context-builder.d.ts.map +1 -0
- package/src/services/voice/eager-context-builder.ts +262 -0
- package/src/services/voice/eliza1-eot-scorer.d.ts +124 -0
- package/src/services/voice/eliza1-eot-scorer.d.ts.map +1 -0
- package/src/services/voice/eliza1-eot-scorer.ts +242 -0
- package/src/services/voice/embedding-server.ts +200 -0
- package/src/services/voice/embedding.d.ts +133 -0
- package/src/services/voice/embedding.d.ts.map +1 -0
- package/src/services/voice/embedding.test.ts +148 -0
- package/src/services/voice/embedding.ts +244 -0
- package/src/services/voice/emotion-attribution.d.ts +68 -0
- package/src/services/voice/emotion-attribution.d.ts.map +1 -0
- package/src/services/voice/emotion-attribution.test.ts +129 -0
- package/src/services/voice/emotion-attribution.ts +361 -0
- package/src/services/voice/engine-bridge-cancellation.test.ts +422 -0
- package/src/services/voice/engine-bridge.d.ts +746 -0
- package/src/services/voice/engine-bridge.d.ts.map +1 -0
- package/src/services/voice/engine-bridge.test.ts +384 -0
- package/src/services/voice/engine-bridge.ts +2226 -0
- package/src/services/voice/eot-classifier-ggml.d.ts +179 -0
- package/src/services/voice/eot-classifier-ggml.d.ts.map +1 -0
- package/src/services/voice/eot-classifier-ggml.ts +566 -0
- package/src/services/voice/eot-classifier.d.ts +214 -0
- package/src/services/voice/eot-classifier.d.ts.map +1 -0
- package/src/services/voice/eot-classifier.ts +533 -0
- package/src/services/voice/errors.d.ts +20 -0
- package/src/services/voice/errors.d.ts.map +1 -0
- package/src/services/voice/errors.ts +32 -0
- package/src/services/voice/expressive-tags.d.ts +158 -0
- package/src/services/voice/expressive-tags.d.ts.map +1 -0
- package/src/services/voice/expressive-tags.ts +405 -0
- package/src/services/voice/ffi-bindings.d.ts +636 -0
- package/src/services/voice/ffi-bindings.d.ts.map +1 -0
- package/src/services/voice/ffi-bindings.test.ts +671 -0
- package/src/services/voice/ffi-bindings.ts +3050 -0
- package/src/services/voice/first-line-cache.d.ts +181 -0
- package/src/services/voice/first-line-cache.d.ts.map +1 -0
- package/src/services/voice/first-line-cache.ts +725 -0
- package/src/services/voice/fused-eot-scorer.d.ts +51 -0
- package/src/services/voice/fused-eot-scorer.d.ts.map +1 -0
- package/src/services/voice/fused-eot-scorer.ts +135 -0
- package/src/services/voice/index.d.ts +91 -0
- package/src/services/voice/index.d.ts.map +1 -0
- package/src/services/voice/index.ts +481 -0
- package/src/services/voice/kokoro/__tests__/kokoro-backend.test.ts +151 -0
- package/src/services/voice/kokoro/__tests__/kokoro-engine-bridge.real.test.ts +151 -0
- package/src/services/voice/kokoro/__tests__/kokoro-engine-bridge.test.ts +60 -0
- package/src/services/voice/kokoro/__tests__/kokoro-engine-discovery.test.ts +277 -0
- package/src/services/voice/kokoro/__tests__/kokoro-ffi-runtime.test.ts +235 -0
- package/src/services/voice/kokoro/__tests__/kokoro-runtime.test.ts +95 -0
- package/src/services/voice/kokoro/__tests__/phonemizer.test.ts +53 -0
- package/src/services/voice/kokoro/__tests__/runtime-selection.test.ts +231 -0
- package/src/services/voice/kokoro/__tests__/voices.test.ts +57 -0
- package/src/services/voice/kokoro/index.ts +79 -0
- package/src/services/voice/kokoro/kokoro-backend.d.ts +72 -0
- package/src/services/voice/kokoro/kokoro-backend.d.ts.map +1 -0
- package/src/services/voice/kokoro/kokoro-backend.ts +207 -0
- package/src/services/voice/kokoro/kokoro-engine-discovery.d.ts +58 -0
- package/src/services/voice/kokoro/kokoro-engine-discovery.d.ts.map +1 -0
- package/src/services/voice/kokoro/kokoro-engine-discovery.ts +177 -0
- package/src/services/voice/kokoro/kokoro-ffi-runtime.d.ts +75 -0
- package/src/services/voice/kokoro/kokoro-ffi-runtime.d.ts.map +1 -0
- package/src/services/voice/kokoro/kokoro-ffi-runtime.ts +233 -0
- package/src/services/voice/kokoro/kokoro-runtime.d.ts +100 -0
- package/src/services/voice/kokoro/kokoro-runtime.d.ts.map +1 -0
- package/src/services/voice/kokoro/kokoro-runtime.ts +170 -0
- package/src/services/voice/kokoro/phoneme-stream.ts +123 -0
- package/src/services/voice/kokoro/phonemizer.d.ts +50 -0
- package/src/services/voice/kokoro/phonemizer.d.ts.map +1 -0
- package/src/services/voice/kokoro/phonemizer.ts +344 -0
- package/src/services/voice/kokoro/pick-runtime.d.ts +61 -0
- package/src/services/voice/kokoro/pick-runtime.d.ts.map +1 -0
- package/src/services/voice/kokoro/pick-runtime.test.ts +91 -0
- package/src/services/voice/kokoro/pick-runtime.ts +130 -0
- package/src/services/voice/kokoro/runtime-selection.d.ts +92 -0
- package/src/services/voice/kokoro/runtime-selection.d.ts.map +1 -0
- package/src/services/voice/kokoro/runtime-selection.ts +237 -0
- package/src/services/voice/kokoro/types.d.ts +82 -0
- package/src/services/voice/kokoro/types.d.ts.map +1 -0
- package/src/services/voice/kokoro/types.ts +95 -0
- package/src/services/voice/kokoro/voice-presets.d.ts +23 -0
- package/src/services/voice/kokoro/voice-presets.d.ts.map +1 -0
- package/src/services/voice/kokoro/voice-presets.ts +129 -0
- package/src/services/voice/kokoro/voices.d.ts +30 -0
- package/src/services/voice/kokoro/voices.d.ts.map +1 -0
- package/src/services/voice/kokoro/voices.ts +64 -0
- package/src/services/voice/lifecycle.d.ts +135 -0
- package/src/services/voice/lifecycle.d.ts.map +1 -0
- package/src/services/voice/lifecycle.test.ts +315 -0
- package/src/services/voice/lifecycle.ts +301 -0
- package/src/services/voice/live-diarization-session.d.ts +96 -0
- package/src/services/voice/live-diarization-session.d.ts.map +1 -0
- package/src/services/voice/live-diarization-session.ts +289 -0
- package/src/services/voice/mic-source.d.ts +136 -0
- package/src/services/voice/mic-source.d.ts.map +1 -0
- package/src/services/voice/mic-source.test.ts +210 -0
- package/src/services/voice/mic-source.ts +503 -0
- package/src/services/voice/optimistic-policy.d.ts +109 -0
- package/src/services/voice/optimistic-policy.d.ts.map +1 -0
- package/src/services/voice/optimistic-policy.test.ts +101 -0
- package/src/services/voice/optimistic-policy.ts +192 -0
- package/src/services/voice/optimistic-rollback.ts +343 -0
- package/src/services/voice/partial-stabilizer.d.ts +73 -0
- package/src/services/voice/partial-stabilizer.d.ts.map +1 -0
- package/src/services/voice/partial-stabilizer.test.ts +68 -0
- package/src/services/voice/partial-stabilizer.ts +140 -0
- package/src/services/voice/phoneme-tokenizer.d.ts +49 -0
- package/src/services/voice/phoneme-tokenizer.d.ts.map +1 -0
- package/src/services/voice/phoneme-tokenizer.ts +158 -0
- package/src/services/voice/phrase-cache.d.ts +76 -0
- package/src/services/voice/phrase-cache.d.ts.map +1 -0
- package/src/services/voice/phrase-cache.test.ts +242 -0
- package/src/services/voice/phrase-cache.ts +186 -0
- package/src/services/voice/phrase-chunker.d.ts +62 -0
- package/src/services/voice/phrase-chunker.d.ts.map +1 -0
- package/src/services/voice/phrase-chunker.test.ts +239 -0
- package/src/services/voice/phrase-chunker.ts +281 -0
- package/src/services/voice/pipeline-impls.d.ts +151 -0
- package/src/services/voice/pipeline-impls.d.ts.map +1 -0
- package/src/services/voice/pipeline-impls.l6.test.ts +110 -0
- package/src/services/voice/pipeline-impls.test.ts +292 -0
- package/src/services/voice/pipeline-impls.ts +315 -0
- package/src/services/voice/pipeline.d.ts +216 -0
- package/src/services/voice/pipeline.d.ts.map +1 -0
- package/src/services/voice/pipeline.ts +505 -0
- package/src/services/voice/prefill-client.d.ts +123 -0
- package/src/services/voice/prefill-client.d.ts.map +1 -0
- package/src/services/voice/prefill-client.ts +316 -0
- package/src/services/voice/prefix-preserving-queue.d.ts +113 -0
- package/src/services/voice/prefix-preserving-queue.d.ts.map +1 -0
- package/src/services/voice/prefix-preserving-queue.ts +162 -0
- package/src/services/voice/profile-store.d.ts +248 -0
- package/src/services/voice/profile-store.d.ts.map +1 -0
- package/src/services/voice/profile-store.ts +887 -0
- package/src/services/voice/ring-buffer.d.ts +40 -0
- package/src/services/voice/ring-buffer.d.ts.map +1 -0
- package/src/services/voice/ring-buffer.ts +105 -0
- package/src/services/voice/rollback-queue.d.ts +24 -0
- package/src/services/voice/rollback-queue.d.ts.map +1 -0
- package/src/services/voice/rollback-queue.ts +74 -0
- package/src/services/voice/samantha-preset-placeholder.d.ts +67 -0
- package/src/services/voice/samantha-preset-placeholder.d.ts.map +1 -0
- package/src/services/voice/samantha-preset-placeholder.test.ts +97 -0
- package/src/services/voice/samantha-preset-placeholder.ts +148 -0
- package/src/services/voice/samantha-preset-regenerator.d.ts +87 -0
- package/src/services/voice/samantha-preset-regenerator.d.ts.map +1 -0
- package/src/services/voice/samantha-preset-regenerator.ts +393 -0
- package/src/services/voice/scheduler.d.ts +146 -0
- package/src/services/voice/scheduler.d.ts.map +1 -0
- package/src/services/voice/scheduler.t2.test.ts +141 -0
- package/src/services/voice/scheduler.ts +927 -0
- package/src/services/voice/shared-resources.d.ts +190 -0
- package/src/services/voice/shared-resources.d.ts.map +1 -0
- package/src/services/voice/shared-resources.ts +320 -0
- package/src/services/voice/speaker/attribution-pipeline.d.ts +74 -0
- package/src/services/voice/speaker/attribution-pipeline.d.ts.map +1 -0
- package/src/services/voice/speaker/attribution-pipeline.ts +386 -0
- package/src/services/voice/speaker/diarizer-fused.d.ts +59 -0
- package/src/services/voice/speaker/diarizer-fused.d.ts.map +1 -0
- package/src/services/voice/speaker/diarizer-fused.real.test.ts +100 -0
- package/src/services/voice/speaker/diarizer-fused.ts +154 -0
- package/src/services/voice/speaker/diarizer.d.ts +75 -0
- package/src/services/voice/speaker/diarizer.d.ts.map +1 -0
- package/src/services/voice/speaker/diarizer.ts +218 -0
- package/src/services/voice/speaker/encoder-fused.d.ts +60 -0
- package/src/services/voice/speaker/encoder-fused.d.ts.map +1 -0
- package/src/services/voice/speaker/encoder-fused.real.test.ts +113 -0
- package/src/services/voice/speaker/encoder-fused.ts +138 -0
- package/src/services/voice/speaker/encoder-ggml.d.ts +33 -0
- package/src/services/voice/speaker/encoder-ggml.d.ts.map +1 -0
- package/src/services/voice/speaker/encoder-ggml.ts +79 -0
- package/src/services/voice/speaker/encoder.d.ts +37 -0
- package/src/services/voice/speaker/encoder.d.ts.map +1 -0
- package/src/services/voice/speaker/encoder.ts +105 -0
- package/src/services/voice/speaker-imprint.d.ts +83 -0
- package/src/services/voice/speaker-imprint.d.ts.map +1 -0
- package/src/services/voice/speaker-imprint.test.ts +185 -0
- package/src/services/voice/speaker-imprint.ts +312 -0
- package/src/services/voice/speaker-preset-cache.d.ts +77 -0
- package/src/services/voice/speaker-preset-cache.d.ts.map +1 -0
- package/src/services/voice/speaker-preset-cache.test.ts +154 -0
- package/src/services/voice/speaker-preset-cache.ts +195 -0
- package/src/services/voice/streaming-asr/streaming-pipeline-adapter.ts +292 -0
- package/src/services/voice/system-audio-sink.d.ts +73 -0
- package/src/services/voice/system-audio-sink.d.ts.map +1 -0
- package/src/services/voice/system-audio-sink.test.ts +29 -0
- package/src/services/voice/system-audio-sink.ts +366 -0
- package/src/services/voice/transcriber.d.ts +244 -0
- package/src/services/voice/transcriber.d.ts.map +1 -0
- package/src/services/voice/transcriber.test.ts +392 -0
- package/src/services/voice/transcriber.ts +704 -0
- package/src/services/voice/turn-controller.d.ts +183 -0
- package/src/services/voice/turn-controller.d.ts.map +1 -0
- package/src/services/voice/turn-controller.test.ts +575 -0
- package/src/services/voice/turn-controller.ts +596 -0
- package/src/services/voice/types.d.ts +643 -0
- package/src/services/voice/types.d.ts.map +1 -0
- package/src/services/voice/types.ts +699 -0
- package/src/services/voice/vad.d.ts +282 -0
- package/src/services/voice/vad.d.ts.map +1 -0
- package/src/services/voice/vad.test.ts +480 -0
- package/src/services/voice/vad.ts +827 -0
- package/src/services/voice/vad.v1-v4.test.ts +222 -0
- package/src/services/voice/voice-budget.d.ts +241 -0
- package/src/services/voice/voice-budget.d.ts.map +1 -0
- package/src/services/voice/voice-budget.test.ts +420 -0
- package/src/services/voice/voice-budget.ts +656 -0
- package/src/services/voice/voice-duet.test.ts +375 -0
- package/src/services/voice/voice-emotion-classifier.d.ts +95 -0
- package/src/services/voice/voice-emotion-classifier.d.ts.map +1 -0
- package/src/services/voice/voice-emotion-classifier.test.ts +210 -0
- package/src/services/voice/voice-emotion-classifier.ts +273 -0
- package/src/services/voice/voice-preset-format.d.ts +158 -0
- package/src/services/voice/voice-preset-format.d.ts.map +1 -0
- package/src/services/voice/voice-preset-format.ts +700 -0
- package/src/services/voice/voice-preset-generator.test.ts +89 -0
- package/src/services/voice/voice-profile-artifact.d.ts +116 -0
- package/src/services/voice/voice-profile-artifact.d.ts.map +1 -0
- package/src/services/voice/voice-profile-artifact.test.ts +138 -0
- package/src/services/voice/voice-profile-artifact.ts +518 -0
- package/src/services/voice/voice-profile-routes.d.ts +83 -0
- package/src/services/voice/voice-profile-routes.d.ts.map +1 -0
- package/src/services/voice/voice-profile-routes.test.ts +429 -0
- package/src/services/voice/voice-profile-routes.ts +425 -0
- package/src/services/voice/voice-scenario.ts +154 -0
- package/src/services/voice/voice-settings.d.ts +82 -0
- package/src/services/voice/voice-settings.d.ts.map +1 -0
- package/src/services/voice/voice-settings.ts +172 -0
- package/src/services/voice/voice-state-machine.d.ts +364 -0
- package/src/services/voice/voice-state-machine.d.ts.map +1 -0
- package/src/services/voice/voice-state-machine.ts +727 -0
- package/src/services/voice/voice-workbench-report.test.ts +168 -0
- package/src/services/voice/voice-workbench-report.ts +326 -0
- package/src/services/voice/voice-workbench.test.ts +158 -0
- package/src/services/voice/voice.test.ts +1070 -0
- package/src/services/voice/wake-word-ggml.d.ts +101 -0
- package/src/services/voice/wake-word-ggml.d.ts.map +1 -0
- package/src/services/voice/wake-word-ggml.ts +320 -0
- package/src/services/voice/wake-word.d.ts +255 -0
- package/src/services/voice/wake-word.d.ts.map +1 -0
- package/src/services/voice/wake-word.test.ts +298 -0
- package/src/services/voice/wake-word.ts +554 -0
- package/src/services/voice/wrap-with-first-line-cache.d.ts +70 -0
- package/src/services/voice/wrap-with-first-line-cache.d.ts.map +1 -0
- package/src/services/voice/wrap-with-first-line-cache.ts +267 -0
- package/src/services/voice-model-updater.d.ts +240 -0
- package/src/services/voice-model-updater.d.ts.map +1 -0
- package/src/services/voice-model-updater.ts +724 -0
- package/src/services/voice-prewarm.d.ts +3 -0
- package/src/services/voice-prewarm.d.ts.map +1 -0
- package/src/services/voice-prewarm.ts +51 -0
- package/dist/index.d.ts +0 -37
- package/dist/index.js +0 -1098
|
@@ -0,0 +1,746 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Engine ↔ voice scheduler bridge.
|
|
3
|
+
*
|
|
4
|
+
* Adapts the live `LocalInferenceEngine` (`engine.ts`) plus the MTP
|
|
5
|
+
* llama-server (`ffi-streaming-backend.ts`) onto the voice scaffold's
|
|
6
|
+
* `VoiceScheduler`. See `packages/inference/AGENTS.md` §4 for the
|
|
7
|
+
* streaming graph this implements:
|
|
8
|
+
*
|
|
9
|
+
* ASR → text tokens → MTP drafter ↔ target verifier (text model)
|
|
10
|
+
* → phrase chunker → speaker preset cache + phrase cache
|
|
11
|
+
* → OmniVoice TTS → PCM ring buffer → audio out
|
|
12
|
+
*
|
|
13
|
+
* Plus rollback queue (MTP rejection → cancel pending TTS chunks)
|
|
14
|
+
* and barge-in cancellation (mic VAD → drain ring buffer + cancel TTS).
|
|
15
|
+
*
|
|
16
|
+
* Two TTS backends are exposed:
|
|
17
|
+
* - `StubOmniVoiceBackend`: deterministic synthetic PCM. Used by tests
|
|
18
|
+
* and any path that wants the streaming graph without real audio.
|
|
19
|
+
* - `FfiOmniVoiceBackend`: forwards through the fused
|
|
20
|
+
* `libelizainference.{dylib,so,dll}` ABI. The bridge creates the
|
|
21
|
+
* context lazily when voice is armed or first used, so voice-off
|
|
22
|
+
* does not keep OmniVoice weights resident.
|
|
23
|
+
*
|
|
24
|
+
* Per AGENTS.md §3 + §9 (no defensive code, no log-and-continue), every
|
|
25
|
+
* startup precondition surfaces as a thrown `VoiceStartupError`. There
|
|
26
|
+
* is no silent fallback to text-only.
|
|
27
|
+
*/
|
|
28
|
+
import type { IAgentRuntime } from "@elizaos/core";
|
|
29
|
+
import type { VoiceCancellationReason } from "@elizaos/shared";
|
|
30
|
+
import { type CoordinatorRuntime, VoiceCancellationCoordinator } from "./cancellation-coordinator";
|
|
31
|
+
import { VoiceStartupError } from "./errors";
|
|
32
|
+
import type { ElizaInferenceContextHandle, ElizaInferenceFfi, NativeVerifierEvent } from "./ffi-bindings";
|
|
33
|
+
import { KokoroTtsBackend } from "./kokoro/kokoro-backend";
|
|
34
|
+
import type { KokoroEngineDiscoveryResult } from "./kokoro/kokoro-engine-discovery";
|
|
35
|
+
import { VoiceLifecycle, type VoiceLifecycleLoaders } from "./lifecycle";
|
|
36
|
+
import { OptimisticGenerationPolicy, type OptimisticPolicyOptions } from "./optimistic-policy";
|
|
37
|
+
import { type CachedPhraseAudio } from "./phrase-cache";
|
|
38
|
+
import { VoicePipeline, type VoicePipelineConfig, type VoicePipelineEvents } from "./pipeline";
|
|
39
|
+
import { type MtpTextRunner } from "./pipeline-impls";
|
|
40
|
+
import type { VoiceProfileStore } from "./profile-store";
|
|
41
|
+
import { type SchedulerEvents, VoiceScheduler } from "./scheduler";
|
|
42
|
+
import { SharedResourceRegistry } from "./shared-resources";
|
|
43
|
+
import { type VoiceAttributionOutput } from "./speaker/attribution-pipeline";
|
|
44
|
+
import type { AudioChunk, AudioSink, OmniVoiceBackend, Phrase, RejectedTokenRange, SpeakerPreset, StreamingTranscriber, TextToken, TranscriptionAudio, VadEventSource } from "./types";
|
|
45
|
+
/** Re-exported from `./errors` so existing `engine-bridge` importers don't churn. */
|
|
46
|
+
export { VoiceStartupError };
|
|
47
|
+
/**
|
|
48
|
+
* Native verifier callbacks report rejected token ranges as half-open
|
|
49
|
+
* `[from, to)` intervals. The scheduler rollback queue uses inclusive
|
|
50
|
+
* token indexes, so convert in exactly one place.
|
|
51
|
+
*/
|
|
52
|
+
export declare function nativeRejectedRangeToRollbackRange(event: Pick<NativeVerifierEvent, "rejectedFrom" | "rejectedTo">): RejectedTokenRange | null;
|
|
53
|
+
/**
|
|
54
|
+
* One PCM segment delivered to a `StreamingTtsBackend.synthesizeStream`
|
|
55
|
+
* consumer (W9's scheduler) as TTS decodes it. `isFinal` marks the
|
|
56
|
+
* zero-length tail chunk that closes the phrase.
|
|
57
|
+
*/
|
|
58
|
+
export interface TtsPcmChunk {
|
|
59
|
+
pcm: Float32Array;
|
|
60
|
+
sampleRate: number;
|
|
61
|
+
isFinal: boolean;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Streaming-TTS seam between the fused `libelizainference` runtime and
|
|
65
|
+
* W9's voice scheduler. The scheduler calls `synthesizeStream(...)` for
|
|
66
|
+
* a phrase and writes each delivered `pcm` segment into the
|
|
67
|
+
* `PcmRingBuffer` on the same scheduler tick (AGENTS.md §4 —
|
|
68
|
+
* phrase-chunk → TTS within one scheduler tick); returning `true` from
|
|
69
|
+
* `onChunk` (or flipping `cancelSignal.cancelled`) hard-cancels the
|
|
70
|
+
* in-flight forward pass at the next kernel boundary (barge-in /
|
|
71
|
+
* MTP-rejected tail).
|
|
72
|
+
*
|
|
73
|
+
* Both `OmniVoiceBackend` implementations in this module satisfy it:
|
|
74
|
+
* - `FfiOmniVoiceBackend` forwards to
|
|
75
|
+
* `eliza_inference_tts_synthesize_stream` when the loaded build
|
|
76
|
+
* advertises streaming TTS (`tts_stream_supported() == 1`), else it
|
|
77
|
+
* synthesizes whole and emits the result as one body chunk + a final
|
|
78
|
+
* tail (no silent "streaming" lie — the chunk count just collapses
|
|
79
|
+
* to one when the build is non-streaming);
|
|
80
|
+
* - `StubOmniVoiceBackend` emits deterministic synthetic PCM split
|
|
81
|
+
* into a fixed number of chunks so scheduler tests can observe the
|
|
82
|
+
* incremental handoff without a real model.
|
|
83
|
+
*/
|
|
84
|
+
export interface StreamingTtsBackend {
|
|
85
|
+
/**
|
|
86
|
+
* Synthesize `phrase` with `preset` and deliver PCM in chunks. The
|
|
87
|
+
* scheduler owns the ring-buffer write inside `onChunk`. Resolves with
|
|
88
|
+
* `cancelled: true` if `onChunk` requested a stop (or `cancelSignal`
|
|
89
|
+
* was set), `false` on a clean finish. The final `onChunk` call always
|
|
90
|
+
* has `isFinal: true` (possibly a zero-length `pcm`) so the consumer
|
|
91
|
+
* can settle per-phrase state.
|
|
92
|
+
*/
|
|
93
|
+
synthesizeStream(args: {
|
|
94
|
+
phrase: Phrase;
|
|
95
|
+
preset: SpeakerPreset;
|
|
96
|
+
cancelSignal: {
|
|
97
|
+
cancelled: boolean;
|
|
98
|
+
};
|
|
99
|
+
onChunk: (chunk: TtsPcmChunk) => boolean | undefined;
|
|
100
|
+
onKernelTick?: () => void;
|
|
101
|
+
}): Promise<{
|
|
102
|
+
cancelled: boolean;
|
|
103
|
+
}>;
|
|
104
|
+
}
|
|
105
|
+
/** True when `backend` implements the `StreamingTtsBackend` seam. */
|
|
106
|
+
export declare function isStreamingTtsBackend(backend: OmniVoiceBackend): backend is OmniVoiceBackend & StreamingTtsBackend;
|
|
107
|
+
/**
|
|
108
|
+
* Deterministic test TTS backend. Each phrase yields
|
|
109
|
+
* `STUB_PCM_MS_PER_PHRASE` ms of silence (zeros), with the
|
|
110
|
+
* cancel signal honoured at the kernel-tick boundary so barge-in tests
|
|
111
|
+
* observe cancellation without waiting on a real model.
|
|
112
|
+
*/
|
|
113
|
+
export declare class StubOmniVoiceBackend implements OmniVoiceBackend, StreamingTtsBackend {
|
|
114
|
+
readonly id: "stub";
|
|
115
|
+
private readonly sampleRate;
|
|
116
|
+
calls: number;
|
|
117
|
+
streamCalls: number;
|
|
118
|
+
constructor(sampleRate?: number);
|
|
119
|
+
synthesize(args: {
|
|
120
|
+
phrase: Phrase;
|
|
121
|
+
preset: SpeakerPreset;
|
|
122
|
+
cancelSignal: {
|
|
123
|
+
cancelled: boolean;
|
|
124
|
+
};
|
|
125
|
+
onKernelTick?: () => void;
|
|
126
|
+
}): Promise<AudioChunk>;
|
|
127
|
+
synthesizeStream(args: {
|
|
128
|
+
phrase: Phrase;
|
|
129
|
+
preset: SpeakerPreset;
|
|
130
|
+
cancelSignal: {
|
|
131
|
+
cancelled: boolean;
|
|
132
|
+
};
|
|
133
|
+
onChunk: (chunk: TtsPcmChunk) => boolean | undefined;
|
|
134
|
+
onKernelTick?: () => void;
|
|
135
|
+
}): Promise<{
|
|
136
|
+
cancelled: boolean;
|
|
137
|
+
}>;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* FFI-backed TTS backend. Forwards each `synthesize()` call through the
|
|
141
|
+
* fused `libelizainference` ABI declared in
|
|
142
|
+
* `packages/app-core/scripts/omnivoice-fuse/ffi.h`. The library handle
|
|
143
|
+
* + a per-engine context pointer are held by the bridge and passed in
|
|
144
|
+
* at construction so this backend stays a thin adapter.
|
|
145
|
+
*
|
|
146
|
+
* Until the real fused build ships, the binding is exercised against
|
|
147
|
+
* the compatibility C library at `scripts/omnivoice-fuse/ffi-stub.c`, which returns
|
|
148
|
+
* `ELIZA_ERR_NOT_IMPLEMENTED` for `tts_synthesize` — the binding then
|
|
149
|
+
* raises `VoiceLifecycleError({code:"kernel-missing"})`. The adapter
|
|
150
|
+
* re-wraps that as `VoiceStartupError("missing-fused-build", ...)` so
|
|
151
|
+
* the engine layer's startup-error taxonomy stays unified. No silent
|
|
152
|
+
* fallback (AGENTS.md §3 + §9).
|
|
153
|
+
*/
|
|
154
|
+
export declare class FfiOmniVoiceBackend implements OmniVoiceBackend, StreamingTtsBackend {
|
|
155
|
+
readonly id: "ffi";
|
|
156
|
+
private readonly ffi;
|
|
157
|
+
private readonly getContext;
|
|
158
|
+
private readonly sampleRate;
|
|
159
|
+
private readonly maxSecondsPerPhrase;
|
|
160
|
+
constructor(args: {
|
|
161
|
+
ffi: ElizaInferenceFfi;
|
|
162
|
+
ctx?: ElizaInferenceContextHandle;
|
|
163
|
+
getContext?: () => ElizaInferenceContextHandle;
|
|
164
|
+
sampleRate?: number;
|
|
165
|
+
maxSecondsPerPhrase?: number;
|
|
166
|
+
});
|
|
167
|
+
/** True when the loaded `libelizainference` advertises streaming TTS. */
|
|
168
|
+
supportsStreamingTts(): boolean;
|
|
169
|
+
/**
|
|
170
|
+
* One-shot synthesis returning the whole phrase as an `AudioChunk`.
|
|
171
|
+
* When the loaded build advertises streaming TTS this routes through
|
|
172
|
+
* `eliza_inference_tts_synthesize_stream` and concatenates the
|
|
173
|
+
* delivered chunks (so the chunk-aware native path is exercised even
|
|
174
|
+
* for whole-phrase callers); otherwise it uses the batch
|
|
175
|
+
* `eliza_inference_tts_synthesize` symbol. `cancelSignal` is honoured
|
|
176
|
+
* at chunk boundaries — a cancelled stream returns whatever was
|
|
177
|
+
* synthesized so far.
|
|
178
|
+
*/
|
|
179
|
+
synthesize(args: {
|
|
180
|
+
phrase: Phrase;
|
|
181
|
+
preset: SpeakerPreset;
|
|
182
|
+
cancelSignal: {
|
|
183
|
+
cancelled: boolean;
|
|
184
|
+
};
|
|
185
|
+
onKernelTick?: () => void;
|
|
186
|
+
}): Promise<AudioChunk>;
|
|
187
|
+
/**
|
|
188
|
+
* Streaming synthesis: forwards to `eliza_inference_tts_synthesize_stream`
|
|
189
|
+
* when the build advertises a streaming decoder. When it does NOT
|
|
190
|
+
* (`tts_stream_supported() == 0`), this still satisfies the seam — but
|
|
191
|
+
* with exactly one body chunk + one final tail (the batch synthesis
|
|
192
|
+
* result), so the caller never mistakes a non-streaming build for a
|
|
193
|
+
* streaming one (no fallback sludge — the chunk count is the honest
|
|
194
|
+
* signal). The native side checks `ctx->tts_cancel` (set via
|
|
195
|
+
* `eliza_inference_cancel_tts`) on top of the `onChunk` return value.
|
|
196
|
+
* A non-streaming build cannot be interrupted while the native batch
|
|
197
|
+
* forward pass is inside `ttsSynthesize`; it only observes cancellation
|
|
198
|
+
* before emitting the body chunk. Barge-in-critical product paths should
|
|
199
|
+
* require `supportsStreamingTts()`.
|
|
200
|
+
*/
|
|
201
|
+
synthesizeStream(args: {
|
|
202
|
+
phrase: Phrase;
|
|
203
|
+
preset: SpeakerPreset;
|
|
204
|
+
cancelSignal: {
|
|
205
|
+
cancelled: boolean;
|
|
206
|
+
};
|
|
207
|
+
onChunk: (chunk: TtsPcmChunk) => boolean | undefined;
|
|
208
|
+
onKernelTick?: () => void;
|
|
209
|
+
}): Promise<{
|
|
210
|
+
cancelled: boolean;
|
|
211
|
+
}>;
|
|
212
|
+
/** Hard-cancel any in-flight TTS forward pass on this backend's context. */
|
|
213
|
+
cancelTts(): void;
|
|
214
|
+
/**
|
|
215
|
+
* Batch transcription. One-shot callers should use the fused batch ABI
|
|
216
|
+
* directly so the native side receives the original sample-rate metadata
|
|
217
|
+
* and can apply its own audio preprocessing. Live mic streaming remains
|
|
218
|
+
* available through `EngineVoiceBridge.createStreamingTranscriber()`.
|
|
219
|
+
*/
|
|
220
|
+
transcribe(args: TranscriptionAudio): Promise<string>;
|
|
221
|
+
}
|
|
222
|
+
export interface EngineVoiceBridgeOptions {
|
|
223
|
+
/**
|
|
224
|
+
* Bundle root on disk. Must contain `cache/voice-preset-default.bin`
|
|
225
|
+
* and the FFI library (`lib/libelizainference.{dylib,so}`) when
|
|
226
|
+
* `useFfiBackend === true`.
|
|
227
|
+
*/
|
|
228
|
+
bundleRoot: string;
|
|
229
|
+
/**
|
|
230
|
+
* When true, use `FfiOmniVoiceBackend`. When false, use the deterministic test backend
|
|
231
|
+
* only for lifecycle/unit tests; live sessions and direct synthesis reject
|
|
232
|
+
* the deterministic test backend before user-visible audio can be emitted.
|
|
233
|
+
*/
|
|
234
|
+
useFfiBackend: boolean;
|
|
235
|
+
/** Override sample rate. Defaults to 24 kHz. */
|
|
236
|
+
sampleRate?: number;
|
|
237
|
+
/** Override ring buffer capacity (samples). Defaults to 4 s @ 24 kHz. */
|
|
238
|
+
ringBufferCapacity?: number;
|
|
239
|
+
/** Phrase chunker `maxTokensPerPhrase` (no-punctuation run-on cap). Defaults to
|
|
240
|
+
* `ELIZA_VOICE_MAX_TOKENS_PER_PHRASE` or 8 (one MTP draft round). */
|
|
241
|
+
maxTokensPerPhrase?: number;
|
|
242
|
+
/** Max concurrent TTS phrase dispatches. Defaults to env or scheduler default. */
|
|
243
|
+
maxInFlightPhrases?: number;
|
|
244
|
+
/**
|
|
245
|
+
* Pre-warmed phrase cache entries. Per AGENTS.md §4, a precomputed
|
|
246
|
+
* phrase cache for common assistant utterances is mandatory for the
|
|
247
|
+
* first-byte-latency win. Empty by default — callers wire actual
|
|
248
|
+
* entries from the bundle when available.
|
|
249
|
+
*/
|
|
250
|
+
prewarmedPhrases?: ReadonlyArray<CachedPhraseAudio>;
|
|
251
|
+
/**
|
|
252
|
+
* Optional sink override (e.g. for tests or for routing PCM to a
|
|
253
|
+
* platform-specific audio device). Defaults to the in-memory sink the
|
|
254
|
+
* scheduler creates.
|
|
255
|
+
*/
|
|
256
|
+
sink?: AudioSink;
|
|
257
|
+
/** Optional scheduler event listeners (rollback, audio, cancel). */
|
|
258
|
+
events?: SchedulerEvents;
|
|
259
|
+
/**
|
|
260
|
+
* Optional override for the TTS backend. When set, supersedes
|
|
261
|
+
* `useFfiBackend`. Tests use this to inject a controllable backend
|
|
262
|
+
* (e.g. one that holds synthesis open until a deferred resolves) so
|
|
263
|
+
* rollback timing can be observed deterministically.
|
|
264
|
+
*/
|
|
265
|
+
backendOverride?: OmniVoiceBackend;
|
|
266
|
+
/**
|
|
267
|
+
* Override only the TTS backend while keeping the fused bundle lifecycle
|
|
268
|
+
* and ASR FFI loaded. Used when a bundle falls back from OmniVoice speech
|
|
269
|
+
* to Kokoro speech but still needs bundled Qwen3-ASR for mic input.
|
|
270
|
+
*/
|
|
271
|
+
ttsBackendOverride?: OmniVoiceBackend;
|
|
272
|
+
/** Optional speaker preset paired with `ttsBackendOverride`. */
|
|
273
|
+
speakerPresetOverride?: SpeakerPreset;
|
|
274
|
+
/**
|
|
275
|
+
* Optional shared resource registry. When the bridge is created
|
|
276
|
+
* inside an engine that already owns one (text + voice on the same
|
|
277
|
+
* tokenizer / mmap regions), the engine passes its registry in so
|
|
278
|
+
* voice ref-counts against the same canonical resources. Tests can
|
|
279
|
+
* leave this unset to get a private registry.
|
|
280
|
+
*/
|
|
281
|
+
sharedResources?: SharedResourceRegistry;
|
|
282
|
+
/**
|
|
283
|
+
* Optional lifecycle loaders override. Production wires real
|
|
284
|
+
* `madvise`-backed mmap handles via the FFI; tests inject mocks so
|
|
285
|
+
* the disarm path can assert eviction without a real file mapping.
|
|
286
|
+
* When unset, default loaders are derived from the bundle root.
|
|
287
|
+
*/
|
|
288
|
+
lifecycleLoaders?: VoiceLifecycleLoaders;
|
|
289
|
+
/**
|
|
290
|
+
* Construct a `KokoroTtsBackend` directly and skip the bundle-root +
|
|
291
|
+
* speaker-preset + FFI checks the fused omnivoice path requires.
|
|
292
|
+
* Kokoro voices are picked by id (`KOKORO_VOICE_PACKS`), so the bundle's
|
|
293
|
+
* per-user speaker preset is not used. Mutually exclusive with
|
|
294
|
+
* `useFfiBackend: true` and `backendOverride`. Lifecycle loaders
|
|
295
|
+
* default to empty lifecycle handles (ORT owns the model memory; nothing to
|
|
296
|
+
* mmap-evict).
|
|
297
|
+
*/
|
|
298
|
+
kokoroOnly?: KokoroEngineDiscoveryResult;
|
|
299
|
+
/**
|
|
300
|
+
* Optional pre-loaded fused inference handle for the `kokoroOnly` path. When
|
|
301
|
+
* set, the Kokoro FFI runtime reuses it instead of dlopen-ing a second copy
|
|
302
|
+
* of `libelizainference` (tests inject a stub; production may share the
|
|
303
|
+
* engine's handle).
|
|
304
|
+
*/
|
|
305
|
+
kokoroFfi?: ElizaInferenceFfi;
|
|
306
|
+
/**
|
|
307
|
+
* Optional voice-profile store for speaker-attribution. When set, the
|
|
308
|
+
* bridge constructs a `VoiceAttributionPipeline` and runs attribution
|
|
309
|
+
* in parallel with ASR on every turn via `runVoiceTurn`. Callers receive
|
|
310
|
+
* the resolved `VoiceAttributionOutput` via `onAttribution` in the turn
|
|
311
|
+
* events passed to `runVoiceTurn`.
|
|
312
|
+
*
|
|
313
|
+
* When absent, attribution is skipped and the pipeline operates exactly
|
|
314
|
+
* as before (no diarizer / encoder overhead).
|
|
315
|
+
*/
|
|
316
|
+
profileStore?: VoiceProfileStore;
|
|
317
|
+
/**
|
|
318
|
+
* W3-9 / F1 — the agent runtime. When supplied, the bridge constructs a
|
|
319
|
+
* `VoiceCancellationCoordinator` and an `OptimisticGenerationPolicy`
|
|
320
|
+
* scoped to this voice session. The coordinator owns one cancellation
|
|
321
|
+
* token per `roomId` and fans abort out to:
|
|
322
|
+
* 1. `runtime.turnControllers.abortTurn(roomId, reason)` — the
|
|
323
|
+
* planner-loop / action handlers / streaming `useModel` see the
|
|
324
|
+
* abort within one tick.
|
|
325
|
+
* 2. The slot-abort callback (`slotAbort`) when the LM slot id is
|
|
326
|
+
* registered with the turn.
|
|
327
|
+
* 3. The TTS hard-stop callback (`ttsStop`), which the bridge wires
|
|
328
|
+
* to its existing `triggerBargeIn()` (audio sink drain + FFI/HTTP
|
|
329
|
+
* synthesis cancel).
|
|
330
|
+
* 4. The standard `AbortSignal` every fetch / `useModel` / FFI call
|
|
331
|
+
* that took `token.signal` honours.
|
|
332
|
+
*
|
|
333
|
+
* The reverse direction (runtime → voice) is wired symmetrically via
|
|
334
|
+
* the coordinator's `runtime.turnControllers.onEvent` subscription.
|
|
335
|
+
*
|
|
336
|
+
* Omit to keep the prior behaviour — the bridge then exposes no
|
|
337
|
+
* coordinator / policy and callers fall back to the legacy
|
|
338
|
+
* `BargeInController` + `triggerBargeIn()` surface.
|
|
339
|
+
*
|
|
340
|
+
* Structural type — `CoordinatorRuntime` is the minimum surface the
|
|
341
|
+
* coordinator needs (`turnControllers.{abortTurn, onEvent}`). Production
|
|
342
|
+
* passes a full `IAgentRuntime`; tests can pass a fake matching the
|
|
343
|
+
* structural shape.
|
|
344
|
+
*/
|
|
345
|
+
runtime?: IAgentRuntime | CoordinatorRuntime;
|
|
346
|
+
/**
|
|
347
|
+
* W3-9 / F1 — optional `OptimisticGenerationPolicy` overrides. When
|
|
348
|
+
* `runtime` is set and `optimisticPolicyOptions` is omitted, the bridge
|
|
349
|
+
* constructs a default policy gated on the resolved power source
|
|
350
|
+
* (plugged-in / battery / unknown) and the canonical EOT threshold.
|
|
351
|
+
*/
|
|
352
|
+
optimisticPolicyOptions?: OptimisticPolicyOptions;
|
|
353
|
+
/**
|
|
354
|
+
* W3-9 / F1 — optional LM slot-abort callback for the cancellation
|
|
355
|
+
* coordinator. Production wires this to `MtpLlamaServer.abortSlot`
|
|
356
|
+
* once a slot id is known per turn. The bridge passes this directly
|
|
357
|
+
* into the coordinator; the bridge itself does not own slot ids.
|
|
358
|
+
*
|
|
359
|
+
* Has no effect when `runtime` is unset (no coordinator is constructed).
|
|
360
|
+
*/
|
|
361
|
+
slotAbort?: (slotId: number, reason: VoiceCancellationReason) => void;
|
|
362
|
+
/**
|
|
363
|
+
* Live speaker-attribution gating. When set alongside a `profileStore` AND
|
|
364
|
+
* a full `runtime` (with `emitEvent`), `runVoiceTurn` automatically:
|
|
365
|
+
* 1. emits `VOICE_TURN_OBSERVED` for every attributed turn, and
|
|
366
|
+
* 2. folds the diarization decision into the turn's `voiceTurnSignal`
|
|
367
|
+
* (stamped onto `output.turn.metadata`) so the server gate
|
|
368
|
+
* `core.voice_turn_signal` can suppress confident-bystander cross-talk.
|
|
369
|
+
*
|
|
370
|
+
* `knownSpeakerEntityIds` / `ownerEntityId` may be functions so the caller
|
|
371
|
+
* can resolve the enrolled-speaker set lazily per turn (the household roster
|
|
372
|
+
* changes as people are named). When omitted, attribution still emits
|
|
373
|
+
* `VOICE_TURN_OBSERVED` and produces a fail-open signal (no bystander
|
|
374
|
+
* suppression — every attribution is treated as potentially addressed to us).
|
|
375
|
+
*/
|
|
376
|
+
liveAttribution?: LiveAttributionConfig;
|
|
377
|
+
}
|
|
378
|
+
/** Gating inputs for the automatic live-attribution → voiceTurnSignal seam. */
|
|
379
|
+
export interface LiveAttributionConfig {
|
|
380
|
+
/** Owner / primary-enrolled entity id (always allowed to speak). */
|
|
381
|
+
ownerEntityId?: string | (() => string | null | undefined);
|
|
382
|
+
/** Entity ids the agent answers without a wake word (owner + enrolled). */
|
|
383
|
+
knownSpeakerEntityIds?: readonly string[] | (() => readonly string[] | undefined);
|
|
384
|
+
/** True when a wake word fired within the recent listen window. */
|
|
385
|
+
wakeWordActive?: boolean | (() => boolean);
|
|
386
|
+
}
|
|
387
|
+
export declare function createKokoroTtsBackend(kokoro: KokoroEngineDiscoveryResult, opts?: {
|
|
388
|
+
bundleRoot?: string;
|
|
389
|
+
ffi?: ElizaInferenceFfi;
|
|
390
|
+
}): KokoroTtsBackend;
|
|
391
|
+
export declare function createKokoroSpeakerPreset(kokoro: KokoroEngineDiscoveryResult): SpeakerPreset;
|
|
392
|
+
/**
|
|
393
|
+
* Per-turn events that include the optional attribution result alongside
|
|
394
|
+
* the existing `VoicePipelineEvents`. The attribution runs in parallel
|
|
395
|
+
* with ASR; it resolves some time after `onAsrComplete` and before
|
|
396
|
+
* `onComplete`.
|
|
397
|
+
*/
|
|
398
|
+
export interface VoiceTurnEvents extends VoicePipelineEvents {
|
|
399
|
+
/**
|
|
400
|
+
* Called once per turn when the `VoiceAttributionPipeline` resolves
|
|
401
|
+
* (diarizer + encoder + profile-store match). Only fired when the
|
|
402
|
+
* bridge was constructed with a `profileStore`. May arrive after
|
|
403
|
+
* `onAsrComplete` but before `onComplete`. Fire-and-forget from the
|
|
404
|
+
* bridge's perspective — callers attach the metadata to the turn's
|
|
405
|
+
* transcript asynchronously.
|
|
406
|
+
*/
|
|
407
|
+
onAttribution?(output: VoiceAttributionOutput): void;
|
|
408
|
+
}
|
|
409
|
+
/**
|
|
410
|
+
* Wires the voice scaffold (`VoiceScheduler` + helpers) onto the engine.
|
|
411
|
+
* One bridge per active voice session — created in
|
|
412
|
+
* `LocalInferenceEngine.startVoice()` and disposed when the engine
|
|
413
|
+
* unloads or `stopVoice()` is called.
|
|
414
|
+
*/
|
|
415
|
+
export declare class EngineVoiceBridge {
|
|
416
|
+
readonly scheduler: VoiceScheduler;
|
|
417
|
+
readonly backend: OmniVoiceBackend;
|
|
418
|
+
readonly lifecycle: VoiceLifecycle;
|
|
419
|
+
/** Loaded FFI handle when running against the fused build (else null). */
|
|
420
|
+
readonly ffi: ElizaInferenceFfi | null;
|
|
421
|
+
/** Lazily-created FFI context this bridge owns; destroyed in `dispose()`. */
|
|
422
|
+
private readonly ffiContextRef;
|
|
423
|
+
readonly asrAvailable: boolean;
|
|
424
|
+
private readonly bundleRoot;
|
|
425
|
+
/** The phrase cache the scheduler dispatches against — held so the bridge
|
|
426
|
+
* can answer "is phrase X cached" for the first-audio filler and seed the
|
|
427
|
+
* idle-time auto-prewarm. */
|
|
428
|
+
private readonly phraseCache;
|
|
429
|
+
/** In-flight fused turn (`runVoiceTurn`), if any — cancelled on barge-in. */
|
|
430
|
+
private activePipeline;
|
|
431
|
+
/**
|
|
432
|
+
* Optional attribution pipeline. Populated when the bridge was created
|
|
433
|
+
* with a `profileStore` option. When present, `runVoiceTurn` fires
|
|
434
|
+
* attribution in parallel with ASR and delivers the result via
|
|
435
|
+
* `VoiceTurnEvents.onAttribution`.
|
|
436
|
+
*/
|
|
437
|
+
private readonly attributionPipeline;
|
|
438
|
+
/**
|
|
439
|
+
* Full agent runtime, retained only when `opts.runtime` supports
|
|
440
|
+
* `emitEvent` (i.e. it is a real `IAgentRuntime`, not the structural
|
|
441
|
+
* `CoordinatorRuntime` a test may pass). Used by the automatic
|
|
442
|
+
* live-attribution seam in `runVoiceTurn` to emit `VOICE_TURN_OBSERVED`.
|
|
443
|
+
* Null when no event-capable runtime was supplied.
|
|
444
|
+
*/
|
|
445
|
+
private readonly eventRuntime;
|
|
446
|
+
/** Gating inputs for the live-attribution → voiceTurnSignal seam. */
|
|
447
|
+
private readonly liveAttribution;
|
|
448
|
+
/**
|
|
449
|
+
* W3-9 / F1 — voice cancellation coordinator. Populated when the bridge
|
|
450
|
+
* was created with a `runtime` option. Owns one
|
|
451
|
+
* `VoiceCancellationToken` per active `roomId` and fans abort out to
|
|
452
|
+
* the runtime turn controller, the LM slot, the TTS pipeline, and the
|
|
453
|
+
* standard `AbortSignal`. See `cancellation-coordinator.ts` for the
|
|
454
|
+
* full contract.
|
|
455
|
+
*/
|
|
456
|
+
private readonly cancellationCoordinator;
|
|
457
|
+
/**
|
|
458
|
+
* W3-9 / F1 — optimistic-generation policy. Constructed once per
|
|
459
|
+
* session when `runtime` is supplied. Gates the speculative LM prefill
|
|
460
|
+
* at the `firePrefill` site (see `voice-state-machine.ts`). Hot-swappable
|
|
461
|
+
* via `setPowerSource()` / `setOverride()` from Settings or a device-
|
|
462
|
+
* event listener.
|
|
463
|
+
*/
|
|
464
|
+
private readonly optimisticGenerationPolicy;
|
|
465
|
+
/**
|
|
466
|
+
* W3-9 / F1 — per-room `BargeInController` bindings the bridge owns.
|
|
467
|
+
* Holds the unsubscribe handle returned by
|
|
468
|
+
* `coordinator.bindBargeInController` so `dispose()` can tear them down.
|
|
469
|
+
*/
|
|
470
|
+
private readonly bargeInBindings;
|
|
471
|
+
private constructor();
|
|
472
|
+
get ffiCtx(): ElizaInferenceContextHandle | null;
|
|
473
|
+
/**
|
|
474
|
+
* Tear down the FFI context the bridge owns. Idempotent; safe to call
|
|
475
|
+
* multiple times. Callers should `disarm()` first to drop voice
|
|
476
|
+
* resources, then `dispose()` to close the FFI handle.
|
|
477
|
+
*/
|
|
478
|
+
dispose(): void;
|
|
479
|
+
/**
|
|
480
|
+
* Start the voice session for a bundle. Validates the bundle layout
|
|
481
|
+
* up-front (per AGENTS.md §3 + §7 — required artifacts checked before
|
|
482
|
+
* activation) and throws `VoiceStartupError` for any missing piece.
|
|
483
|
+
* No partial activation: either the scheduler exists and is wired or
|
|
484
|
+
* the call throws.
|
|
485
|
+
*/
|
|
486
|
+
static start(opts: EngineVoiceBridgeOptions): EngineVoiceBridge;
|
|
487
|
+
/**
|
|
488
|
+
* Kokoro-only path. Skips bundle-root / speaker-preset / FFI checks
|
|
489
|
+
* (Kokoro picks voices by id against `KOKORO_VOICE_PACKS`) and
|
|
490
|
+
* synthesizes a minimal `SpeakerPreset` keyed to the discovered voice
|
|
491
|
+
* id. Defaults lifecycle loaders to empty handles since ORT owns the
|
|
492
|
+
* model memory. `asrAvailable` is `false`: callers needing ASR
|
|
493
|
+
* construct `createStreamingTranscriber` directly.
|
|
494
|
+
*/
|
|
495
|
+
private static startKokoroOnly;
|
|
496
|
+
/**
|
|
497
|
+
* True when this bridge runs against a TTS backend that produces real
|
|
498
|
+
* audio — i.e. anything but the `StubOmniVoiceBackend` (which yields
|
|
499
|
+
* zeros and is tests-only). The prewarm + first-audio-filler paths gate
|
|
500
|
+
* on this so the cache never holds silence (AGENTS.md §3 — no fake data).
|
|
501
|
+
*/
|
|
502
|
+
hasRealTtsBackend(): boolean;
|
|
503
|
+
/**
|
|
504
|
+
* Lazy-load the TTS mmap region, optional ASR region, and the voice
|
|
505
|
+
* scheduler nodes via the lifecycle state machine. Idempotent for
|
|
506
|
+
* repeated calls in `voice-on` (returns the existing armed resources).
|
|
507
|
+
* Surfaces RAM pressure / mmap-fail / kernel-missing as `VoiceLifecycleError` —
|
|
508
|
+
* see `lifecycle.ts` for the full error taxonomy.
|
|
509
|
+
*/
|
|
510
|
+
arm(): Promise<void>;
|
|
511
|
+
/**
|
|
512
|
+
* Drain in-flight TTS, settle the scheduler, then disarm the
|
|
513
|
+
* lifecycle. Disarm calls `evictPages()` (madvise / VirtualUnlock
|
|
514
|
+
* equivalent) on the TTS + optional ASR mmap regions and releases every
|
|
515
|
+
* voice-only ref. Speaker preset + phrase cache survive in the
|
|
516
|
+
* registry as small LRU entries (KB-scale; not worth evicting).
|
|
517
|
+
*/
|
|
518
|
+
disarm(): Promise<void>;
|
|
519
|
+
/**
|
|
520
|
+
* Forward an accepted text token from the verifier into the scheduler.
|
|
521
|
+
* Tokens that fill a phrase trigger TTS dispatch on the same scheduler
|
|
522
|
+
* tick (AGENTS.md §4 — no buffering past phrase boundaries).
|
|
523
|
+
*/
|
|
524
|
+
pushAcceptedToken(token: TextToken, acceptedAt?: number): Promise<void>;
|
|
525
|
+
/**
|
|
526
|
+
* MTP rejection → rollback queue. The scheduler cancels any
|
|
527
|
+
* in-flight TTS forward pass for phrases that overlap the rejected
|
|
528
|
+
* token range and emits an `onRollback` event for observability.
|
|
529
|
+
* Already-played audio cannot be unplayed; the chunker is sized so
|
|
530
|
+
* rollback is rare and cheap.
|
|
531
|
+
*/
|
|
532
|
+
pushRejectedRange(range: RejectedTokenRange): Promise<void>;
|
|
533
|
+
/**
|
|
534
|
+
* Voice activity detected on the mic input → cancel everything.
|
|
535
|
+
* Drains the ring buffer immediately, flushes the chunker queue, and
|
|
536
|
+
* marks every in-flight cancel signal so synthesise loops exit at the
|
|
537
|
+
* next kernel boundary (AGENTS.md §4 — barge-in cancellation MUST be
|
|
538
|
+
* within one kernel tick).
|
|
539
|
+
*/
|
|
540
|
+
triggerBargeIn(): void;
|
|
541
|
+
/**
|
|
542
|
+
* W3-9 / F1 — the canonical voice cancellation coordinator for this
|
|
543
|
+
* session, or `null` when the bridge was constructed without a
|
|
544
|
+
* `runtime` option. Callers (turn controller, mic VAD source, UI cancel
|
|
545
|
+
* route) use this to arm per-turn tokens, fire `bargeIn(roomId)` on
|
|
546
|
+
* VAD speech-start, fire `revokeEot(roomId)` when the turn detector
|
|
547
|
+
* revokes a tentative EOT, etc. See
|
|
548
|
+
* `plugins/plugin-local-inference/docs/voice-cancellation-contract.md`.
|
|
549
|
+
*/
|
|
550
|
+
cancellationCoordinatorOrNull(): VoiceCancellationCoordinator | null;
|
|
551
|
+
/**
|
|
552
|
+
* W3-9 / F1 — the optimistic-generation policy for this session, or
|
|
553
|
+
* `null` when the bridge was constructed without a `runtime` option.
|
|
554
|
+
* The bridge primes it with the resolved power source at construction
|
|
555
|
+
* time; callers can mutate it via `setPowerSource()` / `setOverride()`
|
|
556
|
+
* to respond to Settings toggles or battery-state events.
|
|
557
|
+
*/
|
|
558
|
+
optimisticPolicyOrNull(): OptimisticGenerationPolicy | null;
|
|
559
|
+
/**
|
|
560
|
+
* W3-9 / F1 — bind the scheduler's `BargeInController` into the
|
|
561
|
+
* cancellation coordinator for `roomId`. Subsequent
|
|
562
|
+
* `BargeInController.hardStop()` calls (typically fired by the
|
|
563
|
+
* ASR-confirmed barge-in words ladder) translate into
|
|
564
|
+
* `coordinator.bargeIn(roomId)` so the canonical token (and every
|
|
565
|
+
* downstream consumer: runtime turn abort, LM slot abort, TTS stop,
|
|
566
|
+
* AbortSignal) sees the abort.
|
|
567
|
+
*
|
|
568
|
+
* Idempotent per `roomId` — repeated calls for the same room return
|
|
569
|
+
* the same unsubscribe handle (the prior binding is torn down first).
|
|
570
|
+
*
|
|
571
|
+
* When the bridge was constructed without a `runtime` option, this returns
|
|
572
|
+
* an empty unsubscribe. Callers should still call it
|
|
573
|
+
* unconditionally — back-compat for the legacy path is automatic.
|
|
574
|
+
*/
|
|
575
|
+
bindBargeInControllerForRoom(roomId: string): () => void;
|
|
576
|
+
/**
|
|
577
|
+
* Drain pending phrase data and wait for in-flight TTS to settle.
|
|
578
|
+
* Used at the end of a turn so callers can synchronise on a quiescent
|
|
579
|
+
* scheduler before they tear it down.
|
|
580
|
+
*/
|
|
581
|
+
settle(): Promise<void>;
|
|
582
|
+
synthesizeTextToWav(text: string, signal?: AbortSignal): Promise<Uint8Array>;
|
|
583
|
+
/**
|
|
584
|
+
* The streaming-TTS seam W9's scheduler drives: returns the active
|
|
585
|
+
* backend as a `StreamingTtsBackend` (`FfiOmniVoiceBackend` against the
|
|
586
|
+
* fused build, `StubOmniVoiceBackend` for tests). The scheduler calls
|
|
587
|
+
* `synthesizeStream(...)` for each phrase and writes the delivered PCM
|
|
588
|
+
* segments into its `PcmRingBuffer` on the same scheduler tick. Returns
|
|
589
|
+
* null when an injected `backendOverride` does not implement the seam.
|
|
590
|
+
*/
|
|
591
|
+
streamingTtsBackend(): StreamingTtsBackend | null;
|
|
592
|
+
/**
|
|
593
|
+
* True when the loaded fused `libelizainference` runs the MTP
|
|
594
|
+
* speculative loop in-process and can emit native accept/reject
|
|
595
|
+
* verifier events. When true, callers (W9's turn controller /
|
|
596
|
+
* `ffi-streaming-backend.ts` wiring) should subscribe via
|
|
597
|
+
* `subscribeNativeVerifier()` and SKIP the `llama-server` SSE
|
|
598
|
+
* `{"verifier":{"rejected":[a,b]}}` side-channel — the SSE path stays
|
|
599
|
+
* only as the non-fused desktop text fallback. False whenever there is
|
|
600
|
+
* no FFI handle or the build pre-dates the verifier callback.
|
|
601
|
+
*/
|
|
602
|
+
hasNativeVerifier(): boolean;
|
|
603
|
+
/**
|
|
604
|
+
* Register the native MTP verifier callback on the fused runtime
|
|
605
|
+
* and adapt each `NativeVerifierEvent` into the rollback-queue domain:
|
|
606
|
+
* accepted/corrected token-id ranges become `VerifierStreamEvent`s and
|
|
607
|
+
* rejected ranges become `RejectedTokenRange`s fed to `pushRejectedRange`.
|
|
608
|
+
* The returned handle MUST be `close()`d (clears the native callback +
|
|
609
|
+
* frees the bun:ffi `JSCallback`). Throws if no fused runtime is loaded.
|
|
610
|
+
*
|
|
611
|
+
* `onEvent` (optional) also receives the raw `NativeVerifierEvent` for
|
|
612
|
+
* callers that want the accepted-token stream (W9's phrase-chunker can
|
|
613
|
+
* commit accepted draft tokens directly off this instead of round-trip
|
|
614
|
+
* SSE deltas).
|
|
615
|
+
*/
|
|
616
|
+
subscribeNativeVerifier(onEvent?: (event: NativeVerifierEvent) => void): {
|
|
617
|
+
close(): void;
|
|
618
|
+
};
|
|
619
|
+
prewarmPhrases(texts: ReadonlyArray<string>, opts?: {
|
|
620
|
+
concurrency?: number;
|
|
621
|
+
}): Promise<{
|
|
622
|
+
warmed: number;
|
|
623
|
+
cached: number;
|
|
624
|
+
}>;
|
|
625
|
+
/**
|
|
626
|
+
* Idle-time auto-prewarm hook: synthesize the canonical phrase-cache seed
|
|
627
|
+
* (`DEFAULT_PHRASE_CACHE_SEED`) so common openers/acks are cached before
|
|
628
|
+
* the next turn. The voice bridge / connector calls this when the loop is
|
|
629
|
+
* idle. No-op (returns `{ warmed: 0, cached: 0 }`) unless a real TTS
|
|
630
|
+
* backend is present and voice is armed — we never cache the test backend's zeros
|
|
631
|
+
* (AGENTS.md §3).
|
|
632
|
+
*/
|
|
633
|
+
prewarmIdlePhrases(opts?: {
|
|
634
|
+
concurrency?: number;
|
|
635
|
+
}): Promise<{
|
|
636
|
+
warmed: number;
|
|
637
|
+
cached: number;
|
|
638
|
+
}>;
|
|
639
|
+
/**
|
|
640
|
+
* First-audio filler (AGENTS.md §4 / H4): the instant W1's VAD fires
|
|
641
|
+
* `speech-start`, play a short cached acknowledgement ("one sec", "okay",
|
|
642
|
+
* …) into the audio sink to mask first-token latency. W9's turn controller
|
|
643
|
+
* owns the call site (it gets the `speech-start` event and the cutover to
|
|
644
|
+
* real `replyText` audio); this method is the seam.
|
|
645
|
+
*
|
|
646
|
+
* It only ever plays audio that is *already in the phrase cache* — it does
|
|
647
|
+
* not synthesize. Returns the filler text that was played, or `null` if no
|
|
648
|
+
* filler was played (no real TTS backend, voice not armed, or none of the
|
|
649
|
+
* filler phrases are cached). When real reply audio is ready, W9 cuts over
|
|
650
|
+
* by writing it through the scheduler as usual (a `triggerBargeIn()` or a
|
|
651
|
+
* direct `ringBuffer.drain()` truncates any still-playing filler first).
|
|
652
|
+
*/
|
|
653
|
+
playFirstAudioFiller(): string | null;
|
|
654
|
+
/**
|
|
655
|
+
* Construct a `StreamingTranscriber` for live ASR — the contract the
|
|
656
|
+
* voice turn controller (W9) feeds mic frames into and the barge-in
|
|
657
|
+
* word-confirm gate (W1) listens to. Resolves the adapter chain:
|
|
658
|
+
* fused `libelizainference` streaming ASR (final path, gated on a
|
|
659
|
+
* working decoder AND a bundled ASR model) → fused batch ASR over the
|
|
660
|
+
* same bundled model → `AsrUnavailableError`. The Eliza-1 bridge runs
|
|
661
|
+
* only the fused path; the whisper.cpp interim fallback has been removed.
|
|
662
|
+
*
|
|
663
|
+
* Pass W1's `vad` event stream to gate decoding to active speech
|
|
664
|
+
* windows. Caller owns the returned transcriber's lifecycle (`dispose()`).
|
|
665
|
+
*/
|
|
666
|
+
createStreamingTranscriber(opts?: {
|
|
667
|
+
vad?: VadEventSource;
|
|
668
|
+
}): StreamingTranscriber;
|
|
669
|
+
/**
|
|
670
|
+
* Batch transcription: one-shot over a whole PCM buffer. When the active
|
|
671
|
+
* backend exposes the fused batch ASR ABI, use it directly so the native
|
|
672
|
+
* side receives the original sample rate and can apply its own resampling.
|
|
673
|
+
* Otherwise drive a `StreamingTranscriber` (fused streaming ASR →
|
|
674
|
+
* fused-batch interim) by feeding the buffer as a single frame and
|
|
675
|
+
* `flush()`ing. Throws `AsrUnavailableError` when no ASR backend is
|
|
676
|
+
* available — never a silent empty string.
|
|
677
|
+
*/
|
|
678
|
+
transcribePcm(args: TranscriptionAudio, signal?: AbortSignal): Promise<string>;
|
|
679
|
+
/**
|
|
680
|
+
* Run one fused mic→speech turn through the overlapped `VoicePipeline`
|
|
681
|
+
* (AGENTS.md §4): ASR streams; the instant its last token lands the
|
|
682
|
+
* MTP drafter and the target verifier kick off concurrently, accepted
|
|
683
|
+
* tokens flow into this bridge's phrase chunker → TTS → ring buffer on
|
|
684
|
+
* the same tick, rejected draft tails roll back not-yet-spoken audio, and
|
|
685
|
+
* a mic-VAD barge-in cancels everything at the next kernel boundary.
|
|
686
|
+
*
|
|
687
|
+
* The drafter + verifier are wired against the running MTP llama-server
|
|
688
|
+
* (`textRunner`); the transcriber is the fused ABI's ASR when this bridge
|
|
689
|
+
* was started with the FFI backend and the bundle ships an `asr/` region.
|
|
690
|
+
* In voice mode a missing ASR region is a hard `VoiceStartupError` — no
|
|
691
|
+
* silent cloud fallback (AGENTS.md §3 + §7).
|
|
692
|
+
*
|
|
693
|
+
* Resolves with the turn's exit reason. Throws if no turn is wired or one
|
|
694
|
+
* is already in flight. The created pipeline is held until the turn ends
|
|
695
|
+
* so `bargeIn()` can cancel it.
|
|
696
|
+
*/
|
|
697
|
+
runVoiceTurn(audio: TranscriptionAudio, textRunner: MtpTextRunner, config: VoicePipelineConfig, events?: VoiceTurnEvents): Promise<"done" | "token-cap" | "cancelled">;
|
|
698
|
+
/** Construct the `VoicePipeline` for this bridge (no-run). Exposed for tests. */
|
|
699
|
+
buildPipeline(textRunner: MtpTextRunner, config: VoicePipelineConfig, events?: VoicePipelineEvents): VoicePipeline;
|
|
700
|
+
/**
|
|
701
|
+
* Resolve the pipeline's ASR backend: a live `StreamingTranscriber` —
|
|
702
|
+
* the fused `eliza_inference_asr_stream_*` decoder when the loaded build
|
|
703
|
+
* advertises one and the bundle ships an `asr/` region, else the fused
|
|
704
|
+
* batch ASR adapter. The `VoicePipeline` drives it as a batch
|
|
705
|
+
* (feed the whole utterance, `flush()`, split the transcript into
|
|
706
|
+
* tokens). When no ASR backend is available the failure is surfaced as a
|
|
707
|
+
* `MissingAsrTranscriber` that throws on first use — AGENTS.md §3, no
|
|
708
|
+
* silent cloud fallback.
|
|
709
|
+
*/
|
|
710
|
+
private resolveTranscriber;
|
|
711
|
+
/** Diagnostic accessor — bundle root the bridge is wired against. */
|
|
712
|
+
bundlePath(): string;
|
|
713
|
+
private assertVoiceOn;
|
|
714
|
+
}
|
|
715
|
+
export declare function encodeMonoPcm16Wav(pcm: Float32Array, sampleRate: number): Uint8Array;
|
|
716
|
+
export declare function decodeMonoPcm16Wav(bytes: Uint8Array): TranscriptionAudio;
|
|
717
|
+
/**
|
|
718
|
+
* Default lifecycle loaders derived from the bundle layout (per
|
|
719
|
+
* AGENTS.md §2: `tts/omnivoice-<size>.gguf` + `asr/...`).
|
|
720
|
+
*
|
|
721
|
+
* When a live `ffi`/`ctx` pair is passed in, arming calls
|
|
722
|
+
* `ffi.mmapAcquire(ctx, "tts" | "asr")` before the lifecycle can enter
|
|
723
|
+
* `voice-on`, and the returned handles' `evictPages()` calls forward
|
|
724
|
+
* to `ffi.mmapEvict(ctx, "tts" | "asr")`. The C ABI is declared in
|
|
725
|
+
* `scripts/omnivoice-fuse/ffi.h`. Production builds may implement this
|
|
726
|
+
* as page eviction or as a full voice-runtime unload for mobile RAM
|
|
727
|
+
* pressure; callers must reacquire before using the region again. The
|
|
728
|
+
* compatibility library returns `ELIZA_ERR_NOT_IMPLEMENTED`, which the binding raises as
|
|
729
|
+
* `VoiceLifecycleError({code:"kernel-missing"})`.
|
|
730
|
+
*
|
|
731
|
+
* When `ffi` is null, acquire/evict are documented empty transitions — used by the
|
|
732
|
+
* development TTS path in tests + dev (no real mmap exists). Directory and
|
|
733
|
+
* "contains at least one file" checks still run for both TTS and ASR.
|
|
734
|
+
* ASR never gets a virtual fallback: voice-on requires a real bundled ASR
|
|
735
|
+
* model file so the FFI path can acquire the `"asr"` region and surface
|
|
736
|
+
* the fused ABI's diagnostic if the runtime lacks the required region support.
|
|
737
|
+
*/
|
|
738
|
+
interface FfiContextRef {
|
|
739
|
+
current: ElizaInferenceContextHandle | null;
|
|
740
|
+
ensure(): ElizaInferenceContextHandle;
|
|
741
|
+
}
|
|
742
|
+
declare function defaultLifecycleLoaders(bundleRoot: string, ffi: ElizaInferenceFfi | null, ctx: ElizaInferenceContextHandle | FfiContextRef | null): VoiceLifecycleLoaders;
|
|
743
|
+
/** Re-export for the engine and tests that want the default loader. */
|
|
744
|
+
export { defaultLifecycleLoaders };
|
|
745
|
+
export declare function isOmniVoiceBundleAvailable(bundleRoot: string): boolean;
|
|
746
|
+
//# sourceMappingURL=engine-bridge.d.ts.map
|