ai 6.0.0-beta.97 → 6.0.0-beta.99

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -757,7 +757,7 @@ import {
757
757
  } from "@ai-sdk/provider-utils";
758
758
 
759
759
  // src/version.ts
760
- var VERSION = true ? "6.0.0-beta.97" : "0.0.0-test";
760
+ var VERSION = true ? "6.0.0-beta.99" : "0.0.0-test";
761
761
 
762
762
  // src/util/download/download.ts
763
763
  var download = async ({ url }) => {
@@ -1862,6 +1862,13 @@ function addLanguageModelUsage(usage1, usage2) {
1862
1862
  function addTokenCounts(tokenCount1, tokenCount2) {
1863
1863
  return tokenCount1 == null && tokenCount2 == null ? void 0 : (tokenCount1 != null ? tokenCount1 : 0) + (tokenCount2 != null ? tokenCount2 : 0);
1864
1864
  }
1865
+ function addImageModelUsage(usage1, usage2) {
1866
+ return {
1867
+ inputTokens: addTokenCounts(usage1.inputTokens, usage2.inputTokens),
1868
+ outputTokens: addTokenCounts(usage1.outputTokens, usage2.outputTokens),
1869
+ totalTokens: addTokenCounts(usage1.totalTokens, usage2.totalTokens)
1870
+ };
1871
+ }
1865
1872
 
1866
1873
  // src/util/as-array.ts
1867
1874
  function asArray(value) {
@@ -6627,14 +6634,26 @@ var ToolLoopAgent = class {
6627
6634
  /**
6628
6635
  * Generates an output from the agent (non-streaming).
6629
6636
  */
6630
- async generate(options) {
6631
- return generateText(await this.prepareCall(options));
6637
+ async generate({
6638
+ abortSignal,
6639
+ ...options
6640
+ }) {
6641
+ return generateText({
6642
+ ...await this.prepareCall(options),
6643
+ abortSignal
6644
+ });
6632
6645
  }
6633
6646
  /**
6634
6647
  * Streams an output from the agent (streaming).
6635
6648
  */
6636
- async stream(options) {
6637
- return streamText(await this.prepareCall(options));
6649
+ async stream({
6650
+ abortSignal,
6651
+ ...options
6652
+ }) {
6653
+ return streamText({
6654
+ ...await this.prepareCall(options),
6655
+ abortSignal
6656
+ });
6638
6657
  }
6639
6658
  };
6640
6659
 
@@ -7861,6 +7880,11 @@ async function generateImage({
7861
7880
  const warnings = [];
7862
7881
  const responses = [];
7863
7882
  const providerMetadata = {};
7883
+ let totalUsage = {
7884
+ inputTokens: void 0,
7885
+ outputTokens: void 0,
7886
+ totalTokens: void 0
7887
+ };
7864
7888
  for (const result of results) {
7865
7889
  images.push(
7866
7890
  ...result.images.map(
@@ -7877,6 +7901,9 @@ async function generateImage({
7877
7901
  )
7878
7902
  );
7879
7903
  warnings.push(...result.warnings);
7904
+ if (result.usage != null) {
7905
+ totalUsage = addImageModelUsage(totalUsage, result.usage);
7906
+ }
7880
7907
  if (result.providerMetadata) {
7881
7908
  for (const [providerName, metadata] of Object.entries(result.providerMetadata)) {
7882
7909
  (_b = providerMetadata[providerName]) != null ? _b : providerMetadata[providerName] = { images: [] };
@@ -7895,7 +7922,8 @@ async function generateImage({
7895
7922
  images,
7896
7923
  warnings,
7897
7924
  responses,
7898
- providerMetadata
7925
+ providerMetadata,
7926
+ usage: totalUsage
7899
7927
  });
7900
7928
  }
7901
7929
  var DefaultGenerateImageResult = class {
@@ -7904,6 +7932,7 @@ var DefaultGenerateImageResult = class {
7904
7932
  this.warnings = options.warnings;
7905
7933
  this.responses = options.responses;
7906
7934
  this.providerMetadata = options.providerMetadata;
7935
+ this.usage = options.usage;
7907
7936
  }
7908
7937
  get image() {
7909
7938
  return this.images[0];