@mcp-b/react-components 0.14.2 → 0.16.1
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/AgentActivity-BNUNrP9O.d.ts +36 -0
- package/dist/{AgentChat-DQkqt82e.d.ts → AgentChat-CrlpbvQJ.d.ts} +58 -6
- package/dist/{CodeBlock-DUh9WOGo.d.ts → CodeBlock-BRajW4QU.d.ts} +1 -1
- package/dist/{CodeBlock-BUFXG8HW.js → CodeBlock-BmB4Xaqq.js} +15 -4
- package/dist/{FileTree-mpEIcfzA.js → FileTree-CkVbIMWV.js} +82 -89
- package/dist/Message-BkMdE3bS.js +375 -0
- package/dist/{ModelSelector-CPCpFAUt.js → ModelSelector-SlJNgwKY.js} +2 -2
- package/dist/{PromptInput-ClNqBiIw.d.ts → PromptInput-BWTuXMOD.d.ts} +123 -5
- package/dist/ResponsiveSidebarShell-Dd9DCcBT.d.ts +67 -0
- package/dist/{Select-Dl_vF_Bt.d.ts → Select-BeEsefzh.d.ts} +12 -2
- package/dist/{ThinkChat-BPcehdbP.js → ThinkChat-CzC-zNGA.js} +24 -36
- package/dist/{ThinkChatActivity-BmwuIigx.d.ts → ThinkChatActivity-BFQnb2ct.d.ts} +3 -10
- package/dist/ThinkChatActivitySummary-BPmu9a-c.d.ts +39 -0
- package/dist/{ThinkChatToolParts-CDEjqS6A.d.ts → ThinkChatToolParts-CSzVwMXf.d.ts} +13 -3
- package/dist/ThinkExecutionRun-ChhWhOoU.d.ts +30 -0
- package/dist/Toggle-CAAlNl-M.d.ts +69 -0
- package/dist/ToggleGroup-8hPv-b69.d.ts +73 -0
- package/dist/Workspace-D39LxGvP.d.ts +62 -0
- package/dist/WorkspaceFile-DOZkPwzu.d.ts +106 -0
- package/dist/WorkspaceFileView-rSN_yT0L.js +744 -0
- package/dist/WorkspaceLink-DIPbXrUM.js +337 -0
- package/dist/WorkspaceLink-DK1DWMHe.d.ts +89 -0
- package/dist/components/Activity.d.ts +27 -1
- package/dist/components/Activity.js +33 -15
- package/dist/components/AgentActivity.d.ts +2 -0
- package/dist/components/AgentActivity.js +45 -0
- package/dist/components/AgentActivityPreview.d.ts +46 -0
- package/dist/components/AgentActivityPreview.js +94 -0
- package/dist/components/AgentAttention.d.ts +73 -0
- package/dist/components/AgentAttention.js +85 -0
- package/dist/components/AgentChat.d.ts +2 -2
- package/dist/components/AgentChat.js +224 -200
- package/dist/components/AgentChatMessageEditor.d.ts +29 -0
- package/dist/components/AgentChatMessageEditor.js +92 -0
- package/dist/components/AgentChatTurnError.d.ts +17 -0
- package/dist/components/AgentChatTurnError.js +40 -0
- package/dist/components/AgentConnection.d.ts +12 -17
- package/dist/components/AgentConnection.js +99 -91
- package/dist/components/AppFrame.d.ts +24 -0
- package/dist/components/AppFrame.js +25 -0
- package/dist/components/AppTopBar.d.ts +71 -0
- package/dist/components/AppTopBar.js +82 -0
- package/dist/components/Artifact.js +1 -1
- package/dist/components/BrowserLiveView.js +1 -1
- package/dist/components/BrowserReplay.js +1 -1
- package/dist/components/BrowserRunPanel.js +1 -1
- package/dist/components/Card.d.ts +3 -0
- package/dist/components/Card.js +2 -1
- package/dist/components/ChainOfThought.d.ts +1 -1
- package/dist/components/ChainOfThought.js +1 -1
- package/dist/components/ChatGptSignInScreen.js +2 -2
- package/dist/components/Checkbox.js +5 -13
- package/dist/components/CheckboxGroup.d.ts +58 -2
- package/dist/components/CheckboxGroup.js +59 -1
- package/dist/components/CodeBlock.d.ts +1 -1
- package/dist/components/CodeBlock.js +1 -1
- package/dist/components/CodexModelSelector.js +1 -1
- package/dist/components/Commit.js +2 -2
- package/dist/components/ContextMenu.js +1 -1
- package/dist/components/Conversation.js +1 -1
- package/dist/components/DescriptionList.d.ts +12 -0
- package/dist/components/DescriptionList.js +11 -0
- package/dist/components/DescriptionListParts.d.ts +37 -0
- package/dist/components/DescriptionListParts.js +35 -0
- package/dist/components/EnvironmentVariables.js +2 -2
- package/dist/components/Fieldset.d.ts +13 -1
- package/dist/components/Fieldset.js +11 -2
- package/dist/components/FileTree.js +1 -1
- package/dist/components/IconButton.d.ts +33 -0
- package/dist/components/IconButton.js +27 -0
- package/dist/components/McpConnectionRequest.d.ts +44 -0
- package/dist/components/McpConnectionRequest.js +122 -0
- package/dist/components/McpServerPicker.d.ts +48 -23
- package/dist/components/McpServerPicker.js +238 -189
- package/dist/components/Menubar.js +1 -1
- package/dist/components/Message.d.ts +1 -0
- package/dist/components/Message.js +1 -285
- package/dist/components/MessageScroller.js +1 -1
- package/dist/components/ModelSelector.js +1 -1
- package/dist/components/Pricing.d.ts +37 -0
- package/dist/components/Pricing.js +17 -0
- package/dist/components/PricingBillingToggle.d.ts +23 -0
- package/dist/components/PricingBillingToggle.js +86 -0
- package/dist/components/PricingConfirmationDialog.d.ts +25 -0
- package/dist/components/PricingConfirmationDialog.js +57 -0
- package/dist/components/PricingFAQ.d.ts +18 -0
- package/dist/components/PricingFAQ.js +27 -0
- package/dist/components/PricingPage.d.ts +2 -38
- package/dist/components/PricingPage.js +39 -359
- package/dist/components/PricingPlanCard.d.ts +22 -0
- package/dist/components/PricingPlanCard.js +109 -0
- package/dist/components/PricingUsageCalculator.d.ts +22 -0
- package/dist/components/PricingUsageCalculator.js +96 -0
- package/dist/components/PromptInput.d.ts +2 -2
- package/dist/components/PromptInput.js +210 -15
- package/dist/components/Queue.js +1 -1
- package/dist/components/Reasoning.d.ts +2 -1
- package/dist/components/Reasoning.js +14 -29
- package/dist/components/ResizableSidePanel.d.ts +57 -0
- package/dist/components/ResizableSidePanel.js +151 -0
- package/dist/components/ResponsiveSidebarShell.d.ts +2 -0
- package/dist/components/ResponsiveSidebarShell.js +129 -0
- package/dist/components/Select.d.ts +2 -2
- package/dist/components/Select.js +11 -2
- package/dist/components/Slider.d.ts +13 -1
- package/dist/components/Slider.js +11 -0
- package/dist/components/Sources.js +1 -1
- package/dist/components/Stepper.d.ts +4 -0
- package/dist/components/Stepper.js +5 -3
- package/dist/components/SubagentRun.d.ts +18 -19
- package/dist/components/SubagentRun.js +25 -18
- package/dist/components/SubagentRunIndicator.d.ts +22 -0
- package/dist/components/SubagentRunIndicator.js +33 -0
- package/dist/components/SubagentRunList.d.ts +25 -0
- package/dist/components/SubagentRunList.js +26 -0
- package/dist/components/SubagentRunSelector.d.ts +47 -0
- package/dist/components/SubagentRunSelector.js +55 -0
- package/dist/components/Task.js +1 -1
- package/dist/components/Terminal.js +2 -2
- package/dist/components/TestResults.js +1 -1
- package/dist/components/Textarea.d.ts +21 -0
- package/dist/components/Textarea.js +19 -0
- package/dist/components/ThemeModeControl.d.ts +24 -0
- package/dist/components/ThemeModeControl.js +52 -0
- package/dist/components/ThemeProvider.d.ts +38 -0
- package/dist/components/ThemeProvider.js +80 -0
- package/dist/components/ThinkChat.d.ts +29 -6
- package/dist/components/ThinkChat.js +7 -4
- package/dist/components/ThinkChatActivity.d.ts +3 -2
- package/dist/components/ThinkChatActivity.js +12 -318
- package/dist/components/ThinkChatActivitySummary.d.ts +2 -0
- package/dist/components/ThinkChatActivitySummary.js +421 -0
- package/dist/components/ThinkChatToolPanels.d.ts +7 -5
- package/dist/components/ThinkChatToolPanels.js +70 -8
- package/dist/components/ThinkChatToolParts.d.ts +2 -2
- package/dist/components/ThinkChatToolParts.js +36 -10
- package/dist/components/ThinkExecutionDetail.d.ts +20 -0
- package/dist/components/ThinkExecutionDetail.js +80 -0
- package/dist/components/ThinkExecutionRun.d.ts +2 -0
- package/dist/components/ThinkExecutionRun.js +72 -0
- package/dist/components/ThinkExecutionStatus.d.ts +22 -0
- package/dist/components/ThinkExecutionStatus.js +36 -0
- package/dist/components/ThinkExecutionWorkbench.d.ts +7 -0
- package/dist/components/ThinkExecutionWorkbench.js +69 -225
- package/dist/components/ThinkFullApp.d.ts +58 -14
- package/dist/components/ThinkFullApp.js +154 -160
- package/dist/components/ThinkFullAppViewSwitch.d.ts +31 -0
- package/dist/components/ThinkFullAppViewSwitch.js +34 -0
- package/dist/components/ThinkRoutine.d.ts +36 -0
- package/dist/components/ThinkRoutine.js +15 -0
- package/dist/components/ThinkRoutineBrowser.d.ts +25 -0
- package/dist/components/ThinkRoutineBrowser.js +156 -0
- package/dist/components/ThinkRoutineDetail.d.ts +24 -0
- package/dist/components/ThinkRoutineDetail.js +102 -0
- package/dist/components/ThinkRoutineForm.d.ts +32 -0
- package/dist/components/ThinkRoutineForm.js +151 -0
- package/dist/components/ThinkRoutineLibrary.d.ts +74 -0
- package/dist/components/ThinkRoutineLibrary.js +178 -0
- package/dist/components/ThinkRoutineRuns.d.ts +24 -0
- package/dist/components/ThinkRoutineRuns.js +68 -0
- package/dist/components/ThinkThreadPicker.d.ts +18 -1
- package/dist/components/ThinkThreadPicker.js +51 -5
- package/dist/components/ThinkThreadShell.d.ts +12 -9
- package/dist/components/ThinkThreadShell.js +17 -137
- package/dist/components/Toggle.d.ts +1 -68
- package/dist/components/ToggleGroup.d.ts +1 -72
- package/dist/components/Tooltip.d.ts +3 -1
- package/dist/components/Tooltip.js +4 -2
- package/dist/components/WebPreview.js +1 -1
- package/dist/components/Workspace.d.ts +2 -0
- package/dist/components/Workspace.js +424 -0
- package/dist/components/WorkspaceBrowser.d.ts +32 -0
- package/dist/components/WorkspaceBrowser.js +103 -0
- package/dist/components/WorkspaceExplorer.d.ts +12 -79
- package/dist/components/WorkspaceExplorer.js +116 -330
- package/dist/components/WorkspaceFile.d.ts +2 -0
- package/dist/components/WorkspaceFile.js +195 -0
- package/dist/components/WorkspaceFileView.d.ts +26 -0
- package/dist/components/WorkspaceFileView.js +2 -0
- package/dist/components/WorkspaceHeader.d.ts +35 -0
- package/dist/components/WorkspaceHeader.js +51 -0
- package/dist/components/WorkspaceLink.d.ts +2 -0
- package/dist/components/WorkspaceLink.js +2 -0
- package/dist/components/icons.d.ts +2 -2
- package/dist/components/icons.js +2 -2
- package/dist/{copy-button-DUMLYdsk.js → copy-button-Dejn5heL.js} +1 -1
- package/dist/icons-CpfUer49.js +85 -0
- package/dist/{icons-CUCz_Sft.d.ts → icons-GQd1xF4e.d.ts} +51 -1
- package/dist/styles/activity-header.css +75 -0
- package/dist/styles/activity.css +49 -63
- package/dist/styles/agent-activity-preview-overlay.css +80 -0
- package/dist/styles/agent-activity-preview.css +233 -0
- package/dist/styles/agent-attention.css +128 -0
- package/dist/styles/agent-chat.css +133 -4
- package/dist/styles/agent-connection.css +9 -9
- package/dist/styles/alert-dialog.css +11 -11
- package/dist/styles/app-frame.css +15 -0
- package/dist/styles/app-top-bar.css +102 -0
- package/dist/styles/avatar.css +0 -1
- package/dist/styles/browser-control-overlay.css +184 -0
- package/dist/styles/card.css +29 -8
- package/dist/styles/chain-of-thought.css +5 -5
- package/dist/styles/checkbox-group.css +69 -0
- package/dist/styles/codex-model-selector.css +3 -3
- package/dist/styles/combobox.css +2 -1
- package/dist/styles/context-menu.css +1 -1
- package/dist/styles/description-list.css +50 -0
- package/dist/styles/dialog.css +11 -11
- package/dist/styles/field.css +14 -14
- package/dist/styles/fieldset.css +15 -4
- package/dist/styles/index.css +14 -2
- package/dist/styles/mcp-connection-request.css +60 -0
- package/dist/styles/mcp-server-picker.css +96 -68
- package/dist/styles/menu.css +1 -1
- package/dist/styles/message.css +4 -43
- package/dist/styles/model-selector.css +18 -12
- package/dist/styles/popover.css +9 -9
- package/dist/styles/preview-card.css +1 -1
- package/dist/styles/pricing-page.css +21 -27
- package/dist/styles/prompt-input.css +225 -32
- package/dist/styles/reasoning.css +1 -55
- package/dist/styles/recipes.css +50 -24
- package/dist/styles/resizable-side-panel.css +66 -0
- package/dist/styles/responsive-sidebar-shell.css +169 -0
- package/dist/styles/select.css +13 -3
- package/dist/styles/sources.css +6 -6
- package/dist/styles/stepper.css +13 -0
- package/dist/styles/streamdown.css +0 -4
- package/dist/styles/subagent-run.css +59 -42
- package/dist/styles/task.css +17 -10
- package/dist/styles/test-results.css +17 -10
- package/dist/styles/textarea.css +20 -0
- package/dist/styles/theme-mode-control.css +72 -0
- package/dist/styles/think-execution-status.css +49 -0
- package/dist/styles/think-execution-workbench.css +16 -80
- package/dist/styles/think-full-app.css +143 -128
- package/dist/styles/think-routine-library.css +491 -0
- package/dist/styles/think-thread-picker.css +47 -3
- package/dist/styles/toast.css +6 -6
- package/dist/styles/toggle-group.css +7 -0
- package/dist/styles/tooltip.css +1 -1
- package/dist/styles/workspace-explorer.css +516 -64
- package/dist/utils/mcp-server-catalog.d.ts +82 -78
- package/dist/utils/mcp-server-catalog.js +64 -41
- package/dist/utils/structured-code.d.ts +1 -1
- package/dist/utils/theme.d.ts +22 -0
- package/dist/utils/theme.js +55 -0
- package/package.json +34 -28
- package/dist/icons-Ba9THQKz.js +0 -64
- package/dist/styles/think-resize-handle.css +0 -33
- package/dist/styles/think-thread-shell.css +0 -219
|
@@ -1,325 +1,16 @@
|
|
|
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
1
|
import { Activity, ActivityContent, ActivityItem, ActivityItemGroup, ActivityText, ActivityTrigger } from "./Activity.js";
|
|
3
|
-
import {
|
|
2
|
+
import { AgentActivityFavicon, AgentActivityIcon } from "./AgentActivity.js";
|
|
3
|
+
import { isBrowserToolPart, isExecuteToolPart, isFetchToolPart, isPartWorking, isSessionContextToolPart, isSkillToolPart, isThinkChatActivityPart, isWorkspaceToolPart } from "./ThinkChatToolParts.js";
|
|
4
4
|
import { useOptionalThinkChatContext } from "./ThinkChatContext.js";
|
|
5
|
-
import { displayUrl, isBrowserToolPart, isExecuteToolPart, isFetchToolPart, isPartFailed, isPartWorking, isSessionContextToolFailure, isSessionContextToolPart, isSkillToolPart, isThinkChatActivityPart, isWorkspaceToolPart } from "./ThinkChatToolParts.js";
|
|
6
5
|
import { ThinkChatBrowserPanel, ThinkChatExecutePanel, ThinkChatFetchPanel, ThinkChatSessionContextPanel, ThinkChatSkillPanel, ThinkChatWorkspacePanel } from "./ThinkChatToolPanels.js";
|
|
7
|
-
import
|
|
6
|
+
import { activityPartIconKind, activityPartUrl, deriveThinkChatActivityHeader, describeThinkChatActivityPart } from "./ThinkChatActivitySummary.js";
|
|
7
|
+
import "react";
|
|
8
8
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
-
import { getToolInput, getToolOutput } from "@cloudflare/think/react";
|
|
10
9
|
import { getToolName, isReasoningUIPart, isToolUIPart } from "ai";
|
|
11
10
|
//#region src/components/ThinkChatActivity.tsx
|
|
12
|
-
const HTTP_URL_PATTERN = /https?:\/\/[^\s"'<>)}\]]+/i;
|
|
13
|
-
function firstHttpUrl(value) {
|
|
14
|
-
const text = typeof value === "string" ? value : JSON.stringify(value) ?? "";
|
|
15
|
-
const raw = HTTP_URL_PATTERN.exec(text)?.[0]?.replace(/[.,;:!?]+$/, "");
|
|
16
|
-
if (!raw) return null;
|
|
17
|
-
try {
|
|
18
|
-
return new URL(raw).href;
|
|
19
|
-
} catch {
|
|
20
|
-
return null;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
function ActivityFavicon({ url }) {
|
|
24
|
-
const src = faviconHref(url);
|
|
25
|
-
const [failed, setFailed] = React.useState(false);
|
|
26
|
-
React.useEffect(() => setFailed(false), [src]);
|
|
27
|
-
if (!src || failed) return /* @__PURE__ */ jsx(LinkIcon, {});
|
|
28
|
-
return /* @__PURE__ */ jsx("img", {
|
|
29
|
-
className: "activity__favicon",
|
|
30
|
-
src,
|
|
31
|
-
alt: "",
|
|
32
|
-
loading: "lazy",
|
|
33
|
-
decoding: "async",
|
|
34
|
-
onError: () => setFailed(true)
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
function faviconHref(url) {
|
|
38
|
-
try {
|
|
39
|
-
return new URL("/favicon.ico", url).href;
|
|
40
|
-
} catch {
|
|
41
|
-
return null;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
function ActivityKindIcon({ kind }) {
|
|
45
|
-
switch (kind) {
|
|
46
|
-
case "thought": return /* @__PURE__ */ jsx(InfoIcon, {});
|
|
47
|
-
case "read": return /* @__PURE__ */ jsx(FileIcon, {});
|
|
48
|
-
case "edit": return /* @__PURE__ */ jsx(PencilIcon, {});
|
|
49
|
-
case "search": return /* @__PURE__ */ jsx(SearchIcon, {});
|
|
50
|
-
case "web": return /* @__PURE__ */ jsx(LinkIcon, {});
|
|
51
|
-
case "command": return /* @__PURE__ */ jsx(TerminalIcon, {});
|
|
52
|
-
case "browser": return /* @__PURE__ */ jsx(MonitorIcon, {});
|
|
53
|
-
case "tool": return /* @__PURE__ */ jsx(WrenchIcon, {});
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
function genericToolLabels(name, hasUrl) {
|
|
57
|
-
const normalized = name.toLowerCase();
|
|
58
|
-
if (normalized.includes("grep") || normalized.includes("find") || normalized.includes("code")) return {
|
|
59
|
-
working: "Searching code",
|
|
60
|
-
done: "Searched code",
|
|
61
|
-
failed: "Code search failed",
|
|
62
|
-
summary: "searched code",
|
|
63
|
-
icon: "search"
|
|
64
|
-
};
|
|
65
|
-
if (normalized.includes("search") || normalized.includes("web") || normalized.includes("browser") || normalized.includes("google")) return {
|
|
66
|
-
working: "Searching the web",
|
|
67
|
-
done: "Searched the web",
|
|
68
|
-
failed: "Web search failed",
|
|
69
|
-
summary: "searched the web",
|
|
70
|
-
icon: "web"
|
|
71
|
-
};
|
|
72
|
-
if (hasUrl || normalized.includes("fetch") || normalized.includes("http") || normalized.includes("url")) return {
|
|
73
|
-
working: "Reading a URL",
|
|
74
|
-
done: "Read a URL",
|
|
75
|
-
failed: "URL read failed",
|
|
76
|
-
summary: "read a URL",
|
|
77
|
-
icon: "web"
|
|
78
|
-
};
|
|
79
|
-
if (normalized.includes("edit") || normalized.includes("write") || normalized.includes("delete") || normalized.includes("patch") || normalized.includes("apply") || normalized.includes("create") || normalized.includes("update")) return {
|
|
80
|
-
working: "Editing files",
|
|
81
|
-
done: "Edited files",
|
|
82
|
-
failed: "Edit failed",
|
|
83
|
-
summary: "edited files",
|
|
84
|
-
icon: "edit"
|
|
85
|
-
};
|
|
86
|
-
if (normalized.includes("exec") || normalized.includes("bash") || normalized.includes("shell") || normalized.includes("terminal") || normalized.includes("command")) return {
|
|
87
|
-
working: "Running a command",
|
|
88
|
-
done: "Ran a command",
|
|
89
|
-
failed: "Command failed",
|
|
90
|
-
summary: "ran a command",
|
|
91
|
-
icon: "command"
|
|
92
|
-
};
|
|
93
|
-
if (normalized.includes("read") || normalized.includes("open") || normalized.includes("list") || normalized.includes("file")) return {
|
|
94
|
-
working: "Reading files",
|
|
95
|
-
done: "Read files",
|
|
96
|
-
failed: "Read failed",
|
|
97
|
-
summary: "read files",
|
|
98
|
-
icon: "read"
|
|
99
|
-
};
|
|
100
|
-
return {
|
|
101
|
-
working: "Using a tool",
|
|
102
|
-
done: "Used a tool",
|
|
103
|
-
failed: "Tool failed",
|
|
104
|
-
summary: "used a tool",
|
|
105
|
-
icon: "tool"
|
|
106
|
-
};
|
|
107
|
-
}
|
|
108
|
-
function describeGenericToolPart(part) {
|
|
109
|
-
const labels = genericToolLabels(getToolName(part), activityPartUrl(part) !== null);
|
|
110
|
-
const label = isPartFailed(part) ? labels.failed : isPartWorking(part) ? labels.working : labels.done;
|
|
111
|
-
const detail = summarizeToolInput(getToolInput(part));
|
|
112
|
-
return detail ? `${label} · ${detail}` : label;
|
|
113
|
-
}
|
|
114
|
-
function activityPartUrl(part) {
|
|
115
|
-
if (isFetchToolPart(part)) return firstHttpUrl(part.input?.url ?? part.input?.path);
|
|
116
|
-
if (isBrowserToolPart(part) && part.type !== "tool-browser_execute") return firstHttpUrl(part.input?.url);
|
|
117
|
-
if (isToolUIPart(part) && !isExecuteToolPart(part)) return firstHttpUrl(getToolInput(part)) ?? (part.state === "output-available" ? firstHttpUrl(getToolOutput(part)) : null);
|
|
118
|
-
return null;
|
|
119
|
-
}
|
|
120
|
-
function activityPartIconKind(part) {
|
|
121
|
-
if (isReasoningUIPart(part)) return "thought";
|
|
122
|
-
if (isWorkspaceToolPart(part)) switch (part.type) {
|
|
123
|
-
case "tool-read":
|
|
124
|
-
case "tool-list": return "read";
|
|
125
|
-
case "tool-write":
|
|
126
|
-
case "tool-edit":
|
|
127
|
-
case "tool-delete": return "edit";
|
|
128
|
-
case "tool-find":
|
|
129
|
-
case "tool-grep": return "search";
|
|
130
|
-
case "tool-bash": return "command";
|
|
131
|
-
}
|
|
132
|
-
if (isSkillToolPart(part)) return "tool";
|
|
133
|
-
if (isSessionContextToolPart(part)) return part.type === "tool-search_context" || part.type === "tool-session_search" ? "search" : "tool";
|
|
134
|
-
if (isFetchToolPart(part)) return "web";
|
|
135
|
-
if (isBrowserToolPart(part)) return part.type === "tool-browser_execute" ? "browser" : "web";
|
|
136
|
-
if (isExecuteToolPart(part)) return "command";
|
|
137
|
-
if (isToolUIPart(part)) return genericToolLabels(getToolName(part), activityPartUrl(part) !== null).icon;
|
|
138
|
-
return "tool";
|
|
139
|
-
}
|
|
140
11
|
function activityPartIcon(part) {
|
|
141
12
|
const url = activityPartUrl(part);
|
|
142
|
-
return url ? /* @__PURE__ */ jsx(
|
|
143
|
-
}
|
|
144
|
-
function activitySummaryIcon(parts) {
|
|
145
|
-
if (parts.find((part) => isToolUIPart(part) && isPartFailed(part))) return /* @__PURE__ */ jsx(WarningIcon, {});
|
|
146
|
-
const representative = parts.find((part) => activityPartIconKind(part) === "edit") ?? parts.find((part) => activityPartUrl(part)) ?? parts.find((part) => describeThinkChatActivityPart(part));
|
|
147
|
-
return representative ? activityPartIcon(representative) : /* @__PURE__ */ jsx(ActivityKindIcon, { kind: "tool" });
|
|
148
|
-
}
|
|
149
|
-
/**
|
|
150
|
-
* One-line natural-language label for an activity part ("Ran vp test",
|
|
151
|
-
* "Fetched developers.cloudflare.com/agents/"); `null` for boundaries that
|
|
152
|
-
* aren't steps (step-start). Exported so a custom `renderPart` can reuse the
|
|
153
|
-
* built-in labels for tools it doesn't override.
|
|
154
|
-
*/
|
|
155
|
-
function describeThinkChatActivityPart(part, toolRenderers) {
|
|
156
|
-
if (isToolUIPart(part)) {
|
|
157
|
-
const custom = toolRenderers?.[getToolName(part)]?.describe?.(part);
|
|
158
|
-
if (custom !== void 0) return custom;
|
|
159
|
-
}
|
|
160
|
-
if (isReasoningUIPart(part)) {
|
|
161
|
-
const snippet = summarizeToolInput({ text: part.text });
|
|
162
|
-
const label = part.state === "streaming" ? "Thinking…" : "Thought";
|
|
163
|
-
return snippet ? `${label} · ${snippet}` : label;
|
|
164
|
-
}
|
|
165
|
-
if (isWorkspaceToolPart(part)) return describeWorkspaceToolPart(part);
|
|
166
|
-
if (isSkillToolPart(part)) return describeSkillToolPart(part);
|
|
167
|
-
if (isSessionContextToolPart(part)) return describeSessionContextToolPart(part);
|
|
168
|
-
if (isFetchToolPart(part)) return describeFetchToolPart(part);
|
|
169
|
-
if (isBrowserToolPart(part)) return describeBrowserToolPart(part);
|
|
170
|
-
if (isExecuteToolPart(part)) return describeExecuteToolPart(part);
|
|
171
|
-
if (isToolUIPart(part)) return describeGenericToolPart(part);
|
|
172
|
-
return null;
|
|
173
|
-
}
|
|
174
|
-
function basename(path) {
|
|
175
|
-
return path?.split("/").filter(Boolean).at(-1) ?? null;
|
|
176
|
-
}
|
|
177
|
-
function describeWorkspaceToolPart(part) {
|
|
178
|
-
const working = isPartWorking(part);
|
|
179
|
-
const failed = isPartFailed(part);
|
|
180
|
-
if (part.type === "tool-bash") {
|
|
181
|
-
const command = part.input?.script?.trim() ?? "";
|
|
182
|
-
if (failed) return command ? `Command failed · ${command}` : "Command failed";
|
|
183
|
-
const verb = working ? "Running" : "Ran";
|
|
184
|
-
return command ? `${verb} ${command}` : `${verb} a command`;
|
|
185
|
-
}
|
|
186
|
-
const label = (() => {
|
|
187
|
-
switch (part.type) {
|
|
188
|
-
case "tool-read": return `${working ? "Reading" : "Read"} ${basename(part.input?.path) ?? "a file"}`;
|
|
189
|
-
case "tool-write": return `${working ? "Writing" : "Wrote"} ${basename(part.input?.path) ?? "a file"}`;
|
|
190
|
-
case "tool-edit": return `${working ? "Editing" : "Edited"} ${basename(part.input?.path) ?? "a file"}`;
|
|
191
|
-
case "tool-delete": return `${working ? "Deleting" : "Deleted"} ${part.input?.path || "a file"}`;
|
|
192
|
-
case "tool-list": {
|
|
193
|
-
const path = part.input?.path;
|
|
194
|
-
return `${working ? "Listing" : "Listed"} ${path && path !== "/" ? path : "files"}`;
|
|
195
|
-
}
|
|
196
|
-
case "tool-find": return `${working ? "Searching" : "Searched"} for ${part.input?.pattern || "files"}`;
|
|
197
|
-
case "tool-grep": return `${working ? "Searching" : "Searched"} for ${part.input?.query || "text"}`;
|
|
198
|
-
}
|
|
199
|
-
})();
|
|
200
|
-
return failed ? `${label} · failed` : label;
|
|
201
|
-
}
|
|
202
|
-
function describeSkillToolPart(part) {
|
|
203
|
-
const working = isPartWorking(part);
|
|
204
|
-
const failed = isPartFailed(part);
|
|
205
|
-
const label = (() => {
|
|
206
|
-
switch (part.type) {
|
|
207
|
-
case "tool-activate_skill": {
|
|
208
|
-
const name = part.input?.name;
|
|
209
|
-
return `${working ? "Using" : "Used"} ${name ? `the ${name} skill` : "a skill"}`;
|
|
210
|
-
}
|
|
211
|
-
case "tool-read_skill_resource": return `${working ? "Reading" : "Read"} ${part.input?.path ?? "a skill resource"}`;
|
|
212
|
-
case "tool-run_skill_script": return `${working ? "Running" : "Ran"} ${part.input?.path ?? "a skill script"}`;
|
|
213
|
-
}
|
|
214
|
-
})();
|
|
215
|
-
return failed ? `${label} · failed` : label;
|
|
216
|
-
}
|
|
217
|
-
function describeSessionContextToolPart(part) {
|
|
218
|
-
const working = isPartWorking(part);
|
|
219
|
-
const failed = isSessionContextToolFailure(part);
|
|
220
|
-
const label = (() => {
|
|
221
|
-
switch (part.type) {
|
|
222
|
-
case "tool-set_context": {
|
|
223
|
-
const target = part.input?.label ? ` ${part.input.label}` : " context";
|
|
224
|
-
return `${working ? "Updating" : "Updated"}${target}`;
|
|
225
|
-
}
|
|
226
|
-
case "tool-load_context": return `${working ? "Loading" : "Loaded"} ${part.input?.key ?? "context"}`;
|
|
227
|
-
case "tool-unload_context": return `${working ? "Unloading" : "Unloaded"} ${part.input?.key ?? "context"}`;
|
|
228
|
-
case "tool-search_context": return `${working ? "Searching" : "Searched"} ${part.input?.label ?? "context"}`;
|
|
229
|
-
case "tool-session_search": return `${working ? "Searching" : "Searched"} conversations`;
|
|
230
|
-
}
|
|
231
|
-
})();
|
|
232
|
-
return failed ? `${label} · failed` : label;
|
|
233
|
-
}
|
|
234
|
-
function describeBrowserToolPart(part) {
|
|
235
|
-
const working = isPartWorking(part);
|
|
236
|
-
const failed = isPartFailed(part);
|
|
237
|
-
if (part.type === "tool-browser_execute") {
|
|
238
|
-
const output = part.state === "output-available" ? part.output : void 0;
|
|
239
|
-
if (failed || output?.status === "error") return "Browser automation failed";
|
|
240
|
-
if (output?.status === "paused") return "Browser waiting for approval";
|
|
241
|
-
return working ? "Using the browser" : "Used the browser";
|
|
242
|
-
}
|
|
243
|
-
const page = displayUrl(part.input?.url) || "a page";
|
|
244
|
-
const label = (() => {
|
|
245
|
-
switch (part.type) {
|
|
246
|
-
case "tool-browser_extract": return `${working ? "Extracting" : "Extracted"} data from ${page}`;
|
|
247
|
-
case "tool-browser_links": return `${working ? "Listing" : "Listed"} links on ${page}`;
|
|
248
|
-
case "tool-browser_scrape": return `${working ? "Scraping" : "Scraped"} ${page}`;
|
|
249
|
-
default: return `${working ? "Browsing" : "Browsed"} ${page}`;
|
|
250
|
-
}
|
|
251
|
-
})();
|
|
252
|
-
return failed ? `${label} · failed` : label;
|
|
253
|
-
}
|
|
254
|
-
function describeExecuteToolPart(part) {
|
|
255
|
-
const output = part.state === "output-available" ? part.output : void 0;
|
|
256
|
-
if (isPartFailed(part) || output?.status === "error") return "Code failed";
|
|
257
|
-
if (output?.status === "paused") return "Code waiting for approval";
|
|
258
|
-
const label = isPartWorking(part) ? "Running code" : "Ran code";
|
|
259
|
-
const snippet = summarizeToolInput(part.input);
|
|
260
|
-
return snippet ? `${label} · ${snippet}` : label;
|
|
261
|
-
}
|
|
262
|
-
function describeFetchToolPart(part) {
|
|
263
|
-
const target = part.input?.url ?? part.input?.path ?? "";
|
|
264
|
-
const output = part.state === "output-available" ? part.output : void 0;
|
|
265
|
-
if (isPartFailed(part) || output?.ok === false) return target ? `Fetch failed · ${target}` : "Fetch failed";
|
|
266
|
-
const verb = isPartWorking(part) ? "Fetching" : "Fetched";
|
|
267
|
-
return target ? `${verb} ${target}` : `${verb} a URL`;
|
|
268
|
-
}
|
|
269
|
-
function summarizeActivitySteps(parts) {
|
|
270
|
-
const byTool = /* @__PURE__ */ new Map();
|
|
271
|
-
const genericSegments = /* @__PURE__ */ new Set();
|
|
272
|
-
const skillNames = /* @__PURE__ */ new Set();
|
|
273
|
-
let thoughts = 0;
|
|
274
|
-
let skillParts = 0;
|
|
275
|
-
const sessionSegments = /* @__PURE__ */ new Set();
|
|
276
|
-
let fetches = 0;
|
|
277
|
-
let browses = 0;
|
|
278
|
-
let codeRuns = 0;
|
|
279
|
-
for (const part of parts) if (isReasoningUIPart(part)) thoughts++;
|
|
280
|
-
else if (isWorkspaceToolPart(part)) {
|
|
281
|
-
const name = getToolName(part);
|
|
282
|
-
byTool.set(name, (byTool.get(name) ?? 0) + 1);
|
|
283
|
-
} else if (isSkillToolPart(part)) {
|
|
284
|
-
skillParts++;
|
|
285
|
-
if (typeof part.input?.name === "string") skillNames.add(part.input.name);
|
|
286
|
-
} else if (isSessionContextToolPart(part)) sessionSegments.add(part.type === "tool-search_context" || part.type === "tool-session_search" ? "searched context" : "updated context");
|
|
287
|
-
else if (isFetchToolPart(part)) fetches++;
|
|
288
|
-
else if (isBrowserToolPart(part)) browses++;
|
|
289
|
-
else if (isExecuteToolPart(part)) codeRuns++;
|
|
290
|
-
else if (isToolUIPart(part)) genericSegments.add(genericToolLabels(getToolName(part), activityPartUrl(part) !== null).summary);
|
|
291
|
-
const count = (name) => byTool.get(name) ?? 0;
|
|
292
|
-
const files = (n) => n === 1 ? "a file" : `${n} files`;
|
|
293
|
-
const reads = count("read");
|
|
294
|
-
const edits = count("edit") + count("write");
|
|
295
|
-
const deletes = count("delete");
|
|
296
|
-
const commands = count("bash");
|
|
297
|
-
const segments = [];
|
|
298
|
-
if (thoughts > 0) segments.push("thought");
|
|
299
|
-
if (skillParts > 0) segments.push(skillNames.size === 1 ? `used the ${[...skillNames][0]} skill` : skillNames.size > 1 ? `used ${skillNames.size} skills` : "used a skill");
|
|
300
|
-
for (const segment of ["updated context", "searched context"]) if (sessionSegments.has(segment)) segments.push(segment);
|
|
301
|
-
if (reads > 0) segments.push(`read ${files(reads)}`);
|
|
302
|
-
if (edits > 0) segments.push(`edited ${files(edits)}`);
|
|
303
|
-
if (deletes > 0) segments.push(`deleted ${files(deletes)}`);
|
|
304
|
-
if (count("find") + count("grep") > 0) segments.push("searched code");
|
|
305
|
-
if (count("list") > 0) segments.push("listed files");
|
|
306
|
-
if (fetches > 0) segments.push(fetches === 1 ? "fetched a URL" : `fetched ${fetches} URLs`);
|
|
307
|
-
if (browses > 0) segments.push("used the browser");
|
|
308
|
-
if (codeRuns > 0) segments.push("ran code");
|
|
309
|
-
if (commands > 0) segments.push(commands === 1 ? "ran a command" : `ran ${commands} commands`);
|
|
310
|
-
for (const segment of [
|
|
311
|
-
"edited files",
|
|
312
|
-
"searched code",
|
|
313
|
-
"searched the web",
|
|
314
|
-
"read a URL",
|
|
315
|
-
"ran a command",
|
|
316
|
-
"read files",
|
|
317
|
-
"used a tool"
|
|
318
|
-
]) if (genericSegments.has(segment)) segments.push(segment);
|
|
319
|
-
if (segments.length === 0) return "Worked";
|
|
320
|
-
const top = segments.slice(0, 3);
|
|
321
|
-
const joined = top.length === 1 ? top[0] : `${top.slice(0, -1).join(", ")} and ${top.at(-1)}`;
|
|
322
|
-
return joined.charAt(0).toUpperCase() + joined.slice(1);
|
|
13
|
+
return url ? /* @__PURE__ */ jsx(AgentActivityFavicon, { url }) : /* @__PURE__ */ jsx(AgentActivityIcon, { kind: activityPartIconKind(part) });
|
|
323
14
|
}
|
|
324
15
|
/**
|
|
325
16
|
* One run of agent work as a collapsed Activity block: while streaming the
|
|
@@ -340,14 +31,17 @@ function ThinkChatActivity({ parts, defaultOpen, isStreaming, toolRenderers }) {
|
|
|
340
31
|
});
|
|
341
32
|
if (steps.length === 0) return null;
|
|
342
33
|
const streaming = isStreaming ?? parts.some(isPartWorking);
|
|
343
|
-
const
|
|
344
|
-
|
|
34
|
+
const header = deriveThinkChatActivityHeader(parts, {
|
|
35
|
+
isStreaming: streaming,
|
|
36
|
+
toolDescribers: toolRenderers
|
|
37
|
+
});
|
|
38
|
+
if (!header) return null;
|
|
345
39
|
return /* @__PURE__ */ jsxs(Activity, {
|
|
346
40
|
isStreaming: streaming,
|
|
347
41
|
defaultOpen,
|
|
348
42
|
children: [/* @__PURE__ */ jsx(ActivityTrigger, {
|
|
349
|
-
icon:
|
|
350
|
-
label:
|
|
43
|
+
icon: header.url ? /* @__PURE__ */ jsx(AgentActivityFavicon, { url: header.url }) : /* @__PURE__ */ jsx(AgentActivityIcon, { kind: header.iconKind }),
|
|
44
|
+
label: header.label
|
|
351
45
|
}), /* @__PURE__ */ jsx(ActivityContent, { children: steps.map((step) => /* @__PURE__ */ jsx(ThinkChatActivityStep, {
|
|
352
46
|
text: step.text,
|
|
353
47
|
part: step.part,
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { a as activityPartIconKind, c as deriveThinkChatToolLifecycleHeader, i as ThinkChatToolLifecycleSnapshot, l as describeThinkChatActivityPart, n as ThinkChatToolDescriber, o as activityPartUrl, r as ThinkChatToolDescribers, s as deriveThinkChatActivityHeader, t as ThinkChatActivityHeader, u as summarizeActivitySteps } from "../ThinkChatActivitySummary-BPmu9a-c.js";
|
|
2
|
+
export { ThinkChatActivityHeader, ThinkChatToolDescriber, ThinkChatToolDescribers, ThinkChatToolLifecycleSnapshot, activityPartIconKind, activityPartUrl, deriveThinkChatActivityHeader, deriveThinkChatToolLifecycleHeader, describeThinkChatActivityPart, summarizeActivitySteps };
|