@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.
Files changed (354) hide show
  1. package/RunAnywhereCore.podspec +130 -0
  2. package/android/CMakeLists.txt +92 -0
  3. package/android/build.gradle +321 -0
  4. package/android/consumer-rules.pro +5 -0
  5. package/android/src/main/AndroidManifest.xml +3 -0
  6. package/android/src/main/cpp/cpp-adapter.cpp +271 -0
  7. package/android/src/main/include/rac/backends/rac_llm_llamacpp.h +218 -0
  8. package/android/src/main/include/rac/backends/rac_stt_onnx.h +99 -0
  9. package/android/src/main/include/rac/backends/rac_stt_whispercpp.h +153 -0
  10. package/android/src/main/include/rac/backends/rac_tts_onnx.h +71 -0
  11. package/android/src/main/include/rac/backends/rac_vad_onnx.h +84 -0
  12. package/android/src/main/include/rac/core/capabilities/rac_lifecycle.h +290 -0
  13. package/android/src/main/include/rac/core/rac_analytics_events.h +610 -0
  14. package/android/src/main/include/rac/core/rac_audio_utils.h +88 -0
  15. package/android/src/main/include/rac/core/rac_component_types.h +160 -0
  16. package/android/src/main/include/rac/core/rac_core.h +331 -0
  17. package/android/src/main/include/rac/core/rac_error.h +469 -0
  18. package/android/src/main/include/rac/core/rac_events.h +334 -0
  19. package/android/src/main/include/rac/core/rac_logger.h +416 -0
  20. package/android/src/main/include/rac/core/rac_platform_adapter.h +340 -0
  21. package/android/src/main/include/rac/core/rac_sdk_state.h +292 -0
  22. package/android/src/main/include/rac/core/rac_structured_error.h +594 -0
  23. package/android/src/main/include/rac/core/rac_types.h +264 -0
  24. package/android/src/main/include/rac/features/llm/rac_llm.h +17 -0
  25. package/android/src/main/include/rac/features/llm/rac_llm_analytics.h +188 -0
  26. package/android/src/main/include/rac/features/llm/rac_llm_component.h +228 -0
  27. package/android/src/main/include/rac/features/llm/rac_llm_events.h +215 -0
  28. package/android/src/main/include/rac/features/llm/rac_llm_metrics.h +402 -0
  29. package/android/src/main/include/rac/features/llm/rac_llm_service.h +163 -0
  30. package/android/src/main/include/rac/features/llm/rac_llm_structured_output.h +141 -0
  31. package/android/src/main/include/rac/features/llm/rac_llm_types.h +384 -0
  32. package/android/src/main/include/rac/features/platform/rac_llm_platform.h +204 -0
  33. package/android/src/main/include/rac/features/platform/rac_tts_platform.h +197 -0
  34. package/android/src/main/include/rac/features/stt/rac_stt.h +17 -0
  35. package/android/src/main/include/rac/features/stt/rac_stt_analytics.h +204 -0
  36. package/android/src/main/include/rac/features/stt/rac_stt_component.h +162 -0
  37. package/android/src/main/include/rac/features/stt/rac_stt_events.h +62 -0
  38. package/android/src/main/include/rac/features/stt/rac_stt_service.h +154 -0
  39. package/android/src/main/include/rac/features/stt/rac_stt_types.h +389 -0
  40. package/android/src/main/include/rac/features/tts/rac_tts.h +17 -0
  41. package/android/src/main/include/rac/features/tts/rac_tts_analytics.h +181 -0
  42. package/android/src/main/include/rac/features/tts/rac_tts_component.h +158 -0
  43. package/android/src/main/include/rac/features/tts/rac_tts_events.h +54 -0
  44. package/android/src/main/include/rac/features/tts/rac_tts_service.h +162 -0
  45. package/android/src/main/include/rac/features/tts/rac_tts_types.h +374 -0
  46. package/android/src/main/include/rac/features/vad/rac_vad.h +17 -0
  47. package/android/src/main/include/rac/features/vad/rac_vad_analytics.h +236 -0
  48. package/android/src/main/include/rac/features/vad/rac_vad_component.h +185 -0
  49. package/android/src/main/include/rac/features/vad/rac_vad_energy.h +443 -0
  50. package/android/src/main/include/rac/features/vad/rac_vad_events.h +76 -0
  51. package/android/src/main/include/rac/features/vad/rac_vad_service.h +167 -0
  52. package/android/src/main/include/rac/features/vad/rac_vad_types.h +244 -0
  53. package/android/src/main/include/rac/features/voice_agent/rac_voice_agent.h +612 -0
  54. package/android/src/main/include/rac/infrastructure/device/rac_device_manager.h +176 -0
  55. package/android/src/main/include/rac/infrastructure/download/rac_download.h +418 -0
  56. package/android/src/main/include/rac/infrastructure/events/rac_events.h +177 -0
  57. package/android/src/main/include/rac/infrastructure/model_management/rac_model_assignment.h +169 -0
  58. package/android/src/main/include/rac/infrastructure/model_management/rac_model_paths.h +258 -0
  59. package/android/src/main/include/rac/infrastructure/model_management/rac_model_registry.h +357 -0
  60. package/android/src/main/include/rac/infrastructure/model_management/rac_model_strategy.h +374 -0
  61. package/android/src/main/include/rac/infrastructure/model_management/rac_model_types.h +613 -0
  62. package/android/src/main/include/rac/infrastructure/network/rac_api_types.h +335 -0
  63. package/android/src/main/include/rac/infrastructure/network/rac_auth_manager.h +252 -0
  64. package/android/src/main/include/rac/infrastructure/network/rac_dev_config.h +85 -0
  65. package/android/src/main/include/rac/infrastructure/network/rac_endpoints.h +102 -0
  66. package/android/src/main/include/rac/infrastructure/network/rac_environment.h +220 -0
  67. package/android/src/main/include/rac/infrastructure/network/rac_http_client.h +233 -0
  68. package/android/src/main/include/rac/infrastructure/storage/rac_storage_analyzer.h +286 -0
  69. package/android/src/main/include/rac/infrastructure/telemetry/rac_telemetry_manager.h +206 -0
  70. package/android/src/main/include/rac/infrastructure/telemetry/rac_telemetry_types.h +234 -0
  71. package/android/src/main/java/com/margelo/nitro/runanywhere/ArchiveUtility.kt +308 -0
  72. package/android/src/main/java/com/margelo/nitro/runanywhere/HybridRunAnywhereDeviceInfo.kt +229 -0
  73. package/android/src/main/java/com/margelo/nitro/runanywhere/PlatformAdapterBridge.kt +392 -0
  74. package/android/src/main/java/com/margelo/nitro/runanywhere/RunAnywhereCorePackage.kt +28 -0
  75. package/android/src/main/java/com/margelo/nitro/runanywhere/SDKLogger.kt +357 -0
  76. package/android/src/main/java/com/margelo/nitro/runanywhere/SecureStorageManager.kt +147 -0
  77. package/android/src/main/jniLibs/arm64-v8a/libc++_shared.so +0 -0
  78. package/android/src/main/jniLibs/arm64-v8a/libomp.so +0 -0
  79. package/android/src/main/jniLibs/arm64-v8a/librac_commons.so +0 -0
  80. package/android/src/main/jniLibs/arm64-v8a/librunanywhere_jni.so +0 -0
  81. package/cpp/HybridRunAnywhereCore.cpp +2505 -0
  82. package/cpp/HybridRunAnywhereCore.hpp +271 -0
  83. package/cpp/bridges/AuthBridge.cpp +209 -0
  84. package/cpp/bridges/AuthBridge.hpp +157 -0
  85. package/cpp/bridges/DeviceBridge.cpp +257 -0
  86. package/cpp/bridges/DeviceBridge.hpp +155 -0
  87. package/cpp/bridges/DownloadBridge.cpp +299 -0
  88. package/cpp/bridges/DownloadBridge.hpp +197 -0
  89. package/cpp/bridges/EventBridge.cpp +125 -0
  90. package/cpp/bridges/EventBridge.hpp +139 -0
  91. package/cpp/bridges/HTTPBridge.cpp +96 -0
  92. package/cpp/bridges/HTTPBridge.hpp +144 -0
  93. package/cpp/bridges/InitBridge.cpp +1273 -0
  94. package/cpp/bridges/InitBridge.hpp +306 -0
  95. package/cpp/bridges/ModelRegistryBridge.cpp +394 -0
  96. package/cpp/bridges/ModelRegistryBridge.hpp +177 -0
  97. package/cpp/bridges/StorageBridge.cpp +269 -0
  98. package/cpp/bridges/StorageBridge.hpp +172 -0
  99. package/cpp/bridges/TelemetryBridge.cpp +352 -0
  100. package/cpp/bridges/TelemetryBridge.hpp +126 -0
  101. package/ios/.testlocal +0 -0
  102. package/ios/ArchiveUtility.swift +526 -0
  103. package/ios/ArchiveUtilityBridge.m +52 -0
  104. package/ios/AudioDecoder.h +38 -0
  105. package/ios/AudioDecoder.m +162 -0
  106. package/ios/Binaries/RACommons.xcframework/Info.plist +44 -0
  107. package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/RACommons.h +67 -0
  108. package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_analytics_events.h +610 -0
  109. package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_api_types.h +335 -0
  110. package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_audio_utils.h +88 -0
  111. package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_auth_manager.h +252 -0
  112. package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_component_types.h +160 -0
  113. package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_core.h +331 -0
  114. package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_dev_config.h +85 -0
  115. package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_device_manager.h +176 -0
  116. package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_download.h +418 -0
  117. package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_endpoints.h +102 -0
  118. package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_environment.h +220 -0
  119. package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_error.h +469 -0
  120. package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_events.h +177 -0
  121. package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_http_client.h +233 -0
  122. package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_lifecycle.h +290 -0
  123. package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_llm.h +17 -0
  124. package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_llm_analytics.h +188 -0
  125. package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_llm_component.h +228 -0
  126. package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_llm_events.h +215 -0
  127. package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_llm_llamacpp.h +218 -0
  128. package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_llm_metrics.h +402 -0
  129. package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_llm_platform.h +204 -0
  130. package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_llm_service.h +163 -0
  131. package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_llm_structured_output.h +141 -0
  132. package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_llm_types.h +384 -0
  133. package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_logger.h +416 -0
  134. package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_model_assignment.h +169 -0
  135. package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_model_paths.h +258 -0
  136. package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_model_registry.h +357 -0
  137. package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_model_strategy.h +374 -0
  138. package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_model_types.h +613 -0
  139. package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_platform_adapter.h +340 -0
  140. package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_sdk_state.h +292 -0
  141. package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_storage_analyzer.h +286 -0
  142. package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_structured_error.h +594 -0
  143. package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_stt.h +17 -0
  144. package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_stt_analytics.h +204 -0
  145. package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_stt_component.h +162 -0
  146. package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_stt_events.h +62 -0
  147. package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_stt_onnx.h +99 -0
  148. package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_stt_service.h +154 -0
  149. package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_stt_types.h +389 -0
  150. package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_stt_whispercpp.h +153 -0
  151. package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_telemetry_manager.h +206 -0
  152. package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_telemetry_types.h +234 -0
  153. package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_tts.h +17 -0
  154. package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_tts_analytics.h +181 -0
  155. package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_tts_component.h +158 -0
  156. package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_tts_events.h +54 -0
  157. package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_tts_onnx.h +71 -0
  158. package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_tts_platform.h +197 -0
  159. package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_tts_service.h +162 -0
  160. package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_tts_types.h +374 -0
  161. package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_types.h +264 -0
  162. package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_vad.h +17 -0
  163. package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_vad_analytics.h +236 -0
  164. package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_vad_component.h +185 -0
  165. package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_vad_energy.h +443 -0
  166. package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_vad_events.h +76 -0
  167. package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_vad_onnx.h +84 -0
  168. package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_vad_service.h +167 -0
  169. package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_vad_types.h +244 -0
  170. package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_voice_agent.h +612 -0
  171. package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Info.plist +11 -0
  172. package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Modules/module.modulemap +5 -0
  173. package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/RACommons +0 -0
  174. package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/RACommons.h +67 -0
  175. package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_analytics_events.h +610 -0
  176. package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_api_types.h +335 -0
  177. package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_audio_utils.h +88 -0
  178. package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_auth_manager.h +252 -0
  179. package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_component_types.h +160 -0
  180. package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_core.h +331 -0
  181. package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_dev_config.h +85 -0
  182. package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_device_manager.h +176 -0
  183. package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_download.h +418 -0
  184. package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_endpoints.h +102 -0
  185. package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_environment.h +220 -0
  186. package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_error.h +469 -0
  187. package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_events.h +177 -0
  188. package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_http_client.h +233 -0
  189. package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_lifecycle.h +290 -0
  190. package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_llm.h +17 -0
  191. package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_llm_analytics.h +188 -0
  192. package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_llm_component.h +228 -0
  193. package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_llm_events.h +215 -0
  194. package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_llm_llamacpp.h +218 -0
  195. package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_llm_metrics.h +402 -0
  196. package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_llm_platform.h +204 -0
  197. package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_llm_service.h +163 -0
  198. package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_llm_structured_output.h +141 -0
  199. package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_llm_types.h +384 -0
  200. package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_logger.h +416 -0
  201. package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_model_assignment.h +169 -0
  202. package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_model_paths.h +258 -0
  203. package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_model_registry.h +357 -0
  204. package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_model_strategy.h +374 -0
  205. package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_model_types.h +613 -0
  206. package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_platform_adapter.h +340 -0
  207. package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_sdk_state.h +292 -0
  208. package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_storage_analyzer.h +286 -0
  209. package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_structured_error.h +594 -0
  210. package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_stt.h +17 -0
  211. package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_stt_analytics.h +204 -0
  212. package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_stt_component.h +162 -0
  213. package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_stt_events.h +62 -0
  214. package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_stt_onnx.h +99 -0
  215. package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_stt_service.h +154 -0
  216. package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_stt_types.h +389 -0
  217. package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_stt_whispercpp.h +153 -0
  218. package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_telemetry_manager.h +206 -0
  219. package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_telemetry_types.h +234 -0
  220. package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_tts.h +17 -0
  221. package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_tts_analytics.h +181 -0
  222. package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_tts_component.h +158 -0
  223. package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_tts_events.h +54 -0
  224. package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_tts_onnx.h +71 -0
  225. package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_tts_platform.h +197 -0
  226. package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_tts_service.h +162 -0
  227. package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_tts_types.h +374 -0
  228. package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_types.h +264 -0
  229. package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_vad.h +17 -0
  230. package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_vad_analytics.h +236 -0
  231. package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_vad_component.h +185 -0
  232. package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_vad_energy.h +443 -0
  233. package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_vad_events.h +76 -0
  234. package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_vad_onnx.h +84 -0
  235. package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_vad_service.h +167 -0
  236. package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_vad_types.h +244 -0
  237. package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_voice_agent.h +612 -0
  238. package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Info.plist +11 -0
  239. package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Modules/module.modulemap +5 -0
  240. package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/RACommons +0 -0
  241. package/ios/HybridRunAnywhereDeviceInfo.swift +214 -0
  242. package/ios/KeychainManager.swift +116 -0
  243. package/ios/PlatformAdapter.swift +100 -0
  244. package/ios/PlatformAdapterBridge.h +152 -0
  245. package/ios/PlatformAdapterBridge.m +570 -0
  246. package/ios/RNSDKLoggerBridge.h +41 -0
  247. package/ios/RNSDKLoggerBridge.m +66 -0
  248. package/ios/SDKLogger.swift +329 -0
  249. package/nitro.json +20 -0
  250. package/nitrogen/generated/.gitattributes +1 -0
  251. package/nitrogen/generated/android/c++/JHybridRunAnywhereDeviceInfoSpec.cpp +257 -0
  252. package/nitrogen/generated/android/c++/JHybridRunAnywhereDeviceInfoSpec.hpp +77 -0
  253. package/nitrogen/generated/android/kotlin/com/margelo/nitro/runanywhere/HybridRunAnywhereDeviceInfoSpec.kt +106 -0
  254. package/nitrogen/generated/android/kotlin/com/margelo/nitro/runanywhere/runanywherecoreOnLoad.kt +35 -0
  255. package/nitrogen/generated/android/runanywherecore+autolinking.cmake +82 -0
  256. package/nitrogen/generated/android/runanywherecore+autolinking.gradle +27 -0
  257. package/nitrogen/generated/android/runanywherecoreOnLoad.cpp +54 -0
  258. package/nitrogen/generated/android/runanywherecoreOnLoad.hpp +25 -0
  259. package/nitrogen/generated/ios/RunAnywhereCore+autolinking.rb +60 -0
  260. package/nitrogen/generated/ios/RunAnywhereCore-Swift-Cxx-Bridge.cpp +65 -0
  261. package/nitrogen/generated/ios/RunAnywhereCore-Swift-Cxx-Bridge.hpp +197 -0
  262. package/nitrogen/generated/ios/RunAnywhereCore-Swift-Cxx-Umbrella.hpp +45 -0
  263. package/nitrogen/generated/ios/RunAnywhereCoreAutolinking.mm +43 -0
  264. package/nitrogen/generated/ios/RunAnywhereCoreAutolinking.swift +25 -0
  265. package/nitrogen/generated/ios/c++/HybridRunAnywhereDeviceInfoSpecSwift.cpp +11 -0
  266. package/nitrogen/generated/ios/c++/HybridRunAnywhereDeviceInfoSpecSwift.hpp +173 -0
  267. package/nitrogen/generated/ios/swift/Func_void_bool.swift +47 -0
  268. package/nitrogen/generated/ios/swift/Func_void_double.swift +47 -0
  269. package/nitrogen/generated/ios/swift/Func_void_std__exception_ptr.swift +47 -0
  270. package/nitrogen/generated/ios/swift/Func_void_std__string.swift +47 -0
  271. package/nitrogen/generated/ios/swift/HybridRunAnywhereDeviceInfoSpec.swift +68 -0
  272. package/nitrogen/generated/ios/swift/HybridRunAnywhereDeviceInfoSpec_cxx.swift +366 -0
  273. package/nitrogen/generated/shared/c++/HybridRunAnywhereCoreSpec.cpp +92 -0
  274. package/nitrogen/generated/shared/c++/HybridRunAnywhereCoreSpec.hpp +138 -0
  275. package/nitrogen/generated/shared/c++/HybridRunAnywhereDeviceInfoSpec.cpp +33 -0
  276. package/nitrogen/generated/shared/c++/HybridRunAnywhereDeviceInfoSpec.hpp +75 -0
  277. package/package.json +76 -0
  278. package/react-native.config.js +14 -0
  279. package/src/Features/VoiceSession/AudioCaptureManager.ts +286 -0
  280. package/src/Features/VoiceSession/AudioPlaybackManager.ts +300 -0
  281. package/src/Features/VoiceSession/VoiceSessionHandle.ts +530 -0
  282. package/src/Features/VoiceSession/index.ts +20 -0
  283. package/src/Features/index.ts +7 -0
  284. package/src/Foundation/Constants/SDKConstants.ts +47 -0
  285. package/src/Foundation/Constants/index.ts +8 -0
  286. package/src/Foundation/DependencyInjection/ServiceContainer.ts +154 -0
  287. package/src/Foundation/DependencyInjection/ServiceRegistry.ts +51 -0
  288. package/src/Foundation/DependencyInjection/index.ts +6 -0
  289. package/src/Foundation/ErrorTypes/ErrorCategory.ts +184 -0
  290. package/src/Foundation/ErrorTypes/ErrorCodes.ts +151 -0
  291. package/src/Foundation/ErrorTypes/ErrorContext.ts +201 -0
  292. package/src/Foundation/ErrorTypes/SDKError.ts +507 -0
  293. package/src/Foundation/ErrorTypes/index.ts +57 -0
  294. package/src/Foundation/Initialization/InitializationPhase.ts +85 -0
  295. package/src/Foundation/Initialization/InitializationState.ts +168 -0
  296. package/src/Foundation/Initialization/index.ts +26 -0
  297. package/src/Foundation/Logging/Destinations/NativeLogBridge.ts +147 -0
  298. package/src/Foundation/Logging/Destinations/SentryDestination.ts +209 -0
  299. package/src/Foundation/Logging/Logger/SDKLogger.ts +232 -0
  300. package/src/Foundation/Logging/Models/LogLevel.ts +36 -0
  301. package/src/Foundation/Logging/Models/LoggingConfiguration.ts +117 -0
  302. package/src/Foundation/Logging/Services/LoggingManager.ts +407 -0
  303. package/src/Foundation/Logging/index.ts +59 -0
  304. package/src/Foundation/Security/DeviceIdentity.ts +92 -0
  305. package/src/Foundation/Security/SecureStorageError.ts +132 -0
  306. package/src/Foundation/Security/SecureStorageKeys.ts +35 -0
  307. package/src/Foundation/Security/SecureStorageService.ts +449 -0
  308. package/src/Foundation/Security/index.ts +17 -0
  309. package/src/Foundation/index.ts +26 -0
  310. package/src/Infrastructure/Events/EventPublisher.ts +165 -0
  311. package/src/Infrastructure/Events/SDKEvent.ts +214 -0
  312. package/src/Infrastructure/Events/index.ts +15 -0
  313. package/src/Infrastructure/index.ts +9 -0
  314. package/src/Public/Events/EventBus.ts +488 -0
  315. package/src/Public/Events/index.ts +8 -0
  316. package/src/Public/Extensions/RunAnywhere+Logging.ts +51 -0
  317. package/src/Public/Extensions/RunAnywhere+Models.ts +392 -0
  318. package/src/Public/Extensions/RunAnywhere+STT.ts +424 -0
  319. package/src/Public/Extensions/RunAnywhere+Storage.ts +151 -0
  320. package/src/Public/Extensions/RunAnywhere+StructuredOutput.ts +316 -0
  321. package/src/Public/Extensions/RunAnywhere+TTS.ts +430 -0
  322. package/src/Public/Extensions/RunAnywhere+TextGeneration.ts +320 -0
  323. package/src/Public/Extensions/RunAnywhere+VAD.ts +359 -0
  324. package/src/Public/Extensions/RunAnywhere+VoiceAgent.ts +225 -0
  325. package/src/Public/Extensions/RunAnywhere+VoiceSession.ts +155 -0
  326. package/src/Public/Extensions/index.ts +126 -0
  327. package/src/Public/RunAnywhere.ts +695 -0
  328. package/src/index.ts +238 -0
  329. package/src/native/NativeRunAnywhereCore.ts +291 -0
  330. package/src/native/NativeRunAnywhereModule.ts +32 -0
  331. package/src/native/index.ts +21 -0
  332. package/src/services/DownloadService.ts +282 -0
  333. package/src/services/FileSystem.ts +810 -0
  334. package/src/services/ModelRegistry.ts +246 -0
  335. package/src/services/Network/APIEndpoints.ts +84 -0
  336. package/src/services/Network/HTTPService.ts +479 -0
  337. package/src/services/Network/NetworkConfiguration.ts +130 -0
  338. package/src/services/Network/TelemetryService.ts +318 -0
  339. package/src/services/Network/index.ts +29 -0
  340. package/src/services/SystemTTSService.ts +130 -0
  341. package/src/services/index.ts +66 -0
  342. package/src/specs/RunAnywhereCore.nitro.ts +627 -0
  343. package/src/specs/RunAnywhereDeviceInfo.nitro.ts +73 -0
  344. package/src/types/LLMTypes.ts +127 -0
  345. package/src/types/STTTypes.ts +124 -0
  346. package/src/types/StructuredOutputTypes.ts +156 -0
  347. package/src/types/TTSTypes.ts +126 -0
  348. package/src/types/VADTypes.ts +70 -0
  349. package/src/types/VoiceAgentTypes.ts +182 -0
  350. package/src/types/enums.ts +258 -0
  351. package/src/types/events.ts +337 -0
  352. package/src/types/external.d.ts +142 -0
  353. package/src/types/index.ts +146 -0
  354. package/src/types/models.ts +579 -0
@@ -0,0 +1,257 @@
1
+ /**
2
+ * @file DeviceBridge.cpp
3
+ * @brief C++ bridge for device operations.
4
+ *
5
+ * Mirrors Swift's CppBridge+Device.swift pattern.
6
+ * Registers callbacks with rac_device_manager and delegates to platform.
7
+ */
8
+
9
+ #include "DeviceBridge.hpp"
10
+ #include "rac_error.h"
11
+ #include <cstring>
12
+
13
+ // Platform-specific logging
14
+ #if defined(ANDROID) || defined(__ANDROID__)
15
+ #include <android/log.h>
16
+ #define LOG_TAG "DeviceBridge"
17
+ #define LOGI(...) __android_log_print(ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__)
18
+ #define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__)
19
+ #define LOGE(...) __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__)
20
+ #else
21
+ #include <cstdio>
22
+ #define LOGI(...) printf("[DeviceBridge] "); printf(__VA_ARGS__); printf("\n")
23
+ #define LOGD(...) printf("[DeviceBridge DEBUG] "); printf(__VA_ARGS__); printf("\n")
24
+ #define LOGE(...) printf("[DeviceBridge ERROR] "); printf(__VA_ARGS__); printf("\n")
25
+ #endif
26
+
27
+ namespace runanywhere {
28
+ namespace bridges {
29
+
30
+ // =============================================================================
31
+ // Static storage for callbacks (needed for C function pointers)
32
+ // =============================================================================
33
+
34
+ static DevicePlatformCallbacks* g_deviceCallbacks = nullptr;
35
+
36
+ // =============================================================================
37
+ // C Callback Implementations (called by RACommons)
38
+ // =============================================================================
39
+
40
+ static void deviceGetInfoCallback(rac_device_registration_info_t* outInfo, void* userData) {
41
+ if (!outInfo || !g_deviceCallbacks || !g_deviceCallbacks->getDeviceInfo) {
42
+ LOGE("getDeviceInfo callback not available");
43
+ return;
44
+ }
45
+
46
+ DeviceInfo info = g_deviceCallbacks->getDeviceInfo();
47
+
48
+ // Note: We need to use static storage for strings since RACommons
49
+ // only keeps pointers. In a real implementation, these would need
50
+ // to be managed carefully for lifetime.
51
+ static std::string s_deviceId, s_deviceModel, s_deviceName, s_platform;
52
+ static std::string s_osVersion, s_formFactor, s_architecture, s_chipName;
53
+ static std::string s_gpuFamily, s_batteryState, s_deviceType, s_osName;
54
+ static std::string s_deviceFingerprint;
55
+
56
+ s_deviceId = info.deviceId;
57
+ s_deviceModel = info.deviceModel;
58
+ s_deviceName = info.deviceName;
59
+ s_platform = info.platform;
60
+ s_osVersion = info.osVersion;
61
+ s_formFactor = info.formFactor;
62
+ s_architecture = info.architecture;
63
+ s_chipName = info.chipName;
64
+ s_gpuFamily = info.gpuFamily;
65
+ s_batteryState = info.batteryState;
66
+ s_deviceType = info.formFactor; // Use formFactor as device_type
67
+ s_osName = info.osName.empty() ? info.platform : info.osName;
68
+ s_deviceFingerprint = info.deviceId;
69
+
70
+ // Fill out the struct - matches Swift's implementation
71
+ outInfo->device_id = s_deviceId.c_str();
72
+ outInfo->device_model = s_deviceModel.c_str();
73
+ outInfo->device_name = s_deviceName.c_str();
74
+ outInfo->platform = s_platform.c_str();
75
+ outInfo->os_version = s_osVersion.c_str();
76
+ outInfo->form_factor = s_formFactor.c_str();
77
+ outInfo->architecture = s_architecture.c_str();
78
+ outInfo->chip_name = s_chipName.c_str();
79
+ outInfo->total_memory = info.totalMemory;
80
+ outInfo->available_memory = info.availableMemory;
81
+ outInfo->has_neural_engine = info.hasNeuralEngine ? RAC_TRUE : RAC_FALSE;
82
+ outInfo->neural_engine_cores = info.neuralEngineCores;
83
+ outInfo->gpu_family = s_gpuFamily.c_str();
84
+ outInfo->battery_level = info.batteryLevel;
85
+ outInfo->battery_state = s_batteryState.empty() ? nullptr : s_batteryState.c_str();
86
+ outInfo->is_low_power_mode = info.isLowPowerMode ? RAC_TRUE : RAC_FALSE;
87
+ outInfo->core_count = info.coreCount;
88
+ outInfo->performance_cores = info.performanceCores;
89
+ outInfo->efficiency_cores = info.efficiencyCores;
90
+ outInfo->device_fingerprint = s_deviceFingerprint.c_str();
91
+
92
+ // Legacy fields
93
+ outInfo->device_type = s_deviceType.c_str();
94
+ outInfo->os_name = s_osName.c_str();
95
+ outInfo->processor_count = info.coreCount;
96
+ outInfo->is_simulator = info.isSimulator ? RAC_TRUE : RAC_FALSE;
97
+
98
+ LOGD("Device info populated: model=%s, platform=%s", s_deviceModel.c_str(), s_platform.c_str());
99
+ }
100
+
101
+ static const char* deviceGetIdCallback(void* userData) {
102
+ if (!g_deviceCallbacks || !g_deviceCallbacks->getDeviceId) {
103
+ LOGE("getDeviceId callback not available");
104
+ return nullptr;
105
+ }
106
+
107
+ static std::string s_deviceId;
108
+ s_deviceId = g_deviceCallbacks->getDeviceId();
109
+ return s_deviceId.c_str();
110
+ }
111
+
112
+ static rac_bool_t deviceIsRegisteredCallback(void* userData) {
113
+ if (!g_deviceCallbacks || !g_deviceCallbacks->isRegistered) {
114
+ return RAC_FALSE;
115
+ }
116
+ return g_deviceCallbacks->isRegistered() ? RAC_TRUE : RAC_FALSE;
117
+ }
118
+
119
+ static void deviceSetRegisteredCallback(rac_bool_t registered, void* userData) {
120
+ if (!g_deviceCallbacks || !g_deviceCallbacks->setRegistered) {
121
+ LOGE("setRegistered callback not available");
122
+ return;
123
+ }
124
+ g_deviceCallbacks->setRegistered(registered == RAC_TRUE);
125
+ LOGI("Device registration status set: %s", registered == RAC_TRUE ? "true" : "false");
126
+ }
127
+
128
+ static rac_result_t deviceHttpPostCallback(
129
+ const char* endpoint,
130
+ const char* jsonBody,
131
+ rac_bool_t requiresAuth,
132
+ rac_device_http_response_t* outResponse,
133
+ void* userData
134
+ ) {
135
+ if (!endpoint || !jsonBody || !outResponse) {
136
+ return RAC_ERROR_INVALID_ARGUMENT;
137
+ }
138
+
139
+ if (!g_deviceCallbacks || !g_deviceCallbacks->httpPost) {
140
+ LOGE("httpPost callback not available");
141
+ outResponse->result = RAC_ERROR_NOT_SUPPORTED;
142
+ return RAC_ERROR_NOT_SUPPORTED;
143
+ }
144
+
145
+ LOGI("Making HTTP POST to: %s", endpoint);
146
+
147
+ auto [success, statusCode, responseBody, errorMessage] =
148
+ g_deviceCallbacks->httpPost(endpoint, jsonBody, requiresAuth == RAC_TRUE);
149
+
150
+ // Store response strings statically for lifetime
151
+ static std::string s_responseBody, s_errorMessage;
152
+ s_responseBody = responseBody;
153
+ s_errorMessage = errorMessage;
154
+
155
+ if (success) {
156
+ outResponse->result = RAC_SUCCESS;
157
+ outResponse->status_code = statusCode;
158
+ outResponse->response_body = s_responseBody.empty() ? nullptr : s_responseBody.c_str();
159
+ outResponse->error_message = nullptr;
160
+ LOGI("HTTP POST succeeded with status %d", statusCode);
161
+ return RAC_SUCCESS;
162
+ } else {
163
+ outResponse->result = RAC_ERROR_NETWORK_ERROR;
164
+ outResponse->status_code = statusCode;
165
+ outResponse->response_body = nullptr;
166
+ outResponse->error_message = s_errorMessage.empty() ? nullptr : s_errorMessage.c_str();
167
+ LOGE("HTTP POST failed: %s", s_errorMessage.c_str());
168
+ return RAC_ERROR_NETWORK_ERROR;
169
+ }
170
+ }
171
+
172
+ // =============================================================================
173
+ // DeviceBridge Implementation
174
+ // =============================================================================
175
+
176
+ DeviceBridge& DeviceBridge::shared() {
177
+ static DeviceBridge instance;
178
+ return instance;
179
+ }
180
+
181
+ void DeviceBridge::setPlatformCallbacks(const DevicePlatformCallbacks& callbacks) {
182
+ platformCallbacks_ = callbacks;
183
+
184
+ // Store in global for C callbacks
185
+ static DevicePlatformCallbacks storedCallbacks;
186
+ storedCallbacks = callbacks;
187
+ g_deviceCallbacks = &storedCallbacks;
188
+
189
+ LOGI("Device platform callbacks set");
190
+ }
191
+
192
+ rac_result_t DeviceBridge::registerCallbacks() {
193
+ if (callbacksRegistered_) {
194
+ LOGD("Device callbacks already registered");
195
+ return RAC_SUCCESS;
196
+ }
197
+
198
+ // Reset callbacks struct
199
+ memset(&racCallbacks_, 0, sizeof(racCallbacks_));
200
+
201
+ // Set callback function pointers
202
+ racCallbacks_.get_device_info = deviceGetInfoCallback;
203
+ racCallbacks_.get_device_id = deviceGetIdCallback;
204
+ racCallbacks_.is_registered = deviceIsRegisteredCallback;
205
+ racCallbacks_.set_registered = deviceSetRegisteredCallback;
206
+ racCallbacks_.http_post = deviceHttpPostCallback;
207
+ racCallbacks_.user_data = nullptr;
208
+
209
+ // Register with RACommons
210
+ rac_result_t result = rac_device_manager_set_callbacks(&racCallbacks_);
211
+
212
+ if (result == RAC_SUCCESS) {
213
+ callbacksRegistered_ = true;
214
+ LOGI("Device manager callbacks registered with RACommons");
215
+ } else {
216
+ LOGE("Failed to register device manager callbacks: %d", result);
217
+ }
218
+
219
+ return result;
220
+ }
221
+
222
+ rac_result_t DeviceBridge::registerIfNeeded(rac_environment_t environment, const std::string& buildToken) {
223
+ if (!callbacksRegistered_) {
224
+ LOGE("Device callbacks not registered - call registerCallbacks() first");
225
+ return RAC_ERROR_NOT_INITIALIZED;
226
+ }
227
+
228
+ LOGI("Registering device if needed (env=%d)...", static_cast<int>(environment));
229
+
230
+ const char* tokenPtr = buildToken.empty() ? nullptr : buildToken.c_str();
231
+ rac_result_t result = rac_device_manager_register_if_needed(environment, tokenPtr);
232
+
233
+ if (result == RAC_SUCCESS) {
234
+ LOGI("Device registration completed successfully");
235
+ } else {
236
+ LOGE("Device registration failed: %d", result);
237
+ }
238
+
239
+ return result;
240
+ }
241
+
242
+ bool DeviceBridge::isRegistered() const {
243
+ return rac_device_manager_is_registered() == RAC_TRUE;
244
+ }
245
+
246
+ void DeviceBridge::clearRegistration() {
247
+ rac_device_manager_clear_registration();
248
+ LOGI("Device registration cleared");
249
+ }
250
+
251
+ std::string DeviceBridge::getDeviceId() const {
252
+ const char* id = rac_device_manager_get_device_id();
253
+ return id ? std::string(id) : "";
254
+ }
255
+
256
+ } // namespace bridges
257
+ } // namespace runanywhere
@@ -0,0 +1,155 @@
1
+ /**
2
+ * @file DeviceBridge.hpp
3
+ * @brief C++ bridge for device operations.
4
+ *
5
+ * Mirrors Swift's CppBridge+Device.swift pattern.
6
+ * Registers callbacks with rac_device_manager and delegates to platform.
7
+ *
8
+ * Reference: sdk/runanywhere-swift/Sources/RunAnywhere/Foundation/Bridge/Extensions/CppBridge+Device.swift
9
+ */
10
+
11
+ #pragma once
12
+
13
+ #include <string>
14
+ #include <functional>
15
+
16
+ #include "rac_types.h"
17
+ #include "rac_device_manager.h"
18
+ #include "rac_environment.h"
19
+
20
+ namespace runanywhere {
21
+ namespace bridges {
22
+
23
+ /**
24
+ * Device info structure
25
+ */
26
+ struct DeviceInfo {
27
+ std::string deviceId;
28
+ std::string deviceModel;
29
+ std::string deviceName;
30
+ std::string platform;
31
+ std::string osName;
32
+ std::string osVersion;
33
+ std::string formFactor;
34
+ std::string architecture;
35
+ std::string chipName;
36
+ int64_t totalMemory = 0;
37
+ int64_t availableMemory = 0;
38
+ bool hasNeuralEngine = false;
39
+ int32_t neuralEngineCores = 0;
40
+ std::string gpuFamily;
41
+ float batteryLevel = -1.0f;
42
+ std::string batteryState;
43
+ bool isLowPowerMode = false;
44
+ int32_t coreCount = 0;
45
+ int32_t performanceCores = 0;
46
+ int32_t efficiencyCores = 0;
47
+ bool isSimulator = false;
48
+ std::string sdkVersion;
49
+ };
50
+
51
+ /**
52
+ * Device registration result
53
+ */
54
+ struct DeviceRegistrationResult {
55
+ bool success = false;
56
+ std::string deviceId;
57
+ std::string error;
58
+ };
59
+
60
+ /**
61
+ * Platform callbacks for device operations
62
+ */
63
+ struct DevicePlatformCallbacks {
64
+ // Get device hardware/OS info
65
+ std::function<DeviceInfo()> getDeviceInfo;
66
+
67
+ // Get persistent device ID (from keychain/keystore)
68
+ std::function<std::string()> getDeviceId;
69
+
70
+ // Check if device is registered (from UserDefaults/SharedPrefs)
71
+ std::function<bool()> isRegistered;
72
+
73
+ // Set registration status
74
+ std::function<void(bool)> setRegistered;
75
+
76
+ // Make HTTP POST for device registration
77
+ // Returns: (success, statusCode, responseBody, errorMessage)
78
+ std::function<std::tuple<bool, int, std::string, std::string>(
79
+ const std::string& endpoint,
80
+ const std::string& jsonBody,
81
+ bool requiresAuth
82
+ )> httpPost;
83
+ };
84
+
85
+ /**
86
+ * DeviceBridge - Device registration and info via rac_device_manager_* API
87
+ *
88
+ * Mirrors Swift's CppBridge.Device pattern:
89
+ * - Platform provides callbacks
90
+ * - C++ handles business logic via RACommons
91
+ */
92
+ class DeviceBridge {
93
+ public:
94
+ /**
95
+ * Get shared instance
96
+ */
97
+ static DeviceBridge& shared();
98
+
99
+ /**
100
+ * Set platform callbacks
101
+ * Must be called during SDK initialization BEFORE registerCallbacks()
102
+ */
103
+ void setPlatformCallbacks(const DevicePlatformCallbacks& callbacks);
104
+
105
+ /**
106
+ * Register callbacks with RACommons device manager
107
+ * Must be called during SDK initialization after setPlatformCallbacks()
108
+ */
109
+ rac_result_t registerCallbacks();
110
+
111
+ /**
112
+ * Register device with backend if not already registered
113
+ * Delegates to rac_device_manager_register_if_needed()
114
+ *
115
+ * @param environment SDK environment
116
+ * @param buildToken Optional build token for development mode
117
+ * @return RAC_SUCCESS if registered or already registered
118
+ */
119
+ rac_result_t registerIfNeeded(rac_environment_t environment, const std::string& buildToken = "");
120
+
121
+ /**
122
+ * Check if device is registered
123
+ */
124
+ bool isRegistered() const;
125
+
126
+ /**
127
+ * Clear device registration status
128
+ */
129
+ void clearRegistration();
130
+
131
+ /**
132
+ * Get the device ID
133
+ */
134
+ std::string getDeviceId() const;
135
+
136
+ /**
137
+ * Check if callbacks are registered
138
+ */
139
+ bool isCallbacksRegistered() const { return callbacksRegistered_; }
140
+
141
+ private:
142
+ DeviceBridge() = default;
143
+ ~DeviceBridge() = default;
144
+ DeviceBridge(const DeviceBridge&) = delete;
145
+ DeviceBridge& operator=(const DeviceBridge&) = delete;
146
+
147
+ bool callbacksRegistered_ = false;
148
+ DevicePlatformCallbacks platformCallbacks_{};
149
+
150
+ // Callbacks struct for RACommons (must persist)
151
+ rac_device_callbacks_t racCallbacks_{};
152
+ };
153
+
154
+ } // namespace bridges
155
+ } // namespace runanywhere
@@ -0,0 +1,299 @@
1
+ /**
2
+ * @file DownloadBridge.cpp
3
+ * @brief C++ bridge for download operations.
4
+ *
5
+ * Mirrors Swift's CppBridge+Download.swift pattern.
6
+ */
7
+
8
+ #include "DownloadBridge.hpp"
9
+ #include <cstdlib>
10
+ #include <cstring>
11
+
12
+ // Platform-specific logging
13
+ #if defined(ANDROID) || defined(__ANDROID__)
14
+ #include <android/log.h>
15
+ #define LOG_TAG "DownloadBridge"
16
+ #define LOGI(...) __android_log_print(ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__)
17
+ #define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__)
18
+ #define LOGE(...) __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__)
19
+ #else
20
+ #include <cstdio>
21
+ #define LOGI(...) printf("[DownloadBridge] "); printf(__VA_ARGS__); printf("\n")
22
+ #define LOGD(...) printf("[DownloadBridge DEBUG] "); printf(__VA_ARGS__); printf("\n")
23
+ #define LOGE(...) printf("[DownloadBridge ERROR] "); printf(__VA_ARGS__); printf("\n")
24
+ #endif
25
+
26
+ namespace runanywhere {
27
+ namespace bridges {
28
+
29
+ DownloadBridge& DownloadBridge::shared() {
30
+ static DownloadBridge instance;
31
+ return instance;
32
+ }
33
+
34
+ DownloadBridge::~DownloadBridge() {
35
+ shutdown();
36
+ }
37
+
38
+ rac_result_t DownloadBridge::initialize(const DownloadConfig* config) {
39
+ if (handle_) {
40
+ LOGD("Download manager already initialized");
41
+ return RAC_SUCCESS;
42
+ }
43
+
44
+ // Setup config if provided
45
+ const rac_download_config_t* racConfig = nullptr;
46
+ rac_download_config_t configStruct = RAC_DOWNLOAD_CONFIG_DEFAULT;
47
+
48
+ if (config) {
49
+ configStruct.max_concurrent_downloads = config->maxConcurrentDownloads;
50
+ configStruct.request_timeout_seconds = config->requestTimeoutSeconds;
51
+ configStruct.max_retry_attempts = config->maxRetryAttempts;
52
+ configStruct.retry_delay_seconds = config->retryDelaySeconds;
53
+ configStruct.allow_cellular = config->allowCellular ? RAC_TRUE : RAC_FALSE;
54
+ configStruct.allow_constrained_network = config->allowConstrainedNetwork ? RAC_TRUE : RAC_FALSE;
55
+ racConfig = &configStruct;
56
+ }
57
+
58
+ // Create manager
59
+ rac_result_t result = rac_download_manager_create(racConfig, &handle_);
60
+
61
+ if (result == RAC_SUCCESS) {
62
+ LOGI("Download manager created successfully");
63
+ } else {
64
+ LOGE("Failed to create download manager: %d", result);
65
+ handle_ = nullptr;
66
+ }
67
+
68
+ return result;
69
+ }
70
+
71
+ void DownloadBridge::shutdown() {
72
+ if (handle_) {
73
+ rac_download_manager_destroy(handle_);
74
+ handle_ = nullptr;
75
+ progressCallbacks_.clear();
76
+ LOGI("Download manager destroyed");
77
+ }
78
+ }
79
+
80
+ std::string DownloadBridge::startDownload(
81
+ const std::string& modelId,
82
+ const std::string& url,
83
+ const std::string& destinationPath,
84
+ bool requiresExtraction,
85
+ std::function<void(const DownloadProgress&)> progressHandler
86
+ ) {
87
+ if (!handle_) {
88
+ LOGE("Download manager not initialized");
89
+ return "";
90
+ }
91
+
92
+ char* taskIdPtr = nullptr;
93
+
94
+ rac_result_t result = rac_download_manager_start(
95
+ handle_,
96
+ modelId.c_str(),
97
+ url.c_str(),
98
+ destinationPath.c_str(),
99
+ requiresExtraction ? RAC_TRUE : RAC_FALSE,
100
+ nullptr, // Progress callback - we poll instead
101
+ nullptr, // Complete callback - we poll instead
102
+ nullptr, // User data
103
+ &taskIdPtr
104
+ );
105
+
106
+ if (result != RAC_SUCCESS || !taskIdPtr) {
107
+ LOGE("Failed to start download: %d", result);
108
+ return "";
109
+ }
110
+
111
+ std::string taskId(taskIdPtr);
112
+ free(taskIdPtr);
113
+
114
+ // Store progress callback
115
+ if (progressHandler) {
116
+ progressCallbacks_[taskId] = progressHandler;
117
+ }
118
+
119
+ LOGI("Started download task: %s for model: %s", taskId.c_str(), modelId.c_str());
120
+ return taskId;
121
+ }
122
+
123
+ rac_result_t DownloadBridge::cancelDownload(const std::string& taskId) {
124
+ if (!handle_) {
125
+ return RAC_ERROR_NOT_INITIALIZED;
126
+ }
127
+
128
+ rac_result_t result = rac_download_manager_cancel(handle_, taskId.c_str());
129
+
130
+ if (result == RAC_SUCCESS) {
131
+ progressCallbacks_.erase(taskId);
132
+ LOGI("Cancelled download task: %s", taskId.c_str());
133
+ } else {
134
+ LOGE("Failed to cancel download %s: %d", taskId.c_str(), result);
135
+ }
136
+
137
+ return result;
138
+ }
139
+
140
+ rac_result_t DownloadBridge::pauseAll() {
141
+ if (!handle_) {
142
+ return RAC_ERROR_NOT_INITIALIZED;
143
+ }
144
+
145
+ rac_result_t result = rac_download_manager_pause_all(handle_);
146
+
147
+ if (result == RAC_SUCCESS) {
148
+ LOGI("Paused all downloads");
149
+ } else {
150
+ LOGE("Failed to pause downloads: %d", result);
151
+ }
152
+
153
+ return result;
154
+ }
155
+
156
+ rac_result_t DownloadBridge::resumeAll() {
157
+ if (!handle_) {
158
+ return RAC_ERROR_NOT_INITIALIZED;
159
+ }
160
+
161
+ rac_result_t result = rac_download_manager_resume_all(handle_);
162
+
163
+ if (result == RAC_SUCCESS) {
164
+ LOGI("Resumed all downloads");
165
+ } else {
166
+ LOGE("Failed to resume downloads: %d", result);
167
+ }
168
+
169
+ return result;
170
+ }
171
+
172
+ DownloadProgress DownloadBridge::fromRac(const rac_download_progress_t& cProgress) {
173
+ DownloadProgress progress;
174
+ progress.stage = static_cast<DownloadStage>(cProgress.stage);
175
+ progress.bytesDownloaded = cProgress.bytes_downloaded;
176
+ progress.totalBytes = cProgress.total_bytes;
177
+ progress.stageProgress = cProgress.stage_progress;
178
+ progress.overallProgress = cProgress.overall_progress;
179
+ progress.state = static_cast<DownloadState>(cProgress.state);
180
+ progress.speed = cProgress.speed;
181
+ progress.estimatedTimeRemaining = cProgress.estimated_time_remaining;
182
+ progress.retryAttempt = cProgress.retry_attempt;
183
+ progress.errorCode = cProgress.error_code;
184
+ progress.errorMessage = cProgress.error_message ? cProgress.error_message : "";
185
+ return progress;
186
+ }
187
+
188
+ std::optional<DownloadProgress> DownloadBridge::getProgress(const std::string& taskId) {
189
+ if (!handle_) {
190
+ return std::nullopt;
191
+ }
192
+
193
+ rac_download_progress_t cProgress = RAC_DOWNLOAD_PROGRESS_DEFAULT;
194
+ rac_result_t result = rac_download_manager_get_progress(handle_, taskId.c_str(), &cProgress);
195
+
196
+ if (result != RAC_SUCCESS) {
197
+ return std::nullopt;
198
+ }
199
+
200
+ return fromRac(cProgress);
201
+ }
202
+
203
+ std::vector<std::string> DownloadBridge::getActiveTasks() {
204
+ std::vector<std::string> tasks;
205
+
206
+ if (!handle_) {
207
+ return tasks;
208
+ }
209
+
210
+ char** taskIdsPtr = nullptr;
211
+ size_t count = 0;
212
+
213
+ rac_result_t result = rac_download_manager_get_active_tasks(handle_, &taskIdsPtr, &count);
214
+
215
+ if (result != RAC_SUCCESS || !taskIdsPtr) {
216
+ return tasks;
217
+ }
218
+
219
+ for (size_t i = 0; i < count; i++) {
220
+ if (taskIdsPtr[i]) {
221
+ tasks.push_back(taskIdsPtr[i]);
222
+ }
223
+ }
224
+
225
+ rac_download_task_ids_free(taskIdsPtr, count);
226
+
227
+ return tasks;
228
+ }
229
+
230
+ bool DownloadBridge::isHealthy() {
231
+ if (!handle_) {
232
+ return false;
233
+ }
234
+
235
+ rac_bool_t healthy = RAC_FALSE;
236
+ rac_result_t result = rac_download_manager_is_healthy(handle_, &healthy);
237
+
238
+ return result == RAC_SUCCESS && healthy == RAC_TRUE;
239
+ }
240
+
241
+ void DownloadBridge::updateProgress(const std::string& taskId, int64_t bytesDownloaded, int64_t totalBytes) {
242
+ if (!handle_) {
243
+ return;
244
+ }
245
+
246
+ rac_download_manager_update_progress(handle_, taskId.c_str(), bytesDownloaded, totalBytes);
247
+
248
+ // Notify callback
249
+ auto it = progressCallbacks_.find(taskId);
250
+ if (it != progressCallbacks_.end()) {
251
+ auto progress = getProgress(taskId);
252
+ if (progress) {
253
+ it->second(*progress);
254
+ }
255
+ }
256
+ }
257
+
258
+ void DownloadBridge::markComplete(const std::string& taskId, const std::string& downloadedPath) {
259
+ if (!handle_) {
260
+ return;
261
+ }
262
+
263
+ rac_download_manager_mark_complete(handle_, taskId.c_str(), downloadedPath.c_str());
264
+
265
+ // Notify final progress
266
+ auto it = progressCallbacks_.find(taskId);
267
+ if (it != progressCallbacks_.end()) {
268
+ auto progress = getProgress(taskId);
269
+ if (progress) {
270
+ it->second(*progress);
271
+ }
272
+ progressCallbacks_.erase(it);
273
+ }
274
+
275
+ LOGI("Download completed: %s", taskId.c_str());
276
+ }
277
+
278
+ void DownloadBridge::markFailed(const std::string& taskId, rac_result_t errorCode, const std::string& errorMessage) {
279
+ if (!handle_) {
280
+ return;
281
+ }
282
+
283
+ rac_download_manager_mark_failed(handle_, taskId.c_str(), errorCode, errorMessage.c_str());
284
+
285
+ // Notify final progress
286
+ auto it = progressCallbacks_.find(taskId);
287
+ if (it != progressCallbacks_.end()) {
288
+ auto progress = getProgress(taskId);
289
+ if (progress) {
290
+ it->second(*progress);
291
+ }
292
+ progressCallbacks_.erase(it);
293
+ }
294
+
295
+ LOGE("Download failed: %s - %s", taskId.c_str(), errorMessage.c_str());
296
+ }
297
+
298
+ } // namespace bridges
299
+ } // namespace runanywhere