@mcp-b/react-components 0.32.0 → 0.34.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.
- package/dist/AgentToolRunsContext-BCVqCtJ1.d.ts +44 -0
- package/dist/{ThinkChat-BIEryLy0.js → ThinkChat-en0UbkVv.js} +3 -14
- package/dist/components/agents-sdk/AgentToolRunsContext.d.ts +2 -2
- package/dist/components/agents-sdk/AgentToolRunsContext.js +20 -1
- package/dist/components/agents-sdk/ThinkChat.d.ts +3 -3
- package/dist/components/agents-sdk/ThinkChat.js +3 -3
- package/dist/components/agents-sdk/ThinkFullApp.d.ts +8 -0
- package/dist/components/agents-sdk/ThinkFullApp.js +2 -3
- package/dist/components/nanites/AgentToolDetail.d.ts +44 -2
- package/dist/components/nanites/AgentToolDetail.js +52 -16
- package/dist/styles/agent-tool-detail.css +12 -2
- package/package.json +2 -2
- package/dist/AgentToolRunsContext-Cgve-Upx.d.ts +0 -21
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { UIMessage } from "ai";
|
|
3
|
+
import { useAgentToolEvents } from "agents/react";
|
|
4
|
+
import { AgentToolRunPart } from "agents/agent-tools";
|
|
5
|
+
|
|
6
|
+
//#region src/components/agents-sdk/AgentToolRunsContext.d.ts
|
|
7
|
+
/** The complete upstream retained-run hook result for one parent connection. */
|
|
8
|
+
type AgentToolEventsValue<Part extends AgentToolRunPart = UIMessage["parts"][number]> = ReturnType<typeof useAgentToolEvents<Part>>;
|
|
9
|
+
/** The live parent connection members the retained-run subscription reads. */
|
|
10
|
+
type AgentToolEventSource = Parameters<typeof useAgentToolEvents>[0]["agent"] & {
|
|
11
|
+
path: ReadonlyArray<{
|
|
12
|
+
agent: string;
|
|
13
|
+
name: string;
|
|
14
|
+
}>;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* The one retained-run subscription for a parent connection: upstream
|
|
18
|
+
* `useAgentToolEvents` scoped to the connection's source identity, so runs
|
|
19
|
+
* from a previous thread cannot leak across a source swap. Call it beside the
|
|
20
|
+
* `useAgent` call that owns the connection — the server replays retained runs
|
|
21
|
+
* once per socket connect, so a later mount misses existing runs — and share
|
|
22
|
+
* the one value with every surface that reads runs (the chat shell and a
|
|
23
|
+
* run-detail route read the same projection, never two subscriptions).
|
|
24
|
+
*/
|
|
25
|
+
declare function useSourceScopedAgentToolEvents<Part extends AgentToolRunPart = UIMessage["parts"][number]>(agent: AgentToolEventSource): {
|
|
26
|
+
runsById: Record<string, import("agents").AgentToolRunState<Part>>;
|
|
27
|
+
runsByToolCallId: Record<string, import("agents").AgentToolRunState<Part>[]>;
|
|
28
|
+
unboundRuns: import("agents").AgentToolRunState<Part>[];
|
|
29
|
+
getRunsForToolCall(toolCallId: string): import("agents").AgentToolRunState<Part>[];
|
|
30
|
+
resetLocalState(): void;
|
|
31
|
+
};
|
|
32
|
+
interface AgentToolRunsProviderProps<Part extends AgentToolRunPart = UIMessage["parts"][number]> {
|
|
33
|
+
/** Pass the whole `useAgentToolEvents({ agent })` result directly. */
|
|
34
|
+
agentTools: AgentToolEventsValue<Part>;
|
|
35
|
+
children: React.ReactNode;
|
|
36
|
+
}
|
|
37
|
+
/** Provides one parent connection's retained Agent Tool event projection. */
|
|
38
|
+
declare function AgentToolRunsProvider<Part extends AgentToolRunPart = UIMessage["parts"][number]>({
|
|
39
|
+
agentTools,
|
|
40
|
+
children
|
|
41
|
+
}: AgentToolRunsProviderProps<Part>): React.JSX.Element;
|
|
42
|
+
declare function useOptionalAgentToolRuns<Part extends AgentToolRunPart = UIMessage["parts"][number]>(): AgentToolEventsValue<Part> | null;
|
|
43
|
+
//#endregion
|
|
44
|
+
export { useOptionalAgentToolRuns as a, AgentToolRunsProviderProps as i, AgentToolEventsValue as n, useSourceScopedAgentToolEvents as o, AgentToolRunsProvider as r, AgentToolEventSource as t };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { J as SpinnerIcon } from "./icons-B1Qw05te.js";
|
|
2
2
|
import { TransitionSurface } from "./components/foundations/TransitionSurface.js";
|
|
3
3
|
import { AgentChat } from "./components/agents-sdk/AgentChat.js";
|
|
4
|
-
import { AgentToolRunsProvider, useOptionalAgentToolRuns } from "./components/agents-sdk/AgentToolRunsContext.js";
|
|
4
|
+
import { AgentToolRunsProvider, useOptionalAgentToolRuns, useSourceScopedAgentToolEvents } from "./components/agents-sdk/AgentToolRunsContext.js";
|
|
5
5
|
import { SubagentRunList } from "./components/agents-sdk/SubagentRunList.js";
|
|
6
6
|
import { ThinkChatContext, ThinkChatLiveContext, useOptionalThinkChatContext, useThinkChatContext } from "./components/agents-sdk/ThinkChatContext.js";
|
|
7
7
|
import { ThinkChatActivity, createThinkChatActivityRenderer, renderThinkChatActivityPart } from "./components/agents-sdk/ThinkChatActivity.js";
|
|
@@ -11,19 +11,8 @@ import * as React from "react";
|
|
|
11
11
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
12
12
|
import { isTextUIPart } from "ai";
|
|
13
13
|
import { useAgentChat } from "@cloudflare/think/react";
|
|
14
|
+
import { useAgent } from "agents/react";
|
|
14
15
|
import { queryOptions, useQuery, useQueryClient } from "@tanstack/react-query";
|
|
15
|
-
import { useAgent, useAgentToolEvents } from "agents/react";
|
|
16
|
-
//#region src/components/_internal/use-agent-tool-events.ts
|
|
17
|
-
function useSourceScopedAgentToolEvents(agent) {
|
|
18
|
-
const agentTools = useAgentToolEvents({ agent });
|
|
19
|
-
const sourceIdentity = JSON.stringify(agent.path);
|
|
20
|
-
const resetAgentTools = React.useEffectEvent(() => agentTools.resetLocalState());
|
|
21
|
-
React.useEffect(() => {
|
|
22
|
-
resetAgentTools();
|
|
23
|
-
}, [sourceIdentity]);
|
|
24
|
-
return agentTools;
|
|
25
|
-
}
|
|
26
|
-
//#endregion
|
|
27
16
|
//#region src/components/_internal/think-approvals.ts
|
|
28
17
|
/**
|
|
29
18
|
* Ambient approvals belong to their stub. An explicit different stub may only
|
|
@@ -343,4 +332,4 @@ const ThinkChat = {
|
|
|
343
332
|
createActivityRenderer: createThinkChatActivityRenderer
|
|
344
333
|
};
|
|
345
334
|
//#endregion
|
|
346
|
-
export { thinkPendingExecutionApprovalsQueryOptions as a, resolveThinkApprovalProps as c, ThinkChatRoot as i,
|
|
335
|
+
export { thinkPendingExecutionApprovalsQueryOptions as a, resolveThinkApprovalProps as c, ThinkChatRoot as i, ThinkChatMessages as n, useThinkChat as o, ThinkChatProvider as r, useThinkPendingExecutionApprovals as s, ThinkChat as t };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { AgentToolEventsValue, AgentToolRunsProvider, AgentToolRunsProviderProps, useOptionalAgentToolRuns };
|
|
1
|
+
import { a as useOptionalAgentToolRuns, i as AgentToolRunsProviderProps, n as AgentToolEventsValue, o as useSourceScopedAgentToolEvents, r as AgentToolRunsProvider, t as AgentToolEventSource } from "../../AgentToolRunsContext-BCVqCtJ1.js";
|
|
2
|
+
export { AgentToolEventSource, AgentToolEventsValue, AgentToolRunsProvider, AgentToolRunsProviderProps, useOptionalAgentToolRuns, useSourceScopedAgentToolEvents };
|
|
@@ -1,6 +1,25 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useAgentToolEvents } from "agents/react";
|
|
3
4
|
//#region src/components/agents-sdk/AgentToolRunsContext.tsx
|
|
5
|
+
/**
|
|
6
|
+
* The one retained-run subscription for a parent connection: upstream
|
|
7
|
+
* `useAgentToolEvents` scoped to the connection's source identity, so runs
|
|
8
|
+
* from a previous thread cannot leak across a source swap. Call it beside the
|
|
9
|
+
* `useAgent` call that owns the connection — the server replays retained runs
|
|
10
|
+
* once per socket connect, so a later mount misses existing runs — and share
|
|
11
|
+
* the one value with every surface that reads runs (the chat shell and a
|
|
12
|
+
* run-detail route read the same projection, never two subscriptions).
|
|
13
|
+
*/
|
|
14
|
+
function useSourceScopedAgentToolEvents(agent) {
|
|
15
|
+
const agentTools = useAgentToolEvents({ agent });
|
|
16
|
+
const sourceIdentity = JSON.stringify(agent.path);
|
|
17
|
+
const resetAgentTools = React.useEffectEvent(() => agentTools.resetLocalState());
|
|
18
|
+
React.useEffect(() => {
|
|
19
|
+
resetAgentTools();
|
|
20
|
+
}, [sourceIdentity]);
|
|
21
|
+
return agentTools;
|
|
22
|
+
}
|
|
4
23
|
const AgentToolRunsContext = React.createContext(null);
|
|
5
24
|
/** Provides one parent connection's retained Agent Tool event projection. */
|
|
6
25
|
function AgentToolRunsProvider({ agentTools, children }) {
|
|
@@ -13,4 +32,4 @@ function useOptionalAgentToolRuns() {
|
|
|
13
32
|
return React.useContext(AgentToolRunsContext);
|
|
14
33
|
}
|
|
15
34
|
//#endregion
|
|
16
|
-
export { AgentToolRunsProvider, useOptionalAgentToolRuns };
|
|
35
|
+
export { AgentToolRunsProvider, useOptionalAgentToolRuns, useSourceScopedAgentToolEvents };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { i as AgentMessageRenderPartContext } from "../../AgentMessageParts-C7L-Mv9U.js";
|
|
2
2
|
import { ct as PromptInputMessage } from "../../PromptInput-DOyee1kM.js";
|
|
3
3
|
import { r as AgentChatProps } from "../../AgentChat-CV-GuYA6.js";
|
|
4
|
-
import {
|
|
4
|
+
import { a as useOptionalAgentToolRuns, i as AgentToolRunsProviderProps, n as AgentToolEventsValue, o as useSourceScopedAgentToolEvents, r as AgentToolRunsProvider, t as AgentToolEventSource } from "../../AgentToolRunsContext-BCVqCtJ1.js";
|
|
5
5
|
import { n as BrowserLiveViewProps, t as BrowserLiveView } from "../../BrowserLiveView-tJTWkoyu.js";
|
|
6
6
|
import { n as BrowserReplayProps, t as BrowserReplay } from "../../BrowserReplay-B0BQZr-N.js";
|
|
7
7
|
import { o as UseSessionCompactionResult } from "../../SessionCompaction-CmTJFpzj.js";
|
|
@@ -15,8 +15,8 @@ import { a as WorkspaceSource, c as workspaceBinaryFileQueryOptions, d as worksp
|
|
|
15
15
|
import { n as WorkspaceExplorerProps, t as WorkspaceExplorer } from "../../WorkspaceExplorer-DygQnEyi.js";
|
|
16
16
|
import * as React from "react";
|
|
17
17
|
import { UIMessage } from "ai";
|
|
18
|
-
import { DataTag, UndefinedInitialDataOptions } from "@tanstack/react-query";
|
|
19
18
|
import { UseAgentOptions } from "agents/react";
|
|
19
|
+
import { DataTag, UndefinedInitialDataOptions } from "@tanstack/react-query";
|
|
20
20
|
import { PendingApproval, Think } from "@cloudflare/think";
|
|
21
21
|
import { AgentStub } from "agents/client";
|
|
22
22
|
import { UseVoiceInputReturn } from "@cloudflare/voice/react";
|
|
@@ -253,4 +253,4 @@ declare const ThinkChat: {
|
|
|
253
253
|
createActivityRenderer: typeof createThinkChatActivityRenderer;
|
|
254
254
|
};
|
|
255
255
|
//#endregion
|
|
256
|
-
export { type AgentToolEventsValue, AgentToolRunsProvider, type AgentToolRunsProviderProps, BrowserLiveView, type BrowserLiveViewProps, BrowserReplay, type BrowserReplayProps, ThinkChat, ThinkChatActivity, type ThinkChatActivityProps, type ThinkChatActivityRendererOptions, ThinkChatDraft, ThinkChatMessages, ThinkChatMessagesProps, ThinkChatProvider, ThinkChatProviderProps, ThinkChatRoot, ThinkChatRootProps, type ThinkChatToolRenderer, type ThinkChatToolRenderers, ThinkPendingExecutionApprovalsQueryKey, ThinkPendingExecutionApprovalsQueryOptions, ThinkRecoveryNotice, type ThinkRecoveryNoticeProps, type UseWorkspaceOptions, WorkspaceExplorer, type WorkspaceExplorerProps, type WorkspaceFileReadTarget, type WorkspaceFileState, type WorkspaceInfo, type WorkspaceQueryKey, type WorkspaceSource, type WorkspaceState, createThinkChatActivityRenderer, describeThinkChatActivityPart, inferWorkspaceLanguage, isThinkChatActivityPart, renderThinkChatActivityPart, thinkPendingExecutionApprovalsQueryOptions, useOptionalAgentToolRuns, useThinkChat, useThinkPendingExecutionApprovals, useWorkspace, workspaceBinaryFileQueryOptions, workspaceDirectoryQueryKey, workspaceDirectoryQueryOptions, workspaceDirectoryQueryPrefix, workspaceFileAssetQueryOptions, workspaceFileStatQueryOptions, workspaceInfoQueryOptions, workspaceQueryKey, workspaceTextFileQueryOptions };
|
|
256
|
+
export { type AgentToolEventSource, type AgentToolEventsValue, AgentToolRunsProvider, type AgentToolRunsProviderProps, BrowserLiveView, type BrowserLiveViewProps, BrowserReplay, type BrowserReplayProps, ThinkChat, ThinkChatActivity, type ThinkChatActivityProps, type ThinkChatActivityRendererOptions, ThinkChatDraft, ThinkChatMessages, ThinkChatMessagesProps, ThinkChatProvider, ThinkChatProviderProps, ThinkChatRoot, ThinkChatRootProps, type ThinkChatToolRenderer, type ThinkChatToolRenderers, ThinkPendingExecutionApprovalsQueryKey, ThinkPendingExecutionApprovalsQueryOptions, ThinkRecoveryNotice, type ThinkRecoveryNoticeProps, type UseWorkspaceOptions, WorkspaceExplorer, type WorkspaceExplorerProps, type WorkspaceFileReadTarget, type WorkspaceFileState, type WorkspaceInfo, type WorkspaceQueryKey, type WorkspaceSource, type WorkspaceState, createThinkChatActivityRenderer, describeThinkChatActivityPart, inferWorkspaceLanguage, isThinkChatActivityPart, renderThinkChatActivityPart, thinkPendingExecutionApprovalsQueryOptions, useOptionalAgentToolRuns, useSourceScopedAgentToolEvents, useThinkChat, useThinkPendingExecutionApprovals, useWorkspace, workspaceBinaryFileQueryOptions, workspaceDirectoryQueryKey, workspaceDirectoryQueryOptions, workspaceDirectoryQueryPrefix, workspaceFileAssetQueryOptions, workspaceFileStatQueryOptions, workspaceInfoQueryOptions, workspaceQueryKey, workspaceTextFileQueryOptions };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AgentToolRunsProvider, useOptionalAgentToolRuns } from "./AgentToolRunsContext.js";
|
|
1
|
+
import { AgentToolRunsProvider, useOptionalAgentToolRuns, useSourceScopedAgentToolEvents } from "./AgentToolRunsContext.js";
|
|
2
2
|
import { BrowserLiveView } from "./BrowserLiveView.js";
|
|
3
3
|
import { BrowserReplay } from "./BrowserReplay.js";
|
|
4
4
|
import { inferWorkspaceLanguage } from "./WorkspaceFile.js";
|
|
@@ -6,7 +6,7 @@ import { isThinkChatActivityPart } from "./ThinkChatToolParts.js";
|
|
|
6
6
|
import { describeThinkChatActivityPart } from "./ThinkChatActivitySummary.js";
|
|
7
7
|
import { ThinkChatActivity, createThinkChatActivityRenderer, renderThinkChatActivityPart } from "./ThinkChatActivity.js";
|
|
8
8
|
import { ThinkRecoveryNotice } from "./ThinkRecoveryNotice.js";
|
|
9
|
-
import { a as thinkPendingExecutionApprovalsQueryOptions, i as ThinkChatRoot, n as ThinkChatMessages, o as useThinkChat, r as ThinkChatProvider, s as useThinkPendingExecutionApprovals, t as ThinkChat } from "../../ThinkChat-
|
|
9
|
+
import { a as thinkPendingExecutionApprovalsQueryOptions, i as ThinkChatRoot, n as ThinkChatMessages, o as useThinkChat, r as ThinkChatProvider, s as useThinkPendingExecutionApprovals, t as ThinkChat } from "../../ThinkChat-en0UbkVv.js";
|
|
10
10
|
import { useWorkspace, workspaceBinaryFileQueryOptions, workspaceDirectoryQueryKey, workspaceDirectoryQueryOptions, workspaceDirectoryQueryPrefix, workspaceFileAssetQueryOptions, workspaceFileStatQueryOptions, workspaceInfoQueryOptions, workspaceQueryKey, workspaceTextFileQueryOptions } from "./Workspace.js";
|
|
11
11
|
import { WorkspaceExplorer } from "./WorkspaceExplorer.js";
|
|
12
|
-
export { AgentToolRunsProvider, BrowserLiveView, BrowserReplay, ThinkChat, ThinkChatActivity, ThinkChatMessages, ThinkChatProvider, ThinkChatRoot, ThinkRecoveryNotice, WorkspaceExplorer, createThinkChatActivityRenderer, describeThinkChatActivityPart, inferWorkspaceLanguage, isThinkChatActivityPart, renderThinkChatActivityPart, thinkPendingExecutionApprovalsQueryOptions, useOptionalAgentToolRuns, useThinkChat, useThinkPendingExecutionApprovals, useWorkspace, workspaceBinaryFileQueryOptions, workspaceDirectoryQueryKey, workspaceDirectoryQueryOptions, workspaceDirectoryQueryPrefix, workspaceFileAssetQueryOptions, workspaceFileStatQueryOptions, workspaceInfoQueryOptions, workspaceQueryKey, workspaceTextFileQueryOptions };
|
|
12
|
+
export { AgentToolRunsProvider, BrowserLiveView, BrowserReplay, ThinkChat, ThinkChatActivity, ThinkChatMessages, ThinkChatProvider, ThinkChatRoot, ThinkRecoveryNotice, WorkspaceExplorer, createThinkChatActivityRenderer, describeThinkChatActivityPart, inferWorkspaceLanguage, isThinkChatActivityPart, renderThinkChatActivityPart, thinkPendingExecutionApprovalsQueryOptions, useOptionalAgentToolRuns, useSourceScopedAgentToolEvents, useThinkChat, useThinkPendingExecutionApprovals, useWorkspace, workspaceBinaryFileQueryOptions, workspaceDirectoryQueryKey, workspaceDirectoryQueryOptions, workspaceDirectoryQueryPrefix, workspaceFileAssetQueryOptions, workspaceFileStatQueryOptions, workspaceInfoQueryOptions, workspaceQueryKey, workspaceTextFileQueryOptions };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { l as WorkspaceNavigationAdapter } from "../../WorkspaceLink-DQogVe8E.js";
|
|
2
|
+
import { n as AgentToolEventsValue } from "../../AgentToolRunsContext-BCVqCtJ1.js";
|
|
2
3
|
import { McpPluginCatalogProps } from "./McpPluginCatalog.js";
|
|
3
4
|
import { r as WorkspaceFileAssetResolver } from "../../WorkspaceFile-C8Riev9j.js";
|
|
4
5
|
import { a as WorkspaceSource } from "../../Workspace-EhvvlHOB.js";
|
|
@@ -45,6 +46,13 @@ interface ThinkFullAppConversation<AgentT extends ThinkFullAppAgent<State>, Stat
|
|
|
45
46
|
agent: ReturnType<typeof useAgent<AgentT, State>>;
|
|
46
47
|
/** The `useAgentChat` value from `@cloudflare/think/react` used by the chat surface. */
|
|
47
48
|
chat: ReturnType<typeof useAgentChat<State, MessageT>>;
|
|
49
|
+
/**
|
|
50
|
+
* The `useSourceScopedAgentToolEvents(agent)` value for this connection.
|
|
51
|
+
* The app owns the subscription — mounted beside the `useAgent` call, since
|
|
52
|
+
* the server replays retained runs once per socket connect — so a run-detail
|
|
53
|
+
* route can read the same projection. ThinkFullApp never subscribes itself.
|
|
54
|
+
*/
|
|
55
|
+
agentTools: AgentToolEventsValue<MessageT["parts"][number]>;
|
|
48
56
|
}
|
|
49
57
|
interface ThinkFullAppProps<AgentT extends ThinkFullAppAgent<State>, State = unknown, MessageT extends UIMessage = UIMessage> extends React.HTMLAttributes<HTMLDivElement> {
|
|
50
58
|
/**
|
|
@@ -4,8 +4,8 @@ import { Button } from "../foundations/Button.js";
|
|
|
4
4
|
import { n as mergeRefs } from "../../merge-refs-DF_7w2x_.js";
|
|
5
5
|
import { ScrollArea } from "../foundations/ScrollArea.js";
|
|
6
6
|
import { McpPluginCatalog } from "./McpPluginCatalog.js";
|
|
7
|
-
import { c as resolveThinkApprovalProps, l as useSourceScopedAgentToolEvents, s as useThinkPendingExecutionApprovals, t as ThinkChat } from "../../ThinkChat-BIEryLy0.js";
|
|
8
7
|
import { a as WorkspaceNavigationRestorationBoundary, i as WorkspaceNavigationFocusRestorer, n as WorkspaceNavigationProvider } from "../../WorkspaceLink-DZeLe_jN.js";
|
|
8
|
+
import { c as resolveThinkApprovalProps, s as useThinkPendingExecutionApprovals, t as ThinkChat } from "../../ThinkChat-en0UbkVv.js";
|
|
9
9
|
import { AppTopBar } from "../general-purpose/AppTopBar.js";
|
|
10
10
|
import { useWorkspace } from "./Workspace.js";
|
|
11
11
|
import { WorkspaceExplorer } from "./WorkspaceExplorer.js";
|
|
@@ -49,8 +49,7 @@ function PluginsPanel({ config }) {
|
|
|
49
49
|
* Approval discovery and background-agent events need a live connection, so they
|
|
50
50
|
* live here rather than in the shell, which also renders before there is one.
|
|
51
51
|
*/
|
|
52
|
-
function ThinkFullAppThreadChat({ agent, chat, messages, renderAgentToolRunLink, sourceKey }) {
|
|
53
|
-
const agentTools = useSourceScopedAgentToolEvents(agent);
|
|
52
|
+
function ThinkFullAppThreadChat({ agent, agentTools, chat, messages, renderAgentToolRunLink, sourceKey }) {
|
|
54
53
|
const approvals = useThinkPendingExecutionApprovals(agent.stub, sourceKey, `${chat.messages.length}:${chat.status}`, messages?.approvalsEnabled !== false);
|
|
55
54
|
const resolvedMessages = React.useMemo(() => {
|
|
56
55
|
const approvalProps = resolveThinkApprovalProps({
|
|
@@ -15,6 +15,11 @@ interface AgentToolDetailProps<State = unknown, MessageT extends UIMessage = UIM
|
|
|
15
15
|
messages?: ThinkChatMessagesProps<MessageT>;
|
|
16
16
|
/** App-authored TanStack Router Link to the parent conversation. */
|
|
17
17
|
backLink?: React.ReactElement;
|
|
18
|
+
/**
|
|
19
|
+
* Route-owned run controls (the app's cancel callable, for example),
|
|
20
|
+
* rendered in a `SubagentRunActions` bar pinned to the bottom edge.
|
|
21
|
+
*/
|
|
22
|
+
actions?: React.ReactNode;
|
|
18
23
|
}
|
|
19
24
|
/**
|
|
20
25
|
* Live retained-child detail composed from upstream connection and chat values.
|
|
@@ -22,6 +27,7 @@ interface AgentToolDetailProps<State = unknown, MessageT extends UIMessage = UIM
|
|
|
22
27
|
* compact parent-side stream projection and is never promoted to fake history.
|
|
23
28
|
*/
|
|
24
29
|
declare function AgentToolDetail<State = unknown, MessageT extends UIMessage = UIMessage>({
|
|
30
|
+
actions,
|
|
25
31
|
backLink,
|
|
26
32
|
chat,
|
|
27
33
|
className,
|
|
@@ -41,17 +47,53 @@ interface SelectedAgentToolChildProps<ParentAgentT extends ThinkAgent<ParentStat
|
|
|
41
47
|
* configuration as the parent; the selected `run.subAgent` is appended.
|
|
42
48
|
*/
|
|
43
49
|
connectionOptions?: UseAgentOptions<ChildState>;
|
|
50
|
+
/**
|
|
51
|
+
* Initial child-transcript loader for hosts that do not serve the agent HTTP
|
|
52
|
+
* routes (upstream's default fetches `/get-messages` over HTTP). Receives the
|
|
53
|
+
* connected child agent so socket-only hosts can read through its stub;
|
|
54
|
+
* wired into `useAgentChat({ getInitialMessages })`.
|
|
55
|
+
*/
|
|
56
|
+
getInitialMessages?: (childAgent: ReturnType<typeof useAgent<ThinkAgent<ChildState>, ChildState>>) => Promise<MessageT[]>;
|
|
44
57
|
messages?: ThinkChatMessagesProps<MessageT>;
|
|
45
58
|
/** App-authored TanStack Router Link to the parent conversation. */
|
|
46
59
|
backLink?: React.ReactElement;
|
|
60
|
+
/** Rendered while the child transcript loads (the internal Suspense fallback). */
|
|
61
|
+
fallback?: React.ReactNode;
|
|
62
|
+
/** Route-owned run controls, forwarded to `AgentToolDetail`'s pinned actions bar. */
|
|
63
|
+
actions?: React.ReactNode;
|
|
47
64
|
}
|
|
48
|
-
/**
|
|
65
|
+
/**
|
|
66
|
+
* Child connection options for a selected retained run: the parent's
|
|
67
|
+
* root-first base (or the app-supplied options) with the run's sub-agent step
|
|
68
|
+
* appended to the sub path.
|
|
69
|
+
*/
|
|
70
|
+
declare function selectedAgentToolChildOptions<ChildState = unknown>(parentAgent: {
|
|
71
|
+
agent: string;
|
|
72
|
+
name: string;
|
|
73
|
+
path: ReadonlyArray<{
|
|
74
|
+
agent: string;
|
|
75
|
+
name: string;
|
|
76
|
+
}>;
|
|
77
|
+
}, run: Pick<AgentToolRunState, "subAgent">, connectionOptions?: UseAgentOptions<ChildState>): UseAgentOptions<ChildState>;
|
|
78
|
+
/**
|
|
79
|
+
* Lazily connects one selected retained child and renders its real Think chat.
|
|
80
|
+
*
|
|
81
|
+
* The Suspense boundary between the connection and the chat is load-bearing:
|
|
82
|
+
* the child socket opens in an effect, and `useAgentChat` suspends while the
|
|
83
|
+
* initial transcript loads. Under one suspension the render never commits, the
|
|
84
|
+
* effect never runs, and the socket the load is waiting on never dials — so
|
|
85
|
+
* this component holds the connection and always commits, while the chat
|
|
86
|
+
* suspends behind the internal boundary.
|
|
87
|
+
*/
|
|
49
88
|
declare function SelectedAgentToolChild<ParentAgentT extends ThinkAgent<ParentState>, ParentState = unknown, ChildState = unknown, MessageT extends UIMessage = UIMessage>({
|
|
89
|
+
actions,
|
|
50
90
|
backLink,
|
|
51
91
|
connectionOptions,
|
|
92
|
+
fallback,
|
|
93
|
+
getInitialMessages,
|
|
52
94
|
messages,
|
|
53
95
|
parentAgent,
|
|
54
96
|
run
|
|
55
97
|
}: SelectedAgentToolChildProps<ParentAgentT, ParentState, ChildState, MessageT>): React.JSX.Element;
|
|
56
98
|
//#endregion
|
|
57
|
-
export { AgentToolDetail, AgentToolDetailProps, SelectedAgentToolChild, SelectedAgentToolChildProps };
|
|
99
|
+
export { AgentToolDetail, AgentToolDetailProps, SelectedAgentToolChild, SelectedAgentToolChildProps, selectedAgentToolChildOptions };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { t as cx } from "../../class-names-BiMDVpUo.js";
|
|
2
2
|
import { r as ArrowLeftIcon } from "../../icons-B1Qw05te.js";
|
|
3
3
|
import { TransitionSurface } from "../foundations/TransitionSurface.js";
|
|
4
|
-
import { SubagentRunMilestone, SubagentRunMilestones, SubagentRunProgress } from "../agents-sdk/SubagentRunDetails.js";
|
|
4
|
+
import { SubagentRunActions, SubagentRunMilestone, SubagentRunMilestones, SubagentRunProgress } from "../agents-sdk/SubagentRunDetails.js";
|
|
5
5
|
import { SubagentRunIndicator, getSubagentRunName } from "../agents-sdk/SubagentRunIndicator.js";
|
|
6
|
-
import { t as ThinkChat } from "../../ThinkChat-
|
|
6
|
+
import { t as ThinkChat } from "../../ThinkChat-en0UbkVv.js";
|
|
7
7
|
import { AppTopBar } from "../general-purpose/AppTopBar.js";
|
|
8
8
|
import { NaniteMark } from "./NaniteScene.js";
|
|
9
9
|
import * as React from "react";
|
|
@@ -16,7 +16,7 @@ import { useAgent } from "agents/react";
|
|
|
16
16
|
* The full child transcript comes from `chat.messages`; `run.parts` remains a
|
|
17
17
|
* compact parent-side stream projection and is never promoted to fake history.
|
|
18
18
|
*/
|
|
19
|
-
function AgentToolDetail({ backLink, chat, className, messages, ref, run, ...props }) {
|
|
19
|
+
function AgentToolDetail({ actions, backLink, chat, className, messages, ref, run, ...props }) {
|
|
20
20
|
const backRef = React.useRef(null);
|
|
21
21
|
const name = getSubagentRunName(run);
|
|
22
22
|
const progressLabel = run.progress?.message ?? run.progress?.phase;
|
|
@@ -76,25 +76,61 @@ function AgentToolDetail({ backLink, chat, className, messages, ref, run, ...pro
|
|
|
76
76
|
showComposer: false
|
|
77
77
|
})
|
|
78
78
|
})
|
|
79
|
-
})
|
|
79
|
+
}),
|
|
80
|
+
actions ? /* @__PURE__ */ jsx(SubagentRunActions, { children: actions }) : null
|
|
80
81
|
]
|
|
81
82
|
});
|
|
82
83
|
}
|
|
83
|
-
/**
|
|
84
|
-
|
|
84
|
+
/**
|
|
85
|
+
* Child connection options for a selected retained run: the parent's
|
|
86
|
+
* root-first base (or the app-supplied options) with the run's sub-agent step
|
|
87
|
+
* appended to the sub path.
|
|
88
|
+
*/
|
|
89
|
+
function selectedAgentToolChildOptions(parentAgent, run, connectionOptions) {
|
|
85
90
|
const [root, ...parentSubPath] = parentAgent.path;
|
|
91
|
+
return {
|
|
92
|
+
...connectionOptions ?? {
|
|
93
|
+
agent: root?.agent ?? parentAgent.agent,
|
|
94
|
+
name: root?.name ?? parentAgent.name
|
|
95
|
+
},
|
|
96
|
+
sub: [...connectionOptions?.sub ?? parentSubPath, run.subAgent]
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Lazily connects one selected retained child and renders its real Think chat.
|
|
101
|
+
*
|
|
102
|
+
* The Suspense boundary between the connection and the chat is load-bearing:
|
|
103
|
+
* the child socket opens in an effect, and `useAgentChat` suspends while the
|
|
104
|
+
* initial transcript loads. Under one suspension the render never commits, the
|
|
105
|
+
* effect never runs, and the socket the load is waiting on never dials — so
|
|
106
|
+
* this component holds the connection and always commits, while the chat
|
|
107
|
+
* suspends behind the internal boundary.
|
|
108
|
+
*/
|
|
109
|
+
function SelectedAgentToolChild({ actions, backLink, connectionOptions, fallback, getInitialMessages, messages, parentAgent, run }) {
|
|
110
|
+
const childAgent = useAgent(selectedAgentToolChildOptions(parentAgent, run, connectionOptions));
|
|
111
|
+
return /* @__PURE__ */ jsx(React.Suspense, {
|
|
112
|
+
fallback: fallback ?? null,
|
|
113
|
+
children: /* @__PURE__ */ jsx(SelectedAgentToolChildChat, {
|
|
114
|
+
actions,
|
|
115
|
+
backLink,
|
|
116
|
+
childAgent,
|
|
117
|
+
getInitialMessages,
|
|
118
|
+
messages,
|
|
119
|
+
run
|
|
120
|
+
}, run.runId)
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
function SelectedAgentToolChildChat({ actions, backLink, childAgent, getInitialMessages, messages, run }) {
|
|
86
124
|
return /* @__PURE__ */ jsx(AgentToolDetail, {
|
|
87
125
|
run,
|
|
88
|
-
chat: useAgentChat({
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
},
|
|
93
|
-
sub: [...connectionOptions?.sub ?? parentSubPath, run.subAgent]
|
|
94
|
-
}) }),
|
|
126
|
+
chat: useAgentChat({
|
|
127
|
+
agent: childAgent,
|
|
128
|
+
...getInitialMessages ? { getInitialMessages: () => getInitialMessages(childAgent) } : {}
|
|
129
|
+
}),
|
|
95
130
|
messages,
|
|
96
|
-
backLink
|
|
97
|
-
|
|
131
|
+
backLink,
|
|
132
|
+
actions
|
|
133
|
+
});
|
|
98
134
|
}
|
|
99
135
|
//#endregion
|
|
100
|
-
export { AgentToolDetail, SelectedAgentToolChild };
|
|
136
|
+
export { AgentToolDetail, SelectedAgentToolChild, selectedAgentToolChildOptions };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
.agent-tool-detail {
|
|
2
2
|
display: grid;
|
|
3
|
-
grid-template-rows: auto auto minmax(0, 1fr);
|
|
3
|
+
grid-template-rows: auto auto minmax(0, 1fr) auto;
|
|
4
4
|
min-inline-size: 0;
|
|
5
5
|
block-size: 100%;
|
|
6
6
|
background-color: var(--sigvelo-color-surface);
|
|
@@ -47,8 +47,18 @@
|
|
|
47
47
|
block-size: 100%;
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
+
.agent-tool-detail > .subagent-run__actions {
|
|
51
|
+
grid-row: 4;
|
|
52
|
+
display: flex;
|
|
53
|
+
justify-content: center;
|
|
54
|
+
padding: var(--sigvelo-spacing-2) var(--sigvelo-spacing-3);
|
|
55
|
+
border-block-start: var(--sigvelo-border-width) var(--sigvelo-border-style)
|
|
56
|
+
var(--sigvelo-color-neutral-border-subtle);
|
|
57
|
+
}
|
|
58
|
+
|
|
50
59
|
@media (forced-colors: active) {
|
|
51
|
-
.agent-tool-detail__run-state
|
|
60
|
+
.agent-tool-detail__run-state,
|
|
61
|
+
.agent-tool-detail > .subagent-run__actions {
|
|
52
62
|
border-color: CanvasText;
|
|
53
63
|
}
|
|
54
64
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mcp-b/react-components",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.34.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": {
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"streamdown": "^2.5.0",
|
|
59
59
|
"unist-util-visit": "^5.1.0",
|
|
60
60
|
"yet-another-react-lightbox": "^3.32.1",
|
|
61
|
-
"@mcp-b/design-tokens": "0.
|
|
61
|
+
"@mcp-b/design-tokens": "0.34.0"
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
64
64
|
"@ai-sdk/react": "^3.0.230",
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import { UIMessage } from "ai";
|
|
3
|
-
import { useAgentToolEvents } from "agents/react";
|
|
4
|
-
import { AgentToolRunPart } from "agents/agent-tools";
|
|
5
|
-
|
|
6
|
-
//#region src/components/agents-sdk/AgentToolRunsContext.d.ts
|
|
7
|
-
/** The complete upstream retained-run hook result for one parent connection. */
|
|
8
|
-
type AgentToolEventsValue<Part extends AgentToolRunPart = UIMessage["parts"][number]> = ReturnType<typeof useAgentToolEvents<Part>>;
|
|
9
|
-
interface AgentToolRunsProviderProps<Part extends AgentToolRunPart = UIMessage["parts"][number]> {
|
|
10
|
-
/** Pass the whole `useAgentToolEvents({ agent })` result directly. */
|
|
11
|
-
agentTools: AgentToolEventsValue<Part>;
|
|
12
|
-
children: React.ReactNode;
|
|
13
|
-
}
|
|
14
|
-
/** Provides one parent connection's retained Agent Tool event projection. */
|
|
15
|
-
declare function AgentToolRunsProvider<Part extends AgentToolRunPart = UIMessage["parts"][number]>({
|
|
16
|
-
agentTools,
|
|
17
|
-
children
|
|
18
|
-
}: AgentToolRunsProviderProps<Part>): React.JSX.Element;
|
|
19
|
-
declare function useOptionalAgentToolRuns<Part extends AgentToolRunPart = UIMessage["parts"][number]>(): AgentToolEventsValue<Part> | null;
|
|
20
|
-
//#endregion
|
|
21
|
-
export { useOptionalAgentToolRuns as i, AgentToolRunsProvider as n, AgentToolRunsProviderProps as r, AgentToolEventsValue as t };
|