cactus-react-native 1.5.0 → 1.7.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 (216) hide show
  1. package/Cactus.podspec +1 -1
  2. package/README.md +347 -241
  3. package/android/CMakeLists.txt +24 -5
  4. package/android/src/main/jniLibs/arm64-v8a/libcactus.a +0 -0
  5. package/android/src/main/jniLibs/arm64-v8a/libcurl.a +0 -0
  6. package/android/src/main/jniLibs/arm64-v8a/libmbedcrypto.a +0 -0
  7. package/android/src/main/jniLibs/arm64-v8a/libmbedtls.a +0 -0
  8. package/android/src/main/jniLibs/arm64-v8a/libmbedx509.a +0 -0
  9. package/cpp/HybridCactus.cpp +149 -117
  10. package/cpp/HybridCactus.hpp +14 -10
  11. package/cpp/cactus_ffi.h +54 -43
  12. package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/cactus.h +0 -1
  13. package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/cactus_ffi.h +54 -43
  14. package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/cactus_utils.h +318 -123
  15. package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/engine.h +118 -15
  16. package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/graph.h +77 -32
  17. package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/kernel.h +68 -6
  18. package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/kernel_utils.h +21 -155
  19. package/ios/cactus.xcframework/ios-arm64/cactus.framework/cactus +0 -0
  20. package/ios/cactus.xcframework/ios-arm64-simulator/cactus.framework/Headers/cactus.h +0 -1
  21. package/ios/cactus.xcframework/ios-arm64-simulator/cactus.framework/Headers/cactus_ffi.h +54 -43
  22. package/ios/cactus.xcframework/ios-arm64-simulator/cactus.framework/Headers/cactus_utils.h +318 -123
  23. package/ios/cactus.xcframework/ios-arm64-simulator/cactus.framework/Headers/engine.h +118 -15
  24. package/ios/cactus.xcframework/ios-arm64-simulator/cactus.framework/Headers/graph.h +77 -32
  25. package/ios/cactus.xcframework/ios-arm64-simulator/cactus.framework/Headers/kernel.h +68 -6
  26. package/ios/cactus.xcframework/ios-arm64-simulator/cactus.framework/Headers/kernel_utils.h +21 -155
  27. package/ios/cactus.xcframework/ios-arm64-simulator/cactus.framework/cactus +0 -0
  28. package/lib/module/classes/CactusLM.js +16 -49
  29. package/lib/module/classes/CactusLM.js.map +1 -1
  30. package/lib/module/classes/CactusSTT.js +30 -79
  31. package/lib/module/classes/CactusSTT.js.map +1 -1
  32. package/lib/module/classes/CactusVAD.js +95 -0
  33. package/lib/module/classes/CactusVAD.js.map +1 -0
  34. package/lib/module/hooks/useCactusLM.js +10 -11
  35. package/lib/module/hooks/useCactusLM.js.map +1 -1
  36. package/lib/module/hooks/useCactusSTT.js +23 -62
  37. package/lib/module/hooks/useCactusSTT.js.map +1 -1
  38. package/lib/module/hooks/useCactusVAD.js +171 -0
  39. package/lib/module/hooks/useCactusVAD.js.map +1 -0
  40. package/lib/module/index.js +2 -3
  41. package/lib/module/index.js.map +1 -1
  42. package/lib/module/modelRegistry.js +52 -0
  43. package/lib/module/modelRegistry.js.map +1 -0
  44. package/lib/module/native/Cactus.js +85 -23
  45. package/lib/module/native/Cactus.js.map +1 -1
  46. package/lib/module/native/CactusIndex.js.map +1 -1
  47. package/lib/module/native/index.js +0 -3
  48. package/lib/module/native/index.js.map +1 -1
  49. package/lib/module/types/CactusVAD.js +4 -0
  50. package/lib/module/{specs/CactusUtil.nitro.js.map → types/CactusVAD.js.map} +1 -1
  51. package/lib/typescript/src/classes/CactusLM.d.ts +5 -7
  52. package/lib/typescript/src/classes/CactusLM.d.ts.map +1 -1
  53. package/lib/typescript/src/classes/CactusSTT.d.ts +8 -12
  54. package/lib/typescript/src/classes/CactusSTT.d.ts.map +1 -1
  55. package/lib/typescript/src/classes/CactusVAD.d.ts +20 -0
  56. package/lib/typescript/src/classes/CactusVAD.d.ts.map +1 -0
  57. package/lib/typescript/src/hooks/useCactusLM.d.ts +2 -2
  58. package/lib/typescript/src/hooks/useCactusLM.d.ts.map +1 -1
  59. package/lib/typescript/src/hooks/useCactusSTT.d.ts +6 -8
  60. package/lib/typescript/src/hooks/useCactusSTT.d.ts.map +1 -1
  61. package/lib/typescript/src/hooks/useCactusVAD.d.ts +15 -0
  62. package/lib/typescript/src/hooks/useCactusVAD.d.ts.map +1 -0
  63. package/lib/typescript/src/index.d.ts +7 -5
  64. package/lib/typescript/src/index.d.ts.map +1 -1
  65. package/lib/typescript/src/modelRegistry.d.ts +5 -0
  66. package/lib/typescript/src/modelRegistry.d.ts.map +1 -0
  67. package/lib/typescript/src/native/Cactus.d.ts +12 -11
  68. package/lib/typescript/src/native/Cactus.d.ts.map +1 -1
  69. package/lib/typescript/src/native/CactusIndex.d.ts +2 -2
  70. package/lib/typescript/src/native/CactusIndex.d.ts.map +1 -1
  71. package/lib/typescript/src/native/index.d.ts +0 -3
  72. package/lib/typescript/src/native/index.d.ts.map +1 -1
  73. package/lib/typescript/src/specs/Cactus.nitro.d.ts +6 -6
  74. package/lib/typescript/src/specs/Cactus.nitro.d.ts.map +1 -1
  75. package/lib/typescript/src/types/CactusIndex.d.ts +2 -2
  76. package/lib/typescript/src/types/CactusIndex.d.ts.map +1 -1
  77. package/lib/typescript/src/types/CactusLM.d.ts +19 -11
  78. package/lib/typescript/src/types/CactusLM.d.ts.map +1 -1
  79. package/lib/typescript/src/types/CactusSTT.d.ts +33 -12
  80. package/lib/typescript/src/types/CactusSTT.d.ts.map +1 -1
  81. package/lib/typescript/src/types/CactusVAD.d.ts +34 -0
  82. package/lib/typescript/src/types/CactusVAD.d.ts.map +1 -0
  83. package/lib/typescript/src/types/common.d.ts +1 -6
  84. package/lib/typescript/src/types/common.d.ts.map +1 -1
  85. package/nitro.json +0 -11
  86. package/nitrogen/generated/android/cactus+autolinking.cmake +0 -5
  87. package/nitrogen/generated/android/cactusOnLoad.cpp +0 -30
  88. package/nitrogen/generated/ios/Cactus-Swift-Cxx-Bridge.cpp +0 -50
  89. package/nitrogen/generated/ios/Cactus-Swift-Cxx-Bridge.hpp +9 -147
  90. package/nitrogen/generated/ios/Cactus-Swift-Cxx-Umbrella.hpp +0 -13
  91. package/nitrogen/generated/ios/CactusAutolinking.mm +0 -26
  92. package/nitrogen/generated/ios/CactusAutolinking.swift +0 -30
  93. package/nitrogen/generated/shared/c++/HybridCactusSpec.cpp +4 -4
  94. package/nitrogen/generated/shared/c++/HybridCactusSpec.hpp +6 -6
  95. package/package.json +3 -3
  96. package/src/classes/CactusLM.ts +18 -65
  97. package/src/classes/CactusSTT.ts +39 -97
  98. package/src/classes/CactusVAD.ts +129 -0
  99. package/src/hooks/useCactusLM.ts +14 -17
  100. package/src/hooks/useCactusSTT.ts +47 -98
  101. package/src/hooks/useCactusVAD.ts +215 -0
  102. package/src/index.tsx +18 -12
  103. package/src/modelRegistry.ts +65 -0
  104. package/src/native/Cactus.ts +102 -41
  105. package/src/native/CactusIndex.ts +2 -2
  106. package/src/native/index.ts +0 -3
  107. package/src/specs/Cactus.nitro.ts +11 -7
  108. package/src/types/CactusIndex.ts +2 -2
  109. package/src/types/CactusLM.ts +19 -11
  110. package/src/types/CactusSTT.ts +33 -13
  111. package/src/types/CactusVAD.ts +39 -0
  112. package/src/types/common.ts +1 -6
  113. package/android/src/main/java/com/margelo/nitro/cactus/HybridCactusCrypto.kt +0 -46
  114. package/android/src/main/java/com/margelo/nitro/cactus/HybridCactusDeviceInfo.kt +0 -27
  115. package/android/src/main/jniLibs/arm64-v8a/libcactus_util.a +0 -0
  116. package/cpp/HybridCactusUtil.cpp +0 -47
  117. package/cpp/HybridCactusUtil.hpp +0 -27
  118. package/cpp/cactus_util.h +0 -25
  119. package/ios/HybridCactusCrypto.swift +0 -37
  120. package/ios/HybridCactusDeviceInfo.swift +0 -32
  121. package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/cactus_telemetry.h +0 -656
  122. package/ios/cactus.xcframework/ios-arm64-simulator/cactus.framework/Headers/cactus_telemetry.h +0 -656
  123. package/ios/cactus_util.xcframework/Info.plist +0 -39
  124. package/ios/cactus_util.xcframework/ios-arm64/cactus_util.framework/Headers/cactus_util.h +0 -25
  125. package/ios/cactus_util.xcframework/ios-arm64/cactus_util.framework/Headers/database.h +0 -27
  126. package/ios/cactus_util.xcframework/ios-arm64/cactus_util.framework/Headers/ios_utils.h +0 -10
  127. package/ios/cactus_util.xcframework/ios-arm64/cactus_util.framework/Headers/logging.h +0 -25
  128. package/ios/cactus_util.xcframework/ios-arm64/cactus_util.framework/Info.plist +0 -0
  129. package/ios/cactus_util.xcframework/ios-arm64/cactus_util.framework/cactus_util +0 -0
  130. package/ios/cactus_util.xcframework/ios-arm64-simulator/cactus_util.framework/Headers/cactus_util.h +0 -25
  131. package/ios/cactus_util.xcframework/ios-arm64-simulator/cactus_util.framework/Headers/database.h +0 -27
  132. package/ios/cactus_util.xcframework/ios-arm64-simulator/cactus_util.framework/Headers/ios_utils.h +0 -10
  133. package/ios/cactus_util.xcframework/ios-arm64-simulator/cactus_util.framework/Headers/logging.h +0 -25
  134. package/ios/cactus_util.xcframework/ios-arm64-simulator/cactus_util.framework/Info.plist +0 -0
  135. package/ios/cactus_util.xcframework/ios-arm64-simulator/cactus_util.framework/_CodeSignature/CodeResources +0 -135
  136. package/ios/cactus_util.xcframework/ios-arm64-simulator/cactus_util.framework/cactus_util +0 -0
  137. package/lib/module/api/Database.js +0 -45
  138. package/lib/module/api/Database.js.map +0 -1
  139. package/lib/module/api/RemoteLM.js +0 -201
  140. package/lib/module/api/RemoteLM.js.map +0 -1
  141. package/lib/module/config/CactusConfig.js +0 -12
  142. package/lib/module/config/CactusConfig.js.map +0 -1
  143. package/lib/module/models.js +0 -336
  144. package/lib/module/models.js.map +0 -1
  145. package/lib/module/native/CactusCrypto.js +0 -10
  146. package/lib/module/native/CactusCrypto.js.map +0 -1
  147. package/lib/module/native/CactusDeviceInfo.js +0 -13
  148. package/lib/module/native/CactusDeviceInfo.js.map +0 -1
  149. package/lib/module/native/CactusUtil.js +0 -36
  150. package/lib/module/native/CactusUtil.js.map +0 -1
  151. package/lib/module/specs/CactusCrypto.nitro.js +0 -4
  152. package/lib/module/specs/CactusCrypto.nitro.js.map +0 -1
  153. package/lib/module/specs/CactusDeviceInfo.nitro.js +0 -4
  154. package/lib/module/specs/CactusDeviceInfo.nitro.js.map +0 -1
  155. package/lib/module/specs/CactusUtil.nitro.js +0 -4
  156. package/lib/module/telemetry/Telemetry.js +0 -154
  157. package/lib/module/telemetry/Telemetry.js.map +0 -1
  158. package/lib/typescript/src/api/Database.d.ts +0 -12
  159. package/lib/typescript/src/api/Database.d.ts.map +0 -1
  160. package/lib/typescript/src/api/RemoteLM.d.ts +0 -14
  161. package/lib/typescript/src/api/RemoteLM.d.ts.map +0 -1
  162. package/lib/typescript/src/config/CactusConfig.d.ts +0 -7
  163. package/lib/typescript/src/config/CactusConfig.d.ts.map +0 -1
  164. package/lib/typescript/src/models.d.ts +0 -6
  165. package/lib/typescript/src/models.d.ts.map +0 -1
  166. package/lib/typescript/src/native/CactusCrypto.d.ts +0 -5
  167. package/lib/typescript/src/native/CactusCrypto.d.ts.map +0 -1
  168. package/lib/typescript/src/native/CactusDeviceInfo.d.ts +0 -7
  169. package/lib/typescript/src/native/CactusDeviceInfo.d.ts.map +0 -1
  170. package/lib/typescript/src/native/CactusUtil.d.ts +0 -6
  171. package/lib/typescript/src/native/CactusUtil.d.ts.map +0 -1
  172. package/lib/typescript/src/specs/CactusCrypto.nitro.d.ts +0 -8
  173. package/lib/typescript/src/specs/CactusCrypto.nitro.d.ts.map +0 -1
  174. package/lib/typescript/src/specs/CactusDeviceInfo.nitro.d.ts +0 -16
  175. package/lib/typescript/src/specs/CactusDeviceInfo.nitro.d.ts.map +0 -1
  176. package/lib/typescript/src/specs/CactusUtil.nitro.d.ts +0 -10
  177. package/lib/typescript/src/specs/CactusUtil.nitro.d.ts.map +0 -1
  178. package/lib/typescript/src/telemetry/Telemetry.d.ts +0 -34
  179. package/lib/typescript/src/telemetry/Telemetry.d.ts.map +0 -1
  180. package/nitrogen/generated/android/c++/JDeviceInfo.hpp +0 -74
  181. package/nitrogen/generated/android/c++/JHybridCactusCryptoSpec.cpp +0 -65
  182. package/nitrogen/generated/android/c++/JHybridCactusCryptoSpec.hpp +0 -65
  183. package/nitrogen/generated/android/c++/JHybridCactusDeviceInfoSpec.cpp +0 -85
  184. package/nitrogen/generated/android/c++/JHybridCactusDeviceInfoSpec.hpp +0 -66
  185. package/nitrogen/generated/android/kotlin/com/margelo/nitro/cactus/DeviceInfo.kt +0 -50
  186. package/nitrogen/generated/android/kotlin/com/margelo/nitro/cactus/HybridCactusCryptoSpec.kt +0 -58
  187. package/nitrogen/generated/android/kotlin/com/margelo/nitro/cactus/HybridCactusDeviceInfoSpec.kt +0 -62
  188. package/nitrogen/generated/ios/c++/HybridCactusCryptoSpecSwift.cpp +0 -11
  189. package/nitrogen/generated/ios/c++/HybridCactusCryptoSpecSwift.hpp +0 -77
  190. package/nitrogen/generated/ios/c++/HybridCactusDeviceInfoSpecSwift.cpp +0 -11
  191. package/nitrogen/generated/ios/c++/HybridCactusDeviceInfoSpecSwift.hpp +0 -88
  192. package/nitrogen/generated/ios/swift/DeviceInfo.swift +0 -98
  193. package/nitrogen/generated/ios/swift/Func_void_DeviceInfo.swift +0 -47
  194. package/nitrogen/generated/ios/swift/Func_void_std__optional_std__string_.swift +0 -54
  195. package/nitrogen/generated/ios/swift/HybridCactusCryptoSpec.swift +0 -57
  196. package/nitrogen/generated/ios/swift/HybridCactusCryptoSpec_cxx.swift +0 -139
  197. package/nitrogen/generated/ios/swift/HybridCactusDeviceInfoSpec.swift +0 -58
  198. package/nitrogen/generated/ios/swift/HybridCactusDeviceInfoSpec_cxx.swift +0 -164
  199. package/nitrogen/generated/shared/c++/DeviceInfo.hpp +0 -92
  200. package/nitrogen/generated/shared/c++/HybridCactusCryptoSpec.cpp +0 -21
  201. package/nitrogen/generated/shared/c++/HybridCactusCryptoSpec.hpp +0 -63
  202. package/nitrogen/generated/shared/c++/HybridCactusDeviceInfoSpec.cpp +0 -22
  203. package/nitrogen/generated/shared/c++/HybridCactusDeviceInfoSpec.hpp +0 -67
  204. package/nitrogen/generated/shared/c++/HybridCactusUtilSpec.cpp +0 -23
  205. package/nitrogen/generated/shared/c++/HybridCactusUtilSpec.hpp +0 -66
  206. package/src/api/Database.ts +0 -55
  207. package/src/api/RemoteLM.ts +0 -273
  208. package/src/config/CactusConfig.ts +0 -11
  209. package/src/models.ts +0 -344
  210. package/src/native/CactusCrypto.ts +0 -11
  211. package/src/native/CactusDeviceInfo.ts +0 -18
  212. package/src/native/CactusUtil.ts +0 -43
  213. package/src/specs/CactusCrypto.nitro.ts +0 -6
  214. package/src/specs/CactusDeviceInfo.nitro.ts +0 -15
  215. package/src/specs/CactusUtil.nitro.ts +0 -8
  216. package/src/telemetry/Telemetry.ts +0 -236
@@ -1,32 +1,37 @@
1
- import { type ModelOptions } from './common';
1
+ import { type CactusModelOptions } from './common';
2
2
 
3
3
  export interface CactusLMParams {
4
4
  model?: string;
5
- contextSize?: number;
6
5
  corpusDir?: string;
7
- options?: ModelOptions;
6
+ cacheIndex?: boolean;
7
+ options?: CactusModelOptions;
8
8
  }
9
9
 
10
10
  export interface CactusLMDownloadParams {
11
11
  onProgress?: (progress: number) => void;
12
12
  }
13
13
 
14
- export interface Message {
14
+ export interface CactusLMMessage {
15
15
  role: 'user' | 'assistant' | 'system';
16
16
  content?: string;
17
17
  images?: string[];
18
18
  }
19
19
 
20
- export interface CompleteOptions {
20
+ export interface CactusLMCompleteOptions {
21
21
  temperature?: number;
22
22
  topP?: number;
23
23
  topK?: number;
24
24
  maxTokens?: number;
25
25
  stopSequences?: string[];
26
26
  forceTools?: boolean;
27
+ telemetryEnabled?: boolean;
28
+ confidenceThreshold?: number;
29
+ toolRagTopK?: number;
30
+ includeStopSequences?: boolean;
31
+ useVad?: boolean;
27
32
  }
28
33
 
29
- export interface Tool {
34
+ export interface CactusLMTool {
30
35
  name: string;
31
36
  description: string;
32
37
  parameters: {
@@ -42,11 +47,10 @@ export interface Tool {
42
47
  }
43
48
 
44
49
  export interface CactusLMCompleteParams {
45
- messages: Message[];
46
- options?: CompleteOptions;
47
- tools?: Tool[];
50
+ messages: CactusLMMessage[];
51
+ options?: CactusLMCompleteOptions;
52
+ tools?: CactusLMTool[];
48
53
  onToken?: (token: string) => void;
49
- mode?: 'local' | 'hybrid';
50
54
  }
51
55
 
52
56
  export interface CactusLMCompleteResult {
@@ -56,12 +60,16 @@ export interface CactusLMCompleteResult {
56
60
  name: string;
57
61
  arguments: { [key: string]: any };
58
62
  }[];
63
+ cloudHandoff?: boolean;
64
+ confidence?: number;
59
65
  timeToFirstTokenMs: number;
60
66
  totalTimeMs: number;
61
- tokensPerSecond: number;
62
67
  prefillTokens: number;
68
+ prefillTps: number;
63
69
  decodeTokens: number;
70
+ decodeTps: number;
64
71
  totalTokens: number;
72
+ ramUsageMb?: number;
65
73
  }
66
74
 
67
75
  export interface CactusLMTokenizeParams {
@@ -1,39 +1,47 @@
1
- import { type ModelOptions } from './common';
1
+ import { type CactusModelOptions } from './common';
2
2
 
3
3
  export interface CactusSTTParams {
4
4
  model?: string;
5
- contextSize?: number;
6
- options?: ModelOptions;
5
+ options?: CactusModelOptions;
7
6
  }
8
7
 
9
8
  export interface CactusSTTDownloadParams {
10
9
  onProgress?: (progress: number) => void;
11
10
  }
12
11
 
13
- export interface TranscribeOptions {
12
+ export interface CactusSTTTranscribeOptions {
14
13
  temperature?: number;
15
14
  topP?: number;
16
15
  topK?: number;
17
16
  maxTokens?: number;
18
17
  stopSequences?: string[];
18
+ useVad?: boolean;
19
+ telemetryEnabled?: boolean;
20
+ confidenceThreshold?: number;
21
+ cloudHandoffThreshold?: number;
22
+ includeStopSequences?: boolean;
19
23
  }
20
24
 
21
25
  export interface CactusSTTTranscribeParams {
22
26
  audio: string | number[];
23
27
  prompt?: string;
24
- options?: TranscribeOptions;
28
+ options?: CactusSTTTranscribeOptions;
25
29
  onToken?: (token: string) => void;
26
30
  }
27
31
 
28
32
  export interface CactusSTTTranscribeResult {
29
33
  success: boolean;
30
34
  response: string;
35
+ cloudHandoff?: boolean;
36
+ confidence?: number;
31
37
  timeToFirstTokenMs: number;
32
38
  totalTimeMs: number;
33
- tokensPerSecond: number;
34
39
  prefillTokens: number;
40
+ prefillTps: number;
35
41
  decodeTokens: number;
42
+ decodeTps: number;
36
43
  totalTokens: number;
44
+ ramUsageMb?: number;
37
45
  }
38
46
 
39
47
  export interface CactusSTTAudioEmbedParams {
@@ -44,25 +52,37 @@ export interface CactusSTTAudioEmbedResult {
44
52
  embedding: number[];
45
53
  }
46
54
 
47
- export interface CactusSTTStreamTranscribeInsertParams {
48
- audio: number[];
49
- }
50
-
51
- export interface StreamTranscribeProcessOptions {
55
+ export interface CactusSTTStreamTranscribeStartOptions {
52
56
  confirmationThreshold?: number;
57
+ minChunkSize?: number;
58
+ telemetryEnabled?: boolean;
53
59
  }
54
60
 
55
61
  export interface CactusSTTStreamTranscribeProcessParams {
56
- options?: StreamTranscribeProcessOptions;
62
+ audio: number[];
57
63
  }
58
64
 
59
65
  export interface CactusSTTStreamTranscribeProcessResult {
60
66
  success: boolean;
61
67
  confirmed: string;
62
68
  pending: string;
69
+ bufferDurationMs?: number;
70
+ confidence?: number;
71
+ cloudHandoff?: boolean;
72
+ cloudResult?: string;
73
+ cloudJobId?: number;
74
+ cloudResultJobId?: number;
75
+ timeToFirstTokenMs?: number;
76
+ totalTimeMs?: number;
77
+ prefillTokens?: number;
78
+ prefillTps?: number;
79
+ decodeTokens?: number;
80
+ decodeTps?: number;
81
+ totalTokens?: number;
82
+ ramUsageMb?: number;
63
83
  }
64
84
 
65
- export interface CactusSTTStreamTranscribeFinalizeResult {
85
+ export interface CactusSTTStreamTranscribeStopResult {
66
86
  success: boolean;
67
87
  confirmed: string;
68
88
  }
@@ -0,0 +1,39 @@
1
+ import type { CactusModelOptions } from './common';
2
+
3
+ export interface CactusVADParams {
4
+ model?: string;
5
+ options?: CactusModelOptions;
6
+ }
7
+
8
+ export interface CactusVADDownloadParams {
9
+ onProgress?: (progress: number) => void;
10
+ }
11
+
12
+ export interface CactusVADOptions {
13
+ threshold?: number;
14
+ negThreshold?: number;
15
+ minSpeechDurationMs?: number;
16
+ maxSpeechDurationS?: number;
17
+ minSilenceDurationMs?: number;
18
+ speechPadMs?: number;
19
+ windowSizeSamples?: number;
20
+ samplingRate?: number;
21
+ minSilenceAtMaxSpeech?: number;
22
+ useMaxPossSilAtMaxSpeech?: boolean;
23
+ }
24
+
25
+ export interface CactusVADSegment {
26
+ start: number;
27
+ end: number;
28
+ }
29
+
30
+ export interface CactusVADResult {
31
+ segments: CactusVADSegment[];
32
+ totalTime: number;
33
+ ramUsage: number;
34
+ }
35
+
36
+ export interface CactusVADVadParams {
37
+ audio: string | number[];
38
+ options?: CactusVADOptions;
39
+ }
@@ -1,9 +1,4 @@
1
1
  export interface CactusModel {
2
- completion: boolean;
3
- tools: boolean;
4
- vision: boolean;
5
- embed: boolean;
6
- speech: boolean;
7
2
  quantization: {
8
3
  int4: {
9
4
  sizeMb: number;
@@ -22,7 +17,7 @@ export interface CactusModel {
22
17
  };
23
18
  }
24
19
 
25
- export interface ModelOptions {
20
+ export interface CactusModelOptions {
26
21
  quantization?: 'int4' | 'int8';
27
22
  pro?: boolean;
28
23
  }
@@ -1,46 +0,0 @@
1
- package com.margelo.nitro.cactus
2
-
3
- import com.margelo.nitro.core.Promise
4
- import java.nio.ByteBuffer
5
- import java.security.MessageDigest
6
- import java.util.Locale
7
- import java.util.UUID
8
-
9
- class HybridCactusCrypto : HybridCactusCryptoSpec() {
10
- override fun uuidv5(
11
- namespaceUuid: String,
12
- name: String,
13
- ): Promise<String> =
14
- Promise.async {
15
- val nsUuid =
16
- try {
17
- UUID.fromString(namespaceUuid)
18
- } catch (e: IllegalArgumentException) {
19
- throw IllegalArgumentException("Invalid namespace UUID")
20
- }
21
-
22
- val nsBytes =
23
- ByteBuffer
24
- .allocate(16)
25
- .apply {
26
- putLong(nsUuid.mostSignificantBits)
27
- putLong(nsUuid.leastSignificantBits)
28
- }.array()
29
- val nameBytes = name.toByteArray(Charsets.UTF_8)
30
-
31
- val sha1 =
32
- MessageDigest
33
- .getInstance("SHA-1")
34
- .apply { update(nsBytes) }
35
- .digest(nameBytes)
36
- val uuidBytes = sha1.copyOfRange(0, 16)
37
- uuidBytes[6] = (uuidBytes[6].toInt() and 0x0F or 0x50).toByte()
38
- uuidBytes[8] = (uuidBytes[8].toInt() and 0x3F or 0x80).toByte()
39
-
40
- val bb = ByteBuffer.wrap(uuidBytes)
41
-
42
- val uuid = UUID(bb.long, bb.long)
43
-
44
- uuid.toString().lowercase(Locale.ROOT)
45
- }
46
- }
@@ -1,27 +0,0 @@
1
- package com.margelo.nitro.cactus
2
-
3
- import android.os.Build
4
- import android.provider.Settings
5
- import com.margelo.nitro.NitroModules
6
- import com.margelo.nitro.core.Promise
7
-
8
- class HybridCactusDeviceInfo : HybridCactusDeviceInfoSpec() {
9
- private val context = NitroModules.applicationContext ?: error("Android context not found")
10
-
11
- override fun getAppIdentifier(): Promise<String?> = Promise.async { context.packageName }
12
-
13
- override fun getDeviceInfo(): Promise<DeviceInfo> =
14
- Promise.async {
15
- DeviceInfo(
16
- brand = Build.MANUFACTURER,
17
- model = Build.MODEL,
18
- device_id =
19
- Settings.Secure.getString(
20
- context.contentResolver,
21
- Settings.Secure.ANDROID_ID,
22
- ),
23
- os = "Android",
24
- os_version = Build.VERSION.RELEASE,
25
- )
26
- }
27
- }
@@ -1,47 +0,0 @@
1
- #include "HybridCactusUtil.hpp"
2
-
3
- namespace margelo::nitro::cactus {
4
-
5
- HybridCactusUtil::HybridCactusUtil() : HybridObject(TAG) {}
6
-
7
- std::shared_ptr<Promise<std::string>>
8
- HybridCactusUtil::registerApp(const std::string &encryptedData) {
9
- return Promise<std::string>::async([this, encryptedData]() -> std::string {
10
- std::lock_guard<std::mutex> lock(this->_mutex);
11
-
12
- const char *raw = register_app(encryptedData.c_str());
13
-
14
- if (raw == nullptr) {
15
- throw std::runtime_error("Failed to register app");
16
- }
17
-
18
- std::string registerAppStr(raw);
19
- free_string(raw);
20
-
21
- return registerAppStr;
22
- });
23
- }
24
-
25
- std::shared_ptr<Promise<std::optional<std::string>>>
26
- HybridCactusUtil::getDeviceId(const std::optional<std::string> &token) {
27
- return Promise<std::optional<std::string>>::async(
28
- [this, token]() -> std::optional<std::string> {
29
- std::lock_guard<std::mutex> lock(this->_mutex);
30
-
31
- const char *deviceId = get_device_id(token ? token->c_str() : nullptr);
32
- return deviceId ? std::optional<std::string>(deviceId) : std::nullopt;
33
- });
34
- }
35
-
36
- std::shared_ptr<Promise<void>>
37
- HybridCactusUtil::setAndroidDataDirectory(const std::string &dataDir) {
38
- return Promise<void>::async([this, dataDir]() -> void {
39
- std::lock_guard<std::mutex> lock(this->_mutex);
40
-
41
- #ifdef __ANDROID__
42
- set_android_data_directory(dataDir.c_str());
43
- #endif
44
- });
45
- }
46
-
47
- } // namespace margelo::nitro::cactus
@@ -1,27 +0,0 @@
1
- #pragma once
2
- #include "HybridCactusUtilSpec.hpp"
3
-
4
- #include "cactus_util.h"
5
-
6
- #include <mutex>
7
-
8
- namespace margelo::nitro::cactus {
9
-
10
- class HybridCactusUtil : public HybridCactusUtilSpec {
11
- public:
12
- HybridCactusUtil();
13
-
14
- std::shared_ptr<Promise<std::string>>
15
- registerApp(const std::string &encryptedData) override;
16
-
17
- std::shared_ptr<Promise<std::optional<std::string>>>
18
- getDeviceId(const std::optional<std::string> &token) override;
19
-
20
- std::shared_ptr<Promise<void>>
21
- setAndroidDataDirectory(const std::string &dataDir) override;
22
-
23
- private:
24
- std::mutex _mutex;
25
- };
26
-
27
- } // namespace margelo::nitro::cactus
package/cpp/cactus_util.h DELETED
@@ -1,25 +0,0 @@
1
- #ifndef cactus_util_H
2
- #define cactus_util_H
3
-
4
- #ifdef __cplusplus
5
- extern "C" {
6
- #endif
7
-
8
- const char* register_app(const char* encrypted_data);
9
-
10
- const char* get_device_id(const char* current_token);
11
-
12
- // Helper function to free memory allocated by register_app
13
- void free_string(const char* str);
14
-
15
- #ifdef __ANDROID__
16
- // Function to set the Android app data directory
17
- // This should be called from Flutter/Java side before any other functions
18
- void set_android_data_directory(const char* data_dir);
19
- #endif
20
-
21
- #ifdef __cplusplus
22
- }
23
- #endif
24
-
25
- #endif
@@ -1,37 +0,0 @@
1
- import CryptoKit
2
- import NitroModules
3
-
4
- class HybridCactusCrypto: HybridCactusCryptoSpec {
5
- func uuidv5(namespaceUuid: String, name: String) throws -> Promise<String> {
6
- return Promise.async {
7
- guard let ns = UUID(uuidString: namespaceUuid) else {
8
- throw RuntimeError.error(withMessage: "Invalid namespace UUID")
9
- }
10
-
11
- var nsBytes = ns.uuid
12
- var data = withUnsafeBytes(of: &nsBytes) { Data($0) }
13
- data.append(Data(name.utf8))
14
-
15
- let digest = Insecure.SHA1.hash(data: data)
16
- var bytes = Data(digest.prefix(16))
17
- bytes.withUnsafeMutableBytes { raw in
18
- let b = raw.bindMemory(to: UInt8.self)
19
- b[6] = (b[6] & 0x0F) | 0x50
20
- b[8] = (b[8] & 0x3F) | 0x80
21
- }
22
-
23
- let tuple = bytes.withUnsafeBytes { ptr -> uuid_t in
24
- let b = ptr.bindMemory(to: UInt8.self)
25
- return uuid_t(
26
- b[0], b[1], b[2], b[3],
27
- b[4], b[5], b[6], b[7],
28
- b[8], b[9], b[10], b[11],
29
- b[12], b[13], b[14], b[15])
30
- }
31
-
32
- let uuid = UUID(uuid: tuple)
33
-
34
- return uuid.uuidString.lowercased()
35
- }
36
- }
37
- }
@@ -1,32 +0,0 @@
1
- import NitroModules
2
- import UIKit
3
-
4
- class HybridCactusDeviceInfo: HybridCactusDeviceInfoSpec {
5
- func getAppIdentifier() throws -> Promise<String?> {
6
- return Promise.async { Bundle.main.bundleIdentifier }
7
- }
8
-
9
- func getDeviceInfo() throws -> Promise<DeviceInfo> {
10
- return Promise.async {
11
- let device = await MainActor.run { UIDevice.current }
12
- return await DeviceInfo(
13
- brand: "Apple",
14
- model: self.deviceModelIdentifier(),
15
- device_id: device.identifierForVendor?.uuidString,
16
- os: device.systemName,
17
- os_version: device.systemVersion
18
- )
19
- }
20
- }
21
-
22
- private func deviceModelIdentifier() -> String {
23
- var systemInfo = utsname()
24
- uname(&systemInfo)
25
- let machineMirror = Mirror(reflecting: systemInfo.machine)
26
- let identifier = machineMirror.children.reduce("") { identifier, element in
27
- guard let value = element.value as? Int8, value != 0 else { return identifier }
28
- return identifier + String(UnicodeScalar(UInt8(value)))
29
- }
30
- return identifier
31
- }
32
- }