@mcp-b/react-components 0.2.2 → 0.4.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 (61) hide show
  1. package/dist/{CodeBlock-BrCoypnc.js → CodeBlock-C2Xjxu9M.js} +1 -1
  2. package/dist/FileTree-D0c9Yj9U.js +310 -0
  3. package/dist/attachment-preview-ChtC3HiU.js +25 -0
  4. package/dist/components/Activity.js +1 -1
  5. package/dist/components/AgentChat.d.ts +56 -9
  6. package/dist/components/AgentChat.js +146 -47
  7. package/dist/components/AgentConnection.js +3 -3
  8. package/dist/components/Artifact.js +1 -1
  9. package/dist/components/BrowserLiveView.d.ts +47 -0
  10. package/dist/components/BrowserLiveView.js +135 -0
  11. package/dist/components/BrowserReplay.d.ts +40 -0
  12. package/dist/components/BrowserReplay.js +187 -0
  13. package/dist/components/ChainOfThought.d.ts +1 -1
  14. package/dist/components/ChainOfThought.js +1 -1
  15. package/dist/components/CodeBlock.js +1 -1
  16. package/dist/components/Commit.js +1 -1
  17. package/dist/components/Context.d.ts +28 -27
  18. package/dist/components/Context.js +48 -47
  19. package/dist/components/ContextMenu.js +1 -1
  20. package/dist/components/Conversation.js +1 -1
  21. package/dist/components/Dialog.js +1 -1
  22. package/dist/components/EnvironmentVariables.js +1 -1
  23. package/dist/components/FileTree.js +1 -309
  24. package/dist/components/Menubar.js +1 -1
  25. package/dist/components/Message.d.ts +17 -2
  26. package/dist/components/Message.js +36 -2
  27. package/dist/components/ModelSelector.js +1 -1
  28. package/dist/components/NavigationMenu.js +1 -1
  29. package/dist/components/PricingPage.js +2 -2
  30. package/dist/components/PromptInput.d.ts +143 -10
  31. package/dist/components/PromptInput.js +318 -5
  32. package/dist/components/Queue.js +1 -1
  33. package/dist/components/Reasoning.js +1 -1
  34. package/dist/components/Select.js +1 -1
  35. package/dist/components/Sources.js +1 -1
  36. package/dist/components/Stepper.js +1 -1
  37. package/dist/components/Suggestion.d.ts +43 -0
  38. package/dist/components/Suggestion.js +39 -0
  39. package/dist/components/Task.js +1 -1
  40. package/dist/components/Terminal.js +2 -2
  41. package/dist/components/TestResults.js +1 -1
  42. package/dist/components/ThinkChat.d.ts +207 -0
  43. package/dist/components/ThinkChat.js +798 -0
  44. package/dist/components/Tool.d.ts +32 -28
  45. package/dist/components/Tool.js +29 -16
  46. package/dist/components/WebPreview.js +1 -1
  47. package/dist/components/WorkspaceExplorer.d.ts +102 -0
  48. package/dist/components/WorkspaceExplorer.js +352 -0
  49. package/dist/components/icons.d.ts +2 -2
  50. package/dist/components/icons.js +2 -2
  51. package/dist/{copy-button-DAPlB8Z0.js → copy-button-Dd6DEhOm.js} +1 -1
  52. package/dist/{icons-Bf7JMKk-.js → icons-DQC4Zw5R.js} +5 -1
  53. package/dist/{icons-BklFyZbx.d.ts → icons-ctdVxng0.d.ts} +2 -1
  54. package/dist/styles/agent-chat.css +19 -0
  55. package/dist/styles/attachment-preview.css +21 -0
  56. package/dist/styles/context.css +9 -17
  57. package/dist/styles/index.css +2 -0
  58. package/dist/styles/message.css +48 -0
  59. package/dist/styles/prompt-input.css +321 -0
  60. package/dist/styles/suggestions.css +21 -0
  61. package/package.json +26 -3
@@ -1,6 +1,6 @@
1
1
  import { CollapsiblePanel, CollapsibleRoot, CollapsibleTrigger } from "./Collapsible.js";
2
2
  import { t as cx } from "../class-names-9UtZwb0J.js";
3
- import { a as BrainIcon, l as ChevronRightIcon } from "../icons-Bf7JMKk-.js";
3
+ import { a as BrainIcon, l as ChevronRightIcon } from "../icons-DQC4Zw5R.js";
4
4
  import * as React from "react";
5
5
  import { jsx, jsxs } from "react/jsx-runtime";
6
6
  import { cjk } from "@streamdown/cjk";
@@ -1,4 +1,4 @@
1
- import { i as ArrowUpIcon, o as CheckIcon, t as ArrowDownIcon } from "../icons-Bf7JMKk-.js";
1
+ import { i as ArrowUpIcon, o as CheckIcon, t as ArrowDownIcon } from "../icons-DQC4Zw5R.js";
2
2
  import * as React from "react";
3
3
  import { jsx, jsxs } from "react/jsx-runtime";
4
4
  import { Select as Select$1 } from "@base-ui/react/select";
@@ -1,6 +1,6 @@
1
1
  import { CollapsiblePanel, CollapsibleRoot, CollapsibleTrigger } from "./Collapsible.js";
2
2
  import { t as cx } from "../class-names-9UtZwb0J.js";
3
- import { b as LinkIcon, l as ChevronRightIcon } from "../icons-Bf7JMKk-.js";
3
+ import { b as LinkIcon, l as ChevronRightIcon } from "../icons-DQC4Zw5R.js";
4
4
  import "react";
5
5
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
6
6
  //#region src/components/Sources.tsx
@@ -1,5 +1,5 @@
1
1
  import { t as cx } from "../class-names-9UtZwb0J.js";
2
- import { k as SpinnerIcon, o as CheckIcon } from "../icons-Bf7JMKk-.js";
2
+ import { A as SpinnerIcon, o as CheckIcon } from "../icons-DQC4Zw5R.js";
3
3
  import * as React from "react";
4
4
  import { jsx } from "react/jsx-runtime";
5
5
  //#region src/components/Stepper.tsx
@@ -0,0 +1,43 @@
1
+ import { r as ButtonProps } from "../Button-Ct5I6aTu.js";
2
+ import * as React from "react";
3
+
4
+ //#region src/components/Suggestion.d.ts
5
+ interface SuggestionsProps extends React.HTMLAttributes<HTMLDivElement> {}
6
+ /**
7
+ * A horizontally scrollable row of prompt suggestions, typically shown above
8
+ * the composer or in the empty state. Children are {@link Suggestion} chips.
9
+ *
10
+ * Ported from AI Elements' Suggestions. Sigvelo changes: design-system Button
11
+ * chips and token-based styling; scrollbars hidden, scroll by wheel/touch.
12
+ */
13
+ declare function Suggestions({
14
+ className,
15
+ children,
16
+ ref,
17
+ ...props
18
+ }: SuggestionsProps & {
19
+ ref?: React.Ref<HTMLDivElement>;
20
+ }): React.JSX.Element;
21
+ interface SuggestionProps extends Omit<ButtonProps, "onClick" | "className"> {
22
+ className?: string;
23
+ /** The suggestion text — the chip label and the `onClick` payload. */
24
+ suggestion: string;
25
+ /** Called with the suggestion text; typically feeds `sendMessage`. */
26
+ onClick?: (suggestion: string) => void;
27
+ }
28
+ /** One pill-shaped suggestion chip. Renders `suggestion` unless children are given. */
29
+ declare function Suggestion({
30
+ className,
31
+ suggestion,
32
+ onClick,
33
+ variant,
34
+ color,
35
+ size,
36
+ children,
37
+ ref,
38
+ ...props
39
+ }: SuggestionProps & {
40
+ ref?: React.Ref<HTMLButtonElement>;
41
+ }): React.JSX.Element;
42
+ //#endregion
43
+ export { Suggestion, SuggestionProps, Suggestions, SuggestionsProps };
@@ -0,0 +1,39 @@
1
+ import { t as cx } from "../class-names-9UtZwb0J.js";
2
+ import { Button } from "./Button.js";
3
+ import "react";
4
+ import { jsx } from "react/jsx-runtime";
5
+ //#region src/components/Suggestion.tsx
6
+ /**
7
+ * A horizontally scrollable row of prompt suggestions, typically shown above
8
+ * the composer or in the empty state. Children are {@link Suggestion} chips.
9
+ *
10
+ * Ported from AI Elements' Suggestions. Sigvelo changes: design-system Button
11
+ * chips and token-based styling; scrollbars hidden, scroll by wheel/touch.
12
+ */
13
+ function Suggestions({ className, children, ref, ...props }) {
14
+ return /* @__PURE__ */ jsx("div", {
15
+ ref,
16
+ className: cx("suggestions", className),
17
+ ...props,
18
+ children: /* @__PURE__ */ jsx("div", {
19
+ className: "suggestions__row",
20
+ children
21
+ })
22
+ });
23
+ }
24
+ /** One pill-shaped suggestion chip. Renders `suggestion` unless children are given. */
25
+ function Suggestion({ className, suggestion, onClick, variant = "outline", color = "neutral", size = "sm", children, ref, ...props }) {
26
+ return /* @__PURE__ */ jsx(Button, {
27
+ ref,
28
+ type: "button",
29
+ variant,
30
+ color,
31
+ size,
32
+ className: cx("suggestions__chip", className),
33
+ onClick: () => onClick?.(suggestion),
34
+ ...props,
35
+ children: children ?? suggestion
36
+ });
37
+ }
38
+ //#endregion
39
+ export { Suggestion, Suggestions };
@@ -1,6 +1,6 @@
1
1
  import { CollapsiblePanel, CollapsibleRoot, CollapsibleTrigger } from "./Collapsible.js";
2
2
  import { t as cx } from "../class-names-9UtZwb0J.js";
3
- import { O as SearchIcon, h as FileIcon, l as ChevronRightIcon } from "../icons-Bf7JMKk-.js";
3
+ import { h as FileIcon, k as SearchIcon, l as ChevronRightIcon } from "../icons-DQC4Zw5R.js";
4
4
  import "react";
5
5
  import { jsx, jsxs } from "react/jsx-runtime";
6
6
  //#region src/components/Task.tsx
@@ -1,9 +1,9 @@
1
1
  import { t as cx } from "../class-names-9UtZwb0J.js";
2
- import { P as XIcon, j as TerminalIcon } from "../icons-Bf7JMKk-.js";
2
+ import { F as XIcon, M as TerminalIcon } from "../icons-DQC4Zw5R.js";
3
3
  import { Button } from "./Button.js";
4
4
  import { Tooltip, TooltipPopup, TooltipPortal, TooltipPositioner, TooltipTrigger } from "./Tooltip.js";
5
5
  import { Badge } from "./Badge.js";
6
- import { t as CopyButton } from "../copy-button-DAPlB8Z0.js";
6
+ import { t as CopyButton } from "../copy-button-Dd6DEhOm.js";
7
7
  import { ScrollArea } from "./ScrollArea.js";
8
8
  import * as React from "react";
9
9
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
@@ -1,6 +1,6 @@
1
1
  import { CollapsiblePanel, CollapsibleRoot, CollapsibleTrigger } from "./Collapsible.js";
2
2
  import { t as cx } from "../class-names-9UtZwb0J.js";
3
- import { P as XIcon, k as SpinnerIcon, l as ChevronRightIcon, o as CheckIcon } from "../icons-Bf7JMKk-.js";
3
+ import { A as SpinnerIcon, F as XIcon, l as ChevronRightIcon, o as CheckIcon } from "../icons-DQC4Zw5R.js";
4
4
  import { Badge } from "./Badge.js";
5
5
  import * as React from "react";
6
6
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
@@ -0,0 +1,207 @@
1
+ import { ExecutionApprovals } from "./PromptInput.js";
2
+ import { AgentChatProps, AgentChatRenderPartContext } from "./AgentChat.js";
3
+ import { BrowserLiveView, BrowserLiveViewProps } from "./BrowserLiveView.js";
4
+ import { BrowserReplay, BrowserReplayProps } from "./BrowserReplay.js";
5
+ import { FileInfo, UseWorkspaceOptions, WorkspaceExplorer, WorkspaceExplorerProps, WorkspaceFileState, WorkspaceInfo, WorkspaceSource, WorkspaceState, inferWorkspaceLanguage, useWorkspace } from "./WorkspaceExplorer.js";
6
+ import * as React from "react";
7
+ import { DynamicToolUIPart, ToolUIPart, UIMessage } from "ai";
8
+ import { useAgentChat } from "@cloudflare/think/react";
9
+ import { UseAgentOptions } from "agents/react";
10
+
11
+ //#region src/components/ThinkChat.d.ts
12
+ type ThinkChatValue = ReturnType<typeof useAgentChat<unknown, UIMessage>>;
13
+ type ThinkChatPart = UIMessage["parts"][number];
14
+ interface ThinkChatProviderProps {
15
+ /** The `useAgentChat` value from the `agents` SDK that descendants read. */
16
+ chat: ThinkChatValue;
17
+ children: React.ReactNode;
18
+ }
19
+ interface ThinkChatRootProps<State = unknown> {
20
+ /** Agent to connect to: a kebab-case class name, or full `useAgent` options. */
21
+ agent: string | UseAgentOptions<State>;
22
+ /** Instance name (e.g. a session or room id). Wins over `agent.name`. */
23
+ name?: string;
24
+ children: React.ReactNode;
25
+ }
26
+ interface ThinkChatMessagesProps extends ThinkChatActivityRendererOptions {
27
+ className?: string;
28
+ /** Disable the composer (e.g. while the agent is unreachable). */
29
+ disabled?: boolean;
30
+ /** Shown in place of the list while there are no messages. */
31
+ emptyState?: React.ReactNode;
32
+ /** Extra controls rendered inside the composer, next to the send button. */
33
+ composerTools?: React.ReactNode;
34
+ /** Composer placeholder text. */
35
+ placeholder?: string;
36
+ /** Rendered after each message (e.g. per-message actions). */
37
+ renderMessageAfter?: AgentChatProps["renderMessageAfter"];
38
+ /** Prompt suggestions shown above the composer; clicking one sends it. */
39
+ suggestions?: AgentChatProps["suggestions"];
40
+ /**
41
+ * Overrides the built-in connection notice (derived from the hook's
42
+ * `isRecovering`/`connectionError`) shown between transcript and composer.
43
+ */
44
+ notice?: AgentChatProps["notice"];
45
+ /** Full replacement for part rendering; wins over excludeTools/toolRenderers. */
46
+ renderPart?: AgentChatProps["renderPart"];
47
+ /**
48
+ * Surfaces paused codemode executions in the composer's approval UI —
49
+ * the same confirmation tool approvals use. See {@link ExecutionApprovals}.
50
+ */
51
+ executionApprovals?: ExecutionApprovals;
52
+ /**
53
+ * Shows a Context ring in the composer footer — how much of the model's
54
+ * window the conversation occupies, from `metadata.usage` on the newest
55
+ * message that reports it.
56
+ */
57
+ contextWindow?: AgentChatProps["contextWindow"];
58
+ }
59
+ /**
60
+ * Bespoke rendering for one tool inside the activity log. Both hooks fall
61
+ * through to the built-in families when they return `undefined`, so an
62
+ * override can adjust just the label or just the panel.
63
+ */
64
+ interface ThinkChatToolRenderer {
65
+ /** One-line step label. `null` hides the step from the log. */
66
+ describe?: (part: ToolUIPart | DynamicToolUIPart) => string | null | undefined;
67
+ /** Expanded detail under the step. `null` keeps the step a plain row. */
68
+ panel?: (part: ToolUIPart | DynamicToolUIPart) => React.ReactNode;
69
+ }
70
+ type ThinkChatToolRenderers = Record<string, ThinkChatToolRenderer>;
71
+ interface ThinkChatActivityRendererOptions {
72
+ /**
73
+ * Tool names to keep out of activity folding entirely — the run splits
74
+ * around them and they fall through to your own renderPart / the generic
75
+ * Tool card. For tools that should stay in the log with custom UI, use
76
+ * `toolRenderers` instead.
77
+ */
78
+ excludeTools?: readonly string[];
79
+ /** Per-tool label/panel overrides inside the activity log, keyed by tool name. */
80
+ toolRenderers?: ThinkChatToolRenderers;
81
+ }
82
+ /**
83
+ * Chat UI for Cloudflare Think agents. Provide a `useAgentChat` value (or let
84
+ * `ThinkChat.Root` create one) and `ThinkChat.Messages` renders the message
85
+ * stream with agent work folded into collapsed Activity blocks.
86
+ */
87
+ declare function ThinkChatProvider({
88
+ chat,
89
+ children
90
+ }: ThinkChatProviderProps): React.JSX.Element;
91
+ /**
92
+ * Batteries-included root: connects to the named Think agent (upstream's
93
+ * `useAgent` + `useAgentChat`) and provides the live chat to everything
94
+ * inside. If the app already owns the chat hook, use `ThinkChat.Provider`.
95
+ *
96
+ * @example
97
+ * ```tsx
98
+ * <ThinkChat.Root agent="my-agent" name="session-1">
99
+ * <ThinkChat.Messages />
100
+ * </ThinkChat.Root>
101
+ * ```
102
+ */
103
+ declare function ThinkChatRoot<State = unknown>({
104
+ agent: agentOption,
105
+ name,
106
+ children
107
+ }: ThinkChatRootProps<State>): React.JSX.Element;
108
+ /**
109
+ * The full conversation surface — message list plus composer — with the
110
+ * activity renderer as the default `renderPart`: runs of reasoning/tool parts
111
+ * fold into one collapsed Activity block with derived labels and per-tool
112
+ * panels. Extend for app-specific tools with `toolRenderers` (label/panel
113
+ * inside the log) or `excludeTools` + your own `renderPart` (standalone
114
+ * card) — see README "App-specific tools" and the Custom Tool Panel story.
115
+ */
116
+ declare function ThinkChatMessages({
117
+ renderPart,
118
+ excludeTools,
119
+ toolRenderers,
120
+ executionApprovals,
121
+ notice,
122
+ ...props
123
+ }: ThinkChatMessagesProps): React.JSX.Element;
124
+ /** Agent work (reasoning, tool calls, step boundaries) vs. content shown to the user. */
125
+ declare function isThinkChatActivityPart(part: ThinkChatPart | undefined, excludeTools?: ReadonlySet<string>): boolean;
126
+ /**
127
+ * One-line natural-language label for an activity part ("Ran vp test",
128
+ * "Fetched developers.cloudflare.com/agents/"); `null` for boundaries that
129
+ * aren't steps (step-start). Exported so a custom `renderPart` can reuse the
130
+ * built-in labels for tools it doesn't override.
131
+ */
132
+ declare function describeThinkChatActivityPart(part: ThinkChatPart, toolRenderers?: ThinkChatToolRenderers): string | null;
133
+ interface ThinkChatActivityProps {
134
+ /** Render with the log expanded. */
135
+ defaultOpen?: boolean;
136
+ parts: readonly ThinkChatPart[];
137
+ /** Defaults to deriving from part states (reasoning streaming, tool awaiting output). */
138
+ isStreaming?: boolean;
139
+ /** Per-tool label/panel overrides, keyed by tool name. */
140
+ toolRenderers?: ThinkChatToolRenderers;
141
+ }
142
+ /**
143
+ * One run of agent work as a collapsed Activity block: while streaming the
144
+ * label shimmers with the live step; settled, it becomes a short summary
145
+ * ("Thought, read 2 files and ran a command") over an expandable step log
146
+ * with per-tool panels. Normally reached through `ThinkChat.Messages`;
147
+ * exported for apps that lay out messages themselves.
148
+ */
149
+ declare function ThinkChatActivity({
150
+ parts,
151
+ defaultOpen,
152
+ isStreaming,
153
+ toolRenderers
154
+ }: ThinkChatActivityProps): React.JSX.Element | null;
155
+ /**
156
+ * Builds a renderPart handler that folds every run of consecutive activity
157
+ * parts (reasoning + tool calls) into one collapsed Activity box. Everything
158
+ * is derived from the UIMessage stream: part order, tool states, reasoning
159
+ * state. Excluded tools split the run and return undefined so your own
160
+ * renderPart (or the generic Tool card) takes over for them.
161
+ */
162
+ declare function createThinkChatActivityRenderer({
163
+ excludeTools,
164
+ toolRenderers
165
+ }?: ThinkChatActivityRendererOptions): NonNullable<AgentChatProps["renderPart"]>;
166
+ /** Default activity renderer — `createThinkChatActivityRenderer()` with no overrides. */
167
+ declare const renderThinkChatActivityPart: (context: AgentChatRenderPartContext<UIMessage<unknown, import("ai").UIDataTypes, import("ai").UITools>>) => React.ReactNode | undefined;
168
+ /**
169
+ * The ambient chat value from `ThinkChat.Root`/`Provider` — for custom tool
170
+ * panels, cards, or composer actions that need `messages`, `status`, or
171
+ * `sendMessage`. Throws outside a provider.
172
+ */
173
+ declare function useThinkChat(): Omit<import("@ai-sdk/react").UseChatHelpers<UIMessage<unknown, import("ai").UIDataTypes, import("ai").UITools>>, "addToolOutput"> & {
174
+ clearHistory: () => void;
175
+ addToolOutput: (opts: {
176
+ toolCallId: string;
177
+ toolName?: string;
178
+ output?: unknown;
179
+ state?: "output-available" | "output-error";
180
+ errorText?: string;
181
+ }) => void;
182
+ isServerStreaming: boolean;
183
+ isStreaming: boolean;
184
+ isRecovering: boolean;
185
+ isToolContinuation: boolean;
186
+ connectionError: (Error & {
187
+ code: number;
188
+ reason: string;
189
+ wasClean: boolean;
190
+ }) | null;
191
+ };
192
+ /**
193
+ * Namespace entry point. `Root` + `Messages` is the standard surface;
194
+ * `Provider` + `useThinkChat` when the app owns the chat hook; `Activity`,
195
+ * `renderActivityPart`, and `createActivityRenderer` for custom layouts and
196
+ * app-specific tools.
197
+ */
198
+ declare const ThinkChat: {
199
+ Provider: typeof ThinkChatProvider;
200
+ Root: typeof ThinkChatRoot;
201
+ Messages: typeof ThinkChatMessages;
202
+ Activity: typeof ThinkChatActivity;
203
+ renderActivityPart: (context: AgentChatRenderPartContext<UIMessage<unknown, import("ai").UIDataTypes, import("ai").UITools>>) => React.ReactNode | undefined;
204
+ createActivityRenderer: typeof createThinkChatActivityRenderer;
205
+ };
206
+ //#endregion
207
+ export { BrowserLiveView, type BrowserLiveViewProps, BrowserReplay, type BrowserReplayProps, type ExecutionApprovals, type FileInfo, ThinkChat, ThinkChatActivity, ThinkChatActivityProps, ThinkChatActivityRendererOptions, ThinkChatMessages, ThinkChatMessagesProps, ThinkChatProvider, ThinkChatProviderProps, ThinkChatRoot, ThinkChatRootProps, ThinkChatToolRenderer, ThinkChatToolRenderers, type UseWorkspaceOptions, WorkspaceExplorer, type WorkspaceExplorerProps, type WorkspaceFileState, type WorkspaceInfo, type WorkspaceSource, type WorkspaceState, createThinkChatActivityRenderer, describeThinkChatActivityPart, inferWorkspaceLanguage, isThinkChatActivityPart, renderThinkChatActivityPart, useThinkChat, useWorkspace };