@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.
Files changed (251) hide show
  1. package/dist/AgentActivity-BNUNrP9O.d.ts +36 -0
  2. package/dist/{AgentChat-DQkqt82e.d.ts → AgentChat-CrlpbvQJ.d.ts} +58 -6
  3. package/dist/{CodeBlock-DUh9WOGo.d.ts → CodeBlock-BRajW4QU.d.ts} +1 -1
  4. package/dist/{CodeBlock-BUFXG8HW.js → CodeBlock-BmB4Xaqq.js} +15 -4
  5. package/dist/{FileTree-mpEIcfzA.js → FileTree-CkVbIMWV.js} +82 -89
  6. package/dist/Message-BkMdE3bS.js +375 -0
  7. package/dist/{ModelSelector-CPCpFAUt.js → ModelSelector-SlJNgwKY.js} +2 -2
  8. package/dist/{PromptInput-ClNqBiIw.d.ts → PromptInput-BWTuXMOD.d.ts} +123 -5
  9. package/dist/ResponsiveSidebarShell-Dd9DCcBT.d.ts +67 -0
  10. package/dist/{Select-Dl_vF_Bt.d.ts → Select-BeEsefzh.d.ts} +12 -2
  11. package/dist/{ThinkChat-BPcehdbP.js → ThinkChat-CzC-zNGA.js} +24 -36
  12. package/dist/{ThinkChatActivity-BmwuIigx.d.ts → ThinkChatActivity-BFQnb2ct.d.ts} +3 -10
  13. package/dist/ThinkChatActivitySummary-BPmu9a-c.d.ts +39 -0
  14. package/dist/{ThinkChatToolParts-CDEjqS6A.d.ts → ThinkChatToolParts-CSzVwMXf.d.ts} +13 -3
  15. package/dist/ThinkExecutionRun-ChhWhOoU.d.ts +30 -0
  16. package/dist/Toggle-CAAlNl-M.d.ts +69 -0
  17. package/dist/ToggleGroup-8hPv-b69.d.ts +73 -0
  18. package/dist/Workspace-D39LxGvP.d.ts +62 -0
  19. package/dist/WorkspaceFile-DOZkPwzu.d.ts +106 -0
  20. package/dist/WorkspaceFileView-rSN_yT0L.js +744 -0
  21. package/dist/WorkspaceLink-DIPbXrUM.js +337 -0
  22. package/dist/WorkspaceLink-DK1DWMHe.d.ts +89 -0
  23. package/dist/components/Activity.d.ts +27 -1
  24. package/dist/components/Activity.js +33 -15
  25. package/dist/components/AgentActivity.d.ts +2 -0
  26. package/dist/components/AgentActivity.js +45 -0
  27. package/dist/components/AgentActivityPreview.d.ts +46 -0
  28. package/dist/components/AgentActivityPreview.js +94 -0
  29. package/dist/components/AgentAttention.d.ts +73 -0
  30. package/dist/components/AgentAttention.js +85 -0
  31. package/dist/components/AgentChat.d.ts +2 -2
  32. package/dist/components/AgentChat.js +224 -200
  33. package/dist/components/AgentChatMessageEditor.d.ts +29 -0
  34. package/dist/components/AgentChatMessageEditor.js +92 -0
  35. package/dist/components/AgentChatTurnError.d.ts +17 -0
  36. package/dist/components/AgentChatTurnError.js +40 -0
  37. package/dist/components/AgentConnection.d.ts +12 -17
  38. package/dist/components/AgentConnection.js +99 -91
  39. package/dist/components/AppFrame.d.ts +24 -0
  40. package/dist/components/AppFrame.js +25 -0
  41. package/dist/components/AppTopBar.d.ts +71 -0
  42. package/dist/components/AppTopBar.js +82 -0
  43. package/dist/components/Artifact.js +1 -1
  44. package/dist/components/BrowserLiveView.js +1 -1
  45. package/dist/components/BrowserReplay.js +1 -1
  46. package/dist/components/BrowserRunPanel.js +1 -1
  47. package/dist/components/Card.d.ts +3 -0
  48. package/dist/components/Card.js +2 -1
  49. package/dist/components/ChainOfThought.d.ts +1 -1
  50. package/dist/components/ChainOfThought.js +1 -1
  51. package/dist/components/ChatGptSignInScreen.js +2 -2
  52. package/dist/components/Checkbox.js +5 -13
  53. package/dist/components/CheckboxGroup.d.ts +58 -2
  54. package/dist/components/CheckboxGroup.js +59 -1
  55. package/dist/components/CodeBlock.d.ts +1 -1
  56. package/dist/components/CodeBlock.js +1 -1
  57. package/dist/components/CodexModelSelector.js +1 -1
  58. package/dist/components/Commit.js +2 -2
  59. package/dist/components/ContextMenu.js +1 -1
  60. package/dist/components/Conversation.js +1 -1
  61. package/dist/components/DescriptionList.d.ts +12 -0
  62. package/dist/components/DescriptionList.js +11 -0
  63. package/dist/components/DescriptionListParts.d.ts +37 -0
  64. package/dist/components/DescriptionListParts.js +35 -0
  65. package/dist/components/EnvironmentVariables.js +2 -2
  66. package/dist/components/Fieldset.d.ts +13 -1
  67. package/dist/components/Fieldset.js +11 -2
  68. package/dist/components/FileTree.js +1 -1
  69. package/dist/components/IconButton.d.ts +33 -0
  70. package/dist/components/IconButton.js +27 -0
  71. package/dist/components/McpConnectionRequest.d.ts +44 -0
  72. package/dist/components/McpConnectionRequest.js +122 -0
  73. package/dist/components/McpServerPicker.d.ts +48 -23
  74. package/dist/components/McpServerPicker.js +238 -189
  75. package/dist/components/Menubar.js +1 -1
  76. package/dist/components/Message.d.ts +1 -0
  77. package/dist/components/Message.js +1 -285
  78. package/dist/components/MessageScroller.js +1 -1
  79. package/dist/components/ModelSelector.js +1 -1
  80. package/dist/components/Pricing.d.ts +37 -0
  81. package/dist/components/Pricing.js +17 -0
  82. package/dist/components/PricingBillingToggle.d.ts +23 -0
  83. package/dist/components/PricingBillingToggle.js +86 -0
  84. package/dist/components/PricingConfirmationDialog.d.ts +25 -0
  85. package/dist/components/PricingConfirmationDialog.js +57 -0
  86. package/dist/components/PricingFAQ.d.ts +18 -0
  87. package/dist/components/PricingFAQ.js +27 -0
  88. package/dist/components/PricingPage.d.ts +2 -38
  89. package/dist/components/PricingPage.js +39 -359
  90. package/dist/components/PricingPlanCard.d.ts +22 -0
  91. package/dist/components/PricingPlanCard.js +109 -0
  92. package/dist/components/PricingUsageCalculator.d.ts +22 -0
  93. package/dist/components/PricingUsageCalculator.js +96 -0
  94. package/dist/components/PromptInput.d.ts +2 -2
  95. package/dist/components/PromptInput.js +210 -15
  96. package/dist/components/Queue.js +1 -1
  97. package/dist/components/Reasoning.d.ts +2 -1
  98. package/dist/components/Reasoning.js +14 -29
  99. package/dist/components/ResizableSidePanel.d.ts +57 -0
  100. package/dist/components/ResizableSidePanel.js +151 -0
  101. package/dist/components/ResponsiveSidebarShell.d.ts +2 -0
  102. package/dist/components/ResponsiveSidebarShell.js +129 -0
  103. package/dist/components/Select.d.ts +2 -2
  104. package/dist/components/Select.js +11 -2
  105. package/dist/components/Slider.d.ts +13 -1
  106. package/dist/components/Slider.js +11 -0
  107. package/dist/components/Sources.js +1 -1
  108. package/dist/components/Stepper.d.ts +4 -0
  109. package/dist/components/Stepper.js +5 -3
  110. package/dist/components/SubagentRun.d.ts +18 -19
  111. package/dist/components/SubagentRun.js +25 -18
  112. package/dist/components/SubagentRunIndicator.d.ts +22 -0
  113. package/dist/components/SubagentRunIndicator.js +33 -0
  114. package/dist/components/SubagentRunList.d.ts +25 -0
  115. package/dist/components/SubagentRunList.js +26 -0
  116. package/dist/components/SubagentRunSelector.d.ts +47 -0
  117. package/dist/components/SubagentRunSelector.js +55 -0
  118. package/dist/components/Task.js +1 -1
  119. package/dist/components/Terminal.js +2 -2
  120. package/dist/components/TestResults.js +1 -1
  121. package/dist/components/Textarea.d.ts +21 -0
  122. package/dist/components/Textarea.js +19 -0
  123. package/dist/components/ThemeModeControl.d.ts +24 -0
  124. package/dist/components/ThemeModeControl.js +52 -0
  125. package/dist/components/ThemeProvider.d.ts +38 -0
  126. package/dist/components/ThemeProvider.js +80 -0
  127. package/dist/components/ThinkChat.d.ts +29 -6
  128. package/dist/components/ThinkChat.js +7 -4
  129. package/dist/components/ThinkChatActivity.d.ts +3 -2
  130. package/dist/components/ThinkChatActivity.js +12 -318
  131. package/dist/components/ThinkChatActivitySummary.d.ts +2 -0
  132. package/dist/components/ThinkChatActivitySummary.js +421 -0
  133. package/dist/components/ThinkChatToolPanels.d.ts +7 -5
  134. package/dist/components/ThinkChatToolPanels.js +70 -8
  135. package/dist/components/ThinkChatToolParts.d.ts +2 -2
  136. package/dist/components/ThinkChatToolParts.js +36 -10
  137. package/dist/components/ThinkExecutionDetail.d.ts +20 -0
  138. package/dist/components/ThinkExecutionDetail.js +80 -0
  139. package/dist/components/ThinkExecutionRun.d.ts +2 -0
  140. package/dist/components/ThinkExecutionRun.js +72 -0
  141. package/dist/components/ThinkExecutionStatus.d.ts +22 -0
  142. package/dist/components/ThinkExecutionStatus.js +36 -0
  143. package/dist/components/ThinkExecutionWorkbench.d.ts +7 -0
  144. package/dist/components/ThinkExecutionWorkbench.js +69 -225
  145. package/dist/components/ThinkFullApp.d.ts +58 -14
  146. package/dist/components/ThinkFullApp.js +154 -160
  147. package/dist/components/ThinkFullAppViewSwitch.d.ts +31 -0
  148. package/dist/components/ThinkFullAppViewSwitch.js +34 -0
  149. package/dist/components/ThinkRoutine.d.ts +36 -0
  150. package/dist/components/ThinkRoutine.js +15 -0
  151. package/dist/components/ThinkRoutineBrowser.d.ts +25 -0
  152. package/dist/components/ThinkRoutineBrowser.js +156 -0
  153. package/dist/components/ThinkRoutineDetail.d.ts +24 -0
  154. package/dist/components/ThinkRoutineDetail.js +102 -0
  155. package/dist/components/ThinkRoutineForm.d.ts +32 -0
  156. package/dist/components/ThinkRoutineForm.js +151 -0
  157. package/dist/components/ThinkRoutineLibrary.d.ts +74 -0
  158. package/dist/components/ThinkRoutineLibrary.js +178 -0
  159. package/dist/components/ThinkRoutineRuns.d.ts +24 -0
  160. package/dist/components/ThinkRoutineRuns.js +68 -0
  161. package/dist/components/ThinkThreadPicker.d.ts +18 -1
  162. package/dist/components/ThinkThreadPicker.js +51 -5
  163. package/dist/components/ThinkThreadShell.d.ts +12 -9
  164. package/dist/components/ThinkThreadShell.js +17 -137
  165. package/dist/components/Toggle.d.ts +1 -68
  166. package/dist/components/ToggleGroup.d.ts +1 -72
  167. package/dist/components/Tooltip.d.ts +3 -1
  168. package/dist/components/Tooltip.js +4 -2
  169. package/dist/components/WebPreview.js +1 -1
  170. package/dist/components/Workspace.d.ts +2 -0
  171. package/dist/components/Workspace.js +424 -0
  172. package/dist/components/WorkspaceBrowser.d.ts +32 -0
  173. package/dist/components/WorkspaceBrowser.js +103 -0
  174. package/dist/components/WorkspaceExplorer.d.ts +12 -79
  175. package/dist/components/WorkspaceExplorer.js +116 -330
  176. package/dist/components/WorkspaceFile.d.ts +2 -0
  177. package/dist/components/WorkspaceFile.js +195 -0
  178. package/dist/components/WorkspaceFileView.d.ts +26 -0
  179. package/dist/components/WorkspaceFileView.js +2 -0
  180. package/dist/components/WorkspaceHeader.d.ts +35 -0
  181. package/dist/components/WorkspaceHeader.js +51 -0
  182. package/dist/components/WorkspaceLink.d.ts +2 -0
  183. package/dist/components/WorkspaceLink.js +2 -0
  184. package/dist/components/icons.d.ts +2 -2
  185. package/dist/components/icons.js +2 -2
  186. package/dist/{copy-button-DUMLYdsk.js → copy-button-Dejn5heL.js} +1 -1
  187. package/dist/icons-CpfUer49.js +85 -0
  188. package/dist/{icons-CUCz_Sft.d.ts → icons-GQd1xF4e.d.ts} +51 -1
  189. package/dist/styles/activity-header.css +75 -0
  190. package/dist/styles/activity.css +49 -63
  191. package/dist/styles/agent-activity-preview-overlay.css +80 -0
  192. package/dist/styles/agent-activity-preview.css +233 -0
  193. package/dist/styles/agent-attention.css +128 -0
  194. package/dist/styles/agent-chat.css +133 -4
  195. package/dist/styles/agent-connection.css +9 -9
  196. package/dist/styles/alert-dialog.css +11 -11
  197. package/dist/styles/app-frame.css +15 -0
  198. package/dist/styles/app-top-bar.css +102 -0
  199. package/dist/styles/avatar.css +0 -1
  200. package/dist/styles/browser-control-overlay.css +184 -0
  201. package/dist/styles/card.css +29 -8
  202. package/dist/styles/chain-of-thought.css +5 -5
  203. package/dist/styles/checkbox-group.css +69 -0
  204. package/dist/styles/codex-model-selector.css +3 -3
  205. package/dist/styles/combobox.css +2 -1
  206. package/dist/styles/context-menu.css +1 -1
  207. package/dist/styles/description-list.css +50 -0
  208. package/dist/styles/dialog.css +11 -11
  209. package/dist/styles/field.css +14 -14
  210. package/dist/styles/fieldset.css +15 -4
  211. package/dist/styles/index.css +14 -2
  212. package/dist/styles/mcp-connection-request.css +60 -0
  213. package/dist/styles/mcp-server-picker.css +96 -68
  214. package/dist/styles/menu.css +1 -1
  215. package/dist/styles/message.css +4 -43
  216. package/dist/styles/model-selector.css +18 -12
  217. package/dist/styles/popover.css +9 -9
  218. package/dist/styles/preview-card.css +1 -1
  219. package/dist/styles/pricing-page.css +21 -27
  220. package/dist/styles/prompt-input.css +225 -32
  221. package/dist/styles/reasoning.css +1 -55
  222. package/dist/styles/recipes.css +50 -24
  223. package/dist/styles/resizable-side-panel.css +66 -0
  224. package/dist/styles/responsive-sidebar-shell.css +169 -0
  225. package/dist/styles/select.css +13 -3
  226. package/dist/styles/sources.css +6 -6
  227. package/dist/styles/stepper.css +13 -0
  228. package/dist/styles/streamdown.css +0 -4
  229. package/dist/styles/subagent-run.css +59 -42
  230. package/dist/styles/task.css +17 -10
  231. package/dist/styles/test-results.css +17 -10
  232. package/dist/styles/textarea.css +20 -0
  233. package/dist/styles/theme-mode-control.css +72 -0
  234. package/dist/styles/think-execution-status.css +49 -0
  235. package/dist/styles/think-execution-workbench.css +16 -80
  236. package/dist/styles/think-full-app.css +143 -128
  237. package/dist/styles/think-routine-library.css +491 -0
  238. package/dist/styles/think-thread-picker.css +47 -3
  239. package/dist/styles/toast.css +6 -6
  240. package/dist/styles/toggle-group.css +7 -0
  241. package/dist/styles/tooltip.css +1 -1
  242. package/dist/styles/workspace-explorer.css +516 -64
  243. package/dist/utils/mcp-server-catalog.d.ts +82 -78
  244. package/dist/utils/mcp-server-catalog.js +64 -41
  245. package/dist/utils/structured-code.d.ts +1 -1
  246. package/dist/utils/theme.d.ts +22 -0
  247. package/dist/utils/theme.js +55 -0
  248. package/package.json +34 -28
  249. package/dist/icons-Ba9THQKz.js +0 -64
  250. package/dist/styles/think-resize-handle.css +0 -33
  251. 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 { a as SessionContextToolPart, d as WorkspaceToolPart, n as ExecuteToolPart, o as SkillToolPart, r as FetchToolPart, t as BrowserToolPart } from "../ThinkChatToolParts-CDEjqS6A.js";
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
@@ -31,17 +31,19 @@ declare function ThinkChatFetchPanel({
31
31
  }: {
32
32
  part: FetchToolPart;
33
33
  }): React.JSX.Element;
34
+ interface ThinkChatExecutePanelProps {
35
+ /** Whole upstream Think execute-tool part, including its current output lifecycle. */
36
+ part: ExecuteToolPart;
37
+ }
34
38
  /** The codemode execute tool as an activity panel: highlighted TypeScript
35
39
  plus logs, result, and the paused pending-approval list. */
36
40
  declare function ThinkChatExecutePanel({
37
41
  part
38
- }: {
39
- part: ExecuteToolPart;
40
- }): React.JSX.Element;
42
+ }: ThinkChatExecutePanelProps): React.JSX.Element;
41
43
  declare function ThinkChatBrowserPanel({
42
44
  part
43
45
  }: {
44
46
  part: BrowserToolPart;
45
47
  }): React.JSX.Element;
46
48
  //#endregion
47
- export { ThinkChatBrowserPanel, ThinkChatExecutePanel, ThinkChatFetchPanel, ThinkChatSessionContextPanel, 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 { t as CodeBlock } from "../CodeBlock-BUFXG8HW.js";
4
- import { BrowserLiveView } from "./BrowserLiveView.js";
5
3
  import { displayUrl, isSessionContextToolFailure } from "./ThinkChatToolParts.js";
4
+ import { t as CodeBlock } from "../CodeBlock-BmB4Xaqq.js";
5
+ import { BrowserLiveView } from "./BrowserLiveView.js";
6
6
  import * as React from "react";
7
7
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
8
8
  import { getToolName } from "ai";
@@ -256,17 +256,79 @@ function findBrowserResultMedia(value, depth = 0) {
256
256
  return media;
257
257
  }
258
258
  function ExecuteCodeView({ code, output, hideResult }) {
259
+ const calls = output && "calls" in output ? output.calls : void 0;
259
260
  const sections = [
260
261
  output && "logs" in output && output.logs?.length ? output.logs.join("\n") : "",
261
262
  output?.status === "error" ? output.error : "",
262
- output?.status === "paused" ? formatPendingActions(output.pending) : "",
263
+ output?.status === "paused" && !calls?.length ? formatPendingActions(output.pending) : "",
263
264
  output?.status === "completed" && output.result !== void 0 && !hideResult ? typeof output.result === "string" ? output.result : JSON.stringify(output.result, null, 2) : ""
264
265
  ].filter(Boolean);
265
- return /* @__PURE__ */ jsxs(Fragment, { children: [code ? /* @__PURE__ */ jsx(CodeBlock, {
266
- className: "activity__code-block",
267
- code,
268
- language: "ts"
269
- }) : null, sections.length ? /* @__PURE__ */ jsx(ActivityOutput, { children: sections.join("\n\n") }) : null] });
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;
270
332
  }
271
333
  function formatPendingActions(pending) {
272
334
  return pending.map((action) => {
@@ -1,2 +1,2 @@
1
- import { S as isWorkspaceToolPart, _ as isPartWorking, a as SessionContextToolPart, b as isSkillToolPart, c as ThinkBashToolPart, d as WorkspaceToolPart, f as displayUrl, g as isPartFailed, h as isFetchToolPart, i as SessionContextToolName, l as ThinkChatPart, m as isExecuteToolPart, n as ExecuteToolPart, o as SkillToolPart, p as isBrowserToolPart, r as FetchToolPart, s as ThinkBashToolOutput, t as BrowserToolPart, u as ThinkWorkspaceToolName, v as isSessionContextToolFailure, x as isThinkChatActivityPart, y as isSessionContextToolPart } from "../ThinkChatToolParts-CDEjqS6A.js";
2
- export { BrowserToolPart, ExecuteToolPart, FetchToolPart, SessionContextToolName, SessionContextToolPart, SkillToolPart, ThinkBashToolOutput, ThinkBashToolPart, ThinkChatPart, ThinkWorkspaceToolName, WorkspaceToolPart, displayUrl, isBrowserToolPart, isExecuteToolPart, isFetchToolPart, isPartFailed, isPartWorking, isSessionContextToolFailure, isSessionContextToolPart, 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 };
@@ -1,6 +1,36 @@
1
- import { getToolPartState } from "@cloudflare/think/react";
2
1
  import { getStaticToolName, getToolName, isReasoningUIPart, isStaticToolUIPart, isToolUIPart } from "ai";
3
2
  //#region src/components/ThinkChatToolParts.ts
3
+ /** React-free equivalent of Think's UI-state mapping. Kept local so activity
4
+ * summaries can run in workers and extension background contexts. */
5
+ function getToolPartState(part) {
6
+ if (!("state" in part)) return "loading";
7
+ switch (part.state) {
8
+ case "input-streaming": return "streaming";
9
+ case "approval-requested": return "waiting-approval";
10
+ case "approval-responded": return "approved";
11
+ case "output-available": return "complete";
12
+ case "output-error": return "error";
13
+ case "output-denied": return "denied";
14
+ default: return "loading";
15
+ }
16
+ }
17
+ /** Prefer AI SDK's provider/tool-authored title over its transport-facing key. */
18
+ function getToolDisplayName(part) {
19
+ return part.title ?? getToolName(part);
20
+ }
21
+ /**
22
+ * Whole-part supplement to Think's simplified state mapping. Think maps every
23
+ * `output-available` part to complete, while AI SDK preliminary outputs remain
24
+ * in flight until a non-preliminary result arrives.
25
+ */
26
+ function isToolPartWorking(part) {
27
+ const state = getToolPartState(part);
28
+ return state === "loading" || state === "streaming" || state === "waiting-approval" || state === "approved" || part.state === "output-available" && part.preliminary === true;
29
+ }
30
+ function isToolPartFailed(part) {
31
+ const state = getToolPartState(part);
32
+ return state === "error" || state === "denied";
33
+ }
4
34
  const WORKSPACE_TOOL_NAMES = /* @__PURE__ */ new Set([
5
35
  "read",
6
36
  "write",
@@ -36,7 +66,7 @@ function isSessionContextToolPart(part) {
36
66
  model can recover. Treat that upstream `Error:` envelope as failed UI while
37
67
  preserving the recorded tool state and output verbatim. */
38
68
  function isSessionContextToolFailure(part) {
39
- return isPartFailed(part) || part.state === "output-available" && part.output.startsWith("Error:");
69
+ return isPartFailed(part) || part.state === "output-available" && typeof part.output === "string" && part.output.startsWith("Error:");
40
70
  }
41
71
  function isFetchToolPart(part) {
42
72
  return isStaticToolUIPart(part) && getStaticToolName(part).startsWith("fetch_");
@@ -61,22 +91,18 @@ function isThinkChatActivityPart(part, excludeTools) {
61
91
  if (isToolUIPart(part) && excludeTools?.has(getToolName(part))) return false;
62
92
  return part.type === "step-start" || isReasoningUIPart(part) || isToolUIPart(part);
63
93
  }
64
- /** In-flight: the stream opened this part but hasn't delivered its result yet. */
94
+ /** In-flight: awaiting input, approval continuation, or a final tool result. */
65
95
  function isPartWorking(part) {
66
96
  if (isReasoningUIPart(part)) return part.state === "streaming";
67
- if (isToolUIPart(part)) {
68
- const state = getToolPartState(part);
69
- return state === "loading" || state === "streaming" || state === "waiting-approval";
70
- }
97
+ if (isToolUIPart(part)) return isToolPartWorking(part);
71
98
  return false;
72
99
  }
73
100
  /** Errored or denied — upstream's simplified tool-part state vocabulary. */
74
101
  function isPartFailed(part) {
75
- const state = getToolPartState(part);
76
- return state === "error" || state === "denied";
102
+ return isToolUIPart(part) && isToolPartFailed(part);
77
103
  }
78
104
  function displayUrl(url) {
79
105
  return url ? url.replace(/^https?:\/\//, "") : "";
80
106
  }
81
107
  //#endregion
82
- export { displayUrl, isBrowserToolPart, isExecuteToolPart, isFetchToolPart, isPartFailed, isPartWorking, isSessionContextToolFailure, isSessionContextToolPart, isSkillToolPart, isThinkChatActivityPart, isWorkspaceToolPart };
108
+ export { displayUrl, getToolDisplayName, isBrowserToolPart, isExecuteToolPart, isFetchToolPart, isPartFailed, isPartWorking, isSessionContextToolFailure, isSessionContextToolPart, isSkillToolPart, isThinkChatActivityPart, isToolPartFailed, isToolPartWorking, isWorkspaceToolPart };
@@ -0,0 +1,20 @@
1
+ import { t as ThinkExecutionRun } from "../ThinkExecutionRun-ChhWhOoU.js";
2
+ import * as React from "react";
3
+
4
+ //#region src/components/ThinkExecutionDetail.d.ts
5
+ interface ThinkExecutionDetailProps extends React.HTMLAttributes<HTMLElement> {
6
+ run: ThinkExecutionRun | null;
7
+ emptyState?: React.ReactNode;
8
+ }
9
+ /** Native Think submission or Agents Workflow detail, reusable outside the execution workbench. */
10
+ declare function ThinkExecutionDetail({
11
+ className,
12
+ emptyState,
13
+ ref,
14
+ run,
15
+ ...props
16
+ }: ThinkExecutionDetailProps & {
17
+ ref?: React.Ref<HTMLElement>;
18
+ }): React.JSX.Element;
19
+ //#endregion
20
+ export { ThinkExecutionDetail, ThinkExecutionDetailProps };