@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,201 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ErrorContext.ts
|
|
3
|
+
*
|
|
4
|
+
* Captures detailed error context for debugging and logging.
|
|
5
|
+
* Matches iOS SDK: Foundation/ErrorTypes/ErrorContext.swift
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Contextual information captured when an error occurs.
|
|
10
|
+
*/
|
|
11
|
+
export interface ErrorContext {
|
|
12
|
+
/** Stack trace at error point */
|
|
13
|
+
readonly stackTrace: string[];
|
|
14
|
+
/** Source file where error occurred */
|
|
15
|
+
readonly file: string;
|
|
16
|
+
/** Line number */
|
|
17
|
+
readonly line: number;
|
|
18
|
+
/** Function name */
|
|
19
|
+
readonly function: string;
|
|
20
|
+
/** Error capture timestamp (ISO8601) */
|
|
21
|
+
readonly timestamp: string;
|
|
22
|
+
/** Thread info ("main" or "background") */
|
|
23
|
+
readonly threadInfo: string;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Create an error context from the current call site.
|
|
28
|
+
* Note: In JavaScript, we can only capture stack traces, not file/line/function directly.
|
|
29
|
+
*/
|
|
30
|
+
export function createErrorContext(error?: Error): ErrorContext {
|
|
31
|
+
const now = new Date().toISOString();
|
|
32
|
+
const stackTrace = parseStackTrace(error?.stack ?? new Error().stack ?? '');
|
|
33
|
+
|
|
34
|
+
// Extract location from first relevant stack frame
|
|
35
|
+
const location = extractLocationFromStack(stackTrace);
|
|
36
|
+
|
|
37
|
+
return {
|
|
38
|
+
stackTrace,
|
|
39
|
+
file: location.file,
|
|
40
|
+
line: location.line,
|
|
41
|
+
function: location.function,
|
|
42
|
+
timestamp: now,
|
|
43
|
+
threadInfo: 'main', // JS is single-threaded (main thread)
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Parse a stack trace string into an array of frames.
|
|
49
|
+
*/
|
|
50
|
+
function parseStackTrace(stack: string): string[] {
|
|
51
|
+
const lines = stack.split('\n');
|
|
52
|
+
|
|
53
|
+
return lines
|
|
54
|
+
.slice(1) // Skip "Error: message" line
|
|
55
|
+
.map((line) => line.trim())
|
|
56
|
+
.filter((line) => line.length > 0)
|
|
57
|
+
.filter((line) => !isSystemFrame(line))
|
|
58
|
+
.slice(0, 15); // Limit to 15 frames like iOS
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Check if a stack frame is a system/internal frame that should be filtered.
|
|
63
|
+
*/
|
|
64
|
+
function isSystemFrame(frame: string): boolean {
|
|
65
|
+
const systemPatterns = [
|
|
66
|
+
'node_modules',
|
|
67
|
+
'internal/',
|
|
68
|
+
'__webpack',
|
|
69
|
+
'regenerator',
|
|
70
|
+
'asyncToGenerator',
|
|
71
|
+
'createErrorContext', // Filter ourselves out
|
|
72
|
+
'parseStackTrace',
|
|
73
|
+
];
|
|
74
|
+
|
|
75
|
+
return systemPatterns.some((pattern) => frame.includes(pattern));
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Extract file, line, and function from the first relevant stack frame.
|
|
80
|
+
*/
|
|
81
|
+
function extractLocationFromStack(stackTrace: string[]): {
|
|
82
|
+
file: string;
|
|
83
|
+
line: number;
|
|
84
|
+
function: string;
|
|
85
|
+
} {
|
|
86
|
+
if (stackTrace.length === 0) {
|
|
87
|
+
return { file: 'unknown', line: 0, function: 'unknown' };
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const firstFrame = stackTrace[0];
|
|
91
|
+
|
|
92
|
+
// Try to parse "at functionName (file:line:column)" format
|
|
93
|
+
const atMatch = firstFrame.match(/at\s+(.+?)\s+\((.+?):(\d+):(\d+)\)/);
|
|
94
|
+
if (atMatch) {
|
|
95
|
+
return {
|
|
96
|
+
function: atMatch[1],
|
|
97
|
+
file: atMatch[2],
|
|
98
|
+
line: parseInt(atMatch[3], 10),
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// Try to parse "at file:line:column" format (anonymous function)
|
|
103
|
+
const atFileMatch = firstFrame.match(/at\s+(.+?):(\d+):(\d+)/);
|
|
104
|
+
if (atFileMatch) {
|
|
105
|
+
return {
|
|
106
|
+
function: 'anonymous',
|
|
107
|
+
file: atFileMatch[1],
|
|
108
|
+
line: parseInt(atFileMatch[2], 10),
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// Try to parse "functionName@file:line:column" format (Safari/Firefox)
|
|
113
|
+
const atSignMatch = firstFrame.match(/(.+?)@(.+?):(\d+):(\d+)/);
|
|
114
|
+
if (atSignMatch) {
|
|
115
|
+
return {
|
|
116
|
+
function: atSignMatch[1] || 'anonymous',
|
|
117
|
+
file: atSignMatch[2],
|
|
118
|
+
line: parseInt(atSignMatch[3], 10),
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
return { file: 'unknown', line: 0, function: 'unknown' };
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Format the stack trace as a readable string.
|
|
127
|
+
*/
|
|
128
|
+
export function formatStackTrace(context: ErrorContext): string {
|
|
129
|
+
if (context.stackTrace.length === 0) {
|
|
130
|
+
return 'No stack trace available';
|
|
131
|
+
}
|
|
132
|
+
return context.stackTrace.join('\n');
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Get a formatted location string (file:line in function).
|
|
137
|
+
*/
|
|
138
|
+
export function formatLocation(context: ErrorContext): string {
|
|
139
|
+
return `${context.file}:${context.line} in ${context.function}`;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Get a complete formatted context string for logging.
|
|
144
|
+
*/
|
|
145
|
+
export function formatContext(context: ErrorContext): string {
|
|
146
|
+
return [
|
|
147
|
+
`Time: ${context.timestamp}`,
|
|
148
|
+
`Thread: ${context.threadInfo}`,
|
|
149
|
+
`Location: ${formatLocation(context)}`,
|
|
150
|
+
`Stack Trace:`,
|
|
151
|
+
formatStackTrace(context),
|
|
152
|
+
].join('\n');
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* An error wrapper that includes context information.
|
|
157
|
+
*/
|
|
158
|
+
export class ContextualError extends Error {
|
|
159
|
+
readonly context: ErrorContext;
|
|
160
|
+
readonly originalError: Error;
|
|
161
|
+
|
|
162
|
+
constructor(error: Error, context?: ErrorContext) {
|
|
163
|
+
super(error.message);
|
|
164
|
+
this.name = 'ContextualError';
|
|
165
|
+
this.originalError = error;
|
|
166
|
+
this.context = context ?? createErrorContext(error);
|
|
167
|
+
|
|
168
|
+
// Maintain proper prototype chain
|
|
169
|
+
Object.setPrototypeOf(this, ContextualError.prototype);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Wrap an error with context information.
|
|
175
|
+
*/
|
|
176
|
+
export function withContext(error: Error): ContextualError {
|
|
177
|
+
if (error instanceof ContextualError) {
|
|
178
|
+
return error; // Already has context
|
|
179
|
+
}
|
|
180
|
+
return new ContextualError(error);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Extract error context from an error if available.
|
|
185
|
+
*/
|
|
186
|
+
export function getErrorContext(error: Error): ErrorContext | undefined {
|
|
187
|
+
if (error instanceof ContextualError) {
|
|
188
|
+
return error.context;
|
|
189
|
+
}
|
|
190
|
+
return undefined;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Get the underlying error value, unwrapping ContextualError if needed.
|
|
195
|
+
*/
|
|
196
|
+
export function getUnderlyingError(error: Error): Error {
|
|
197
|
+
if (error instanceof ContextualError) {
|
|
198
|
+
return error.originalError;
|
|
199
|
+
}
|
|
200
|
+
return error;
|
|
201
|
+
}
|
|
@@ -0,0 +1,507 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SDKError.ts
|
|
3
|
+
*
|
|
4
|
+
* Base SDK error class matching iOS SDKErrorProtocol.
|
|
5
|
+
* Matches iOS SDK: Foundation/ErrorTypes/SDKErrorProtocol.swift
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { ErrorCode, getErrorCodeMessage } from './ErrorCodes';
|
|
9
|
+
import {
|
|
10
|
+
ErrorCategory,
|
|
11
|
+
getCategoryFromCode,
|
|
12
|
+
inferCategoryFromError,
|
|
13
|
+
} from './ErrorCategory';
|
|
14
|
+
import type { ErrorContext } from './ErrorContext';
|
|
15
|
+
import {
|
|
16
|
+
createErrorContext,
|
|
17
|
+
formatContext,
|
|
18
|
+
formatLocation,
|
|
19
|
+
} from './ErrorContext';
|
|
20
|
+
import { SDKLogger, LogLevel } from '../Logging';
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Legacy SDK error code enum (string-based).
|
|
24
|
+
* @deprecated Prefer using ErrorCode (numeric) for new code.
|
|
25
|
+
*/
|
|
26
|
+
export enum SDKErrorCode {
|
|
27
|
+
NotInitialized = 'notInitialized',
|
|
28
|
+
NotImplemented = 'notImplemented',
|
|
29
|
+
InvalidAPIKey = 'invalidAPIKey',
|
|
30
|
+
ModelNotFound = 'modelNotFound',
|
|
31
|
+
LoadingFailed = 'loadingFailed',
|
|
32
|
+
ModelLoadFailed = 'modelLoadFailed',
|
|
33
|
+
GenerationFailed = 'generationFailed',
|
|
34
|
+
GenerationTimeout = 'generationTimeout',
|
|
35
|
+
FrameworkNotAvailable = 'frameworkNotAvailable',
|
|
36
|
+
FeatureNotAvailable = 'featureNotAvailable',
|
|
37
|
+
DownloadFailed = 'downloadFailed',
|
|
38
|
+
ValidationFailed = 'validationFailed',
|
|
39
|
+
RoutingFailed = 'routingFailed',
|
|
40
|
+
DatabaseInitializationFailed = 'databaseInitializationFailed',
|
|
41
|
+
UnsupportedModality = 'unsupportedModality',
|
|
42
|
+
InvalidResponse = 'invalidResponse',
|
|
43
|
+
AuthenticationFailed = 'authenticationFailed',
|
|
44
|
+
NetworkError = 'networkError',
|
|
45
|
+
InvalidState = 'invalidState',
|
|
46
|
+
ComponentNotInitialized = 'componentNotInitialized',
|
|
47
|
+
ComponentNotReady = 'componentNotReady',
|
|
48
|
+
CleanupFailed = 'cleanupFailed',
|
|
49
|
+
ProcessingFailed = 'processingFailed',
|
|
50
|
+
Timeout = 'timeout',
|
|
51
|
+
ServerError = 'serverError',
|
|
52
|
+
StorageError = 'storageError',
|
|
53
|
+
InvalidConfiguration = 'invalidConfiguration',
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Map legacy string-based SDKErrorCode to numeric ErrorCode
|
|
58
|
+
*/
|
|
59
|
+
function mapLegacyCodeToErrorCode(code: SDKErrorCode): ErrorCode {
|
|
60
|
+
switch (code) {
|
|
61
|
+
case SDKErrorCode.NotInitialized:
|
|
62
|
+
return ErrorCode.NotInitialized;
|
|
63
|
+
case SDKErrorCode.NotImplemented:
|
|
64
|
+
return ErrorCode.Unknown;
|
|
65
|
+
case SDKErrorCode.InvalidAPIKey:
|
|
66
|
+
return ErrorCode.ApiKeyInvalid;
|
|
67
|
+
case SDKErrorCode.ModelNotFound:
|
|
68
|
+
return ErrorCode.ModelNotFound;
|
|
69
|
+
case SDKErrorCode.LoadingFailed:
|
|
70
|
+
case SDKErrorCode.ModelLoadFailed:
|
|
71
|
+
return ErrorCode.ModelLoadFailed;
|
|
72
|
+
case SDKErrorCode.GenerationFailed:
|
|
73
|
+
return ErrorCode.GenerationFailed;
|
|
74
|
+
case SDKErrorCode.GenerationTimeout:
|
|
75
|
+
return ErrorCode.GenerationTimeout;
|
|
76
|
+
case SDKErrorCode.FrameworkNotAvailable:
|
|
77
|
+
case SDKErrorCode.FeatureNotAvailable:
|
|
78
|
+
return ErrorCode.HardwareUnavailable;
|
|
79
|
+
case SDKErrorCode.DownloadFailed:
|
|
80
|
+
return ErrorCode.DownloadFailed;
|
|
81
|
+
case SDKErrorCode.ValidationFailed:
|
|
82
|
+
case SDKErrorCode.InvalidConfiguration:
|
|
83
|
+
return ErrorCode.InvalidInput;
|
|
84
|
+
case SDKErrorCode.RoutingFailed:
|
|
85
|
+
return ErrorCode.Unknown;
|
|
86
|
+
case SDKErrorCode.DatabaseInitializationFailed:
|
|
87
|
+
return ErrorCode.Unknown;
|
|
88
|
+
case SDKErrorCode.UnsupportedModality:
|
|
89
|
+
return ErrorCode.InvalidInput;
|
|
90
|
+
case SDKErrorCode.InvalidResponse:
|
|
91
|
+
return ErrorCode.ApiError;
|
|
92
|
+
case SDKErrorCode.AuthenticationFailed:
|
|
93
|
+
return ErrorCode.AuthenticationFailed;
|
|
94
|
+
case SDKErrorCode.NetworkError:
|
|
95
|
+
return ErrorCode.NetworkUnavailable;
|
|
96
|
+
case SDKErrorCode.InvalidState:
|
|
97
|
+
case SDKErrorCode.ComponentNotInitialized:
|
|
98
|
+
case SDKErrorCode.ComponentNotReady:
|
|
99
|
+
return ErrorCode.NotInitialized;
|
|
100
|
+
case SDKErrorCode.CleanupFailed:
|
|
101
|
+
return ErrorCode.Unknown;
|
|
102
|
+
case SDKErrorCode.ProcessingFailed:
|
|
103
|
+
return ErrorCode.GenerationFailed;
|
|
104
|
+
case SDKErrorCode.Timeout:
|
|
105
|
+
return ErrorCode.NetworkTimeout;
|
|
106
|
+
case SDKErrorCode.ServerError:
|
|
107
|
+
return ErrorCode.ApiError;
|
|
108
|
+
case SDKErrorCode.StorageError:
|
|
109
|
+
return ErrorCode.FileAccessDenied;
|
|
110
|
+
default:
|
|
111
|
+
return ErrorCode.Unknown;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Base SDK error interface matching iOS SDKErrorProtocol.
|
|
117
|
+
*/
|
|
118
|
+
export interface SDKErrorProtocol {
|
|
119
|
+
/** Machine-readable error code */
|
|
120
|
+
readonly code: ErrorCode;
|
|
121
|
+
/** Error category for filtering/analytics */
|
|
122
|
+
readonly category: ErrorCategory;
|
|
123
|
+
/** Original error that caused this error */
|
|
124
|
+
readonly underlyingError?: Error;
|
|
125
|
+
/** Error context with stack trace and location */
|
|
126
|
+
readonly context: ErrorContext;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Unified SDK error class.
|
|
131
|
+
*
|
|
132
|
+
* Supports both legacy string-based codes (SDKErrorCode) and
|
|
133
|
+
* new numeric codes (ErrorCode) for backwards compatibility.
|
|
134
|
+
*
|
|
135
|
+
* @example
|
|
136
|
+
* // Legacy usage (still works):
|
|
137
|
+
* throw new SDKError(SDKErrorCode.NotInitialized, 'SDK not ready');
|
|
138
|
+
*
|
|
139
|
+
* // New recommended usage:
|
|
140
|
+
* throw new SDKError(ErrorCode.NotInitialized, 'SDK not ready');
|
|
141
|
+
*/
|
|
142
|
+
export class SDKError extends Error implements SDKErrorProtocol {
|
|
143
|
+
readonly code: ErrorCode;
|
|
144
|
+
readonly legacyCode?: SDKErrorCode;
|
|
145
|
+
readonly category: ErrorCategory;
|
|
146
|
+
readonly underlyingError?: Error;
|
|
147
|
+
readonly context: ErrorContext;
|
|
148
|
+
readonly details?: Record<string, unknown>;
|
|
149
|
+
|
|
150
|
+
constructor(
|
|
151
|
+
code: ErrorCode | SDKErrorCode,
|
|
152
|
+
message?: string,
|
|
153
|
+
options?: {
|
|
154
|
+
underlyingError?: Error;
|
|
155
|
+
category?: ErrorCategory;
|
|
156
|
+
details?: Record<string, unknown>;
|
|
157
|
+
}
|
|
158
|
+
) {
|
|
159
|
+
// Determine if we're using legacy string code or new numeric code
|
|
160
|
+
const isLegacyCode = typeof code === 'string';
|
|
161
|
+
const numericCode = isLegacyCode
|
|
162
|
+
? mapLegacyCodeToErrorCode(code as SDKErrorCode)
|
|
163
|
+
: (code as ErrorCode);
|
|
164
|
+
const errorMessage = message ?? getErrorCodeMessage(numericCode);
|
|
165
|
+
|
|
166
|
+
super(errorMessage);
|
|
167
|
+
|
|
168
|
+
this.name = 'SDKError';
|
|
169
|
+
this.code = numericCode;
|
|
170
|
+
this.legacyCode = isLegacyCode ? (code as SDKErrorCode) : undefined;
|
|
171
|
+
this.category = options?.category ?? getCategoryFromCode(numericCode);
|
|
172
|
+
this.underlyingError = options?.underlyingError;
|
|
173
|
+
this.context = createErrorContext(options?.underlyingError ?? this);
|
|
174
|
+
this.details = options?.details;
|
|
175
|
+
|
|
176
|
+
// Maintain proper prototype chain
|
|
177
|
+
Object.setPrototypeOf(this, SDKError.prototype);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* Convert error to analytics data for event tracking.
|
|
182
|
+
*/
|
|
183
|
+
toAnalyticsData(): Record<string, unknown> {
|
|
184
|
+
return {
|
|
185
|
+
error_code: this.code,
|
|
186
|
+
error_code_name: ErrorCode[this.code],
|
|
187
|
+
legacy_code: this.legacyCode,
|
|
188
|
+
error_category: this.category,
|
|
189
|
+
error_message: this.message,
|
|
190
|
+
error_location: formatLocation(this.context),
|
|
191
|
+
error_timestamp: this.context.timestamp,
|
|
192
|
+
has_underlying_error: this.underlyingError !== undefined,
|
|
193
|
+
underlying_error_name: this.underlyingError?.name,
|
|
194
|
+
underlying_error_message: this.underlyingError?.message,
|
|
195
|
+
...this.details,
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Log error with full context using SDKLogger.
|
|
201
|
+
*/
|
|
202
|
+
logError(): void {
|
|
203
|
+
const logger = new SDKLogger('SDKError');
|
|
204
|
+
const metadata: Record<string, unknown> = {
|
|
205
|
+
error_code: this.code,
|
|
206
|
+
error_code_name: ErrorCode[this.code],
|
|
207
|
+
category: this.category,
|
|
208
|
+
context: formatContext(this.context),
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
if (this.underlyingError) {
|
|
212
|
+
metadata.underlying_error = this.underlyingError.message;
|
|
213
|
+
metadata.underlying_stack = this.underlyingError.stack;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
logger.log(LogLevel.Error, `${ErrorCode[this.code]}: ${this.message}`, metadata);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* Convert any error to an SDKError.
|
|
222
|
+
* If already an SDKError, returns as-is.
|
|
223
|
+
* Otherwise, wraps with appropriate categorization.
|
|
224
|
+
*/
|
|
225
|
+
export function asSDKError(error: Error): SDKError {
|
|
226
|
+
if (error instanceof SDKError) {
|
|
227
|
+
return error;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
const category = inferCategoryFromError(error);
|
|
231
|
+
const code = mapCategoryToCode(category);
|
|
232
|
+
|
|
233
|
+
return new SDKError(code, error.message, {
|
|
234
|
+
underlyingError: error,
|
|
235
|
+
category,
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* Map an error category to a default error code.
|
|
241
|
+
*/
|
|
242
|
+
function mapCategoryToCode(category: ErrorCategory): ErrorCode {
|
|
243
|
+
switch (category) {
|
|
244
|
+
case ErrorCategory.Initialization:
|
|
245
|
+
return ErrorCode.NotInitialized;
|
|
246
|
+
case ErrorCategory.Model:
|
|
247
|
+
return ErrorCode.ModelLoadFailed;
|
|
248
|
+
case ErrorCategory.Generation:
|
|
249
|
+
return ErrorCode.GenerationFailed;
|
|
250
|
+
case ErrorCategory.Network:
|
|
251
|
+
return ErrorCode.NetworkUnavailable;
|
|
252
|
+
case ErrorCategory.Storage:
|
|
253
|
+
return ErrorCode.FileNotFound;
|
|
254
|
+
case ErrorCategory.Memory:
|
|
255
|
+
return ErrorCode.HardwareUnavailable;
|
|
256
|
+
case ErrorCategory.Hardware:
|
|
257
|
+
return ErrorCode.HardwareUnsupported;
|
|
258
|
+
case ErrorCategory.Validation:
|
|
259
|
+
return ErrorCode.InvalidInput;
|
|
260
|
+
case ErrorCategory.Authentication:
|
|
261
|
+
return ErrorCode.AuthenticationFailed;
|
|
262
|
+
case ErrorCategory.Component:
|
|
263
|
+
return ErrorCode.Unknown;
|
|
264
|
+
case ErrorCategory.Framework:
|
|
265
|
+
return ErrorCode.Unknown;
|
|
266
|
+
case ErrorCategory.Unknown:
|
|
267
|
+
default:
|
|
268
|
+
return ErrorCode.Unknown;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* Type guard to check if an error is an SDKError.
|
|
274
|
+
*/
|
|
275
|
+
export function isSDKError(error: unknown): error is SDKError {
|
|
276
|
+
return error instanceof SDKError;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* Create and throw an SDKError, capturing context at the call site.
|
|
281
|
+
* Useful for wrapping errors with automatic context capture.
|
|
282
|
+
*/
|
|
283
|
+
export function captureAndThrow(
|
|
284
|
+
code: ErrorCode,
|
|
285
|
+
message?: string,
|
|
286
|
+
underlyingError?: Error
|
|
287
|
+
): never {
|
|
288
|
+
throw new SDKError(code, message, { underlyingError });
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
// Convenience factory functions for common error types
|
|
292
|
+
|
|
293
|
+
export function notInitializedError(component?: string): SDKError {
|
|
294
|
+
const message = component
|
|
295
|
+
? `${component} not initialized`
|
|
296
|
+
: 'SDK not initialized';
|
|
297
|
+
return new SDKError(ErrorCode.NotInitialized, message);
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
export function alreadyInitializedError(component?: string): SDKError {
|
|
301
|
+
const message = component
|
|
302
|
+
? `${component} already initialized`
|
|
303
|
+
: 'SDK already initialized';
|
|
304
|
+
return new SDKError(ErrorCode.AlreadyInitialized, message);
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
export function invalidInputError(details?: string): SDKError {
|
|
308
|
+
const message = details ? `Invalid input: ${details}` : 'Invalid input';
|
|
309
|
+
return new SDKError(ErrorCode.InvalidInput, message);
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
export function modelNotFoundError(modelId?: string): SDKError {
|
|
313
|
+
const message = modelId ? `Model not found: ${modelId}` : 'Model not found';
|
|
314
|
+
return new SDKError(ErrorCode.ModelNotFound, message);
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
export function modelLoadError(modelId?: string, cause?: Error): SDKError {
|
|
318
|
+
const message = modelId
|
|
319
|
+
? `Failed to load model: ${modelId}`
|
|
320
|
+
: 'Failed to load model';
|
|
321
|
+
return new SDKError(ErrorCode.ModelLoadFailed, message, {
|
|
322
|
+
underlyingError: cause,
|
|
323
|
+
});
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
export function networkError(details?: string, cause?: Error): SDKError {
|
|
327
|
+
const message = details ?? 'Network error';
|
|
328
|
+
return new SDKError(ErrorCode.NetworkUnavailable, message, {
|
|
329
|
+
underlyingError: cause,
|
|
330
|
+
});
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
export function authenticationError(details?: string): SDKError {
|
|
334
|
+
const message = details ?? 'Authentication failed';
|
|
335
|
+
return new SDKError(ErrorCode.AuthenticationFailed, message);
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
export function generationError(details?: string, cause?: Error): SDKError {
|
|
339
|
+
const message = details ?? 'Generation failed';
|
|
340
|
+
return new SDKError(ErrorCode.GenerationFailed, message, {
|
|
341
|
+
underlyingError: cause,
|
|
342
|
+
});
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
export function storageError(details?: string, cause?: Error): SDKError {
|
|
346
|
+
const message = details ?? 'Storage error';
|
|
347
|
+
return new SDKError(ErrorCode.FileNotFound, message, {
|
|
348
|
+
underlyingError: cause,
|
|
349
|
+
});
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
// ============================================================================
|
|
353
|
+
// Native Error Wrapping
|
|
354
|
+
// ============================================================================
|
|
355
|
+
|
|
356
|
+
/**
|
|
357
|
+
* Native error structure from Nitro/React Native bridge.
|
|
358
|
+
* Native modules typically return errors as JSON with these fields.
|
|
359
|
+
*/
|
|
360
|
+
export interface NativeErrorData {
|
|
361
|
+
/** Error code (may be string or number) */
|
|
362
|
+
code?: string | number;
|
|
363
|
+
/** Error message */
|
|
364
|
+
message?: string;
|
|
365
|
+
/** Domain (iOS) or exception type (Android) */
|
|
366
|
+
domain?: string;
|
|
367
|
+
/** User info dictionary (iOS) */
|
|
368
|
+
userInfo?: Record<string, unknown>;
|
|
369
|
+
/** Native stack trace */
|
|
370
|
+
nativeStackTrace?: string;
|
|
371
|
+
/** Additional details */
|
|
372
|
+
details?: Record<string, unknown>;
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
/**
|
|
376
|
+
* Parse and wrap a native error from JSON-based error data.
|
|
377
|
+
*
|
|
378
|
+
* Native modules (via Nitro) often return errors as JSON strings or objects.
|
|
379
|
+
* This function converts them to proper SDKError instances with full context.
|
|
380
|
+
*
|
|
381
|
+
* Matches iOS pattern where native errors are wrapped with proper categorization.
|
|
382
|
+
*
|
|
383
|
+
* @param nativeError - Native error data (string, object, or Error)
|
|
384
|
+
* @returns SDKError with proper wrapping
|
|
385
|
+
*
|
|
386
|
+
* @example
|
|
387
|
+
* ```typescript
|
|
388
|
+
* try {
|
|
389
|
+
* const result = await nativeModule.someMethod();
|
|
390
|
+
* } catch (error) {
|
|
391
|
+
* throw fromNativeError(error);
|
|
392
|
+
* }
|
|
393
|
+
* ```
|
|
394
|
+
*/
|
|
395
|
+
export function fromNativeError(nativeError: unknown): SDKError {
|
|
396
|
+
// Already an SDKError - return as-is
|
|
397
|
+
if (nativeError instanceof SDKError) {
|
|
398
|
+
return nativeError;
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
// Standard Error - wrap it
|
|
402
|
+
if (nativeError instanceof Error) {
|
|
403
|
+
return asSDKError(nativeError);
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
// Try to parse as JSON string
|
|
407
|
+
if (typeof nativeError === 'string') {
|
|
408
|
+
try {
|
|
409
|
+
const parsed = JSON.parse(nativeError);
|
|
410
|
+
return parseNativeErrorData(parsed);
|
|
411
|
+
} catch {
|
|
412
|
+
// Not JSON, treat as error message
|
|
413
|
+
return new SDKError(ErrorCode.Unknown, nativeError);
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
// Object with error data
|
|
418
|
+
if (typeof nativeError === 'object' && nativeError !== null) {
|
|
419
|
+
return parseNativeErrorData(nativeError as NativeErrorData);
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
// Unknown type - create generic error
|
|
423
|
+
return new SDKError(ErrorCode.Unknown, String(nativeError));
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
/**
|
|
427
|
+
* Parse native error data object into SDKError.
|
|
428
|
+
*/
|
|
429
|
+
function parseNativeErrorData(data: NativeErrorData): SDKError {
|
|
430
|
+
// Extract error code
|
|
431
|
+
let code = ErrorCode.Unknown;
|
|
432
|
+
if (typeof data.code === 'number') {
|
|
433
|
+
code = data.code in ErrorCode ? data.code : ErrorCode.Unknown;
|
|
434
|
+
} else if (typeof data.code === 'string') {
|
|
435
|
+
// Try to map string code to ErrorCode
|
|
436
|
+
code = mapNativeCodeString(data.code);
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
// Build message
|
|
440
|
+
const message = data.message ?? 'Native error';
|
|
441
|
+
|
|
442
|
+
// Create underlying error with native stack trace
|
|
443
|
+
let underlyingError: Error | undefined;
|
|
444
|
+
if (data.nativeStackTrace) {
|
|
445
|
+
const nativeErr = new Error(message);
|
|
446
|
+
nativeErr.stack = data.nativeStackTrace;
|
|
447
|
+
nativeErr.name = data.domain ?? 'NativeError';
|
|
448
|
+
underlyingError = nativeErr;
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
return new SDKError(code, message, {
|
|
452
|
+
underlyingError,
|
|
453
|
+
details: {
|
|
454
|
+
nativeDomain: data.domain,
|
|
455
|
+
nativeUserInfo: data.userInfo,
|
|
456
|
+
...data.details,
|
|
457
|
+
},
|
|
458
|
+
});
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
/**
|
|
462
|
+
* Map native code strings to ErrorCode.
|
|
463
|
+
* Native modules may use various string identifiers.
|
|
464
|
+
*/
|
|
465
|
+
function mapNativeCodeString(codeString: string): ErrorCode {
|
|
466
|
+
const normalized = codeString.toLowerCase().replace(/[_-]/g, '');
|
|
467
|
+
|
|
468
|
+
// Common native error patterns
|
|
469
|
+
if (normalized.includes('notinitialized') || normalized.includes('notinit')) {
|
|
470
|
+
return ErrorCode.NotInitialized;
|
|
471
|
+
}
|
|
472
|
+
if (normalized.includes('modelload') || normalized.includes('loadfail')) {
|
|
473
|
+
return ErrorCode.ModelLoadFailed;
|
|
474
|
+
}
|
|
475
|
+
if (normalized.includes('modelnotfound')) {
|
|
476
|
+
return ErrorCode.ModelNotFound;
|
|
477
|
+
}
|
|
478
|
+
if (normalized.includes('generation') || normalized.includes('inference')) {
|
|
479
|
+
return ErrorCode.GenerationFailed;
|
|
480
|
+
}
|
|
481
|
+
if (normalized.includes('network') || normalized.includes('connection')) {
|
|
482
|
+
return ErrorCode.NetworkUnavailable;
|
|
483
|
+
}
|
|
484
|
+
if (normalized.includes('auth') || normalized.includes('unauthorized')) {
|
|
485
|
+
return ErrorCode.AuthenticationFailed;
|
|
486
|
+
}
|
|
487
|
+
if (normalized.includes('timeout')) {
|
|
488
|
+
return ErrorCode.NetworkTimeout;
|
|
489
|
+
}
|
|
490
|
+
if (normalized.includes('memory') || normalized.includes('oom')) {
|
|
491
|
+
return ErrorCode.HardwareUnavailable;
|
|
492
|
+
}
|
|
493
|
+
if (normalized.includes('file') || normalized.includes('storage')) {
|
|
494
|
+
return ErrorCode.FileNotFound;
|
|
495
|
+
}
|
|
496
|
+
if (normalized.includes('invalid') || normalized.includes('validation')) {
|
|
497
|
+
return ErrorCode.InvalidInput;
|
|
498
|
+
}
|
|
499
|
+
if (normalized.includes('download')) {
|
|
500
|
+
return ErrorCode.DownloadFailed;
|
|
501
|
+
}
|
|
502
|
+
if (normalized.includes('cancelled') || normalized.includes('canceled')) {
|
|
503
|
+
return ErrorCode.OperationCancelled;
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
return ErrorCode.Unknown;
|
|
507
|
+
}
|