@mcp-b/react-components 0.2.2 → 0.3.0
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/dist/{CodeBlock-BrCoypnc.js → CodeBlock-C2Xjxu9M.js} +1 -1
- package/dist/FileTree-D0c9Yj9U.js +310 -0
- package/dist/PromptInput-Dzn-fOPc.d.ts +444 -0
- package/dist/components/Activity.js +1 -1
- package/dist/components/AgentChat.d.ts +19 -9
- package/dist/components/AgentChat.js +27 -24
- package/dist/components/AgentConnection.js +2 -2
- package/dist/components/Artifact.js +1 -1
- package/dist/components/BrowserLiveView.d.ts +47 -0
- package/dist/components/BrowserLiveView.js +135 -0
- package/dist/components/BrowserReplay.d.ts +40 -0
- package/dist/components/BrowserReplay.js +187 -0
- package/dist/components/ChainOfThought.d.ts +1 -1
- package/dist/components/ChainOfThought.js +1 -1
- package/dist/components/CodeBlock.js +1 -1
- package/dist/components/Commit.js +1 -1
- package/dist/components/ContextMenu.js +1 -1
- package/dist/components/Conversation.js +1 -1
- package/dist/components/Dialog.js +1 -1
- package/dist/components/EnvironmentVariables.js +1 -1
- package/dist/components/FileTree.js +1 -309
- package/dist/components/Menubar.js +1 -1
- package/dist/components/Message.d.ts +2 -1
- package/dist/components/Message.js +1 -1
- package/dist/components/ModelSelector.js +1 -1
- package/dist/components/NavigationMenu.js +1 -1
- package/dist/components/PricingPage.js +1 -1
- package/dist/components/PromptInput.d.ts +2 -399
- package/dist/components/PromptInput.js +177 -2
- package/dist/components/Queue.js +1 -1
- package/dist/components/Reasoning.js +1 -1
- package/dist/components/Select.js +1 -1
- package/dist/components/Sources.js +1 -1
- package/dist/components/Stepper.js +1 -1
- package/dist/components/Task.js +1 -1
- package/dist/components/Terminal.js +2 -2
- package/dist/components/TestResults.js +1 -1
- package/dist/components/ThinkChat.d.ts +186 -0
- package/dist/components/ThinkChat.js +730 -0
- package/dist/components/Tool.d.ts +32 -28
- package/dist/components/Tool.js +29 -16
- package/dist/components/WebPreview.js +1 -1
- package/dist/components/WorkspaceExplorer.d.ts +102 -0
- package/dist/components/WorkspaceExplorer.js +352 -0
- package/dist/components/icons.d.ts +2 -2
- package/dist/components/icons.js +2 -2
- package/dist/{copy-button-DAPlB8Z0.js → copy-button-Dd6DEhOm.js} +1 -1
- package/dist/{icons-Bf7JMKk-.js → icons-DQC4Zw5R.js} +5 -1
- package/dist/{icons-BklFyZbx.d.ts → icons-ctdVxng0.d.ts} +2 -1
- package/dist/styles/prompt-input.css +149 -0
- package/package.json +26 -3
|
@@ -0,0 +1,444 @@
|
|
|
1
|
+
import { A as SelectTriggerProps, M as SelectValueProps, S as SelectProps, f as SelectOption, j as SelectValue, r as SelectContentProps, s as SelectItemProps, t as Select } from "./Select-CRsKCJ9x.js";
|
|
2
|
+
import { c as ComboboxGroup, d as ComboboxLabel, f as ComboboxList, g as ComboboxTrigger, h as ComboboxSeparator, l as ComboboxInput, m as ComboboxPositioner, p as ComboboxPopup, s as ComboboxEmpty, t as Combobox, u as ComboboxItem } from "./Combobox-D9anamNr.js";
|
|
3
|
+
import { h as MenuItemProps, w as MenuProps, y as MenuPopupProps } from "./Menu-B5vDqZe_.js";
|
|
4
|
+
import { c as TabsList, n as TabPanel, t as Tab } from "./Tabs-D9EAq09D.js";
|
|
5
|
+
import { r as ButtonProps } from "./Button-Ct5I6aTu.js";
|
|
6
|
+
import * as React from "react";
|
|
7
|
+
import { ChatAddToolApproveResponseFunction, ChatStatus, DynamicToolUIPart, ToolUIPart, UIMessage } from "ai";
|
|
8
|
+
|
|
9
|
+
//#region src/components/PromptInput.d.ts
|
|
10
|
+
interface PromptInputFilePart {
|
|
11
|
+
type: "file";
|
|
12
|
+
id?: string;
|
|
13
|
+
filename?: string;
|
|
14
|
+
mediaType?: string;
|
|
15
|
+
url?: string;
|
|
16
|
+
}
|
|
17
|
+
interface PromptInputReferencedSource {
|
|
18
|
+
id?: string;
|
|
19
|
+
title?: string;
|
|
20
|
+
url?: string;
|
|
21
|
+
[key: string]: unknown;
|
|
22
|
+
}
|
|
23
|
+
/** The payload produced when the prompt input is submitted. */
|
|
24
|
+
interface PromptInputMessage {
|
|
25
|
+
text: string;
|
|
26
|
+
files: PromptInputFilePart[];
|
|
27
|
+
}
|
|
28
|
+
/** Lifecycle status of an in-flight model request — the AI SDK's `ChatStatus`. */
|
|
29
|
+
type PromptInputStatus = ChatStatus;
|
|
30
|
+
interface AttachmentsContext {
|
|
31
|
+
files: Array<PromptInputFilePart & {
|
|
32
|
+
id: string;
|
|
33
|
+
}>;
|
|
34
|
+
add: (files: File[] | FileList) => void;
|
|
35
|
+
remove: (id: string) => void;
|
|
36
|
+
clear: () => void;
|
|
37
|
+
openFileDialog: () => void;
|
|
38
|
+
fileInputRef: React.RefObject<HTMLInputElement | null>;
|
|
39
|
+
}
|
|
40
|
+
interface TextInputContext {
|
|
41
|
+
value: string;
|
|
42
|
+
setInput: (value: string) => void;
|
|
43
|
+
clear: () => void;
|
|
44
|
+
}
|
|
45
|
+
interface PromptInputControllerProps {
|
|
46
|
+
textInput: TextInputContext;
|
|
47
|
+
attachments: AttachmentsContext;
|
|
48
|
+
__registerFileInput: (ref: React.RefObject<HTMLInputElement | null>, open: () => void) => void;
|
|
49
|
+
}
|
|
50
|
+
interface ReferencedSourcesContext {
|
|
51
|
+
sources: Array<PromptInputReferencedSource & {
|
|
52
|
+
id: string;
|
|
53
|
+
}>;
|
|
54
|
+
add: (sources: PromptInputReferencedSource[] | PromptInputReferencedSource) => void;
|
|
55
|
+
remove: (id: string) => void;
|
|
56
|
+
clear: () => void;
|
|
57
|
+
}
|
|
58
|
+
declare function usePromptInputController(): PromptInputControllerProps;
|
|
59
|
+
declare function useProviderAttachments(): AttachmentsContext;
|
|
60
|
+
declare function usePromptInputAttachments(): AttachmentsContext;
|
|
61
|
+
declare function usePromptInputReferencedSources(): ReferencedSourcesContext;
|
|
62
|
+
interface PromptInputProviderProps extends React.PropsWithChildren {
|
|
63
|
+
initialInput?: string;
|
|
64
|
+
}
|
|
65
|
+
declare function PromptInputProvider({
|
|
66
|
+
initialInput,
|
|
67
|
+
children
|
|
68
|
+
}: PromptInputProviderProps): React.JSX.Element;
|
|
69
|
+
interface PromptInputProps extends Omit<React.FormHTMLAttributes<HTMLFormElement>, "onSubmit" | "onError"> {
|
|
70
|
+
/** Accepted file MIME types/extensions, passed to the hidden file input. */
|
|
71
|
+
accept?: string;
|
|
72
|
+
/** Allows multiple files in a single file picker/drop action. */
|
|
73
|
+
multiple?: boolean;
|
|
74
|
+
/** Listen for file drops on the whole document instead of only the form. */
|
|
75
|
+
globalDrop?: boolean;
|
|
76
|
+
/** Clears the hidden file input when attachments are cleared. */
|
|
77
|
+
syncHiddenInput?: boolean;
|
|
78
|
+
/** Maximum number of attached files. */
|
|
79
|
+
maxFiles?: number;
|
|
80
|
+
/** Maximum accepted file size in bytes. */
|
|
81
|
+
maxFileSize?: number;
|
|
82
|
+
/** Called when file validation rejects an attachment. */
|
|
83
|
+
onError?: (error: {
|
|
84
|
+
code: "max_files" | "max_file_size" | "accept";
|
|
85
|
+
message: string;
|
|
86
|
+
}) => void;
|
|
87
|
+
/** Called with the trimmed message text and files when the form is submitted. */
|
|
88
|
+
onSubmit?: (message: PromptInputMessage, event: React.FormEvent<HTMLFormElement>) => void | Promise<void>;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Chat-style composer form. Wraps a textarea and footer controls, with
|
|
92
|
+
* Enter-to-submit semantics, auto-resizing behavior, and optional attachments.
|
|
93
|
+
* Adapted from Vercel AI Elements and restyled with Sigvelo CSS tokens.
|
|
94
|
+
*
|
|
95
|
+
* Use for assistant/chat submit forms. Do not use it as a generic textarea or
|
|
96
|
+
* non-chat form. Sigvelo changes: uses shared Menu, Select, Combobox, Tabs,
|
|
97
|
+
* Button, and Tooltip components; maps styles to CSS tokens; adds local
|
|
98
|
+
* attachment and referenced-source helpers.
|
|
99
|
+
*
|
|
100
|
+
* The form handles Enter-to-submit while multiline editing remains in the
|
|
101
|
+
* textarea. Attachment controls need accessible labels through their buttons
|
|
102
|
+
* and menus. Add new shared tools here when multiple apps need them.
|
|
103
|
+
*
|
|
104
|
+
* @example
|
|
105
|
+
* ```tsx
|
|
106
|
+
* <PromptInput onSubmit={({ text, files }) => sendMessage(text, files)}>
|
|
107
|
+
* <PromptInputBody>
|
|
108
|
+
* <PromptInputTextarea placeholder="Ask Sigvelo..." />
|
|
109
|
+
* </PromptInputBody>
|
|
110
|
+
* <PromptInputFooter>
|
|
111
|
+
* <PromptInputTools>
|
|
112
|
+
* <PromptInputActionAddAttachments />
|
|
113
|
+
* </PromptInputTools>
|
|
114
|
+
* <PromptInputSubmit status="ready" />
|
|
115
|
+
* </PromptInputFooter>
|
|
116
|
+
* </PromptInput>
|
|
117
|
+
* ```
|
|
118
|
+
*
|
|
119
|
+
* @see {@link https://elements.ai-sdk.dev/components/prompt-input | AI Elements Prompt Input}
|
|
120
|
+
*/
|
|
121
|
+
declare function PromptInput({
|
|
122
|
+
className,
|
|
123
|
+
accept,
|
|
124
|
+
multiple,
|
|
125
|
+
globalDrop,
|
|
126
|
+
syncHiddenInput,
|
|
127
|
+
maxFiles,
|
|
128
|
+
maxFileSize,
|
|
129
|
+
onError,
|
|
130
|
+
onSubmit,
|
|
131
|
+
children,
|
|
132
|
+
id,
|
|
133
|
+
ref,
|
|
134
|
+
...props
|
|
135
|
+
}: PromptInputProps & {
|
|
136
|
+
ref?: React.Ref<HTMLFormElement>;
|
|
137
|
+
}): React.JSX.Element;
|
|
138
|
+
interface PromptInputHeaderProps extends React.HTMLAttributes<HTMLDivElement> {}
|
|
139
|
+
declare function PromptInputHeader({
|
|
140
|
+
className,
|
|
141
|
+
children,
|
|
142
|
+
ref,
|
|
143
|
+
...props
|
|
144
|
+
}: PromptInputHeaderProps & {
|
|
145
|
+
ref?: React.Ref<HTMLDivElement>;
|
|
146
|
+
}): React.JSX.Element;
|
|
147
|
+
interface PromptInputBodyProps extends React.HTMLAttributes<HTMLDivElement> {}
|
|
148
|
+
declare function PromptInputBody({
|
|
149
|
+
className,
|
|
150
|
+
children,
|
|
151
|
+
ref,
|
|
152
|
+
...props
|
|
153
|
+
}: PromptInputBodyProps & {
|
|
154
|
+
ref?: React.Ref<HTMLDivElement>;
|
|
155
|
+
}): React.JSX.Element;
|
|
156
|
+
interface PromptInputFooterProps extends React.HTMLAttributes<HTMLDivElement> {}
|
|
157
|
+
declare function PromptInputFooter({
|
|
158
|
+
className,
|
|
159
|
+
children,
|
|
160
|
+
ref,
|
|
161
|
+
...props
|
|
162
|
+
}: PromptInputFooterProps & {
|
|
163
|
+
ref?: React.Ref<HTMLDivElement>;
|
|
164
|
+
}): React.JSX.Element;
|
|
165
|
+
interface PromptInputToolsProps extends React.HTMLAttributes<HTMLDivElement> {}
|
|
166
|
+
declare function PromptInputTools({
|
|
167
|
+
className,
|
|
168
|
+
children,
|
|
169
|
+
ref,
|
|
170
|
+
...props
|
|
171
|
+
}: PromptInputToolsProps & {
|
|
172
|
+
ref?: React.Ref<HTMLDivElement>;
|
|
173
|
+
}): React.JSX.Element;
|
|
174
|
+
interface PromptInputTextareaProps extends React.TextareaHTMLAttributes<HTMLTextAreaElement> {
|
|
175
|
+
minHeight?: number;
|
|
176
|
+
maxHeight?: number;
|
|
177
|
+
}
|
|
178
|
+
declare function PromptInputTextarea({
|
|
179
|
+
className,
|
|
180
|
+
placeholder,
|
|
181
|
+
rows,
|
|
182
|
+
minHeight,
|
|
183
|
+
maxHeight,
|
|
184
|
+
onChange,
|
|
185
|
+
onCompositionEnd,
|
|
186
|
+
onCompositionStart,
|
|
187
|
+
onKeyDown,
|
|
188
|
+
onInput,
|
|
189
|
+
onPaste,
|
|
190
|
+
ref,
|
|
191
|
+
...props
|
|
192
|
+
}: PromptInputTextareaProps & {
|
|
193
|
+
ref?: React.Ref<HTMLTextAreaElement>;
|
|
194
|
+
}): React.JSX.Element;
|
|
195
|
+
type TooltipSide = "top" | "right" | "bottom" | "left";
|
|
196
|
+
type PromptInputButtonTooltip = string | {
|
|
197
|
+
content: React.ReactNode;
|
|
198
|
+
shortcut?: string;
|
|
199
|
+
side?: TooltipSide;
|
|
200
|
+
};
|
|
201
|
+
type PromptInputTooltipConfig = Exclude<PromptInputButtonTooltip, string>;
|
|
202
|
+
interface PromptInputButtonProps extends Omit<ButtonProps, "children" | "className"> {
|
|
203
|
+
className?: string;
|
|
204
|
+
tooltip?: PromptInputButtonTooltip;
|
|
205
|
+
children?: React.ReactNode;
|
|
206
|
+
}
|
|
207
|
+
declare function PromptInputButton({
|
|
208
|
+
className,
|
|
209
|
+
tooltip,
|
|
210
|
+
variant,
|
|
211
|
+
color,
|
|
212
|
+
size,
|
|
213
|
+
children,
|
|
214
|
+
"aria-label": ariaLabel,
|
|
215
|
+
ref,
|
|
216
|
+
...props
|
|
217
|
+
}: PromptInputButtonProps & {
|
|
218
|
+
ref?: React.Ref<HTMLButtonElement>;
|
|
219
|
+
}): React.JSX.Element;
|
|
220
|
+
type PromptInputActionMenuProps = MenuProps;
|
|
221
|
+
declare function PromptInputActionMenu(props: PromptInputActionMenuProps): React.JSX.Element;
|
|
222
|
+
type PromptInputActionMenuTriggerProps = PromptInputButtonProps;
|
|
223
|
+
declare function PromptInputActionMenuTrigger({
|
|
224
|
+
className,
|
|
225
|
+
children,
|
|
226
|
+
...props
|
|
227
|
+
}: PromptInputActionMenuTriggerProps): React.JSX.Element;
|
|
228
|
+
type PromptInputActionMenuContentProps = MenuPopupProps;
|
|
229
|
+
declare function PromptInputActionMenuContent({
|
|
230
|
+
className,
|
|
231
|
+
children,
|
|
232
|
+
...props
|
|
233
|
+
}: PromptInputActionMenuContentProps): React.JSX.Element;
|
|
234
|
+
type PromptInputActionMenuItemProps = MenuItemProps;
|
|
235
|
+
declare function PromptInputActionMenuItem({
|
|
236
|
+
className,
|
|
237
|
+
...props
|
|
238
|
+
}: PromptInputActionMenuItemProps): React.JSX.Element;
|
|
239
|
+
interface PromptInputActionAddAttachmentsProps extends PromptInputActionMenuItemProps {
|
|
240
|
+
label?: string;
|
|
241
|
+
}
|
|
242
|
+
declare function PromptInputActionAddAttachments({
|
|
243
|
+
label,
|
|
244
|
+
onClick,
|
|
245
|
+
children,
|
|
246
|
+
...props
|
|
247
|
+
}: PromptInputActionAddAttachmentsProps): React.JSX.Element;
|
|
248
|
+
interface PromptInputActionAddScreenshotProps extends PromptInputActionMenuItemProps {
|
|
249
|
+
label?: string;
|
|
250
|
+
}
|
|
251
|
+
declare function PromptInputActionAddScreenshot({
|
|
252
|
+
label,
|
|
253
|
+
onClick,
|
|
254
|
+
children,
|
|
255
|
+
...props
|
|
256
|
+
}: PromptInputActionAddScreenshotProps): React.JSX.Element;
|
|
257
|
+
interface PromptInputSubmitProps extends Omit<ButtonProps, "children" | "className" | "type"> {
|
|
258
|
+
className?: string;
|
|
259
|
+
status?: PromptInputStatus;
|
|
260
|
+
onStop?: () => void;
|
|
261
|
+
children?: React.ReactNode;
|
|
262
|
+
label?: string;
|
|
263
|
+
}
|
|
264
|
+
declare function PromptInputSubmit({
|
|
265
|
+
className,
|
|
266
|
+
status,
|
|
267
|
+
onStop,
|
|
268
|
+
variant,
|
|
269
|
+
color,
|
|
270
|
+
size,
|
|
271
|
+
onClick,
|
|
272
|
+
children,
|
|
273
|
+
label,
|
|
274
|
+
ref,
|
|
275
|
+
...props
|
|
276
|
+
}: PromptInputSubmitProps & {
|
|
277
|
+
ref?: React.Ref<HTMLButtonElement>;
|
|
278
|
+
}): React.JSX.Element;
|
|
279
|
+
/** A tool part that may carry a pending approval request. Upstream AI SDK types, taken whole. */
|
|
280
|
+
type ApprovalToolPart = ToolUIPart | DynamicToolUIPart;
|
|
281
|
+
interface PendingToolApproval<MessageT extends UIMessage = UIMessage> {
|
|
282
|
+
message: MessageT;
|
|
283
|
+
messageIndex: number;
|
|
284
|
+
part: ApprovalToolPart;
|
|
285
|
+
partIndex: number;
|
|
286
|
+
}
|
|
287
|
+
/** Derives pending tool approvals straight from the messages — no app-owned shapes. */
|
|
288
|
+
declare function getPendingToolApprovals<MessageT extends UIMessage>(messages: readonly MessageT[]): Array<PendingToolApproval<MessageT>>;
|
|
289
|
+
interface PromptInputApprovalProps extends Omit<React.HTMLAttributes<HTMLDivElement>, "part"> {
|
|
290
|
+
/** The `approval-requested` tool part, passed whole. Renders nothing for other states. */
|
|
291
|
+
part: ApprovalToolPart;
|
|
292
|
+
/** Pass `addToolApprovalResponse` from `useAgentChat`/`useChat` directly. */
|
|
293
|
+
onRespond: ChatAddToolApproveResponseFunction;
|
|
294
|
+
/**
|
|
295
|
+
* Renders a Skip action that dismisses the confirmation without responding —
|
|
296
|
+
* the approval stays pending upstream.
|
|
297
|
+
*/
|
|
298
|
+
onSkip?: () => void;
|
|
299
|
+
/** Overrides the default "Do you want to allow…" question. */
|
|
300
|
+
question?: React.ReactNode;
|
|
301
|
+
/** Total pending approvals, for the "1 of N" hint. */
|
|
302
|
+
count?: number;
|
|
303
|
+
}
|
|
304
|
+
/**
|
|
305
|
+
* The composer's approval state: when a tool call awaits human approval the
|
|
306
|
+
* prompt input area becomes the confirmation. "Yes" approves on click; typing
|
|
307
|
+
* in the "No, and tell the agent what to do differently" row selects deny and
|
|
308
|
+
* sends the text as the native approval `reason`. Submit (or Enter) sends the
|
|
309
|
+
* current selection — approve by default.
|
|
310
|
+
*/
|
|
311
|
+
declare function PromptInputApproval({
|
|
312
|
+
part,
|
|
313
|
+
onRespond,
|
|
314
|
+
onSkip,
|
|
315
|
+
question,
|
|
316
|
+
count,
|
|
317
|
+
className,
|
|
318
|
+
ref,
|
|
319
|
+
...props
|
|
320
|
+
}: PromptInputApprovalProps & {
|
|
321
|
+
ref?: React.Ref<HTMLDivElement>;
|
|
322
|
+
}): React.JSX.Element | null;
|
|
323
|
+
type PromptInputSelectProps = SelectProps;
|
|
324
|
+
declare const PromptInputSelect: typeof Select;
|
|
325
|
+
type PromptInputSelectTriggerProps = SelectTriggerProps;
|
|
326
|
+
declare function PromptInputSelectTrigger(props: PromptInputSelectTriggerProps): React.JSX.Element;
|
|
327
|
+
type PromptInputSelectContentProps = SelectContentProps;
|
|
328
|
+
declare function PromptInputSelectContent(props: PromptInputSelectContentProps): React.JSX.Element;
|
|
329
|
+
type PromptInputSelectItemProps = SelectItemProps;
|
|
330
|
+
declare const PromptInputSelectItem: typeof SelectOption;
|
|
331
|
+
type PromptInputSelectValueProps = SelectValueProps;
|
|
332
|
+
declare const PromptInputSelectValue: typeof SelectValue;
|
|
333
|
+
interface PromptInputHoverCardProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
334
|
+
openDelay?: number;
|
|
335
|
+
closeDelay?: number;
|
|
336
|
+
}
|
|
337
|
+
declare function PromptInputHoverCard({
|
|
338
|
+
openDelay,
|
|
339
|
+
closeDelay,
|
|
340
|
+
className,
|
|
341
|
+
children,
|
|
342
|
+
ref,
|
|
343
|
+
...props
|
|
344
|
+
}: PromptInputHoverCardProps & {
|
|
345
|
+
ref?: React.Ref<HTMLDivElement>;
|
|
346
|
+
}): React.JSX.Element;
|
|
347
|
+
interface PromptInputHoverCardTriggerProps extends React.HTMLAttributes<HTMLSpanElement> {}
|
|
348
|
+
declare function PromptInputHoverCardTrigger({
|
|
349
|
+
className,
|
|
350
|
+
ref,
|
|
351
|
+
...props
|
|
352
|
+
}: PromptInputHoverCardTriggerProps & {
|
|
353
|
+
ref?: React.Ref<HTMLSpanElement>;
|
|
354
|
+
}): React.JSX.Element;
|
|
355
|
+
interface PromptInputHoverCardContentProps extends React.HTMLAttributes<HTMLDivElement> {}
|
|
356
|
+
declare function PromptInputHoverCardContent({
|
|
357
|
+
className,
|
|
358
|
+
ref,
|
|
359
|
+
...props
|
|
360
|
+
}: PromptInputHoverCardContentProps & {
|
|
361
|
+
ref?: React.Ref<HTMLDivElement>;
|
|
362
|
+
}): React.JSX.Element | null;
|
|
363
|
+
type PromptInputTabsListProps = React.ComponentPropsWithoutRef<typeof TabsList>;
|
|
364
|
+
declare const PromptInputTabsList: typeof TabsList;
|
|
365
|
+
type PromptInputTabProps = React.ComponentPropsWithoutRef<typeof Tab>;
|
|
366
|
+
declare const PromptInputTab: typeof Tab;
|
|
367
|
+
type PromptInputTabBodyProps = React.ComponentPropsWithoutRef<typeof TabPanel>;
|
|
368
|
+
declare const PromptInputTabBody: typeof TabPanel;
|
|
369
|
+
interface PromptInputTabLabelProps extends React.HTMLAttributes<HTMLHeadingElement> {}
|
|
370
|
+
declare function PromptInputTabLabel({
|
|
371
|
+
className,
|
|
372
|
+
ref,
|
|
373
|
+
...props
|
|
374
|
+
}: PromptInputTabLabelProps & {
|
|
375
|
+
ref?: React.Ref<HTMLHeadingElement>;
|
|
376
|
+
}): React.JSX.Element;
|
|
377
|
+
interface PromptInputTabItemProps extends React.HTMLAttributes<HTMLDivElement> {}
|
|
378
|
+
declare function PromptInputTabItem({
|
|
379
|
+
className,
|
|
380
|
+
ref,
|
|
381
|
+
...props
|
|
382
|
+
}: PromptInputTabItemProps & {
|
|
383
|
+
ref?: React.Ref<HTMLDivElement>;
|
|
384
|
+
}): React.JSX.Element;
|
|
385
|
+
type PromptInputCommandProps = React.ComponentPropsWithoutRef<typeof Combobox>;
|
|
386
|
+
declare const PromptInputCommand: typeof import("@base-ui/react").ComboboxRoot & {
|
|
387
|
+
Root: typeof import("@base-ui/react").ComboboxRoot;
|
|
388
|
+
Input: typeof ComboboxInput;
|
|
389
|
+
Trigger: typeof ComboboxTrigger;
|
|
390
|
+
Clear: ({
|
|
391
|
+
className,
|
|
392
|
+
ref,
|
|
393
|
+
...props
|
|
394
|
+
}: Omit<React.ComponentPropsWithRef<typeof import("@base-ui/react").ComboboxClear>, "className"> & {
|
|
395
|
+
className?: string;
|
|
396
|
+
} & {
|
|
397
|
+
ref?: React.Ref<HTMLButtonElement>;
|
|
398
|
+
}) => React.JSX.Element;
|
|
399
|
+
Portal: React.ForwardRefExoticComponent<Omit<import("@base-ui/react").AutocompletePortalProps, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
400
|
+
Positioner: typeof ComboboxPositioner;
|
|
401
|
+
Popup: typeof ComboboxPopup;
|
|
402
|
+
Content: typeof ComboboxPopup;
|
|
403
|
+
List: typeof ComboboxList;
|
|
404
|
+
Item: typeof ComboboxItem;
|
|
405
|
+
ItemIndicator: ({
|
|
406
|
+
className,
|
|
407
|
+
ref,
|
|
408
|
+
...props
|
|
409
|
+
}: Omit<React.ComponentPropsWithRef<typeof import("@base-ui/react").ComboboxItemIndicator>, "className"> & {
|
|
410
|
+
className?: string;
|
|
411
|
+
} & {
|
|
412
|
+
ref?: React.Ref<HTMLSpanElement>;
|
|
413
|
+
}) => React.JSX.Element;
|
|
414
|
+
Empty: typeof ComboboxEmpty;
|
|
415
|
+
Group: typeof ComboboxGroup;
|
|
416
|
+
GroupLabel: typeof ComboboxLabel;
|
|
417
|
+
Label: typeof ComboboxLabel;
|
|
418
|
+
Value: typeof import("@base-ui/react").ComboboxValue;
|
|
419
|
+
Chips: React.ForwardRefExoticComponent<Omit<import("@base-ui/react").ComboboxChipsProps, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
420
|
+
Chip: React.ForwardRefExoticComponent<Omit<import("@base-ui/react").ComboboxChipProps, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
421
|
+
ChipsInput: typeof ComboboxInput;
|
|
422
|
+
Collection: typeof import("@base-ui/react").ComboboxCollection;
|
|
423
|
+
Separator: React.ForwardRefExoticComponent<Omit<import("@base-ui/react").SeparatorProps, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
424
|
+
};
|
|
425
|
+
type PromptInputCommandInputProps = React.ComponentPropsWithoutRef<typeof ComboboxInput>;
|
|
426
|
+
declare const PromptInputCommandInput: typeof ComboboxInput;
|
|
427
|
+
interface PromptInputCommandListProps extends React.HTMLAttributes<HTMLDivElement> {}
|
|
428
|
+
declare function PromptInputCommandList({
|
|
429
|
+
className,
|
|
430
|
+
ref,
|
|
431
|
+
...props
|
|
432
|
+
}: PromptInputCommandListProps & {
|
|
433
|
+
ref?: React.Ref<HTMLDivElement>;
|
|
434
|
+
}): React.JSX.Element;
|
|
435
|
+
type PromptInputCommandEmptyProps = React.ComponentPropsWithoutRef<typeof ComboboxEmpty>;
|
|
436
|
+
declare const PromptInputCommandEmpty: typeof ComboboxEmpty;
|
|
437
|
+
type PromptInputCommandGroupProps = React.ComponentPropsWithoutRef<typeof ComboboxGroup>;
|
|
438
|
+
declare const PromptInputCommandGroup: typeof ComboboxGroup;
|
|
439
|
+
type PromptInputCommandItemProps = React.ComponentPropsWithoutRef<typeof ComboboxItem>;
|
|
440
|
+
declare const PromptInputCommandItem: typeof ComboboxItem;
|
|
441
|
+
type PromptInputCommandSeparatorProps = React.ComponentPropsWithoutRef<typeof ComboboxSeparator>;
|
|
442
|
+
declare const PromptInputCommandSeparator: React.ForwardRefExoticComponent<Omit<import("@base-ui/react").SeparatorProps, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
443
|
+
//#endregion
|
|
444
|
+
export { PromptInputProviderProps as $, PromptInputCommandInputProps as A, TextInputContext as At, PromptInputFooter as B, PromptInputButtonTooltip as C, PromptInputTabsListProps as Ct, PromptInputCommandGroup as D, PromptInputToolsProps as Dt, PromptInputCommandEmptyProps as E, PromptInputTools as Et, PromptInputCommandProps as F, usePromptInputReferencedSources as Ft, PromptInputHoverCardContent as G, PromptInputHeader as H, PromptInputCommandSeparator as I, useProviderAttachments as It, PromptInputHoverCardTrigger as J, PromptInputHoverCardContentProps as K, PromptInputCommandSeparatorProps as L, PromptInputCommandItemProps as M, getPendingToolApprovals as Mt, PromptInputCommandList as N, usePromptInputAttachments as Nt, PromptInputCommandGroupProps as O, PromptInputTooltipConfig as Ot, PromptInputCommandListProps as P, usePromptInputController as Pt, PromptInputProvider as Q, PromptInputControllerProps as R, PromptInputButtonProps as S, PromptInputTabsList as St, PromptInputCommandEmpty as T, PromptInputTextareaProps as Tt, PromptInputHeaderProps as U, PromptInputFooterProps as V, PromptInputHoverCard as W, PromptInputMessage as X, PromptInputHoverCardTriggerProps as Y, PromptInputProps as Z, PromptInputApproval as _, PromptInputTabItem as _t, PromptInputActionAddAttachments as a, PromptInputSelectItemProps as at, PromptInputBodyProps as b, PromptInputTabLabelProps as bt, PromptInputActionAddScreenshotProps as c, PromptInputSelectTriggerProps as ct, PromptInputActionMenuContentProps as d, PromptInputStatus as dt, PromptInputReferencedSource as et, PromptInputActionMenuItem as f, PromptInputSubmit as ft, PromptInputActionMenuTriggerProps as g, PromptInputTabBodyProps as gt, PromptInputActionMenuTrigger as h, PromptInputTabBody as ht, PromptInput as i, PromptInputSelectItem as it, PromptInputCommandItem as j, TooltipSide as jt, PromptInputCommandInput as k, ReferencedSourcesContext as kt, PromptInputActionMenu as l, PromptInputSelectValue as lt, PromptInputActionMenuProps as m, PromptInputTab as mt, AttachmentsContext as n, PromptInputSelectContent as nt, PromptInputActionAddAttachmentsProps as o, PromptInputSelectProps as ot, PromptInputActionMenuItemProps as p, PromptInputSubmitProps as pt, PromptInputHoverCardProps as q, PendingToolApproval as r, PromptInputSelectContentProps as rt, PromptInputActionAddScreenshot as s, PromptInputSelectTrigger as st, ApprovalToolPart as t, PromptInputSelect as tt, PromptInputActionMenuContent as u, PromptInputSelectValueProps as ut, PromptInputApprovalProps as v, PromptInputTabItemProps as vt, PromptInputCommand as w, PromptInputTextarea as wt, PromptInputButton as x, PromptInputTabProps as xt, PromptInputBody as y, PromptInputTabLabel as yt, PromptInputFilePart as z };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CollapsiblePanel, CollapsibleRoot, CollapsibleTrigger } from "./Collapsible.js";
|
|
2
2
|
import { t as cx } from "../class-names-9UtZwb0J.js";
|
|
3
|
-
import { l as ChevronRightIcon } from "../icons-
|
|
3
|
+
import { l as ChevronRightIcon } from "../icons-DQC4Zw5R.js";
|
|
4
4
|
import "react";
|
|
5
5
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
6
|
//#region src/components/Activity.tsx
|
|
@@ -1,21 +1,20 @@
|
|
|
1
|
-
import { PromptInputMessage, PromptInputStatus } from "
|
|
1
|
+
import { X as PromptInputMessage, dt as PromptInputStatus } from "../PromptInput-Dzn-fOPc.js";
|
|
2
2
|
import * as React from "react";
|
|
3
|
-
import {
|
|
3
|
+
import { ChatAddToolApproveResponseFunction, UIMessage } from "ai";
|
|
4
4
|
|
|
5
5
|
//#region src/components/AgentChat.d.ts
|
|
6
|
-
type
|
|
7
|
-
|
|
8
|
-
interface AgentChatRenderPartContext<MessageT extends AgentChatMessage = AgentChatMessage> {
|
|
6
|
+
type AgentChatPart<MessageT extends UIMessage = UIMessage> = MessageT["parts"][number];
|
|
7
|
+
interface AgentChatRenderPartContext<MessageT extends UIMessage = UIMessage> {
|
|
9
8
|
message: MessageT;
|
|
10
9
|
part: AgentChatPart<MessageT>;
|
|
11
10
|
partIndex: number;
|
|
12
11
|
defaultRender: () => React.ReactNode;
|
|
13
12
|
}
|
|
14
|
-
interface AgentChatRenderMessageContext<MessageT extends
|
|
13
|
+
interface AgentChatRenderMessageContext<MessageT extends UIMessage = UIMessage> {
|
|
15
14
|
message: MessageT;
|
|
16
15
|
messageIndex: number;
|
|
17
16
|
}
|
|
18
|
-
interface AgentChatProps<MessageT extends
|
|
17
|
+
interface AgentChatProps<MessageT extends UIMessage = UIMessage> {
|
|
19
18
|
className?: string;
|
|
20
19
|
/** AI SDK `UIMessage`s to render, oldest first. */
|
|
21
20
|
messages: readonly MessageT[];
|
|
@@ -31,6 +30,12 @@ interface AgentChatProps<MessageT extends AgentChatMessage = AgentChatMessage> {
|
|
|
31
30
|
emptyState?: React.ReactNode;
|
|
32
31
|
/** Extra controls rendered in the composer toolbar. */
|
|
33
32
|
composerTools?: React.ReactNode;
|
|
33
|
+
/**
|
|
34
|
+
* Pass `addToolApprovalResponse` from `useAgentChat`/`useChat` directly.
|
|
35
|
+
* When set and a tool call awaits approval, the composer becomes the
|
|
36
|
+
* confirmation.
|
|
37
|
+
*/
|
|
38
|
+
onApprovalResponse?: ChatAddToolApproveResponseFunction;
|
|
34
39
|
/** Override rendering per part; return `undefined` to fall back to the default part UI. */
|
|
35
40
|
renderPart?: (context: AgentChatRenderPartContext<MessageT>) => React.ReactNode | undefined;
|
|
36
41
|
/** Rendered after each message's parts — for actions, citations, and the like. */
|
|
@@ -40,8 +45,12 @@ interface AgentChatProps<MessageT extends AgentChatMessage = AgentChatMessage> {
|
|
|
40
45
|
* A complete agent chat surface: auto-scrolling conversation of AI SDK
|
|
41
46
|
* `UIMessage`s (text, reasoning, and tool parts rendered by default) plus a
|
|
42
47
|
* prompt composer. Customize per-part rendering with `renderPart`.
|
|
48
|
+
*
|
|
49
|
+
* This is the presentational layer under `ThinkChat` — props in, no
|
|
50
|
+
* transport. Use it directly with plain AI SDK `useChat` or a read-only
|
|
51
|
+
* transcript; if you have a Cloudflare Think agent, use `ThinkChat` instead.
|
|
43
52
|
*/
|
|
44
|
-
declare function AgentChat<MessageT extends
|
|
53
|
+
declare function AgentChat<MessageT extends UIMessage = UIMessage>({
|
|
45
54
|
className,
|
|
46
55
|
messages,
|
|
47
56
|
status,
|
|
@@ -51,6 +60,7 @@ declare function AgentChat<MessageT extends AgentChatMessage = AgentChatMessage>
|
|
|
51
60
|
disabled,
|
|
52
61
|
emptyState,
|
|
53
62
|
composerTools,
|
|
63
|
+
onApprovalResponse,
|
|
54
64
|
renderPart,
|
|
55
65
|
renderMessageAfter,
|
|
56
66
|
ref
|
|
@@ -58,4 +68,4 @@ declare function AgentChat<MessageT extends AgentChatMessage = AgentChatMessage>
|
|
|
58
68
|
ref?: React.Ref<HTMLDivElement>;
|
|
59
69
|
}): React.JSX.Element;
|
|
60
70
|
//#endregion
|
|
61
|
-
export { AgentChat,
|
|
71
|
+
export { AgentChat, AgentChatPart, AgentChatProps, AgentChatRenderMessageContext, AgentChatRenderPartContext };
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { t as cx } from "../class-names-9UtZwb0J.js";
|
|
2
2
|
import { Conversation, ConversationContent, ConversationEmptyState, ConversationScrollButton } from "./Conversation.js";
|
|
3
3
|
import { Message, MessageContent, MessageResponse } from "./Message.js";
|
|
4
|
-
import { PromptInput, PromptInputBody, PromptInputFooter, PromptInputSubmit, PromptInputTextarea, PromptInputTools } from "./PromptInput.js";
|
|
4
|
+
import { PromptInput, PromptInputApproval, PromptInputBody, PromptInputFooter, PromptInputSubmit, PromptInputTextarea, PromptInputTools, getPendingToolApprovals } from "./PromptInput.js";
|
|
5
5
|
import { Reasoning, ReasoningContent, ReasoningTrigger } from "./Reasoning.js";
|
|
6
6
|
import { Tool, ToolContent, ToolHeader, ToolInput, ToolOutput } from "./Tool.js";
|
|
7
7
|
import * as React from "react";
|
|
8
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
-
import {
|
|
8
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
+
import { isReasoningUIPart, isTextUIPart, isToolOrDynamicToolUIPart } from "ai";
|
|
10
10
|
//#region src/components/AgentChat.tsx
|
|
11
11
|
function getPartKey(part, partIndex) {
|
|
12
|
-
if (
|
|
12
|
+
if (isToolOrDynamicToolUIPart(part)) return part.toolCallId;
|
|
13
13
|
if ("id" in part && typeof part.id === "string") return `${part.type}-${part.id}`;
|
|
14
14
|
return `${part.type}-${partIndex}`;
|
|
15
15
|
}
|
|
@@ -19,33 +19,28 @@ function renderDefaultPart(part) {
|
|
|
19
19
|
isStreaming: part.state === "streaming",
|
|
20
20
|
children: [/* @__PURE__ */ jsx(ReasoningTrigger, {}), /* @__PURE__ */ jsx(ReasoningContent, { children: part.text })]
|
|
21
21
|
});
|
|
22
|
-
if (
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
return /* @__PURE__ */ jsxs(Tool, {
|
|
27
|
-
state: part.state,
|
|
28
|
-
children: [/* @__PURE__ */ jsx(ToolHeader, {
|
|
29
|
-
type: toolType,
|
|
30
|
-
toolName: getToolName(part),
|
|
31
|
-
title: part.title
|
|
32
|
-
}), /* @__PURE__ */ jsxs(ToolContent, { children: [part.input !== void 0 ? /* @__PURE__ */ jsx(ToolInput, { input: part.input }) : null, /* @__PURE__ */ jsx(ToolOutput, {
|
|
33
|
-
output,
|
|
34
|
-
errorText
|
|
35
|
-
})] })]
|
|
36
|
-
});
|
|
37
|
-
}
|
|
22
|
+
if (isToolOrDynamicToolUIPart(part)) return /* @__PURE__ */ jsxs(Tool, {
|
|
23
|
+
part,
|
|
24
|
+
children: [/* @__PURE__ */ jsx(ToolHeader, {}), /* @__PURE__ */ jsxs(ToolContent, { children: [/* @__PURE__ */ jsx(ToolInput, {}), /* @__PURE__ */ jsx(ToolOutput, {})] })]
|
|
25
|
+
});
|
|
38
26
|
return null;
|
|
39
27
|
}
|
|
40
28
|
/**
|
|
41
29
|
* A complete agent chat surface: auto-scrolling conversation of AI SDK
|
|
42
30
|
* `UIMessage`s (text, reasoning, and tool parts rendered by default) plus a
|
|
43
31
|
* prompt composer. Customize per-part rendering with `renderPart`.
|
|
32
|
+
*
|
|
33
|
+
* This is the presentational layer under `ThinkChat` — props in, no
|
|
34
|
+
* transport. Use it directly with plain AI SDK `useChat` or a read-only
|
|
35
|
+
* transcript; if you have a Cloudflare Think agent, use `ThinkChat` instead.
|
|
44
36
|
*/
|
|
45
|
-
function AgentChat({ className, messages, status = "ready", onSubmit, onStop, placeholder = "Ask anything...", disabled, emptyState, composerTools, renderPart, renderMessageAfter, ref }) {
|
|
37
|
+
function AgentChat({ className, messages, status = "ready", onSubmit, onStop, placeholder = "Ask anything...", disabled, emptyState, composerTools, onApprovalResponse, renderPart, renderMessageAfter, ref }) {
|
|
46
38
|
const handleSubmit = React.useCallback((message) => {
|
|
47
39
|
onSubmit?.(message);
|
|
48
40
|
}, [onSubmit]);
|
|
41
|
+
const [skippedApprovalIds, setSkippedApprovalIds] = React.useState([]);
|
|
42
|
+
const pendingApprovals = (onApprovalResponse ? getPendingToolApprovals(messages) : []).filter(({ part }) => part.state !== "approval-requested" || !skippedApprovalIds.includes(part.approval.id));
|
|
43
|
+
const pendingApproval = pendingApprovals[0];
|
|
49
44
|
return /* @__PURE__ */ jsxs("div", {
|
|
50
45
|
ref,
|
|
51
46
|
className: cx("agent-chat", className),
|
|
@@ -73,16 +68,24 @@ function AgentChat({ className, messages, status = "ready", onSubmit, onStop, pl
|
|
|
73
68
|
}, message.id ?? messageIndex))] }), /* @__PURE__ */ jsx(ConversationScrollButton, {})]
|
|
74
69
|
}), /* @__PURE__ */ jsx("div", {
|
|
75
70
|
className: "agent-chat__composer",
|
|
76
|
-
children: /* @__PURE__ */
|
|
71
|
+
children: /* @__PURE__ */ jsx(PromptInput, {
|
|
77
72
|
onSubmit: handleSubmit,
|
|
78
|
-
children:
|
|
73
|
+
children: pendingApproval && onApprovalResponse ? /* @__PURE__ */ jsx(PromptInputApproval, {
|
|
74
|
+
part: pendingApproval.part,
|
|
75
|
+
count: pendingApprovals.length,
|
|
76
|
+
onRespond: onApprovalResponse,
|
|
77
|
+
onSkip: () => {
|
|
78
|
+
const { part } = pendingApproval;
|
|
79
|
+
if (part.state === "approval-requested") setSkippedApprovalIds((previous) => [...previous, part.approval.id]);
|
|
80
|
+
}
|
|
81
|
+
}) : /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(PromptInputBody, { children: /* @__PURE__ */ jsx(PromptInputTextarea, {
|
|
79
82
|
"aria-label": "Message",
|
|
80
83
|
placeholder,
|
|
81
84
|
disabled
|
|
82
85
|
}) }), /* @__PURE__ */ jsxs(PromptInputFooter, { children: [/* @__PURE__ */ jsx(PromptInputTools, { children: composerTools }), /* @__PURE__ */ jsx(PromptInputSubmit, {
|
|
83
86
|
status,
|
|
84
87
|
onStop
|
|
85
|
-
})] })]
|
|
88
|
+
})] })] })
|
|
86
89
|
})
|
|
87
90
|
})]
|
|
88
91
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { t as cx } from "../class-names-9UtZwb0J.js";
|
|
2
|
-
import { b as LinkIcon } from "../icons-
|
|
2
|
+
import { b as LinkIcon } from "../icons-DQC4Zw5R.js";
|
|
3
3
|
import { Button } from "./Button.js";
|
|
4
|
-
import { a as CodeBlockCopyButton, i as CodeBlockContent, n as CodeBlockActions, p as CodeBlockTitle, r as CodeBlockContainer, s as CodeBlockHeader, t as CodeBlock } from "../CodeBlock-
|
|
4
|
+
import { a as CodeBlockCopyButton, i as CodeBlockContent, n as CodeBlockActions, p as CodeBlockTitle, r as CodeBlockContainer, s as CodeBlockHeader, t as CodeBlock } from "../CodeBlock-C2Xjxu9M.js";
|
|
5
5
|
import { Popover } from "./Popover.js";
|
|
6
6
|
import * as React from "react";
|
|
7
7
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as cx } from "../class-names-9UtZwb0J.js";
|
|
2
|
-
import {
|
|
2
|
+
import { F as XIcon } from "../icons-DQC4Zw5R.js";
|
|
3
3
|
import { Button } from "./Button.js";
|
|
4
4
|
import { Tooltip, TooltipPopup, TooltipPortal, TooltipPositioner, TooltipTrigger } from "./Tooltip.js";
|
|
5
5
|
import "react";
|