@mcp-b/react-components 0.54.0 → 0.56.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 (24) hide show
  1. package/dist/{AgentToolRunsContext-GMe_hSnD.d.ts → AgentToolRunsContext-DT50htHj.d.ts} +4 -17
  2. package/dist/{EmployeeChrome-B605rpVz.d.ts → EmployeeChrome-B7Gt2Hpk.d.ts} +1 -1
  3. package/dist/{ThinkChatActivity-DENkintt.d.ts → ThinkChatActivity-B6dh3n0-.d.ts} +1 -1
  4. package/dist/components/agents-sdk/AgentChat.js +3 -3
  5. package/dist/components/agents-sdk/AgentToolRunsContext.d.ts +1 -1
  6. package/dist/components/agents-sdk/EmployeeApp.d.ts +1 -1
  7. package/dist/components/agents-sdk/EmployeeChrome.d.ts +1 -1
  8. package/dist/components/agents-sdk/EmployeeSchedules.d.ts +1 -1
  9. package/dist/components/agents-sdk/EmployeeStartScreen.d.ts +1 -1
  10. package/dist/components/agents-sdk/ManagerOfficeScreens.d.ts +1 -1
  11. package/dist/components/agents-sdk/SubagentRunDetails.d.ts +1 -1
  12. package/dist/components/agents-sdk/SubagentRunIndicator.d.ts +1 -1
  13. package/dist/components/agents-sdk/SubagentRunList.d.ts +1 -1
  14. package/dist/components/agents-sdk/SubagentRunPanel.d.ts +3 -14
  15. package/dist/components/agents-sdk/SubagentRunPanel.js +11 -14
  16. package/dist/components/agents-sdk/SubagentRunSelector.d.ts +1 -1
  17. package/dist/components/agents-sdk/ThinkChat.d.ts +2 -9
  18. package/dist/components/agents-sdk/ThinkChat.js +3 -36
  19. package/dist/components/agents-sdk/ThinkChatActivity.d.ts +1 -1
  20. package/dist/components/nanites/AgentToolDetail.d.ts +1 -1
  21. package/package.json +9 -14
  22. package/dist/SessionCompaction-CmTJFpzj.d.ts +0 -89
  23. package/dist/components/agents-sdk/SessionCompaction.d.ts +0 -2
  24. package/dist/components/agents-sdk/SessionCompaction.js +0 -140
@@ -1,25 +1,12 @@
1
1
  import * as React from "react";
2
2
  import { UIMessage } from "ai";
3
3
  import { useAgentToolEvents } from "agents/react";
4
- import { AgentToolRunPart, AgentToolRunState, AgentToolRunStatus } from "agents/agent-tools";
4
+ import { AgentToolRunPart, AgentToolRunState } from "agents/agent-tools";
5
5
 
6
6
  //#region src/components/agents-sdk/AgentToolRunsContext.d.ts
7
- /**
8
- * Whole native run fields with the SDK's complete lifecycle status. Published
9
- * Agents 0.21.0 excludes `starting` from AgentToolRunState while its native
10
- * AgentToolRunStatus includes it and current retained replay emits it. This
11
- * type-only correction does not translate records or accept another shape.
12
- */
13
- type AgentToolRunValue<Part extends AgentToolRunPart = AgentToolRunPart> = Omit<AgentToolRunState<Part>, "status"> & {
14
- status: AgentToolRunStatus;
15
- };
16
- /** Whole event-hook value; run records keep the complete native lifecycle. */
17
- type AgentToolEventsValue<Part extends AgentToolRunPart = UIMessage["parts"][number]> = Omit<ReturnType<typeof useAgentToolEvents<Part>>, "runsById" | "runsByToolCallId" | "unboundRuns" | "getRunsForToolCall"> & {
18
- runsById: Record<string, AgentToolRunValue<Part>>;
19
- runsByToolCallId: Record<string, AgentToolRunValue<Part>[]>;
20
- unboundRuns: AgentToolRunValue<Part>[];
21
- getRunsForToolCall(toolCallId: string): AgentToolRunValue<Part>[];
22
- };
7
+ /** Native SDK run and event-hook values, passed without translation. */
8
+ type AgentToolRunValue<Part extends AgentToolRunPart = AgentToolRunPart> = AgentToolRunState<Part>;
9
+ type AgentToolEventsValue<Part extends AgentToolRunPart = UIMessage["parts"][number]> = ReturnType<typeof useAgentToolEvents<Part>>;
23
10
  interface AgentToolRunsProviderProps<Part extends AgentToolRunPart = UIMessage["parts"][number]> {
24
11
  /** Pass the whole `useAgentToolEvents({ agent })` result directly. */
25
12
  agentTools: AgentToolEventsValue<Part>;
@@ -1,5 +1,5 @@
1
1
  import { J as PromptInputMessage } from "./PromptInput-DGPrCTPl.js";
2
- import { n as AgentToolRunValue } from "./AgentToolRunsContext-GMe_hSnD.js";
2
+ import { n as AgentToolRunValue } from "./AgentToolRunsContext-DT50htHj.js";
3
3
  import { n as ResponsiveSidebarShell } from "./ResponsiveSidebarShell-BUBQa_IV.js";
4
4
  import { t as ThinkThreadItem } from "./ThinkThreadPicker-DX0lL-P7.js";
5
5
  import * as React from "react";
@@ -1,6 +1,6 @@
1
1
  import { i as AgentMessageRenderPartContext } from "./AgentMessageParts-C7L-Mv9U.js";
2
2
  import { AgentChatMessageContentProps } from "./components/agents-sdk/AgentChat.js";
3
- import { n as AgentToolRunValue } from "./AgentToolRunsContext-GMe_hSnD.js";
3
+ import { n as AgentToolRunValue } from "./AgentToolRunsContext-DT50htHj.js";
4
4
  import { l as ThinkChatPart } from "./ThinkChatToolParts-D4qcnnxt.js";
5
5
  import { t as ThinkChatActivityDescription } from "./ThinkChatActivitySummary-BtBQgMg6.js";
6
6
  import * as React from "react";
@@ -17,7 +17,7 @@ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
17
17
  import { useRender } from "@base-ui/react/use-render";
18
18
  import { mergeProps } from "@base-ui/react/merge-props";
19
19
  import { isTextUIPart } from "ai";
20
- import { isCompactionMessage } from "agents/experimental/memory/utils";
20
+ import { isCompactionMessage } from "agents/sessions";
21
21
  //#region src/components/agents-sdk/AgentChat.tsx
22
22
  function observeAgentChatDock(element) {
23
23
  if (!element || typeof ResizeObserver === "undefined") return;
@@ -472,7 +472,7 @@ function AgentChatApprovals({ thinkStub, pendingApprovals = [], onExecutionSettl
472
472
  ids: []
473
473
  });
474
474
  const ids = skipped.source === thinkStub ? skipped.ids : EMPTY_SKIPPED_IDS;
475
- const items = [...getPendingToolApprovals(messages, { pausedExecutions: Boolean(thinkStub) }).filter((part) => (part.state !== "approval-requested" || onApprovalResponse) && !ids.includes(getApprovalStateKey(part) ?? "")).map((part) => ({ part })), ...pendingApprovals.filter((a) => a.source === "action" && !ids.includes(a.executionId)).map((approval) => ({ approval }))];
475
+ const items = [...getPendingToolApprovals(messages, { pausedExecutions: Boolean(thinkStub) }).filter((part) => (part.state !== "approval-requested" || onApprovalResponse) && !ids.includes(getApprovalStateKey(part) ?? "")).map((part) => ({ part })), ...pendingApprovals.filter((a) => !ids.includes(a.executionId)).map((approval) => ({ approval }))];
476
476
  const pending = items.length ? items : EMPTY_APPROVAL_ITEMS;
477
477
  const restore = React.useRef(false);
478
478
  const active = React.useRef(false);
@@ -553,7 +553,7 @@ const compactingNotice = /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE_
553
553
  const COMPACTION_NOTICES = {
554
554
  pending: compactingNotice,
555
555
  compacted: "Context compacted. Context usage updates after your next message.",
556
- unchanged: "No context was compacted. Recent context is already protected.",
556
+ unchanged: "No summary was created. Run /compact to try again.",
557
557
  failed: "Compaction failed — run /compact to try again."
558
558
  };
559
559
  const COMPACTION_COMMAND = {
@@ -1,2 +1,2 @@
1
- import { a as useOptionalAgentToolRuns, i as AgentToolRunsProviderProps, n as AgentToolRunValue, r as AgentToolRunsProvider, t as AgentToolEventsValue } from "../../AgentToolRunsContext-GMe_hSnD.js";
1
+ import { a as useOptionalAgentToolRuns, i as AgentToolRunsProviderProps, n as AgentToolRunValue, r as AgentToolRunsProvider, t as AgentToolEventsValue } from "../../AgentToolRunsContext-DT50htHj.js";
2
2
  export { AgentToolEventsValue, AgentToolRunValue, AgentToolRunsProvider, AgentToolRunsProviderProps, useOptionalAgentToolRuns };
@@ -1,5 +1,5 @@
1
1
  import { l as WorkspaceNavigationAdapter } from "../../WorkspaceLink-Bh9-Jo1r.js";
2
- import { f as EmployeeShellProps, l as EmployeeModelSetup, n as EmployeeBrand, p as EmployeeStatus, t as EmployeeAgentRun } from "../../EmployeeChrome-B605rpVz.js";
2
+ import { f as EmployeeShellProps, l as EmployeeModelSetup, n as EmployeeBrand, p as EmployeeStatus, t as EmployeeAgentRun } from "../../EmployeeChrome-B7Gt2Hpk.js";
3
3
  import * as React from "react";
4
4
 
5
5
  //#region src/components/agents-sdk/EmployeeApp.d.ts
@@ -1,2 +1,2 @@
1
- import { a as EmployeeDestination, c as EmployeeMenuProps, d as EmployeeRenderLink, f as EmployeeShellProps, h as EmployeeWorkbenchItem, i as EmployeeCompanion, l as EmployeeModelSetup, m as EmployeeView, n as EmployeeBrand, o as EmployeeFollow, p as EmployeeStatus, r as EmployeeChrome, s as EmployeeIdentity, t as EmployeeAgentRun, u as EmployeePasskeyVault } from "../../EmployeeChrome-B605rpVz.js";
1
+ import { a as EmployeeDestination, c as EmployeeMenuProps, d as EmployeeRenderLink, f as EmployeeShellProps, h as EmployeeWorkbenchItem, i as EmployeeCompanion, l as EmployeeModelSetup, m as EmployeeView, n as EmployeeBrand, o as EmployeeFollow, p as EmployeeStatus, r as EmployeeChrome, s as EmployeeIdentity, t as EmployeeAgentRun, u as EmployeePasskeyVault } from "../../EmployeeChrome-B7Gt2Hpk.js";
2
2
  export { EmployeeAgentRun, EmployeeBrand, EmployeeChrome, EmployeeCompanion, EmployeeDestination, EmployeeFollow, EmployeeIdentity, EmployeeMenuProps, EmployeeModelSetup, EmployeePasskeyVault, EmployeeRenderLink, EmployeeShellProps, EmployeeStatus, EmployeeView, EmployeeWorkbenchItem };
@@ -1,4 +1,4 @@
1
- import { c as EmployeeMenuProps } from "../../EmployeeChrome-B605rpVz.js";
1
+ import { c as EmployeeMenuProps } from "../../EmployeeChrome-B7Gt2Hpk.js";
2
2
  import { t as ThinkRoutine } from "../../ThinkRoutine-Cb1DdaHa.js";
3
3
  import { ThinkRoutineActionsRootProps } from "./ThinkRoutineActions.js";
4
4
  import * as React from "react";
@@ -1,5 +1,5 @@
1
1
  import { J as PromptInputMessage } from "../../PromptInput-DGPrCTPl.js";
2
- import { a as EmployeeDestination, n as EmployeeBrand } from "../../EmployeeChrome-B605rpVz.js";
2
+ import { a as EmployeeDestination, n as EmployeeBrand } from "../../EmployeeChrome-B7Gt2Hpk.js";
3
3
  import { SetupChecklistGroupProps } from "../general-purpose/SetupChecklist.js";
4
4
  import { n as McpPluginCatalogProps } from "../../McpPluginCatalog-DNeHDrts.js";
5
5
  import { r as WorkspaceMountManagerProps } from "../../WorkspaceMountManager-CkLI1B-G.js";
@@ -1,4 +1,4 @@
1
- import { f as EmployeeShellProps } from "../../EmployeeChrome-B605rpVz.js";
1
+ import { f as EmployeeShellProps } from "../../EmployeeChrome-B7Gt2Hpk.js";
2
2
  import { ManagerOfficeConnectedEmployee, ManagerOfficeDestination, ManagerOfficeEmployee } from "./ManagerOffice.js";
3
3
  import * as React from "react";
4
4
 
@@ -1,4 +1,4 @@
1
- import { n as AgentToolRunValue } from "../../AgentToolRunsContext-GMe_hSnD.js";
1
+ import { n as AgentToolRunValue } from "../../AgentToolRunsContext-DT50htHj.js";
2
2
  import * as React from "react";
3
3
 
4
4
  //#region src/components/agents-sdk/SubagentRunDetails.d.ts
@@ -1,4 +1,4 @@
1
- import { n as AgentToolRunValue } from "../../AgentToolRunsContext-GMe_hSnD.js";
1
+ import { n as AgentToolRunValue } from "../../AgentToolRunsContext-DT50htHj.js";
2
2
  import * as React from "react";
3
3
  import { AgentToolRunPart } from "agents/agent-tools";
4
4
 
@@ -1,4 +1,4 @@
1
- import { n as AgentToolRunValue } from "../../AgentToolRunsContext-GMe_hSnD.js";
1
+ import { n as AgentToolRunValue } from "../../AgentToolRunsContext-DT50htHj.js";
2
2
  import * as React from "react";
3
3
  import { UIMessage } from "ai";
4
4
  import { AgentToolRunPart } from "agents/agent-tools";
@@ -1,4 +1,4 @@
1
- import { n as AgentToolRunValue, t as AgentToolEventsValue } from "../../AgentToolRunsContext-GMe_hSnD.js";
1
+ import { n as AgentToolRunValue, t as AgentToolEventsValue } from "../../AgentToolRunsContext-DT50htHj.js";
2
2
  import { ExpansionStore } from "../ai-sdk/ExpansionState.js";
3
3
  import * as React from "react";
4
4
  import { AgentToolRunPart } from "agents/agent-tools";
@@ -8,27 +8,18 @@ interface CommandState {
8
8
  pending: boolean;
9
9
  error?: string;
10
10
  }
11
- /** Controlled collection facts supplied by the connection owner. */
12
- interface SubagentRunCollectionState {
13
- status: "loading" | "ready" | "error";
14
- stale: boolean;
15
- error?: string;
16
- }
17
11
  interface SubagentRunPanelProviderProps {
18
12
  /** Conversation identity; changing it resets transient controls without remounting children. */
19
13
  scopeKey: string;
20
14
  /** The one upstream event-hook value from the parent connection. */
21
15
  agentTools: AgentToolEventsValue<AgentToolRunPart>;
22
- collection: SubagentRunCollectionState;
23
- /** The host's native execution predicate; presentation does not own cancellation policy. */
24
- mayExecute: (run: AgentToolRunValue) => boolean;
25
16
  selectedRunId?: string;
26
17
  parentRunning: boolean;
27
18
  onStopCurrentWork: () => Promise<void>;
28
19
  onStopRun: (runId: string) => Promise<void>;
29
20
  children: React.ReactNode;
30
21
  }
31
- interface SubagentRunPanelValue extends Pick<SubagentRunPanelProviderProps, "agentTools" | "collection" | "mayExecute" | "selectedRunId" | "parentRunning"> {
22
+ interface SubagentRunPanelValue extends Pick<SubagentRunPanelProviderProps, "agentTools" | "selectedRunId" | "parentRunning"> {
32
23
  open: boolean;
33
24
  setOpen: (open: boolean) => void;
34
25
  hiddenCompleted: ReadonlySet<string>;
@@ -43,8 +34,6 @@ interface SubagentRunPanelValue extends Pick<SubagentRunPanelProviderProps, "age
43
34
  declare function SubagentRunPanelProvider({
44
35
  scopeKey,
45
36
  agentTools,
46
- collection,
47
- mayExecute,
48
37
  selectedRunId,
49
38
  parentRunning,
50
39
  onStopCurrentWork,
@@ -60,4 +49,4 @@ declare function SubagentRunPanel({
60
49
  renderRunLink
61
50
  }: SubagentRunPanelProps): React.JSX.Element | null;
62
51
  //#endregion
63
- export { SubagentRunCollectionState, SubagentRunPanel, SubagentRunPanelProps, SubagentRunPanelProvider, SubagentRunPanelProviderProps, useOptionalSubagentRunPanel };
52
+ export { SubagentRunPanel, SubagentRunPanelProps, SubagentRunPanelProvider, SubagentRunPanelProviderProps, useOptionalSubagentRunPanel };
@@ -7,6 +7,7 @@ import { AgentChatNotice, AgentChatPromptTray } from "./AgentChat.js";
7
7
  import { SubagentRunSelector } from "./SubagentRunSelector.js";
8
8
  import * as React from "react";
9
9
  import { jsx, jsxs } from "react/jsx-runtime";
10
+ import { agentToolRunMayExecute } from "agents/react";
10
11
  //#region src/components/agents-sdk/SubagentRunPanel.tsx
11
12
  const IDLE = { pending: false };
12
13
  const SubagentRunPanelContext = React.createContext(null);
@@ -22,7 +23,7 @@ function createPanelState(scopeKey, selectedRunId) {
22
23
  };
23
24
  }
24
25
  /** A thread's transient controls/disclosure state; run facts remain in the SDK value. */
25
- function SubagentRunPanelProvider({ scopeKey, agentTools, collection, mayExecute, selectedRunId, parentRunning, onStopCurrentWork, onStopRun, children }) {
26
+ function SubagentRunPanelProvider({ scopeKey, agentTools, selectedRunId, parentRunning, onStopCurrentWork, onStopRun, children }) {
26
27
  const [state, setState] = React.useState(() => createPanelState(scopeKey, selectedRunId));
27
28
  if (state.scopeKey !== scopeKey) setState(createPanelState(scopeKey, selectedRunId));
28
29
  const { open, hiddenCompleted, commands, reportDisclosures, inFlight, restoreFocusRunId } = state;
@@ -63,8 +64,6 @@ function SubagentRunPanelProvider({ scopeKey, agentTools, collection, mayExecute
63
64
  const stopRun = React.useCallback((id) => execute(id, () => onStopRun(id)), [execute, onStopRun]);
64
65
  const value = React.useMemo(() => ({
65
66
  agentTools,
66
- collection,
67
- mayExecute,
68
67
  selectedRunId,
69
68
  parentRunning,
70
69
  open,
@@ -78,8 +77,6 @@ function SubagentRunPanelProvider({ scopeKey, agentTools, collection, mayExecute
78
77
  stopRun
79
78
  }), [
80
79
  agentTools,
81
- collection,
82
- mayExecute,
83
80
  selectedRunId,
84
81
  parentRunning,
85
82
  open,
@@ -101,12 +98,12 @@ function useOptionalSubagentRunPanel() {
101
98
  return React.useContext(SubagentRunPanelContext);
102
99
  }
103
100
  function getSubagentRunRows(panel) {
104
- const runs = Object.values(panel.agentTools.runsById).sort((a, b) => Number(!panel.mayExecute(a)) - Number(!panel.mayExecute(b)) || a.order - b.order);
101
+ const runs = Object.values(panel.agentTools.runsById).sort((a, b) => Number(!agentToolRunMayExecute(a)) - Number(!agentToolRunMayExecute(b)) || a.order - b.order);
105
102
  return {
106
103
  runs,
107
- active: runs.filter(panel.mayExecute),
108
- completed: runs.filter((run) => !panel.mayExecute(run)),
109
- visible: runs.filter((run) => !panel.hiddenCompleted.has(run.runId) || panel.mayExecute(run))
104
+ active: runs.filter(agentToolRunMayExecute),
105
+ completed: runs.filter((run) => !agentToolRunMayExecute(run)),
106
+ visible: runs.filter((run) => !panel.hiddenCompleted.has(run.runId) || agentToolRunMayExecute(run))
110
107
  };
111
108
  }
112
109
  function useSubagentRunFocus(panel, visible) {
@@ -155,7 +152,7 @@ function delegatedWorkLabel(active, completed) {
155
152
  function SubagentRunPanelControls({ panel, active }) {
156
153
  const queue = useOptionalAgentChatQueue();
157
154
  const stop = panel.commands["current-work"] ?? IDLE;
158
- const canStop = panel.parentRunning || active > 1 || panel.collection.status !== "ready";
155
+ const canStop = panel.parentRunning || active > 1 || panel.agentTools.collection.status !== "ready";
159
156
  if (!canStop && !stop.error && !stop.pending) return null;
160
157
  return /* @__PURE__ */ jsx(QueueSectionActions, {
161
158
  "aria-label": "Delegated work controls",
@@ -176,7 +173,7 @@ function SubagentRunPanelControls({ panel, active }) {
176
173
  }
177
174
  function SubagentRunRow({ panel, run, renderRunLink }) {
178
175
  const command = panel.commands[run.runId] ?? IDLE;
179
- const actionable = panel.mayExecute(run) || command.error || command.pending;
176
+ const actionable = agentToolRunMayExecute(run) || command.error || command.pending;
180
177
  return /* @__PURE__ */ jsxs(QueueItem, {
181
178
  "data-run-id": run.runId,
182
179
  children: [/* @__PURE__ */ jsxs(QueueItemContent, { children: [/* @__PURE__ */ jsx(SubagentRunSelector, {
@@ -240,11 +237,11 @@ function SubagentRunPanelContent({ panel, renderRunLink }) {
240
237
  role: "alert",
241
238
  children: stop.error
242
239
  }) : null,
243
- panel.collection.status === "loading" ? /* @__PURE__ */ jsx(AgentChatNotice, { children: panel.collection.stale ? "Reconnecting. Last known runs are shown." : "Loading delegated work…" }) : null,
244
- panel.collection.status === "error" ? /* @__PURE__ */ jsx(AgentChatNotice, {
240
+ panel.agentTools.collection.status === "loading" ? /* @__PURE__ */ jsx(AgentChatNotice, { children: panel.agentTools.collection.stale ? "Reconnecting. Last known runs are shown." : "Loading delegated work…" }) : null,
241
+ panel.agentTools.collection.status === "error" ? /* @__PURE__ */ jsx(AgentChatNotice, {
245
242
  "data-tone": "danger",
246
243
  role: "alert",
247
- children: panel.collection.error ?? "Could not refresh delegated work. Last known runs are retained."
244
+ children: panel.agentTools.collection.error ?? "Could not refresh delegated work. Last known runs are retained."
248
245
  }) : null,
249
246
  /* @__PURE__ */ jsx(QueueList, {
250
247
  "aria-label": "Delegated work runs",
@@ -1,4 +1,4 @@
1
- import { n as AgentToolRunValue } from "../../AgentToolRunsContext-GMe_hSnD.js";
1
+ import { n as AgentToolRunValue } from "../../AgentToolRunsContext-DT50htHj.js";
2
2
  import * as React from "react";
3
3
  import { UIMessage } from "ai";
4
4
  import { AgentToolRunPart } from "agents/agent-tools";
@@ -1,10 +1,9 @@
1
1
  import { J as PromptInputMessage } from "../../PromptInput-DGPrCTPl.js";
2
2
  import { i as AgentMessageRenderPartContext } from "../../AgentMessageParts-C7L-Mv9U.js";
3
3
  import { AgentChatMessageContentProps, AgentChatRootProps } from "./AgentChat.js";
4
- import { o as createThinkChatActivityRenderer, r as ThinkChatActivityRendererOptions, t as ThinkChatActivity } from "../../ThinkChatActivity-DENkintt.js";
4
+ import { o as createThinkChatActivityRenderer, r as ThinkChatActivityRendererOptions, t as ThinkChatActivity } from "../../ThinkChatActivity-B6dh3n0-.js";
5
5
  import { i as ThinkChatValue } from "../../ThinkChatContext-COIgzkYp.js";
6
6
  import { n as WorkspaceFileRenderer } from "../../WorkspaceMessageResponse-BApg8KZv.js";
7
- import { o as UseSessionCompactionResult } from "../../SessionCompaction-CmTJFpzj.js";
8
7
  import * as React from "react";
9
8
  import { ChatStatus, UIMessage } from "ai";
10
9
  import { DataTag, UndefinedInitialDataOptions } from "@tanstack/react-query";
@@ -64,11 +63,6 @@ declare function ThinkChatApprovals({
64
63
  children
65
64
  }: ThinkChatApprovalsProps): React.JSX.Element;
66
65
  declare function ThinkChatRecoveryNotice(): React.JSX.Element;
67
- declare function ThinkChatCompactionNotice({
68
- compaction
69
- }: {
70
- compaction: UseSessionCompactionResult;
71
- }): React.JSX.Element;
72
66
  declare function useThinkChat<State = unknown, MessageT extends UIMessage = UIMessage>(): Omit<import("@ai-sdk/react").UseChatHelpers<MessageT>, "addToolOutput"> & {
73
67
  clearHistory: () => void;
74
68
  addToolOutput: (opts: {
@@ -93,10 +87,9 @@ declare const ThinkChat: {
93
87
  MessageContent: typeof ThinkChatMessageContent;
94
88
  Approvals: typeof ThinkChatApprovals;
95
89
  RecoveryNotice: typeof ThinkChatRecoveryNotice;
96
- CompactionNotice: typeof ThinkChatCompactionNotice;
97
90
  Activity: typeof ThinkChatActivity;
98
91
  renderActivityPart: (context: AgentMessageRenderPartContext<UIMessage<unknown, import("ai").UIDataTypes, import("ai").UITools>>) => React.ReactNode | undefined;
99
92
  createActivityRenderer: typeof createThinkChatActivityRenderer;
100
93
  };
101
94
  //#endregion
102
- export { ThinkChat, ThinkChatApprovals, ThinkChatApprovalsProps, ThinkChatCompactionNotice, ThinkChatMessageContent, ThinkChatMessageContentProps, ThinkChatRecoveryNotice, ThinkChatRoot, ThinkChatRootProps, ThinkPendingExecutionApprovalsQueryKey, ThinkPendingExecutionApprovalsQueryOptions, getThinkChatStatus, normalizeThinkPrompt, thinkPendingExecutionApprovalsQueryOptions, useThinkChat, useThinkPendingExecutionApprovals };
95
+ export { ThinkChat, ThinkChatApprovals, ThinkChatApprovalsProps, ThinkChatMessageContent, ThinkChatMessageContentProps, ThinkChatRecoveryNotice, ThinkChatRoot, ThinkChatRootProps, ThinkPendingExecutionApprovalsQueryKey, ThinkPendingExecutionApprovalsQueryOptions, getThinkChatStatus, normalizeThinkPrompt, thinkPendingExecutionApprovalsQueryOptions, useThinkChat, useThinkPendingExecutionApprovals };
@@ -1,6 +1,6 @@
1
1
  import { composerDraftToPrompt, parseComposerLinks } from "../../utils/composer-link.js";
2
- import { AgentChat, compactingNotice, useAgentChatControls } from "./AgentChat.js";
3
- import { ThinkChatContext, ThinkChatLiveContext, useOptionalThinkChatContext, useThinkChatContext } from "./ThinkChatContext.js";
2
+ import { AgentChat, useAgentChatControls } from "./AgentChat.js";
3
+ import { ThinkChatContext, ThinkChatLiveContext, useThinkChatContext } from "./ThinkChatContext.js";
4
4
  import { ThinkChatActivity, createThinkChatActivityRenderer, renderThinkChatActivityPart } from "./ThinkChatActivity.js";
5
5
  import { ThinkRecoveryNotice } from "./ThinkRecoveryNotice.js";
6
6
  import { n as WorkspaceMessageResponse, t as WorkspaceFileRendererProvider } from "../../WorkspaceMessageResponse-CUJk9_P5.js";
@@ -185,38 +185,6 @@ function ThinkChatRecoveryNotice() {
185
185
  const chat = useThinkChatContext("ThinkChat.RecoveryNotice");
186
186
  return /* @__PURE__ */ jsx(AgentChat.Notice, { children: /* @__PURE__ */ jsx(ThinkRecoveryNotice, { chat }) });
187
187
  }
188
- /** A submitted turn dismisses the result visible in that same committed update. */
189
- function useCompactionDismissal(result, revision) {
190
- const previousRevision = React.useRef(revision);
191
- const dismissed = React.useRef(null);
192
- const revisionChanged = previousRevision.current !== revision;
193
- React.useLayoutEffect(() => {
194
- if (!revisionChanged) return;
195
- previousRevision.current = revision;
196
- dismissed.current = result;
197
- }, [
198
- result,
199
- revision,
200
- revisionChanged
201
- ]);
202
- return revisionChanged || result === dismissed.current;
203
- }
204
- function getCompactionNotice(compaction, resultDismissed) {
205
- if (compaction.compacting) return compactingNotice;
206
- if (compaction.sessionError) return `Compaction failed: ${compaction.sessionError}`;
207
- if (compaction.reloadError) return "Transcript may be out of date. The next completed turn will retry the refresh.";
208
- const result = compaction.lastCompaction;
209
- if (!result || resultDismissed) return null;
210
- const freed = Math.round((result.tokensBefore - result.tokensAfter) / 1e3) * 1e3;
211
- return `Context compacted${freed > 0 ? ` — about ${freed.toLocaleString()} tokens freed` : ""}. Context usage updates after your next message.`;
212
- }
213
- function ThinkChatCompactionNotice({ compaction }) {
214
- const chat = useOptionalThinkChatContext();
215
- const { submissionVersion } = useAgentChatControls();
216
- const revision = `${chat?.messages.length}:${submissionVersion}`;
217
- const dismissed = useCompactionDismissal(compaction.lastCompaction, revision);
218
- return /* @__PURE__ */ jsx(AgentChat.Notice, { children: getCompactionNotice(compaction, dismissed) });
219
- }
220
188
  function useThinkChat() {
221
189
  return useThinkChatContext("useThinkChat");
222
190
  }
@@ -225,10 +193,9 @@ const ThinkChat = {
225
193
  MessageContent: ThinkChatMessageContent,
226
194
  Approvals: ThinkChatApprovals,
227
195
  RecoveryNotice: ThinkChatRecoveryNotice,
228
- CompactionNotice: ThinkChatCompactionNotice,
229
196
  Activity: ThinkChatActivity,
230
197
  renderActivityPart: renderThinkChatActivityPart,
231
198
  createActivityRenderer: createThinkChatActivityRenderer
232
199
  };
233
200
  //#endregion
234
- export { ThinkChat, ThinkChatApprovals, ThinkChatCompactionNotice, ThinkChatMessageContent, ThinkChatRecoveryNotice, ThinkChatRoot, getThinkChatStatus, normalizeThinkPrompt, thinkPendingExecutionApprovalsQueryOptions, useThinkChat, useThinkPendingExecutionApprovals };
201
+ export { ThinkChat, ThinkChatApprovals, ThinkChatMessageContent, ThinkChatRecoveryNotice, ThinkChatRoot, getThinkChatStatus, normalizeThinkPrompt, thinkPendingExecutionApprovalsQueryOptions, useThinkChat, useThinkPendingExecutionApprovals };
@@ -1,2 +1,2 @@
1
- import { a as ThinkChatToolRenderers, i as ThinkChatToolRenderer, n as ThinkChatActivityProps, o as createThinkChatActivityRenderer, r as ThinkChatActivityRendererOptions, s as renderThinkChatActivityPart, t as ThinkChatActivity } from "../../ThinkChatActivity-DENkintt.js";
1
+ import { a as ThinkChatToolRenderers, i as ThinkChatToolRenderer, n as ThinkChatActivityProps, o as createThinkChatActivityRenderer, r as ThinkChatActivityRendererOptions, s as renderThinkChatActivityPart, t as ThinkChatActivity } from "../../ThinkChatActivity-B6dh3n0-.js";
2
2
  export { ThinkChatActivity, ThinkChatActivityProps, ThinkChatActivityRendererOptions, ThinkChatToolRenderer, ThinkChatToolRenderers, createThinkChatActivityRenderer, renderThinkChatActivityPart };
@@ -1,4 +1,4 @@
1
- import { n as AgentToolRunValue } from "../../AgentToolRunsContext-GMe_hSnD.js";
1
+ import { n as AgentToolRunValue } from "../../AgentToolRunsContext-DT50htHj.js";
2
2
  import { i as ThinkChatValue } from "../../ThinkChatContext-COIgzkYp.js";
3
3
  import { SubagentRunMetadataProps } from "../agents-sdk/SubagentRunDetails.js";
4
4
  import * as React from "react";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mcp-b/react-components",
3
- "version": "0.54.0",
3
+ "version": "0.56.0",
4
4
  "description": "MCP-B React components built on Base UI and shared design tokens, including Cloudflare Think chat primitives.",
5
5
  "homepage": "https://design-system.sigvelo.com",
6
6
  "bugs": {
@@ -54,14 +54,13 @@
54
54
  "streamdown": "^2.5.0",
55
55
  "unist-util-visit": "^5.1.0",
56
56
  "yet-another-react-lightbox": "^3.32.2",
57
- "@mcp-b/design-tokens": "0.54.0"
57
+ "@mcp-b/design-tokens": "0.56.0"
58
58
  },
59
59
  "devDependencies": {
60
60
  "@ai-sdk/react": "^3.0.249",
61
- "@cloudflare/codemode": "^0.5.1",
62
- "@cloudflare/shell": "^0.4.3",
63
- "@cloudflare/think": "^0.16.0",
64
- "@cloudflare/voice": "^0.3.6",
61
+ "@cloudflare/codemode": "https://github.com/WebMCP-org/do-runtime/releases/download/rook-sdk-e3966bd9e759/cloudflare-codemode-0.5.2.tgz",
62
+ "@cloudflare/shell": "https://github.com/WebMCP-org/do-runtime/releases/download/rook-sdk-e3966bd9e759/cloudflare-shell-0.4.3.tgz",
63
+ "@cloudflare/think": "https://github.com/WebMCP-org/do-runtime/releases/download/rook-sdk-e3966bd9e759/cloudflare-think-0.18.0.tgz",
65
64
  "@cloudflare/workers-types": "^5.20260811.1",
66
65
  "@storybook/addon-a11y": "^10.5.7",
67
66
  "@storybook/addon-docs": "^10.5.7",
@@ -80,7 +79,7 @@
80
79
  "@vitest/browser-playwright": "^4.1.10",
81
80
  "@vitest/coverage-v8": "^4.1.10",
82
81
  "@vitest/mocker": "^4.1.10",
83
- "agents": "^0.21.0",
82
+ "agents": "https://github.com/WebMCP-org/do-runtime/releases/download/rook-sdk-e3966bd9e759/agents-0.23.0.tgz",
84
83
  "ai": "^6.0.247",
85
84
  "cloudflare": "^7.0.0",
86
85
  "oversight-lint": "0.7.1",
@@ -96,13 +95,12 @@
96
95
  },
97
96
  "peerDependencies": {
98
97
  "@ai-sdk/react": "^3.0.230",
99
- "@cloudflare/codemode": "^0.5.1",
98
+ "@cloudflare/codemode": "^0.5.2",
100
99
  "@cloudflare/shell": "^0.4.3",
101
- "@cloudflare/think": "^0.16.0",
102
- "@cloudflare/voice": "^0.3.6",
100
+ "@cloudflare/think": "^0.18.0",
103
101
  "@cloudflare/workers-types": "^5.20260715.1",
104
102
  "@tanstack/react-query": "^5.101.2",
105
- "agents": "^0.21.0",
103
+ "agents": "^0.23.0",
106
104
  "ai": "^6.0.228",
107
105
  "cloudflare": "^7.0.0",
108
106
  "react": "19.3.0-canary-711c445b-20260722",
@@ -121,9 +119,6 @@
121
119
  "@cloudflare/think": {
122
120
  "optional": true
123
121
  },
124
- "@cloudflare/voice": {
125
- "optional": true
126
- },
127
122
  "@cloudflare/workers-types": {
128
123
  "optional": true
129
124
  },
@@ -1,89 +0,0 @@
1
- import { ChatStatus, UIMessage } from "ai";
2
-
3
- //#region src/components/agents-sdk/SessionCompaction.d.ts
4
- type SessionStatusPhase = "idle" | "compacting";
5
- interface SessionStatusFrame {
6
- phase: SessionStatusPhase;
7
- /** Present on the idle frame that follows a successful compaction. */
8
- compacted: boolean;
9
- /**
10
- * Session's own estimate for the history this frame describes, or null when
11
- * the frame omits it or carries a non-finite value. Not provider-reported
12
- * usage — never render it as an exact token count, and never feed it to the
13
- * `Context` ring, which reads `metadata.usage`.
14
- */
15
- tokenEstimate: number | null;
16
- /**
17
- * The same estimate taken before the compaction this frame reports, from its
18
- * `compacted` payload. Null on every other frame. Both numbers come from one
19
- * estimator over one history, so their difference is a meaningful size even
20
- * though neither is exact.
21
- */
22
- tokensBefore: number | null;
23
- }
24
- /**
25
- * Parse a raw websocket payload as a `cf_agent_session` status frame.
26
- * Returns null for every other frame on the connection.
27
- */
28
- declare function parseSessionStatusFrame(data: unknown): SessionStatusFrame | null;
29
- /**
30
- * Parse a raw websocket payload as a `cf_agent_session_error` frame,
31
- * returning its error text. Null for every other frame on the connection.
32
- */
33
- declare function parseSessionErrorFrame(data: unknown): string | null;
34
- /** The message-frame surface of a `useAgent` connection. */
35
- interface SessionFrameSource {
36
- addEventListener(type: "message", listener: (event: MessageEvent) => void): void;
37
- removeEventListener(type: "message", listener: (event: MessageEvent) => void): void;
38
- }
39
- interface UseSessionCompactionOptions<MessageT extends UIMessage> {
40
- /** The conversation agent's `useAgent` connection. */
41
- agent: SessionFrameSource;
42
- /** The conversation's `useAgentChat` value (status + local view setter). */
43
- chat: {
44
- status: ChatStatus;
45
- setMessages: (messages: MessageT[]) => void;
46
- };
47
- /** Server read used to reload the transcript after a compaction lands. */
48
- getMessages: () => Promise<MessageT[]>;
49
- }
50
- /**
51
- * How much a landed compaction shortened the history, per Session's own
52
- * estimator. A UI may show the difference as an approximate size; it must not
53
- * present either number as exact usage.
54
- */
55
- interface SessionCompactionSize {
56
- tokensBefore: number;
57
- tokensAfter: number;
58
- }
59
- interface UseSessionCompactionResult {
60
- compacting: boolean;
61
- /**
62
- * Size of the compaction that landed most recently on this connection, or
63
- * null when none has landed or the frames carried no usable estimates. A new
64
- * object per compaction, so a consumer can dismiss one acknowledgement by
65
- * identity and still show the next. Cleared when the next compaction starts.
66
- */
67
- lastCompaction: SessionCompactionSize | null;
68
- /**
69
- * Set when the post-compaction transcript reload rejected — the local view
70
- * is stale relative to the server until a retry succeeds. Surface it
71
- * ("Transcript may be out of date"); the hook retries on the next status
72
- * transition to `"ready"`.
73
- */
74
- reloadError: unknown;
75
- /**
76
- * Error text from the last `cf_agent_session_error` frame — the only signal
77
- * a user who ran /compact gets when the server-side compaction itself fails
78
- * (the phase just flips back to idle with no `compacted` payload). Cleared
79
- * when the next compaction starts.
80
- */
81
- sessionError: string | null;
82
- }
83
- declare function useSessionCompaction<MessageT extends UIMessage>({
84
- agent,
85
- chat,
86
- getMessages
87
- }: UseSessionCompactionOptions<MessageT>): UseSessionCompactionResult;
88
- //#endregion
89
- export { UseSessionCompactionOptions as a, parseSessionStatusFrame as c, SessionStatusPhase as i, useSessionCompaction as l, SessionFrameSource as n, UseSessionCompactionResult as o, SessionStatusFrame as r, parseSessionErrorFrame as s, SessionCompactionSize as t };
@@ -1,2 +0,0 @@
1
- import { a as UseSessionCompactionOptions, c as parseSessionStatusFrame, i as SessionStatusPhase, l as useSessionCompaction, n as SessionFrameSource, o as UseSessionCompactionResult, r as SessionStatusFrame, s as parseSessionErrorFrame, t as SessionCompactionSize } from "../../SessionCompaction-CmTJFpzj.js";
2
- export { SessionCompactionSize, SessionFrameSource, SessionStatusFrame, SessionStatusPhase, UseSessionCompactionOptions, UseSessionCompactionResult, parseSessionErrorFrame, parseSessionStatusFrame, useSessionCompaction };
@@ -1,140 +0,0 @@
1
- import * as React from "react";
2
- //#region src/components/agents-sdk/SessionCompaction.ts
3
- /**
4
- * Client-side session-compaction plumbing for Think conversations.
5
- *
6
- * The Agents Session broadcasts `cf_agent_session` status frames to every
7
- * connected client: `phase` flips to `"compacting"` while a compaction runs
8
- * and back to `"idle"` when it settles, with a `compacted` payload on the
9
- * idle frame when an overlay was actually written. Think refreshes only its
10
- * server-side message cache after a compaction (`_syncMessages()` does not
11
- * push to clients), so a connected transcript keeps showing the uncompacted
12
- * history until its next `getMessages()`. `useSessionCompaction` closes that
13
- * gap: it tracks the live phase for a "Compacting context…" affordance and
14
- * reloads the transcript once a compaction lands — deferring the reload to
15
- * the end of the turn when one is streaming, so a mid-turn proactive
16
- * compaction never clobbers streamed state.
17
- *
18
- * Compose the command with `useAgentChatCompaction`: supply the app's
19
- * compaction callable, then place its command and notice explicitly.
20
- *
21
- * This module is the "local adapter … documented runtime-only mirror" that
22
- * docs/think-session-ui.md calls for: upstream exports no payload types or
23
- * client hook for these frames. The doc records the complete frame shapes;
24
- * this adapter consumes `phase`, the presence of `compacted`, the error string
25
- * of `cf_agent_session_error`, and the two estimates that size a landed
26
- * compaction (`tokenEstimate` and `compacted.tokensBefore`). Every field but
27
- * `phase` degrades to null rather than throwing, so an upstream field change
28
- * costs detail, never the UI. Per that doc, `tokenThreshold` is the
29
- * auto-compaction threshold, not the model context window — it stays unread
30
- * here, and neither estimate may drive the `Context` ring, which reads
31
- * provider-reported `metadata.usage`.
32
- *
33
- * @see ../../docs/think-session-ui.md
34
- * @see https://github.com/cloudflare/agents/blob/main/docs/agents/sessions.md#compaction
35
- */
36
- /** Finite numbers only — an absent or malformed field degrades to null. */
37
- function finiteNumber(value) {
38
- return typeof value === "number" && Number.isFinite(value) ? value : null;
39
- }
40
- /**
41
- * Parse a raw websocket payload as a `cf_agent_session` status frame.
42
- * Returns null for every other frame on the connection.
43
- */
44
- function parseSessionStatusFrame(data) {
45
- if (typeof data !== "string") return null;
46
- let message;
47
- try {
48
- message = JSON.parse(data);
49
- } catch {
50
- return null;
51
- }
52
- if (typeof message !== "object" || message === null || !("type" in message) || message.type !== "cf_agent_session" || !("phase" in message) || message.phase !== "idle" && message.phase !== "compacting") return null;
53
- const compacted = "compacted" in message && message.compacted != null ? message.compacted : null;
54
- return {
55
- phase: message.phase,
56
- compacted: compacted !== null,
57
- tokenEstimate: finiteNumber("tokenEstimate" in message ? message.tokenEstimate : void 0),
58
- tokensBefore: typeof compacted === "object" && compacted !== null && "tokensBefore" in compacted ? finiteNumber(compacted.tokensBefore) : null
59
- };
60
- }
61
- /**
62
- * Parse a raw websocket payload as a `cf_agent_session_error` frame,
63
- * returning its error text. Null for every other frame on the connection.
64
- */
65
- function parseSessionErrorFrame(data) {
66
- if (typeof data !== "string") return null;
67
- let message;
68
- try {
69
- message = JSON.parse(data);
70
- } catch {
71
- return null;
72
- }
73
- if (typeof message !== "object" || message === null || !("type" in message) || message.type !== "cf_agent_session_error" || !("error" in message) || typeof message.error !== "string") return null;
74
- return message.error;
75
- }
76
- function useSessionCompaction({ agent, chat, getMessages }) {
77
- const [compacting, setCompacting] = React.useState(false);
78
- const [refreshPending, setRefreshPending] = React.useState(false);
79
- const [reloadError, setReloadError] = React.useState(null);
80
- const [sessionError, setSessionError] = React.useState(null);
81
- const [lastCompaction, setLastCompaction] = React.useState(null);
82
- React.useEffect(() => {
83
- setCompacting(false);
84
- setSessionError(null);
85
- setRefreshPending(false);
86
- setReloadError(null);
87
- setLastCompaction(null);
88
- const onMessage = (event) => {
89
- const frame = parseSessionStatusFrame(event.data);
90
- if (frame) {
91
- setCompacting(frame.phase === "compacting");
92
- if (frame.phase === "compacting") {
93
- setSessionError(null);
94
- setLastCompaction(null);
95
- }
96
- if (frame.compacted) {
97
- setRefreshPending(true);
98
- setLastCompaction(frame.tokensBefore !== null && frame.tokenEstimate !== null ? {
99
- tokensAfter: frame.tokenEstimate,
100
- tokensBefore: frame.tokensBefore
101
- } : null);
102
- }
103
- return;
104
- }
105
- const error = parseSessionErrorFrame(event.data);
106
- if (error !== null) {
107
- setCompacting(false);
108
- setSessionError(error);
109
- }
110
- };
111
- agent.addEventListener("message", onMessage);
112
- return () => agent.removeEventListener("message", onMessage);
113
- }, [agent]);
114
- const { status, setMessages } = chat;
115
- React.useEffect(() => {
116
- if (!refreshPending || status !== "ready") return;
117
- let stale = false;
118
- getMessages().then((messages) => {
119
- if (stale) return;
120
- setRefreshPending(false);
121
- setReloadError(null);
122
- setMessages(messages);
123
- }, (error) => {
124
- if (stale) return;
125
- console.error("Transcript reload after compaction failed", error);
126
- setReloadError(error);
127
- });
128
- return () => {
129
- stale = true;
130
- };
131
- }, [refreshPending, status]);
132
- return {
133
- compacting,
134
- lastCompaction,
135
- reloadError,
136
- sessionError
137
- };
138
- }
139
- //#endregion
140
- export { parseSessionErrorFrame, parseSessionStatusFrame, useSessionCompaction };