@mcp-b/react-components 0.11.0 → 0.13.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/{AgentChat-B9LD_WF1.d.ts → AgentChat-Br6tKEl8.d.ts} +38 -10
- package/dist/{BrowserLiveView-ZktFZiMD.d.ts → BrowserLiveView-BV5qgFgI.d.ts} +11 -10
- package/dist/{BrowserReplay-6G-mnwcn.d.ts → BrowserReplay-xWvRjRAC.d.ts} +2 -1
- package/dist/{Button-Ct5I6aTu.d.ts → Button-FX_hpqxm.d.ts} +8 -11
- package/dist/{CodeBlock-XNQOupQ3.js → CodeBlock-BUFXG8HW.js} +22 -12
- package/dist/{CodeBlock-CxQXv3C4.d.ts → CodeBlock-DUh9WOGo.d.ts} +13 -7
- package/dist/{Combobox-D9anamNr.d.ts → Combobox-B9Fcd6q-.d.ts} +4 -14
- package/dist/{FileTree-wMyZhhHO.js → FileTree-mpEIcfzA.js} +1 -1
- package/dist/{Menu-B5vDqZe_.d.ts → Menu-Bgu-ufb5.d.ts} +29 -65
- package/dist/{ModelSelector-DXtpcRmT.js → ModelSelector-DVgVBdvw.js} +23 -20
- package/dist/{PromptInput-D6-G24p7.d.ts → PromptInput-p5KmOmt1.d.ts} +313 -89
- package/dist/Select-Dl_vF_Bt.d.ts +213 -0
- package/dist/{Tabs-D9EAq09D.d.ts → Tabs-3Zc4tb9D.d.ts} +9 -6
- package/dist/ThinkChat-7DQ2CogF.js +222 -0
- package/dist/{ThinkChatActivity-B2UD95My.d.ts → ThinkChatActivity-Cuk28Js_.d.ts} +4 -4
- package/dist/ThinkChatContext-C3Eb1Xpi.d.ts +16 -0
- package/dist/{ThinkChatToolParts-DnUiZgCC.d.ts → ThinkChatToolParts-Cv4o7j6F.d.ts} +13 -5
- package/dist/{attachment-preview-ChtC3HiU.js → attachment-preview-DIs50Q0h.js} +3 -3
- package/dist/components/Accordion.d.ts +17 -6
- package/dist/components/Accordion.js +23 -36
- package/dist/components/Activity.d.ts +5 -5
- package/dist/components/Activity.js +9 -9
- package/dist/components/AgentChat.d.ts +1 -1
- package/dist/components/AgentChat.js +354 -132
- package/dist/components/AgentConnection.js +6 -22
- package/dist/components/AlertDialog.d.ts +40 -32
- package/dist/components/AlertDialog.js +46 -39
- package/dist/components/Artifact.d.ts +1 -1
- package/dist/components/Artifact.js +5 -5
- package/dist/components/Autocomplete.js +10 -2
- package/dist/components/Avatar.d.ts +2 -2
- package/dist/components/Avatar.js +3 -3
- package/dist/components/Badge.d.ts +11 -14
- package/dist/components/Badge.js +11 -33
- package/dist/components/BrowserLiveView.d.ts +1 -1
- package/dist/components/BrowserLiveView.js +39 -45
- package/dist/components/BrowserReplay.d.ts +1 -1
- package/dist/components/BrowserReplay.js +4 -4
- package/dist/components/BrowserRunPanel.js +91 -55
- package/dist/components/Button.d.ts +2 -2
- package/dist/components/Button.js +7 -30
- package/dist/components/ChainOfThought.d.ts +5 -5
- package/dist/components/ChainOfThought.js +8 -5
- package/dist/components/ChatGptSignInScreen.js +3 -3
- package/dist/components/Checkbox.d.ts +10 -2
- package/dist/components/Checkbox.js +13 -6
- package/dist/components/CheckboxGroup.d.ts +6 -6
- package/dist/components/CheckboxGroup.js +6 -6
- package/dist/components/CodeBlock.d.ts +1 -1
- package/dist/components/CodeBlock.js +1 -1
- package/dist/components/CodexModelSelector.d.ts +58 -0
- package/dist/components/CodexModelSelector.js +170 -0
- package/dist/components/Collapsible.d.ts +2 -4
- package/dist/components/Collapsible.js +9 -7
- package/dist/components/Combobox.d.ts +2 -2
- package/dist/components/Combobox.js +20 -22
- package/dist/components/Commit.d.ts +6 -6
- package/dist/components/Commit.js +14 -26
- package/dist/components/Context.js +5 -1
- package/dist/components/ContextMenu.d.ts +20 -72
- package/dist/components/ContextMenu.js +46 -56
- package/dist/components/Conversation.d.ts +3 -7
- package/dist/components/Conversation.js +3 -4
- package/dist/components/Dialog.d.ts +38 -30
- package/dist/components/Dialog.js +46 -34
- package/dist/components/EnvironmentVariables.d.ts +2 -7
- package/dist/components/EnvironmentVariables.js +13 -36
- package/dist/components/Field.d.ts +3 -3
- package/dist/components/Field.js +7 -8
- package/dist/components/Fieldset.d.ts +2 -2
- package/dist/components/Fieldset.js +2 -2
- package/dist/components/FileTree.js +1 -1
- package/dist/components/Label.d.ts +1 -1
- package/dist/components/Label.js +1 -1
- package/dist/components/Marker.js +1 -15
- package/dist/components/McpServerPicker.d.ts +31 -6
- package/dist/components/McpServerPicker.js +136 -72
- package/dist/components/Menu.d.ts +2 -2
- package/dist/components/Menu.js +41 -51
- package/dist/components/Menubar.d.ts +16 -52
- package/dist/components/Menubar.js +44 -56
- package/dist/components/Message.d.ts +4 -3
- package/dist/components/Message.js +16 -9
- package/dist/components/MessageScroller.d.ts +1 -1
- package/dist/components/MessageScroller.js +1 -1
- package/dist/components/Meter.js +5 -0
- package/dist/components/ModelSelector.d.ts +12 -9
- package/dist/components/ModelSelector.js +1 -1
- package/dist/components/NavigationMenu.d.ts +3 -14
- package/dist/components/NavigationMenu.js +22 -38
- package/dist/components/NumberField.js +6 -0
- package/dist/components/Popover.d.ts +21 -44
- package/dist/components/Popover.js +33 -23
- package/dist/components/PreviewCard.d.ts +20 -18
- package/dist/components/PreviewCard.js +30 -20
- package/dist/components/PricingPage.js +30 -29
- package/dist/components/Progress.d.ts +7 -3
- package/dist/components/Progress.js +9 -4
- package/dist/components/PromptInput.d.ts +2 -2
- package/dist/components/PromptInput.js +184 -148
- package/dist/components/Queue.d.ts +8 -19
- package/dist/components/Queue.js +6 -6
- package/dist/components/RadioGroup.d.ts +10 -9
- package/dist/components/RadioGroup.js +8 -9
- package/dist/components/Reasoning.d.ts +4 -4
- package/dist/components/Reasoning.js +12 -21
- package/dist/components/ScrollArea.d.ts +2 -9
- package/dist/components/ScrollArea.js +5 -23
- package/dist/components/Select.d.ts +2 -2
- package/dist/components/Select.js +100 -134
- package/dist/components/Slider.d.ts +10 -7
- package/dist/components/Slider.js +12 -11
- package/dist/components/Sources.d.ts +4 -4
- package/dist/components/Sources.js +8 -5
- package/dist/components/Stepper.js +2 -8
- package/dist/components/Switch.d.ts +6 -3
- package/dist/components/Switch.js +7 -4
- package/dist/components/Tabs.d.ts +2 -2
- package/dist/components/Tabs.js +9 -4
- package/dist/components/Task.d.ts +4 -4
- package/dist/components/Task.js +10 -6
- package/dist/components/Terminal.d.ts +2 -2
- package/dist/components/Terminal.js +5 -5
- package/dist/components/TestResults.d.ts +4 -4
- package/dist/components/TestResults.js +5 -5
- package/dist/components/ThinkChat.d.ts +37 -30
- package/dist/components/ThinkChat.js +1 -152
- package/dist/components/ThinkChatActivity.d.ts +2 -2
- package/dist/components/ThinkChatActivity.js +4 -11
- package/dist/components/ThinkChatContext.d.ts +2 -2
- package/dist/components/ThinkChatContext.js +9 -2
- package/dist/components/ThinkChatToolPanels.d.ts +1 -1
- package/dist/components/ThinkChatToolPanels.js +27 -15
- package/dist/components/ThinkChatToolParts.d.ts +1 -1
- package/dist/components/ThinkExecutionWorkbench.d.ts +10 -7
- package/dist/components/ThinkExecutionWorkbench.js +382 -359
- package/dist/components/ThinkFullApp.d.ts +16 -13
- package/dist/components/ThinkFullApp.js +35 -25
- package/dist/components/ThinkThreadPicker.d.ts +1 -31
- package/dist/components/ThinkThreadPicker.js +32 -171
- package/dist/components/ThinkThreadShell.d.ts +35 -0
- package/dist/components/ThinkThreadShell.js +146 -0
- package/dist/components/Toast.js +7 -0
- package/dist/components/ToggleGroup.d.ts +6 -2
- package/dist/components/ToggleGroup.js +6 -2
- package/dist/components/Toolbar.js +6 -0
- package/dist/components/Tooltip.d.ts +36 -27
- package/dist/components/Tooltip.js +45 -29
- package/dist/components/WebPreview.d.ts +1 -1
- package/dist/components/WebPreview.js +3 -3
- package/dist/components/WorkspaceExplorer.d.ts +6 -8
- package/dist/components/WorkspaceExplorer.js +9 -7
- package/dist/components/icons.d.ts +2 -2
- package/dist/components/icons.js +2 -2
- package/dist/{copy-button-C6JSKtFE.js → copy-button-DUMLYdsk.js} +7 -6
- package/dist/{copy-button-BKXqGiNm.d.ts → copy-button-DtPMgN7e.d.ts} +3 -2
- package/dist/icons-Ba9THQKz.js +64 -0
- package/dist/icons-CUCz_Sft.d.ts +210 -0
- package/dist/merge-refs-DF_7w2x_.js +18 -0
- package/dist/styles/accessibility.css +14 -0
- package/dist/styles/accordion.css +21 -61
- package/dist/styles/activity.css +23 -58
- package/dist/styles/agent-chat.css +49 -5
- package/dist/styles/agent-connection.css +8 -10
- package/dist/styles/alert-dialog.css +20 -26
- package/dist/styles/artifact.css +6 -6
- package/dist/styles/attachment-preview.css +1 -1
- package/dist/styles/autocomplete.css +5 -170
- package/dist/styles/avatar.css +8 -8
- package/dist/styles/badge.css +8 -10
- package/dist/styles/base-ui-motion.css +176 -0
- package/dist/styles/base.css +19 -25
- package/dist/styles/browser-live-view.css +7 -7
- package/dist/styles/browser-replay.css +5 -5
- package/dist/styles/browser-run-panel.css +59 -112
- package/dist/styles/button.css +48 -43
- package/dist/styles/card.css +3 -5
- package/dist/styles/chain-of-thought.css +14 -70
- package/dist/styles/chatgpt-sign-in-screen.css +3 -3
- package/dist/styles/checkbox-group.css +1 -1
- package/dist/styles/checkbox.css +3 -7
- package/dist/styles/code-block.css +10 -10
- package/dist/styles/codex-model-selector.css +186 -0
- package/dist/styles/collapsible.css +11 -27
- package/dist/styles/combobox.css +3 -149
- package/dist/styles/commit.css +19 -35
- package/dist/styles/context-menu.css +1 -77
- package/dist/styles/context.css +12 -12
- package/dist/styles/conversation.css +7 -7
- package/dist/styles/dialog.css +34 -55
- package/dist/styles/environment-variables.css +10 -10
- package/dist/styles/field.css +16 -58
- package/dist/styles/fieldset.css +2 -2
- package/dist/styles/file-tree.css +7 -9
- package/dist/styles/index.css +12 -2
- package/dist/styles/input.css +1 -51
- package/dist/styles/label.css +2 -2
- package/dist/styles/marker.css +2 -4
- package/dist/styles/mcp-server-picker.css +66 -19
- package/dist/styles/menu.css +6 -153
- package/dist/styles/menubar.css +6 -105
- package/dist/styles/message-scroller.css +1 -1
- package/dist/styles/message.css +87 -9
- package/dist/styles/meter.css +4 -20
- package/dist/styles/model-selector.css +32 -20
- package/dist/styles/navigation-menu.css +14 -54
- package/dist/styles/number-field.css +8 -23
- package/dist/styles/popover.css +13 -68
- package/dist/styles/preview-card.css +5 -46
- package/dist/styles/pricing-page.css +43 -43
- package/dist/styles/progress.css +7 -16
- package/dist/styles/prompt-input.css +100 -44
- package/dist/styles/queue.css +12 -28
- package/dist/styles/radio.css +4 -8
- package/dist/styles/reasoning.css +3 -62
- package/dist/styles/recipes.css +475 -0
- package/dist/styles/select.css +7 -103
- package/dist/styles/shell.css +3 -3
- package/dist/styles/slider.css +5 -7
- package/dist/styles/sources.css +9 -66
- package/dist/styles/stepper.css +16 -14
- package/dist/styles/streamdown.css +11 -57
- package/dist/styles/switch.css +4 -7
- package/dist/styles/tabs.css +7 -8
- package/dist/styles/task.css +13 -42
- package/dist/styles/terminal.css +7 -7
- package/dist/styles/test-results.css +21 -37
- package/dist/styles/think-execution-workbench.css +337 -0
- package/dist/styles/think-full-app.css +27 -410
- package/dist/styles/think-resize-handle.css +33 -0
- package/dist/styles/think-thread-picker.css +18 -247
- package/dist/styles/think-thread-shell.css +219 -0
- package/dist/styles/toast.css +14 -25
- package/dist/styles/toggle-group.css +16 -14
- package/dist/styles/toggle.css +14 -15
- package/dist/styles/toolbar.css +13 -25
- package/dist/styles/tooltip.css +6 -16
- package/dist/styles/web-preview.css +15 -15
- package/dist/styles/workspace-explorer.css +21 -14
- package/dist/summarize-tool-input-BUJsENSn.js +12 -0
- package/dist/utils/codex-model-catalog.d.ts +142 -0
- package/dist/utils/codex-model-catalog.js +112 -0
- package/dist/utils/structured-code.d.ts +1 -1
- package/package.json +8 -2
- package/dist/Select-CRsKCJ9x.d.ts +0 -200
- package/dist/ThinkChatContext-BLAAb8J5.d.ts +0 -28
- package/dist/components/McpServerConnections.d.ts +0 -41
- package/dist/components/McpServerConnections.js +0 -188
- package/dist/components/useStickToBottom.d.ts +0 -33
- package/dist/components/useStickToBottom.js +0 -107
- package/dist/icons-CbjtbIJK.d.ts +0 -51
- package/dist/icons-D2Q5n5C1.js +0 -291
- package/dist/styles/mcp-server-connections.css +0 -145
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import { t as cx } from "../class-names-9UtZwb0J.js";
|
|
2
|
-
import {
|
|
2
|
+
import { A as RefreshIcon, D as PencilIcon, k as PlusIcon } from "../icons-Ba9THQKz.js";
|
|
3
3
|
import { Activity, ActivityContent, ActivityPanel, ActivityTrigger } from "./Activity.js";
|
|
4
4
|
import { Context, ContextContent, ContextContentBody, ContextContentHeader, ContextTrigger, getContextUsage, getContextUsedTokens } from "./Context.js";
|
|
5
|
+
import { Button } from "./Button.js";
|
|
5
6
|
import { MessageScroller, MessageScrollerButton, MessageScrollerContent, MessageScrollerItem, MessageScrollerProvider, MessageScrollerViewport } from "./MessageScroller.js";
|
|
6
7
|
import { ConversationEmptyState } from "./Conversation.js";
|
|
7
8
|
import { Message, MessageAction, MessageActions, MessageAttachment, MessageContent, MessageResponse } from "./Message.js";
|
|
8
9
|
import { Marker, MarkerContent } from "./Marker.js";
|
|
9
|
-
import {
|
|
10
|
-
import { PromptInput, PromptInputActionAddAttachments, PromptInputActionMenu, PromptInputActionMenuContent, PromptInputActionMenuTrigger, PromptInputApproval, PromptInputAttachments, PromptInputBody, PromptInputButton, PromptInputFooter, PromptInputPermissionSelector, PromptInputSubmit, PromptInputTextarea, PromptInputTools, getApprovalRequestId, getApprovalStateKey, getPendingToolApprovals, usePromptInputAttachments } from "./PromptInput.js";
|
|
10
|
+
import { PromptInput, PromptInputActionAddAttachments, PromptInputActionMenu, PromptInputActionMenuContent, PromptInputActionMenuTrigger, PromptInputApproval, PromptInputAttachments, PromptInputBody, PromptInputButton, PromptInputFooter, PromptInputHeader, PromptInputPermissionSelector, PromptInputSubmit, PromptInputTextarea, PromptInputTools, getApprovalRequestId, getApprovalStateKey, getPendingToolApprovals, usePromptInputAttachments } from "./PromptInput.js";
|
|
11
11
|
import { Reasoning, ReasoningContent, ReasoningTrigger } from "./Reasoning.js";
|
|
12
12
|
import { Source, Sources, SourcesContent, SourcesTrigger } from "./Sources.js";
|
|
13
|
+
import { t as CopyButton } from "../copy-button-DUMLYdsk.js";
|
|
14
|
+
import { t as summarizeToolInput } from "../summarize-tool-input-BUJsENSn.js";
|
|
13
15
|
import * as React from "react";
|
|
14
16
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
15
17
|
import { isCompactionMessage } from "agents/experimental/memory/utils";
|
|
@@ -17,6 +19,17 @@ import { getToolInput, getToolOutput, getToolPartState } from "@cloudflare/think
|
|
|
17
19
|
import { getToolName, isFileUIPart, isReasoningUIPart, isTextUIPart, isToolUIPart } from "ai";
|
|
18
20
|
//#region src/components/AgentChat.tsx
|
|
19
21
|
const EMPTY_PENDING_APPROVALS = [];
|
|
22
|
+
const EMPTY_SKIPPED_APPROVAL_IDS = [];
|
|
23
|
+
function createApprovalSessionState(thinkStub) {
|
|
24
|
+
return {
|
|
25
|
+
thinkStub,
|
|
26
|
+
skippedApprovalIds: EMPTY_SKIPPED_APPROVAL_IDS,
|
|
27
|
+
permissionMode: "ask"
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
function isCurrentApprovalSession(state, thinkStub) {
|
|
31
|
+
return state.thinkStub === thinkStub;
|
|
32
|
+
}
|
|
20
33
|
function AgentChatAttachButton() {
|
|
21
34
|
const attachments = usePromptInputAttachments();
|
|
22
35
|
return /* @__PURE__ */ jsx(PromptInputButton, {
|
|
@@ -33,7 +46,7 @@ function AgentChatAddMenu({ children }) {
|
|
|
33
46
|
sideOffset: 12,
|
|
34
47
|
collisionPadding: 8,
|
|
35
48
|
className: "agent-chat__add-menu",
|
|
36
|
-
children: [/* @__PURE__ */
|
|
49
|
+
children: [/* @__PURE__ */ jsx(PromptInputActionAddAttachments, {}), children]
|
|
37
50
|
})] });
|
|
38
51
|
}
|
|
39
52
|
/**
|
|
@@ -62,14 +75,6 @@ function getPartKey(part, partIndex) {
|
|
|
62
75
|
if ("id" in part && typeof part.id === "string") return `${part.type}-${part.id}`;
|
|
63
76
|
return `${part.type}-${partIndex}`;
|
|
64
77
|
}
|
|
65
|
-
function summarizeToolInput(input) {
|
|
66
|
-
if (!input || typeof input !== "object") return null;
|
|
67
|
-
for (const value of Object.values(input)) if (typeof value === "string" && value.trim()) {
|
|
68
|
-
const line = value.trim().split("\n", 1)[0] ?? "";
|
|
69
|
-
return line.length > 64 ? `${line.slice(0, 64)}…` : line;
|
|
70
|
-
}
|
|
71
|
-
return null;
|
|
72
|
-
}
|
|
73
78
|
function isToolPartWorking(part) {
|
|
74
79
|
const state = getToolPartState(part);
|
|
75
80
|
return state === "loading" || state === "streaming" || state === "waiting-approval";
|
|
@@ -114,6 +119,123 @@ function isCompactionMessage$1(message) {
|
|
|
114
119
|
function getMessageText(message) {
|
|
115
120
|
return message.parts.filter((part) => isTextUIPart(part) || isReasoningUIPart(part)).map((part) => part.text).join("");
|
|
116
121
|
}
|
|
122
|
+
function getCopyableResponseText(message) {
|
|
123
|
+
return message.parts.filter(isTextUIPart).map((part) => part.text).join("\n\n").trim() || void 0;
|
|
124
|
+
}
|
|
125
|
+
function AgentChatAssistantActions({ message, responseNumber, showCopy, showRetry, onRegenerate, onCopyStatus }) {
|
|
126
|
+
const copyText = getCopyableResponseText(message);
|
|
127
|
+
if ((!showCopy || !copyText) && !showRetry) return null;
|
|
128
|
+
return /* @__PURE__ */ jsxs(MessageActions, {
|
|
129
|
+
"aria-label": `Actions for response ${responseNumber}`,
|
|
130
|
+
children: [showCopy && copyText ? /* @__PURE__ */ jsx(CopyButton, {
|
|
131
|
+
className: "message__action",
|
|
132
|
+
label: `Copy response ${responseNumber}`,
|
|
133
|
+
tooltip: "Copy response",
|
|
134
|
+
text: copyText,
|
|
135
|
+
size: "icon-lg",
|
|
136
|
+
onCopy: () => onCopyStatus(`Response ${responseNumber} copied.`),
|
|
137
|
+
onError: () => onCopyStatus(`Could not copy response ${responseNumber}. Try again.`)
|
|
138
|
+
}) : null, showRetry && onRegenerate ? /* @__PURE__ */ jsx(MessageAction, {
|
|
139
|
+
label: "Retry",
|
|
140
|
+
tooltip: "Regenerate response",
|
|
141
|
+
size: "icon-lg",
|
|
142
|
+
onClick: () => onRegenerate(message.id),
|
|
143
|
+
children: /* @__PURE__ */ jsx(RefreshIcon, { size: 14 })
|
|
144
|
+
}) : null]
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
function getEditableUserText(message) {
|
|
148
|
+
if (message.role !== "user" || message.parts.length !== 1) return void 0;
|
|
149
|
+
const part = message.parts[0];
|
|
150
|
+
return isTextUIPart(part) && part.text.trim() ? part.text : void 0;
|
|
151
|
+
}
|
|
152
|
+
function AgentChatMessageEditor({ message, originalText, onCancel, onEditAndResend, onSuccess }) {
|
|
153
|
+
const [draft, setDraft] = React.useState(originalText);
|
|
154
|
+
const [isSubmitting, setIsSubmitting] = React.useState(false);
|
|
155
|
+
const [error, setError] = React.useState();
|
|
156
|
+
const textareaRef = React.useRef(null);
|
|
157
|
+
const labelId = React.useId();
|
|
158
|
+
const errorId = React.useId();
|
|
159
|
+
const trimmedDraft = draft.trim();
|
|
160
|
+
const canSubmit = !isSubmitting && Boolean(trimmedDraft) && trimmedDraft !== originalText.trim();
|
|
161
|
+
React.useLayoutEffect(() => {
|
|
162
|
+
textareaRef.current?.focus();
|
|
163
|
+
const end = textareaRef.current?.value.length ?? 0;
|
|
164
|
+
textareaRef.current?.setSelectionRange(end, end);
|
|
165
|
+
}, []);
|
|
166
|
+
const handleSubmit = async (event) => {
|
|
167
|
+
event.preventDefault();
|
|
168
|
+
if (!canSubmit) return;
|
|
169
|
+
setError(void 0);
|
|
170
|
+
setIsSubmitting(true);
|
|
171
|
+
try {
|
|
172
|
+
await onEditAndResend({
|
|
173
|
+
message,
|
|
174
|
+
text: trimmedDraft
|
|
175
|
+
});
|
|
176
|
+
onSuccess();
|
|
177
|
+
} catch {
|
|
178
|
+
setError("Message wasn’t resent. Try again.");
|
|
179
|
+
setIsSubmitting(false);
|
|
180
|
+
}
|
|
181
|
+
};
|
|
182
|
+
return /* @__PURE__ */ jsxs("form", {
|
|
183
|
+
className: "message__edit-form",
|
|
184
|
+
"aria-busy": isSubmitting,
|
|
185
|
+
onSubmit: (event) => void handleSubmit(event),
|
|
186
|
+
children: [
|
|
187
|
+
/* @__PURE__ */ jsx("label", {
|
|
188
|
+
id: labelId,
|
|
189
|
+
className: "message__edit-label",
|
|
190
|
+
htmlFor: `${labelId}-textarea`,
|
|
191
|
+
children: "Edit message"
|
|
192
|
+
}),
|
|
193
|
+
/* @__PURE__ */ jsx("textarea", {
|
|
194
|
+
ref: textareaRef,
|
|
195
|
+
id: `${labelId}-textarea`,
|
|
196
|
+
className: "message__edit-textarea",
|
|
197
|
+
value: draft,
|
|
198
|
+
"aria-describedby": error ? errorId : void 0,
|
|
199
|
+
"aria-invalid": error ? true : void 0,
|
|
200
|
+
disabled: isSubmitting,
|
|
201
|
+
rows: 3,
|
|
202
|
+
onChange: (event) => {
|
|
203
|
+
setDraft(event.currentTarget.value);
|
|
204
|
+
if (error) setError(void 0);
|
|
205
|
+
},
|
|
206
|
+
onKeyDown: (event) => {
|
|
207
|
+
if (event.key !== "Escape" || isSubmitting) return;
|
|
208
|
+
event.preventDefault();
|
|
209
|
+
onCancel();
|
|
210
|
+
}
|
|
211
|
+
}),
|
|
212
|
+
error ? /* @__PURE__ */ jsx("p", {
|
|
213
|
+
id: errorId,
|
|
214
|
+
className: "message__edit-error",
|
|
215
|
+
role: "alert",
|
|
216
|
+
children: error
|
|
217
|
+
}) : null,
|
|
218
|
+
/* @__PURE__ */ jsxs("div", {
|
|
219
|
+
className: "message__edit-actions",
|
|
220
|
+
children: [/* @__PURE__ */ jsx(Button, {
|
|
221
|
+
type: "button",
|
|
222
|
+
variant: "outline",
|
|
223
|
+
color: "neutral",
|
|
224
|
+
size: "lg",
|
|
225
|
+
disabled: isSubmitting,
|
|
226
|
+
onClick: onCancel,
|
|
227
|
+
children: "Cancel"
|
|
228
|
+
}), /* @__PURE__ */ jsx(Button, {
|
|
229
|
+
type: "submit",
|
|
230
|
+
color: "primary",
|
|
231
|
+
size: "lg",
|
|
232
|
+
disabled: !canSubmit,
|
|
233
|
+
children: isSubmitting ? "Resending…" : "Send"
|
|
234
|
+
})]
|
|
235
|
+
})
|
|
236
|
+
]
|
|
237
|
+
});
|
|
238
|
+
}
|
|
117
239
|
function formatSourceTitle(part) {
|
|
118
240
|
if (part.title) return part.title;
|
|
119
241
|
if (part.type === "source-document") return part.filename ?? part.mediaType;
|
|
@@ -188,42 +310,98 @@ function renderDefaultPart(part) {
|
|
|
188
310
|
* transport. Product code that talks to a Cloudflare Think agent should render
|
|
189
311
|
* `ThinkChat`; use this directly only for plain AI SDK or read-only messages.
|
|
190
312
|
*/
|
|
191
|
-
function AgentChat({ className, messages, status = "ready", onSubmit, onStop, placeholder = "Ask anything...", disabled, emptyState, composerTools, composerAddMenuItems, notice, onRegenerate, onApprovalResponse,
|
|
313
|
+
function AgentChat({ className, messages, status = "ready", onSubmit, onStop, placeholder = "Ask anything...", disabled, emptyState, composerHeader, composerTools, composerAddMenuItems, notice, onRegenerate, onEditAndResend, onApprovalResponse, thinkStub, onExecutionSettled, pendingApprovals: durableApprovals = EMPTY_PENDING_APPROVALS, contextWindow, renderPart, renderMessageAfter, ref }) {
|
|
314
|
+
const [copyAnnouncement, setCopyAnnouncement] = React.useState("");
|
|
315
|
+
const copyAnnouncementTimer = React.useRef(null);
|
|
316
|
+
const announceCopyStatus = React.useCallback((message) => {
|
|
317
|
+
if (copyAnnouncementTimer.current !== null) window.clearTimeout(copyAnnouncementTimer.current);
|
|
318
|
+
setCopyAnnouncement("");
|
|
319
|
+
copyAnnouncementTimer.current = window.setTimeout(() => {
|
|
320
|
+
setCopyAnnouncement(message);
|
|
321
|
+
copyAnnouncementTimer.current = null;
|
|
322
|
+
}, 50);
|
|
323
|
+
}, []);
|
|
324
|
+
React.useEffect(() => () => {
|
|
325
|
+
if (copyAnnouncementTimer.current !== null) window.clearTimeout(copyAnnouncementTimer.current);
|
|
326
|
+
}, []);
|
|
192
327
|
const handleSubmit = React.useCallback((message) => {
|
|
193
328
|
onSubmit?.(message);
|
|
194
329
|
}, [onSubmit]);
|
|
195
|
-
const [
|
|
196
|
-
const
|
|
330
|
+
const [approvalSession, setApprovalSession] = React.useState(() => createApprovalSessionState(thinkStub));
|
|
331
|
+
const approvalSessionIsCurrent = isCurrentApprovalSession(approvalSession, thinkStub);
|
|
332
|
+
const skippedApprovalIds = approvalSessionIsCurrent ? approvalSession.skippedApprovalIds : EMPTY_SKIPPED_APPROVAL_IDS;
|
|
333
|
+
const permissionMode = approvalSessionIsCurrent ? approvalSession.permissionMode : "ask";
|
|
334
|
+
const updateApprovalSession = React.useCallback((update) => {
|
|
335
|
+
setApprovalSession((previous) => update(isCurrentApprovalSession(previous, thinkStub) ? previous : createApprovalSessionState(thinkStub)));
|
|
336
|
+
}, [thinkStub]);
|
|
337
|
+
const setPermissionMode = React.useCallback((next) => {
|
|
338
|
+
updateApprovalSession((current) => ({
|
|
339
|
+
...current,
|
|
340
|
+
permissionMode: next
|
|
341
|
+
}));
|
|
342
|
+
}, [updateApprovalSession]);
|
|
343
|
+
React.useLayoutEffect(() => {
|
|
344
|
+
setApprovalSession((previous) => isCurrentApprovalSession(previous, thinkStub) ? previous : createApprovalSessionState(thinkStub));
|
|
345
|
+
}, [thinkStub]);
|
|
346
|
+
const pendingApprovalItems = [...getPendingToolApprovals(messages, { pausedExecutions: Boolean(thinkStub) }).filter(({ part }) => {
|
|
197
347
|
if (part.state === "approval-requested" && !onApprovalResponse) return false;
|
|
198
348
|
const id = getApprovalStateKey(part);
|
|
199
349
|
return Boolean(id) && !skippedApprovalIds.includes(id);
|
|
200
|
-
}).map((approval) => ({ part: approval.part })), ...
|
|
201
|
-
const approvalsWired = Boolean(onApprovalResponse ||
|
|
202
|
-
const
|
|
203
|
-
|
|
350
|
+
}).map((approval) => ({ part: approval.part })), ...thinkStub ? durableApprovals.filter((approval) => approval.source === "action" && !skippedApprovalIds.includes(approval.executionId)).map((approval) => ({ approval })) : []];
|
|
351
|
+
const approvalsWired = Boolean(onApprovalResponse || thinkStub);
|
|
352
|
+
const autoApprovedIds = React.useRef({
|
|
353
|
+
thinkStub,
|
|
354
|
+
ids: /* @__PURE__ */ new Set()
|
|
355
|
+
});
|
|
356
|
+
React.useLayoutEffect(() => {
|
|
357
|
+
if (isCurrentApprovalSession(autoApprovedIds.current, thinkStub)) return;
|
|
358
|
+
autoApprovedIds.current = {
|
|
359
|
+
thinkStub,
|
|
360
|
+
ids: /* @__PURE__ */ new Set()
|
|
361
|
+
};
|
|
362
|
+
}, [thinkStub]);
|
|
204
363
|
React.useEffect(() => {
|
|
205
364
|
if (permissionMode !== "bypass") return;
|
|
206
365
|
for (const item of pendingApprovalItems) {
|
|
207
366
|
const id = "part" in item ? getApprovalRequestId(item.part) : item.approval.executionId;
|
|
208
367
|
const key = "part" in item ? getApprovalStateKey(item.part) : item.approval.executionId;
|
|
209
|
-
if (!id || !key || autoApprovedIds.current.has(key)) continue;
|
|
210
|
-
autoApprovedIds.current.add(key);
|
|
368
|
+
if (!id || !key || autoApprovedIds.current.ids.has(key)) continue;
|
|
369
|
+
autoApprovedIds.current.ids.add(key);
|
|
211
370
|
if ("part" in item && item.part.state === "approval-requested") onApprovalResponse?.({
|
|
212
371
|
id,
|
|
213
372
|
approved: true
|
|
214
373
|
});
|
|
215
|
-
else
|
|
374
|
+
else if (thinkStub) thinkStub.approveExecution(id).finally(() => {
|
|
375
|
+
onExecutionSettled?.();
|
|
376
|
+
});
|
|
216
377
|
}
|
|
217
378
|
}, [
|
|
218
379
|
permissionMode,
|
|
219
380
|
messages,
|
|
220
381
|
durableApprovals,
|
|
221
382
|
onApprovalResponse,
|
|
222
|
-
|
|
383
|
+
thinkStub,
|
|
384
|
+
onExecutionSettled
|
|
223
385
|
]);
|
|
224
386
|
const pendingApproval = permissionMode === "bypass" ? void 0 : pendingApprovalItems[0];
|
|
225
387
|
const contextUsage = contextWindow ? getContextUsage(messages) : void 0;
|
|
226
|
-
const
|
|
388
|
+
const newestAssistantIndex = messages.findLastIndex((message) => message.role === "assistant" && !isCompactionMessage$1(message));
|
|
389
|
+
const lastAssistantIndex = onRegenerate && status !== "streaming" && status !== "submitted" ? newestAssistantIndex : -1;
|
|
390
|
+
const lastUserIndex = onEditAndResend && !disabled && status !== "streaming" && status !== "submitted" ? messages.findLastIndex((message) => message.role === "user") : -1;
|
|
391
|
+
const [editingMessageId, setEditingMessageId] = React.useState();
|
|
392
|
+
const restoreEditFocus = React.useRef(false);
|
|
393
|
+
const editButtonRef = React.useRef(null);
|
|
394
|
+
let assistantResponseCount = 0;
|
|
395
|
+
const assistantResponseNumbers = messages.map((message) => {
|
|
396
|
+
if (message.role !== "assistant" || isCompactionMessage$1(message)) return 0;
|
|
397
|
+
assistantResponseCount += 1;
|
|
398
|
+
return assistantResponseCount;
|
|
399
|
+
});
|
|
400
|
+
React.useLayoutEffect(() => {
|
|
401
|
+
if (editingMessageId || !restoreEditFocus.current) return;
|
|
402
|
+
editButtonRef.current?.focus();
|
|
403
|
+
restoreEditFocus.current = false;
|
|
404
|
+
}, [editingMessageId]);
|
|
227
405
|
const composerRef = (el) => {
|
|
228
406
|
if (!el || typeof ResizeObserver === "undefined") return;
|
|
229
407
|
const root = el.parentElement;
|
|
@@ -236,117 +414,161 @@ function AgentChat({ className, messages, status = "ready", onSubmit, onStop, pl
|
|
|
236
414
|
return /* @__PURE__ */ jsxs("div", {
|
|
237
415
|
ref,
|
|
238
416
|
className: cx("agent-chat", className),
|
|
239
|
-
children: [
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
children:
|
|
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
|
-
if (isSourceUrlPart(part) || isSourceDocumentPart(part)) {
|
|
271
|
-
if (custom !== void 0) return custom ? /* @__PURE__ */ jsx(MessageContent, { children: custom }, getPartKey(part, partIndex)) : null;
|
|
272
|
-
const previous = message.parts[partIndex - 1];
|
|
273
|
-
if (isSourceUrlPart(previous) || isSourceDocumentPart(previous)) return null;
|
|
274
|
-
return /* @__PURE__ */ jsx(MessageContent, { children: renderSources(getSourceRun(message.parts, partIndex)) }, getPartKey(part, partIndex));
|
|
275
|
-
}
|
|
276
|
-
const rendered = custom === void 0 ? defaultRender() : custom;
|
|
277
|
-
return rendered ? /* @__PURE__ */ jsxs(MessageContent, { children: [rendered, isCompactedPart(message, part, partIndex) ? /* @__PURE__ */ jsx("div", {
|
|
278
|
-
className: "message__compacted",
|
|
279
|
-
children: "Output truncated for storage"
|
|
280
|
-
}) : null] }, getPartKey(part, partIndex)) : null;
|
|
281
|
-
}),
|
|
282
|
-
renderMessageAfter?.({
|
|
417
|
+
children: [
|
|
418
|
+
/* @__PURE__ */ jsx("span", {
|
|
419
|
+
className: "message__copy-status",
|
|
420
|
+
role: "status",
|
|
421
|
+
"aria-atomic": "true",
|
|
422
|
+
children: copyAnnouncement
|
|
423
|
+
}),
|
|
424
|
+
/* @__PURE__ */ jsx(MessageScrollerProvider, {
|
|
425
|
+
autoScroll: true,
|
|
426
|
+
defaultScrollPosition: "last-anchor",
|
|
427
|
+
children: /* @__PURE__ */ jsxs(MessageScroller, {
|
|
428
|
+
className: "agent-chat__conversation",
|
|
429
|
+
children: [/* @__PURE__ */ jsx(MessageScrollerViewport, { children: /* @__PURE__ */ jsxs(MessageScrollerContent, {
|
|
430
|
+
"aria-busy": status === "streaming" || status === "submitted",
|
|
431
|
+
className: "agent-chat__transcript-content",
|
|
432
|
+
children: [messages.length === 0 ? /* @__PURE__ */ jsx(MessageScrollerItem, {
|
|
433
|
+
className: "agent-chat__empty-row",
|
|
434
|
+
children: emptyState ?? /* @__PURE__ */ jsx(ConversationEmptyState, {
|
|
435
|
+
title: "Start a conversation",
|
|
436
|
+
description: "Ask the agent to inspect, plan, or build."
|
|
437
|
+
})
|
|
438
|
+
}) : null, messages.map((message, messageIndex) => /* @__PURE__ */ jsx(MessageScrollerItem, {
|
|
439
|
+
messageId: message.id,
|
|
440
|
+
scrollAnchor: message.role === "user",
|
|
441
|
+
children: isCompactionMessage$1(message) ? /* @__PURE__ */ jsx(Marker, {
|
|
442
|
+
variant: "separator",
|
|
443
|
+
children: /* @__PURE__ */ jsx(MarkerContent, { children: getMessageText(message) || "Conversation compacted" })
|
|
444
|
+
}) : /* @__PURE__ */ jsx(Message, {
|
|
445
|
+
from: message.role,
|
|
446
|
+
children: editingMessageId === message.id && onEditAndResend ? /* @__PURE__ */ jsx(AgentChatMessageEditor, {
|
|
283
447
|
message,
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
448
|
+
originalText: getEditableUserText(message) ?? "",
|
|
449
|
+
onEditAndResend,
|
|
450
|
+
onCancel: () => {
|
|
451
|
+
restoreEditFocus.current = true;
|
|
452
|
+
setEditingMessageId(void 0);
|
|
453
|
+
},
|
|
454
|
+
onSuccess: () => {
|
|
455
|
+
restoreEditFocus.current = false;
|
|
456
|
+
setEditingMessageId(void 0);
|
|
457
|
+
}
|
|
458
|
+
}, message.id) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
459
|
+
message.parts.map((part, partIndex) => {
|
|
460
|
+
const defaultRender = () => renderDefaultPart(part);
|
|
461
|
+
const custom = renderPart?.({
|
|
462
|
+
message,
|
|
463
|
+
part,
|
|
464
|
+
partIndex,
|
|
465
|
+
defaultRender
|
|
466
|
+
});
|
|
467
|
+
if (isSourceUrlPart(part) || isSourceDocumentPart(part)) {
|
|
468
|
+
if (custom !== void 0) return custom ? /* @__PURE__ */ jsx(MessageContent, { children: custom }, getPartKey(part, partIndex)) : null;
|
|
469
|
+
const previous = message.parts[partIndex - 1];
|
|
470
|
+
if (isSourceUrlPart(previous) || isSourceDocumentPart(previous)) return null;
|
|
471
|
+
return /* @__PURE__ */ jsx(MessageContent, { children: renderSources(getSourceRun(message.parts, partIndex)) }, getPartKey(part, partIndex));
|
|
472
|
+
}
|
|
473
|
+
const rendered = custom === void 0 ? defaultRender() : custom;
|
|
474
|
+
return rendered ? /* @__PURE__ */ jsxs(MessageContent, { children: [rendered, isCompactedPart(message, part, partIndex) ? /* @__PURE__ */ jsx("div", {
|
|
475
|
+
className: "message__compacted",
|
|
476
|
+
children: "Output truncated for storage"
|
|
477
|
+
}) : null] }, getPartKey(part, partIndex)) : null;
|
|
478
|
+
}),
|
|
479
|
+
renderMessageAfter?.({
|
|
480
|
+
message,
|
|
481
|
+
messageIndex
|
|
482
|
+
}),
|
|
483
|
+
onEditAndResend && messageIndex === lastUserIndex && getEditableUserText(message) !== void 0 ? /* @__PURE__ */ jsx(MessageActions, {
|
|
484
|
+
"aria-label": "Message actions",
|
|
485
|
+
children: /* @__PURE__ */ jsx(MessageAction, {
|
|
486
|
+
ref: editButtonRef,
|
|
487
|
+
label: "Edit message",
|
|
488
|
+
tooltip: "Edit and resend",
|
|
489
|
+
size: "icon-lg",
|
|
490
|
+
onClick: () => {
|
|
491
|
+
restoreEditFocus.current = false;
|
|
492
|
+
setEditingMessageId(message.id);
|
|
493
|
+
},
|
|
494
|
+
children: /* @__PURE__ */ jsx(PencilIcon, {})
|
|
495
|
+
})
|
|
496
|
+
}) : null,
|
|
497
|
+
message.role === "assistant" ? /* @__PURE__ */ jsx(AgentChatAssistantActions, {
|
|
498
|
+
message,
|
|
499
|
+
responseNumber: assistantResponseNumbers[messageIndex],
|
|
500
|
+
showCopy: messageIndex !== newestAssistantIndex || status !== "streaming" && status !== "submitted",
|
|
501
|
+
showRetry: messageIndex === lastAssistantIndex,
|
|
502
|
+
onRegenerate,
|
|
503
|
+
onCopyStatus: announceCopyStatus
|
|
504
|
+
}) : null
|
|
505
|
+
] })
|
|
506
|
+
})
|
|
507
|
+
}, message.id ?? messageIndex))]
|
|
508
|
+
}) }), /* @__PURE__ */ jsx(MessageScrollerButton, {
|
|
509
|
+
"aria-label": "Scroll to latest",
|
|
510
|
+
className: "agent-chat__scroll-button",
|
|
511
|
+
size: "icon"
|
|
512
|
+
})]
|
|
513
|
+
})
|
|
514
|
+
}),
|
|
515
|
+
/* @__PURE__ */ jsxs("div", {
|
|
516
|
+
ref: composerRef,
|
|
517
|
+
className: "agent-chat__composer",
|
|
518
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
519
|
+
className: "agent-chat__notice",
|
|
520
|
+
role: "status",
|
|
521
|
+
"aria-atomic": "true",
|
|
522
|
+
children: notice
|
|
523
|
+
}), /* @__PURE__ */ jsx(PromptInput, {
|
|
524
|
+
multiple: true,
|
|
525
|
+
onSubmit: handleSubmit,
|
|
526
|
+
children: pendingApproval ? /* @__PURE__ */ jsx(PromptInputApproval, {
|
|
527
|
+
part: "part" in pendingApproval ? pendingApproval.part : void 0,
|
|
528
|
+
approval: "approval" in pendingApproval ? pendingApproval.approval : void 0,
|
|
529
|
+
count: pendingApprovalItems.length,
|
|
530
|
+
onRespond: onApprovalResponse,
|
|
531
|
+
thinkStub,
|
|
532
|
+
onExecutionSettled,
|
|
533
|
+
onSkip: () => {
|
|
534
|
+
const id = "part" in pendingApproval ? getApprovalStateKey(pendingApproval.part) : pendingApproval.approval.executionId;
|
|
535
|
+
if (id) updateApprovalSession((current) => ({
|
|
536
|
+
...current,
|
|
537
|
+
skippedApprovalIds: [...current.skippedApprovalIds, id]
|
|
538
|
+
}));
|
|
539
|
+
}
|
|
540
|
+
}) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
541
|
+
composerHeader ? /* @__PURE__ */ jsx(PromptInputHeader, { children: composerHeader }) : null,
|
|
542
|
+
/* @__PURE__ */ jsx(PromptInputAttachments, {}),
|
|
543
|
+
/* @__PURE__ */ jsx(PromptInputBody, { children: /* @__PURE__ */ jsx(PromptInputTextarea, {
|
|
544
|
+
"aria-label": "Message",
|
|
545
|
+
placeholder,
|
|
546
|
+
disabled
|
|
547
|
+
}) }),
|
|
548
|
+
/* @__PURE__ */ jsxs(PromptInputFooter, { children: [/* @__PURE__ */ jsxs(PromptInputTools, { children: [
|
|
549
|
+
/* @__PURE__ */ jsx(AgentChatAddMenu, { children: composerAddMenuItems }),
|
|
550
|
+
approvalsWired ? /* @__PURE__ */ jsx(PromptInputPermissionSelector, {
|
|
551
|
+
value: permissionMode,
|
|
552
|
+
onValueChange: setPermissionMode
|
|
553
|
+
}) : null,
|
|
554
|
+
composerTools
|
|
555
|
+
] }), /* @__PURE__ */ jsxs("div", {
|
|
556
|
+
className: "prompt-input__footer-end",
|
|
557
|
+
children: [contextWindow ? /* @__PURE__ */ jsxs(Context, {
|
|
558
|
+
usedTokens: getContextUsedTokens(contextUsage),
|
|
559
|
+
maxTokens: contextWindow.maxTokens,
|
|
560
|
+
usage: contextUsage,
|
|
561
|
+
modelId: contextWindow.modelId,
|
|
562
|
+
children: [/* @__PURE__ */ jsx(ContextTrigger, {}), /* @__PURE__ */ jsxs(ContextContent, { children: [/* @__PURE__ */ jsx(ContextContentHeader, {}), /* @__PURE__ */ jsx(ContextContentBody, {})] })]
|
|
563
|
+
}) : null, /* @__PURE__ */ jsx(PromptInputSubmit, {
|
|
564
|
+
status,
|
|
565
|
+
onStop
|
|
566
|
+
})]
|
|
567
|
+
})] })
|
|
568
|
+
] })
|
|
299
569
|
})]
|
|
300
570
|
})
|
|
301
|
-
|
|
302
|
-
ref: composerRef,
|
|
303
|
-
className: "agent-chat__composer",
|
|
304
|
-
children: [notice ? /* @__PURE__ */ jsx("div", {
|
|
305
|
-
className: "agent-chat__notice",
|
|
306
|
-
children: notice
|
|
307
|
-
}) : null, /* @__PURE__ */ jsx(PromptInput, {
|
|
308
|
-
multiple: true,
|
|
309
|
-
onSubmit: handleSubmit,
|
|
310
|
-
children: pendingApproval ? /* @__PURE__ */ jsx(PromptInputApproval, {
|
|
311
|
-
part: "part" in pendingApproval ? pendingApproval.part : void 0,
|
|
312
|
-
approval: "approval" in pendingApproval ? pendingApproval.approval : void 0,
|
|
313
|
-
count: pendingApprovalItems.length,
|
|
314
|
-
onRespond: onApprovalResponse,
|
|
315
|
-
executionApprovals,
|
|
316
|
-
onSkip: () => {
|
|
317
|
-
const id = "part" in pendingApproval ? getApprovalStateKey(pendingApproval.part) : pendingApproval.approval.executionId;
|
|
318
|
-
if (id) setSkippedApprovalIds((previous) => [...previous, id]);
|
|
319
|
-
}
|
|
320
|
-
}) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
321
|
-
/* @__PURE__ */ jsx(PromptInputAttachments, {}),
|
|
322
|
-
/* @__PURE__ */ jsx(PromptInputBody, { children: /* @__PURE__ */ jsx(PromptInputTextarea, {
|
|
323
|
-
"aria-label": "Message",
|
|
324
|
-
placeholder,
|
|
325
|
-
disabled
|
|
326
|
-
}) }),
|
|
327
|
-
/* @__PURE__ */ jsxs(PromptInputFooter, { children: [/* @__PURE__ */ jsxs(PromptInputTools, { children: [
|
|
328
|
-
/* @__PURE__ */ jsx(AgentChatAddMenu, { children: composerAddMenuItems }),
|
|
329
|
-
approvalsWired ? /* @__PURE__ */ jsx(PromptInputPermissionSelector, {
|
|
330
|
-
value: permissionMode,
|
|
331
|
-
onValueChange: setPermissionMode
|
|
332
|
-
}) : null,
|
|
333
|
-
composerTools
|
|
334
|
-
] }), /* @__PURE__ */ jsxs("div", {
|
|
335
|
-
className: "prompt-input__footer-end",
|
|
336
|
-
children: [contextWindow ? /* @__PURE__ */ jsxs(Context, {
|
|
337
|
-
usedTokens: getContextUsedTokens(contextUsage),
|
|
338
|
-
maxTokens: contextWindow.maxTokens,
|
|
339
|
-
usage: contextUsage,
|
|
340
|
-
modelId: contextWindow.modelId,
|
|
341
|
-
children: [/* @__PURE__ */ jsx(ContextTrigger, {}), /* @__PURE__ */ jsxs(ContextContent, { children: [/* @__PURE__ */ jsx(ContextContentHeader, {}), /* @__PURE__ */ jsx(ContextContentBody, {})] })]
|
|
342
|
-
}) : null, /* @__PURE__ */ jsx(PromptInputSubmit, {
|
|
343
|
-
status,
|
|
344
|
-
onStop
|
|
345
|
-
})]
|
|
346
|
-
})] })
|
|
347
|
-
] })
|
|
348
|
-
})]
|
|
349
|
-
})]
|
|
571
|
+
]
|
|
350
572
|
});
|
|
351
573
|
}
|
|
352
574
|
//#endregion
|
|
@@ -1,8 +1,8 @@
|
|
|
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-Ba9THQKz.js";
|
|
3
3
|
import { Popover } from "./Popover.js";
|
|
4
4
|
import { Button } from "./Button.js";
|
|
5
|
-
import { a as CodeBlockCopyButton, i as CodeBlockContent, n as CodeBlockActions, p as CodeBlockTitle, r as CodeBlockContainer, s as CodeBlockHeader, t as CodeBlock } from "../CodeBlock-
|
|
5
|
+
import { a as CodeBlockCopyButton, i as CodeBlockContent, n as CodeBlockActions, p as CodeBlockTitle, r as CodeBlockContainer, s as CodeBlockHeader, t as CodeBlock } from "../CodeBlock-BUFXG8HW.js";
|
|
6
6
|
import { Field } from "./Field.js";
|
|
7
7
|
import { Form } from "./Form.js";
|
|
8
8
|
import * as React from "react";
|
|
@@ -178,12 +178,8 @@ function McpConnectorForm({ auth, authorizeLabel = "Authorize", className, defau
|
|
|
178
178
|
...props,
|
|
179
179
|
children: [
|
|
180
180
|
/* @__PURE__ */ jsxs(Field.Root, { children: [
|
|
181
|
-
/* @__PURE__ */ jsx(Field.Label, {
|
|
182
|
-
htmlFor: "mcpName",
|
|
183
|
-
children: "MCP name"
|
|
184
|
-
}),
|
|
181
|
+
/* @__PURE__ */ jsx(Field.Label, { children: "MCP name" }),
|
|
185
182
|
/* @__PURE__ */ jsx(Field.Control, {
|
|
186
|
-
id: "mcpName",
|
|
187
183
|
name: "name",
|
|
188
184
|
pattern: namePattern,
|
|
189
185
|
required: true,
|
|
@@ -200,12 +196,8 @@ function McpConnectorForm({ auth, authorizeLabel = "Authorize", className, defau
|
|
|
200
196
|
})
|
|
201
197
|
] }),
|
|
202
198
|
/* @__PURE__ */ jsxs(Field.Root, { children: [
|
|
203
|
-
/* @__PURE__ */ jsx(Field.Label, {
|
|
204
|
-
htmlFor: "mcpUrl",
|
|
205
|
-
children: "MCP URL"
|
|
206
|
-
}),
|
|
199
|
+
/* @__PURE__ */ jsx(Field.Label, { children: "MCP URL" }),
|
|
207
200
|
/* @__PURE__ */ jsx(Field.Control, {
|
|
208
|
-
id: "mcpUrl",
|
|
209
201
|
name: "url",
|
|
210
202
|
placeholder: "http://127.0.0.1:8787/mcp",
|
|
211
203
|
required: true,
|
|
@@ -221,24 +213,16 @@ function McpConnectorForm({ auth, authorizeLabel = "Authorize", className, defau
|
|
|
221
213
|
children: "MCP URL must use http or https."
|
|
222
214
|
})
|
|
223
215
|
] }),
|
|
224
|
-
redirectUrlField ? /* @__PURE__ */ jsxs(Field.Root, { children: [/* @__PURE__ */ jsx(Field.Label, {
|
|
225
|
-
htmlFor: "mcpRedirectUrl",
|
|
226
|
-
children: redirectUrlField.label
|
|
227
|
-
}), /* @__PURE__ */ jsx(Field.Control, {
|
|
228
|
-
id: "mcpRedirectUrl",
|
|
216
|
+
redirectUrlField ? /* @__PURE__ */ jsxs(Field.Root, { children: [/* @__PURE__ */ jsx(Field.Label, { children: redirectUrlField.label }), /* @__PURE__ */ jsx(Field.Control, {
|
|
229
217
|
name: "redirectUrl",
|
|
230
218
|
readOnly: true,
|
|
231
219
|
type: "url",
|
|
232
220
|
value: redirectUrl
|
|
233
221
|
})] }) : null,
|
|
234
222
|
credentialFields.map((authField) => /* @__PURE__ */ jsxs(Field.Root, { children: [
|
|
235
|
-
/* @__PURE__ */ jsx(Field.Label, {
|
|
236
|
-
htmlFor: `mcp-${authField.name}`,
|
|
237
|
-
children: authField.label
|
|
238
|
-
}),
|
|
223
|
+
/* @__PURE__ */ jsx(Field.Label, { children: authField.label }),
|
|
239
224
|
/* @__PURE__ */ jsx(Field.Control, {
|
|
240
225
|
autoComplete: "off",
|
|
241
|
-
id: `mcp-${authField.name}`,
|
|
242
226
|
name: authField.name,
|
|
243
227
|
placeholder: authField.placeholder,
|
|
244
228
|
required: authField.required,
|