@mcp-b/react-components 0.11.0 → 0.12.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 (83) hide show
  1. package/dist/{AgentChat-B9LD_WF1.d.ts → AgentChat-CRmsKg9B.d.ts} +10 -6
  2. package/dist/{BrowserLiveView-ZktFZiMD.d.ts → BrowserLiveView-BV5qgFgI.d.ts} +11 -10
  3. package/dist/{BrowserReplay-6G-mnwcn.d.ts → BrowserReplay-xWvRjRAC.d.ts} +2 -1
  4. package/dist/{Menu-B5vDqZe_.d.ts → Menu-BLhnNnRK.d.ts} +3 -0
  5. package/dist/{ModelSelector-DXtpcRmT.js → ModelSelector-BB-xB-Es.js} +16 -13
  6. package/dist/{PromptInput-D6-G24p7.d.ts → PromptInput-IyM6ZETj.d.ts} +13 -45
  7. package/dist/ThinkChat-B3wYahor.js +190 -0
  8. package/dist/{ThinkChatActivity-B2UD95My.d.ts → ThinkChatActivity-F4KFPcJA.d.ts} +4 -4
  9. package/dist/ThinkChatContext-C3Eb1Xpi.d.ts +16 -0
  10. package/dist/{ThinkChatToolParts-DnUiZgCC.d.ts → ThinkChatToolParts-Cv4o7j6F.d.ts} +13 -5
  11. package/dist/components/AgentChat.d.ts +1 -1
  12. package/dist/components/AgentChat.js +57 -23
  13. package/dist/components/AgentConnection.js +4 -20
  14. package/dist/components/Badge.js +1 -15
  15. package/dist/components/BrowserLiveView.d.ts +1 -1
  16. package/dist/components/BrowserLiveView.js +14 -10
  17. package/dist/components/BrowserReplay.d.ts +1 -1
  18. package/dist/components/BrowserRunPanel.js +91 -55
  19. package/dist/components/ChatGptSignInScreen.js +1 -1
  20. package/dist/components/CodexModelSelector.d.ts +63 -0
  21. package/dist/components/CodexModelSelector.js +148 -0
  22. package/dist/components/Commit.d.ts +2 -2
  23. package/dist/components/Commit.js +10 -22
  24. package/dist/components/Conversation.d.ts +2 -6
  25. package/dist/components/Conversation.js +2 -3
  26. package/dist/components/EnvironmentVariables.d.ts +2 -7
  27. package/dist/components/EnvironmentVariables.js +10 -33
  28. package/dist/components/Marker.js +1 -15
  29. package/dist/components/McpServerPicker.d.ts +31 -6
  30. package/dist/components/McpServerPicker.js +129 -67
  31. package/dist/components/Menu.d.ts +1 -1
  32. package/dist/components/Menu.js +2 -2
  33. package/dist/components/Message.d.ts +3 -2
  34. package/dist/components/Message.js +10 -3
  35. package/dist/components/ModelSelector.d.ts +11 -8
  36. package/dist/components/ModelSelector.js +1 -1
  37. package/dist/components/PromptInput.d.ts +2 -2
  38. package/dist/components/PromptInput.js +49 -98
  39. package/dist/components/Queue.d.ts +1 -12
  40. package/dist/components/Reasoning.js +2 -15
  41. package/dist/components/Stepper.js +1 -7
  42. package/dist/components/ThinkChat.d.ts +30 -30
  43. package/dist/components/ThinkChat.js +1 -152
  44. package/dist/components/ThinkChatActivity.d.ts +2 -2
  45. package/dist/components/ThinkChatActivity.js +3 -10
  46. package/dist/components/ThinkChatContext.d.ts +2 -2
  47. package/dist/components/ThinkChatContext.js +9 -2
  48. package/dist/components/ThinkChatToolPanels.d.ts +1 -1
  49. package/dist/components/ThinkChatToolPanels.js +19 -7
  50. package/dist/components/ThinkChatToolParts.d.ts +1 -1
  51. package/dist/components/ThinkExecutionWorkbench.d.ts +10 -7
  52. package/dist/components/ThinkExecutionWorkbench.js +382 -359
  53. package/dist/components/ThinkFullApp.d.ts +16 -13
  54. package/dist/components/ThinkFullApp.js +28 -18
  55. package/dist/components/ThinkThreadPicker.d.ts +1 -31
  56. package/dist/components/ThinkThreadPicker.js +32 -171
  57. package/dist/components/ThinkThreadShell.d.ts +35 -0
  58. package/dist/components/ThinkThreadShell.js +146 -0
  59. package/dist/components/WorkspaceExplorer.js +3 -1
  60. package/dist/merge-refs-DF_7w2x_.js +18 -0
  61. package/dist/styles/agent-chat.css +4 -1
  62. package/dist/styles/browser-run-panel.css +57 -110
  63. package/dist/styles/codex-model-selector.css +197 -0
  64. package/dist/styles/index.css +4 -1
  65. package/dist/styles/mcp-server-picker.css +62 -15
  66. package/dist/styles/message.css +1 -1
  67. package/dist/styles/model-selector.css +20 -8
  68. package/dist/styles/prompt-input.css +5 -0
  69. package/dist/styles/streamdown.css +2 -48
  70. package/dist/styles/think-execution-workbench.css +337 -0
  71. package/dist/styles/think-full-app.css +15 -390
  72. package/dist/styles/think-resize-handle.css +33 -0
  73. package/dist/styles/think-thread-picker.css +0 -238
  74. package/dist/styles/think-thread-shell.css +219 -0
  75. package/dist/styles/workspace-explorer.css +8 -2
  76. package/dist/summarize-tool-input-BUJsENSn.js +12 -0
  77. package/package.json +2 -2
  78. package/dist/ThinkChatContext-BLAAb8J5.d.ts +0 -28
  79. package/dist/components/McpServerConnections.d.ts +0 -41
  80. package/dist/components/McpServerConnections.js +0 -188
  81. package/dist/components/useStickToBottom.d.ts +0 -33
  82. package/dist/components/useStickToBottom.js +0 -107
  83. package/dist/styles/mcp-server-connections.css +0 -145
@@ -12,16 +12,8 @@ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
12
12
  import { getToolApproval, getToolInput, getToolOutput } from "@cloudflare/think/react";
13
13
  import { getToolName, isToolUIPart } from "ai";
14
14
  //#region src/components/PromptInput.tsx
15
- const PromptInputContext = React.createContext(null);
16
15
  const PromptInputController = React.createContext(null);
17
- const ProviderAttachmentsContext = React.createContext(null);
18
16
  const LocalAttachmentsContext = React.createContext(null);
19
- const LocalReferencedSourcesContext = React.createContext(null);
20
- function usePromptInputContext(component) {
21
- const ctx = React.useContext(PromptInputContext);
22
- if (!ctx) throw new Error(`${component} must be used inside a <PromptInput>.`);
23
- return ctx;
24
- }
25
17
  function usePromptInputController() {
26
18
  const ctx = React.useContext(PromptInputController);
27
19
  if (!ctx) throw new Error("Wrap your component inside <PromptInputProvider> to use usePromptInputController().");
@@ -31,24 +23,16 @@ function useOptionalPromptInputController() {
31
23
  return React.useContext(PromptInputController);
32
24
  }
33
25
  function useProviderAttachments() {
34
- const ctx = React.useContext(ProviderAttachmentsContext);
35
- if (!ctx) throw new Error("Wrap your component inside <PromptInputProvider> to use useProviderAttachments().");
36
- return ctx;
37
- }
38
- function useOptionalProviderAttachments() {
39
- return React.useContext(ProviderAttachmentsContext);
26
+ const controller = useOptionalPromptInputController();
27
+ if (!controller) throw new Error("Wrap your component inside <PromptInputProvider> to use useProviderAttachments().");
28
+ return controller.attachments;
40
29
  }
41
30
  function usePromptInputAttachments() {
42
- const provider = useOptionalProviderAttachments();
43
- const context = React.useContext(LocalAttachmentsContext) ?? provider;
31
+ const controller = useOptionalPromptInputController();
32
+ const context = React.useContext(LocalAttachmentsContext) ?? controller?.attachments;
44
33
  if (!context) throw new Error("usePromptInputAttachments must be used within a PromptInput or PromptInputProvider.");
45
34
  return context;
46
35
  }
47
- function usePromptInputReferencedSources() {
48
- const ctx = React.useContext(LocalReferencedSourcesContext);
49
- if (!ctx) throw new Error("usePromptInputReferencedSources must be used within a PromptInput.");
50
- return ctx;
51
- }
52
36
  function PromptInputProvider({ initialInput = "", children }) {
53
37
  const [textInput, setTextInput] = React.useState(initialInput);
54
38
  const [attachmentFiles, setAttachmentFiles] = React.useState([]);
@@ -103,10 +87,7 @@ function PromptInputProvider({ initialInput = "", children }) {
103
87
  }), [attachments, textInput]);
104
88
  return /* @__PURE__ */ jsx(PromptInputController.Provider, {
105
89
  value: controller,
106
- children: /* @__PURE__ */ jsx(ProviderAttachmentsContext.Provider, {
107
- value: attachments,
108
- children
109
- })
90
+ children
110
91
  });
111
92
  }
112
93
  /**
@@ -116,8 +97,8 @@ function PromptInputProvider({ initialInput = "", children }) {
116
97
  *
117
98
  * Use for assistant/chat submit forms. Do not use it as a generic textarea or
118
99
  * non-chat form. Sigvelo changes: uses shared Menu, Select, Combobox, Tabs,
119
- * Button, and Tooltip components; maps styles to CSS tokens; adds local
120
- * attachment and referenced-source helpers.
100
+ * Button, and Tooltip components; maps styles to CSS tokens; and adds local
101
+ * attachment helpers.
121
102
  *
122
103
  * The form handles Enter-to-submit while multiline editing remains in the
123
104
  * textarea. Attachment controls need accessible labels through their buttons
@@ -140,15 +121,12 @@ function PromptInputProvider({ initialInput = "", children }) {
140
121
  *
141
122
  * @see {@link https://elements.ai-sdk.dev/components/prompt-input | AI Elements Prompt Input}
142
123
  */
143
- function PromptInput({ className, accept, multiple, globalDrop, syncHiddenInput, maxFiles, maxFileSize, onError, onSubmit, children, id, ref, ...props }) {
144
- const generatedId = React.useId();
145
- const formId = id ?? generatedId;
124
+ function PromptInput({ className, accept, multiple, globalDrop, syncHiddenInput, maxFiles, maxFileSize, onError, onSubmit, children, ref, ...props }) {
146
125
  const controller = useOptionalPromptInputController();
147
126
  const usingProvider = Boolean(controller);
148
127
  const formRef = React.useRef(null);
149
128
  const inputRef = React.useRef(null);
150
129
  const [localFiles, setLocalFiles] = React.useState([]);
151
- const [referencedSources, setReferencedSources] = React.useState([]);
152
130
  const files = controller?.attachments.files ?? localFiles;
153
131
  const filesRef = React.useRef(files);
154
132
  filesRef.current = files;
@@ -215,11 +193,6 @@ function PromptInput({ className, accept, multiple, globalDrop, syncHiddenInput,
215
193
  return [];
216
194
  });
217
195
  }, [controller]);
218
- const clearReferencedSources = React.useCallback(() => setReferencedSources([]), []);
219
- const clear = React.useCallback(() => {
220
- clearAttachments();
221
- clearReferencedSources();
222
- }, [clearAttachments, clearReferencedSources]);
223
196
  const openFileDialog = React.useCallback(() => inputRef.current?.click(), []);
224
197
  React.useEffect(() => {
225
198
  if (!controller) return;
@@ -261,25 +234,6 @@ function PromptInput({ className, accept, multiple, globalDrop, syncHiddenInput,
261
234
  openFileDialog,
262
235
  remove
263
236
  ]);
264
- const referencedSourcesCtx = React.useMemo(() => ({
265
- add: (incoming) => {
266
- const array = Array.isArray(incoming) ? incoming : [incoming];
267
- setReferencedSources((prev) => [...prev, ...array.map((source) => ({
268
- ...source,
269
- id: source.id ?? createId()
270
- }))]);
271
- },
272
- clear: clearReferencedSources,
273
- remove: (sourceId) => setReferencedSources((prev) => prev.filter((source) => source.id !== sourceId)),
274
- sources: referencedSources
275
- }), [clearReferencedSources, referencedSources]);
276
- const submit = React.useCallback(() => {
277
- formRef.current?.requestSubmit();
278
- }, []);
279
- const ctx = React.useMemo(() => ({
280
- formId,
281
- submit
282
- }), [formId, submit]);
283
237
  const handleSubmit = React.useCallback(async (event) => {
284
238
  event.preventDefault();
285
239
  const textarea = event.currentTarget.querySelector("textarea[data-prompt-input-textarea=\"true\"]");
@@ -295,42 +249,35 @@ function PromptInput({ className, accept, multiple, globalDrop, syncHiddenInput,
295
249
  textarea.dispatchEvent(new Event("input", { bubbles: true }));
296
250
  }
297
251
  controller?.textInput.clear();
298
- clear();
252
+ clearAttachments();
299
253
  } catch {}
300
254
  }, [
301
- clear,
255
+ clearAttachments,
302
256
  controller,
303
257
  files,
304
258
  onSubmit
305
259
  ]);
306
- return /* @__PURE__ */ jsx(PromptInputContext.Provider, {
307
- value: ctx,
308
- children: /* @__PURE__ */ jsx(LocalAttachmentsContext.Provider, {
309
- value: attachmentsCtx,
310
- children: /* @__PURE__ */ jsxs(LocalReferencedSourcesContext.Provider, {
311
- value: referencedSourcesCtx,
312
- children: [/* @__PURE__ */ jsx("input", {
313
- ref: inputRef,
314
- accept,
315
- "aria-label": "Upload files",
316
- className: "prompt-input__file-input",
317
- multiple,
318
- onChange: (event) => {
319
- if (event.currentTarget.files?.length) add(event.currentTarget.files);
320
- event.currentTarget.value = "";
321
- },
322
- tabIndex: -1,
323
- type: "file"
324
- }), /* @__PURE__ */ jsx("form", {
325
- ref: formRef,
326
- id: formId,
327
- className: cx("prompt-input", className),
328
- onSubmit: handleSubmit,
329
- ...props,
330
- children
331
- })]
332
- })
333
- })
260
+ return /* @__PURE__ */ jsxs(LocalAttachmentsContext.Provider, {
261
+ value: attachmentsCtx,
262
+ children: [/* @__PURE__ */ jsx("input", {
263
+ ref: inputRef,
264
+ accept,
265
+ "aria-label": "Upload files",
266
+ className: "prompt-input__file-input",
267
+ multiple,
268
+ onChange: (event) => {
269
+ if (event.currentTarget.files?.length) add(event.currentTarget.files);
270
+ event.currentTarget.value = "";
271
+ },
272
+ tabIndex: -1,
273
+ type: "file"
274
+ }), /* @__PURE__ */ jsx("form", {
275
+ ref: formRef,
276
+ className: cx("prompt-input", className),
277
+ onSubmit: handleSubmit,
278
+ ...props,
279
+ children
280
+ })]
334
281
  });
335
282
  }
336
283
  function PromptInputHeader({ className, children, ref, ...props }) {
@@ -421,7 +368,6 @@ function PromptInputTools({ className, children, ref, ...props }) {
421
368
  const MIN_TEXTAREA_HEIGHT_PX = 24;
422
369
  const MAX_TEXTAREA_HEIGHT_PX = 240;
423
370
  function PromptInputTextarea({ className, placeholder = "How can I help?", rows = 1, minHeight = MIN_TEXTAREA_HEIGHT_PX, maxHeight = MAX_TEXTAREA_HEIGHT_PX, onChange, onCompositionEnd, onCompositionStart, onKeyDown, onInput, onPaste, ref, ...props }) {
424
- const { submit } = usePromptInputContext("PromptInputTextarea");
425
371
  const controller = useOptionalPromptInputController();
426
372
  const attachments = usePromptInputAttachments();
427
373
  const innerRef = React.useRef(null);
@@ -470,7 +416,7 @@ function PromptInputTextarea({ className, placeholder = "How can I help?", rows
470
416
  if (event.defaultPrevented) return;
471
417
  if (event.key === "Enter" && !event.shiftKey && !isComposing && !event.nativeEvent.isComposing) {
472
418
  event.preventDefault();
473
- submit();
419
+ event.currentTarget.form?.requestSubmit();
474
420
  }
475
421
  if (event.key === "Backspace" && event.currentTarget.value === "" && attachments.files.length > 0) {
476
422
  event.preventDefault();
@@ -532,14 +478,18 @@ function PromptInputActionMenu(props) {
532
478
  return /* @__PURE__ */ jsx(MenuRoot, { ...props });
533
479
  }
534
480
  function PromptInputActionMenuTrigger({ className, children, ...props }) {
535
- return /* @__PURE__ */ jsx(MenuTrigger, { render: /* @__PURE__ */ jsx(PromptInputButton, {
536
- className,
537
- ...props,
538
- children: children ?? /* @__PURE__ */ jsx(PlusIcon, {})
539
- }) });
481
+ return /* @__PURE__ */ jsx(MenuTrigger, {
482
+ unstyled: true,
483
+ render: /* @__PURE__ */ jsx(PromptInputButton, {
484
+ className: cx("prompt-input__action-menu-trigger", className),
485
+ ...props,
486
+ children: children ?? /* @__PURE__ */ jsx(PlusIcon, {})
487
+ })
488
+ });
540
489
  }
541
- function PromptInputActionMenuContent({ className, children, ...props }) {
490
+ function PromptInputActionMenuContent({ className, children, tabIndex = 0, ...props }) {
542
491
  return /* @__PURE__ */ jsx(MenuContent, {
492
+ tabIndex,
543
493
  className: cx("prompt-input__action-menu", className),
544
494
  ...props,
545
495
  children
@@ -702,7 +652,7 @@ function formatApprovalValue(value) {
702
652
  * sends the text as the native approval `reason`. Submit (or Enter) sends the
703
653
  * current selection — approve by default.
704
654
  */
705
- function PromptInputApproval({ part, approval: durableApproval, onRespond, executionApprovals, onSkip, question, count, className, ref, ...props }) {
655
+ function PromptInputApproval({ part, approval: durableApproval, onRespond, thinkStub, onExecutionSettled, onSkip, question, count, className, ref, ...props }) {
706
656
  const [selected, setSelected] = React.useState("approve");
707
657
  const [reason, setReason] = React.useState("");
708
658
  const [busy, setBusy] = React.useState(false);
@@ -717,7 +667,7 @@ function PromptInputApproval({ part, approval: durableApproval, onRespond, execu
717
667
  setBusy(false);
718
668
  }, [approvalId]);
719
669
  if (!part && !durableApproval) return null;
720
- if (approval ? !onRespond : !(executionApprovals && (paused || durableApproval))) return null;
670
+ if (approval ? !onRespond : !(thinkStub && (paused || durableApproval))) return null;
721
671
  const toolName = durableApproval?.descriptor.action ?? (part ? getToolName(part) : "action");
722
672
  const respond = async (approved) => {
723
673
  if (busy) return;
@@ -730,10 +680,11 @@ function PromptInputApproval({ part, approval: durableApproval, onRespond, execu
730
680
  approved,
731
681
  reason: denyReason
732
682
  });
733
- else if (paused) await (approved ? executionApprovals?.approve(paused.executionId) : executionApprovals?.reject(paused.executionId, denyReason));
734
- else if (durableApproval) await (approved ? executionApprovals?.approve(durableApproval.executionId) : executionApprovals?.reject(durableApproval.executionId, denyReason));
683
+ else if (paused && thinkStub) await (approved ? thinkStub.approveExecution(paused.executionId) : thinkStub.rejectExecution(paused.executionId, denyReason));
684
+ else if (durableApproval && thinkStub) await (approved ? thinkStub.approveExecution(durableApproval.executionId) : thinkStub.rejectExecution(durableApproval.executionId, denyReason));
735
685
  } finally {
736
686
  setBusy(false);
687
+ if (!approval) onExecutionSettled?.();
737
688
  }
738
689
  };
739
690
  const submit = () => void respond(selected === "approve");
@@ -1066,4 +1017,4 @@ function createId() {
1066
1017
  return globalThis.crypto?.randomUUID?.() ?? `prompt-input-${Date.now()}-${Math.random()}`;
1067
1018
  }
1068
1019
  //#endregion
1069
- export { PromptInput, PromptInputActionAddAttachments, PromptInputActionAddScreenshot, PromptInputActionMenu, PromptInputActionMenuContent, PromptInputActionMenuItem, PromptInputActionMenuTrigger, PromptInputApproval, PromptInputAttachment, PromptInputAttachments, PromptInputBody, PromptInputButton, PromptInputCommand, PromptInputCommandEmpty, PromptInputCommandGroup, PromptInputCommandInput, PromptInputCommandItem, PromptInputCommandList, PromptInputCommandSeparator, PromptInputFooter, PromptInputHeader, PromptInputHoverCard, PromptInputHoverCardContent, PromptInputHoverCardTrigger, PromptInputPermissionSelector, PromptInputProvider, PromptInputSelect, PromptInputSelectContent, PromptInputSelectItem, PromptInputSelectTrigger, PromptInputSelectValue, PromptInputSubmit, PromptInputTab, PromptInputTabBody, PromptInputTabItem, PromptInputTabLabel, PromptInputTabsList, PromptInputTextarea, PromptInputTools, getApprovalRequestId, getApprovalStateKey, getPendingToolApprovals, usePromptInputAttachments, usePromptInputController, usePromptInputReferencedSources, useProviderAttachments };
1020
+ export { PromptInput, PromptInputActionAddAttachments, PromptInputActionAddScreenshot, PromptInputActionMenu, PromptInputActionMenuContent, PromptInputActionMenuItem, PromptInputActionMenuTrigger, PromptInputApproval, PromptInputAttachment, PromptInputAttachments, PromptInputBody, PromptInputButton, PromptInputCommand, PromptInputCommandEmpty, PromptInputCommandGroup, PromptInputCommandInput, PromptInputCommandItem, PromptInputCommandList, PromptInputCommandSeparator, PromptInputFooter, PromptInputHeader, PromptInputHoverCard, PromptInputHoverCardContent, PromptInputHoverCardTrigger, PromptInputPermissionSelector, PromptInputProvider, PromptInputSelect, PromptInputSelectContent, PromptInputSelectItem, PromptInputSelectTrigger, PromptInputSelectValue, PromptInputSubmit, PromptInputTab, PromptInputTabBody, PromptInputTabItem, PromptInputTabLabel, PromptInputTabsList, PromptInputTextarea, PromptInputTools, getApprovalRequestId, getApprovalStateKey, getPendingToolApprovals, usePromptInputAttachments, usePromptInputController, useProviderAttachments };
@@ -4,17 +4,6 @@ import { ScrollAreaRootProps } from "./ScrollArea.js";
4
4
  import * as React from "react";
5
5
 
6
6
  //#region src/components/Queue.d.ts
7
- interface QueueMessagePart {
8
- type: string;
9
- text?: string;
10
- url?: string;
11
- filename?: string;
12
- mediaType?: string;
13
- }
14
- interface QueueMessage {
15
- id: string;
16
- parts: QueueMessagePart[];
17
- }
18
7
  interface QueueTodo {
19
8
  id: string;
20
9
  title: string;
@@ -238,4 +227,4 @@ declare function QueueItemFile({
238
227
  ref?: React.Ref<HTMLDivElement>;
239
228
  }): React.JSX.Element;
240
229
  //#endregion
241
- export { Queue, QueueItem, QueueItemAction, QueueItemActionProps, QueueItemActions, QueueItemActionsProps, QueueItemAttachment, QueueItemAttachmentProps, QueueItemContent, QueueItemContentProps, QueueItemDescription, QueueItemDescriptionProps, QueueItemFile, QueueItemFileProps, QueueItemImage, QueueItemImageProps, QueueItemIndicator, QueueItemIndicatorProps, QueueItemProps, QueueItemStatus, QueueList, QueueListProps, QueueMessage, QueueMessagePart, QueueProps, QueueSection, QueueSectionContent, QueueSectionContentProps, QueueSectionLabel, QueueSectionLabelProps, QueueSectionProps, QueueSectionTrigger, QueueSectionTriggerProps, QueueTodo };
230
+ export { Queue, QueueItem, QueueItemAction, QueueItemActionProps, QueueItemActions, QueueItemActionsProps, QueueItemAttachment, QueueItemAttachmentProps, QueueItemContent, QueueItemContentProps, QueueItemDescription, QueueItemDescriptionProps, QueueItemFile, QueueItemFileProps, QueueItemImage, QueueItemImageProps, QueueItemIndicator, QueueItemIndicatorProps, QueueItemProps, QueueItemStatus, QueueList, QueueListProps, QueueProps, QueueSection, QueueSectionContent, QueueSectionContentProps, QueueSectionLabel, QueueSectionLabelProps, QueueSectionProps, QueueSectionTrigger, QueueSectionTriggerProps, QueueTodo };
@@ -1,13 +1,9 @@
1
1
  import { CollapsiblePanel, CollapsibleRoot, CollapsibleTrigger } from "./Collapsible.js";
2
2
  import { t as cx } from "../class-names-9UtZwb0J.js";
3
3
  import { c as ChevronRightIcon } from "../icons-D2Q5n5C1.js";
4
+ import { MessageResponse } from "./Message.js";
4
5
  import * as React from "react";
5
6
  import { jsx, jsxs } from "react/jsx-runtime";
6
- import { cjk } from "@streamdown/cjk";
7
- import { code } from "@streamdown/code";
8
- import { math } from "@streamdown/math";
9
- import { mermaid } from "@streamdown/mermaid";
10
- import { Streamdown } from "streamdown";
11
7
  //#region src/components/Reasoning.tsx
12
8
  const ReasoningContext = React.createContext(null);
13
9
  const AUTO_CLOSE_DELAY_MS = 1e3;
@@ -150,12 +146,6 @@ function ReasoningTrigger({ className, children, getThinkingMessage = defaultGet
150
146
  })]
151
147
  });
152
148
  }
153
- const streamdownPlugins = {
154
- cjk,
155
- code,
156
- math,
157
- mermaid
158
- };
159
149
  /**
160
150
  * The reasoning text panel. Accepts any React node but is optimized for
161
151
  * long-form text; a muted left border visually distinguishes the block.
@@ -168,10 +158,7 @@ function ReasoningContent({ className, children, ref, ...props }) {
168
158
  unstyled: true,
169
159
  children: /* @__PURE__ */ jsx("div", {
170
160
  className: "reasoning__text",
171
- children: typeof children === "string" ? /* @__PURE__ */ jsx(Streamdown, {
172
- plugins: streamdownPlugins,
173
- children
174
- }) : children
161
+ children: typeof children === "string" ? /* @__PURE__ */ jsx(MessageResponse, { children }) : children
175
162
  })
176
163
  });
177
164
  }
@@ -1,5 +1,6 @@
1
1
  import { t as cx } from "../class-names-9UtZwb0J.js";
2
2
  import { M as SpinnerIcon, a as CheckIcon } from "../icons-D2Q5n5C1.js";
3
+ import { t as assignRef } from "../merge-refs-DF_7w2x_.js";
3
4
  import * as React from "react";
4
5
  import { jsx } from "react/jsx-runtime";
5
6
  //#region src/components/Stepper.tsx
@@ -304,12 +305,5 @@ function getIndicatorContent({ children, indicators, isLoading, state, step }) {
304
305
  if (state === "completed") return /* @__PURE__ */ jsx(CheckIcon, {});
305
306
  return step;
306
307
  }
307
- function assignRef(ref, value) {
308
- if (typeof ref === "function") {
309
- ref(value);
310
- return;
311
- }
312
- if (ref) ref.current = value;
313
- }
314
308
  //#endregion
315
309
  export { Stepper, StepperContent, StepperDescription, StepperIndicator, StepperItem, StepperNav, StepperPanel, StepperSeparator, StepperTitle, StepperTrigger, useStepItem, useStepper };
@@ -1,10 +1,9 @@
1
- import { n as ExecutionApprovals } from "../PromptInput-D6-G24p7.js";
2
- import { a as AgentChatRenderPartContext, r as AgentChatProps } from "../AgentChat-B9LD_WF1.js";
3
- import { n as BrowserLiveViewProps, t as BrowserLiveView } from "../BrowserLiveView-ZktFZiMD.js";
4
- import { n as BrowserReplayProps, t as BrowserReplay } from "../BrowserReplay-6G-mnwcn.js";
5
- import { _ as isThinkChatActivityPart } from "../ThinkChatToolParts-DnUiZgCC.js";
6
- import { a as ThinkChatToolRenderers, c as renderThinkChatActivityPart, i as ThinkChatToolRenderer, n as ThinkChatActivityProps, o as createThinkChatActivityRenderer, r as ThinkChatActivityRendererOptions, s as describeThinkChatActivityPart, t as ThinkChatActivity } from "../ThinkChatActivity-B2UD95My.js";
7
- import { n as ThinkChatValue } from "../ThinkChatContext-BLAAb8J5.js";
1
+ import { a as AgentChatRenderPartContext, r as AgentChatProps } from "../AgentChat-CRmsKg9B.js";
2
+ import { n as BrowserLiveViewProps, t as BrowserLiveView } from "../BrowserLiveView-BV5qgFgI.js";
3
+ import { n as BrowserReplayProps, t as BrowserReplay } from "../BrowserReplay-xWvRjRAC.js";
4
+ import { _ as isThinkChatActivityPart } from "../ThinkChatToolParts-Cv4o7j6F.js";
5
+ import { a as ThinkChatToolRenderers, c as renderThinkChatActivityPart, i as ThinkChatToolRenderer, n as ThinkChatActivityProps, o as createThinkChatActivityRenderer, r as ThinkChatActivityRendererOptions, s as describeThinkChatActivityPart, t as ThinkChatActivity } from "../ThinkChatActivity-F4KFPcJA.js";
6
+ import { n as ThinkChatValue } from "../ThinkChatContext-C3Eb1Xpi.js";
8
7
  import { FileInfo, UseWorkspaceOptions, WorkspaceExplorer, WorkspaceExplorerProps, WorkspaceFileState, WorkspaceInfo, WorkspaceSource, WorkspaceState, inferWorkspaceLanguage, useWorkspace } from "./WorkspaceExplorer.js";
9
8
  import * as React from "react";
10
9
  import { UIMessage } from "ai";
@@ -13,11 +12,9 @@ import { PendingApproval, Think } from "@cloudflare/think";
13
12
  import { AgentStub } from "agents/client";
14
13
 
15
14
  //#region src/components/ThinkChat.d.ts
16
- type ThinkAgent<State> = Think<object, State>;
17
- type ThinkApprovalStub<State = unknown> = AgentStub<ThinkAgent<State>>;
18
- interface ThinkChatProviderProps {
15
+ interface ThinkChatProviderProps<State = unknown, MessageT extends UIMessage = UIMessage> {
19
16
  /** The `useAgentChat` value from `@cloudflare/think/react` that descendants read. */
20
- chat: ThinkChatValue;
17
+ chat: ThinkChatValue<State, MessageT>;
21
18
  children: React.ReactNode;
22
19
  }
23
20
  interface ThinkChatRootProps<State = unknown> {
@@ -27,7 +24,7 @@ interface ThinkChatRootProps<State = unknown> {
27
24
  name?: string;
28
25
  children: React.ReactNode;
29
26
  }
30
- interface ThinkChatMessagesProps extends ThinkChatActivityRendererOptions {
27
+ interface ThinkChatMessagesProps<MessageT extends UIMessage = UIMessage> extends ThinkChatActivityRendererOptions {
31
28
  className?: string;
32
29
  /** Disable the composer (e.g. while the agent is unreachable). */
33
30
  disabled?: boolean;
@@ -36,42 +33,44 @@ interface ThinkChatMessagesProps extends ThinkChatActivityRendererOptions {
36
33
  /** Extra controls rendered inside the composer, next to the send button. */
37
34
  composerTools?: React.ReactNode;
38
35
  /** Extra rows rendered in the built-in plus menu after files. */
39
- composerAddMenuItems?: AgentChatProps["composerAddMenuItems"];
36
+ composerAddMenuItems?: AgentChatProps<MessageT>["composerAddMenuItems"];
40
37
  /** Composer placeholder text. */
41
38
  placeholder?: string;
42
39
  /** Rendered after each message (e.g. per-message actions). */
43
- renderMessageAfter?: AgentChatProps["renderMessageAfter"];
40
+ renderMessageAfter?: AgentChatProps<MessageT>["renderMessageAfter"];
44
41
  /**
45
42
  * Overrides the built-in connection notice (derived from the hook's
46
43
  * `isRecovering`/`connectionError`) shown between transcript and composer.
47
44
  */
48
- notice?: AgentChatProps["notice"];
45
+ notice?: AgentChatProps<MessageT>["notice"];
49
46
  /** Full replacement for part rendering; wins over excludeTools/toolRenderers. */
50
- renderPart?: AgentChatProps["renderPart"];
51
- /** Resolves Think execution approvals. `ThinkChat.Root` wires this automatically. */
52
- executionApprovals?: ExecutionApprovals;
47
+ renderPart?: AgentChatProps<MessageT>["renderPart"];
48
+ /** Whole upstream Think stub. `ThinkChat.Root` wires `agent.stub` automatically. */
49
+ thinkStub?: AgentStub<Think>;
50
+ /** Called after a Think approve/reject RPC settles. Root uses this to refresh approvals. */
51
+ onExecutionSettled?: AgentChatProps<MessageT>["onExecutionSettled"];
53
52
  /** Think durable-pause approvals from `pendingApprovals()`. */
54
- pendingApprovals?: AgentChatProps["pendingApprovals"];
53
+ pendingApprovals?: AgentChatProps<MessageT>["pendingApprovals"];
55
54
  /**
56
55
  * Shows a Context ring in the composer footer — how much of the model's
57
56
  * window the conversation occupies, from `metadata.usage` on the newest
58
57
  * message that reports it.
59
58
  */
60
- contextWindow?: AgentChatProps["contextWindow"];
59
+ contextWindow?: AgentChatProps<MessageT>["contextWindow"];
61
60
  }
62
- declare function useThinkPendingApprovals(stub: ThinkApprovalStub, refreshKey: unknown): {
61
+ declare function useThinkPendingApprovals(stub: AgentStub<Think>, refreshKey: unknown): {
63
62
  pendingApprovals: readonly PendingApproval[];
64
- executionApprovals: ExecutionApprovals;
63
+ refreshPendingApprovals: () => Promise<void>;
65
64
  };
66
65
  /**
67
66
  * Chat UI for Cloudflare Think agents. Provide a `useAgentChat` value (or let
68
67
  * `ThinkChat.Root` create one) and `ThinkChat.Messages` renders the message
69
68
  * stream with agent work folded into collapsed Activity blocks.
70
69
  */
71
- declare function ThinkChatProvider({
70
+ declare function ThinkChatProvider<State = unknown, MessageT extends UIMessage = UIMessage>({
72
71
  chat,
73
72
  children
74
- }: ThinkChatProviderProps): React.JSX.Element;
73
+ }: ThinkChatProviderProps<State, MessageT>): React.JSX.Element;
75
74
  /**
76
75
  * Batteries-included root: connects to the named Think agent (upstream's
77
76
  * `useAgent` + `useAgentChat`) and provides the live chat to everything
@@ -84,7 +83,7 @@ declare function ThinkChatProvider({
84
83
  * </ThinkChat.Root>
85
84
  * ```
86
85
  */
87
- declare function ThinkChatRoot<State = unknown>({
86
+ declare function ThinkChatRoot<State = unknown, MessageT extends UIMessage = UIMessage>({
88
87
  agent: agentOption,
89
88
  name,
90
89
  children
@@ -97,21 +96,22 @@ declare function ThinkChatRoot<State = unknown>({
97
96
  * inside the log) or `excludeTools` + your own `renderPart` (standalone
98
97
  * card) — see README "App-specific tools" and the Custom Tool Panel story.
99
98
  */
100
- declare function ThinkChatMessages({
99
+ declare function ThinkChatMessages<State = unknown, MessageT extends UIMessage = UIMessage>({
101
100
  renderPart,
102
101
  excludeTools,
103
102
  toolRenderers,
104
- executionApprovals,
103
+ thinkStub,
104
+ onExecutionSettled,
105
105
  pendingApprovals,
106
106
  notice,
107
107
  ...props
108
- }: ThinkChatMessagesProps): React.JSX.Element;
108
+ }: ThinkChatMessagesProps<MessageT>): React.JSX.Element;
109
109
  /**
110
110
  * The ambient chat value from `ThinkChat.Root`/`Provider` — for custom tool
111
111
  * panels, cards, or composer actions that need `messages`, `status`, or
112
112
  * `sendMessage`. Throws outside a provider.
113
113
  */
114
- declare function useThinkChat(): Omit<import("@ai-sdk/react").UseChatHelpers<UIMessage<unknown, import("ai").UIDataTypes, import("ai").UITools>>, "addToolOutput"> & {
114
+ declare function useThinkChat<State = unknown, MessageT extends UIMessage = UIMessage>(): Omit<import("@ai-sdk/react").UseChatHelpers<MessageT>, "addToolOutput"> & {
115
115
  clearHistory: () => void;
116
116
  addToolOutput: (opts: {
117
117
  toolCallId: string;
@@ -145,4 +145,4 @@ declare const ThinkChat: {
145
145
  createActivityRenderer: typeof createThinkChatActivityRenderer;
146
146
  };
147
147
  //#endregion
148
- export { BrowserLiveView, type BrowserLiveViewProps, BrowserReplay, type BrowserReplayProps, type ExecutionApprovals, type FileInfo, ThinkApprovalStub, ThinkChat, ThinkChatActivity, type ThinkChatActivityProps, type ThinkChatActivityRendererOptions, ThinkChatMessages, ThinkChatMessagesProps, ThinkChatProvider, ThinkChatProviderProps, ThinkChatRoot, ThinkChatRootProps, type ThinkChatToolRenderer, type ThinkChatToolRenderers, type UseWorkspaceOptions, WorkspaceExplorer, type WorkspaceExplorerProps, type WorkspaceFileState, type WorkspaceInfo, type WorkspaceSource, type WorkspaceState, createThinkChatActivityRenderer, describeThinkChatActivityPart, inferWorkspaceLanguage, isThinkChatActivityPart, renderThinkChatActivityPart, useThinkChat, useThinkPendingApprovals, useWorkspace };
148
+ export { BrowserLiveView, type BrowserLiveViewProps, BrowserReplay, type BrowserReplayProps, type FileInfo, ThinkChat, ThinkChatActivity, type ThinkChatActivityProps, type ThinkChatActivityRendererOptions, ThinkChatMessages, ThinkChatMessagesProps, ThinkChatProvider, ThinkChatProviderProps, ThinkChatRoot, ThinkChatRootProps, type ThinkChatToolRenderer, type ThinkChatToolRenderers, type UseWorkspaceOptions, WorkspaceExplorer, type WorkspaceExplorerProps, type WorkspaceFileState, type WorkspaceInfo, type WorkspaceSource, type WorkspaceState, createThinkChatActivityRenderer, describeThinkChatActivityPart, inferWorkspaceLanguage, isThinkChatActivityPart, renderThinkChatActivityPart, useThinkChat, useThinkPendingApprovals, useWorkspace };
@@ -1,158 +1,7 @@
1
- import { AgentChat } from "./AgentChat.js";
2
1
  import { BrowserLiveView } from "./BrowserLiveView.js";
3
2
  import { BrowserReplay } from "./BrowserReplay.js";
4
- import { ThinkChatContext, useThinkChatContext } from "./ThinkChatContext.js";
5
3
  import { isThinkChatActivityPart } from "./ThinkChatToolParts.js";
6
4
  import { ThinkChatActivity, createThinkChatActivityRenderer, describeThinkChatActivityPart, renderThinkChatActivityPart } from "./ThinkChatActivity.js";
5
+ import { a as useThinkChat, i as ThinkChatRoot, n as ThinkChatMessages, o as useThinkPendingApprovals, r as ThinkChatProvider, t as ThinkChat } from "../ThinkChat-B3wYahor.js";
7
6
  import { WorkspaceExplorer, inferWorkspaceLanguage, useWorkspace } from "./WorkspaceExplorer.js";
8
- import * as React from "react";
9
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
10
- import { useAgentChat } from "@cloudflare/think/react";
11
- import { useAgent } from "agents/react";
12
- //#region src/components/ThinkChat.tsx
13
- function toAgentChatStatus(chat) {
14
- if (chat.status === "submitted") return "submitted";
15
- if (chat.isStreaming || chat.isRecovering) return "streaming";
16
- return chat.status ?? "ready";
17
- }
18
- function useThinkPendingApprovals(stub, refreshKey) {
19
- const [pendingApprovals, setPendingApprovals] = React.useState([]);
20
- const refresh = React.useCallback(async () => {
21
- try {
22
- setPendingApprovals(await stub.pendingApprovals());
23
- } catch {
24
- setPendingApprovals([]);
25
- }
26
- }, [stub]);
27
- React.useEffect(() => {
28
- refresh();
29
- }, [refresh, refreshKey]);
30
- const executionApprovals = React.useMemo(() => ({
31
- approve: async (id) => {
32
- try {
33
- return await stub.approveExecution(id);
34
- } finally {
35
- refresh();
36
- }
37
- },
38
- reject: async (id, reason) => {
39
- try {
40
- return await stub.rejectExecution(id, reason);
41
- } finally {
42
- refresh();
43
- }
44
- }
45
- }), [stub, refresh]);
46
- return React.useMemo(() => ({
47
- pendingApprovals,
48
- executionApprovals
49
- }), [pendingApprovals, executionApprovals]);
50
- }
51
- /**
52
- * Chat UI for Cloudflare Think agents. Provide a `useAgentChat` value (or let
53
- * `ThinkChat.Root` create one) and `ThinkChat.Messages` renders the message
54
- * stream with agent work folded into collapsed Activity blocks.
55
- */
56
- function ThinkChatProvider({ chat, children }) {
57
- return /* @__PURE__ */ jsx(ThinkChatContext.Provider, {
58
- value: chat,
59
- children
60
- });
61
- }
62
- /**
63
- * Batteries-included root: connects to the named Think agent (upstream's
64
- * `useAgent` + `useAgentChat`) and provides the live chat to everything
65
- * inside. If the app already owns the chat hook, use `ThinkChat.Provider`.
66
- *
67
- * @example
68
- * ```tsx
69
- * <ThinkChat.Root agent="my-agent" name="session-1">
70
- * <ThinkChat.Messages />
71
- * </ThinkChat.Root>
72
- * ```
73
- */
74
- function ThinkChatRoot({ agent: agentOption, name, children }) {
75
- const agent = useAgent(typeof agentOption === "string" ? {
76
- agent: agentOption,
77
- name
78
- } : {
79
- ...agentOption,
80
- name: name ?? agentOption.name
81
- });
82
- const chat = useAgentChat({ agent });
83
- const approvals = useThinkPendingApprovals(agent.stub, `${chat.messages.length}:${chat.status}`);
84
- return /* @__PURE__ */ jsx(ThinkChatContext.Provider, {
85
- value: chat,
86
- children: /* @__PURE__ */ jsx(ThinkChatApprovalsContext.Provider, {
87
- value: approvals,
88
- children
89
- })
90
- });
91
- }
92
- const ThinkChatApprovalsContext = React.createContext(null);
93
- /**
94
- * The full conversation surface — message list plus composer — with the
95
- * activity renderer as the default `renderPart`: runs of reasoning/tool parts
96
- * fold into one collapsed Activity block with derived labels and per-tool
97
- * panels. Extend for app-specific tools with `toolRenderers` (label/panel
98
- * inside the log) or `excludeTools` + your own `renderPart` (standalone
99
- * card) — see README "App-specific tools" and the Custom Tool Panel story.
100
- */
101
- function ThinkChatMessages({ renderPart, excludeTools, toolRenderers, executionApprovals, pendingApprovals, notice, ...props }) {
102
- const chat = useThinkChatContext("ThinkChat.Messages");
103
- const approvals = React.useContext(ThinkChatApprovalsContext);
104
- const status = toAgentChatStatus(chat);
105
- const resolvedExecutionApprovals = executionApprovals ?? approvals?.executionApprovals;
106
- const resolvedPendingApprovals = pendingApprovals ?? approvals?.pendingApprovals;
107
- const defaultRenderPart = React.useMemo(() => createThinkChatActivityRenderer({
108
- excludeTools,
109
- toolRenderers
110
- }), [excludeTools, toolRenderers]);
111
- const connectionNotice = chat.isRecovering ? /* @__PURE__ */ jsx(Fragment, { children: "Reconnecting to the agent…" }) : chat.connectionError ? /* @__PURE__ */ jsxs("span", {
112
- "data-tone": "danger",
113
- children: ["Connection lost", chat.connectionError.reason ? ` — ${chat.connectionError.reason}` : ""]
114
- }) : void 0;
115
- return /* @__PURE__ */ jsx(AgentChat, {
116
- ...props,
117
- renderPart: renderPart ?? defaultRenderPart,
118
- messages: chat.messages,
119
- status,
120
- onStop: chat.stop,
121
- onApprovalResponse: chat.addToolApprovalResponse,
122
- executionApprovals: resolvedExecutionApprovals,
123
- pendingApprovals: resolvedPendingApprovals,
124
- notice: notice ?? connectionNotice,
125
- onRegenerate: (messageId) => void chat.regenerate({ messageId }),
126
- onSubmit: ({ text, files }) => {
127
- const trimmed = text.trim();
128
- if (trimmed || files.length) chat.sendMessage({
129
- text: trimmed,
130
- files
131
- });
132
- }
133
- });
134
- }
135
- /**
136
- * The ambient chat value from `ThinkChat.Root`/`Provider` — for custom tool
137
- * panels, cards, or composer actions that need `messages`, `status`, or
138
- * `sendMessage`. Throws outside a provider.
139
- */
140
- function useThinkChat() {
141
- return useThinkChatContext("useThinkChat");
142
- }
143
- /**
144
- * Namespace entry point. `Root` + `Messages` is the standard surface;
145
- * `Provider` + `useThinkChat` when the app owns the chat hook; `Activity`,
146
- * `renderActivityPart`, and `createActivityRenderer` for custom layouts and
147
- * app-specific tools.
148
- */
149
- const ThinkChat = {
150
- Provider: ThinkChatProvider,
151
- Root: ThinkChatRoot,
152
- Messages: ThinkChatMessages,
153
- Activity: ThinkChatActivity,
154
- renderActivityPart: renderThinkChatActivityPart,
155
- createActivityRenderer: createThinkChatActivityRenderer
156
- };
157
- //#endregion
158
7
  export { BrowserLiveView, BrowserReplay, ThinkChat, ThinkChatActivity, ThinkChatMessages, ThinkChatProvider, ThinkChatRoot, WorkspaceExplorer, createThinkChatActivityRenderer, describeThinkChatActivityPart, inferWorkspaceLanguage, isThinkChatActivityPart, renderThinkChatActivityPart, useThinkChat, useThinkPendingApprovals, useWorkspace };