ai 7.0.100 → 7.0.101

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,11 @@
1
1
  # ai
2
2
 
3
+ ## 7.0.101
4
+
5
+ ### Patch Changes
6
+
7
+ - 6aa7c54: fix(ai): serialize tool output JSON values
8
+
3
9
  ## 7.0.100
4
10
 
5
11
  ### Patch Changes
package/dist/index.js CHANGED
@@ -1178,7 +1178,7 @@ import {
1178
1178
  } from "@ai-sdk/provider-utils";
1179
1179
 
1180
1180
  // src/version.ts
1181
- var VERSION = true ? "7.0.100" : "0.0.0-test";
1181
+ var VERSION = true ? "7.0.101" : "0.0.0-test";
1182
1182
 
1183
1183
  // src/util/download/download.ts
1184
1184
  var download = async ({
@@ -2007,6 +2007,9 @@ function getMediaTypeFromUrl(url, fallbackMediaType = "application/octet-stream"
2007
2007
 
2008
2008
  // src/prompt/create-tool-model-output.ts
2009
2009
  import { getErrorMessage as getErrorMessage3 } from "@ai-sdk/provider";
2010
+ import {
2011
+ parseJSON
2012
+ } from "@ai-sdk/provider-utils";
2010
2013
  async function createToolModelOutput({
2011
2014
  toolCallId,
2012
2015
  input,
@@ -2017,15 +2020,19 @@ async function createToolModelOutput({
2017
2020
  if (errorMode === "text") {
2018
2021
  return { type: "error-text", value: getErrorMessage3(output) };
2019
2022
  } else if (errorMode === "json") {
2020
- return { type: "error-json", value: toJSONValue(output) };
2023
+ return { type: "error-json", value: await toJSONValue(output) };
2021
2024
  }
2022
2025
  if (tool2 == null ? void 0 : tool2.toModelOutput) {
2023
2026
  return await tool2.toModelOutput({ toolCallId, input, output });
2024
2027
  }
2025
- return typeof output === "string" ? { type: "text", value: output } : { type: "json", value: toJSONValue(output) };
2028
+ return typeof output === "string" ? { type: "text", value: output } : { type: "json", value: await toJSONValue(output) };
2026
2029
  }
2027
- function toJSONValue(value) {
2028
- return value === void 0 ? null : value;
2030
+ async function toJSONValue(value) {
2031
+ if (value === void 0) {
2032
+ return null;
2033
+ }
2034
+ const serialized = JSON.stringify(value);
2035
+ return serialized === void 0 ? null : await parseJSON({ text: serialized });
2029
2036
  }
2030
2037
 
2031
2038
  // src/prompt/prepare-language-model-call-options.ts