@runanywhere/core 0.16.0
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/RunAnywhereCore.podspec +130 -0
- package/android/CMakeLists.txt +92 -0
- package/android/build.gradle +321 -0
- package/android/consumer-rules.pro +5 -0
- package/android/src/main/AndroidManifest.xml +3 -0
- package/android/src/main/cpp/cpp-adapter.cpp +271 -0
- package/android/src/main/include/rac/backends/rac_llm_llamacpp.h +218 -0
- package/android/src/main/include/rac/backends/rac_stt_onnx.h +99 -0
- package/android/src/main/include/rac/backends/rac_stt_whispercpp.h +153 -0
- package/android/src/main/include/rac/backends/rac_tts_onnx.h +71 -0
- package/android/src/main/include/rac/backends/rac_vad_onnx.h +84 -0
- package/android/src/main/include/rac/core/capabilities/rac_lifecycle.h +290 -0
- package/android/src/main/include/rac/core/rac_analytics_events.h +610 -0
- package/android/src/main/include/rac/core/rac_audio_utils.h +88 -0
- package/android/src/main/include/rac/core/rac_component_types.h +160 -0
- package/android/src/main/include/rac/core/rac_core.h +331 -0
- package/android/src/main/include/rac/core/rac_error.h +469 -0
- package/android/src/main/include/rac/core/rac_events.h +334 -0
- package/android/src/main/include/rac/core/rac_logger.h +416 -0
- package/android/src/main/include/rac/core/rac_platform_adapter.h +340 -0
- package/android/src/main/include/rac/core/rac_sdk_state.h +292 -0
- package/android/src/main/include/rac/core/rac_structured_error.h +594 -0
- package/android/src/main/include/rac/core/rac_types.h +264 -0
- package/android/src/main/include/rac/features/llm/rac_llm.h +17 -0
- package/android/src/main/include/rac/features/llm/rac_llm_analytics.h +188 -0
- package/android/src/main/include/rac/features/llm/rac_llm_component.h +228 -0
- package/android/src/main/include/rac/features/llm/rac_llm_events.h +215 -0
- package/android/src/main/include/rac/features/llm/rac_llm_metrics.h +402 -0
- package/android/src/main/include/rac/features/llm/rac_llm_service.h +163 -0
- package/android/src/main/include/rac/features/llm/rac_llm_structured_output.h +141 -0
- package/android/src/main/include/rac/features/llm/rac_llm_types.h +384 -0
- package/android/src/main/include/rac/features/platform/rac_llm_platform.h +204 -0
- package/android/src/main/include/rac/features/platform/rac_tts_platform.h +197 -0
- package/android/src/main/include/rac/features/stt/rac_stt.h +17 -0
- package/android/src/main/include/rac/features/stt/rac_stt_analytics.h +204 -0
- package/android/src/main/include/rac/features/stt/rac_stt_component.h +162 -0
- package/android/src/main/include/rac/features/stt/rac_stt_events.h +62 -0
- package/android/src/main/include/rac/features/stt/rac_stt_service.h +154 -0
- package/android/src/main/include/rac/features/stt/rac_stt_types.h +389 -0
- package/android/src/main/include/rac/features/tts/rac_tts.h +17 -0
- package/android/src/main/include/rac/features/tts/rac_tts_analytics.h +181 -0
- package/android/src/main/include/rac/features/tts/rac_tts_component.h +158 -0
- package/android/src/main/include/rac/features/tts/rac_tts_events.h +54 -0
- package/android/src/main/include/rac/features/tts/rac_tts_service.h +162 -0
- package/android/src/main/include/rac/features/tts/rac_tts_types.h +374 -0
- package/android/src/main/include/rac/features/vad/rac_vad.h +17 -0
- package/android/src/main/include/rac/features/vad/rac_vad_analytics.h +236 -0
- package/android/src/main/include/rac/features/vad/rac_vad_component.h +185 -0
- package/android/src/main/include/rac/features/vad/rac_vad_energy.h +443 -0
- package/android/src/main/include/rac/features/vad/rac_vad_events.h +76 -0
- package/android/src/main/include/rac/features/vad/rac_vad_service.h +167 -0
- package/android/src/main/include/rac/features/vad/rac_vad_types.h +244 -0
- package/android/src/main/include/rac/features/voice_agent/rac_voice_agent.h +612 -0
- package/android/src/main/include/rac/infrastructure/device/rac_device_manager.h +176 -0
- package/android/src/main/include/rac/infrastructure/download/rac_download.h +418 -0
- package/android/src/main/include/rac/infrastructure/events/rac_events.h +177 -0
- package/android/src/main/include/rac/infrastructure/model_management/rac_model_assignment.h +169 -0
- package/android/src/main/include/rac/infrastructure/model_management/rac_model_paths.h +258 -0
- package/android/src/main/include/rac/infrastructure/model_management/rac_model_registry.h +357 -0
- package/android/src/main/include/rac/infrastructure/model_management/rac_model_strategy.h +374 -0
- package/android/src/main/include/rac/infrastructure/model_management/rac_model_types.h +613 -0
- package/android/src/main/include/rac/infrastructure/network/rac_api_types.h +335 -0
- package/android/src/main/include/rac/infrastructure/network/rac_auth_manager.h +252 -0
- package/android/src/main/include/rac/infrastructure/network/rac_dev_config.h +85 -0
- package/android/src/main/include/rac/infrastructure/network/rac_endpoints.h +102 -0
- package/android/src/main/include/rac/infrastructure/network/rac_environment.h +220 -0
- package/android/src/main/include/rac/infrastructure/network/rac_http_client.h +233 -0
- package/android/src/main/include/rac/infrastructure/storage/rac_storage_analyzer.h +286 -0
- package/android/src/main/include/rac/infrastructure/telemetry/rac_telemetry_manager.h +206 -0
- package/android/src/main/include/rac/infrastructure/telemetry/rac_telemetry_types.h +234 -0
- package/android/src/main/java/com/margelo/nitro/runanywhere/ArchiveUtility.kt +308 -0
- package/android/src/main/java/com/margelo/nitro/runanywhere/HybridRunAnywhereDeviceInfo.kt +229 -0
- package/android/src/main/java/com/margelo/nitro/runanywhere/PlatformAdapterBridge.kt +392 -0
- package/android/src/main/java/com/margelo/nitro/runanywhere/RunAnywhereCorePackage.kt +28 -0
- package/android/src/main/java/com/margelo/nitro/runanywhere/SDKLogger.kt +357 -0
- package/android/src/main/java/com/margelo/nitro/runanywhere/SecureStorageManager.kt +147 -0
- package/android/src/main/jniLibs/arm64-v8a/libc++_shared.so +0 -0
- package/android/src/main/jniLibs/arm64-v8a/libomp.so +0 -0
- package/android/src/main/jniLibs/arm64-v8a/librac_commons.so +0 -0
- package/android/src/main/jniLibs/arm64-v8a/librunanywhere_jni.so +0 -0
- package/cpp/HybridRunAnywhereCore.cpp +2505 -0
- package/cpp/HybridRunAnywhereCore.hpp +271 -0
- package/cpp/bridges/AuthBridge.cpp +209 -0
- package/cpp/bridges/AuthBridge.hpp +157 -0
- package/cpp/bridges/DeviceBridge.cpp +257 -0
- package/cpp/bridges/DeviceBridge.hpp +155 -0
- package/cpp/bridges/DownloadBridge.cpp +299 -0
- package/cpp/bridges/DownloadBridge.hpp +197 -0
- package/cpp/bridges/EventBridge.cpp +125 -0
- package/cpp/bridges/EventBridge.hpp +139 -0
- package/cpp/bridges/HTTPBridge.cpp +96 -0
- package/cpp/bridges/HTTPBridge.hpp +144 -0
- package/cpp/bridges/InitBridge.cpp +1273 -0
- package/cpp/bridges/InitBridge.hpp +306 -0
- package/cpp/bridges/ModelRegistryBridge.cpp +394 -0
- package/cpp/bridges/ModelRegistryBridge.hpp +177 -0
- package/cpp/bridges/StorageBridge.cpp +269 -0
- package/cpp/bridges/StorageBridge.hpp +172 -0
- package/cpp/bridges/TelemetryBridge.cpp +352 -0
- package/cpp/bridges/TelemetryBridge.hpp +126 -0
- package/ios/.testlocal +0 -0
- package/ios/ArchiveUtility.swift +526 -0
- package/ios/ArchiveUtilityBridge.m +52 -0
- package/ios/AudioDecoder.h +38 -0
- package/ios/AudioDecoder.m +162 -0
- package/ios/Binaries/RACommons.xcframework/Info.plist +44 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/RACommons.h +67 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_analytics_events.h +610 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_api_types.h +335 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_audio_utils.h +88 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_auth_manager.h +252 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_component_types.h +160 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_core.h +331 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_dev_config.h +85 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_device_manager.h +176 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_download.h +418 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_endpoints.h +102 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_environment.h +220 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_error.h +469 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_events.h +177 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_http_client.h +233 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_lifecycle.h +290 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_llm.h +17 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_llm_analytics.h +188 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_llm_component.h +228 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_llm_events.h +215 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_llm_llamacpp.h +218 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_llm_metrics.h +402 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_llm_platform.h +204 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_llm_service.h +163 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_llm_structured_output.h +141 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_llm_types.h +384 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_logger.h +416 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_model_assignment.h +169 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_model_paths.h +258 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_model_registry.h +357 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_model_strategy.h +374 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_model_types.h +613 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_platform_adapter.h +340 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_sdk_state.h +292 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_storage_analyzer.h +286 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_structured_error.h +594 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_stt.h +17 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_stt_analytics.h +204 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_stt_component.h +162 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_stt_events.h +62 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_stt_onnx.h +99 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_stt_service.h +154 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_stt_types.h +389 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_stt_whispercpp.h +153 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_telemetry_manager.h +206 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_telemetry_types.h +234 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_tts.h +17 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_tts_analytics.h +181 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_tts_component.h +158 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_tts_events.h +54 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_tts_onnx.h +71 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_tts_platform.h +197 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_tts_service.h +162 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_tts_types.h +374 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_types.h +264 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_vad.h +17 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_vad_analytics.h +236 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_vad_component.h +185 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_vad_energy.h +443 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_vad_events.h +76 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_vad_onnx.h +84 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_vad_service.h +167 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_vad_types.h +244 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_voice_agent.h +612 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Info.plist +11 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Modules/module.modulemap +5 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/RACommons +0 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/RACommons.h +67 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_analytics_events.h +610 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_api_types.h +335 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_audio_utils.h +88 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_auth_manager.h +252 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_component_types.h +160 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_core.h +331 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_dev_config.h +85 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_device_manager.h +176 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_download.h +418 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_endpoints.h +102 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_environment.h +220 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_error.h +469 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_events.h +177 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_http_client.h +233 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_lifecycle.h +290 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_llm.h +17 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_llm_analytics.h +188 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_llm_component.h +228 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_llm_events.h +215 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_llm_llamacpp.h +218 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_llm_metrics.h +402 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_llm_platform.h +204 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_llm_service.h +163 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_llm_structured_output.h +141 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_llm_types.h +384 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_logger.h +416 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_model_assignment.h +169 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_model_paths.h +258 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_model_registry.h +357 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_model_strategy.h +374 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_model_types.h +613 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_platform_adapter.h +340 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_sdk_state.h +292 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_storage_analyzer.h +286 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_structured_error.h +594 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_stt.h +17 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_stt_analytics.h +204 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_stt_component.h +162 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_stt_events.h +62 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_stt_onnx.h +99 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_stt_service.h +154 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_stt_types.h +389 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_stt_whispercpp.h +153 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_telemetry_manager.h +206 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_telemetry_types.h +234 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_tts.h +17 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_tts_analytics.h +181 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_tts_component.h +158 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_tts_events.h +54 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_tts_onnx.h +71 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_tts_platform.h +197 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_tts_service.h +162 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_tts_types.h +374 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_types.h +264 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_vad.h +17 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_vad_analytics.h +236 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_vad_component.h +185 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_vad_energy.h +443 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_vad_events.h +76 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_vad_onnx.h +84 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_vad_service.h +167 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_vad_types.h +244 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_voice_agent.h +612 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Info.plist +11 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Modules/module.modulemap +5 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/RACommons +0 -0
- package/ios/HybridRunAnywhereDeviceInfo.swift +214 -0
- package/ios/KeychainManager.swift +116 -0
- package/ios/PlatformAdapter.swift +100 -0
- package/ios/PlatformAdapterBridge.h +152 -0
- package/ios/PlatformAdapterBridge.m +570 -0
- package/ios/RNSDKLoggerBridge.h +41 -0
- package/ios/RNSDKLoggerBridge.m +66 -0
- package/ios/SDKLogger.swift +329 -0
- package/nitro.json +20 -0
- package/nitrogen/generated/.gitattributes +1 -0
- package/nitrogen/generated/android/c++/JHybridRunAnywhereDeviceInfoSpec.cpp +257 -0
- package/nitrogen/generated/android/c++/JHybridRunAnywhereDeviceInfoSpec.hpp +77 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/runanywhere/HybridRunAnywhereDeviceInfoSpec.kt +106 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/runanywhere/runanywherecoreOnLoad.kt +35 -0
- package/nitrogen/generated/android/runanywherecore+autolinking.cmake +82 -0
- package/nitrogen/generated/android/runanywherecore+autolinking.gradle +27 -0
- package/nitrogen/generated/android/runanywherecoreOnLoad.cpp +54 -0
- package/nitrogen/generated/android/runanywherecoreOnLoad.hpp +25 -0
- package/nitrogen/generated/ios/RunAnywhereCore+autolinking.rb +60 -0
- package/nitrogen/generated/ios/RunAnywhereCore-Swift-Cxx-Bridge.cpp +65 -0
- package/nitrogen/generated/ios/RunAnywhereCore-Swift-Cxx-Bridge.hpp +197 -0
- package/nitrogen/generated/ios/RunAnywhereCore-Swift-Cxx-Umbrella.hpp +45 -0
- package/nitrogen/generated/ios/RunAnywhereCoreAutolinking.mm +43 -0
- package/nitrogen/generated/ios/RunAnywhereCoreAutolinking.swift +25 -0
- package/nitrogen/generated/ios/c++/HybridRunAnywhereDeviceInfoSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridRunAnywhereDeviceInfoSpecSwift.hpp +173 -0
- package/nitrogen/generated/ios/swift/Func_void_bool.swift +47 -0
- package/nitrogen/generated/ios/swift/Func_void_double.swift +47 -0
- package/nitrogen/generated/ios/swift/Func_void_std__exception_ptr.swift +47 -0
- package/nitrogen/generated/ios/swift/Func_void_std__string.swift +47 -0
- package/nitrogen/generated/ios/swift/HybridRunAnywhereDeviceInfoSpec.swift +68 -0
- package/nitrogen/generated/ios/swift/HybridRunAnywhereDeviceInfoSpec_cxx.swift +366 -0
- package/nitrogen/generated/shared/c++/HybridRunAnywhereCoreSpec.cpp +92 -0
- package/nitrogen/generated/shared/c++/HybridRunAnywhereCoreSpec.hpp +138 -0
- package/nitrogen/generated/shared/c++/HybridRunAnywhereDeviceInfoSpec.cpp +33 -0
- package/nitrogen/generated/shared/c++/HybridRunAnywhereDeviceInfoSpec.hpp +75 -0
- package/package.json +76 -0
- package/react-native.config.js +14 -0
- package/src/Features/VoiceSession/AudioCaptureManager.ts +286 -0
- package/src/Features/VoiceSession/AudioPlaybackManager.ts +300 -0
- package/src/Features/VoiceSession/VoiceSessionHandle.ts +530 -0
- package/src/Features/VoiceSession/index.ts +20 -0
- package/src/Features/index.ts +7 -0
- package/src/Foundation/Constants/SDKConstants.ts +47 -0
- package/src/Foundation/Constants/index.ts +8 -0
- package/src/Foundation/DependencyInjection/ServiceContainer.ts +154 -0
- package/src/Foundation/DependencyInjection/ServiceRegistry.ts +51 -0
- package/src/Foundation/DependencyInjection/index.ts +6 -0
- package/src/Foundation/ErrorTypes/ErrorCategory.ts +184 -0
- package/src/Foundation/ErrorTypes/ErrorCodes.ts +151 -0
- package/src/Foundation/ErrorTypes/ErrorContext.ts +201 -0
- package/src/Foundation/ErrorTypes/SDKError.ts +507 -0
- package/src/Foundation/ErrorTypes/index.ts +57 -0
- package/src/Foundation/Initialization/InitializationPhase.ts +85 -0
- package/src/Foundation/Initialization/InitializationState.ts +168 -0
- package/src/Foundation/Initialization/index.ts +26 -0
- package/src/Foundation/Logging/Destinations/NativeLogBridge.ts +147 -0
- package/src/Foundation/Logging/Destinations/SentryDestination.ts +209 -0
- package/src/Foundation/Logging/Logger/SDKLogger.ts +232 -0
- package/src/Foundation/Logging/Models/LogLevel.ts +36 -0
- package/src/Foundation/Logging/Models/LoggingConfiguration.ts +117 -0
- package/src/Foundation/Logging/Services/LoggingManager.ts +407 -0
- package/src/Foundation/Logging/index.ts +59 -0
- package/src/Foundation/Security/DeviceIdentity.ts +92 -0
- package/src/Foundation/Security/SecureStorageError.ts +132 -0
- package/src/Foundation/Security/SecureStorageKeys.ts +35 -0
- package/src/Foundation/Security/SecureStorageService.ts +449 -0
- package/src/Foundation/Security/index.ts +17 -0
- package/src/Foundation/index.ts +26 -0
- package/src/Infrastructure/Events/EventPublisher.ts +165 -0
- package/src/Infrastructure/Events/SDKEvent.ts +214 -0
- package/src/Infrastructure/Events/index.ts +15 -0
- package/src/Infrastructure/index.ts +9 -0
- package/src/Public/Events/EventBus.ts +488 -0
- package/src/Public/Events/index.ts +8 -0
- package/src/Public/Extensions/RunAnywhere+Logging.ts +51 -0
- package/src/Public/Extensions/RunAnywhere+Models.ts +392 -0
- package/src/Public/Extensions/RunAnywhere+STT.ts +424 -0
- package/src/Public/Extensions/RunAnywhere+Storage.ts +151 -0
- package/src/Public/Extensions/RunAnywhere+StructuredOutput.ts +316 -0
- package/src/Public/Extensions/RunAnywhere+TTS.ts +430 -0
- package/src/Public/Extensions/RunAnywhere+TextGeneration.ts +320 -0
- package/src/Public/Extensions/RunAnywhere+VAD.ts +359 -0
- package/src/Public/Extensions/RunAnywhere+VoiceAgent.ts +225 -0
- package/src/Public/Extensions/RunAnywhere+VoiceSession.ts +155 -0
- package/src/Public/Extensions/index.ts +126 -0
- package/src/Public/RunAnywhere.ts +695 -0
- package/src/index.ts +238 -0
- package/src/native/NativeRunAnywhereCore.ts +291 -0
- package/src/native/NativeRunAnywhereModule.ts +32 -0
- package/src/native/index.ts +21 -0
- package/src/services/DownloadService.ts +282 -0
- package/src/services/FileSystem.ts +810 -0
- package/src/services/ModelRegistry.ts +246 -0
- package/src/services/Network/APIEndpoints.ts +84 -0
- package/src/services/Network/HTTPService.ts +479 -0
- package/src/services/Network/NetworkConfiguration.ts +130 -0
- package/src/services/Network/TelemetryService.ts +318 -0
- package/src/services/Network/index.ts +29 -0
- package/src/services/SystemTTSService.ts +130 -0
- package/src/services/index.ts +66 -0
- package/src/specs/RunAnywhereCore.nitro.ts +627 -0
- package/src/specs/RunAnywhereDeviceInfo.nitro.ts +73 -0
- package/src/types/LLMTypes.ts +127 -0
- package/src/types/STTTypes.ts +124 -0
- package/src/types/StructuredOutputTypes.ts +156 -0
- package/src/types/TTSTypes.ts +126 -0
- package/src/types/VADTypes.ts +70 -0
- package/src/types/VoiceAgentTypes.ts +182 -0
- package/src/types/enums.ts +258 -0
- package/src/types/events.ts +337 -0
- package/src/types/external.d.ts +142 -0
- package/src/types/index.ts +146 -0
- package/src/types/models.ts +579 -0
|
@@ -0,0 +1,530 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* VoiceSessionHandle.ts
|
|
3
|
+
*
|
|
4
|
+
* High-level voice session API for simplified voice assistant integration.
|
|
5
|
+
* Handles audio capture, VAD, and processing internally.
|
|
6
|
+
*
|
|
7
|
+
* Reference: sdk/runanywhere-swift/Sources/RunAnywhere/Public/Extensions/VoiceAgent/RunAnywhere+VoiceSession.swift
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { EventBus } from '../../Public/Events';
|
|
11
|
+
import { SDKLogger } from '../../Foundation/Logging/Logger/SDKLogger';
|
|
12
|
+
import { AudioCaptureManager } from './AudioCaptureManager';
|
|
13
|
+
import { AudioPlaybackManager } from './AudioPlaybackManager';
|
|
14
|
+
import * as VoiceAgent from '../../Public/Extensions/RunAnywhere+VoiceAgent';
|
|
15
|
+
import type { VoiceTurnResult } from '../../types/VoiceAgentTypes';
|
|
16
|
+
|
|
17
|
+
const logger = new SDKLogger('VoiceSession');
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Voice session configuration
|
|
21
|
+
*/
|
|
22
|
+
export interface VoiceSessionConfig {
|
|
23
|
+
/** Silence duration (seconds) before processing speech (default: 1.5) */
|
|
24
|
+
silenceDuration?: number;
|
|
25
|
+
|
|
26
|
+
/** Minimum audio level to detect speech (0.0 - 1.0, default: 0.1) */
|
|
27
|
+
speechThreshold?: number;
|
|
28
|
+
|
|
29
|
+
/** Whether to auto-play TTS response (default: true) */
|
|
30
|
+
autoPlayTTS?: boolean;
|
|
31
|
+
|
|
32
|
+
/** Whether to auto-resume listening after TTS playback (default: true) */
|
|
33
|
+
continuousMode?: boolean;
|
|
34
|
+
|
|
35
|
+
/** Language code (default: 'en') */
|
|
36
|
+
language?: string;
|
|
37
|
+
|
|
38
|
+
/** System prompt for LLM */
|
|
39
|
+
systemPrompt?: string;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Default voice session configuration
|
|
44
|
+
*/
|
|
45
|
+
export const DEFAULT_VOICE_SESSION_CONFIG: Required<VoiceSessionConfig> = {
|
|
46
|
+
silenceDuration: 1.5,
|
|
47
|
+
speechThreshold: 0.1,
|
|
48
|
+
autoPlayTTS: true,
|
|
49
|
+
continuousMode: true,
|
|
50
|
+
language: 'en',
|
|
51
|
+
systemPrompt: '',
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Voice session event types
|
|
56
|
+
*/
|
|
57
|
+
export type VoiceSessionEventType =
|
|
58
|
+
| 'started'
|
|
59
|
+
| 'listening'
|
|
60
|
+
| 'speechStarted'
|
|
61
|
+
| 'speechEnded'
|
|
62
|
+
| 'processing'
|
|
63
|
+
| 'transcribed'
|
|
64
|
+
| 'responded'
|
|
65
|
+
| 'speaking'
|
|
66
|
+
| 'turnCompleted'
|
|
67
|
+
| 'stopped'
|
|
68
|
+
| 'error';
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Voice session event
|
|
72
|
+
*/
|
|
73
|
+
export interface VoiceSessionEvent {
|
|
74
|
+
type: VoiceSessionEventType;
|
|
75
|
+
timestamp: number;
|
|
76
|
+
|
|
77
|
+
/** Audio level (for 'listening' events) */
|
|
78
|
+
audioLevel?: number;
|
|
79
|
+
|
|
80
|
+
/** Transcription text (for 'transcribed' events) */
|
|
81
|
+
transcription?: string;
|
|
82
|
+
|
|
83
|
+
/** Response text (for 'responded' events) */
|
|
84
|
+
response?: string;
|
|
85
|
+
|
|
86
|
+
/** Audio data base64 (for 'turnCompleted' events) */
|
|
87
|
+
audio?: string;
|
|
88
|
+
|
|
89
|
+
/** Error message (for 'error' events) */
|
|
90
|
+
error?: string;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Voice session event callback
|
|
95
|
+
*/
|
|
96
|
+
export type VoiceSessionEventCallback = (event: VoiceSessionEvent) => void;
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Voice session state
|
|
100
|
+
*/
|
|
101
|
+
export type VoiceSessionState =
|
|
102
|
+
| 'idle'
|
|
103
|
+
| 'starting'
|
|
104
|
+
| 'listening'
|
|
105
|
+
| 'processing'
|
|
106
|
+
| 'speaking'
|
|
107
|
+
| 'stopped'
|
|
108
|
+
| 'error';
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* VoiceSessionHandle
|
|
112
|
+
*
|
|
113
|
+
* Handle to control an active voice session.
|
|
114
|
+
* Manages the full voice interaction loop: listen -> transcribe -> respond -> speak.
|
|
115
|
+
*/
|
|
116
|
+
export class VoiceSessionHandle {
|
|
117
|
+
private config: Required<VoiceSessionConfig>;
|
|
118
|
+
private audioCapture: AudioCaptureManager;
|
|
119
|
+
private audioPlayback: AudioPlaybackManager;
|
|
120
|
+
private eventCallback: VoiceSessionEventCallback | null = null;
|
|
121
|
+
private eventListeners: VoiceSessionEventCallback[] = [];
|
|
122
|
+
|
|
123
|
+
private state: VoiceSessionState = 'idle';
|
|
124
|
+
private audioBuffer: ArrayBuffer[] = [];
|
|
125
|
+
private lastSpeechTime: number | null = null;
|
|
126
|
+
private isSpeechActive = false;
|
|
127
|
+
private silenceCheckInterval: ReturnType<typeof setInterval> | null = null;
|
|
128
|
+
|
|
129
|
+
constructor(config: VoiceSessionConfig = {}) {
|
|
130
|
+
this.config = { ...DEFAULT_VOICE_SESSION_CONFIG, ...config };
|
|
131
|
+
this.audioCapture = new AudioCaptureManager({ sampleRate: 16000 });
|
|
132
|
+
this.audioPlayback = new AudioPlaybackManager();
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Current session state
|
|
137
|
+
*/
|
|
138
|
+
get sessionState(): VoiceSessionState {
|
|
139
|
+
return this.state;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Whether the session is running (listening or processing)
|
|
144
|
+
*/
|
|
145
|
+
get isRunning(): boolean {
|
|
146
|
+
return this.state !== 'idle' && this.state !== 'stopped' && this.state !== 'error';
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Whether audio is currently playing
|
|
151
|
+
*/
|
|
152
|
+
get isSpeaking(): boolean {
|
|
153
|
+
return this.audioPlayback.isPlaying;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Current audio level (0.0 - 1.0)
|
|
158
|
+
*/
|
|
159
|
+
get audioLevel(): number {
|
|
160
|
+
return this.audioCapture.audioLevel;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Start the voice session
|
|
165
|
+
*/
|
|
166
|
+
async start(): Promise<void> {
|
|
167
|
+
if (this.isRunning) {
|
|
168
|
+
logger.warning('Session already running');
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
this.state = 'starting';
|
|
173
|
+
logger.info('Starting voice session...');
|
|
174
|
+
|
|
175
|
+
try {
|
|
176
|
+
// Check if voice agent is ready
|
|
177
|
+
const isReady = await VoiceAgent.isVoiceAgentReady();
|
|
178
|
+
if (!isReady) {
|
|
179
|
+
logger.info('Voice agent not ready, attempting to initialize with loaded models...');
|
|
180
|
+
const initialized = await VoiceAgent.initializeVoiceAgentWithLoadedModels();
|
|
181
|
+
if (!initialized) {
|
|
182
|
+
throw new Error('Voice agent not ready. Load STT, LLM, and TTS models first.');
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
// Request microphone permission
|
|
187
|
+
const hasPermission = await this.audioCapture.requestPermission();
|
|
188
|
+
if (!hasPermission) {
|
|
189
|
+
throw new Error('Microphone permission denied');
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
// Start listening
|
|
193
|
+
this.emit({ type: 'started', timestamp: Date.now() });
|
|
194
|
+
await this.startListening();
|
|
195
|
+
|
|
196
|
+
} catch (error) {
|
|
197
|
+
const errorMsg = error instanceof Error ? error.message : String(error);
|
|
198
|
+
this.state = 'error';
|
|
199
|
+
logger.error(`Failed to start session: ${errorMsg}`);
|
|
200
|
+
this.emit({ type: 'error', timestamp: Date.now(), error: errorMsg });
|
|
201
|
+
throw error;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Stop the voice session
|
|
207
|
+
*/
|
|
208
|
+
stop(): void {
|
|
209
|
+
if (this.state === 'idle' || this.state === 'stopped') {
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
logger.info('Stopping voice session');
|
|
214
|
+
this.state = 'stopped';
|
|
215
|
+
|
|
216
|
+
// Stop audio capture and playback
|
|
217
|
+
this.audioCapture.stopRecording();
|
|
218
|
+
this.audioPlayback.stop();
|
|
219
|
+
|
|
220
|
+
// Clear timers
|
|
221
|
+
if (this.silenceCheckInterval) {
|
|
222
|
+
clearInterval(this.silenceCheckInterval);
|
|
223
|
+
this.silenceCheckInterval = null;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
// Clear state
|
|
227
|
+
this.audioBuffer = [];
|
|
228
|
+
this.isSpeechActive = false;
|
|
229
|
+
this.lastSpeechTime = null;
|
|
230
|
+
|
|
231
|
+
this.emit({ type: 'stopped', timestamp: Date.now() });
|
|
232
|
+
logger.info('Voice session stopped');
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* Force process current audio (push-to-talk mode)
|
|
237
|
+
*/
|
|
238
|
+
async sendNow(): Promise<void> {
|
|
239
|
+
if (!this.isRunning) {
|
|
240
|
+
logger.warning('Session not running');
|
|
241
|
+
return;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
this.isSpeechActive = false;
|
|
245
|
+
await this.processCurrentAudio();
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* Add event listener
|
|
250
|
+
*/
|
|
251
|
+
addEventListener(callback: VoiceSessionEventCallback): () => void {
|
|
252
|
+
this.eventListeners.push(callback);
|
|
253
|
+
return () => {
|
|
254
|
+
const index = this.eventListeners.indexOf(callback);
|
|
255
|
+
if (index > -1) {
|
|
256
|
+
this.eventListeners.splice(index, 1);
|
|
257
|
+
}
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* Set single event callback (alternative to addEventListener)
|
|
263
|
+
*/
|
|
264
|
+
setEventCallback(callback: VoiceSessionEventCallback | null): void {
|
|
265
|
+
this.eventCallback = callback;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* Create async iterator for events
|
|
270
|
+
*/
|
|
271
|
+
async *events(): AsyncGenerator<VoiceSessionEvent> {
|
|
272
|
+
const queue: VoiceSessionEvent[] = [];
|
|
273
|
+
let resolver: ((value: VoiceSessionEvent | null) => void) | null = null;
|
|
274
|
+
let done = false;
|
|
275
|
+
|
|
276
|
+
const unsubscribe = this.addEventListener((event) => {
|
|
277
|
+
if (event.type === 'stopped' || event.type === 'error') {
|
|
278
|
+
done = true;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
if (resolver) {
|
|
282
|
+
const currentResolver = resolver;
|
|
283
|
+
resolver = null;
|
|
284
|
+
currentResolver(event);
|
|
285
|
+
} else {
|
|
286
|
+
queue.push(event);
|
|
287
|
+
}
|
|
288
|
+
});
|
|
289
|
+
|
|
290
|
+
try {
|
|
291
|
+
while (!done) {
|
|
292
|
+
if (queue.length > 0) {
|
|
293
|
+
const event = queue.shift()!;
|
|
294
|
+
yield event;
|
|
295
|
+
if (event.type === 'stopped' || event.type === 'error') {
|
|
296
|
+
break;
|
|
297
|
+
}
|
|
298
|
+
} else {
|
|
299
|
+
const event = await new Promise<VoiceSessionEvent | null>((resolve) => {
|
|
300
|
+
resolver = resolve;
|
|
301
|
+
});
|
|
302
|
+
if (event === null) break;
|
|
303
|
+
yield event;
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
} finally {
|
|
307
|
+
unsubscribe();
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
/**
|
|
312
|
+
* Cleanup resources
|
|
313
|
+
*/
|
|
314
|
+
cleanup(): void {
|
|
315
|
+
this.stop();
|
|
316
|
+
this.audioCapture.cleanup();
|
|
317
|
+
this.audioPlayback.cleanup();
|
|
318
|
+
this.eventListeners = [];
|
|
319
|
+
this.eventCallback = null;
|
|
320
|
+
logger.info('VoiceSessionHandle cleaned up');
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
// Private methods
|
|
324
|
+
|
|
325
|
+
private emit(event: VoiceSessionEvent): void {
|
|
326
|
+
// Call single callback
|
|
327
|
+
if (this.eventCallback) {
|
|
328
|
+
this.eventCallback(event);
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
// Call all listeners
|
|
332
|
+
for (const listener of this.eventListeners) {
|
|
333
|
+
try {
|
|
334
|
+
listener(event);
|
|
335
|
+
} catch (error) {
|
|
336
|
+
logger.error(`Event listener error: ${error}`);
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
// Also publish to EventBus
|
|
341
|
+
// Map internal event type to EventBus voice session event type
|
|
342
|
+
switch (event.type) {
|
|
343
|
+
case 'started':
|
|
344
|
+
EventBus.publish('Voice', { type: 'voiceSession_started' });
|
|
345
|
+
break;
|
|
346
|
+
case 'listening':
|
|
347
|
+
EventBus.publish('Voice', { type: 'voiceSession_listening', audioLevel: event.audioLevel });
|
|
348
|
+
break;
|
|
349
|
+
case 'speechStarted':
|
|
350
|
+
EventBus.publish('Voice', { type: 'voiceSession_speechStarted' });
|
|
351
|
+
break;
|
|
352
|
+
case 'speechEnded':
|
|
353
|
+
EventBus.publish('Voice', { type: 'voiceSession_speechEnded' });
|
|
354
|
+
break;
|
|
355
|
+
case 'processing':
|
|
356
|
+
EventBus.publish('Voice', { type: 'voiceSession_processing' });
|
|
357
|
+
break;
|
|
358
|
+
case 'transcribed':
|
|
359
|
+
EventBus.publish('Voice', { type: 'voiceSession_transcribed', transcription: event.transcription });
|
|
360
|
+
break;
|
|
361
|
+
case 'responded':
|
|
362
|
+
EventBus.publish('Voice', { type: 'voiceSession_responded', response: event.response });
|
|
363
|
+
break;
|
|
364
|
+
case 'speaking':
|
|
365
|
+
EventBus.publish('Voice', { type: 'voiceSession_speaking' });
|
|
366
|
+
break;
|
|
367
|
+
case 'turnCompleted':
|
|
368
|
+
EventBus.publish('Voice', {
|
|
369
|
+
type: 'voiceSession_turnCompleted',
|
|
370
|
+
transcription: event.transcription,
|
|
371
|
+
response: event.response,
|
|
372
|
+
audio: event.audio
|
|
373
|
+
});
|
|
374
|
+
break;
|
|
375
|
+
case 'stopped':
|
|
376
|
+
EventBus.publish('Voice', { type: 'voiceSession_stopped' });
|
|
377
|
+
break;
|
|
378
|
+
case 'error':
|
|
379
|
+
EventBus.publish('Voice', { type: 'voiceSession_error', error: event.error });
|
|
380
|
+
break;
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
private async startListening(): Promise<void> {
|
|
385
|
+
this.state = 'listening';
|
|
386
|
+
this.audioBuffer = [];
|
|
387
|
+
this.lastSpeechTime = null;
|
|
388
|
+
this.isSpeechActive = false;
|
|
389
|
+
|
|
390
|
+
// Set up audio level callback
|
|
391
|
+
this.audioCapture.setAudioLevelCallback((level) => {
|
|
392
|
+
this.emit({ type: 'listening', timestamp: Date.now(), audioLevel: level });
|
|
393
|
+
this.checkSpeechState(level);
|
|
394
|
+
});
|
|
395
|
+
|
|
396
|
+
// Start recording
|
|
397
|
+
await this.audioCapture.startRecording((data) => {
|
|
398
|
+
this.handleAudioData(data);
|
|
399
|
+
});
|
|
400
|
+
|
|
401
|
+
// Start silence check interval
|
|
402
|
+
this.silenceCheckInterval = setInterval(() => {
|
|
403
|
+
this.checkSilenceTimeout();
|
|
404
|
+
}, 100);
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
private handleAudioData(data: ArrayBuffer): void {
|
|
408
|
+
if (!this.isRunning) return;
|
|
409
|
+
this.audioBuffer.push(data);
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
private checkSpeechState(level: number): void {
|
|
413
|
+
if (!this.isRunning) return;
|
|
414
|
+
|
|
415
|
+
if (level > this.config.speechThreshold) {
|
|
416
|
+
if (!this.isSpeechActive) {
|
|
417
|
+
logger.debug('Speech started');
|
|
418
|
+
this.isSpeechActive = true;
|
|
419
|
+
this.emit({ type: 'speechStarted', timestamp: Date.now() });
|
|
420
|
+
}
|
|
421
|
+
this.lastSpeechTime = Date.now();
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
private checkSilenceTimeout(): void {
|
|
426
|
+
if (!this.isRunning || !this.isSpeechActive) return;
|
|
427
|
+
|
|
428
|
+
if (this.lastSpeechTime) {
|
|
429
|
+
const silenceDuration = (Date.now() - this.lastSpeechTime) / 1000;
|
|
430
|
+
|
|
431
|
+
if (silenceDuration > this.config.silenceDuration) {
|
|
432
|
+
logger.debug('Speech ended (silence detected)');
|
|
433
|
+
this.isSpeechActive = false;
|
|
434
|
+
this.emit({ type: 'speechEnded', timestamp: Date.now() });
|
|
435
|
+
|
|
436
|
+
// Only process if we have enough audio (at least 0.5s at 16kHz)
|
|
437
|
+
const totalBytes = this.audioBuffer.reduce((sum, buf) => sum + buf.byteLength, 0);
|
|
438
|
+
if (totalBytes > 16000) {
|
|
439
|
+
this.processCurrentAudio();
|
|
440
|
+
} else {
|
|
441
|
+
this.audioBuffer = [];
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
private async processCurrentAudio(): Promise<void> {
|
|
448
|
+
// Gather audio data
|
|
449
|
+
const totalLength = this.audioBuffer.reduce((acc, buf) => acc + buf.byteLength, 0);
|
|
450
|
+
const audioData = new ArrayBuffer(totalLength);
|
|
451
|
+
const view = new Uint8Array(audioData);
|
|
452
|
+
let offset = 0;
|
|
453
|
+
for (const buffer of this.audioBuffer) {
|
|
454
|
+
view.set(new Uint8Array(buffer), offset);
|
|
455
|
+
offset += buffer.byteLength;
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
this.audioBuffer = [];
|
|
459
|
+
|
|
460
|
+
if (totalLength === 0) return;
|
|
461
|
+
|
|
462
|
+
// Stop listening during processing
|
|
463
|
+
this.audioCapture.stopRecording();
|
|
464
|
+
if (this.silenceCheckInterval) {
|
|
465
|
+
clearInterval(this.silenceCheckInterval);
|
|
466
|
+
this.silenceCheckInterval = null;
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
this.state = 'processing';
|
|
470
|
+
this.emit({ type: 'processing', timestamp: Date.now() });
|
|
471
|
+
|
|
472
|
+
try {
|
|
473
|
+
// Process the voice turn
|
|
474
|
+
const result = await VoiceAgent.processVoiceTurn(audioData);
|
|
475
|
+
|
|
476
|
+
if (!result.speechDetected) {
|
|
477
|
+
logger.info('No speech detected');
|
|
478
|
+
if (this.config.continuousMode && this.isRunning) {
|
|
479
|
+
await this.startListening();
|
|
480
|
+
}
|
|
481
|
+
return;
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
// Emit transcription
|
|
485
|
+
if (result.transcription) {
|
|
486
|
+
this.emit({
|
|
487
|
+
type: 'transcribed',
|
|
488
|
+
timestamp: Date.now(),
|
|
489
|
+
transcription: result.transcription
|
|
490
|
+
});
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
// Emit response
|
|
494
|
+
if (result.response) {
|
|
495
|
+
this.emit({
|
|
496
|
+
type: 'responded',
|
|
497
|
+
timestamp: Date.now(),
|
|
498
|
+
response: result.response
|
|
499
|
+
});
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
// Play TTS if enabled
|
|
503
|
+
if (this.config.autoPlayTTS && result.synthesizedAudio) {
|
|
504
|
+
this.state = 'speaking';
|
|
505
|
+
this.emit({ type: 'speaking', timestamp: Date.now() });
|
|
506
|
+
await this.audioPlayback.play(result.synthesizedAudio);
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
// Emit complete result
|
|
510
|
+
this.emit({
|
|
511
|
+
type: 'turnCompleted',
|
|
512
|
+
timestamp: Date.now(),
|
|
513
|
+
transcription: result.transcription,
|
|
514
|
+
response: result.response,
|
|
515
|
+
audio: result.synthesizedAudio,
|
|
516
|
+
});
|
|
517
|
+
|
|
518
|
+
} catch (error) {
|
|
519
|
+
const errorMsg = error instanceof Error ? error.message : String(error);
|
|
520
|
+
logger.error(`Processing failed: ${errorMsg}`);
|
|
521
|
+
this.emit({ type: 'error', timestamp: Date.now(), error: errorMsg });
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
// Resume listening if continuous mode
|
|
525
|
+
if (this.config.continuousMode && this.isRunning) {
|
|
526
|
+
this.state = 'listening';
|
|
527
|
+
await this.startListening();
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* VoiceSession Feature Module
|
|
3
|
+
*
|
|
4
|
+
* Provides high-level voice session management for voice assistant integration.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
export { AudioCaptureManager } from './AudioCaptureManager';
|
|
8
|
+
export type { AudioDataCallback, AudioLevelCallback, AudioCaptureConfig, AudioCaptureState } from './AudioCaptureManager';
|
|
9
|
+
|
|
10
|
+
export { AudioPlaybackManager } from './AudioPlaybackManager';
|
|
11
|
+
export type { PlaybackState, PlaybackCompletionCallback, PlaybackErrorCallback, PlaybackConfig } from './AudioPlaybackManager';
|
|
12
|
+
|
|
13
|
+
export { VoiceSessionHandle, DEFAULT_VOICE_SESSION_CONFIG } from './VoiceSessionHandle';
|
|
14
|
+
export type {
|
|
15
|
+
VoiceSessionConfig,
|
|
16
|
+
VoiceSessionEvent,
|
|
17
|
+
VoiceSessionEventType,
|
|
18
|
+
VoiceSessionEventCallback,
|
|
19
|
+
VoiceSessionState,
|
|
20
|
+
} from './VoiceSessionHandle';
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SDK-wide constants (metadata only)
|
|
3
|
+
*
|
|
4
|
+
* Centralized constants to ensure consistency across the SDK.
|
|
5
|
+
* Matches pattern: sdk/runanywhere-swift/Sources/RunAnywhere/Foundation/Constants/SDKConstants.swift
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { Platform } from 'react-native';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* SDK Constants
|
|
12
|
+
*
|
|
13
|
+
* All SDK-wide constants should be defined here to avoid hardcoded values
|
|
14
|
+
* scattered throughout the codebase.
|
|
15
|
+
*/
|
|
16
|
+
export const SDKConstants = {
|
|
17
|
+
/**
|
|
18
|
+
* SDK version - must match the VERSION file in the repository root
|
|
19
|
+
* Update this when bumping the SDK version
|
|
20
|
+
*/
|
|
21
|
+
version: '0.2.0',
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* SDK name
|
|
25
|
+
*/
|
|
26
|
+
name: 'RunAnywhere SDK',
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* User agent string
|
|
30
|
+
*/
|
|
31
|
+
get userAgent(): string {
|
|
32
|
+
return `${this.name}/${this.version} (React Native)`;
|
|
33
|
+
},
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Platform identifier (ios/android)
|
|
37
|
+
*/
|
|
38
|
+
get platform(): string {
|
|
39
|
+
return Platform.OS === 'ios' ? 'ios' : 'android';
|
|
40
|
+
},
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Minimum log level in production
|
|
44
|
+
*/
|
|
45
|
+
productionLogLevel: 'error',
|
|
46
|
+
} as const;
|
|
47
|
+
|