@mcp-b/react-components 0.14.1 → 0.16.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/AgentActivity-BNUNrP9O.d.ts +36 -0
- package/dist/{AgentChat-Cgb1xuT7.d.ts → AgentChat-CrlpbvQJ.d.ts} +62 -8
- 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-DVgVBdvw.js → ModelSelector-SlJNgwKY.js} +17 -8
- 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-7DQ2CogF.js → ThinkChat-CzC-zNGA.js} +27 -37
- package/dist/{ThinkChatActivity-m9orbdeI.d.ts → ThinkChatActivity-BFQnb2ct.d.ts} +3 -10
- package/dist/ThinkChatActivitySummary-BPmu9a-c.d.ts +39 -0
- package/dist/{ThinkChatToolParts-Cv4o7j6F.d.ts → ThinkChatToolParts-CSzVwMXf.d.ts} +62 -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 +231 -205
- 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.d.ts +15 -3
- package/dist/components/ModelSelector.js +1 -1
- package/dist/components/NaniteScene.d.ts +10 -1
- package/dist/components/NaniteScene.js +36 -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 +86 -0
- package/dist/components/SubagentRun.js +108 -0
- package/dist/components/SubagentRunDetails.d.ts +44 -0
- package/dist/components/SubagentRunDetails.js +48 -0
- 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 +34 -7
- package/dist/components/ThinkChat.js +7 -4
- package/dist/components/ThinkChatActivity.d.ts +3 -2
- package/dist/components/ThinkChatActivity.js +18 -297
- package/dist/components/ThinkChatActivitySummary.d.ts +2 -0
- package/dist/components/ThinkChatActivitySummary.js +421 -0
- package/dist/components/ThinkChatToolPanels.d.ts +15 -5
- package/dist/components/ThinkChatToolPanels.js +116 -9
- package/dist/components/ThinkChatToolParts.d.ts +2 -2
- package/dist/components/ThinkChatToolParts.js +51 -9
- 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 +129 -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 +235 -0
- package/dist/styles/agent-attention.css +122 -0
- package/dist/styles/agent-chat.css +141 -4
- package/dist/styles/app-frame.css +15 -0
- package/dist/styles/app-top-bar.css +100 -0
- package/dist/styles/avatar.css +0 -1
- package/dist/styles/browser-control-overlay.css +184 -0
- package/dist/styles/card.css +21 -0
- package/dist/styles/checkbox-group.css +69 -0
- package/dist/styles/description-list.css +50 -0
- package/dist/styles/fieldset.css +11 -0
- package/dist/styles/index.css +15 -2
- package/dist/styles/mcp-connection-request.css +60 -0
- package/dist/styles/mcp-server-picker.css +95 -68
- package/dist/styles/message.css +4 -43
- package/dist/styles/nanite-scene.css +16 -0
- 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 +23 -15
- package/dist/styles/resizable-side-panel.css +66 -0
- package/dist/styles/responsive-sidebar-shell.css +169 -0
- package/dist/styles/select.css +10 -0
- package/dist/styles/stepper.css +13 -0
- package/dist/styles/streamdown.css +0 -4
- package/dist/styles/subagent-run.css +205 -0
- 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 +8 -72
- package/dist/styles/think-full-app.css +106 -131
- package/dist/styles/think-routine-library.css +491 -0
- package/dist/styles/think-thread-picker.css +47 -3
- package/dist/styles/toggle-group.css +7 -0
- package/dist/styles/workspace-explorer.css +511 -64
- package/dist/utils/codex-model-catalog.d.ts +4 -4
- 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
|
@@ -0,0 +1,421 @@
|
|
|
1
|
+
import { displayUrl, getToolDisplayName, isBrowserToolPart, isExecuteToolPart, isFetchToolPart, isPartFailed, isPartWorking, isSessionContextToolFailure, isSessionContextToolPart, isSkillToolPart, isWorkspaceToolPart } from "./ThinkChatToolParts.js";
|
|
2
|
+
import { t as summarizeToolInput } from "../summarize-tool-input-BUJsENSn.js";
|
|
3
|
+
import { getToolName, isReasoningUIPart, isToolUIPart } from "ai";
|
|
4
|
+
//#region src/components/ThinkChatActivitySummary.ts
|
|
5
|
+
const ACTIVITY_HEADER_LABEL_MAX_LENGTH = 240;
|
|
6
|
+
function boundedActivityHeader(header) {
|
|
7
|
+
if (header.label.length <= ACTIVITY_HEADER_LABEL_MAX_LENGTH) return header;
|
|
8
|
+
return {
|
|
9
|
+
...header,
|
|
10
|
+
label: `${header.label.slice(0, ACTIVITY_HEADER_LABEL_MAX_LENGTH - 1).trimEnd()}…`
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
function getToolInput(part) {
|
|
14
|
+
return part.input;
|
|
15
|
+
}
|
|
16
|
+
function getToolOutput(part) {
|
|
17
|
+
return part.state === "output-available" ? part.output : void 0;
|
|
18
|
+
}
|
|
19
|
+
const HTTP_URL_PATTERN = /https?:\/\/[^\s"'<>)}\]]+/i;
|
|
20
|
+
function firstHttpUrl(value) {
|
|
21
|
+
let text;
|
|
22
|
+
if (typeof value === "string") text = value;
|
|
23
|
+
else try {
|
|
24
|
+
text = JSON.stringify(value) ?? "";
|
|
25
|
+
} catch {
|
|
26
|
+
text = "";
|
|
27
|
+
}
|
|
28
|
+
const raw = HTTP_URL_PATTERN.exec(text)?.[0]?.replace(/[.,;:!?]+$/, "");
|
|
29
|
+
if (!raw) return null;
|
|
30
|
+
try {
|
|
31
|
+
return new URL(raw).origin;
|
|
32
|
+
} catch {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
function genericToolLabels(name, hasUrl) {
|
|
37
|
+
const normalized = name.toLowerCase();
|
|
38
|
+
if (normalized.includes("grep") || normalized.includes("find") || normalized.includes("code")) return {
|
|
39
|
+
working: "Searching code",
|
|
40
|
+
done: "Searched code",
|
|
41
|
+
failed: "Code search failed",
|
|
42
|
+
summary: "searched code",
|
|
43
|
+
icon: "search"
|
|
44
|
+
};
|
|
45
|
+
if (normalized.includes("search") || normalized.includes("web") || normalized.includes("browser") || normalized.includes("google")) return {
|
|
46
|
+
working: "Searching the web",
|
|
47
|
+
done: "Searched the web",
|
|
48
|
+
failed: "Web search failed",
|
|
49
|
+
summary: "searched the web",
|
|
50
|
+
icon: "web"
|
|
51
|
+
};
|
|
52
|
+
if (hasUrl || normalized.includes("fetch") || normalized.includes("http") || normalized.includes("url")) return {
|
|
53
|
+
working: "Reading a URL",
|
|
54
|
+
done: "Read a URL",
|
|
55
|
+
failed: "URL read failed",
|
|
56
|
+
summary: "read a URL",
|
|
57
|
+
icon: "web"
|
|
58
|
+
};
|
|
59
|
+
if (normalized.includes("edit") || normalized.includes("write") || normalized.includes("delete") || normalized.includes("patch") || normalized.includes("apply") || normalized.includes("create") || normalized.includes("update")) return {
|
|
60
|
+
working: "Editing files",
|
|
61
|
+
done: "Edited files",
|
|
62
|
+
failed: "Edit failed",
|
|
63
|
+
summary: "edited files",
|
|
64
|
+
icon: "edit"
|
|
65
|
+
};
|
|
66
|
+
if (normalized.includes("exec") || normalized.includes("bash") || normalized.includes("shell") || normalized.includes("terminal") || normalized.includes("command")) return {
|
|
67
|
+
working: "Running a command",
|
|
68
|
+
done: "Ran a command",
|
|
69
|
+
failed: "Command failed",
|
|
70
|
+
summary: "ran a command",
|
|
71
|
+
icon: "command"
|
|
72
|
+
};
|
|
73
|
+
if (normalized.includes("read") || normalized.includes("open") || normalized.includes("list") || normalized.includes("file")) return {
|
|
74
|
+
working: "Reading files",
|
|
75
|
+
done: "Read files",
|
|
76
|
+
failed: "Read failed",
|
|
77
|
+
summary: "read files",
|
|
78
|
+
icon: "read"
|
|
79
|
+
};
|
|
80
|
+
return {
|
|
81
|
+
working: "Using a tool",
|
|
82
|
+
done: "Used a tool",
|
|
83
|
+
failed: "Tool failed",
|
|
84
|
+
summary: "used a tool",
|
|
85
|
+
icon: "tool"
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
function genericToolPresentation(part, hasUrl) {
|
|
89
|
+
const labels = genericToolLabels(getToolName(part), hasUrl);
|
|
90
|
+
if (part.title === void 0 && labels.summary !== "used a tool") return labels;
|
|
91
|
+
const displayName = getToolDisplayName(part);
|
|
92
|
+
return {
|
|
93
|
+
...labels,
|
|
94
|
+
working: `Running ${displayName}`,
|
|
95
|
+
done: `Ran ${displayName}`,
|
|
96
|
+
failed: `${displayName} failed`,
|
|
97
|
+
summary: `ran ${displayName}`
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
function describeGenericToolPart(part) {
|
|
101
|
+
const labels = genericToolPresentation(part, activityPartUrl(part) !== null);
|
|
102
|
+
const label = isPartFailed(part) ? labels.failed : isPartWorking(part) ? labels.working : labels.done;
|
|
103
|
+
const detail = summarizeToolInput(getToolInput(part));
|
|
104
|
+
return detail ? `${label} · ${detail}` : label;
|
|
105
|
+
}
|
|
106
|
+
function activityPartUrl(part) {
|
|
107
|
+
if (isFetchToolPart(part)) return firstHttpUrl(part.input?.url ?? part.input?.path);
|
|
108
|
+
if (isBrowserToolPart(part) && part.type !== "tool-browser_execute") return firstHttpUrl(part.input?.url);
|
|
109
|
+
if (isToolUIPart(part) && !isExecuteToolPart(part)) return firstHttpUrl(getToolInput(part)) ?? (part.state === "output-available" ? firstHttpUrl(getToolOutput(part)) : null);
|
|
110
|
+
return null;
|
|
111
|
+
}
|
|
112
|
+
function activityPartIconKind(part) {
|
|
113
|
+
if (isReasoningUIPart(part)) return "thought";
|
|
114
|
+
if (isWorkspaceToolPart(part)) switch (part.type) {
|
|
115
|
+
case "tool-read":
|
|
116
|
+
case "tool-list": return "read";
|
|
117
|
+
case "tool-write":
|
|
118
|
+
case "tool-edit":
|
|
119
|
+
case "tool-delete": return "edit";
|
|
120
|
+
case "tool-find":
|
|
121
|
+
case "tool-grep": return "search";
|
|
122
|
+
case "tool-bash": return "command";
|
|
123
|
+
}
|
|
124
|
+
if (isSkillToolPart(part)) return "tool";
|
|
125
|
+
if (isSessionContextToolPart(part)) return part.type === "tool-search_context" || part.type === "tool-session_search" ? "search" : "tool";
|
|
126
|
+
if (isFetchToolPart(part)) return "web";
|
|
127
|
+
if (isBrowserToolPart(part)) return part.type === "tool-browser_execute" ? "browser" : "web";
|
|
128
|
+
if (isExecuteToolPart(part)) return "command";
|
|
129
|
+
if (isToolUIPart(part)) return genericToolLabels(getToolName(part), activityPartUrl(part) !== null).icon;
|
|
130
|
+
return "tool";
|
|
131
|
+
}
|
|
132
|
+
function activityPartWorkspaceDestination(part) {
|
|
133
|
+
if (!isWorkspaceToolPart(part)) return null;
|
|
134
|
+
switch (part.type) {
|
|
135
|
+
case "tool-read":
|
|
136
|
+
case "tool-write":
|
|
137
|
+
case "tool-edit":
|
|
138
|
+
case "tool-delete": {
|
|
139
|
+
const path = part.input?.path;
|
|
140
|
+
return typeof path === "string" && path.length > 0 ? {
|
|
141
|
+
kind: "file",
|
|
142
|
+
path,
|
|
143
|
+
fragment: null
|
|
144
|
+
} : null;
|
|
145
|
+
}
|
|
146
|
+
case "tool-list":
|
|
147
|
+
case "tool-find":
|
|
148
|
+
case "tool-grep":
|
|
149
|
+
case "tool-bash": return null;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* One-line natural-language label for an activity part ("Ran vp test",
|
|
154
|
+
* "Fetched developers.cloudflare.com/agents/"); `null` for boundaries that
|
|
155
|
+
* aren't steps (step-start). Exported so a custom `renderPart` can reuse the
|
|
156
|
+
* built-in labels for tools it doesn't override.
|
|
157
|
+
*/
|
|
158
|
+
function describeThinkChatActivityPart(part, toolRenderers) {
|
|
159
|
+
if (isToolUIPart(part)) {
|
|
160
|
+
const custom = toolRenderers?.[getToolName(part)]?.describe?.(part);
|
|
161
|
+
if (custom !== void 0) return custom;
|
|
162
|
+
}
|
|
163
|
+
if (isReasoningUIPart(part)) {
|
|
164
|
+
const snippet = summarizeToolInput({ text: part.text });
|
|
165
|
+
const label = part.state === "streaming" ? "Thinking…" : "Thought";
|
|
166
|
+
return snippet ? `${label} · ${snippet}` : label;
|
|
167
|
+
}
|
|
168
|
+
if (isWorkspaceToolPart(part)) return describeWorkspaceToolPart(part);
|
|
169
|
+
if (isSkillToolPart(part)) return describeSkillToolPart(part);
|
|
170
|
+
if (isSessionContextToolPart(part)) return describeSessionContextToolPart(part);
|
|
171
|
+
if (isFetchToolPart(part)) return describeFetchToolPart(part);
|
|
172
|
+
if (isBrowserToolPart(part)) return describeBrowserToolPart(part);
|
|
173
|
+
if (isExecuteToolPart(part)) return describeExecuteToolPart(part);
|
|
174
|
+
if (isToolUIPart(part)) return describeGenericToolPart(part);
|
|
175
|
+
return null;
|
|
176
|
+
}
|
|
177
|
+
function basename(path) {
|
|
178
|
+
return path?.split("/").filter(Boolean).at(-1) ?? null;
|
|
179
|
+
}
|
|
180
|
+
function describeWorkspaceToolPart(part) {
|
|
181
|
+
const working = isPartWorking(part);
|
|
182
|
+
const failed = isPartFailed(part);
|
|
183
|
+
if (part.type === "tool-bash") {
|
|
184
|
+
const command = part.input?.script?.trim() ?? "";
|
|
185
|
+
if (failed) return command ? `Command failed · ${command}` : "Command failed";
|
|
186
|
+
const verb = working ? "Running" : "Ran";
|
|
187
|
+
return command ? `${verb} ${command}` : `${verb} a command`;
|
|
188
|
+
}
|
|
189
|
+
const label = (() => {
|
|
190
|
+
switch (part.type) {
|
|
191
|
+
case "tool-read": return `${working ? "Reading" : "Read"} ${basename(part.input?.path) ?? "a file"}`;
|
|
192
|
+
case "tool-write": return `${working ? "Writing" : "Wrote"} ${basename(part.input?.path) ?? "a file"}`;
|
|
193
|
+
case "tool-edit": return `${working ? "Editing" : "Edited"} ${basename(part.input?.path) ?? "a file"}`;
|
|
194
|
+
case "tool-delete": return `${working ? "Deleting" : "Deleted"} ${part.input?.path || "a file"}`;
|
|
195
|
+
case "tool-list": {
|
|
196
|
+
const path = part.input?.path;
|
|
197
|
+
return `${working ? "Listing" : "Listed"} ${path && path !== "/" ? path : "files"}`;
|
|
198
|
+
}
|
|
199
|
+
case "tool-find": return `${working ? "Searching" : "Searched"} for ${part.input?.pattern || "files"}`;
|
|
200
|
+
case "tool-grep": return `${working ? "Searching" : "Searched"} for ${part.input?.query || "text"}`;
|
|
201
|
+
}
|
|
202
|
+
})();
|
|
203
|
+
return failed ? `${label} · failed` : label;
|
|
204
|
+
}
|
|
205
|
+
function describeSkillToolPart(part) {
|
|
206
|
+
const working = isPartWorking(part);
|
|
207
|
+
const failed = isPartFailed(part);
|
|
208
|
+
const label = (() => {
|
|
209
|
+
switch (part.type) {
|
|
210
|
+
case "tool-activate_skill": {
|
|
211
|
+
const name = part.input?.name;
|
|
212
|
+
return `${working ? "Using" : "Used"} ${name ? `the ${name} skill` : "a skill"}`;
|
|
213
|
+
}
|
|
214
|
+
case "tool-read_skill_resource": return `${working ? "Reading" : "Read"} ${part.input?.path ?? "a skill resource"}`;
|
|
215
|
+
case "tool-run_skill_script": return `${working ? "Running" : "Ran"} ${part.input?.path ?? "a skill script"}`;
|
|
216
|
+
}
|
|
217
|
+
})();
|
|
218
|
+
return failed ? `${label} · failed` : label;
|
|
219
|
+
}
|
|
220
|
+
function describeSessionContextToolPart(part) {
|
|
221
|
+
const working = isPartWorking(part);
|
|
222
|
+
const failed = isSessionContextToolFailure(part);
|
|
223
|
+
const label = (() => {
|
|
224
|
+
switch (part.type) {
|
|
225
|
+
case "tool-set_context": {
|
|
226
|
+
const target = part.input?.label ? ` ${part.input.label}` : " context";
|
|
227
|
+
return `${working ? "Updating" : "Updated"}${target}`;
|
|
228
|
+
}
|
|
229
|
+
case "tool-load_context": return `${working ? "Loading" : "Loaded"} ${part.input?.key ?? "context"}`;
|
|
230
|
+
case "tool-unload_context": return `${working ? "Unloading" : "Unloaded"} ${part.input?.key ?? "context"}`;
|
|
231
|
+
case "tool-search_context": return `${working ? "Searching" : "Searched"} ${part.input?.label ?? "context"}`;
|
|
232
|
+
case "tool-session_search": return `${working ? "Searching" : "Searched"} conversations`;
|
|
233
|
+
}
|
|
234
|
+
})();
|
|
235
|
+
return failed ? `${label} · failed` : label;
|
|
236
|
+
}
|
|
237
|
+
function describeBrowserToolPart(part) {
|
|
238
|
+
const working = isPartWorking(part);
|
|
239
|
+
const failed = isPartFailed(part);
|
|
240
|
+
if (part.type === "tool-browser_execute") {
|
|
241
|
+
const output = part.state === "output-available" ? part.output : void 0;
|
|
242
|
+
if (failed || output?.status === "error") return "Browser automation failed";
|
|
243
|
+
if (output?.status === "paused") return "Browser waiting for approval";
|
|
244
|
+
return working ? "Using the browser" : "Used the browser";
|
|
245
|
+
}
|
|
246
|
+
const page = displayUrl(part.input?.url) || "a page";
|
|
247
|
+
const label = (() => {
|
|
248
|
+
switch (part.type) {
|
|
249
|
+
case "tool-browser_extract": return `${working ? "Extracting" : "Extracted"} data from ${page}`;
|
|
250
|
+
case "tool-browser_links": return `${working ? "Listing" : "Listed"} links on ${page}`;
|
|
251
|
+
case "tool-browser_scrape": return `${working ? "Scraping" : "Scraped"} ${page}`;
|
|
252
|
+
default: return `${working ? "Browsing" : "Browsed"} ${page}`;
|
|
253
|
+
}
|
|
254
|
+
})();
|
|
255
|
+
return failed ? `${label} · failed` : label;
|
|
256
|
+
}
|
|
257
|
+
function describeExecuteToolPart(part) {
|
|
258
|
+
const output = part.state === "output-available" ? part.output : void 0;
|
|
259
|
+
if (isPartFailed(part) || output?.status === "error") return "Code failed";
|
|
260
|
+
if (output?.status === "paused") return "Code waiting for approval";
|
|
261
|
+
const label = isPartWorking(part) ? "Running code" : "Ran code";
|
|
262
|
+
const snippet = summarizeToolInput(part.input);
|
|
263
|
+
return snippet ? `${label} · ${snippet}` : label;
|
|
264
|
+
}
|
|
265
|
+
function describeFetchToolPart(part) {
|
|
266
|
+
const target = part.input?.url ?? part.input?.path ?? "";
|
|
267
|
+
const output = part.state === "output-available" ? part.output : void 0;
|
|
268
|
+
if (isPartFailed(part) || output?.ok === false) return target ? `Fetch failed · ${target}` : "Fetch failed";
|
|
269
|
+
const verb = isPartWorking(part) ? "Fetching" : "Fetched";
|
|
270
|
+
return target ? `${verb} ${target}` : `${verb} a URL`;
|
|
271
|
+
}
|
|
272
|
+
function summarizeActivitySteps(parts) {
|
|
273
|
+
const byTool = /* @__PURE__ */ new Map();
|
|
274
|
+
const genericSegments = /* @__PURE__ */ new Set();
|
|
275
|
+
const skillNames = /* @__PURE__ */ new Set();
|
|
276
|
+
let thoughts = 0;
|
|
277
|
+
let skillParts = 0;
|
|
278
|
+
const sessionSegments = /* @__PURE__ */ new Set();
|
|
279
|
+
let fetches = 0;
|
|
280
|
+
let browses = 0;
|
|
281
|
+
let codeRuns = 0;
|
|
282
|
+
for (const part of parts) if (isReasoningUIPart(part)) thoughts++;
|
|
283
|
+
else if (isWorkspaceToolPart(part)) {
|
|
284
|
+
const name = getToolName(part);
|
|
285
|
+
byTool.set(name, (byTool.get(name) ?? 0) + 1);
|
|
286
|
+
} else if (isSkillToolPart(part)) {
|
|
287
|
+
skillParts++;
|
|
288
|
+
if (typeof part.input?.name === "string") skillNames.add(part.input.name);
|
|
289
|
+
} else if (isSessionContextToolPart(part)) sessionSegments.add(part.type === "tool-search_context" || part.type === "tool-session_search" ? "searched context" : "updated context");
|
|
290
|
+
else if (isFetchToolPart(part)) fetches++;
|
|
291
|
+
else if (isBrowserToolPart(part)) browses++;
|
|
292
|
+
else if (isExecuteToolPart(part)) codeRuns++;
|
|
293
|
+
else if (isToolUIPart(part)) genericSegments.add(genericToolPresentation(part, activityPartUrl(part) !== null).summary);
|
|
294
|
+
const count = (name) => byTool.get(name) ?? 0;
|
|
295
|
+
const files = (n) => n === 1 ? "a file" : `${n} files`;
|
|
296
|
+
const reads = count("read");
|
|
297
|
+
const edits = count("edit") + count("write");
|
|
298
|
+
const deletes = count("delete");
|
|
299
|
+
const commands = count("bash");
|
|
300
|
+
const segments = [];
|
|
301
|
+
if (thoughts > 0) segments.push("thought");
|
|
302
|
+
if (skillParts > 0) segments.push(skillNames.size === 1 ? `used the ${[...skillNames][0]} skill` : skillNames.size > 1 ? `used ${skillNames.size} skills` : "used a skill");
|
|
303
|
+
for (const segment of ["updated context", "searched context"]) if (sessionSegments.has(segment)) segments.push(segment);
|
|
304
|
+
if (reads > 0) segments.push(`read ${files(reads)}`);
|
|
305
|
+
if (edits > 0) segments.push(`edited ${files(edits)}`);
|
|
306
|
+
if (deletes > 0) segments.push(`deleted ${files(deletes)}`);
|
|
307
|
+
if (count("find") + count("grep") > 0) segments.push("searched code");
|
|
308
|
+
if (count("list") > 0) segments.push("listed files");
|
|
309
|
+
if (fetches > 0) segments.push(fetches === 1 ? "fetched a URL" : `fetched ${fetches} URLs`);
|
|
310
|
+
if (browses > 0) segments.push("used the browser");
|
|
311
|
+
if (codeRuns > 0) segments.push("ran code");
|
|
312
|
+
if (commands > 0) segments.push(commands === 1 ? "ran a command" : `ran ${commands} commands`);
|
|
313
|
+
for (const segment of [
|
|
314
|
+
"edited files",
|
|
315
|
+
"searched code",
|
|
316
|
+
"searched the web",
|
|
317
|
+
"read a URL",
|
|
318
|
+
"ran a command",
|
|
319
|
+
"read files",
|
|
320
|
+
"used a tool"
|
|
321
|
+
]) if (genericSegments.has(segment)) segments.push(segment);
|
|
322
|
+
for (const segment of genericSegments) if (!segments.includes(segment)) segments.push(segment);
|
|
323
|
+
if (segments.length === 0) return "Worked";
|
|
324
|
+
const top = segments.slice(0, 3);
|
|
325
|
+
const joined = top.length === 1 ? top[0] : `${top.slice(0, -1).join(", ")} and ${top.at(-1)}`;
|
|
326
|
+
return joined.charAt(0).toUpperCase() + joined.slice(1);
|
|
327
|
+
}
|
|
328
|
+
/** Derive the serializable collapsed header from persisted AI SDK message parts. */
|
|
329
|
+
function deriveThinkChatActivityHeader(parts, options = {}) {
|
|
330
|
+
const described = parts.flatMap((part) => {
|
|
331
|
+
const label = describeThinkChatActivityPart(part, options.toolDescribers);
|
|
332
|
+
return label ? [{
|
|
333
|
+
label,
|
|
334
|
+
part
|
|
335
|
+
}] : [];
|
|
336
|
+
});
|
|
337
|
+
if (described.length === 0) return null;
|
|
338
|
+
if (options.isStreaming ?? parts.some(isPartWorking)) {
|
|
339
|
+
const latest = described.at(-1);
|
|
340
|
+
const workspaceDestination = activityPartWorkspaceDestination(latest.part);
|
|
341
|
+
return boundedActivityHeader({
|
|
342
|
+
label: latest.label,
|
|
343
|
+
iconKind: activityPartIconKind(latest.part),
|
|
344
|
+
...activityPartUrl(latest.part) ? { url: activityPartUrl(latest.part) } : {},
|
|
345
|
+
...workspaceDestination ? { workspaceDestination } : {}
|
|
346
|
+
});
|
|
347
|
+
}
|
|
348
|
+
if (parts.some((part) => isToolUIPart(part) && isPartFailed(part))) return boundedActivityHeader({
|
|
349
|
+
label: summarizeActivitySteps(parts),
|
|
350
|
+
iconKind: "approval"
|
|
351
|
+
});
|
|
352
|
+
const workspaceRepresentative = parts.find((part) => activityPartIconKind(part) === "edit" && activityPartWorkspaceDestination(part)) ?? parts.find((part) => activityPartWorkspaceDestination(part));
|
|
353
|
+
const workspaceDestination = workspaceRepresentative ? activityPartWorkspaceDestination(workspaceRepresentative) : null;
|
|
354
|
+
const representative = parts.find((part) => activityPartIconKind(part) === "edit") ?? parts.find((part) => activityPartUrl(part)) ?? parts.find((part) => describeThinkChatActivityPart(part));
|
|
355
|
+
if (!representative) return boundedActivityHeader({
|
|
356
|
+
label: summarizeActivitySteps(parts),
|
|
357
|
+
iconKind: "tool"
|
|
358
|
+
});
|
|
359
|
+
const url = activityPartUrl(representative);
|
|
360
|
+
return boundedActivityHeader({
|
|
361
|
+
label: summarizeActivitySteps(parts),
|
|
362
|
+
iconKind: activityPartIconKind(representative),
|
|
363
|
+
...url ? { url } : {},
|
|
364
|
+
...workspaceDestination ? { workspaceDestination } : {}
|
|
365
|
+
});
|
|
366
|
+
}
|
|
367
|
+
/**
|
|
368
|
+
* Derive the same live header from a host lifecycle event without making the
|
|
369
|
+
* host manufacture an AI SDK UI message part.
|
|
370
|
+
*/
|
|
371
|
+
function deriveThinkChatToolLifecycleHeader(snapshot) {
|
|
372
|
+
if (snapshot.state === "approval-required") return boundedActivityHeader({
|
|
373
|
+
label: "Approval needed",
|
|
374
|
+
iconKind: "approval"
|
|
375
|
+
});
|
|
376
|
+
const part = lifecycleSnapshotToToolPart(snapshot);
|
|
377
|
+
const url = activityPartUrl(part);
|
|
378
|
+
const workspaceDestination = activityPartWorkspaceDestination(part);
|
|
379
|
+
return boundedActivityHeader({
|
|
380
|
+
label: describeThinkChatActivityPart(part) ?? "Used a tool",
|
|
381
|
+
iconKind: activityPartIconKind(part),
|
|
382
|
+
...url ? { url } : {},
|
|
383
|
+
...workspaceDestination ? { workspaceDestination } : {}
|
|
384
|
+
});
|
|
385
|
+
}
|
|
386
|
+
/** Internal adapter only: callers stay on the small semantic lifecycle API. */
|
|
387
|
+
function lifecycleSnapshotToToolPart(snapshot) {
|
|
388
|
+
const base = {
|
|
389
|
+
type: `tool-${snapshot.toolName}`,
|
|
390
|
+
toolCallId: "activity-summary",
|
|
391
|
+
input: snapshot.input
|
|
392
|
+
};
|
|
393
|
+
switch (snapshot.state) {
|
|
394
|
+
case "working": return {
|
|
395
|
+
...base,
|
|
396
|
+
state: "input-available"
|
|
397
|
+
};
|
|
398
|
+
case "succeeded": return {
|
|
399
|
+
...base,
|
|
400
|
+
state: "output-available",
|
|
401
|
+
output: snapshot.output
|
|
402
|
+
};
|
|
403
|
+
case "failed": return {
|
|
404
|
+
...base,
|
|
405
|
+
state: "output-error",
|
|
406
|
+
errorText: lifecycleErrorText(snapshot.error)
|
|
407
|
+
};
|
|
408
|
+
case "approval-required": throw new Error("Approval snapshots are handled before UI-part adaptation");
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
function lifecycleErrorText(error) {
|
|
412
|
+
if (typeof error === "string") return error;
|
|
413
|
+
if (error instanceof Error) return error.message;
|
|
414
|
+
try {
|
|
415
|
+
return error === void 0 ? "Tool failed" : String(error);
|
|
416
|
+
} catch {
|
|
417
|
+
return "Tool failed";
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
//#endregion
|
|
421
|
+
export { activityPartIconKind, activityPartUrl, deriveThinkChatActivityHeader, deriveThinkChatToolLifecycleHeader, describeThinkChatActivityPart, summarizeActivitySteps };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as SessionContextToolPart, d as WorkspaceToolPart, n as ExecuteToolPart, o as SkillToolPart, r as FetchToolPart, t as BrowserToolPart } from "../ThinkChatToolParts-CSzVwMXf.js";
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
|
|
4
4
|
//#region src/components/ThinkChatToolPanels.d.ts
|
|
@@ -18,22 +18,32 @@ declare function ThinkChatSkillPanel({
|
|
|
18
18
|
}: {
|
|
19
19
|
part: SkillToolPart;
|
|
20
20
|
}): React.JSX.Element;
|
|
21
|
+
/** Session panels expose the durable context/search operation recorded in the
|
|
22
|
+
UIMessage. The session itself remains server-owned; this is transcript
|
|
23
|
+
rendering, not a client-side mirror of context state. */
|
|
24
|
+
declare function ThinkChatSessionContextPanel({
|
|
25
|
+
part
|
|
26
|
+
}: {
|
|
27
|
+
part: SessionContextToolPart;
|
|
28
|
+
}): React.JSX.Element;
|
|
21
29
|
declare function ThinkChatFetchPanel({
|
|
22
30
|
part
|
|
23
31
|
}: {
|
|
24
32
|
part: FetchToolPart;
|
|
25
33
|
}): React.JSX.Element;
|
|
34
|
+
interface ThinkChatExecutePanelProps {
|
|
35
|
+
/** Whole upstream Think execute-tool part, including its current output lifecycle. */
|
|
36
|
+
part: ExecuteToolPart;
|
|
37
|
+
}
|
|
26
38
|
/** The codemode execute tool as an activity panel: highlighted TypeScript
|
|
27
39
|
plus logs, result, and the paused pending-approval list. */
|
|
28
40
|
declare function ThinkChatExecutePanel({
|
|
29
41
|
part
|
|
30
|
-
}:
|
|
31
|
-
part: ExecuteToolPart;
|
|
32
|
-
}): React.JSX.Element;
|
|
42
|
+
}: ThinkChatExecutePanelProps): React.JSX.Element;
|
|
33
43
|
declare function ThinkChatBrowserPanel({
|
|
34
44
|
part
|
|
35
45
|
}: {
|
|
36
46
|
part: BrowserToolPart;
|
|
37
47
|
}): React.JSX.Element;
|
|
38
48
|
//#endregion
|
|
39
|
-
export { ThinkChatBrowserPanel, ThinkChatExecutePanel, ThinkChatFetchPanel, ThinkChatSkillPanel, ThinkChatWorkspacePanel };
|
|
49
|
+
export { ThinkChatBrowserPanel, ThinkChatExecutePanel, ThinkChatExecutePanelProps, ThinkChatFetchPanel, ThinkChatSessionContextPanel, ThinkChatSkillPanel, ThinkChatWorkspacePanel };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ActivityOutput, ActivityPanel } from "./Activity.js";
|
|
2
2
|
import { Tabs } from "./Tabs.js";
|
|
3
|
-
import {
|
|
3
|
+
import { displayUrl, isSessionContextToolFailure } from "./ThinkChatToolParts.js";
|
|
4
|
+
import { t as CodeBlock } from "../CodeBlock-BmB4Xaqq.js";
|
|
4
5
|
import { BrowserLiveView } from "./BrowserLiveView.js";
|
|
5
|
-
import { displayUrl } from "./ThinkChatToolParts.js";
|
|
6
6
|
import * as React from "react";
|
|
7
7
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
8
8
|
import { getToolName } from "ai";
|
|
@@ -152,6 +152,51 @@ function ThinkChatSkillPanel({ part }) {
|
|
|
152
152
|
}
|
|
153
153
|
}
|
|
154
154
|
}
|
|
155
|
+
/** Session panels expose the durable context/search operation recorded in the
|
|
156
|
+
UIMessage. The session itself remains server-owned; this is transcript
|
|
157
|
+
rendering, not a client-side mirror of context state. */
|
|
158
|
+
function ThinkChatSessionContextPanel({ part }) {
|
|
159
|
+
if (part.state === "output-error") return /* @__PURE__ */ jsx(ActivityPanel, {
|
|
160
|
+
label: getToolName(part),
|
|
161
|
+
text: part.errorText,
|
|
162
|
+
status: "error",
|
|
163
|
+
error: true
|
|
164
|
+
});
|
|
165
|
+
if (part.state === "output-denied") return renderDeniedPanel(getToolName(part), part.approval.reason);
|
|
166
|
+
const output = part.state === "output-available" ? part.output : void 0;
|
|
167
|
+
const outputIsError = isSessionContextToolFailure(part);
|
|
168
|
+
switch (part.type) {
|
|
169
|
+
case "tool-set_context": {
|
|
170
|
+
const input = part.input;
|
|
171
|
+
const title = input?.metadata?.title;
|
|
172
|
+
return /* @__PURE__ */ jsx(ActivityPanel, {
|
|
173
|
+
label: title ? `${input?.label ?? "context"} / ${title}` : input?.label ?? "context",
|
|
174
|
+
text: input?.content,
|
|
175
|
+
status: output,
|
|
176
|
+
error: outputIsError
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
case "tool-load_context":
|
|
180
|
+
case "tool-unload_context": return /* @__PURE__ */ jsx(ActivityPanel, {
|
|
181
|
+
label: `${part.input?.label ?? "context"} / ${part.input?.key ?? "entry"}`,
|
|
182
|
+
text: output,
|
|
183
|
+
status: outputIsError ? "error" : void 0,
|
|
184
|
+
error: outputIsError
|
|
185
|
+
});
|
|
186
|
+
case "tool-search_context": return /* @__PURE__ */ jsx(ActivityPanel, {
|
|
187
|
+
label: part.input?.query ?? "Context search",
|
|
188
|
+
text: output,
|
|
189
|
+
status: outputIsError ? "error" : part.input?.label,
|
|
190
|
+
error: outputIsError
|
|
191
|
+
});
|
|
192
|
+
case "tool-session_search": return /* @__PURE__ */ jsx(ActivityPanel, {
|
|
193
|
+
label: part.input?.query ?? "Conversation search",
|
|
194
|
+
text: output,
|
|
195
|
+
status: outputIsError ? "error" : void 0,
|
|
196
|
+
error: outputIsError
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
}
|
|
155
200
|
function ThinkChatFetchPanel({ part }) {
|
|
156
201
|
const label = part.input?.url ?? part.input?.path ?? "fetch";
|
|
157
202
|
if (part.state === "output-error") return /* @__PURE__ */ jsx(ActivityPanel, {
|
|
@@ -211,17 +256,79 @@ function findBrowserResultMedia(value, depth = 0) {
|
|
|
211
256
|
return media;
|
|
212
257
|
}
|
|
213
258
|
function ExecuteCodeView({ code, output, hideResult }) {
|
|
259
|
+
const calls = output && "calls" in output ? output.calls : void 0;
|
|
214
260
|
const sections = [
|
|
215
261
|
output && "logs" in output && output.logs?.length ? output.logs.join("\n") : "",
|
|
216
262
|
output?.status === "error" ? output.error : "",
|
|
217
|
-
output?.status === "paused" ? formatPendingActions(output.pending) : "",
|
|
263
|
+
output?.status === "paused" && !calls?.length ? formatPendingActions(output.pending) : "",
|
|
218
264
|
output?.status === "completed" && output.result !== void 0 && !hideResult ? typeof output.result === "string" ? output.result : JSON.stringify(output.result, null, 2) : ""
|
|
219
265
|
].filter(Boolean);
|
|
220
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
266
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
267
|
+
code ? /* @__PURE__ */ jsx(CodeBlock, {
|
|
268
|
+
className: "activity__code-block",
|
|
269
|
+
code,
|
|
270
|
+
language: "ts"
|
|
271
|
+
}) : null,
|
|
272
|
+
calls?.length ? /* @__PURE__ */ jsx(ToolCallAudit, { calls }) : null,
|
|
273
|
+
sections.length ? /* @__PURE__ */ jsx(ActivityOutput, { children: sections.join("\n\n") }) : null
|
|
274
|
+
] });
|
|
275
|
+
}
|
|
276
|
+
/** Durable connector calls emitted by Codemode 0.4.3. The ordered list keeps
|
|
277
|
+
execution order and state available to assistive technology without adding
|
|
278
|
+
another host-side activity protocol. */
|
|
279
|
+
function ToolCallAudit({ calls }) {
|
|
280
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
281
|
+
className: "activity__call-audit",
|
|
282
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
283
|
+
className: "activity__call-audit-label",
|
|
284
|
+
children: "Calls"
|
|
285
|
+
}), /* @__PURE__ */ jsx("ol", {
|
|
286
|
+
className: "activity__call-audit-list",
|
|
287
|
+
children: calls.map((call) => /* @__PURE__ */ jsxs("li", {
|
|
288
|
+
className: "activity__call-audit-item",
|
|
289
|
+
"data-state": call.state,
|
|
290
|
+
children: [
|
|
291
|
+
/* @__PURE__ */ jsx("code", {
|
|
292
|
+
className: "activity__call-audit-code",
|
|
293
|
+
children: formatToolCall(call)
|
|
294
|
+
}),
|
|
295
|
+
/* @__PURE__ */ jsx("span", {
|
|
296
|
+
className: "activity__call-audit-state",
|
|
297
|
+
children: toolCallStateLabel(call)
|
|
298
|
+
}),
|
|
299
|
+
call.result !== void 0 ? /* @__PURE__ */ jsxs("code", {
|
|
300
|
+
className: "activity__call-audit-result",
|
|
301
|
+
children: [
|
|
302
|
+
" ",
|
|
303
|
+
"→ ",
|
|
304
|
+
formatAuditValue(call.result)
|
|
305
|
+
]
|
|
306
|
+
}) : null
|
|
307
|
+
]
|
|
308
|
+
}, call.seq))
|
|
309
|
+
})]
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
function formatToolCall(call) {
|
|
313
|
+
const target = call.connector === "__step" ? `codemode.step(${JSON.stringify(call.method)})` : `${call.connector}.${call.method}`;
|
|
314
|
+
if (call.connector === "__step") return target;
|
|
315
|
+
return `${target}(${formatAuditValue(call.args)})`;
|
|
316
|
+
}
|
|
317
|
+
function formatAuditValue(value) {
|
|
318
|
+
let formatted;
|
|
319
|
+
if (typeof value === "string") formatted = value;
|
|
320
|
+
else try {
|
|
321
|
+
formatted = JSON.stringify(value, (_, item) => typeof item === "bigint" ? `${item}n` : item) ?? String(value);
|
|
322
|
+
} catch {
|
|
323
|
+
formatted = String(value);
|
|
324
|
+
}
|
|
325
|
+
const maxLength = 240;
|
|
326
|
+
return formatted.length > maxLength ? `${formatted.slice(0, maxLength - 1)}…` : formatted;
|
|
327
|
+
}
|
|
328
|
+
function toolCallStateLabel(call) {
|
|
329
|
+
const state = call.state === "pending" ? "awaiting approval" : call.state === "applied" ? "applied" : call.state;
|
|
330
|
+
const qualifiers = [call.requiresApproval && call.state !== "pending" ? "approval required" : "", call.ephemeral ? "re-executes on replay" : ""].filter(Boolean);
|
|
331
|
+
return qualifiers.length ? `${state} · ${qualifiers.join(" · ")}` : state;
|
|
225
332
|
}
|
|
226
333
|
function formatPendingActions(pending) {
|
|
227
334
|
return pending.map((action) => {
|
|
@@ -364,4 +471,4 @@ function getBashStatusText(output, errorText, deniedReason) {
|
|
|
364
471
|
return "success";
|
|
365
472
|
}
|
|
366
473
|
//#endregion
|
|
367
|
-
export { ThinkChatBrowserPanel, ThinkChatExecutePanel, ThinkChatFetchPanel, ThinkChatSkillPanel, ThinkChatWorkspacePanel };
|
|
474
|
+
export { ThinkChatBrowserPanel, ThinkChatExecutePanel, ThinkChatFetchPanel, ThinkChatSessionContextPanel, ThinkChatSkillPanel, ThinkChatWorkspacePanel };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { BrowserToolPart, ExecuteToolPart, FetchToolPart, SkillToolPart, ThinkBashToolOutput, ThinkBashToolPart, ThinkChatPart, ThinkWorkspaceToolName, WorkspaceToolPart, displayUrl, isBrowserToolPart, isExecuteToolPart, isFetchToolPart, isPartFailed, isPartWorking, isSkillToolPart, isThinkChatActivityPart, isWorkspaceToolPart };
|
|
1
|
+
import { C as isToolPartFailed, S as isThinkChatActivityPart, T as isWorkspaceToolPart, _ as isPartFailed, a as SessionContextToolPart, b as isSessionContextToolPart, c as ThinkBashToolPart, d as WorkspaceToolPart, f as displayUrl, g as isFetchToolPart, h as isExecuteToolPart, i as SessionContextToolName, l as ThinkChatPart, m as isBrowserToolPart, n as ExecuteToolPart, o as SkillToolPart, p as getToolDisplayName, r as FetchToolPart, s as ThinkBashToolOutput, t as BrowserToolPart, u as ThinkWorkspaceToolName, v as isPartWorking, w as isToolPartWorking, x as isSkillToolPart, y as isSessionContextToolFailure } from "../ThinkChatToolParts-CSzVwMXf.js";
|
|
2
|
+
export { BrowserToolPart, ExecuteToolPart, FetchToolPart, SessionContextToolName, SessionContextToolPart, SkillToolPart, ThinkBashToolOutput, ThinkBashToolPart, ThinkChatPart, ThinkWorkspaceToolName, WorkspaceToolPart, displayUrl, getToolDisplayName, isBrowserToolPart, isExecuteToolPart, isFetchToolPart, isPartFailed, isPartWorking, isSessionContextToolFailure, isSessionContextToolPart, isSkillToolPart, isThinkChatActivityPart, isToolPartFailed, isToolPartWorking, isWorkspaceToolPart };
|