@ai-sdk/langchain 2.0.319 → 2.0.321

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
@@ -13,6 +13,10 @@ import {
13
13
  ToolMessage,
14
14
  AIMessageChunk
15
15
  } from "@langchain/core/messages";
16
+ import {
17
+ convertUint8ArrayToBase64,
18
+ secureJsonParse
19
+ } from "@ai-sdk/provider-utils";
16
20
  function parseLangGraphEvent(event) {
17
21
  return event.length === 3 ? [event[0], event[1], event[2]] : [void 0, event[0], event[1]];
18
22
  }
@@ -162,7 +166,7 @@ function convertImageToContentBlock(data, mediaType = "image/png") {
162
166
  const bytes = data instanceof ArrayBuffer ? new Uint8Array(data) : data;
163
167
  return {
164
168
  type: "image",
165
- data: btoa(String.fromCharCode(...bytes)),
169
+ data: convertUint8ArrayToBase64(bytes),
166
170
  mimeType: mediaType
167
171
  };
168
172
  }
@@ -233,7 +237,7 @@ function convertUserContent(content) {
233
237
  }
234
238
  } else if (filePart.data instanceof Uint8Array || filePart.data instanceof ArrayBuffer) {
235
239
  const bytes = filePart.data instanceof ArrayBuffer ? new Uint8Array(filePart.data) : filePart.data;
236
- const base64 = btoa(String.fromCharCode(...bytes));
240
+ const base64 = convertUint8ArrayToBase64(bytes);
237
241
  contentBlocks.push({
238
242
  type: "file",
239
243
  data: base64,
@@ -994,7 +998,7 @@ function processLangGraphEvent(event, state, controller) {
994
998
  const functionData = tc.function;
995
999
  let args;
996
1000
  try {
997
- args = (functionData == null ? void 0 : functionData.arguments) ? JSON.parse(functionData.arguments) : {};
1001
+ args = (functionData == null ? void 0 : functionData.arguments) ? secureJsonParse(functionData.arguments) : {};
998
1002
  } catch (e) {
999
1003
  args = {};
1000
1004
  }