@mcp-b/react-components 0.32.0 → 0.33.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 +14 -1
- package/dist/components/nanites/AgentToolDetail.js +18 -10
- 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({
|
|
@@ -45,6 +45,19 @@ interface SelectedAgentToolChildProps<ParentAgentT extends ThinkAgent<ParentStat
|
|
|
45
45
|
/** App-authored TanStack Router Link to the parent conversation. */
|
|
46
46
|
backLink?: React.ReactElement;
|
|
47
47
|
}
|
|
48
|
+
/**
|
|
49
|
+
* Child connection options for a selected retained run: the parent's
|
|
50
|
+
* root-first base (or the app-supplied options) with the run's sub-agent step
|
|
51
|
+
* appended to the sub path.
|
|
52
|
+
*/
|
|
53
|
+
declare function selectedAgentToolChildOptions<ChildState = unknown>(parentAgent: {
|
|
54
|
+
agent: string;
|
|
55
|
+
name: string;
|
|
56
|
+
path: ReadonlyArray<{
|
|
57
|
+
agent: string;
|
|
58
|
+
name: string;
|
|
59
|
+
}>;
|
|
60
|
+
}, run: Pick<AgentToolRunState, "subAgent">, connectionOptions?: UseAgentOptions<ChildState>): UseAgentOptions<ChildState>;
|
|
48
61
|
/** Lazily connects one selected retained child and renders its real Think chat. */
|
|
49
62
|
declare function SelectedAgentToolChild<ParentAgentT extends ThinkAgent<ParentState>, ParentState = unknown, ChildState = unknown, MessageT extends UIMessage = UIMessage>({
|
|
50
63
|
backLink,
|
|
@@ -54,4 +67,4 @@ declare function SelectedAgentToolChild<ParentAgentT extends ThinkAgent<ParentSt
|
|
|
54
67
|
run
|
|
55
68
|
}: SelectedAgentToolChildProps<ParentAgentT, ParentState, ChildState, MessageT>): React.JSX.Element;
|
|
56
69
|
//#endregion
|
|
57
|
-
export { AgentToolDetail, AgentToolDetailProps, SelectedAgentToolChild, SelectedAgentToolChildProps };
|
|
70
|
+
export { AgentToolDetail, AgentToolDetailProps, SelectedAgentToolChild, SelectedAgentToolChildProps, selectedAgentToolChildOptions };
|
|
@@ -3,7 +3,7 @@ import { r as ArrowLeftIcon } from "../../icons-B1Qw05te.js";
|
|
|
3
3
|
import { TransitionSurface } from "../foundations/TransitionSurface.js";
|
|
4
4
|
import { 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";
|
|
@@ -80,21 +80,29 @@ function AgentToolDetail({ backLink, chat, className, messages, ref, run, ...pro
|
|
|
80
80
|
]
|
|
81
81
|
});
|
|
82
82
|
}
|
|
83
|
+
/**
|
|
84
|
+
* Child connection options for a selected retained run: the parent's
|
|
85
|
+
* root-first base (or the app-supplied options) with the run's sub-agent step
|
|
86
|
+
* appended to the sub path.
|
|
87
|
+
*/
|
|
88
|
+
function selectedAgentToolChildOptions(parentAgent, run, connectionOptions) {
|
|
89
|
+
const [root, ...parentSubPath] = parentAgent.path;
|
|
90
|
+
return {
|
|
91
|
+
...connectionOptions ?? {
|
|
92
|
+
agent: root?.agent ?? parentAgent.agent,
|
|
93
|
+
name: root?.name ?? parentAgent.name
|
|
94
|
+
},
|
|
95
|
+
sub: [...connectionOptions?.sub ?? parentSubPath, run.subAgent]
|
|
96
|
+
};
|
|
97
|
+
}
|
|
83
98
|
/** Lazily connects one selected retained child and renders its real Think chat. */
|
|
84
99
|
function SelectedAgentToolChild({ backLink, connectionOptions, messages, parentAgent, run }) {
|
|
85
|
-
const [root, ...parentSubPath] = parentAgent.path;
|
|
86
100
|
return /* @__PURE__ */ jsx(AgentToolDetail, {
|
|
87
101
|
run,
|
|
88
|
-
chat: useAgentChat({ agent: useAgent(
|
|
89
|
-
...connectionOptions ?? {
|
|
90
|
-
agent: root?.agent ?? parentAgent.agent,
|
|
91
|
-
name: root?.name ?? parentAgent.name
|
|
92
|
-
},
|
|
93
|
-
sub: [...connectionOptions?.sub ?? parentSubPath, run.subAgent]
|
|
94
|
-
}) }),
|
|
102
|
+
chat: useAgentChat({ agent: useAgent(selectedAgentToolChildOptions(parentAgent, run, connectionOptions)) }),
|
|
95
103
|
messages,
|
|
96
104
|
backLink
|
|
97
105
|
}, run.runId);
|
|
98
106
|
}
|
|
99
107
|
//#endregion
|
|
100
|
-
export { AgentToolDetail, SelectedAgentToolChild };
|
|
108
|
+
export { AgentToolDetail, SelectedAgentToolChild, selectedAgentToolChildOptions };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mcp-b/react-components",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.33.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.33.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 };
|