@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,424 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RunAnywhere+STT.ts
|
|
3
|
+
*
|
|
4
|
+
* Speech-to-Text extension for RunAnywhere SDK.
|
|
5
|
+
* Matches iOS: RunAnywhere+STT.swift
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { EventBus } from '../Events';
|
|
9
|
+
import { requireNativeModule, isNativeModuleAvailable } from '../../native';
|
|
10
|
+
import type { STTOptions, STTResult } from '../../types';
|
|
11
|
+
import { SDKLogger } from '../../Foundation/Logging/Logger/SDKLogger';
|
|
12
|
+
import type {
|
|
13
|
+
STTOutput,
|
|
14
|
+
STTPartialResult,
|
|
15
|
+
STTStreamCallback,
|
|
16
|
+
STTStreamOptions,
|
|
17
|
+
TranscriptionMetadata,
|
|
18
|
+
} from '../../types/STTTypes';
|
|
19
|
+
|
|
20
|
+
const logger = new SDKLogger('RunAnywhere.STT');
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Extended native module type for streaming STT methods
|
|
24
|
+
* These methods are optional and may not be implemented in all backends
|
|
25
|
+
*/
|
|
26
|
+
interface StreamingSTTNativeModule {
|
|
27
|
+
startStreamingSTT?: (language: string) => Promise<boolean>;
|
|
28
|
+
stopStreamingSTT?: () => Promise<boolean>;
|
|
29
|
+
isStreamingSTT?: () => Promise<boolean>;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// ============================================================================
|
|
33
|
+
// Speech-to-Text (STT) Extension
|
|
34
|
+
// ============================================================================
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Load an STT model
|
|
38
|
+
*/
|
|
39
|
+
export async function loadSTTModel(
|
|
40
|
+
modelPath: string,
|
|
41
|
+
modelType: string = 'whisper',
|
|
42
|
+
config?: Record<string, unknown>
|
|
43
|
+
): Promise<boolean> {
|
|
44
|
+
if (!isNativeModuleAvailable()) {
|
|
45
|
+
logger.warning('Native module not available for loadSTTModel');
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
const native = requireNativeModule();
|
|
49
|
+
return native.loadSTTModel(
|
|
50
|
+
modelPath,
|
|
51
|
+
modelType,
|
|
52
|
+
config ? JSON.stringify(config) : undefined
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Check if an STT model is loaded
|
|
58
|
+
*/
|
|
59
|
+
export async function isSTTModelLoaded(): Promise<boolean> {
|
|
60
|
+
if (!isNativeModuleAvailable()) {
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
const native = requireNativeModule();
|
|
64
|
+
return native.isSTTModelLoaded();
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Unload the current STT model
|
|
69
|
+
*/
|
|
70
|
+
export async function unloadSTTModel(): Promise<boolean> {
|
|
71
|
+
if (!isNativeModuleAvailable()) {
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
const native = requireNativeModule();
|
|
75
|
+
return native.unloadSTTModel();
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Simple voice transcription
|
|
80
|
+
* Matches Swift SDK: RunAnywhere.transcribe(_:)
|
|
81
|
+
*
|
|
82
|
+
* @param audioData Audio data (base64 string or ArrayBuffer)
|
|
83
|
+
* @returns Transcribed text
|
|
84
|
+
*/
|
|
85
|
+
export async function transcribeSimple(
|
|
86
|
+
audioData: string | ArrayBuffer
|
|
87
|
+
): Promise<string> {
|
|
88
|
+
const result = await transcribe(audioData);
|
|
89
|
+
return result.text;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Transcribe audio data with full options
|
|
94
|
+
* Matches Swift SDK: RunAnywhere.transcribeWithOptions(_:options:)
|
|
95
|
+
*/
|
|
96
|
+
export async function transcribe(
|
|
97
|
+
audioData: string | ArrayBuffer,
|
|
98
|
+
options?: STTOptions
|
|
99
|
+
): Promise<STTResult> {
|
|
100
|
+
if (!isNativeModuleAvailable()) {
|
|
101
|
+
throw new Error('Native module not available');
|
|
102
|
+
}
|
|
103
|
+
const native = requireNativeModule();
|
|
104
|
+
|
|
105
|
+
let audioBase64: string;
|
|
106
|
+
if (typeof audioData === 'string') {
|
|
107
|
+
audioBase64 = audioData;
|
|
108
|
+
} else {
|
|
109
|
+
const bytes = new Uint8Array(audioData);
|
|
110
|
+
let binary = '';
|
|
111
|
+
for (let i = 0; i < bytes.byteLength; i++) {
|
|
112
|
+
const byte = bytes[i];
|
|
113
|
+
if (byte !== undefined) {
|
|
114
|
+
binary += String.fromCharCode(byte);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
audioBase64 = btoa(binary);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
const sampleRate = options?.sampleRate ?? 16000;
|
|
121
|
+
const language = options?.language;
|
|
122
|
+
|
|
123
|
+
const resultJson = await native.transcribe(audioBase64, sampleRate, language);
|
|
124
|
+
|
|
125
|
+
try {
|
|
126
|
+
const result = JSON.parse(resultJson);
|
|
127
|
+
return {
|
|
128
|
+
text: result.text ?? '',
|
|
129
|
+
segments: result.segments ?? [],
|
|
130
|
+
language: result.language,
|
|
131
|
+
confidence: result.confidence ?? 1.0,
|
|
132
|
+
duration: result.duration ?? 0,
|
|
133
|
+
alternatives: result.alternatives ?? [],
|
|
134
|
+
};
|
|
135
|
+
} catch {
|
|
136
|
+
if (resultJson.includes('error')) {
|
|
137
|
+
throw new Error(resultJson);
|
|
138
|
+
}
|
|
139
|
+
return {
|
|
140
|
+
text: resultJson,
|
|
141
|
+
segments: [],
|
|
142
|
+
confidence: 1.0,
|
|
143
|
+
duration: 0,
|
|
144
|
+
alternatives: [],
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Transcribe audio buffer (Float32Array)
|
|
151
|
+
* Matches Swift SDK: RunAnywhere.transcribeBuffer(_:language:)
|
|
152
|
+
*/
|
|
153
|
+
export async function transcribeBuffer(
|
|
154
|
+
samples: Float32Array,
|
|
155
|
+
options?: STTOptions
|
|
156
|
+
): Promise<STTOutput> {
|
|
157
|
+
if (!isNativeModuleAvailable()) {
|
|
158
|
+
throw new Error('Native module not available');
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
const startTime = Date.now();
|
|
162
|
+
const native = requireNativeModule();
|
|
163
|
+
|
|
164
|
+
// Convert Float32Array to base64
|
|
165
|
+
const bytes = new Uint8Array(samples.buffer);
|
|
166
|
+
let binary = '';
|
|
167
|
+
for (let i = 0; i < bytes.byteLength; i++) {
|
|
168
|
+
const byte = bytes[i];
|
|
169
|
+
if (byte !== undefined) {
|
|
170
|
+
binary += String.fromCharCode(byte);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
const audioBase64 = btoa(binary);
|
|
174
|
+
|
|
175
|
+
const sampleRate = options?.sampleRate ?? 16000;
|
|
176
|
+
const language = options?.language ?? 'en';
|
|
177
|
+
|
|
178
|
+
const resultJson = await native.transcribe(audioBase64, sampleRate, language);
|
|
179
|
+
const endTime = Date.now();
|
|
180
|
+
const processingTime = (endTime - startTime) / 1000;
|
|
181
|
+
|
|
182
|
+
try {
|
|
183
|
+
const result = JSON.parse(resultJson);
|
|
184
|
+
|
|
185
|
+
// Estimate audio length from samples
|
|
186
|
+
const audioLength = samples.length / sampleRate;
|
|
187
|
+
|
|
188
|
+
const metadata: TranscriptionMetadata = {
|
|
189
|
+
modelId: 'unknown',
|
|
190
|
+
processingTime,
|
|
191
|
+
audioLength,
|
|
192
|
+
realTimeFactor: processingTime / audioLength,
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
return {
|
|
196
|
+
text: result.text ?? '',
|
|
197
|
+
confidence: result.confidence ?? 1.0,
|
|
198
|
+
wordTimestamps: result.timestamps,
|
|
199
|
+
detectedLanguage: result.language,
|
|
200
|
+
alternatives: result.alternatives,
|
|
201
|
+
metadata,
|
|
202
|
+
};
|
|
203
|
+
} catch {
|
|
204
|
+
throw new Error(`Transcription failed: ${resultJson}`);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Transcribe audio with streaming callbacks
|
|
210
|
+
* Matches Swift SDK: RunAnywhere.transcribeStream(audioData:options:onPartialResult:)
|
|
211
|
+
*
|
|
212
|
+
* @param audioData Audio data to transcribe
|
|
213
|
+
* @param options Stream options with callback
|
|
214
|
+
* @returns Final transcription output
|
|
215
|
+
*/
|
|
216
|
+
export async function transcribeStream(
|
|
217
|
+
audioData: string | ArrayBuffer,
|
|
218
|
+
options: STTStreamOptions
|
|
219
|
+
): Promise<STTOutput> {
|
|
220
|
+
if (!isNativeModuleAvailable()) {
|
|
221
|
+
throw new Error('Native module not available');
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
const startTime = Date.now();
|
|
225
|
+
const native = requireNativeModule();
|
|
226
|
+
|
|
227
|
+
let audioBase64: string;
|
|
228
|
+
let audioSize: number;
|
|
229
|
+
|
|
230
|
+
if (typeof audioData === 'string') {
|
|
231
|
+
audioBase64 = audioData;
|
|
232
|
+
audioSize = atob(audioData).length;
|
|
233
|
+
} else {
|
|
234
|
+
const bytes = new Uint8Array(audioData);
|
|
235
|
+
audioSize = bytes.byteLength;
|
|
236
|
+
let binary = '';
|
|
237
|
+
for (let i = 0; i < bytes.byteLength; i++) {
|
|
238
|
+
const byte = bytes[i];
|
|
239
|
+
if (byte !== undefined) {
|
|
240
|
+
binary += String.fromCharCode(byte);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
audioBase64 = btoa(binary);
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
const sampleRate = options?.sampleRate ?? 16000;
|
|
247
|
+
const language = options?.language ?? 'en';
|
|
248
|
+
|
|
249
|
+
// Set up event listener for partial results
|
|
250
|
+
let finalText = '';
|
|
251
|
+
let finalConfidence = 1.0;
|
|
252
|
+
|
|
253
|
+
if (options.onPartialResult) {
|
|
254
|
+
const unsubscribe = EventBus.onVoice((event) => {
|
|
255
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
256
|
+
const evt = event as any;
|
|
257
|
+
if (evt.type === 'sttPartialResult') {
|
|
258
|
+
const partialResult: STTPartialResult = {
|
|
259
|
+
transcript: evt.text ?? '',
|
|
260
|
+
confidence: evt.confidence,
|
|
261
|
+
isFinal: false,
|
|
262
|
+
};
|
|
263
|
+
options.onPartialResult?.(partialResult);
|
|
264
|
+
} else if (evt.type === 'sttCompleted') {
|
|
265
|
+
finalText = evt.text ?? '';
|
|
266
|
+
finalConfidence = evt.confidence ?? 1.0;
|
|
267
|
+
unsubscribe();
|
|
268
|
+
}
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
// Transcribe
|
|
273
|
+
const resultJson = await native.transcribe(audioBase64, sampleRate, language);
|
|
274
|
+
const endTime = Date.now();
|
|
275
|
+
const processingTime = (endTime - startTime) / 1000;
|
|
276
|
+
|
|
277
|
+
try {
|
|
278
|
+
const result = JSON.parse(resultJson);
|
|
279
|
+
|
|
280
|
+
// Estimate audio length
|
|
281
|
+
const bytesPerSample = 2; // 16-bit
|
|
282
|
+
const audioLength = audioSize / (sampleRate * bytesPerSample);
|
|
283
|
+
|
|
284
|
+
const metadata: TranscriptionMetadata = {
|
|
285
|
+
modelId: 'unknown',
|
|
286
|
+
processingTime,
|
|
287
|
+
audioLength,
|
|
288
|
+
realTimeFactor: processingTime / audioLength,
|
|
289
|
+
};
|
|
290
|
+
|
|
291
|
+
// Emit final partial result
|
|
292
|
+
if (options.onPartialResult) {
|
|
293
|
+
options.onPartialResult({
|
|
294
|
+
transcript: result.text ?? '',
|
|
295
|
+
confidence: result.confidence ?? 1.0,
|
|
296
|
+
isFinal: true,
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
return {
|
|
301
|
+
text: result.text ?? finalText,
|
|
302
|
+
confidence: result.confidence ?? finalConfidence,
|
|
303
|
+
wordTimestamps: result.timestamps,
|
|
304
|
+
detectedLanguage: result.language,
|
|
305
|
+
alternatives: result.alternatives,
|
|
306
|
+
metadata,
|
|
307
|
+
};
|
|
308
|
+
} catch {
|
|
309
|
+
throw new Error(`Streaming transcription failed: ${resultJson}`);
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
/**
|
|
314
|
+
* Transcribe audio from a file path
|
|
315
|
+
*/
|
|
316
|
+
export async function transcribeFile(
|
|
317
|
+
filePath: string,
|
|
318
|
+
options?: STTOptions
|
|
319
|
+
): Promise<STTResult> {
|
|
320
|
+
if (!isNativeModuleAvailable()) {
|
|
321
|
+
throw new Error('Native module not available');
|
|
322
|
+
}
|
|
323
|
+
const native = requireNativeModule();
|
|
324
|
+
|
|
325
|
+
const language = options?.language ?? 'en';
|
|
326
|
+
const resultJson = await native.transcribeFile(filePath, language);
|
|
327
|
+
|
|
328
|
+
try {
|
|
329
|
+
const result = JSON.parse(resultJson);
|
|
330
|
+
if (result.error) {
|
|
331
|
+
throw new Error(result.error);
|
|
332
|
+
}
|
|
333
|
+
return {
|
|
334
|
+
text: result.text ?? '',
|
|
335
|
+
segments: result.segments ?? [],
|
|
336
|
+
language: result.language,
|
|
337
|
+
confidence: result.confidence ?? 1.0,
|
|
338
|
+
duration: result.duration ?? 0,
|
|
339
|
+
alternatives: result.alternatives ?? [],
|
|
340
|
+
};
|
|
341
|
+
} catch {
|
|
342
|
+
if (resultJson.includes('error')) {
|
|
343
|
+
const errorMatch = resultJson.match(/"error":\s*"([^"]+)"/);
|
|
344
|
+
throw new Error(errorMatch ? errorMatch[1] : resultJson);
|
|
345
|
+
}
|
|
346
|
+
return {
|
|
347
|
+
text: resultJson,
|
|
348
|
+
segments: [],
|
|
349
|
+
confidence: 1.0,
|
|
350
|
+
duration: 0,
|
|
351
|
+
alternatives: [],
|
|
352
|
+
};
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
// ============================================================================
|
|
357
|
+
// Streaming STT (Real-time)
|
|
358
|
+
// ============================================================================
|
|
359
|
+
|
|
360
|
+
/**
|
|
361
|
+
* Start streaming speech-to-text transcription
|
|
362
|
+
* @deprecated Use transcribeStream() for better API parity with Swift SDK
|
|
363
|
+
*/
|
|
364
|
+
export async function startStreamingSTT(
|
|
365
|
+
language: string = 'en',
|
|
366
|
+
onPartial?: (text: string, confidence: number) => void,
|
|
367
|
+
onFinal?: (text: string, confidence: number) => void,
|
|
368
|
+
onError?: (error: string) => void
|
|
369
|
+
): Promise<boolean> {
|
|
370
|
+
if (!isNativeModuleAvailable()) {
|
|
371
|
+
logger.warning('Native module not available for startStreamingSTT');
|
|
372
|
+
return false;
|
|
373
|
+
}
|
|
374
|
+
const native = requireNativeModule();
|
|
375
|
+
|
|
376
|
+
if (onPartial || onFinal || onError) {
|
|
377
|
+
EventBus.onVoice((event) => {
|
|
378
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
379
|
+
const evt = event as any;
|
|
380
|
+
if (evt.type === 'sttPartialResult' && onPartial) {
|
|
381
|
+
onPartial(evt.text || '', evt.confidence || 0);
|
|
382
|
+
} else if (evt.type === 'sttCompleted' && onFinal) {
|
|
383
|
+
onFinal(evt.text || '', evt.confidence || 0);
|
|
384
|
+
} else if (evt.type === 'sttFailed' && onError) {
|
|
385
|
+
onError(evt.error || 'Unknown error');
|
|
386
|
+
}
|
|
387
|
+
});
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
const streamingNative = native as unknown as StreamingSTTNativeModule;
|
|
391
|
+
if (!streamingNative.startStreamingSTT) {
|
|
392
|
+
logger.warning('startStreamingSTT not available');
|
|
393
|
+
return false;
|
|
394
|
+
}
|
|
395
|
+
return streamingNative.startStreamingSTT(language);
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
/**
|
|
399
|
+
* Stop streaming speech-to-text transcription
|
|
400
|
+
*/
|
|
401
|
+
export async function stopStreamingSTT(): Promise<boolean> {
|
|
402
|
+
if (!isNativeModuleAvailable()) {
|
|
403
|
+
return false;
|
|
404
|
+
}
|
|
405
|
+
const native = requireNativeModule() as unknown as StreamingSTTNativeModule;
|
|
406
|
+
if (!native.stopStreamingSTT) {
|
|
407
|
+
return false;
|
|
408
|
+
}
|
|
409
|
+
return native.stopStreamingSTT();
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
/**
|
|
413
|
+
* Check if streaming STT is currently active
|
|
414
|
+
*/
|
|
415
|
+
export async function isStreamingSTT(): Promise<boolean> {
|
|
416
|
+
if (!isNativeModuleAvailable()) {
|
|
417
|
+
return false;
|
|
418
|
+
}
|
|
419
|
+
const native = requireNativeModule() as unknown as StreamingSTTNativeModule;
|
|
420
|
+
if (!native.isStreamingSTT) {
|
|
421
|
+
return false;
|
|
422
|
+
}
|
|
423
|
+
return native.isStreamingSTT();
|
|
424
|
+
}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RunAnywhere+Storage.ts
|
|
3
|
+
*
|
|
4
|
+
* Storage management extension.
|
|
5
|
+
* Uses react-native-fs via FileSystem service.
|
|
6
|
+
*
|
|
7
|
+
* Reference: sdk/runanywhere-swift/Sources/RunAnywhere/Public/Extensions/Storage/RunAnywhere+Storage.swift
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { ModelRegistry } from '../../services/ModelRegistry';
|
|
11
|
+
import { FileSystem } from '../../services/FileSystem';
|
|
12
|
+
import { SDKLogger } from '../../Foundation/Logging/Logger/SDKLogger';
|
|
13
|
+
|
|
14
|
+
const logger = new SDKLogger('RunAnywhere.Storage');
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Device storage information
|
|
18
|
+
* Matches Swift's DeviceStorageInfo
|
|
19
|
+
*/
|
|
20
|
+
export interface DeviceStorageInfo {
|
|
21
|
+
totalSpace: number;
|
|
22
|
+
freeSpace: number;
|
|
23
|
+
usedSpace: number;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* App storage information
|
|
28
|
+
* Matches Swift's AppStorageInfo
|
|
29
|
+
*/
|
|
30
|
+
export interface AppStorageInfo {
|
|
31
|
+
documentsSize: number;
|
|
32
|
+
cacheSize: number;
|
|
33
|
+
appSupportSize: number;
|
|
34
|
+
totalSize: number;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Model storage information
|
|
39
|
+
*/
|
|
40
|
+
export interface ModelStorageInfo {
|
|
41
|
+
totalSize: number;
|
|
42
|
+
modelCount: number;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Complete storage info structure
|
|
47
|
+
* Matches Swift's StorageInfo
|
|
48
|
+
*/
|
|
49
|
+
export interface StorageInfo {
|
|
50
|
+
deviceStorage: DeviceStorageInfo;
|
|
51
|
+
appStorage: AppStorageInfo;
|
|
52
|
+
modelStorage: ModelStorageInfo;
|
|
53
|
+
cacheSize: number;
|
|
54
|
+
totalModelsSize: number;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Get storage information
|
|
59
|
+
* Returns structure matching Swift's StorageInfo
|
|
60
|
+
*/
|
|
61
|
+
export async function getStorageInfo(): Promise<StorageInfo> {
|
|
62
|
+
const emptyResult: StorageInfo = {
|
|
63
|
+
deviceStorage: { totalSpace: 0, freeSpace: 0, usedSpace: 0 },
|
|
64
|
+
appStorage: { documentsSize: 0, cacheSize: 0, appSupportSize: 0, totalSize: 0 },
|
|
65
|
+
modelStorage: { totalSize: 0, modelCount: 0 },
|
|
66
|
+
cacheSize: 0,
|
|
67
|
+
totalModelsSize: 0,
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
if (!FileSystem.isAvailable()) {
|
|
71
|
+
return emptyResult;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
try {
|
|
75
|
+
const freeSpace = await FileSystem.getAvailableDiskSpace();
|
|
76
|
+
const totalSpace = await FileSystem.getTotalDiskSpace();
|
|
77
|
+
const usedSpace = totalSpace - freeSpace;
|
|
78
|
+
|
|
79
|
+
// Get models directory size
|
|
80
|
+
let modelsSize = 0;
|
|
81
|
+
let modelCount = 0;
|
|
82
|
+
try {
|
|
83
|
+
const modelsDir = FileSystem.getModelsDirectory();
|
|
84
|
+
const exists = await FileSystem.directoryExists(modelsDir);
|
|
85
|
+
if (exists) {
|
|
86
|
+
modelsSize = await FileSystem.getDirectorySize(modelsDir);
|
|
87
|
+
const files = await FileSystem.listDirectory(modelsDir);
|
|
88
|
+
modelCount = files.length;
|
|
89
|
+
}
|
|
90
|
+
} catch {
|
|
91
|
+
// Models directory may not exist yet
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// Get cache size
|
|
95
|
+
let cacheSize = 0;
|
|
96
|
+
try {
|
|
97
|
+
const cacheDir = FileSystem.getCacheDirectory();
|
|
98
|
+
const exists = await FileSystem.directoryExists(cacheDir);
|
|
99
|
+
if (exists) {
|
|
100
|
+
cacheSize = await FileSystem.getDirectorySize(cacheDir);
|
|
101
|
+
}
|
|
102
|
+
} catch {
|
|
103
|
+
// Cache directory may not exist
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// Get app documents size (RunAnywhere directory)
|
|
107
|
+
let documentsSize = 0;
|
|
108
|
+
try {
|
|
109
|
+
const docsDir = FileSystem.getRunAnywhereDirectory();
|
|
110
|
+
const exists = await FileSystem.directoryExists(docsDir);
|
|
111
|
+
if (exists) {
|
|
112
|
+
documentsSize = await FileSystem.getDirectorySize(docsDir);
|
|
113
|
+
}
|
|
114
|
+
} catch {
|
|
115
|
+
// Documents directory may not exist
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
const totalAppSize = documentsSize + cacheSize;
|
|
119
|
+
|
|
120
|
+
return {
|
|
121
|
+
deviceStorage: {
|
|
122
|
+
totalSpace,
|
|
123
|
+
freeSpace,
|
|
124
|
+
usedSpace,
|
|
125
|
+
},
|
|
126
|
+
appStorage: {
|
|
127
|
+
documentsSize,
|
|
128
|
+
cacheSize,
|
|
129
|
+
appSupportSize: 0,
|
|
130
|
+
totalSize: totalAppSize,
|
|
131
|
+
},
|
|
132
|
+
modelStorage: {
|
|
133
|
+
totalSize: modelsSize,
|
|
134
|
+
modelCount,
|
|
135
|
+
},
|
|
136
|
+
cacheSize,
|
|
137
|
+
totalModelsSize: modelsSize,
|
|
138
|
+
};
|
|
139
|
+
} catch (error) {
|
|
140
|
+
logger.warning('Failed to get storage info:', { error });
|
|
141
|
+
return emptyResult;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Clear cache
|
|
147
|
+
*/
|
|
148
|
+
export async function clearCache(): Promise<void> {
|
|
149
|
+
ModelRegistry.reset();
|
|
150
|
+
logger.info('Cache cleared');
|
|
151
|
+
}
|