ai 7.0.64 → 7.0.66
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 +18 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +49 -13
- package/dist/index.js.map +1 -1
- package/dist/internal/index.js +1 -1
- package/docs/02-foundations/02-providers-and-models.mdx +0 -1
- package/docs/03-ai-sdk-harnesses/05-harness-adapters.mdx +2 -0
- package/package.json +2 -2
- package/src/generate-object/output-strategy.ts +11 -2
- package/src/generate-text/index.ts +1 -0
- package/src/generate-text/output.ts +12 -2
- package/src/ui/chat.ts +11 -11
- package/src/ui/process-ui-message-stream.ts +6 -2
- package/src/ui-message-stream/handle-ui-message-stream-finish.ts +2 -1
- package/src/ui-message-stream/read-ui-message-stream.ts +32 -2
package/dist/internal/index.js
CHANGED
|
@@ -121,7 +121,6 @@ Here are the capabilities of popular models:
|
|
|
121
121
|
| [xAI Grok](/providers/ai-sdk-providers/xai) | `grok-4` | <Cross /> | <Check /> | <Check /> | <Check /> |
|
|
122
122
|
| [xAI Grok](/providers/ai-sdk-providers/xai) | `grok-3` | <Cross /> | <Check /> | <Check /> | <Check /> |
|
|
123
123
|
| [xAI Grok](/providers/ai-sdk-providers/xai) | `grok-3-mini` | <Cross /> | <Check /> | <Check /> | <Check /> |
|
|
124
|
-
| [Vercel](/providers/ai-sdk-providers/vercel) | `v0-1.0-md` | <Check /> | <Check /> | <Check /> | <Check /> |
|
|
125
124
|
| [OpenAI](/providers/ai-sdk-providers/openai) | `gpt-5.6` | <Check /> | <Check /> | <Check /> | <Check /> |
|
|
126
125
|
| [OpenAI](/providers/ai-sdk-providers/openai) | `gpt-5.6-luna` | <Check /> | <Check /> | <Check /> | <Check /> |
|
|
127
126
|
| [OpenAI](/providers/ai-sdk-providers/openai) | `gpt-5.6-sol` | <Check /> | <Check /> | <Check /> | <Check /> |
|
|
@@ -15,6 +15,7 @@ configuration into the harness contract.
|
|
|
15
15
|
The AI SDK includes the following harness adapters:
|
|
16
16
|
|
|
17
17
|
- [Claude Code](/providers/ai-sdk-harnesses/claude-code) (`@ai-sdk/harness-claude-code`)
|
|
18
|
+
- [Cline](/providers/ai-sdk-harnesses/cline) (`@ai-sdk/harness-cline`)
|
|
18
19
|
- [Codex](/providers/ai-sdk-harnesses/codex) (`@ai-sdk/harness-codex`)
|
|
19
20
|
- [Deep Agents](/providers/ai-sdk-harnesses/deepagents) (`@ai-sdk/harness-deepagents`)
|
|
20
21
|
- [Grok Build](/providers/ai-sdk-harnesses/grok-build) (`@ai-sdk/harness-grok-build`)
|
|
@@ -32,6 +33,7 @@ The AI SDK includes the following harness adapters:
|
|
|
32
33
|
| Adapter | Runtime location | Custom tools | Custom skills | Built-in tool approval | Built-in tool filtering |
|
|
33
34
|
| ------------------------------------------------------ | ---------------- | ------------ | ------------- | ---------------------- | ---------------------------- |
|
|
34
35
|
| [Claude Code](/providers/ai-sdk-harnesses/claude-code) | Sandbox bridge | <Check /> | <Check /> | <Check /> | <Check /> |
|
|
36
|
+
| [Cline](/providers/ai-sdk-harnesses/cline) | Host process | <Check /> | <Check /> | <Check /> | <Check /> |
|
|
35
37
|
| [Codex](/providers/ai-sdk-harnesses/codex) | Sandbox bridge | <Check /> | <Check /> | <Cross /> | <Cross /> |
|
|
36
38
|
| [Deep Agents](/providers/ai-sdk-harnesses/deepagents) | Sandbox bridge | <Check /> | <Check /> | <Check /> | <Check /> via auto-rejection |
|
|
37
39
|
| [Grok Build](/providers/ai-sdk-harnesses/grok-build) | Sandbox via ACP | <Check /> | <Check /> | <Check /> | <Cross /> |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ai",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.0.66",
|
|
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",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
}
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@ai-sdk/gateway": "4.0.
|
|
45
|
+
"@ai-sdk/gateway": "4.0.52",
|
|
46
46
|
"@ai-sdk/provider": "4.0.7",
|
|
47
47
|
"@ai-sdk/provider-utils": "5.0.27"
|
|
48
48
|
},
|
|
@@ -140,11 +140,20 @@ const arrayOutputStrategy = <ELEMENT>(
|
|
|
140
140
|
// be able to generate an array directly:
|
|
141
141
|
// possible future optimization: use arrays directly when model supports grammar-guided generation
|
|
142
142
|
jsonSchema: async () => {
|
|
143
|
-
//
|
|
144
|
-
const {
|
|
143
|
+
// keep root-level definitions available to root-relative references:
|
|
144
|
+
const {
|
|
145
|
+
$schema: _$schema,
|
|
146
|
+
definitions,
|
|
147
|
+
$defs,
|
|
148
|
+
...itemSchema
|
|
149
|
+
} = (await schema.jsonSchema) as JSONSchema7 & {
|
|
150
|
+
$defs?: JSONSchema7['definitions'];
|
|
151
|
+
};
|
|
145
152
|
|
|
146
153
|
return {
|
|
147
154
|
$schema: 'http://json-schema.org/draft-07/schema#',
|
|
155
|
+
...(definitions != null && { definitions }),
|
|
156
|
+
...($defs != null && { $defs }),
|
|
148
157
|
type: 'object',
|
|
149
158
|
properties: {
|
|
150
159
|
elements: { type: 'array', items: itemSchema },
|
|
@@ -34,6 +34,7 @@ export type {
|
|
|
34
34
|
OnLanguageModelCallStartCallback,
|
|
35
35
|
} from './language-model-events';
|
|
36
36
|
export * as Output from './output';
|
|
37
|
+
export type { Output as OutputInterface } from './output';
|
|
37
38
|
export type {
|
|
38
39
|
InferCompleteOutput as InferGenerateOutput,
|
|
39
40
|
InferPartialOutput as InferStreamOutput,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
TypeValidationError,
|
|
3
|
+
type JSONSchema7,
|
|
3
4
|
type JSONValue,
|
|
4
5
|
type LanguageModelV4CallOptions,
|
|
5
6
|
} from '@ai-sdk/provider';
|
|
@@ -217,13 +218,22 @@ export const array = <ELEMENT>({
|
|
|
217
218
|
|
|
218
219
|
// JSON schema that describes an array of elements:
|
|
219
220
|
responseFormat: resolve(elementSchema.jsonSchema).then(jsonSchema => {
|
|
220
|
-
//
|
|
221
|
-
const {
|
|
221
|
+
// keep root-level definitions available to root-relative references:
|
|
222
|
+
const {
|
|
223
|
+
$schema: _$schema,
|
|
224
|
+
definitions,
|
|
225
|
+
$defs,
|
|
226
|
+
...itemSchema
|
|
227
|
+
} = jsonSchema as JSONSchema7 & {
|
|
228
|
+
$defs?: JSONSchema7['definitions'];
|
|
229
|
+
};
|
|
222
230
|
|
|
223
231
|
return {
|
|
224
232
|
type: 'json' as const,
|
|
225
233
|
schema: {
|
|
226
234
|
$schema: 'http://json-schema.org/draft-07/schema#',
|
|
235
|
+
...(definitions != null && { definitions }),
|
|
236
|
+
...($defs != null && { $defs }),
|
|
227
237
|
type: 'object',
|
|
228
238
|
properties: {
|
|
229
239
|
elements: { type: 'array', items: itemSchema },
|
package/src/ui/chat.ts
CHANGED
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
createStreamingUIMessageState,
|
|
16
16
|
processUIMessageStream,
|
|
17
17
|
type StreamingUIMessageState,
|
|
18
|
+
type UIMessageStreamWriteOptions,
|
|
18
19
|
} from './process-ui-message-stream';
|
|
19
20
|
import {
|
|
20
21
|
isToolUIPart,
|
|
@@ -757,7 +758,7 @@ export abstract class AbstractChat<UI_MESSAGE extends UIMessage> {
|
|
|
757
758
|
const runUpdateMessageJob = (
|
|
758
759
|
job: (options: {
|
|
759
760
|
state: StreamingUIMessageState<UI_MESSAGE>;
|
|
760
|
-
write: () => void;
|
|
761
|
+
write: (options?: UIMessageStreamWriteOptions) => void;
|
|
761
762
|
}) => Promise<void>,
|
|
762
763
|
) =>
|
|
763
764
|
// serialize the job execution to avoid race conditions:
|
|
@@ -768,13 +769,14 @@ export abstract class AbstractChat<UI_MESSAGE extends UIMessage> {
|
|
|
768
769
|
|
|
769
770
|
return job({
|
|
770
771
|
state: response.state,
|
|
771
|
-
write: () => {
|
|
772
|
+
write: ({ updateStatus = true } = {}) => {
|
|
772
773
|
if (response.abortController.signal.aborted) {
|
|
773
774
|
return;
|
|
774
775
|
}
|
|
775
776
|
|
|
776
|
-
|
|
777
|
-
|
|
777
|
+
if (updateStatus) {
|
|
778
|
+
this.setStatus({ status: 'streaming' });
|
|
779
|
+
}
|
|
778
780
|
|
|
779
781
|
const replaceLastMessage =
|
|
780
782
|
response.state.message.id === this.lastMessage?.id;
|
|
@@ -861,15 +863,13 @@ export abstract class AbstractChat<UI_MESSAGE extends UIMessage> {
|
|
|
861
863
|
finishReason: activeResponse.state.finishReason,
|
|
862
864
|
});
|
|
863
865
|
}
|
|
864
|
-
}
|
|
865
|
-
|
|
866
|
-
|
|
866
|
+
} finally {
|
|
867
|
+
if (this.activeResponse === activeResponse) {
|
|
868
|
+
this.activeResponse = undefined;
|
|
869
|
+
}
|
|
867
870
|
|
|
868
|
-
|
|
869
|
-
this.activeResponse = undefined;
|
|
871
|
+
clearActiveResumeRequest();
|
|
870
872
|
}
|
|
871
|
-
|
|
872
|
-
clearActiveResumeRequest();
|
|
873
873
|
}
|
|
874
874
|
|
|
875
875
|
// automatically send the message if the sendAutomaticallyWhen function returns true
|
|
@@ -49,6 +49,10 @@ export type StreamingUIMessageState<UI_MESSAGE extends UIMessage> = {
|
|
|
49
49
|
finishReason?: FinishReason;
|
|
50
50
|
};
|
|
51
51
|
|
|
52
|
+
export type UIMessageStreamWriteOptions = {
|
|
53
|
+
updateStatus?: boolean;
|
|
54
|
+
};
|
|
55
|
+
|
|
52
56
|
export function createStreamingUIMessageState<UI_MESSAGE extends UIMessage>({
|
|
53
57
|
lastMessage,
|
|
54
58
|
messageId,
|
|
@@ -95,7 +99,7 @@ export function processUIMessageStream<UI_MESSAGE extends UIMessage>({
|
|
|
95
99
|
runUpdateMessageJob: (
|
|
96
100
|
job: (options: {
|
|
97
101
|
state: StreamingUIMessageState<UI_MESSAGE>;
|
|
98
|
-
write: () => void;
|
|
102
|
+
write: (options?: UIMessageStreamWriteOptions) => void;
|
|
99
103
|
}) => Promise<void>,
|
|
100
104
|
) => Promise<void>;
|
|
101
105
|
onError: ErrorHandler;
|
|
@@ -891,7 +895,7 @@ export function processUIMessageStream<UI_MESSAGE extends UIMessage>({
|
|
|
891
895
|
await updateMessageMetadata(chunk.messageMetadata);
|
|
892
896
|
|
|
893
897
|
if (chunk.messageId != null || chunk.messageMetadata != null) {
|
|
894
|
-
write();
|
|
898
|
+
write({ updateStatus: false });
|
|
895
899
|
}
|
|
896
900
|
break;
|
|
897
901
|
}
|
|
@@ -2,6 +2,7 @@ import {
|
|
|
2
2
|
createStreamingUIMessageState,
|
|
3
3
|
processUIMessageStream,
|
|
4
4
|
type StreamingUIMessageState,
|
|
5
|
+
type UIMessageStreamWriteOptions,
|
|
5
6
|
} from '../ui/process-ui-message-stream';
|
|
6
7
|
import type { UIMessage } from '../ui/ui-messages';
|
|
7
8
|
import type { ErrorHandler } from '../util/error-handler';
|
|
@@ -109,7 +110,7 @@ export function handleUIMessageStreamFinish<UI_MESSAGE extends UIMessage>({
|
|
|
109
110
|
const runUpdateMessageJob = async (
|
|
110
111
|
job: (options: {
|
|
111
112
|
state: StreamingUIMessageState<UI_MESSAGE>;
|
|
112
|
-
write: () => void;
|
|
113
|
+
write: (options?: UIMessageStreamWriteOptions) => void;
|
|
113
114
|
}) => Promise<void>,
|
|
114
115
|
) => {
|
|
115
116
|
await job({ state, write: () => {} });
|
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
createStreamingUIMessageState,
|
|
5
5
|
processUIMessageStream,
|
|
6
6
|
type StreamingUIMessageState,
|
|
7
|
+
type UIMessageStreamWriteOptions,
|
|
7
8
|
} from '../ui/process-ui-message-stream';
|
|
8
9
|
import {
|
|
9
10
|
createAsyncIterableStream,
|
|
@@ -11,6 +12,35 @@ import {
|
|
|
11
12
|
} from '../util/async-iterable-stream';
|
|
12
13
|
import { consumeStream } from '../util/consume-stream';
|
|
13
14
|
|
|
15
|
+
function createUIMessageSnapshot<UI_MESSAGE extends UIMessage>(
|
|
16
|
+
message: UI_MESSAGE,
|
|
17
|
+
): UI_MESSAGE {
|
|
18
|
+
const textByPartIndex = new Map<number, string>();
|
|
19
|
+
const messageWithoutText = {
|
|
20
|
+
...message,
|
|
21
|
+
parts: message.parts.map((part, index) => {
|
|
22
|
+
if (part.type === 'text' || part.type === 'reasoning') {
|
|
23
|
+
textByPartIndex.set(index, part.text);
|
|
24
|
+
return { ...part, text: '' };
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return part;
|
|
28
|
+
}),
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const snapshot = structuredClone(messageWithoutText) as UI_MESSAGE;
|
|
32
|
+
|
|
33
|
+
for (const [index, text] of textByPartIndex) {
|
|
34
|
+
const part = snapshot.parts[index];
|
|
35
|
+
|
|
36
|
+
if (part.type === 'text' || part.type === 'reasoning') {
|
|
37
|
+
part.text = text;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return snapshot;
|
|
42
|
+
}
|
|
43
|
+
|
|
14
44
|
/**
|
|
15
45
|
* Transforms a stream of `UIMessageChunk`s into an `AsyncIterableStream` of `UIMessage`s.
|
|
16
46
|
*
|
|
@@ -62,13 +92,13 @@ export function readUIMessageStream<UI_MESSAGE extends UIMessage>({
|
|
|
62
92
|
runUpdateMessageJob(
|
|
63
93
|
job: (options: {
|
|
64
94
|
state: StreamingUIMessageState<UI_MESSAGE>;
|
|
65
|
-
write: () => void;
|
|
95
|
+
write: (options?: UIMessageStreamWriteOptions) => void;
|
|
66
96
|
}) => Promise<void>,
|
|
67
97
|
) {
|
|
68
98
|
return job({
|
|
69
99
|
state,
|
|
70
100
|
write: () => {
|
|
71
|
-
controller?.enqueue(
|
|
101
|
+
controller?.enqueue(createUIMessageSnapshot(state.message));
|
|
72
102
|
},
|
|
73
103
|
});
|
|
74
104
|
},
|