edge-intelligence-sdk 0.3.7

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.
@@ -0,0 +1,545 @@
1
+ // This file was autogenerated by some hot garbage in the `uniffi-bindgen-react-native` crate.
2
+ // Trust me, you don't want to mess with it!
3
+ /* tslint:disable */
4
+ /* eslint-disable */
5
+ // @ts-nocheck
6
+ import nativeModule from "./el_ffi-ffi";
7
+ import { type UniffiRustFutureContinuationCallback, type UniffiForeignFutureDroppedCallback, type UniffiForeignFutureDroppedCallbackStruct, type UniffiVTableCallbackInterfaceElFfiStreamHandler,
8
+ } from "./el_ffi-ffi";
9
+ import { type FfiConverter, type UniffiByteArray, type UniffiGcObject, type UniffiHandle, type UniffiObjectFactory, type UniffiReferenceHolder, type UniffiRustCallStatus, AbstractFfiConverterByteArray, FfiConverterCallback, FfiConverterInt32, FfiConverterObject, FfiConverterUInt8, RustBuffer, UniffiAbstractObject, UniffiError, UniffiInternalError, UniffiResult, UniffiRustCaller, destructorGuardSymbol, pointerLiteralSymbol, uniffiCreateFfiConverterString, uniffiTraitInterfaceCall, uniffiTypeNameSymbol, variantOrdinalSymbol,
10
+ } from "@ubjs/core";
11
+ const uniffiCaller = new UniffiRustCaller(() => ({ code: 0 }));
12
+
13
+ const uniffiIsDebug =
14
+ // @ts-ignore -- The process global might not be defined
15
+ typeof process !== "object" ||
16
+ // @ts-ignore -- The process global might not be defined
17
+ process?.env?.NODE_ENV !== "production" ||
18
+ false;
19
+
20
+ // Public interface members begin here.
21
+
22
+ // Hermes (React Native ≥ 0.74) ships TextEncoder and encodeInto, but not
23
+ // TextDecoder. For single-string decode (bytesToString), we polyfill via the
24
+ // C++ string_from_buffer helper using a duck-typed object matching the
25
+ // standard TextDecoder.decode signature. Once Hermes ships a real
26
+ // TextDecoder, the `typeof` check will pick it up automatically.
27
+ //
28
+ // For array-of-strings decode (readStringFromBuffer), we keep a dedicated C++
29
+ // helper: the polyfill path (new Uint8Array view + decode) measured ~40%
30
+ // slower on getStringArray benchmarks than a direct (buf, offset, length)
31
+ // call, due to the per-read view allocation and extra property lookups in
32
+ // string_from_buffer.
33
+ const stringConverter = (() => {
34
+ const encoder = new TextEncoder();
35
+ const decoder: { decode(input: UniffiByteArray): string } =
36
+ typeof TextDecoder !== "undefined"
37
+ ? new TextDecoder()
38
+ : {
39
+ decode: (bytes: UniffiByteArray) =>
40
+ nativeModule().ubrn_uniffi_internal_fn_func_ffi__string_from_buffer(
41
+ bytes,
42
+ undefined as any,
43
+ ) as string,
44
+ };
45
+ return {
46
+ // Single-string lower() uses the C++ helper — TextEncoder.encode
47
+ // measured ~43% slower on takeString benchmarks.
48
+ stringToBytes: (s: string) =>
49
+ nativeModule().ubrn_uniffi_internal_fn_func_ffi__string_to_buffer(s, undefined as any),
50
+ bytesToString: (ab: UniffiByteArray) => decoder.decode(ab),
51
+ // Direct C++ call — bypasses uniffiCaller.rustCall() overhead.
52
+ // Matters for N-element arrays.
53
+ stringByteLength: (s: string) =>
54
+ nativeModule().ubrn_uniffi_internal_fn_func_ffi__string_to_byte_length(s, undefined as any) as number,
55
+ // Encode directly into the RustBuffer backing store via
56
+ // TextEncoder.encodeInto — zero intermediate allocation. Replaces
57
+ // the old C++ write_string_into_buffer helper.
58
+ writeStringIntoBuffer: (s: string, buf: any, offset: number): number => {
59
+ const view = new Uint8Array(
60
+ buf.arrayBuffer,
61
+ offset,
62
+ buf.arrayBuffer.byteLength - offset,
63
+ );
64
+ return encoder.encodeInto(s, view).written;
65
+ },
66
+ // Dedicated C++ helper — avoids per-read Uint8Array allocation and
67
+ // the double property-lookup in string_from_buffer.
68
+ readStringFromBuffer: (buf: any, offset: number, length: number): string =>
69
+ nativeModule().ubrn_uniffi_internal_fn_func_ffi__read_string_from_buffer(buf, offset, length) as string,
70
+ };
71
+ })();
72
+ const FfiConverterString = uniffiCreateFfiConverterString(stringConverter);
73
+
74
+
75
+ // Error type: SdkError
76
+ export enum SdkError_Tags {
77
+ ProviderError = "ProviderError"
78
+ }
79
+ /**
80
+ * Error returned across the FFI boundary.
81
+ *
82
+ * On **native** (non-wasm32): `#[uniffi::Error]` projects this to the host
83
+ * language's exception type (TS `Error`, Kotlin `Exception`, Swift `Error`).
84
+ * On **wasm32**: converted to a JS exception via `JsValue` at the
85
+ * `ask_wasm` call site.
86
+ *
87
+ * Design note: `EdgeError` from el-core is not directly FFI-safe (uses
88
+ * `Box<str>` and Rust-specific variants). `SdkError` is a thin projection.
89
+ */
90
+ export const SdkError = (() => {
91
+
92
+ type ProviderError__interface = {
93
+ tag: SdkError_Tags.ProviderError;
94
+ inner:
95
+ Readonly<{message: string}>
96
+ };
97
+ /**
98
+ * The LLM backend (local Candle or cloud) returned an error.
99
+ */
100
+ class ProviderError_ extends UniffiError implements ProviderError__interface {
101
+ /**
102
+ * @private
103
+ * This field is private and should not be used, use `tag` instead.
104
+ */
105
+ readonly [uniffiTypeNameSymbol] = "SdkError";
106
+ readonly tag = SdkError_Tags.ProviderError;
107
+ readonly inner:
108
+ Readonly<{message: string}>;
109
+ constructor(
110
+ inner: {message: string }) {
111
+ super("SdkError", "ProviderError");
112
+
113
+ this.inner = Object.freeze(inner);
114
+ }
115
+ static new(
116
+ inner: {message: string }): ProviderError_ {
117
+ return new ProviderError_(inner);
118
+ }
119
+
120
+ static instanceOf(obj: any): obj is ProviderError_ {
121
+ return obj.tag === SdkError_Tags.ProviderError;
122
+ }
123
+ static hasInner(obj: any): obj is ProviderError_ {
124
+ return ProviderError_.instanceOf(obj);
125
+ }
126
+
127
+ static getInner(obj: ProviderError_):
128
+ Readonly<{message: string}> {
129
+ return obj.inner;
130
+ }
131
+
132
+ }
133
+
134
+ function instanceOf(obj: any): obj is SdkError {
135
+ return obj[uniffiTypeNameSymbol] === "SdkError";
136
+ }
137
+
138
+ return Object.freeze({
139
+ instanceOf,
140
+ ProviderError: ProviderError_
141
+ });
142
+
143
+ })();
144
+ /**
145
+ * Error returned across the FFI boundary.
146
+ *
147
+ * On **native** (non-wasm32): `#[uniffi::Error]` projects this to the host
148
+ * language's exception type (TS `Error`, Kotlin `Exception`, Swift `Error`).
149
+ * On **wasm32**: converted to a JS exception via `JsValue` at the
150
+ * `ask_wasm` call site.
151
+ *
152
+ * Design note: `EdgeError` from el-core is not directly FFI-safe (uses
153
+ * `Box<str>` and Rust-specific variants). `SdkError` is a thin projection.
154
+ */
155
+ export type SdkError = InstanceType<
156
+ typeof SdkError['ProviderError']
157
+ >;
158
+
159
+ // FfiConverter for enum SdkError
160
+ const FfiConverterTypeSdkError = (() => {
161
+ const ordinalConverter = FfiConverterInt32;
162
+ type TypeName = SdkError;
163
+ class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {
164
+ read(from: RustBuffer): TypeName {
165
+ switch (ordinalConverter.read(from)) {
166
+ case 1: return new SdkError.ProviderError({message: FfiConverterString.read(from) });
167
+ default: throw new UniffiInternalError.UnexpectedEnumCase();
168
+ }
169
+ }
170
+ write(value: TypeName, into: RustBuffer): void {
171
+ switch (value.tag) {
172
+ case SdkError_Tags.ProviderError: {
173
+ ordinalConverter.write(1, into);
174
+ const inner = value.inner;
175
+ FfiConverterString.write(inner.message, into);
176
+ return;
177
+ }
178
+ default:
179
+ // Throwing from here means that SdkError_Tags hasn't matched an ordinal.
180
+ throw new UniffiInternalError.UnexpectedEnumCase();
181
+ }
182
+ }
183
+ allocationSize(value: TypeName): number {
184
+ switch (value.tag) {
185
+ case SdkError_Tags.ProviderError: {
186
+ const inner = value.inner;
187
+ let size = ordinalConverter.allocationSize(1);
188
+ size += FfiConverterString.allocationSize(inner.message);
189
+ return size;
190
+ }
191
+ default: throw new UniffiInternalError.UnexpectedEnumCase();
192
+ }
193
+ }
194
+ }
195
+ return new FFIConverter();
196
+ })();
197
+
198
+
199
+ /**
200
+ * Token-by-token callback for streaming on React Native.
201
+ *
202
+ * Implement on the TS/Kotlin/Swift side and pass to
203
+ * [`EdgeLlm::ask_stream_cb`]. Each call delivers one text fragment; the
204
+ * method returns (and calls nothing more) when generation is complete.
205
+ *
206
+ * Flutter uses the closure-based [`EdgeLlm::ask_stream`] instead.
207
+ */
208
+ export interface StreamHandler {
209
+
210
+ onToken(token: string): void;
211
+ }
212
+
213
+
214
+
215
+ // Put the implementation in a struct so we don't pollute the top-level namespace
216
+ const uniffiCallbackInterfaceStreamHandler: { vtable: any; register: () => void; } = {
217
+ // Create the VTable using a series of closures.
218
+ // ts automatically converts these into C callback functions.
219
+ vtable: {
220
+ on_token: (
221
+ uniffiHandle: bigint,
222
+ token: Uint8Array,) => {
223
+ const uniffiMakeCall =
224
+ ()
225
+ : void => {
226
+ const jsCallback = FfiConverterTypeStreamHandler.lift(uniffiHandle);
227
+ return jsCallback.onToken(
228
+ FfiConverterString.lift(token)
229
+ )
230
+ };
231
+ const uniffiResult = UniffiResult.ready<void>();
232
+ const uniffiHandleSuccess = (obj: any) => {};
233
+ const uniffiHandleError = (code: number, errBuf: UniffiByteArray) => {
234
+ UniffiResult.writeError(uniffiResult, code, errBuf);
235
+ };
236
+ uniffiTraitInterfaceCall(
237
+ /*makeCall:*/ uniffiMakeCall,
238
+ /*handleSuccess:*/ uniffiHandleSuccess,
239
+ /*handleError:*/ uniffiHandleError,
240
+ /*lowerString:*/ FfiConverterString.lower.bind(FfiConverterString),
241
+ /*alloc:*/ nativeModule().rustbuffer_alloc,
242
+ )
243
+ return uniffiResult;
244
+ },
245
+ uniffi_free: (uniffiHandle: UniffiHandle): void => {
246
+ // this will throw a stale handle error if the handle isn't found.
247
+ FfiConverterTypeStreamHandler.drop(uniffiHandle);
248
+ },
249
+ uniffi_clone: (uniffiHandle: UniffiHandle): UniffiHandle => {
250
+ return FfiConverterTypeStreamHandler.clone(uniffiHandle);
251
+ }
252
+ },
253
+ register: () => {nativeModule().ubrn_uniffi_el_ffi_fn_init_callback_vtable_streamhandler(
254
+ uniffiCallbackInterfaceStreamHandler.vtable
255
+ );
256
+ },
257
+ };
258
+
259
+ // FfiConverter protocol for callback interfaces
260
+ const FfiConverterTypeStreamHandler = new FfiConverterCallback<StreamHandler>();
261
+
262
+ /**
263
+ * The flat FFI-friendly facade (ADR-001, ADR-009, ADR-010).
264
+ *
265
+ * Annotated for all three binding surfaces:
266
+ * - `uniffi::Object` (native) → opaque UniFFI / React Native handle
267
+ * - `frb(opaque)` (native) → opaque Flutter/Dart handle via FRB v2
268
+ * - `wasm_bindgen` (wasm32) → satisfies `IntoWasmAbi`/`WasmDescribe` so
269
+ * that `#[wasm_bindgen] impl EdgeLlm { ... }` compiles
270
+ */
271
+ export interface EdgeLlmLike {
272
+
273
+ /**
274
+ * Blocking chat completion.
275
+ *
276
+ * Returns `Err(SdkError::ProviderError)` on network/auth/engine failure
277
+ * so callers can distinguish model output from error conditions.
278
+ */
279
+ ask(prompt: string) /*throws*/: string;
280
+ /**
281
+ * Stream tokens to a [`StreamHandler`] callback (React Native path).
282
+ *
283
+ * Returns an error on network/auth/engine failure so callers are not
284
+ * left waiting for a stream that will never arrive.
285
+ */
286
+ askStreamCb(prompt: string, handler: StreamHandler) /*throws*/: void;
287
+ /**
288
+ * Reset the session (clears KV cache and output).
289
+ */
290
+ reset(): void;
291
+ }
292
+ /**
293
+ * @deprecated Use `EdgeLlmLike` instead.
294
+ */
295
+ export type EdgeLlmInterface = EdgeLlmLike;
296
+
297
+
298
+ /**
299
+ * The flat FFI-friendly facade (ADR-001, ADR-009, ADR-010).
300
+ *
301
+ * Annotated for all three binding surfaces:
302
+ * - `uniffi::Object` (native) → opaque UniFFI / React Native handle
303
+ * - `frb(opaque)` (native) → opaque Flutter/Dart handle via FRB v2
304
+ * - `wasm_bindgen` (wasm32) → satisfies `IntoWasmAbi`/`WasmDescribe` so
305
+ * that `#[wasm_bindgen] impl EdgeLlm { ... }` compiles
306
+ */
307
+ export class EdgeLlm extends UniffiAbstractObject implements EdgeLlmLike {
308
+
309
+ readonly [uniffiTypeNameSymbol] = "EdgeLlm";
310
+ readonly [destructorGuardSymbol]: UniffiGcObject;
311
+ readonly [pointerLiteralSymbol]: UniffiHandle;
312
+ // No primary constructor declared for this class.
313
+ private constructor(pointer: UniffiHandle) {
314
+ super();
315
+ this[pointerLiteralSymbol] = pointer;
316
+ this[destructorGuardSymbol] = uniffiTypeEdgeLlmObjectFactory.bless(pointer);
317
+ }
318
+
319
+
320
+ /**
321
+ * Construct with a frontier cloud backend (opt-in, ADR-010).
322
+ *
323
+ * `model` uses the routing prefix: `"openai/gpt-4o"`,
324
+ * `"anthropic/claude-sonnet-4-6"`, `"ollama/llama3"`,
325
+ * `"gemini/gemini-2.0-flash"`, or any OpenAI-compat base URL.
326
+ * `api_key` must come from the platform keystore — never embedded.
327
+ *
328
+ * **Native only** (React Native / Flutter). On wasm32 this constructor
329
+ * does not exist — the web surface exposes a throwing `cloud` instead
330
+ * (see the wasm32 impl block below and the ADR-010 amendment).
331
+ */
332
+ static cloud(model: string, apiKey: string): EdgeLlmLike {
333
+ return FfiConverterTypeEdgeLlm.lift(uniffiCaller.rustCall(
334
+ /*caller:*/ (callStatus) => {
335
+ return nativeModule().ubrn_uniffi_el_ffi_fn_constructor_edgellm_cloud(
336
+ FfiConverterString.lower(model, nativeModule().rustbuffer_alloc),
337
+ FfiConverterString.lower(apiKey, nativeModule().rustbuffer_alloc),
338
+ callStatus);
339
+ },
340
+ /*liftString:*/ FfiConverterString.lift.bind(FfiConverterString),
341
+ ));
342
+ }
343
+
344
+ /**
345
+ * Construct with the local Candle engine (air-gapped, ADR-002/004).
346
+ *
347
+ * If `model_uri` is non-empty, loads the GGUF at that path via
348
+ * `CandleEngine::from_path` (consumer-supplied model, ADR-002).
349
+ * Pass an empty string to use a deterministic toy model for development
350
+ * and testing — the toy generates gibberish but exercises the full
351
+ * binding layer end-to-end.
352
+ *
353
+ * Returns `Err(SdkError)` if `model_uri` is non-empty but the file
354
+ * cannot be parsed (missing, malformed GGUF, incompatible tensor shapes).
355
+ * An empty `model_uri` never fails.
356
+ *
357
+ * The permissive signature verifier used here is intentional: it lets the
358
+ * binding layer be exercised without a signed model artifact. A production
359
+ * deployment should substitute a real `SignatureVerifier` backed by the
360
+ * platform keystore.
361
+ */
362
+ static local(modelUri: string): EdgeLlmLike /*throws*/ {
363
+ return FfiConverterTypeEdgeLlm.lift(uniffiCaller.rustCallWithError(
364
+ /*liftError:*/ FfiConverterTypeSdkError.lift.bind(FfiConverterTypeSdkError),
365
+ /*caller:*/ (callStatus) => {
366
+ return nativeModule().ubrn_uniffi_el_ffi_fn_constructor_edgellm_local(
367
+ FfiConverterString.lower(modelUri, nativeModule().rustbuffer_alloc),
368
+ callStatus);
369
+ },
370
+ /*liftString:*/ FfiConverterString.lift.bind(FfiConverterString),
371
+ ));
372
+ }
373
+
374
+
375
+
376
+ /**
377
+ * Blocking chat completion.
378
+ *
379
+ * Returns `Err(SdkError::ProviderError)` on network/auth/engine failure
380
+ * so callers can distinguish model output from error conditions.
381
+ */
382
+ ask(prompt: string): string /*throws*/ {
383
+ return ((__rb: Uint8Array) => {
384
+ try {
385
+ return FfiConverterString.lift(__rb);
386
+ } finally {
387
+ nativeModule().rustbuffer_free(__rb);
388
+ }
389
+ })(uniffiCaller.rustCallWithError(
390
+ /*liftError:*/ FfiConverterTypeSdkError.lift.bind(FfiConverterTypeSdkError),
391
+ /*caller:*/ (callStatus) => {
392
+ return nativeModule().ubrn_uniffi_el_ffi_fn_method_edgellm_ask(
393
+ uniffiTypeEdgeLlmObjectFactory.clonePointer(this),
394
+ FfiConverterString.lower(prompt, nativeModule().rustbuffer_alloc),
395
+ callStatus);
396
+ },
397
+ /*liftString:*/ FfiConverterString.lift.bind(FfiConverterString),
398
+ ));
399
+ }
400
+
401
+ /**
402
+ * Stream tokens to a [`StreamHandler`] callback (React Native path).
403
+ *
404
+ * Returns an error on network/auth/engine failure so callers are not
405
+ * left waiting for a stream that will never arrive.
406
+ */
407
+ askStreamCb(prompt: string, handler: StreamHandler): void /*throws*/ {uniffiCaller.rustCallWithError(
408
+ /*liftError:*/ FfiConverterTypeSdkError.lift.bind(FfiConverterTypeSdkError),
409
+ /*caller:*/ (callStatus) => { nativeModule().ubrn_uniffi_el_ffi_fn_method_edgellm_ask_stream_cb(
410
+ uniffiTypeEdgeLlmObjectFactory.clonePointer(this),
411
+ FfiConverterString.lower(prompt, nativeModule().rustbuffer_alloc),
412
+ FfiConverterTypeStreamHandler.lower(handler, nativeModule().rustbuffer_alloc),
413
+ callStatus);
414
+ },
415
+ /*liftString:*/ FfiConverterString.lift.bind(FfiConverterString),
416
+ );
417
+ }
418
+
419
+ /**
420
+ * Reset the session (clears KV cache and output).
421
+ */
422
+ reset(): void {uniffiCaller.rustCall(
423
+ /*caller:*/ (callStatus) => { nativeModule().ubrn_uniffi_el_ffi_fn_method_edgellm_reset(
424
+ uniffiTypeEdgeLlmObjectFactory.clonePointer(this),
425
+ callStatus);
426
+ },
427
+ /*liftString:*/ FfiConverterString.lift.bind(FfiConverterString),
428
+ );
429
+ }
430
+
431
+
432
+ uniffiDestroy(): void {
433
+ const ptr = (this as any)[destructorGuardSymbol];
434
+ if (ptr !== undefined) {
435
+ const pointer = uniffiTypeEdgeLlmObjectFactory.pointer(this);
436
+ uniffiTypeEdgeLlmObjectFactory.freePointer(pointer);
437
+ uniffiTypeEdgeLlmObjectFactory.unbless(ptr);
438
+ delete (this as any)[destructorGuardSymbol];
439
+ }
440
+ }
441
+
442
+ static instanceOf(obj_: any): obj_ is EdgeLlm {
443
+ return uniffiTypeEdgeLlmObjectFactory.isConcreteType(obj_);
444
+ }
445
+
446
+
447
+ }
448
+
449
+ const uniffiTypeEdgeLlmObjectFactory: UniffiObjectFactory<EdgeLlmLike> = (() => {
450
+
451
+ return {
452
+ create(pointer: UniffiHandle): EdgeLlmLike {
453
+ const instance = Object.create(EdgeLlm.prototype);
454
+ instance[pointerLiteralSymbol] = pointer;
455
+ instance[destructorGuardSymbol] = this.bless(pointer);
456
+ instance[uniffiTypeNameSymbol] = "EdgeLlm";
457
+ return instance;
458
+ },
459
+
460
+
461
+ bless(p: UniffiHandle): UniffiGcObject {
462
+ return uniffiCaller.rustCall(
463
+ /*caller:*/ (status) =>
464
+ nativeModule().ubrn_uniffi_internal_fn_method_edgellm_ffi__bless_pointer(p, status),
465
+ /*liftString:*/ FfiConverterString.lift
466
+ );
467
+ },
468
+
469
+ unbless(ptr_: UniffiGcObject) {
470
+ ptr_.markDestroyed();
471
+ },
472
+
473
+ pointer(obj_: EdgeLlmLike): UniffiHandle {
474
+ if ((obj_ as any)[destructorGuardSymbol] === undefined) {
475
+ throw new UniffiInternalError.UnexpectedNullPointer();
476
+ }
477
+ return (obj_ as any)[pointerLiteralSymbol];
478
+ },
479
+
480
+ clonePointer(obj_: EdgeLlmLike): UniffiHandle {
481
+ const pointer = this.pointer(obj_);
482
+ return uniffiCaller.rustCall(
483
+ /*caller:*/ (callStatus) => nativeModule().ubrn_uniffi_el_ffi_fn_clone_edgellm(pointer, callStatus),
484
+ /*liftString:*/ FfiConverterString.lift
485
+ );
486
+ },
487
+
488
+ freePointer(pointer: UniffiHandle): void {
489
+ uniffiCaller.rustCall(
490
+ /*caller:*/ (callStatus) => nativeModule().ubrn_uniffi_el_ffi_fn_free_edgellm(pointer, callStatus),
491
+ /*liftString:*/ FfiConverterString.lift
492
+ );
493
+ },
494
+
495
+ isConcreteType(obj_: any): obj_ is EdgeLlmLike {
496
+ return obj_[destructorGuardSymbol] && obj_[uniffiTypeNameSymbol] === "EdgeLlm";
497
+ },
498
+ }})();
499
+ const FfiConverterTypeEdgeLlm = new FfiConverterObject(uniffiTypeEdgeLlmObjectFactory);
500
+
501
+
502
+ /**
503
+ * This should be called before anything else.
504
+ *
505
+ * It is likely that this is being done for you by the library's `index.ts`.
506
+ *
507
+ * It checks versions of uniffi between when the Rust scaffolding was generated
508
+ * and when the bindings were generated.
509
+ *
510
+ * It also initializes the machinery to enable Rust to talk back to Javascript.
511
+ */
512
+ function uniffiEnsureInitialized() {
513
+ // Get the bindings contract version from our ComponentInterface
514
+ const bindingsContractVersion = 30;
515
+ // Get the scaffolding contract version by calling the into the dylib
516
+ const scaffoldingContractVersion = nativeModule().ubrn_ffi_el_ffi_uniffi_contract_version();
517
+ if (bindingsContractVersion !== scaffoldingContractVersion) {
518
+ throw new UniffiInternalError.ContractVersionMismatch(scaffoldingContractVersion, bindingsContractVersion);
519
+ }
520
+ if (nativeModule().ubrn_uniffi_el_ffi_checksum_constructor_edgellm_cloud() !== 15440) {
521
+ throw new UniffiInternalError.ApiChecksumMismatch("uniffi_el_ffi_checksum_constructor_edgellm_cloud");
522
+ }
523
+ if (nativeModule().ubrn_uniffi_el_ffi_checksum_constructor_edgellm_local() !== 50108) {
524
+ throw new UniffiInternalError.ApiChecksumMismatch("uniffi_el_ffi_checksum_constructor_edgellm_local");
525
+ }
526
+ if (nativeModule().ubrn_uniffi_el_ffi_checksum_method_edgellm_ask() !== 5083) {
527
+ throw new UniffiInternalError.ApiChecksumMismatch("uniffi_el_ffi_checksum_method_edgellm_ask");
528
+ }
529
+ if (nativeModule().ubrn_uniffi_el_ffi_checksum_method_edgellm_ask_stream_cb() !== 532) {
530
+ throw new UniffiInternalError.ApiChecksumMismatch("uniffi_el_ffi_checksum_method_edgellm_ask_stream_cb");
531
+ }
532
+ if (nativeModule().ubrn_uniffi_el_ffi_checksum_method_edgellm_reset() !== 31815) {
533
+ throw new UniffiInternalError.ApiChecksumMismatch("uniffi_el_ffi_checksum_method_edgellm_reset");
534
+ }
535
+
536
+ uniffiCallbackInterfaceStreamHandler.register();
537
+ }
538
+
539
+ export default Object.freeze({
540
+ initialize: uniffiEnsureInitialized,
541
+ converters: {
542
+ FfiConverterTypeEdgeLlm,
543
+ FfiConverterTypeSdkError,
544
+ }
545
+ });
@@ -0,0 +1,68 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+
4
+ /**
5
+ * The flat FFI-friendly facade (ADR-001, ADR-009, ADR-010).
6
+ *
7
+ * Annotated for all three binding surfaces:
8
+ * - `uniffi::Object` (native) → opaque UniFFI / React Native handle
9
+ * - `frb(opaque)` (native) → opaque Flutter/Dart handle via FRB v2
10
+ * - `wasm_bindgen` (wasm32) → satisfies `IntoWasmAbi`/`WasmDescribe` so
11
+ * that `#[wasm_bindgen] impl EdgeLlm { ... }` compiles
12
+ */
13
+ export class EdgeLlm {
14
+ free(): void;
15
+ [Symbol.dispose](): void;
16
+ /**
17
+ * Blocking chat; throws a JS Error on provider failure.
18
+ */
19
+ ask_wasm(prompt: string): string;
20
+ /**
21
+ * Frontier cloud backend is **not yet available on web** (ADR-010):
22
+ * `el-cloud`'s blocking HTTP transport has no wasm implementation, and
23
+ * the synchronous `LlmProvider` trait cannot await the browser's async
24
+ * `fetch`. Always throws so callers fail loudly instead of silently
25
+ * receiving an echo stub. Use a native binding (React Native / Flutter)
26
+ * for cloud access.
27
+ */
28
+ static cloud(_model: string, _api_key: string): EdgeLlm;
29
+ constructor(model_uri: string);
30
+ }
31
+
32
+ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
33
+
34
+ export interface InitOutput {
35
+ readonly memory: WebAssembly.Memory;
36
+ readonly __wbg_edgellm_free: (a: number, b: number) => void;
37
+ readonly edgellm_ask_wasm: (a: number, b: number, c: number) => [number, number, number, number];
38
+ readonly edgellm_cloud: (a: number, b: number, c: number, d: number) => [number, number, number];
39
+ readonly edgellm_new_local: (a: number, b: number) => [number, number, number];
40
+ readonly __wbindgen_externrefs: WebAssembly.Table;
41
+ readonly __wbindgen_malloc: (a: number, b: number) => number;
42
+ readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
43
+ readonly __externref_table_dealloc: (a: number) => void;
44
+ readonly __wbindgen_free: (a: number, b: number, c: number) => void;
45
+ readonly __wbindgen_start: () => void;
46
+ }
47
+
48
+ export type SyncInitInput = BufferSource | WebAssembly.Module;
49
+
50
+ /**
51
+ * Instantiates the given `module`, which can either be bytes or
52
+ * a precompiled `WebAssembly.Module`.
53
+ *
54
+ * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
55
+ *
56
+ * @returns {InitOutput}
57
+ */
58
+ export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
59
+
60
+ /**
61
+ * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
62
+ * for everything else, calls `WebAssembly.instantiate` directly.
63
+ *
64
+ * @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
65
+ *
66
+ * @returns {Promise<InitOutput>}
67
+ */
68
+ export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;