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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai",
3
- "version": "7.0.100",
3
+ "version": "7.0.101",
4
4
  "type": "module",
5
5
  "description": "AI SDK by Vercel - build apps like ChatGPT, Claude, Gemini, and more with a single interface for any model using the Vercel AI Gateway or go direct to OpenAI, Anthropic, Google, or any other model provider.",
6
6
  "license": "Apache-2.0",
@@ -49,7 +49,7 @@
49
49
  "devDependencies": {
50
50
  "@ai-sdk/amazon-bedrock": "5.0.82",
51
51
  "@ai-sdk/deepseek": "3.0.44",
52
- "@ai-sdk/google": "4.0.69",
52
+ "@ai-sdk/google": "4.0.70",
53
53
  "@ai-sdk/groq": "4.0.41",
54
54
  "@ai-sdk/huggingface": "2.0.48",
55
55
  "@ai-sdk/moonshotai": "3.0.49",
@@ -1,5 +1,9 @@
1
1
  import { getErrorMessage, type JSONValue } from '@ai-sdk/provider';
2
- import type { Tool, ToolResultOutput } from '@ai-sdk/provider-utils';
2
+ import {
3
+ parseJSON,
4
+ type Tool,
5
+ type ToolResultOutput,
6
+ } from '@ai-sdk/provider-utils';
3
7
 
4
8
  export async function createToolModelOutput({
5
9
  toolCallId,
@@ -17,7 +21,7 @@ export async function createToolModelOutput({
17
21
  if (errorMode === 'text') {
18
22
  return { type: 'error-text', value: getErrorMessage(output) };
19
23
  } else if (errorMode === 'json') {
20
- return { type: 'error-json', value: toJSONValue(output) };
24
+ return { type: 'error-json', value: await toJSONValue(output) };
21
25
  }
22
26
 
23
27
  if (tool?.toModelOutput) {
@@ -26,9 +30,16 @@ export async function createToolModelOutput({
26
30
 
27
31
  return typeof output === 'string'
28
32
  ? { type: 'text', value: output }
29
- : { type: 'json', value: toJSONValue(output) };
33
+ : { type: 'json', value: await toJSONValue(output) };
30
34
  }
31
35
 
32
- function toJSONValue(value: unknown): JSONValue {
33
- return value === undefined ? null : (value as JSONValue);
36
+ async function toJSONValue(value: unknown): Promise<JSONValue> {
37
+ if (value === undefined) {
38
+ return null;
39
+ }
40
+
41
+ const serialized = JSON.stringify(value);
42
+ return serialized === undefined
43
+ ? null
44
+ : await parseJSON({ text: serialized });
34
45
  }