@boundaryml/baml-bridge 0.0.0 → 0.13.1-nightly.20260707.f

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 (46) hide show
  1. package/dist/ctx_manager.d.ts +22 -0
  2. package/dist/ctx_manager.d.ts.map +1 -0
  3. package/dist/ctx_manager.js +91 -0
  4. package/dist/ctx_manager.js.map +1 -0
  5. package/dist/define_function.d.ts +38 -0
  6. package/dist/define_function.d.ts.map +1 -0
  7. package/dist/define_function.js +281 -0
  8. package/dist/define_function.js.map +1 -0
  9. package/dist/errors.d.ts +51 -0
  10. package/dist/errors.d.ts.map +1 -0
  11. package/dist/errors.js +67 -0
  12. package/dist/errors.js.map +1 -0
  13. package/dist/exit_hook.d.ts +9 -0
  14. package/dist/exit_hook.d.ts.map +1 -0
  15. package/dist/exit_hook.js +27 -0
  16. package/dist/exit_hook.js.map +1 -0
  17. package/dist/host_value_registry.d.ts +57 -0
  18. package/dist/host_value_registry.d.ts.map +1 -0
  19. package/dist/host_value_registry.js +141 -0
  20. package/dist/host_value_registry.js.map +1 -0
  21. package/dist/index.d.ts +67 -0
  22. package/dist/index.d.ts.map +1 -0
  23. package/dist/index.js +162 -0
  24. package/dist/index.js.map +1 -0
  25. package/dist/native.d.ts +312 -0
  26. package/dist/native.js +625 -0
  27. package/dist/proto/baml_cffi.d.ts +6385 -0
  28. package/dist/proto/baml_cffi.js +17738 -0
  29. package/dist/proto.d.ts +62 -0
  30. package/dist/proto.d.ts.map +1 -0
  31. package/dist/proto.js +963 -0
  32. package/dist/proto.js.map +1 -0
  33. package/dist/stream.d.ts +23 -0
  34. package/dist/stream.d.ts.map +1 -0
  35. package/dist/stream.js +68 -0
  36. package/dist/stream.js.map +1 -0
  37. package/dist/typemap.d.ts +37 -0
  38. package/dist/typemap.d.ts.map +1 -0
  39. package/dist/typemap.js +110 -0
  40. package/dist/typemap.js.map +1 -0
  41. package/dist/wire_ty.d.ts +58 -0
  42. package/dist/wire_ty.d.ts.map +1 -0
  43. package/dist/wire_ty.js +147 -0
  44. package/dist/wire_ty.js.map +1 -0
  45. package/package.json +64 -5
  46. package/README.md +0 -3
package/dist/native.js ADDED
@@ -0,0 +1,625 @@
1
+ /**
2
+ * THIS FILE IS AUTO-GENERATED — DO NOT EDIT BY HAND.
3
+ *
4
+ * Source: baml_language/crates/bridge_nodejs/typescript_src/
5
+ * Proto: baml_language/crates/bridge_ctypes/types/baml_bridge/cffi/v1/*.proto
6
+ * Build: cd baml_language/crates/bridge_nodejs && pnpm build:debug
7
+ */
8
+ // prettier-ignore
9
+ /* eslint-disable */
10
+ // @ts-nocheck
11
+ /* auto-generated by NAPI-RS */
12
+
13
+ import { createRequire } from 'node:module'
14
+ const require = createRequire(import.meta.url)
15
+ const __dirname = new URL('.', import.meta.url).pathname
16
+
17
+ const { readFileSync } = require('node:fs')
18
+ let nativeBinding = null
19
+ const loadErrors = []
20
+
21
+ const isMusl = () => {
22
+ let musl = false
23
+ if (process.platform === 'linux') {
24
+ musl = isMuslFromFilesystem()
25
+ if (musl === null) {
26
+ musl = isMuslFromReport()
27
+ }
28
+ if (musl === null) {
29
+ musl = isMuslFromChildProcess()
30
+ }
31
+ }
32
+ return musl
33
+ }
34
+
35
+ const isFileMusl = (f) => f.includes('libc.musl-') || f.includes('ld-musl-')
36
+
37
+ const isMuslFromFilesystem = () => {
38
+ try {
39
+ return readFileSync('/usr/bin/ldd', 'utf-8').includes('musl')
40
+ } catch {
41
+ return null
42
+ }
43
+ }
44
+
45
+ const isMuslFromReport = () => {
46
+ let report = null
47
+ if (typeof process.report?.getReport === 'function') {
48
+ process.report.excludeNetwork = true
49
+ report = process.report.getReport()
50
+ }
51
+ if (!report) {
52
+ return null
53
+ }
54
+ if (report.header && report.header.glibcVersionRuntime) {
55
+ return false
56
+ }
57
+ if (Array.isArray(report.sharedObjects)) {
58
+ if (report.sharedObjects.some(isFileMusl)) {
59
+ return true
60
+ }
61
+ }
62
+ return false
63
+ }
64
+
65
+ const isMuslFromChildProcess = () => {
66
+ try {
67
+ return require('child_process').execSync('ldd --version', { encoding: 'utf8' }).includes('musl')
68
+ } catch (e) {
69
+ // If we reach this case, we don't know if the system is musl or not, so is better to just fallback to false
70
+ return false
71
+ }
72
+ }
73
+
74
+ function requireNative() {
75
+ if (process.env.NAPI_RS_NATIVE_LIBRARY_PATH) {
76
+ try {
77
+ return require(process.env.NAPI_RS_NATIVE_LIBRARY_PATH);
78
+ } catch (err) {
79
+ loadErrors.push(err)
80
+ }
81
+ } else if (process.platform === 'android') {
82
+ if (process.arch === 'arm64') {
83
+ try {
84
+ return require('./baml_node.android-arm64.node')
85
+ } catch (e) {
86
+ loadErrors.push(e)
87
+ }
88
+ try {
89
+ const binding = require('@boundaryml/baml-bridge-android-arm64')
90
+ const bindingPackageVersion = require('@boundaryml/baml-bridge-android-arm64/package.json').version
91
+ if (bindingPackageVersion !== '0.13.1-nightly.20260707.f' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
92
+ throw new Error(`Native binding package version mismatch, expected 0.13.1-nightly.20260707.f but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
93
+ }
94
+ return binding
95
+ } catch (e) {
96
+ loadErrors.push(e)
97
+ }
98
+ } else if (process.arch === 'arm') {
99
+ try {
100
+ return require('./baml_node.android-arm-eabi.node')
101
+ } catch (e) {
102
+ loadErrors.push(e)
103
+ }
104
+ try {
105
+ const binding = require('@boundaryml/baml-bridge-android-arm-eabi')
106
+ const bindingPackageVersion = require('@boundaryml/baml-bridge-android-arm-eabi/package.json').version
107
+ if (bindingPackageVersion !== '0.13.1-nightly.20260707.f' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
108
+ throw new Error(`Native binding package version mismatch, expected 0.13.1-nightly.20260707.f but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
109
+ }
110
+ return binding
111
+ } catch (e) {
112
+ loadErrors.push(e)
113
+ }
114
+ } else {
115
+ loadErrors.push(new Error(`Unsupported architecture on Android ${process.arch}`))
116
+ }
117
+ } else if (process.platform === 'win32') {
118
+ if (process.arch === 'x64') {
119
+ if (process.config?.variables?.shlib_suffix === 'dll.a' || process.config?.variables?.node_target_type === 'shared_library') {
120
+ try {
121
+ return require('./baml_node.win32-x64-gnu.node')
122
+ } catch (e) {
123
+ loadErrors.push(e)
124
+ }
125
+ try {
126
+ const binding = require('@boundaryml/baml-bridge-win32-x64-gnu')
127
+ const bindingPackageVersion = require('@boundaryml/baml-bridge-win32-x64-gnu/package.json').version
128
+ if (bindingPackageVersion !== '0.13.1-nightly.20260707.f' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
129
+ throw new Error(`Native binding package version mismatch, expected 0.13.1-nightly.20260707.f but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
130
+ }
131
+ return binding
132
+ } catch (e) {
133
+ loadErrors.push(e)
134
+ }
135
+ } else {
136
+ try {
137
+ return require('./baml_node.win32-x64-msvc.node')
138
+ } catch (e) {
139
+ loadErrors.push(e)
140
+ }
141
+ try {
142
+ const binding = require('@boundaryml/baml-bridge-win32-x64-msvc')
143
+ const bindingPackageVersion = require('@boundaryml/baml-bridge-win32-x64-msvc/package.json').version
144
+ if (bindingPackageVersion !== '0.13.1-nightly.20260707.f' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
145
+ throw new Error(`Native binding package version mismatch, expected 0.13.1-nightly.20260707.f but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
146
+ }
147
+ return binding
148
+ } catch (e) {
149
+ loadErrors.push(e)
150
+ }
151
+ }
152
+ } else if (process.arch === 'ia32') {
153
+ try {
154
+ return require('./baml_node.win32-ia32-msvc.node')
155
+ } catch (e) {
156
+ loadErrors.push(e)
157
+ }
158
+ try {
159
+ const binding = require('@boundaryml/baml-bridge-win32-ia32-msvc')
160
+ const bindingPackageVersion = require('@boundaryml/baml-bridge-win32-ia32-msvc/package.json').version
161
+ if (bindingPackageVersion !== '0.13.1-nightly.20260707.f' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
162
+ throw new Error(`Native binding package version mismatch, expected 0.13.1-nightly.20260707.f but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
163
+ }
164
+ return binding
165
+ } catch (e) {
166
+ loadErrors.push(e)
167
+ }
168
+ } else if (process.arch === 'arm64') {
169
+ try {
170
+ return require('./baml_node.win32-arm64-msvc.node')
171
+ } catch (e) {
172
+ loadErrors.push(e)
173
+ }
174
+ try {
175
+ const binding = require('@boundaryml/baml-bridge-win32-arm64-msvc')
176
+ const bindingPackageVersion = require('@boundaryml/baml-bridge-win32-arm64-msvc/package.json').version
177
+ if (bindingPackageVersion !== '0.13.1-nightly.20260707.f' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
178
+ throw new Error(`Native binding package version mismatch, expected 0.13.1-nightly.20260707.f but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
179
+ }
180
+ return binding
181
+ } catch (e) {
182
+ loadErrors.push(e)
183
+ }
184
+ } else {
185
+ loadErrors.push(new Error(`Unsupported architecture on Windows: ${process.arch}`))
186
+ }
187
+ } else if (process.platform === 'darwin') {
188
+ try {
189
+ return require('./baml_node.darwin-universal.node')
190
+ } catch (e) {
191
+ loadErrors.push(e)
192
+ }
193
+ try {
194
+ const binding = require('@boundaryml/baml-bridge-darwin-universal')
195
+ const bindingPackageVersion = require('@boundaryml/baml-bridge-darwin-universal/package.json').version
196
+ if (bindingPackageVersion !== '0.13.1-nightly.20260707.f' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
197
+ throw new Error(`Native binding package version mismatch, expected 0.13.1-nightly.20260707.f but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
198
+ }
199
+ return binding
200
+ } catch (e) {
201
+ loadErrors.push(e)
202
+ }
203
+ if (process.arch === 'x64') {
204
+ try {
205
+ return require('./baml_node.darwin-x64.node')
206
+ } catch (e) {
207
+ loadErrors.push(e)
208
+ }
209
+ try {
210
+ const binding = require('@boundaryml/baml-bridge-darwin-x64')
211
+ const bindingPackageVersion = require('@boundaryml/baml-bridge-darwin-x64/package.json').version
212
+ if (bindingPackageVersion !== '0.13.1-nightly.20260707.f' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
213
+ throw new Error(`Native binding package version mismatch, expected 0.13.1-nightly.20260707.f but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
214
+ }
215
+ return binding
216
+ } catch (e) {
217
+ loadErrors.push(e)
218
+ }
219
+ } else if (process.arch === 'arm64') {
220
+ try {
221
+ return require('./baml_node.darwin-arm64.node')
222
+ } catch (e) {
223
+ loadErrors.push(e)
224
+ }
225
+ try {
226
+ const binding = require('@boundaryml/baml-bridge-darwin-arm64')
227
+ const bindingPackageVersion = require('@boundaryml/baml-bridge-darwin-arm64/package.json').version
228
+ if (bindingPackageVersion !== '0.13.1-nightly.20260707.f' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
229
+ throw new Error(`Native binding package version mismatch, expected 0.13.1-nightly.20260707.f but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
230
+ }
231
+ return binding
232
+ } catch (e) {
233
+ loadErrors.push(e)
234
+ }
235
+ } else {
236
+ loadErrors.push(new Error(`Unsupported architecture on macOS: ${process.arch}`))
237
+ }
238
+ } else if (process.platform === 'freebsd') {
239
+ if (process.arch === 'x64') {
240
+ try {
241
+ return require('./baml_node.freebsd-x64.node')
242
+ } catch (e) {
243
+ loadErrors.push(e)
244
+ }
245
+ try {
246
+ const binding = require('@boundaryml/baml-bridge-freebsd-x64')
247
+ const bindingPackageVersion = require('@boundaryml/baml-bridge-freebsd-x64/package.json').version
248
+ if (bindingPackageVersion !== '0.13.1-nightly.20260707.f' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
249
+ throw new Error(`Native binding package version mismatch, expected 0.13.1-nightly.20260707.f but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
250
+ }
251
+ return binding
252
+ } catch (e) {
253
+ loadErrors.push(e)
254
+ }
255
+ } else if (process.arch === 'arm64') {
256
+ try {
257
+ return require('./baml_node.freebsd-arm64.node')
258
+ } catch (e) {
259
+ loadErrors.push(e)
260
+ }
261
+ try {
262
+ const binding = require('@boundaryml/baml-bridge-freebsd-arm64')
263
+ const bindingPackageVersion = require('@boundaryml/baml-bridge-freebsd-arm64/package.json').version
264
+ if (bindingPackageVersion !== '0.13.1-nightly.20260707.f' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
265
+ throw new Error(`Native binding package version mismatch, expected 0.13.1-nightly.20260707.f but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
266
+ }
267
+ return binding
268
+ } catch (e) {
269
+ loadErrors.push(e)
270
+ }
271
+ } else {
272
+ loadErrors.push(new Error(`Unsupported architecture on FreeBSD: ${process.arch}`))
273
+ }
274
+ } else if (process.platform === 'linux') {
275
+ if (process.arch === 'x64') {
276
+ if (isMusl()) {
277
+ try {
278
+ return require('./baml_node.linux-x64-musl.node')
279
+ } catch (e) {
280
+ loadErrors.push(e)
281
+ }
282
+ try {
283
+ const binding = require('@boundaryml/baml-bridge-linux-x64-musl')
284
+ const bindingPackageVersion = require('@boundaryml/baml-bridge-linux-x64-musl/package.json').version
285
+ if (bindingPackageVersion !== '0.13.1-nightly.20260707.f' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
286
+ throw new Error(`Native binding package version mismatch, expected 0.13.1-nightly.20260707.f but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
287
+ }
288
+ return binding
289
+ } catch (e) {
290
+ loadErrors.push(e)
291
+ }
292
+ } else {
293
+ try {
294
+ return require('./baml_node.linux-x64-gnu.node')
295
+ } catch (e) {
296
+ loadErrors.push(e)
297
+ }
298
+ try {
299
+ const binding = require('@boundaryml/baml-bridge-linux-x64-gnu')
300
+ const bindingPackageVersion = require('@boundaryml/baml-bridge-linux-x64-gnu/package.json').version
301
+ if (bindingPackageVersion !== '0.13.1-nightly.20260707.f' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
302
+ throw new Error(`Native binding package version mismatch, expected 0.13.1-nightly.20260707.f but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
303
+ }
304
+ return binding
305
+ } catch (e) {
306
+ loadErrors.push(e)
307
+ }
308
+ }
309
+ } else if (process.arch === 'arm64') {
310
+ if (isMusl()) {
311
+ try {
312
+ return require('./baml_node.linux-arm64-musl.node')
313
+ } catch (e) {
314
+ loadErrors.push(e)
315
+ }
316
+ try {
317
+ const binding = require('@boundaryml/baml-bridge-linux-arm64-musl')
318
+ const bindingPackageVersion = require('@boundaryml/baml-bridge-linux-arm64-musl/package.json').version
319
+ if (bindingPackageVersion !== '0.13.1-nightly.20260707.f' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
320
+ throw new Error(`Native binding package version mismatch, expected 0.13.1-nightly.20260707.f but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
321
+ }
322
+ return binding
323
+ } catch (e) {
324
+ loadErrors.push(e)
325
+ }
326
+ } else {
327
+ try {
328
+ return require('./baml_node.linux-arm64-gnu.node')
329
+ } catch (e) {
330
+ loadErrors.push(e)
331
+ }
332
+ try {
333
+ const binding = require('@boundaryml/baml-bridge-linux-arm64-gnu')
334
+ const bindingPackageVersion = require('@boundaryml/baml-bridge-linux-arm64-gnu/package.json').version
335
+ if (bindingPackageVersion !== '0.13.1-nightly.20260707.f' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
336
+ throw new Error(`Native binding package version mismatch, expected 0.13.1-nightly.20260707.f but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
337
+ }
338
+ return binding
339
+ } catch (e) {
340
+ loadErrors.push(e)
341
+ }
342
+ }
343
+ } else if (process.arch === 'arm') {
344
+ if (isMusl()) {
345
+ try {
346
+ return require('./baml_node.linux-arm-musleabihf.node')
347
+ } catch (e) {
348
+ loadErrors.push(e)
349
+ }
350
+ try {
351
+ const binding = require('@boundaryml/baml-bridge-linux-arm-musleabihf')
352
+ const bindingPackageVersion = require('@boundaryml/baml-bridge-linux-arm-musleabihf/package.json').version
353
+ if (bindingPackageVersion !== '0.13.1-nightly.20260707.f' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
354
+ throw new Error(`Native binding package version mismatch, expected 0.13.1-nightly.20260707.f but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
355
+ }
356
+ return binding
357
+ } catch (e) {
358
+ loadErrors.push(e)
359
+ }
360
+ } else {
361
+ try {
362
+ return require('./baml_node.linux-arm-gnueabihf.node')
363
+ } catch (e) {
364
+ loadErrors.push(e)
365
+ }
366
+ try {
367
+ const binding = require('@boundaryml/baml-bridge-linux-arm-gnueabihf')
368
+ const bindingPackageVersion = require('@boundaryml/baml-bridge-linux-arm-gnueabihf/package.json').version
369
+ if (bindingPackageVersion !== '0.13.1-nightly.20260707.f' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
370
+ throw new Error(`Native binding package version mismatch, expected 0.13.1-nightly.20260707.f but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
371
+ }
372
+ return binding
373
+ } catch (e) {
374
+ loadErrors.push(e)
375
+ }
376
+ }
377
+ } else if (process.arch === 'loong64') {
378
+ if (isMusl()) {
379
+ try {
380
+ return require('./baml_node.linux-loong64-musl.node')
381
+ } catch (e) {
382
+ loadErrors.push(e)
383
+ }
384
+ try {
385
+ const binding = require('@boundaryml/baml-bridge-linux-loong64-musl')
386
+ const bindingPackageVersion = require('@boundaryml/baml-bridge-linux-loong64-musl/package.json').version
387
+ if (bindingPackageVersion !== '0.13.1-nightly.20260707.f' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
388
+ throw new Error(`Native binding package version mismatch, expected 0.13.1-nightly.20260707.f but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
389
+ }
390
+ return binding
391
+ } catch (e) {
392
+ loadErrors.push(e)
393
+ }
394
+ } else {
395
+ try {
396
+ return require('./baml_node.linux-loong64-gnu.node')
397
+ } catch (e) {
398
+ loadErrors.push(e)
399
+ }
400
+ try {
401
+ const binding = require('@boundaryml/baml-bridge-linux-loong64-gnu')
402
+ const bindingPackageVersion = require('@boundaryml/baml-bridge-linux-loong64-gnu/package.json').version
403
+ if (bindingPackageVersion !== '0.13.1-nightly.20260707.f' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
404
+ throw new Error(`Native binding package version mismatch, expected 0.13.1-nightly.20260707.f but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
405
+ }
406
+ return binding
407
+ } catch (e) {
408
+ loadErrors.push(e)
409
+ }
410
+ }
411
+ } else if (process.arch === 'riscv64') {
412
+ if (isMusl()) {
413
+ try {
414
+ return require('./baml_node.linux-riscv64-musl.node')
415
+ } catch (e) {
416
+ loadErrors.push(e)
417
+ }
418
+ try {
419
+ const binding = require('@boundaryml/baml-bridge-linux-riscv64-musl')
420
+ const bindingPackageVersion = require('@boundaryml/baml-bridge-linux-riscv64-musl/package.json').version
421
+ if (bindingPackageVersion !== '0.13.1-nightly.20260707.f' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
422
+ throw new Error(`Native binding package version mismatch, expected 0.13.1-nightly.20260707.f but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
423
+ }
424
+ return binding
425
+ } catch (e) {
426
+ loadErrors.push(e)
427
+ }
428
+ } else {
429
+ try {
430
+ return require('./baml_node.linux-riscv64-gnu.node')
431
+ } catch (e) {
432
+ loadErrors.push(e)
433
+ }
434
+ try {
435
+ const binding = require('@boundaryml/baml-bridge-linux-riscv64-gnu')
436
+ const bindingPackageVersion = require('@boundaryml/baml-bridge-linux-riscv64-gnu/package.json').version
437
+ if (bindingPackageVersion !== '0.13.1-nightly.20260707.f' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
438
+ throw new Error(`Native binding package version mismatch, expected 0.13.1-nightly.20260707.f but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
439
+ }
440
+ return binding
441
+ } catch (e) {
442
+ loadErrors.push(e)
443
+ }
444
+ }
445
+ } else if (process.arch === 'ppc64') {
446
+ try {
447
+ return require('./baml_node.linux-ppc64-gnu.node')
448
+ } catch (e) {
449
+ loadErrors.push(e)
450
+ }
451
+ try {
452
+ const binding = require('@boundaryml/baml-bridge-linux-ppc64-gnu')
453
+ const bindingPackageVersion = require('@boundaryml/baml-bridge-linux-ppc64-gnu/package.json').version
454
+ if (bindingPackageVersion !== '0.13.1-nightly.20260707.f' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
455
+ throw new Error(`Native binding package version mismatch, expected 0.13.1-nightly.20260707.f but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
456
+ }
457
+ return binding
458
+ } catch (e) {
459
+ loadErrors.push(e)
460
+ }
461
+ } else if (process.arch === 's390x') {
462
+ try {
463
+ return require('./baml_node.linux-s390x-gnu.node')
464
+ } catch (e) {
465
+ loadErrors.push(e)
466
+ }
467
+ try {
468
+ const binding = require('@boundaryml/baml-bridge-linux-s390x-gnu')
469
+ const bindingPackageVersion = require('@boundaryml/baml-bridge-linux-s390x-gnu/package.json').version
470
+ if (bindingPackageVersion !== '0.13.1-nightly.20260707.f' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
471
+ throw new Error(`Native binding package version mismatch, expected 0.13.1-nightly.20260707.f but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
472
+ }
473
+ return binding
474
+ } catch (e) {
475
+ loadErrors.push(e)
476
+ }
477
+ } else {
478
+ loadErrors.push(new Error(`Unsupported architecture on Linux: ${process.arch}`))
479
+ }
480
+ } else if (process.platform === 'openharmony') {
481
+ if (process.arch === 'arm64') {
482
+ try {
483
+ return require('./baml_node.openharmony-arm64.node')
484
+ } catch (e) {
485
+ loadErrors.push(e)
486
+ }
487
+ try {
488
+ const binding = require('@boundaryml/baml-bridge-openharmony-arm64')
489
+ const bindingPackageVersion = require('@boundaryml/baml-bridge-openharmony-arm64/package.json').version
490
+ if (bindingPackageVersion !== '0.13.1-nightly.20260707.f' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
491
+ throw new Error(`Native binding package version mismatch, expected 0.13.1-nightly.20260707.f but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
492
+ }
493
+ return binding
494
+ } catch (e) {
495
+ loadErrors.push(e)
496
+ }
497
+ } else if (process.arch === 'x64') {
498
+ try {
499
+ return require('./baml_node.openharmony-x64.node')
500
+ } catch (e) {
501
+ loadErrors.push(e)
502
+ }
503
+ try {
504
+ const binding = require('@boundaryml/baml-bridge-openharmony-x64')
505
+ const bindingPackageVersion = require('@boundaryml/baml-bridge-openharmony-x64/package.json').version
506
+ if (bindingPackageVersion !== '0.13.1-nightly.20260707.f' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
507
+ throw new Error(`Native binding package version mismatch, expected 0.13.1-nightly.20260707.f but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
508
+ }
509
+ return binding
510
+ } catch (e) {
511
+ loadErrors.push(e)
512
+ }
513
+ } else if (process.arch === 'arm') {
514
+ try {
515
+ return require('./baml_node.openharmony-arm.node')
516
+ } catch (e) {
517
+ loadErrors.push(e)
518
+ }
519
+ try {
520
+ const binding = require('@boundaryml/baml-bridge-openharmony-arm')
521
+ const bindingPackageVersion = require('@boundaryml/baml-bridge-openharmony-arm/package.json').version
522
+ if (bindingPackageVersion !== '0.13.1-nightly.20260707.f' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
523
+ throw new Error(`Native binding package version mismatch, expected 0.13.1-nightly.20260707.f but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
524
+ }
525
+ return binding
526
+ } catch (e) {
527
+ loadErrors.push(e)
528
+ }
529
+ } else {
530
+ loadErrors.push(new Error(`Unsupported architecture on OpenHarmony: ${process.arch}`))
531
+ }
532
+ } else {
533
+ loadErrors.push(new Error(`Unsupported OS: ${process.platform}, architecture: ${process.arch}`))
534
+ }
535
+ }
536
+
537
+ nativeBinding = requireNative()
538
+
539
+ // NAPI_RS_FORCE_WASI is a tri-state flag:
540
+ // unset / any other value → native binding preferred, WASI is only a fallback
541
+ // 'true' → force WASI fallback even if native loaded
542
+ // 'error' → force WASI and throw if no WASI binding is found
543
+ // Treating any non-empty string as truthy (the historical behavior) meant
544
+ // NAPI_RS_FORCE_WASI=false, NAPI_RS_FORCE_WASI=0, etc. inadvertently triggered
545
+ // the WASI path, causing ENOENT for packages shipped without a .wasi.cjs file.
546
+ const forceWasi =
547
+ process.env.NAPI_RS_FORCE_WASI === 'true' || process.env.NAPI_RS_FORCE_WASI === 'error'
548
+
549
+ if (!nativeBinding || forceWasi) {
550
+ let wasiBinding = null
551
+ let wasiBindingError = null
552
+ try {
553
+ wasiBinding = require('./baml_node.wasi.cjs')
554
+ nativeBinding = wasiBinding
555
+ } catch (err) {
556
+ if (forceWasi) {
557
+ wasiBindingError = err
558
+ }
559
+ }
560
+ if (!nativeBinding || forceWasi) {
561
+ try {
562
+ wasiBinding = require('@boundaryml/baml-bridge-wasm32-wasi')
563
+ nativeBinding = wasiBinding
564
+ } catch (err) {
565
+ if (forceWasi) {
566
+ if (!wasiBindingError) {
567
+ wasiBindingError = err
568
+ } else {
569
+ wasiBindingError.cause = err
570
+ }
571
+ loadErrors.push(err)
572
+ }
573
+ }
574
+ }
575
+ if (process.env.NAPI_RS_FORCE_WASI === 'error' && !wasiBinding) {
576
+ const error = new Error('WASI binding not found and NAPI_RS_FORCE_WASI is set to error')
577
+ error.cause = wasiBindingError
578
+ throw error
579
+ }
580
+ }
581
+
582
+ if (!nativeBinding) {
583
+ if (loadErrors.length > 0) {
584
+ throw new Error(
585
+ `Cannot find native binding. ` +
586
+ `npm has a bug related to optional dependencies (https://github.com/npm/cli/issues/4828). ` +
587
+ 'Please try `npm i` again after removing both package-lock.json and node_modules directory.',
588
+ {
589
+ cause: loadErrors.reduce((err, cur) => {
590
+ cur.cause = err
591
+ return cur
592
+ }),
593
+ },
594
+ )
595
+ }
596
+ throw new Error(`Failed to load native binding`)
597
+ }
598
+
599
+ const { BamlAudio, BamlCallContext, BamlHandle, BamlImage, BamlPdf, BamlRuntime, BamlVideo, Collector, FunctionLog, HostSpanManager, LlmCall, LLMCall, Timing, Usage, _seedFunctionRefHandle, _seedGenericMediaHandle, cancelFunctionCall, completeHostCall, flushEvents, getRuntime, getVersion, mintHostValueKey, newFunctionCall, registerHostCallable, registerHostValueReleaseCallback, releaseHostCallable } = nativeBinding
600
+ export { BamlAudio }
601
+ export { BamlCallContext }
602
+ export { BamlHandle }
603
+ export { BamlImage }
604
+ export { BamlPdf }
605
+ export { BamlRuntime }
606
+ export { BamlVideo }
607
+ export { Collector }
608
+ export { FunctionLog }
609
+ export { HostSpanManager }
610
+ export { LlmCall }
611
+ export { LLMCall }
612
+ export { Timing }
613
+ export { Usage }
614
+ export { _seedFunctionRefHandle }
615
+ export { _seedGenericMediaHandle }
616
+ export { cancelFunctionCall }
617
+ export { completeHostCall }
618
+ export { flushEvents }
619
+ export { getRuntime }
620
+ export { getVersion }
621
+ export { mintHostValueKey }
622
+ export { newFunctionCall }
623
+ export { registerHostCallable }
624
+ export { registerHostValueReleaseCallback }
625
+ export { releaseHostCallable }