@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,214 @@
1
+ import Foundation
2
+ import NitroModules
3
+ import UIKit
4
+
5
+ /// Swift implementation of RunAnywhereDeviceInfo HybridObject
6
+ /// Mirrors: sdk/runanywhere-swift/Sources/RunAnywhere/Infrastructure/Device/Models/Domain/DeviceInfo.swift
7
+ class HybridRunAnywhereDeviceInfo: HybridRunAnywhereDeviceInfoSpec {
8
+
9
+ // MARK: - Model Lookup Tables (from Swift SDK)
10
+
11
+ private static let deviceModels: [String: String] = [
12
+ // iPhone 17 (2025)
13
+ "iPhone18,1": "iPhone 17 Pro", "iPhone18,2": "iPhone 17 Pro Max",
14
+ "iPhone18,3": "iPhone 17", "iPhone18,4": "iPhone 17 Plus",
15
+ // iPhone 16 (2024)
16
+ "iPhone17,1": "iPhone 16 Pro", "iPhone17,2": "iPhone 16 Pro Max",
17
+ "iPhone17,3": "iPhone 16", "iPhone17,4": "iPhone 16 Plus",
18
+ // iPhone 15 (2023)
19
+ "iPhone16,1": "iPhone 15 Pro", "iPhone16,2": "iPhone 15 Pro Max",
20
+ "iPhone15,4": "iPhone 15", "iPhone15,5": "iPhone 15 Plus",
21
+ // iPhone 14 (2022)
22
+ "iPhone15,2": "iPhone 14 Pro", "iPhone15,3": "iPhone 14 Pro Max",
23
+ "iPhone14,7": "iPhone 14", "iPhone14,8": "iPhone 14 Plus",
24
+ // iPhone 13 (2021)
25
+ "iPhone14,2": "iPhone 13 Pro", "iPhone14,3": "iPhone 13 Pro Max",
26
+ "iPhone14,4": "iPhone 13 mini", "iPhone14,5": "iPhone 13",
27
+ // iPhone 12 (2020)
28
+ "iPhone13,1": "iPhone 12 mini", "iPhone13,2": "iPhone 12",
29
+ "iPhone13,3": "iPhone 12 Pro", "iPhone13,4": "iPhone 12 Pro Max",
30
+ // iPhone SE
31
+ "iPhone14,6": "iPhone SE (3rd gen)", "iPhone12,8": "iPhone SE (2nd gen)",
32
+ // iPad Pro M4 (2024)
33
+ "iPad16,3": "iPad Pro 11-inch (M4)", "iPad16,4": "iPad Pro 11-inch (M4)",
34
+ "iPad16,5": "iPad Pro 13-inch (M4)", "iPad16,6": "iPad Pro 13-inch (M4)",
35
+ // iPad Pro M2 (2022)
36
+ "iPad14,3": "iPad Pro 11-inch (M2)", "iPad14,4": "iPad Pro 11-inch (M2)",
37
+ "iPad14,5": "iPad Pro 12.9-inch (M2)", "iPad14,6": "iPad Pro 12.9-inch (M2)",
38
+ // iPad Air
39
+ "iPad14,8": "iPad Air (M2)", "iPad14,9": "iPad Air (M2)",
40
+ "iPad13,16": "iPad Air (5th gen)", "iPad13,17": "iPad Air (5th gen)"
41
+ ]
42
+
43
+ // MARK: - Get Machine Identifier
44
+
45
+ private static func getMachineIdentifier() -> String {
46
+ var sysinfo = utsname()
47
+ uname(&sysinfo)
48
+ return withUnsafePointer(to: &sysinfo.machine) {
49
+ $0.withMemoryRebound(to: CChar.self, capacity: 1) {
50
+ String(validatingUTF8: $0) ?? "Unknown"
51
+ }
52
+ }
53
+ }
54
+
55
+ // MARK: - Chip Name Lookup (from Swift SDK)
56
+
57
+ private static func getChipNameForModel(_ identifier: String) -> String {
58
+ if identifier.hasPrefix("iPhone18,") { return "A19 Pro" }
59
+ if identifier.hasPrefix("iPhone17,1") || identifier.hasPrefix("iPhone17,2") { return "A18 Pro" }
60
+ if identifier.hasPrefix("iPhone17,") { return "A18" }
61
+ if identifier.hasPrefix("iPhone16,") { return "A17 Pro" }
62
+ if identifier.hasPrefix("iPhone15,2") || identifier.hasPrefix("iPhone15,3") { return "A16 Bionic" }
63
+ if identifier.hasPrefix("iPhone15,") { return "A16 Bionic" }
64
+ if identifier.hasPrefix("iPhone14,") { return "A15 Bionic" }
65
+ if identifier.hasPrefix("iPhone13,") { return "A14 Bionic" }
66
+ if identifier.hasPrefix("iPhone12,") { return "A13 Bionic" }
67
+ if identifier.hasPrefix("iPad16,") { return "M4" }
68
+ if identifier.hasPrefix("iPad14,3") || identifier.hasPrefix("iPad14,4") ||
69
+ identifier.hasPrefix("iPad14,5") || identifier.hasPrefix("iPad14,6") { return "M2" }
70
+ if identifier.hasPrefix("iPad14,8") || identifier.hasPrefix("iPad14,9") { return "M2" }
71
+ if identifier.hasPrefix("iPad13,") { return "M1" }
72
+
73
+ #if arch(arm64)
74
+ return "Apple Silicon"
75
+ #else
76
+ return "Intel"
77
+ #endif
78
+ }
79
+
80
+ // MARK: - HybridObject Implementation
81
+
82
+ func getDeviceModel() throws -> Promise<String> {
83
+ return Promise.async {
84
+ let machineId = Self.getMachineIdentifier()
85
+
86
+ // Check simulator
87
+ #if targetEnvironment(simulator)
88
+ if let simModelId = ProcessInfo.processInfo.environment["SIMULATOR_MODEL_IDENTIFIER"] {
89
+ return Self.deviceModels[simModelId] ?? "iOS Simulator"
90
+ }
91
+ return "iOS Simulator"
92
+ #else
93
+ // Look up friendly model name
94
+ return Self.deviceModels[machineId] ?? UIDevice.current.model
95
+ #endif
96
+ }
97
+ }
98
+
99
+ func getOSVersion() throws -> Promise<String> {
100
+ return Promise.async {
101
+ return UIDevice.current.systemVersion
102
+ }
103
+ }
104
+
105
+ func getPlatform() throws -> Promise<String> {
106
+ return Promise.async {
107
+ return "ios"
108
+ }
109
+ }
110
+
111
+ func getTotalRAM() throws -> Promise<Double> {
112
+ return Promise.async {
113
+ return Double(ProcessInfo.processInfo.physicalMemory)
114
+ }
115
+ }
116
+
117
+ func getAvailableRAM() throws -> Promise<Double> {
118
+ return Promise.async {
119
+ var info = mach_task_basic_info()
120
+ var count = mach_msg_type_number_t(MemoryLayout<mach_task_basic_info>.size)/4
121
+ let kerr: kern_return_t = withUnsafeMutablePointer(to: &info) {
122
+ $0.withMemoryRebound(to: integer_t.self, capacity: 1) {
123
+ task_info(mach_task_self_, task_flavor_t(MACH_TASK_BASIC_INFO), $0, &count)
124
+ }
125
+ }
126
+ if kerr == KERN_SUCCESS {
127
+ let usedMemory = Double(info.resident_size)
128
+ let totalMemory = Double(ProcessInfo.processInfo.physicalMemory)
129
+ return totalMemory - usedMemory
130
+ }
131
+ return Double(ProcessInfo.processInfo.physicalMemory) / 2
132
+ }
133
+ }
134
+
135
+ func getCPUCores() throws -> Promise<Double> {
136
+ return Promise.async {
137
+ return Double(ProcessInfo.processInfo.processorCount)
138
+ }
139
+ }
140
+
141
+ func hasGPU() throws -> Promise<Bool> {
142
+ return Promise.async {
143
+ // iOS devices always have GPU
144
+ return true
145
+ }
146
+ }
147
+
148
+ func hasNPU() throws -> Promise<Bool> {
149
+ return Promise.async {
150
+ // Check for Neural Engine (A11 Bionic and later = iPhone X and later)
151
+ // All arm64 iOS devices since 2017 have Neural Engine
152
+ #if arch(arm64)
153
+ return true
154
+ #else
155
+ return false
156
+ #endif
157
+ }
158
+ }
159
+
160
+ func getChipName() throws -> Promise<String> {
161
+ return Promise.async {
162
+ let machineId = Self.getMachineIdentifier()
163
+
164
+ #if targetEnvironment(simulator)
165
+ if let simModelId = ProcessInfo.processInfo.environment["SIMULATOR_MODEL_IDENTIFIER"] {
166
+ return Self.getChipNameForModel(simModelId)
167
+ }
168
+ return "Simulated"
169
+ #else
170
+ return Self.getChipNameForModel(machineId)
171
+ #endif
172
+ }
173
+ }
174
+
175
+ func getThermalState() throws -> Promise<Double> {
176
+ return Promise.async {
177
+ let state = ProcessInfo.processInfo.thermalState
178
+ switch state {
179
+ case .nominal: return 0.0
180
+ case .fair: return 1.0
181
+ case .serious: return 2.0
182
+ case .critical: return 3.0
183
+ @unknown default: return 0.0
184
+ }
185
+ }
186
+ }
187
+
188
+ func getBatteryLevel() throws -> Promise<Double> {
189
+ return Promise.async {
190
+ await MainActor.run {
191
+ UIDevice.current.isBatteryMonitoringEnabled = true
192
+ }
193
+ let level = UIDevice.current.batteryLevel
194
+ // batteryLevel is -1.0 if monitoring not enabled or on simulator
195
+ return level >= 0 ? Double(level) : -1.0
196
+ }
197
+ }
198
+
199
+ func isCharging() throws -> Promise<Bool> {
200
+ return Promise.async {
201
+ await MainActor.run {
202
+ UIDevice.current.isBatteryMonitoringEnabled = true
203
+ }
204
+ let state = UIDevice.current.batteryState
205
+ return state == .charging || state == .full
206
+ }
207
+ }
208
+
209
+ func isLowPowerMode() throws -> Promise<Bool> {
210
+ return Promise.async {
211
+ return ProcessInfo.processInfo.isLowPowerModeEnabled
212
+ }
213
+ }
214
+ }
@@ -0,0 +1,116 @@
1
+ /**
2
+ * KeychainManager.swift
3
+ *
4
+ * iOS Keychain manager for secure storage of sensitive data.
5
+ * Matches Swift SDK's KeychainManager pattern.
6
+ *
7
+ * Reference: sdk/runanywhere-swift/Sources/RunAnywhere/Foundation/Security/KeychainManager.swift
8
+ */
9
+
10
+ import Foundation
11
+ import Security
12
+
13
+ /// Keychain manager for secure storage (singleton)
14
+ @objc public class KeychainManager: NSObject {
15
+
16
+ // MARK: - Singleton
17
+
18
+ @objc public static let shared = KeychainManager()
19
+
20
+ // MARK: - Properties
21
+
22
+ private let serviceName = "com.runanywhere.sdk"
23
+
24
+ // MARK: - Initialization
25
+
26
+ private override init() {
27
+ super.init()
28
+ }
29
+
30
+ // MARK: - Public API
31
+
32
+ /// Store a value in the keychain
33
+ /// - Parameters:
34
+ /// - value: Value to store
35
+ /// - key: Key to store under
36
+ /// - Returns: true if successful
37
+ @objc public func set(_ value: String, forKey key: String) -> Bool {
38
+ guard let data = value.data(using: .utf8) else {
39
+ return false
40
+ }
41
+
42
+ // Delete existing item first (update by delete + add)
43
+ _ = delete(forKey: key)
44
+
45
+ let query: [String: Any] = [
46
+ kSecClass as String: kSecClassGenericPassword,
47
+ kSecAttrService as String: serviceName,
48
+ kSecAttrAccount as String: key,
49
+ kSecValueData as String: data,
50
+ kSecAttrAccessible as String: kSecAttrAccessibleAfterFirstUnlockThisDeviceOnly
51
+ ]
52
+
53
+ let status = SecItemAdd(query as CFDictionary, nil)
54
+ return status == errSecSuccess
55
+ }
56
+
57
+ /// Retrieve a value from the keychain
58
+ /// - Parameter key: Key to retrieve
59
+ /// - Returns: Stored value or nil
60
+ @objc public func get(forKey key: String) -> String? {
61
+ let query: [String: Any] = [
62
+ kSecClass as String: kSecClassGenericPassword,
63
+ kSecAttrService as String: serviceName,
64
+ kSecAttrAccount as String: key,
65
+ kSecReturnData as String: true,
66
+ kSecMatchLimit as String: kSecMatchLimitOne
67
+ ]
68
+
69
+ var dataTypeRef: AnyObject?
70
+ let status = SecItemCopyMatching(query as CFDictionary, &dataTypeRef)
71
+
72
+ guard status == errSecSuccess,
73
+ let data = dataTypeRef as? Data,
74
+ let value = String(data: data, encoding: .utf8) else {
75
+ return nil
76
+ }
77
+
78
+ return value
79
+ }
80
+
81
+ /// Delete a value from the keychain
82
+ /// - Parameter key: Key to delete
83
+ /// - Returns: true if successful or item didn't exist
84
+ @objc public func delete(forKey key: String) -> Bool {
85
+ let query: [String: Any] = [
86
+ kSecClass as String: kSecClassGenericPassword,
87
+ kSecAttrService as String: serviceName,
88
+ kSecAttrAccount as String: key
89
+ ]
90
+
91
+ let status = SecItemDelete(query as CFDictionary)
92
+ return status == errSecSuccess || status == errSecItemNotFound
93
+ }
94
+
95
+ /// Check if a key exists in the keychain
96
+ /// - Parameter key: Key to check
97
+ /// - Returns: true if key exists
98
+ @objc public func exists(forKey key: String) -> Bool {
99
+ return get(forKey: key) != nil
100
+ }
101
+
102
+ // MARK: - Device UUID Convenience
103
+
104
+ private let deviceUUIDKey = "com.runanywhere.sdk.device.uuid"
105
+
106
+ /// Store device UUID
107
+ @objc public func storeDeviceUUID(_ uuid: String) -> Bool {
108
+ return set(uuid, forKey: deviceUUIDKey)
109
+ }
110
+
111
+ /// Retrieve device UUID
112
+ @objc public func retrieveDeviceUUID() -> String? {
113
+ return get(forKey: deviceUUIDKey)
114
+ }
115
+ }
116
+
@@ -0,0 +1,100 @@
1
+ /**
2
+ * PlatformAdapter.swift
3
+ *
4
+ * iOS platform adapter for C++ callbacks.
5
+ * Bridges iOS-specific implementations (Keychain, FileManager) to C++ layer.
6
+ *
7
+ * Reference: sdk/runanywhere-swift/Sources/RunAnywhere/Foundation/Bridge/Extensions/CppBridge+State.swift
8
+ */
9
+
10
+ import Foundation
11
+
12
+ /// Platform adapter that provides iOS implementations for C++ callbacks
13
+ @objc public class PlatformAdapter: NSObject {
14
+
15
+ // MARK: - Singleton
16
+
17
+ @objc public static let shared = PlatformAdapter()
18
+
19
+ private override init() {
20
+ super.init()
21
+ }
22
+
23
+ // MARK: - Secure Storage (Keychain)
24
+
25
+ /// Get value from Keychain
26
+ @objc public func secureGet(_ key: String) -> String? {
27
+ return KeychainManager.shared.get(forKey: key)
28
+ }
29
+
30
+ /// Set value in Keychain
31
+ @objc public func secureSet(_ key: String, value: String) -> Bool {
32
+ return KeychainManager.shared.set(value, forKey: key)
33
+ }
34
+
35
+ /// Delete value from Keychain
36
+ @objc public func secureDelete(_ key: String) -> Bool {
37
+ return KeychainManager.shared.delete(forKey: key)
38
+ }
39
+
40
+ /// Check if key exists in Keychain
41
+ @objc public func secureExists(_ key: String) -> Bool {
42
+ return KeychainManager.shared.exists(forKey: key)
43
+ }
44
+
45
+ // MARK: - File Operations
46
+
47
+ /// Check if file exists
48
+ @objc public func fileExists(_ path: String) -> Bool {
49
+ return FileManager.default.fileExists(atPath: path)
50
+ }
51
+
52
+ /// Read file contents
53
+ @objc public func fileRead(_ path: String) -> String? {
54
+ return try? String(contentsOfFile: path, encoding: .utf8)
55
+ }
56
+
57
+ /// Write file contents
58
+ @objc public func fileWrite(_ path: String, data: String) -> Bool {
59
+ do {
60
+ try data.write(toFile: path, atomically: true, encoding: .utf8)
61
+ return true
62
+ } catch {
63
+ return false
64
+ }
65
+ }
66
+
67
+ /// Delete file
68
+ @objc public func fileDelete(_ path: String) -> Bool {
69
+ do {
70
+ try FileManager.default.removeItem(atPath: path)
71
+ return true
72
+ } catch {
73
+ return false
74
+ }
75
+ }
76
+
77
+ // MARK: - Device UUID
78
+
79
+ /// Get persistent device UUID (from Keychain or generate new)
80
+ @objc public func getPersistentDeviceUUID() -> String {
81
+ // Try to get from Keychain first
82
+ if let existingUUID = KeychainManager.shared.retrieveDeviceUUID() {
83
+ return existingUUID
84
+ }
85
+
86
+ // Try vendor ID
87
+ #if os(iOS) || os(tvOS)
88
+ if let vendorUUID = UIDevice.current.identifierForVendor?.uuidString {
89
+ _ = KeychainManager.shared.storeDeviceUUID(vendorUUID)
90
+ return vendorUUID
91
+ }
92
+ #endif
93
+
94
+ // Generate new UUID
95
+ let newUUID = UUID().uuidString
96
+ _ = KeychainManager.shared.storeDeviceUUID(newUUID)
97
+ return newUUID
98
+ }
99
+ }
100
+
@@ -0,0 +1,152 @@
1
+ /**
2
+ * PlatformAdapterBridge.h
3
+ *
4
+ * C interface for platform-specific operations (Keychain, File I/O).
5
+ * Called from C++ via extern "C" functions.
6
+ */
7
+
8
+ #ifndef PlatformAdapterBridge_h
9
+ #define PlatformAdapterBridge_h
10
+
11
+ #include <stdbool.h>
12
+
13
+ #ifdef __cplusplus
14
+ extern "C" {
15
+ #endif
16
+
17
+ // ============================================================================
18
+ // Secure Storage (Keychain)
19
+ // ============================================================================
20
+
21
+ /**
22
+ * Set a value in the Keychain
23
+ * @param key The key to store under
24
+ * @param value The value to store
25
+ * @return true if successful
26
+ */
27
+ bool PlatformAdapter_secureSet(const char* key, const char* value);
28
+
29
+ /**
30
+ * Get a value from the Keychain
31
+ * @param key The key to retrieve
32
+ * @param outValue Pointer to store the result (must be freed by caller with free())
33
+ * @return true if found
34
+ */
35
+ bool PlatformAdapter_secureGet(const char* key, char** outValue);
36
+
37
+ /**
38
+ * Delete a value from the Keychain
39
+ * @param key The key to delete
40
+ * @return true if successful
41
+ */
42
+ bool PlatformAdapter_secureDelete(const char* key);
43
+
44
+ /**
45
+ * Check if a key exists in the Keychain
46
+ * @param key The key to check
47
+ * @return true if exists
48
+ */
49
+ bool PlatformAdapter_secureExists(const char* key);
50
+
51
+ /**
52
+ * Get persistent device UUID (from Keychain or generate new)
53
+ * @param outValue Pointer to store the UUID (must be freed by caller with free())
54
+ * @return true if successful
55
+ */
56
+ bool PlatformAdapter_getPersistentDeviceUUID(char** outValue);
57
+
58
+ // ============================================================================
59
+ // Device Info (Synchronous)
60
+ // ============================================================================
61
+
62
+ /**
63
+ * Get device model name (e.g., "iPhone 16 Pro Max")
64
+ * @param outValue Pointer to store the result (must be freed by caller)
65
+ * @return true if successful
66
+ */
67
+ bool PlatformAdapter_getDeviceModel(char** outValue);
68
+
69
+ /**
70
+ * Get OS version (e.g., "18.2")
71
+ * @param outValue Pointer to store the result (must be freed by caller)
72
+ * @return true if successful
73
+ */
74
+ bool PlatformAdapter_getOSVersion(char** outValue);
75
+
76
+ /**
77
+ * Get chip name (e.g., "A18 Pro")
78
+ * @param outValue Pointer to store the result (must be freed by caller)
79
+ * @return true if successful
80
+ */
81
+ bool PlatformAdapter_getChipName(char** outValue);
82
+
83
+ /**
84
+ * Get total memory in bytes
85
+ * @return Total memory in bytes
86
+ */
87
+ uint64_t PlatformAdapter_getTotalMemory(void);
88
+
89
+ /**
90
+ * Get available memory in bytes
91
+ * @return Available memory in bytes
92
+ */
93
+ uint64_t PlatformAdapter_getAvailableMemory(void);
94
+
95
+ /**
96
+ * Get CPU core count
97
+ * @return Number of CPU cores
98
+ */
99
+ int PlatformAdapter_getCoreCount(void);
100
+
101
+ /**
102
+ * Get architecture (e.g., "arm64")
103
+ * @param outValue Pointer to store the result (must be freed by caller)
104
+ * @return true if successful
105
+ */
106
+ bool PlatformAdapter_getArchitecture(char** outValue);
107
+
108
+ /**
109
+ * Get GPU family (e.g., "apple" for iOS, "mali", "adreno" for Android)
110
+ * @param outValue Pointer to store the result (must be freed by caller)
111
+ * @return true if successful
112
+ */
113
+ bool PlatformAdapter_getGPUFamily(char** outValue);
114
+
115
+ /**
116
+ * Check if device is a tablet
117
+ * Uses UIDevice.userInterfaceIdiom on iOS, Configuration on Android
118
+ * @return true if device is a tablet
119
+ */
120
+ bool PlatformAdapter_isTablet(void);
121
+
122
+ // ============================================================================
123
+ // HTTP POST for Device Registration (Synchronous)
124
+ // ============================================================================
125
+
126
+ /**
127
+ * Synchronous HTTP POST for device registration
128
+ * Called from C++ device manager callbacks
129
+ *
130
+ * @param url Full URL to POST to
131
+ * @param jsonBody JSON body string
132
+ * @param supabaseKey Supabase API key (for dev mode, can be NULL)
133
+ * @param outStatusCode Pointer to store HTTP status code
134
+ * @param outResponseBody Pointer to store response body (must be freed by caller)
135
+ * @param outErrorMessage Pointer to store error message (must be freed by caller)
136
+ * @return true if request succeeded (2xx or 409)
137
+ */
138
+ bool PlatformAdapter_httpPostSync(
139
+ const char* url,
140
+ const char* jsonBody,
141
+ const char* supabaseKey,
142
+ int* outStatusCode,
143
+ char** outResponseBody,
144
+ char** outErrorMessage
145
+ );
146
+
147
+ #ifdef __cplusplus
148
+ }
149
+ #endif
150
+
151
+ #endif /* PlatformAdapterBridge_h */
152
+