blazen 0.1.153 → 0.1.154

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/index.d.ts +712 -12
  2. package/index.js +30 -0
  3. package/package.json +23 -10
package/index.d.ts CHANGED
@@ -2612,7 +2612,7 @@ export type JsModelCache = ModelCache
2612
2612
  *
2613
2613
  * ```javascript
2614
2614
  * const manager = new ModelManager({ budgetGb: 8.0 });
2615
- * await manager.register("llama-7b", model, 4_000_000_000);
2615
+ * await manager.register("llama-7b", model, 4_000_000_000n); // BigInt
2616
2616
  * await manager.load("llama-7b");
2617
2617
  * ```
2618
2618
  */
@@ -2633,7 +2633,7 @@ export declare class ModelManager {
2633
2633
  * Only local in-process providers (mistral.rs, llama.cpp, candle) can be
2634
2634
  * registered -- remote HTTP providers will throw.
2635
2635
  */
2636
- register(id: string, model: JsCompletionModel, vramEstimateBytes?: number | undefined | null): Promise<void>
2636
+ register(id: string, model: JsCompletionModel, vramEstimateBytes?: bigint | undefined | null): Promise<void>
2637
2637
  /**
2638
2638
  * Load a model, evicting LRU models if the budget would be exceeded.
2639
2639
  *
@@ -2657,9 +2657,9 @@ export declare class ModelManager {
2657
2657
  */
2658
2658
  ensureLoaded(id: string): Promise<void>
2659
2659
  /** Total VRAM currently used by loaded models (in bytes). */
2660
- usedBytes(): Promise<number>
2660
+ usedBytes(): Promise<bigint>
2661
2661
  /** Available VRAM within the budget (in bytes). */
2662
- availableBytes(): Promise<number>
2662
+ availableBytes(): Promise<bigint>
2663
2663
  /** Status of all registered models. */
2664
2664
  status(): Promise<Array<JsModelStatus>>
2665
2665
  }
@@ -2719,6 +2719,21 @@ export declare class MusicProvider {
2719
2719
  }
2720
2720
  export type JsMusicProvider = MusicProvider
2721
2721
 
2722
+ /**
2723
+ * A no-op emitter that drops every event.
2724
+ *
2725
+ * Useful as a default when no downstream observer is wired up:
2726
+ *
2727
+ * ```javascript
2728
+ * const model = new UsageRecordingCompletionModel(base, new NoopUsageEmitter(), "openai");
2729
+ * ```
2730
+ */
2731
+ export declare class NoopUsageEmitter {
2732
+ /** Construct a no-op emitter. */
2733
+ constructor()
2734
+ }
2735
+ export type JsNoopUsageEmitter = NoopUsageEmitter
2736
+
2722
2737
  /**
2723
2738
  * An `OpenAI`-compatible embedding model (Together, Cohere, Fireworks).
2724
2739
  *
@@ -2873,6 +2888,37 @@ export declare class ParallelStage {
2873
2888
  }
2874
2889
  export type JsParallelStage = ParallelStage
2875
2890
 
2891
+ /**
2892
+ * Fan out into multiple parallel sub-workflow branches.
2893
+ *
2894
+ * Each branch is a `SubWorkflowStep` that runs concurrently. The
2895
+ * `joinStrategy` controls whether the parent waits for all branches
2896
+ * (`JoinStrategy.WaitAll`) or only the first to complete
2897
+ * (`JoinStrategy.FirstCompletes`).
2898
+ */
2899
+ export declare class ParallelSubWorkflowsStep {
2900
+ /**
2901
+ * Create a parallel sub-workflow fan-out step.
2902
+ *
2903
+ * `branches` is an array of already-constructed `SubWorkflowStep`
2904
+ * instances. The branches' inner workflows are captured by reference
2905
+ * so the parent step keeps a stable view even if the originals are
2906
+ * dropped from JS.
2907
+ *
2908
+ * `joinStrategy` defaults to `JoinStrategy.WaitAll`.
2909
+ */
2910
+ constructor(name: string, accepts: Array<string>, emits: Array<string>, branches: Array<SubWorkflowStep>, joinStrategy?: JoinStrategy | undefined | null)
2911
+ /** The step name. */
2912
+ get name(): string
2913
+ /** Event type identifiers this step accepts. */
2914
+ get accepts(): Array<string>
2915
+ /** Event type identifiers this step may emit. */
2916
+ get emits(): Array<string>
2917
+ /** The join strategy used to combine branch results. */
2918
+ get joinStrategy(): JoinStrategy
2919
+ }
2920
+ export type JsParallelSubWorkflowsStep = ParallelSubWorkflowsStep
2921
+
2876
2922
  /** A Perplexity chat completion provider. */
2877
2923
  export declare class PerplexityProvider {
2878
2924
  /** Create a new Perplexity provider. */
@@ -2897,6 +2943,12 @@ export declare class Pipeline {
2897
2943
  * Consumes the pipeline -- calling start/resume a second time errors.
2898
2944
  */
2899
2945
  start(input: any): Promise<PipelineHandler>
2946
+ /**
2947
+ * Inspect the pipeline-level default retry configuration, if any.
2948
+ * Mirrors [`blazen_pipeline::Pipeline::retry_config`] (Wave 2).
2949
+ * Returns `null` after the pipeline has been consumed.
2950
+ */
2951
+ retryConfig(): JsRetryConfig | null
2900
2952
  /**
2901
2953
  * Resume the pipeline from a previously captured snapshot.
2902
2954
  * Consumes the pipeline.
@@ -2914,6 +2966,31 @@ export declare class PipelineBuilder {
2914
2966
  parallel(parallel: JsParallelStage): this
2915
2967
  /** Set a per-stage timeout in seconds. Each stage's workflow gets this duration. */
2916
2968
  timeoutPerStage(seconds: number): this
2969
+ /**
2970
+ * Set a total wall-clock timeout for the entire pipeline run, in
2971
+ * seconds. When the pipeline does not finish within this duration the
2972
+ * run is cancelled with a `PipelineError::Timeout`. Default is no
2973
+ * total timeout. Mirrors [`blazen_pipeline::PipelineBuilder::total_timeout`].
2974
+ */
2975
+ totalTimeout(seconds: number): this
2976
+ /** Disable the total-pipeline timeout (default). */
2977
+ noTotalTimeout(): this
2978
+ /**
2979
+ * Set a default retry configuration applied to every LLM call inside
2980
+ * the pipeline. Workflow / step / per-call overrides take precedence.
2981
+ * Mirrors [`blazen_pipeline::PipelineBuilder::retry_config`].
2982
+ */
2983
+ retryConfig(config: JsRetryConfig): this
2984
+ /**
2985
+ * Disable pipeline-level retries (`maxRetries = 0`). Workflow / step /
2986
+ * per-call overrides still take precedence.
2987
+ */
2988
+ noRetry(): this
2989
+ /**
2990
+ * Clear any pipeline-level retry config; LLM calls fall through to
2991
+ * workflow / step / provider defaults.
2992
+ */
2993
+ clearRetryConfig(): this
2917
2994
  /**
2918
2995
  * Register a persist callback that receives a typed `PipelineSnapshot`
2919
2996
  * after each stage completes.
@@ -2954,6 +3031,13 @@ export declare class PipelineHandler {
2954
3031
  resumeInPlace(): Promise<void>
2955
3032
  /** Capture a snapshot without stopping the pipeline. */
2956
3033
  snapshot(): Promise<JsPipelineSnapshot>
3034
+ /**
3035
+ * Best-effort polled view of the pipeline's stage cursor. Mirrors
3036
+ * [`blazen_pipeline::PipelineHandler::progress`].
3037
+ *
3038
+ * Returns `null` after [`Self::result`] has consumed the handler.
3039
+ */
3040
+ progress(): Promise<JsProgressSnapshot | null>
2957
3041
  /** Abort the pipeline. */
2958
3042
  abort(): Promise<void>
2959
3043
  /**
@@ -2971,6 +3055,16 @@ export declare class PipelineResult {
2971
3055
  get finalOutput(): any
2972
3056
  get stageResults(): Array<StageResult>
2973
3057
  get sharedState(): any
3058
+ /**
3059
+ * Aggregated token usage across the pipeline run. Mirrors
3060
+ * [`blazen_pipeline::PipelineResult::usage_total`] (Wave 3).
3061
+ */
3062
+ get usageTotal(): JsTokenUsageClass
3063
+ /**
3064
+ * Aggregated cost in USD across the pipeline run. Mirrors
3065
+ * [`blazen_pipeline::PipelineResult::cost_total_usd`] (Wave 3).
3066
+ */
3067
+ get costTotalUsd(): number
2974
3068
  }
2975
3069
  export type JsPipelineResult = PipelineResult
2976
3070
 
@@ -3337,6 +3431,34 @@ export declare class RetryCompletionModel {
3337
3431
  }
3338
3432
  export type JsRetryCompletionModel = RetryCompletionModel
3339
3433
 
3434
+ /**
3435
+ * A `MemoryBackend` decorator that retries transient errors with
3436
+ * exponential backoff.
3437
+ *
3438
+ * Mirrors `RetryCompletionModel` for `MemoryBackend`. Use one of the
3439
+ * `wrapInMemory` / `wrapJsonl` / `wrapValkey` factories to wrap the
3440
+ * matching backend.
3441
+ *
3442
+ * ```javascript
3443
+ * const inner = new InMemoryBackend();
3444
+ * const retried = RetryMemoryBackend.wrapInMemory(inner, { maxRetries: 5 });
3445
+ * ```
3446
+ */
3447
+ export declare class RetryMemoryBackend {
3448
+ /** Wrap an `InMemoryBackend` with retry-on-transient-error behaviour. */
3449
+ static wrapInMemory(backend: InMemoryBackend, config?: JsRetryConfig | undefined | null): RetryMemoryBackend
3450
+ /** Wrap a `JsonlBackend` with retry-on-transient-error behaviour. */
3451
+ static wrapJsonl(backend: JsonlBackend, config?: JsRetryConfig | undefined | null): RetryMemoryBackend
3452
+ /** Wrap a `ValkeyBackend` with retry-on-transient-error behaviour. */
3453
+ static wrapValkey(backend: ValkeyBackend, config?: JsRetryConfig | undefined | null): RetryMemoryBackend
3454
+ /**
3455
+ * Generic factory accepting any of the three concrete backends. Useful
3456
+ * when the caller doesn't statically know which backend is in hand.
3457
+ */
3458
+ static wrap(backend: AnyBackend, config?: JsRetryConfig | undefined | null): RetryMemoryBackend
3459
+ }
3460
+ export type JsRetryMemoryBackend = RetryMemoryBackend
3461
+
3340
3462
  /**
3341
3463
  * Built-in middleware that wraps the inner model with retry-on-transient-
3342
3464
  * error behaviour. Equivalent to constructing a
@@ -3525,6 +3647,17 @@ export declare class StageResult {
3525
3647
  get output(): any
3526
3648
  get skipped(): boolean
3527
3649
  get durationMs(): number
3650
+ /**
3651
+ * Token usage for this stage, if any LLM calls inside the stage
3652
+ * emitted [`UsageEvent`](blazen_events::UsageEvent)s. Mirrors
3653
+ * [`blazen_pipeline::StageResult::usage`] (Wave 3).
3654
+ */
3655
+ get usage(): JsTokenUsageClass | null
3656
+ /**
3657
+ * Cost in USD for this stage, if known. Mirrors
3658
+ * [`blazen_pipeline::StageResult::cost_usd`] (Wave 3).
3659
+ */
3660
+ get costUsd(): number | null
3528
3661
  }
3529
3662
  export type JsStageResult = StageResult
3530
3663
 
@@ -3774,6 +3907,41 @@ export declare class StructuredOutput {
3774
3907
  }
3775
3908
  export type JsStructuredOutput = StructuredOutput
3776
3909
 
3910
+ /**
3911
+ * A workflow step that delegates to another `Workflow`.
3912
+ *
3913
+ * The parent workflow's event loop spawns the child via `Workflow.run()`,
3914
+ * converts the parent event to JSON for the child's input, and wraps the
3915
+ * child's terminal `StopEvent.result` into a `DynamicEvent` named
3916
+ * `"<stepName>::output"` for the parent.
3917
+ *
3918
+ * ```javascript
3919
+ * const child = new Workflow("enrich");
3920
+ * child.addStep("enrich", ["blazen::StartEvent"], async (ev) => ({ type: "blazen::StopEvent", result: { ok: true } }));
3921
+ * const step = new SubWorkflowStep("enrich", ["blazen::StartEvent"], ["enrich::output"], child);
3922
+ * const parent = new Workflow("parent");
3923
+ * parent.addSubworkflowStepObj(step);
3924
+ * ```
3925
+ */
3926
+ export declare class SubWorkflowStep {
3927
+ /**
3928
+ * Create a sub-workflow step.
3929
+ *
3930
+ * `name` / `accepts` / `emits` describe routing. `inner` is the child
3931
+ * workflow whose event loop is spawned for each parent dispatch. The
3932
+ * inner workflow is cloned (and built) at construction time so this
3933
+ * step instance can be reused across builders.
3934
+ */
3935
+ constructor(name: string, accepts: Array<string>, emits: Array<string>, inner: JsWorkflow, timeoutSecs?: number | undefined | null, retryConfig?: JsRetryConfig | undefined | null)
3936
+ /** The step name. */
3937
+ get name(): string
3938
+ /** Event type identifiers this step accepts. */
3939
+ get accepts(): Array<string>
3940
+ /** Event type identifiers this step may emit. */
3941
+ get emits(): Array<string>
3942
+ }
3943
+ export type JsSubWorkflowStep = SubWorkflowStep
3944
+
3777
3945
  /**
3778
3946
  * r" Base class for 3D model generation providers.
3779
3947
  * r"
@@ -4113,9 +4281,93 @@ export declare class TypedTool {
4113
4281
  get description(): string
4114
4282
  /** The JSON Schema parameter definition. */
4115
4283
  get parameters(): any
4284
+ /**
4285
+ * Whether this tool is marked as an "exit" tool, signalling the agent
4286
+ * loop to stop after it runs. Mirrors
4287
+ * [`blazen_llm::Tool::is_exit`] (Wave 6).
4288
+ */
4289
+ get isExit(): boolean
4290
+ /**
4291
+ * Builder-style toggle for the exit-tool marker. Returns a new
4292
+ * [`JsTypedTool`] that shares the same underlying handler but
4293
+ * reports the requested [`Tool::is_exit`] value. Mirrors
4294
+ * [`blazen_llm::TypedTool::exit_tool`] (Wave 6).
4295
+ *
4296
+ * ```typescript
4297
+ * const exit = new TypedTool(
4298
+ * "submit",
4299
+ * "Submit the final answer and exit",
4300
+ * { type: "object", properties: { answer: { type: "string" } }, required: ["answer"] },
4301
+ * async (_n, args) => ({ submitted: args.answer }),
4302
+ * ).exitTool(true);
4303
+ * ```
4304
+ */
4305
+ exitTool(exit: boolean): TypedTool
4116
4306
  }
4117
4307
  export type JsTypedTool = TypedTool
4118
4308
 
4309
+ /**
4310
+ * A sink for emitted [`JsUsageEvent`]s.
4311
+ *
4312
+ * Construct with a JS callback that handles each event. The callback runs
4313
+ * on the libuv main thread, so it can do anything synchronous; a thrown
4314
+ * error is caught and logged, never propagated into the completion call.
4315
+ *
4316
+ * ```javascript
4317
+ * const events: UsageEvent[] = [];
4318
+ * const emitter = new UsageEmitter((event) => { events.push(event); });
4319
+ * const model = new UsageRecordingCompletionModel(base, emitter, "openai");
4320
+ * ```
4321
+ */
4322
+ export declare class UsageEmitter {
4323
+ /**
4324
+ * Create an emitter from a JS callback. The callback is invoked once
4325
+ * per emitted event.
4326
+ */
4327
+ constructor(callback: ((arg: UsageEvent) => void))
4328
+ }
4329
+ export type JsUsageEmitter = UsageEmitter
4330
+
4331
+ /**
4332
+ * A `CompletionModel` decorator that emits a `UsageEvent` after each
4333
+ * successful `complete` call. Mirrors
4334
+ * `blazen_llm::usage_recording::UsageRecordingCompletionModel`.
4335
+ *
4336
+ * ```javascript
4337
+ * const base = CompletionModel.openai();
4338
+ * const events = [];
4339
+ * const emitter = new UsageEmitter((e) => events.push(e));
4340
+ * const model = new UsageRecordingCompletionModel(base, emitter, "openai");
4341
+ * const response = await model.complete([ChatMessage.user("hi")]);
4342
+ * ```
4343
+ */
4344
+ export declare class UsageRecordingCompletionModel {
4345
+ /** Wrap a `CompletionModel` with a usage-recording layer. */
4346
+ constructor(model: CompletionModel, emitter: AnyEmitter, providerLabel: string, runId?: string | undefined | null)
4347
+ /** The underlying provider's model id. */
4348
+ get modelId(): string
4349
+ /**
4350
+ * Convert this decorator into a `CompletionModel` so it can be passed to
4351
+ * APIs that expect the base type (`runAgent`, further decorators, …).
4352
+ */
4353
+ toCompletionModel(): CompletionModel
4354
+ }
4355
+ export type JsUsageRecordingCompletionModel = UsageRecordingCompletionModel
4356
+
4357
+ /**
4358
+ * An `EmbeddingModel` decorator that emits a `UsageEvent` after each
4359
+ * successful `embed` call.
4360
+ */
4361
+ export declare class UsageRecordingEmbeddingModel {
4362
+ /** Wrap an `EmbeddingModel` with a usage-recording layer. */
4363
+ constructor(model: EmbeddingModel, emitter: AnyEmitter, providerLabel: string, runId?: string | undefined | null)
4364
+ /** The underlying provider's model id. */
4365
+ get modelId(): string
4366
+ /** Output dimensionality. */
4367
+ get dimensions(): number
4368
+ }
4369
+ export type JsUsageRecordingEmbeddingModel = UsageRecordingEmbeddingModel
4370
+
4119
4371
  /**
4120
4372
  * A Valkey/Redis-backed backend for the memory store.
4121
4373
  *
@@ -4307,6 +4559,45 @@ export declare class Workflow {
4307
4559
  * started, step completed, step failed). Defaults to `false`.
4308
4560
  */
4309
4561
  setAutoPublishEvents(enabled: boolean): void
4562
+ /**
4563
+ * Register a sub-workflow step that delegates to another `Workflow`.
4564
+ * Mirrors [`blazen_core::WorkflowBuilder::add_subworkflow_step`].
4565
+ *
4566
+ * - `name`: human-readable step name.
4567
+ * - `accepts`: array of event type strings this step handles.
4568
+ * - `emits`: array of event type strings this step may emit (informational).
4569
+ * - `inner`: the child `Workflow` to run.
4570
+ * - `timeoutSecs`: optional wall-clock timeout for the child run.
4571
+ * - `retryConfig`: optional retry policy for the child run.
4572
+ */
4573
+ addSubworkflowStep(name: string, accepts: Array<string>, emits: Array<string>, inner: Workflow, timeoutSecs?: number | undefined | null, retryConfig?: JsRetryConfig | undefined | null): void
4574
+ /**
4575
+ * Register a parallel sub-workflows fan-out step. Mirrors
4576
+ * [`blazen_core::WorkflowBuilder::add_parallel_subworkflows`].
4577
+ *
4578
+ * `branchSpecs` and `branchWorkflows` are parallel arrays of equal
4579
+ * length: each `(spec, wf)` pair becomes one branch. They're split
4580
+ * into two parameters because napi-rs cannot embed napi-class values
4581
+ * (the `Workflow` instances) inside `#[napi(object)]` shapes.
4582
+ *
4583
+ * `joinStrategy` defaults to `WaitAll`.
4584
+ */
4585
+ addParallelSubworkflows(name: string, accepts: Array<string>, emits: Array<string>, branchSpecs: Array<SubWorkflowBranchSpec>, branchWorkflows: Array<Workflow>, joinStrategy?: JoinStrategy | undefined | null): void
4586
+ /**
4587
+ * Register a pre-built [`SubWorkflowStep`] wrapper.
4588
+ *
4589
+ * Object-form of [`Self::add_subworkflow_step`]: the same step instance
4590
+ * can be reused across multiple workflows since its inner child
4591
+ * workflow is captured in `Arc` form at construction time.
4592
+ */
4593
+ addSubworkflowStepObj(step: SubWorkflowStep): void
4594
+ /**
4595
+ * Register a pre-built [`ParallelSubWorkflowsStep`] wrapper.
4596
+ *
4597
+ * Object-form of [`Self::add_parallel_subworkflows`]: lifts the
4598
+ * awkward parallel-arrays signature into a single class instance.
4599
+ */
4600
+ addParallelSubworkflowsObj(step: ParallelSubWorkflowsStep): void
4310
4601
  /**
4311
4602
  * Add a step to the workflow.
4312
4603
  *
@@ -4462,6 +4753,31 @@ export declare class WorkflowBuilder {
4462
4753
  * `SessionPausePolicy.PickleOrError`.
4463
4754
  */
4464
4755
  sessionPausePolicy(policy: SessionPausePolicy): this
4756
+ /**
4757
+ * Set a per-step wall-clock timeout in seconds on the most-recently
4758
+ * added step. Mirrors [`blazen_core::WorkflowBuilder::step_timeout`].
4759
+ * Errors if no step has been registered yet.
4760
+ */
4761
+ stepTimeout(seconds: number): this
4762
+ /** Clear the per-step timeout on the most-recently added step. */
4763
+ noStepTimeout(): this
4764
+ /**
4765
+ * Set a per-step retry config on the most-recently added step.
4766
+ * Mirrors [`blazen_core::WorkflowBuilder::step_retry`].
4767
+ */
4768
+ stepRetry(config: JsRetryConfig): this
4769
+ /** Disable retries on the most-recently added step (`maxRetries = 0`). */
4770
+ noStepRetry(): this
4771
+ /**
4772
+ * Set a workflow-level default retry config. Step / per-call
4773
+ * overrides take precedence; pipeline / provider defaults take
4774
+ * lower precedence.
4775
+ */
4776
+ retryConfig(config: JsRetryConfig): this
4777
+ /** Disable workflow-level retries (`maxRetries = 0`). */
4778
+ noRetry(): this
4779
+ /** Clear any workflow-level retry config. */
4780
+ clearRetryConfig(): this
4465
4781
  /**
4466
4782
  * Enable history collection.
4467
4783
  *
@@ -4611,6 +4927,19 @@ export declare class WorkflowHandler {
4611
4927
  * they may have built earlier.
4612
4928
  */
4613
4929
  respondToInputTyped(event: InputResponseEvent): Promise<void>
4930
+ /**
4931
+ * Aggregated token usage across the workflow run so far.
4932
+ *
4933
+ * Mirrors [`blazen_core::WorkflowHandler::usage_total`]. Returns
4934
+ * `null` after the handler has been consumed by [`Self::result`].
4935
+ */
4936
+ usageTotal(): Promise<TokenUsage | null>
4937
+ /**
4938
+ * Aggregated cost in USD across the workflow run so far. Mirrors
4939
+ * [`blazen_core::WorkflowHandler::cost_total_usd`]. Returns `null`
4940
+ * after the handler has been consumed by [`Self::result`].
4941
+ */
4942
+ costTotalUsd(): Promise<number | null>
4614
4943
  /** Abort the running workflow. */
4615
4944
  abort(): Promise<void>
4616
4945
  /**
@@ -4731,6 +5060,19 @@ export declare class XaiProvider {
4731
5060
  }
4732
5061
  export type JsXaiProvider = XaiProvider
4733
5062
 
5063
+ /**
5064
+ * Aggregate one [`JsUsageEvent`] into a [`crate::types::JsTokenUsageClass`].
5065
+ * Returns a fresh class instance that adds the seven token counters from the
5066
+ * event into the existing usage. Mirrors the Rust `TokenUsage::add` /
5067
+ * `PipelineState::record_usage` flow at the JS layer.
5068
+ *
5069
+ * # Errors
5070
+ *
5071
+ * Currently never returns an error; the [`Result`] return is reserved for
5072
+ * future validation (e.g. parsing the `runId` UUID).
5073
+ */
5074
+ export declare function addUsageToTokenUsage(base: JsTokenUsageClass, event: UsageEvent): JsTokenUsageClass
5075
+
4734
5076
  /**
4735
5077
  * Typed configuration for the agentic tool execution loop.
4736
5078
  *
@@ -4742,8 +5084,23 @@ export type JsXaiProvider = XaiProvider
4742
5084
  export interface AgentConfig {
4743
5085
  /** Maximum number of tool call rounds before forcing a stop. */
4744
5086
  maxIterations: number
4745
- /** Whether to add an implicit "finish" tool the model can call to exit early. */
5087
+ /**
5088
+ * Whether to add the legacy implicit "finish" tool the model can call
5089
+ * to exit early.
5090
+ */
4746
5091
  addFinishTool: boolean
5092
+ /**
5093
+ * Suppress automatic registration of the built-in `finish_workflow`
5094
+ * exit tool. Default `false`. Mirrors
5095
+ * [`blazen_llm::AgentConfig::no_finish_tool`] (Wave 6).
5096
+ */
5097
+ noFinishTool: boolean
5098
+ /**
5099
+ * Override the name of the built-in `finish_workflow` tool. `null`
5100
+ * uses the canonical [`crate::agent::FINISH_WORKFLOW_TOOL_NAME`].
5101
+ * Mirrors [`blazen_llm::AgentConfig::finish_tool_name`] (Wave 6).
5102
+ */
5103
+ finishToolName?: string
4747
5104
  /** Optional system prompt prepended to messages. */
4748
5105
  systemPrompt?: string
4749
5106
  /** Sampling temperature. */
@@ -4948,6 +5305,14 @@ export interface CompletionRequest {
4948
5305
  audioConfig?: any
4949
5306
  }
4950
5307
 
5308
+ /**
5309
+ * Compute the cost in USD for an audio call (TTS / STT) given the model id
5310
+ * and the duration in seconds. Returns `null` when the model has no
5311
+ * `perSecond` pricing entry registered. Mirrors
5312
+ * [`blazen_llm::compute_audio_cost`].
5313
+ */
5314
+ export declare function computeAudioCost(modelId: string, seconds: number): number | null
5315
+
4951
5316
  /**
4952
5317
  * Compute ELID-based similarity between two embedding vectors.
4953
5318
  *
@@ -4965,6 +5330,18 @@ export declare function computeElidSimilarity(a: Array<number>, b: Array<number>
4965
5330
  */
4966
5331
  export declare function computeEmbeddingSimhashSimilarity(a: Array<number>, b: Array<number>): number
4967
5332
 
5333
+ /**
5334
+ * Compute the cost in USD for an image-generation call given the model id
5335
+ * and the number of images returned. Returns `null` when the model has no
5336
+ * `perImage` pricing entry registered. Mirrors
5337
+ * [`blazen_llm::compute_image_cost`].
5338
+ *
5339
+ * ```javascript
5340
+ * const cost = computeImageCost("dall-e-3", 4);
5341
+ * ```
5342
+ */
5343
+ export declare function computeImageCost(modelId: string, imageCount: number): number | null
5344
+
4968
5345
  /**
4969
5346
  * Compute similarity between two text strings using 64-bit `SimHash`.
4970
5347
  *
@@ -4973,6 +5350,14 @@ export declare function computeEmbeddingSimhashSimilarity(a: Array<number>, b: A
4973
5350
  */
4974
5351
  export declare function computeTextSimhashSimilarity(a: string, b: string): number
4975
5352
 
5353
+ /**
5354
+ * Compute the cost in USD for a video-generation call given the model id
5355
+ * and the output duration in seconds. Returns `null` when the model has no
5356
+ * `perSecond` pricing entry registered. Mirrors
5357
+ * [`blazen_llm::compute_video_cost`].
5358
+ */
5359
+ export declare function computeVideoCost(modelId: string, seconds: number): number | null
5360
+
4976
5361
  /**
4977
5362
  * Estimate the total token count for an array of chat messages.
4978
5363
  *
@@ -4999,6 +5384,9 @@ export interface CustomProviderOptions {
4999
5384
  providerId?: string
5000
5385
  }
5001
5386
 
5387
+ /** Build a default [`JsHttpClientConfig`] (60s request, 10s connect, no UA). */
5388
+ export declare function defaultHttpClientConfig(): HttpClientConfig
5389
+
5002
5390
  /**
5003
5391
  * Configuration for subclassed `EmbeddingModel` instances.
5004
5392
  *
@@ -5097,6 +5485,30 @@ export interface FileContent {
5097
5485
  filename?: string
5098
5486
  }
5099
5487
 
5488
+ /**
5489
+ * Canonical name of the built-in `finish_workflow` exit tool. Mirrors
5490
+ * [`blazen_llm::FINISH_WORKFLOW_TOOL_NAME`].
5491
+ */
5492
+ export const FINISH_WORKFLOW_TOOL_NAME: string
5493
+
5494
+ /**
5495
+ * Alias of [`finish_workflow_tool_def`] under the canonical Rust name
5496
+ * (`finish_workflow_tool` → `finishWorkflowTool` in JS). Returns a
5497
+ * `JsToolDef` for the built-in exit tool.
5498
+ *
5499
+ * Mirrors `blazen_llm::finish_workflow_tool` and `blazen-py`'s
5500
+ * `finish_workflow_tool()` for cross-binding parity.
5501
+ */
5502
+ export declare function finishWorkflowTool(): JsToolDef
5503
+
5504
+ /**
5505
+ * Build a fresh JSON-Schema description of the built-in `finish_workflow`
5506
+ * exit tool. The shape mirrors [`blazen_llm::finish_workflow_tool`] —
5507
+ * callers that want to surface the same tool to a JS-side agent loop can
5508
+ * use this object as a [`JsToolDef`] entry.
5509
+ */
5510
+ export declare function finishWorkflowToolDef(): JsToolDef
5511
+
5100
5512
  /**
5101
5513
  * Format the tail of a `ProviderHttp` error message, the same way
5102
5514
  * `BlazenError::ProviderHttp` does internally.
@@ -5153,6 +5565,40 @@ export declare const enum HistoryEventKindTag {
5153
5565
  WorkflowTimedOut = 'WorkflowTimedOut'
5154
5566
  }
5155
5567
 
5568
+ /**
5569
+ * Configuration applied when constructing the default HTTP client.
5570
+ *
5571
+ * Mirrors [`HttpClientConfig`]. All fields are optional in JS — pass
5572
+ * `null` / `undefined` for any field to mean "no timeout / no UA
5573
+ * override".
5574
+ *
5575
+ * ```typescript
5576
+ * const cfg: HttpClientConfig = {
5577
+ * requestTimeoutMs: 30_000,
5578
+ * connectTimeoutMs: 5_000,
5579
+ * userAgent: "my-app/1.0",
5580
+ * };
5581
+ * const unlimited = HttpClientConfig.unlimited();
5582
+ * ```
5583
+ */
5584
+ export interface HttpClientConfig {
5585
+ /**
5586
+ * Maximum wall-clock duration for a single request, in milliseconds.
5587
+ * `null` / `undefined` means unlimited.
5588
+ */
5589
+ requestTimeoutMs?: number
5590
+ /**
5591
+ * Maximum duration for the connection-establishment phase, in
5592
+ * milliseconds. `null` / `undefined` means unlimited.
5593
+ */
5594
+ connectTimeoutMs?: number
5595
+ /**
5596
+ * User-Agent header string. `null` / `undefined` uses the underlying
5597
+ * client's default.
5598
+ */
5599
+ userAgent?: string
5600
+ }
5601
+
5156
5602
  /**
5157
5603
  * Initialize the Langfuse exporter and install it as a layer on the global
5158
5604
  * `tracing` subscriber.
@@ -5252,10 +5698,22 @@ export interface JsAgentRunOptions {
5252
5698
  /** Maximum tokens per completion call. */
5253
5699
  maxTokens?: number
5254
5700
  /**
5255
- * Whether to add a built-in "finish" tool that the model can call to
5256
- * signal it has a final answer.
5701
+ * Whether to add the legacy implicit "finish" tool the model can call
5702
+ * to signal it has a final answer.
5257
5703
  */
5258
5704
  addFinishTool?: boolean
5705
+ /**
5706
+ * Suppress automatic registration of the built-in `finish_workflow`
5707
+ * exit tool (default `false`, i.e. it is auto-added). Mirrors
5708
+ * [`blazen_llm::AgentConfig::no_finish_tool`] (Wave 6).
5709
+ */
5710
+ noFinishTool?: boolean
5711
+ /**
5712
+ * Override the name of the built-in `finish_workflow` tool. Defaults
5713
+ * to [`FINISH_WORKFLOW_TOOL_NAME`]. Mirrors
5714
+ * [`blazen_llm::AgentConfig::finish_tool_name`] (Wave 6).
5715
+ */
5716
+ finishToolName?: string
5259
5717
  /**
5260
5718
  * Maximum number of tool calls to execute concurrently within a single
5261
5719
  * model response. `0` means unlimited (all in parallel). Defaults to 0.
@@ -5319,6 +5777,8 @@ export interface JsAudioResult {
5319
5777
  audio: Array<JsGeneratedAudio>
5320
5778
  timing: JsRequestTiming
5321
5779
  cost?: number
5780
+ usage?: JsTokenUsage
5781
+ audioSeconds?: number
5322
5782
  metadata: any
5323
5783
  }
5324
5784
 
@@ -5768,6 +6228,8 @@ export interface JsImageResult {
5768
6228
  images: Array<JsGeneratedImage>
5769
6229
  timing: JsRequestTiming
5770
6230
  cost?: number
6231
+ usage?: JsTokenUsage
6232
+ imageCount?: number
5771
6233
  metadata: any
5772
6234
  }
5773
6235
 
@@ -5922,7 +6384,7 @@ export interface JsModelStatus {
5922
6384
  /** Whether the model is currently loaded into VRAM. */
5923
6385
  loaded: boolean
5924
6386
  /** Estimated VRAM footprint in bytes. */
5925
- vramEstimate: number
6387
+ vramEstimate: bigint
5926
6388
  }
5927
6389
 
5928
6390
  export interface JsMusicRequest {
@@ -6239,6 +6701,7 @@ export interface JsThreeDResult {
6239
6701
  models: Array<JsGenerated3DModel>
6240
6702
  timing: JsRequestTiming
6241
6703
  cost?: number
6704
+ usage?: JsTokenUsage
6242
6705
  metadata: any
6243
6706
  }
6244
6707
 
@@ -6337,6 +6800,8 @@ export interface JsTranscriptionResult {
6337
6800
  language?: string
6338
6801
  timing: JsRequestTiming
6339
6802
  cost?: number
6803
+ usage?: JsTokenUsage
6804
+ audioSeconds?: number
6340
6805
  metadata: any
6341
6806
  }
6342
6807
 
@@ -6376,6 +6841,8 @@ export interface JsVideoResult {
6376
6841
  videos: Array<JsGeneratedVideo>
6377
6842
  timing: JsRequestTiming
6378
6843
  cost?: number
6844
+ usage?: JsTokenUsage
6845
+ videoSeconds?: number
6379
6846
  metadata: any
6380
6847
  }
6381
6848
 
@@ -6481,6 +6948,16 @@ export interface JsWorkflowResult {
6481
6948
  type: string
6482
6949
  /** The result data as a JSON object. */
6483
6950
  data: any
6951
+ /**
6952
+ * Aggregated token usage across the run, mirroring
6953
+ * [`blazen_core::WorkflowResult::usage_total`].
6954
+ */
6955
+ usageTotal: JsTokenUsage
6956
+ /**
6957
+ * Aggregated cost in USD across the run, mirroring
6958
+ * [`blazen_core::WorkflowResult::cost_total_usd`].
6959
+ */
6960
+ costTotalUsd: number
6484
6961
  }
6485
6962
 
6486
6963
  /**
@@ -6585,6 +7062,28 @@ export interface MessageContent {
6585
7062
  parts?: Array<JsContentPart>
6586
7063
  }
6587
7064
 
7065
+ /**
7066
+ * Discriminant for the kind of provider call a [`JsUsageEvent`] describes.
7067
+ *
7068
+ * Mirrors [`blazen_events::Modality`]. The string-enum representation
7069
+ * matches the `Modality::*` unit variants. Custom modalities (the Rust
7070
+ * `Modality::Custom(String)` variant) are surfaced via the
7071
+ * [`JsUsageEvent::modalityCustom`] string field — when `modalityCustom`
7072
+ * is non-null, callers should treat `modality` as `Custom` regardless of
7073
+ * its value.
7074
+ */
7075
+ export declare const enum Modality {
7076
+ Llm = 'Llm',
7077
+ Embedding = 'Embedding',
7078
+ ImageGen = 'ImageGen',
7079
+ AudioTts = 'AudioTts',
7080
+ AudioStt = 'AudioStt',
7081
+ Video = 'Video',
7082
+ ThreeD = 'ThreeD',
7083
+ BackgroundRemoval = 'BackgroundRemoval',
7084
+ Custom = 'Custom'
7085
+ }
7086
+
6588
7087
  /**
6589
7088
  * Capability flags advertised by a model.
6590
7089
  *
@@ -6645,10 +7144,20 @@ export interface ModelInfo {
6645
7144
  export interface ModelManagerConfig {
6646
7145
  /** VRAM budget in gigabytes (e.g. `8.0` for 8 GiB). */
6647
7146
  budgetGb?: number
6648
- /** VRAM budget in bytes. */
6649
- budgetBytes?: number
7147
+ /** VRAM budget in bytes (pass as JS `BigInt` to support values >4 GiB). */
7148
+ budgetBytes?: bigint
6650
7149
  }
6651
7150
 
7151
+ /** Build an empty [`JsRetryStack`] with every scope set to `null`. */
7152
+ export declare function newRetryStack(): RetryStack
7153
+
7154
+ /**
7155
+ * Build a default [`JsUsageEvent`] for the given provider / model, with
7156
+ * every numeric field zeroed and `modality = Llm`. Useful as a starting
7157
+ * point for emitter shims that only know a subset of the fields.
7158
+ */
7159
+ export declare function newUsageEvent(provider: string, model: string, runId: string): UsageEvent
7160
+
6652
7161
  /**
6653
7162
  * Why a workflow was paused.
6654
7163
  *
@@ -6679,14 +7188,76 @@ export interface PersistedEvent {
6679
7188
  *
6680
7189
  * Mirrors [`blazen_llm::PricingEntry`]. The existing
6681
7190
  * [`crate::types::pricing::JsModelPricing`] is a richer "input" type that
6682
- * also carries `perImage` / `perSecond`; this shape only covers the
6683
- * per-million token rates the registry actually stores.
7191
+ * also carries `perImage` / `perSecond`; this shape covers the
7192
+ * per-million token rates the registry actually stores, plus optional
7193
+ * per-image and per-second rates for multimodal/audio/video models.
6684
7194
  */
6685
7195
  export interface PricingEntry {
6686
7196
  /** USD per million input (prompt) tokens. */
6687
7197
  inputPerMillion: number
6688
7198
  /** USD per million output (completion) tokens. */
6689
7199
  outputPerMillion: number
7200
+ /** USD per image (for multimodal models). `null` if not applicable. */
7201
+ perImage?: number
7202
+ /** USD per second (for audio/video models). `null` if not applicable. */
7203
+ perSecond?: number
7204
+ }
7205
+
7206
+ /**
7207
+ * Per-stage / per-step progress tick emitted by Pipeline and Workflow
7208
+ * runners. Mirrors [`blazen_events::ProgressEvent`].
7209
+ *
7210
+ * `total` and `percent` are absent (`undefined`) when the step set is
7211
+ * dynamic and the total is not known up front.
7212
+ */
7213
+ export interface ProgressEvent {
7214
+ /** What this progress event describes. */
7215
+ kind: ProgressKind
7216
+ /** Current step / stage index (1-based). */
7217
+ current: number
7218
+ /** Total number of steps / stages, when known. */
7219
+ total?: number
7220
+ /** Progress as a percentage in `0.0..=100.0`, when computable. */
7221
+ percent?: number
7222
+ /** Human-readable label for this progress tick (typically the step name). */
7223
+ label: string
7224
+ /** UUID of the run this progress belongs to. */
7225
+ runId: string
7226
+ }
7227
+
7228
+ /**
7229
+ * What a [`JsProgressEvent`] describes. Mirrors
7230
+ * [`blazen_events::ProgressKind`].
7231
+ */
7232
+ export declare const enum ProgressKind {
7233
+ Pipeline = 'Pipeline',
7234
+ Workflow = 'Workflow',
7235
+ SubWorkflow = 'SubWorkflow',
7236
+ Stage = 'Stage'
7237
+ }
7238
+
7239
+ /**
7240
+ * Lightweight, polled view of a running pipeline's progress.
7241
+ *
7242
+ * Mirrors [`ProgressSnapshot`]. Reads are best-effort and may briefly be
7243
+ * one stage behind the actual position because they do not synchronise
7244
+ * with the executor task.
7245
+ */
7246
+ export interface ProgressSnapshot {
7247
+ /**
7248
+ * 1-based index of the stage currently executing (or just completed).
7249
+ * `0` before the first stage starts.
7250
+ */
7251
+ currentStageIndex: number
7252
+ /** Total number of stages declared on the pipeline. */
7253
+ totalStages: number
7254
+ /** Progress as a percentage in `0.0..=100.0`. */
7255
+ percent: number
7256
+ /**
7257
+ * Name of the current stage, when available. Always `null` from the
7258
+ * current atomic-index implementation; reserved for future use.
7259
+ */
7260
+ currentStageName?: string
6690
7261
  }
6691
7262
 
6692
7263
  /** Options for creating a `PromptTemplate`. */
@@ -6915,6 +7486,39 @@ export declare function resolveApiKey(provider: string, explicit?: string | unde
6915
7486
  */
6916
7487
  export declare function resolveBeerToken(): string | null
6917
7488
 
7489
+ /**
7490
+ * Resolve the effective [`JsRetryConfig`] for the given stack and an
7491
+ * optional per-call override. Mirrors [`RetryStack::resolve`].
7492
+ *
7493
+ * ```typescript
7494
+ * const effective = resolveRetryStack(
7495
+ * { workflow: { maxRetries: 5 } },
7496
+ * { maxRetries: 9 }, // per-call override wins
7497
+ * );
7498
+ * // effective.maxRetries === 9
7499
+ * ```
7500
+ */
7501
+ export declare function resolveRetryStack(stack: RetryStack, callOverride?: JsRetryConfig | undefined | null): JsRetryConfig
7502
+
7503
+ /**
7504
+ * Snapshot of every scope's retry configuration. Mirrors
7505
+ * [`RetryStack`].
7506
+ *
7507
+ * All fields are optional; any combination of `null` / `undefined`
7508
+ * scopes is valid and falls through to the next-outer non-`None` scope
7509
+ * when [`resolveRetryStack`] is called.
7510
+ */
7511
+ export interface RetryStack {
7512
+ /** Provider-level default (lowest priority). */
7513
+ provider?: JsRetryConfig
7514
+ /** Pipeline-level default. */
7515
+ pipeline?: JsRetryConfig
7516
+ /** Workflow-level override. */
7517
+ workflow?: JsRetryConfig
7518
+ /** Step-level override (highest priority before the per-call override). */
7519
+ step?: JsRetryConfig
7520
+ }
7521
+
6918
7522
  /**
6919
7523
  * Run an agentic tool execution loop.
6920
7524
  *
@@ -7145,6 +7749,26 @@ export interface StructuredResponse {
7145
7749
  artifacts: Array<JsArtifact>
7146
7750
  }
7147
7751
 
7752
+ /**
7753
+ * Plain-object descriptor for one branch of a parallel fan-out — every
7754
+ * field except `workflowName` is metadata. The actual child `Workflow`
7755
+ * instances are passed alongside the spec array in
7756
+ * [`JsWorkflow::addParallelSubworkflows`] (napi cannot embed napi-class
7757
+ * values inside `#[napi(object)]` shapes).
7758
+ */
7759
+ export interface SubWorkflowBranchSpec {
7760
+ /** Human-readable name for this branch. */
7761
+ name: string
7762
+ /** Event types this branch's parent step accepts. */
7763
+ accepts: Array<string>
7764
+ /** Event types this branch's parent step may emit (informational). */
7765
+ emits: Array<string>
7766
+ /** Optional wall-clock timeout in seconds for this branch. */
7767
+ timeoutSecs?: number
7768
+ /** Optional retry config for this branch. */
7769
+ retryConfig?: JsRetryConfig
7770
+ }
7771
+
7148
7772
  /**
7149
7773
  * The role for a prompt template.
7150
7774
  *
@@ -7239,6 +7863,82 @@ export declare function tryDeserializeEvent(name: string, jsonStr: string): Prom
7239
7863
  */
7240
7864
  export declare function typedToolSimple(name: string, description: string, parameters: any, handler: TypedToolHandlerTsfn): TypedTool
7241
7865
 
7866
+ /**
7867
+ * Build a [`JsHttpClientConfig`] with no request or connect timeout.
7868
+ * Mirrors [`HttpClientConfig::unlimited`].
7869
+ */
7870
+ export declare function unlimitedHttpClientConfig(): HttpClientConfig
7871
+
7872
+ /**
7873
+ * Token / cost / latency snapshot for a single provider call, emitted
7874
+ * after each LLM / embedding / image / audio / video / 3D request.
7875
+ *
7876
+ * Pipelines and workflows aggregate these into [`PipelineState.usageTotal`]
7877
+ * and [`PipelineState.costTotalUsd`] when a `UsageEmitter` is wired up.
7878
+ *
7879
+ * ```typescript
7880
+ * import { UsageEvent, Modality } from 'blazen';
7881
+ *
7882
+ * const ev: UsageEvent = {
7883
+ * provider: "openai",
7884
+ * model: "gpt-4o-mini",
7885
+ * modality: Modality.Llm,
7886
+ * promptTokens: 100,
7887
+ * completionTokens: 25,
7888
+ * totalTokens: 125,
7889
+ * reasoningTokens: 0,
7890
+ * cachedInputTokens: 0,
7891
+ * audioInputTokens: 0,
7892
+ * audioOutputTokens: 0,
7893
+ * imageCount: 0,
7894
+ * audioSeconds: 0,
7895
+ * videoSeconds: 0,
7896
+ * latencyMs: 432,
7897
+ * costUsd: 0.000_25,
7898
+ * runId: "...",
7899
+ * };
7900
+ * ```
7901
+ */
7902
+ export interface UsageEvent {
7903
+ /** The provider that served the call (e.g. `"openai"`, `"anthropic"`). */
7904
+ provider: string
7905
+ /** The model identifier. */
7906
+ model: string
7907
+ /** Discriminant for the kind of call. */
7908
+ modality: Modality
7909
+ /**
7910
+ * Free-form custom-modality label. Populated when [`Self::modality`] is
7911
+ * [`JsModality::Custom`]; ignored otherwise.
7912
+ */
7913
+ modalityCustom?: string
7914
+ /** Number of prompt / input tokens billed. */
7915
+ promptTokens: number
7916
+ /** Number of completion / output tokens billed. */
7917
+ completionTokens: number
7918
+ /** Total tokens billed (typically `promptTokens + completionTokens`). */
7919
+ totalTokens: number
7920
+ /** Reasoning tokens (e.g. `OpenAI` o-series, Anthropic extended thinking). */
7921
+ reasoningTokens: number
7922
+ /** Tokens served from the provider's prompt cache at a discount. */
7923
+ cachedInputTokens: number
7924
+ /** Audio input tokens (multimodal speech-in models). */
7925
+ audioInputTokens: number
7926
+ /** Audio output tokens (multimodal speech-out models). */
7927
+ audioOutputTokens: number
7928
+ /** Number of images generated or processed. */
7929
+ imageCount: number
7930
+ /** Audio duration in seconds (for STT inputs and TTS outputs). */
7931
+ audioSeconds: number
7932
+ /** Video duration in seconds. */
7933
+ videoSeconds: number
7934
+ /** Cost in USD as reported (or computed) for this call. */
7935
+ costUsd?: number
7936
+ /** Wall-clock latency of the provider call in milliseconds. */
7937
+ latencyMs: number
7938
+ /** UUID of the run / pipeline invocation this usage belongs to. */
7939
+ runId: string
7940
+ }
7941
+
7242
7942
  /** Returns the version of the blazen library. */
7243
7943
  export declare function version(): string
7244
7944
 
package/index.js CHANGED
@@ -720,6 +720,8 @@ module.exports.ModelRegistry = nativeBinding.ModelRegistry
720
720
  module.exports.JsModelRegistry = nativeBinding.JsModelRegistry
721
721
  module.exports.MusicProvider = nativeBinding.MusicProvider
722
722
  module.exports.JsMusicProvider = nativeBinding.JsMusicProvider
723
+ module.exports.NoopUsageEmitter = nativeBinding.NoopUsageEmitter
724
+ module.exports.JsNoopUsageEmitter = nativeBinding.JsNoopUsageEmitter
723
725
  module.exports.OpenAiCompatEmbeddingModel = nativeBinding.OpenAiCompatEmbeddingModel
724
726
  module.exports.JsOpenAiCompatEmbeddingModel = nativeBinding.JsOpenAiCompatEmbeddingModel
725
727
  module.exports.OpenAiCompatProvider = nativeBinding.OpenAiCompatProvider
@@ -732,6 +734,8 @@ module.exports.OpenRouterProvider = nativeBinding.OpenRouterProvider
732
734
  module.exports.JsOpenRouterProvider = nativeBinding.JsOpenRouterProvider
733
735
  module.exports.ParallelStage = nativeBinding.ParallelStage
734
736
  module.exports.JsParallelStage = nativeBinding.JsParallelStage
737
+ module.exports.ParallelSubWorkflowsStep = nativeBinding.ParallelSubWorkflowsStep
738
+ module.exports.JsParallelSubWorkflowsStep = nativeBinding.JsParallelSubWorkflowsStep
735
739
  module.exports.PerplexityProvider = nativeBinding.PerplexityProvider
736
740
  module.exports.JsPerplexityProvider = nativeBinding.JsPerplexityProvider
737
741
  module.exports.Pipeline = nativeBinding.Pipeline
@@ -766,6 +770,8 @@ module.exports.RequestTiming = nativeBinding.RequestTiming
766
770
  module.exports.JsRequestTimingClass = nativeBinding.JsRequestTimingClass
767
771
  module.exports.RetryCompletionModel = nativeBinding.RetryCompletionModel
768
772
  module.exports.JsRetryCompletionModel = nativeBinding.JsRetryCompletionModel
773
+ module.exports.RetryMemoryBackend = nativeBinding.RetryMemoryBackend
774
+ module.exports.JsRetryMemoryBackend = nativeBinding.JsRetryMemoryBackend
769
775
  module.exports.RetryMiddleware = nativeBinding.RetryMiddleware
770
776
  module.exports.JsRetryMiddleware = nativeBinding.JsRetryMiddleware
771
777
  module.exports.SessionNamespace = nativeBinding.SessionNamespace
@@ -792,6 +798,8 @@ module.exports.StopEvent = nativeBinding.StopEvent
792
798
  module.exports.JsStopEventClass = nativeBinding.JsStopEventClass
793
799
  module.exports.StructuredOutput = nativeBinding.StructuredOutput
794
800
  module.exports.JsStructuredOutput = nativeBinding.JsStructuredOutput
801
+ module.exports.SubWorkflowStep = nativeBinding.SubWorkflowStep
802
+ module.exports.JsSubWorkflowStep = nativeBinding.JsSubWorkflowStep
795
803
  module.exports.ThreeDProvider = nativeBinding.ThreeDProvider
796
804
  module.exports.JsThreeDProvider = nativeBinding.JsThreeDProvider
797
805
  module.exports.TogetherProvider = nativeBinding.TogetherProvider
@@ -814,6 +822,12 @@ module.exports.TTSProvider = nativeBinding.TTSProvider
814
822
  module.exports.JsTTSProvider = nativeBinding.JsTTSProvider
815
823
  module.exports.TypedTool = nativeBinding.TypedTool
816
824
  module.exports.JsTypedTool = nativeBinding.JsTypedTool
825
+ module.exports.UsageEmitter = nativeBinding.UsageEmitter
826
+ module.exports.JsUsageEmitter = nativeBinding.JsUsageEmitter
827
+ module.exports.UsageRecordingCompletionModel = nativeBinding.UsageRecordingCompletionModel
828
+ module.exports.JsUsageRecordingCompletionModel = nativeBinding.JsUsageRecordingCompletionModel
829
+ module.exports.UsageRecordingEmbeddingModel = nativeBinding.UsageRecordingEmbeddingModel
830
+ module.exports.JsUsageRecordingEmbeddingModel = nativeBinding.JsUsageRecordingEmbeddingModel
817
831
  module.exports.ValkeyBackend = nativeBinding.ValkeyBackend
818
832
  module.exports.JsValkeyBackend = nativeBinding.JsValkeyBackend
819
833
  module.exports.ValkeyCheckpointStore = nativeBinding.ValkeyCheckpointStore
@@ -838,17 +852,25 @@ module.exports.WorkflowSnapshot = nativeBinding.WorkflowSnapshot
838
852
  module.exports.JsWorkflowSnapshot = nativeBinding.JsWorkflowSnapshot
839
853
  module.exports.XaiProvider = nativeBinding.XaiProvider
840
854
  module.exports.JsXaiProvider = nativeBinding.JsXaiProvider
855
+ module.exports.addUsageToTokenUsage = nativeBinding.addUsageToTokenUsage
841
856
  module.exports.ChatRole = nativeBinding.ChatRole
842
857
  module.exports.JsChatRole = nativeBinding.JsChatRole
843
858
  module.exports.completeBatch = nativeBinding.completeBatch
844
859
  module.exports.completeBatchConfig = nativeBinding.completeBatchConfig
860
+ module.exports.computeAudioCost = nativeBinding.computeAudioCost
845
861
  module.exports.computeElidSimilarity = nativeBinding.computeElidSimilarity
846
862
  module.exports.computeEmbeddingSimhashSimilarity = nativeBinding.computeEmbeddingSimhashSimilarity
863
+ module.exports.computeImageCost = nativeBinding.computeImageCost
847
864
  module.exports.computeTextSimhashSimilarity = nativeBinding.computeTextSimhashSimilarity
865
+ module.exports.computeVideoCost = nativeBinding.computeVideoCost
848
866
  module.exports.countMessageTokens = nativeBinding.countMessageTokens
867
+ module.exports.defaultHttpClientConfig = nativeBinding.defaultHttpClientConfig
849
868
  module.exports.envVarForProvider = nativeBinding.envVarForProvider
850
869
  module.exports.estimateTokens = nativeBinding.estimateTokens
851
870
  module.exports.extractInlineArtifacts = nativeBinding.extractInlineArtifacts
871
+ module.exports.FINISH_WORKFLOW_TOOL_NAME = nativeBinding.FINISH_WORKFLOW_TOOL_NAME
872
+ module.exports.finishWorkflowTool = nativeBinding.finishWorkflowTool
873
+ module.exports.finishWorkflowToolDef = nativeBinding.finishWorkflowToolDef
852
874
  module.exports.formatProviderHttpTail = nativeBinding.formatProviderHttpTail
853
875
  module.exports.getContextWindow = nativeBinding.getContextWindow
854
876
  module.exports.HistoryEventKindTag = nativeBinding.HistoryEventKindTag
@@ -870,10 +892,16 @@ module.exports.loadClientTls = nativeBinding.loadClientTls
870
892
  module.exports.loadServerTls = nativeBinding.loadServerTls
871
893
  module.exports.lookupPricing = nativeBinding.lookupPricing
872
894
  module.exports.lookupStepBuilder = nativeBinding.lookupStepBuilder
895
+ module.exports.Modality = nativeBinding.Modality
896
+ module.exports.JsModality = nativeBinding.JsModality
897
+ module.exports.newRetryStack = nativeBinding.newRetryStack
898
+ module.exports.newUsageEvent = nativeBinding.newUsageEvent
873
899
  module.exports.PauseReason = nativeBinding.PauseReason
874
900
  module.exports.JsPauseReason = nativeBinding.JsPauseReason
875
901
  module.exports.peerEnvelopeVersion = nativeBinding.peerEnvelopeVersion
876
902
  module.exports.peerTokenEnv = nativeBinding.peerTokenEnv
903
+ module.exports.ProgressKind = nativeBinding.ProgressKind
904
+ module.exports.JsProgressKind = nativeBinding.JsProgressKind
877
905
  module.exports.providerEnvVars = nativeBinding.providerEnvVars
878
906
  module.exports.ProviderId = nativeBinding.ProviderId
879
907
  module.exports.JsProviderId = nativeBinding.JsProviderId
@@ -886,6 +914,7 @@ module.exports.registerPricing = nativeBinding.registerPricing
886
914
  module.exports.registerStepBuilder = nativeBinding.registerStepBuilder
887
915
  module.exports.resolveApiKey = nativeBinding.resolveApiKey
888
916
  module.exports.resolveBeerToken = nativeBinding.resolveBeerToken
917
+ module.exports.resolveRetryStack = nativeBinding.resolveRetryStack
889
918
  module.exports.runAgent = nativeBinding.runAgent
890
919
  module.exports.runAgentWithCallback = nativeBinding.runAgentWithCallback
891
920
  module.exports.SessionPausePolicy = nativeBinding.SessionPausePolicy
@@ -900,6 +929,7 @@ module.exports.TemplateRole = nativeBinding.TemplateRole
900
929
  module.exports.JsTemplateRole = nativeBinding.JsTemplateRole
901
930
  module.exports.tryDeserializeEvent = nativeBinding.tryDeserializeEvent
902
931
  module.exports.typedToolSimple = nativeBinding.typedToolSimple
932
+ module.exports.unlimitedHttpClientConfig = nativeBinding.unlimitedHttpClientConfig
903
933
  module.exports.version = nativeBinding.version
904
934
 
905
935
  // --- post-build: typed-error wrapping ---
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "blazen",
3
- "version": "0.1.153",
3
+ "version": "0.1.154",
4
4
  "description": "Blazen - Event-driven AI workflow framework for Node.js/TypeScript",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -40,23 +40,36 @@
40
40
  ],
41
41
  "devDependencies": {
42
42
  "@napi-rs/cli": "^3.0.0",
43
- "@biomejs/biome": "^2"
43
+ "@biomejs/biome": "^2",
44
+ "ava": "^6.4.1"
44
45
  },
45
46
  "engines": {
46
47
  "node": ">= 18"
47
48
  },
49
+ "ava": {
50
+ "files": [
51
+ "../../tests/node/test_*.mjs"
52
+ ],
53
+ "extensions": [
54
+ "mjs"
55
+ ],
56
+ "timeout": "120s",
57
+ "concurrency": 4,
58
+ "verbose": true
59
+ },
48
60
  "optionalDependencies": {
49
- "@blazen-dev/blazen-linux-x64-gnu": "0.1.153",
50
- "@blazen-dev/blazen-linux-x64-musl": "0.1.153",
51
- "@blazen-dev/blazen-linux-arm64-gnu": "0.1.153",
52
- "@blazen-dev/blazen-linux-arm64-musl": "0.1.153",
53
- "@blazen-dev/blazen-darwin-arm64": "0.1.153",
54
- "@blazen-dev/blazen-win32-x64-msvc": "0.1.153"
61
+ "@blazen-dev/blazen-linux-x64-gnu": "0.1.154",
62
+ "@blazen-dev/blazen-linux-x64-musl": "0.1.154",
63
+ "@blazen-dev/blazen-linux-arm64-gnu": "0.1.154",
64
+ "@blazen-dev/blazen-linux-arm64-musl": "0.1.154",
65
+ "@blazen-dev/blazen-darwin-arm64": "0.1.154",
66
+ "@blazen-dev/blazen-win32-x64-msvc": "0.1.154"
55
67
  },
56
68
  "scripts": {
57
69
  "build": "napi build --release --platform --features local-all,langfuse --js index.js && node scripts/post-build.mjs",
58
70
  "build:debug": "napi build --platform --features local-all,langfuse --js index.js && node scripts/post-build.mjs",
59
- "test": "node --test ../../tests/node/test_workflow.mjs",
60
- "test:smoke": "node --test ../../tests/node/test_llm_smoke.mjs"
71
+ "test": "ava",
72
+ "test:workflow": "ava ../../tests/node/test_workflow.mjs",
73
+ "test:smoke": "ava ../../tests/node/test_llm_smoke.mjs"
61
74
  }
62
75
  }