ai 6.0.295 → 6.0.296

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
@@ -1224,7 +1224,7 @@ import {
1224
1224
  } from "@ai-sdk/provider-utils";
1225
1225
 
1226
1226
  // src/version.ts
1227
- var VERSION = true ? "6.0.295" : "0.0.0-test";
1227
+ var VERSION = true ? "6.0.296" : "0.0.0-test";
1228
1228
 
1229
1229
  // src/util/download/download.ts
1230
1230
  var download = async ({
@@ -5950,7 +5950,7 @@ function processUIMessageStream({
5950
5950
  new TransformStream({
5951
5951
  async transform(chunk, controller) {
5952
5952
  await runUpdateMessageJob(async ({ state, write }) => {
5953
- var _a23, _b, _c, _d;
5953
+ var _a23, _b, _c, _d, _e, _f, _g, _h;
5954
5954
  function getCurrentStepParts() {
5955
5955
  const parts = state.message.parts;
5956
5956
  let currentStepStartIndex = parts.length - 1;
@@ -6384,7 +6384,7 @@ function processUIMessageStream({
6384
6384
  providerExecuted: chunk.providerExecuted,
6385
6385
  providerMetadata: chunk.providerMetadata,
6386
6386
  title: toolInvocation.title,
6387
- toolMetadata: toolInvocation.toolMetadata
6387
+ toolMetadata: (_e = chunk.toolMetadata) != null ? _e : toolInvocation.toolMetadata
6388
6388
  },
6389
6389
  toolInvocation
6390
6390
  );
@@ -6400,7 +6400,7 @@ function processUIMessageStream({
6400
6400
  preliminary: chunk.preliminary,
6401
6401
  providerMetadata: chunk.providerMetadata,
6402
6402
  title: toolInvocation.title,
6403
- toolMetadata: toolInvocation.toolMetadata
6403
+ toolMetadata: (_f = chunk.toolMetadata) != null ? _f : toolInvocation.toolMetadata
6404
6404
  },
6405
6405
  toolInvocation
6406
6406
  );
@@ -6421,7 +6421,7 @@ function processUIMessageStream({
6421
6421
  providerExecuted: chunk.providerExecuted,
6422
6422
  providerMetadata: chunk.providerMetadata,
6423
6423
  title: toolInvocation.title,
6424
- toolMetadata: toolInvocation.toolMetadata
6424
+ toolMetadata: (_g = chunk.toolMetadata) != null ? _g : toolInvocation.toolMetadata
6425
6425
  },
6426
6426
  toolInvocation
6427
6427
  );
@@ -6437,7 +6437,7 @@ function processUIMessageStream({
6437
6437
  providerExecuted: chunk.providerExecuted,
6438
6438
  providerMetadata: chunk.providerMetadata,
6439
6439
  title: toolInvocation.title,
6440
- toolMetadata: toolInvocation.toolMetadata
6440
+ toolMetadata: (_h = chunk.toolMetadata) != null ? _h : toolInvocation.toolMetadata
6441
6441
  },
6442
6442
  toolInvocation
6443
6443
  );
@@ -10272,8 +10272,9 @@ async function createAgentUIStream({
10272
10272
  ...uiMessageStreamOptions
10273
10273
  }) {
10274
10274
  var _a23;
10275
+ const inputMessages = uiMessages != null ? uiMessages : uiMessageStreamOptions.originalMessages;
10275
10276
  const validatedMessages = await validateUIMessagesForAgent({
10276
- messages: uiMessages,
10277
+ messages: inputMessages,
10277
10278
  tools: agent.tools
10278
10279
  });
10279
10280
  const modelMessages = await convertToModelMessages(validatedMessages, {
@@ -12704,21 +12705,32 @@ function smoothStream({
12704
12705
  controller.enqueue(chunk);
12705
12706
  return;
12706
12707
  }
12707
- if ((chunk.type !== type || chunk.id !== id) && (buffer.length > 0 || providerMetadata != null)) {
12708
+ if (chunk.text.length === 0 && chunk.providerMetadata != null) {
12709
+ flushBuffer(controller);
12710
+ controller.enqueue(chunk);
12711
+ return;
12712
+ }
12713
+ if (buffer.length > 0 && (chunk.type !== type || chunk.id !== id || providerMetadata != null || chunk.providerMetadata != null)) {
12708
12714
  flushBuffer(controller);
12709
12715
  }
12710
12716
  buffer += chunk.text;
12711
12717
  id = chunk.id;
12712
12718
  type = chunk.type;
12713
- if (chunk.providerMetadata != null) {
12714
- providerMetadata = chunk.providerMetadata;
12715
- }
12719
+ providerMetadata = chunk.providerMetadata;
12716
12720
  let match;
12717
12721
  while ((match = detectChunk(buffer)) != null) {
12718
- controller.enqueue({ type, text: match, id });
12722
+ controller.enqueue({
12723
+ type,
12724
+ text: match,
12725
+ id,
12726
+ ...providerMetadata != null ? { providerMetadata } : {}
12727
+ });
12719
12728
  buffer = buffer.slice(match.length);
12720
12729
  await delay(isDocumentHidden() ? null : delayInMs);
12721
12730
  }
12731
+ if (buffer.length === 0) {
12732
+ providerMetadata = void 0;
12733
+ }
12722
12734
  }
12723
12735
  });
12724
12736
  };