@trymirai/uzu 0.1.21 → 0.1.23

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 (358) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +103 -136
  3. package/bridging/classificationFeature.d.mts +9 -0
  4. package/bridging/classificationFeature.d.mts.map +1 -0
  5. package/bridging/classificationFeature.d.ts +9 -0
  6. package/bridging/classificationFeature.d.ts.map +1 -0
  7. package/bridging/classificationFeature.js +18 -0
  8. package/bridging/classificationFeature.js.map +1 -0
  9. package/bridging/classificationFeature.mjs +14 -0
  10. package/bridging/classificationFeature.mjs.map +1 -0
  11. package/bridging/config.d.mts +20 -0
  12. package/bridging/config.d.mts.map +1 -0
  13. package/bridging/config.d.ts +20 -0
  14. package/bridging/config.d.ts.map +1 -0
  15. package/bridging/config.js +41 -0
  16. package/bridging/config.js.map +1 -0
  17. package/bridging/config.mjs +37 -0
  18. package/bridging/config.mjs.map +1 -0
  19. package/bridging/contextLength.d.mts +11 -0
  20. package/bridging/contextLength.d.mts.map +1 -0
  21. package/bridging/contextLength.d.ts +11 -0
  22. package/bridging/contextLength.d.ts.map +1 -0
  23. package/bridging/contextLength.js +25 -0
  24. package/bridging/contextLength.js.map +1 -0
  25. package/bridging/contextLength.mjs +21 -0
  26. package/bridging/contextLength.mjs.map +1 -0
  27. package/bridging/downloadHandle.d.mts +14 -0
  28. package/bridging/downloadHandle.d.mts.map +1 -0
  29. package/bridging/downloadHandle.d.ts +14 -0
  30. package/bridging/downloadHandle.d.ts.map +1 -0
  31. package/bridging/downloadHandle.js +36 -0
  32. package/bridging/downloadHandle.js.map +1 -0
  33. package/bridging/downloadHandle.mjs +32 -0
  34. package/bridging/downloadHandle.mjs.map +1 -0
  35. package/bridging/downloadProgressUpdate.d.mts +9 -0
  36. package/bridging/downloadProgressUpdate.d.mts.map +1 -0
  37. package/bridging/downloadProgressUpdate.d.ts +9 -0
  38. package/bridging/downloadProgressUpdate.d.ts.map +1 -0
  39. package/bridging/downloadProgressUpdate.js +15 -0
  40. package/bridging/downloadProgressUpdate.js.map +1 -0
  41. package/bridging/downloadProgressUpdate.mjs +11 -0
  42. package/bridging/downloadProgressUpdate.mjs.map +1 -0
  43. package/bridging/downloadState.d.mts +18 -0
  44. package/bridging/downloadState.d.mts.map +1 -0
  45. package/bridging/downloadState.d.ts +18 -0
  46. package/bridging/downloadState.d.ts.map +1 -0
  47. package/bridging/downloadState.js +42 -0
  48. package/bridging/downloadState.js.map +1 -0
  49. package/bridging/downloadState.mjs +38 -0
  50. package/bridging/downloadState.mjs.map +1 -0
  51. package/bridging/engine.d.mts +17 -0
  52. package/bridging/engine.d.mts.map +1 -0
  53. package/bridging/engine.d.ts +17 -0
  54. package/bridging/engine.d.ts.map +1 -0
  55. package/bridging/engine.js +84 -0
  56. package/bridging/engine.js.map +1 -0
  57. package/bridging/engine.mjs +80 -0
  58. package/bridging/engine.mjs.map +1 -0
  59. package/bridging/finishReason.d.mts +7 -0
  60. package/bridging/finishReason.d.mts.map +1 -0
  61. package/bridging/finishReason.d.ts +7 -0
  62. package/bridging/finishReason.d.ts.map +1 -0
  63. package/bridging/finishReason.js +11 -0
  64. package/bridging/finishReason.js.map +1 -0
  65. package/bridging/finishReason.mjs +8 -0
  66. package/bridging/finishReason.mjs.map +1 -0
  67. package/bridging/input.d.mts +11 -0
  68. package/bridging/input.d.mts.map +1 -0
  69. package/bridging/input.d.ts +11 -0
  70. package/bridging/input.d.ts.map +1 -0
  71. package/bridging/input.js +25 -0
  72. package/bridging/input.js.map +1 -0
  73. package/bridging/input.mjs +21 -0
  74. package/bridging/input.mjs.map +1 -0
  75. package/bridging/licenseStatus.d.mts +14 -0
  76. package/bridging/licenseStatus.d.mts.map +1 -0
  77. package/bridging/licenseStatus.d.ts +14 -0
  78. package/bridging/licenseStatus.d.ts.map +1 -0
  79. package/bridging/licenseStatus.js +42 -0
  80. package/bridging/licenseStatus.js.map +1 -0
  81. package/bridging/licenseStatus.mjs +38 -0
  82. package/bridging/licenseStatus.mjs.map +1 -0
  83. package/bridging/message.d.mts +15 -0
  84. package/bridging/message.d.mts.map +1 -0
  85. package/bridging/message.d.ts +15 -0
  86. package/bridging/message.d.ts.map +1 -0
  87. package/bridging/message.js +43 -0
  88. package/bridging/message.js.map +1 -0
  89. package/bridging/message.mjs +39 -0
  90. package/bridging/message.mjs.map +1 -0
  91. package/bridging/model.d.mts +18 -0
  92. package/bridging/model.d.mts.map +1 -0
  93. package/bridging/model.d.ts +18 -0
  94. package/bridging/model.d.ts.map +1 -0
  95. package/bridging/model.js +28 -0
  96. package/bridging/model.js.map +1 -0
  97. package/bridging/model.mjs +24 -0
  98. package/bridging/model.mjs.map +1 -0
  99. package/bridging/napi.d.mts +4 -0
  100. package/bridging/napi.d.mts.map +1 -0
  101. package/bridging/napi.d.ts +4 -0
  102. package/bridging/napi.d.ts.map +1 -0
  103. package/bridging/napi.js +3 -0
  104. package/bridging/napi.js.map +1 -0
  105. package/bridging/napi.mjs +2 -0
  106. package/bridging/napi.mjs.map +1 -0
  107. package/bridging/output.d.mts +13 -0
  108. package/bridging/output.d.mts.map +1 -0
  109. package/bridging/output.d.ts +13 -0
  110. package/bridging/output.d.ts.map +1 -0
  111. package/bridging/output.js +36 -0
  112. package/bridging/output.js.map +1 -0
  113. package/bridging/output.mjs +32 -0
  114. package/bridging/output.mjs.map +1 -0
  115. package/bridging/parsedText.d.mts +8 -0
  116. package/bridging/parsedText.d.mts.map +1 -0
  117. package/bridging/parsedText.d.ts +8 -0
  118. package/bridging/parsedText.d.ts.map +1 -0
  119. package/bridging/parsedText.js +16 -0
  120. package/bridging/parsedText.js.map +1 -0
  121. package/bridging/parsedText.mjs +12 -0
  122. package/bridging/parsedText.mjs.map +1 -0
  123. package/bridging/prefillStepSize.d.mts +11 -0
  124. package/bridging/prefillStepSize.d.mts.map +1 -0
  125. package/bridging/prefillStepSize.d.ts +11 -0
  126. package/bridging/prefillStepSize.d.ts.map +1 -0
  127. package/bridging/prefillStepSize.js +28 -0
  128. package/bridging/prefillStepSize.js.map +1 -0
  129. package/bridging/prefillStepSize.mjs +24 -0
  130. package/bridging/prefillStepSize.mjs.map +1 -0
  131. package/bridging/preset.d.mts +12 -0
  132. package/bridging/preset.d.mts.map +1 -0
  133. package/bridging/preset.d.ts +12 -0
  134. package/bridging/preset.d.ts.map +1 -0
  135. package/bridging/preset.js +29 -0
  136. package/bridging/preset.js.map +1 -0
  137. package/bridging/preset.mjs +25 -0
  138. package/bridging/preset.mjs.map +1 -0
  139. package/bridging/role.d.mts +6 -0
  140. package/bridging/role.d.mts.map +1 -0
  141. package/bridging/role.d.ts +6 -0
  142. package/bridging/role.d.ts.map +1 -0
  143. package/bridging/role.js +10 -0
  144. package/bridging/role.js.map +1 -0
  145. package/bridging/role.mjs +7 -0
  146. package/bridging/role.mjs.map +1 -0
  147. package/bridging/runConfig.d.mts +15 -0
  148. package/bridging/runConfig.d.mts.map +1 -0
  149. package/bridging/runConfig.d.ts +15 -0
  150. package/bridging/runConfig.d.ts.map +1 -0
  151. package/bridging/runConfig.js +34 -0
  152. package/bridging/runConfig.js.map +1 -0
  153. package/bridging/runConfig.mjs +30 -0
  154. package/bridging/runConfig.mjs.map +1 -0
  155. package/bridging/runStats.d.mts +8 -0
  156. package/bridging/runStats.d.mts.map +1 -0
  157. package/bridging/runStats.d.ts +8 -0
  158. package/bridging/runStats.d.ts.map +1 -0
  159. package/bridging/runStats.js +16 -0
  160. package/bridging/runStats.js.map +1 -0
  161. package/bridging/runStats.mjs +12 -0
  162. package/bridging/runStats.mjs.map +1 -0
  163. package/bridging/samplingMethod.d.mts +11 -0
  164. package/bridging/samplingMethod.d.mts.map +1 -0
  165. package/bridging/samplingMethod.d.ts +11 -0
  166. package/bridging/samplingMethod.d.ts.map +1 -0
  167. package/bridging/samplingMethod.js +28 -0
  168. package/bridging/samplingMethod.js.map +1 -0
  169. package/bridging/samplingMethod.mjs +24 -0
  170. package/bridging/samplingMethod.mjs.map +1 -0
  171. package/bridging/samplingPolicy.d.mts +11 -0
  172. package/bridging/samplingPolicy.d.mts.map +1 -0
  173. package/bridging/samplingPolicy.d.ts +11 -0
  174. package/bridging/samplingPolicy.d.ts.map +1 -0
  175. package/bridging/samplingPolicy.js +25 -0
  176. package/bridging/samplingPolicy.js.map +1 -0
  177. package/bridging/samplingPolicy.mjs +21 -0
  178. package/bridging/samplingPolicy.mjs.map +1 -0
  179. package/bridging/samplingSeed.d.mts +10 -0
  180. package/bridging/samplingSeed.d.mts.map +1 -0
  181. package/bridging/samplingSeed.d.ts +10 -0
  182. package/bridging/samplingSeed.d.ts.map +1 -0
  183. package/bridging/samplingSeed.js +21 -0
  184. package/bridging/samplingSeed.js.map +1 -0
  185. package/bridging/samplingSeed.mjs +17 -0
  186. package/bridging/samplingSeed.mjs.map +1 -0
  187. package/bridging/session.d.mts +10 -0
  188. package/bridging/session.d.mts.map +1 -0
  189. package/bridging/session.d.ts +10 -0
  190. package/bridging/session.d.ts.map +1 -0
  191. package/bridging/session.js +19 -0
  192. package/bridging/session.js.map +1 -0
  193. package/bridging/session.mjs +15 -0
  194. package/bridging/session.mjs.map +1 -0
  195. package/bridging/stats.d.mts +11 -0
  196. package/bridging/stats.d.mts.map +1 -0
  197. package/bridging/stats.d.ts +11 -0
  198. package/bridging/stats.d.ts.map +1 -0
  199. package/bridging/stats.js +20 -0
  200. package/bridging/stats.js.map +1 -0
  201. package/bridging/stats.mjs +16 -0
  202. package/bridging/stats.mjs.map +1 -0
  203. package/bridging/stepStats.d.mts +13 -0
  204. package/bridging/stepStats.d.mts.map +1 -0
  205. package/bridging/stepStats.d.ts +13 -0
  206. package/bridging/stepStats.d.ts.map +1 -0
  207. package/bridging/stepStats.js +25 -0
  208. package/bridging/stepStats.js.map +1 -0
  209. package/bridging/stepStats.mjs +21 -0
  210. package/bridging/stepStats.mjs.map +1 -0
  211. package/bridging/text.d.mts +9 -0
  212. package/bridging/text.d.mts.map +1 -0
  213. package/bridging/text.d.ts +9 -0
  214. package/bridging/text.d.ts.map +1 -0
  215. package/bridging/text.js +17 -0
  216. package/bridging/text.js.map +1 -0
  217. package/bridging/text.mjs +13 -0
  218. package/bridging/text.mjs.map +1 -0
  219. package/bridging/totalStats.d.mts +9 -0
  220. package/bridging/totalStats.d.mts.map +1 -0
  221. package/bridging/totalStats.d.ts +9 -0
  222. package/bridging/totalStats.d.ts.map +1 -0
  223. package/bridging/totalStats.js +18 -0
  224. package/bridging/totalStats.js.map +1 -0
  225. package/bridging/totalStats.mjs +14 -0
  226. package/bridging/totalStats.mjs.map +1 -0
  227. package/error.d.mts +16 -0
  228. package/error.d.mts.map +1 -0
  229. package/error.d.ts +16 -0
  230. package/error.d.ts.map +1 -0
  231. package/error.js +42 -0
  232. package/error.js.map +1 -0
  233. package/error.mjs +37 -0
  234. package/error.mjs.map +1 -0
  235. package/index.d.mts +33 -0
  236. package/index.d.mts.map +1 -0
  237. package/index.d.ts +33 -0
  238. package/index.d.ts.map +1 -0
  239. package/index.js +74 -0
  240. package/index.js.map +1 -0
  241. package/index.mjs +33 -0
  242. package/index.mjs.map +1 -0
  243. package/interactors/downloadInteractor.d.mts +16 -0
  244. package/interactors/downloadInteractor.d.mts.map +1 -0
  245. package/interactors/downloadInteractor.d.ts +16 -0
  246. package/interactors/downloadInteractor.d.ts.map +1 -0
  247. package/interactors/downloadInteractor.js +38 -0
  248. package/interactors/downloadInteractor.js.map +1 -0
  249. package/interactors/downloadInteractor.mjs +34 -0
  250. package/interactors/downloadInteractor.mjs.map +1 -0
  251. package/interactors/engineInteractor.d.mts +17 -0
  252. package/interactors/engineInteractor.d.mts.map +1 -0
  253. package/interactors/engineInteractor.d.ts +17 -0
  254. package/interactors/engineInteractor.d.ts.map +1 -0
  255. package/interactors/engineInteractor.js +34 -0
  256. package/interactors/engineInteractor.js.map +1 -0
  257. package/interactors/engineInteractor.mjs +30 -0
  258. package/interactors/engineInteractor.mjs.map +1 -0
  259. package/interactors/interactor.d.mts +6 -0
  260. package/interactors/interactor.d.mts.map +1 -0
  261. package/interactors/interactor.d.ts +6 -0
  262. package/interactors/interactor.d.ts.map +1 -0
  263. package/interactors/interactor.js +3 -0
  264. package/interactors/interactor.js.map +1 -0
  265. package/interactors/interactor.mjs +2 -0
  266. package/interactors/interactor.mjs.map +1 -0
  267. package/interactors/modelInteractor.d.mts +30 -0
  268. package/interactors/modelInteractor.d.mts.map +1 -0
  269. package/interactors/modelInteractor.d.ts +30 -0
  270. package/interactors/modelInteractor.d.ts.map +1 -0
  271. package/interactors/modelInteractor.js +85 -0
  272. package/interactors/modelInteractor.js.map +1 -0
  273. package/interactors/modelInteractor.mjs +81 -0
  274. package/interactors/modelInteractor.mjs.map +1 -0
  275. package/interactors/modelsInteractor.d.mts +12 -0
  276. package/interactors/modelsInteractor.d.mts.map +1 -0
  277. package/interactors/modelsInteractor.d.ts +12 -0
  278. package/interactors/modelsInteractor.d.ts.map +1 -0
  279. package/interactors/modelsInteractor.js +25 -0
  280. package/interactors/modelsInteractor.js.map +1 -0
  281. package/interactors/modelsInteractor.mjs +21 -0
  282. package/interactors/modelsInteractor.mjs.map +1 -0
  283. package/interactors/sessionInteractor.d.mts +24 -0
  284. package/interactors/sessionInteractor.d.mts.map +1 -0
  285. package/interactors/sessionInteractor.d.ts +24 -0
  286. package/interactors/sessionInteractor.d.ts.map +1 -0
  287. package/interactors/sessionInteractor.js +50 -0
  288. package/interactors/sessionInteractor.js.map +1 -0
  289. package/interactors/sessionInteractor.mjs +46 -0
  290. package/interactors/sessionInteractor.mjs.map +1 -0
  291. package/internal/tslib.js +2 -0
  292. package/internal/tslib.mjs +1 -0
  293. package/{uzu.d.ts → napi/uzu.d.ts} +38 -37
  294. package/napi/uzu.js +95 -0
  295. package/napi/uzu.mjs +61 -0
  296. package/{uzu.node → napi/uzu.node} +0 -0
  297. package/package.json +96 -35
  298. package/src/bridging/classificationFeature.ts +20 -0
  299. package/src/bridging/config.ts +60 -0
  300. package/src/bridging/contextLength.ts +29 -0
  301. package/src/bridging/downloadHandle.ts +41 -0
  302. package/src/bridging/downloadProgressUpdate.ts +21 -0
  303. package/src/bridging/downloadState.ts +59 -0
  304. package/src/bridging/engine.ts +97 -0
  305. package/src/bridging/finishReason.ts +6 -0
  306. package/src/bridging/input.ts +29 -0
  307. package/src/bridging/licenseStatus.ts +39 -0
  308. package/src/bridging/message.ts +50 -0
  309. package/src/bridging/model.ts +32 -0
  310. package/src/bridging/napi.ts +3 -0
  311. package/src/bridging/output.ts +40 -0
  312. package/src/bridging/parsedText.ts +17 -0
  313. package/src/bridging/prefillStepSize.ts +32 -0
  314. package/src/bridging/preset.ts +34 -0
  315. package/src/bridging/role.ts +5 -0
  316. package/src/bridging/runConfig.ts +41 -0
  317. package/src/bridging/runStats.ts +17 -0
  318. package/src/bridging/samplingMethod.ts +32 -0
  319. package/src/bridging/samplingPolicy.ts +29 -0
  320. package/src/bridging/samplingSeed.ts +24 -0
  321. package/src/bridging/session.ts +24 -0
  322. package/src/bridging/stats.ts +22 -0
  323. package/src/bridging/stepStats.ts +37 -0
  324. package/src/bridging/text.ts +18 -0
  325. package/src/bridging/totalStats.ts +20 -0
  326. package/src/error.ts +38 -0
  327. package/src/index.ts +32 -0
  328. package/src/interactors/downloadInteractor.ts +47 -0
  329. package/src/interactors/engineInteractor.ts +48 -0
  330. package/src/interactors/interactor.ts +7 -0
  331. package/src/interactors/modelInteractor.ts +113 -0
  332. package/src/interactors/modelsInteractor.ts +29 -0
  333. package/src/interactors/sessionInteractor.ts +70 -0
  334. package/src/napi/uzu.d.ts +230 -0
  335. package/src/napi/uzu.js +95 -0
  336. package/src/napi/uzu.mjs +61 -0
  337. package/src/napi/uzu.node +0 -0
  338. package/src/tsconfig.json +11 -0
  339. package/src/utilities/env.ts +9 -0
  340. package/src/version.ts +1 -0
  341. package/utilities/env.d.mts +2 -0
  342. package/utilities/env.d.mts.map +1 -0
  343. package/utilities/env.d.ts +2 -0
  344. package/utilities/env.d.ts.map +1 -0
  345. package/utilities/env.js +14 -0
  346. package/utilities/env.js.map +1 -0
  347. package/utilities/env.mjs +10 -0
  348. package/utilities/env.mjs.map +1 -0
  349. package/version.d.mts +2 -0
  350. package/version.d.mts.map +1 -0
  351. package/version.d.ts +2 -0
  352. package/version.d.ts.map +1 -0
  353. package/version.js +5 -0
  354. package/version.js.map +1 -0
  355. package/version.mjs +2 -0
  356. package/version.mjs.map +1 -0
  357. package/README.orig.md +0 -213
  358. package/README.src.md +0 -124
package/napi/uzu.js ADDED
@@ -0,0 +1,95 @@
1
+ // Auto-generated NAPI wrapper for uzu native module
2
+ // Currently supports only Apple Silicon (arm64) on macOS
3
+ // Other platforms may be added in future releases
4
+
5
+ const { createRequire } = require('module');
6
+
7
+ const require_ = createRequire(__filename);
8
+
9
+ // Check for Apple Silicon support only
10
+ if (process.platform !== 'darwin' || process.arch !== 'arm64') {
11
+ throw new Error(`This package only supports Apple Silicon (arm64) on macOS. Current platform: ${process.platform}-${process.arch}`);
12
+ }
13
+
14
+ let nativeBinding = null;
15
+
16
+ try {
17
+ nativeBinding = require_('./uzu.node');
18
+ } catch (e) {
19
+ throw new Error(`Failed to load native binding: ${e.message}`);
20
+ }
21
+
22
+ // Re-export all runtime exports
23
+ const {
24
+ Engine,
25
+ ModelDownloadHandle,
26
+ ProgressStream,
27
+ ProgressUpdate,
28
+ Session,
29
+ FinishReason,
30
+ ModelDownloadPhase,
31
+ Role,
32
+ version,
33
+ ClassificationFeature,
34
+ CloudModel,
35
+ Config,
36
+ LocalModel,
37
+ Message,
38
+ ModelDownloadState,
39
+ Output,
40
+ ParsedText,
41
+ RunConfig,
42
+ RunStats,
43
+ Stats,
44
+ StepStats,
45
+ Text,
46
+ TotalStats,
47
+ ContextLength,
48
+ Input,
49
+ LicenseStatus,
50
+ ModelID,
51
+ ModelStorageError,
52
+ PrefillStepSize,
53
+ Preset,
54
+ SamplingMethod,
55
+ SamplingPolicy,
56
+ SamplingSeed,
57
+ StorageError
58
+ } = nativeBinding;
59
+
60
+ module.exports = {
61
+ Engine,
62
+ ModelDownloadHandle,
63
+ ProgressStream,
64
+ ProgressUpdate,
65
+ Session,
66
+ FinishReason,
67
+ ModelDownloadPhase,
68
+ Role,
69
+ version,
70
+ ClassificationFeature,
71
+ CloudModel,
72
+ Config,
73
+ LocalModel,
74
+ Message,
75
+ ModelDownloadState,
76
+ Output,
77
+ ParsedText,
78
+ RunConfig,
79
+ RunStats,
80
+ Stats,
81
+ StepStats,
82
+ Text,
83
+ TotalStats,
84
+ ContextLength,
85
+ Input,
86
+ LicenseStatus,
87
+ ModelID,
88
+ ModelStorageError,
89
+ PrefillStepSize,
90
+ Preset,
91
+ SamplingMethod,
92
+ SamplingPolicy,
93
+ SamplingSeed,
94
+ StorageError
95
+ };
package/napi/uzu.mjs ADDED
@@ -0,0 +1,61 @@
1
+ // Auto-generated NAPI wrapper for uzu native module
2
+ // Currently supports only Apple Silicon (arm64) on macOS
3
+ // Other platforms may be added in future releases
4
+
5
+ import { createRequire } from 'module';
6
+
7
+ const require = createRequire(import.meta.url);
8
+
9
+ // Check for Apple Silicon support only
10
+ if (process.platform !== 'darwin' || process.arch !== 'arm64') {
11
+ throw new Error(`This package only supports Apple Silicon (arm64) on macOS. Current platform: ${process.platform}-${process.arch}`);
12
+ }
13
+
14
+ let nativeBinding = null;
15
+
16
+ try {
17
+ nativeBinding = require('./uzu.node');
18
+ } catch (e) {
19
+ throw new Error(`Failed to load native binding: ${e.message}`);
20
+ }
21
+
22
+ // Re-export all runtime exports as named exports
23
+ export const {
24
+ Engine,
25
+ ModelDownloadHandle,
26
+ ProgressStream,
27
+ ProgressUpdate,
28
+ Session,
29
+ FinishReason,
30
+ ModelDownloadPhase,
31
+ Role,
32
+ version,
33
+ ClassificationFeature,
34
+ CloudModel,
35
+ Config,
36
+ LocalModel,
37
+ Message,
38
+ ModelDownloadState,
39
+ Output,
40
+ ParsedText,
41
+ RunConfig,
42
+ RunStats,
43
+ Stats,
44
+ StepStats,
45
+ Text,
46
+ TotalStats,
47
+ ContextLength,
48
+ Input,
49
+ LicenseStatus,
50
+ ModelID,
51
+ ModelStorageError,
52
+ PrefillStepSize,
53
+ Preset,
54
+ SamplingMethod,
55
+ SamplingPolicy,
56
+ SamplingSeed,
57
+ StorageError
58
+ } = nativeBinding;
59
+
60
+ // Also provide default export
61
+ export default nativeBinding;
Binary file
package/package.json CHANGED
@@ -1,41 +1,102 @@
1
1
  {
2
- "name": "@trymirai/uzu",
3
- "version": "0.1.21",
4
- "private": false,
5
- "main": "uzu.node",
6
- "types": "uzu.d.ts",
7
- "packageManager": "pnpm@10.14.0",
8
- "scripts": {
9
- "quick-start": "ts-node examples/quick-start.ts",
10
- "chat": "ts-node examples/chat.ts",
11
- "summarisation": "ts-node examples/summarisation.ts",
12
- "classification": "ts-node examples/classification.ts"
13
- },
14
- "devDependencies": {
15
- "@napi-rs/cli": "3.1.2",
16
- "@types/node": "24.2.0",
17
- "@types/progress": "2.0.7",
18
- "eslint": "9.33.0",
19
- "ts-node": "10.9.2",
20
- "typescript": "5.9.2",
21
- "typescript-eslint": "8.40.0"
22
- },
23
- "dependencies": {
24
- "progress": "2.0.3"
25
- },
26
- "napi": {
27
- "binaryName": "uzu"
28
- },
29
- "os": [
30
- "darwin"
31
- ],
2
+ "author": "Mirai Tech Inc. <contact@getmirai.co>",
32
3
  "cpu": [
33
4
  "arm64"
34
5
  ],
6
+ "description": "A high-performance inference engine for AI models",
7
+ "exports": {
8
+ ".": {
9
+ "require": {
10
+ "types": "./index.d.ts",
11
+ "default": "./index.js"
12
+ },
13
+ "types": "./index.d.mts",
14
+ "default": "./index.mjs"
15
+ },
16
+ "./bridging/*.mjs": {
17
+ "default": "./bridging/*.mjs"
18
+ },
19
+ "./bridging/*.js": {
20
+ "default": "./bridging/*.js"
21
+ },
22
+ "./bridging/*": {
23
+ "import": "./bridging/*.mjs",
24
+ "require": "./bridging/*.js"
25
+ },
26
+ "./error": {
27
+ "import": "./error.mjs",
28
+ "require": "./error.js"
29
+ },
30
+ "./error.js": {
31
+ "default": "./error.js"
32
+ },
33
+ "./error.mjs": {
34
+ "default": "./error.mjs"
35
+ },
36
+ "./index": {
37
+ "import": "./index.mjs",
38
+ "require": "./index.js"
39
+ },
40
+ "./index.js": {
41
+ "default": "./index.js"
42
+ },
43
+ "./index.mjs": {
44
+ "default": "./index.mjs"
45
+ },
46
+ "./interactors/*.mjs": {
47
+ "default": "./interactors/*.mjs"
48
+ },
49
+ "./interactors/*.js": {
50
+ "default": "./interactors/*.js"
51
+ },
52
+ "./interactors/*": {
53
+ "import": "./interactors/*.mjs",
54
+ "require": "./interactors/*.js"
55
+ },
56
+ "./utilities/*.mjs": {
57
+ "default": "./utilities/*.mjs"
58
+ },
59
+ "./utilities/*.js": {
60
+ "default": "./utilities/*.js"
61
+ },
62
+ "./utilities/*": {
63
+ "import": "./utilities/*.mjs",
64
+ "require": "./utilities/*.js"
65
+ },
66
+ "./version": {
67
+ "import": "./version.mjs",
68
+ "require": "./version.js"
69
+ },
70
+ "./version.js": {
71
+ "default": "./version.js"
72
+ },
73
+ "./version.mjs": {
74
+ "default": "./version.mjs"
75
+ }
76
+ },
35
77
  "files": [
36
- "uzu.node",
37
- "uzu.d.ts",
38
- "package.json",
39
- "README.md"
40
- ]
78
+ "**/*"
79
+ ],
80
+ "license": "MIT",
81
+ "main": "./index.js",
82
+ "name": "@trymirai/uzu",
83
+ "os": [
84
+ "darwin"
85
+ ],
86
+ "packageManager": "pnpm@10.18.1",
87
+ "private": false,
88
+ "publishConfig": {
89
+ "access": "public"
90
+ },
91
+ "repository": "github:trymirai/uzu-ts",
92
+ "scripts": {
93
+ "build": "./scripts/build",
94
+ "fix": "./scripts/format",
95
+ "format": "./scripts/format",
96
+ "lint": "./scripts/lint",
97
+ "tsn": "ts-node -r tsconfig-paths/register"
98
+ },
99
+ "type": "commonjs",
100
+ "types": "./index.d.ts",
101
+ "version": "0.1.23"
41
102
  }
@@ -0,0 +1,20 @@
1
+ import { ClassificationFeature as NapiClassificationFeature } from '../napi/uzu';
2
+ import { ToNapi } from './napi';
3
+
4
+ export class ClassificationFeature implements ToNapi<NapiClassificationFeature> {
5
+ readonly name: string;
6
+ readonly values: string[];
7
+
8
+ constructor(name: string, values: string[]) {
9
+ this.name = name;
10
+ this.values = values;
11
+ }
12
+
13
+ toNapi(): NapiClassificationFeature {
14
+ const result: NapiClassificationFeature = {
15
+ name: this.name,
16
+ values: this.values,
17
+ };
18
+ return result;
19
+ }
20
+ }
@@ -0,0 +1,60 @@
1
+ import { Config as NapiConfig } from '../napi/uzu';
2
+ import { ContextLength } from './contextLength';
3
+ import { ToNapi } from './napi';
4
+ import { PrefillStepSize } from './prefillStepSize';
5
+ import { Preset } from './preset';
6
+ import { SamplingSeed } from './samplingSeed';
7
+
8
+ export class Config implements ToNapi<NapiConfig> {
9
+ readonly preset: Preset;
10
+ readonly prefillStepSize: PrefillStepSize;
11
+ readonly contextLength: ContextLength;
12
+ readonly samplingSeed: SamplingSeed;
13
+
14
+ constructor(
15
+ preset: Preset,
16
+ prefillStepSize: PrefillStepSize,
17
+ contextLength: ContextLength,
18
+ samplingSeed: SamplingSeed,
19
+ ) {
20
+ this.preset = preset;
21
+ this.prefillStepSize = prefillStepSize;
22
+ this.contextLength = contextLength;
23
+ this.samplingSeed = samplingSeed;
24
+ }
25
+
26
+ static default(): Config {
27
+ return new Config(
28
+ Preset.general(),
29
+ PrefillStepSize.default(),
30
+ ContextLength.default(),
31
+ SamplingSeed.default(),
32
+ );
33
+ }
34
+
35
+ withPreset(preset: Preset): Config {
36
+ return new Config(preset, this.prefillStepSize, this.contextLength, this.samplingSeed);
37
+ }
38
+
39
+ withPrefillStepSize(prefillStepSize: PrefillStepSize): Config {
40
+ return new Config(this.preset, prefillStepSize, this.contextLength, this.samplingSeed);
41
+ }
42
+
43
+ withContextLength(contextLength: ContextLength): Config {
44
+ return new Config(this.preset, this.prefillStepSize, contextLength, this.samplingSeed);
45
+ }
46
+
47
+ withSamplingSeed(samplingSeed: SamplingSeed): Config {
48
+ return new Config(this.preset, this.prefillStepSize, this.contextLength, samplingSeed);
49
+ }
50
+
51
+ toNapi(): NapiConfig {
52
+ const napiConfig: NapiConfig = {
53
+ preset: this.preset.toNapi(),
54
+ prefillStepSize: this.prefillStepSize.toNapi(),
55
+ contextLength: this.contextLength.toNapi(),
56
+ samplingSeed: this.samplingSeed.toNapi(),
57
+ };
58
+ return napiConfig;
59
+ }
60
+ }
@@ -0,0 +1,29 @@
1
+ import { ContextLength as NapiContextLength } from '../napi/uzu';
2
+ import { ToNapi } from './napi';
3
+
4
+ export class ContextLength implements ToNapi<NapiContextLength> {
5
+ private readonly napiContextLength: NapiContextLength;
6
+
7
+ private constructor(napiContextLength: NapiContextLength) {
8
+ this.napiContextLength = napiContextLength;
9
+ }
10
+
11
+ static default(): ContextLength {
12
+ const napiContextLength: NapiContextLength = { type: 'Default' };
13
+ return new ContextLength(napiContextLength);
14
+ }
15
+
16
+ static maximal(): ContextLength {
17
+ const napiContextLength: NapiContextLength = { type: 'Maximal' };
18
+ return new ContextLength(napiContextLength);
19
+ }
20
+
21
+ static custom(length: number): ContextLength {
22
+ const napiContextLength: NapiContextLength = { type: 'Custom', length };
23
+ return new ContextLength(napiContextLength);
24
+ }
25
+
26
+ toNapi(): NapiContextLength {
27
+ return this.napiContextLength;
28
+ }
29
+ }
@@ -0,0 +1,41 @@
1
+ import { ModelDownloadHandle as NapiModelDownloadHandle } from '../napi/uzu';
2
+ import { DownloadProgressUpdate } from './downloadProgressUpdate';
3
+ import { DownloadState } from './downloadState';
4
+
5
+ export class DownloadHandle {
6
+ private readonly napiDownloadHandle: NapiModelDownloadHandle;
7
+
8
+ constructor(napiDownloadHandle: NapiModelDownloadHandle) {
9
+ this.napiDownloadHandle = napiDownloadHandle;
10
+ }
11
+
12
+ identifier(): string {
13
+ return this.napiDownloadHandle.identifier();
14
+ }
15
+
16
+ async state(): Promise<DownloadState> {
17
+ const napiDownloadState = await this.napiDownloadHandle.state();
18
+ return DownloadState.fromNapi(napiDownloadState);
19
+ }
20
+
21
+ async download(): Promise<void> {
22
+ await this.napiDownloadHandle.download();
23
+ }
24
+
25
+ async pause(): Promise<void> {
26
+ await this.napiDownloadHandle.pause();
27
+ }
28
+
29
+ async delete(): Promise<void> {
30
+ await this.napiDownloadHandle.delete();
31
+ }
32
+
33
+ progressUpdate(): AsyncIterable<DownloadProgressUpdate> {
34
+ const source = this.napiDownloadHandle.progress();
35
+ return (async function* () {
36
+ for await (const update of source) {
37
+ yield DownloadProgressUpdate.fromNapi(update);
38
+ }
39
+ })();
40
+ }
41
+ }
@@ -0,0 +1,21 @@
1
+ import { ProgressUpdate as NapiProgressUpdate } from '../napi/uzu';
2
+
3
+ export class DownloadProgressUpdate {
4
+ readonly completedBytes: number;
5
+ readonly totalBytes: number | null;
6
+ readonly progress: number;
7
+
8
+ private constructor(completedBytes: number, totalBytes: number | null, progress: number) {
9
+ this.completedBytes = completedBytes;
10
+ this.totalBytes = totalBytes;
11
+ this.progress = progress;
12
+ }
13
+
14
+ static fromNapi(napiDownloadProgress: NapiProgressUpdate): DownloadProgressUpdate {
15
+ return new DownloadProgressUpdate(
16
+ napiDownloadProgress.completedBytes,
17
+ napiDownloadProgress.totalBytes ?? null,
18
+ napiDownloadProgress.progress,
19
+ );
20
+ }
21
+ }
@@ -0,0 +1,59 @@
1
+ import { EngineError, EngineErrorCode } from '../error';
2
+ import {
3
+ ModelDownloadPhase as NapiModelDownloadPhase,
4
+ ModelDownloadState as NapiModelDownloadState,
5
+ } from '../napi/uzu';
6
+
7
+ export enum DownloadPhase {
8
+ NotDownloaded = 'NotDownloaded',
9
+ Downloading = 'Downloading',
10
+ Paused = 'Paused',
11
+ Downloaded = 'Downloaded',
12
+ Error = 'Error',
13
+ }
14
+
15
+ export class DownloadState {
16
+ readonly totalKbytes: number;
17
+ readonly downloadedKbytes: number;
18
+ readonly phase: DownloadPhase;
19
+ readonly error: string | null;
20
+
21
+ private constructor(
22
+ totalKbytes: number,
23
+ downloadedKbytes: number,
24
+ phase: DownloadPhase,
25
+ error: string | null,
26
+ ) {
27
+ this.totalKbytes = totalKbytes;
28
+ this.downloadedKbytes = downloadedKbytes;
29
+ this.phase = phase;
30
+ this.error = error;
31
+ }
32
+
33
+ private static napiPhaseToDownloadPhase(napiPhase: NapiModelDownloadPhase): DownloadPhase {
34
+ switch (napiPhase) {
35
+ case 0:
36
+ return DownloadPhase.NotDownloaded;
37
+ case 1:
38
+ return DownloadPhase.Downloading;
39
+ case 2:
40
+ return DownloadPhase.Paused;
41
+ case 3:
42
+ return DownloadPhase.Downloaded;
43
+ case 4:
44
+ return DownloadPhase.Error;
45
+ default:
46
+ throw new EngineError(EngineErrorCode.UnexpectedDownloadPhase);
47
+ }
48
+ }
49
+
50
+ static fromNapi(napiDownloadState: NapiModelDownloadState): DownloadState {
51
+ const phase = DownloadState.napiPhaseToDownloadPhase(napiDownloadState.phase);
52
+ return new DownloadState(
53
+ napiDownloadState.totalKbytes,
54
+ napiDownloadState.downloadedKbytes,
55
+ phase,
56
+ napiDownloadState.error ?? null,
57
+ );
58
+ }
59
+ }
@@ -0,0 +1,97 @@
1
+ import { EngineError, EngineErrorCode, unwrapOrThrow } from '../error';
2
+ import { EngineInteractor } from '../interactors/engineInteractor';
3
+ import { Engine as NapiEngine, ModelID as NapiModelID } from '../napi/uzu';
4
+ import { readEnv } from '../utilities/env';
5
+ import { Config } from './config';
6
+ import { DownloadHandle } from './downloadHandle';
7
+ import { LicenseStatus, licenseStatusFromNapiLicenseStatus } from './licenseStatus';
8
+ import { Model, ModelKind, ModelType } from './model';
9
+ import { Session } from './session';
10
+
11
+ export class Engine {
12
+ private readonly napiEngine: NapiEngine;
13
+
14
+ private constructor(napiEngine: NapiEngine) {
15
+ this.napiEngine = napiEngine;
16
+ }
17
+
18
+ static async load(apiKey: string | undefined = undefined): Promise<Engine> {
19
+ const resolvedApiKey = unwrapOrThrow(
20
+ apiKey ?? readEnv('MIRAI_API_KEY'),
21
+ EngineErrorCode.APIKeyNotFound,
22
+ );
23
+
24
+ const napiEngine = new NapiEngine();
25
+
26
+ const napiLicenseStatus = await napiEngine.activate(resolvedApiKey);
27
+ const licenseStatus = licenseStatusFromNapiLicenseStatus(napiLicenseStatus);
28
+ switch (licenseStatus) {
29
+ case LicenseStatus.Activated:
30
+ case LicenseStatus.GracePeriodActive:
31
+ break;
32
+ default:
33
+ throw new EngineError(EngineErrorCode.LicenseNotActivated);
34
+ }
35
+
36
+ return new Engine(napiEngine);
37
+ }
38
+
39
+ static create(apiKey: string | undefined = undefined): EngineInteractor {
40
+ const enginePromise = (async () => {
41
+ return await Engine.load(apiKey);
42
+ })();
43
+ return new EngineInteractor(enginePromise);
44
+ }
45
+
46
+ async models(types: ModelType[] | null = null, kinds: ModelKind[] | null = null): Promise<Model[]> {
47
+ function isTypeAllowed(type: ModelType): boolean {
48
+ return types === null || types.includes(type);
49
+ }
50
+
51
+ function isKindAllowed(kind: ModelKind): boolean {
52
+ return kinds === null || kinds.includes(kind);
53
+ }
54
+
55
+ let results: Model[] = [];
56
+ if (isTypeAllowed(ModelType.Local) && isKindAllowed(ModelKind.Text)) {
57
+ const napiLocalModels = this.napiEngine.getLocalModels();
58
+ results.push(...napiLocalModels.map(Model.fromNapiLocalModel));
59
+ }
60
+ if (isTypeAllowed(ModelType.Cloud) && isKindAllowed(ModelKind.Text)) {
61
+ const napiCloudModels = await this.napiEngine.getCloudModels();
62
+ results.push(...napiCloudModels.map(Model.fromNapiCloudModel));
63
+ }
64
+ return results;
65
+ }
66
+
67
+ async model(repoId: string): Promise<Model> {
68
+ const models = await this.models();
69
+ const model = models.find((model) => model.repoId === repoId);
70
+ return unwrapOrThrow(model, EngineErrorCode.ModelNotFound);
71
+ }
72
+
73
+ downloadHandle(model: Model): DownloadHandle {
74
+ if (model.type !== ModelType.Local) {
75
+ throw new EngineError(EngineErrorCode.ExpectedLocalModel);
76
+ }
77
+ return new DownloadHandle(this.napiEngine.downloadHandle(model.repoId));
78
+ }
79
+
80
+ private static napiModelId(model: Model): NapiModelID {
81
+ switch (model.type) {
82
+ case ModelType.Local:
83
+ return { type: 'Local', id: model.repoId };
84
+ case ModelType.Cloud:
85
+ return { type: 'Cloud', id: model.repoId };
86
+ }
87
+ }
88
+
89
+ session(model: Model, config: Config = Config.default()): Session {
90
+ if (model.kind !== ModelKind.Text) {
91
+ throw new EngineError(EngineErrorCode.ExpectedTextModel);
92
+ }
93
+ const napiModelId = Engine.napiModelId(model);
94
+ const napiConfig = config.toNapi();
95
+ return new Session(this.napiEngine.createSession(napiModelId, napiConfig));
96
+ }
97
+ }
@@ -0,0 +1,6 @@
1
+ export enum FinishReason {
2
+ Stop = 0,
3
+ Length = 1,
4
+ Cancelled = 2,
5
+ ContextLimitReached = 3,
6
+ }
@@ -0,0 +1,29 @@
1
+ import { Input as NapiInput, Message as NapiMessage } from '../napi/uzu';
2
+ import { Message } from './message';
3
+ import { ToNapi } from './napi';
4
+
5
+ export class Input implements ToNapi<NapiInput> {
6
+ private readonly napiInput: NapiInput;
7
+
8
+ private constructor(napiInput: NapiInput) {
9
+ this.napiInput = napiInput;
10
+ }
11
+
12
+ static text(text: string): Input {
13
+ const napiInput: NapiInput = { type: 'Text', text };
14
+ return new Input(napiInput);
15
+ }
16
+
17
+ static messages(messages: Message[]): Input {
18
+ const napiMessages: NapiMessage[] = messages.map((message) => message.toNapi());
19
+ const napiInput: NapiInput = {
20
+ type: 'Messages',
21
+ messages: napiMessages,
22
+ };
23
+ return new Input(napiInput);
24
+ }
25
+
26
+ toNapi(): NapiInput {
27
+ return this.napiInput;
28
+ }
29
+ }