@ai-sdk/react 4.0.123 → 4.0.126
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 +37 -0
- package/dist/index.d.ts +280 -276
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1171 -1346
- package/dist/index.js.map +1 -1
- package/package.json +10 -10
- package/src/use-chat.ts +37 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,42 @@
|
|
|
1
1
|
# @ai-sdk/react
|
|
2
2
|
|
|
3
|
+
## 4.0.126
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 193d284: fix(react): deduplicate automatic stream resumption for shared Chat instances
|
|
8
|
+
- ede5b89: chore: migrate package builds from tsup to tsdown
|
|
9
|
+
- Updated dependencies [05cdac6]
|
|
10
|
+
- Updated dependencies [4514fc1]
|
|
11
|
+
- Updated dependencies [ede5b89]
|
|
12
|
+
- Updated dependencies [2a625cf]
|
|
13
|
+
- Updated dependencies [50a26d5]
|
|
14
|
+
- ai@7.0.123
|
|
15
|
+
- @ai-sdk/mcp@2.0.63
|
|
16
|
+
- @ai-sdk/provider@4.0.20
|
|
17
|
+
- @ai-sdk/provider-utils@5.0.52
|
|
18
|
+
|
|
19
|
+
## 4.0.125
|
|
20
|
+
|
|
21
|
+
### Patch Changes
|
|
22
|
+
|
|
23
|
+
- Updated dependencies [f3575f8]
|
|
24
|
+
- Updated dependencies [27ab8d4]
|
|
25
|
+
- ai@7.0.122
|
|
26
|
+
|
|
27
|
+
## 4.0.124
|
|
28
|
+
|
|
29
|
+
### Patch Changes
|
|
30
|
+
|
|
31
|
+
- Updated dependencies [c5e90bb]
|
|
32
|
+
- Updated dependencies [c2511c1]
|
|
33
|
+
- Updated dependencies [868c475]
|
|
34
|
+
- Updated dependencies [119536f]
|
|
35
|
+
- Updated dependencies [9941f32]
|
|
36
|
+
- ai@7.0.121
|
|
37
|
+
- @ai-sdk/provider-utils@5.0.51
|
|
38
|
+
- @ai-sdk/mcp@2.0.62
|
|
39
|
+
|
|
3
40
|
## 4.0.123
|
|
4
41
|
|
|
5
42
|
### Patch Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -1,318 +1,322 @@
|
|
|
1
|
-
import { FlexibleSchema,
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import { FetchFunction, FlexibleSchema, InferSchema, Resolvable } from "@ai-sdk/provider-utils";
|
|
2
|
+
import { AbstractChat, ChatInit, CompletionRequestOptions, CreateUIMessage, DeepPartial, DynamicToolUIPart, Experimental_AbstractRealtimeSession, Experimental_RealtimeServerEvent, Experimental_RealtimeSessionOptions, Experimental_RealtimeState, Experimental_RealtimeStatus as RealtimeStatus, ToolUIPart, UIMessage, UIMessage as UIMessage$1, UITools, UseCompletionOptions } from "ai";
|
|
3
|
+
import { CSSProperties, ReactNode } from "react";
|
|
4
|
+
import { MCPAppResource } from "@ai-sdk/mcp";
|
|
5
|
+
//#region src/use-object.d.ts
|
|
6
|
+
export type UseObjectOptions<SCHEMA extends FlexibleSchema, RESULT> = {
|
|
7
|
+
/**
|
|
8
|
+
* The API endpoint. It should stream JSON that matches the schema as chunked text.
|
|
9
|
+
*/
|
|
10
|
+
api: string;
|
|
11
|
+
/**
|
|
12
|
+
* A schema that defines the shape of the complete object.
|
|
13
|
+
*/
|
|
14
|
+
schema: SCHEMA;
|
|
15
|
+
/**
|
|
16
|
+
* An unique identifier. If not provided, a random one will be
|
|
17
|
+
* generated. When provided, the `useObject` hook with the same `id` will
|
|
18
|
+
* have shared states across components.
|
|
19
|
+
*/
|
|
20
|
+
id?: string;
|
|
21
|
+
/**
|
|
22
|
+
* An optional value for the initial object.
|
|
23
|
+
*/
|
|
24
|
+
initialValue?: DeepPartial<RESULT>;
|
|
25
|
+
/**
|
|
26
|
+
* Custom fetch implementation. You can use it as a middleware to intercept requests,
|
|
27
|
+
* or to provide a custom fetch implementation for e.g. testing.
|
|
28
|
+
*/
|
|
29
|
+
fetch?: FetchFunction;
|
|
30
|
+
/**
|
|
31
|
+
* Callback that is called when the stream has finished.
|
|
32
|
+
*/
|
|
33
|
+
onFinish?: (event: {
|
|
11
34
|
/**
|
|
12
|
-
* The
|
|
35
|
+
* The generated object (typed according to the schema).
|
|
36
|
+
* Can be undefined if the final object does not match the schema.
|
|
13
37
|
*/
|
|
14
|
-
|
|
38
|
+
object: RESULT | undefined;
|
|
15
39
|
/**
|
|
16
|
-
*
|
|
17
|
-
*/
|
|
18
|
-
schema: SCHEMA;
|
|
19
|
-
/**
|
|
20
|
-
* An unique identifier. If not provided, a random one will be
|
|
21
|
-
* generated. When provided, the `useObject` hook with the same `id` will
|
|
22
|
-
* have shared states across components.
|
|
23
|
-
*/
|
|
24
|
-
id?: string;
|
|
25
|
-
/**
|
|
26
|
-
* An optional value for the initial object.
|
|
27
|
-
*/
|
|
28
|
-
initialValue?: DeepPartial<RESULT>;
|
|
29
|
-
/**
|
|
30
|
-
* Custom fetch implementation. You can use it as a middleware to intercept requests,
|
|
31
|
-
* or to provide a custom fetch implementation for e.g. testing.
|
|
32
|
-
*/
|
|
33
|
-
fetch?: FetchFunction;
|
|
34
|
-
/**
|
|
35
|
-
* Callback that is called when the stream has finished.
|
|
36
|
-
*/
|
|
37
|
-
onFinish?: (event: {
|
|
38
|
-
/**
|
|
39
|
-
* The generated object (typed according to the schema).
|
|
40
|
-
* Can be undefined if the final object does not match the schema.
|
|
41
|
-
*/
|
|
42
|
-
object: RESULT | undefined;
|
|
43
|
-
/**
|
|
44
|
-
* Optional error object. This is e.g. a TypeValidationError when the final object does not match the schema.
|
|
45
|
-
*/
|
|
46
|
-
error: Error | undefined;
|
|
47
|
-
}) => Promise<void> | void;
|
|
48
|
-
/**
|
|
49
|
-
* Callback function to be called when an error is encountered.
|
|
50
|
-
*/
|
|
51
|
-
onError?: (error: Error) => void;
|
|
52
|
-
/**
|
|
53
|
-
* Additional HTTP headers to be included in the request.
|
|
54
|
-
* Can be a static object, a function that returns headers, or an async function
|
|
55
|
-
* for dynamic auth tokens.
|
|
56
|
-
*/
|
|
57
|
-
headers?: Resolvable<Record<string, string> | Headers>;
|
|
58
|
-
/**
|
|
59
|
-
* The credentials mode to be used for the fetch request.
|
|
60
|
-
* Possible values are: 'omit', 'same-origin', 'include'.
|
|
61
|
-
* Defaults to 'same-origin'.
|
|
62
|
-
*/
|
|
63
|
-
credentials?: RequestCredentials;
|
|
64
|
-
};
|
|
65
|
-
type UseObjectHelpers<RESULT, INPUT> = {
|
|
66
|
-
/**
|
|
67
|
-
* Calls the API with the provided input as JSON body.
|
|
68
|
-
*/
|
|
69
|
-
submit: (input: INPUT) => void;
|
|
70
|
-
/**
|
|
71
|
-
* The current value for the generated object. Updated as the API streams JSON chunks.
|
|
72
|
-
*/
|
|
73
|
-
object: DeepPartial<RESULT> | undefined;
|
|
74
|
-
/**
|
|
75
|
-
* The error object of the API request if any.
|
|
40
|
+
* Optional error object. This is e.g. a TypeValidationError when the final object does not match the schema.
|
|
76
41
|
*/
|
|
77
42
|
error: Error | undefined;
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
43
|
+
}) => Promise<void> | void;
|
|
44
|
+
/**
|
|
45
|
+
* Callback function to be called when an error is encountered.
|
|
46
|
+
*/
|
|
47
|
+
onError?: (error: Error) => void;
|
|
48
|
+
/**
|
|
49
|
+
* Additional HTTP headers to be included in the request.
|
|
50
|
+
* Can be a static object, a function that returns headers, or an async function
|
|
51
|
+
* for dynamic auth tokens.
|
|
52
|
+
*/
|
|
53
|
+
headers?: Resolvable<Record<string, string> | Headers>;
|
|
54
|
+
/**
|
|
55
|
+
* The credentials mode to be used for the fetch request.
|
|
56
|
+
* Possible values are: 'omit', 'same-origin', 'include'.
|
|
57
|
+
* Defaults to 'same-origin'.
|
|
58
|
+
*/
|
|
59
|
+
credentials?: RequestCredentials;
|
|
90
60
|
};
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
61
|
+
export type UseObjectHelpers<RESULT, INPUT> = {
|
|
62
|
+
/**
|
|
63
|
+
* Calls the API with the provided input as JSON body.
|
|
64
|
+
*/
|
|
65
|
+
submit: (input: INPUT) => void;
|
|
66
|
+
/**
|
|
67
|
+
* The current value for the generated object. Updated as the API streams JSON chunks.
|
|
68
|
+
*/
|
|
69
|
+
object: DeepPartial<RESULT> | undefined;
|
|
70
|
+
/**
|
|
71
|
+
* The error object of the API request if any.
|
|
72
|
+
*/
|
|
73
|
+
error: Error | undefined;
|
|
74
|
+
/**
|
|
75
|
+
* Flag that indicates whether an API request is in progress.
|
|
76
|
+
*/
|
|
77
|
+
isLoading: boolean;
|
|
78
|
+
/**
|
|
79
|
+
* Abort the current request immediately, keep the current partial object if any.
|
|
80
|
+
*/
|
|
81
|
+
stop: () => void;
|
|
82
|
+
/**
|
|
83
|
+
* Clear the object state.
|
|
84
|
+
*/
|
|
85
|
+
clear: () => void;
|
|
86
|
+
};
|
|
87
|
+
export declare function useObject<SCHEMA extends FlexibleSchema, RESULT = InferSchema<SCHEMA>, INPUT = any>({ api, id, schema, initialValue, fetch, onError, onFinish, headers, credentials }: UseObjectOptions<SCHEMA, RESULT>): UseObjectHelpers<RESULT, INPUT>;
|
|
88
|
+
//#endregion
|
|
89
|
+
//#region src/chat.react.d.ts
|
|
90
|
+
export declare class Chat<UI_MESSAGE extends UIMessage$1> extends AbstractChat<UI_MESSAGE> {
|
|
91
|
+
#private;
|
|
92
|
+
constructor({ messages, ...init }: ChatInit<UI_MESSAGE>);
|
|
93
|
+
'~registerMessagesCallback': (onChange: () => void, throttleWaitMs?: number) => (() => void);
|
|
94
|
+
'~registerStatusCallback': (onChange: () => void) => (() => void);
|
|
95
|
+
'~registerErrorCallback': (onChange: () => void) => (() => void);
|
|
100
96
|
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
97
|
+
//#endregion
|
|
98
|
+
//#region src/use-chat.d.ts
|
|
99
|
+
export type UseChatHelpers<UI_MESSAGE extends UIMessage> = {
|
|
100
|
+
/**
|
|
101
|
+
* The id of the chat.
|
|
102
|
+
*/
|
|
103
|
+
readonly id: string;
|
|
104
|
+
/**
|
|
105
|
+
* Update the `messages` state locally. This is useful when you want to
|
|
106
|
+
* edit the messages on the client, and then trigger the `reload` method
|
|
107
|
+
* manually to regenerate the AI response.
|
|
108
|
+
*/
|
|
109
|
+
setMessages: (messages: UI_MESSAGE[] | ((messages: UI_MESSAGE[]) => UI_MESSAGE[])) => void;
|
|
110
|
+
error: Error | undefined;
|
|
114
111
|
} & Pick<AbstractChat<UI_MESSAGE>, 'sendMessage' | 'regenerate' | 'stop' | 'resumeStream' | 'addToolResult' | 'addToolOutput' | 'addToolApprovalResponse' | 'status' | 'messages' | 'clearError'>;
|
|
115
|
-
type UseChatOptions<UI_MESSAGE extends UIMessage> = ({
|
|
116
|
-
|
|
112
|
+
export type UseChatOptions<UI_MESSAGE extends UIMessage> = ({
|
|
113
|
+
chat: Chat<UI_MESSAGE>;
|
|
117
114
|
} | ChatInit<UI_MESSAGE>) & {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
115
|
+
/**
|
|
116
|
+
* Custom throttle wait in ms for the chat messages and data updates.
|
|
117
|
+
* Default is undefined, which disables throttling.
|
|
118
|
+
*/
|
|
119
|
+
throttle?: number;
|
|
120
|
+
/**
|
|
121
|
+
* @deprecated Use `throttle` instead.
|
|
122
|
+
*/
|
|
123
|
+
experimental_throttle?: number;
|
|
124
|
+
/**
|
|
125
|
+
* Whether to resume an ongoing chat generation stream.
|
|
126
|
+
*/
|
|
127
|
+
resume?: boolean;
|
|
131
128
|
};
|
|
132
|
-
declare function useChat<UI_MESSAGE extends UIMessage = UIMessage>({ throttle, experimental_throttle, resume, ...options }?: UseChatOptions<UI_MESSAGE>): UseChatHelpers<UI_MESSAGE>;
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
129
|
+
export declare function useChat<UI_MESSAGE extends UIMessage = UIMessage>({ throttle, experimental_throttle, resume, ...options }?: UseChatOptions<UI_MESSAGE>): UseChatHelpers<UI_MESSAGE>;
|
|
130
|
+
//#endregion
|
|
131
|
+
//#region src/use-completion.d.ts
|
|
132
|
+
export type UseCompletionHelpers<BODY extends object = object> = {
|
|
133
|
+
/** The current completion result */
|
|
134
|
+
completion: string;
|
|
135
|
+
/**
|
|
136
|
+
* Send a new prompt to the API endpoint and update the completion state.
|
|
137
|
+
*/
|
|
138
|
+
complete: (prompt: string, options?: CompletionRequestOptions<BODY>) => Promise<string | null | undefined>;
|
|
139
|
+
/** The error object of the API request */
|
|
140
|
+
error: undefined | Error;
|
|
141
|
+
/**
|
|
142
|
+
* Abort the current API request but keep the generated tokens.
|
|
143
|
+
*/
|
|
144
|
+
stop: () => void;
|
|
145
|
+
/**
|
|
146
|
+
* Update the `completion` state locally.
|
|
147
|
+
*/
|
|
148
|
+
setCompletion: (completion: string) => void;
|
|
149
|
+
/** The current value of the input */
|
|
150
|
+
input: string;
|
|
151
|
+
/** setState-powered method to update the input value */
|
|
152
|
+
setInput: React.Dispatch<React.SetStateAction<string>>;
|
|
153
|
+
/**
|
|
154
|
+
* An input/textarea-ready onChange handler to control the value of the input
|
|
155
|
+
* @example
|
|
156
|
+
* ```jsx
|
|
157
|
+
* <input onChange={handleInputChange} value={input} />
|
|
158
|
+
* ```
|
|
159
|
+
*/
|
|
160
|
+
handleInputChange: (event: React.ChangeEvent<HTMLInputElement> | React.ChangeEvent<HTMLTextAreaElement>) => void;
|
|
161
|
+
/**
|
|
162
|
+
* Form submission handler to automatically reset input and append a user message
|
|
163
|
+
* @example
|
|
164
|
+
* ```jsx
|
|
165
|
+
* <form onSubmit={handleSubmit}>
|
|
166
|
+
* <input onChange={handleInputChange} value={input} />
|
|
167
|
+
* </form>
|
|
168
|
+
* ```
|
|
169
|
+
*/
|
|
170
|
+
handleSubmit: (event?: {
|
|
171
|
+
preventDefault?: () => void;
|
|
172
|
+
}) => void;
|
|
173
|
+
/** Whether the API request is in progress */
|
|
174
|
+
isLoading: boolean;
|
|
177
175
|
};
|
|
178
|
-
declare function useCompletion<BODY extends object = object>({ api, id, initialCompletion, initialInput, credentials, headers, body, streamProtocol, fetch, onFinish, onError, throttle: throttleWait, experimental_throttle
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
176
|
+
export declare function useCompletion<BODY extends object = object>({ api, id, initialCompletion, initialInput, credentials, headers, body, streamProtocol, fetch, onFinish, onError, throttle: throttleWait, experimental_throttle }?: UseCompletionOptions<NoInfer<BODY>> & {
|
|
177
|
+
/**
|
|
178
|
+
* Custom throttle wait in ms for the completion and data updates.
|
|
179
|
+
* Default is undefined, which disables throttling.
|
|
180
|
+
*/
|
|
181
|
+
throttle?: number;
|
|
182
|
+
/**
|
|
183
|
+
* @deprecated Use `throttle` instead.
|
|
184
|
+
*/
|
|
185
|
+
experimental_throttle?: number;
|
|
188
186
|
}): UseCompletionHelpers<BODY>;
|
|
189
|
-
|
|
187
|
+
//#endregion
|
|
188
|
+
//#region src/use-realtime.d.ts
|
|
190
189
|
type UseRealtimeOptions = Experimental_RealtimeSessionOptions;
|
|
191
190
|
type UseRealtimeReturn = {
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
191
|
+
status: RealtimeStatus;
|
|
192
|
+
messages: UIMessage$1[];
|
|
193
|
+
events: Experimental_RealtimeServerEvent[];
|
|
194
|
+
isCapturing: boolean;
|
|
195
|
+
isPlaying: boolean;
|
|
196
|
+
session?: Experimental_RealtimeState['session'];
|
|
197
|
+
connect: Experimental_AbstractRealtimeSession['connect'];
|
|
198
|
+
close: Experimental_AbstractRealtimeSession['close'];
|
|
199
|
+
resumePlayback: () => Promise<void>;
|
|
200
|
+
resumeAudioCapture: () => Promise<void>;
|
|
201
|
+
disconnect: () => void;
|
|
202
|
+
addToolOutput: (callId: string, result: unknown) => void;
|
|
203
|
+
sendEvent: Experimental_AbstractRealtimeSession['sendEvent'];
|
|
204
|
+
sendTextMessage: (text: string) => void;
|
|
205
|
+
sendAudio: (base64Audio: string) => void;
|
|
206
|
+
commitAudio: () => void;
|
|
207
|
+
clearAudioBuffer: () => void;
|
|
208
|
+
requestResponse: (options?: {
|
|
209
|
+
modalities?: string[];
|
|
210
|
+
}) => void;
|
|
211
|
+
cancelResponse: () => void;
|
|
212
|
+
startAudioCapture: (stream: MediaStream) => void;
|
|
213
|
+
stopAudioCapture: () => void;
|
|
214
|
+
stopPlayback: () => void;
|
|
216
215
|
};
|
|
217
216
|
declare function useRealtime(options: UseRealtimeOptions): UseRealtimeReturn;
|
|
218
|
-
declare const experimental_useRealtime: typeof useRealtime;
|
|
219
|
-
|
|
217
|
+
export declare const experimental_useRealtime: typeof useRealtime;
|
|
218
|
+
//#endregion
|
|
219
|
+
//#region src/mcp-apps/sandbox.d.ts
|
|
220
220
|
/**
|
|
221
221
|
* A permission an MCP App may request and a host may allow.
|
|
222
222
|
*/
|
|
223
223
|
type MCPAppPermission = 'camera' | 'microphone' | 'geolocation' | 'clipboardWrite';
|
|
224
|
-
|
|
224
|
+
//#endregion
|
|
225
|
+
//#region src/mcp-apps/types.d.ts
|
|
225
226
|
type MCPAppDisplayMode = 'inline' | 'fullscreen' | 'pip';
|
|
226
227
|
type MCPAppMetadata = {
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
228
|
+
resourceUri: string;
|
|
229
|
+
mimeType: MCPAppResource['mimeType'];
|
|
230
|
+
visibility?: Array<'model' | 'app'>;
|
|
230
231
|
};
|
|
231
232
|
type MCPAppHostContext = {
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
233
|
+
theme?: 'light' | 'dark';
|
|
234
|
+
displayMode?: MCPAppDisplayMode;
|
|
235
|
+
availableDisplayModes?: MCPAppDisplayMode[];
|
|
236
|
+
[key: string]: unknown;
|
|
236
237
|
};
|
|
237
238
|
type MCPAppToolCallParams = {
|
|
238
|
-
|
|
239
|
-
|
|
239
|
+
name: string;
|
|
240
|
+
arguments?: Record<string, unknown>;
|
|
240
241
|
};
|
|
241
242
|
type MCPAppBridgeHandlers = {
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
243
|
+
/**
|
|
244
|
+
* Tools the MCP App is allowed to invoke via `tools/call`. Deny-by-default:
|
|
245
|
+
* if omitted, the (untrusted) app cannot call any tool. List only the tools
|
|
246
|
+
* the app is meant to see.
|
|
247
|
+
*/
|
|
248
|
+
allowedTools?: string[];
|
|
249
|
+
callTool?: (params: MCPAppToolCallParams) => Promise<unknown> | unknown;
|
|
250
|
+
readResource?: (params: {
|
|
251
|
+
uri: string;
|
|
252
|
+
}) => Promise<unknown> | unknown;
|
|
253
|
+
listResources?: (params?: unknown) => Promise<unknown> | unknown;
|
|
254
|
+
openLink?: (params: {
|
|
255
|
+
url: string;
|
|
256
|
+
}) => Promise<unknown> | unknown;
|
|
257
|
+
sendMessage?: (params: unknown) => Promise<unknown> | unknown;
|
|
258
|
+
updateModelContext?: (params: unknown) => Promise<unknown> | unknown;
|
|
259
|
+
requestDisplayMode?: (params: {
|
|
260
|
+
mode: MCPAppDisplayMode;
|
|
261
|
+
}) => Promise<{
|
|
262
|
+
mode: MCPAppDisplayMode;
|
|
263
|
+
}> | {
|
|
264
|
+
mode: MCPAppDisplayMode;
|
|
265
|
+
};
|
|
266
|
+
onSizeChange?: (params: {
|
|
267
|
+
width?: number;
|
|
268
|
+
height?: number;
|
|
269
|
+
}) => void;
|
|
270
|
+
onInitialized?: () => void;
|
|
271
|
+
onRequestTeardown?: (params: unknown) => void;
|
|
272
|
+
onLog?: (params: unknown) => void;
|
|
273
|
+
onError?: (error: Error) => void;
|
|
273
274
|
};
|
|
274
275
|
type MCPAppSandboxConfig = {
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
276
|
+
url: string | URL;
|
|
277
|
+
title?: string;
|
|
278
|
+
className?: string;
|
|
279
|
+
style?: CSSProperties;
|
|
280
|
+
targetOrigin?: string;
|
|
281
|
+
outerSandbox?: string;
|
|
282
|
+
innerSandbox?: string;
|
|
283
|
+
/**
|
|
284
|
+
* Iframe capabilities the host allows an app to use. Deny-by-default: a
|
|
285
|
+
* server-requested permission (camera/microphone/geolocation/clipboardWrite)
|
|
286
|
+
* is only granted when it also appears here. Omitting this grants nothing.
|
|
287
|
+
*/
|
|
288
|
+
allowedPermissions?: MCPAppPermission[];
|
|
288
289
|
};
|
|
289
290
|
type MCPAppRendererProps = {
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
291
|
+
part: ToolUIPart<UITools> | DynamicToolUIPart;
|
|
292
|
+
sandbox: MCPAppSandboxConfig;
|
|
293
|
+
resource?: MCPAppResource;
|
|
294
|
+
loadResource?: (app: MCPAppMetadata) => Promise<MCPAppResource>;
|
|
295
|
+
handlers?: MCPAppBridgeHandlers;
|
|
296
|
+
hostInfo?: {
|
|
297
|
+
name: string;
|
|
298
|
+
version: string;
|
|
299
|
+
};
|
|
300
|
+
hostContext?: MCPAppHostContext;
|
|
301
|
+
fallback?: ReactNode;
|
|
301
302
|
};
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
303
|
+
//#endregion
|
|
304
|
+
//#region src/mcp-apps/app-renderer.d.ts
|
|
305
|
+
declare function MCPAppRenderer({ part, sandbox, resource: resourceProp, loadResource, handlers, hostInfo, hostContext, fallback }: MCPAppRendererProps): string | number | boolean | Iterable<import("react").ReactNode> | import("react/jsx-runtime").JSX.Element | null;
|
|
306
|
+
//#endregion
|
|
307
|
+
//#region src/index.d.ts
|
|
305
308
|
/**
|
|
306
309
|
* @deprecated Use `useObject` instead.
|
|
307
310
|
*/
|
|
308
|
-
declare const experimental_useObject: typeof useObject;
|
|
311
|
+
export declare const experimental_useObject: typeof useObject;
|
|
309
312
|
/**
|
|
310
313
|
* @deprecated Use `UseObjectOptions` instead.
|
|
311
314
|
*/
|
|
312
|
-
type Experimental_UseObjectOptions<SCHEMA extends FlexibleSchema, RESULT> = UseObjectOptions<SCHEMA, RESULT>;
|
|
315
|
+
export type Experimental_UseObjectOptions<SCHEMA extends FlexibleSchema, RESULT> = UseObjectOptions<SCHEMA, RESULT>;
|
|
313
316
|
/**
|
|
314
317
|
* @deprecated Use `UseObjectHelpers` instead.
|
|
315
318
|
*/
|
|
316
|
-
type Experimental_UseObjectHelpers<RESULT, INPUT> = UseObjectHelpers<RESULT, INPUT>;
|
|
317
|
-
|
|
318
|
-
export {
|
|
319
|
+
export type Experimental_UseObjectHelpers<RESULT, INPUT> = UseObjectHelpers<RESULT, INPUT>;
|
|
320
|
+
//#endregion
|
|
321
|
+
export { type CreateUIMessage, type RealtimeStatus as Experimental_RealtimeStatus, type UseRealtimeOptions as Experimental_UseRealtimeOptions, type UseRealtimeReturn as Experimental_UseRealtimeReturn, type MCPAppBridgeHandlers, type MCPAppMetadata, type MCPAppPermission, type MCPAppRendererProps, type MCPAppResource, type MCPAppSandboxConfig, type UIMessage, type UseCompletionOptions, MCPAppRenderer as experimental_MCPAppRenderer };
|
|
322
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":["UIMessage","RealtimeSessionOptions","UIMessage","RealtimeServerEvent","RealtimeState","AbstractRealtimeSession"],"sources":["../src/use-object.ts","../src/chat.react.ts","../src/use-chat.ts","../src/use-completion.ts","../src/use-realtime.ts","../src/mcp-apps/sandbox.ts","../src/mcp-apps/types.ts","../src/mcp-apps/app-renderer.tsx","../src/index.ts"],"mappings":"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"}
|