@runanywhere/core 0.17.7 → 0.18.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/README.md +218 -2
- package/RunAnywhereCore.podspec +1 -0
- package/android/CMakeLists.txt +24 -2
- package/android/build.gradle +61 -9
- package/android/src/main/cpp/cpp-adapter.cpp +51 -3
- package/android/src/main/include/rac/backends/rac_vlm_llamacpp.h +216 -0
- package/android/src/main/include/rac/core/capabilities/rac_lifecycle.h +3 -1
- package/android/src/main/include/rac/core/rac_core.h +11 -0
- package/android/src/main/include/rac/core/rac_types.h +8 -6
- package/android/src/main/include/rac/features/diffusion/rac_diffusion.h +22 -0
- package/android/src/main/include/rac/features/diffusion/rac_diffusion_component.h +263 -0
- package/android/src/main/include/rac/features/diffusion/rac_diffusion_model_registry.h +358 -0
- package/android/src/main/include/rac/features/diffusion/rac_diffusion_service.h +187 -0
- package/android/src/main/include/rac/features/diffusion/rac_diffusion_tokenizer.h +167 -0
- package/android/src/main/include/rac/features/diffusion/rac_diffusion_types.h +454 -0
- package/android/src/main/include/rac/features/llm/rac_tool_calling.h +373 -0
- package/android/src/main/include/rac/features/platform/rac_diffusion_platform.h +305 -0
- package/android/src/main/include/rac/features/vad/rac_vad_energy.h +1 -1
- package/android/src/main/include/rac/features/vlm/rac_vlm.h +16 -0
- package/android/src/main/include/rac/features/vlm/rac_vlm_component.h +168 -0
- package/android/src/main/include/rac/features/vlm/rac_vlm_service.h +206 -0
- package/android/src/main/include/rac/features/vlm/rac_vlm_types.h +417 -0
- package/android/src/main/include/rac/infrastructure/model_management/rac_model_registry.h +15 -0
- package/android/src/main/include/rac/infrastructure/model_management/rac_model_types.h +3 -0
- package/android/src/main/include/rac/utils/rac_image_utils.h +215 -0
- package/android/src/main/java/com/margelo/nitro/runanywhere/PlatformAdapterBridge.kt +201 -1
- 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/android/src/main/jniLibs/x86_64/libc++_shared.so +0 -0
- package/android/src/main/jniLibs/x86_64/libomp.so +0 -0
- package/android/src/main/jniLibs/x86_64/librac_commons.so +0 -0
- package/android/src/main/jniLibs/x86_64/librunanywhere_jni.so +0 -0
- package/cpp/HybridRunAnywhereCore.cpp +259 -160
- package/cpp/HybridRunAnywhereCore.hpp +11 -0
- package/cpp/bridges/InitBridge.cpp +234 -3
- package/cpp/bridges/PlatformDownloadBridge.h +44 -0
- package/cpp/bridges/ToolCallingBridge.cpp +188 -0
- package/cpp/bridges/ToolCallingBridge.hpp +98 -0
- package/cpp/third_party/nlohmann/json.hpp +24765 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/RACommons.h +18 -4
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_core.h +11 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_diffusion.h +22 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_diffusion_component.h +263 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_diffusion_model_registry.h +358 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_diffusion_platform.h +305 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_diffusion_service.h +187 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_diffusion_tokenizer.h +167 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_diffusion_types.h +454 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_endpoints.h +3 -17
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_image_utils.h +215 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_lifecycle.h +3 -1
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_model_assignment.h +4 -20
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_model_registry.h +15 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_model_types.h +3 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_tool_calling.h +373 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_types.h +8 -6
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_vad_energy.h +1 -1
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_vlm.h +16 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_vlm_component.h +168 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_vlm_llamacpp.h +216 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_vlm_service.h +206 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_vlm_types.h +417 -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 +18 -4
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_core.h +11 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_diffusion.h +22 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_diffusion_component.h +263 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_diffusion_model_registry.h +358 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_diffusion_platform.h +305 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_diffusion_service.h +187 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_diffusion_tokenizer.h +167 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_diffusion_types.h +454 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_endpoints.h +3 -17
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_image_utils.h +215 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_lifecycle.h +3 -1
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_model_assignment.h +4 -20
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_model_registry.h +15 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_model_types.h +3 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_tool_calling.h +373 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_types.h +8 -6
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_vad_energy.h +1 -1
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_vlm.h +16 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_vlm_component.h +168 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_vlm_llamacpp.h +216 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_vlm_service.h +206 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_vlm_types.h +417 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/RACommons +0 -0
- package/ios/PlatformAdapterBridge.h +24 -1
- package/ios/PlatformAdapterBridge.m +243 -0
- package/nitrogen/generated/shared/c++/HybridRunAnywhereCoreSpec.cpp +4 -0
- package/nitrogen/generated/shared/c++/HybridRunAnywhereCoreSpec.hpp +4 -0
- package/package.json +8 -4
- package/src/Foundation/Security/SecureStorageService.ts +12 -6
- package/src/Public/Extensions/RunAnywhere+Models.ts +5 -3
- package/src/Public/Extensions/RunAnywhere+STT.ts +7 -2
- package/src/Public/Extensions/RunAnywhere+ToolCalling.ts +472 -0
- package/src/Public/Extensions/index.ts +16 -0
- package/src/Public/RunAnywhere.ts +18 -0
- package/src/index.ts +0 -1
- package/src/services/Network/index.ts +0 -1
- package/src/services/index.ts +0 -1
- package/src/specs/RunAnywhereCore.nitro.ts +72 -0
- package/src/types/ToolCallingTypes.ts +198 -0
- package/src/types/index.ts +13 -0
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
#import <Foundation/Foundation.h>
|
|
9
9
|
#import <UIKit/UIKit.h>
|
|
10
|
+
#import "PlatformDownloadBridge.h"
|
|
10
11
|
|
|
11
12
|
// Import the generated Swift header from the pod
|
|
12
13
|
#if __has_include(<RunAnywhereCore/RunAnywhereCore-Swift.h>)
|
|
@@ -29,6 +30,206 @@
|
|
|
29
30
|
@end
|
|
30
31
|
#endif
|
|
31
32
|
|
|
33
|
+
// =============================================================================
|
|
34
|
+
// HTTP Download (Platform Adapter)
|
|
35
|
+
// =============================================================================
|
|
36
|
+
|
|
37
|
+
static const int RAC_SUCCESS = 0;
|
|
38
|
+
static const int RAC_ERROR_INVALID_PARAMETER = -106;
|
|
39
|
+
static const int RAC_ERROR_DOWNLOAD_FAILED = -153;
|
|
40
|
+
static const int RAC_ERROR_CANCELLED = -380;
|
|
41
|
+
|
|
42
|
+
@interface RunAnywhereHttpDownloadTaskInfo : NSObject
|
|
43
|
+
@property(nonatomic, copy) NSString* taskId;
|
|
44
|
+
@property(nonatomic, copy) NSString* destinationPath;
|
|
45
|
+
@property(nonatomic, assign) BOOL cancelled;
|
|
46
|
+
@end
|
|
47
|
+
|
|
48
|
+
@implementation RunAnywhereHttpDownloadTaskInfo
|
|
49
|
+
@end
|
|
50
|
+
|
|
51
|
+
@interface RunAnywhereHttpDownloadManager : NSObject <NSURLSessionDownloadDelegate>
|
|
52
|
+
@property(nonatomic, strong) NSURLSession* session;
|
|
53
|
+
@property(nonatomic, strong) NSMutableDictionary<NSNumber*, RunAnywhereHttpDownloadTaskInfo*>* taskInfoByIdentifier;
|
|
54
|
+
@property(nonatomic, strong) NSMutableDictionary<NSString*, NSURLSessionDownloadTask*>* taskById;
|
|
55
|
+
@property(nonatomic, strong) NSMutableDictionary<NSString*, NSString*>* completedPathById;
|
|
56
|
+
+ (instancetype)shared;
|
|
57
|
+
- (int)startDownload:(NSString*)url destination:(NSString*)destination taskId:(NSString*)taskId;
|
|
58
|
+
- (BOOL)cancelDownload:(NSString*)taskId;
|
|
59
|
+
@end
|
|
60
|
+
|
|
61
|
+
@implementation RunAnywhereHttpDownloadManager
|
|
62
|
+
|
|
63
|
+
+ (instancetype)shared {
|
|
64
|
+
static RunAnywhereHttpDownloadManager* instance = nil;
|
|
65
|
+
static dispatch_once_t onceToken;
|
|
66
|
+
dispatch_once(&onceToken, ^{
|
|
67
|
+
instance = [[RunAnywhereHttpDownloadManager alloc] init];
|
|
68
|
+
});
|
|
69
|
+
return instance;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
- (instancetype)init {
|
|
73
|
+
self = [super init];
|
|
74
|
+
if (self) {
|
|
75
|
+
NSURLSessionConfiguration* config = [NSURLSessionConfiguration defaultSessionConfiguration];
|
|
76
|
+
NSOperationQueue* queue = [[NSOperationQueue alloc] init];
|
|
77
|
+
queue.maxConcurrentOperationCount = 4;
|
|
78
|
+
_session = [NSURLSession sessionWithConfiguration:config delegate:self delegateQueue:queue];
|
|
79
|
+
_taskInfoByIdentifier = [NSMutableDictionary dictionary];
|
|
80
|
+
_taskById = [NSMutableDictionary dictionary];
|
|
81
|
+
_completedPathById = [NSMutableDictionary dictionary];
|
|
82
|
+
}
|
|
83
|
+
return self;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
- (int)startDownload:(NSString*)url destination:(NSString*)destination taskId:(NSString*)taskId {
|
|
87
|
+
if (url.length == 0 || destination.length == 0 || taskId.length == 0) {
|
|
88
|
+
return RAC_ERROR_INVALID_PARAMETER;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
NSURL* downloadURL = [NSURL URLWithString:url];
|
|
92
|
+
if (!downloadURL) {
|
|
93
|
+
return RAC_ERROR_INVALID_PARAMETER;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
NSURLSessionDownloadTask* task = [self.session downloadTaskWithURL:downloadURL];
|
|
97
|
+
RunAnywhereHttpDownloadTaskInfo* info = [[RunAnywhereHttpDownloadTaskInfo alloc] init];
|
|
98
|
+
info.taskId = taskId;
|
|
99
|
+
info.destinationPath = destination;
|
|
100
|
+
info.cancelled = NO;
|
|
101
|
+
|
|
102
|
+
@synchronized (self) {
|
|
103
|
+
self.taskInfoByIdentifier[@(task.taskIdentifier)] = info;
|
|
104
|
+
self.taskById[taskId] = task;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
[task resume];
|
|
108
|
+
return RAC_SUCCESS;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
- (BOOL)cancelDownload:(NSString*)taskId {
|
|
112
|
+
if (taskId.length == 0) {
|
|
113
|
+
return NO;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
NSURLSessionDownloadTask* task = nil;
|
|
117
|
+
@synchronized (self) {
|
|
118
|
+
task = self.taskById[taskId];
|
|
119
|
+
if (task) {
|
|
120
|
+
RunAnywhereHttpDownloadTaskInfo* info = self.taskInfoByIdentifier[@(task.taskIdentifier)];
|
|
121
|
+
if (info) {
|
|
122
|
+
info.cancelled = YES;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
if (!task) {
|
|
128
|
+
return NO;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
[task cancel];
|
|
132
|
+
return YES;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
#pragma mark - NSURLSessionDownloadDelegate
|
|
136
|
+
|
|
137
|
+
- (void)URLSession:(NSURLSession*)session
|
|
138
|
+
downloadTask:(NSURLSessionDownloadTask*)downloadTask
|
|
139
|
+
didWriteData:(int64_t)bytesWritten
|
|
140
|
+
totalBytesWritten:(int64_t)totalBytesWritten
|
|
141
|
+
totalBytesExpectedToWrite:(int64_t)totalBytesExpectedToWrite {
|
|
142
|
+
(void)session;
|
|
143
|
+
RunAnywhereHttpDownloadTaskInfo* info = nil;
|
|
144
|
+
@synchronized (self) {
|
|
145
|
+
info = self.taskInfoByIdentifier[@(downloadTask.taskIdentifier)];
|
|
146
|
+
}
|
|
147
|
+
if (!info) {
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
RunAnywhereHttpDownloadReportProgress(
|
|
151
|
+
info.taskId.UTF8String,
|
|
152
|
+
totalBytesWritten,
|
|
153
|
+
totalBytesExpectedToWrite > 0 ? totalBytesExpectedToWrite : 0
|
|
154
|
+
);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
- (void)URLSession:(NSURLSession*)session
|
|
158
|
+
downloadTask:(NSURLSessionDownloadTask*)downloadTask
|
|
159
|
+
didFinishDownloadingToURL:(NSURL*)location {
|
|
160
|
+
(void)session;
|
|
161
|
+
RunAnywhereHttpDownloadTaskInfo* info = nil;
|
|
162
|
+
@synchronized (self) {
|
|
163
|
+
info = self.taskInfoByIdentifier[@(downloadTask.taskIdentifier)];
|
|
164
|
+
}
|
|
165
|
+
if (!info) {
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
NSString* destination = info.destinationPath;
|
|
170
|
+
NSString* destinationDir = [destination stringByDeletingLastPathComponent];
|
|
171
|
+
NSError* error = nil;
|
|
172
|
+
[[NSFileManager defaultManager] createDirectoryAtPath:destinationDir
|
|
173
|
+
withIntermediateDirectories:YES
|
|
174
|
+
attributes:nil
|
|
175
|
+
error:&error];
|
|
176
|
+
if (error) {
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
if ([[NSFileManager defaultManager] fileExistsAtPath:destination]) {
|
|
181
|
+
[[NSFileManager defaultManager] removeItemAtPath:destination error:nil];
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
if ([[NSFileManager defaultManager] moveItemAtURL:location
|
|
185
|
+
toURL:[NSURL fileURLWithPath:destination]
|
|
186
|
+
error:&error]) {
|
|
187
|
+
@synchronized (self) {
|
|
188
|
+
self.completedPathById[info.taskId] = destination;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
- (void)URLSession:(NSURLSession*)session
|
|
194
|
+
task:(NSURLSessionTask*)task
|
|
195
|
+
didCompleteWithError:(NSError*)error {
|
|
196
|
+
(void)session;
|
|
197
|
+
RunAnywhereHttpDownloadTaskInfo* info = nil;
|
|
198
|
+
NSString* completedPath = nil;
|
|
199
|
+
|
|
200
|
+
@synchronized (self) {
|
|
201
|
+
info = self.taskInfoByIdentifier[@(task.taskIdentifier)];
|
|
202
|
+
if (info) {
|
|
203
|
+
[self.taskInfoByIdentifier removeObjectForKey:@(task.taskIdentifier)];
|
|
204
|
+
[self.taskById removeObjectForKey:info.taskId];
|
|
205
|
+
completedPath = self.completedPathById[info.taskId];
|
|
206
|
+
if (completedPath) {
|
|
207
|
+
[self.completedPathById removeObjectForKey:info.taskId];
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
if (!info) {
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
int result = RAC_SUCCESS;
|
|
217
|
+
if (error) {
|
|
218
|
+
if (info.cancelled || error.code == NSURLErrorCancelled) {
|
|
219
|
+
result = RAC_ERROR_CANCELLED;
|
|
220
|
+
} else {
|
|
221
|
+
result = RAC_ERROR_DOWNLOAD_FAILED;
|
|
222
|
+
}
|
|
223
|
+
} else if (!completedPath) {
|
|
224
|
+
result = RAC_ERROR_DOWNLOAD_FAILED;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
const char* pathCString = completedPath ? completedPath.UTF8String : NULL;
|
|
228
|
+
RunAnywhereHttpDownloadReportComplete(info.taskId.UTF8String, result, pathCString);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
@end
|
|
232
|
+
|
|
32
233
|
// ============================================================================
|
|
33
234
|
// Secure Storage (Keychain)
|
|
34
235
|
// ============================================================================
|
|
@@ -568,3 +769,45 @@ bool PlatformAdapter_httpPostSync(
|
|
|
568
769
|
}
|
|
569
770
|
}
|
|
570
771
|
|
|
772
|
+
// ============================================================================
|
|
773
|
+
// HTTP Download (Async)
|
|
774
|
+
// ============================================================================
|
|
775
|
+
|
|
776
|
+
int PlatformAdapter_httpDownload(
|
|
777
|
+
const char* url,
|
|
778
|
+
const char* destinationPath,
|
|
779
|
+
const char* taskId
|
|
780
|
+
) {
|
|
781
|
+
@autoreleasepool {
|
|
782
|
+
if (!url || !destinationPath || !taskId) {
|
|
783
|
+
return RAC_ERROR_INVALID_PARAMETER;
|
|
784
|
+
}
|
|
785
|
+
|
|
786
|
+
NSString* urlStr = [NSString stringWithUTF8String:url];
|
|
787
|
+
NSString* destStr = [NSString stringWithUTF8String:destinationPath];
|
|
788
|
+
NSString* taskStr = [NSString stringWithUTF8String:taskId];
|
|
789
|
+
|
|
790
|
+
if (!urlStr || !destStr || !taskStr) {
|
|
791
|
+
return RAC_ERROR_INVALID_PARAMETER;
|
|
792
|
+
}
|
|
793
|
+
|
|
794
|
+
return [[RunAnywhereHttpDownloadManager shared] startDownload:urlStr
|
|
795
|
+
destination:destStr
|
|
796
|
+
taskId:taskStr];
|
|
797
|
+
}
|
|
798
|
+
}
|
|
799
|
+
|
|
800
|
+
bool PlatformAdapter_httpDownloadCancel(const char* taskId) {
|
|
801
|
+
@autoreleasepool {
|
|
802
|
+
if (!taskId) {
|
|
803
|
+
return false;
|
|
804
|
+
}
|
|
805
|
+
|
|
806
|
+
NSString* taskStr = [NSString stringWithUTF8String:taskId];
|
|
807
|
+
if (!taskStr) {
|
|
808
|
+
return false;
|
|
809
|
+
}
|
|
810
|
+
|
|
811
|
+
return [[RunAnywhereHttpDownloadManager shared] cancelDownload:taskStr];
|
|
812
|
+
}
|
|
813
|
+
}
|
|
@@ -86,6 +86,10 @@ namespace margelo::nitro::runanywhere {
|
|
|
86
86
|
prototype.registerHybridMethod("voiceAgentGenerateResponse", &HybridRunAnywhereCoreSpec::voiceAgentGenerateResponse);
|
|
87
87
|
prototype.registerHybridMethod("voiceAgentSynthesizeSpeech", &HybridRunAnywhereCoreSpec::voiceAgentSynthesizeSpeech);
|
|
88
88
|
prototype.registerHybridMethod("cleanupVoiceAgent", &HybridRunAnywhereCoreSpec::cleanupVoiceAgent);
|
|
89
|
+
prototype.registerHybridMethod("parseToolCallFromOutput", &HybridRunAnywhereCoreSpec::parseToolCallFromOutput);
|
|
90
|
+
prototype.registerHybridMethod("formatToolsForPrompt", &HybridRunAnywhereCoreSpec::formatToolsForPrompt);
|
|
91
|
+
prototype.registerHybridMethod("buildInitialPrompt", &HybridRunAnywhereCoreSpec::buildInitialPrompt);
|
|
92
|
+
prototype.registerHybridMethod("buildFollowupPrompt", &HybridRunAnywhereCoreSpec::buildFollowupPrompt);
|
|
89
93
|
});
|
|
90
94
|
}
|
|
91
95
|
|
|
@@ -125,6 +125,10 @@ namespace margelo::nitro::runanywhere {
|
|
|
125
125
|
virtual std::shared_ptr<Promise<std::string>> voiceAgentGenerateResponse(const std::string& prompt) = 0;
|
|
126
126
|
virtual std::shared_ptr<Promise<std::string>> voiceAgentSynthesizeSpeech(const std::string& text) = 0;
|
|
127
127
|
virtual std::shared_ptr<Promise<void>> cleanupVoiceAgent() = 0;
|
|
128
|
+
virtual std::shared_ptr<Promise<std::string>> parseToolCallFromOutput(const std::string& llmOutput) = 0;
|
|
129
|
+
virtual std::shared_ptr<Promise<std::string>> formatToolsForPrompt(const std::string& toolsJson, const std::string& format) = 0;
|
|
130
|
+
virtual std::shared_ptr<Promise<std::string>> buildInitialPrompt(const std::string& userPrompt, const std::string& toolsJson, const std::string& optionsJson) = 0;
|
|
131
|
+
virtual std::shared_ptr<Promise<std::string>> buildFollowupPrompt(const std::string& originalPrompt, const std::string& toolsPrompt, const std::string& toolName, const std::string& resultJson, bool keepToolsAvailable) = 0;
|
|
128
132
|
|
|
129
133
|
protected:
|
|
130
134
|
// Hybrid Setup
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@runanywhere/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.18.0",
|
|
4
4
|
"description": "Core SDK for RunAnywhere React Native - includes RACommons bindings, native bridges, and public API",
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"types": "src/index.ts",
|
|
@@ -18,7 +18,11 @@
|
|
|
18
18
|
"src",
|
|
19
19
|
"cpp",
|
|
20
20
|
"ios",
|
|
21
|
-
"
|
|
21
|
+
"!ios/build",
|
|
22
|
+
"android/src",
|
|
23
|
+
"android/build.gradle",
|
|
24
|
+
"android/CMakeLists.txt",
|
|
25
|
+
"android/consumer-rules.pro",
|
|
22
26
|
"nitrogen",
|
|
23
27
|
"nitro.json",
|
|
24
28
|
"react-native.config.js",
|
|
@@ -67,8 +71,8 @@
|
|
|
67
71
|
},
|
|
68
72
|
"devDependencies": {
|
|
69
73
|
"@types/react": "~19.1.0",
|
|
70
|
-
"nitrogen": "^0.
|
|
71
|
-
"react-native-nitro-modules": "0.
|
|
74
|
+
"nitrogen": "^0.31.10",
|
|
75
|
+
"react-native-nitro-modules": "^0.31.10",
|
|
72
76
|
"typescript": "~5.9.2"
|
|
73
77
|
},
|
|
74
78
|
"create-react-native-library": {
|
|
@@ -25,10 +25,9 @@ import type { SDKEnvironment } from '../../types';
|
|
|
25
25
|
* These methods are optional and may not be available on all platforms
|
|
26
26
|
*/
|
|
27
27
|
interface SecureStorageNativeModule {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
secureStorageDelete?: (key: string) => Promise<void>;
|
|
28
|
+
secureStorageSet?: (key: string, value: string) => Promise<boolean>;
|
|
29
|
+
secureStorageGet?: (key: string) => Promise<string | null>;
|
|
30
|
+
secureStorageDelete?: (key: string) => Promise<boolean>;
|
|
32
31
|
secureStorageExists?: (key: string) => Promise<boolean>;
|
|
33
32
|
}
|
|
34
33
|
|
|
@@ -92,6 +91,9 @@ class SecureStorageServiceImpl {
|
|
|
92
91
|
const native = requireNativeModule() as unknown as SecureStorageNativeModule;
|
|
93
92
|
|
|
94
93
|
// Use the new native method
|
|
94
|
+
if (!native.secureStorageSet) {
|
|
95
|
+
throw new Error('secureStorageSet is not available on this platform');
|
|
96
|
+
}
|
|
95
97
|
const success = await native.secureStorageSet(key, value);
|
|
96
98
|
|
|
97
99
|
if (!success) {
|
|
@@ -130,6 +132,9 @@ class SecureStorageServiceImpl {
|
|
|
130
132
|
const native = requireNativeModule() as unknown as SecureStorageNativeModule;
|
|
131
133
|
|
|
132
134
|
// Use the new native method
|
|
135
|
+
if (!native.secureStorageGet) {
|
|
136
|
+
throw new Error('secureStorageGet is not available on this platform');
|
|
137
|
+
}
|
|
133
138
|
const value = await native.secureStorageGet(key);
|
|
134
139
|
|
|
135
140
|
if (value !== null && value !== undefined) {
|
|
@@ -163,7 +168,7 @@ class SecureStorageServiceImpl {
|
|
|
163
168
|
const native = requireNativeModule() as unknown as SecureStorageNativeModule;
|
|
164
169
|
|
|
165
170
|
// Use the new native method
|
|
166
|
-
await native.secureStorageDelete(key);
|
|
171
|
+
await native.secureStorageDelete?.(key);
|
|
167
172
|
|
|
168
173
|
// Remove from cache
|
|
169
174
|
this.cache.delete(key);
|
|
@@ -199,7 +204,8 @@ class SecureStorageServiceImpl {
|
|
|
199
204
|
const native = requireNativeModule() as unknown as SecureStorageNativeModule;
|
|
200
205
|
|
|
201
206
|
// Use the new native method
|
|
202
|
-
|
|
207
|
+
const result = await native.secureStorageExists?.(key);
|
|
208
|
+
return result ?? false;
|
|
203
209
|
} catch {
|
|
204
210
|
return false;
|
|
205
211
|
}
|
|
@@ -217,9 +217,11 @@ export async function registerModel(options: {
|
|
|
217
217
|
id: options.id ?? generateModelId(options.url),
|
|
218
218
|
name: options.name,
|
|
219
219
|
category: options.category ?? ModelCategory.Language,
|
|
220
|
-
format: options.url.includes('.
|
|
221
|
-
? ModelFormat.
|
|
222
|
-
:
|
|
220
|
+
format: options.url.includes('.zip')
|
|
221
|
+
? ModelFormat.Zip
|
|
222
|
+
: options.url.includes('.gguf')
|
|
223
|
+
? ModelFormat.GGUF
|
|
224
|
+
: ModelFormat.GGUF,
|
|
223
225
|
downloadURL: options.url,
|
|
224
226
|
localPath: undefined,
|
|
225
227
|
downloadSize: undefined,
|
|
@@ -124,6 +124,9 @@ export async function transcribe(
|
|
|
124
124
|
|
|
125
125
|
try {
|
|
126
126
|
const result = JSON.parse(resultJson);
|
|
127
|
+
if (result.error) {
|
|
128
|
+
throw new Error(result.error);
|
|
129
|
+
}
|
|
127
130
|
return {
|
|
128
131
|
text: result.text ?? '',
|
|
129
132
|
segments: result.segments ?? [],
|
|
@@ -132,9 +135,11 @@ export async function transcribe(
|
|
|
132
135
|
duration: result.duration ?? 0,
|
|
133
136
|
alternatives: result.alternatives ?? [],
|
|
134
137
|
};
|
|
135
|
-
} catch {
|
|
138
|
+
} catch (err) {
|
|
139
|
+
if (err instanceof Error) throw err;
|
|
136
140
|
if (resultJson.includes('error')) {
|
|
137
|
-
|
|
141
|
+
const errorMatch = resultJson.match(/"error":\s*"([^"]+)"/);
|
|
142
|
+
throw new Error(errorMatch ? errorMatch[1] : resultJson);
|
|
138
143
|
}
|
|
139
144
|
return {
|
|
140
145
|
text: resultJson,
|