@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.
- package/RunAnywhereCore.podspec +130 -0
- package/android/CMakeLists.txt +92 -0
- package/android/build.gradle +321 -0
- package/android/consumer-rules.pro +5 -0
- package/android/src/main/AndroidManifest.xml +3 -0
- package/android/src/main/cpp/cpp-adapter.cpp +271 -0
- package/android/src/main/include/rac/backends/rac_llm_llamacpp.h +218 -0
- package/android/src/main/include/rac/backends/rac_stt_onnx.h +99 -0
- package/android/src/main/include/rac/backends/rac_stt_whispercpp.h +153 -0
- package/android/src/main/include/rac/backends/rac_tts_onnx.h +71 -0
- package/android/src/main/include/rac/backends/rac_vad_onnx.h +84 -0
- package/android/src/main/include/rac/core/capabilities/rac_lifecycle.h +290 -0
- package/android/src/main/include/rac/core/rac_analytics_events.h +610 -0
- package/android/src/main/include/rac/core/rac_audio_utils.h +88 -0
- package/android/src/main/include/rac/core/rac_component_types.h +160 -0
- package/android/src/main/include/rac/core/rac_core.h +331 -0
- package/android/src/main/include/rac/core/rac_error.h +469 -0
- package/android/src/main/include/rac/core/rac_events.h +334 -0
- package/android/src/main/include/rac/core/rac_logger.h +416 -0
- package/android/src/main/include/rac/core/rac_platform_adapter.h +340 -0
- package/android/src/main/include/rac/core/rac_sdk_state.h +292 -0
- package/android/src/main/include/rac/core/rac_structured_error.h +594 -0
- package/android/src/main/include/rac/core/rac_types.h +264 -0
- package/android/src/main/include/rac/features/llm/rac_llm.h +17 -0
- package/android/src/main/include/rac/features/llm/rac_llm_analytics.h +188 -0
- package/android/src/main/include/rac/features/llm/rac_llm_component.h +228 -0
- package/android/src/main/include/rac/features/llm/rac_llm_events.h +215 -0
- package/android/src/main/include/rac/features/llm/rac_llm_metrics.h +402 -0
- package/android/src/main/include/rac/features/llm/rac_llm_service.h +163 -0
- package/android/src/main/include/rac/features/llm/rac_llm_structured_output.h +141 -0
- package/android/src/main/include/rac/features/llm/rac_llm_types.h +384 -0
- package/android/src/main/include/rac/features/platform/rac_llm_platform.h +204 -0
- package/android/src/main/include/rac/features/platform/rac_tts_platform.h +197 -0
- package/android/src/main/include/rac/features/stt/rac_stt.h +17 -0
- package/android/src/main/include/rac/features/stt/rac_stt_analytics.h +204 -0
- package/android/src/main/include/rac/features/stt/rac_stt_component.h +162 -0
- package/android/src/main/include/rac/features/stt/rac_stt_events.h +62 -0
- package/android/src/main/include/rac/features/stt/rac_stt_service.h +154 -0
- package/android/src/main/include/rac/features/stt/rac_stt_types.h +389 -0
- package/android/src/main/include/rac/features/tts/rac_tts.h +17 -0
- package/android/src/main/include/rac/features/tts/rac_tts_analytics.h +181 -0
- package/android/src/main/include/rac/features/tts/rac_tts_component.h +158 -0
- package/android/src/main/include/rac/features/tts/rac_tts_events.h +54 -0
- package/android/src/main/include/rac/features/tts/rac_tts_service.h +162 -0
- package/android/src/main/include/rac/features/tts/rac_tts_types.h +374 -0
- package/android/src/main/include/rac/features/vad/rac_vad.h +17 -0
- package/android/src/main/include/rac/features/vad/rac_vad_analytics.h +236 -0
- package/android/src/main/include/rac/features/vad/rac_vad_component.h +185 -0
- package/android/src/main/include/rac/features/vad/rac_vad_energy.h +443 -0
- package/android/src/main/include/rac/features/vad/rac_vad_events.h +76 -0
- package/android/src/main/include/rac/features/vad/rac_vad_service.h +167 -0
- package/android/src/main/include/rac/features/vad/rac_vad_types.h +244 -0
- package/android/src/main/include/rac/features/voice_agent/rac_voice_agent.h +612 -0
- package/android/src/main/include/rac/infrastructure/device/rac_device_manager.h +176 -0
- package/android/src/main/include/rac/infrastructure/download/rac_download.h +418 -0
- package/android/src/main/include/rac/infrastructure/events/rac_events.h +177 -0
- package/android/src/main/include/rac/infrastructure/model_management/rac_model_assignment.h +169 -0
- package/android/src/main/include/rac/infrastructure/model_management/rac_model_paths.h +258 -0
- package/android/src/main/include/rac/infrastructure/model_management/rac_model_registry.h +357 -0
- package/android/src/main/include/rac/infrastructure/model_management/rac_model_strategy.h +374 -0
- package/android/src/main/include/rac/infrastructure/model_management/rac_model_types.h +613 -0
- package/android/src/main/include/rac/infrastructure/network/rac_api_types.h +335 -0
- package/android/src/main/include/rac/infrastructure/network/rac_auth_manager.h +252 -0
- package/android/src/main/include/rac/infrastructure/network/rac_dev_config.h +85 -0
- package/android/src/main/include/rac/infrastructure/network/rac_endpoints.h +102 -0
- package/android/src/main/include/rac/infrastructure/network/rac_environment.h +220 -0
- package/android/src/main/include/rac/infrastructure/network/rac_http_client.h +233 -0
- package/android/src/main/include/rac/infrastructure/storage/rac_storage_analyzer.h +286 -0
- package/android/src/main/include/rac/infrastructure/telemetry/rac_telemetry_manager.h +206 -0
- package/android/src/main/include/rac/infrastructure/telemetry/rac_telemetry_types.h +234 -0
- package/android/src/main/java/com/margelo/nitro/runanywhere/ArchiveUtility.kt +308 -0
- package/android/src/main/java/com/margelo/nitro/runanywhere/HybridRunAnywhereDeviceInfo.kt +229 -0
- package/android/src/main/java/com/margelo/nitro/runanywhere/PlatformAdapterBridge.kt +392 -0
- package/android/src/main/java/com/margelo/nitro/runanywhere/RunAnywhereCorePackage.kt +28 -0
- package/android/src/main/java/com/margelo/nitro/runanywhere/SDKLogger.kt +357 -0
- package/android/src/main/java/com/margelo/nitro/runanywhere/SecureStorageManager.kt +147 -0
- package/android/src/main/jniLibs/arm64-v8a/libc++_shared.so +0 -0
- package/android/src/main/jniLibs/arm64-v8a/libomp.so +0 -0
- package/android/src/main/jniLibs/arm64-v8a/librac_commons.so +0 -0
- package/android/src/main/jniLibs/arm64-v8a/librunanywhere_jni.so +0 -0
- package/cpp/HybridRunAnywhereCore.cpp +2505 -0
- package/cpp/HybridRunAnywhereCore.hpp +271 -0
- package/cpp/bridges/AuthBridge.cpp +209 -0
- package/cpp/bridges/AuthBridge.hpp +157 -0
- package/cpp/bridges/DeviceBridge.cpp +257 -0
- package/cpp/bridges/DeviceBridge.hpp +155 -0
- package/cpp/bridges/DownloadBridge.cpp +299 -0
- package/cpp/bridges/DownloadBridge.hpp +197 -0
- package/cpp/bridges/EventBridge.cpp +125 -0
- package/cpp/bridges/EventBridge.hpp +139 -0
- package/cpp/bridges/HTTPBridge.cpp +96 -0
- package/cpp/bridges/HTTPBridge.hpp +144 -0
- package/cpp/bridges/InitBridge.cpp +1273 -0
- package/cpp/bridges/InitBridge.hpp +306 -0
- package/cpp/bridges/ModelRegistryBridge.cpp +394 -0
- package/cpp/bridges/ModelRegistryBridge.hpp +177 -0
- package/cpp/bridges/StorageBridge.cpp +269 -0
- package/cpp/bridges/StorageBridge.hpp +172 -0
- package/cpp/bridges/TelemetryBridge.cpp +352 -0
- package/cpp/bridges/TelemetryBridge.hpp +126 -0
- package/ios/.testlocal +0 -0
- package/ios/ArchiveUtility.swift +526 -0
- package/ios/ArchiveUtilityBridge.m +52 -0
- package/ios/AudioDecoder.h +38 -0
- package/ios/AudioDecoder.m +162 -0
- package/ios/Binaries/RACommons.xcframework/Info.plist +44 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/RACommons.h +67 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_analytics_events.h +610 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_api_types.h +335 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_audio_utils.h +88 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_auth_manager.h +252 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_component_types.h +160 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_core.h +331 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_dev_config.h +85 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_device_manager.h +176 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_download.h +418 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_endpoints.h +102 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_environment.h +220 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_error.h +469 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_events.h +177 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_http_client.h +233 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_lifecycle.h +290 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_llm.h +17 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_llm_analytics.h +188 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_llm_component.h +228 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_llm_events.h +215 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_llm_llamacpp.h +218 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_llm_metrics.h +402 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_llm_platform.h +204 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_llm_service.h +163 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_llm_structured_output.h +141 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_llm_types.h +384 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_logger.h +416 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_model_assignment.h +169 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_model_paths.h +258 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_model_registry.h +357 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_model_strategy.h +374 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_model_types.h +613 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_platform_adapter.h +340 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_sdk_state.h +292 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_storage_analyzer.h +286 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_structured_error.h +594 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_stt.h +17 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_stt_analytics.h +204 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_stt_component.h +162 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_stt_events.h +62 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_stt_onnx.h +99 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_stt_service.h +154 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_stt_types.h +389 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_stt_whispercpp.h +153 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_telemetry_manager.h +206 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_telemetry_types.h +234 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_tts.h +17 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_tts_analytics.h +181 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_tts_component.h +158 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_tts_events.h +54 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_tts_onnx.h +71 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_tts_platform.h +197 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_tts_service.h +162 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_tts_types.h +374 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_types.h +264 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_vad.h +17 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_vad_analytics.h +236 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_vad_component.h +185 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_vad_energy.h +443 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_vad_events.h +76 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_vad_onnx.h +84 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_vad_service.h +167 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_vad_types.h +244 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_voice_agent.h +612 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Info.plist +11 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Modules/module.modulemap +5 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/RACommons +0 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/RACommons.h +67 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_analytics_events.h +610 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_api_types.h +335 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_audio_utils.h +88 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_auth_manager.h +252 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_component_types.h +160 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_core.h +331 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_dev_config.h +85 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_device_manager.h +176 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_download.h +418 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_endpoints.h +102 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_environment.h +220 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_error.h +469 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_events.h +177 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_http_client.h +233 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_lifecycle.h +290 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_llm.h +17 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_llm_analytics.h +188 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_llm_component.h +228 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_llm_events.h +215 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_llm_llamacpp.h +218 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_llm_metrics.h +402 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_llm_platform.h +204 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_llm_service.h +163 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_llm_structured_output.h +141 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_llm_types.h +384 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_logger.h +416 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_model_assignment.h +169 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_model_paths.h +258 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_model_registry.h +357 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_model_strategy.h +374 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_model_types.h +613 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_platform_adapter.h +340 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_sdk_state.h +292 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_storage_analyzer.h +286 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_structured_error.h +594 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_stt.h +17 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_stt_analytics.h +204 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_stt_component.h +162 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_stt_events.h +62 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_stt_onnx.h +99 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_stt_service.h +154 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_stt_types.h +389 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_stt_whispercpp.h +153 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_telemetry_manager.h +206 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_telemetry_types.h +234 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_tts.h +17 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_tts_analytics.h +181 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_tts_component.h +158 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_tts_events.h +54 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_tts_onnx.h +71 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_tts_platform.h +197 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_tts_service.h +162 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_tts_types.h +374 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_types.h +264 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_vad.h +17 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_vad_analytics.h +236 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_vad_component.h +185 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_vad_energy.h +443 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_vad_events.h +76 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_vad_onnx.h +84 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_vad_service.h +167 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_vad_types.h +244 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_voice_agent.h +612 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Info.plist +11 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Modules/module.modulemap +5 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/RACommons +0 -0
- package/ios/HybridRunAnywhereDeviceInfo.swift +214 -0
- package/ios/KeychainManager.swift +116 -0
- package/ios/PlatformAdapter.swift +100 -0
- package/ios/PlatformAdapterBridge.h +152 -0
- package/ios/PlatformAdapterBridge.m +570 -0
- package/ios/RNSDKLoggerBridge.h +41 -0
- package/ios/RNSDKLoggerBridge.m +66 -0
- package/ios/SDKLogger.swift +329 -0
- package/nitro.json +20 -0
- package/nitrogen/generated/.gitattributes +1 -0
- package/nitrogen/generated/android/c++/JHybridRunAnywhereDeviceInfoSpec.cpp +257 -0
- package/nitrogen/generated/android/c++/JHybridRunAnywhereDeviceInfoSpec.hpp +77 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/runanywhere/HybridRunAnywhereDeviceInfoSpec.kt +106 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/runanywhere/runanywherecoreOnLoad.kt +35 -0
- package/nitrogen/generated/android/runanywherecore+autolinking.cmake +82 -0
- package/nitrogen/generated/android/runanywherecore+autolinking.gradle +27 -0
- package/nitrogen/generated/android/runanywherecoreOnLoad.cpp +54 -0
- package/nitrogen/generated/android/runanywherecoreOnLoad.hpp +25 -0
- package/nitrogen/generated/ios/RunAnywhereCore+autolinking.rb +60 -0
- package/nitrogen/generated/ios/RunAnywhereCore-Swift-Cxx-Bridge.cpp +65 -0
- package/nitrogen/generated/ios/RunAnywhereCore-Swift-Cxx-Bridge.hpp +197 -0
- package/nitrogen/generated/ios/RunAnywhereCore-Swift-Cxx-Umbrella.hpp +45 -0
- package/nitrogen/generated/ios/RunAnywhereCoreAutolinking.mm +43 -0
- package/nitrogen/generated/ios/RunAnywhereCoreAutolinking.swift +25 -0
- package/nitrogen/generated/ios/c++/HybridRunAnywhereDeviceInfoSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridRunAnywhereDeviceInfoSpecSwift.hpp +173 -0
- package/nitrogen/generated/ios/swift/Func_void_bool.swift +47 -0
- package/nitrogen/generated/ios/swift/Func_void_double.swift +47 -0
- package/nitrogen/generated/ios/swift/Func_void_std__exception_ptr.swift +47 -0
- package/nitrogen/generated/ios/swift/Func_void_std__string.swift +47 -0
- package/nitrogen/generated/ios/swift/HybridRunAnywhereDeviceInfoSpec.swift +68 -0
- package/nitrogen/generated/ios/swift/HybridRunAnywhereDeviceInfoSpec_cxx.swift +366 -0
- package/nitrogen/generated/shared/c++/HybridRunAnywhereCoreSpec.cpp +92 -0
- package/nitrogen/generated/shared/c++/HybridRunAnywhereCoreSpec.hpp +138 -0
- package/nitrogen/generated/shared/c++/HybridRunAnywhereDeviceInfoSpec.cpp +33 -0
- package/nitrogen/generated/shared/c++/HybridRunAnywhereDeviceInfoSpec.hpp +75 -0
- package/package.json +76 -0
- package/react-native.config.js +14 -0
- package/src/Features/VoiceSession/AudioCaptureManager.ts +286 -0
- package/src/Features/VoiceSession/AudioPlaybackManager.ts +300 -0
- package/src/Features/VoiceSession/VoiceSessionHandle.ts +530 -0
- package/src/Features/VoiceSession/index.ts +20 -0
- package/src/Features/index.ts +7 -0
- package/src/Foundation/Constants/SDKConstants.ts +47 -0
- package/src/Foundation/Constants/index.ts +8 -0
- package/src/Foundation/DependencyInjection/ServiceContainer.ts +154 -0
- package/src/Foundation/DependencyInjection/ServiceRegistry.ts +51 -0
- package/src/Foundation/DependencyInjection/index.ts +6 -0
- package/src/Foundation/ErrorTypes/ErrorCategory.ts +184 -0
- package/src/Foundation/ErrorTypes/ErrorCodes.ts +151 -0
- package/src/Foundation/ErrorTypes/ErrorContext.ts +201 -0
- package/src/Foundation/ErrorTypes/SDKError.ts +507 -0
- package/src/Foundation/ErrorTypes/index.ts +57 -0
- package/src/Foundation/Initialization/InitializationPhase.ts +85 -0
- package/src/Foundation/Initialization/InitializationState.ts +168 -0
- package/src/Foundation/Initialization/index.ts +26 -0
- package/src/Foundation/Logging/Destinations/NativeLogBridge.ts +147 -0
- package/src/Foundation/Logging/Destinations/SentryDestination.ts +209 -0
- package/src/Foundation/Logging/Logger/SDKLogger.ts +232 -0
- package/src/Foundation/Logging/Models/LogLevel.ts +36 -0
- package/src/Foundation/Logging/Models/LoggingConfiguration.ts +117 -0
- package/src/Foundation/Logging/Services/LoggingManager.ts +407 -0
- package/src/Foundation/Logging/index.ts +59 -0
- package/src/Foundation/Security/DeviceIdentity.ts +92 -0
- package/src/Foundation/Security/SecureStorageError.ts +132 -0
- package/src/Foundation/Security/SecureStorageKeys.ts +35 -0
- package/src/Foundation/Security/SecureStorageService.ts +449 -0
- package/src/Foundation/Security/index.ts +17 -0
- package/src/Foundation/index.ts +26 -0
- package/src/Infrastructure/Events/EventPublisher.ts +165 -0
- package/src/Infrastructure/Events/SDKEvent.ts +214 -0
- package/src/Infrastructure/Events/index.ts +15 -0
- package/src/Infrastructure/index.ts +9 -0
- package/src/Public/Events/EventBus.ts +488 -0
- package/src/Public/Events/index.ts +8 -0
- package/src/Public/Extensions/RunAnywhere+Logging.ts +51 -0
- package/src/Public/Extensions/RunAnywhere+Models.ts +392 -0
- package/src/Public/Extensions/RunAnywhere+STT.ts +424 -0
- package/src/Public/Extensions/RunAnywhere+Storage.ts +151 -0
- package/src/Public/Extensions/RunAnywhere+StructuredOutput.ts +316 -0
- package/src/Public/Extensions/RunAnywhere+TTS.ts +430 -0
- package/src/Public/Extensions/RunAnywhere+TextGeneration.ts +320 -0
- package/src/Public/Extensions/RunAnywhere+VAD.ts +359 -0
- package/src/Public/Extensions/RunAnywhere+VoiceAgent.ts +225 -0
- package/src/Public/Extensions/RunAnywhere+VoiceSession.ts +155 -0
- package/src/Public/Extensions/index.ts +126 -0
- package/src/Public/RunAnywhere.ts +695 -0
- package/src/index.ts +238 -0
- package/src/native/NativeRunAnywhereCore.ts +291 -0
- package/src/native/NativeRunAnywhereModule.ts +32 -0
- package/src/native/index.ts +21 -0
- package/src/services/DownloadService.ts +282 -0
- package/src/services/FileSystem.ts +810 -0
- package/src/services/ModelRegistry.ts +246 -0
- package/src/services/Network/APIEndpoints.ts +84 -0
- package/src/services/Network/HTTPService.ts +479 -0
- package/src/services/Network/NetworkConfiguration.ts +130 -0
- package/src/services/Network/TelemetryService.ts +318 -0
- package/src/services/Network/index.ts +29 -0
- package/src/services/SystemTTSService.ts +130 -0
- package/src/services/index.ts +66 -0
- package/src/specs/RunAnywhereCore.nitro.ts +627 -0
- package/src/specs/RunAnywhereDeviceInfo.nitro.ts +73 -0
- package/src/types/LLMTypes.ts +127 -0
- package/src/types/STTTypes.ts +124 -0
- package/src/types/StructuredOutputTypes.ts +156 -0
- package/src/types/TTSTypes.ts +126 -0
- package/src/types/VADTypes.ts +70 -0
- package/src/types/VoiceAgentTypes.ts +182 -0
- package/src/types/enums.ts +258 -0
- package/src/types/events.ts +337 -0
- package/src/types/external.d.ts +142 -0
- package/src/types/index.ts +146 -0
- package/src/types/models.ts +579 -0
|
@@ -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 "rac/core/rac_error.h"
|
|
14
|
+
#include "rac/features/llm/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 "rac/core/rac_error.h"
|
|
18
|
+
#include "rac/core/rac_types.h"
|
|
19
|
+
#include "rac/features/llm/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 */
|
|
@@ -0,0 +1,384 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file rac_llm_types.h
|
|
3
|
+
* @brief RunAnywhere Commons - LLM Types and Data Structures
|
|
4
|
+
*
|
|
5
|
+
* C port of Swift's LLM Models from:
|
|
6
|
+
* Sources/RunAnywhere/Features/LLM/Models/LLMGenerationOptions.swift
|
|
7
|
+
* Sources/RunAnywhere/Features/LLM/Models/LLMGenerationResult.swift
|
|
8
|
+
*
|
|
9
|
+
* This header defines data structures only. For the service interface,
|
|
10
|
+
* see rac_llm_service.h.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
#ifndef RAC_LLM_TYPES_H
|
|
14
|
+
#define RAC_LLM_TYPES_H
|
|
15
|
+
|
|
16
|
+
#include "rac/core/rac_types.h"
|
|
17
|
+
|
|
18
|
+
#ifdef __cplusplus
|
|
19
|
+
extern "C" {
|
|
20
|
+
#endif
|
|
21
|
+
|
|
22
|
+
// =============================================================================
|
|
23
|
+
// CONFIGURATION - Mirrors Swift's LLMConfiguration
|
|
24
|
+
// =============================================================================
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* @brief LLM component configuration
|
|
28
|
+
*
|
|
29
|
+
* Mirrors Swift's LLMConfiguration struct exactly.
|
|
30
|
+
* See: Sources/RunAnywhere/Features/LLM/Models/LLMConfiguration.swift
|
|
31
|
+
*/
|
|
32
|
+
typedef struct rac_llm_config {
|
|
33
|
+
/** Model ID (optional - uses default if NULL) */
|
|
34
|
+
const char* model_id;
|
|
35
|
+
|
|
36
|
+
/** Preferred framework for generation (use RAC_FRAMEWORK_UNKNOWN for auto) */
|
|
37
|
+
int32_t preferred_framework;
|
|
38
|
+
|
|
39
|
+
/** Context length - max tokens the model can handle (default: 2048) */
|
|
40
|
+
int32_t context_length;
|
|
41
|
+
|
|
42
|
+
/** Temperature for sampling (0.0 - 2.0, default: 0.7) */
|
|
43
|
+
float temperature;
|
|
44
|
+
|
|
45
|
+
/** Maximum tokens to generate (default: 100) */
|
|
46
|
+
int32_t max_tokens;
|
|
47
|
+
|
|
48
|
+
/** System prompt for generation (can be NULL) */
|
|
49
|
+
const char* system_prompt;
|
|
50
|
+
|
|
51
|
+
/** Enable streaming mode (default: true) */
|
|
52
|
+
rac_bool_t streaming_enabled;
|
|
53
|
+
} rac_llm_config_t;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* @brief Default LLM configuration
|
|
57
|
+
*/
|
|
58
|
+
static const rac_llm_config_t RAC_LLM_CONFIG_DEFAULT = {.model_id = RAC_NULL,
|
|
59
|
+
.preferred_framework =
|
|
60
|
+
99, // RAC_FRAMEWORK_UNKNOWN
|
|
61
|
+
.context_length = 2048,
|
|
62
|
+
.temperature = 0.7f,
|
|
63
|
+
.max_tokens = 100,
|
|
64
|
+
.system_prompt = RAC_NULL,
|
|
65
|
+
.streaming_enabled = RAC_TRUE};
|
|
66
|
+
|
|
67
|
+
// =============================================================================
|
|
68
|
+
// OPTIONS - Mirrors Swift's LLMGenerationOptions
|
|
69
|
+
// =============================================================================
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* @brief LLM generation options
|
|
73
|
+
*
|
|
74
|
+
* Mirrors Swift's LLMGenerationOptions struct exactly.
|
|
75
|
+
* See: Sources/RunAnywhere/Features/LLM/Models/LLMGenerationOptions.swift
|
|
76
|
+
*/
|
|
77
|
+
typedef struct rac_llm_options {
|
|
78
|
+
/** Maximum number of tokens to generate (default: 100) */
|
|
79
|
+
int32_t max_tokens;
|
|
80
|
+
|
|
81
|
+
/** Temperature for sampling (0.0 - 2.0, default: 0.8) */
|
|
82
|
+
float temperature;
|
|
83
|
+
|
|
84
|
+
/** Top-p sampling parameter (default: 1.0) */
|
|
85
|
+
float top_p;
|
|
86
|
+
|
|
87
|
+
/** Stop sequences (null-terminated array, can be NULL) */
|
|
88
|
+
const char* const* stop_sequences;
|
|
89
|
+
size_t num_stop_sequences;
|
|
90
|
+
|
|
91
|
+
/** Enable streaming mode (default: false) */
|
|
92
|
+
rac_bool_t streaming_enabled;
|
|
93
|
+
|
|
94
|
+
/** System prompt (can be NULL) */
|
|
95
|
+
const char* system_prompt;
|
|
96
|
+
} rac_llm_options_t;
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* @brief Default LLM generation options
|
|
100
|
+
*/
|
|
101
|
+
static const rac_llm_options_t RAC_LLM_OPTIONS_DEFAULT = {.max_tokens = 100,
|
|
102
|
+
.temperature = 0.8f,
|
|
103
|
+
.top_p = 1.0f,
|
|
104
|
+
.stop_sequences = RAC_NULL,
|
|
105
|
+
.num_stop_sequences = 0,
|
|
106
|
+
.streaming_enabled = RAC_FALSE,
|
|
107
|
+
.system_prompt = RAC_NULL};
|
|
108
|
+
|
|
109
|
+
// =============================================================================
|
|
110
|
+
// RESULT - Mirrors Swift's LLMGenerationResult
|
|
111
|
+
// =============================================================================
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* @brief LLM generation result
|
|
115
|
+
*/
|
|
116
|
+
typedef struct rac_llm_result {
|
|
117
|
+
/** Generated text (owned, must be freed with rac_free) */
|
|
118
|
+
char* text;
|
|
119
|
+
|
|
120
|
+
/** Number of tokens in prompt */
|
|
121
|
+
int32_t prompt_tokens;
|
|
122
|
+
|
|
123
|
+
/** Number of tokens generated */
|
|
124
|
+
int32_t completion_tokens;
|
|
125
|
+
|
|
126
|
+
/** Total tokens (prompt + completion) */
|
|
127
|
+
int32_t total_tokens;
|
|
128
|
+
|
|
129
|
+
/** Time to first token in milliseconds */
|
|
130
|
+
int64_t time_to_first_token_ms;
|
|
131
|
+
|
|
132
|
+
/** Total generation time in milliseconds */
|
|
133
|
+
int64_t total_time_ms;
|
|
134
|
+
|
|
135
|
+
/** Tokens per second */
|
|
136
|
+
float tokens_per_second;
|
|
137
|
+
} rac_llm_result_t;
|
|
138
|
+
|
|
139
|
+
// =============================================================================
|
|
140
|
+
// INFO - Mirrors Swift's LLMService properties
|
|
141
|
+
// =============================================================================
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* @brief LLM service handle info
|
|
145
|
+
*
|
|
146
|
+
* Mirrors Swift's LLMService properties.
|
|
147
|
+
*/
|
|
148
|
+
typedef struct rac_llm_info {
|
|
149
|
+
/** Whether the service is ready for generation (isReady) */
|
|
150
|
+
rac_bool_t is_ready;
|
|
151
|
+
|
|
152
|
+
/** Current model identifier (currentModel, can be NULL) */
|
|
153
|
+
const char* current_model;
|
|
154
|
+
|
|
155
|
+
/** Context length (contextLength, 0 if unknown) */
|
|
156
|
+
int32_t context_length;
|
|
157
|
+
|
|
158
|
+
/** Whether streaming is supported (supportsStreaming) */
|
|
159
|
+
rac_bool_t supports_streaming;
|
|
160
|
+
} rac_llm_info_t;
|
|
161
|
+
|
|
162
|
+
// =============================================================================
|
|
163
|
+
// CALLBACKS
|
|
164
|
+
// =============================================================================
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* @brief LLM streaming callback
|
|
168
|
+
*
|
|
169
|
+
* Called for each generated token during streaming.
|
|
170
|
+
* Mirrors Swift's onToken callback pattern.
|
|
171
|
+
*
|
|
172
|
+
* @param token The generated token string
|
|
173
|
+
* @param user_data User-provided context
|
|
174
|
+
* @return RAC_TRUE to continue, RAC_FALSE to stop generation
|
|
175
|
+
*/
|
|
176
|
+
typedef rac_bool_t (*rac_llm_stream_callback_fn)(const char* token, void* user_data);
|
|
177
|
+
|
|
178
|
+
// =============================================================================
|
|
179
|
+
// THINKING TAG PATTERN - Mirrors Swift's ThinkingTagPattern
|
|
180
|
+
// =============================================================================
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* @brief Pattern for extracting thinking/reasoning content from model output
|
|
184
|
+
*
|
|
185
|
+
* Mirrors Swift's ThinkingTagPattern struct exactly.
|
|
186
|
+
* See: Sources/RunAnywhere/Features/LLM/Models/ThinkingTagPattern.swift
|
|
187
|
+
*/
|
|
188
|
+
typedef struct rac_thinking_tag_pattern {
|
|
189
|
+
/** Opening tag for thinking content (e.g., "<think>") */
|
|
190
|
+
const char* opening_tag;
|
|
191
|
+
|
|
192
|
+
/** Closing tag for thinking content (e.g., "</think>") */
|
|
193
|
+
const char* closing_tag;
|
|
194
|
+
} rac_thinking_tag_pattern_t;
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* @brief Default thinking tag pattern (DeepSeek/Hermes style)
|
|
198
|
+
*/
|
|
199
|
+
static const rac_thinking_tag_pattern_t RAC_THINKING_TAG_DEFAULT = {.opening_tag = "<think>",
|
|
200
|
+
.closing_tag = "</think>"};
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* @brief Alternative thinking pattern with full word
|
|
204
|
+
*/
|
|
205
|
+
static const rac_thinking_tag_pattern_t RAC_THINKING_TAG_FULL = {.opening_tag = "<thinking>",
|
|
206
|
+
.closing_tag = "</thinking>"};
|
|
207
|
+
|
|
208
|
+
// =============================================================================
|
|
209
|
+
// STRUCTURED OUTPUT - Mirrors Swift's StructuredOutputConfig
|
|
210
|
+
// =============================================================================
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* @brief Structured output configuration
|
|
214
|
+
*
|
|
215
|
+
* Mirrors Swift's StructuredOutputConfig struct.
|
|
216
|
+
* See: Sources/RunAnywhere/Features/LLM/StructuredOutput/Generatable.swift
|
|
217
|
+
*
|
|
218
|
+
* Note: In C, we pass the JSON schema directly instead of using reflection.
|
|
219
|
+
*/
|
|
220
|
+
typedef struct rac_structured_output_config {
|
|
221
|
+
/** JSON schema for the expected output structure */
|
|
222
|
+
const char* json_schema;
|
|
223
|
+
|
|
224
|
+
/** Whether to include the schema in the prompt */
|
|
225
|
+
rac_bool_t include_schema_in_prompt;
|
|
226
|
+
} rac_structured_output_config_t;
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* @brief Default structured output configuration
|
|
230
|
+
*/
|
|
231
|
+
static const rac_structured_output_config_t RAC_STRUCTURED_OUTPUT_DEFAULT = {
|
|
232
|
+
.json_schema = RAC_NULL, .include_schema_in_prompt = RAC_TRUE};
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* @brief Structured output validation result
|
|
236
|
+
*
|
|
237
|
+
* Mirrors Swift's StructuredOutputValidation struct.
|
|
238
|
+
*/
|
|
239
|
+
typedef struct rac_structured_output_validation {
|
|
240
|
+
/** Whether the output is valid according to the schema */
|
|
241
|
+
rac_bool_t is_valid;
|
|
242
|
+
|
|
243
|
+
/** Error message if validation failed (can be NULL) */
|
|
244
|
+
const char* error_message;
|
|
245
|
+
|
|
246
|
+
/** Extracted JSON string (can be NULL) */
|
|
247
|
+
char* extracted_json;
|
|
248
|
+
} rac_structured_output_validation_t;
|
|
249
|
+
|
|
250
|
+
// =============================================================================
|
|
251
|
+
// STREAMING RESULT - Mirrors Swift's LLMStreamingResult
|
|
252
|
+
// =============================================================================
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* @brief Token event during streaming
|
|
256
|
+
*
|
|
257
|
+
* Provides detailed information about each token during streaming generation.
|
|
258
|
+
*/
|
|
259
|
+
typedef struct rac_llm_token_event {
|
|
260
|
+
/** The generated token text */
|
|
261
|
+
const char* token;
|
|
262
|
+
|
|
263
|
+
/** Token index in the sequence */
|
|
264
|
+
int32_t token_index;
|
|
265
|
+
|
|
266
|
+
/** Is this the final token? */
|
|
267
|
+
rac_bool_t is_final;
|
|
268
|
+
|
|
269
|
+
/** Tokens generated per second so far */
|
|
270
|
+
float tokens_per_second;
|
|
271
|
+
} rac_llm_token_event_t;
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* @brief Extended streaming callback with token event details
|
|
275
|
+
*
|
|
276
|
+
* @param event Token event details
|
|
277
|
+
* @param user_data User-provided context
|
|
278
|
+
* @return RAC_TRUE to continue, RAC_FALSE to stop generation
|
|
279
|
+
*/
|
|
280
|
+
typedef rac_bool_t (*rac_llm_token_event_callback_fn)(const rac_llm_token_event_t* event,
|
|
281
|
+
void* user_data);
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* @brief Streaming result handle
|
|
285
|
+
*
|
|
286
|
+
* Opaque handle for managing streaming generation.
|
|
287
|
+
* In C++, this wraps the streaming state and provides synchronization.
|
|
288
|
+
*
|
|
289
|
+
* Note: LLMStreamingResult in Swift returns an AsyncThrowingStream and a Task.
|
|
290
|
+
* In C, we use callbacks instead of async streams.
|
|
291
|
+
*/
|
|
292
|
+
typedef void* rac_llm_stream_handle_t;
|
|
293
|
+
|
|
294
|
+
/**
|
|
295
|
+
* @brief Streaming generation parameters
|
|
296
|
+
*
|
|
297
|
+
* Configuration for starting a streaming generation.
|
|
298
|
+
*/
|
|
299
|
+
typedef struct rac_llm_stream_params {
|
|
300
|
+
/** Prompt to generate from */
|
|
301
|
+
const char* prompt;
|
|
302
|
+
|
|
303
|
+
/** Generation options */
|
|
304
|
+
rac_llm_options_t options;
|
|
305
|
+
|
|
306
|
+
/** Callback for each token */
|
|
307
|
+
rac_llm_stream_callback_fn on_token;
|
|
308
|
+
|
|
309
|
+
/** Extended callback with token event details (optional, can be NULL) */
|
|
310
|
+
rac_llm_token_event_callback_fn on_token_event;
|
|
311
|
+
|
|
312
|
+
/** User data passed to callbacks */
|
|
313
|
+
void* user_data;
|
|
314
|
+
|
|
315
|
+
/** Optional thinking tag pattern to extract thinking content */
|
|
316
|
+
const rac_thinking_tag_pattern_t* thinking_pattern;
|
|
317
|
+
} rac_llm_stream_params_t;
|
|
318
|
+
|
|
319
|
+
/**
|
|
320
|
+
* @brief Streaming generation metrics
|
|
321
|
+
*
|
|
322
|
+
* Metrics collected during streaming generation.
|
|
323
|
+
*/
|
|
324
|
+
typedef struct rac_llm_stream_metrics {
|
|
325
|
+
/** Time to first token in milliseconds */
|
|
326
|
+
int64_t time_to_first_token_ms;
|
|
327
|
+
|
|
328
|
+
/** Total generation time in milliseconds */
|
|
329
|
+
int64_t total_time_ms;
|
|
330
|
+
|
|
331
|
+
/** Number of tokens generated */
|
|
332
|
+
int32_t tokens_generated;
|
|
333
|
+
|
|
334
|
+
/** Tokens per second */
|
|
335
|
+
float tokens_per_second;
|
|
336
|
+
|
|
337
|
+
/** Number of tokens in the prompt */
|
|
338
|
+
int32_t prompt_tokens;
|
|
339
|
+
|
|
340
|
+
/** Thinking tokens if thinking pattern was used */
|
|
341
|
+
int32_t thinking_tokens;
|
|
342
|
+
|
|
343
|
+
/** Response tokens (excluding thinking) */
|
|
344
|
+
int32_t response_tokens;
|
|
345
|
+
} rac_llm_stream_metrics_t;
|
|
346
|
+
|
|
347
|
+
/**
|
|
348
|
+
* @brief Complete streaming result
|
|
349
|
+
*
|
|
350
|
+
* Final result after streaming generation is complete.
|
|
351
|
+
*/
|
|
352
|
+
typedef struct rac_llm_stream_result {
|
|
353
|
+
/** Full generated text (owned, must be freed with rac_free) */
|
|
354
|
+
char* text;
|
|
355
|
+
|
|
356
|
+
/** Extracted thinking content if pattern was provided (can be NULL) */
|
|
357
|
+
char* thinking_content;
|
|
358
|
+
|
|
359
|
+
/** Generation metrics */
|
|
360
|
+
rac_llm_stream_metrics_t metrics;
|
|
361
|
+
|
|
362
|
+
/** Error code if generation failed (RAC_SUCCESS on success) */
|
|
363
|
+
rac_result_t error_code;
|
|
364
|
+
|
|
365
|
+
/** Error message if generation failed (can be NULL) */
|
|
366
|
+
char* error_message;
|
|
367
|
+
} rac_llm_stream_result_t;
|
|
368
|
+
|
|
369
|
+
// =============================================================================
|
|
370
|
+
// MEMORY MANAGEMENT
|
|
371
|
+
// =============================================================================
|
|
372
|
+
|
|
373
|
+
/**
|
|
374
|
+
* @brief Free LLM result resources
|
|
375
|
+
*
|
|
376
|
+
* @param result Result to free (can be NULL)
|
|
377
|
+
*/
|
|
378
|
+
RAC_API void rac_llm_result_free(rac_llm_result_t* result);
|
|
379
|
+
|
|
380
|
+
#ifdef __cplusplus
|
|
381
|
+
}
|
|
382
|
+
#endif
|
|
383
|
+
|
|
384
|
+
#endif /* RAC_LLM_TYPES_H */
|