@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/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # @ai-sdk/langchain
2
2
 
3
+ ## 2.0.321
4
+
5
+ ### Patch Changes
6
+
7
+ - 842eea4: Harden LangChain tool argument JSON parsing against prototype pollution while preserving the fallback for invalid arguments.
8
+ - Updated dependencies [52803fb]
9
+ - Updated dependencies [a0f7494]
10
+ - Updated dependencies [a48e8a9]
11
+ - ai@6.0.313
12
+
13
+ ## 2.0.320
14
+
15
+ ### Patch Changes
16
+
17
+ - 26f647b: fix(langchain): avoid `RangeError: Maximum call stack size exceeded` when converting large binary image and file parts
18
+ - Updated dependencies [1183cc4]
19
+ - Updated dependencies [d726591]
20
+ - @ai-sdk/provider-utils@4.0.62
21
+ - ai@6.0.312
22
+
3
23
  ## 2.0.319
4
24
 
5
25
  ### Patch Changes
package/dist/index.js CHANGED
@@ -33,6 +33,7 @@ var import_ai = require("ai");
33
33
 
34
34
  // src/utils.ts
35
35
  var import_messages = require("@langchain/core/messages");
36
+ var import_provider_utils = require("@ai-sdk/provider-utils");
36
37
  function parseLangGraphEvent(event) {
37
38
  return event.length === 3 ? [event[0], event[1], event[2]] : [void 0, event[0], event[1]];
38
39
  }
@@ -182,7 +183,7 @@ function convertImageToContentBlock(data, mediaType = "image/png") {
182
183
  const bytes = data instanceof ArrayBuffer ? new Uint8Array(data) : data;
183
184
  return {
184
185
  type: "image",
185
- data: btoa(String.fromCharCode(...bytes)),
186
+ data: (0, import_provider_utils.convertUint8ArrayToBase64)(bytes),
186
187
  mimeType: mediaType
187
188
  };
188
189
  }
@@ -253,7 +254,7 @@ function convertUserContent(content) {
253
254
  }
254
255
  } else if (filePart.data instanceof Uint8Array || filePart.data instanceof ArrayBuffer) {
255
256
  const bytes = filePart.data instanceof ArrayBuffer ? new Uint8Array(filePart.data) : filePart.data;
256
- const base64 = btoa(String.fromCharCode(...bytes));
257
+ const base64 = (0, import_provider_utils.convertUint8ArrayToBase64)(bytes);
257
258
  contentBlocks.push({
258
259
  type: "file",
259
260
  data: base64,
@@ -1014,7 +1015,7 @@ function processLangGraphEvent(event, state, controller) {
1014
1015
  const functionData = tc.function;
1015
1016
  let args;
1016
1017
  try {
1017
- args = (functionData == null ? void 0 : functionData.arguments) ? JSON.parse(functionData.arguments) : {};
1018
+ args = (functionData == null ? void 0 : functionData.arguments) ? (0, import_provider_utils.secureJsonParse)(functionData.arguments) : {};
1018
1019
  } catch (e) {
1019
1020
  args = {};
1020
1021
  }