@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.
Files changed (241) hide show
  1. package/dist/AgentActivity-BNUNrP9O.d.ts +36 -0
  2. package/dist/{AgentChat-Cgb1xuT7.d.ts → AgentChat-CrlpbvQJ.d.ts} +62 -8
  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-DVgVBdvw.js → ModelSelector-SlJNgwKY.js} +17 -8
  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-7DQ2CogF.js → ThinkChat-CzC-zNGA.js} +27 -37
  12. package/dist/{ThinkChatActivity-m9orbdeI.d.ts → ThinkChatActivity-BFQnb2ct.d.ts} +3 -10
  13. package/dist/ThinkChatActivitySummary-BPmu9a-c.d.ts +39 -0
  14. package/dist/{ThinkChatToolParts-Cv4o7j6F.d.ts → ThinkChatToolParts-CSzVwMXf.d.ts} +62 -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 +231 -205
  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.d.ts +15 -3
  80. package/dist/components/ModelSelector.js +1 -1
  81. package/dist/components/NaniteScene.d.ts +10 -1
  82. package/dist/components/NaniteScene.js +36 -1
  83. package/dist/components/Pricing.d.ts +37 -0
  84. package/dist/components/Pricing.js +17 -0
  85. package/dist/components/PricingBillingToggle.d.ts +23 -0
  86. package/dist/components/PricingBillingToggle.js +86 -0
  87. package/dist/components/PricingConfirmationDialog.d.ts +25 -0
  88. package/dist/components/PricingConfirmationDialog.js +57 -0
  89. package/dist/components/PricingFAQ.d.ts +18 -0
  90. package/dist/components/PricingFAQ.js +27 -0
  91. package/dist/components/PricingPage.d.ts +2 -38
  92. package/dist/components/PricingPage.js +39 -359
  93. package/dist/components/PricingPlanCard.d.ts +22 -0
  94. package/dist/components/PricingPlanCard.js +109 -0
  95. package/dist/components/PricingUsageCalculator.d.ts +22 -0
  96. package/dist/components/PricingUsageCalculator.js +96 -0
  97. package/dist/components/PromptInput.d.ts +2 -2
  98. package/dist/components/PromptInput.js +210 -15
  99. package/dist/components/Queue.js +1 -1
  100. package/dist/components/Reasoning.d.ts +2 -1
  101. package/dist/components/Reasoning.js +14 -29
  102. package/dist/components/ResizableSidePanel.d.ts +57 -0
  103. package/dist/components/ResizableSidePanel.js +151 -0
  104. package/dist/components/ResponsiveSidebarShell.d.ts +2 -0
  105. package/dist/components/ResponsiveSidebarShell.js +129 -0
  106. package/dist/components/Select.d.ts +2 -2
  107. package/dist/components/Select.js +11 -2
  108. package/dist/components/Slider.d.ts +13 -1
  109. package/dist/components/Slider.js +11 -0
  110. package/dist/components/Sources.js +1 -1
  111. package/dist/components/Stepper.d.ts +4 -0
  112. package/dist/components/Stepper.js +5 -3
  113. package/dist/components/SubagentRun.d.ts +86 -0
  114. package/dist/components/SubagentRun.js +108 -0
  115. package/dist/components/SubagentRunDetails.d.ts +44 -0
  116. package/dist/components/SubagentRunDetails.js +48 -0
  117. package/dist/components/SubagentRunIndicator.d.ts +22 -0
  118. package/dist/components/SubagentRunIndicator.js +33 -0
  119. package/dist/components/SubagentRunList.d.ts +25 -0
  120. package/dist/components/SubagentRunList.js +26 -0
  121. package/dist/components/SubagentRunSelector.d.ts +47 -0
  122. package/dist/components/SubagentRunSelector.js +55 -0
  123. package/dist/components/Task.js +1 -1
  124. package/dist/components/Terminal.js +2 -2
  125. package/dist/components/TestResults.js +1 -1
  126. package/dist/components/Textarea.d.ts +21 -0
  127. package/dist/components/Textarea.js +19 -0
  128. package/dist/components/ThemeModeControl.d.ts +24 -0
  129. package/dist/components/ThemeModeControl.js +52 -0
  130. package/dist/components/ThemeProvider.d.ts +38 -0
  131. package/dist/components/ThemeProvider.js +80 -0
  132. package/dist/components/ThinkChat.d.ts +34 -7
  133. package/dist/components/ThinkChat.js +7 -4
  134. package/dist/components/ThinkChatActivity.d.ts +3 -2
  135. package/dist/components/ThinkChatActivity.js +18 -297
  136. package/dist/components/ThinkChatActivitySummary.d.ts +2 -0
  137. package/dist/components/ThinkChatActivitySummary.js +421 -0
  138. package/dist/components/ThinkChatToolPanels.d.ts +15 -5
  139. package/dist/components/ThinkChatToolPanels.js +116 -9
  140. package/dist/components/ThinkChatToolParts.d.ts +2 -2
  141. package/dist/components/ThinkChatToolParts.js +51 -9
  142. package/dist/components/ThinkExecutionDetail.d.ts +20 -0
  143. package/dist/components/ThinkExecutionDetail.js +80 -0
  144. package/dist/components/ThinkExecutionRun.d.ts +2 -0
  145. package/dist/components/ThinkExecutionRun.js +72 -0
  146. package/dist/components/ThinkExecutionStatus.d.ts +22 -0
  147. package/dist/components/ThinkExecutionStatus.js +36 -0
  148. package/dist/components/ThinkExecutionWorkbench.d.ts +7 -0
  149. package/dist/components/ThinkExecutionWorkbench.js +69 -225
  150. package/dist/components/ThinkFullApp.d.ts +58 -14
  151. package/dist/components/ThinkFullApp.js +129 -160
  152. package/dist/components/ThinkFullAppViewSwitch.d.ts +31 -0
  153. package/dist/components/ThinkFullAppViewSwitch.js +34 -0
  154. package/dist/components/ThinkRoutine.d.ts +36 -0
  155. package/dist/components/ThinkRoutine.js +15 -0
  156. package/dist/components/ThinkRoutineBrowser.d.ts +25 -0
  157. package/dist/components/ThinkRoutineBrowser.js +156 -0
  158. package/dist/components/ThinkRoutineDetail.d.ts +24 -0
  159. package/dist/components/ThinkRoutineDetail.js +102 -0
  160. package/dist/components/ThinkRoutineForm.d.ts +32 -0
  161. package/dist/components/ThinkRoutineForm.js +151 -0
  162. package/dist/components/ThinkRoutineLibrary.d.ts +74 -0
  163. package/dist/components/ThinkRoutineLibrary.js +178 -0
  164. package/dist/components/ThinkRoutineRuns.d.ts +24 -0
  165. package/dist/components/ThinkRoutineRuns.js +68 -0
  166. package/dist/components/ThinkThreadPicker.d.ts +18 -1
  167. package/dist/components/ThinkThreadPicker.js +51 -5
  168. package/dist/components/ThinkThreadShell.d.ts +12 -9
  169. package/dist/components/ThinkThreadShell.js +17 -137
  170. package/dist/components/Toggle.d.ts +1 -68
  171. package/dist/components/ToggleGroup.d.ts +1 -72
  172. package/dist/components/Tooltip.d.ts +3 -1
  173. package/dist/components/Tooltip.js +4 -2
  174. package/dist/components/WebPreview.js +1 -1
  175. package/dist/components/Workspace.d.ts +2 -0
  176. package/dist/components/Workspace.js +424 -0
  177. package/dist/components/WorkspaceBrowser.d.ts +32 -0
  178. package/dist/components/WorkspaceBrowser.js +103 -0
  179. package/dist/components/WorkspaceExplorer.d.ts +12 -79
  180. package/dist/components/WorkspaceExplorer.js +116 -330
  181. package/dist/components/WorkspaceFile.d.ts +2 -0
  182. package/dist/components/WorkspaceFile.js +195 -0
  183. package/dist/components/WorkspaceFileView.d.ts +26 -0
  184. package/dist/components/WorkspaceFileView.js +2 -0
  185. package/dist/components/WorkspaceHeader.d.ts +35 -0
  186. package/dist/components/WorkspaceHeader.js +51 -0
  187. package/dist/components/WorkspaceLink.d.ts +2 -0
  188. package/dist/components/WorkspaceLink.js +2 -0
  189. package/dist/components/icons.d.ts +2 -2
  190. package/dist/components/icons.js +2 -2
  191. package/dist/{copy-button-DUMLYdsk.js → copy-button-Dejn5heL.js} +1 -1
  192. package/dist/icons-CpfUer49.js +85 -0
  193. package/dist/{icons-CUCz_Sft.d.ts → icons-GQd1xF4e.d.ts} +51 -1
  194. package/dist/styles/activity-header.css +75 -0
  195. package/dist/styles/activity.css +49 -63
  196. package/dist/styles/agent-activity-preview-overlay.css +80 -0
  197. package/dist/styles/agent-activity-preview.css +235 -0
  198. package/dist/styles/agent-attention.css +122 -0
  199. package/dist/styles/agent-chat.css +141 -4
  200. package/dist/styles/app-frame.css +15 -0
  201. package/dist/styles/app-top-bar.css +100 -0
  202. package/dist/styles/avatar.css +0 -1
  203. package/dist/styles/browser-control-overlay.css +184 -0
  204. package/dist/styles/card.css +21 -0
  205. package/dist/styles/checkbox-group.css +69 -0
  206. package/dist/styles/description-list.css +50 -0
  207. package/dist/styles/fieldset.css +11 -0
  208. package/dist/styles/index.css +15 -2
  209. package/dist/styles/mcp-connection-request.css +60 -0
  210. package/dist/styles/mcp-server-picker.css +95 -68
  211. package/dist/styles/message.css +4 -43
  212. package/dist/styles/nanite-scene.css +16 -0
  213. package/dist/styles/pricing-page.css +21 -27
  214. package/dist/styles/prompt-input.css +225 -32
  215. package/dist/styles/reasoning.css +1 -55
  216. package/dist/styles/recipes.css +23 -15
  217. package/dist/styles/resizable-side-panel.css +66 -0
  218. package/dist/styles/responsive-sidebar-shell.css +169 -0
  219. package/dist/styles/select.css +10 -0
  220. package/dist/styles/stepper.css +13 -0
  221. package/dist/styles/streamdown.css +0 -4
  222. package/dist/styles/subagent-run.css +205 -0
  223. package/dist/styles/textarea.css +20 -0
  224. package/dist/styles/theme-mode-control.css +72 -0
  225. package/dist/styles/think-execution-status.css +49 -0
  226. package/dist/styles/think-execution-workbench.css +8 -72
  227. package/dist/styles/think-full-app.css +106 -131
  228. package/dist/styles/think-routine-library.css +491 -0
  229. package/dist/styles/think-thread-picker.css +47 -3
  230. package/dist/styles/toggle-group.css +7 -0
  231. package/dist/styles/workspace-explorer.css +511 -64
  232. package/dist/utils/codex-model-catalog.d.ts +4 -4
  233. package/dist/utils/mcp-server-catalog.d.ts +82 -78
  234. package/dist/utils/mcp-server-catalog.js +64 -41
  235. package/dist/utils/structured-code.d.ts +1 -1
  236. package/dist/utils/theme.d.ts +22 -0
  237. package/dist/utils/theme.js +55 -0
  238. package/package.json +34 -28
  239. package/dist/icons-Ba9THQKz.js +0 -64
  240. package/dist/styles/think-resize-handle.css +0 -33
  241. package/dist/styles/think-thread-shell.css +0 -219
@@ -0,0 +1,36 @@
1
+ import { n as WorkspaceDestination } from "./WorkspaceLink-DK1DWMHe.js";
2
+ import * as React from "react";
3
+
4
+ //#region src/components/AgentActivity.d.ts
5
+ type AgentActivityMode = "working" | "approval";
6
+ type AgentActivityIconKind = "thought" | "read" | "edit" | "search" | "web" | "command" | "browser" | "tool" | "approval";
7
+ /** Safe, serializable presentation state suitable for an Agents SDK state object. */
8
+ interface AgentActivitySummary<CustomIcon extends string = never> {
9
+ mode: AgentActivityMode;
10
+ label: string;
11
+ iconKind: AgentActivityIconKind | CustomIcon;
12
+ /** Optional presentation hint. Consumers decide whether exposing or fetching it is safe. */
13
+ url?: string;
14
+ /** Optional file target. Hosts validate it against their workspace before navigation. */
15
+ workspaceDestination?: Extract<WorkspaceDestination, {
16
+ kind: "file";
17
+ }>;
18
+ }
19
+ interface AgentActivityIconProps {
20
+ kind: string;
21
+ }
22
+ /** Built-in icon vocabulary shared by AI SDK activity and Agents SDK state summaries. */
23
+ declare function AgentActivityIcon({
24
+ kind
25
+ }: AgentActivityIconProps): React.JSX.Element;
26
+ interface AgentActivityFaviconProps {
27
+ url: string;
28
+ fallbackKind?: AgentActivityIconKind;
29
+ }
30
+ /** Site favicon for URL-backed activity, with the shared icon vocabulary as fallback. */
31
+ declare function AgentActivityFavicon({
32
+ fallbackKind,
33
+ url
34
+ }: AgentActivityFaviconProps): React.JSX.Element;
35
+ //#endregion
36
+ export { AgentActivityIconProps as a, AgentActivityIconKind as i, AgentActivityFaviconProps as n, AgentActivityMode as o, AgentActivityIcon as r, AgentActivitySummary as s, AgentActivityFavicon as t };
@@ -1,4 +1,4 @@
1
- import { W as PromptInputDictationProps, tt as PromptInputMessage } from "./PromptInput-ClNqBiIw.js";
1
+ import { Z as PromptInputContextSelectorProps, _t as PromptInputReference, dt as PromptInputMessage, et as PromptInputDictationProps, j as PromptInputCommandDefinition, r as PermissionMode } from "./PromptInput-BWTuXMOD.js";
2
2
  import * as React from "react";
3
3
  import { ChatAddToolApproveResponseFunction, ChatStatus, UIMessage } from "ai";
4
4
  import { PendingApproval, Think } from "@cloudflare/think";
@@ -44,8 +44,7 @@ interface AgentChatProps<MessageT extends UIMessage = UIMessage> {
44
44
  * @example Think session compaction setup
45
45
  * ```ts
46
46
  * import { Think, defaultContextOverflowClassifier } from "@cloudflare/think";
47
- * import { Session } from "agents/experimental/memory/session";
48
- * import { createCompactFunction } from "agents/experimental/memory/utils";
47
+ * import { Session, createCompactFunction } from "agents/sessions";
49
48
  * import { generateText } from "ai";
50
49
  *
51
50
  * export class MyAgent extends Think<Env> {
@@ -78,14 +77,45 @@ interface AgentChatProps<MessageT extends UIMessage = UIMessage> {
78
77
  status?: ChatStatus;
79
78
  /** Called with the composed message when the user submits. Omit for a read-only transcript. */
80
79
  onSubmit?: (message: PromptInputMessage) => void | Promise<void>;
80
+ /** Show the prompt composer. Defaults to whether `onSubmit` is provided. */
81
+ showComposer?: boolean;
81
82
  /** Called when the user hits stop while `status` is streaming/submitted. */
82
83
  onStop?: () => void;
84
+ /**
85
+ * Let a composed follow-up submit while a response is active. The single
86
+ * trailing action remains Stop until the draft contains content, then
87
+ * becomes Queue. The transport remains the queue owner.
88
+ */
89
+ allowSubmitWhileBusy?: boolean;
90
+ /**
91
+ * Authoritative user messages waiting behind the active turn. Their ids are
92
+ * excluded from the transcript and rendered as queued cards above the composer.
93
+ */
94
+ queuedMessages?: readonly MessageT[];
95
+ /** Promote a queued message into the host's steering flow. */
96
+ onSteerQueuedMessage?: (message: MessageT) => void;
97
+ /** Remove a queued message through the host-owned queue transport. */
98
+ onRemoveQueuedMessage?: (message: MessageT) => void;
83
99
  placeholder?: string;
84
100
  disabled?: boolean;
85
101
  /** Rendered in place of the transcript while `messages` is empty. */
86
102
  emptyState?: React.ReactNode;
87
103
  /** Extra controls rendered in the composer toolbar. */
88
104
  composerTools?: React.ReactNode;
105
+ /** Controlled slash-command catalog and host-owned selection policy. */
106
+ slashCommands?: {
107
+ items: readonly PromptInputCommandDefinition[];
108
+ onSelect?: (command: PromptInputCommandDefinition, draft: AgentChatComposerDraft) => void;
109
+ };
110
+ /** Controlled MCP catalog revealed by `@`; selections become composer references. */
111
+ mentionCommands?: {
112
+ items: readonly PromptInputCommandDefinition[];
113
+ onSelect?: (command: PromptInputCommandDefinition, draft: AgentChatComposerDraft) => void;
114
+ };
115
+ /** Controlled folder or working-context picker rendered beside permission controls. */
116
+ contextSelector?: PromptInputContextSelectorProps;
117
+ /** Extra controls rendered at the trailing edge, before dictation and submit. */
118
+ composerEndTools?: React.ReactNode;
89
119
  /** Whole upstream voice-input hook result used by the built-in dictation recorder. */
90
120
  voiceInput?: UseVoiceInputReturn;
91
121
  /** Host prerequisite run before the built-in recorder calls `voiceInput.start()`. */
@@ -131,6 +161,8 @@ interface AgentChatProps<MessageT extends UIMessage = UIMessage> {
131
161
  onApprovalResponse?: ChatAddToolApproveResponseFunction;
132
162
  /** Whole upstream Think stub used to resolve paused and durable execution approvals. */
133
163
  thinkStub?: AgentStub<Think>;
164
+ /** Parent-owned approval policy. Omit to keep AgentChat's session-local mode. */
165
+ permissionModeControl?: PermissionModeControl;
134
166
  /** Called after a Think approve/reject RPC settles, including when it rejects. */
135
167
  onExecutionSettled?: () => void | Promise<void>;
136
168
  /** Think durable-pause approvals from `pendingApprovals()`, rendered when `thinkStub` is set. */
@@ -153,10 +185,10 @@ interface AgentChatProps<MessageT extends UIMessage = UIMessage> {
153
185
  * `isTextUIPart`, `isReasoningUIPart`, `isFileUIPart`, `isToolUIPart`,
154
186
  * `getToolName`, and Think's `getToolPartState`/input/output accessors. It
155
187
  * also renders native AI SDK `source-url`/`source-document` parts as a single
156
- * grouped `Sources` block when they appear consecutively, and native
157
- * `step-start` parts as step separators. App-defined `data-*` parts stay
158
- * whole and should be narrowed with AI SDK's `isDataUIPart` inside this
159
- * callback. If you override source rendering,
188
+ * grouped `Sources` block when they appear consecutively, consolidates native
189
+ * reasoning parts into one disclosure, and treats `step-start` as a silent
190
+ * structural boundary. App-defined `data-*` parts stay whole and should be
191
+ * narrowed with AI SDK's `isDataUIPart` inside this callback. If you override source rendering,
160
192
  * return a React node for every source part you want to show; returning
161
193
  * `undefined` lets `AgentChat` keep the upstream-shaped source-run grouping.
162
194
  */
@@ -164,6 +196,18 @@ interface AgentChatProps<MessageT extends UIMessage = UIMessage> {
164
196
  /** Rendered after each message's parts — for actions, citations, and the like. */
165
197
  renderMessageAfter?: (context: AgentChatRenderMessageContext<MessageT>) => React.ReactNode;
166
198
  }
199
+ interface AgentChatComposerDraft {
200
+ value: string;
201
+ references: readonly PromptInputReference[];
202
+ setValue: (value: string) => void;
203
+ clear: () => void;
204
+ addReference: (reference: PromptInputReference) => void;
205
+ removeReference: (reference: PromptInputReference) => void;
206
+ }
207
+ interface PermissionModeControl {
208
+ value: PermissionMode;
209
+ onChange: (mode: PermissionMode) => void | Promise<void>;
210
+ }
167
211
  /**
168
212
  * Low-level transcript/composer surface used by `ThinkChat`: props in, no
169
213
  * transport. Product code that talks to a Cloudflare Think agent should render
@@ -172,14 +216,23 @@ interface AgentChatProps<MessageT extends UIMessage = UIMessage> {
172
216
  declare function AgentChat<MessageT extends UIMessage = UIMessage>({
173
217
  className,
174
218
  messages,
219
+ queuedMessages,
220
+ onSteerQueuedMessage,
221
+ onRemoveQueuedMessage,
175
222
  status,
176
223
  onSubmit,
224
+ showComposer,
177
225
  onStop,
226
+ allowSubmitWhileBusy,
178
227
  placeholder,
179
228
  disabled,
180
229
  emptyState,
181
230
  composerHeader,
182
231
  composerTools,
232
+ slashCommands,
233
+ mentionCommands,
234
+ contextSelector,
235
+ composerEndTools,
183
236
  voiceInput,
184
237
  beforeVoiceStart,
185
238
  composerAddMenuItems,
@@ -188,6 +241,7 @@ declare function AgentChat<MessageT extends UIMessage = UIMessage>({
188
241
  onEditAndResend,
189
242
  onApprovalResponse,
190
243
  thinkStub,
244
+ permissionModeControl,
191
245
  onExecutionSettled,
192
246
  pendingApprovals: durableApprovals,
193
247
  contextWindow,
@@ -198,4 +252,4 @@ declare function AgentChat<MessageT extends UIMessage = UIMessage>({
198
252
  ref?: React.Ref<HTMLDivElement>;
199
253
  }): React.JSX.Element;
200
254
  //#endregion
201
- export { AgentChatRenderPartContext as a, AgentChatRenderMessageContext as i, AgentChatPart as n, AgentChatProps as r, AgentChat as t };
255
+ export { AgentChatRenderMessageContext as a, AgentChatProps as i, AgentChatComposerDraft as n, AgentChatRenderPartContext as o, AgentChatPart as r, PermissionModeControl as s, AgentChat as t };
@@ -1,4 +1,4 @@
1
- import { p as SelectProps, t as Select } from "./Select-Dl_vF_Bt.js";
1
+ import { m as SelectProps, t as Select } from "./Select-BeEsefzh.js";
2
2
  import { t as CopyButtonProps } from "./copy-button-DtPMgN7e.js";
3
3
  import * as React from "react";
4
4
  import { BundledLanguage, ThemedToken } from "shiki";
@@ -1,6 +1,6 @@
1
1
  import { t as cx } from "./class-names-9UtZwb0J.js";
2
2
  import { Select } from "./components/Select.js";
3
- import { t as CopyButton } from "./copy-button-DUMLYdsk.js";
3
+ import { t as CopyButton } from "./copy-button-Dejn5heL.js";
4
4
  import * as React from "react";
5
5
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
6
6
  import { createHighlighter } from "shiki";
@@ -308,18 +308,29 @@ function CodeBlockContainer({ className, children, ref, ...props }) {
308
308
  function CodeBlockContent({ className, ref, ...props }) {
309
309
  const { code, language, showLineNumbers, isStreaming } = useCodeBlockContext();
310
310
  const [html, setHtml] = React.useState(null);
311
- const [theme, setTheme] = React.useState(() => typeof document !== "undefined" && document.documentElement.dataset.theme === "dark" ? "github-dark-high-contrast" : "github-light-high-contrast");
311
+ const [theme, setTheme] = React.useState(() => {
312
+ if (typeof document === "undefined") return "github-light-high-contrast";
313
+ const preference = document.documentElement.dataset.theme;
314
+ return preference === "dark" || preference === void 0 && window.matchMedia("(prefers-color-scheme: dark)").matches ? "github-dark-high-contrast" : "github-light-high-contrast";
315
+ });
312
316
  React.useEffect(() => {
313
317
  if (typeof document === "undefined") return;
318
+ const mediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
314
319
  const update = () => {
315
- setTheme(document.documentElement.dataset.theme === "dark" ? "github-dark-high-contrast" : "github-light-high-contrast");
320
+ const preference = document.documentElement.dataset.theme;
321
+ const dark = preference === "dark" || preference === void 0 && mediaQuery.matches;
322
+ setTheme(dark ? "github-dark-high-contrast" : "github-light-high-contrast");
316
323
  };
317
324
  const observer = new MutationObserver(update);
318
325
  observer.observe(document.documentElement, {
319
326
  attributes: true,
320
327
  attributeFilter: ["data-theme"]
321
328
  });
322
- return () => observer.disconnect();
329
+ mediaQuery.addEventListener("change", update);
330
+ return () => {
331
+ observer.disconnect();
332
+ mediaQuery.removeEventListener("change", update);
333
+ };
323
334
  }, []);
324
335
  React.useEffect(() => {
325
336
  if (isStreaming) return;
@@ -1,5 +1,5 @@
1
1
  import { t as cx } from "./class-names-9UtZwb0J.js";
2
- import { _ as FolderOpenIcon, c as ChevronRightIcon, g as FolderIcon, h as FileIcon } from "./icons-Ba9THQKz.js";
2
+ import { b as FolderOpenIcon, l as ChevronRightIcon, v as FileIcon, y as FolderIcon } from "./icons-CpfUer49.js";
3
3
  import * as React from "react";
4
4
  import { jsx, jsxs } from "react/jsx-runtime";
5
5
  //#region src/components/_internal/use-file-tree-nav.ts
@@ -10,41 +10,11 @@ function useFileTreeContext() {
10
10
  return ctx;
11
11
  }
12
12
  /**
13
- * Builds a FileTreeContextValue that tracks registered nodes and dispatches
14
- * keyboard navigation per the WAI-ARIA Tree Pattern.
15
- *
16
- * Call `register` from every FileTreeFolder/FileTreeFile during render. The
17
- * hook resets its internal list on each render pass so removed nodes don't
18
- * leave stale entries.
13
+ * Builds a FileTreeContextValue that dispatches keyboard navigation per the
14
+ * WAI-ARIA Tree Pattern.
19
15
  */
20
- function useFileTreeNav({ expanded, selectedPath, onSelect, onExpandedChange }) {
21
- const [focusedPath, setFocusedPath] = React.useState(null);
22
- const nodesRef = React.useRef([]);
23
- nodesRef.current = [];
24
- const register = React.useCallback((path, kind, parentExpanded) => {
25
- nodesRef.current.push({
26
- path,
27
- kind,
28
- visible: parentExpanded
29
- });
30
- }, []);
31
- const visibleNodes = () => nodesRef.current.filter((n) => n.visible);
32
- const moveFocus = React.useCallback((direction, from) => {
33
- const visible = visibleNodes();
34
- const idx = visible.findIndex((n) => n.path === from);
35
- if (idx < 0) return;
36
- const next = visible[Math.max(0, Math.min(visible.length - 1, idx + direction))];
37
- if (next) setFocusedPath(next.path);
38
- }, []);
39
- const focusFirstVisibleNode = React.useCallback(() => {
40
- const first = visibleNodes()[0];
41
- if (first) setFocusedPath(first.path);
42
- }, []);
43
- const focusLastVisibleNode = React.useCallback(() => {
44
- const visible = visibleNodes();
45
- const last = visible[visible.length - 1];
46
- if (last) setFocusedPath(last.path);
47
- }, []);
16
+ function useFileTreeNav({ expanded, initialFocusedPath, selectedPath, onSelect, onExpandedChange }) {
17
+ const [focusedPath, setFocusedPath] = React.useState(initialFocusedPath);
48
18
  const setFolderExpanded = React.useCallback((path, nextExpanded) => {
49
19
  const next = new Set(expanded);
50
20
  if (nextExpanded) next.add(path);
@@ -54,54 +24,52 @@ function useFileTreeNav({ expanded, selectedPath, onSelect, onExpandedChange })
54
24
  const toggleFolderExpanded = React.useCallback((path) => {
55
25
  setFolderExpanded(path, !expanded.has(path));
56
26
  }, [expanded, setFolderExpanded]);
57
- const keyHandlers = React.useMemo(() => ({
58
- ArrowDown(path) {
59
- moveFocus(1, path);
60
- },
61
- ArrowUp(path) {
62
- moveFocus(-1, path);
63
- },
64
- ArrowRight(path, kind) {
65
- if (!(kind === "folder")) return;
66
- if (expanded.has(path)) moveFocus(1, path);
67
- else setFolderExpanded(path, true);
68
- },
69
- ArrowLeft(path, kind) {
70
- if (kind === "folder" && expanded.has(path)) setFolderExpanded(path, false);
71
- },
72
- Enter(path, kind) {
73
- if (kind === "folder") {
74
- onSelect(path);
75
- toggleFolderExpanded(path);
76
- } else onSelect(path);
77
- },
78
- " "(path, kind) {
79
- if (kind === "folder") {
27
+ const handleKeyDown = React.useCallback((event, path, kind) => {
28
+ const tree = event.currentTarget.closest("[role=\"tree\"]");
29
+ const nodes = tree ? [...tree.querySelectorAll(".file-tree__node")] : [];
30
+ const currentIndex = nodes.indexOf(event.currentTarget);
31
+ const focusAt = (index) => nodes[index]?.focus();
32
+ switch (event.key) {
33
+ case "ArrowDown":
34
+ event.preventDefault();
35
+ focusAt(Math.min(nodes.length - 1, currentIndex + 1));
36
+ break;
37
+ case "ArrowUp":
38
+ event.preventDefault();
39
+ focusAt(Math.max(0, currentIndex - 1));
40
+ break;
41
+ case "ArrowRight":
42
+ if (kind !== "folder") return;
43
+ event.preventDefault();
44
+ if (expanded.has(path)) focusAt(currentIndex + 1);
45
+ else setFolderExpanded(path, true);
46
+ break;
47
+ case "ArrowLeft":
48
+ if (kind !== "folder" || !expanded.has(path)) return;
49
+ event.preventDefault();
50
+ setFolderExpanded(path, false);
51
+ break;
52
+ case "Enter":
53
+ case " ":
54
+ event.preventDefault();
80
55
  onSelect(path);
81
- toggleFolderExpanded(path);
82
- } else onSelect(path);
83
- },
84
- Home() {
85
- focusFirstVisibleNode();
86
- },
87
- End() {
88
- focusLastVisibleNode();
56
+ if (kind === "folder") toggleFolderExpanded(path);
57
+ break;
58
+ case "Home":
59
+ event.preventDefault();
60
+ focusAt(0);
61
+ break;
62
+ case "End":
63
+ event.preventDefault();
64
+ focusAt(nodes.length - 1);
65
+ break;
89
66
  }
90
- }), [
67
+ }, [
91
68
  expanded,
92
- focusFirstVisibleNode,
93
- focusLastVisibleNode,
94
- moveFocus,
95
69
  onSelect,
96
70
  setFolderExpanded,
97
71
  toggleFolderExpanded
98
72
  ]);
99
- const handleKeyDown = React.useCallback((event, path, kind) => {
100
- const keyHandler = keyHandlers[event.key];
101
- if (!keyHandler) return;
102
- event.preventDefault();
103
- keyHandler(path, kind);
104
- }, [keyHandlers]);
105
73
  return {
106
74
  focusedPath,
107
75
  selectedPath,
@@ -113,12 +81,23 @@ function useFileTreeNav({ expanded, selectedPath, onSelect, onExpandedChange })
113
81
  onExpandedChange: React.useCallback((path, next) => {
114
82
  setFolderExpanded(path, next);
115
83
  }, [setFolderExpanded]),
116
- register,
117
84
  handleKeyDown
118
85
  };
119
86
  }
120
87
  //#endregion
121
88
  //#region src/components/FileTree.tsx
89
+ function getFirstFileTreePath(children) {
90
+ let firstPath = null;
91
+ React.Children.forEach(children, (child) => {
92
+ if (firstPath || !React.isValidElement(child)) return;
93
+ if (child.type === FileTreeFolder || child.type === FileTreeFile) {
94
+ firstPath = child.props.path;
95
+ return;
96
+ }
97
+ if (child.type === React.Fragment) firstPath = getFirstFileTreePath(child.props.children);
98
+ });
99
+ return firstPath;
100
+ }
122
101
  /**
123
102
  * A keyboard-accessible hierarchical file browser. Compose with
124
103
  * FileTreeFolder and FileTreeFile children.
@@ -146,14 +125,28 @@ function FileTree({ className, "aria-label": ariaLabel = "File tree", expanded,
146
125
  if (!isControlled) setInternalExpanded(next);
147
126
  onExpandedChange?.(next);
148
127
  }, [isControlled, onExpandedChange]);
128
+ const handleSelect = React.useCallback((path) => {
129
+ onSelect?.(path);
130
+ }, [onSelect]);
149
131
  const ctx = useFileTreeNav({
150
132
  expanded: currentExpanded,
133
+ initialFocusedPath: getFirstFileTreePath(children),
151
134
  selectedPath,
152
- onSelect: React.useCallback((path) => {
153
- onSelect?.(path);
154
- }, [onSelect]),
135
+ onSelect: handleSelect,
155
136
  onExpandedChange: handleExpandedChange
156
137
  });
138
+ const treeRef = React.useRef(null);
139
+ React.useLayoutEffect(() => {
140
+ const nodes = [...treeRef.current?.querySelectorAll(".file-tree__node") ?? []];
141
+ if (nodes.length === 0) return;
142
+ if (nodes.some((node) => node.dataset.workspacePath === ctx.focusedPath)) return;
143
+ const firstPath = nodes[0]?.dataset.workspacePath;
144
+ if (firstPath) ctx.onFocus(firstPath);
145
+ }, [
146
+ children,
147
+ ctx.focusedPath,
148
+ ctx.onFocus
149
+ ]);
157
150
  return /* @__PURE__ */ jsx(FileTreeContext.Provider, {
158
151
  value: ctx,
159
152
  children: /* @__PURE__ */ jsx("div", {
@@ -161,10 +154,10 @@ function FileTree({ className, "aria-label": ariaLabel = "File tree", expanded,
161
154
  className: cx("file-tree", className),
162
155
  ...props,
163
156
  children: /* @__PURE__ */ jsx("ul", {
157
+ ref: treeRef,
164
158
  className: "file-tree__list",
165
159
  role: "tree",
166
160
  "aria-label": ariaLabel,
167
- tabIndex: 0,
168
161
  children
169
162
  })
170
163
  })
@@ -177,18 +170,17 @@ function renderNestedFileTreeChild(child, level) {
177
170
  function dataFlag(enabled) {
178
171
  return enabled ? "" : void 0;
179
172
  }
180
- function getFileTreeNodeTabIndex(focusedPath, path, level) {
181
- return focusedPath === path || !focusedPath && level === 0 ? 0 : -1;
173
+ function getFileTreeNodeTabIndex(focusedPath, path) {
174
+ return focusedPath === path ? 0 : -1;
182
175
  }
183
176
  function getFileTreeNodeIndent(level, offset) {
184
177
  return `${level * 1.125 + offset}rem`;
185
178
  }
186
179
  function FileTreeFolder({ className, path, name, level = 0, children, ref, ...props }) {
187
- const { expanded, focusedPath, selectedPath, onFocus, onSelect, register, handleKeyDown, onExpandedChange } = useFileTreeContext();
180
+ const { expanded, focusedPath, selectedPath, onFocus, onSelect, handleKeyDown, onExpandedChange } = useFileTreeContext();
188
181
  const isExpanded = expanded.has(path);
189
182
  const isFocused = focusedPath === path;
190
183
  const isSelected = selectedPath === path;
191
- register(path, "folder", true);
192
184
  const toggle = React.useCallback(() => {
193
185
  onExpandedChange(path, !isExpanded);
194
186
  }, [
@@ -216,7 +208,8 @@ function FileTreeFolder({ className, path, name, level = 0, children, ref, ...pr
216
208
  className: "file-tree__node file-tree__node--folder",
217
209
  "data-focused": dataFlag(isFocused),
218
210
  "data-selected": dataFlag(isSelected),
219
- tabIndex: getFileTreeNodeTabIndex(focusedPath, path, level),
211
+ "data-workspace-path": path,
212
+ tabIndex: getFileTreeNodeTabIndex(focusedPath, path),
220
213
  onClick: handleClick,
221
214
  onFocus: () => onFocus(path),
222
215
  onKeyDown: (e) => handleKeyDown(e, path, "folder"),
@@ -245,10 +238,9 @@ function FileTreeFolder({ className, path, name, level = 0, children, ref, ...pr
245
238
  });
246
239
  }
247
240
  function FileTreeFile({ className, path, name, icon, level = 0, ref, ...props }) {
248
- const { selectedPath, focusedPath, onFocus, onSelect, register, handleKeyDown } = useFileTreeContext();
241
+ const { selectedPath, focusedPath, onFocus, onSelect, handleKeyDown } = useFileTreeContext();
249
242
  const isSelected = selectedPath === path;
250
243
  const isFocused = focusedPath === path;
251
- register(path, "file", true);
252
244
  return /* @__PURE__ */ jsx("li", {
253
245
  ref,
254
246
  role: "treeitem",
@@ -260,7 +252,8 @@ function FileTreeFile({ className, path, name, icon, level = 0, ref, ...props })
260
252
  className: "file-tree__node file-tree__node--file",
261
253
  "data-selected": dataFlag(isSelected),
262
254
  "data-focused": dataFlag(isFocused),
263
- tabIndex: getFileTreeNodeTabIndex(focusedPath, path, level),
255
+ "data-workspace-path": path,
256
+ tabIndex: getFileTreeNodeTabIndex(focusedPath, path),
264
257
  onClick: () => onSelect(path),
265
258
  onFocus: () => onFocus(path),
266
259
  onKeyDown: (e) => handleKeyDown(e, path, "file"),