@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,158 +1,7 @@
|
|
|
1
|
-
import { AgentChat } from "./AgentChat.js";
|
|
2
1
|
import { BrowserLiveView } from "./BrowserLiveView.js";
|
|
3
2
|
import { BrowserReplay } from "./BrowserReplay.js";
|
|
4
|
-
import { ThinkChatContext, useThinkChatContext } from "./ThinkChatContext.js";
|
|
5
3
|
import { isThinkChatActivityPart } from "./ThinkChatToolParts.js";
|
|
6
4
|
import { ThinkChatActivity, createThinkChatActivityRenderer, describeThinkChatActivityPart, renderThinkChatActivityPart } from "./ThinkChatActivity.js";
|
|
5
|
+
import { a as useThinkChat, i as ThinkChatRoot, n as ThinkChatMessages, o as useThinkPendingApprovals, r as ThinkChatProvider, t as ThinkChat } from "../ThinkChat-7DQ2CogF.js";
|
|
7
6
|
import { WorkspaceExplorer, inferWorkspaceLanguage, useWorkspace } from "./WorkspaceExplorer.js";
|
|
8
|
-
import * as React from "react";
|
|
9
|
-
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
10
|
-
import { useAgentChat } from "@cloudflare/think/react";
|
|
11
|
-
import { useAgent } from "agents/react";
|
|
12
|
-
//#region src/components/ThinkChat.tsx
|
|
13
|
-
function toAgentChatStatus(chat) {
|
|
14
|
-
if (chat.status === "submitted") return "submitted";
|
|
15
|
-
if (chat.isStreaming || chat.isRecovering) return "streaming";
|
|
16
|
-
return chat.status ?? "ready";
|
|
17
|
-
}
|
|
18
|
-
function useThinkPendingApprovals(stub, refreshKey) {
|
|
19
|
-
const [pendingApprovals, setPendingApprovals] = React.useState([]);
|
|
20
|
-
const refresh = React.useCallback(async () => {
|
|
21
|
-
try {
|
|
22
|
-
setPendingApprovals(await stub.pendingApprovals());
|
|
23
|
-
} catch {
|
|
24
|
-
setPendingApprovals([]);
|
|
25
|
-
}
|
|
26
|
-
}, [stub]);
|
|
27
|
-
React.useEffect(() => {
|
|
28
|
-
refresh();
|
|
29
|
-
}, [refresh, refreshKey]);
|
|
30
|
-
const executionApprovals = React.useMemo(() => ({
|
|
31
|
-
approve: async (id) => {
|
|
32
|
-
try {
|
|
33
|
-
return await stub.approveExecution(id);
|
|
34
|
-
} finally {
|
|
35
|
-
refresh();
|
|
36
|
-
}
|
|
37
|
-
},
|
|
38
|
-
reject: async (id, reason) => {
|
|
39
|
-
try {
|
|
40
|
-
return await stub.rejectExecution(id, reason);
|
|
41
|
-
} finally {
|
|
42
|
-
refresh();
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}), [stub, refresh]);
|
|
46
|
-
return React.useMemo(() => ({
|
|
47
|
-
pendingApprovals,
|
|
48
|
-
executionApprovals
|
|
49
|
-
}), [pendingApprovals, executionApprovals]);
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* Chat UI for Cloudflare Think agents. Provide a `useAgentChat` value (or let
|
|
53
|
-
* `ThinkChat.Root` create one) and `ThinkChat.Messages` renders the message
|
|
54
|
-
* stream with agent work folded into collapsed Activity blocks.
|
|
55
|
-
*/
|
|
56
|
-
function ThinkChatProvider({ chat, children }) {
|
|
57
|
-
return /* @__PURE__ */ jsx(ThinkChatContext.Provider, {
|
|
58
|
-
value: chat,
|
|
59
|
-
children
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Batteries-included root: connects to the named Think agent (upstream's
|
|
64
|
-
* `useAgent` + `useAgentChat`) and provides the live chat to everything
|
|
65
|
-
* inside. If the app already owns the chat hook, use `ThinkChat.Provider`.
|
|
66
|
-
*
|
|
67
|
-
* @example
|
|
68
|
-
* ```tsx
|
|
69
|
-
* <ThinkChat.Root agent="my-agent" name="session-1">
|
|
70
|
-
* <ThinkChat.Messages />
|
|
71
|
-
* </ThinkChat.Root>
|
|
72
|
-
* ```
|
|
73
|
-
*/
|
|
74
|
-
function ThinkChatRoot({ agent: agentOption, name, children }) {
|
|
75
|
-
const agent = useAgent(typeof agentOption === "string" ? {
|
|
76
|
-
agent: agentOption,
|
|
77
|
-
name
|
|
78
|
-
} : {
|
|
79
|
-
...agentOption,
|
|
80
|
-
name: name ?? agentOption.name
|
|
81
|
-
});
|
|
82
|
-
const chat = useAgentChat({ agent });
|
|
83
|
-
const approvals = useThinkPendingApprovals(agent.stub, `${chat.messages.length}:${chat.status}`);
|
|
84
|
-
return /* @__PURE__ */ jsx(ThinkChatContext.Provider, {
|
|
85
|
-
value: chat,
|
|
86
|
-
children: /* @__PURE__ */ jsx(ThinkChatApprovalsContext.Provider, {
|
|
87
|
-
value: approvals,
|
|
88
|
-
children
|
|
89
|
-
})
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
const ThinkChatApprovalsContext = React.createContext(null);
|
|
93
|
-
/**
|
|
94
|
-
* The full conversation surface — message list plus composer — with the
|
|
95
|
-
* activity renderer as the default `renderPart`: runs of reasoning/tool parts
|
|
96
|
-
* fold into one collapsed Activity block with derived labels and per-tool
|
|
97
|
-
* panels. Extend for app-specific tools with `toolRenderers` (label/panel
|
|
98
|
-
* inside the log) or `excludeTools` + your own `renderPart` (standalone
|
|
99
|
-
* card) — see README "App-specific tools" and the Custom Tool Panel story.
|
|
100
|
-
*/
|
|
101
|
-
function ThinkChatMessages({ renderPart, excludeTools, toolRenderers, executionApprovals, pendingApprovals, notice, ...props }) {
|
|
102
|
-
const chat = useThinkChatContext("ThinkChat.Messages");
|
|
103
|
-
const approvals = React.useContext(ThinkChatApprovalsContext);
|
|
104
|
-
const status = toAgentChatStatus(chat);
|
|
105
|
-
const resolvedExecutionApprovals = executionApprovals ?? approvals?.executionApprovals;
|
|
106
|
-
const resolvedPendingApprovals = pendingApprovals ?? approvals?.pendingApprovals;
|
|
107
|
-
const defaultRenderPart = React.useMemo(() => createThinkChatActivityRenderer({
|
|
108
|
-
excludeTools,
|
|
109
|
-
toolRenderers
|
|
110
|
-
}), [excludeTools, toolRenderers]);
|
|
111
|
-
const connectionNotice = chat.isRecovering ? /* @__PURE__ */ jsx(Fragment, { children: "Reconnecting to the agent…" }) : chat.connectionError ? /* @__PURE__ */ jsxs("span", {
|
|
112
|
-
"data-tone": "danger",
|
|
113
|
-
children: ["Connection lost", chat.connectionError.reason ? ` — ${chat.connectionError.reason}` : ""]
|
|
114
|
-
}) : void 0;
|
|
115
|
-
return /* @__PURE__ */ jsx(AgentChat, {
|
|
116
|
-
...props,
|
|
117
|
-
renderPart: renderPart ?? defaultRenderPart,
|
|
118
|
-
messages: chat.messages,
|
|
119
|
-
status,
|
|
120
|
-
onStop: chat.stop,
|
|
121
|
-
onApprovalResponse: chat.addToolApprovalResponse,
|
|
122
|
-
executionApprovals: resolvedExecutionApprovals,
|
|
123
|
-
pendingApprovals: resolvedPendingApprovals,
|
|
124
|
-
notice: notice ?? connectionNotice,
|
|
125
|
-
onRegenerate: (messageId) => void chat.regenerate({ messageId }),
|
|
126
|
-
onSubmit: ({ text, files }) => {
|
|
127
|
-
const trimmed = text.trim();
|
|
128
|
-
if (trimmed || files.length) chat.sendMessage({
|
|
129
|
-
text: trimmed,
|
|
130
|
-
files
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
|
-
});
|
|
134
|
-
}
|
|
135
|
-
/**
|
|
136
|
-
* The ambient chat value from `ThinkChat.Root`/`Provider` — for custom tool
|
|
137
|
-
* panels, cards, or composer actions that need `messages`, `status`, or
|
|
138
|
-
* `sendMessage`. Throws outside a provider.
|
|
139
|
-
*/
|
|
140
|
-
function useThinkChat() {
|
|
141
|
-
return useThinkChatContext("useThinkChat");
|
|
142
|
-
}
|
|
143
|
-
/**
|
|
144
|
-
* Namespace entry point. `Root` + `Messages` is the standard surface;
|
|
145
|
-
* `Provider` + `useThinkChat` when the app owns the chat hook; `Activity`,
|
|
146
|
-
* `renderActivityPart`, and `createActivityRenderer` for custom layouts and
|
|
147
|
-
* app-specific tools.
|
|
148
|
-
*/
|
|
149
|
-
const ThinkChat = {
|
|
150
|
-
Provider: ThinkChatProvider,
|
|
151
|
-
Root: ThinkChatRoot,
|
|
152
|
-
Messages: ThinkChatMessages,
|
|
153
|
-
Activity: ThinkChatActivity,
|
|
154
|
-
renderActivityPart: renderThinkChatActivityPart,
|
|
155
|
-
createActivityRenderer: createThinkChatActivityRenderer
|
|
156
|
-
};
|
|
157
|
-
//#endregion
|
|
158
7
|
export { BrowserLiveView, BrowserReplay, ThinkChat, ThinkChatActivity, ThinkChatMessages, ThinkChatProvider, ThinkChatRoot, WorkspaceExplorer, createThinkChatActivityRenderer, describeThinkChatActivityPart, inferWorkspaceLanguage, isThinkChatActivityPart, renderThinkChatActivityPart, useThinkChat, useThinkPendingApprovals, useWorkspace };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { _ as isThinkChatActivityPart } from "../ThinkChatToolParts-
|
|
2
|
-
import { a as ThinkChatToolRenderers, c as renderThinkChatActivityPart, i as ThinkChatToolRenderer, n as ThinkChatActivityProps, o as createThinkChatActivityRenderer, r as ThinkChatActivityRendererOptions, s as describeThinkChatActivityPart, t as ThinkChatActivity } from "../ThinkChatActivity-
|
|
1
|
+
import { _ as isThinkChatActivityPart } from "../ThinkChatToolParts-Cv4o7j6F.js";
|
|
2
|
+
import { a as ThinkChatToolRenderers, c as renderThinkChatActivityPart, i as ThinkChatToolRenderer, n as ThinkChatActivityProps, o as createThinkChatActivityRenderer, r as ThinkChatActivityRendererOptions, s as describeThinkChatActivityPart, t as ThinkChatActivity } from "../ThinkChatActivity-Cuk28Js_.js";
|
|
3
3
|
export { ThinkChatActivity, ThinkChatActivityProps, ThinkChatActivityRendererOptions, ThinkChatToolRenderer, ThinkChatToolRenderers, createThinkChatActivityRenderer, describeThinkChatActivityPart, isThinkChatActivityPart, renderThinkChatActivityPart };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { D as PencilIcon, I as TerminalIcon, L as WarningIcon, R as WrenchIcon, b as LinkIcon, h as FileIcon, j as SearchIcon, w as MonitorIcon, y as InfoIcon } from "../icons-Ba9THQKz.js";
|
|
2
2
|
import { Activity, ActivityContent, ActivityItem, ActivityItemGroup, ActivityText, ActivityTrigger } from "./Activity.js";
|
|
3
|
-
import {
|
|
3
|
+
import { t as summarizeToolInput } from "../summarize-tool-input-BUJsENSn.js";
|
|
4
|
+
import { useOptionalThinkChatContext } from "./ThinkChatContext.js";
|
|
4
5
|
import { displayUrl, isBrowserToolPart, isExecuteToolPart, isFetchToolPart, isPartFailed, isPartWorking, isSkillToolPart, isThinkChatActivityPart, isWorkspaceToolPart } from "./ThinkChatToolParts.js";
|
|
5
6
|
import { ThinkChatBrowserPanel, ThinkChatExecutePanel, ThinkChatFetchPanel, ThinkChatSkillPanel, ThinkChatWorkspacePanel } from "./ThinkChatToolPanels.js";
|
|
6
7
|
import * as React from "react";
|
|
@@ -8,14 +9,6 @@ import { jsx, jsxs } from "react/jsx-runtime";
|
|
|
8
9
|
import { getToolInput, getToolOutput } from "@cloudflare/think/react";
|
|
9
10
|
import { getToolName, isReasoningUIPart, isToolUIPart } from "ai";
|
|
10
11
|
//#region src/components/ThinkChatActivity.tsx
|
|
11
|
-
function summarizeToolInput(input) {
|
|
12
|
-
if (!input || typeof input !== "object") return null;
|
|
13
|
-
for (const value of Object.values(input)) if (typeof value === "string" && value.trim()) {
|
|
14
|
-
const line = value.trim().split("\n", 1)[0] ?? "";
|
|
15
|
-
return line.length > 64 ? `${line.slice(0, 64)}…` : line;
|
|
16
|
-
}
|
|
17
|
-
return null;
|
|
18
|
-
}
|
|
19
12
|
const HTTP_URL_PATTERN = /https?:\/\/[^\s"'<>)}\]]+/i;
|
|
20
13
|
function firstHttpUrl(value) {
|
|
21
14
|
const text = typeof value === "string" ? value : JSON.stringify(value) ?? "";
|
|
@@ -390,7 +383,7 @@ function ThinkChatActivityStep({ text, part, toolRenderers }) {
|
|
|
390
383
|
});
|
|
391
384
|
}
|
|
392
385
|
function ThinkChatActivityGroup({ message, parts, isTrailing, toolRenderers }) {
|
|
393
|
-
const chat =
|
|
386
|
+
const chat = useOptionalThinkChatContext();
|
|
394
387
|
const chatStillWorking = isTrailing && Boolean(chat?.isStreaming) && chat?.messages.at(-1)?.id === message.id;
|
|
395
388
|
return /* @__PURE__ */ jsx(ThinkChatActivity, {
|
|
396
389
|
parts,
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as ThinkChatValue, r as
|
|
2
|
-
export { ThinkChatContext, ThinkChatValue, useThinkChatContext };
|
|
1
|
+
import { i as useThinkChatContext, n as ThinkChatValue, r as useOptionalThinkChatContext, t as ThinkChatContext } from "../ThinkChatContext-C3Eb1Xpi.js";
|
|
2
|
+
export { ThinkChatContext, ThinkChatValue, useOptionalThinkChatContext, useThinkChatContext };
|
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
//#region src/components/ThinkChatContext.ts
|
|
3
|
+
/**
|
|
4
|
+
* React contexts cannot bind provider-specific generics. Keep the stored value
|
|
5
|
+
* opaque and restore the complete upstream hook type through the typed accessors.
|
|
6
|
+
*/
|
|
3
7
|
const ThinkChatContext = React.createContext(null);
|
|
8
|
+
function useOptionalThinkChatContext() {
|
|
9
|
+
return React.useContext(ThinkChatContext);
|
|
10
|
+
}
|
|
4
11
|
function useThinkChatContext(component) {
|
|
5
|
-
const context =
|
|
12
|
+
const context = useOptionalThinkChatContext();
|
|
6
13
|
if (!context) throw new Error(`${component} must be used inside <ThinkChat.Provider> or <ThinkChat.Root>.`);
|
|
7
14
|
return context;
|
|
8
15
|
}
|
|
9
16
|
//#endregion
|
|
10
|
-
export { ThinkChatContext, useThinkChatContext };
|
|
17
|
+
export { ThinkChatContext, useOptionalThinkChatContext, useThinkChatContext };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as SkillToolPart, l as WorkspaceToolPart, n as ExecuteToolPart, r as FetchToolPart, t as BrowserToolPart } from "../ThinkChatToolParts-
|
|
1
|
+
import { i as SkillToolPart, l as WorkspaceToolPart, n as ExecuteToolPart, r as FetchToolPart, t as BrowserToolPart } from "../ThinkChatToolParts-Cv4o7j6F.js";
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
|
|
4
4
|
//#region src/components/ThinkChatToolPanels.d.ts
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ActivityOutput, ActivityPanel } from "./Activity.js";
|
|
2
|
-
import {
|
|
3
|
-
import { t as CodeBlock } from "../CodeBlock-
|
|
2
|
+
import { Tabs } from "./Tabs.js";
|
|
3
|
+
import { t as CodeBlock } from "../CodeBlock-BUFXG8HW.js";
|
|
4
4
|
import { BrowserLiveView } from "./BrowserLiveView.js";
|
|
5
5
|
import { displayUrl } from "./ThinkChatToolParts.js";
|
|
6
6
|
import * as React from "react";
|
|
@@ -176,13 +176,22 @@ function ThinkChatFetchPanel({ part }) {
|
|
|
176
176
|
status: `${output.status} · ${output.bytes} bytes${output.truncated ? " (truncated)" : ""}`
|
|
177
177
|
});
|
|
178
178
|
}
|
|
179
|
+
function isBrowserLiveViewUrl(value) {
|
|
180
|
+
if (!value || typeof value !== "object") return false;
|
|
181
|
+
const source = value;
|
|
182
|
+
if (typeof source.url !== "string" || typeof source.targetId !== "string" || typeof source.expiresInMs !== "number" || !Number.isFinite(source.expiresInMs)) return false;
|
|
183
|
+
try {
|
|
184
|
+
return new URL(source.url).origin === "https://live.browser.run";
|
|
185
|
+
} catch {
|
|
186
|
+
return false;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
179
189
|
function findBrowserResultMedia(value, depth = 0) {
|
|
180
190
|
const media = {};
|
|
181
191
|
const visit = (node, level) => {
|
|
182
192
|
if (level > 4 || node === null) return;
|
|
183
193
|
if (typeof node === "string") {
|
|
184
|
-
if (!media.
|
|
185
|
-
else if (!media.screenshot && node.startsWith("data:image/")) media.screenshot = node;
|
|
194
|
+
if (!media.screenshot && node.startsWith("data:image/")) media.screenshot = node;
|
|
186
195
|
return;
|
|
187
196
|
}
|
|
188
197
|
if (Array.isArray(node)) {
|
|
@@ -190,8 +199,11 @@ function findBrowserResultMedia(value, depth = 0) {
|
|
|
190
199
|
return;
|
|
191
200
|
}
|
|
192
201
|
if (typeof node === "object") {
|
|
202
|
+
if (!media.liveView && isBrowserLiveViewUrl(node)) {
|
|
203
|
+
media.liveView = node;
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
193
206
|
const record = node;
|
|
194
|
-
if (media.expiresInMs === void 0 && typeof record.url === "string" && typeof record.expiresInMs === "number") media.expiresInMs = record.expiresInMs;
|
|
195
207
|
for (const item of Object.values(record)) visit(item, level + 1);
|
|
196
208
|
}
|
|
197
209
|
};
|
|
@@ -255,10 +267,10 @@ function ThinkChatBrowserPanel({ part }) {
|
|
|
255
267
|
const output = part.state === "output-available" ? part.output : void 0;
|
|
256
268
|
const code = part.input?.code ?? "";
|
|
257
269
|
const media = output?.status === "completed" ? findBrowserResultMedia(output.result) : {};
|
|
258
|
-
const hasMedia = Boolean(media.
|
|
259
|
-
const browserView = media.
|
|
260
|
-
|
|
261
|
-
|
|
270
|
+
const hasMedia = Boolean(media.liveView || media.screenshot);
|
|
271
|
+
const browserView = media.liveView ? /* @__PURE__ */ jsx(BrowserLiveView, {
|
|
272
|
+
source: media.liveView,
|
|
273
|
+
receivedAt: seenAt,
|
|
262
274
|
fallback: media.screenshot ? /* @__PURE__ */ jsx("img", {
|
|
263
275
|
src: media.screenshot,
|
|
264
276
|
alt: "Last browser state"
|
|
@@ -277,25 +289,25 @@ function ThinkChatBrowserPanel({ part }) {
|
|
|
277
289
|
label: "Browser",
|
|
278
290
|
status: executeStatusText(output),
|
|
279
291
|
error: output?.status === "error",
|
|
280
|
-
children: browserView && code ? /* @__PURE__ */ jsxs(Tabs, {
|
|
292
|
+
children: browserView && code ? /* @__PURE__ */ jsxs(Tabs.Root, {
|
|
281
293
|
className: "activity__browser-tabs",
|
|
282
294
|
defaultValue: "browser",
|
|
283
295
|
children: [
|
|
284
|
-
/* @__PURE__ */ jsxs(
|
|
296
|
+
/* @__PURE__ */ jsxs(Tabs.List, {
|
|
285
297
|
variant: "line",
|
|
286
|
-
children: [/* @__PURE__ */ jsx(Tab, {
|
|
298
|
+
children: [/* @__PURE__ */ jsx(Tabs.Tab, {
|
|
287
299
|
value: "browser",
|
|
288
300
|
children: "Preview"
|
|
289
|
-
}), /* @__PURE__ */ jsx(Tab, {
|
|
301
|
+
}), /* @__PURE__ */ jsx(Tabs.Tab, {
|
|
290
302
|
value: "code",
|
|
291
303
|
children: "Code"
|
|
292
304
|
})]
|
|
293
305
|
}),
|
|
294
|
-
/* @__PURE__ */ jsx(
|
|
306
|
+
/* @__PURE__ */ jsx(Tabs.Panel, {
|
|
295
307
|
value: "browser",
|
|
296
308
|
children: browserView
|
|
297
309
|
}),
|
|
298
|
-
/* @__PURE__ */ jsx(
|
|
310
|
+
/* @__PURE__ */ jsx(Tabs.Panel, {
|
|
299
311
|
value: "code",
|
|
300
312
|
children: codeView
|
|
301
313
|
})
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { _ as isThinkChatActivityPart, a as ThinkBashToolOutput, c as ThinkWorkspaceToolName, d as isBrowserToolPart, f as isExecuteToolPart, g as isSkillToolPart, h as isPartWorking, i as SkillToolPart, l as WorkspaceToolPart, m as isPartFailed, n as ExecuteToolPart, o as ThinkBashToolPart, p as isFetchToolPart, r as FetchToolPart, s as ThinkChatPart, t as BrowserToolPart, u as displayUrl, v as isWorkspaceToolPart } from "../ThinkChatToolParts-
|
|
1
|
+
import { _ as isThinkChatActivityPart, a as ThinkBashToolOutput, c as ThinkWorkspaceToolName, d as isBrowserToolPart, f as isExecuteToolPart, g as isSkillToolPart, h as isPartWorking, i as SkillToolPart, l as WorkspaceToolPart, m as isPartFailed, n as ExecuteToolPart, o as ThinkBashToolPart, p as isFetchToolPart, r as FetchToolPart, s as ThinkChatPart, t as BrowserToolPart, u as displayUrl, v as isWorkspaceToolPart } from "../ThinkChatToolParts-Cv4o7j6F.js";
|
|
2
2
|
export { BrowserToolPart, ExecuteToolPart, FetchToolPart, SkillToolPart, ThinkBashToolOutput, ThinkBashToolPart, ThinkChatPart, ThinkWorkspaceToolName, WorkspaceToolPart, displayUrl, isBrowserToolPart, isExecuteToolPart, isFetchToolPart, isPartFailed, isPartWorking, isSkillToolPart, isThinkChatActivityPart, isWorkspaceToolPart };
|
|
@@ -3,16 +3,19 @@ import { Think } from "@cloudflare/think";
|
|
|
3
3
|
import { AgentStub } from "agents/client";
|
|
4
4
|
|
|
5
5
|
//#region src/components/ThinkExecutionWorkbench.d.ts
|
|
6
|
-
|
|
7
|
-
type ThinkExecutionWorkbenchSource<State = unknown> = AgentStub<ThinkExecutionAgent<State>>;
|
|
8
|
-
interface ThinkExecutionWorkbenchProps<State = unknown> extends Omit<React.HTMLAttributes<HTMLDivElement>, "title"> {
|
|
6
|
+
interface ThinkExecutionWorkbenchProps extends Omit<React.HTMLAttributes<HTMLDivElement>, "title"> {
|
|
9
7
|
/** Agents SDK client stub for a Think agent; this UI calls native submission/workflow methods. */
|
|
10
|
-
source:
|
|
8
|
+
source: AgentStub<Think>;
|
|
11
9
|
title?: React.ReactNode;
|
|
12
10
|
backButton?: React.ReactNode;
|
|
13
11
|
pageSize?: number;
|
|
14
12
|
}
|
|
15
|
-
|
|
13
|
+
/**
|
|
14
|
+
* Unified execution history for native Think submissions and Agents workflows.
|
|
15
|
+
* The workbench reads and acts through the whole upstream agent stub; it does
|
|
16
|
+
* not normalize execution records or own workflow authoring.
|
|
17
|
+
*/
|
|
18
|
+
declare function ThinkExecutionWorkbench({
|
|
16
19
|
backButton,
|
|
17
20
|
className,
|
|
18
21
|
pageSize,
|
|
@@ -20,8 +23,8 @@ declare function ThinkExecutionWorkbench<State = unknown>({
|
|
|
20
23
|
source,
|
|
21
24
|
title,
|
|
22
25
|
...props
|
|
23
|
-
}: ThinkExecutionWorkbenchProps
|
|
26
|
+
}: ThinkExecutionWorkbenchProps & {
|
|
24
27
|
ref?: React.Ref<HTMLDivElement>;
|
|
25
28
|
}): React.JSX.Element;
|
|
26
29
|
//#endregion
|
|
27
|
-
export {
|
|
30
|
+
export { ThinkExecutionWorkbench, ThinkExecutionWorkbenchProps };
|