ai 7.0.31 → 7.0.33
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 +23 -0
- package/dist/index.d.ts +3 -150
- package/dist/index.js +164 -120
- package/dist/index.js.map +1 -1
- package/dist/internal/index.js +45 -1
- package/dist/internal/index.js.map +1 -1
- package/docs/03-ai-sdk-harnesses/02-harness-agent.mdx +10 -2
- package/docs/03-ai-sdk-harnesses/03-tools.mdx +40 -0
- package/docs/04-ai-sdk-ui/03-chatbot-message-persistence.mdx +1 -1
- package/docs/05-ai-sdk-rsc/10-migrating-to-ui.mdx +1 -1
- package/docs/07-reference/01-ai-sdk-core/32-validate-ui-messages.mdx +1 -1
- package/docs/07-reference/01-ai-sdk-core/33-safe-validate-ui-messages.mdx +1 -1
- package/docs/07-reference/01-ai-sdk-core/71-has-tool-call.mdx +1 -1
- package/docs/07-reference/02-ai-sdk-ui/50-direct-chat-transport.mdx +1 -1
- package/docs/09-troubleshooting/05-tool-invocation-missing-result.mdx +1 -1
- package/docs/09-troubleshooting/13-repeated-assistant-messages.mdx +2 -2
- package/package.json +3 -3
- package/src/generate-text/generate-text.ts +4 -0
- package/src/prompt/convert-to-language-model-prompt.ts +13 -0
- package/src/ui/chat.ts +2 -2
- package/src/ui/process-ui-message-stream.ts +109 -61
- package/src/ui-message-stream/ui-message-chunks.ts +29 -29
|
@@ -21,29 +21,29 @@ const toolMetadataSchema: z.ZodType<JSONObject> = z.record(
|
|
|
21
21
|
);
|
|
22
22
|
|
|
23
23
|
export const uiMessageChunkSchema = lazySchema(() =>
|
|
24
|
-
zodSchema(
|
|
24
|
+
zodSchema<UIMessageChunk>(
|
|
25
25
|
z.union([
|
|
26
|
-
z.
|
|
26
|
+
z.looseObject({
|
|
27
27
|
type: z.literal('text-start'),
|
|
28
28
|
id: z.string(),
|
|
29
29
|
providerMetadata: providerMetadataSchema.optional(),
|
|
30
30
|
}),
|
|
31
|
-
z.
|
|
31
|
+
z.looseObject({
|
|
32
32
|
type: z.literal('text-delta'),
|
|
33
33
|
id: z.string(),
|
|
34
34
|
delta: z.string(),
|
|
35
35
|
providerMetadata: providerMetadataSchema.optional(),
|
|
36
36
|
}),
|
|
37
|
-
z.
|
|
37
|
+
z.looseObject({
|
|
38
38
|
type: z.literal('text-end'),
|
|
39
39
|
id: z.string(),
|
|
40
40
|
providerMetadata: providerMetadataSchema.optional(),
|
|
41
41
|
}),
|
|
42
|
-
z.
|
|
42
|
+
z.looseObject({
|
|
43
43
|
type: z.literal('error'),
|
|
44
44
|
errorText: z.string(),
|
|
45
45
|
}),
|
|
46
|
-
z.
|
|
46
|
+
z.looseObject({
|
|
47
47
|
type: z.literal('tool-input-start'),
|
|
48
48
|
toolCallId: z.string(),
|
|
49
49
|
toolName: z.string(),
|
|
@@ -53,12 +53,12 @@ export const uiMessageChunkSchema = lazySchema(() =>
|
|
|
53
53
|
dynamic: z.boolean().optional(),
|
|
54
54
|
title: z.string().optional(),
|
|
55
55
|
}),
|
|
56
|
-
z.
|
|
56
|
+
z.looseObject({
|
|
57
57
|
type: z.literal('tool-input-delta'),
|
|
58
58
|
toolCallId: z.string(),
|
|
59
59
|
inputTextDelta: z.string(),
|
|
60
60
|
}),
|
|
61
|
-
z.
|
|
61
|
+
z.looseObject({
|
|
62
62
|
type: z.literal('tool-input-available'),
|
|
63
63
|
toolCallId: z.string(),
|
|
64
64
|
toolName: z.string(),
|
|
@@ -69,7 +69,7 @@ export const uiMessageChunkSchema = lazySchema(() =>
|
|
|
69
69
|
dynamic: z.boolean().optional(),
|
|
70
70
|
title: z.string().optional(),
|
|
71
71
|
}),
|
|
72
|
-
z.
|
|
72
|
+
z.looseObject({
|
|
73
73
|
type: z.literal('tool-input-error'),
|
|
74
74
|
toolCallId: z.string(),
|
|
75
75
|
toolName: z.string(),
|
|
@@ -81,14 +81,14 @@ export const uiMessageChunkSchema = lazySchema(() =>
|
|
|
81
81
|
errorText: z.string(),
|
|
82
82
|
title: z.string().optional(),
|
|
83
83
|
}),
|
|
84
|
-
z.
|
|
84
|
+
z.looseObject({
|
|
85
85
|
type: z.literal('tool-approval-request'),
|
|
86
86
|
approvalId: z.string(),
|
|
87
87
|
toolCallId: z.string(),
|
|
88
88
|
isAutomatic: z.boolean().optional(),
|
|
89
89
|
signature: z.string().optional(),
|
|
90
90
|
}),
|
|
91
|
-
z.
|
|
91
|
+
z.looseObject({
|
|
92
92
|
type: z.literal('tool-approval-response'),
|
|
93
93
|
approvalId: z.string(),
|
|
94
94
|
approved: z.boolean(),
|
|
@@ -96,7 +96,7 @@ export const uiMessageChunkSchema = lazySchema(() =>
|
|
|
96
96
|
providerExecuted: z.boolean().optional(),
|
|
97
97
|
providerMetadata: providerMetadataSchema.optional(),
|
|
98
98
|
}),
|
|
99
|
-
z.
|
|
99
|
+
z.looseObject({
|
|
100
100
|
type: z.literal('tool-output-available'),
|
|
101
101
|
toolCallId: z.string(),
|
|
102
102
|
output: z.unknown(),
|
|
@@ -106,7 +106,7 @@ export const uiMessageChunkSchema = lazySchema(() =>
|
|
|
106
106
|
dynamic: z.boolean().optional(),
|
|
107
107
|
preliminary: z.boolean().optional(),
|
|
108
108
|
}),
|
|
109
|
-
z.
|
|
109
|
+
z.looseObject({
|
|
110
110
|
type: z.literal('tool-output-error'),
|
|
111
111
|
toolCallId: z.string(),
|
|
112
112
|
errorText: z.string(),
|
|
@@ -115,39 +115,39 @@ export const uiMessageChunkSchema = lazySchema(() =>
|
|
|
115
115
|
toolMetadata: toolMetadataSchema.optional(),
|
|
116
116
|
dynamic: z.boolean().optional(),
|
|
117
117
|
}),
|
|
118
|
-
z.
|
|
118
|
+
z.looseObject({
|
|
119
119
|
type: z.literal('tool-output-denied'),
|
|
120
120
|
toolCallId: z.string(),
|
|
121
121
|
}),
|
|
122
|
-
z.
|
|
122
|
+
z.looseObject({
|
|
123
123
|
type: z.literal('reasoning-start'),
|
|
124
124
|
id: z.string(),
|
|
125
125
|
providerMetadata: providerMetadataSchema.optional(),
|
|
126
126
|
}),
|
|
127
|
-
z.
|
|
127
|
+
z.looseObject({
|
|
128
128
|
type: z.literal('reasoning-delta'),
|
|
129
129
|
id: z.string(),
|
|
130
130
|
delta: z.string(),
|
|
131
131
|
providerMetadata: providerMetadataSchema.optional(),
|
|
132
132
|
}),
|
|
133
|
-
z.
|
|
133
|
+
z.looseObject({
|
|
134
134
|
type: z.literal('reasoning-end'),
|
|
135
135
|
id: z.string(),
|
|
136
136
|
providerMetadata: providerMetadataSchema.optional(),
|
|
137
137
|
}),
|
|
138
|
-
z.
|
|
138
|
+
z.looseObject({
|
|
139
139
|
type: z.literal('custom'),
|
|
140
140
|
kind: z.string().transform(value => value as `${string}.${string}`),
|
|
141
141
|
providerMetadata: providerMetadataSchema.optional(),
|
|
142
142
|
}),
|
|
143
|
-
z.
|
|
143
|
+
z.looseObject({
|
|
144
144
|
type: z.literal('source-url'),
|
|
145
145
|
sourceId: z.string(),
|
|
146
146
|
url: z.string(),
|
|
147
147
|
title: z.string().optional(),
|
|
148
148
|
providerMetadata: providerMetadataSchema.optional(),
|
|
149
149
|
}),
|
|
150
|
-
z.
|
|
150
|
+
z.looseObject({
|
|
151
151
|
type: z.literal('source-document'),
|
|
152
152
|
sourceId: z.string(),
|
|
153
153
|
mediaType: z.string(),
|
|
@@ -155,19 +155,19 @@ export const uiMessageChunkSchema = lazySchema(() =>
|
|
|
155
155
|
filename: z.string().optional(),
|
|
156
156
|
providerMetadata: providerMetadataSchema.optional(),
|
|
157
157
|
}),
|
|
158
|
-
z.
|
|
158
|
+
z.looseObject({
|
|
159
159
|
type: z.literal('file'),
|
|
160
160
|
url: z.string(),
|
|
161
161
|
mediaType: z.string(),
|
|
162
162
|
providerMetadata: providerMetadataSchema.optional(),
|
|
163
163
|
}),
|
|
164
|
-
z.
|
|
164
|
+
z.looseObject({
|
|
165
165
|
type: z.literal('reasoning-file'),
|
|
166
166
|
url: z.string(),
|
|
167
167
|
mediaType: z.string(),
|
|
168
168
|
providerMetadata: providerMetadataSchema.optional(),
|
|
169
169
|
}),
|
|
170
|
-
z.
|
|
170
|
+
z.looseObject({
|
|
171
171
|
type: z.custom<`data-${string}`>(
|
|
172
172
|
(value): value is `data-${string}` =>
|
|
173
173
|
typeof value === 'string' && value.startsWith('data-'),
|
|
@@ -177,18 +177,18 @@ export const uiMessageChunkSchema = lazySchema(() =>
|
|
|
177
177
|
data: z.unknown(),
|
|
178
178
|
transient: z.boolean().optional(),
|
|
179
179
|
}),
|
|
180
|
-
z.
|
|
180
|
+
z.looseObject({
|
|
181
181
|
type: z.literal('start-step'),
|
|
182
182
|
}),
|
|
183
|
-
z.
|
|
183
|
+
z.looseObject({
|
|
184
184
|
type: z.literal('finish-step'),
|
|
185
185
|
}),
|
|
186
|
-
z.
|
|
186
|
+
z.looseObject({
|
|
187
187
|
type: z.literal('start'),
|
|
188
188
|
messageId: z.string().optional(),
|
|
189
189
|
messageMetadata: z.unknown().optional(),
|
|
190
190
|
}),
|
|
191
|
-
z.
|
|
191
|
+
z.looseObject({
|
|
192
192
|
type: z.literal('finish'),
|
|
193
193
|
finishReason: z
|
|
194
194
|
.enum([
|
|
@@ -202,11 +202,11 @@ export const uiMessageChunkSchema = lazySchema(() =>
|
|
|
202
202
|
.optional(),
|
|
203
203
|
messageMetadata: z.unknown().optional(),
|
|
204
204
|
}),
|
|
205
|
-
z.
|
|
205
|
+
z.looseObject({
|
|
206
206
|
type: z.literal('abort'),
|
|
207
207
|
reason: z.string().optional(),
|
|
208
208
|
}),
|
|
209
|
-
z.
|
|
209
|
+
z.looseObject({
|
|
210
210
|
type: z.literal('message-metadata'),
|
|
211
211
|
messageMetadata: z.unknown(),
|
|
212
212
|
}),
|