@zenning/ai 5.3.0 → 5.3.1

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.js CHANGED
@@ -802,7 +802,7 @@ function detectMediaType({
802
802
  var import_provider_utils2 = require("@zenning/provider-utils");
803
803
 
804
804
  // src/version.ts
805
- var VERSION = true ? "5.3.0" : "0.0.0-test";
805
+ var VERSION = true ? "5.3.1" : "0.0.0-test";
806
806
 
807
807
  // src/util/download/download.ts
808
808
  var download = async ({ url }) => {
@@ -3693,38 +3693,53 @@ function processUIMessageStream({
3693
3693
  break;
3694
3694
  }
3695
3695
  case "source-url": {
3696
- state.message.parts.push({
3697
- type: "source-url",
3698
- sourceId: chunk.sourceId,
3699
- url: chunk.url,
3700
- title: chunk.title,
3701
- providerMetadata: chunk.providerMetadata
3702
- });
3703
- write();
3696
+ const existingSource = state.message.parts.find(
3697
+ (part) => part.type === "source-url" && part.sourceId === chunk.sourceId
3698
+ );
3699
+ if (!existingSource) {
3700
+ state.message.parts.push({
3701
+ type: "source-url",
3702
+ sourceId: chunk.sourceId,
3703
+ url: chunk.url,
3704
+ title: chunk.title,
3705
+ providerMetadata: chunk.providerMetadata
3706
+ });
3707
+ write();
3708
+ }
3704
3709
  break;
3705
3710
  }
3706
3711
  case "source-execution-file": {
3707
- state.message.parts.push({
3708
- type: "source-execution-file",
3709
- sourceId: chunk.sourceId,
3710
- providerMetadata: chunk.providerMetadata
3711
- });
3712
- write();
3712
+ const existingSource = state.message.parts.find(
3713
+ (part) => part.type === "source-execution-file" && part.sourceId === chunk.sourceId
3714
+ );
3715
+ if (!existingSource) {
3716
+ state.message.parts.push({
3717
+ type: "source-execution-file",
3718
+ sourceId: chunk.sourceId,
3719
+ providerMetadata: chunk.providerMetadata
3720
+ });
3721
+ write();
3722
+ }
3713
3723
  break;
3714
3724
  }
3715
3725
  case "source-document": {
3716
- state.message.parts.push({
3717
- type: "source-document",
3718
- sourceId: chunk.sourceId,
3719
- mediaType: chunk.mediaType,
3720
- title: chunk.title,
3721
- filename: chunk.filename,
3722
- fileId: chunk.fileId,
3723
- startIndex: chunk.startIndex,
3724
- endIndex: chunk.endIndex,
3725
- providerMetadata: chunk.providerMetadata
3726
- });
3727
- write();
3726
+ const existingSource = state.message.parts.find(
3727
+ (part) => part.type === "source-document" && part.sourceId === chunk.sourceId
3728
+ );
3729
+ if (!existingSource) {
3730
+ state.message.parts.push({
3731
+ type: "source-document",
3732
+ sourceId: chunk.sourceId,
3733
+ mediaType: chunk.mediaType,
3734
+ title: chunk.title,
3735
+ filename: chunk.filename,
3736
+ fileId: chunk.fileId,
3737
+ startIndex: chunk.startIndex,
3738
+ endIndex: chunk.endIndex,
3739
+ providerMetadata: chunk.providerMetadata
3740
+ });
3741
+ write();
3742
+ }
3728
3743
  break;
3729
3744
  }
3730
3745
  case "tool-input-start": {