@mcp-b/react-components 0.3.0 → 0.5.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 (59) hide show
  1. package/dist/{CodeBlock-C2Xjxu9M.js → CodeBlock-D-a84xBL.js} +1 -1
  2. package/dist/{FileTree-D0c9Yj9U.js → FileTree-D8rtTLgK.js} +1 -1
  3. package/dist/attachment-preview-ChtC3HiU.js +25 -0
  4. package/dist/components/Activity.js +1 -1
  5. package/dist/components/AgentChat.d.ts +31 -1
  6. package/dist/components/AgentChat.js +166 -38
  7. package/dist/components/AgentConnection.js +3 -3
  8. package/dist/components/Artifact.js +1 -1
  9. package/dist/components/BrowserLiveView.js +2 -2
  10. package/dist/components/BrowserReplay.js +1 -1
  11. package/dist/components/ChainOfThought.d.ts +1 -1
  12. package/dist/components/ChainOfThought.js +1 -1
  13. package/dist/components/CodeBlock.js +1 -1
  14. package/dist/components/Commit.js +2 -2
  15. package/dist/components/Context.d.ts +28 -27
  16. package/dist/components/Context.js +48 -47
  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 -1
  22. package/dist/components/Menubar.js +1 -1
  23. package/dist/components/Message.d.ts +16 -2
  24. package/dist/components/Message.js +39 -5
  25. package/dist/components/ModelSelector.js +1 -1
  26. package/dist/components/NavigationMenu.js +1 -1
  27. package/dist/components/PricingPage.js +2 -2
  28. package/dist/components/PromptInput.d.ts +532 -2
  29. package/dist/components/PromptInput.js +158 -20
  30. package/dist/components/Queue.js +1 -1
  31. package/dist/components/Reasoning.js +9 -17
  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 +24 -5
  39. package/dist/components/ThinkChat.js +87 -19
  40. package/dist/components/WebPreview.js +1 -1
  41. package/dist/components/WorkspaceExplorer.js +3 -3
  42. package/dist/components/icons.d.ts +2 -2
  43. package/dist/components/icons.js +2 -2
  44. package/dist/{copy-button-Dd6DEhOm.js → copy-button-BmJEAKuP.js} +1 -1
  45. package/dist/{icons-DQC4Zw5R.js → icons-CZRH4FVH.js} +1 -15
  46. package/dist/{icons-ctdVxng0.d.ts → icons-CmO7-pNY.d.ts} +1 -2
  47. package/dist/styles/agent-chat.css +39 -6
  48. package/dist/styles/attachment-preview.css +21 -0
  49. package/dist/styles/context.css +9 -17
  50. package/dist/styles/conversation.css +3 -3
  51. package/dist/styles/index.css +1 -1
  52. package/dist/styles/message.css +50 -2
  53. package/dist/styles/prompt-input.css +189 -6
  54. package/dist/styles/reasoning.css +0 -1
  55. package/package.json +2 -2
  56. package/dist/PromptInput-Dzn-fOPc.d.ts +0 -444
  57. package/dist/components/Tool.d.ts +0 -123
  58. package/dist/components/Tool.js +0 -209
  59. package/dist/styles/tool.css +0 -203
@@ -1,6 +1,6 @@
1
1
  import { t as cx } from "./class-names-9UtZwb0J.js";
2
2
  import { Select, SelectContent, SelectItem, SelectList, SelectTrigger, SelectValue } from "./components/Select.js";
3
- import { t as CopyButton } from "./copy-button-Dd6DEhOm.js";
3
+ import { t as CopyButton } from "./copy-button-BmJEAKuP.js";
4
4
  import * as React from "react";
5
5
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
6
6
  import { createHighlighter } from "shiki";
@@ -1,5 +1,5 @@
1
1
  import { t as cx } from "./class-names-9UtZwb0J.js";
2
- import { _ as FolderOpenIcon, g as FolderIcon, h as FileIcon, l as ChevronRightIcon } from "./icons-DQC4Zw5R.js";
2
+ import { c as ChevronRightIcon, g as FolderOpenIcon, h as FolderIcon, m as FileIcon } from "./icons-CZRH4FVH.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
@@ -0,0 +1,25 @@
1
+ import { Dialog, DialogContent, DialogTrigger } from "./components/Dialog.js";
2
+ import "react";
3
+ import { jsx, jsxs } from "react/jsx-runtime";
4
+ //#region src/components/_internal/attachment-preview.tsx
5
+ /**
6
+ * Click-to-zoom for image attachments: `children` is the thumbnail and
7
+ * becomes the dialog trigger; the dialog shows the image full size. Shared by
8
+ * the composer chips and message-side attachments.
9
+ */
10
+ function AttachmentPreview({ url, filename, children }) {
11
+ return /* @__PURE__ */ jsxs(Dialog, { children: [/* @__PURE__ */ jsx(DialogTrigger, { render: children }), /* @__PURE__ */ jsxs(DialogContent, {
12
+ className: "attachment-preview",
13
+ "aria-label": filename ?? "Attachment preview",
14
+ children: [/* @__PURE__ */ jsx("img", {
15
+ className: "attachment-preview__image",
16
+ src: url,
17
+ alt: filename ?? "Attachment"
18
+ }), filename ? /* @__PURE__ */ jsx("div", {
19
+ className: "attachment-preview__name",
20
+ children: filename
21
+ }) : null]
22
+ })] });
23
+ }
24
+ //#endregion
25
+ export { AttachmentPreview as t };
@@ -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 { l as ChevronRightIcon } from "../icons-DQC4Zw5R.js";
3
+ import { c as ChevronRightIcon } from "../icons-CZRH4FVH.js";
4
4
  import "react";
5
5
  import { jsx, jsxs } from "react/jsx-runtime";
6
6
  //#region src/components/Activity.tsx
@@ -1,4 +1,4 @@
1
- import { X as PromptInputMessage, dt as PromptInputStatus } from "../PromptInput-Dzn-fOPc.js";
1
+ import { ExecutionApprovals, PromptInputMessage, PromptInputStatus } from "./PromptInput.js";
2
2
  import * as React from "react";
3
3
  import { ChatAddToolApproveResponseFunction, UIMessage } from "ai";
4
4
 
@@ -30,12 +30,38 @@ interface AgentChatProps<MessageT extends UIMessage = UIMessage> {
30
30
  emptyState?: React.ReactNode;
31
31
  /** Extra controls rendered in the composer toolbar. */
32
32
  composerTools?: React.ReactNode;
33
+ /**
34
+ * Transient status rendered between the transcript and the composer —
35
+ * e.g. a "Reconnecting…" pill. `ThinkChat.Messages` fills this from the
36
+ * hook's `isRecovering`/`connectionError` automatically.
37
+ */
38
+ notice?: React.ReactNode;
39
+ /**
40
+ * When set, the last assistant message gets a Retry action that calls this
41
+ * with its message id — pass to the AI SDK's `regenerate({ messageId })`.
42
+ */
43
+ onRegenerate?: (messageId: string) => void;
33
44
  /**
34
45
  * Pass `addToolApprovalResponse` from `useAgentChat`/`useChat` directly.
35
46
  * When set and a tool call awaits approval, the composer becomes the
36
47
  * confirmation.
37
48
  */
38
49
  onApprovalResponse?: ChatAddToolApproveResponseFunction;
50
+ /**
51
+ * When set, paused codemode executions surface in the same composer
52
+ * confirmation as tool approvals. See {@link ExecutionApprovals}.
53
+ */
54
+ executionApprovals?: ExecutionApprovals;
55
+ /**
56
+ * When set, a Context ring in the composer footer shows how much of the
57
+ * model's window the conversation occupies. Used tokens come from the
58
+ * newest message carrying `metadata.usage` (the AI SDK `messageMetadata`
59
+ * convention; Think merges it into message metadata as turns finish).
60
+ */
61
+ contextWindow?: {
62
+ maxTokens: number;
63
+ modelId?: string;
64
+ };
39
65
  /** Override rendering per part; return `undefined` to fall back to the default part UI. */
40
66
  renderPart?: (context: AgentChatRenderPartContext<MessageT>) => React.ReactNode | undefined;
41
67
  /** Rendered after each message's parts — for actions, citations, and the like. */
@@ -60,7 +86,11 @@ declare function AgentChat<MessageT extends UIMessage = UIMessage>({
60
86
  disabled,
61
87
  emptyState,
62
88
  composerTools,
89
+ notice,
90
+ onRegenerate,
63
91
  onApprovalResponse,
92
+ executionApprovals,
93
+ contextWindow,
64
94
  renderPart,
65
95
  renderMessageAfter,
66
96
  ref
@@ -1,28 +1,82 @@
1
1
  import { t as cx } from "../class-names-9UtZwb0J.js";
2
+ import { D as RefreshIcon, E as PlusIcon } from "../icons-CZRH4FVH.js";
3
+ import { Activity, ActivityContent, ActivityPanel, ActivityTrigger } from "./Activity.js";
4
+ import { Context, ContextContent, ContextContentBody, ContextContentHeader, ContextTrigger, getContextUsage, getContextUsedTokens } from "./Context.js";
2
5
  import { Conversation, ConversationContent, ConversationEmptyState, ConversationScrollButton } from "./Conversation.js";
3
- import { Message, MessageContent, MessageResponse } from "./Message.js";
4
- import { PromptInput, PromptInputApproval, PromptInputBody, PromptInputFooter, PromptInputSubmit, PromptInputTextarea, PromptInputTools, getPendingToolApprovals } from "./PromptInput.js";
6
+ import { Message, MessageAction, MessageActions, MessageAttachment, MessageContent, MessageResponse } from "./Message.js";
7
+ import { PromptInput, PromptInputApproval, PromptInputAttachments, PromptInputBody, PromptInputButton, PromptInputFooter, PromptInputPermissionSelector, PromptInputSubmit, PromptInputTextarea, PromptInputTools, getApprovalRequestId, getPendingToolApprovals, usePromptInputAttachments } from "./PromptInput.js";
5
8
  import { Reasoning, ReasoningContent, ReasoningTrigger } from "./Reasoning.js";
6
- import { Tool, ToolContent, ToolHeader, ToolInput, ToolOutput } from "./Tool.js";
7
9
  import * as React from "react";
8
10
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
9
- import { isReasoningUIPart, isTextUIPart, isToolOrDynamicToolUIPart } from "ai";
11
+ import { getToolName, isFileUIPart, isReasoningUIPart, isTextUIPart, isToolOrDynamicToolUIPart } from "ai";
10
12
  //#region src/components/AgentChat.tsx
13
+ function AgentChatAttachButton() {
14
+ const attachments = usePromptInputAttachments();
15
+ return /* @__PURE__ */ jsx(PromptInputButton, {
16
+ tooltip: "Add photos or files",
17
+ onClick: () => attachments.openFileDialog(),
18
+ children: /* @__PURE__ */ jsx(PlusIcon, {})
19
+ });
20
+ }
21
+ function isCompactedPart(message, part, partIndex) {
22
+ const metadata = message.metadata;
23
+ if (isTextUIPart(part)) return Array.isArray(metadata?.compactedTextParts) && metadata.compactedTextParts.includes(partIndex);
24
+ if (isToolOrDynamicToolUIPart(part)) return Array.isArray(metadata?.compactedToolOutputs) && metadata.compactedToolOutputs.includes(part.toolCallId);
25
+ return false;
26
+ }
11
27
  function getPartKey(part, partIndex) {
12
28
  if (isToolOrDynamicToolUIPart(part)) return part.toolCallId;
13
29
  if ("id" in part && typeof part.id === "string") return `${part.type}-${part.id}`;
14
30
  return `${part.type}-${partIndex}`;
15
31
  }
32
+ function summarizeToolInput(input) {
33
+ if (!input || typeof input !== "object") return null;
34
+ for (const value of Object.values(input)) if (typeof value === "string" && value.trim()) {
35
+ const line = value.trim().split("\n", 1)[0] ?? "";
36
+ return line.length > 64 ? `${line.slice(0, 64)}…` : line;
37
+ }
38
+ return null;
39
+ }
40
+ function isToolPartWorking(part) {
41
+ return part.state === "input-streaming" || part.state === "input-available" || part.state === "approval-requested";
42
+ }
43
+ function isToolPartFailed(part) {
44
+ return part.state === "output-error" || part.state === "output-denied";
45
+ }
46
+ function describeToolPart(part) {
47
+ const name = getToolName(part);
48
+ const verb = isToolPartFailed(part) ? `${name} failed` : isToolPartWorking(part) ? `Running ${name}` : `Ran ${name}`;
49
+ const detail = summarizeToolInput(part.input);
50
+ return detail ? `${verb} · ${detail}` : verb;
51
+ }
52
+ function formatToolValue(value) {
53
+ if (value === void 0) return void 0;
54
+ return typeof value === "string" ? value : JSON.stringify(value, null, 2);
55
+ }
56
+ function renderToolActivity(part) {
57
+ const failed = isToolPartFailed(part);
58
+ const output = part.state === "output-error" ? part.errorText : part.state === "output-denied" ? part.approval.reason ?? "Denied" : formatToolValue("output" in part ? part.output : void 0);
59
+ return /* @__PURE__ */ jsxs(Activity, {
60
+ isStreaming: isToolPartWorking(part),
61
+ children: [/* @__PURE__ */ jsx(ActivityTrigger, { label: describeToolPart(part) }), /* @__PURE__ */ jsxs(ActivityContent, { children: [/* @__PURE__ */ jsx(ActivityPanel, {
62
+ label: getToolName(part),
63
+ text: formatToolValue(part.input)
64
+ }), output ? /* @__PURE__ */ jsx(ActivityPanel, {
65
+ label: "output",
66
+ text: output,
67
+ status: part.state === "output-denied" ? "denied" : failed ? "error" : void 0,
68
+ error: failed
69
+ }) : null] })]
70
+ });
71
+ }
16
72
  function renderDefaultPart(part) {
17
73
  if (isTextUIPart(part) && part.text) return /* @__PURE__ */ jsx(MessageResponse, { children: part.text });
74
+ if (isFileUIPart(part)) return /* @__PURE__ */ jsx(MessageAttachment, { part });
18
75
  if (isReasoningUIPart(part) && part.text) return /* @__PURE__ */ jsxs(Reasoning, {
19
76
  isStreaming: part.state === "streaming",
20
77
  children: [/* @__PURE__ */ jsx(ReasoningTrigger, {}), /* @__PURE__ */ jsx(ReasoningContent, { children: part.text })]
21
78
  });
22
- if (isToolOrDynamicToolUIPart(part)) return /* @__PURE__ */ jsxs(Tool, {
23
- part,
24
- children: [/* @__PURE__ */ jsx(ToolHeader, {}), /* @__PURE__ */ jsxs(ToolContent, { children: [/* @__PURE__ */ jsx(ToolInput, {}), /* @__PURE__ */ jsx(ToolOutput, {})] })]
25
- });
79
+ if (isToolOrDynamicToolUIPart(part)) return renderToolActivity(part);
26
80
  return null;
27
81
  }
28
82
  /**
@@ -34,13 +88,49 @@ function renderDefaultPart(part) {
34
88
  * transport. Use it directly with plain AI SDK `useChat` or a read-only
35
89
  * transcript; if you have a Cloudflare Think agent, use `ThinkChat` instead.
36
90
  */
37
- function AgentChat({ className, messages, status = "ready", onSubmit, onStop, placeholder = "Ask anything...", disabled, emptyState, composerTools, onApprovalResponse, renderPart, renderMessageAfter, ref }) {
91
+ function AgentChat({ className, messages, status = "ready", onSubmit, onStop, placeholder = "Ask anything...", disabled, emptyState, composerTools, notice, onRegenerate, onApprovalResponse, executionApprovals, contextWindow, renderPart, renderMessageAfter, ref }) {
38
92
  const handleSubmit = React.useCallback((message) => {
39
93
  onSubmit?.(message);
40
94
  }, [onSubmit]);
41
95
  const [skippedApprovalIds, setSkippedApprovalIds] = React.useState([]);
42
- const pendingApprovals = (onApprovalResponse ? getPendingToolApprovals(messages) : []).filter(({ part }) => part.state !== "approval-requested" || !skippedApprovalIds.includes(part.approval.id));
43
- const pendingApproval = pendingApprovals[0];
96
+ const pendingApprovals = getPendingToolApprovals(messages, { pausedExecutions: Boolean(executionApprovals) }).filter(({ part }) => {
97
+ if (part.state === "approval-requested" && !onApprovalResponse) return false;
98
+ const id = getApprovalRequestId(part);
99
+ return Boolean(id) && !skippedApprovalIds.includes(id);
100
+ });
101
+ const approvalsWired = Boolean(onApprovalResponse || executionApprovals);
102
+ const [permissionMode, setPermissionMode] = React.useState("ask");
103
+ const autoApprovedIds = React.useRef(/* @__PURE__ */ new Set());
104
+ React.useEffect(() => {
105
+ if (permissionMode !== "bypass") return;
106
+ for (const { part } of pendingApprovals) {
107
+ const id = getApprovalRequestId(part);
108
+ if (!id || autoApprovedIds.current.has(id)) continue;
109
+ autoApprovedIds.current.add(id);
110
+ if (part.state === "approval-requested") onApprovalResponse?.({
111
+ id,
112
+ approved: true
113
+ });
114
+ else executionApprovals?.approve(id);
115
+ }
116
+ }, [
117
+ permissionMode,
118
+ messages,
119
+ onApprovalResponse,
120
+ executionApprovals
121
+ ]);
122
+ const pendingApproval = permissionMode === "bypass" ? void 0 : pendingApprovals[0];
123
+ const contextUsage = contextWindow ? getContextUsage(messages) : void 0;
124
+ const lastAssistantIndex = onRegenerate && status !== "streaming" && status !== "submitted" ? messages.findLastIndex((message) => message.role === "assistant") : -1;
125
+ const composerRef = (el) => {
126
+ if (!el || typeof ResizeObserver === "undefined") return;
127
+ const root = el.parentElement;
128
+ const observer = new ResizeObserver(() => {
129
+ root?.style.setProperty("--agent-chat-composer-size", `${el.offsetHeight}px`);
130
+ });
131
+ observer.observe(el);
132
+ return () => observer.disconnect();
133
+ };
44
134
  return /* @__PURE__ */ jsxs("div", {
45
135
  ref,
46
136
  className: cx("agent-chat", className),
@@ -51,42 +141,80 @@ function AgentChat({ className, messages, status = "ready", onSubmit, onStop, pl
51
141
  description: "Ask the agent to inspect, plan, or build."
52
142
  }) : null, messages.map((message, messageIndex) => /* @__PURE__ */ jsxs(Message, {
53
143
  from: message.role,
54
- children: [message.parts.map((part, partIndex) => {
55
- const defaultRender = () => renderDefaultPart(part);
56
- const custom = renderPart?.({
144
+ children: [
145
+ message.parts.map((part, partIndex) => {
146
+ const defaultRender = () => renderDefaultPart(part);
147
+ const custom = renderPart?.({
148
+ message,
149
+ part,
150
+ partIndex,
151
+ defaultRender
152
+ });
153
+ const rendered = custom === void 0 ? defaultRender() : custom;
154
+ return rendered ? /* @__PURE__ */ jsxs(MessageContent, { children: [rendered, isCompactedPart(message, part, partIndex) ? /* @__PURE__ */ jsx("div", {
155
+ className: "message__compacted",
156
+ children: "Output truncated for storage"
157
+ }) : null] }, getPartKey(part, partIndex)) : null;
158
+ }),
159
+ renderMessageAfter?.({
57
160
  message,
58
- part,
59
- partIndex,
60
- defaultRender
61
- });
62
- const rendered = custom === void 0 ? defaultRender() : custom;
63
- return rendered ? /* @__PURE__ */ jsx(MessageContent, { children: rendered }, getPartKey(part, partIndex)) : null;
64
- }), renderMessageAfter?.({
65
- message,
66
- messageIndex
67
- })]
161
+ messageIndex
162
+ }),
163
+ onRegenerate && messageIndex === lastAssistantIndex ? /* @__PURE__ */ jsx(MessageActions, { children: /* @__PURE__ */ jsx(MessageAction, {
164
+ label: "Retry",
165
+ tooltip: "Regenerate response",
166
+ onClick: () => onRegenerate(message.id),
167
+ children: /* @__PURE__ */ jsx(RefreshIcon, { size: 14 })
168
+ }) }) : null
169
+ ]
68
170
  }, message.id ?? messageIndex))] }), /* @__PURE__ */ jsx(ConversationScrollButton, {})]
69
- }), /* @__PURE__ */ jsx("div", {
171
+ }), /* @__PURE__ */ jsxs("div", {
172
+ ref: composerRef,
70
173
  className: "agent-chat__composer",
71
- children: /* @__PURE__ */ jsx(PromptInput, {
174
+ children: [notice ? /* @__PURE__ */ jsx("div", {
175
+ className: "agent-chat__notice",
176
+ children: notice
177
+ }) : null, /* @__PURE__ */ jsx(PromptInput, {
178
+ multiple: true,
72
179
  onSubmit: handleSubmit,
73
- children: pendingApproval && onApprovalResponse ? /* @__PURE__ */ jsx(PromptInputApproval, {
180
+ children: pendingApproval ? /* @__PURE__ */ jsx(PromptInputApproval, {
74
181
  part: pendingApproval.part,
75
182
  count: pendingApprovals.length,
76
183
  onRespond: onApprovalResponse,
184
+ executionApprovals,
77
185
  onSkip: () => {
78
- const { part } = pendingApproval;
79
- if (part.state === "approval-requested") setSkippedApprovalIds((previous) => [...previous, part.approval.id]);
186
+ const id = getApprovalRequestId(pendingApproval.part);
187
+ if (id) setSkippedApprovalIds((previous) => [...previous, id]);
80
188
  }
81
- }) : /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(PromptInputBody, { children: /* @__PURE__ */ jsx(PromptInputTextarea, {
82
- "aria-label": "Message",
83
- placeholder,
84
- disabled
85
- }) }), /* @__PURE__ */ jsxs(PromptInputFooter, { children: [/* @__PURE__ */ jsx(PromptInputTools, { children: composerTools }), /* @__PURE__ */ jsx(PromptInputSubmit, {
86
- status,
87
- onStop
88
- })] })] })
89
- })
189
+ }) : /* @__PURE__ */ jsxs(Fragment, { children: [
190
+ /* @__PURE__ */ jsx(PromptInputAttachments, {}),
191
+ /* @__PURE__ */ jsx(PromptInputBody, { children: /* @__PURE__ */ jsx(PromptInputTextarea, {
192
+ "aria-label": "Message",
193
+ placeholder,
194
+ disabled
195
+ }) }),
196
+ /* @__PURE__ */ jsxs(PromptInputFooter, { children: [/* @__PURE__ */ jsxs(PromptInputTools, { children: [
197
+ /* @__PURE__ */ jsx(AgentChatAttachButton, {}),
198
+ approvalsWired ? /* @__PURE__ */ jsx(PromptInputPermissionSelector, {
199
+ value: permissionMode,
200
+ onValueChange: setPermissionMode
201
+ }) : null,
202
+ composerTools
203
+ ] }), /* @__PURE__ */ jsxs("div", {
204
+ className: "prompt-input__footer-end",
205
+ children: [contextWindow ? /* @__PURE__ */ jsxs(Context, {
206
+ usedTokens: getContextUsedTokens(contextUsage),
207
+ maxTokens: contextWindow.maxTokens,
208
+ usage: contextUsage,
209
+ modelId: contextWindow.modelId,
210
+ children: [/* @__PURE__ */ jsx(ContextTrigger, {}), /* @__PURE__ */ jsxs(ContextContent, { children: [/* @__PURE__ */ jsx(ContextContentHeader, {}), /* @__PURE__ */ jsx(ContextContentBody, {})] })]
211
+ }) : null, /* @__PURE__ */ jsx(PromptInputSubmit, {
212
+ status,
213
+ onStop
214
+ })]
215
+ })] })
216
+ ] })
217
+ })]
90
218
  })]
91
219
  });
92
220
  }
@@ -1,8 +1,8 @@
1
1
  import { t as cx } from "../class-names-9UtZwb0J.js";
2
- import { b as LinkIcon } from "../icons-DQC4Zw5R.js";
3
- import { Button } from "./Button.js";
4
- import { a as CodeBlockCopyButton, i as CodeBlockContent, n as CodeBlockActions, p as CodeBlockTitle, r as CodeBlockContainer, s as CodeBlockHeader, t as CodeBlock } from "../CodeBlock-C2Xjxu9M.js";
2
+ import { y as LinkIcon } from "../icons-CZRH4FVH.js";
5
3
  import { Popover } from "./Popover.js";
4
+ import { Button } from "./Button.js";
5
+ import { a as CodeBlockCopyButton, i as CodeBlockContent, n as CodeBlockActions, p as CodeBlockTitle, r as CodeBlockContainer, s as CodeBlockHeader, t as CodeBlock } from "../CodeBlock-D-a84xBL.js";
6
6
  import * as React from "react";
7
7
  import { jsx, jsxs } from "react/jsx-runtime";
8
8
  //#region src/components/AgentConnection.tsx
@@ -1,5 +1,5 @@
1
1
  import { t as cx } from "../class-names-9UtZwb0J.js";
2
- import { F as XIcon } from "../icons-DQC4Zw5R.js";
2
+ import { P as XIcon } from "../icons-CZRH4FVH.js";
3
3
  import { Button } from "./Button.js";
4
4
  import { Tooltip, TooltipPopup, TooltipPortal, TooltipPositioner, TooltipTrigger } from "./Tooltip.js";
5
5
  import "react";
@@ -1,8 +1,8 @@
1
1
  import { t as cx } from "../class-names-9UtZwb0J.js";
2
- import { A as SpinnerIcon, x as MaximizeIcon } from "../icons-DQC4Zw5R.js";
2
+ import { b as MaximizeIcon, k as SpinnerIcon } from "../icons-CZRH4FVH.js";
3
3
  import { Button } from "./Button.js";
4
- import { Badge } from "./Badge.js";
5
4
  import { Dialog, DialogContent, DialogTitle } from "./Dialog.js";
5
+ import { Badge } from "./Badge.js";
6
6
  import * as React from "react";
7
7
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
8
8
  //#region src/components/BrowserLiveView.tsx
@@ -1,5 +1,5 @@
1
1
  import { t as cx } from "../class-names-9UtZwb0J.js";
2
- import { E as PlayIcon, w as PauseIcon } from "../icons-DQC4Zw5R.js";
2
+ import { C as PauseIcon, T as PlayIcon } from "../icons-CZRH4FVH.js";
3
3
  import { Button } from "./Button.js";
4
4
  import { Slider, SliderControl, SliderIndicator, SliderThumb, SliderTrack } from "./Slider.js";
5
5
  import * as React from "react";
@@ -1,5 +1,5 @@
1
1
  import { CollapsiblePanelProps, CollapsibleRootProps, CollapsibleTriggerProps } from "./Collapsible.js";
2
- import { v as IconProps } from "../icons-ctdVxng0.js";
2
+ import { _ as IconProps } from "../icons-CmO7-pNY.js";
3
3
  import * as React from "react";
4
4
 
5
5
  //#region src/components/ChainOfThought.d.ts
@@ -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 SpinnerIcon, d as DotIcon, l as ChevronRightIcon, o as CheckIcon } from "../icons-DQC4Zw5R.js";
3
+ import { a as CheckIcon, c as ChevronRightIcon, k as SpinnerIcon, u as DotIcon } from "../icons-CZRH4FVH.js";
4
4
  import "react";
5
5
  import { jsx, jsxs } from "react/jsx-runtime";
6
6
  //#region src/components/ChainOfThought.tsx
@@ -1,2 +1,2 @@
1
- import { a as CodeBlockCopyButton, c as CodeBlockLanguageSelector, d as CodeBlockLanguageSelectorTrigger, f as CodeBlockLanguageSelectorValue, h as CODE_BLOCK_LANGUAGES, i as CodeBlockContent, l as CodeBlockLanguageSelectorContent, m as highlightCode, n as CodeBlockActions, o as CodeBlockFilename, p as CodeBlockTitle, r as CodeBlockContainer, s as CodeBlockHeader, t as CodeBlock, u as CodeBlockLanguageSelectorItem } from "../CodeBlock-C2Xjxu9M.js";
1
+ import { a as CodeBlockCopyButton, c as CodeBlockLanguageSelector, d as CodeBlockLanguageSelectorTrigger, f as CodeBlockLanguageSelectorValue, h as CODE_BLOCK_LANGUAGES, i as CodeBlockContent, l as CodeBlockLanguageSelectorContent, m as highlightCode, n as CodeBlockActions, o as CodeBlockFilename, p as CodeBlockTitle, r as CodeBlockContainer, s as CodeBlockHeader, t as CodeBlock, u as CodeBlockLanguageSelectorItem } from "../CodeBlock-D-a84xBL.js";
2
2
  export { CODE_BLOCK_LANGUAGES, CodeBlock, CodeBlockActions, CodeBlockContainer, CodeBlockContent, CodeBlockCopyButton, CodeBlockFilename, CodeBlockHeader, CodeBlockLanguageSelector, CodeBlockLanguageSelectorContent, CodeBlockLanguageSelectorItem, CodeBlockLanguageSelectorTrigger, CodeBlockLanguageSelectorValue, CodeBlockTitle, highlightCode };
@@ -1,10 +1,10 @@
1
1
  import { CollapsiblePanel, CollapsibleRoot, CollapsibleTrigger } from "./Collapsible.js";
2
2
  import { t as cx } from "../class-names-9UtZwb0J.js";
3
- import { h as FileIcon, l as ChevronRightIcon, o as CheckIcon, u as CopyIcon } from "../icons-DQC4Zw5R.js";
3
+ import { a as CheckIcon, c as ChevronRightIcon, l as CopyIcon, m as FileIcon } from "../icons-CZRH4FVH.js";
4
4
  import { Button } from "./Button.js";
5
5
  import { Tooltip, TooltipPopup, TooltipPortal, TooltipPositioner, TooltipTrigger } from "./Tooltip.js";
6
- import { Badge } from "./Badge.js";
7
6
  import { Avatar } from "./Avatar.js";
7
+ import { Badge } from "./Badge.js";
8
8
  import * as React from "react";
9
9
  import { jsx, jsxs } from "react/jsx-runtime";
10
10
  //#region src/components/Commit.tsx
@@ -1,31 +1,21 @@
1
- import { r as ButtonProps } from "../Button-Ct5I6aTu.js";
2
- import { PopoverProps } from "./Popover.js";
1
+ import { PopoverPositionerProps, PopoverProps } from "./Popover.js";
3
2
  import * as React from "react";
3
+ import { LanguageModelUsage, UIMessage } from "ai";
4
4
 
5
5
  //#region src/components/Context.d.ts
6
- interface ContextUsageCategory {
7
- label: string;
8
- tokens: number;
9
- costUsd?: number;
10
- }
11
- interface ContextUsage {
12
- input?: number;
13
- inputTokens?: number;
14
- output?: number;
15
- outputTokens?: number;
16
- reasoning?: number;
17
- reasoningTokens?: number;
18
- cache?: number;
19
- cachedInputTokens?: number;
20
- categories?: ContextUsageCategory[];
21
- }
6
+ /**
7
+ * The AI SDK's `LanguageModelUsage`, taken whole. `Partial` only relaxes the
8
+ * required-but-`undefined`able keys for fixtures/JSX literals — key names and
9
+ * meanings are upstream's.
10
+ */
11
+ type ContextTokenUsage = Partial<LanguageModelUsage>;
22
12
  interface ContextProps extends React.HTMLAttributes<HTMLDivElement> {
23
13
  /** Tokens currently used. */
24
14
  usedTokens: number;
25
15
  /** Maximum context window size. */
26
16
  maxTokens: number;
27
17
  /** Optional usage breakdown. */
28
- usage?: ContextUsage;
18
+ usage?: ContextTokenUsage;
29
19
  /** Optional model identifier shown in the header. */
30
20
  modelId?: string;
31
21
  /** Optional total cost in USD. */
@@ -36,8 +26,8 @@ interface ContextProps extends React.HTMLAttributes<HTMLDivElement> {
36
26
  }
37
27
  /**
38
28
  * Displays token / context usage with a hover card breakdown. The trigger is
39
- * a button showing a compact percentage indicator; hovering or clicking opens
40
- * a popover with category rows and total cost.
29
+ * a bare progress ring; clicking it opens a popover (upward by default) with
30
+ * category rows and total cost.
41
31
  *
42
32
  * @example
43
33
  * ```tsx
@@ -45,7 +35,7 @@ interface ContextProps extends React.HTMLAttributes<HTMLDivElement> {
45
35
  * usedTokens={42_300}
46
36
  * maxTokens={200_000}
47
37
  * modelId="claude-opus-4-6"
48
- * usage={{ input: 30000, output: 12300 }}
38
+ * usage={{ inputTokens: 30000, outputTokens: 12300 }}
49
39
  * totalCostUsd={0.42}
50
40
  * >
51
41
  * <ContextTrigger />
@@ -73,17 +63,19 @@ declare function Context({
73
63
  }: ContextProps & {
74
64
  ref?: React.Ref<HTMLDivElement>;
75
65
  }): React.JSX.Element;
76
- interface ContextTriggerProps extends Omit<ButtonProps, "variant" | "color" | "className"> {
77
- className?: string;
78
- }
66
+ interface ContextTriggerProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {}
79
67
  declare function ContextTrigger({
80
68
  className,
81
69
  children,
82
70
  ...props
83
71
  }: ContextTriggerProps): React.JSX.Element;
84
- interface ContextContentProps extends React.HTMLAttributes<HTMLDivElement> {}
72
+ interface ContextContentProps extends React.HTMLAttributes<HTMLDivElement> {
73
+ /** The trigger usually sits in a composer at the bottom, so default "top". */
74
+ side?: PopoverPositionerProps["side"];
75
+ }
85
76
  declare function ContextContent({
86
77
  className,
78
+ side,
87
79
  children,
88
80
  ...props
89
81
  }: ContextContentProps): React.JSX.Element;
@@ -125,5 +117,14 @@ declare function ContextInputUsage(props: ContextInputUsageProps): React.JSX.Ele
125
117
  declare function ContextOutputUsage(props: ContextOutputUsageProps): React.JSX.Element;
126
118
  declare function ContextReasoningUsage(props: ContextReasoningUsageProps): React.JSX.Element;
127
119
  declare function ContextCacheUsage(props: ContextCacheUsageProps): React.JSX.Element;
120
+ /**
121
+ * Latest `metadata.usage` in a transcript — the AI SDK convention for token
122
+ * accounting (`toUIMessageStreamResponse({ messageMetadata })`), which Think
123
+ * merges into `message.metadata` as turns finish. Structural: any message
124
+ * whose metadata carries a `usage` object qualifies.
125
+ */
126
+ declare function getContextUsage(messages: readonly UIMessage[]): LanguageModelUsage | undefined;
127
+ /** Tokens occupying the context window: `totalTokens`, or input + output. */
128
+ declare function getContextUsedTokens(usage: LanguageModelUsage | undefined): number;
128
129
  //#endregion
129
- export { Context, ContextCacheUsage, ContextCacheUsageProps, ContextContent, ContextContentBody, ContextContentBodyProps, ContextContentFooter, ContextContentFooterProps, ContextContentHeader, ContextContentHeaderProps, ContextContentProps, ContextInputUsage, ContextInputUsageProps, ContextOutputUsage, ContextOutputUsageProps, ContextProps, ContextReasoningUsage, ContextReasoningUsageProps, ContextTrigger, ContextTriggerProps, ContextUsage, ContextUsageCategory, ContextUsageRowProps };
130
+ export { Context, ContextCacheUsage, ContextCacheUsageProps, ContextContent, ContextContentBody, ContextContentBodyProps, ContextContentFooter, ContextContentFooterProps, ContextContentHeader, ContextContentHeaderProps, ContextContentProps, ContextInputUsage, ContextInputUsageProps, ContextOutputUsage, ContextOutputUsageProps, ContextProps, ContextReasoningUsage, ContextReasoningUsageProps, ContextTokenUsage, ContextTrigger, ContextTriggerProps, ContextUsageRowProps, getContextUsage, getContextUsedTokens };