@mcp-b/react-components 0.2.1 → 0.3.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 (53) hide show
  1. package/dist/{CodeBlock-BrCoypnc.js → CodeBlock-C2Xjxu9M.js} +1 -1
  2. package/dist/FileTree-D0c9Yj9U.js +310 -0
  3. package/dist/PromptInput-Dzn-fOPc.d.ts +444 -0
  4. package/dist/components/Activity.js +1 -1
  5. package/dist/components/AgentChat.d.ts +19 -9
  6. package/dist/components/AgentChat.js +27 -24
  7. package/dist/components/AgentConnection.js +2 -2
  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/ContextMenu.js +1 -1
  18. package/dist/components/Conversation.js +1 -1
  19. package/dist/components/Dialog.js +1 -1
  20. package/dist/components/EnvironmentVariables.js +1 -1
  21. package/dist/components/FileTree.js +1 -309
  22. package/dist/components/Menubar.js +1 -1
  23. package/dist/components/Message.d.ts +2 -1
  24. package/dist/components/Message.js +1 -1
  25. package/dist/components/ModelSelector.js +1 -1
  26. package/dist/components/NavigationMenu.js +1 -1
  27. package/dist/components/PricingPage.js +1 -1
  28. package/dist/components/PromptInput.d.ts +2 -399
  29. package/dist/components/PromptInput.js +177 -2
  30. package/dist/components/Queue.js +1 -1
  31. package/dist/components/Reasoning.js +1 -1
  32. package/dist/components/Select.js +1 -1
  33. package/dist/components/Sources.js +1 -1
  34. package/dist/components/Stepper.js +1 -1
  35. package/dist/components/Task.js +1 -1
  36. package/dist/components/Terminal.js +2 -2
  37. package/dist/components/TestResults.js +1 -1
  38. package/dist/components/ThinkChat.d.ts +186 -0
  39. package/dist/components/ThinkChat.js +730 -0
  40. package/dist/components/Tool.d.ts +32 -28
  41. package/dist/components/Tool.js +29 -16
  42. package/dist/components/WebPreview.js +1 -1
  43. package/dist/components/WorkspaceExplorer.d.ts +102 -0
  44. package/dist/components/WorkspaceExplorer.js +352 -0
  45. package/dist/components/icons.d.ts +2 -2
  46. package/dist/components/icons.js +2 -2
  47. package/dist/{copy-button-DAPlB8Z0.js → copy-button-Dd6DEhOm.js} +1 -1
  48. package/dist/{icons-Bf7JMKk-.js → icons-DQC4Zw5R.js} +5 -1
  49. package/dist/{icons-BklFyZbx.d.ts → icons-ctdVxng0.d.ts} +2 -1
  50. package/dist/styles/activity.css +6 -5
  51. package/dist/styles/conversation.css +3 -0
  52. package/dist/styles/prompt-input.css +149 -0
  53. package/package.json +26 -3
@@ -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,186 @@
1
+ import { AgentChatProps, AgentChatRenderPartContext } from "./AgentChat.js";
2
+ import { BrowserLiveView, BrowserLiveViewProps } from "./BrowserLiveView.js";
3
+ import { BrowserReplay, BrowserReplayProps } from "./BrowserReplay.js";
4
+ import { FileInfo, UseWorkspaceOptions, WorkspaceExplorer, WorkspaceExplorerProps, WorkspaceFileState, WorkspaceInfo, WorkspaceSource, WorkspaceState, inferWorkspaceLanguage, useWorkspace } from "./WorkspaceExplorer.js";
5
+ import * as React from "react";
6
+ import { DynamicToolUIPart, ToolUIPart, UIMessage } from "ai";
7
+ import { useAgentChat } from "@cloudflare/think/react";
8
+ import { UseAgentOptions } from "agents/react";
9
+
10
+ //#region src/components/ThinkChat.d.ts
11
+ type ThinkChatValue = ReturnType<typeof useAgentChat<unknown, UIMessage>>;
12
+ type ThinkChatPart = UIMessage["parts"][number];
13
+ interface ThinkChatProviderProps {
14
+ /** The `useAgentChat` value from the `agents` SDK that descendants read. */
15
+ chat: ThinkChatValue;
16
+ children: React.ReactNode;
17
+ }
18
+ interface ThinkChatRootProps<State = unknown> {
19
+ /** Agent to connect to: a kebab-case class name, or full `useAgent` options. */
20
+ agent: string | UseAgentOptions<State>;
21
+ /** Instance name (e.g. a session or room id). Wins over `agent.name`. */
22
+ name?: string;
23
+ children: React.ReactNode;
24
+ }
25
+ interface ThinkChatMessagesProps extends ThinkChatActivityRendererOptions {
26
+ className?: string;
27
+ /** Disable the composer (e.g. while the agent is unreachable). */
28
+ disabled?: boolean;
29
+ /** Shown in place of the list while there are no messages. */
30
+ emptyState?: React.ReactNode;
31
+ /** Extra controls rendered inside the composer, next to the send button. */
32
+ composerTools?: React.ReactNode;
33
+ /** Composer placeholder text. */
34
+ placeholder?: string;
35
+ /** Rendered after each message (e.g. per-message actions). */
36
+ renderMessageAfter?: AgentChatProps["renderMessageAfter"];
37
+ /** Full replacement for part rendering; wins over excludeTools/toolRenderers. */
38
+ renderPart?: AgentChatProps["renderPart"];
39
+ }
40
+ /**
41
+ * Bespoke rendering for one tool inside the activity log. Both hooks fall
42
+ * through to the built-in families when they return `undefined`, so an
43
+ * override can adjust just the label or just the panel.
44
+ */
45
+ interface ThinkChatToolRenderer {
46
+ /** One-line step label. `null` hides the step from the log. */
47
+ describe?: (part: ToolUIPart | DynamicToolUIPart) => string | null | undefined;
48
+ /** Expanded detail under the step. `null` keeps the step a plain row. */
49
+ panel?: (part: ToolUIPart | DynamicToolUIPart) => React.ReactNode;
50
+ }
51
+ type ThinkChatToolRenderers = Record<string, ThinkChatToolRenderer>;
52
+ interface ThinkChatActivityRendererOptions {
53
+ /**
54
+ * Tool names to keep out of activity folding entirely — the run splits
55
+ * around them and they fall through to your own renderPart / the generic
56
+ * Tool card. For tools that should stay in the log with custom UI, use
57
+ * `toolRenderers` instead.
58
+ */
59
+ excludeTools?: readonly string[];
60
+ /** Per-tool label/panel overrides inside the activity log, keyed by tool name. */
61
+ toolRenderers?: ThinkChatToolRenderers;
62
+ }
63
+ /**
64
+ * Chat UI for Cloudflare Think agents. Provide a `useAgentChat` value (or let
65
+ * `ThinkChat.Root` create one) and `ThinkChat.Messages` renders the message
66
+ * stream with agent work folded into collapsed Activity blocks.
67
+ */
68
+ declare function ThinkChatProvider({
69
+ chat,
70
+ children
71
+ }: ThinkChatProviderProps): React.JSX.Element;
72
+ /**
73
+ * Batteries-included root: connects to the named Think agent (upstream's
74
+ * `useAgent` + `useAgentChat`) and provides the live chat to everything
75
+ * inside. If the app already owns the chat hook, use `ThinkChat.Provider`.
76
+ *
77
+ * @example
78
+ * ```tsx
79
+ * <ThinkChat.Root agent="my-agent" name="session-1">
80
+ * <ThinkChat.Messages />
81
+ * </ThinkChat.Root>
82
+ * ```
83
+ */
84
+ declare function ThinkChatRoot<State = unknown>({
85
+ agent: agentOption,
86
+ name,
87
+ children
88
+ }: ThinkChatRootProps<State>): React.JSX.Element;
89
+ /**
90
+ * The full conversation surface — message list plus composer — with the
91
+ * activity renderer as the default `renderPart`: runs of reasoning/tool parts
92
+ * fold into one collapsed Activity block with derived labels and per-tool
93
+ * panels. Extend for app-specific tools with `toolRenderers` (label/panel
94
+ * inside the log) or `excludeTools` + your own `renderPart` (standalone
95
+ * card) — see README "App-specific tools" and the Custom Tool Panel story.
96
+ */
97
+ declare function ThinkChatMessages({
98
+ renderPart,
99
+ excludeTools,
100
+ toolRenderers,
101
+ ...props
102
+ }: ThinkChatMessagesProps): React.JSX.Element;
103
+ /** Agent work (reasoning, tool calls, step boundaries) vs. content shown to the user. */
104
+ declare function isThinkChatActivityPart(part: ThinkChatPart | undefined, excludeTools?: ReadonlySet<string>): boolean;
105
+ /**
106
+ * One-line natural-language label for an activity part ("Ran vp test",
107
+ * "Fetched developers.cloudflare.com/agents/"); `null` for boundaries that
108
+ * aren't steps (step-start). Exported so a custom `renderPart` can reuse the
109
+ * built-in labels for tools it doesn't override.
110
+ */
111
+ declare function describeThinkChatActivityPart(part: ThinkChatPart, toolRenderers?: ThinkChatToolRenderers): string | null;
112
+ interface ThinkChatActivityProps {
113
+ /** Render with the log expanded. */
114
+ defaultOpen?: boolean;
115
+ parts: readonly ThinkChatPart[];
116
+ /** Defaults to deriving from part states (reasoning streaming, tool awaiting output). */
117
+ isStreaming?: boolean;
118
+ /** Per-tool label/panel overrides, keyed by tool name. */
119
+ toolRenderers?: ThinkChatToolRenderers;
120
+ }
121
+ /**
122
+ * One run of agent work as a collapsed Activity block: while streaming the
123
+ * label shimmers with the live step; settled, it becomes a short summary
124
+ * ("Thought, read 2 files and ran a command") over an expandable step log
125
+ * with per-tool panels. Normally reached through `ThinkChat.Messages`;
126
+ * exported for apps that lay out messages themselves.
127
+ */
128
+ declare function ThinkChatActivity({
129
+ parts,
130
+ defaultOpen,
131
+ isStreaming,
132
+ toolRenderers
133
+ }: ThinkChatActivityProps): React.JSX.Element | null;
134
+ /**
135
+ * Builds a renderPart handler that folds every run of consecutive activity
136
+ * parts (reasoning + tool calls) into one collapsed Activity box. Everything
137
+ * is derived from the UIMessage stream: part order, tool states, reasoning
138
+ * state. Excluded tools split the run and return undefined so your own
139
+ * renderPart (or the generic Tool card) takes over for them.
140
+ */
141
+ declare function createThinkChatActivityRenderer({
142
+ excludeTools,
143
+ toolRenderers
144
+ }?: ThinkChatActivityRendererOptions): NonNullable<AgentChatProps["renderPart"]>;
145
+ /** Default activity renderer — `createThinkChatActivityRenderer()` with no overrides. */
146
+ declare const renderThinkChatActivityPart: (context: AgentChatRenderPartContext<UIMessage<unknown, import("ai").UIDataTypes, import("ai").UITools>>) => React.ReactNode | undefined;
147
+ /**
148
+ * The ambient chat value from `ThinkChat.Root`/`Provider` — for custom tool
149
+ * panels, cards, or composer actions that need `messages`, `status`, or
150
+ * `sendMessage`. Throws outside a provider.
151
+ */
152
+ declare function useThinkChat(): Omit<import("@ai-sdk/react").UseChatHelpers<UIMessage<unknown, import("ai").UIDataTypes, import("ai").UITools>>, "addToolOutput"> & {
153
+ clearHistory: () => void;
154
+ addToolOutput: (opts: {
155
+ toolCallId: string;
156
+ toolName?: string;
157
+ output?: unknown;
158
+ state?: "output-available" | "output-error";
159
+ errorText?: string;
160
+ }) => void;
161
+ isServerStreaming: boolean;
162
+ isStreaming: boolean;
163
+ isRecovering: boolean;
164
+ isToolContinuation: boolean;
165
+ connectionError: (Error & {
166
+ code: number;
167
+ reason: string;
168
+ wasClean: boolean;
169
+ }) | null;
170
+ };
171
+ /**
172
+ * Namespace entry point. `Root` + `Messages` is the standard surface;
173
+ * `Provider` + `useThinkChat` when the app owns the chat hook; `Activity`,
174
+ * `renderActivityPart`, and `createActivityRenderer` for custom layouts and
175
+ * app-specific tools.
176
+ */
177
+ declare const ThinkChat: {
178
+ Provider: typeof ThinkChatProvider;
179
+ Root: typeof ThinkChatRoot;
180
+ Messages: typeof ThinkChatMessages;
181
+ Activity: typeof ThinkChatActivity;
182
+ renderActivityPart: (context: AgentChatRenderPartContext<UIMessage<unknown, import("ai").UIDataTypes, import("ai").UITools>>) => React.ReactNode | undefined;
183
+ createActivityRenderer: typeof createThinkChatActivityRenderer;
184
+ };
185
+ //#endregion
186
+ export { BrowserLiveView, type BrowserLiveViewProps, BrowserReplay, type BrowserReplayProps, 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 };