ai 5.0.0-beta.4 → 5.0.0-beta.6

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
@@ -523,7 +523,8 @@ var uiMessageStreamPartSchema = z.union([
523
523
  z.strictObject({
524
524
  type: z.string().startsWith("data-"),
525
525
  id: z.string().optional(),
526
- data: z.unknown()
526
+ data: z.unknown(),
527
+ transient: z.boolean().optional()
527
528
  }),
528
529
  z.strictObject({
529
530
  type: z.literal("start-step")
@@ -766,14 +767,13 @@ async function convertFileListToFileUIParts(files) {
766
767
  import { parseJsonEventStream as parseJsonEventStream2 } from "@ai-sdk/provider-utils";
767
768
 
768
769
  // src/ui/http-chat-transport.ts
769
- var getOriginalFetch2 = () => fetch;
770
770
  var HttpChatTransport = class {
771
771
  constructor({
772
772
  api = "/api/chat",
773
773
  credentials,
774
774
  headers,
775
775
  body,
776
- fetch: fetch2 = getOriginalFetch2(),
776
+ fetch: fetch2,
777
777
  prepareSendMessagesRequest,
778
778
  prepareReconnectToStreamRequest
779
779
  }) {
@@ -789,7 +789,7 @@ var HttpChatTransport = class {
789
789
  abortSignal,
790
790
  ...options
791
791
  }) {
792
- var _a16, _b, _c, _d;
792
+ var _a16, _b, _c, _d, _e;
793
793
  const preparedRequest = await ((_a16 = this.prepareSendMessagesRequest) == null ? void 0 : _a16.call(this, {
794
794
  api: this.api,
795
795
  id: options.chatId,
@@ -812,7 +812,8 @@ var HttpChatTransport = class {
812
812
  messageId: options.messageId
813
813
  };
814
814
  const credentials = (_c = preparedRequest == null ? void 0 : preparedRequest.credentials) != null ? _c : this.credentials;
815
- const response = await this.fetch.call(void 0, api, {
815
+ const fetch2 = (_d = this.fetch) != null ? _d : globalThis.fetch;
816
+ const response = await fetch2(api, {
816
817
  method: "POST",
817
818
  headers: {
818
819
  "Content-Type": "application/json",
@@ -824,7 +825,7 @@ var HttpChatTransport = class {
824
825
  });
825
826
  if (!response.ok) {
826
827
  throw new Error(
827
- (_d = await response.text()) != null ? _d : "Failed to fetch the chat response."
828
+ (_e = await response.text()) != null ? _e : "Failed to fetch the chat response."
828
829
  );
829
830
  }
830
831
  if (!response.body) {
@@ -833,7 +834,7 @@ var HttpChatTransport = class {
833
834
  return this.processResponseStream(response.body);
834
835
  }
835
836
  async reconnectToStream(options) {
836
- var _a16, _b, _c, _d;
837
+ var _a16, _b, _c, _d, _e;
837
838
  const preparedRequest = await ((_a16 = this.prepareReconnectToStreamRequest) == null ? void 0 : _a16.call(this, {
838
839
  api: this.api,
839
840
  id: options.chatId,
@@ -845,7 +846,8 @@ var HttpChatTransport = class {
845
846
  const api = (_b = preparedRequest == null ? void 0 : preparedRequest.api) != null ? _b : `${this.api}/${options.chatId}/stream`;
846
847
  const headers = (preparedRequest == null ? void 0 : preparedRequest.headers) !== void 0 ? preparedRequest.headers : { ...this.headers, ...options.headers };
847
848
  const credentials = (_c = preparedRequest == null ? void 0 : preparedRequest.credentials) != null ? _c : this.credentials;
848
- const response = await this.fetch.call(void 0, api, {
849
+ const fetch2 = (_d = this.fetch) != null ? _d : globalThis.fetch;
850
+ const response = await fetch2(api, {
849
851
  method: "GET",
850
852
  headers,
851
853
  credentials
@@ -855,7 +857,7 @@ var HttpChatTransport = class {
855
857
  }
856
858
  if (!response.ok) {
857
859
  throw new Error(
858
- (_d = await response.text()) != null ? _d : "Failed to fetch the chat response."
860
+ (_e = await response.text()) != null ? _e : "Failed to fetch the chat response."
859
861
  );
860
862
  }
861
863
  if (!response.body) {
@@ -1293,7 +1295,8 @@ function processUIMessageStream({
1293
1295
  messageMetadataSchema,
1294
1296
  dataPartSchemas,
1295
1297
  runUpdateMessageJob,
1296
- onError
1298
+ onError,
1299
+ onData
1297
1300
  }) {
1298
1301
  return stream.pipeThrough(
1299
1302
  new TransformStream({
@@ -1571,14 +1574,20 @@ function processUIMessageStream({
1571
1574
  }
1572
1575
  default: {
1573
1576
  if (isDataUIMessageStreamPart(part)) {
1574
- const existingPart = part.id != null ? state.message.parts.find(
1575
- (partArg) => part.type === partArg.type && part.id === partArg.id
1577
+ const dataPart = part;
1578
+ if (dataPart.transient) {
1579
+ onData == null ? void 0 : onData(dataPart);
1580
+ break;
1581
+ }
1582
+ const existingPart = dataPart.id != null ? state.message.parts.find(
1583
+ (partArg) => dataPart.type === partArg.type && dataPart.id === partArg.id
1576
1584
  ) : void 0;
1577
1585
  if (existingPart != null) {
1578
- existingPart.data = isObject(existingPart.data) && isObject(part.data) ? mergeObjects(existingPart.data, part.data) : part.data;
1586
+ existingPart.data = isObject(existingPart.data) && isObject(dataPart.data) ? mergeObjects(existingPart.data, dataPart.data) : dataPart.data;
1579
1587
  } else {
1580
- state.message.parts.push(part);
1588
+ state.message.parts.push(dataPart);
1581
1589
  }
1590
+ onData == null ? void 0 : onData(dataPart);
1582
1591
  write();
1583
1592
  }
1584
1593
  }
@@ -1639,7 +1648,8 @@ var AbstractChat = class {
1639
1648
  state,
1640
1649
  onError,
1641
1650
  onToolCall,
1642
- onFinish
1651
+ onFinish,
1652
+ onData
1643
1653
  }) {
1644
1654
  this.activeResponse = void 0;
1645
1655
  this.jobExecutor = new SerialJobExecutor();
@@ -1768,6 +1778,7 @@ var AbstractChat = class {
1768
1778
  this.onError = onError;
1769
1779
  this.onToolCall = onToolCall;
1770
1780
  this.onFinish = onFinish;
1781
+ this.onData = onData;
1771
1782
  }
1772
1783
  /**
1773
1784
  * Hook status:
@@ -1871,6 +1882,7 @@ var AbstractChat = class {
1871
1882
  stream: processUIMessageStream({
1872
1883
  stream,
1873
1884
  onToolCall: this.onToolCall,
1885
+ onData: this.onData,
1874
1886
  messageMetadataSchema: this.messageMetadataSchema,
1875
1887
  dataPartSchemas: this.dataPartSchemas,
1876
1888
  runUpdateMessageJob,
@@ -8357,10 +8369,10 @@ import { z as z9 } from "zod/v4";
8357
8369
 
8358
8370
  // core/tool/mcp/types.ts
8359
8371
  import { z as z8 } from "zod/v4";
8360
- var LATEST_PROTOCOL_VERSION = "2024-11-05";
8372
+ var LATEST_PROTOCOL_VERSION = "2025-26-03";
8361
8373
  var SUPPORTED_PROTOCOL_VERSIONS = [
8362
8374
  LATEST_PROTOCOL_VERSION,
8363
- "2024-10-07"
8375
+ "2024-11-05"
8364
8376
  ];
8365
8377
  var ClientOrServerImplementationSchema = z8.object({
8366
8378
  name: z8.string(),