ai 7.0.0-beta.184 → 7.0.0-beta.186

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/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # ai
2
2
 
3
+ ## 7.0.0-beta.186
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [eb024b6]
8
+ - @ai-sdk/gateway@4.0.0-beta.113
9
+
10
+ ## 7.0.0-beta.185
11
+
12
+ ### Patch Changes
13
+
14
+ - 75763b0: agents: tag outgoing requests with an ai-sdk-agent user-agent segment for usage attribution (tool-loop, workflow)
15
+
3
16
  ## 7.0.0-beta.184
4
17
 
5
18
  ### Patch Changes
package/dist/index.d.ts CHANGED
@@ -5221,6 +5221,12 @@ declare class ToolLoopAgent<CALL_OPTIONS = never, TOOLS extends ToolSet = {}, RU
5221
5221
  */
5222
5222
  get tools(): TOOLS;
5223
5223
  private prepareCall;
5224
+ /**
5225
+ * Tags outgoing requests so usage can be attributed to ToolLoopAgent. Chains
5226
+ * with the `ai/<version>` and `ai-sdk/<provider>/<version>` suffixes added
5227
+ * downstream by generateText/streamText and the provider.
5228
+ */
5229
+ private agentHeaders;
5224
5230
  /**
5225
5231
  * Generates an output from the agent (non-streaming).
5226
5232
  */
package/dist/index.js CHANGED
@@ -19,7 +19,8 @@ import {
19
19
 
20
20
  // src/agent/tool-loop-agent.ts
21
21
  import {
22
- validateTypes as validateTypes3
22
+ validateTypes as validateTypes3,
23
+ withUserAgentSuffix as withUserAgentSuffix3
23
24
  } from "@ai-sdk/provider-utils";
24
25
 
25
26
  // src/generate-text/generate-text.ts
@@ -1088,7 +1089,7 @@ import {
1088
1089
  } from "@ai-sdk/provider-utils";
1089
1090
 
1090
1091
  // src/version.ts
1091
- var VERSION = true ? "7.0.0-beta.184" : "0.0.0-test";
1092
+ var VERSION = true ? "7.0.0-beta.186" : "0.0.0-test";
1092
1093
 
1093
1094
  // src/util/download/download.ts
1094
1095
  var download = async ({
@@ -10014,6 +10015,18 @@ var ToolLoopAgent = class {
10014
10015
  ...promptArgs
10015
10016
  };
10016
10017
  }
10018
+ /**
10019
+ * Tags outgoing requests so usage can be attributed to ToolLoopAgent. Chains
10020
+ * with the `ai/<version>` and `ai-sdk/<provider>/<version>` suffixes added
10021
+ * downstream by generateText/streamText and the provider.
10022
+ */
10023
+ agentHeaders(preparedCall) {
10024
+ var _a22;
10025
+ return withUserAgentSuffix3(
10026
+ (_a22 = preparedCall.headers) != null ? _a22 : {},
10027
+ "ai-sdk-agent/tool-loop"
10028
+ );
10029
+ }
10017
10030
  /**
10018
10031
  * Generates an output from the agent (non-streaming).
10019
10032
  */
@@ -10067,7 +10080,8 @@ var ToolLoopAgent = class {
10067
10080
  };
10068
10081
  return await generate({
10069
10082
  ...preparedCall,
10070
- ...callbackArgs
10083
+ ...callbackArgs,
10084
+ headers: this.agentHeaders(preparedCall)
10071
10085
  });
10072
10086
  }
10073
10087
  /**
@@ -10125,7 +10139,8 @@ var ToolLoopAgent = class {
10125
10139
  };
10126
10140
  return await stream({
10127
10141
  ...preparedCall,
10128
- ...callbackArgs
10142
+ ...callbackArgs,
10143
+ headers: this.agentHeaders(preparedCall)
10129
10144
  });
10130
10145
  }
10131
10146
  };
@@ -11087,7 +11102,7 @@ async function pipeAgentUIStreamToResponse({
11087
11102
  // src/embed/embed.ts
11088
11103
  import {
11089
11104
  createIdGenerator as createIdGenerator4,
11090
- withUserAgentSuffix as withUserAgentSuffix3
11105
+ withUserAgentSuffix as withUserAgentSuffix4
11091
11106
  } from "@ai-sdk/provider-utils";
11092
11107
  var originalGenerateCallId4 = createIdGenerator4({
11093
11108
  prefix: "call",
@@ -11116,7 +11131,7 @@ async function embed({
11116
11131
  });
11117
11132
  const resolvedOnStart = onStart != null ? onStart : experimental_onStart;
11118
11133
  const resolvedOnEnd = onEnd != null ? onEnd : experimental_onEnd;
11119
- const headersWithUserAgent = withUserAgentSuffix3(
11134
+ const headersWithUserAgent = withUserAgentSuffix4(
11120
11135
  headers != null ? headers : {},
11121
11136
  `ai/${VERSION}`
11122
11137
  );
@@ -11237,7 +11252,7 @@ var DefaultEmbedResult = class {
11237
11252
  // src/embed/embed-many.ts
11238
11253
  import {
11239
11254
  createIdGenerator as createIdGenerator5,
11240
- withUserAgentSuffix as withUserAgentSuffix4
11255
+ withUserAgentSuffix as withUserAgentSuffix5
11241
11256
  } from "@ai-sdk/provider-utils";
11242
11257
 
11243
11258
  // src/util/split-array.ts
@@ -11281,7 +11296,7 @@ async function embedMany({
11281
11296
  });
11282
11297
  const resolvedOnStart = onStart != null ? onStart : experimental_onStart;
11283
11298
  const resolvedOnEnd = onEnd != null ? onEnd : experimental_onEnd;
11284
- const headersWithUserAgent = withUserAgentSuffix4(
11299
+ const headersWithUserAgent = withUserAgentSuffix5(
11285
11300
  headers != null ? headers : {},
11286
11301
  `ai/${VERSION}`
11287
11302
  );
@@ -11507,7 +11522,7 @@ var DefaultEmbedManyResult = class {
11507
11522
  import {
11508
11523
  convertBase64ToUint8Array as convertBase64ToUint8Array4,
11509
11524
  detectMediaType as detectMediaType2,
11510
- withUserAgentSuffix as withUserAgentSuffix5
11525
+ withUserAgentSuffix as withUserAgentSuffix6
11511
11526
  } from "@ai-sdk/provider-utils";
11512
11527
 
11513
11528
  // src/prompt/data-content.ts
@@ -11561,7 +11576,7 @@ async function generateImage({
11561
11576
  }) {
11562
11577
  var _a22, _b;
11563
11578
  const model = resolveImageModel(modelArg);
11564
- const headersWithUserAgent = withUserAgentSuffix5(
11579
+ const headersWithUserAgent = withUserAgentSuffix6(
11565
11580
  headers != null ? headers : {},
11566
11581
  `ai/${VERSION}`
11567
11582
  );
@@ -11729,7 +11744,7 @@ function toImageModelV4File(dataContent) {
11729
11744
  // src/generate-object/generate-object.ts
11730
11745
  import {
11731
11746
  createIdGenerator as createIdGenerator6,
11732
- withUserAgentSuffix as withUserAgentSuffix6
11747
+ withUserAgentSuffix as withUserAgentSuffix7
11733
11748
  } from "@ai-sdk/provider-utils";
11734
11749
 
11735
11750
  // src/generate-text/extract-reasoning-content.ts
@@ -12253,7 +12268,7 @@ async function generateObject(options) {
12253
12268
  enumValues
12254
12269
  });
12255
12270
  const callSettings = prepareLanguageModelCallOptions(settings);
12256
- const headersWithUserAgent = withUserAgentSuffix6(
12271
+ const headersWithUserAgent = withUserAgentSuffix7(
12257
12272
  headers != null ? headers : {},
12258
12273
  `ai/${VERSION}`
12259
12274
  );
@@ -13090,7 +13105,7 @@ var DefaultStreamObjectResult = class {
13090
13105
  // src/generate-speech/generate-speech.ts
13091
13106
  import {
13092
13107
  detectMediaType as detectMediaType3,
13093
- withUserAgentSuffix as withUserAgentSuffix7
13108
+ withUserAgentSuffix as withUserAgentSuffix8
13094
13109
  } from "@ai-sdk/provider-utils";
13095
13110
 
13096
13111
  // src/generate-speech/generated-audio-file.ts
@@ -13137,7 +13152,7 @@ async function generateSpeech({
13137
13152
  if (!resolvedModel) {
13138
13153
  throw new Error("Model could not be resolved");
13139
13154
  }
13140
- const headersWithUserAgent = withUserAgentSuffix7(
13155
+ const headersWithUserAgent = withUserAgentSuffix8(
13141
13156
  headers != null ? headers : {},
13142
13157
  `ai/${VERSION}`
13143
13158
  );
@@ -13374,7 +13389,7 @@ function smoothStream({
13374
13389
  // src/generate-video/generate-video.ts
13375
13390
  import {
13376
13391
  convertBase64ToUint8Array as convertBase64ToUint8Array5,
13377
- withUserAgentSuffix as withUserAgentSuffix8,
13392
+ withUserAgentSuffix as withUserAgentSuffix9,
13378
13393
  detectMediaType as detectMediaType4
13379
13394
  } from "@ai-sdk/provider-utils";
13380
13395
  var defaultDownload = createDownload();
@@ -13397,7 +13412,7 @@ async function experimental_generateVideo({
13397
13412
  }) {
13398
13413
  var _a22;
13399
13414
  const model = resolveVideoModel(modelArg);
13400
- const headersWithUserAgent = withUserAgentSuffix8(
13415
+ const headersWithUserAgent = withUserAgentSuffix9(
13401
13416
  headers != null ? headers : {},
13402
13417
  `ai/${VERSION}`
13403
13418
  );
@@ -15715,7 +15730,7 @@ var DefaultRerankResult = class {
15715
15730
  // src/transcribe/transcribe.ts
15716
15731
  import {
15717
15732
  detectMediaType as detectMediaType5,
15718
- withUserAgentSuffix as withUserAgentSuffix9
15733
+ withUserAgentSuffix as withUserAgentSuffix10
15719
15734
  } from "@ai-sdk/provider-utils";
15720
15735
  var defaultDownload2 = createDownload();
15721
15736
  async function transcribe({
@@ -15735,7 +15750,7 @@ async function transcribe({
15735
15750
  maxRetries: maxRetriesArg,
15736
15751
  abortSignal
15737
15752
  });
15738
- const headersWithUserAgent = withUserAgentSuffix9(
15753
+ const headersWithUserAgent = withUserAgentSuffix10(
15739
15754
  headers != null ? headers : {},
15740
15755
  `ai/${VERSION}`
15741
15756
  );
@@ -15792,7 +15807,7 @@ var experimental_transcribe = transcribe;
15792
15807
  // src/ui/call-completion-api.ts
15793
15808
  import {
15794
15809
  parseJsonEventStream,
15795
- withUserAgentSuffix as withUserAgentSuffix10,
15810
+ withUserAgentSuffix as withUserAgentSuffix11,
15796
15811
  getRuntimeEnvironmentUserAgent as getRuntimeEnvironmentUserAgent2
15797
15812
  } from "@ai-sdk/provider-utils";
15798
15813
 
@@ -15842,7 +15857,7 @@ async function callCompletionApi({
15842
15857
  ...body
15843
15858
  }),
15844
15859
  credentials,
15845
- headers: withUserAgentSuffix10(
15860
+ headers: withUserAgentSuffix11(
15846
15861
  {
15847
15862
  "Content-Type": "application/json",
15848
15863
  ...headers