blazen 0.1.97 → 0.1.99

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 (4) hide show
  1. package/README.md +97 -26
  2. package/index.d.ts +657 -20
  3. package/index.js +60 -52
  4. package/package.json +3 -2
package/README.md CHANGED
@@ -130,22 +130,55 @@ console.log(result.data); // { status: "done" }
130
130
 
131
131
  ## LLM Integration
132
132
 
133
- `CompletionModel` provides a unified interface to 15 LLM providers. Create a model instance with a static factory method and call `complete()` or `completeWithOptions()`.
133
+ `CompletionModel` provides a unified interface to 15 LLM providers. Create a model instance with a static factory method and call `complete()` or `completeWithOptions()`. All messages and responses are fully typed.
134
+
135
+ ### ChatMessage and Role
136
+
137
+ Build messages with the `ChatMessage` class and `Role` enum:
134
138
 
135
139
  ```typescript
136
- import { CompletionModel } from "blazen";
140
+ import { CompletionModel, ChatMessage, Role } from "blazen";
141
+ import type { CompletionResponse, ToolCall, TokenUsage } from "blazen";
137
142
 
138
143
  const model = CompletionModel.openrouter(process.env.OPENROUTER_API_KEY!);
139
144
 
140
- const response = await model.complete([
141
- { role: "system", content: "You are helpful." },
142
- { role: "user", content: "What is 2+2?" },
145
+ // Using static factory methods (recommended)
146
+ const response: CompletionResponse = await model.complete([
147
+ ChatMessage.system("You are helpful."),
148
+ ChatMessage.user("What is 2+2?"),
143
149
  ]);
144
150
 
145
- console.log(response.content); // "4"
146
- console.log(response.model); // model name used
147
- console.log(response.usage); // { promptTokens, completionTokens, totalTokens }
148
- console.log(response.finishReason);
151
+ console.log(response.content); // "4"
152
+ console.log(response.model); // model name used
153
+ console.log(response.usage); // TokenUsage: { promptTokens, completionTokens, totalTokens }
154
+ console.log(response.finishReason); // "stop", "tool_calls", etc.
155
+ console.log(response.toolCalls); // ToolCall[] | undefined
156
+ ```
157
+
158
+ You can also construct messages with the `ChatMessage` constructor:
159
+
160
+ ```typescript
161
+ const msg = new ChatMessage({ role: Role.User, content: "Hello" });
162
+ ```
163
+
164
+ ### Multimodal Messages
165
+
166
+ Send images alongside text using multimodal factory methods:
167
+
168
+ ```typescript
169
+ // Image from URL
170
+ const msg = ChatMessage.userImageUrl("https://example.com/photo.jpg", "What's in this image?");
171
+
172
+ // Image from base64
173
+ const msg = ChatMessage.userImageBase64(base64Data, "image/png", "Describe this.");
174
+
175
+ // Multiple content parts
176
+ import type { ContentPart } from "blazen";
177
+ const msg = ChatMessage.userParts([
178
+ { type: "text", text: "Compare these two images:" },
179
+ { type: "image_url", imageUrl: { url: "https://example.com/a.jpg" } },
180
+ { type: "image_url", imageUrl: { url: "https://example.com/b.jpg" } },
181
+ ]);
149
182
  ```
150
183
 
151
184
  ### Advanced Options
@@ -153,18 +186,22 @@ console.log(response.finishReason);
153
186
  Use `completeWithOptions` to control temperature, token limits, model selection, and tool definitions:
154
187
 
155
188
  ```typescript
189
+ import type { CompletionOptions } from "blazen";
190
+
191
+ const options: CompletionOptions = {
192
+ temperature: 0.9,
193
+ maxTokens: 256,
194
+ topP: 0.95,
195
+ model: "anthropic/claude-sonnet-4-20250514",
196
+ tools: [/* tool definitions */],
197
+ };
198
+
156
199
  const response = await model.completeWithOptions(
157
200
  [
158
- { role: "system", content: "You are a creative writer." },
159
- { role: "user", content: "Write a haiku about Rust." },
201
+ ChatMessage.system("You are a creative writer."),
202
+ ChatMessage.user("Write a haiku about Rust."),
160
203
  ],
161
- {
162
- temperature: 0.9,
163
- maxTokens: 256,
164
- topP: 0.95,
165
- model: "anthropic/claude-sonnet-4-20250514",
166
- tools: [/* tool definitions */],
167
- }
204
+ options,
168
205
  );
169
206
  ```
170
207
 
@@ -191,7 +228,7 @@ const response = await model.completeWithOptions(
191
228
  ### Using LLMs Inside Workflows
192
229
 
193
230
  ```typescript
194
- import { Workflow, CompletionModel } from "blazen";
231
+ import { Workflow, CompletionModel, ChatMessage } from "blazen";
195
232
 
196
233
  const model = CompletionModel.openai(process.env.OPENAI_API_KEY!);
197
234
 
@@ -199,8 +236,8 @@ const wf = new Workflow("llm-workflow");
199
236
 
200
237
  wf.addStep("ask", ["blazen::StartEvent"], async (event, ctx) => {
201
238
  const response = await model.complete([
202
- { role: "system", content: "You are a helpful assistant." },
203
- { role: "user", content: event.question },
239
+ ChatMessage.system("You are a helpful assistant."),
240
+ ChatMessage.user(event.question),
204
241
  ]);
205
242
  return { type: "blazen::StopEvent", result: { answer: response.content } };
206
243
  });
@@ -353,6 +390,12 @@ await ctx.set("key", { any: "value" });
353
390
  // Retrieve a stored value (returns null if not found)
354
391
  const value = await ctx.get("key");
355
392
 
393
+ // Store raw binary data (no serialization requirement)
394
+ await ctx.setBytes("model-weights", buffer);
395
+
396
+ // Retrieve raw binary data (returns null if not found)
397
+ const data: Buffer | null = await ctx.getBytes("model-weights");
398
+
356
399
  // Send an event through the internal step registry
357
400
  await ctx.sendEvent({ type: "MyEvent", data: "..." });
358
401
 
@@ -363,6 +406,19 @@ await ctx.writeEventToStream({ type: "Progress", percent: 50 });
363
406
  const runId = await ctx.runId();
364
407
  ```
365
408
 
409
+ ### Binary Storage
410
+
411
+ `setBytes` / `getBytes` let you store raw binary data in the context with no serialization requirement. Store any type by converting to bytes yourself (e.g., MessagePack, protobuf, or raw buffers). Binary data persists through pause/resume/checkpoint.
412
+
413
+ ```typescript
414
+ // Store a raw buffer
415
+ const pixels = Buffer.from([0xff, 0x00, 0x00, 0xff]);
416
+ await ctx.setBytes("image-pixels", pixels);
417
+
418
+ // Retrieve it later in another step
419
+ const restored = await ctx.getBytes("image-pixels");
420
+ ```
421
+
366
422
  ---
367
423
 
368
424
  ## Timeout
@@ -381,8 +437,14 @@ wf.setTimeout(60); // 60 second timeout
381
437
  Full TypeScript type definitions ship with the package -- no `@types` needed. All classes and interfaces are exported.
382
438
 
383
439
  ```typescript
384
- import { Workflow, WorkflowHandler, Context, CompletionModel, version } from "blazen";
385
- import type { JsWorkflowResult } from "blazen";
440
+ import {
441
+ Workflow, WorkflowHandler, Context, CompletionModel,
442
+ ChatMessage, Role, version,
443
+ } from "blazen";
444
+ import type {
445
+ JsWorkflowResult, CompletionResponse, CompletionOptions,
446
+ ToolCall, TokenUsage, ContentPart, ImageContent, ImageSource,
447
+ } from "blazen";
386
448
  ```
387
449
 
388
450
  ---
@@ -403,15 +465,24 @@ import type { JsWorkflowResult } from "blazen";
403
465
  | `WorkflowHandler.pause()` | Pause and get a serialized snapshot string |
404
466
  | `WorkflowHandler.streamEvents(callback)` | Subscribe to intermediate stream events |
405
467
  | `Context` | Per-run shared state, event routing, and stream output |
406
- | `Context.set(key, value)` | Store a value (async) |
468
+ | `Context.set(key, value)` | Store a JSON-serializable value (async) |
407
469
  | `Context.get(key)` | Retrieve a value (async, returns null if missing) |
470
+ | `Context.setBytes(key, buffer)` | Store raw binary data (async) |
471
+ | `Context.getBytes(key)` | Retrieve raw binary data (async, returns null if missing) |
408
472
  | `Context.sendEvent(event)` | Route an event to matching steps (async) |
409
473
  | `Context.writeEventToStream(event)` | Publish to external stream consumers (async) |
410
474
  | `Context.runId()` | Get the workflow run ID (async) |
411
475
  | `CompletionModel` | Unified LLM client with 15 provider factory methods |
412
- | `CompletionModel.complete(messages)` | Chat completion (async) |
413
- | `CompletionModel.completeWithOptions(messages, opts)` | Chat completion with temperature, maxTokens, model, tools (async) |
476
+ | `CompletionModel.complete(messages)` | Chat completion with typed `ChatMessage[]` input, returns `CompletionResponse` (async) |
477
+ | `CompletionModel.completeWithOptions(messages, opts)` | Chat completion with `CompletionOptions` (async) |
414
478
  | `CompletionModel.modelId` | Getter for the current model ID |
479
+ | `ChatMessage` | Chat message class with static factories: `.system()`, `.user()`, `.assistant()`, `.tool()`, `.userImageUrl()`, `.userImageBase64()`, `.userParts()` |
480
+ | `Role` | String enum: `Role.System`, `Role.User`, `Role.Assistant`, `Role.Tool` |
481
+ | `CompletionResponse` | Interface: `{ content, toolCalls, usage, model, finishReason }` |
482
+ | `ToolCall` | Interface: `{ id, name, arguments }` |
483
+ | `TokenUsage` | Interface: `{ promptTokens, completionTokens, totalTokens }` |
484
+ | `CompletionOptions` | Interface: `{ temperature?, maxTokens?, topP?, model?, tools? }` |
485
+ | `ContentPart` / `ImageContent` / `ImageSource` | Types for multimodal message content |
415
486
  | `JsWorkflowResult` | Interface: `{ type: string, data: any }` |
416
487
  | `version()` | Returns the blazen library version string |
417
488
 
package/index.d.ts CHANGED
@@ -1,5 +1,35 @@
1
1
  /* auto-generated by NAPI-RS */
2
2
  /* eslint-disable */
3
+ /** A single message in a chat conversation. */
4
+ export declare class ChatMessage {
5
+ /**
6
+ * Create a new chat message from an options object.
7
+ *
8
+ * `role` defaults to `"user"` if not provided.
9
+ * Supply either `content` (text) or `parts` (multimodal).
10
+ */
11
+ constructor(options: ChatMessageOptions)
12
+ /** Create a system message. */
13
+ static system(content: string): ChatMessage
14
+ /** Create a user message. */
15
+ static user(content: string): ChatMessage
16
+ /** Create an assistant message. */
17
+ static assistant(content: string): ChatMessage
18
+ /** Create a tool result message. */
19
+ static tool(content: string): ChatMessage
20
+ /** Create a user message containing text and an image from a URL. */
21
+ static userImageUrl(text: string, url: string, mediaType?: string | undefined | null): ChatMessage
22
+ /** Create a user message containing text and a base64-encoded image. */
23
+ static userImageBase64(text: string, data: string, mediaType: string): ChatMessage
24
+ /** Create a user message from an explicit list of content parts. */
25
+ static userParts(parts: Array<JsContentPart>): ChatMessage
26
+ /** The role of the message author. */
27
+ get role(): string
28
+ /** The text content of the message, if any. */
29
+ get content(): string | null
30
+ }
31
+ export type JsChatMessage = ChatMessage
32
+
3
33
  /**
4
34
  * A chat completion model.
5
35
  *
@@ -8,52 +38,52 @@
8
38
  * ```javascript
9
39
  * const model = CompletionModel.openai("sk-...");
10
40
  * const response = await model.complete([
11
- * { role: "user", content: "What is 2 + 2?" }
41
+ * ChatMessage.user("What is 2 + 2?")
12
42
  * ]);
13
43
  * ```
14
44
  */
15
45
  export declare class CompletionModel {
16
46
  /** Create an `OpenAI` completion model. */
17
- static openai(apiKey: string): CompletionModel
47
+ static openai(apiKey: string, model?: string | undefined | null): CompletionModel
18
48
  /** Create an Anthropic completion model. */
19
- static anthropic(apiKey: string): CompletionModel
49
+ static anthropic(apiKey: string, model?: string | undefined | null): CompletionModel
20
50
  /** Create a Google Gemini completion model. */
21
- static gemini(apiKey: string): CompletionModel
51
+ static gemini(apiKey: string, model?: string | undefined | null): CompletionModel
22
52
  /** Create an Azure `OpenAI` completion model. */
23
53
  static azure(apiKey: string, resourceName: string, deploymentName: string): CompletionModel
24
54
  /** Create a fal.ai completion model. */
25
- static fal(apiKey: string): CompletionModel
55
+ static fal(apiKey: string, model?: string | undefined | null): CompletionModel
26
56
  /** Create an `OpenRouter` completion model. */
27
- static openrouter(apiKey: string): CompletionModel
57
+ static openrouter(apiKey: string, model?: string | undefined | null): CompletionModel
28
58
  /** Create a Groq completion model. */
29
- static groq(apiKey: string): CompletionModel
59
+ static groq(apiKey: string, model?: string | undefined | null): CompletionModel
30
60
  /** Create a Together AI completion model. */
31
- static together(apiKey: string): CompletionModel
61
+ static together(apiKey: string, model?: string | undefined | null): CompletionModel
32
62
  /** Create a Mistral AI completion model. */
33
- static mistral(apiKey: string): CompletionModel
63
+ static mistral(apiKey: string, model?: string | undefined | null): CompletionModel
34
64
  /** Create a `DeepSeek` completion model. */
35
- static deepseek(apiKey: string): CompletionModel
65
+ static deepseek(apiKey: string, model?: string | undefined | null): CompletionModel
36
66
  /** Create a Fireworks AI completion model. */
37
- static fireworks(apiKey: string): CompletionModel
67
+ static fireworks(apiKey: string, model?: string | undefined | null): CompletionModel
38
68
  /** Create a Perplexity completion model. */
39
- static perplexity(apiKey: string): CompletionModel
69
+ static perplexity(apiKey: string, model?: string | undefined | null): CompletionModel
40
70
  /** Create an xAI (Grok) completion model. */
41
- static xai(apiKey: string): CompletionModel
71
+ static xai(apiKey: string, model?: string | undefined | null): CompletionModel
42
72
  /** Create a Cohere completion model. */
43
- static cohere(apiKey: string): CompletionModel
73
+ static cohere(apiKey: string, model?: string | undefined | null): CompletionModel
44
74
  /** Create an AWS Bedrock completion model. */
45
- static bedrock(apiKey: string, region: string): CompletionModel
75
+ static bedrock(apiKey: string, region: string, model?: string | undefined | null): CompletionModel
46
76
  /** Get the model ID. */
47
77
  get modelId(): string
48
78
  /**
49
79
  * Perform a chat completion.
50
80
  *
51
- * Messages should be an array of `{ role: string, content: string }` objects.
81
+ * Messages should be an array of `ChatMessage` instances.
52
82
  *
53
- * Returns the response as a JSON object with `content`, `toolCalls`,
54
- * `usage`, `model`, and `finishReason` fields.
83
+ * Returns a typed response with `content`, `toolCalls`, `usage`, `model`,
84
+ * and `finishReason` fields.
55
85
  */
56
- complete(messages: Array<any>): Promise<any>
86
+ complete(messages: Array<JsChatMessage>): Promise<JsCompletionResponse>
57
87
  /**
58
88
  * Perform a chat completion with additional options.
59
89
  *
@@ -64,7 +94,32 @@ export declare class CompletionModel {
64
94
  * - `model` (string): Override the default model
65
95
  * - `tools` (array): Tool definitions for function calling
66
96
  */
67
- completeWithOptions(messages: Array<any>, options: any): Promise<any>
97
+ completeWithOptions(messages: Array<JsChatMessage>, options: JsCompletionOptions): Promise<JsCompletionResponse>
98
+ /**
99
+ * Stream a chat completion.
100
+ *
101
+ * The `onChunk` callback receives each chunk as it arrives, with keys:
102
+ * `delta`, `finishReason`, `toolCalls`.
103
+ *
104
+ * ```javascript
105
+ * await model.stream(
106
+ * [ChatMessage.user("Tell me a story")],
107
+ * (chunk) => { if (chunk.delta) process.stdout.write(chunk.delta); }
108
+ * );
109
+ * ```
110
+ */
111
+ stream(messages: Array<JsChatMessage>, onChunk: StreamChunkCallbackTsfn): Promise<void>
112
+ /**
113
+ * Stream a chat completion with additional options.
114
+ *
115
+ * Options object may include:
116
+ * - `temperature` (number): Sampling temperature (0.0 - 2.0)
117
+ * - `maxTokens` (number): Maximum tokens to generate
118
+ * - `topP` (number): Nucleus sampling parameter
119
+ * - `model` (string): Override the default model
120
+ * - `tools` (array): Tool definitions for function calling
121
+ */
122
+ streamWithOptions(messages: Array<JsChatMessage>, onChunk: StreamChunkCallbackTsfn, options: JsCompletionOptions): Promise<void>
68
123
  }
69
124
  export type JsCompletionModel = CompletionModel
70
125
 
@@ -102,11 +157,74 @@ export declare class Context {
102
157
  * internal step registry.
103
158
  */
104
159
  writeEventToStream(event: any): Promise<void>
160
+ /**
161
+ * Store raw binary data under the given key.
162
+ *
163
+ * Useful for storing files, images, serialized objects, or any binary
164
+ * data that should not be JSON-serialized. The data persists through
165
+ * pause/resume snapshots.
166
+ */
167
+ setBytes(key: string, data: Buffer): Promise<void>
168
+ /**
169
+ * Retrieve raw binary data previously stored under the given key.
170
+ *
171
+ * Returns `null` if the key does not exist or the stored value is
172
+ * not binary data.
173
+ */
174
+ getBytes(key: string): Promise<Buffer | null>
105
175
  /** Get the workflow run ID. */
106
176
  runId(): Promise<string>
107
177
  }
108
178
  export type JsContext = Context
109
179
 
180
+ /**
181
+ * A fal.ai compute platform provider with image, video, audio, transcription,
182
+ * and LLM capabilities.
183
+ *
184
+ * ```typescript
185
+ * const fal = FalProvider.create("fal-key-...");
186
+ * const result = await fal.generateImage({ prompt: "a sunset" });
187
+ * const response = await fal.complete([ChatMessage.user("Hi")]);
188
+ * ```
189
+ */
190
+ export declare class FalProvider {
191
+ /**
192
+ * Create a new fal.ai provider.
193
+ *
194
+ * `model` optionally overrides the default fal.ai model endpoint.
195
+ */
196
+ static create(apiKey: string, model?: string | undefined | null): FalProvider
197
+ /** Get the model ID. */
198
+ get modelId(): string
199
+ /** Generate images from a text prompt. */
200
+ generateImage(request: JsImageRequest): Promise<any>
201
+ /** Upscale an image. */
202
+ upscaleImage(request: JsUpscaleRequest): Promise<any>
203
+ /** Generate a video from a text prompt. */
204
+ textToVideo(request: JsVideoRequest): Promise<any>
205
+ /** Generate a video from a source image and prompt. */
206
+ imageToVideo(request: JsVideoRequest): Promise<any>
207
+ /** Synthesize speech from text. */
208
+ textToSpeech(request: JsSpeechRequest): Promise<any>
209
+ /** Generate music from a prompt. */
210
+ generateMusic(request: JsMusicRequest): Promise<any>
211
+ /** Generate sound effects from a prompt. */
212
+ generateSfx(request: JsMusicRequest): Promise<any>
213
+ /** Transcribe audio to text. */
214
+ transcribe(request: JsTranscriptionRequest): Promise<any>
215
+ /** Run a model synchronously (submit + wait for result). */
216
+ run(model: string, input: any): Promise<any>
217
+ /** Submit a job to the queue and return a job handle. */
218
+ submit(model: string, input: any): Promise<any>
219
+ /** Get the status of a submitted job. */
220
+ status(jobId: string, model: string): Promise<any>
221
+ /** Cancel a submitted job. */
222
+ cancel(jobId: string, model: string): Promise<void>
223
+ /** Perform a chat completion via fal.ai's `any-llm` proxy. */
224
+ complete(messages: Array<JsChatMessage>): Promise<JsCompletionResponse>
225
+ }
226
+ export type JsFalProvider = FalProvider
227
+
110
228
  /**
111
229
  * A workflow builder and runner.
112
230
  *
@@ -255,6 +373,482 @@ export declare class WorkflowHandler {
255
373
  }
256
374
  export type JsWorkflowHandler = WorkflowHandler
257
375
 
376
+ /** Options for creating a `ChatMessage`. */
377
+ export interface ChatMessageOptions {
378
+ /** Role: "system", "user", "assistant", or "tool". Defaults to "user". */
379
+ role?: string
380
+ /** Text content. */
381
+ content?: string
382
+ /** Multimodal content parts (alternative to content). */
383
+ parts?: Array<JsContentPart>
384
+ }
385
+
386
+ /** The result of an agent run. */
387
+ export interface JsAgentResult {
388
+ /** The final completion response from the model. */
389
+ response: JsCompletionResponse
390
+ /** Full message history including all tool calls and results. */
391
+ messages: Array<any>
392
+ /** Number of tool-calling iterations that occurred. */
393
+ iterations: number
394
+ /** Aggregated cost across all iterations, if available. */
395
+ totalCost?: number
396
+ }
397
+
398
+ /** Options for configuring an agent run. */
399
+ export interface JsAgentRunOptions {
400
+ /**
401
+ * Maximum number of tool-calling iterations before forcing a final answer.
402
+ * Defaults to 10.
403
+ */
404
+ maxIterations?: number
405
+ /** Optional system prompt prepended to the conversation. */
406
+ systemPrompt?: string
407
+ /** Sampling temperature (0.0 - 2.0). */
408
+ temperature?: number
409
+ /** Maximum tokens per completion call. */
410
+ maxTokens?: number
411
+ /**
412
+ * Whether to add a built-in "finish" tool that the model can call to
413
+ * signal it has a final answer.
414
+ */
415
+ addFinishTool?: boolean
416
+ }
417
+
418
+ /** Result of an audio generation or TTS operation. */
419
+ export interface JsAudioResult {
420
+ /** The generated audio clips. */
421
+ audio: Array<JsGeneratedAudio>
422
+ /** Request timing breakdown. */
423
+ timing?: JsComputeTiming
424
+ /** Cost in USD, if reported by the provider. */
425
+ cost?: number
426
+ /** Arbitrary provider-specific metadata. */
427
+ metadata: any
428
+ }
429
+
430
+ /** Options for a chat completion request. */
431
+ export interface JsCompletionOptions {
432
+ temperature?: number
433
+ maxTokens?: number
434
+ topP?: number
435
+ model?: string
436
+ tools?: Array<JsToolDefinition>
437
+ /** JSON Schema for structured output / response format. */
438
+ responseFormat?: any
439
+ }
440
+
441
+ /** The result of a chat completion. */
442
+ export interface JsCompletionResponse {
443
+ content?: string
444
+ toolCalls: Array<JsToolCall>
445
+ usage?: JsTokenUsage
446
+ model: string
447
+ finishReason?: string
448
+ cost?: number
449
+ timing?: JsRequestTiming
450
+ images: Array<any>
451
+ audio: Array<any>
452
+ videos: Array<any>
453
+ metadata: any
454
+ }
455
+
456
+ /** Input for a generic compute job. */
457
+ export interface JsComputeRequest {
458
+ /** The model/endpoint to run (e.g., "fal-ai/flux/dev"). */
459
+ model: string
460
+ /** Input parameters as JSON (model-specific). */
461
+ input: any
462
+ /** Optional webhook URL for async completion notification. */
463
+ webhook?: string
464
+ }
465
+
466
+ /** Result of a completed compute job. */
467
+ export interface JsComputeResult {
468
+ /** The job handle that produced this result, if available. */
469
+ job?: JsJobHandle
470
+ /** Output data (model-specific JSON). */
471
+ output: any
472
+ /** Request timing breakdown. */
473
+ timing?: JsComputeTiming
474
+ /** Cost in USD, if reported by the provider. */
475
+ cost?: number
476
+ /** Raw provider-specific metadata. */
477
+ metadata: any
478
+ }
479
+
480
+ /** Timing breakdown for a compute request. */
481
+ export interface JsComputeTiming {
482
+ /** Time spent waiting in queue, in milliseconds. */
483
+ queueMs?: number
484
+ /** Time spent executing, in milliseconds. */
485
+ executionMs?: number
486
+ /** Total wall-clock time, in milliseconds. */
487
+ totalMs?: number
488
+ }
489
+
490
+ /** A single part in a multi-part message. */
491
+ export interface JsContentPart {
492
+ partType: string
493
+ text?: string
494
+ image?: JsImageContent
495
+ }
496
+
497
+ /** A single generated 3D model with optional mesh metadata. */
498
+ export interface JsGenerated3DModel {
499
+ /** The 3D model media output. */
500
+ media: JsMediaOutput
501
+ /** Total vertex count, if known. */
502
+ vertexCount?: number
503
+ /** Total face/triangle count, if known. */
504
+ faceCount?: number
505
+ /** Whether the model includes texture data. */
506
+ hasTextures: boolean
507
+ /** Whether the model includes animation data. */
508
+ hasAnimations: boolean
509
+ }
510
+
511
+ /** A single generated audio clip with optional metadata. */
512
+ export interface JsGeneratedAudio {
513
+ /** The audio media output. */
514
+ media: JsMediaOutput
515
+ /** Duration in seconds, if known. */
516
+ durationSeconds?: number
517
+ /** Sample rate in Hz, if known. */
518
+ sampleRate?: number
519
+ /** Number of audio channels, if known. */
520
+ channels?: number
521
+ }
522
+
523
+ /** A single generated image with optional dimension metadata. */
524
+ export interface JsGeneratedImage {
525
+ /** The image media output. */
526
+ media: JsMediaOutput
527
+ /** Image width in pixels, if known. */
528
+ width?: number
529
+ /** Image height in pixels, if known. */
530
+ height?: number
531
+ }
532
+
533
+ /** A single generated video with optional metadata. */
534
+ export interface JsGeneratedVideo {
535
+ /** The video media output. */
536
+ media: JsMediaOutput
537
+ /** Video width in pixels, if known. */
538
+ width?: number
539
+ /** Video height in pixels, if known. */
540
+ height?: number
541
+ /** Duration in seconds, if known. */
542
+ durationSeconds?: number
543
+ /** Frames per second, if known. */
544
+ fps?: number
545
+ }
546
+
547
+ /** Image content for multimodal messages. */
548
+ export interface JsImageContent {
549
+ source: JsImageSource
550
+ mediaType?: string
551
+ }
552
+
553
+ /** Request to generate images from a text prompt. */
554
+ export interface JsImageRequest {
555
+ /** The text prompt describing the desired image. */
556
+ prompt: string
557
+ /** Negative prompt (things to avoid in the image). */
558
+ negativePrompt?: string
559
+ /** Desired image width in pixels. */
560
+ width?: number
561
+ /** Desired image height in pixels. */
562
+ height?: number
563
+ /** Number of images to generate. */
564
+ numImages?: number
565
+ /** Model override (provider-specific model identifier). */
566
+ model?: string
567
+ /** Additional provider-specific parameters. */
568
+ parameters?: any
569
+ }
570
+
571
+ /** Result of an image generation or upscale operation. */
572
+ export interface JsImageResult {
573
+ /** The generated or upscaled images. */
574
+ images: Array<JsGeneratedImage>
575
+ /** Request timing breakdown. */
576
+ timing?: JsComputeTiming
577
+ /** Cost in USD, if reported by the provider. */
578
+ cost?: number
579
+ /** Arbitrary provider-specific metadata. */
580
+ metadata: any
581
+ }
582
+
583
+ /** How an image is provided (URL or base64). */
584
+ export interface JsImageSource {
585
+ sourceType: string
586
+ url?: string
587
+ data?: string
588
+ }
589
+
590
+ /** A handle to a submitted compute job. */
591
+ export interface JsJobHandle {
592
+ /** Provider-assigned job/request identifier. */
593
+ id: string
594
+ /** Provider name (e.g., "fal", "replicate", "runpod"). */
595
+ provider: string
596
+ /** The model/endpoint that was invoked. */
597
+ model: string
598
+ /** When the job was submitted (ISO 8601). */
599
+ submittedAt: string
600
+ }
601
+
602
+ /** Status of a compute job. */
603
+ export declare const enum JsJobStatus {
604
+ /** Job is waiting in the provider's queue. */
605
+ Queued = 'queued',
606
+ /** Job is currently executing. */
607
+ Running = 'running',
608
+ /** Job completed successfully. */
609
+ Completed = 'completed',
610
+ /** Job failed with an error. */
611
+ Failed = 'failed',
612
+ /** Job was cancelled. */
613
+ Cancelled = 'cancelled'
614
+ }
615
+
616
+ /** A single piece of generated media content. */
617
+ export interface JsMediaOutput {
618
+ /** URL where the media can be downloaded. */
619
+ url?: string
620
+ /** Base64-encoded media data. */
621
+ base64?: string
622
+ /** Raw text content for text-based formats (SVG, OBJ, GLTF JSON). */
623
+ rawContent?: string
624
+ /** The MIME type of the media (e.g. "image/png", "video/mp4"). */
625
+ mediaType: string
626
+ /** File size in bytes, if known. */
627
+ fileSize?: number
628
+ /** Arbitrary provider-specific metadata. */
629
+ metadata: any
630
+ }
631
+
632
+ /** Map of friendly format names to their MIME type strings. */
633
+ export interface JsMediaTypeMap {
634
+ png: string
635
+ jpeg: string
636
+ webp: string
637
+ gif: string
638
+ svg: string
639
+ bmp: string
640
+ tiff: string
641
+ avif: string
642
+ ico: string
643
+ mp4: string
644
+ webm: string
645
+ mov: string
646
+ avi: string
647
+ mkv: string
648
+ mp3: string
649
+ wav: string
650
+ ogg: string
651
+ flac: string
652
+ aac: string
653
+ m4A: string
654
+ glb: string
655
+ gltf: string
656
+ obj: string
657
+ fbx: string
658
+ usdz: string
659
+ stl: string
660
+ ply: string
661
+ pdf: string
662
+ }
663
+
664
+ /** Request to generate music or sound effects. */
665
+ export interface JsMusicRequest {
666
+ /** Text prompt describing the desired audio. */
667
+ prompt: string
668
+ /** Desired duration in seconds. */
669
+ durationSeconds?: number
670
+ /** Model override. */
671
+ model?: string
672
+ /** Additional provider-specific parameters. */
673
+ parameters?: any
674
+ }
675
+
676
+ /** Timing metadata for a completion request. */
677
+ export interface JsRequestTiming {
678
+ queueMs?: number
679
+ executionMs?: number
680
+ totalMs?: number
681
+ }
682
+
683
+ /** The role of a participant in a chat conversation. */
684
+ export declare const enum JsRole {
685
+ System = 'system',
686
+ User = 'user',
687
+ Assistant = 'assistant',
688
+ Tool = 'tool'
689
+ }
690
+
691
+ /** Request to generate speech from text (TTS). */
692
+ export interface JsSpeechRequest {
693
+ /** The text to synthesize into speech. */
694
+ text: string
695
+ /** Voice identifier (provider-specific). */
696
+ voice?: string
697
+ /** URL to a reference voice sample for voice cloning. */
698
+ voiceUrl?: string
699
+ /** Language code (e.g. "en", "fr", "ja"). */
700
+ language?: string
701
+ /** Speech speed multiplier (1.0 = normal). */
702
+ speed?: number
703
+ /** Model override. */
704
+ model?: string
705
+ /** Additional provider-specific parameters. */
706
+ parameters?: any
707
+ }
708
+
709
+ /** Request to generate a 3D model. */
710
+ export interface JsThreeDRequest {
711
+ /** Text prompt describing the desired 3D model. */
712
+ prompt?: string
713
+ /** Source image URL for image-to-3D generation. */
714
+ imageUrl?: string
715
+ /** Desired output format (e.g. "glb", "obj", "usdz"). */
716
+ format?: string
717
+ /** Model override. */
718
+ model?: string
719
+ /** Additional provider-specific parameters. */
720
+ parameters?: any
721
+ }
722
+
723
+ /** Result of a 3D model generation operation. */
724
+ export interface JsThreeDResult {
725
+ /** The generated 3D models. */
726
+ models: Array<JsGenerated3DModel>
727
+ /** Request timing breakdown. */
728
+ timing?: JsComputeTiming
729
+ /** Cost in USD, if reported by the provider. */
730
+ cost?: number
731
+ /** Arbitrary provider-specific metadata. */
732
+ metadata: any
733
+ }
734
+
735
+ /** Token usage statistics for a completion request. */
736
+ export interface JsTokenUsage {
737
+ promptTokens: number
738
+ completionTokens: number
739
+ totalTokens: number
740
+ }
741
+
742
+ /** A tool invocation requested by the model. */
743
+ export interface JsToolCall {
744
+ id: string
745
+ name: string
746
+ arguments: any
747
+ }
748
+
749
+ /** Describes a tool that the agent may invoke during its execution loop. */
750
+ export interface JsToolDef {
751
+ /** The unique name of the tool. */
752
+ name: string
753
+ /** A human-readable description of what the tool does. */
754
+ description: string
755
+ /** JSON Schema describing the tool's parameters. */
756
+ parameters: any
757
+ }
758
+
759
+ /** Describes a tool that the model may invoke during a conversation. */
760
+ export interface JsToolDefinition {
761
+ name: string
762
+ description: string
763
+ parameters: any
764
+ }
765
+
766
+ /** Request to transcribe audio to text. */
767
+ export interface JsTranscriptionRequest {
768
+ /** URL of the audio file to transcribe. */
769
+ audioUrl: string
770
+ /** Language hint (e.g. "en", "fr"). */
771
+ language?: string
772
+ /** Whether to perform speaker diarization. */
773
+ diarize?: boolean
774
+ /** Model override. */
775
+ model?: string
776
+ /** Additional provider-specific parameters. */
777
+ parameters?: any
778
+ }
779
+
780
+ /** Result of a transcription operation. */
781
+ export interface JsTranscriptionResult {
782
+ /** The full transcribed text. */
783
+ text: string
784
+ /** Time-aligned segments, if available. */
785
+ segments: Array<JsTranscriptionSegment>
786
+ /** Detected or specified language code (e.g. "en", "fr"). */
787
+ language?: string
788
+ /** Request timing breakdown. */
789
+ timing?: JsComputeTiming
790
+ /** Cost in USD, if reported by the provider. */
791
+ cost?: number
792
+ /** Arbitrary provider-specific metadata. */
793
+ metadata: any
794
+ }
795
+
796
+ /** A single segment within a transcription. */
797
+ export interface JsTranscriptionSegment {
798
+ /** The transcribed text for this segment. */
799
+ text: string
800
+ /** Start time in seconds. */
801
+ start: number
802
+ /** End time in seconds. */
803
+ end: number
804
+ /** Speaker label, if diarization was enabled. */
805
+ speaker?: string
806
+ }
807
+
808
+ /** Request to upscale an image. */
809
+ export interface JsUpscaleRequest {
810
+ /** URL of the image to upscale. */
811
+ imageUrl: string
812
+ /** Scale factor (e.g., 2.0 for 2x, 4.0 for 4x). */
813
+ scale: number
814
+ /** Model override. */
815
+ model?: string
816
+ /** Additional provider-specific parameters. */
817
+ parameters?: any
818
+ }
819
+
820
+ /** Request to generate a video. */
821
+ export interface JsVideoRequest {
822
+ /** Text prompt describing the desired video. */
823
+ prompt: string
824
+ /** Source image URL for image-to-video generation. */
825
+ imageUrl?: string
826
+ /** Desired duration in seconds. */
827
+ durationSeconds?: number
828
+ /** Negative prompt (things to avoid). */
829
+ negativePrompt?: string
830
+ /** Desired video width in pixels. */
831
+ width?: number
832
+ /** Desired video height in pixels. */
833
+ height?: number
834
+ /** Model override. */
835
+ model?: string
836
+ /** Additional provider-specific parameters. */
837
+ parameters?: any
838
+ }
839
+
840
+ /** Result of a video generation operation. */
841
+ export interface JsVideoResult {
842
+ /** The generated videos. */
843
+ videos: Array<JsGeneratedVideo>
844
+ /** Request timing breakdown. */
845
+ timing?: JsComputeTiming
846
+ /** Cost in USD, if reported by the provider. */
847
+ cost?: number
848
+ /** Arbitrary provider-specific metadata. */
849
+ metadata: any
850
+ }
851
+
258
852
  /** The result of a workflow run. */
259
853
  export interface JsWorkflowResult {
260
854
  /** The event type of the final result (typically "`blazen::StopEvent`"). */
@@ -263,5 +857,48 @@ export interface JsWorkflowResult {
263
857
  data: any
264
858
  }
265
859
 
860
+ /**
861
+ * Returns an object mapping friendly names to MIME type strings.
862
+ *
863
+ * ```typescript
864
+ * import { mediaTypes } from 'blazen';
865
+ *
866
+ * const types = mediaTypes();
867
+ * console.log(types.png); // "image/png"
868
+ * console.log(types.mp4); // "video/mp4"
869
+ * ```
870
+ */
871
+ export declare function mediaTypes(): JsMediaTypeMap
872
+
873
+ /**
874
+ * Run an agentic tool execution loop.
875
+ *
876
+ * The agent repeatedly calls the model, executes any tool calls via the
877
+ * `toolHandler` callback, feeds results back, and repeats until the model
878
+ * stops calling tools or `maxIterations` is reached.
879
+ *
880
+ * The `toolHandler` callback receives `(toolName: string, arguments: object)`
881
+ * and must return the tool result as a JSON-serializable value (or a Promise
882
+ * that resolves to one).
883
+ *
884
+ * ```typescript
885
+ * import { CompletionModel, ChatMessage, runAgent } from 'blazen';
886
+ *
887
+ * const model = CompletionModel.openai("sk-...");
888
+ *
889
+ * const result = await runAgent(
890
+ * model,
891
+ * [ChatMessage.user("What is the weather in NYC?")],
892
+ * [{ name: "getWeather", description: "Get weather", parameters: { type: "object", properties: { city: { type: "string" } }, required: ["city"] } }],
893
+ * async (toolName, args) => {
894
+ * if (toolName === "getWeather") return { temp: 72, condition: "sunny" };
895
+ * throw new Error(`Unknown tool: ${toolName}`);
896
+ * },
897
+ * { maxIterations: 5 }
898
+ * );
899
+ * ```
900
+ */
901
+ export declare function runAgent(model: JsCompletionModel, messages: Array<JsChatMessage>, tools: Array<JsToolDef>, toolHandler: ToolHandlerTsfn, options?: JsAgentRunOptions | undefined | null): Promise<JsAgentResult>
902
+
266
903
  /** Returns the version of the blazen library. */
267
904
  export declare function version(): string
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.97' && 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.97 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
80
+ if (bindingPackageVersion !== '0.1.99' && 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.99 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.97' && 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.97 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
96
+ if (bindingPackageVersion !== '0.1.99' && 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.99 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.97' && 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.97 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
117
+ if (bindingPackageVersion !== '0.1.99' && 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.99 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.97' && 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.97 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
133
+ if (bindingPackageVersion !== '0.1.99' && 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.99 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.97' && 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.97 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
150
+ if (bindingPackageVersion !== '0.1.99' && 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.99 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.97' && 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.97 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
166
+ if (bindingPackageVersion !== '0.1.99' && 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.99 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.97' && 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.97 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
185
+ if (bindingPackageVersion !== '0.1.99' && 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.99 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.97' && 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.97 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
201
+ if (bindingPackageVersion !== '0.1.99' && 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.99 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.97' && 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.97 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
217
+ if (bindingPackageVersion !== '0.1.99' && 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.99 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.97' && 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.97 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
237
+ if (bindingPackageVersion !== '0.1.99' && 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.99 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.97' && 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.97 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
253
+ if (bindingPackageVersion !== '0.1.99' && 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.99 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.97' && 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.97 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
274
+ if (bindingPackageVersion !== '0.1.99' && 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.99 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.97' && 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.97 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
290
+ if (bindingPackageVersion !== '0.1.99' && 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.99 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.97' && 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.97 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
308
+ if (bindingPackageVersion !== '0.1.99' && 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.99 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.97' && 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.97 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
324
+ if (bindingPackageVersion !== '0.1.99' && 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.99 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.97' && 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.97 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
342
+ if (bindingPackageVersion !== '0.1.99' && 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.99 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.97' && 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.97 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
358
+ if (bindingPackageVersion !== '0.1.99' && 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.99 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.97' && 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.97 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
376
+ if (bindingPackageVersion !== '0.1.99' && 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.99 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.97' && 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.97 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
392
+ if (bindingPackageVersion !== '0.1.99' && 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.99 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.97' && 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.97 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
410
+ if (bindingPackageVersion !== '0.1.99' && 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.99 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.97' && 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.97 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
426
+ if (bindingPackageVersion !== '0.1.99' && 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.99 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.97' && 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.97 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
443
+ if (bindingPackageVersion !== '0.1.99' && 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.99 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.97' && 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.97 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
459
+ if (bindingPackageVersion !== '0.1.99' && 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.99 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.97' && 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.97 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
479
+ if (bindingPackageVersion !== '0.1.99' && 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.99 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.97' && 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.97 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
495
+ if (bindingPackageVersion !== '0.1.99' && 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.99 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.97' && 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.97 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
511
+ if (bindingPackageVersion !== '0.1.99' && 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.99 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
513
513
  }
514
514
  return binding
515
515
  } catch (e) {
@@ -576,12 +576,20 @@ if (!nativeBinding) {
576
576
  }
577
577
 
578
578
  module.exports = nativeBinding
579
+ module.exports.ChatMessage = nativeBinding.ChatMessage
580
+ module.exports.JsChatMessage = nativeBinding.JsChatMessage
579
581
  module.exports.CompletionModel = nativeBinding.CompletionModel
580
582
  module.exports.JsCompletionModel = nativeBinding.JsCompletionModel
581
583
  module.exports.Context = nativeBinding.Context
582
584
  module.exports.JsContext = nativeBinding.JsContext
585
+ module.exports.FalProvider = nativeBinding.FalProvider
586
+ module.exports.JsFalProvider = nativeBinding.JsFalProvider
583
587
  module.exports.Workflow = nativeBinding.Workflow
584
588
  module.exports.JsWorkflow = nativeBinding.JsWorkflow
585
589
  module.exports.WorkflowHandler = nativeBinding.WorkflowHandler
586
590
  module.exports.JsWorkflowHandler = nativeBinding.JsWorkflowHandler
591
+ module.exports.JsJobStatus = nativeBinding.JsJobStatus
592
+ module.exports.JsRole = nativeBinding.JsRole
593
+ module.exports.mediaTypes = nativeBinding.mediaTypes
594
+ module.exports.runAgent = nativeBinding.runAgent
587
595
  module.exports.version = nativeBinding.version
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "blazen",
3
- "version": "0.1.97",
3
+ "version": "0.1.99",
4
4
  "description": "Blazen - Event-driven AI workflow framework for Node.js/TypeScript",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -34,7 +34,8 @@
34
34
  "index.d.ts"
35
35
  ],
36
36
  "devDependencies": {
37
- "@napi-rs/cli": "^3.0.0"
37
+ "@napi-rs/cli": "^3.0.0",
38
+ "@biomejs/biome": "^2"
38
39
  },
39
40
  "engines": {
40
41
  "node": ">= 18"