@voltro/ai 0.71.1 → 0.72.0

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.
package/dist/index.d.ts CHANGED
@@ -15,6 +15,7 @@ import { LanguageModelMiddleware } from 'ai';
15
15
  import { LanguageModelV4 } from '@ai-sdk/provider';
16
16
  import { LanguageModelV4Source } from '@ai-sdk/provider';
17
17
  import { ModelMessage } from 'ai';
18
+ import { PluginMediaPersistCapability } from '@voltro/protocol';
18
19
  import { QueryDescriptor } from '@voltro/database';
19
20
  import { QueryProcedureDescriptor } from '@voltro/protocol';
20
21
  import { Runtime } from 'effect';
@@ -468,6 +469,13 @@ export declare interface AiUsage {
468
469
  readonly totalTokens?: number | undefined;
469
470
  }
470
471
 
472
+ /**
473
+ * Price a usage tally and write a ledger row. Returns the computed
474
+ * `CostBreakdown` so the caller can surface the cost without a re-query.
475
+ */
476
+ /** What `recordAiUsage` did with the receipt: wrote it, or found it already written. */
477
+ export declare type AiUsageReceipt = 'recorded' | 'replayed';
478
+
471
479
  export declare interface AiUsageRecordInput {
472
480
  readonly tenantId?: string | null;
473
481
  readonly provider: ProviderName | string;
@@ -488,6 +496,14 @@ export declare interface AiUsageRecordInput {
488
496
  readonly prompt?: PromptStamp;
489
497
  /** Override the timestamp (tests; default `new Date()`). */
490
498
  readonly calledAt?: Date;
499
+ /** The request this call belongs to (a queued inference id, a message id, a
500
+ * workflow step's request id) and which attempt of it. Together they name
501
+ * the receipt, so a replayed recording writes one row. */
502
+ readonly requestId?: string;
503
+ readonly attempt?: number;
504
+ /** The receipt's idempotency key outright, when the caller has one that is
505
+ * not `requestId#attempt`. */
506
+ readonly receiptKey?: string;
491
507
  }
492
508
 
493
509
  /**
@@ -1443,6 +1459,10 @@ export declare interface GenerateImageOptions {
1443
1459
  readonly aspectRatio?: `${number}:${number}`;
1444
1460
  /** Provider-specific options forwarded to the SDK. */
1445
1461
  readonly providerOptions?: AiProviderOptions;
1462
+ /** Retries of a failed provider call (the SDK's default is 2). A charged call
1463
+ * that fails with a retryable status is paid again on every retry — set 0
1464
+ * where the caller retries on its own terms. */
1465
+ readonly maxRetries?: number;
1446
1466
  }
1447
1467
 
1448
1468
  export declare interface GenerateImageResult {
@@ -1542,6 +1562,8 @@ export declare interface GenerateObjectWithToolsOptions<A, I> {
1542
1562
  readonly prompt: string;
1543
1563
  readonly system?: string;
1544
1564
  readonly provider?: ProviderConfig;
1565
+ /** Abort the turn — the provider call and every tool, through one signal. */
1566
+ readonly abortSignal?: AbortSignal;
1545
1567
  /** Ordered provider/model fallback chain — see {@link ProviderFallbacks}. */
1546
1568
  readonly fallbacks?: ProviderFallbacks;
1547
1569
  readonly maxTokens?: number;
@@ -1620,6 +1642,10 @@ export declare interface GenerateTextOptions {
1620
1642
  readonly maxSteps?: number;
1621
1643
  /** Request context threaded into the tool executors. */
1622
1644
  readonly toolContext?: ToolContext;
1645
+ /** Abort the turn: the provider call is interrupted AND every tool sees the
1646
+ * same signal (`ctx.abortSignal`), so a tool call the model emitted just
1647
+ * before the abort does not run after it. */
1648
+ readonly abortSignal?: AbortSignal;
1623
1649
  /** The user prompt. The SDK auto-wraps it as the single user message. */
1624
1650
  readonly prompt?: string;
1625
1651
  /** Complete conversation, including the latest user message. Supply instead of prompt. */
@@ -1702,7 +1728,8 @@ export declare interface GenerateVideoOptions {
1702
1728
  }
1703
1729
 
1704
1730
  export declare interface GenerateVideoParams {
1705
- readonly aspectRatio?: `${number}:${number}`;
1731
+ /** `{width}:{height}`, or `adaptive` where the model derives it from the reference input. */
1732
+ readonly aspectRatio?: `${number}:${number}` | 'adaptive';
1706
1733
  readonly durationSeconds?: number;
1707
1734
  readonly resolution?: `${number}x${number}`;
1708
1735
  readonly fps?: number;
@@ -1802,6 +1829,13 @@ export declare interface InferenceDispatchDeps {
1802
1829
  bytes: Uint8Array;
1803
1830
  mediaType: string;
1804
1831
  }>;
1832
+ /**
1833
+ * Persist a media artifact a provider produced — the storage plugin's
1834
+ * `mediaPersist` capability, handed over by the host. Required for a `media`
1835
+ * job; a queued media job with no persistence is failed with the reason,
1836
+ * never resumed with bytes in the payload.
1837
+ */
1838
+ readonly persistMedia?: PluginMediaPersistCapability;
1805
1839
  /**
1806
1840
  * Resume the parked run with the call's outcome.
1807
1841
  *
@@ -2689,7 +2723,7 @@ export declare interface QueuedInference {
2689
2723
  readonly runId: string | null;
2690
2724
  readonly signalName: string;
2691
2725
  readonly stepName: string;
2692
- readonly kind: 'text' | 'object' | 'transcription';
2726
+ readonly kind: 'text' | 'object' | 'transcription' | 'media';
2693
2727
  readonly provider: string;
2694
2728
  readonly model: string;
2695
2729
  readonly prompt: string;
@@ -2703,7 +2737,28 @@ export declare interface QueuedInference {
2703
2737
  readonly jsonSchema: Record<string, unknown> | null;
2704
2738
  /** The source + options for a `transcription` call. */
2705
2739
  readonly transcription: Record<string, unknown> | null;
2740
+ /** The media job for a `media` call. */
2741
+ readonly media: QueuedMediaJob | null;
2706
2742
  readonly attempts: number;
2743
+ readonly fence: number;
2744
+ }
2745
+
2746
+ /** What a `media` row carries. Inputs are URLs; bytes never enter the queue. */
2747
+ export declare interface QueuedMediaJob {
2748
+ readonly modality: 'image' | 'video' | 'speech';
2749
+ readonly params: Record<string, unknown>;
2750
+ readonly inputs: Record<string, unknown>;
2751
+ }
2752
+
2753
+ /** What a media job resumes its run with: hosted artifacts, never bytes. */
2754
+ export declare interface QueuedMediaResult {
2755
+ readonly artifacts: ReadonlyArray<{
2756
+ readonly url: string;
2757
+ readonly refId: string | null;
2758
+ readonly mediaType: string;
2759
+ }>;
2760
+ readonly usage: unknown;
2761
+ readonly providerMetadata: unknown;
2707
2762
  }
2708
2763
 
2709
2764
  /** One entry of the raw `/v1/models` response, every field optional — the
@@ -2761,11 +2816,9 @@ export declare interface ReadRecorder<S extends QueryableStore> {
2761
2816
  reset(): void;
2762
2817
  }
2763
2818
 
2764
- /**
2765
- * Price a usage tally and write a ledger row. Returns the computed
2766
- * `CostBreakdown` so the caller can surface the cost without a re-query.
2767
- */
2768
- export declare const recordAiUsage: (store: DataStore, record: AiUsageRecordInput) => Effect.Effect<CostBreakdown>;
2819
+ export declare const recordAiUsage: (store: DataStore, record: AiUsageRecordInput) => Effect.Effect<CostBreakdown & {
2820
+ readonly receipt: AiUsageReceipt;
2821
+ }>;
2769
2822
 
2770
2823
  /**
2771
2824
  * Register a prompt version, idempotently, and return it.