@boundaryml/baml-core-node 0.11.2-nightly.20260604.d

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,22 @@
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_core/cffi/v1/*.proto
6
+ * Build: cd baml_language/crates/bridge_nodejs && pnpm build:debug
7
+ */
8
+ import { HostSpanManager } from './native.js';
9
+ export declare class CtxManager {
10
+ private rt;
11
+ private ctx;
12
+ constructor(rt: unknown);
13
+ get(): HostSpanManager;
14
+ allowReset(): boolean;
15
+ reset(): void;
16
+ cloneContext(): HostSpanManager;
17
+ upsertTags(tags: Record<string, string>): void;
18
+ traceFn<T>(name: string, fn: (...args: unknown[]) => T): (...args: unknown[]) => T;
19
+ traceFnAsync<T>(name: string, fn: (...args: unknown[]) => Promise<T>): (...args: unknown[]) => Promise<T>;
20
+ flush(): void;
21
+ }
22
+ //# sourceMappingURL=ctx_manager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ctx_manager.d.ts","sourceRoot":"","sources":["../typescript_src/ctx_manager.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,eAAe,EAAe,MAAM,aAAa,CAAC;AAG3D,qBAAa,UAAU;IACnB,OAAO,CAAC,EAAE,CAAU;IACpB,OAAO,CAAC,GAAG,CAAqC;gBAEpC,EAAE,EAAE,OAAO;IAavB,GAAG,IAAI,eAAe;IAStB,UAAU,IAAI,OAAO;IAMrB,KAAK,IAAI,IAAI;IAIb,YAAY,IAAI,eAAe;IAK/B,UAAU,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI;IAI9C,OAAO,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,GAAG,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC;IAkBlF,YAAY,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,CAAC,CAAC,CAAC;IAkBzG,KAAK,IAAI,IAAI;CAGhB"}
@@ -0,0 +1,91 @@
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_core/cffi/v1/*.proto
6
+ * Build: cd baml_language/crates/bridge_nodejs && pnpm build:debug
7
+ */
8
+ // ctx_manager.ts — mirrors bridge_python/python_src/baml_py/ctx_manager.py
9
+ // Uses AsyncLocalStorage for async context isolation (Node.js built-in).
10
+ import { AsyncLocalStorage } from 'node:async_hooks';
11
+ import { HostSpanManager, flushEvents } from './native.js';
12
+ import { installFlushOnExit } from './exit_hook.js';
13
+ export class CtxManager {
14
+ rt;
15
+ ctx;
16
+ constructor(rt) {
17
+ this.rt = rt;
18
+ this.ctx = new AsyncLocalStorage();
19
+ // FIXME: Eagerly creates HostSpanManager before the runtime may be fully initialized.
20
+ // Legacy engine/ was also eager (rt.createContextManager() in constructor).
21
+ // bridge_python lazily creates HostSpanManager per-thread on first access.
22
+ // Leaving as-is: get() and reset() already create fresh managers, and the legacy
23
+ // engine/ had the same eager pattern without reported issues.
24
+ this.ctx.enterWith(new HostSpanManager());
25
+ installFlushOnExit();
26
+ }
27
+ get() {
28
+ let mgr = this.ctx.getStore();
29
+ if (!mgr) {
30
+ mgr = new HostSpanManager();
31
+ this.ctx.enterWith(mgr);
32
+ }
33
+ return mgr;
34
+ }
35
+ allowReset() {
36
+ const mgr = this.ctx.getStore();
37
+ if (!mgr)
38
+ return true;
39
+ return mgr.contextDepth() === 0;
40
+ }
41
+ reset() {
42
+ this.ctx.enterWith(new HostSpanManager());
43
+ }
44
+ cloneContext() {
45
+ const mgr = this.get();
46
+ return mgr.deepClone();
47
+ }
48
+ upsertTags(tags) {
49
+ this.get().upsertTags(tags);
50
+ }
51
+ traceFn(name, fn) {
52
+ const self = this;
53
+ return function (...args) {
54
+ const mgr = self.cloneContext();
55
+ const argsObj = {};
56
+ args.forEach((arg, i) => { argsObj[`arg${i}`] = arg; });
57
+ mgr.enter(name, argsObj);
58
+ try {
59
+ const result = self.ctx.run(mgr, () => fn.apply(this, args));
60
+ mgr.exitOk();
61
+ return result;
62
+ }
63
+ catch (e) {
64
+ mgr.exitError(String(e));
65
+ throw e;
66
+ }
67
+ };
68
+ }
69
+ traceFnAsync(name, fn) {
70
+ const self = this;
71
+ return async function (...args) {
72
+ const mgr = self.cloneContext();
73
+ const argsObj = {};
74
+ args.forEach((arg, i) => { argsObj[`arg${i}`] = arg; });
75
+ mgr.enter(name, argsObj);
76
+ try {
77
+ const result = await self.ctx.run(mgr, () => fn.apply(this, args));
78
+ mgr.exitOk();
79
+ return result;
80
+ }
81
+ catch (e) {
82
+ mgr.exitError(String(e));
83
+ throw e;
84
+ }
85
+ };
86
+ }
87
+ flush() {
88
+ flushEvents();
89
+ }
90
+ }
91
+ //# sourceMappingURL=ctx_manager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ctx_manager.js","sourceRoot":"","sources":["../typescript_src/ctx_manager.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,yEAAyE;AAEzE,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC3D,OA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AC,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;gBACnE,GAAG,CAAC,MAAM,EAAE,CAAC;gBACb,OAAO,MAAM,CAAC;YAClB,CAAC;YAAC,OAAO,CAAC,EAAE,CAAC;gBACT,GAAG,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;gBACzB,MAAM,CAAC,CAAC;YACZ,CAAC;QACL,CAAC,CAAC;IACN,CAAC;IAED,KAAK;QACD,WAAW,EAAE,CAAC;IAClB,CAAC;CACJ"}
@@ -0,0 +1,27 @@
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_core/cffi/v1/*.proto
6
+ * Build: cd baml_language/crates/bridge_nodejs && pnpm build:debug
7
+ */
8
+ export type Mode = 'sync' | 'async';
9
+ /** Sentinel for "argument not supplied" so optional kwargs can be skipped. */
10
+ export declare const UNSET: unique symbol;
11
+ /**
12
+ * Factory for a free function or static method binding. Returns a callable
13
+ * that maps positional args to kwargs, encodes, calls the runtime, and decodes.
14
+ * `sync` returns the decoded value; `async` returns a `Promise` of it.
15
+ */
16
+ export declare function defineFunction(bamlFqn: string, mode: Mode, paramNames: readonly string[], requiredPositionalCount?: number): (...args: unknown[]) => unknown;
17
+ /**
18
+ * Receiver-binding factory for instance methods. `paramNames[0]` is always
19
+ * `"self"`. Codegen emits the binding as a class-field initializer
20
+ * `m = defineInstanceFunction(...).bind(this) as () => R;`, so `.bind(self)`
21
+ * captures the instance at construction time; the synthetic `self` param never
22
+ * appears in the surface type.
23
+ */
24
+ export declare function defineInstanceFunction(bamlFqn: string, mode: Mode, paramNames: readonly string[]): {
25
+ bind(self: unknown): (...args: unknown[]) => unknown;
26
+ };
27
+ //# sourceMappingURL=define_function.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"define_function.d.ts","sourceRoot":"","sources":["../typescript_src/define_function.ts"],"names":[],"mappings":"AAgBA,MAAM,MAAM,IAAI,GAAG,MAAM,GAAG,OAAO,CAAC;AAEpC,8EAA8E;AAC9E,eAAO,MAAM,KAAK,EAAE,OAAO,MAA6B,CAAC;AAsBzD;;;;GAIG;AACH,wBAAgB,cAAc,CAC1B,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,IAAI,EACV,UAAU,EAAE,SAAS,MAAM,EAAE,EAC7B,uBAAuB,CAAC,EAAE,MAAM,GACjC,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,CAqBjC;AAED;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAClC,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,IAAI,EACV,UAAU,EAAE,SAAS,MAAM,EAAE,GAC9B;IAAE,IAAI,CAAC,IAAI,EAAE,OAAO,GAAG,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,CAAA;CAAE,CAkC1D"}
@@ -0,0 +1,105 @@
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_core/cffi/v1/*.proto
6
+ * Build: cd baml_language/crates/bridge_nodejs && pnpm build:debug
7
+ */
8
+ // define_function.ts — runtime factories for BAML callables, the Node analog
9
+ // of `define_function` in sdks/python/src/baml_core/__init__.py.
10
+ //
11
+ // Generated SDK code emits, per BAML function:
12
+ // export const f = defineFunction("user.ns.f", "sync", ["a"]) as (a: A) => R;
13
+ // export const f_async = defineFunction("user.ns.f", "async", ["a"]) as (a: A) => Promise<R>;
14
+ // and per instance method (inside the class body):
15
+ // m = defineInstanceFunction("user.ns.C.m", "sync", ["self"]).bind(this) as () => R;
16
+ //
17
+ // The factory captures (fqn, mode, paramNames) by closure; the returned
18
+ // callable zips positional args against paramNames into a kwargs object,
19
+ // encodes it, calls the runtime, and decodes the result.
20
+ import { getRuntime } from './native.js';
21
+ import { encodeCallArgs, decodeCallResult } from './proto.js';
22
+ /** Sentinel for "argument not supplied" so optional kwargs can be skipped. */
23
+ export const UNSET = Symbol('baml.UNSET');
24
+ function buildKwargs(args, paramNames, requiredPositionalCount) {
25
+ const positionalLimit = requiredPositionalCount ?? paramNames.length;
26
+ if (args.length > positionalLimit) {
27
+ throw new TypeError(`got ${args.length} positional arguments but only ${positionalLimit} positional ` +
28
+ `parameter names (${JSON.stringify(paramNames.slice(0, positionalLimit))})`);
29
+ }
30
+ const built = {};
31
+ for (let i = 0; i < args.length && i < paramNames.length; i++) {
32
+ if (args[i] === UNSET)
33
+ continue;
34
+ built[paramNames[i]] = args[i];
35
+ }
36
+ return built;
37
+ }
38
+ /**
39
+ * Factory for a free function or static method binding. Returns a callable
40
+ * that maps positional args to kwargs, encodes, calls the runtime, and decodes.
41
+ * `sync` returns the decoded value; `async` returns a `Promise` of it.
42
+ */
43
+ export function defineFunction(bamlFqn, mode, paramNames, requiredPositionalCount) {
44
+ const names = [...paramNames];
45
+ if (mode === 'sync') {
46
+ return (...args) => {
47
+ const merged = buildKwargs(args, names, requiredPositionalCount);
48
+ const rt = getRuntime();
49
+ const argsProto = encodeCallArgs(merged, /* syncMode */ true);
50
+ const resultBytes = rt.callFunctionSync(bamlFqn, argsProto, null, null, null);
51
+ return decodeCallResult(resultBytes);
52
+ };
53
+ }
54
+ if (mode === 'async') {
55
+ return async (...args) => {
56
+ const merged = buildKwargs(args, names, requiredPositionalCount);
57
+ const rt = getRuntime();
58
+ const argsProto = encodeCallArgs(merged);
59
+ const resultBytes = await rt.callFunction(bamlFqn, argsProto, null, null, null);
60
+ return decodeCallResult(resultBytes);
61
+ };
62
+ }
63
+ throw new Error(`mode must be 'sync' or 'async', got ${JSON.stringify(mode)}`);
64
+ }
65
+ /**
66
+ * Receiver-binding factory for instance methods. `paramNames[0]` is always
67
+ * `"self"`. Codegen emits the binding as a class-field initializer
68
+ * `m = defineInstanceFunction(...).bind(this) as () => R;`, so `.bind(self)`
69
+ * captures the instance at construction time; the synthetic `self` param never
70
+ * appears in the surface type.
71
+ */
72
+ export function defineInstanceFunction(bamlFqn, mode, paramNames) {
73
+ const names = [...paramNames];
74
+ const selfName = names[0] ?? 'self';
75
+ const rest = names.slice(1);
76
+ const makeKwargs = (self, args) => {
77
+ const merged = buildKwargs(args, rest);
78
+ merged[selfName] = self;
79
+ return merged;
80
+ };
81
+ return {
82
+ bind(self) {
83
+ if (mode === 'sync') {
84
+ return (...args) => {
85
+ const merged = makeKwargs(self, args);
86
+ const rt = getRuntime();
87
+ const argsProto = encodeCallArgs(merged, /* syncMode */ true);
88
+ const resultBytes = rt.callFunctionSync(bamlFqn, argsProto, null, null, null);
89
+ return decodeCallResult(resultBytes);
90
+ };
91
+ }
92
+ if (mode === 'async') {
93
+ return async (...args) => {
94
+ const merged = makeKwargs(self, args);
95
+ const rt = getRuntime();
96
+ const argsProto = encodeCallArgs(merged);
97
+ const resultBytes = await rt.callFunction(bamlFqn, argsProto, null, null, null);
98
+ return decodeCallResult(resultBytes);
99
+ };
100
+ }
101
+ throw new Error(`mode must be 'sync' or 'async', got ${JSON.stringify(mode)}`);
102
+ },
103
+ };
104
+ }
105
+ //# sourceMappingURL=define_function.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"define_function.js","sourceRoot":"","sources":["../typescript_src/define_function.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,iEAAiE;AACjE,EAAE;AACF,+CAA+C;AAC/C,gFAAgF;AAChF,gGAAgG;AAChG,mDAAmD;AACnD,uFAAuF;AACvF,EAAE;AACF,wEAAwE;AACxE,yEAAyE;AACzE,yDAAyD;AAEzD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,Y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Error(value, baml_trace=..., class_name=...)`.
4
+ *
5
+ * - `value`: the fully decoded thrown BAML value (a generated class instance
6
+ * when the FQN is mapped, else a plain object / primitive).
7
+ * - `bamlTrace`: the pre-rendered `File "...", line N, in fn` frame strings
8
+ * from the BAML stack.
9
+ * - `className`: the thrown value's BAML FQN when known (e.g.
10
+ * `baml.json.JsonParseError`).
11
+ */
12
+ export interface BamlErrorDetail {
13
+ value?: unknown;
14
+ bamlTrace?: string[];
15
+ className?: string;
16
+ }
17
+ export declare class BamlError extends Error {
18
+ /** The decoded thrown BAML value, or `undefined` for SDK-internal errors. */
19
+ readonly value: unknown;
20
+ /** Pre-rendered BAML stack frames; empty for SDK-internal errors. */
21
+ readonly bamlTrace: string[];
22
+ /** The thrown value's BAML FQN, when known. */
23
+ readonly className: string | undefined;
24
+ constructor(message: string, detail?: BamlErrorDetail);
25
+ }
26
+ export declare class BamlInvalidArgumentError extends BamlError {
27
+ constructor(message: string);
28
+ }
29
+ export declare class BamlClientError extends BamlError {
30
+ constructor(message: string);
31
+ }
32
+ export declare class BamlCancelledError extends BamlError {
33
+ constructor(message: string);
34
+ }
35
+ /**
36
+ * Raised for SDK-setup failures and BAML-runtime panics — the Node analog of
37
+ * `bridge_python`'s `BamlPanic`. The in-call panic path (`decodeCallResult`'s
38
+ * `panic` arm) and the `getRuntime` not-initialized path both surface this,
39
+ * except clean process-exit panics, which exit after flushing telemetry.
40
+ */
41
+ export declare class BamlPanic extends BamlError {
42
+ constructor(message: string, detail?: BamlErrorDetail);
43
+ }
44
+ export declare function wrapNativeError(err: unknown): BamlError;
45
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../typescript_src/errors.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;GAUG;AACH,MAAM,WAAW,eAAe;IAC5B,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,qBAAa,SAAU,SAAQ,KAAK;IAChC,6EAA6E;IAC7E,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB,qEAAqE;IACrE,QAAQ,CAAC,SAAS,EAAE,MAAM,EAAE,CAAC;IAC7B,+CAA+C;IAC/C,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;gBAE3B,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,eAAe;CAOxD;AAED,qBAAa,wBAAyB,SAAQ,SAAS;gBACvC,OAAO,EAAE,MAAM;CAI9B;AAED,qBAAa,eAAgB,SAAQ,SAAS;gBAC9B,OAAO,EAAE,MAAM;CAI9B;AAED,qBAAa,kBAAmB,SAAQ,SAAS;gBACjC,OAAO,EAAE,MAAM;CAI9B;AAED;;;;;GAKG;AACH,qBAAa,SAAU,SAAQ,SAAS;gBACxB,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,eAAe;CAIxD;AAYD,wBAAgB,eAAe,CAAC,GAAG,EAAE,OAAO,GAAG,SAAS,CAOvD"}
package/dist/errors.js ADDED
@@ -0,0 +1,75 @@
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_core/cffi/v1/*.proto
6
+ * Build: cd baml_language/crates/bridge_nodejs && pnpm build:debug
7
+ */
8
+ // errors.ts — mirrors bridge_python/python_src/baml_py/errors.py
9
+ // Error types are encoded as prefixed strings in napi::Error messages.
10
+ // This module provides helpers to identify error types from native errors.
11
+ export class BamlError extends Error {
12
+ /** The decoded thrown BAML value, or `undefined` for SDK-internal errors. */
13
+ value;
14
+ /** Pre-rendered BAML stack frames; empty for SDK-internal errors. */
15
+ bamlTrace;
16
+ /** The thrown value's BAML FQN, when known. */
17
+ className;
18
+ constructor(message, detail) {
19
+ super(message);
20
+ this.name = 'BamlError';
21
+ this.value = detail?.value;
22
+ this.bamlTrace = detail?.bamlTrace ? [...detail.bamlTrace] : [];
23
+ this.className = detail?.className;
24
+ }
25
+ }
26
+ export class BamlInvalidArgumentError extends BamlError {
27
+ constructor(message) {
28
+ super(message);
29
+ this.name = 'BamlInvalidArgumentError';
30
+ }
31
+ }
32
+ export class BamlClientError extends BamlError {
33
+ constructor(message) {
34
+ super(message);
35
+ this.name = 'BamlClientError';
36
+ }
37
+ }
38
+ export class BamlCancelledError extends BamlError {
39
+ constructor(message) {
40
+ super(message);
41
+ this.name = 'BamlCancelledError';
42
+ }
43
+ }
44
+ /**
45
+ * Raised for SDK-setup failures and BAML-runtime panics — the Node analog of
46
+ * `bridge_python`'s `BamlPanic`. The in-call panic path (`decodeCallResult`'s
47
+ * `panic` arm) and the `getRuntime` not-initialized path both surface this,
48
+ * except clean process-exit panics, which exit after flushing telemetry.
49
+ */
50
+ export class BamlPanic extends BamlError {
51
+ constructor(message, detail) {
52
+ super(message, detail);
53
+ this.name = 'BamlPanic';
54
+ }
55
+ }
56
+ // Native errors are encoded as prefixed strings in napi::Error messages, e.g.
57
+ // `BamlError: BamlCancelledError: <detail>`. Match on the exact prefix rather
58
+ // than a substring so a user-supplied message that merely *contains* the words
59
+ // can't be misclassified.
60
+ const PREFIX_MAP = [
61
+ ['BamlError: BamlCancelledError:', BamlCancelledError],
62
+ ['BamlError: BamlInvalidArgumentError:', BamlInvalidArgumentError],
63
+ ['BamlError: BamlClientError:', BamlClientError],
64
+ ];
65
+ export function wrapNativeError(err) {
66
+ if (!(err instanceof Error))
67
+ return new BamlError(String(err));
68
+ const msg = err.message;
69
+ for (const [prefix, Ctor] of PREFIX_MAP) {
70
+ if (msg.startsWith(prefix))
71
+ return new Ctor(msg);
72
+ }
73
+ return new BamlError(msg);
74
+ }
75
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../typesc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ACJ;AAED,8EAA8E;AAC9E,8EAA8E;AAC9E,+EAA+E;AAC/E,0BAA0B;AAC1B,MAAM,UAAU,GAAkD;IAC9D,CAAC,gCAAgC,EAAE,kBAAkB,CAAC;IACtD,CAAC,sCAAsC,EAAE,wBAAwB,CAAC;IAClE,CAAC,6BAA6B,EAAE,eAAe,CAAC;CACnD,CAAC;AAEF,MAAM,UAAU,eAAe,CAAC,GAAY;IACxC,IAAI,CAAC,CAAC,GAAG,YAAY,KAAK,CAAC;QAAE,OAAO,IAAI,SAAS,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;IAC/D,MAAM,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC;IACxB,KAAK,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,IAAI,UAAU,EAAE,CAAC;QACtC,IAAI,GAAG,CAAC,UAAU,CAAC,MAAM,CAAC;YAAE,OAAO,IAAI,IAAI,CAAC,GAAG,CAAC,CAAC;IACrD,CAAC;IACD,OAAO,IAAI,SAAS,CAAC,GAAG,CAAC,CAAC;AAC9B,CAAC"}
@@ -0,0 +1,9 @@
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_core/cffi/v1/*.proto
6
+ * Build: cd baml_language/crates/bridge_nodejs && pnpm build:debug
7
+ */
8
+ export declare function installFlushOnExit(): void;
9
+ //# sourceMappingURL=exit_hook.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exit_hook.d.ts","sourceRoot":"","sources":["../typescript_src/exit_hook.ts"],"names":[],"mappings":"AASA,wBAAgB,kBAAkB,IAAI,IAAI,CAUzC"}
@@ -0,0 +1,27 @@
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_core/cffi/v1/*.proto
6
+ * Build: cd baml_language/crates/bridge_nodejs && pnpm build:debug
7
+ */
8
+ // exit_hook.ts — single-registration helper for flushEvents on process exit.
9
+ // Both index.ts and the CtxManager constructor used to call
10
+ // process.once('exit', …) independently; consolidate to one registration so
11
+ // `process.listenerCount('exit')` increases by exactly one per process.
12
+ import { flushEvents } from './native.js';
13
+ let installed = false;
14
+ export function installFlushOnExit() {
15
+ if (installed)
16
+ return;
17
+ installed = true;
18
+ process.once('exit', () => {
19
+ try {
20
+ flushEvents();
21
+ }
22
+ catch {
23
+ /* ignore */
24
+ }
25
+ });
26
+ }
27
+ //# sourceMappingURL=exit_hook.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exit_hook.js","sourceRoot":"","sources":["../typescript_src/exit_hook.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,4DAA4D;AAC5D,4EAA4E;AAC5E,wEAAwE;AAExE,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,IAAI,SAAS,GAAG,KAAK,CAAC;AAEtB,MAAM,UAAU,kBAAkB;IAC9B,IAAI,SAAS;QAAE,OAAO;IACtB,SAAS,GAAG,IAAI,CAAC;IACjB,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE;QACtB,IAAI,CAAC;YACD,WAAW,EAAE,CAAC;QAClB,CAAC;QAAC,MAAM,CAAC;YACL,YAAY;QAChB,CAAC;IACL,CAAC,CAAC,CAAC;AACP,CAAC"}