@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,215 @@
1
+ /**
2
+ * @file rac_llm_events.h
3
+ * @brief LLM-specific event types - 1:1 port of LLMEvent.swift
4
+ *
5
+ * All LLM-related events in one place.
6
+ * Each event declares its destination (public, analytics, or both).
7
+ *
8
+ * Swift Source: Sources/RunAnywhere/Features/LLM/Analytics/LLMEvent.swift
9
+ */
10
+
11
+ #ifndef RAC_LLM_EVENTS_H
12
+ #define RAC_LLM_EVENTS_H
13
+
14
+ #include "rac/core/rac_types.h"
15
+ #include "rac/infrastructure/events/rac_events.h"
16
+
17
+ #ifdef __cplusplus
18
+ extern "C" {
19
+ #endif
20
+
21
+ // =============================================================================
22
+ // LLM EVENT TYPES
23
+ // =============================================================================
24
+
25
+ /**
26
+ * @brief LLM event types enumeration
27
+ * Mirrors Swift's LLMEvent cases
28
+ */
29
+ typedef enum rac_llm_event_type {
30
+ RAC_LLM_EVENT_MODEL_LOAD_STARTED = 0,
31
+ RAC_LLM_EVENT_MODEL_LOAD_COMPLETED,
32
+ RAC_LLM_EVENT_MODEL_LOAD_FAILED,
33
+ RAC_LLM_EVENT_MODEL_UNLOADED,
34
+ RAC_LLM_EVENT_MODEL_UNLOAD_STARTED,
35
+ RAC_LLM_EVENT_GENERATION_STARTED,
36
+ RAC_LLM_EVENT_FIRST_TOKEN,
37
+ RAC_LLM_EVENT_STREAMING_UPDATE,
38
+ RAC_LLM_EVENT_GENERATION_COMPLETED,
39
+ RAC_LLM_EVENT_GENERATION_FAILED,
40
+ } rac_llm_event_type_t;
41
+
42
+ // =============================================================================
43
+ // LLM EVENT DATA STRUCTURES
44
+ // =============================================================================
45
+
46
+ /**
47
+ * @brief Model load event data
48
+ */
49
+ typedef struct rac_llm_model_load_event {
50
+ const char* model_id;
51
+ int64_t model_size_bytes;
52
+ rac_inference_framework_t framework;
53
+ double duration_ms; /**< Only for completed events */
54
+ rac_result_t error_code; /**< Only for failed events */
55
+ const char* error_message; /**< Only for failed events */
56
+ } rac_llm_model_load_event_t;
57
+
58
+ /**
59
+ * @brief Generation event data
60
+ */
61
+ typedef struct rac_llm_generation_event {
62
+ const char* generation_id;
63
+ const char* model_id;
64
+ rac_bool_t is_streaming;
65
+ rac_inference_framework_t framework;
66
+
67
+ /** For completed events */
68
+ int32_t input_tokens;
69
+ int32_t output_tokens;
70
+ double duration_ms;
71
+ double tokens_per_second;
72
+ double time_to_first_token_ms; /**< -1 if not applicable */
73
+ float temperature;
74
+ int32_t max_tokens;
75
+ int32_t context_length;
76
+
77
+ /** For streaming updates */
78
+ int32_t tokens_generated;
79
+
80
+ /** For failed events */
81
+ rac_result_t error_code;
82
+ const char* error_message;
83
+ } rac_llm_generation_event_t;
84
+
85
+ // =============================================================================
86
+ // EVENT PUBLISHING FUNCTIONS
87
+ // =============================================================================
88
+
89
+ /**
90
+ * @brief Publish a model load started event
91
+ *
92
+ * @param model_id Model identifier
93
+ * @param model_size_bytes Size of model in bytes (0 if unknown)
94
+ * @param framework Inference framework
95
+ * @return RAC_SUCCESS or error code
96
+ */
97
+ RAC_API rac_result_t rac_llm_event_model_load_started(const char* model_id,
98
+ int64_t model_size_bytes,
99
+ rac_inference_framework_t framework);
100
+
101
+ /**
102
+ * @brief Publish a model load completed event
103
+ *
104
+ * @param model_id Model identifier
105
+ * @param duration_ms Load duration in milliseconds
106
+ * @param model_size_bytes Size of model in bytes
107
+ * @param framework Inference framework
108
+ * @return RAC_SUCCESS or error code
109
+ */
110
+ RAC_API rac_result_t rac_llm_event_model_load_completed(const char* model_id, double duration_ms,
111
+ int64_t model_size_bytes,
112
+ rac_inference_framework_t framework);
113
+
114
+ /**
115
+ * @brief Publish a model load failed event
116
+ *
117
+ * @param model_id Model identifier
118
+ * @param error_code Error code
119
+ * @param error_message Error message
120
+ * @param framework Inference framework
121
+ * @return RAC_SUCCESS or error code
122
+ */
123
+ RAC_API rac_result_t rac_llm_event_model_load_failed(const char* model_id, rac_result_t error_code,
124
+ const char* error_message,
125
+ rac_inference_framework_t framework);
126
+
127
+ /**
128
+ * @brief Publish a model unloaded event
129
+ *
130
+ * @param model_id Model identifier
131
+ * @return RAC_SUCCESS or error code
132
+ */
133
+ RAC_API rac_result_t rac_llm_event_model_unloaded(const char* model_id);
134
+
135
+ /**
136
+ * @brief Publish a generation started event
137
+ *
138
+ * @param generation_id Generation identifier
139
+ * @param model_id Model identifier
140
+ * @param is_streaming Whether this is streaming generation
141
+ * @param framework Inference framework
142
+ * @return RAC_SUCCESS or error code
143
+ */
144
+ RAC_API rac_result_t rac_llm_event_generation_started(const char* generation_id,
145
+ const char* model_id, rac_bool_t is_streaming,
146
+ rac_inference_framework_t framework);
147
+
148
+ /**
149
+ * @brief Publish a first token event (streaming only)
150
+ *
151
+ * @param generation_id Generation identifier
152
+ * @param model_id Model identifier
153
+ * @param time_to_first_token_ms Time to first token in milliseconds
154
+ * @param framework Inference framework
155
+ * @return RAC_SUCCESS or error code
156
+ */
157
+ RAC_API rac_result_t rac_llm_event_first_token(const char* generation_id, const char* model_id,
158
+ double time_to_first_token_ms,
159
+ rac_inference_framework_t framework);
160
+
161
+ /**
162
+ * @brief Publish a streaming update event
163
+ *
164
+ * @param generation_id Generation identifier
165
+ * @param tokens_generated Number of tokens generated so far
166
+ * @return RAC_SUCCESS or error code
167
+ */
168
+ RAC_API rac_result_t rac_llm_event_streaming_update(const char* generation_id,
169
+ int32_t tokens_generated);
170
+
171
+ /**
172
+ * @brief Publish a generation completed event
173
+ *
174
+ * @param event Generation event data
175
+ * @return RAC_SUCCESS or error code
176
+ */
177
+ RAC_API rac_result_t rac_llm_event_generation_completed(const rac_llm_generation_event_t* event);
178
+
179
+ /**
180
+ * @brief Publish a generation failed event
181
+ *
182
+ * @param generation_id Generation identifier
183
+ * @param error_code Error code
184
+ * @param error_message Error message
185
+ * @return RAC_SUCCESS or error code
186
+ */
187
+ RAC_API rac_result_t rac_llm_event_generation_failed(const char* generation_id,
188
+ rac_result_t error_code,
189
+ const char* error_message);
190
+
191
+ // =============================================================================
192
+ // UTILITY FUNCTIONS
193
+ // =============================================================================
194
+
195
+ /**
196
+ * @brief Get the event type string for an LLM event type
197
+ *
198
+ * @param event_type The LLM event type
199
+ * @return Event type string (never NULL)
200
+ */
201
+ RAC_API const char* rac_llm_event_type_string(rac_llm_event_type_t event_type);
202
+
203
+ /**
204
+ * @brief Get the event destination for an LLM event type
205
+ *
206
+ * @param event_type The LLM event type
207
+ * @return Event destination
208
+ */
209
+ RAC_API rac_event_destination_t rac_llm_event_destination(rac_llm_event_type_t event_type);
210
+
211
+ #ifdef __cplusplus
212
+ }
213
+ #endif
214
+
215
+ #endif /* RAC_LLM_EVENTS_H */
@@ -0,0 +1,402 @@
1
+ /**
2
+ * @file rac_llm_metrics.h
3
+ * @brief LLM Streaming Metrics - TTFT and Token Rate Tracking
4
+ *
5
+ * C port of Swift's StreamingMetricsCollector and GenerationAnalyticsService.
6
+ * Swift Source: Sources/RunAnywhere/Features/LLM/LLMCapability.swift (StreamingMetricsCollector)
7
+ * Swift Source: Sources/RunAnywhere/Features/LLM/Analytics/GenerationAnalyticsService.swift
8
+ *
9
+ * IMPORTANT: This is a direct translation of the Swift implementation.
10
+ * Do NOT add features not present in the Swift code.
11
+ */
12
+
13
+ #ifndef RAC_LLM_METRICS_H
14
+ #define RAC_LLM_METRICS_H
15
+
16
+ #include "rac/core/rac_error.h"
17
+ #include "rac/core/rac_types.h"
18
+
19
+ #ifdef __cplusplus
20
+ extern "C" {
21
+ #endif
22
+
23
+ // =============================================================================
24
+ // TYPES - Mirrors Swift's GenerationMetrics and StreamingMetricsCollector
25
+ // =============================================================================
26
+
27
+ /**
28
+ * @brief Generation metrics snapshot.
29
+ * Mirrors Swift's GenerationMetrics struct.
30
+ */
31
+ typedef struct rac_generation_metrics {
32
+ /** Total generation count */
33
+ int32_t total_generations;
34
+
35
+ /** Streaming generation count */
36
+ int32_t streaming_generations;
37
+
38
+ /** Non-streaming generation count */
39
+ int32_t non_streaming_generations;
40
+
41
+ /** Average time-to-first-token in ms (streaming only) */
42
+ double average_ttft_ms;
43
+
44
+ /** Average tokens per second */
45
+ double average_tokens_per_second;
46
+
47
+ /** Total input tokens processed */
48
+ int64_t total_input_tokens;
49
+
50
+ /** Total output tokens generated */
51
+ int64_t total_output_tokens;
52
+
53
+ /** Service start time (Unix timestamp ms) */
54
+ int64_t start_time_ms;
55
+
56
+ /** Last event time (Unix timestamp ms) */
57
+ int64_t last_event_time_ms;
58
+ } rac_generation_metrics_t;
59
+
60
+ /**
61
+ * @brief Default generation metrics.
62
+ */
63
+ static const rac_generation_metrics_t RAC_GENERATION_METRICS_DEFAULT = {
64
+ .total_generations = 0,
65
+ .streaming_generations = 0,
66
+ .non_streaming_generations = 0,
67
+ .average_ttft_ms = 0.0,
68
+ .average_tokens_per_second = 0.0,
69
+ .total_input_tokens = 0,
70
+ .total_output_tokens = 0,
71
+ .start_time_ms = 0,
72
+ .last_event_time_ms = 0};
73
+
74
+ /**
75
+ * @brief Streaming generation result.
76
+ * Mirrors Swift's LLMGenerationResult for streaming.
77
+ */
78
+ typedef struct rac_streaming_result {
79
+ /** Generated text (owned, must be freed) */
80
+ char* text;
81
+
82
+ /** Thinking/reasoning content if any (owned, must be freed, can be NULL) */
83
+ char* thinking_content;
84
+
85
+ /** Input tokens processed */
86
+ int32_t input_tokens;
87
+
88
+ /** Output tokens generated */
89
+ int32_t output_tokens;
90
+
91
+ /** Model ID used (owned, must be freed) */
92
+ char* model_id;
93
+
94
+ /** Total latency in milliseconds */
95
+ double latency_ms;
96
+
97
+ /** Tokens generated per second */
98
+ double tokens_per_second;
99
+
100
+ /** Time-to-first-token in milliseconds (0 if not streaming) */
101
+ double ttft_ms;
102
+
103
+ /** Thinking tokens (for reasoning models) */
104
+ int32_t thinking_tokens;
105
+
106
+ /** Response tokens (excluding thinking) */
107
+ int32_t response_tokens;
108
+ } rac_streaming_result_t;
109
+
110
+ /**
111
+ * @brief Default streaming result.
112
+ */
113
+ static const rac_streaming_result_t RAC_STREAMING_RESULT_DEFAULT = {.text = RAC_NULL,
114
+ .thinking_content = RAC_NULL,
115
+ .input_tokens = 0,
116
+ .output_tokens = 0,
117
+ .model_id = RAC_NULL,
118
+ .latency_ms = 0.0,
119
+ .tokens_per_second = 0.0,
120
+ .ttft_ms = 0.0,
121
+ .thinking_tokens = 0,
122
+ .response_tokens = 0};
123
+
124
+ // =============================================================================
125
+ // OPAQUE HANDLES
126
+ // =============================================================================
127
+
128
+ /**
129
+ * @brief Opaque handle for streaming metrics collector.
130
+ */
131
+ typedef struct rac_streaming_metrics_collector* rac_streaming_metrics_handle_t;
132
+
133
+ /**
134
+ * @brief Opaque handle for generation analytics service.
135
+ */
136
+ typedef struct rac_generation_analytics* rac_generation_analytics_handle_t;
137
+
138
+ // =============================================================================
139
+ // STREAMING METRICS COLLECTOR API - Mirrors Swift's StreamingMetricsCollector
140
+ // =============================================================================
141
+
142
+ /**
143
+ * @brief Create a streaming metrics collector.
144
+ *
145
+ * @param model_id Model ID being used
146
+ * @param generation_id Unique generation identifier
147
+ * @param prompt_length Length of input prompt (for token estimation)
148
+ * @param out_handle Output: Handle to the created collector
149
+ * @return RAC_SUCCESS or error code
150
+ */
151
+ RAC_API rac_result_t rac_streaming_metrics_create(const char* model_id, const char* generation_id,
152
+ int32_t prompt_length,
153
+ rac_streaming_metrics_handle_t* out_handle);
154
+
155
+ /**
156
+ * @brief Destroy a streaming metrics collector.
157
+ *
158
+ * @param handle Collector handle
159
+ */
160
+ RAC_API void rac_streaming_metrics_destroy(rac_streaming_metrics_handle_t handle);
161
+
162
+ /**
163
+ * @brief Mark the start of generation.
164
+ *
165
+ * Mirrors Swift's StreamingMetricsCollector.markStart().
166
+ *
167
+ * @param handle Collector handle
168
+ * @return RAC_SUCCESS or error code
169
+ */
170
+ RAC_API rac_result_t rac_streaming_metrics_mark_start(rac_streaming_metrics_handle_t handle);
171
+
172
+ /**
173
+ * @brief Record a token received during streaming.
174
+ *
175
+ * Mirrors Swift's StreamingMetricsCollector.recordToken(_:).
176
+ * First call records TTFT.
177
+ *
178
+ * @param handle Collector handle
179
+ * @param token Token string received
180
+ * @return RAC_SUCCESS or error code
181
+ */
182
+ RAC_API rac_result_t rac_streaming_metrics_record_token(rac_streaming_metrics_handle_t handle,
183
+ const char* token);
184
+
185
+ /**
186
+ * @brief Mark generation as complete.
187
+ *
188
+ * Mirrors Swift's StreamingMetricsCollector.markComplete().
189
+ *
190
+ * @param handle Collector handle
191
+ * @return RAC_SUCCESS or error code
192
+ */
193
+ RAC_API rac_result_t rac_streaming_metrics_mark_complete(rac_streaming_metrics_handle_t handle);
194
+
195
+ /**
196
+ * @brief Mark generation as failed.
197
+ *
198
+ * Mirrors Swift's StreamingMetricsCollector.recordError(_:).
199
+ *
200
+ * @param handle Collector handle
201
+ * @param error_code Error code
202
+ * @return RAC_SUCCESS or error code
203
+ */
204
+ RAC_API rac_result_t rac_streaming_metrics_mark_failed(rac_streaming_metrics_handle_t handle,
205
+ rac_result_t error_code);
206
+
207
+ /**
208
+ * @brief Get the generation result.
209
+ *
210
+ * Mirrors Swift's StreamingMetricsCollector.buildResult().
211
+ * Only valid after markComplete() is called.
212
+ *
213
+ * @param handle Collector handle
214
+ * @param out_result Output: Streaming result (must be freed with rac_streaming_result_free)
215
+ * @return RAC_SUCCESS or error code
216
+ */
217
+ RAC_API rac_result_t rac_streaming_metrics_get_result(rac_streaming_metrics_handle_t handle,
218
+ rac_streaming_result_t* out_result);
219
+
220
+ /**
221
+ * @brief Get current TTFT in milliseconds.
222
+ *
223
+ * @param handle Collector handle
224
+ * @param out_ttft_ms Output: TTFT in ms (0 if first token not yet received)
225
+ * @return RAC_SUCCESS or error code
226
+ */
227
+ RAC_API rac_result_t rac_streaming_metrics_get_ttft(rac_streaming_metrics_handle_t handle,
228
+ double* out_ttft_ms);
229
+
230
+ /**
231
+ * @brief Get current token count.
232
+ *
233
+ * @param handle Collector handle
234
+ * @param out_token_count Output: Number of tokens recorded
235
+ * @return RAC_SUCCESS or error code
236
+ */
237
+ RAC_API rac_result_t rac_streaming_metrics_get_token_count(rac_streaming_metrics_handle_t handle,
238
+ int32_t* out_token_count);
239
+
240
+ /**
241
+ * @brief Get accumulated text.
242
+ *
243
+ * @param handle Collector handle
244
+ * @param out_text Output: Accumulated text (owned, must be freed)
245
+ * @return RAC_SUCCESS or error code
246
+ */
247
+ RAC_API rac_result_t rac_streaming_metrics_get_text(rac_streaming_metrics_handle_t handle,
248
+ char** out_text);
249
+
250
+ /**
251
+ * @brief Set actual token counts from backend.
252
+ *
253
+ * Call this with actual token counts from the LLM backend's tokenizer
254
+ * to get accurate telemetry instead of character-based estimation.
255
+ *
256
+ * @param handle Collector handle
257
+ * @param input_tokens Actual input/prompt token count (0 to use estimation)
258
+ * @param output_tokens Actual output/completion token count (0 to use estimation)
259
+ * @return RAC_SUCCESS or error code
260
+ */
261
+ RAC_API rac_result_t rac_streaming_metrics_set_token_counts(rac_streaming_metrics_handle_t handle,
262
+ int32_t input_tokens,
263
+ int32_t output_tokens);
264
+
265
+ // =============================================================================
266
+ // GENERATION ANALYTICS SERVICE API - Mirrors Swift's GenerationAnalyticsService
267
+ // =============================================================================
268
+
269
+ /**
270
+ * @brief Create a generation analytics service.
271
+ *
272
+ * @param out_handle Output: Handle to the created service
273
+ * @return RAC_SUCCESS or error code
274
+ */
275
+ RAC_API rac_result_t rac_generation_analytics_create(rac_generation_analytics_handle_t* out_handle);
276
+
277
+ /**
278
+ * @brief Destroy a generation analytics service.
279
+ *
280
+ * @param handle Service handle
281
+ */
282
+ RAC_API void rac_generation_analytics_destroy(rac_generation_analytics_handle_t handle);
283
+
284
+ /**
285
+ * @brief Start tracking a non-streaming generation.
286
+ *
287
+ * Mirrors Swift's GenerationAnalyticsService.startGeneration().
288
+ *
289
+ * @param handle Service handle
290
+ * @param generation_id Unique generation identifier
291
+ * @param model_id Model ID
292
+ * @return RAC_SUCCESS or error code
293
+ */
294
+ RAC_API rac_result_t rac_generation_analytics_start(rac_generation_analytics_handle_t handle,
295
+ const char* generation_id,
296
+ const char* model_id);
297
+
298
+ /**
299
+ * @brief Start tracking a streaming generation.
300
+ *
301
+ * Mirrors Swift's GenerationAnalyticsService.startStreamingGeneration().
302
+ *
303
+ * @param handle Service handle
304
+ * @param generation_id Unique generation identifier
305
+ * @param model_id Model ID
306
+ * @return RAC_SUCCESS or error code
307
+ */
308
+ RAC_API rac_result_t rac_generation_analytics_start_streaming(
309
+ rac_generation_analytics_handle_t handle, const char* generation_id, const char* model_id);
310
+
311
+ /**
312
+ * @brief Track first token received (streaming only).
313
+ *
314
+ * Mirrors Swift's GenerationAnalyticsService.trackFirstToken().
315
+ *
316
+ * @param handle Service handle
317
+ * @param generation_id Generation identifier
318
+ * @return RAC_SUCCESS or error code
319
+ */
320
+ RAC_API rac_result_t rac_generation_analytics_track_first_token(
321
+ rac_generation_analytics_handle_t handle, const char* generation_id);
322
+
323
+ /**
324
+ * @brief Track streaming update.
325
+ *
326
+ * Mirrors Swift's GenerationAnalyticsService.trackStreamingUpdate().
327
+ *
328
+ * @param handle Service handle
329
+ * @param generation_id Generation identifier
330
+ * @param tokens_generated Number of tokens generated so far
331
+ * @return RAC_SUCCESS or error code
332
+ */
333
+ RAC_API rac_result_t rac_generation_analytics_track_streaming_update(
334
+ rac_generation_analytics_handle_t handle, const char* generation_id, int32_t tokens_generated);
335
+
336
+ /**
337
+ * @brief Complete a generation.
338
+ *
339
+ * Mirrors Swift's GenerationAnalyticsService.completeGeneration().
340
+ *
341
+ * @param handle Service handle
342
+ * @param generation_id Generation identifier
343
+ * @param input_tokens Number of input tokens
344
+ * @param output_tokens Number of output tokens
345
+ * @param model_id Model ID used
346
+ * @return RAC_SUCCESS or error code
347
+ */
348
+ RAC_API rac_result_t rac_generation_analytics_complete(rac_generation_analytics_handle_t handle,
349
+ const char* generation_id,
350
+ int32_t input_tokens, int32_t output_tokens,
351
+ const char* model_id);
352
+
353
+ /**
354
+ * @brief Track generation failure.
355
+ *
356
+ * Mirrors Swift's GenerationAnalyticsService.trackGenerationFailed().
357
+ *
358
+ * @param handle Service handle
359
+ * @param generation_id Generation identifier
360
+ * @param error_code Error code
361
+ * @return RAC_SUCCESS or error code
362
+ */
363
+ RAC_API rac_result_t rac_generation_analytics_track_failed(rac_generation_analytics_handle_t handle,
364
+ const char* generation_id,
365
+ rac_result_t error_code);
366
+
367
+ /**
368
+ * @brief Get aggregated metrics.
369
+ *
370
+ * Mirrors Swift's GenerationAnalyticsService.getMetrics().
371
+ *
372
+ * @param handle Service handle
373
+ * @param out_metrics Output: Generation metrics
374
+ * @return RAC_SUCCESS or error code
375
+ */
376
+ RAC_API rac_result_t rac_generation_analytics_get_metrics(rac_generation_analytics_handle_t handle,
377
+ rac_generation_metrics_t* out_metrics);
378
+
379
+ /**
380
+ * @brief Reset metrics.
381
+ *
382
+ * @param handle Service handle
383
+ * @return RAC_SUCCESS or error code
384
+ */
385
+ RAC_API rac_result_t rac_generation_analytics_reset(rac_generation_analytics_handle_t handle);
386
+
387
+ // =============================================================================
388
+ // MEMORY MANAGEMENT
389
+ // =============================================================================
390
+
391
+ /**
392
+ * @brief Free a streaming result.
393
+ *
394
+ * @param result Result to free
395
+ */
396
+ RAC_API void rac_streaming_result_free(rac_streaming_result_t* result);
397
+
398
+ #ifdef __cplusplus
399
+ }
400
+ #endif
401
+
402
+ #endif /* RAC_LLM_METRICS_H */