blazen 0.1.102 → 0.1.104

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 (3) hide show
  1. package/index.d.ts +354 -2
  2. package/index.js +64 -52
  3. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -75,6 +75,38 @@ export declare class CompletionModel {
75
75
  static bedrock(apiKey: string, region: string, model?: string | undefined | null): CompletionModel
76
76
  /** Get the model ID. */
77
77
  get modelId(): string
78
+ /**
79
+ * Wrap this model with automatic retry on transient failures.
80
+ *
81
+ * ```javascript
82
+ * const model = CompletionModel.openrouter(key);
83
+ * const withRetry = model.withRetry({ maxRetries: 3, initialDelayMs: 1000 });
84
+ * ```
85
+ */
86
+ withRetry(config?: JsRetryConfig | undefined | null): CompletionModel
87
+ /**
88
+ * Wrap this model with an in-memory response cache.
89
+ *
90
+ * Streaming requests are never cached and always delegate directly to the
91
+ * underlying model.
92
+ *
93
+ * ```javascript
94
+ * const cached = model.withCache({ ttlSeconds: 300, maxEntries: 1000 });
95
+ * ```
96
+ */
97
+ withCache(config?: JsCacheConfig | undefined | null): CompletionModel
98
+ /**
99
+ * Create a fallback model that tries multiple providers in order.
100
+ *
101
+ * When the primary provider fails with a transient error (rate limit,
102
+ * timeout, server error) the request is automatically forwarded to the
103
+ * next provider. Non-retryable errors short-circuit immediately.
104
+ *
105
+ * ```javascript
106
+ * const model = CompletionModel.withFallback([modelA, modelB]);
107
+ * ```
108
+ */
109
+ static withFallback(models: Array<CompletionModel>): CompletionModel
78
110
  /**
79
111
  * Perform a chat completion.
80
112
  *
@@ -98,8 +130,8 @@ export declare class CompletionModel {
98
130
  /**
99
131
  * Stream a chat completion.
100
132
  *
101
- * The `onChunk` callback receives each chunk as it arrives, with keys:
102
- * `delta`, `finishReason`, `toolCalls`.
133
+ * The `onChunk` callback receives each chunk as a typed `StreamChunk` with
134
+ * `delta`, `finishReason`, and `toolCalls` fields.
103
135
  *
104
136
  * ```javascript
105
137
  * await model.stream(
@@ -177,6 +209,51 @@ export declare class Context {
177
209
  }
178
210
  export type JsContext = Context
179
211
 
212
+ /**
213
+ * An embedding model that produces vector representations of text.
214
+ *
215
+ * Use the static factory methods to create an instance for your provider:
216
+ *
217
+ * ```javascript
218
+ * const model = EmbeddingModel.openai("sk-...");
219
+ * const response = await model.embed(["Hello", "World"]);
220
+ * console.log(response.embeddings); // [[0.1, ...], [0.3, ...]]
221
+ * ```
222
+ */
223
+ export declare class EmbeddingModel {
224
+ /**
225
+ * Create an `OpenAI` embedding model.
226
+ *
227
+ * Defaults to `text-embedding-3-small` (1536 dimensions).
228
+ */
229
+ static openai(apiKey: string): EmbeddingModel
230
+ /**
231
+ * Create a Together AI embedding model.
232
+ *
233
+ * Defaults to `togethercomputer/m2-bert-80M-8k-retrieval` (768 dimensions).
234
+ */
235
+ static together(apiKey: string): EmbeddingModel
236
+ /**
237
+ * Create a Cohere embedding model.
238
+ *
239
+ * Defaults to `embed-v4.0` (1024 dimensions).
240
+ */
241
+ static cohere(apiKey: string): EmbeddingModel
242
+ /**
243
+ * Create a Fireworks AI embedding model.
244
+ *
245
+ * Defaults to `nomic-ai/nomic-embed-text-v1.5` (768 dimensions).
246
+ */
247
+ static fireworks(apiKey: string): EmbeddingModel
248
+ /** The model identifier. */
249
+ get modelId(): string
250
+ /** The dimensionality of the embedding vectors produced by this model. */
251
+ get dimensions(): number
252
+ /** Embed one or more texts, returning one vector per input text. */
253
+ embed(texts: Array<string>): Promise<JsEmbeddingResponse>
254
+ }
255
+ export type JsEmbeddingModel = EmbeddingModel
256
+
180
257
  /**
181
258
  * A fal.ai compute platform provider with image, video, audio, transcription,
182
259
  * and LLM capabilities.
@@ -225,6 +302,156 @@ export declare class FalProvider {
225
302
  }
226
303
  export type JsFalProvider = FalProvider
227
304
 
305
+ /**
306
+ * An in-memory backend for the memory store.
307
+ *
308
+ * Data lives only as long as the process; nothing is persisted.
309
+ *
310
+ * ```javascript
311
+ * const backend = new InMemoryBackend();
312
+ * const memory = new Memory(embedder, backend);
313
+ * ```
314
+ */
315
+ export declare class InMemoryBackend {
316
+ /** Create a new, empty in-memory backend. */
317
+ constructor()
318
+ }
319
+ export type JsInMemoryBackend = InMemoryBackend
320
+
321
+ /**
322
+ * A JSONL file-backed backend for the memory store.
323
+ *
324
+ * Loads entries from the file on creation, appends new entries, and rewrites
325
+ * on updates/deletes.
326
+ *
327
+ * ```javascript
328
+ * const backend = await JsonlBackend.create("./memory.jsonl");
329
+ * const memory = new Memory(embedder, backend);
330
+ * ```
331
+ */
332
+ export declare class JsonlBackend {
333
+ /**
334
+ * Create a JSONL backend at the given file path.
335
+ *
336
+ * If the file exists, its contents are loaded. Otherwise an empty store
337
+ * is created and the file is written on the first insert.
338
+ */
339
+ static create(path: string): Promise<JsonlBackend>
340
+ }
341
+ export type JsJsonlBackend = JsonlBackend
342
+
343
+ /**
344
+ * A memory store that uses ELID for vector indexing and similarity search.
345
+ *
346
+ * Supports two modes:
347
+ * - **Full mode** (`new Memory(embedder, backend)`): embedding-based search
348
+ * - **Local mode** (`Memory.local(backend)`): text `SimHash` only, no embedder
349
+ *
350
+ * ```javascript
351
+ * import { Memory, EmbeddingModel, InMemoryBackend } from 'blazen';
352
+ *
353
+ * const embedder = EmbeddingModel.openai(key);
354
+ * const memory = new Memory(embedder, new InMemoryBackend());
355
+ *
356
+ * await memory.add("doc1", "Paris is the capital of France");
357
+ * const results = await memory.search("What is France's capital?", 5);
358
+ * console.log(results[0].text);
359
+ * ```
360
+ */
361
+ export declare class Memory {
362
+ /**
363
+ * Create a memory store with an embedding model for full ELID-based search.
364
+ *
365
+ * @param embedder - The embedding model to use for vectorisation.
366
+ * @param backend - An `InMemoryBackend` instance.
367
+ */
368
+ constructor(embedder: EmbeddingModel, backend: InMemoryBackend)
369
+ /** Create a memory store with an embedding model and a `JsonlBackend`. */
370
+ static withJsonl(embedder: EmbeddingModel, backend: JsonlBackend): Memory
371
+ /** Create a memory store with an embedding model and a `ValkeyBackend`. */
372
+ static withValkey(embedder: EmbeddingModel, backend: ValkeyBackend): Memory
373
+ /**
374
+ * Create a memory store in local-only mode (no embedding model) with an `InMemoryBackend`.
375
+ *
376
+ * Only `searchLocal()` is available; `search()` will throw.
377
+ */
378
+ static local(backend: InMemoryBackend): Memory
379
+ /** Create a memory store in local-only mode with a `JsonlBackend`. */
380
+ static localJsonl(backend: JsonlBackend): Memory
381
+ /** Create a memory store in local-only mode with a `ValkeyBackend`. */
382
+ static localValkey(backend: ValkeyBackend): Memory
383
+ /**
384
+ * Add a text entry to the memory store.
385
+ *
386
+ * @param id - A unique identifier for this entry.
387
+ * @param text - The text content to store.
388
+ * @param metadata - Optional arbitrary metadata (will be stored as JSON).
389
+ * @returns The id of the stored entry.
390
+ */
391
+ add(id: string, text: string, metadata?: any | undefined | null): Promise<string>
392
+ /**
393
+ * Add multiple text entries to the memory store in a single batch.
394
+ *
395
+ * @param entries - An array of `{ id, text, metadata? }` objects.
396
+ * @returns The ids of the stored entries.
397
+ */
398
+ addMany(entries: Array<JsAddEntry>): Promise<Array<string>>
399
+ /**
400
+ * Search using a query string with the configured embedding model.
401
+ *
402
+ * Returns up to `limit` results sorted by descending similarity.
403
+ * Requires an embedding model (throws if created with `Memory.local()`).
404
+ *
405
+ * @param query - The search query text.
406
+ * @param limit - Maximum number of results (default: 10).
407
+ */
408
+ search(query: string, limit?: number | undefined | null): Promise<Array<JsMemoryResult>>
409
+ /**
410
+ * Search using only text-level `SimHash` (no embedding model required).
411
+ *
412
+ * This is a cheaper, lower-quality search that works in local-only mode.
413
+ *
414
+ * @param query - The search query text.
415
+ * @param limit - Maximum number of results (default: 10).
416
+ */
417
+ searchLocal(query: string, limit?: number | undefined | null): Promise<Array<JsMemoryResult>>
418
+ /**
419
+ * Retrieve a single entry by id.
420
+ *
421
+ * @param id - The entry identifier.
422
+ * @returns The entry, or `null` if not found.
423
+ */
424
+ get(id: string): Promise<JsMemoryEntry | null>
425
+ /**
426
+ * Delete an entry by id.
427
+ *
428
+ * @param id - The entry identifier.
429
+ * @returns `true` if the entry existed and was deleted.
430
+ */
431
+ delete(id: string): Promise<boolean>
432
+ /** Return the number of entries in the store. */
433
+ count(): Promise<number>
434
+ }
435
+ export type JsMemory = Memory
436
+
437
+ /**
438
+ * A Valkey/Redis-backed backend for the memory store.
439
+ *
440
+ * ```javascript
441
+ * const backend = ValkeyBackend.create("redis://localhost:6379");
442
+ * const memory = new Memory(embedder, backend);
443
+ * ```
444
+ */
445
+ export declare class ValkeyBackend {
446
+ /**
447
+ * Create a Valkey backend connected to the given Redis/Valkey URL.
448
+ *
449
+ * The URL should be in standard Redis format, e.g. `redis://localhost:6379`.
450
+ */
451
+ static create(url: string): ValkeyBackend
452
+ }
453
+ export type JsValkeyBackend = ValkeyBackend
454
+
228
455
  /**
229
456
  * A workflow builder and runner.
230
457
  *
@@ -383,6 +610,48 @@ export interface ChatMessageOptions {
383
610
  parts?: Array<JsContentPart>
384
611
  }
385
612
 
613
+ /**
614
+ * Estimate the total token count for an array of chat messages.
615
+ *
616
+ * Includes per-message overhead (role markers, separators) and assistant
617
+ * priming tokens, matching the overhead model used by `OpenAI`.
618
+ *
619
+ * `contextSize` defaults to 128 000 if not provided.
620
+ *
621
+ * ```javascript
622
+ * const tokens = countMessageTokens([
623
+ * ChatMessage.system("You are helpful."),
624
+ * ChatMessage.user("Hi"),
625
+ * ]);
626
+ * ```
627
+ */
628
+ export declare function countMessageTokens(messages: Array<ChatMessage>, contextSize?: number | undefined | null): number
629
+
630
+ /**
631
+ * Estimate the number of tokens in a text string.
632
+ *
633
+ * Uses a heuristic (3.5 characters per token) that works everywhere without
634
+ * external data files. Good enough for budget checks when exact counts are
635
+ * not critical.
636
+ *
637
+ * `contextSize` defaults to 128 000 if not provided.
638
+ *
639
+ * ```javascript
640
+ * const tokens = estimateTokens("Hello world");
641
+ * ```
642
+ */
643
+ export declare function estimateTokens(text: string, contextSize?: number | undefined | null): number
644
+
645
+ /** An entry to add to the memory store (used by `addMany`). */
646
+ export interface JsAddEntry {
647
+ /** Unique identifier. If empty, one will be generated. */
648
+ id: string
649
+ /** The text content to store. */
650
+ text: string
651
+ /** Optional arbitrary metadata. */
652
+ metadata?: any
653
+ }
654
+
386
655
  /** The result of an agent run. */
387
656
  export interface JsAgentResult {
388
657
  /** The final completion response from the model. */
@@ -427,6 +696,14 @@ export interface JsAudioResult {
427
696
  metadata: any
428
697
  }
429
698
 
699
+ /** Configuration for the `withCache` decorator. */
700
+ export interface JsCacheConfig {
701
+ /** How long a cached response remains valid, in seconds. */
702
+ ttlSeconds?: number
703
+ /** Maximum number of entries to keep in the cache. */
704
+ maxEntries?: number
705
+ }
706
+
430
707
  /** Options for a chat completion request. */
431
708
  export interface JsCompletionOptions {
432
709
  temperature?: number
@@ -494,6 +771,22 @@ export interface JsContentPart {
494
771
  image?: JsImageContent
495
772
  }
496
773
 
774
+ /** The result of an embedding operation. */
775
+ export interface JsEmbeddingResponse {
776
+ /** The embedding vectors (one per input text). */
777
+ embeddings: Array<Array<number>>
778
+ /** The model that produced these embeddings. */
779
+ model: string
780
+ /** Token usage statistics, if available. */
781
+ usage?: JsTokenUsage
782
+ /** Estimated cost in USD, if available. */
783
+ cost?: number
784
+ /** Request timing breakdown, if available. */
785
+ timing?: JsRequestTiming
786
+ /** Provider-specific metadata. */
787
+ metadata: any
788
+ }
789
+
497
790
  /** A single generated 3D model with optional mesh metadata. */
498
791
  export interface JsGenerated3DModel {
499
792
  /** The 3D model media output. */
@@ -661,6 +954,28 @@ export interface JsMediaTypeMap {
661
954
  pdf: string
662
955
  }
663
956
 
957
+ /** A stored entry retrieved from the memory store. */
958
+ export interface JsMemoryEntry {
959
+ /** The entry id. */
960
+ id: string
961
+ /** The original text content. */
962
+ text: string
963
+ /** Arbitrary user metadata. */
964
+ metadata: any
965
+ }
966
+
967
+ /** A search result from the memory store. */
968
+ export interface JsMemoryResult {
969
+ /** The entry id. */
970
+ id: string
971
+ /** The original text content. */
972
+ text: string
973
+ /** Similarity score in 0.0..=1.0 (higher = more similar). */
974
+ score: number
975
+ /** Arbitrary user metadata. */
976
+ metadata: any
977
+ }
978
+
664
979
  /** Request to generate music or sound effects. */
665
980
  export interface JsMusicRequest {
666
981
  /** Text prompt describing the desired audio. */
@@ -680,6 +995,16 @@ export interface JsRequestTiming {
680
995
  totalMs?: number
681
996
  }
682
997
 
998
+ /** Configuration for the `withRetry` decorator. */
999
+ export interface JsRetryConfig {
1000
+ /** Maximum number of retry attempts (total calls = `maxRetries + 1`). */
1001
+ maxRetries?: number
1002
+ /** Delay before the first retry, in milliseconds. */
1003
+ initialDelayMs?: number
1004
+ /** Upper bound on the computed backoff delay, in milliseconds. */
1005
+ maxDelayMs?: number
1006
+ }
1007
+
683
1008
  /** The role of a participant in a chat conversation. */
684
1009
  export declare const enum JsRole {
685
1010
  System = 'system',
@@ -706,6 +1031,33 @@ export interface JsSpeechRequest {
706
1031
  parameters?: any
707
1032
  }
708
1033
 
1034
+ /**
1035
+ * A single chunk from a streaming completion response.
1036
+ *
1037
+ * Passed to the `onChunk` callback during streaming operations.
1038
+ *
1039
+ * ```javascript
1040
+ * await model.stream(
1041
+ * [ChatMessage.user("Tell me a story")],
1042
+ * (chunk) => {
1043
+ * if (chunk.delta) process.stdout.write(chunk.delta);
1044
+ * if (chunk.finishReason) console.log("done:", chunk.finishReason);
1045
+ * }
1046
+ * );
1047
+ * ```
1048
+ */
1049
+ export interface JsStreamChunk {
1050
+ /** Incremental text content, if any. */
1051
+ delta?: string
1052
+ /**
1053
+ * The reason the model stopped generating (`"stop"`, `"tool_use"`, etc.).
1054
+ * Present only in the final chunk.
1055
+ */
1056
+ finishReason?: string
1057
+ /** Tool invocations completed in this chunk. */
1058
+ toolCalls: Array<JsToolCall>
1059
+ }
1060
+
709
1061
  /** Request to generate a 3D model. */
710
1062
  export interface JsThreeDRequest {
711
1063
  /** Text prompt describing the desired 3D model. */
package/index.js CHANGED
@@ -77,8 +77,8 @@ function requireNative() {
77
77
  try {
78
78
  const binding = require('blazen-android-arm64')
79
79
  const bindingPackageVersion = require('blazen-android-arm64/package.json').version
80
- if (bindingPackageVersion !== '0.1.102' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
81
- throw new Error(`Native binding package version mismatch, expected 0.1.102 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
80
+ if (bindingPackageVersion !== '0.1.104' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
81
+ throw new Error(`Native binding package version mismatch, expected 0.1.104 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
82
82
  }
83
83
  return binding
84
84
  } catch (e) {
@@ -93,8 +93,8 @@ function requireNative() {
93
93
  try {
94
94
  const binding = require('blazen-android-arm-eabi')
95
95
  const bindingPackageVersion = require('blazen-android-arm-eabi/package.json').version
96
- if (bindingPackageVersion !== '0.1.102' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
97
- throw new Error(`Native binding package version mismatch, expected 0.1.102 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
96
+ if (bindingPackageVersion !== '0.1.104' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
97
+ throw new Error(`Native binding package version mismatch, expected 0.1.104 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
98
98
  }
99
99
  return binding
100
100
  } catch (e) {
@@ -114,8 +114,8 @@ function requireNative() {
114
114
  try {
115
115
  const binding = require('blazen-win32-x64-gnu')
116
116
  const bindingPackageVersion = require('blazen-win32-x64-gnu/package.json').version
117
- if (bindingPackageVersion !== '0.1.102' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
118
- throw new Error(`Native binding package version mismatch, expected 0.1.102 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
117
+ if (bindingPackageVersion !== '0.1.104' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
118
+ throw new Error(`Native binding package version mismatch, expected 0.1.104 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
119
119
  }
120
120
  return binding
121
121
  } catch (e) {
@@ -130,8 +130,8 @@ function requireNative() {
130
130
  try {
131
131
  const binding = require('blazen-win32-x64-msvc')
132
132
  const bindingPackageVersion = require('blazen-win32-x64-msvc/package.json').version
133
- if (bindingPackageVersion !== '0.1.102' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
134
- throw new Error(`Native binding package version mismatch, expected 0.1.102 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
133
+ if (bindingPackageVersion !== '0.1.104' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
134
+ throw new Error(`Native binding package version mismatch, expected 0.1.104 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
135
135
  }
136
136
  return binding
137
137
  } catch (e) {
@@ -147,8 +147,8 @@ function requireNative() {
147
147
  try {
148
148
  const binding = require('blazen-win32-ia32-msvc')
149
149
  const bindingPackageVersion = require('blazen-win32-ia32-msvc/package.json').version
150
- if (bindingPackageVersion !== '0.1.102' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
151
- throw new Error(`Native binding package version mismatch, expected 0.1.102 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
150
+ if (bindingPackageVersion !== '0.1.104' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
151
+ throw new Error(`Native binding package version mismatch, expected 0.1.104 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
152
152
  }
153
153
  return binding
154
154
  } catch (e) {
@@ -163,8 +163,8 @@ function requireNative() {
163
163
  try {
164
164
  const binding = require('blazen-win32-arm64-msvc')
165
165
  const bindingPackageVersion = require('blazen-win32-arm64-msvc/package.json').version
166
- if (bindingPackageVersion !== '0.1.102' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
167
- throw new Error(`Native binding package version mismatch, expected 0.1.102 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
166
+ if (bindingPackageVersion !== '0.1.104' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
167
+ throw new Error(`Native binding package version mismatch, expected 0.1.104 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
168
168
  }
169
169
  return binding
170
170
  } catch (e) {
@@ -182,8 +182,8 @@ function requireNative() {
182
182
  try {
183
183
  const binding = require('blazen-darwin-universal')
184
184
  const bindingPackageVersion = require('blazen-darwin-universal/package.json').version
185
- if (bindingPackageVersion !== '0.1.102' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
186
- throw new Error(`Native binding package version mismatch, expected 0.1.102 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
185
+ if (bindingPackageVersion !== '0.1.104' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
186
+ throw new Error(`Native binding package version mismatch, expected 0.1.104 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
187
187
  }
188
188
  return binding
189
189
  } catch (e) {
@@ -198,8 +198,8 @@ function requireNative() {
198
198
  try {
199
199
  const binding = require('blazen-darwin-x64')
200
200
  const bindingPackageVersion = require('blazen-darwin-x64/package.json').version
201
- if (bindingPackageVersion !== '0.1.102' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
202
- throw new Error(`Native binding package version mismatch, expected 0.1.102 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
201
+ if (bindingPackageVersion !== '0.1.104' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
202
+ throw new Error(`Native binding package version mismatch, expected 0.1.104 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
203
203
  }
204
204
  return binding
205
205
  } catch (e) {
@@ -214,8 +214,8 @@ function requireNative() {
214
214
  try {
215
215
  const binding = require('blazen-darwin-arm64')
216
216
  const bindingPackageVersion = require('blazen-darwin-arm64/package.json').version
217
- if (bindingPackageVersion !== '0.1.102' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
218
- throw new Error(`Native binding package version mismatch, expected 0.1.102 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
217
+ if (bindingPackageVersion !== '0.1.104' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
218
+ throw new Error(`Native binding package version mismatch, expected 0.1.104 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
219
219
  }
220
220
  return binding
221
221
  } catch (e) {
@@ -234,8 +234,8 @@ function requireNative() {
234
234
  try {
235
235
  const binding = require('blazen-freebsd-x64')
236
236
  const bindingPackageVersion = require('blazen-freebsd-x64/package.json').version
237
- if (bindingPackageVersion !== '0.1.102' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
238
- throw new Error(`Native binding package version mismatch, expected 0.1.102 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
237
+ if (bindingPackageVersion !== '0.1.104' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
238
+ throw new Error(`Native binding package version mismatch, expected 0.1.104 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
239
239
  }
240
240
  return binding
241
241
  } catch (e) {
@@ -250,8 +250,8 @@ function requireNative() {
250
250
  try {
251
251
  const binding = require('blazen-freebsd-arm64')
252
252
  const bindingPackageVersion = require('blazen-freebsd-arm64/package.json').version
253
- if (bindingPackageVersion !== '0.1.102' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
254
- throw new Error(`Native binding package version mismatch, expected 0.1.102 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
253
+ if (bindingPackageVersion !== '0.1.104' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
254
+ throw new Error(`Native binding package version mismatch, expected 0.1.104 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
255
255
  }
256
256
  return binding
257
257
  } catch (e) {
@@ -271,8 +271,8 @@ function requireNative() {
271
271
  try {
272
272
  const binding = require('blazen-linux-x64-musl')
273
273
  const bindingPackageVersion = require('blazen-linux-x64-musl/package.json').version
274
- if (bindingPackageVersion !== '0.1.102' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
275
- throw new Error(`Native binding package version mismatch, expected 0.1.102 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
274
+ if (bindingPackageVersion !== '0.1.104' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
275
+ throw new Error(`Native binding package version mismatch, expected 0.1.104 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
276
276
  }
277
277
  return binding
278
278
  } catch (e) {
@@ -287,8 +287,8 @@ function requireNative() {
287
287
  try {
288
288
  const binding = require('blazen-linux-x64-gnu')
289
289
  const bindingPackageVersion = require('blazen-linux-x64-gnu/package.json').version
290
- if (bindingPackageVersion !== '0.1.102' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
291
- throw new Error(`Native binding package version mismatch, expected 0.1.102 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
290
+ if (bindingPackageVersion !== '0.1.104' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
291
+ throw new Error(`Native binding package version mismatch, expected 0.1.104 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
292
292
  }
293
293
  return binding
294
294
  } catch (e) {
@@ -305,8 +305,8 @@ function requireNative() {
305
305
  try {
306
306
  const binding = require('blazen-linux-arm64-musl')
307
307
  const bindingPackageVersion = require('blazen-linux-arm64-musl/package.json').version
308
- if (bindingPackageVersion !== '0.1.102' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
309
- throw new Error(`Native binding package version mismatch, expected 0.1.102 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
308
+ if (bindingPackageVersion !== '0.1.104' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
309
+ throw new Error(`Native binding package version mismatch, expected 0.1.104 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
310
310
  }
311
311
  return binding
312
312
  } catch (e) {
@@ -321,8 +321,8 @@ function requireNative() {
321
321
  try {
322
322
  const binding = require('blazen-linux-arm64-gnu')
323
323
  const bindingPackageVersion = require('blazen-linux-arm64-gnu/package.json').version
324
- if (bindingPackageVersion !== '0.1.102' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
325
- throw new Error(`Native binding package version mismatch, expected 0.1.102 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
324
+ if (bindingPackageVersion !== '0.1.104' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
325
+ throw new Error(`Native binding package version mismatch, expected 0.1.104 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
326
326
  }
327
327
  return binding
328
328
  } catch (e) {
@@ -339,8 +339,8 @@ function requireNative() {
339
339
  try {
340
340
  const binding = require('blazen-linux-arm-musleabihf')
341
341
  const bindingPackageVersion = require('blazen-linux-arm-musleabihf/package.json').version
342
- if (bindingPackageVersion !== '0.1.102' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
343
- throw new Error(`Native binding package version mismatch, expected 0.1.102 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
342
+ if (bindingPackageVersion !== '0.1.104' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
343
+ throw new Error(`Native binding package version mismatch, expected 0.1.104 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
344
344
  }
345
345
  return binding
346
346
  } catch (e) {
@@ -355,8 +355,8 @@ function requireNative() {
355
355
  try {
356
356
  const binding = require('blazen-linux-arm-gnueabihf')
357
357
  const bindingPackageVersion = require('blazen-linux-arm-gnueabihf/package.json').version
358
- if (bindingPackageVersion !== '0.1.102' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
359
- throw new Error(`Native binding package version mismatch, expected 0.1.102 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
358
+ if (bindingPackageVersion !== '0.1.104' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
359
+ throw new Error(`Native binding package version mismatch, expected 0.1.104 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
360
360
  }
361
361
  return binding
362
362
  } catch (e) {
@@ -373,8 +373,8 @@ function requireNative() {
373
373
  try {
374
374
  const binding = require('blazen-linux-loong64-musl')
375
375
  const bindingPackageVersion = require('blazen-linux-loong64-musl/package.json').version
376
- if (bindingPackageVersion !== '0.1.102' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
377
- throw new Error(`Native binding package version mismatch, expected 0.1.102 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
376
+ if (bindingPackageVersion !== '0.1.104' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
377
+ throw new Error(`Native binding package version mismatch, expected 0.1.104 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
378
378
  }
379
379
  return binding
380
380
  } catch (e) {
@@ -389,8 +389,8 @@ function requireNative() {
389
389
  try {
390
390
  const binding = require('blazen-linux-loong64-gnu')
391
391
  const bindingPackageVersion = require('blazen-linux-loong64-gnu/package.json').version
392
- if (bindingPackageVersion !== '0.1.102' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
393
- throw new Error(`Native binding package version mismatch, expected 0.1.102 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
392
+ if (bindingPackageVersion !== '0.1.104' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
393
+ throw new Error(`Native binding package version mismatch, expected 0.1.104 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
394
394
  }
395
395
  return binding
396
396
  } catch (e) {
@@ -407,8 +407,8 @@ function requireNative() {
407
407
  try {
408
408
  const binding = require('blazen-linux-riscv64-musl')
409
409
  const bindingPackageVersion = require('blazen-linux-riscv64-musl/package.json').version
410
- if (bindingPackageVersion !== '0.1.102' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
411
- throw new Error(`Native binding package version mismatch, expected 0.1.102 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
410
+ if (bindingPackageVersion !== '0.1.104' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
411
+ throw new Error(`Native binding package version mismatch, expected 0.1.104 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
412
412
  }
413
413
  return binding
414
414
  } catch (e) {
@@ -423,8 +423,8 @@ function requireNative() {
423
423
  try {
424
424
  const binding = require('blazen-linux-riscv64-gnu')
425
425
  const bindingPackageVersion = require('blazen-linux-riscv64-gnu/package.json').version
426
- if (bindingPackageVersion !== '0.1.102' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
427
- throw new Error(`Native binding package version mismatch, expected 0.1.102 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
426
+ if (bindingPackageVersion !== '0.1.104' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
427
+ throw new Error(`Native binding package version mismatch, expected 0.1.104 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
428
428
  }
429
429
  return binding
430
430
  } catch (e) {
@@ -440,8 +440,8 @@ function requireNative() {
440
440
  try {
441
441
  const binding = require('blazen-linux-ppc64-gnu')
442
442
  const bindingPackageVersion = require('blazen-linux-ppc64-gnu/package.json').version
443
- if (bindingPackageVersion !== '0.1.102' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
444
- throw new Error(`Native binding package version mismatch, expected 0.1.102 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
443
+ if (bindingPackageVersion !== '0.1.104' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
444
+ throw new Error(`Native binding package version mismatch, expected 0.1.104 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
445
445
  }
446
446
  return binding
447
447
  } catch (e) {
@@ -456,8 +456,8 @@ function requireNative() {
456
456
  try {
457
457
  const binding = require('blazen-linux-s390x-gnu')
458
458
  const bindingPackageVersion = require('blazen-linux-s390x-gnu/package.json').version
459
- if (bindingPackageVersion !== '0.1.102' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
460
- throw new Error(`Native binding package version mismatch, expected 0.1.102 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
459
+ if (bindingPackageVersion !== '0.1.104' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
460
+ throw new Error(`Native binding package version mismatch, expected 0.1.104 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
461
461
  }
462
462
  return binding
463
463
  } catch (e) {
@@ -476,8 +476,8 @@ function requireNative() {
476
476
  try {
477
477
  const binding = require('blazen-openharmony-arm64')
478
478
  const bindingPackageVersion = require('blazen-openharmony-arm64/package.json').version
479
- if (bindingPackageVersion !== '0.1.102' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
480
- throw new Error(`Native binding package version mismatch, expected 0.1.102 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
479
+ if (bindingPackageVersion !== '0.1.104' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
480
+ throw new Error(`Native binding package version mismatch, expected 0.1.104 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
481
481
  }
482
482
  return binding
483
483
  } catch (e) {
@@ -492,8 +492,8 @@ function requireNative() {
492
492
  try {
493
493
  const binding = require('blazen-openharmony-x64')
494
494
  const bindingPackageVersion = require('blazen-openharmony-x64/package.json').version
495
- if (bindingPackageVersion !== '0.1.102' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
496
- throw new Error(`Native binding package version mismatch, expected 0.1.102 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
495
+ if (bindingPackageVersion !== '0.1.104' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
496
+ throw new Error(`Native binding package version mismatch, expected 0.1.104 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
497
497
  }
498
498
  return binding
499
499
  } catch (e) {
@@ -508,8 +508,8 @@ function requireNative() {
508
508
  try {
509
509
  const binding = require('blazen-openharmony-arm')
510
510
  const bindingPackageVersion = require('blazen-openharmony-arm/package.json').version
511
- if (bindingPackageVersion !== '0.1.102' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
512
- throw new Error(`Native binding package version mismatch, expected 0.1.102 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
511
+ if (bindingPackageVersion !== '0.1.104' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
512
+ throw new Error(`Native binding package version mismatch, expected 0.1.104 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
513
513
  }
514
514
  return binding
515
515
  } catch (e) {
@@ -582,12 +582,24 @@ module.exports.CompletionModel = nativeBinding.CompletionModel
582
582
  module.exports.JsCompletionModel = nativeBinding.JsCompletionModel
583
583
  module.exports.Context = nativeBinding.Context
584
584
  module.exports.JsContext = nativeBinding.JsContext
585
+ module.exports.EmbeddingModel = nativeBinding.EmbeddingModel
586
+ module.exports.JsEmbeddingModel = nativeBinding.JsEmbeddingModel
585
587
  module.exports.FalProvider = nativeBinding.FalProvider
586
588
  module.exports.JsFalProvider = nativeBinding.JsFalProvider
589
+ module.exports.InMemoryBackend = nativeBinding.InMemoryBackend
590
+ module.exports.JsInMemoryBackend = nativeBinding.JsInMemoryBackend
591
+ module.exports.JsonlBackend = nativeBinding.JsonlBackend
592
+ module.exports.JsJsonlBackend = nativeBinding.JsJsonlBackend
593
+ module.exports.Memory = nativeBinding.Memory
594
+ module.exports.JsMemory = nativeBinding.JsMemory
595
+ module.exports.ValkeyBackend = nativeBinding.ValkeyBackend
596
+ module.exports.JsValkeyBackend = nativeBinding.JsValkeyBackend
587
597
  module.exports.Workflow = nativeBinding.Workflow
588
598
  module.exports.JsWorkflow = nativeBinding.JsWorkflow
589
599
  module.exports.WorkflowHandler = nativeBinding.WorkflowHandler
590
600
  module.exports.JsWorkflowHandler = nativeBinding.JsWorkflowHandler
601
+ module.exports.countMessageTokens = nativeBinding.countMessageTokens
602
+ module.exports.estimateTokens = nativeBinding.estimateTokens
591
603
  module.exports.JsJobStatus = nativeBinding.JsJobStatus
592
604
  module.exports.JsRole = nativeBinding.JsRole
593
605
  module.exports.mediaTypes = nativeBinding.mediaTypes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "blazen",
3
- "version": "0.1.102",
3
+ "version": "0.1.104",
4
4
  "description": "Blazen - Event-driven AI workflow framework for Node.js/TypeScript",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",