@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,234 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file rac_telemetry_types.h
|
|
3
|
+
* @brief Telemetry data structures - canonical source of truth
|
|
4
|
+
*
|
|
5
|
+
* All telemetry payloads are defined here. Platform SDKs (Swift, Kotlin, Flutter)
|
|
6
|
+
* use these types directly or create thin wrappers.
|
|
7
|
+
*
|
|
8
|
+
* Mirrors Swift's TelemetryEventPayload.swift structure.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
#ifndef RAC_TELEMETRY_TYPES_H
|
|
12
|
+
#define RAC_TELEMETRY_TYPES_H
|
|
13
|
+
|
|
14
|
+
#include "rac/core/rac_types.h"
|
|
15
|
+
#include "rac/infrastructure/network/rac_environment.h"
|
|
16
|
+
|
|
17
|
+
#ifdef __cplusplus
|
|
18
|
+
extern "C" {
|
|
19
|
+
#endif
|
|
20
|
+
|
|
21
|
+
// =============================================================================
|
|
22
|
+
// TELEMETRY EVENT PAYLOAD
|
|
23
|
+
// =============================================================================
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* @brief Complete telemetry event payload
|
|
27
|
+
*
|
|
28
|
+
* Maps to backend SDKTelemetryEvent schema with all fields for:
|
|
29
|
+
* - LLM events (tokens, generation times, etc.)
|
|
30
|
+
* - STT events (audio duration, word count, etc.)
|
|
31
|
+
* - TTS events (character count, audio size, etc.)
|
|
32
|
+
* - VAD events (speech duration)
|
|
33
|
+
* - Model lifecycle events (size, archive type)
|
|
34
|
+
* - SDK lifecycle events (count)
|
|
35
|
+
* - Storage events (freed bytes)
|
|
36
|
+
* - Network events (online status)
|
|
37
|
+
*/
|
|
38
|
+
typedef struct rac_telemetry_payload {
|
|
39
|
+
// Required fields
|
|
40
|
+
const char* id; // Unique event ID (UUID)
|
|
41
|
+
const char* event_type; // Event type string
|
|
42
|
+
int64_t timestamp_ms; // Unix timestamp in milliseconds
|
|
43
|
+
int64_t created_at_ms; // When payload was created
|
|
44
|
+
|
|
45
|
+
// Event classification
|
|
46
|
+
const char* modality; // "llm", "stt", "tts", "model", "system"
|
|
47
|
+
|
|
48
|
+
// Device identification
|
|
49
|
+
const char* device_id; // Persistent device UUID
|
|
50
|
+
const char* session_id; // Optional session ID
|
|
51
|
+
|
|
52
|
+
// Model info
|
|
53
|
+
const char* model_id;
|
|
54
|
+
const char* model_name;
|
|
55
|
+
const char* framework; // "llamacpp", "onnx", "mlx", etc.
|
|
56
|
+
|
|
57
|
+
// Device info
|
|
58
|
+
const char* device; // Device model (e.g., "iPhone15,2")
|
|
59
|
+
const char* os_version; // OS version (e.g., "17.0")
|
|
60
|
+
const char* platform; // "ios", "android", "flutter"
|
|
61
|
+
const char* sdk_version; // SDK version string
|
|
62
|
+
|
|
63
|
+
// Common performance metrics
|
|
64
|
+
double processing_time_ms;
|
|
65
|
+
rac_bool_t success;
|
|
66
|
+
rac_bool_t has_success; // Whether success field is set
|
|
67
|
+
const char* error_message;
|
|
68
|
+
const char* error_code;
|
|
69
|
+
|
|
70
|
+
// LLM-specific fields
|
|
71
|
+
int32_t input_tokens;
|
|
72
|
+
int32_t output_tokens;
|
|
73
|
+
int32_t total_tokens;
|
|
74
|
+
double tokens_per_second;
|
|
75
|
+
double time_to_first_token_ms;
|
|
76
|
+
double prompt_eval_time_ms;
|
|
77
|
+
double generation_time_ms;
|
|
78
|
+
int32_t context_length;
|
|
79
|
+
double temperature;
|
|
80
|
+
int32_t max_tokens;
|
|
81
|
+
|
|
82
|
+
// STT-specific fields
|
|
83
|
+
double audio_duration_ms;
|
|
84
|
+
double real_time_factor;
|
|
85
|
+
int32_t word_count;
|
|
86
|
+
double confidence;
|
|
87
|
+
const char* language;
|
|
88
|
+
rac_bool_t is_streaming;
|
|
89
|
+
rac_bool_t has_is_streaming;
|
|
90
|
+
int32_t segment_index;
|
|
91
|
+
|
|
92
|
+
// TTS-specific fields
|
|
93
|
+
int32_t character_count;
|
|
94
|
+
double characters_per_second;
|
|
95
|
+
int32_t audio_size_bytes;
|
|
96
|
+
int32_t sample_rate;
|
|
97
|
+
const char* voice;
|
|
98
|
+
double output_duration_ms;
|
|
99
|
+
|
|
100
|
+
// Model lifecycle fields
|
|
101
|
+
int64_t model_size_bytes;
|
|
102
|
+
const char* archive_type;
|
|
103
|
+
|
|
104
|
+
// VAD fields
|
|
105
|
+
double speech_duration_ms;
|
|
106
|
+
|
|
107
|
+
// SDK lifecycle fields
|
|
108
|
+
int32_t count;
|
|
109
|
+
|
|
110
|
+
// Storage fields
|
|
111
|
+
int64_t freed_bytes;
|
|
112
|
+
|
|
113
|
+
// Network fields
|
|
114
|
+
rac_bool_t is_online;
|
|
115
|
+
rac_bool_t has_is_online;
|
|
116
|
+
} rac_telemetry_payload_t;
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* @brief Default/empty telemetry payload
|
|
120
|
+
*/
|
|
121
|
+
RAC_API rac_telemetry_payload_t rac_telemetry_payload_default(void);
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* @brief Free any allocated strings in a telemetry payload
|
|
125
|
+
*/
|
|
126
|
+
RAC_API void rac_telemetry_payload_free(rac_telemetry_payload_t* payload);
|
|
127
|
+
|
|
128
|
+
// =============================================================================
|
|
129
|
+
// TELEMETRY BATCH REQUEST
|
|
130
|
+
// =============================================================================
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* @brief Batch telemetry request for API
|
|
134
|
+
*
|
|
135
|
+
* Supports both V1 and V2 storage paths:
|
|
136
|
+
* - V1 (legacy): modality = NULL → stores in sdk_telemetry_events table
|
|
137
|
+
* - V2 (normalized): modality = "llm"/"stt"/"tts"/"model" → normalized tables
|
|
138
|
+
*/
|
|
139
|
+
typedef struct rac_telemetry_batch_request {
|
|
140
|
+
rac_telemetry_payload_t* events;
|
|
141
|
+
size_t events_count;
|
|
142
|
+
const char* device_id;
|
|
143
|
+
int64_t timestamp_ms;
|
|
144
|
+
const char* modality; // NULL for V1, "llm"/"stt"/"tts"/"model" for V2
|
|
145
|
+
} rac_telemetry_batch_request_t;
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* @brief Batch telemetry response from API
|
|
149
|
+
*/
|
|
150
|
+
typedef struct rac_telemetry_batch_response {
|
|
151
|
+
rac_bool_t success;
|
|
152
|
+
int32_t events_received;
|
|
153
|
+
int32_t events_stored;
|
|
154
|
+
int32_t events_skipped; // Duplicates skipped
|
|
155
|
+
const char** errors; // Array of error messages
|
|
156
|
+
size_t errors_count;
|
|
157
|
+
const char* storage_version; // "V1" or "V2"
|
|
158
|
+
} rac_telemetry_batch_response_t;
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* @brief Free batch response
|
|
162
|
+
*/
|
|
163
|
+
RAC_API void rac_telemetry_batch_response_free(rac_telemetry_batch_response_t* response);
|
|
164
|
+
|
|
165
|
+
// =============================================================================
|
|
166
|
+
// DEVICE REGISTRATION TYPES
|
|
167
|
+
// =============================================================================
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* @brief Device information for registration (telemetry-specific)
|
|
171
|
+
*
|
|
172
|
+
* Platform-specific values are passed in from Swift/Kotlin.
|
|
173
|
+
* Matches backend schemas/device.py DeviceInfo schema.
|
|
174
|
+
* Note: Named differently from rac_device_info_t to avoid conflict.
|
|
175
|
+
*/
|
|
176
|
+
typedef struct rac_device_registration_info {
|
|
177
|
+
// Required fields (backend schema)
|
|
178
|
+
const char* device_id; // Persistent UUID from Keychain/secure storage
|
|
179
|
+
const char* device_model; // "iPhone 16 Pro Max", "Pixel 7", etc.
|
|
180
|
+
const char* device_name; // User-assigned device name
|
|
181
|
+
const char* platform; // "ios", "android"
|
|
182
|
+
const char* os_version; // "17.0", "14"
|
|
183
|
+
const char* form_factor; // "phone", "tablet", "laptop", etc.
|
|
184
|
+
const char* architecture; // "arm64", "x86_64", etc.
|
|
185
|
+
const char* chip_name; // "A18 Pro", "Snapdragon 888", etc.
|
|
186
|
+
int64_t total_memory; // Total RAM in bytes
|
|
187
|
+
int64_t available_memory; // Available RAM in bytes
|
|
188
|
+
rac_bool_t has_neural_engine; // true if device has Neural Engine / NPU
|
|
189
|
+
int32_t neural_engine_cores; // Number of Neural Engine cores (0 if none)
|
|
190
|
+
const char* gpu_family; // "apple", "adreno", etc.
|
|
191
|
+
double battery_level; // 0.0-1.0, negative if unavailable
|
|
192
|
+
const char* battery_state; // "charging", "full", "unplugged", NULL if unavailable
|
|
193
|
+
rac_bool_t is_low_power_mode; // Low power mode enabled
|
|
194
|
+
int32_t core_count; // Total CPU cores
|
|
195
|
+
int32_t performance_cores; // Performance (P) cores
|
|
196
|
+
int32_t efficiency_cores; // Efficiency (E) cores
|
|
197
|
+
const char* device_fingerprint; // Unique device fingerprint (may be same as device_id)
|
|
198
|
+
|
|
199
|
+
// Legacy fields (for backward compatibility)
|
|
200
|
+
const char* device_type; // "smartphone", "tablet", etc. (deprecated - use form_factor)
|
|
201
|
+
const char* os_name; // "iOS", "Android" (deprecated - use platform)
|
|
202
|
+
int64_t total_disk_bytes;
|
|
203
|
+
int64_t available_disk_bytes;
|
|
204
|
+
const char* processor_info;
|
|
205
|
+
int32_t processor_count; // Deprecated - use core_count
|
|
206
|
+
rac_bool_t is_simulator;
|
|
207
|
+
const char* locale;
|
|
208
|
+
const char* timezone;
|
|
209
|
+
} rac_device_registration_info_t;
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* @brief Device registration request
|
|
213
|
+
*/
|
|
214
|
+
typedef struct rac_device_registration_request {
|
|
215
|
+
rac_device_registration_info_t device_info;
|
|
216
|
+
const char* sdk_version;
|
|
217
|
+
const char* build_token; // For development mode
|
|
218
|
+
int64_t last_seen_at_ms;
|
|
219
|
+
} rac_device_registration_request_t;
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* @brief Device registration response
|
|
223
|
+
*/
|
|
224
|
+
typedef struct rac_device_registration_response {
|
|
225
|
+
const char* device_id;
|
|
226
|
+
const char* status; // "registered" or "updated"
|
|
227
|
+
const char* sync_status; // "synced" or "pending"
|
|
228
|
+
} rac_device_registration_response_t;
|
|
229
|
+
|
|
230
|
+
#ifdef __cplusplus
|
|
231
|
+
}
|
|
232
|
+
#endif
|
|
233
|
+
|
|
234
|
+
#endif // RAC_TELEMETRY_TYPES_H
|
|
@@ -0,0 +1,308 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ArchiveUtility.kt
|
|
3
|
+
*
|
|
4
|
+
* Native archive extraction utility for Android.
|
|
5
|
+
* Uses Apache Commons Compress for robust tar.gz extraction (streaming, memory-efficient).
|
|
6
|
+
* Uses Java's native ZipInputStream for zip extraction.
|
|
7
|
+
*
|
|
8
|
+
* Mirrors the implementation from:
|
|
9
|
+
* sdk/runanywhere-swift/Sources/RunAnywhere/Infrastructure/Download/Utilities/ArchiveUtility.swift
|
|
10
|
+
*
|
|
11
|
+
* Supports: tar.gz, zip
|
|
12
|
+
* Note: All models should use tar.gz from RunanywhereAI/sherpa-onnx fork for best performance
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
package com.margelo.nitro.runanywhere
|
|
16
|
+
|
|
17
|
+
import org.apache.commons.compress.archivers.tar.TarArchiveEntry
|
|
18
|
+
import org.apache.commons.compress.archivers.tar.TarArchiveInputStream
|
|
19
|
+
import org.apache.commons.compress.compressors.gzip.GzipCompressorInputStream
|
|
20
|
+
import java.io.BufferedInputStream
|
|
21
|
+
import java.io.File
|
|
22
|
+
import java.io.FileInputStream
|
|
23
|
+
import java.io.FileOutputStream
|
|
24
|
+
import java.util.zip.ZipInputStream
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Utility for handling archive extraction on Android
|
|
28
|
+
*/
|
|
29
|
+
object ArchiveUtility {
|
|
30
|
+
private val logger = SDKLogger.archive
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Extract an archive to a destination directory
|
|
34
|
+
* @param archivePath Path to the archive file
|
|
35
|
+
* @param destinationPath Destination directory path
|
|
36
|
+
* @return true if extraction succeeded
|
|
37
|
+
*/
|
|
38
|
+
@JvmStatic
|
|
39
|
+
fun extract(archivePath: String, destinationPath: String): Boolean {
|
|
40
|
+
logger.info("extract() called: $archivePath -> $destinationPath")
|
|
41
|
+
return try {
|
|
42
|
+
extractArchive(archivePath, destinationPath)
|
|
43
|
+
logger.info("extract() succeeded")
|
|
44
|
+
true
|
|
45
|
+
} catch (e: Exception) {
|
|
46
|
+
logger.logError(e, "Extraction failed")
|
|
47
|
+
false
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Extract an archive to a destination directory (throwing version)
|
|
53
|
+
*/
|
|
54
|
+
@Throws(Exception::class)
|
|
55
|
+
fun extractArchive(
|
|
56
|
+
archivePath: String,
|
|
57
|
+
destinationPath: String,
|
|
58
|
+
progressHandler: ((Double) -> Unit)? = null
|
|
59
|
+
) {
|
|
60
|
+
val archiveFile = File(archivePath)
|
|
61
|
+
val destinationDir = File(destinationPath)
|
|
62
|
+
|
|
63
|
+
if (!archiveFile.exists()) {
|
|
64
|
+
throw Exception("Archive not found: $archivePath")
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// Detect archive type by magic bytes (more reliable than file extension)
|
|
68
|
+
val archiveType = detectArchiveTypeByMagicBytes(archiveFile)
|
|
69
|
+
logger.info("Detected archive type: $archiveType for: $archivePath")
|
|
70
|
+
|
|
71
|
+
when (archiveType) {
|
|
72
|
+
ArchiveType.GZIP -> {
|
|
73
|
+
extractTarGz(archiveFile, destinationDir, progressHandler)
|
|
74
|
+
}
|
|
75
|
+
ArchiveType.ZIP -> {
|
|
76
|
+
extractZip(archiveFile, destinationDir, progressHandler)
|
|
77
|
+
}
|
|
78
|
+
ArchiveType.BZIP2 -> {
|
|
79
|
+
throw Exception("tar.bz2 not supported. Use tar.gz from RunanywhereAI/sherpa-onnx fork.")
|
|
80
|
+
}
|
|
81
|
+
ArchiveType.XZ -> {
|
|
82
|
+
throw Exception("tar.xz not supported. Use tar.gz from RunanywhereAI/sherpa-onnx fork.")
|
|
83
|
+
}
|
|
84
|
+
ArchiveType.UNKNOWN -> {
|
|
85
|
+
// Fallback to file extension check
|
|
86
|
+
val lowercased = archivePath.lowercase()
|
|
87
|
+
when {
|
|
88
|
+
lowercased.endsWith(".tar.gz") || lowercased.endsWith(".tgz") -> {
|
|
89
|
+
extractTarGz(archiveFile, destinationDir, progressHandler)
|
|
90
|
+
}
|
|
91
|
+
lowercased.endsWith(".zip") -> {
|
|
92
|
+
extractZip(archiveFile, destinationDir, progressHandler)
|
|
93
|
+
}
|
|
94
|
+
else -> {
|
|
95
|
+
throw Exception("Unknown archive format: $archivePath")
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Archive type detected by magic bytes
|
|
104
|
+
*/
|
|
105
|
+
private enum class ArchiveType {
|
|
106
|
+
GZIP, ZIP, BZIP2, XZ, UNKNOWN
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Detect archive type by reading magic bytes from file header
|
|
111
|
+
*/
|
|
112
|
+
private fun detectArchiveTypeByMagicBytes(file: File): ArchiveType {
|
|
113
|
+
return try {
|
|
114
|
+
FileInputStream(file).use { fis ->
|
|
115
|
+
val header = ByteArray(6)
|
|
116
|
+
val bytesRead = fis.read(header)
|
|
117
|
+
if (bytesRead < 2) return ArchiveType.UNKNOWN
|
|
118
|
+
|
|
119
|
+
// Check for gzip: 0x1f 0x8b
|
|
120
|
+
if (header[0] == 0x1f.toByte() && header[1] == 0x8b.toByte()) {
|
|
121
|
+
return ArchiveType.GZIP
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// Check for zip: 0x50 0x4b 0x03 0x04 ("PK\x03\x04")
|
|
125
|
+
if (bytesRead >= 4 &&
|
|
126
|
+
header[0] == 0x50.toByte() && header[1] == 0x4b.toByte() &&
|
|
127
|
+
header[2] == 0x03.toByte() && header[3] == 0x04.toByte()) {
|
|
128
|
+
return ArchiveType.ZIP
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// Check for bzip2: 0x42 0x5a ("BZ")
|
|
132
|
+
if (header[0] == 0x42.toByte() && header[1] == 0x5a.toByte()) {
|
|
133
|
+
return ArchiveType.BZIP2
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// Check for xz: 0xfd 0x37 0x7a 0x58 0x5a 0x00
|
|
137
|
+
if (bytesRead >= 6 &&
|
|
138
|
+
header[0] == 0xfd.toByte() && header[1] == 0x37.toByte() &&
|
|
139
|
+
header[2] == 0x7a.toByte() && header[3] == 0x58.toByte() &&
|
|
140
|
+
header[4] == 0x5a.toByte() && header[5] == 0x00.toByte()) {
|
|
141
|
+
return ArchiveType.XZ
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
ArchiveType.UNKNOWN
|
|
145
|
+
}
|
|
146
|
+
} catch (e: Exception) {
|
|
147
|
+
logger.error("Failed to detect archive type: ${e.message}")
|
|
148
|
+
ArchiveType.UNKNOWN
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
// MARK: - tar.gz Extraction
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Extract a tar.gz archive using Apache Commons Compress (streaming, memory-efficient)
|
|
156
|
+
* This approach doesn't load the entire file into memory.
|
|
157
|
+
*/
|
|
158
|
+
private fun extractTarGz(
|
|
159
|
+
sourceFile: File,
|
|
160
|
+
destinationDir: File,
|
|
161
|
+
progressHandler: ((Double) -> Unit)?
|
|
162
|
+
) {
|
|
163
|
+
val startTime = System.currentTimeMillis()
|
|
164
|
+
logger.info("Extracting tar.gz: ${sourceFile.name} (size: ${formatBytes(sourceFile.length())})")
|
|
165
|
+
progressHandler?.invoke(0.0)
|
|
166
|
+
|
|
167
|
+
destinationDir.mkdirs()
|
|
168
|
+
var fileCount = 0
|
|
169
|
+
val totalSize = sourceFile.length()
|
|
170
|
+
var bytesRead = 0L
|
|
171
|
+
|
|
172
|
+
try {
|
|
173
|
+
// Use Apache Commons Compress for streaming tar.gz extraction
|
|
174
|
+
FileInputStream(sourceFile).use { fis ->
|
|
175
|
+
BufferedInputStream(fis).use { bis ->
|
|
176
|
+
GzipCompressorInputStream(bis).use { gzis ->
|
|
177
|
+
TarArchiveInputStream(gzis).use { tarIn ->
|
|
178
|
+
var entry: TarArchiveEntry? = tarIn.nextTarEntry
|
|
179
|
+
while (entry != null) {
|
|
180
|
+
val name = entry.name
|
|
181
|
+
|
|
182
|
+
// Skip macOS resource forks and empty names
|
|
183
|
+
if (name.isEmpty() || name.startsWith("._") || name.startsWith("./._")) {
|
|
184
|
+
entry = tarIn.nextTarEntry
|
|
185
|
+
continue
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
val outputFile = File(destinationDir, name)
|
|
189
|
+
|
|
190
|
+
// Security check - prevent zip slip attack
|
|
191
|
+
val destDirPath = destinationDir.canonicalPath
|
|
192
|
+
val outputFilePath = outputFile.canonicalPath
|
|
193
|
+
if (!outputFilePath.startsWith(destDirPath + File.separator) &&
|
|
194
|
+
outputFilePath != destDirPath) {
|
|
195
|
+
logger.warning("Skipping entry outside destination: $name")
|
|
196
|
+
entry = tarIn.nextTarEntry
|
|
197
|
+
continue
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
if (entry.isDirectory) {
|
|
201
|
+
outputFile.mkdirs()
|
|
202
|
+
} else {
|
|
203
|
+
// Create parent directories
|
|
204
|
+
outputFile.parentFile?.mkdirs()
|
|
205
|
+
|
|
206
|
+
// Extract file
|
|
207
|
+
FileOutputStream(outputFile).use { fos ->
|
|
208
|
+
val buffer = ByteArray(8192)
|
|
209
|
+
var len: Int
|
|
210
|
+
while (tarIn.read(buffer).also { len = it } != -1) {
|
|
211
|
+
fos.write(buffer, 0, len)
|
|
212
|
+
bytesRead += len
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
fileCount++
|
|
216
|
+
|
|
217
|
+
// Log progress for large files
|
|
218
|
+
if (fileCount % 10 == 0) {
|
|
219
|
+
logger.debug("Extracted $fileCount files...")
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
// Report progress (estimate based on compressed bytes)
|
|
224
|
+
val progress = (bytesRead.toDouble() / (totalSize * 3)).coerceAtMost(0.95)
|
|
225
|
+
progressHandler?.invoke(progress)
|
|
226
|
+
|
|
227
|
+
entry = tarIn.nextTarEntry
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
val totalTime = System.currentTimeMillis() - startTime
|
|
235
|
+
logger.info("Extracted $fileCount files in ${totalTime}ms")
|
|
236
|
+
progressHandler?.invoke(1.0)
|
|
237
|
+
} catch (e: Exception) {
|
|
238
|
+
logger.logError(e, "tar.gz extraction failed")
|
|
239
|
+
throw e
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
// MARK: - ZIP Extraction
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* Extract a zip archive using Java's native ZipInputStream
|
|
247
|
+
*/
|
|
248
|
+
private fun extractZip(
|
|
249
|
+
sourceFile: File,
|
|
250
|
+
destinationDir: File,
|
|
251
|
+
progressHandler: ((Double) -> Unit)?
|
|
252
|
+
) {
|
|
253
|
+
logger.info("Extracting zip: ${sourceFile.name}")
|
|
254
|
+
progressHandler?.invoke(0.0)
|
|
255
|
+
|
|
256
|
+
destinationDir.mkdirs()
|
|
257
|
+
|
|
258
|
+
var fileCount = 0
|
|
259
|
+
ZipInputStream(BufferedInputStream(FileInputStream(sourceFile))).use { zis ->
|
|
260
|
+
var entry = zis.nextEntry
|
|
261
|
+
while (entry != null) {
|
|
262
|
+
val fileName = entry.name
|
|
263
|
+
val newFile = File(destinationDir, fileName)
|
|
264
|
+
|
|
265
|
+
// Security check - prevent zip slip attack
|
|
266
|
+
val destDirPath = destinationDir.canonicalPath
|
|
267
|
+
val newFilePath = newFile.canonicalPath
|
|
268
|
+
if (!newFilePath.startsWith(destDirPath + File.separator)) {
|
|
269
|
+
throw Exception("Entry is outside of the target dir: $fileName")
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
if (entry.isDirectory) {
|
|
273
|
+
newFile.mkdirs()
|
|
274
|
+
} else {
|
|
275
|
+
// Create parent directories
|
|
276
|
+
newFile.parentFile?.mkdirs()
|
|
277
|
+
|
|
278
|
+
// Write file
|
|
279
|
+
FileOutputStream(newFile).use { fos ->
|
|
280
|
+
val buffer = ByteArray(8192)
|
|
281
|
+
var len: Int
|
|
282
|
+
while (zis.read(buffer).also { len = it } != -1) {
|
|
283
|
+
fos.write(buffer, 0, len)
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
fileCount++
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
zis.closeEntry()
|
|
290
|
+
entry = zis.nextEntry
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
logger.info("Extracted $fileCount files from zip")
|
|
295
|
+
progressHandler?.invoke(1.0)
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
// MARK: - Helpers
|
|
299
|
+
|
|
300
|
+
private fun formatBytes(bytes: Long): String {
|
|
301
|
+
return when {
|
|
302
|
+
bytes < 1024 -> "$bytes B"
|
|
303
|
+
bytes < 1024 * 1024 -> String.format("%.1f KB", bytes / 1024.0)
|
|
304
|
+
bytes < 1024 * 1024 * 1024 -> String.format("%.1f MB", bytes / (1024.0 * 1024))
|
|
305
|
+
else -> String.format("%.2f GB", bytes / (1024.0 * 1024 * 1024))
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
}
|