@mcp-b/react-components 0.48.0 → 0.49.1
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/AgentChatQueue-v5890eA1.d.ts +48 -0
- package/dist/AgentToolRunsContext-GMe_hSnD.d.ts +35 -0
- package/dist/Avatar-o2NO1fCG.d.ts +124 -0
- package/dist/{Button-CZt3yywF.d.ts → Button-DjONW5UW.d.ts} +1 -1
- package/dist/{CodeBlock-C380GD5t.d.ts → CodeBlock--r6GS8YV.d.ts} +8 -2
- package/dist/{CodeBlock-BSJl682D.js → CodeBlock-g8sADidM.js} +8 -8
- package/dist/{FileTree-DvE0hNZu.js → FileTree-DruTQ-oa.js} +38 -36
- package/dist/{IconButton-BAUFhUk8.d.ts → IconButton-ByiyjkYE.d.ts} +2 -2
- package/dist/{Menu-yb6QXWA3.d.ts → Menu-CgfUZhZd.d.ts} +1 -1
- package/dist/{Message-D_vCVEGB.d.ts → Message-DyaTBiV7.d.ts} +17 -4
- package/dist/MessageScrollerVirtual-D4afYwVB.d.ts +84 -0
- package/dist/{PromptInput-DtJHyp0S.d.ts → PromptInput-4kCz3T9P.d.ts} +45 -32
- package/dist/PromptInputApproval-D2hpn54U.d.ts +44 -0
- package/dist/Separator-CzhtLYE1.d.ts +41 -0
- package/dist/Toolbar-CGY004u0.d.ts +155 -0
- package/dist/{Workspace-LIoU30n7.d.ts → Workspace-HzGrWDX3.d.ts} +1 -1
- package/dist/{WorkspaceFile-Dq-GC0_T.d.ts → WorkspaceFile-Bouauobc.d.ts} +1 -1
- package/dist/{WorkspaceFileView-C_WnYm-a.js → WorkspaceFileView-DYPtRVpM.js} +5 -4
- package/dist/{WorkspaceLink-B1d2GIGl.js → WorkspaceLink-BYZG-V_I.js} +8 -91
- package/dist/{WorkspaceMessageResponse-BqOezptB.js → WorkspaceMessageResponse-CUJk9_P5.js} +2 -2
- package/dist/components/agents-sdk/AgentActivity.js +1 -1
- package/dist/components/agents-sdk/AgentChat.d.ts +198 -2
- package/dist/components/agents-sdk/AgentChat.js +527 -672
- package/dist/components/agents-sdk/AgentChatQueue.d.ts +2 -0
- package/dist/components/agents-sdk/AgentChatQueue.js +206 -0
- package/dist/components/agents-sdk/AgentEvent.js +2 -2
- package/dist/components/agents-sdk/AgentToolRunsContext.d.ts +2 -2
- package/dist/components/agents-sdk/AgentToolRunsContext.js +1 -36
- package/dist/components/agents-sdk/BrowserLiveScreen.js +22 -14
- package/dist/components/agents-sdk/BrowserLiveView.js +1 -1
- package/dist/components/agents-sdk/BrowserReplay.d.ts +1 -1
- package/dist/components/agents-sdk/BrowserReplay.js +1 -1
- package/dist/components/agents-sdk/BrowserRunPanel.d.ts +3 -0
- package/dist/components/agents-sdk/BrowserRunPanel.js +32 -31
- package/dist/components/agents-sdk/EmployeeChrome.d.ts +212 -0
- package/dist/components/agents-sdk/EmployeeChrome.js +555 -0
- package/dist/components/agents-sdk/ManagerOffice.d.ts +79 -40
- package/dist/components/agents-sdk/ManagerOffice.js +291 -281
- package/dist/components/agents-sdk/McpConnectionRequest.d.ts +4 -4
- package/dist/components/agents-sdk/McpConnectionRequest.js +4 -3
- package/dist/components/agents-sdk/McpConnectorForm.d.ts +38 -1
- package/dist/components/agents-sdk/McpConnectorForm.js +1 -1
- package/dist/components/agents-sdk/McpPluginCatalog.d.ts +93 -1
- package/dist/components/agents-sdk/McpPluginCatalog.js +5 -4
- package/dist/components/agents-sdk/McpServerIcon.d.ts +17 -0
- package/dist/components/agents-sdk/McpServerIcon.js +25 -0
- package/dist/components/agents-sdk/McpServerPicker.d.ts +5 -4
- package/dist/components/agents-sdk/McpServerPicker.js +4 -3
- package/dist/components/agents-sdk/ModelSelector.d.ts +4 -4
- package/dist/components/agents-sdk/ModelSelector.js +4 -4
- package/dist/components/agents-sdk/PromptInputApproval.d.ts +1 -43
- package/dist/components/agents-sdk/PromptInputApproval.js +1 -1
- package/dist/components/agents-sdk/PromptInputCommands.d.ts +1 -1
- package/dist/components/agents-sdk/PromptInputCommands.js +2 -3
- package/dist/components/agents-sdk/SessionCompaction.d.ts +88 -1
- package/dist/components/agents-sdk/SessionCompaction.js +2 -2
- package/dist/components/agents-sdk/SubagentRunDetails.d.ts +30 -1
- package/dist/components/agents-sdk/SubagentRunDetails.js +57 -1
- package/dist/components/agents-sdk/SubagentRunIndicator.d.ts +9 -9
- package/dist/components/agents-sdk/SubagentRunIndicator.js +19 -24
- package/dist/components/agents-sdk/SubagentRunList.d.ts +6 -3
- package/dist/components/agents-sdk/SubagentRunList.js +4 -2
- package/dist/components/agents-sdk/SubagentRunPanel.d.ts +60 -0
- package/dist/components/agents-sdk/SubagentRunPanel.js +255 -0
- package/dist/components/agents-sdk/SubagentRunSelector.d.ts +8 -4
- package/dist/components/agents-sdk/SubagentRunSelector.js +5 -3
- package/dist/components/agents-sdk/ThinkChat.d.ts +102 -2
- package/dist/components/agents-sdk/ThinkChat.js +233 -2
- package/dist/components/agents-sdk/ThinkChatActivity.d.ts +76 -1
- package/dist/components/agents-sdk/ThinkChatActivity.js +18 -10
- package/dist/components/agents-sdk/ThinkChatContext.d.ts +27 -1
- package/dist/components/agents-sdk/ThinkChatContext.js +1 -1
- package/dist/components/agents-sdk/ThinkChatToolPanels.js +24 -19
- package/dist/components/agents-sdk/ThinkExecutionDetail.js +2 -2
- package/dist/components/agents-sdk/ThinkExecutionStatus.d.ts +1 -1
- package/dist/components/agents-sdk/ThinkExecutionStatus.js +1 -1
- package/dist/components/agents-sdk/ThinkExecutionWorkbench.d.ts +85 -28
- package/dist/components/agents-sdk/ThinkExecutionWorkbench.js +159 -102
- package/dist/components/agents-sdk/ThinkFullApp.d.ts +40 -158
- package/dist/components/agents-sdk/ThinkFullApp.js +71 -290
- package/dist/components/agents-sdk/ThinkRecoveryNotice.d.ts +18 -1
- package/dist/components/agents-sdk/ThinkRecoveryNotice.js +1 -1
- package/dist/components/agents-sdk/ThinkRoutineActions.d.ts +51 -0
- package/dist/components/agents-sdk/ThinkRoutineActions.js +201 -0
- package/dist/components/agents-sdk/ThinkRoutineBrowser.d.ts +4 -1
- package/dist/components/agents-sdk/ThinkRoutineBrowser.js +17 -15
- package/dist/components/agents-sdk/ThinkRoutineDetail.js +11 -11
- package/dist/components/agents-sdk/ThinkRoutineForm.d.ts +2 -1
- package/dist/components/agents-sdk/ThinkRoutineForm.js +14 -14
- package/dist/components/agents-sdk/ThinkRoutineRuns.js +7 -7
- package/dist/components/agents-sdk/ThinkThreadPicker.d.ts +90 -1
- package/dist/components/agents-sdk/ThinkThreadPicker.js +3 -3
- package/dist/components/agents-sdk/Workspace.d.ts +1 -1
- package/dist/components/agents-sdk/Workspace.js +7 -13
- package/dist/components/agents-sdk/WorkspaceBrowser.d.ts +1 -1
- package/dist/components/agents-sdk/WorkspaceBrowser.js +1 -1
- package/dist/components/agents-sdk/WorkspaceConcept.d.ts +1 -1
- package/dist/components/agents-sdk/WorkspaceCorrespondence.d.ts +10 -1
- package/dist/components/agents-sdk/WorkspaceCorrespondence.js +10 -7
- package/dist/components/agents-sdk/WorkspaceExecution.d.ts +5 -14
- package/dist/components/agents-sdk/WorkspaceExecution.js +24 -38
- package/dist/components/agents-sdk/WorkspaceExplorer.d.ts +5 -2
- package/dist/components/agents-sdk/WorkspaceExplorer.js +3 -2
- package/dist/components/agents-sdk/WorkspaceFile.d.ts +1 -1
- package/dist/components/agents-sdk/WorkspaceFileView.d.ts +1 -1
- package/dist/components/agents-sdk/WorkspaceFileView.js +1 -1
- package/dist/components/agents-sdk/WorkspaceHeader.js +1 -1
- package/dist/components/agents-sdk/WorkspaceLink.js +1 -1
- package/dist/components/agents-sdk/WorkspaceLive.d.ts +60 -1
- package/dist/components/agents-sdk/WorkspaceMessageResponse.d.ts +47 -1
- package/dist/components/agents-sdk/WorkspaceMessageResponse.js +1 -1
- package/dist/components/agents-sdk/WorkspaceMountManager.d.ts +3 -2
- package/dist/components/agents-sdk/WorkspaceMountManager.js +6 -9
- package/dist/components/agents-sdk/WorkspaceNavigationRestoration.d.ts +38 -0
- package/dist/components/agents-sdk/WorkspaceNavigationRestoration.js +86 -0
- package/dist/components/agents-sdk/WorkspaceProject.d.ts +5 -14
- package/dist/components/agents-sdk/WorkspaceProject.js +21 -35
- package/dist/components/agents-sdk/WorkspaceUserScript.d.ts +1 -1
- package/dist/components/agents-sdk/WorkspaceUserScript.js +8 -5
- package/dist/components/ai-sdk/Activity.d.ts +1 -1
- package/dist/components/ai-sdk/Activity.js +1 -1
- package/dist/components/ai-sdk/AgentAttention.d.ts +2 -2
- package/dist/components/ai-sdk/AgentChatMessageEditor.js +5 -1
- package/dist/components/ai-sdk/AgentChatStartScreen.d.ts +89 -2
- package/dist/components/ai-sdk/AgentChatStartScreen.js +64 -43
- package/dist/components/ai-sdk/AgentMessageParts.d.ts +45 -1
- package/dist/components/ai-sdk/Approval.d.ts +1 -1
- package/dist/components/ai-sdk/Approval.js +2 -2
- package/dist/components/ai-sdk/Artifact.d.ts +2 -2
- package/dist/components/ai-sdk/Artifact.js +1 -1
- package/dist/components/ai-sdk/ChainOfThought.d.ts +1 -1
- package/dist/components/ai-sdk/ChainOfThought.js +1 -1
- package/dist/components/ai-sdk/Checkpoint.js +1 -1
- package/dist/components/ai-sdk/CodeBlock.d.ts +1 -1
- package/dist/components/ai-sdk/CodeBlock.js +1 -1
- package/dist/components/ai-sdk/ComposerLink.js +2 -3
- package/dist/components/ai-sdk/ConnectedAppCards.d.ts +9 -1
- package/dist/components/ai-sdk/ConnectedAppCards.js +28 -21
- package/dist/components/ai-sdk/Context.d.ts +7 -3
- package/dist/components/ai-sdk/Context.js +7 -17
- package/dist/components/ai-sdk/Conversation.d.ts +2 -2
- package/dist/components/ai-sdk/Conversation.js +1 -1
- package/dist/components/ai-sdk/Goal.d.ts +3 -3
- package/dist/components/ai-sdk/Goal.js +3 -3
- package/dist/components/ai-sdk/InlineCitation.d.ts +1 -1
- package/dist/components/ai-sdk/MediaPreviewCard.d.ts +1 -1
- package/dist/components/ai-sdk/MediaPreviewCard.js +1 -1
- package/dist/components/ai-sdk/Message.d.ts +2 -2
- package/dist/components/ai-sdk/Message.js +12 -3
- package/dist/components/ai-sdk/MessageScroller.d.ts +1 -1
- package/dist/components/ai-sdk/MessageScroller.js +1 -1
- package/dist/components/ai-sdk/MessageScrollerVirtual.d.ts +2 -76
- package/dist/components/ai-sdk/MessageScrollerVirtual.js +40 -5
- package/dist/components/ai-sdk/Plan.d.ts +1 -1
- package/dist/components/ai-sdk/Plan.js +1 -1
- package/dist/components/ai-sdk/PromptInput.d.ts +2 -2
- package/dist/components/ai-sdk/PromptInput.js +175 -231
- package/dist/components/ai-sdk/PromptInputComposerEditor.js +32 -9
- package/dist/components/ai-sdk/Queue.d.ts +28 -5
- package/dist/components/ai-sdk/Queue.js +20 -5
- package/dist/components/ai-sdk/Reasoning.d.ts +1 -1
- package/dist/components/ai-sdk/Reasoning.js +5 -5
- package/dist/components/ai-sdk/Sources.d.ts +1 -1
- package/dist/components/ai-sdk/Sources.js +1 -1
- package/dist/components/ai-sdk/Task.d.ts +1 -1
- package/dist/components/ai-sdk/Task.js +1 -1
- package/dist/components/extension/ChatGptSignInScreen.d.ts +1 -1
- package/dist/components/extension/ChatGptSignInScreen.js +1 -1
- package/dist/components/extension/CodexModelSelector.d.ts +6 -1
- package/dist/components/extension/CodexModelSelector.js +3 -3
- package/dist/components/extension/ConversationTabPicker.d.ts +1 -0
- package/dist/components/extension/ConversationTabPicker.js +2 -2
- package/dist/components/foundations/AlertDialog.d.ts +1 -1
- package/dist/components/foundations/AppIcon.d.ts +3 -2
- package/dist/components/foundations/Autocomplete.js +6 -1
- package/dist/components/foundations/Avatar.d.ts +1 -121
- package/dist/components/foundations/Button.d.ts +1 -1
- package/dist/components/foundations/Card.d.ts +22 -27
- package/dist/components/foundations/Card.js +51 -32
- package/dist/components/foundations/Checkbox.js +1 -1
- package/dist/components/foundations/CheckboxGroup.d.ts +1 -1
- package/dist/components/foundations/Collapsible.d.ts +1 -1
- package/dist/components/foundations/Collapsible.js +1 -1
- package/dist/components/foundations/Combobox.js +6 -1
- package/dist/components/foundations/ContextMenu.d.ts +10 -23
- package/dist/components/foundations/ContextMenu.js +3 -2
- package/dist/components/foundations/Dialog.d.ts +106 -1
- package/dist/components/foundations/EmptyState.d.ts +1 -1
- package/dist/components/foundations/Field.d.ts +2 -1
- package/dist/components/foundations/Fieldset.d.ts +1 -1
- package/dist/components/foundations/Form.d.ts +4 -4
- package/dist/components/foundations/IconButton.d.ts +1 -1
- package/dist/components/foundations/Label.d.ts +1 -1
- package/dist/components/foundations/LinkButton.d.ts +2 -2
- package/dist/components/foundations/Menu.d.ts +1 -1
- package/dist/components/foundations/Menubar.d.ts +1 -1
- package/dist/components/foundations/Menubar.js +1 -1
- package/dist/components/foundations/Meter.d.ts +1 -1
- package/dist/components/foundations/NumberField.d.ts +1 -1
- package/dist/components/foundations/PreviewCard.d.ts +1 -1
- package/dist/components/foundations/ScrollArea.d.ts +1 -1
- package/dist/components/foundations/SearchField.d.ts +1 -1
- package/dist/components/foundations/SearchField.js +1 -1
- package/dist/components/foundations/Select.js +7 -2
- package/dist/components/foundations/Separator.d.ts +1 -40
- package/dist/components/foundations/Stepper.d.ts +1 -1
- package/dist/components/foundations/Stepper.js +1 -1
- package/dist/components/foundations/Textarea.d.ts +1 -1
- package/dist/components/foundations/Toast.d.ts +5 -1
- package/dist/components/foundations/Toast.js +1 -1
- package/dist/components/foundations/Toggle.d.ts +70 -1
- package/dist/components/foundations/ToggleGroup.d.ts +4 -3
- package/dist/components/foundations/ToggleGroup.js +1 -1
- package/dist/components/foundations/Toolbar.d.ts +1 -151
- package/dist/components/foundations/Tooltip.d.ts +1 -1
- package/dist/components/foundations/TransitionSurface.d.ts +1 -1
- package/dist/components/foundations/icons.js +1 -1
- package/dist/components/general-purpose/ActionGuide.d.ts +10 -26
- package/dist/components/general-purpose/ActionGuide.js +4 -18
- package/dist/components/general-purpose/AppTopBar.d.ts +4 -2
- package/dist/components/general-purpose/Commit.d.ts +2 -2
- package/dist/components/general-purpose/Commit.js +2 -2
- package/dist/components/general-purpose/EnvironmentVariables.d.ts +2 -2
- package/dist/components/general-purpose/EnvironmentVariables.js +2 -2
- package/dist/components/general-purpose/FileTree.d.ts +1 -7
- package/dist/components/general-purpose/FileTree.js +1 -1
- package/dist/components/general-purpose/PricingPlanCard.d.ts +4 -0
- package/dist/components/general-purpose/PricingPlanCard.js +2 -2
- package/dist/components/general-purpose/PricingUsageCalculator.js +2 -2
- package/dist/components/general-purpose/ResizableSidePanel.d.ts +2 -2
- package/dist/components/general-purpose/ResponsiveSidebarShell.d.ts +128 -2
- package/dist/components/general-purpose/ResponsiveSidebarShell.js +120 -102
- package/dist/components/general-purpose/SettingsFormDialog.d.ts +14 -27
- package/dist/components/general-purpose/SettingsFormDialog.js +42 -72
- package/dist/components/general-purpose/SetupChecklist.d.ts +1 -0
- package/dist/components/general-purpose/SetupChecklist.js +76 -1
- package/dist/components/general-purpose/Terminal.d.ts +3 -3
- package/dist/components/general-purpose/Terminal.js +11 -6
- package/dist/components/general-purpose/TestResults.d.ts +23 -11
- package/dist/components/general-purpose/TestResults.js +49 -51
- package/dist/components/general-purpose/ThemeModeControl.d.ts +2 -0
- package/dist/components/general-purpose/ThemeModeControl.js +2 -2
- package/dist/components/general-purpose/WebPreview.d.ts +29 -4
- package/dist/components/general-purpose/WebPreview.js +39 -14
- package/dist/components/nanites/AgentConnection.js +2 -2
- package/dist/components/nanites/AgentToolDetail.d.ts +13 -11
- package/dist/components/nanites/AgentToolDetail.js +21 -42
- package/dist/{copy-button-Dk2vRe9j.js → copy-button-CSDuDfdP.js} +1 -1
- package/dist/{copy-button-C0JyjClr.d.ts → copy-button-OUwOdgEm.d.ts} +1 -1
- package/dist/mcp-server-mAErsxHU.js +27 -0
- package/dist/styles/accessibility.css +20 -0
- package/dist/styles/activity.css +1 -96
- package/dist/styles/agent-chat.css +75 -102
- package/dist/styles/agent-tool-detail.css +0 -16
- package/dist/styles/base.css +1 -9
- package/dist/styles/browser-run-panel.css +1 -15
- package/dist/styles/button.css +7 -1
- package/dist/styles/code-block.css +12 -0
- package/dist/styles/codex-model-selector.css +4 -0
- package/dist/styles/color-contrast.test.ts +212 -0
- package/dist/styles/composition-motion.css +0 -2
- package/dist/styles/employee-chrome.css +43 -0
- package/dist/styles/file-tree.css +10 -1
- package/dist/styles/index.css +4 -2
- package/dist/styles/manager-office.css +5 -5
- package/dist/styles/message.css +2 -10
- package/dist/styles/queue.css +71 -0
- package/dist/styles/responsive-sidebar-shell.css +1 -1
- package/dist/styles/subagent-run.css +122 -6
- package/dist/styles/test-results.css +2 -5
- package/dist/styles/think-chat-activity.css +13 -0
- package/dist/styles/think-chat-tool-panels.css +81 -0
- package/dist/styles/think-execution-workbench.css +2 -8
- package/dist/styles/think-full-app.css +42 -251
- package/dist/styles/{think-routine-library.css → think-routine.css} +64 -80
- package/dist/styles/web-preview.css +15 -1
- package/dist/utils/codex-model-catalog.d.ts +25 -6
- package/dist/utils/codex-model-catalog.js +22 -5
- package/dist/utils/mcp-server-catalog.d.ts +1112 -2
- package/dist/utils/mcp-server-catalog.js +28 -9
- package/dist/utils/structured-code.d.ts +1 -1
- package/dist/{workspace-assets-GqsCYxqT.js → workspace-assets-Bg7XhPsk.js} +2 -2
- package/package.json +8 -4
- package/dist/AgentChat-BLmQghkt.d.ts +0 -327
- package/dist/AgentChatStartScreen-Bkv7Avni.d.ts +0 -84
- package/dist/AgentMessageParts-C7L-Mv9U.d.ts +0 -46
- package/dist/AgentToolRunsContext-jtmveaRE.d.ts +0 -57
- package/dist/Dialog-B_FhRWaz.d.ts +0 -107
- package/dist/McpConnectorForm-CeYNY0MI.d.ts +0 -39
- package/dist/McpPluginCatalog-3qWu8oK1.d.ts +0 -92
- package/dist/ResponsiveSidebarShell-BTVPxLJK.d.ts +0 -123
- package/dist/SessionCompaction-CmTJFpzj.d.ts +0 -89
- package/dist/SetupChecklist-DeTU9YpW.js +0 -77
- package/dist/ThinkChat-CwMdEum8.d.ts +0 -185
- package/dist/ThinkChat-DiI6hhDP.js +0 -332
- package/dist/ThinkChatActivity-B3lGVS-6.d.ts +0 -77
- package/dist/ThinkChatContext-COIgzkYp.d.ts +0 -28
- package/dist/ThinkRecoveryNotice-DGWr94rk.d.ts +0 -19
- package/dist/ThinkThreadPicker-yFz4vvIf.d.ts +0 -91
- package/dist/Toggle-DLrIf5YH.d.ts +0 -69
- package/dist/WorkspaceLive-DfjH1Ypm.d.ts +0 -61
- package/dist/WorkspaceMessageResponse-kJYU8Onj.d.ts +0 -48
- package/dist/components/agents-sdk/ThinkFullAppViewSwitch.d.ts +0 -31
- package/dist/components/agents-sdk/ThinkFullAppViewSwitch.js +0 -34
- package/dist/components/agents-sdk/ThinkRoutineLibrary.d.ts +0 -80
- package/dist/components/agents-sdk/ThinkRoutineLibrary.js +0 -159
- package/dist/components/agents-sdk/ThinkSidepanel.d.ts +0 -200
- package/dist/components/agents-sdk/ThinkSidepanel.js +0 -775
- package/dist/mcp-server-7NR24ASj.js +0 -69
- package/dist/mcp-server-catalog-C_g7C-9o.d.ts +0 -1108
- package/dist/styles/think-sidepanel.css +0 -78
- package/dist/think-agent-Cip5KAPj.d.ts +0 -7
- package/dist/{icons-CeGfXO21.js → icons-cuEtsgj9.js} +1 -1
|
@@ -1,2 +1,102 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { J as PromptInputMessage } from "../../PromptInput-4kCz3T9P.js";
|
|
2
|
+
import { AgentMessageRenderPartContext } from "../ai-sdk/AgentMessageParts.js";
|
|
3
|
+
import { AgentChatMessageContentProps, AgentChatRootProps } from "./AgentChat.js";
|
|
4
|
+
import { UseSessionCompactionResult } from "./SessionCompaction.js";
|
|
5
|
+
import { ThinkChatActivity, ThinkChatActivityRendererOptions, createThinkChatActivityRenderer } from "./ThinkChatActivity.js";
|
|
6
|
+
import { ThinkChatValue } from "./ThinkChatContext.js";
|
|
7
|
+
import { WorkspaceFileRenderer } from "./WorkspaceMessageResponse.js";
|
|
8
|
+
import * as React from "react";
|
|
9
|
+
import { ChatStatus, UIMessage } from "ai";
|
|
10
|
+
import { DataTag, UndefinedInitialDataOptions } from "@tanstack/react-query";
|
|
11
|
+
import { PendingApproval, Think } from "@cloudflare/think";
|
|
12
|
+
import { AgentStub } from "agents/client";
|
|
13
|
+
|
|
14
|
+
//#region src/components/agents-sdk/ThinkChat.d.ts
|
|
15
|
+
type ThinkPendingExecutionApprovalsQueryKey = readonly ["think", sourceKey: string, "pending-approvals"];
|
|
16
|
+
type ThinkPendingExecutionApprovalsQueryOptions = UndefinedInitialDataOptions<readonly PendingApproval[], Error, readonly PendingApproval[], ThinkPendingExecutionApprovalsQueryKey> & {
|
|
17
|
+
queryKey: DataTag<ThinkPendingExecutionApprovalsQueryKey, readonly PendingApproval[], Error>;
|
|
18
|
+
};
|
|
19
|
+
/** Shared pending-approval options for components and TanStack Router loaders. */
|
|
20
|
+
declare function thinkPendingExecutionApprovalsQueryOptions(stub: AgentStub<Think>, sourceKey: string): ThinkPendingExecutionApprovalsQueryOptions;
|
|
21
|
+
declare function useThinkPendingExecutionApprovals(stub: AgentStub<Think>, sourceKey: string, refreshSignal?: unknown, enabled?: boolean): {
|
|
22
|
+
pendingApprovals: readonly PendingApproval[];
|
|
23
|
+
refreshPendingApprovals: () => Promise<void>;
|
|
24
|
+
};
|
|
25
|
+
/** The chat status shared by transcript, composer, and an external queue owner. */
|
|
26
|
+
declare function getThinkChatStatus<State = unknown, MessageT extends UIMessage = UIMessage>(chat: ThinkChatValue<State, MessageT>): ChatStatus;
|
|
27
|
+
interface ThinkChatRootProps<State = unknown, MessageT extends UIMessage = UIMessage> extends Omit<AgentChatRootProps<MessageT>, "messages" | "status" | "onSubmit" | "onStop" | "onRegenerate" | "onApprovalResponse"> {
|
|
28
|
+
/** Whole upstream hook value. Connections and subscriptions remain application-owned. */
|
|
29
|
+
chat: ThinkChatValue<State, MessageT>;
|
|
30
|
+
}
|
|
31
|
+
/** A single live adapter. It renders only explicit children and never opens another connection. */
|
|
32
|
+
declare function ThinkChatRoot<State = unknown, MessageT extends UIMessage = UIMessage>({
|
|
33
|
+
chat,
|
|
34
|
+
children,
|
|
35
|
+
...props
|
|
36
|
+
}: ThinkChatRootProps<State, MessageT>): React.JSX.Element;
|
|
37
|
+
/** Normalize composer references for the upstream transport, also usable before a conversation exists. */
|
|
38
|
+
declare function normalizeThinkPrompt({
|
|
39
|
+
text,
|
|
40
|
+
references
|
|
41
|
+
}: PromptInputMessage): string;
|
|
42
|
+
interface ThinkChatMessageContentProps<MessageT extends UIMessage = UIMessage> extends AgentChatMessageContentProps<MessageT>, ThinkChatActivityRendererOptions<MessageT> {
|
|
43
|
+
renderWorkspaceFile?: WorkspaceFileRenderer;
|
|
44
|
+
}
|
|
45
|
+
/** Think activity/workspace rendering, independent of transcript layout and message actions. */
|
|
46
|
+
declare function ThinkChatMessageContent<MessageT extends UIMessage = UIMessage>({
|
|
47
|
+
message,
|
|
48
|
+
renderPart,
|
|
49
|
+
excludeTools,
|
|
50
|
+
renderAgentToolRunLink,
|
|
51
|
+
toolRenderers,
|
|
52
|
+
renderWorkspaceFile
|
|
53
|
+
}: ThinkChatMessageContentProps<MessageT>): React.JSX.Element;
|
|
54
|
+
interface ThinkChatApprovalsProps {
|
|
55
|
+
stub: AgentStub<Think>;
|
|
56
|
+
sourceKey: string;
|
|
57
|
+
/** Chat parts that share the pending approvals discovered for this source. */
|
|
58
|
+
children: React.ReactNode;
|
|
59
|
+
}
|
|
60
|
+
/** Explicit durable discovery; policy and the decision to render a card remain with the caller. */
|
|
61
|
+
declare function ThinkChatApprovals({
|
|
62
|
+
stub,
|
|
63
|
+
sourceKey,
|
|
64
|
+
children
|
|
65
|
+
}: ThinkChatApprovalsProps): React.JSX.Element;
|
|
66
|
+
declare function ThinkChatRecoveryNotice(): React.JSX.Element;
|
|
67
|
+
declare function ThinkChatCompactionNotice({
|
|
68
|
+
compaction
|
|
69
|
+
}: {
|
|
70
|
+
compaction: UseSessionCompactionResult;
|
|
71
|
+
}): React.JSX.Element;
|
|
72
|
+
declare function useThinkChat<State = unknown, MessageT extends UIMessage = UIMessage>(): Omit<import("@ai-sdk/react").UseChatHelpers<MessageT>, "addToolOutput"> & {
|
|
73
|
+
clearHistory: () => void;
|
|
74
|
+
addToolOutput: (opts: {
|
|
75
|
+
toolCallId: string;
|
|
76
|
+
toolName?: string;
|
|
77
|
+
output?: unknown;
|
|
78
|
+
state?: "output-available" | "output-error";
|
|
79
|
+
errorText?: string;
|
|
80
|
+
}) => void;
|
|
81
|
+
isServerStreaming: boolean;
|
|
82
|
+
isStreaming: boolean;
|
|
83
|
+
isRecovering: boolean;
|
|
84
|
+
isToolContinuation: boolean;
|
|
85
|
+
connectionError: (Error & {
|
|
86
|
+
code: number;
|
|
87
|
+
reason: string;
|
|
88
|
+
wasClean: boolean;
|
|
89
|
+
}) | null;
|
|
90
|
+
};
|
|
91
|
+
declare const ThinkChat: {
|
|
92
|
+
Root: typeof ThinkChatRoot;
|
|
93
|
+
MessageContent: typeof ThinkChatMessageContent;
|
|
94
|
+
Approvals: typeof ThinkChatApprovals;
|
|
95
|
+
RecoveryNotice: typeof ThinkChatRecoveryNotice;
|
|
96
|
+
CompactionNotice: typeof ThinkChatCompactionNotice;
|
|
97
|
+
Activity: typeof ThinkChatActivity;
|
|
98
|
+
renderActivityPart: (context: AgentMessageRenderPartContext<UIMessage<unknown, import("ai").UIDataTypes, import("ai").UITools>>) => React.ReactNode | undefined;
|
|
99
|
+
createActivityRenderer: typeof createThinkChatActivityRenderer;
|
|
100
|
+
};
|
|
101
|
+
//#endregion
|
|
102
|
+
export { ThinkChat, ThinkChatApprovals, ThinkChatApprovalsProps, ThinkChatCompactionNotice, ThinkChatMessageContent, ThinkChatMessageContentProps, ThinkChatRecoveryNotice, ThinkChatRoot, ThinkChatRootProps, ThinkPendingExecutionApprovalsQueryKey, ThinkPendingExecutionApprovalsQueryOptions, getThinkChatStatus, normalizeThinkPrompt, thinkPendingExecutionApprovalsQueryOptions, useThinkChat, useThinkPendingExecutionApprovals };
|
|
@@ -1,2 +1,233 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { composerDraftToPrompt, parseComposerLinks } from "../../utils/composer-link.js";
|
|
2
|
+
import { AgentChat, compactingNotice, useAgentChatRuntime } from "./AgentChat.js";
|
|
3
|
+
import { ThinkChatContext, ThinkChatLiveContext, useOptionalThinkChatContext, useThinkChatContext } from "./ThinkChatContext.js";
|
|
4
|
+
import { ThinkChatActivity, createThinkChatActivityRenderer, renderThinkChatActivityPart } from "./ThinkChatActivity.js";
|
|
5
|
+
import { ThinkRecoveryNotice } from "./ThinkRecoveryNotice.js";
|
|
6
|
+
import { n as WorkspaceMessageResponse, t as WorkspaceFileRendererProvider } from "../../WorkspaceMessageResponse-CUJk9_P5.js";
|
|
7
|
+
import * as React from "react";
|
|
8
|
+
import { jsx } from "react/jsx-runtime";
|
|
9
|
+
import { isTextUIPart } from "ai";
|
|
10
|
+
import { queryOptions, useQuery, useQueryClient } from "@tanstack/react-query";
|
|
11
|
+
//#region src/components/agents-sdk/ThinkChat.tsx
|
|
12
|
+
const EMPTY_PENDING_APPROVALS = [];
|
|
13
|
+
const STREAMED_TEXT_ANIMATION = {
|
|
14
|
+
animation: "fadeIn",
|
|
15
|
+
duration: 150,
|
|
16
|
+
easing: "cubic-bezier(0.37, 0.55, 0.86, 0.88)",
|
|
17
|
+
sep: "word",
|
|
18
|
+
stagger: 0
|
|
19
|
+
};
|
|
20
|
+
function thinkPendingExecutionApprovalsQueryKey(sourceKey) {
|
|
21
|
+
return [
|
|
22
|
+
"think",
|
|
23
|
+
sourceKey,
|
|
24
|
+
"pending-approvals"
|
|
25
|
+
];
|
|
26
|
+
}
|
|
27
|
+
/** Shared pending-approval options for components and TanStack Router loaders. */
|
|
28
|
+
function thinkPendingExecutionApprovalsQueryOptions(stub, sourceKey) {
|
|
29
|
+
return queryOptions({
|
|
30
|
+
queryKey: thinkPendingExecutionApprovalsQueryKey(sourceKey),
|
|
31
|
+
queryFn: () => stub.pendingApprovals(),
|
|
32
|
+
staleTime: 5e3
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
function useThinkPendingExecutionApprovals(stub, sourceKey, refreshSignal, enabled = true) {
|
|
36
|
+
const queryClient = useQueryClient();
|
|
37
|
+
const approvalsQuery = useQuery({
|
|
38
|
+
...thinkPendingExecutionApprovalsQueryOptions(stub, sourceKey),
|
|
39
|
+
enabled
|
|
40
|
+
});
|
|
41
|
+
const refreshState = React.useRef({
|
|
42
|
+
sourceKey,
|
|
43
|
+
observedSignal: refreshSignal,
|
|
44
|
+
pending: false
|
|
45
|
+
});
|
|
46
|
+
const refetch = React.useEffectEvent(() => approvalsQuery.refetch());
|
|
47
|
+
const refreshPendingApprovals = React.useCallback(async () => {
|
|
48
|
+
if (!enabled) return;
|
|
49
|
+
const filters = {
|
|
50
|
+
queryKey: thinkPendingExecutionApprovalsQueryKey(sourceKey),
|
|
51
|
+
exact: true
|
|
52
|
+
};
|
|
53
|
+
await queryClient.cancelQueries(filters);
|
|
54
|
+
await queryClient.invalidateQueries(filters);
|
|
55
|
+
}, [
|
|
56
|
+
enabled,
|
|
57
|
+
queryClient,
|
|
58
|
+
sourceKey
|
|
59
|
+
]);
|
|
60
|
+
React.useEffect(() => {
|
|
61
|
+
if (!enabled || refreshState.current.sourceKey !== sourceKey) {
|
|
62
|
+
refreshState.current = {
|
|
63
|
+
sourceKey,
|
|
64
|
+
observedSignal: refreshSignal,
|
|
65
|
+
pending: false
|
|
66
|
+
};
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
if (!Object.is(refreshState.current.observedSignal, refreshSignal)) {
|
|
70
|
+
refreshState.current.observedSignal = refreshSignal;
|
|
71
|
+
refreshState.current.pending = true;
|
|
72
|
+
}
|
|
73
|
+
if (approvalsQuery.isFetching || !refreshState.current.pending) return;
|
|
74
|
+
refreshState.current.pending = false;
|
|
75
|
+
refetch();
|
|
76
|
+
}, [
|
|
77
|
+
approvalsQuery.isFetching,
|
|
78
|
+
enabled,
|
|
79
|
+
refreshSignal,
|
|
80
|
+
sourceKey
|
|
81
|
+
]);
|
|
82
|
+
return React.useMemo(() => ({
|
|
83
|
+
pendingApprovals: approvalsQuery.data ?? EMPTY_PENDING_APPROVALS,
|
|
84
|
+
refreshPendingApprovals
|
|
85
|
+
}), [approvalsQuery.data, refreshPendingApprovals]);
|
|
86
|
+
}
|
|
87
|
+
/** The chat status shared by transcript, composer, and an external queue owner. */
|
|
88
|
+
function getThinkChatStatus(chat) {
|
|
89
|
+
return chat.status === "submitted" ? "submitted" : chat.isStreaming || chat.isRecovering ? "streaming" : chat.status;
|
|
90
|
+
}
|
|
91
|
+
/** A single live adapter. It renders only explicit children and never opens another connection. */
|
|
92
|
+
function ThinkChatRoot({ chat, children, ...props }) {
|
|
93
|
+
const lastMessageId = chat.messages.at(-1)?.id;
|
|
94
|
+
const live = React.useMemo(() => ({
|
|
95
|
+
isStreaming: Boolean(chat.isStreaming),
|
|
96
|
+
lastMessageId
|
|
97
|
+
}), [chat.isStreaming, lastMessageId]);
|
|
98
|
+
const submit = React.useCallback(async ({ text, files, references }) => {
|
|
99
|
+
const prompt = normalizeThinkPrompt({
|
|
100
|
+
text,
|
|
101
|
+
files,
|
|
102
|
+
references
|
|
103
|
+
});
|
|
104
|
+
if (prompt || files.length) await chat.sendMessage({
|
|
105
|
+
text: prompt,
|
|
106
|
+
files
|
|
107
|
+
});
|
|
108
|
+
}, [chat.sendMessage]);
|
|
109
|
+
return /* @__PURE__ */ jsx(ThinkChatContext.Provider, {
|
|
110
|
+
value: chat,
|
|
111
|
+
children: /* @__PURE__ */ jsx(ThinkChatLiveContext.Provider, {
|
|
112
|
+
value: live,
|
|
113
|
+
children: /* @__PURE__ */ jsx(AgentChat.Root, {
|
|
114
|
+
...props,
|
|
115
|
+
messages: chat.messages,
|
|
116
|
+
status: getThinkChatStatus(chat),
|
|
117
|
+
onSubmit: submit,
|
|
118
|
+
onStop: chat.stop,
|
|
119
|
+
onRegenerate: (messageId) => void chat.regenerate({ messageId }),
|
|
120
|
+
onApprovalResponse: chat.addToolApprovalResponse,
|
|
121
|
+
children
|
|
122
|
+
})
|
|
123
|
+
})
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
/** Normalize composer references for the upstream transport, also usable before a conversation exists. */
|
|
127
|
+
function normalizeThinkPrompt({ text, references }) {
|
|
128
|
+
return parseComposerLinks(text).length ? composerDraftToPrompt(text) : [...references?.map(({ trigger, value }) => trigger ? `${trigger}${value}` : value) ?? [], text.trim()].filter(Boolean).join(" ");
|
|
129
|
+
}
|
|
130
|
+
/** Think activity/workspace rendering, independent of transcript layout and message actions. */
|
|
131
|
+
function ThinkChatMessageContent({ message, renderPart, excludeTools, renderAgentToolRunLink, toolRenderers, renderWorkspaceFile }) {
|
|
132
|
+
const { messages, status } = useAgentChatRuntime();
|
|
133
|
+
const isLiveMessage = message.role === "assistant" && message.id === messages.at(-1)?.id && status === "streaming";
|
|
134
|
+
const activity = React.useMemo(() => createThinkChatActivityRenderer({
|
|
135
|
+
excludeTools,
|
|
136
|
+
renderAgentToolRunLink,
|
|
137
|
+
toolRenderers
|
|
138
|
+
}), [
|
|
139
|
+
excludeTools,
|
|
140
|
+
renderAgentToolRunLink,
|
|
141
|
+
toolRenderers
|
|
142
|
+
]);
|
|
143
|
+
const resolved = React.useCallback((context) => {
|
|
144
|
+
const renderBuiltIn = () => {
|
|
145
|
+
const result = activity(context);
|
|
146
|
+
if (result !== void 0) return result;
|
|
147
|
+
return isTextUIPart(context.part) && context.part.text ? /* @__PURE__ */ jsx(WorkspaceMessageResponse, {
|
|
148
|
+
animated: STREAMED_TEXT_ANIMATION,
|
|
149
|
+
isAnimating: isLiveMessage && context.part.state === "streaming",
|
|
150
|
+
promoteWorkspaceFiles: context.message.role === "assistant",
|
|
151
|
+
children: context.part.text
|
|
152
|
+
}) : context.defaultRender();
|
|
153
|
+
};
|
|
154
|
+
const custom = renderPart?.({
|
|
155
|
+
...context,
|
|
156
|
+
defaultRender: renderBuiltIn
|
|
157
|
+
});
|
|
158
|
+
return custom === void 0 ? renderBuiltIn() : custom;
|
|
159
|
+
}, [
|
|
160
|
+
activity,
|
|
161
|
+
renderPart,
|
|
162
|
+
isLiveMessage
|
|
163
|
+
]);
|
|
164
|
+
return /* @__PURE__ */ jsx(WorkspaceFileRendererProvider, {
|
|
165
|
+
renderWorkspaceFile,
|
|
166
|
+
children: /* @__PURE__ */ jsx(AgentChat.MessageContent, {
|
|
167
|
+
message,
|
|
168
|
+
renderPart: resolved
|
|
169
|
+
})
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
/** Explicit durable discovery; policy and the decision to render a card remain with the caller. */
|
|
173
|
+
function ThinkChatApprovals({ stub, sourceKey, children }) {
|
|
174
|
+
const chat = useThinkChatContext("ThinkChat.Approvals");
|
|
175
|
+
const approvals = useThinkPendingExecutionApprovals(stub, sourceKey, `${chat.messages.length}:${chat.status}`);
|
|
176
|
+
return /* @__PURE__ */ jsx(AgentChat.Approvals, {
|
|
177
|
+
thinkStub: stub,
|
|
178
|
+
pendingApprovals: approvals.pendingApprovals,
|
|
179
|
+
onExecutionSettled: approvals.refreshPendingApprovals,
|
|
180
|
+
children
|
|
181
|
+
}, sourceKey);
|
|
182
|
+
}
|
|
183
|
+
function ThinkChatRecoveryNotice() {
|
|
184
|
+
const chat = useThinkChatContext("ThinkChat.RecoveryNotice");
|
|
185
|
+
return /* @__PURE__ */ jsx(AgentChat.Notice, { children: /* @__PURE__ */ jsx(ThinkRecoveryNotice, { chat }) });
|
|
186
|
+
}
|
|
187
|
+
/** A submitted turn dismisses the result visible in that same committed update. */
|
|
188
|
+
function useCompactionDismissal(result, revision) {
|
|
189
|
+
const previousRevision = React.useRef(revision);
|
|
190
|
+
const dismissed = React.useRef(null);
|
|
191
|
+
const revisionChanged = previousRevision.current !== revision;
|
|
192
|
+
React.useLayoutEffect(() => {
|
|
193
|
+
if (!revisionChanged) return;
|
|
194
|
+
previousRevision.current = revision;
|
|
195
|
+
dismissed.current = result;
|
|
196
|
+
}, [
|
|
197
|
+
result,
|
|
198
|
+
revision,
|
|
199
|
+
revisionChanged
|
|
200
|
+
]);
|
|
201
|
+
return revisionChanged || result === dismissed.current;
|
|
202
|
+
}
|
|
203
|
+
function getCompactionNotice(compaction, resultDismissed) {
|
|
204
|
+
if (compaction.compacting) return compactingNotice;
|
|
205
|
+
if (compaction.sessionError) return `Compaction failed: ${compaction.sessionError}`;
|
|
206
|
+
if (compaction.reloadError) return "Transcript may be out of date. The next completed turn will retry the refresh.";
|
|
207
|
+
const result = compaction.lastCompaction;
|
|
208
|
+
if (!result || resultDismissed) return null;
|
|
209
|
+
const freed = Math.round((result.tokensBefore - result.tokensAfter) / 1e3) * 1e3;
|
|
210
|
+
return `Context compacted${freed > 0 ? ` — about ${freed.toLocaleString()} tokens freed` : ""}. Context usage updates after your next message.`;
|
|
211
|
+
}
|
|
212
|
+
function ThinkChatCompactionNotice({ compaction }) {
|
|
213
|
+
const chat = useOptionalThinkChatContext();
|
|
214
|
+
const { submissionVersion } = useAgentChatRuntime();
|
|
215
|
+
const revision = `${chat?.messages.length}:${submissionVersion}`;
|
|
216
|
+
const dismissed = useCompactionDismissal(compaction.lastCompaction, revision);
|
|
217
|
+
return /* @__PURE__ */ jsx(AgentChat.Notice, { children: getCompactionNotice(compaction, dismissed) });
|
|
218
|
+
}
|
|
219
|
+
function useThinkChat() {
|
|
220
|
+
return useThinkChatContext("useThinkChat");
|
|
221
|
+
}
|
|
222
|
+
const ThinkChat = {
|
|
223
|
+
Root: ThinkChatRoot,
|
|
224
|
+
MessageContent: ThinkChatMessageContent,
|
|
225
|
+
Approvals: ThinkChatApprovals,
|
|
226
|
+
RecoveryNotice: ThinkChatRecoveryNotice,
|
|
227
|
+
CompactionNotice: ThinkChatCompactionNotice,
|
|
228
|
+
Activity: ThinkChatActivity,
|
|
229
|
+
renderActivityPart: renderThinkChatActivityPart,
|
|
230
|
+
createActivityRenderer: createThinkChatActivityRenderer
|
|
231
|
+
};
|
|
232
|
+
//#endregion
|
|
233
|
+
export { ThinkChat, ThinkChatApprovals, ThinkChatCompactionNotice, ThinkChatMessageContent, ThinkChatRecoveryNotice, ThinkChatRoot, getThinkChatStatus, normalizeThinkPrompt, thinkPendingExecutionApprovalsQueryOptions, useThinkChat, useThinkPendingExecutionApprovals };
|
|
@@ -1,2 +1,77 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AgentMessageRenderPartContext } from "../ai-sdk/AgentMessageParts.js";
|
|
2
|
+
import { AgentChatMessageContentProps } from "./AgentChat.js";
|
|
3
|
+
import { n as AgentToolRunValue } from "../../AgentToolRunsContext-GMe_hSnD.js";
|
|
4
|
+
import { l as ThinkChatPart } from "../../ThinkChatToolParts-D4qcnnxt.js";
|
|
5
|
+
import { t as ThinkChatActivityDescription } from "../../ThinkChatActivitySummary-BtBQgMg6.js";
|
|
6
|
+
import * as React from "react";
|
|
7
|
+
import { DynamicToolUIPart, ToolUIPart, UIMessage } from "ai";
|
|
8
|
+
|
|
9
|
+
//#region src/components/agents-sdk/ThinkChatActivity.d.ts
|
|
10
|
+
/**
|
|
11
|
+
* Bespoke rendering for one tool inside the activity log. Both hooks fall
|
|
12
|
+
* through to the built-in families when they return `undefined`, so an
|
|
13
|
+
* override can adjust just the action or just the panel.
|
|
14
|
+
*/
|
|
15
|
+
interface ThinkChatToolRenderer {
|
|
16
|
+
/** One-line step action. `null` hides the step from the log. */
|
|
17
|
+
describe?: (part: ToolUIPart | DynamicToolUIPart) => ThinkChatActivityDescription | null | undefined;
|
|
18
|
+
/** Expanded detail under the step. `null` keeps the step a plain row. */
|
|
19
|
+
panel?: (part: ToolUIPart | DynamicToolUIPart) => React.ReactNode;
|
|
20
|
+
}
|
|
21
|
+
type ThinkChatToolRenderers = Record<string, ThinkChatToolRenderer>;
|
|
22
|
+
interface ThinkChatActivityRendererOptions<MessageT extends UIMessage = UIMessage> {
|
|
23
|
+
/**
|
|
24
|
+
* Tool names to keep out of activity folding entirely — the run splits
|
|
25
|
+
* around them and they fall through to your own renderPart / AgentChat's
|
|
26
|
+
* generic standalone activity row. For tools that should stay in the log
|
|
27
|
+
* with custom UI, use `toolRenderers` instead.
|
|
28
|
+
*/
|
|
29
|
+
excludeTools?: readonly string[];
|
|
30
|
+
/** Per-tool action/panel overrides inside the activity log, keyed by tool name. */
|
|
31
|
+
toolRenderers?: ThinkChatToolRenderers;
|
|
32
|
+
/** App-authored TanStack Router Link for each retained child destination. */
|
|
33
|
+
renderAgentToolRunLink?: (run: AgentToolRunValue<MessageT["parts"][number]>) => React.ReactElement;
|
|
34
|
+
}
|
|
35
|
+
interface ThinkChatActivityProps {
|
|
36
|
+
/** Render with the log expanded. */
|
|
37
|
+
defaultOpen?: boolean;
|
|
38
|
+
parts: readonly ThinkChatPart[];
|
|
39
|
+
/** Defaults to deriving from part states (reasoning streaming, tool awaiting output). */
|
|
40
|
+
isStreaming?: boolean;
|
|
41
|
+
/** Per-tool action/panel overrides, keyed by tool name. */
|
|
42
|
+
toolRenderers?: ThinkChatToolRenderers;
|
|
43
|
+
/** Replaces the summary action after the activity settles. */
|
|
44
|
+
settledAction?: string;
|
|
45
|
+
/**
|
|
46
|
+
* Uniquely identifies this run across the whole transcript for persisted
|
|
47
|
+
* disclosure state (the activity renderer passes `${message.id}:${runStart}`).
|
|
48
|
+
* Required because any derivable fallback collides for reasoning-led runs
|
|
49
|
+
* in different messages, bleeding open/closed state across virtualization
|
|
50
|
+
* remounts.
|
|
51
|
+
*/
|
|
52
|
+
stateKey: string;
|
|
53
|
+
}
|
|
54
|
+
declare function ThinkChatActivity({
|
|
55
|
+
parts,
|
|
56
|
+
defaultOpen,
|
|
57
|
+
isStreaming,
|
|
58
|
+
toolRenderers,
|
|
59
|
+
settledAction,
|
|
60
|
+
stateKey
|
|
61
|
+
}: ThinkChatActivityProps): React.JSX.Element | null;
|
|
62
|
+
/**
|
|
63
|
+
* Builds a renderPart handler that folds every run of consecutive activity
|
|
64
|
+
* parts (reasoning + tool calls) into one collapsed Activity box. Everything
|
|
65
|
+
* is derived from the UIMessage stream: part order, tool states, reasoning
|
|
66
|
+
* state. Excluded tools split the run and return undefined so your own
|
|
67
|
+
* renderPart (or AgentChat's generic activity row) takes over for them.
|
|
68
|
+
*/
|
|
69
|
+
declare function createThinkChatActivityRenderer<MessageT extends UIMessage = UIMessage>({
|
|
70
|
+
excludeTools,
|
|
71
|
+
renderAgentToolRunLink,
|
|
72
|
+
toolRenderers
|
|
73
|
+
}?: ThinkChatActivityRendererOptions<MessageT>): NonNullable<AgentChatMessageContentProps<MessageT>["renderPart"]>;
|
|
74
|
+
/** Default activity renderer — `createThinkChatActivityRenderer()` with no overrides. */
|
|
75
|
+
declare const renderThinkChatActivityPart: (context: AgentMessageRenderPartContext<UIMessage<unknown, import("ai").UIDataTypes, import("ai").UITools>>) => React.ReactNode | undefined;
|
|
76
|
+
//#endregion
|
|
2
77
|
export { ThinkChatActivity, ThinkChatActivityProps, ThinkChatActivityRendererOptions, ThinkChatToolRenderer, ThinkChatToolRenderers, createThinkChatActivityRenderer, renderThinkChatActivityPart };
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import { AgentActivityFavicon, AgentActivityIcon } from "./AgentActivity.js";
|
|
1
2
|
import { useExpansionState } from "../ai-sdk/ExpansionState.js";
|
|
2
3
|
import { Activity, ActivityContent, ActivityItem, ActivityItemGroup, ActivityText, ActivityTrigger } from "../ai-sdk/Activity.js";
|
|
3
4
|
import { Button } from "../foundations/Button.js";
|
|
4
5
|
import { MessageResponse } from "../ai-sdk/Message.js";
|
|
5
6
|
import { useOptionalAgentToolRuns } from "./AgentToolRunsContext.js";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
7
|
+
import { getSubagentRunName } from "./SubagentRunIndicator.js";
|
|
8
|
+
import { t as NavigationLink } from "../../navigation-link-kqMa81v5.js";
|
|
8
9
|
import { useOptionalThinkChatLive } from "./ThinkChatContext.js";
|
|
9
10
|
import { isBrowserToolPart, isExecuteToolPart, isFetchToolPart, isPartWorking, isSessionContextToolPart, isSkillToolPart, isThinkChatActivityPart, isWorkspaceToolPart } from "./ThinkChatToolParts.js";
|
|
10
11
|
import { ThinkChatBrowserPanel, ThinkChatExecutePanel, ThinkChatFetchPanel, ThinkChatSessionContextPanel, ThinkChatSkillPanel, ThinkChatWorkspacePanel } from "./ThinkChatToolPanels.js";
|
|
@@ -21,7 +22,7 @@ function activityPartIcon(part) {
|
|
|
21
22
|
* One run of agent work as a collapsed Activity block: while streaming the
|
|
22
23
|
* action shimmers with the live step; settled, it becomes a short summary
|
|
23
24
|
* ("Thought, read 2 files and ran a command") over an expandable step log
|
|
24
|
-
* with per-tool panels. Normally reached through `ThinkChat.
|
|
25
|
+
* with per-tool panels. Normally reached through `ThinkChat.MessageContent`;
|
|
25
26
|
* exported for apps that lay out messages themselves.
|
|
26
27
|
*/
|
|
27
28
|
/**
|
|
@@ -64,7 +65,7 @@ function ThinkChatActivity({ parts, defaultOpen, isStreaming, toolRenderers, set
|
|
|
64
65
|
}), /* @__PURE__ */ jsxs(ActivityContent, { children: [hiddenStepCount > 0 ? /* @__PURE__ */ jsxs(Button, {
|
|
65
66
|
size: "sm",
|
|
66
67
|
variant: "ghost",
|
|
67
|
-
className: "activity__show-earlier",
|
|
68
|
+
className: "think-chat-activity__show-earlier",
|
|
68
69
|
onClick: () => setShowAllSteps(true),
|
|
69
70
|
children: [
|
|
70
71
|
"Show ",
|
|
@@ -170,7 +171,7 @@ function ThinkChatActivityGroup({ message, parts, renderAgentToolRunLink, isTrai
|
|
|
170
171
|
const agentTools = useOptionalAgentToolRuns();
|
|
171
172
|
const runs = React.useMemo(() => {
|
|
172
173
|
if (!agentTools || !renderAgentToolRunLink) return [];
|
|
173
|
-
return parts.flatMap((part) => isToolUIPart(part) ? agentTools.getRunsForToolCall(part.toolCallId) : []);
|
|
174
|
+
return [...new Map(parts.flatMap((part) => isToolUIPart(part) ? agentTools.getRunsForToolCall(part.toolCallId) : []).map((run) => [run.runId, run])).values()];
|
|
174
175
|
}, [
|
|
175
176
|
agentTools,
|
|
176
177
|
parts,
|
|
@@ -182,11 +183,18 @@ function ThinkChatActivityGroup({ message, parts, renderAgentToolRunLink, isTrai
|
|
|
182
183
|
settledAction,
|
|
183
184
|
toolRenderers,
|
|
184
185
|
stateKey
|
|
185
|
-
}), runs.length && renderAgentToolRunLink ? /* @__PURE__ */ jsx(
|
|
186
|
-
className: "
|
|
187
|
-
"aria-label": "
|
|
188
|
-
runs,
|
|
189
|
-
|
|
186
|
+
}), runs.length && renderAgentToolRunLink ? /* @__PURE__ */ jsx("ul", {
|
|
187
|
+
className: "think-chat-activity__runs",
|
|
188
|
+
"aria-label": "Delegation history",
|
|
189
|
+
children: runs.map((run) => /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsxs(NavigationLink, {
|
|
190
|
+
render: renderAgentToolRunLink(run),
|
|
191
|
+
"aria-label": `View ${getSubagentRunName(run)} report`,
|
|
192
|
+
children: [
|
|
193
|
+
"Delegated ",
|
|
194
|
+
getSubagentRunName(run),
|
|
195
|
+
" · View report"
|
|
196
|
+
]
|
|
197
|
+
}) }, run.runId))
|
|
190
198
|
}) : null] });
|
|
191
199
|
}
|
|
192
200
|
/**
|
|
@@ -1,2 +1,28 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { UIMessage } from "ai";
|
|
3
|
+
import { useAgentChat } from "@cloudflare/think/react";
|
|
4
|
+
|
|
5
|
+
//#region src/components/agents-sdk/ThinkChatContext.d.ts
|
|
6
|
+
/** The complete upstream Think chat hook value, preserving app state and message extensions. */
|
|
7
|
+
type ThinkChatValue<State = unknown, MessageT extends UIMessage = UIMessage> = ReturnType<typeof useAgentChat<State, MessageT>>;
|
|
8
|
+
/**
|
|
9
|
+
* React contexts cannot bind provider-specific generics. Keep the stored value
|
|
10
|
+
* opaque and restore the complete upstream hook type through the typed accessors.
|
|
11
|
+
*/
|
|
12
|
+
declare const ThinkChatContext: React.Context<unknown>;
|
|
13
|
+
declare function useOptionalThinkChatContext<State = unknown, MessageT extends UIMessage = UIMessage>(): ThinkChatValue<State, MessageT> | null;
|
|
14
|
+
declare function useThinkChatContext<State = unknown, MessageT extends UIMessage = UIMessage>(component: string): ThinkChatValue<State, MessageT>;
|
|
15
|
+
/**
|
|
16
|
+
* The two live-chat facts transcript rows actually need. Kept separate from
|
|
17
|
+
* the full chat value (whose identity changes every stream delta) so memoized
|
|
18
|
+
* rows subscribed here only re-render when the run starts, ends, or moves to
|
|
19
|
+
* a new message.
|
|
20
|
+
*/
|
|
21
|
+
interface ThinkChatLiveValue {
|
|
22
|
+
isStreaming: boolean;
|
|
23
|
+
lastMessageId: string | undefined;
|
|
24
|
+
}
|
|
25
|
+
declare const ThinkChatLiveContext: React.Context<ThinkChatLiveValue | null>;
|
|
26
|
+
declare function useOptionalThinkChatLive(): ThinkChatLiveValue | null;
|
|
27
|
+
//#endregion
|
|
2
28
|
export { ThinkChatContext, ThinkChatLiveContext, ThinkChatLiveValue, ThinkChatValue, useOptionalThinkChatContext, useOptionalThinkChatLive, useThinkChatContext };
|
|
@@ -10,7 +10,7 @@ function useOptionalThinkChatContext() {
|
|
|
10
10
|
}
|
|
11
11
|
function useThinkChatContext(component) {
|
|
12
12
|
const context = useOptionalThinkChatContext();
|
|
13
|
-
if (!context) throw new Error(`${component} must be used inside <ThinkChat.
|
|
13
|
+
if (!context) throw new Error(`${component} must be used inside <ThinkChat.Root>.`);
|
|
14
14
|
return context;
|
|
15
15
|
}
|
|
16
16
|
const ThinkChatLiveContext = React.createContext(null);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ActivityOutput, ActivityPanel } from "../ai-sdk/Activity.js";
|
|
2
|
-
import { Tabs } from "../foundations/Tabs.js";
|
|
3
2
|
import { o as formatUnknownValue } from "../../format-COCyV98Z.js";
|
|
4
|
-
import {
|
|
3
|
+
import { Tabs } from "../foundations/Tabs.js";
|
|
5
4
|
import { BrowserLiveView } from "./BrowserLiveView.js";
|
|
5
|
+
import { i as CodeBlockContent, r as CodeBlockContainer, t as CodeBlock } from "../../CodeBlock-g8sADidM.js";
|
|
6
6
|
import { inferWorkspaceLanguage } from "./WorkspaceFile.js";
|
|
7
7
|
import { displayUrl, isSessionContextToolFailure } from "./ThinkChatToolParts.js";
|
|
8
8
|
import * as React from "react";
|
|
@@ -62,11 +62,14 @@ function ThinkChatWorkspacePanel({ part }) {
|
|
|
62
62
|
label: path,
|
|
63
63
|
status: output ? `${output.lines} lines written` : void 0,
|
|
64
64
|
children: content !== void 0 ? /* @__PURE__ */ jsx(CodeBlock, {
|
|
65
|
-
|
|
65
|
+
surface: "plain",
|
|
66
|
+
wrap: true,
|
|
67
|
+
className: "think-chat-tool-panels__code-block",
|
|
66
68
|
code: content,
|
|
67
69
|
isStreaming: part.state === "input-streaming",
|
|
68
70
|
language: inferWorkspaceLanguage(path),
|
|
69
|
-
showLineNumbers: true
|
|
71
|
+
showLineNumbers: true,
|
|
72
|
+
children: /* @__PURE__ */ jsx(CodeBlockContainer, { children: /* @__PURE__ */ jsx(CodeBlockContent, {}) })
|
|
70
73
|
}) : null
|
|
71
74
|
});
|
|
72
75
|
}
|
|
@@ -80,12 +83,12 @@ function ThinkChatWorkspacePanel({ part }) {
|
|
|
80
83
|
error: Boolean(output?.error),
|
|
81
84
|
children: input?.old_string !== void 0 && input.new_string !== void 0 ? /* @__PURE__ */ jsxs(ActivityOutput, { children: [
|
|
82
85
|
/* @__PURE__ */ jsx("span", {
|
|
83
|
-
className: "
|
|
86
|
+
className: "think-chat-tool-panels__diff-del",
|
|
84
87
|
children: prefixLines(input.old_string, "- ")
|
|
85
88
|
}),
|
|
86
89
|
"\n",
|
|
87
90
|
/* @__PURE__ */ jsx("span", {
|
|
88
|
-
className: "
|
|
91
|
+
className: "think-chat-tool-panels__diff-add",
|
|
89
92
|
children: prefixLines(input.new_string, "+ ")
|
|
90
93
|
})
|
|
91
94
|
] }) : null
|
|
@@ -270,10 +273,13 @@ function ExecuteCodeView({ code, output, hideResult, isStreaming }) {
|
|
|
270
273
|
].filter(Boolean);
|
|
271
274
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
272
275
|
code ? /* @__PURE__ */ jsx(CodeBlock, {
|
|
273
|
-
|
|
276
|
+
surface: "plain",
|
|
277
|
+
wrap: true,
|
|
278
|
+
className: "think-chat-tool-panels__code-block",
|
|
274
279
|
code,
|
|
275
280
|
isStreaming,
|
|
276
|
-
language: "ts"
|
|
281
|
+
language: "ts",
|
|
282
|
+
children: /* @__PURE__ */ jsx(CodeBlockContainer, { children: /* @__PURE__ */ jsx(CodeBlockContent, {}) })
|
|
277
283
|
}) : null,
|
|
278
284
|
calls?.length ? /* @__PURE__ */ jsx(ToolCallAudit, { calls }) : null,
|
|
279
285
|
sections.length ? /* @__PURE__ */ jsx(ActivityOutput, { children: sections.join("\n\n") }) : null
|
|
@@ -284,26 +290,26 @@ execution order and state available to assistive technology without adding
|
|
|
284
290
|
another host-side activity protocol. */
|
|
285
291
|
function ToolCallAudit({ calls }) {
|
|
286
292
|
return /* @__PURE__ */ jsxs("div", {
|
|
287
|
-
className: "
|
|
293
|
+
className: "think-chat-tool-panels__call-audit",
|
|
288
294
|
children: [/* @__PURE__ */ jsx("span", {
|
|
289
|
-
className: "
|
|
295
|
+
className: "think-chat-tool-panels__call-audit-label",
|
|
290
296
|
children: "Calls"
|
|
291
297
|
}), /* @__PURE__ */ jsx("ol", {
|
|
292
|
-
className: "
|
|
298
|
+
className: "think-chat-tool-panels__call-audit-list",
|
|
293
299
|
children: calls.map((call) => /* @__PURE__ */ jsxs("li", {
|
|
294
|
-
className: "
|
|
300
|
+
className: "think-chat-tool-panels__call-audit-item",
|
|
295
301
|
"data-state": call.state,
|
|
296
302
|
children: [
|
|
297
303
|
/* @__PURE__ */ jsx("code", {
|
|
298
|
-
className: "
|
|
304
|
+
className: "think-chat-tool-panels__call-audit-code",
|
|
299
305
|
children: formatToolCall(call)
|
|
300
306
|
}),
|
|
301
307
|
/* @__PURE__ */ jsx("span", {
|
|
302
|
-
className: "
|
|
308
|
+
className: "think-chat-tool-panels__call-audit-state",
|
|
303
309
|
children: toolCallStateLabel(call)
|
|
304
310
|
}),
|
|
305
311
|
call.result !== void 0 ? /* @__PURE__ */ jsxs("code", {
|
|
306
|
-
className: "
|
|
312
|
+
className: "think-chat-tool-panels__call-audit-result",
|
|
307
313
|
children: [
|
|
308
314
|
" ",
|
|
309
315
|
"→ ",
|
|
@@ -391,7 +397,7 @@ function ThinkChatBrowserPanel({ part }) {
|
|
|
391
397
|
height: 10
|
|
392
398
|
}) : void 0
|
|
393
399
|
}) : media.screenshot ? /* @__PURE__ */ jsx("img", {
|
|
394
|
-
className: "
|
|
400
|
+
className: "think-chat-tool-panels__browser-screenshot",
|
|
395
401
|
src: media.screenshot,
|
|
396
402
|
alt: "Browser screenshot",
|
|
397
403
|
width: 16,
|
|
@@ -408,7 +414,6 @@ function ThinkChatBrowserPanel({ part }) {
|
|
|
408
414
|
status: executeStatusText(output),
|
|
409
415
|
error: output?.status === "error",
|
|
410
416
|
children: browserView && code ? /* @__PURE__ */ jsxs(Tabs.Root, {
|
|
411
|
-
className: "activity__browser-tabs",
|
|
412
417
|
defaultValue: "browser",
|
|
413
418
|
children: [
|
|
414
419
|
/* @__PURE__ */ jsxs(Tabs.List, {
|
|
@@ -426,12 +431,12 @@ function ThinkChatBrowserPanel({ part }) {
|
|
|
426
431
|
]
|
|
427
432
|
}),
|
|
428
433
|
/* @__PURE__ */ jsx(Tabs.Panel, {
|
|
429
|
-
className: "
|
|
434
|
+
className: "think-chat-tool-panels__browser-panel",
|
|
430
435
|
value: "browser",
|
|
431
436
|
children: browserView
|
|
432
437
|
}),
|
|
433
438
|
/* @__PURE__ */ jsx(Tabs.Panel, {
|
|
434
|
-
className: "
|
|
439
|
+
className: "think-chat-tool-panels__browser-panel",
|
|
435
440
|
value: "code",
|
|
436
441
|
children: codeView
|
|
437
442
|
})
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { t as cx } from "../../class-names-BiMDVpUo.js";
|
|
2
|
-
import { S as FileIcon, T as InfoIcon } from "../../icons-
|
|
2
|
+
import { S as FileIcon, T as InfoIcon } from "../../icons-cuEtsgj9.js";
|
|
3
3
|
import { Activity, ActivityContent, ActivityItemGroup, ActivityOutput, ActivityTrigger } from "../ai-sdk/Activity.js";
|
|
4
4
|
import { o as formatUnknownValue } from "../../format-COCyV98Z.js";
|
|
5
|
-
import { DescriptionList } from "../foundations/DescriptionList.js";
|
|
6
5
|
import { EmptyState } from "../foundations/EmptyState.js";
|
|
6
|
+
import { DescriptionList } from "../foundations/DescriptionList.js";
|
|
7
7
|
import { formatThinkExecutionTimestamp, getThinkExecutionRunError, getThinkExecutionRunId, getThinkExecutionRunKindLabel, getThinkExecutionRunProgressedAt, getThinkExecutionRunProgressedLabel, getThinkExecutionRunTitle, isThinkSubmissionRun } from "./ThinkExecutionRun.js";
|
|
8
8
|
import { ThinkExecutionStatus } from "./ThinkExecutionStatus.js";
|
|
9
9
|
import "react";
|