blazen 0.1.97 → 0.1.98

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 +607 -20
  3. package/index.js +58 -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<ChatMessage>): 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<ChatMessage>, 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<ChatMessage>, 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<ChatMessage>, onChunk: StreamChunkCallbackTsfn, options: JsCompletionOptions): Promise<void>
68
123
  }
69
124
  export type JsCompletionModel = CompletionModel
70
125
 
@@ -102,6 +157,21 @@ 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
  }
@@ -255,6 +325,480 @@ export declare class WorkflowHandler {
255
325
  }
256
326
  export type JsWorkflowHandler = WorkflowHandler
257
327
 
328
+ /** Options for creating a `ChatMessage`. */
329
+ export interface ChatMessageOptions {
330
+ /** Role: "system", "user", "assistant", or "tool". Defaults to "user". */
331
+ role?: string
332
+ /** Text content. */
333
+ content?: string
334
+ /** Multimodal content parts (alternative to content). */
335
+ parts?: Array<JsContentPart>
336
+ }
337
+
338
+ /** The result of an agent run. */
339
+ export interface JsAgentResult {
340
+ /** The final completion response from the model. */
341
+ response: JsCompletionResponse
342
+ /** Full message history including all tool calls and results. */
343
+ messages: Array<any>
344
+ /** Number of tool-calling iterations that occurred. */
345
+ iterations: number
346
+ /** Aggregated cost across all iterations, if available. */
347
+ totalCost?: number
348
+ }
349
+
350
+ /** Options for configuring an agent run. */
351
+ export interface JsAgentRunOptions {
352
+ /**
353
+ * Maximum number of tool-calling iterations before forcing a final answer.
354
+ * Defaults to 10.
355
+ */
356
+ maxIterations?: number
357
+ /** Optional system prompt prepended to the conversation. */
358
+ systemPrompt?: string
359
+ /** Sampling temperature (0.0 - 2.0). */
360
+ temperature?: number
361
+ /** Maximum tokens per completion call. */
362
+ maxTokens?: number
363
+ /**
364
+ * Whether to add a built-in "finish" tool that the model can call to
365
+ * signal it has a final answer.
366
+ */
367
+ addFinishTool?: boolean
368
+ }
369
+
370
+ /** Result of an audio generation or TTS operation. */
371
+ export interface JsAudioResult {
372
+ /** The generated audio clips. */
373
+ audio: Array<JsGeneratedAudio>
374
+ /** Request timing breakdown. */
375
+ timing?: JsComputeTiming
376
+ /** Cost in USD, if reported by the provider. */
377
+ cost?: number
378
+ /** Arbitrary provider-specific metadata. */
379
+ metadata: any
380
+ }
381
+
382
+ /** Options for a chat completion request. */
383
+ export interface JsCompletionOptions {
384
+ temperature?: number
385
+ maxTokens?: number
386
+ topP?: number
387
+ model?: string
388
+ tools?: Array<JsToolDefinition>
389
+ }
390
+
391
+ /** The result of a chat completion. */
392
+ export interface JsCompletionResponse {
393
+ content?: string
394
+ toolCalls: Array<JsToolCall>
395
+ usage?: JsTokenUsage
396
+ model: string
397
+ finishReason?: string
398
+ cost?: number
399
+ timing?: JsRequestTiming
400
+ images: Array<any>
401
+ audio: Array<any>
402
+ videos: Array<any>
403
+ metadata: any
404
+ }
405
+
406
+ /** Input for a generic compute job. */
407
+ export interface JsComputeRequest {
408
+ /** The model/endpoint to run (e.g., "fal-ai/flux/dev"). */
409
+ model: string
410
+ /** Input parameters as JSON (model-specific). */
411
+ input: any
412
+ /** Optional webhook URL for async completion notification. */
413
+ webhook?: string
414
+ }
415
+
416
+ /** Result of a completed compute job. */
417
+ export interface JsComputeResult {
418
+ /** The job handle that produced this result, if available. */
419
+ job?: JsJobHandle
420
+ /** Output data (model-specific JSON). */
421
+ output: any
422
+ /** Request timing breakdown. */
423
+ timing?: JsComputeTiming
424
+ /** Cost in USD, if reported by the provider. */
425
+ cost?: number
426
+ /** Raw provider-specific metadata. */
427
+ metadata: any
428
+ }
429
+
430
+ /** Timing breakdown for a compute request. */
431
+ export interface JsComputeTiming {
432
+ /** Time spent waiting in queue, in milliseconds. */
433
+ queueMs?: number
434
+ /** Time spent executing, in milliseconds. */
435
+ executionMs?: number
436
+ /** Total wall-clock time, in milliseconds. */
437
+ totalMs?: number
438
+ }
439
+
440
+ /** A single part in a multi-part message. */
441
+ export interface JsContentPart {
442
+ partType: string
443
+ text?: string
444
+ image?: JsImageContent
445
+ }
446
+
447
+ /** A single generated 3D model with optional mesh metadata. */
448
+ export interface JsGenerated3DModel {
449
+ /** The 3D model media output. */
450
+ media: JsMediaOutput
451
+ /** Total vertex count, if known. */
452
+ vertexCount?: number
453
+ /** Total face/triangle count, if known. */
454
+ faceCount?: number
455
+ /** Whether the model includes texture data. */
456
+ hasTextures: boolean
457
+ /** Whether the model includes animation data. */
458
+ hasAnimations: boolean
459
+ }
460
+
461
+ /** A single generated audio clip with optional metadata. */
462
+ export interface JsGeneratedAudio {
463
+ /** The audio media output. */
464
+ media: JsMediaOutput
465
+ /** Duration in seconds, if known. */
466
+ durationSeconds?: number
467
+ /** Sample rate in Hz, if known. */
468
+ sampleRate?: number
469
+ /** Number of audio channels, if known. */
470
+ channels?: number
471
+ }
472
+
473
+ /** A single generated image with optional dimension metadata. */
474
+ export interface JsGeneratedImage {
475
+ /** The image media output. */
476
+ media: JsMediaOutput
477
+ /** Image width in pixels, if known. */
478
+ width?: number
479
+ /** Image height in pixels, if known. */
480
+ height?: number
481
+ }
482
+
483
+ /** A single generated video with optional metadata. */
484
+ export interface JsGeneratedVideo {
485
+ /** The video media output. */
486
+ media: JsMediaOutput
487
+ /** Video width in pixels, if known. */
488
+ width?: number
489
+ /** Video height in pixels, if known. */
490
+ height?: number
491
+ /** Duration in seconds, if known. */
492
+ durationSeconds?: number
493
+ /** Frames per second, if known. */
494
+ fps?: number
495
+ }
496
+
497
+ /** Image content for multimodal messages. */
498
+ export interface JsImageContent {
499
+ source: JsImageSource
500
+ mediaType?: string
501
+ }
502
+
503
+ /** Request to generate images from a text prompt. */
504
+ export interface JsImageRequest {
505
+ /** The text prompt describing the desired image. */
506
+ prompt: string
507
+ /** Negative prompt (things to avoid in the image). */
508
+ negativePrompt?: string
509
+ /** Desired image width in pixels. */
510
+ width?: number
511
+ /** Desired image height in pixels. */
512
+ height?: number
513
+ /** Number of images to generate. */
514
+ numImages?: number
515
+ /** Model override (provider-specific model identifier). */
516
+ model?: string
517
+ /** Additional provider-specific parameters. */
518
+ parameters?: any
519
+ }
520
+
521
+ /** Result of an image generation or upscale operation. */
522
+ export interface JsImageResult {
523
+ /** The generated or upscaled images. */
524
+ images: Array<JsGeneratedImage>
525
+ /** Request timing breakdown. */
526
+ timing?: JsComputeTiming
527
+ /** Cost in USD, if reported by the provider. */
528
+ cost?: number
529
+ /** Arbitrary provider-specific metadata. */
530
+ metadata: any
531
+ }
532
+
533
+ /** How an image is provided (URL or base64). */
534
+ export interface JsImageSource {
535
+ sourceType: string
536
+ url?: string
537
+ data?: string
538
+ }
539
+
540
+ /** A handle to a submitted compute job. */
541
+ export interface JsJobHandle {
542
+ /** Provider-assigned job/request identifier. */
543
+ id: string
544
+ /** Provider name (e.g., "fal", "replicate", "runpod"). */
545
+ provider: string
546
+ /** The model/endpoint that was invoked. */
547
+ model: string
548
+ /** When the job was submitted (ISO 8601). */
549
+ submittedAt: string
550
+ }
551
+
552
+ /** Status of a compute job. */
553
+ export declare const enum JsJobStatus {
554
+ /** Job is waiting in the provider's queue. */
555
+ Queued = 'queued',
556
+ /** Job is currently executing. */
557
+ Running = 'running',
558
+ /** Job completed successfully. */
559
+ Completed = 'completed',
560
+ /** Job failed with an error. */
561
+ Failed = 'failed',
562
+ /** Job was cancelled. */
563
+ Cancelled = 'cancelled'
564
+ }
565
+
566
+ /** A single piece of generated media content. */
567
+ export interface JsMediaOutput {
568
+ /** URL where the media can be downloaded. */
569
+ url?: string
570
+ /** Base64-encoded media data. */
571
+ base64?: string
572
+ /** Raw text content for text-based formats (SVG, OBJ, GLTF JSON). */
573
+ rawContent?: string
574
+ /** The MIME type of the media (e.g. "image/png", "video/mp4"). */
575
+ mediaType: string
576
+ /** File size in bytes, if known. */
577
+ fileSize?: number
578
+ /** Arbitrary provider-specific metadata. */
579
+ metadata: any
580
+ }
581
+
582
+ /** Map of friendly format names to their MIME type strings. */
583
+ export interface JsMediaTypeMap {
584
+ png: string
585
+ jpeg: string
586
+ webp: string
587
+ gif: string
588
+ svg: string
589
+ bmp: string
590
+ tiff: string
591
+ avif: string
592
+ ico: string
593
+ mp4: string
594
+ webm: string
595
+ mov: string
596
+ avi: string
597
+ mkv: string
598
+ mp3: string
599
+ wav: string
600
+ ogg: string
601
+ flac: string
602
+ aac: string
603
+ m4A: string
604
+ glb: string
605
+ gltf: string
606
+ obj: string
607
+ fbx: string
608
+ usdz: string
609
+ stl: string
610
+ ply: string
611
+ pdf: string
612
+ }
613
+
614
+ /** Request to generate music or sound effects. */
615
+ export interface JsMusicRequest {
616
+ /** Text prompt describing the desired audio. */
617
+ prompt: string
618
+ /** Desired duration in seconds. */
619
+ durationSeconds?: number
620
+ /** Model override. */
621
+ model?: string
622
+ /** Additional provider-specific parameters. */
623
+ parameters?: any
624
+ }
625
+
626
+ /** Timing metadata for a completion request. */
627
+ export interface JsRequestTiming {
628
+ queueMs?: number
629
+ executionMs?: number
630
+ totalMs?: number
631
+ }
632
+
633
+ /** The role of a participant in a chat conversation. */
634
+ export declare const enum JsRole {
635
+ System = 'system',
636
+ User = 'user',
637
+ Assistant = 'assistant',
638
+ Tool = 'tool'
639
+ }
640
+
641
+ /** Request to generate speech from text (TTS). */
642
+ export interface JsSpeechRequest {
643
+ /** The text to synthesize into speech. */
644
+ text: string
645
+ /** Voice identifier (provider-specific). */
646
+ voice?: string
647
+ /** URL to a reference voice sample for voice cloning. */
648
+ voiceUrl?: string
649
+ /** Language code (e.g. "en", "fr", "ja"). */
650
+ language?: string
651
+ /** Speech speed multiplier (1.0 = normal). */
652
+ speed?: number
653
+ /** Model override. */
654
+ model?: string
655
+ /** Additional provider-specific parameters. */
656
+ parameters?: any
657
+ }
658
+
659
+ /** Request to generate a 3D model. */
660
+ export interface JsThreeDRequest {
661
+ /** Text prompt describing the desired 3D model. */
662
+ prompt?: string
663
+ /** Source image URL for image-to-3D generation. */
664
+ imageUrl?: string
665
+ /** Desired output format (e.g. "glb", "obj", "usdz"). */
666
+ format?: string
667
+ /** Model override. */
668
+ model?: string
669
+ /** Additional provider-specific parameters. */
670
+ parameters?: any
671
+ }
672
+
673
+ /** Result of a 3D model generation operation. */
674
+ export interface JsThreeDResult {
675
+ /** The generated 3D models. */
676
+ models: Array<JsGenerated3DModel>
677
+ /** Request timing breakdown. */
678
+ timing?: JsComputeTiming
679
+ /** Cost in USD, if reported by the provider. */
680
+ cost?: number
681
+ /** Arbitrary provider-specific metadata. */
682
+ metadata: any
683
+ }
684
+
685
+ /** Token usage statistics for a completion request. */
686
+ export interface JsTokenUsage {
687
+ promptTokens: number
688
+ completionTokens: number
689
+ totalTokens: number
690
+ }
691
+
692
+ /** A tool invocation requested by the model. */
693
+ export interface JsToolCall {
694
+ id: string
695
+ name: string
696
+ arguments: any
697
+ }
698
+
699
+ /** Describes a tool that the agent may invoke during its execution loop. */
700
+ export interface JsToolDef {
701
+ /** The unique name of the tool. */
702
+ name: string
703
+ /** A human-readable description of what the tool does. */
704
+ description: string
705
+ /** JSON Schema describing the tool's parameters. */
706
+ parameters: any
707
+ }
708
+
709
+ /** Describes a tool that the model may invoke during a conversation. */
710
+ export interface JsToolDefinition {
711
+ name: string
712
+ description: string
713
+ parameters: any
714
+ }
715
+
716
+ /** Request to transcribe audio to text. */
717
+ export interface JsTranscriptionRequest {
718
+ /** URL of the audio file to transcribe. */
719
+ audioUrl: string
720
+ /** Language hint (e.g. "en", "fr"). */
721
+ language?: string
722
+ /** Whether to perform speaker diarization. */
723
+ diarize?: boolean
724
+ /** Model override. */
725
+ model?: string
726
+ /** Additional provider-specific parameters. */
727
+ parameters?: any
728
+ }
729
+
730
+ /** Result of a transcription operation. */
731
+ export interface JsTranscriptionResult {
732
+ /** The full transcribed text. */
733
+ text: string
734
+ /** Time-aligned segments, if available. */
735
+ segments: Array<JsTranscriptionSegment>
736
+ /** Detected or specified language code (e.g. "en", "fr"). */
737
+ language?: string
738
+ /** Request timing breakdown. */
739
+ timing?: JsComputeTiming
740
+ /** Cost in USD, if reported by the provider. */
741
+ cost?: number
742
+ /** Arbitrary provider-specific metadata. */
743
+ metadata: any
744
+ }
745
+
746
+ /** A single segment within a transcription. */
747
+ export interface JsTranscriptionSegment {
748
+ /** The transcribed text for this segment. */
749
+ text: string
750
+ /** Start time in seconds. */
751
+ start: number
752
+ /** End time in seconds. */
753
+ end: number
754
+ /** Speaker label, if diarization was enabled. */
755
+ speaker?: string
756
+ }
757
+
758
+ /** Request to upscale an image. */
759
+ export interface JsUpscaleRequest {
760
+ /** URL of the image to upscale. */
761
+ imageUrl: string
762
+ /** Scale factor (e.g., 2.0 for 2x, 4.0 for 4x). */
763
+ scale: number
764
+ /** Model override. */
765
+ model?: string
766
+ /** Additional provider-specific parameters. */
767
+ parameters?: any
768
+ }
769
+
770
+ /** Request to generate a video. */
771
+ export interface JsVideoRequest {
772
+ /** Text prompt describing the desired video. */
773
+ prompt: string
774
+ /** Source image URL for image-to-video generation. */
775
+ imageUrl?: string
776
+ /** Desired duration in seconds. */
777
+ durationSeconds?: number
778
+ /** Negative prompt (things to avoid). */
779
+ negativePrompt?: string
780
+ /** Desired video width in pixels. */
781
+ width?: number
782
+ /** Desired video height in pixels. */
783
+ height?: number
784
+ /** Model override. */
785
+ model?: string
786
+ /** Additional provider-specific parameters. */
787
+ parameters?: any
788
+ }
789
+
790
+ /** Result of a video generation operation. */
791
+ export interface JsVideoResult {
792
+ /** The generated videos. */
793
+ videos: Array<JsGeneratedVideo>
794
+ /** Request timing breakdown. */
795
+ timing?: JsComputeTiming
796
+ /** Cost in USD, if reported by the provider. */
797
+ cost?: number
798
+ /** Arbitrary provider-specific metadata. */
799
+ metadata: any
800
+ }
801
+
258
802
  /** The result of a workflow run. */
259
803
  export interface JsWorkflowResult {
260
804
  /** The event type of the final result (typically "`blazen::StopEvent`"). */
@@ -263,5 +807,48 @@ export interface JsWorkflowResult {
263
807
  data: any
264
808
  }
265
809
 
810
+ /**
811
+ * Returns an object mapping friendly names to MIME type strings.
812
+ *
813
+ * ```typescript
814
+ * import { mediaTypes } from 'blazen';
815
+ *
816
+ * const types = mediaTypes();
817
+ * console.log(types.png); // "image/png"
818
+ * console.log(types.mp4); // "video/mp4"
819
+ * ```
820
+ */
821
+ export declare function mediaTypes(): JsMediaTypeMap
822
+
823
+ /**
824
+ * Run an agentic tool execution loop.
825
+ *
826
+ * The agent repeatedly calls the model, executes any tool calls via the
827
+ * `toolHandler` callback, feeds results back, and repeats until the model
828
+ * stops calling tools or `maxIterations` is reached.
829
+ *
830
+ * The `toolHandler` callback receives `(toolName: string, arguments: object)`
831
+ * and must return the tool result as a JSON-serializable value (or a Promise
832
+ * that resolves to one).
833
+ *
834
+ * ```typescript
835
+ * import { CompletionModel, ChatMessage, runAgent } from 'blazen';
836
+ *
837
+ * const model = CompletionModel.openai("sk-...");
838
+ *
839
+ * const result = await runAgent(
840
+ * model,
841
+ * [ChatMessage.user("What is the weather in NYC?")],
842
+ * [{ name: "getWeather", description: "Get weather", parameters: { type: "object", properties: { city: { type: "string" } }, required: ["city"] } }],
843
+ * async (toolName, args) => {
844
+ * if (toolName === "getWeather") return { temp: 72, condition: "sunny" };
845
+ * throw new Error(`Unknown tool: ${toolName}`);
846
+ * },
847
+ * { maxIterations: 5 }
848
+ * );
849
+ * ```
850
+ */
851
+ export declare function runAgent(model: JsCompletionModel, messages: Array<JsChatMessage>, tools: Array<JsToolDef>, toolHandler: ToolHandlerTsfn, options?: JsAgentRunOptions | undefined | null): Promise<JsAgentResult>
852
+
266
853
  /** Returns the version of the blazen library. */
267
854
  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.98' && 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.98 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.98' && 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.98 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.98' && 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.98 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.98' && 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.98 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.98' && 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.98 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.98' && 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.98 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.98' && 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.98 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.98' && 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.98 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.98' && 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.98 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.98' && 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.98 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.98' && 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.98 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.98' && 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.98 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.98' && 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.98 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.98' && 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.98 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.98' && 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.98 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.98' && 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.98 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.98' && 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.98 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.98' && 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.98 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.98' && 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.98 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.98' && 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.98 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.98' && 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.98 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.98' && 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.98 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.98' && 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.98 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.98' && 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.98 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.98' && 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.98 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.98' && 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.98 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
513
513
  }
514
514
  return binding
515
515
  } catch (e) {
@@ -576,6 +576,8 @@ 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
@@ -584,4 +586,8 @@ module.exports.Workflow = nativeBinding.Workflow
584
586
  module.exports.JsWorkflow = nativeBinding.JsWorkflow
585
587
  module.exports.WorkflowHandler = nativeBinding.WorkflowHandler
586
588
  module.exports.JsWorkflowHandler = nativeBinding.JsWorkflowHandler
589
+ module.exports.JsJobStatus = nativeBinding.JsJobStatus
590
+ module.exports.JsRole = nativeBinding.JsRole
591
+ module.exports.mediaTypes = nativeBinding.mediaTypes
592
+ module.exports.runAgent = nativeBinding.runAgent
587
593
  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.98",
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"