ai 0.0.0-8777c42a-20250115032312 → 0.0.0-9477ebb9-20250403064906
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 +660 -2
- package/README.md +19 -6
- package/dist/index.d.mts +3036 -1314
- package/dist/index.d.ts +3036 -1314
- package/dist/index.js +2705 -985
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2667 -962
- package/dist/index.mjs.map +1 -1
- package/mcp-stdio/create-child-process.test.ts +92 -0
- package/mcp-stdio/create-child-process.ts +21 -0
- package/mcp-stdio/dist/index.d.mts +169 -0
- package/mcp-stdio/dist/index.d.ts +169 -0
- package/mcp-stdio/dist/index.js +352 -0
- package/mcp-stdio/dist/index.js.map +1 -0
- package/mcp-stdio/dist/index.mjs +337 -0
- package/mcp-stdio/dist/index.mjs.map +1 -0
- package/mcp-stdio/get-environment.ts +43 -0
- package/mcp-stdio/index.ts +4 -0
- package/mcp-stdio/mcp-stdio-transport.test.ts +262 -0
- package/mcp-stdio/mcp-stdio-transport.ts +157 -0
- package/package.json +14 -10
- package/react/dist/index.d.mts +12 -4
- package/react/dist/index.d.ts +12 -4
- package/react/dist/index.js +0 -3
- package/react/dist/index.js.map +1 -1
- package/react/dist/index.mjs +0 -3
- package/react/dist/index.mjs.map +1 -1
- package/rsc/dist/index.d.ts +108 -18
- package/rsc/dist/rsc-server.d.mts +108 -18
- package/rsc/dist/rsc-server.mjs +550 -256
- package/rsc/dist/rsc-server.mjs.map +1 -1
- package/rsc/dist/rsc-shared.mjs +1 -3
- package/rsc/dist/rsc-shared.mjs.map +1 -1
- package/test/dist/index.d.mts +2 -4
- package/test/dist/index.d.ts +2 -4
- package/test/dist/index.js +4 -14
- package/test/dist/index.js.map +1 -1
- package/test/dist/index.mjs +7 -14
- package/test/dist/index.mjs.map +1 -1
@@ -0,0 +1,157 @@
|
|
1
|
+
import type { ChildProcess, IOType } from 'node:child_process';
|
2
|
+
import { Stream } from 'node:stream';
|
3
|
+
import {
|
4
|
+
JSONRPCMessage,
|
5
|
+
JSONRPCMessageSchema,
|
6
|
+
} from '../core/tool/mcp/json-rpc-message';
|
7
|
+
import { MCPTransport } from '../core/tool/mcp/mcp-transport';
|
8
|
+
import { MCPClientError } from '../errors';
|
9
|
+
import { createChildProcess } from './create-child-process';
|
10
|
+
|
11
|
+
export interface StdioConfig {
|
12
|
+
command: string;
|
13
|
+
args?: string[];
|
14
|
+
env?: Record<string, string>;
|
15
|
+
stderr?: IOType | Stream | number;
|
16
|
+
cwd?: string;
|
17
|
+
}
|
18
|
+
|
19
|
+
export class StdioMCPTransport implements MCPTransport {
|
20
|
+
private process?: ChildProcess;
|
21
|
+
private abortController: AbortController = new AbortController();
|
22
|
+
private readBuffer: ReadBuffer = new ReadBuffer();
|
23
|
+
private serverParams: StdioConfig;
|
24
|
+
|
25
|
+
onclose?: () => void;
|
26
|
+
onerror?: (error: unknown) => void;
|
27
|
+
onmessage?: (message: JSONRPCMessage) => void;
|
28
|
+
|
29
|
+
constructor(server: StdioConfig) {
|
30
|
+
this.serverParams = server;
|
31
|
+
}
|
32
|
+
|
33
|
+
async start(): Promise<void> {
|
34
|
+
if (this.process) {
|
35
|
+
throw new MCPClientError({
|
36
|
+
message: 'StdioMCPTransport already started.',
|
37
|
+
});
|
38
|
+
}
|
39
|
+
|
40
|
+
return new Promise(async (resolve, reject) => {
|
41
|
+
try {
|
42
|
+
const process = await createChildProcess(
|
43
|
+
this.serverParams,
|
44
|
+
this.abortController.signal,
|
45
|
+
);
|
46
|
+
|
47
|
+
this.process = process;
|
48
|
+
|
49
|
+
this.process.on('error', error => {
|
50
|
+
if (error.name === 'AbortError') {
|
51
|
+
this.onclose?.();
|
52
|
+
return;
|
53
|
+
}
|
54
|
+
|
55
|
+
reject(error);
|
56
|
+
this.onerror?.(error);
|
57
|
+
});
|
58
|
+
|
59
|
+
this.process.on('spawn', () => {
|
60
|
+
resolve();
|
61
|
+
});
|
62
|
+
|
63
|
+
this.process.on('close', _code => {
|
64
|
+
this.process = undefined;
|
65
|
+
this.onclose?.();
|
66
|
+
});
|
67
|
+
|
68
|
+
this.process.stdin?.on('error', error => {
|
69
|
+
this.onerror?.(error);
|
70
|
+
});
|
71
|
+
|
72
|
+
this.process.stdout?.on('data', chunk => {
|
73
|
+
this.readBuffer.append(chunk);
|
74
|
+
this.processReadBuffer();
|
75
|
+
});
|
76
|
+
|
77
|
+
this.process.stdout?.on('error', error => {
|
78
|
+
this.onerror?.(error);
|
79
|
+
});
|
80
|
+
} catch (error) {
|
81
|
+
reject(error);
|
82
|
+
this.onerror?.(error);
|
83
|
+
}
|
84
|
+
});
|
85
|
+
}
|
86
|
+
|
87
|
+
private processReadBuffer() {
|
88
|
+
while (true) {
|
89
|
+
try {
|
90
|
+
const message = this.readBuffer.readMessage();
|
91
|
+
if (message === null) {
|
92
|
+
break;
|
93
|
+
}
|
94
|
+
|
95
|
+
this.onmessage?.(message);
|
96
|
+
} catch (error) {
|
97
|
+
this.onerror?.(error as Error);
|
98
|
+
}
|
99
|
+
}
|
100
|
+
}
|
101
|
+
|
102
|
+
async close(): Promise<void> {
|
103
|
+
this.abortController.abort();
|
104
|
+
this.process = undefined;
|
105
|
+
this.readBuffer.clear();
|
106
|
+
}
|
107
|
+
|
108
|
+
send(message: JSONRPCMessage): Promise<void> {
|
109
|
+
return new Promise(resolve => {
|
110
|
+
if (!this.process?.stdin) {
|
111
|
+
throw new MCPClientError({
|
112
|
+
message: 'StdioClientTransport not connected',
|
113
|
+
});
|
114
|
+
}
|
115
|
+
|
116
|
+
const json = serializeMessage(message);
|
117
|
+
if (this.process.stdin.write(json)) {
|
118
|
+
resolve();
|
119
|
+
} else {
|
120
|
+
this.process.stdin.once('drain', resolve);
|
121
|
+
}
|
122
|
+
});
|
123
|
+
}
|
124
|
+
}
|
125
|
+
|
126
|
+
class ReadBuffer {
|
127
|
+
private buffer?: Buffer;
|
128
|
+
|
129
|
+
append(chunk: Buffer): void {
|
130
|
+
this.buffer = this.buffer ? Buffer.concat([this.buffer, chunk]) : chunk;
|
131
|
+
}
|
132
|
+
|
133
|
+
readMessage(): JSONRPCMessage | null {
|
134
|
+
if (!this.buffer) return null;
|
135
|
+
|
136
|
+
const index = this.buffer.indexOf('\n');
|
137
|
+
if (index === -1) {
|
138
|
+
return null;
|
139
|
+
}
|
140
|
+
|
141
|
+
const line = this.buffer.toString('utf8', 0, index);
|
142
|
+
this.buffer = this.buffer.subarray(index + 1);
|
143
|
+
return deserializeMessage(line);
|
144
|
+
}
|
145
|
+
|
146
|
+
clear(): void {
|
147
|
+
this.buffer = undefined;
|
148
|
+
}
|
149
|
+
}
|
150
|
+
|
151
|
+
function serializeMessage(message: JSONRPCMessage): string {
|
152
|
+
return JSON.stringify(message) + '\n';
|
153
|
+
}
|
154
|
+
|
155
|
+
export function deserializeMessage(line: string): JSONRPCMessage {
|
156
|
+
return JSONRPCMessageSchema.parse(JSON.parse(line));
|
157
|
+
}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "ai",
|
3
|
-
"version": "0.0.0-
|
3
|
+
"version": "0.0.0-9477ebb9-20250403064906",
|
4
4
|
"description": "AI SDK by Vercel - The AI Toolkit for TypeScript and JavaScript",
|
5
5
|
"license": "Apache-2.0",
|
6
6
|
"sideEffects": false,
|
@@ -9,6 +9,7 @@
|
|
9
9
|
"types": "./dist/index.d.ts",
|
10
10
|
"files": [
|
11
11
|
"dist/**/*",
|
12
|
+
"mcp-stdio/**/*",
|
12
13
|
"react/dist/**/*",
|
13
14
|
"rsc/dist/**/*",
|
14
15
|
"test/dist/**/*",
|
@@ -37,19 +38,24 @@
|
|
37
38
|
"react-server": "./react/dist/index.server.mjs",
|
38
39
|
"import": "./react/dist/index.mjs",
|
39
40
|
"require": "./react/dist/index.js"
|
41
|
+
},
|
42
|
+
"./mcp-stdio": {
|
43
|
+
"types": "./mcp-stdio/dist/index.d.ts",
|
44
|
+
"import": "./mcp-stdio/dist/index.mjs",
|
45
|
+
"require": "./mcp-stdio/dist/index.js"
|
40
46
|
}
|
41
47
|
},
|
42
48
|
"dependencies": {
|
43
|
-
"@ai-sdk/provider": "1.0
|
44
|
-
"@ai-sdk/provider-utils": "2.
|
45
|
-
"@ai-sdk/react": "
|
46
|
-
"@ai-sdk/ui-utils": "
|
49
|
+
"@ai-sdk/provider": "1.1.0",
|
50
|
+
"@ai-sdk/provider-utils": "2.2.3",
|
51
|
+
"@ai-sdk/react": "0.0.0-9477ebb9-20250403064906",
|
52
|
+
"@ai-sdk/ui-utils": "0.0.0-9477ebb9-20250403064906",
|
47
53
|
"@opentelemetry/api": "1.9.0",
|
48
54
|
"jsondiffpatch": "0.6.0"
|
49
55
|
},
|
50
56
|
"devDependencies": {
|
51
57
|
"@edge-runtime/vm": "^5.0.0",
|
52
|
-
"@types/node": "
|
58
|
+
"@types/node": "20.17.24",
|
53
59
|
"@types/react": "^18",
|
54
60
|
"@types/react-dom": "^18",
|
55
61
|
"@vitejs/plugin-react": "4.3.3",
|
@@ -64,14 +70,11 @@
|
|
64
70
|
},
|
65
71
|
"peerDependencies": {
|
66
72
|
"react": "^18 || ^19 || ^19.0.0-rc",
|
67
|
-
"zod": "^3.
|
73
|
+
"zod": "^3.23.8"
|
68
74
|
},
|
69
75
|
"peerDependenciesMeta": {
|
70
76
|
"react": {
|
71
77
|
"optional": true
|
72
|
-
},
|
73
|
-
"zod": {
|
74
|
-
"optional": true
|
75
78
|
}
|
76
79
|
},
|
77
80
|
"engines": {
|
@@ -109,6 +112,7 @@
|
|
109
112
|
"test:node": "vitest --config vitest.node.config.js --run",
|
110
113
|
"test:node:watch": "vitest --config vitest.node.config.js",
|
111
114
|
"test:node:core": "pnpm vitest --config vitest.node.config.js --run ./core/",
|
115
|
+
"test:node:core:watch": "pnpm vitest --config vitest.node.config.js ./core/",
|
112
116
|
"test:node:util": "pnpm vitest --config vitest.node.config.js --run ./util/",
|
113
117
|
"test:ui": "pnpm test:ui:react",
|
114
118
|
"test:ui:react": "vitest --config vitest.ui.react.config.js --run",
|
package/react/dist/index.d.mts
CHANGED
@@ -1,10 +1,18 @@
|
|
1
1
|
import * as _ai_sdk_react from '@ai-sdk/react';
|
2
|
-
import { useChat as useChat$1, useCompletion as useCompletion$1
|
2
|
+
import { useChat as useChat$1, useCompletion as useCompletion$1 } from '@ai-sdk/react';
|
3
3
|
export { CreateMessage, Message, UseChatHelpers, UseChatOptions } from '@ai-sdk/react';
|
4
4
|
|
5
|
+
/**
|
6
|
+
* @deprecated Use `@ai-sdk/react` instead.
|
7
|
+
*/
|
5
8
|
declare const useChat: typeof useChat$1;
|
9
|
+
/**
|
10
|
+
* @deprecated Use `@ai-sdk/react` instead.
|
11
|
+
*/
|
6
12
|
declare const useCompletion: typeof useCompletion$1;
|
7
|
-
|
8
|
-
|
13
|
+
/**
|
14
|
+
* @deprecated Use `@ai-sdk/react` instead.
|
15
|
+
*/
|
16
|
+
declare const experimental_useObject: <RESULT, INPUT = any>({ api, id, schema, initialValue, fetch, onError, onFinish, headers, credentials, }: _ai_sdk_react.Experimental_UseObjectOptions<RESULT>) => _ai_sdk_react.Experimental_UseObjectHelpers<RESULT, INPUT>;
|
9
17
|
|
10
|
-
export { experimental_useObject,
|
18
|
+
export { experimental_useObject, useChat, useCompletion };
|
package/react/dist/index.d.ts
CHANGED
@@ -1,10 +1,18 @@
|
|
1
1
|
import * as _ai_sdk_react from '@ai-sdk/react';
|
2
|
-
import { useChat as useChat$1, useCompletion as useCompletion$1
|
2
|
+
import { useChat as useChat$1, useCompletion as useCompletion$1 } from '@ai-sdk/react';
|
3
3
|
export { CreateMessage, Message, UseChatHelpers, UseChatOptions } from '@ai-sdk/react';
|
4
4
|
|
5
|
+
/**
|
6
|
+
* @deprecated Use `@ai-sdk/react` instead.
|
7
|
+
*/
|
5
8
|
declare const useChat: typeof useChat$1;
|
9
|
+
/**
|
10
|
+
* @deprecated Use `@ai-sdk/react` instead.
|
11
|
+
*/
|
6
12
|
declare const useCompletion: typeof useCompletion$1;
|
7
|
-
|
8
|
-
|
13
|
+
/**
|
14
|
+
* @deprecated Use `@ai-sdk/react` instead.
|
15
|
+
*/
|
16
|
+
declare const experimental_useObject: <RESULT, INPUT = any>({ api, id, schema, initialValue, fetch, onError, onFinish, headers, credentials, }: _ai_sdk_react.Experimental_UseObjectOptions<RESULT>) => _ai_sdk_react.Experimental_UseObjectHelpers<RESULT, INPUT>;
|
9
17
|
|
10
|
-
export { experimental_useObject,
|
18
|
+
export { experimental_useObject, useChat, useCompletion };
|
package/react/dist/index.js
CHANGED
@@ -22,7 +22,6 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
22
22
|
var react_exports = {};
|
23
23
|
__export(react_exports, {
|
24
24
|
experimental_useObject: () => experimental_useObject,
|
25
|
-
useAssistant: () => useAssistant,
|
26
25
|
useChat: () => useChat,
|
27
26
|
useCompletion: () => useCompletion
|
28
27
|
});
|
@@ -30,12 +29,10 @@ module.exports = __toCommonJS(react_exports);
|
|
30
29
|
var import_react = require("@ai-sdk/react");
|
31
30
|
var useChat = import_react.useChat;
|
32
31
|
var useCompletion = import_react.useCompletion;
|
33
|
-
var useAssistant = import_react.useAssistant;
|
34
32
|
var experimental_useObject = import_react.experimental_useObject;
|
35
33
|
// Annotate the CommonJS export names for ESM import in node:
|
36
34
|
0 && (module.exports = {
|
37
35
|
experimental_useObject,
|
38
|
-
useAssistant,
|
39
36
|
useChat,
|
40
37
|
useCompletion
|
41
38
|
});
|
package/react/dist/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../index.ts"],"sourcesContent":["import {\n useChat as useChatReact,\n useCompletion as useCompletionReact,\n
|
1
|
+
{"version":3,"sources":["../index.ts"],"sourcesContent":["import {\n useChat as useChatReact,\n useCompletion as useCompletionReact,\n experimental_useObject as experimental_useObjectReact,\n} from '@ai-sdk/react';\n\n/**\n * @deprecated Use `@ai-sdk/react` instead.\n */\nexport const useChat = useChatReact;\n\n/**\n * @deprecated Use `@ai-sdk/react` instead.\n */\nexport const useCompletion = useCompletionReact;\n\n/**\n * @deprecated Use `@ai-sdk/react` instead.\n */\nexport const experimental_useObject = experimental_useObjectReact;\n\nexport type {\n /**\n * @deprecated Use `@ai-sdk/react` instead.\n */\n CreateMessage,\n\n /**\n * @deprecated Use `@ai-sdk/react` instead.\n */\n Message,\n\n /**\n * @deprecated Use `@ai-sdk/react` instead.\n */\n UseChatOptions,\n\n /**\n * @deprecated Use `@ai-sdk/react` instead.\n */\n UseChatHelpers,\n} from '@ai-sdk/react';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAIO;AAKA,IAAM,UAAU,aAAAA;AAKhB,IAAM,gBAAgB,aAAAC;AAKtB,IAAM,yBAAyB,aAAAC;","names":["useChatReact","useCompletionReact","experimental_useObjectReact"]}
|
package/react/dist/index.mjs
CHANGED
@@ -4,16 +4,13 @@
|
|
4
4
|
import {
|
5
5
|
useChat as useChatReact,
|
6
6
|
useCompletion as useCompletionReact,
|
7
|
-
useAssistant as useAssistantReact,
|
8
7
|
experimental_useObject as experimental_useObjectReact
|
9
8
|
} from "@ai-sdk/react";
|
10
9
|
var useChat = useChatReact;
|
11
10
|
var useCompletion = useCompletionReact;
|
12
|
-
var useAssistant = useAssistantReact;
|
13
11
|
var experimental_useObject = experimental_useObjectReact;
|
14
12
|
export {
|
15
13
|
experimental_useObject,
|
16
|
-
useAssistant,
|
17
14
|
useChat,
|
18
15
|
useCompletion
|
19
16
|
};
|
package/react/dist/index.mjs.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../index.ts"],"sourcesContent":["import {\n useChat as useChatReact,\n useCompletion as useCompletionReact,\n
|
1
|
+
{"version":3,"sources":["../index.ts"],"sourcesContent":["import {\n useChat as useChatReact,\n useCompletion as useCompletionReact,\n experimental_useObject as experimental_useObjectReact,\n} from '@ai-sdk/react';\n\n/**\n * @deprecated Use `@ai-sdk/react` instead.\n */\nexport const useChat = useChatReact;\n\n/**\n * @deprecated Use `@ai-sdk/react` instead.\n */\nexport const useCompletion = useCompletionReact;\n\n/**\n * @deprecated Use `@ai-sdk/react` instead.\n */\nexport const experimental_useObject = experimental_useObjectReact;\n\nexport type {\n /**\n * @deprecated Use `@ai-sdk/react` instead.\n */\n CreateMessage,\n\n /**\n * @deprecated Use `@ai-sdk/react` instead.\n */\n Message,\n\n /**\n * @deprecated Use `@ai-sdk/react` instead.\n */\n UseChatOptions,\n\n /**\n * @deprecated Use `@ai-sdk/react` instead.\n */\n UseChatHelpers,\n} from '@ai-sdk/react';\n"],"mappings":";;;AAAA;AAAA,EACE,WAAW;AAAA,EACX,iBAAiB;AAAA,EACjB,0BAA0B;AAAA,OACrB;AAKA,IAAM,UAAU;AAKhB,IAAM,gBAAgB;AAKtB,IAAM,yBAAyB;","names":[]}
|
package/rsc/dist/index.d.ts
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
import { LanguageModelV1FinishReason, LanguageModelV1CallWarning, LanguageModelV1ProviderMetadata, LanguageModelV1 } from '@ai-sdk/provider';
|
2
2
|
import { ReactNode } from 'react';
|
3
3
|
import { z } from 'zod';
|
4
|
-
import {
|
4
|
+
import { Message } from '@ai-sdk/ui-utils';
|
5
5
|
|
6
6
|
type AIAction<T = any, R = any> = (...args: T[]) => Promise<R>;
|
7
7
|
type AIActions<T = any, R = any> = Record<string, AIAction<T, R>>;
|
@@ -199,17 +199,25 @@ Tool choice for the generation. It supports the following settings:
|
|
199
199
|
- `none`: the model must not call tools
|
200
200
|
- `{ type: 'tool', toolName: string (typed) }`: the model must call the specified tool
|
201
201
|
*/
|
202
|
-
type
|
202
|
+
type ToolChoice<TOOLS extends Record<string, unknown>> = 'auto' | 'none' | 'required' | {
|
203
203
|
type: 'tool';
|
204
204
|
toolName: keyof TOOLS;
|
205
205
|
};
|
206
206
|
|
207
207
|
/**
|
208
|
-
Additional provider-specific metadata
|
209
|
-
|
210
|
-
|
208
|
+
Additional provider-specific metadata that is returned from the provider.
|
209
|
+
|
210
|
+
This is needed to enable provider-specific functionality that can be
|
211
|
+
fully encapsulated in the provider.
|
211
212
|
*/
|
212
213
|
type ProviderMetadata = LanguageModelV1ProviderMetadata;
|
214
|
+
/**
|
215
|
+
Additional provider-specific options.
|
216
|
+
|
217
|
+
They are passed through to the provider from the AI SDK and enable
|
218
|
+
provider-specific functionality that can be fully encapsulated in the provider.
|
219
|
+
*/
|
220
|
+
type ProviderOptions = LanguageModelV1ProviderMetadata;
|
213
221
|
|
214
222
|
/**
|
215
223
|
Represents the number of tokens used in a prompt and completion.
|
@@ -256,6 +264,10 @@ interface TextPart {
|
|
256
264
|
Additional provider-specific metadata. They are passed through
|
257
265
|
to the provider from the AI SDK and enable provider-specific
|
258
266
|
functionality that can be fully encapsulated in the provider.
|
267
|
+
*/
|
268
|
+
providerOptions?: ProviderOptions;
|
269
|
+
/**
|
270
|
+
@deprecated Use `providerOptions` instead.
|
259
271
|
*/
|
260
272
|
experimental_providerMetadata?: ProviderMetadata;
|
261
273
|
}
|
@@ -279,6 +291,10 @@ interface ImagePart {
|
|
279
291
|
Additional provider-specific metadata. They are passed through
|
280
292
|
to the provider from the AI SDK and enable provider-specific
|
281
293
|
functionality that can be fully encapsulated in the provider.
|
294
|
+
*/
|
295
|
+
providerOptions?: ProviderOptions;
|
296
|
+
/**
|
297
|
+
@deprecated Use `providerOptions` instead.
|
282
298
|
*/
|
283
299
|
experimental_providerMetadata?: ProviderMetadata;
|
284
300
|
}
|
@@ -295,6 +311,10 @@ interface FilePart {
|
|
295
311
|
*/
|
296
312
|
data: DataContent | URL;
|
297
313
|
/**
|
314
|
+
Optional filename of the file.
|
315
|
+
*/
|
316
|
+
filename?: string;
|
317
|
+
/**
|
298
318
|
Mime type of the file.
|
299
319
|
*/
|
300
320
|
mimeType: string;
|
@@ -302,6 +322,54 @@ interface FilePart {
|
|
302
322
|
Additional provider-specific metadata. They are passed through
|
303
323
|
to the provider from the AI SDK and enable provider-specific
|
304
324
|
functionality that can be fully encapsulated in the provider.
|
325
|
+
*/
|
326
|
+
providerOptions?: ProviderOptions;
|
327
|
+
/**
|
328
|
+
@deprecated Use `providerOptions` instead.
|
329
|
+
*/
|
330
|
+
experimental_providerMetadata?: ProviderMetadata;
|
331
|
+
}
|
332
|
+
/**
|
333
|
+
* Reasoning content part of a prompt. It contains a reasoning.
|
334
|
+
*/
|
335
|
+
interface ReasoningPart {
|
336
|
+
type: 'reasoning';
|
337
|
+
/**
|
338
|
+
The reasoning text.
|
339
|
+
*/
|
340
|
+
text: string;
|
341
|
+
/**
|
342
|
+
An optional signature for verifying that the reasoning originated from the model.
|
343
|
+
*/
|
344
|
+
signature?: string;
|
345
|
+
/**
|
346
|
+
Additional provider-specific metadata. They are passed through
|
347
|
+
to the provider from the AI SDK and enable provider-specific
|
348
|
+
functionality that can be fully encapsulated in the provider.
|
349
|
+
*/
|
350
|
+
providerOptions?: ProviderOptions;
|
351
|
+
/**
|
352
|
+
@deprecated Use `providerOptions` instead.
|
353
|
+
*/
|
354
|
+
experimental_providerMetadata?: ProviderMetadata;
|
355
|
+
}
|
356
|
+
/**
|
357
|
+
Redacted reasoning content part of a prompt.
|
358
|
+
*/
|
359
|
+
interface RedactedReasoningPart {
|
360
|
+
type: 'redacted-reasoning';
|
361
|
+
/**
|
362
|
+
Redacted reasoning data.
|
363
|
+
*/
|
364
|
+
data: string;
|
365
|
+
/**
|
366
|
+
Additional provider-specific metadata. They are passed through
|
367
|
+
to the provider from the AI SDK and enable provider-specific
|
368
|
+
functionality that can be fully encapsulated in the provider.
|
369
|
+
*/
|
370
|
+
providerOptions?: ProviderOptions;
|
371
|
+
/**
|
372
|
+
@deprecated Use `providerOptions` instead.
|
305
373
|
*/
|
306
374
|
experimental_providerMetadata?: ProviderMetadata;
|
307
375
|
}
|
@@ -326,6 +394,10 @@ interface ToolCallPart {
|
|
326
394
|
Additional provider-specific metadata. They are passed through
|
327
395
|
to the provider from the AI SDK and enable provider-specific
|
328
396
|
functionality that can be fully encapsulated in the provider.
|
397
|
+
*/
|
398
|
+
providerOptions?: ProviderOptions;
|
399
|
+
/**
|
400
|
+
@deprecated Use `providerOptions` instead.
|
329
401
|
*/
|
330
402
|
experimental_providerMetadata?: ProviderMetadata;
|
331
403
|
}
|
@@ -358,6 +430,10 @@ interface ToolResultPart {
|
|
358
430
|
Additional provider-specific metadata. They are passed through
|
359
431
|
to the provider from the AI SDK and enable provider-specific
|
360
432
|
functionality that can be fully encapsulated in the provider.
|
433
|
+
*/
|
434
|
+
providerOptions?: ProviderOptions;
|
435
|
+
/**
|
436
|
+
@deprecated Use `providerOptions` instead.
|
361
437
|
*/
|
362
438
|
experimental_providerMetadata?: ProviderMetadata;
|
363
439
|
}
|
@@ -376,6 +452,10 @@ type CoreSystemMessage = {
|
|
376
452
|
Additional provider-specific metadata. They are passed through
|
377
453
|
to the provider from the AI SDK and enable provider-specific
|
378
454
|
functionality that can be fully encapsulated in the provider.
|
455
|
+
*/
|
456
|
+
providerOptions?: ProviderOptions;
|
457
|
+
/**
|
458
|
+
@deprecated Use `providerOptions` instead.
|
379
459
|
*/
|
380
460
|
experimental_providerMetadata?: ProviderMetadata;
|
381
461
|
};
|
@@ -390,6 +470,10 @@ type CoreUserMessage = {
|
|
390
470
|
to the provider from the AI SDK and enable provider-specific
|
391
471
|
functionality that can be fully encapsulated in the provider.
|
392
472
|
*/
|
473
|
+
providerOptions?: ProviderOptions;
|
474
|
+
/**
|
475
|
+
@deprecated Use `providerOptions` instead.
|
476
|
+
*/
|
393
477
|
experimental_providerMetadata?: ProviderMetadata;
|
394
478
|
};
|
395
479
|
/**
|
@@ -407,12 +491,17 @@ type CoreAssistantMessage = {
|
|
407
491
|
to the provider from the AI SDK and enable provider-specific
|
408
492
|
functionality that can be fully encapsulated in the provider.
|
409
493
|
*/
|
494
|
+
providerOptions?: ProviderOptions;
|
495
|
+
/**
|
496
|
+
@deprecated Use `providerOptions` instead.
|
497
|
+
*/
|
410
498
|
experimental_providerMetadata?: ProviderMetadata;
|
411
499
|
};
|
412
500
|
/**
|
413
|
-
Content of an assistant message.
|
501
|
+
Content of an assistant message.
|
502
|
+
It can be a string or an array of text, image, reasoning, redacted reasoning, and tool call parts.
|
414
503
|
*/
|
415
|
-
type AssistantContent = string | Array<TextPart | ToolCallPart>;
|
504
|
+
type AssistantContent = string | Array<TextPart | FilePart | ReasoningPart | RedactedReasoningPart | ToolCallPart>;
|
416
505
|
/**
|
417
506
|
A tool message. It contains the result of one or more tool calls.
|
418
507
|
*/
|
@@ -424,6 +513,10 @@ type CoreToolMessage = {
|
|
424
513
|
to the provider from the AI SDK and enable provider-specific
|
425
514
|
functionality that can be fully encapsulated in the provider.
|
426
515
|
*/
|
516
|
+
providerOptions?: ProviderOptions;
|
517
|
+
/**
|
518
|
+
@deprecated Use `providerOptions` instead.
|
519
|
+
*/
|
427
520
|
experimental_providerMetadata?: ProviderMetadata;
|
428
521
|
};
|
429
522
|
/**
|
@@ -436,13 +529,6 @@ It can be a user message, an assistant message, or a tool message.
|
|
436
529
|
*/
|
437
530
|
type CoreMessage = CoreSystemMessage | CoreUserMessage | CoreAssistantMessage | CoreToolMessage;
|
438
531
|
|
439
|
-
type UIMessage = {
|
440
|
-
role: 'system' | 'user' | 'assistant' | 'data';
|
441
|
-
content: string;
|
442
|
-
toolInvocations?: ToolInvocation[];
|
443
|
-
experimental_attachments?: Attachment[];
|
444
|
-
};
|
445
|
-
|
446
532
|
/**
|
447
533
|
Prompt part of the AI function options.
|
448
534
|
It contains a system message, a simple text prompt, or a list of messages.
|
@@ -459,7 +545,7 @@ type Prompt = {
|
|
459
545
|
/**
|
460
546
|
A list of messages. You can either use `prompt` or `messages` but not both.
|
461
547
|
*/
|
462
|
-
messages?: Array<CoreMessage> | Array<
|
548
|
+
messages?: Array<CoreMessage> | Array<Omit<Message, 'id'>>;
|
463
549
|
};
|
464
550
|
|
465
551
|
type Streamable = ReactNode | Promise<ReactNode>;
|
@@ -500,7 +586,7 @@ type RenderResult = {
|
|
500
586
|
*/
|
501
587
|
declare function streamUI<TOOLS extends {
|
502
588
|
[name: string]: z.ZodTypeAny;
|
503
|
-
} = {}>({ model, tools, toolChoice, system, prompt, messages, maxRetries, abortSignal, headers, initial, text, experimental_providerMetadata
|
589
|
+
} = {}>({ model, tools, toolChoice, system, prompt, messages, maxRetries, abortSignal, headers, initial, text, experimental_providerMetadata, providerOptions, onFinish, ...settings }: CallSettings & Prompt & {
|
504
590
|
/**
|
505
591
|
* The language model to use.
|
506
592
|
*/
|
@@ -514,14 +600,18 @@ declare function streamUI<TOOLS extends {
|
|
514
600
|
/**
|
515
601
|
* The tool choice strategy. Default: 'auto'.
|
516
602
|
*/
|
517
|
-
toolChoice?:
|
603
|
+
toolChoice?: ToolChoice<TOOLS>;
|
518
604
|
text?: RenderText;
|
519
605
|
initial?: ReactNode;
|
520
606
|
/**
|
521
|
-
Additional provider-specific
|
607
|
+
Additional provider-specific options. They are passed through
|
522
608
|
to the provider from the AI SDK and enable provider-specific
|
523
609
|
functionality that can be fully encapsulated in the provider.
|
524
610
|
*/
|
611
|
+
providerOptions?: ProviderOptions;
|
612
|
+
/**
|
613
|
+
@deprecated Use `providerOptions` instead.
|
614
|
+
*/
|
525
615
|
experimental_providerMetadata?: ProviderMetadata;
|
526
616
|
/**
|
527
617
|
* Callback that is called when the LLM response and the final object validation are finished.
|