ai 5.0.103 → 5.0.105

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,20 @@
1
1
  # ai
2
2
 
3
+ ## 5.0.105
4
+
5
+ ### Patch Changes
6
+
7
+ - 1063aca: fix(ai): Preverse providerMetadata in tool-call and tool-result parts
8
+
9
+ ## 5.0.104
10
+
11
+ ### Patch Changes
12
+
13
+ - d1dbe5d: move DelayedPromise into provider utils
14
+ - Updated dependencies [d1dbe5d]
15
+ - @ai-sdk/provider-utils@3.0.18
16
+ - @ai-sdk/gateway@2.0.17
17
+
3
18
  ## 5.0.103
4
19
 
5
20
  ### Patch Changes
package/dist/index.js CHANGED
@@ -777,7 +777,7 @@ function detectMediaType({
777
777
  var import_provider_utils2 = require("@ai-sdk/provider-utils");
778
778
 
779
779
  // src/version.ts
780
- var VERSION = true ? "5.0.103" : "0.0.0-test";
780
+ var VERSION = true ? "5.0.105" : "0.0.0-test";
781
781
 
782
782
  // src/util/download/download.ts
783
783
  var download = async ({ url }) => {
@@ -1969,7 +1969,8 @@ async function parseToolCall({
1969
1969
  input,
1970
1970
  dynamic: true,
1971
1971
  invalid: true,
1972
- error
1972
+ error,
1973
+ providerMetadata: toolCall.providerMetadata
1973
1974
  };
1974
1975
  }
1975
1976
  }
@@ -4235,44 +4236,6 @@ function createStitchableStream() {
4235
4236
  };
4236
4237
  }
4237
4238
 
4238
- // src/util/delayed-promise.ts
4239
- var DelayedPromise = class {
4240
- constructor() {
4241
- this.status = { type: "pending" };
4242
- this._resolve = void 0;
4243
- this._reject = void 0;
4244
- }
4245
- get promise() {
4246
- if (this._promise) {
4247
- return this._promise;
4248
- }
4249
- this._promise = new Promise((resolve2, reject) => {
4250
- if (this.status.type === "resolved") {
4251
- resolve2(this.status.value);
4252
- } else if (this.status.type === "rejected") {
4253
- reject(this.status.error);
4254
- }
4255
- this._resolve = resolve2;
4256
- this._reject = reject;
4257
- });
4258
- return this._promise;
4259
- }
4260
- resolve(value) {
4261
- var _a16;
4262
- this.status = { type: "resolved", value };
4263
- if (this._promise) {
4264
- (_a16 = this._resolve) == null ? void 0 : _a16.call(this, value);
4265
- }
4266
- }
4267
- reject(error) {
4268
- var _a16;
4269
- this.status = { type: "rejected", error };
4270
- if (this._promise) {
4271
- (_a16 = this._reject) == null ? void 0 : _a16.call(this, error);
4272
- }
4273
- }
4274
- };
4275
-
4276
4239
  // src/util/now.ts
4277
4240
  function now() {
4278
4241
  var _a16, _b;
@@ -4693,9 +4656,9 @@ var DefaultStreamTextResult = class {
4693
4656
  experimental_context,
4694
4657
  download: download2
4695
4658
  }) {
4696
- this._totalUsage = new DelayedPromise();
4697
- this._finishReason = new DelayedPromise();
4698
- this._steps = new DelayedPromise();
4659
+ this._totalUsage = new import_provider_utils15.DelayedPromise();
4660
+ this._finishReason = new import_provider_utils15.DelayedPromise();
4661
+ this._steps = new import_provider_utils15.DelayedPromise();
4699
4662
  this.output = output;
4700
4663
  this.includeRawChunks = includeRawChunks;
4701
4664
  this.tools = tools;
@@ -5005,7 +4968,7 @@ var DefaultStreamTextResult = class {
5005
4968
  }) {
5006
4969
  var _a16, _b, _c, _d, _e;
5007
4970
  const includeRawChunks2 = self.includeRawChunks;
5008
- stepFinish = new DelayedPromise();
4971
+ stepFinish = new import_provider_utils15.DelayedPromise();
5009
4972
  const initialPrompt = await standardizePrompt({
5010
4973
  system,
5011
4974
  prompt,
@@ -5973,7 +5936,8 @@ function convertToModelMessages(messages, options) {
5973
5936
  output: part.state === "output-error" ? part.errorText : part.output,
5974
5937
  tool: (_b = options == null ? void 0 : options.tools) == null ? void 0 : _b[toolName],
5975
5938
  errorMode: part.state === "output-error" ? "json" : "none"
5976
- })
5939
+ }),
5940
+ ...part.callProviderMetadata != null ? { providerOptions: part.callProviderMetadata } : {}
5977
5941
  });
5978
5942
  }
5979
5943
  }
@@ -6014,7 +5978,8 @@ function convertToModelMessages(messages, options) {
6014
5978
  output: toolPart.state === "output-error" ? toolPart.errorText : toolPart.output,
6015
5979
  tool: (_a17 = options == null ? void 0 : options.tools) == null ? void 0 : _a17[toolName],
6016
5980
  errorMode: toolPart.state === "output-error" ? "text" : "none"
6017
- })
5981
+ }),
5982
+ ...toolPart.callProviderMetadata != null ? { providerOptions: toolPart.callProviderMetadata } : {}
6018
5983
  };
6019
5984
  }
6020
5985
  default: {
@@ -7507,13 +7472,13 @@ var DefaultStreamObjectResult = class {
7507
7472
  currentDate,
7508
7473
  now: now2
7509
7474
  }) {
7510
- this._object = new DelayedPromise();
7511
- this._usage = new DelayedPromise();
7512
- this._providerMetadata = new DelayedPromise();
7513
- this._warnings = new DelayedPromise();
7514
- this._request = new DelayedPromise();
7515
- this._response = new DelayedPromise();
7516
- this._finishReason = new DelayedPromise();
7475
+ this._object = new import_provider_utils23.DelayedPromise();
7476
+ this._usage = new import_provider_utils23.DelayedPromise();
7477
+ this._providerMetadata = new import_provider_utils23.DelayedPromise();
7478
+ this._warnings = new import_provider_utils23.DelayedPromise();
7479
+ this._request = new import_provider_utils23.DelayedPromise();
7480
+ this._response = new import_provider_utils23.DelayedPromise();
7481
+ this._finishReason = new import_provider_utils23.DelayedPromise();
7517
7482
  const model = resolveLanguageModel(modelArg);
7518
7483
  const { maxRetries, retry } = prepareRetries({
7519
7484
  maxRetries: maxRetriesArg,