@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,271 @@
1
+ #include <jni.h>
2
+ #include <string>
3
+ #include <android/log.h>
4
+ #include "runanywherecoreOnLoad.hpp"
5
+
6
+ #define LOG_TAG "ArchiveJNI"
7
+ #define LOGI(...) __android_log_print(ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__)
8
+ #define LOGE(...) __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__)
9
+
10
+ // Store JavaVM globally for JNI calls from background threads
11
+ // NOT static - needs to be accessible from InitBridge.cpp for secure storage
12
+ JavaVM* g_javaVM = nullptr;
13
+
14
+ // Cache class and method references at JNI_OnLoad time
15
+ // This is necessary because FindClass from native threads uses the system class loader
16
+ static jclass g_archiveUtilityClass = nullptr;
17
+ static jmethodID g_extractMethod = nullptr;
18
+
19
+ // PlatformAdapterBridge class and methods for secure storage (used by InitBridge.cpp)
20
+ // NOT static - needs to be accessible from InitBridge.cpp
21
+ jclass g_platformAdapterBridgeClass = nullptr;
22
+ jclass g_httpResponseClass = nullptr; // Inner class for httpPostSync response
23
+ jmethodID g_secureSetMethod = nullptr;
24
+ jmethodID g_secureGetMethod = nullptr;
25
+ jmethodID g_secureDeleteMethod = nullptr;
26
+ jmethodID g_secureExistsMethod = nullptr;
27
+ jmethodID g_getPersistentDeviceUUIDMethod = nullptr;
28
+ jmethodID g_httpPostSyncMethod = nullptr;
29
+ jmethodID g_getDeviceModelMethod = nullptr;
30
+ jmethodID g_getOSVersionMethod = nullptr;
31
+ jmethodID g_getChipNameMethod = nullptr;
32
+ jmethodID g_getTotalMemoryMethod = nullptr;
33
+ jmethodID g_getAvailableMemoryMethod = nullptr;
34
+ jmethodID g_getCoreCountMethod = nullptr;
35
+ jmethodID g_getArchitectureMethod = nullptr;
36
+ jmethodID g_getGPUFamilyMethod = nullptr;
37
+ jmethodID g_isTabletMethod = nullptr;
38
+ // HttpResponse field IDs
39
+ jfieldID g_httpResponse_successField = nullptr;
40
+ jfieldID g_httpResponse_statusCodeField = nullptr;
41
+ jfieldID g_httpResponse_responseBodyField = nullptr;
42
+ jfieldID g_httpResponse_errorMessageField = nullptr;
43
+
44
+ // Forward declaration
45
+ extern "C" bool ArchiveUtility_extractAndroid(const char* archivePath, const char* destinationPath);
46
+
47
+ JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void*) {
48
+ g_javaVM = vm;
49
+
50
+ // Get JNIEnv to cache class references
51
+ JNIEnv* env = nullptr;
52
+ if (vm->GetEnv(reinterpret_cast<void**>(&env), JNI_VERSION_1_6) == JNI_OK && env != nullptr) {
53
+ // Find and cache the ArchiveUtility class
54
+ jclass localClass = env->FindClass("com/margelo/nitro/runanywhere/ArchiveUtility");
55
+ if (localClass != nullptr) {
56
+ // Create a global reference so it persists across JNI calls
57
+ g_archiveUtilityClass = (jclass)env->NewGlobalRef(localClass);
58
+ env->DeleteLocalRef(localClass);
59
+
60
+ // Cache the extract method
61
+ g_extractMethod = env->GetStaticMethodID(
62
+ g_archiveUtilityClass,
63
+ "extract",
64
+ "(Ljava/lang/String;Ljava/lang/String;)Z"
65
+ );
66
+
67
+ if (g_extractMethod != nullptr) {
68
+ LOGI("ArchiveUtility class and method cached successfully");
69
+ } else {
70
+ LOGE("Failed to find extract method in ArchiveUtility");
71
+ if (env->ExceptionCheck()) {
72
+ env->ExceptionClear();
73
+ }
74
+ }
75
+ } else {
76
+ LOGE("Failed to find ArchiveUtility class at JNI_OnLoad");
77
+ if (env->ExceptionCheck()) {
78
+ env->ExceptionClear();
79
+ }
80
+ }
81
+
82
+ // Find and cache the PlatformAdapterBridge class (for secure storage)
83
+ jclass platformClass = env->FindClass("com/margelo/nitro/runanywhere/PlatformAdapterBridge");
84
+ if (platformClass != nullptr) {
85
+ g_platformAdapterBridgeClass = (jclass)env->NewGlobalRef(platformClass);
86
+ env->DeleteLocalRef(platformClass);
87
+
88
+ // Cache all methods we need
89
+ g_secureSetMethod = env->GetStaticMethodID(g_platformAdapterBridgeClass, "secureSet", "(Ljava/lang/String;Ljava/lang/String;)Z");
90
+ g_secureGetMethod = env->GetStaticMethodID(g_platformAdapterBridgeClass, "secureGet", "(Ljava/lang/String;)Ljava/lang/String;");
91
+ g_secureDeleteMethod = env->GetStaticMethodID(g_platformAdapterBridgeClass, "secureDelete", "(Ljava/lang/String;)Z");
92
+ g_secureExistsMethod = env->GetStaticMethodID(g_platformAdapterBridgeClass, "secureExists", "(Ljava/lang/String;)Z");
93
+ g_getPersistentDeviceUUIDMethod = env->GetStaticMethodID(g_platformAdapterBridgeClass, "getPersistentDeviceUUID", "()Ljava/lang/String;");
94
+ g_httpPostSyncMethod = env->GetStaticMethodID(g_platformAdapterBridgeClass, "httpPostSync", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Lcom/margelo/nitro/runanywhere/PlatformAdapterBridge$HttpResponse;");
95
+ g_getDeviceModelMethod = env->GetStaticMethodID(g_platformAdapterBridgeClass, "getDeviceModel", "()Ljava/lang/String;");
96
+ g_getOSVersionMethod = env->GetStaticMethodID(g_platformAdapterBridgeClass, "getOSVersion", "()Ljava/lang/String;");
97
+ g_getChipNameMethod = env->GetStaticMethodID(g_platformAdapterBridgeClass, "getChipName", "()Ljava/lang/String;");
98
+ g_getTotalMemoryMethod = env->GetStaticMethodID(g_platformAdapterBridgeClass, "getTotalMemory", "()J");
99
+ g_getAvailableMemoryMethod = env->GetStaticMethodID(g_platformAdapterBridgeClass, "getAvailableMemory", "()J");
100
+ g_getCoreCountMethod = env->GetStaticMethodID(g_platformAdapterBridgeClass, "getCoreCount", "()I");
101
+ g_getArchitectureMethod = env->GetStaticMethodID(g_platformAdapterBridgeClass, "getArchitecture", "()Ljava/lang/String;");
102
+ g_getGPUFamilyMethod = env->GetStaticMethodID(g_platformAdapterBridgeClass, "getGPUFamily", "()Ljava/lang/String;");
103
+ g_isTabletMethod = env->GetStaticMethodID(g_platformAdapterBridgeClass, "isTablet", "()Z");
104
+
105
+ if (g_secureSetMethod && g_secureGetMethod && g_getPersistentDeviceUUIDMethod &&
106
+ g_getDeviceModelMethod && g_getOSVersionMethod && g_getChipNameMethod &&
107
+ g_getTotalMemoryMethod && g_getAvailableMemoryMethod && g_getCoreCountMethod &&
108
+ g_getArchitectureMethod && g_getGPUFamilyMethod && g_isTabletMethod) {
109
+ LOGI("PlatformAdapterBridge class and methods cached successfully");
110
+ } else {
111
+ LOGE("Failed to cache some PlatformAdapterBridge methods");
112
+ if (env->ExceptionCheck()) {
113
+ env->ExceptionClear();
114
+ }
115
+ }
116
+
117
+ // Cache HttpResponse inner class and its fields
118
+ jclass responseClass = env->FindClass("com/margelo/nitro/runanywhere/PlatformAdapterBridge$HttpResponse");
119
+ if (responseClass != nullptr) {
120
+ g_httpResponseClass = (jclass)env->NewGlobalRef(responseClass);
121
+ env->DeleteLocalRef(responseClass);
122
+
123
+ g_httpResponse_successField = env->GetFieldID(g_httpResponseClass, "success", "Z");
124
+ g_httpResponse_statusCodeField = env->GetFieldID(g_httpResponseClass, "statusCode", "I");
125
+ g_httpResponse_responseBodyField = env->GetFieldID(g_httpResponseClass, "responseBody", "Ljava/lang/String;");
126
+ g_httpResponse_errorMessageField = env->GetFieldID(g_httpResponseClass, "errorMessage", "Ljava/lang/String;");
127
+
128
+ if (g_httpResponse_successField && g_httpResponse_statusCodeField) {
129
+ LOGI("HttpResponse class and fields cached successfully");
130
+ } else {
131
+ LOGE("Failed to cache HttpResponse fields");
132
+ }
133
+ } else {
134
+ LOGE("Failed to find HttpResponse inner class at JNI_OnLoad");
135
+ if (env->ExceptionCheck()) {
136
+ env->ExceptionClear();
137
+ }
138
+ }
139
+ } else {
140
+ LOGE("Failed to find PlatformAdapterBridge class at JNI_OnLoad");
141
+ if (env->ExceptionCheck()) {
142
+ env->ExceptionClear();
143
+ }
144
+ }
145
+ }
146
+
147
+ return margelo::nitro::runanywhere::initialize(vm);
148
+ }
149
+
150
+ /**
151
+ * Get JNIEnv for the current thread
152
+ * Attaches thread if not already attached
153
+ */
154
+ static JNIEnv* getJNIEnv() {
155
+ JNIEnv* env = nullptr;
156
+ if (g_javaVM == nullptr) {
157
+ LOGE("JavaVM is null");
158
+ return nullptr;
159
+ }
160
+
161
+ int status = g_javaVM->GetEnv(reinterpret_cast<void**>(&env), JNI_VERSION_1_6);
162
+ if (status == JNI_EDETACHED) {
163
+ if (g_javaVM->AttachCurrentThread(&env, nullptr) != JNI_OK) {
164
+ LOGE("Failed to attach thread");
165
+ return nullptr;
166
+ }
167
+ LOGI("Attached thread to JVM");
168
+ } else if (status != JNI_OK) {
169
+ LOGE("Failed to get JNIEnv, status=%d", status);
170
+ return nullptr;
171
+ }
172
+ return env;
173
+ }
174
+
175
+ /**
176
+ * Log Java exception details before clearing
177
+ */
178
+ static void logAndClearException(JNIEnv* env, const char* context) {
179
+ if (env->ExceptionCheck()) {
180
+ jthrowable exception = env->ExceptionOccurred();
181
+ env->ExceptionClear();
182
+
183
+ // Get exception message
184
+ jclass throwableClass = env->FindClass("java/lang/Throwable");
185
+ if (throwableClass) {
186
+ jmethodID getMessageMethod = env->GetMethodID(throwableClass, "getMessage", "()Ljava/lang/String;");
187
+ if (getMessageMethod) {
188
+ jstring messageStr = (jstring)env->CallObjectMethod(exception, getMessageMethod);
189
+ if (messageStr) {
190
+ const char* message = env->GetStringUTFChars(messageStr, nullptr);
191
+ LOGE("[%s] Java exception: %s", context, message);
192
+ env->ReleaseStringUTFChars(messageStr, message);
193
+ env->DeleteLocalRef(messageStr);
194
+ } else {
195
+ LOGE("[%s] Java exception (no message)", context);
196
+ }
197
+ }
198
+ env->DeleteLocalRef(throwableClass);
199
+ }
200
+
201
+ // Also print stack trace to logcat
202
+ jclass exceptionClass = env->GetObjectClass(exception);
203
+ if (exceptionClass) {
204
+ jmethodID printStackTraceMethod = env->GetMethodID(exceptionClass, "printStackTrace", "()V");
205
+ if (printStackTraceMethod) {
206
+ env->CallVoidMethod(exception, printStackTraceMethod);
207
+ env->ExceptionClear(); // Clear any exception from printStackTrace
208
+ }
209
+ env->DeleteLocalRef(exceptionClass);
210
+ }
211
+
212
+ env->DeleteLocalRef(exception);
213
+ }
214
+ }
215
+
216
+ /**
217
+ * Call Kotlin ArchiveUtility.extract() via JNI
218
+ * Uses cached class and method references from JNI_OnLoad
219
+ */
220
+ extern "C" bool ArchiveUtility_extractAndroid(const char* archivePath, const char* destinationPath) {
221
+ LOGI("Starting extraction: %s -> %s", archivePath, destinationPath);
222
+
223
+ // Check if class and method were cached
224
+ if (g_archiveUtilityClass == nullptr || g_extractMethod == nullptr) {
225
+ LOGE("ArchiveUtility class or method not cached. JNI_OnLoad may have failed.");
226
+ return false;
227
+ }
228
+
229
+ JNIEnv* env = getJNIEnv();
230
+ if (env == nullptr) {
231
+ LOGE("Failed to get JNIEnv");
232
+ return false;
233
+ }
234
+
235
+ LOGI("Using cached ArchiveUtility class and method");
236
+
237
+ // Create Java strings
238
+ jstring jArchivePath = env->NewStringUTF(archivePath);
239
+ jstring jDestinationPath = env->NewStringUTF(destinationPath);
240
+
241
+ if (jArchivePath == nullptr || jDestinationPath == nullptr) {
242
+ LOGE("Failed to create Java strings");
243
+ if (jArchivePath) env->DeleteLocalRef(jArchivePath);
244
+ if (jDestinationPath) env->DeleteLocalRef(jDestinationPath);
245
+ return false;
246
+ }
247
+
248
+ // Call the method using cached references
249
+ LOGI("Calling ArchiveUtility.extract()...");
250
+ jboolean result = env->CallStaticBooleanMethod(
251
+ g_archiveUtilityClass,
252
+ g_extractMethod,
253
+ jArchivePath,
254
+ jDestinationPath
255
+ );
256
+
257
+ // Check for exceptions
258
+ if (env->ExceptionCheck()) {
259
+ LOGE("Exception during extraction");
260
+ logAndClearException(env, "extract");
261
+ result = JNI_FALSE;
262
+ } else {
263
+ LOGI("Extraction returned: %s", result ? "true" : "false");
264
+ }
265
+
266
+ // Cleanup local references
267
+ env->DeleteLocalRef(jArchivePath);
268
+ env->DeleteLocalRef(jDestinationPath);
269
+
270
+ return result == JNI_TRUE;
271
+ }
@@ -0,0 +1,218 @@
1
+ /**
2
+ * @file rac_llm_llamacpp.h
3
+ * @brief RunAnywhere Core - LlamaCPP Backend RAC API
4
+ *
5
+ * Direct RAC API export from runanywhere-core's LlamaCPP backend.
6
+ * This header defines the public C API for LLM inference using llama.cpp.
7
+ *
8
+ * Mirrors Swift's LlamaCPPService implementation pattern.
9
+ */
10
+
11
+ #ifndef RAC_LLM_LLAMACPP_H
12
+ #define RAC_LLM_LLAMACPP_H
13
+
14
+ #include "rac/core/rac_error.h"
15
+ #include "rac/core/rac_types.h"
16
+ #include "rac/features/llm/rac_llm.h"
17
+
18
+ #ifdef __cplusplus
19
+ extern "C" {
20
+ #endif
21
+
22
+ // =============================================================================
23
+ // EXPORT MACRO
24
+ // =============================================================================
25
+
26
+ #if defined(RAC_LLAMACPP_BUILDING)
27
+ #if defined(_WIN32)
28
+ #define RAC_LLAMACPP_API __declspec(dllexport)
29
+ #elif defined(__GNUC__) || defined(__clang__)
30
+ #define RAC_LLAMACPP_API __attribute__((visibility("default")))
31
+ #else
32
+ #define RAC_LLAMACPP_API
33
+ #endif
34
+ #else
35
+ #define RAC_LLAMACPP_API
36
+ #endif
37
+
38
+ // =============================================================================
39
+ // CONFIGURATION - Mirrors Swift's LlamaCPPGenerationConfig
40
+ // =============================================================================
41
+
42
+ /**
43
+ * LlamaCPP-specific configuration.
44
+ *
45
+ * Mirrors Swift's LlamaCPPGenerationConfig.
46
+ */
47
+ typedef struct rac_llm_llamacpp_config {
48
+ /** Context size (0 = auto-detect from model) */
49
+ int32_t context_size;
50
+
51
+ /** Number of threads (0 = auto-detect) */
52
+ int32_t num_threads;
53
+
54
+ /** Number of layers to offload to GPU (Metal on iOS/macOS) */
55
+ int32_t gpu_layers;
56
+
57
+ /** Batch size for prompt processing */
58
+ int32_t batch_size;
59
+ } rac_llm_llamacpp_config_t;
60
+
61
+ /**
62
+ * Default LlamaCPP configuration.
63
+ */
64
+ static const rac_llm_llamacpp_config_t RAC_LLM_LLAMACPP_CONFIG_DEFAULT = {
65
+ .context_size = 0, // Auto-detect
66
+ .num_threads = 0, // Auto-detect
67
+ .gpu_layers = -1, // All layers on GPU
68
+ .batch_size = 512};
69
+
70
+ // =============================================================================
71
+ // LLAMACPP-SPECIFIC API
72
+ // =============================================================================
73
+
74
+ /**
75
+ * Creates a LlamaCPP LLM service.
76
+ *
77
+ * Mirrors Swift's LlamaCPPService.initialize(modelPath:)
78
+ *
79
+ * @param model_path Path to the GGUF model file
80
+ * @param config LlamaCPP-specific configuration (can be NULL for defaults)
81
+ * @param out_handle Output: Handle to the created service
82
+ * @return RAC_SUCCESS or error code
83
+ */
84
+ RAC_LLAMACPP_API rac_result_t rac_llm_llamacpp_create(const char* model_path,
85
+ const rac_llm_llamacpp_config_t* config,
86
+ rac_handle_t* out_handle);
87
+
88
+ /**
89
+ * Loads a GGUF model into an existing service.
90
+ *
91
+ * Mirrors Swift's LlamaCPPService.loadModel(path:config:)
92
+ *
93
+ * @param handle Service handle
94
+ * @param model_path Path to the GGUF model file
95
+ * @param config LlamaCPP configuration (can be NULL)
96
+ * @return RAC_SUCCESS or error code
97
+ */
98
+ RAC_LLAMACPP_API rac_result_t rac_llm_llamacpp_load_model(rac_handle_t handle,
99
+ const char* model_path,
100
+ const rac_llm_llamacpp_config_t* config);
101
+
102
+ /**
103
+ * Unloads the current model.
104
+ *
105
+ * Mirrors Swift's LlamaCPPService.unloadModel()
106
+ *
107
+ * @param handle Service handle
108
+ * @return RAC_SUCCESS or error code
109
+ */
110
+ RAC_LLAMACPP_API rac_result_t rac_llm_llamacpp_unload_model(rac_handle_t handle);
111
+
112
+ /**
113
+ * Checks if a model is loaded.
114
+ *
115
+ * Mirrors Swift's LlamaCPPService.isModelLoaded
116
+ *
117
+ * @param handle Service handle
118
+ * @return RAC_TRUE if model is loaded, RAC_FALSE otherwise
119
+ */
120
+ RAC_LLAMACPP_API rac_bool_t rac_llm_llamacpp_is_model_loaded(rac_handle_t handle);
121
+
122
+ /**
123
+ * Generates text completion.
124
+ *
125
+ * Mirrors Swift's LlamaCPPService.generate(prompt:config:)
126
+ *
127
+ * @param handle Service handle
128
+ * @param prompt Input prompt text
129
+ * @param options Generation options (can be NULL for defaults)
130
+ * @param out_result Output: Generation result (caller must free text with rac_free)
131
+ * @return RAC_SUCCESS or error code
132
+ */
133
+ RAC_LLAMACPP_API rac_result_t rac_llm_llamacpp_generate(rac_handle_t handle, const char* prompt,
134
+ const rac_llm_options_t* options,
135
+ rac_llm_result_t* out_result);
136
+
137
+ /**
138
+ * Streaming text generation callback.
139
+ *
140
+ * Mirrors Swift's streaming callback pattern.
141
+ *
142
+ * @param token Generated token string
143
+ * @param is_final Whether this is the final token
144
+ * @param user_data User-provided context
145
+ * @return RAC_TRUE to continue, RAC_FALSE to stop
146
+ */
147
+ typedef rac_bool_t (*rac_llm_llamacpp_stream_callback_fn)(const char* token, rac_bool_t is_final,
148
+ void* user_data);
149
+
150
+ /**
151
+ * Generates text with streaming callback.
152
+ *
153
+ * Mirrors Swift's LlamaCPPService.generateStream(prompt:config:)
154
+ *
155
+ * @param handle Service handle
156
+ * @param prompt Input prompt text
157
+ * @param options Generation options
158
+ * @param callback Callback for each token
159
+ * @param user_data User context passed to callback
160
+ * @return RAC_SUCCESS or error code
161
+ */
162
+ RAC_LLAMACPP_API rac_result_t rac_llm_llamacpp_generate_stream(
163
+ rac_handle_t handle, const char* prompt, const rac_llm_options_t* options,
164
+ rac_llm_llamacpp_stream_callback_fn callback, void* user_data);
165
+
166
+ /**
167
+ * Cancels ongoing generation.
168
+ *
169
+ * Mirrors Swift's LlamaCPPService.cancel()
170
+ *
171
+ * @param handle Service handle
172
+ */
173
+ RAC_LLAMACPP_API void rac_llm_llamacpp_cancel(rac_handle_t handle);
174
+
175
+ /**
176
+ * Gets model information as JSON.
177
+ *
178
+ * @param handle Service handle
179
+ * @param out_json Output: JSON string (caller must free with rac_free)
180
+ * @return RAC_SUCCESS or error code
181
+ */
182
+ RAC_LLAMACPP_API rac_result_t rac_llm_llamacpp_get_model_info(rac_handle_t handle, char** out_json);
183
+
184
+ /**
185
+ * Destroys a LlamaCPP LLM service.
186
+ *
187
+ * @param handle Service handle to destroy
188
+ */
189
+ RAC_LLAMACPP_API void rac_llm_llamacpp_destroy(rac_handle_t handle);
190
+
191
+ // =============================================================================
192
+ // BACKEND REGISTRATION
193
+ // =============================================================================
194
+
195
+ /**
196
+ * Registers the LlamaCPP backend with the commons module and service registries.
197
+ *
198
+ * Should be called once during SDK initialization.
199
+ * This registers:
200
+ * - Module: "llamacpp" with TEXT_GENERATION capability
201
+ * - Service provider: LlamaCPP LLM provider
202
+ *
203
+ * @return RAC_SUCCESS or error code
204
+ */
205
+ RAC_LLAMACPP_API rac_result_t rac_backend_llamacpp_register(void);
206
+
207
+ /**
208
+ * Unregisters the LlamaCPP backend.
209
+ *
210
+ * @return RAC_SUCCESS or error code
211
+ */
212
+ RAC_LLAMACPP_API rac_result_t rac_backend_llamacpp_unregister(void);
213
+
214
+ #ifdef __cplusplus
215
+ }
216
+ #endif
217
+
218
+ #endif /* RAC_LLM_LLAMACPP_H */
@@ -0,0 +1,99 @@
1
+ /**
2
+ * @file rac_stt_onnx.h
3
+ * @brief RunAnywhere Core - ONNX Backend RAC API for STT
4
+ *
5
+ * Direct RAC API export from runanywhere-core's ONNX STT backend.
6
+ * Mirrors Swift's ONNXSTTService implementation pattern.
7
+ */
8
+
9
+ #ifndef RAC_STT_ONNX_H
10
+ #define RAC_STT_ONNX_H
11
+
12
+ #include "rac/core/rac_error.h"
13
+ #include "rac/core/rac_types.h"
14
+ #include "rac/features/stt/rac_stt.h"
15
+
16
+ #ifdef __cplusplus
17
+ extern "C" {
18
+ #endif
19
+
20
+ // =============================================================================
21
+ // EXPORT MACRO
22
+ // =============================================================================
23
+
24
+ #if defined(RAC_ONNX_BUILDING)
25
+ #if defined(_WIN32)
26
+ #define RAC_ONNX_API __declspec(dllexport)
27
+ #elif defined(__GNUC__) || defined(__clang__)
28
+ #define RAC_ONNX_API __attribute__((visibility("default")))
29
+ #else
30
+ #define RAC_ONNX_API
31
+ #endif
32
+ #else
33
+ #define RAC_ONNX_API
34
+ #endif
35
+
36
+ // =============================================================================
37
+ // CONFIGURATION
38
+ // =============================================================================
39
+
40
+ /**
41
+ * ONNX STT model types.
42
+ */
43
+ typedef enum rac_stt_onnx_model_type {
44
+ RAC_STT_ONNX_MODEL_WHISPER = 0,
45
+ RAC_STT_ONNX_MODEL_ZIPFORMER = 1,
46
+ RAC_STT_ONNX_MODEL_PARAFORMER = 2,
47
+ RAC_STT_ONNX_MODEL_AUTO = 99
48
+ } rac_stt_onnx_model_type_t;
49
+
50
+ /**
51
+ * ONNX STT configuration.
52
+ */
53
+ typedef struct rac_stt_onnx_config {
54
+ rac_stt_onnx_model_type_t model_type;
55
+ int32_t num_threads;
56
+ rac_bool_t use_coreml;
57
+ } rac_stt_onnx_config_t;
58
+
59
+ static const rac_stt_onnx_config_t RAC_STT_ONNX_CONFIG_DEFAULT = {
60
+ .model_type = RAC_STT_ONNX_MODEL_AUTO, .num_threads = 0, .use_coreml = RAC_TRUE};
61
+
62
+ // =============================================================================
63
+ // ONNX STT API
64
+ // =============================================================================
65
+
66
+ RAC_ONNX_API rac_result_t rac_stt_onnx_create(const char* model_path,
67
+ const rac_stt_onnx_config_t* config,
68
+ rac_handle_t* out_handle);
69
+
70
+ RAC_ONNX_API rac_result_t rac_stt_onnx_transcribe(rac_handle_t handle, const float* audio_samples,
71
+ size_t num_samples,
72
+ const rac_stt_options_t* options,
73
+ rac_stt_result_t* out_result);
74
+
75
+ RAC_ONNX_API rac_bool_t rac_stt_onnx_supports_streaming(rac_handle_t handle);
76
+
77
+ RAC_ONNX_API rac_result_t rac_stt_onnx_create_stream(rac_handle_t handle, rac_handle_t* out_stream);
78
+
79
+ RAC_ONNX_API rac_result_t rac_stt_onnx_feed_audio(rac_handle_t handle, rac_handle_t stream,
80
+ const float* audio_samples, size_t num_samples);
81
+
82
+ RAC_ONNX_API rac_bool_t rac_stt_onnx_stream_is_ready(rac_handle_t handle, rac_handle_t stream);
83
+
84
+ RAC_ONNX_API rac_result_t rac_stt_onnx_decode_stream(rac_handle_t handle, rac_handle_t stream,
85
+ char** out_text);
86
+
87
+ RAC_ONNX_API void rac_stt_onnx_input_finished(rac_handle_t handle, rac_handle_t stream);
88
+
89
+ RAC_ONNX_API rac_bool_t rac_stt_onnx_is_endpoint(rac_handle_t handle, rac_handle_t stream);
90
+
91
+ RAC_ONNX_API void rac_stt_onnx_destroy_stream(rac_handle_t handle, rac_handle_t stream);
92
+
93
+ RAC_ONNX_API void rac_stt_onnx_destroy(rac_handle_t handle);
94
+
95
+ #ifdef __cplusplus
96
+ }
97
+ #endif
98
+
99
+ #endif /* RAC_STT_ONNX_H */