@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,204 @@
1
+ /**
2
+ * @file rac_llm_platform.h
3
+ * @brief RunAnywhere Commons - Platform LLM Backend (Apple Foundation Models)
4
+ *
5
+ * C API for platform-native LLM services. On Apple platforms, this uses
6
+ * Foundation Models (Apple Intelligence). The actual implementation is in
7
+ * Swift, with C++ providing the registration and callback infrastructure.
8
+ *
9
+ * This backend follows the same pattern as LlamaCPP and ONNX backends,
10
+ * but delegates to Swift via function pointer callbacks since Foundation
11
+ * Models is a Swift-only framework.
12
+ */
13
+
14
+ #ifndef RAC_LLM_PLATFORM_H
15
+ #define RAC_LLM_PLATFORM_H
16
+
17
+ #include <RACommons/rac_types.h>
18
+
19
+ #ifdef __cplusplus
20
+ extern "C" {
21
+ #endif
22
+
23
+ // =============================================================================
24
+ // TYPES
25
+ // =============================================================================
26
+
27
+ /** Opaque handle to platform LLM service */
28
+ typedef struct rac_llm_platform* rac_llm_platform_handle_t;
29
+
30
+ /**
31
+ * Platform LLM configuration.
32
+ * Passed during initialization.
33
+ */
34
+ typedef struct rac_llm_platform_config {
35
+ /** Reserved for future use */
36
+ void* reserved;
37
+ } rac_llm_platform_config_t;
38
+
39
+ /**
40
+ * Generation options for platform LLM.
41
+ */
42
+ typedef struct rac_llm_platform_options {
43
+ /** Temperature for sampling (0.0 = deterministic, 1.0 = creative) */
44
+ float temperature;
45
+ /** Maximum tokens to generate */
46
+ int32_t max_tokens;
47
+ /** Reserved for future options */
48
+ void* reserved;
49
+ } rac_llm_platform_options_t;
50
+
51
+ // =============================================================================
52
+ // SWIFT CALLBACK TYPES
53
+ // =============================================================================
54
+
55
+ /**
56
+ * Callback to check if platform LLM can handle a model ID.
57
+ * Implemented in Swift.
58
+ *
59
+ * @param model_id Model identifier to check (can be NULL)
60
+ * @param user_data User-provided context
61
+ * @return RAC_TRUE if this backend can handle the model
62
+ */
63
+ typedef rac_bool_t (*rac_platform_llm_can_handle_fn)(const char* model_id, void* user_data);
64
+
65
+ /**
66
+ * Callback to create platform LLM service.
67
+ * Implemented in Swift.
68
+ *
69
+ * @param model_path Path to model (ignored for built-in)
70
+ * @param config Configuration options
71
+ * @param user_data User-provided context
72
+ * @return Handle to created service (Swift object pointer), or NULL on failure
73
+ */
74
+ typedef rac_handle_t (*rac_platform_llm_create_fn)(const char* model_path,
75
+ const rac_llm_platform_config_t* config,
76
+ void* user_data);
77
+
78
+ /**
79
+ * Callback to generate text.
80
+ * Implemented in Swift.
81
+ *
82
+ * @param handle Service handle from create
83
+ * @param prompt Input prompt
84
+ * @param options Generation options
85
+ * @param out_response Output: Generated text (caller must free)
86
+ * @param user_data User-provided context
87
+ * @return RAC_SUCCESS or error code
88
+ */
89
+ typedef rac_result_t (*rac_platform_llm_generate_fn)(rac_handle_t handle, const char* prompt,
90
+ const rac_llm_platform_options_t* options,
91
+ char** out_response, void* user_data);
92
+
93
+ /**
94
+ * Callback to destroy platform LLM service.
95
+ * Implemented in Swift.
96
+ *
97
+ * @param handle Service handle to destroy
98
+ * @param user_data User-provided context
99
+ */
100
+ typedef void (*rac_platform_llm_destroy_fn)(rac_handle_t handle, void* user_data);
101
+
102
+ /**
103
+ * Swift callbacks for platform LLM operations.
104
+ */
105
+ typedef struct rac_platform_llm_callbacks {
106
+ rac_platform_llm_can_handle_fn can_handle;
107
+ rac_platform_llm_create_fn create;
108
+ rac_platform_llm_generate_fn generate;
109
+ rac_platform_llm_destroy_fn destroy;
110
+ void* user_data;
111
+ } rac_platform_llm_callbacks_t;
112
+
113
+ // =============================================================================
114
+ // CALLBACK REGISTRATION
115
+ // =============================================================================
116
+
117
+ /**
118
+ * Sets the Swift callbacks for platform LLM operations.
119
+ * Must be called before using platform LLM services.
120
+ *
121
+ * @param callbacks Callback functions (copied internally)
122
+ * @return RAC_SUCCESS on success
123
+ */
124
+ RAC_API rac_result_t rac_platform_llm_set_callbacks(const rac_platform_llm_callbacks_t* callbacks);
125
+
126
+ /**
127
+ * Gets the current Swift callbacks.
128
+ *
129
+ * @return Pointer to callbacks, or NULL if not set
130
+ */
131
+ RAC_API const rac_platform_llm_callbacks_t* rac_platform_llm_get_callbacks(void);
132
+
133
+ /**
134
+ * Checks if Swift callbacks are registered.
135
+ *
136
+ * @return RAC_TRUE if callbacks are available
137
+ */
138
+ RAC_API rac_bool_t rac_platform_llm_is_available(void);
139
+
140
+ // =============================================================================
141
+ // SERVICE API
142
+ // =============================================================================
143
+
144
+ /**
145
+ * Creates a platform LLM service.
146
+ *
147
+ * @param model_path Path to model (ignored for built-in, can be NULL)
148
+ * @param config Configuration options (can be NULL for defaults)
149
+ * @param out_handle Output: Service handle
150
+ * @return RAC_SUCCESS on success, or error code
151
+ */
152
+ RAC_API rac_result_t rac_llm_platform_create(const char* model_path,
153
+ const rac_llm_platform_config_t* config,
154
+ rac_llm_platform_handle_t* out_handle);
155
+
156
+ /**
157
+ * Destroys a platform LLM service.
158
+ *
159
+ * @param handle Service handle to destroy
160
+ */
161
+ RAC_API void rac_llm_platform_destroy(rac_llm_platform_handle_t handle);
162
+
163
+ /**
164
+ * Generates text using platform LLM.
165
+ *
166
+ * @param handle Service handle
167
+ * @param prompt Input prompt
168
+ * @param options Generation options (can be NULL for defaults)
169
+ * @param out_response Output: Generated text (caller must free with free())
170
+ * @return RAC_SUCCESS on success, or error code
171
+ */
172
+ RAC_API rac_result_t rac_llm_platform_generate(rac_llm_platform_handle_t handle, const char* prompt,
173
+ const rac_llm_platform_options_t* options,
174
+ char** out_response);
175
+
176
+ // =============================================================================
177
+ // BACKEND REGISTRATION
178
+ // =============================================================================
179
+
180
+ /**
181
+ * Registers the Platform backend with the module and service registries.
182
+ *
183
+ * This registers:
184
+ * - Module: "platform" with TEXT_GENERATION and TTS capabilities
185
+ * - LLM Provider: "AppleFoundationModels" (priority 50)
186
+ * - TTS Provider: "SystemTTS" (priority 10)
187
+ * - Built-in model entries for Foundation Models and System TTS
188
+ *
189
+ * @return RAC_SUCCESS on success, or an error code
190
+ */
191
+ RAC_API rac_result_t rac_backend_platform_register(void);
192
+
193
+ /**
194
+ * Unregisters the Platform backend.
195
+ *
196
+ * @return RAC_SUCCESS on success, or an error code
197
+ */
198
+ RAC_API rac_result_t rac_backend_platform_unregister(void);
199
+
200
+ #ifdef __cplusplus
201
+ }
202
+ #endif
203
+
204
+ #endif /* RAC_LLM_PLATFORM_H */
@@ -0,0 +1,163 @@
1
+ /**
2
+ * @file rac_llm_service.h
3
+ * @brief RunAnywhere Commons - LLM Service Interface
4
+ *
5
+ * Defines the generic LLM service API and vtable for multi-backend dispatch.
6
+ * Backends (LlamaCpp, Platform, ONNX) implement the vtable and register
7
+ * with the service registry.
8
+ */
9
+
10
+ #ifndef RAC_LLM_SERVICE_H
11
+ #define RAC_LLM_SERVICE_H
12
+
13
+ #include <RACommons/rac_error.h>
14
+ #include <RACommons/rac_llm_types.h>
15
+
16
+ #ifdef __cplusplus
17
+ extern "C" {
18
+ #endif
19
+
20
+ // =============================================================================
21
+ // SERVICE VTABLE - Backend implementations provide this
22
+ // =============================================================================
23
+
24
+ /**
25
+ * LLM Service operations vtable.
26
+ * Each backend implements these functions and provides a static vtable.
27
+ */
28
+ typedef struct rac_llm_service_ops {
29
+ /** Initialize the service with a model path */
30
+ rac_result_t (*initialize)(void* impl, const char* model_path);
31
+
32
+ /** Generate text (blocking) */
33
+ rac_result_t (*generate)(void* impl, const char* prompt, const rac_llm_options_t* options,
34
+ rac_llm_result_t* out_result);
35
+
36
+ /** Generate text with streaming callback */
37
+ rac_result_t (*generate_stream)(void* impl, const char* prompt,
38
+ const rac_llm_options_t* options,
39
+ rac_llm_stream_callback_fn callback, void* user_data);
40
+
41
+ /** Get service info */
42
+ rac_result_t (*get_info)(void* impl, rac_llm_info_t* out_info);
43
+
44
+ /** Cancel ongoing generation */
45
+ rac_result_t (*cancel)(void* impl);
46
+
47
+ /** Cleanup/unload model (keeps service alive) */
48
+ rac_result_t (*cleanup)(void* impl);
49
+
50
+ /** Destroy the service */
51
+ void (*destroy)(void* impl);
52
+ } rac_llm_service_ops_t;
53
+
54
+ /**
55
+ * LLM Service instance.
56
+ * Contains vtable pointer and backend-specific implementation.
57
+ */
58
+ typedef struct rac_llm_service {
59
+ /** Vtable with backend operations */
60
+ const rac_llm_service_ops_t* ops;
61
+
62
+ /** Backend-specific implementation handle */
63
+ void* impl;
64
+
65
+ /** Model ID for reference */
66
+ const char* model_id;
67
+ } rac_llm_service_t;
68
+
69
+ // =============================================================================
70
+ // PUBLIC API - Generic service functions
71
+ // =============================================================================
72
+
73
+ /**
74
+ * @brief Create an LLM service
75
+ *
76
+ * Routes through service registry to find appropriate backend.
77
+ *
78
+ * @param model_id Model identifier (registry ID or path to model file)
79
+ * @param out_handle Output: Handle to the created service
80
+ * @return RAC_SUCCESS or error code
81
+ */
82
+ RAC_API rac_result_t rac_llm_create(const char* model_id, rac_handle_t* out_handle);
83
+
84
+ /**
85
+ * @brief Initialize an LLM service
86
+ *
87
+ * @param handle Service handle
88
+ * @param model_path Path to the model file (can be NULL)
89
+ * @return RAC_SUCCESS or error code
90
+ */
91
+ RAC_API rac_result_t rac_llm_initialize(rac_handle_t handle, const char* model_path);
92
+
93
+ /**
94
+ * @brief Generate text from prompt
95
+ *
96
+ * @param handle Service handle
97
+ * @param prompt Input prompt
98
+ * @param options Generation options (can be NULL for defaults)
99
+ * @param out_result Output: Generation result (caller must free with rac_llm_result_free)
100
+ * @return RAC_SUCCESS or error code
101
+ */
102
+ RAC_API rac_result_t rac_llm_generate(rac_handle_t handle, const char* prompt,
103
+ const rac_llm_options_t* options,
104
+ rac_llm_result_t* out_result);
105
+
106
+ /**
107
+ * @brief Stream generate text token by token
108
+ *
109
+ * @param handle Service handle
110
+ * @param prompt Input prompt
111
+ * @param options Generation options (can be NULL for defaults)
112
+ * @param callback Callback for each token
113
+ * @param user_data User context passed to callback
114
+ * @return RAC_SUCCESS or error code
115
+ */
116
+ RAC_API rac_result_t rac_llm_generate_stream(rac_handle_t handle, const char* prompt,
117
+ const rac_llm_options_t* options,
118
+ rac_llm_stream_callback_fn callback, void* user_data);
119
+
120
+ /**
121
+ * @brief Get service information
122
+ *
123
+ * @param handle Service handle
124
+ * @param out_info Output: Service information
125
+ * @return RAC_SUCCESS or error code
126
+ */
127
+ RAC_API rac_result_t rac_llm_get_info(rac_handle_t handle, rac_llm_info_t* out_info);
128
+
129
+ /**
130
+ * @brief Cancel ongoing generation
131
+ *
132
+ * @param handle Service handle
133
+ * @return RAC_SUCCESS or error code
134
+ */
135
+ RAC_API rac_result_t rac_llm_cancel(rac_handle_t handle);
136
+
137
+ /**
138
+ * @brief Cleanup and release model resources
139
+ *
140
+ * @param handle Service handle
141
+ * @return RAC_SUCCESS or error code
142
+ */
143
+ RAC_API rac_result_t rac_llm_cleanup(rac_handle_t handle);
144
+
145
+ /**
146
+ * @brief Destroy an LLM service instance
147
+ *
148
+ * @param handle Service handle to destroy
149
+ */
150
+ RAC_API void rac_llm_destroy(rac_handle_t handle);
151
+
152
+ /**
153
+ * @brief Free an LLM result
154
+ *
155
+ * @param result Result to free
156
+ */
157
+ RAC_API void rac_llm_result_free(rac_llm_result_t* result);
158
+
159
+ #ifdef __cplusplus
160
+ }
161
+ #endif
162
+
163
+ #endif /* RAC_LLM_SERVICE_H */
@@ -0,0 +1,141 @@
1
+ /**
2
+ * @file rac_llm_structured_output.h
3
+ * @brief RunAnywhere Commons - LLM Structured Output JSON Parsing
4
+ *
5
+ * C port of Swift's StructuredOutputHandler.swift from:
6
+ * Sources/RunAnywhere/Features/LLM/StructuredOutput/StructuredOutputHandler.swift
7
+ *
8
+ * IMPORTANT: This is a direct translation of the Swift implementation.
9
+ * Do NOT add features not present in the Swift code.
10
+ *
11
+ * Provides JSON extraction and parsing functions for structured output generation.
12
+ */
13
+
14
+ #ifndef RAC_LLM_STRUCTURED_OUTPUT_H
15
+ #define RAC_LLM_STRUCTURED_OUTPUT_H
16
+
17
+ #include <RACommons/rac_error.h>
18
+ #include <RACommons/rac_types.h>
19
+ #include <RACommons/rac_llm_types.h>
20
+
21
+ #ifdef __cplusplus
22
+ extern "C" {
23
+ #endif
24
+
25
+ // =============================================================================
26
+ // STRUCTURED OUTPUT API
27
+ // =============================================================================
28
+
29
+ /**
30
+ * @brief Extract JSON from potentially mixed text
31
+ *
32
+ * Ported from Swift StructuredOutputHandler.extractJSON(from:) (lines 102-132)
33
+ *
34
+ * Searches for complete JSON objects or arrays in the given text,
35
+ * handling cases where the text contains additional content before/after JSON.
36
+ *
37
+ * @param text Input text that may contain JSON mixed with other content
38
+ * @param out_json Output: Allocated JSON string (caller must free with rac_free)
39
+ * @param out_length Output: Length of extracted JSON string (can be NULL)
40
+ * @return RAC_SUCCESS if JSON found and extracted, error code otherwise
41
+ */
42
+ RAC_API rac_result_t rac_structured_output_extract_json(const char* text, char** out_json,
43
+ size_t* out_length);
44
+
45
+ /**
46
+ * @brief Find complete JSON boundaries in text
47
+ *
48
+ * Ported from Swift StructuredOutputHandler.findCompleteJSON(in:) (lines 135-176)
49
+ *
50
+ * Uses a character-by-character state machine to find matching braces/brackets
51
+ * while properly handling string escapes and nesting.
52
+ *
53
+ * @param text Text to search for JSON
54
+ * @param out_start Output: Start position of JSON (0-indexed)
55
+ * @param out_end Output: End position of JSON (exclusive)
56
+ * @return RAC_TRUE if complete JSON found, RAC_FALSE otherwise
57
+ */
58
+ RAC_API rac_bool_t rac_structured_output_find_complete_json(const char* text, size_t* out_start,
59
+ size_t* out_end);
60
+
61
+ /**
62
+ * @brief Find matching closing brace for an opening brace
63
+ *
64
+ * Ported from Swift StructuredOutputHandler.findMatchingBrace(in:startingFrom:) (lines 179-212)
65
+ *
66
+ * @param text Text to search
67
+ * @param start_pos Position of opening brace '{'
68
+ * @param out_end_pos Output: Position of matching closing brace '}'
69
+ * @return RAC_TRUE if matching brace found, RAC_FALSE otherwise
70
+ */
71
+ RAC_API rac_bool_t rac_structured_output_find_matching_brace(const char* text, size_t start_pos,
72
+ size_t* out_end_pos);
73
+
74
+ /**
75
+ * @brief Find matching closing bracket for an opening bracket
76
+ *
77
+ * Ported from Swift StructuredOutputHandler.findMatchingBracket(in:startingFrom:) (lines 215-248)
78
+ *
79
+ * @param text Text to search
80
+ * @param start_pos Position of opening bracket '['
81
+ * @param out_end_pos Output: Position of matching closing bracket ']'
82
+ * @return RAC_TRUE if matching bracket found, RAC_FALSE otherwise
83
+ */
84
+ RAC_API rac_bool_t rac_structured_output_find_matching_bracket(const char* text, size_t start_pos,
85
+ size_t* out_end_pos);
86
+
87
+ /**
88
+ * @brief Prepare prompt with structured output instructions
89
+ *
90
+ * Ported from Swift StructuredOutputHandler.preparePrompt(originalPrompt:config:) (lines 43-82)
91
+ *
92
+ * Adds JSON schema and generation instructions to the prompt.
93
+ *
94
+ * @param original_prompt Original user prompt
95
+ * @param config Structured output configuration with JSON schema
96
+ * @param out_prompt Output: Allocated prepared prompt (caller must free with rac_free)
97
+ * @return RAC_SUCCESS on success, error code otherwise
98
+ */
99
+ RAC_API rac_result_t rac_structured_output_prepare_prompt(
100
+ const char* original_prompt, const rac_structured_output_config_t* config, char** out_prompt);
101
+
102
+ /**
103
+ * @brief Get system prompt for structured output generation
104
+ *
105
+ * Ported from Swift StructuredOutputHandler.getSystemPrompt(for:) (lines 10-30)
106
+ *
107
+ * Generates a system prompt instructing the model to output only valid JSON.
108
+ *
109
+ * @param json_schema JSON schema describing expected output structure
110
+ * @param out_prompt Output: Allocated system prompt (caller must free with rac_free)
111
+ * @return RAC_SUCCESS on success, error code otherwise
112
+ */
113
+ RAC_API rac_result_t rac_structured_output_get_system_prompt(const char* json_schema,
114
+ char** out_prompt);
115
+
116
+ /**
117
+ * @brief Validate that text contains valid structured output
118
+ *
119
+ * Ported from Swift StructuredOutputHandler.validateStructuredOutput(text:config:) (lines 264-282)
120
+ *
121
+ * @param text Text to validate
122
+ * @param config Structured output configuration (can be NULL for basic validation)
123
+ * @param out_validation Output: Validation result (caller must free extracted_json with rac_free)
124
+ * @return RAC_SUCCESS on success, error code otherwise
125
+ */
126
+ RAC_API rac_result_t
127
+ rac_structured_output_validate(const char* text, const rac_structured_output_config_t* config,
128
+ rac_structured_output_validation_t* out_validation);
129
+
130
+ /**
131
+ * @brief Free structured output validation result
132
+ *
133
+ * @param validation Validation result to free
134
+ */
135
+ RAC_API void rac_structured_output_validation_free(rac_structured_output_validation_t* validation);
136
+
137
+ #ifdef __cplusplus
138
+ }
139
+ #endif
140
+
141
+ #endif /* RAC_LLM_STRUCTURED_OUTPUT_H */