@mcp-b/react-components 0.48.0 → 0.49.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/AgentChatQueue-C_Jaw3Ia.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-H8mMg4rV.js} +21 -30
- package/dist/{IconButton-BAUFhUk8.d.ts → IconButton-ByiyjkYE.d.ts} +2 -2
- 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-C4Mofitz.d.ts} +44 -31
- 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 +4 -3
- 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/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 +39 -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 +5 -0
- package/dist/components/extension/CodexModelSelector.js +2 -2
- 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.js +1 -1
- 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/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/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/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/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 -1
- 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/composition-motion.css +0 -2
- package/dist/styles/employee-chrome.css +43 -0
- package/dist/styles/file-tree.css +5 -0
- package/dist/styles/index.css +4 -2
- package/dist/styles/message.css +2 -10
- package/dist/styles/queue.css +71 -0
- 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/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 +7 -3
- 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,185 +0,0 @@
|
|
|
1
|
-
import { i as AgentMessageRenderPartContext } from "./AgentMessageParts-C7L-Mv9U.js";
|
|
2
|
-
import { K as PromptInputMessage } from "./PromptInput-DtJHyp0S.js";
|
|
3
|
-
import { r as AgentChatProps } from "./AgentChat-BLmQghkt.js";
|
|
4
|
-
import { n as AgentToolEventsValue } from "./AgentToolRunsContext-jtmveaRE.js";
|
|
5
|
-
import { o as UseSessionCompactionResult } from "./SessionCompaction-CmTJFpzj.js";
|
|
6
|
-
import { o as createThinkChatActivityRenderer, r as ThinkChatActivityRendererOptions, t as ThinkChatActivity } from "./ThinkChatActivity-B3lGVS-6.js";
|
|
7
|
-
import { i as ThinkChatValue } from "./ThinkChatContext-COIgzkYp.js";
|
|
8
|
-
import { t as ThinkRecoveryNotice } from "./ThinkRecoveryNotice-DGWr94rk.js";
|
|
9
|
-
import { n as WorkspaceFileRenderer } from "./WorkspaceMessageResponse-kJYU8Onj.js";
|
|
10
|
-
import * as React from "react";
|
|
11
|
-
import { UIMessage } from "ai";
|
|
12
|
-
import { UseAgentOptions } from "agents/react";
|
|
13
|
-
import { DataTag, UndefinedInitialDataOptions } from "@tanstack/react-query";
|
|
14
|
-
import { PendingApproval, Think } from "@cloudflare/think";
|
|
15
|
-
import { AgentStub } from "agents/client";
|
|
16
|
-
|
|
17
|
-
//#region src/components/agents-sdk/ThinkChat.d.ts
|
|
18
|
-
type ThinkPendingExecutionApprovalsQueryKey = readonly ["think", sourceKey: string, "pending-approvals"];
|
|
19
|
-
type ThinkPendingExecutionApprovalsQueryOptions = UndefinedInitialDataOptions<readonly PendingApproval[], Error, readonly PendingApproval[], ThinkPendingExecutionApprovalsQueryKey> & {
|
|
20
|
-
queryKey: DataTag<ThinkPendingExecutionApprovalsQueryKey, readonly PendingApproval[], Error>;
|
|
21
|
-
};
|
|
22
|
-
interface ThinkChatProviderProps<State = unknown, MessageT extends UIMessage = UIMessage> {
|
|
23
|
-
/** The `useAgentChat` value from `@cloudflare/think/react` that descendants read. */
|
|
24
|
-
chat: ThinkChatValue<State, MessageT>;
|
|
25
|
-
/** Optional whole `useAgentToolEvents` result when the app owns the parent connection. */
|
|
26
|
-
agentTools?: AgentToolEventsValue<MessageT["parts"][number]>;
|
|
27
|
-
children: React.ReactNode;
|
|
28
|
-
}
|
|
29
|
-
interface ThinkChatRootProps<State = unknown> {
|
|
30
|
-
/** Agent to connect to: a kebab-case class name, or full `useAgent` options. */
|
|
31
|
-
agent: string | UseAgentOptions<State>;
|
|
32
|
-
/** Disable durable pending-approval discovery. Also disable it on `ThinkChat.Messages`. */
|
|
33
|
-
approvalsEnabled?: boolean;
|
|
34
|
-
/** Instance name (e.g. a session or room id). Wins over `agent.name`. */
|
|
35
|
-
name?: string;
|
|
36
|
-
/**
|
|
37
|
-
* Stable, non-secret identity for the remote Think agent. Include endpoint,
|
|
38
|
-
* account or tenant scope, and agent path so sources cannot share cached data.
|
|
39
|
-
*/
|
|
40
|
-
sourceKey: string;
|
|
41
|
-
children: React.ReactNode;
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* The first-turn surface with no conversation behind it. Supply this instead of
|
|
45
|
-
* a chat provider when the composer's submission is what creates the
|
|
46
|
-
* conversation: connecting early is what leaves empty threads behind.
|
|
47
|
-
*/
|
|
48
|
-
interface ThinkChatDraft<MessageT extends UIMessage = UIMessage> {
|
|
49
|
-
/** Client-only transcript rows, such as a locally rendered guide. */
|
|
50
|
-
messages?: readonly MessageT[];
|
|
51
|
-
/** Receives the first message, normalized the same way a live thread's is. */
|
|
52
|
-
onSubmit: (message: {
|
|
53
|
-
text: string;
|
|
54
|
-
files: PromptInputMessage["files"];
|
|
55
|
-
}) => void | Promise<void>;
|
|
56
|
-
/** Set while the app is creating the conversation, so the composer reads busy. */
|
|
57
|
-
status?: AgentChatProps<MessageT>["status"];
|
|
58
|
-
}
|
|
59
|
-
type ThinkChatManagedAgentChatProp = "messages" | "onApprovalResponse" | "onRegenerate" | "onStop" | "onSubmit" | "status";
|
|
60
|
-
/**
|
|
61
|
-
* The AgentChat composition surface, minus the live values ThinkChat supplies
|
|
62
|
-
* from `useAgentChat`. Think-specific activity and draft/session inputs extend
|
|
63
|
-
* that owner instead of mirroring every AgentChat prop here.
|
|
64
|
-
*/
|
|
65
|
-
type ThinkChatMessagesProps<MessageT extends UIMessage = UIMessage> = Omit<AgentChatProps<MessageT>, ThinkChatManagedAgentChatProp> & ThinkChatActivityRendererOptions<MessageT> & {
|
|
66
|
-
/**
|
|
67
|
-
* Renders without a chat provider, for the first turn of a conversation
|
|
68
|
-
* that does not exist yet.
|
|
69
|
-
*/
|
|
70
|
-
draft?: ThinkChatDraft<MessageT>; /** Whole `useSessionCompaction` result for built-in progress and error notices. */
|
|
71
|
-
sessionCompaction?: UseSessionCompactionResult;
|
|
72
|
-
/**
|
|
73
|
-
* Promotes one standalone assistant workspace file link through a host
|
|
74
|
-
* callback. Return a node to replace the link, or `null` to keep it.
|
|
75
|
-
*/
|
|
76
|
-
renderWorkspaceFile?: WorkspaceFileRenderer;
|
|
77
|
-
};
|
|
78
|
-
/** Shared pending-approval options for components and TanStack Router loaders. */
|
|
79
|
-
declare function thinkPendingExecutionApprovalsQueryOptions(stub: AgentStub<Think>, sourceKey: string): ThinkPendingExecutionApprovalsQueryOptions;
|
|
80
|
-
declare function useThinkPendingExecutionApprovals(stub: AgentStub<Think>, sourceKey: string, refreshSignal?: unknown, enabled?: boolean): {
|
|
81
|
-
pendingApprovals: readonly PendingApproval[];
|
|
82
|
-
refreshPendingApprovals: () => Promise<void>;
|
|
83
|
-
};
|
|
84
|
-
/**
|
|
85
|
-
* Chat UI for Cloudflare Think agents. Provide a `useAgentChat` value (or let
|
|
86
|
-
* `ThinkChat.Root` create one) and `ThinkChat.Messages` renders the message
|
|
87
|
-
* stream with agent work folded into collapsed Activity blocks.
|
|
88
|
-
*/
|
|
89
|
-
declare function ThinkChatProvider<State = unknown, MessageT extends UIMessage = UIMessage>({
|
|
90
|
-
agentTools,
|
|
91
|
-
chat,
|
|
92
|
-
children
|
|
93
|
-
}: ThinkChatProviderProps<State, MessageT>): React.JSX.Element;
|
|
94
|
-
/**
|
|
95
|
-
* Batteries-included root: connects to the named Think agent (upstream's
|
|
96
|
-
* `useAgent` + `useAgentChat`) and provides the live chat to everything
|
|
97
|
-
* inside. Render it beneath the app's `QueryClientProvider`. If the app
|
|
98
|
-
* already owns the chat hook, use `ThinkChat.Provider`.
|
|
99
|
-
*
|
|
100
|
-
* @example
|
|
101
|
-
* ```tsx
|
|
102
|
-
* <QueryClientProvider client={queryClient}>
|
|
103
|
-
* <ThinkChat.Root
|
|
104
|
-
* agent="my-agent"
|
|
105
|
-
* name="session-1"
|
|
106
|
-
* sourceKey="api.example.com:account:acme:agent:session-1"
|
|
107
|
-
* >
|
|
108
|
-
* <ThinkChat.Messages />
|
|
109
|
-
* </ThinkChat.Root>
|
|
110
|
-
* </QueryClientProvider>
|
|
111
|
-
* ```
|
|
112
|
-
*/
|
|
113
|
-
declare function ThinkChatRoot<State = unknown, MessageT extends UIMessage = UIMessage>({
|
|
114
|
-
agent: agentOption,
|
|
115
|
-
approvalsEnabled,
|
|
116
|
-
name,
|
|
117
|
-
sourceKey,
|
|
118
|
-
children
|
|
119
|
-
}: ThinkChatRootProps<State>): React.JSX.Element;
|
|
120
|
-
/**
|
|
121
|
-
* The full conversation surface — message list plus composer — with the
|
|
122
|
-
* activity renderer as the default `renderPart`: runs of reasoning/tool parts
|
|
123
|
-
* fold into one collapsed Activity block with derived labels and per-tool
|
|
124
|
-
* panels. Session-generated context/load/search tools are recognized from
|
|
125
|
-
* their upstream runtime schemas and keep their recorded inputs and outputs
|
|
126
|
-
* inspectable. Extend for app-specific tools with `toolRenderers` (label/panel
|
|
127
|
-
* inside the log) or `excludeTools` + your own `renderPart` (standalone
|
|
128
|
-
* card) — see README "App-specific tools" and the Custom Tool Panel story.
|
|
129
|
-
*/
|
|
130
|
-
declare function ThinkChatMessages<State = unknown, MessageT extends UIMessage = UIMessage>({
|
|
131
|
-
draft,
|
|
132
|
-
loading,
|
|
133
|
-
renderPart,
|
|
134
|
-
excludeTools,
|
|
135
|
-
renderAgentToolRunLink,
|
|
136
|
-
renderWorkspaceFile,
|
|
137
|
-
toolRenderers,
|
|
138
|
-
thinkStub,
|
|
139
|
-
onExecutionSettled,
|
|
140
|
-
pendingApprovals,
|
|
141
|
-
notice,
|
|
142
|
-
sessionCompaction,
|
|
143
|
-
...props
|
|
144
|
-
}: ThinkChatMessagesProps<MessageT>): React.JSX.Element;
|
|
145
|
-
/**
|
|
146
|
-
* The ambient chat value from `ThinkChat.Root`/`Provider` — for custom tool
|
|
147
|
-
* panels, cards, or composer actions that need `messages`, `status`, or
|
|
148
|
-
* `sendMessage`. Throws outside a provider.
|
|
149
|
-
*/
|
|
150
|
-
declare function useThinkChat<State = unknown, MessageT extends UIMessage = UIMessage>(): Omit<import("@ai-sdk/react").UseChatHelpers<MessageT>, "addToolOutput"> & {
|
|
151
|
-
clearHistory: () => void;
|
|
152
|
-
addToolOutput: (opts: {
|
|
153
|
-
toolCallId: string;
|
|
154
|
-
toolName?: string;
|
|
155
|
-
output?: unknown;
|
|
156
|
-
state?: "output-available" | "output-error";
|
|
157
|
-
errorText?: string;
|
|
158
|
-
}) => void;
|
|
159
|
-
isServerStreaming: boolean;
|
|
160
|
-
isStreaming: boolean;
|
|
161
|
-
isRecovering: boolean;
|
|
162
|
-
isToolContinuation: boolean;
|
|
163
|
-
connectionError: (Error & {
|
|
164
|
-
code: number;
|
|
165
|
-
reason: string;
|
|
166
|
-
wasClean: boolean;
|
|
167
|
-
}) | null;
|
|
168
|
-
};
|
|
169
|
-
/**
|
|
170
|
-
* Namespace entry point. `Root` + `Messages` is the standard surface;
|
|
171
|
-
* `Provider` + `useThinkChat` when the app owns the chat hook; `Activity`,
|
|
172
|
-
* `renderActivityPart`, and `createActivityRenderer` for custom layouts and
|
|
173
|
-
* app-specific tools.
|
|
174
|
-
*/
|
|
175
|
-
declare const ThinkChat: {
|
|
176
|
-
Provider: typeof ThinkChatProvider;
|
|
177
|
-
Root: typeof ThinkChatRoot;
|
|
178
|
-
Messages: typeof ThinkChatMessages;
|
|
179
|
-
Activity: typeof ThinkChatActivity;
|
|
180
|
-
RecoveryNotice: typeof ThinkRecoveryNotice;
|
|
181
|
-
renderActivityPart: (context: AgentMessageRenderPartContext<UIMessage<unknown, import("ai").UIDataTypes, import("ai").UITools>>) => React.ReactNode | undefined;
|
|
182
|
-
createActivityRenderer: typeof createThinkChatActivityRenderer;
|
|
183
|
-
};
|
|
184
|
-
//#endregion
|
|
185
|
-
export { ThinkChatProvider as a, ThinkChatRootProps as c, thinkPendingExecutionApprovalsQueryOptions as d, useThinkChat as f, ThinkChatMessagesProps as i, ThinkPendingExecutionApprovalsQueryKey as l, ThinkChatDraft as n, ThinkChatProviderProps as o, useThinkPendingExecutionApprovals as p, ThinkChatMessages as r, ThinkChatRoot as s, ThinkChat as t, ThinkPendingExecutionApprovalsQueryOptions as u };
|
|
@@ -1,332 +0,0 @@
|
|
|
1
|
-
import { composerDraftToPrompt, parseComposerLinks } from "./utils/composer-link.js";
|
|
2
|
-
import { TransitionSurface } from "./components/foundations/TransitionSurface.js";
|
|
3
|
-
import { AgentToolRunsProvider, useSourceScopedAgentToolEvents } from "./components/agents-sdk/AgentToolRunsContext.js";
|
|
4
|
-
import { AgentChat, compactingNotice } from "./components/agents-sdk/AgentChat.js";
|
|
5
|
-
import { ThinkChatContext, ThinkChatLiveContext, useOptionalThinkChatContext, useThinkChatContext } from "./components/agents-sdk/ThinkChatContext.js";
|
|
6
|
-
import { ThinkChatActivity, createThinkChatActivityRenderer, renderThinkChatActivityPart } from "./components/agents-sdk/ThinkChatActivity.js";
|
|
7
|
-
import { ThinkRecoveryNotice } from "./components/agents-sdk/ThinkRecoveryNotice.js";
|
|
8
|
-
import { n as WorkspaceMessageResponse, t as WorkspaceFileRendererProvider } from "./WorkspaceMessageResponse-BqOezptB.js";
|
|
9
|
-
import * as React from "react";
|
|
10
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
11
|
-
import { isTextUIPart } from "ai";
|
|
12
|
-
import { useAgentChat } from "@cloudflare/think/react";
|
|
13
|
-
import { useAgent } from "agents/react";
|
|
14
|
-
import { queryOptions, useQuery, useQueryClient } from "@tanstack/react-query";
|
|
15
|
-
//#region src/components/_internal/think-approvals.ts
|
|
16
|
-
/**
|
|
17
|
-
* Ambient approvals belong to their stub. An explicit different stub may only
|
|
18
|
-
* use approval state and settlement handlers supplied alongside that override.
|
|
19
|
-
*/
|
|
20
|
-
function resolveThinkApprovalProps(overrides, ambient) {
|
|
21
|
-
const inheritsAmbient = overrides.thinkStub === void 0 || overrides.thinkStub === ambient?.thinkStub;
|
|
22
|
-
return {
|
|
23
|
-
thinkStub: overrides.thinkStub ?? ambient?.thinkStub,
|
|
24
|
-
pendingApprovals: overrides.pendingApprovals ?? (inheritsAmbient ? ambient?.pendingApprovals : void 0),
|
|
25
|
-
onExecutionSettled: overrides.onExecutionSettled ?? (inheritsAmbient ? ambient?.onExecutionSettled : void 0)
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
//#endregion
|
|
29
|
-
//#region src/components/agents-sdk/ThinkChat.tsx
|
|
30
|
-
const EMPTY_PENDING_APPROVALS = [];
|
|
31
|
-
const STREAMED_TEXT_ANIMATION = {
|
|
32
|
-
animation: "fadeIn",
|
|
33
|
-
duration: 150,
|
|
34
|
-
easing: "cubic-bezier(0.37, 0.55, 0.86, 0.88)",
|
|
35
|
-
sep: "word",
|
|
36
|
-
stagger: 0
|
|
37
|
-
};
|
|
38
|
-
/**
|
|
39
|
-
* Acknowledgement copy for a landed compaction. Both numbers are Session's own
|
|
40
|
-
* estimates, so the text is hedged ("about", rounded to thousands) and falls
|
|
41
|
-
* back to the plain sentence when the difference is not a positive size —
|
|
42
|
-
* estimator noise must never render as "0 tokens freed".
|
|
43
|
-
*/
|
|
44
|
-
function compactionSizeText({ tokensAfter, tokensBefore }) {
|
|
45
|
-
const freed = Math.round((tokensBefore - tokensAfter) / 1e3) * 1e3;
|
|
46
|
-
return freed > 0 ? `Context compacted — about ${freed.toLocaleString()} tokens freed.` : "Context compacted.";
|
|
47
|
-
}
|
|
48
|
-
function toAgentChatStatus(chat) {
|
|
49
|
-
if (chat.status === "submitted") return "submitted";
|
|
50
|
-
if (chat.isStreaming || chat.isRecovering) return "streaming";
|
|
51
|
-
return chat.status ?? "ready";
|
|
52
|
-
}
|
|
53
|
-
function thinkPendingExecutionApprovalsQueryKey(sourceKey) {
|
|
54
|
-
return [
|
|
55
|
-
"think",
|
|
56
|
-
sourceKey,
|
|
57
|
-
"pending-approvals"
|
|
58
|
-
];
|
|
59
|
-
}
|
|
60
|
-
/** Shared pending-approval options for components and TanStack Router loaders. */
|
|
61
|
-
function thinkPendingExecutionApprovalsQueryOptions(stub, sourceKey) {
|
|
62
|
-
return queryOptions({
|
|
63
|
-
queryKey: thinkPendingExecutionApprovalsQueryKey(sourceKey),
|
|
64
|
-
queryFn: () => stub.pendingApprovals(),
|
|
65
|
-
staleTime: 5e3
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
function useThinkPendingExecutionApprovals(stub, sourceKey, refreshSignal, enabled = true) {
|
|
69
|
-
const queryClient = useQueryClient();
|
|
70
|
-
const approvalsQuery = useQuery({
|
|
71
|
-
...thinkPendingExecutionApprovalsQueryOptions(stub, sourceKey),
|
|
72
|
-
enabled
|
|
73
|
-
});
|
|
74
|
-
const refreshState = React.useRef({
|
|
75
|
-
sourceKey,
|
|
76
|
-
observedSignal: refreshSignal,
|
|
77
|
-
pending: false
|
|
78
|
-
});
|
|
79
|
-
const refetch = React.useEffectEvent(() => approvalsQuery.refetch());
|
|
80
|
-
const refreshPendingApprovals = React.useCallback(async () => {
|
|
81
|
-
if (!enabled) return;
|
|
82
|
-
const filters = {
|
|
83
|
-
queryKey: thinkPendingExecutionApprovalsQueryKey(sourceKey),
|
|
84
|
-
exact: true
|
|
85
|
-
};
|
|
86
|
-
await queryClient.cancelQueries(filters);
|
|
87
|
-
await queryClient.invalidateQueries(filters);
|
|
88
|
-
}, [
|
|
89
|
-
enabled,
|
|
90
|
-
queryClient,
|
|
91
|
-
sourceKey
|
|
92
|
-
]);
|
|
93
|
-
React.useEffect(() => {
|
|
94
|
-
if (!enabled || refreshState.current.sourceKey !== sourceKey) {
|
|
95
|
-
refreshState.current = {
|
|
96
|
-
sourceKey,
|
|
97
|
-
observedSignal: refreshSignal,
|
|
98
|
-
pending: false
|
|
99
|
-
};
|
|
100
|
-
return;
|
|
101
|
-
}
|
|
102
|
-
if (!Object.is(refreshState.current.observedSignal, refreshSignal)) {
|
|
103
|
-
refreshState.current.observedSignal = refreshSignal;
|
|
104
|
-
refreshState.current.pending = true;
|
|
105
|
-
}
|
|
106
|
-
if (approvalsQuery.isFetching || !refreshState.current.pending) return;
|
|
107
|
-
refreshState.current.pending = false;
|
|
108
|
-
refetch();
|
|
109
|
-
}, [
|
|
110
|
-
approvalsQuery.isFetching,
|
|
111
|
-
enabled,
|
|
112
|
-
refreshSignal,
|
|
113
|
-
sourceKey
|
|
114
|
-
]);
|
|
115
|
-
return React.useMemo(() => ({
|
|
116
|
-
pendingApprovals: approvalsQuery.data ?? EMPTY_PENDING_APPROVALS,
|
|
117
|
-
refreshPendingApprovals
|
|
118
|
-
}), [approvalsQuery.data, refreshPendingApprovals]);
|
|
119
|
-
}
|
|
120
|
-
/**
|
|
121
|
-
* Chat UI for Cloudflare Think agents. Provide a `useAgentChat` value (or let
|
|
122
|
-
* `ThinkChat.Root` create one) and `ThinkChat.Messages` renders the message
|
|
123
|
-
* stream with agent work folded into collapsed Activity blocks.
|
|
124
|
-
*/
|
|
125
|
-
function ThinkChatProvider({ agentTools, chat, children }) {
|
|
126
|
-
const isStreaming = Boolean(chat.isStreaming);
|
|
127
|
-
const lastMessageId = chat.messages.at(-1)?.id;
|
|
128
|
-
const live = React.useMemo(() => ({
|
|
129
|
-
isStreaming,
|
|
130
|
-
lastMessageId
|
|
131
|
-
}), [isStreaming, lastMessageId]);
|
|
132
|
-
const chatProvider = /* @__PURE__ */ jsx(ThinkChatContext.Provider, {
|
|
133
|
-
value: chat,
|
|
134
|
-
children: /* @__PURE__ */ jsx(ThinkChatLiveContext.Provider, {
|
|
135
|
-
value: live,
|
|
136
|
-
children
|
|
137
|
-
})
|
|
138
|
-
});
|
|
139
|
-
return agentTools ? /* @__PURE__ */ jsx(AgentToolRunsProvider, {
|
|
140
|
-
agentTools,
|
|
141
|
-
children: chatProvider
|
|
142
|
-
}) : chatProvider;
|
|
143
|
-
}
|
|
144
|
-
/**
|
|
145
|
-
* Batteries-included root: connects to the named Think agent (upstream's
|
|
146
|
-
* `useAgent` + `useAgentChat`) and provides the live chat to everything
|
|
147
|
-
* inside. Render it beneath the app's `QueryClientProvider`. If the app
|
|
148
|
-
* already owns the chat hook, use `ThinkChat.Provider`.
|
|
149
|
-
*
|
|
150
|
-
* @example
|
|
151
|
-
* ```tsx
|
|
152
|
-
* <QueryClientProvider client={queryClient}>
|
|
153
|
-
* <ThinkChat.Root
|
|
154
|
-
* agent="my-agent"
|
|
155
|
-
* name="session-1"
|
|
156
|
-
* sourceKey="api.example.com:account:acme:agent:session-1"
|
|
157
|
-
* >
|
|
158
|
-
* <ThinkChat.Messages />
|
|
159
|
-
* </ThinkChat.Root>
|
|
160
|
-
* </QueryClientProvider>
|
|
161
|
-
* ```
|
|
162
|
-
*/
|
|
163
|
-
function ThinkChatRoot({ agent: agentOption, approvalsEnabled = true, name, sourceKey, children }) {
|
|
164
|
-
const agent = useAgent(typeof agentOption === "string" ? {
|
|
165
|
-
agent: agentOption,
|
|
166
|
-
name
|
|
167
|
-
} : {
|
|
168
|
-
...agentOption,
|
|
169
|
-
name: name ?? agentOption.name
|
|
170
|
-
});
|
|
171
|
-
const chat = useAgentChat({ agent });
|
|
172
|
-
const agentTools = useSourceScopedAgentToolEvents(agent);
|
|
173
|
-
const approvals = useThinkPendingExecutionApprovals(agent.stub, sourceKey, `${chat.messages.length}:${chat.status}`, approvalsEnabled);
|
|
174
|
-
const approvalsContext = React.useMemo(() => ({
|
|
175
|
-
...approvals,
|
|
176
|
-
thinkStub: agent.stub
|
|
177
|
-
}), [agent.stub, approvals]);
|
|
178
|
-
return /* @__PURE__ */ jsx(ThinkChatProvider, {
|
|
179
|
-
chat,
|
|
180
|
-
agentTools,
|
|
181
|
-
children: /* @__PURE__ */ jsx(ThinkChatApprovalsContext.Provider, {
|
|
182
|
-
value: approvalsContext,
|
|
183
|
-
children
|
|
184
|
-
})
|
|
185
|
-
});
|
|
186
|
-
}
|
|
187
|
-
const ThinkChatApprovalsContext = React.createContext(null);
|
|
188
|
-
/**
|
|
189
|
-
* The full conversation surface — message list plus composer — with the
|
|
190
|
-
* activity renderer as the default `renderPart`: runs of reasoning/tool parts
|
|
191
|
-
* fold into one collapsed Activity block with derived labels and per-tool
|
|
192
|
-
* panels. Session-generated context/load/search tools are recognized from
|
|
193
|
-
* their upstream runtime schemas and keep their recorded inputs and outputs
|
|
194
|
-
* inspectable. Extend for app-specific tools with `toolRenderers` (label/panel
|
|
195
|
-
* inside the log) or `excludeTools` + your own `renderPart` (standalone
|
|
196
|
-
* card) — see README "App-specific tools" and the Custom Tool Panel story.
|
|
197
|
-
*/
|
|
198
|
-
function ThinkChatMessages({ draft, loading, renderPart, excludeTools, renderAgentToolRunLink, renderWorkspaceFile, toolRenderers, thinkStub, onExecutionSettled, pendingApprovals, notice, sessionCompaction, ...props }) {
|
|
199
|
-
const chat = useOptionalThinkChatContext();
|
|
200
|
-
const approvals = React.useContext(ThinkChatApprovalsContext);
|
|
201
|
-
const resolvedApprovals = resolveThinkApprovalProps({
|
|
202
|
-
thinkStub,
|
|
203
|
-
pendingApprovals,
|
|
204
|
-
onExecutionSettled
|
|
205
|
-
}, approvals && {
|
|
206
|
-
thinkStub: approvals.thinkStub,
|
|
207
|
-
pendingApprovals: approvals.pendingApprovals,
|
|
208
|
-
onExecutionSettled: approvals.refreshPendingApprovals
|
|
209
|
-
});
|
|
210
|
-
const activityRenderPart = React.useMemo(() => createThinkChatActivityRenderer({
|
|
211
|
-
excludeTools,
|
|
212
|
-
renderAgentToolRunLink,
|
|
213
|
-
toolRenderers
|
|
214
|
-
}), [
|
|
215
|
-
excludeTools,
|
|
216
|
-
renderAgentToolRunLink,
|
|
217
|
-
toolRenderers
|
|
218
|
-
]);
|
|
219
|
-
const streamingMessageId = (chat ? chat.isStreaming : draft?.status === "streaming") ? (chat?.messages ?? draft?.messages)?.at(-1)?.id : void 0;
|
|
220
|
-
const defaultRenderPart = React.useCallback((context) => {
|
|
221
|
-
const activity = activityRenderPart(context);
|
|
222
|
-
if (activity !== void 0) return activity;
|
|
223
|
-
return isTextUIPart(context.part) && context.part.text ? /* @__PURE__ */ jsx(WorkspaceMessageResponse, {
|
|
224
|
-
animated: STREAMED_TEXT_ANIMATION,
|
|
225
|
-
isAnimating: context.message.role === "assistant" && context.message.id === streamingMessageId && context.part.state === "streaming",
|
|
226
|
-
promoteWorkspaceFiles: context.message.role === "assistant",
|
|
227
|
-
children: context.part.text
|
|
228
|
-
}) : void 0;
|
|
229
|
-
}, [activityRenderPart, streamingMessageId]);
|
|
230
|
-
const resolvedRenderPart = React.useMemo(() => renderPart ? (context) => {
|
|
231
|
-
const renderBuiltIn = () => {
|
|
232
|
-
const builtIn = defaultRenderPart(context);
|
|
233
|
-
return builtIn === void 0 ? context.defaultRender() : builtIn;
|
|
234
|
-
};
|
|
235
|
-
const custom = renderPart({
|
|
236
|
-
...context,
|
|
237
|
-
defaultRender: renderBuiltIn
|
|
238
|
-
});
|
|
239
|
-
return custom === void 0 ? renderBuiltIn() : custom;
|
|
240
|
-
} : defaultRenderPart, [defaultRenderPart, renderPart]);
|
|
241
|
-
const defaultNotice = chat ? /* @__PURE__ */ jsx(ThinkRecoveryNotice, { chat }) : null;
|
|
242
|
-
const [dismissedCompaction, setDismissedCompaction] = React.useState(null);
|
|
243
|
-
const landedCompaction = sessionCompaction?.lastCompaction && sessionCompaction.lastCompaction !== dismissedCompaction ? sessionCompaction.lastCompaction : null;
|
|
244
|
-
const sessionCompactionNotice = sessionCompaction?.compacting ? compactingNotice : sessionCompaction?.sessionError ? /* @__PURE__ */ jsxs(TransitionSurface, {
|
|
245
|
-
className: "think-recovery-notice",
|
|
246
|
-
"data-tone": "danger",
|
|
247
|
-
children: ["Compaction failed: ", sessionCompaction.sessionError]
|
|
248
|
-
}) : sessionCompaction?.reloadError ? /* @__PURE__ */ jsx(TransitionSurface, {
|
|
249
|
-
className: "think-recovery-notice",
|
|
250
|
-
"data-tone": "danger",
|
|
251
|
-
children: "Transcript may be out of date. The next completed turn will retry the refresh."
|
|
252
|
-
}) : landedCompaction ? /* @__PURE__ */ jsxs(TransitionSurface, {
|
|
253
|
-
className: "think-recovery-notice",
|
|
254
|
-
children: [compactionSizeText(landedCompaction), " Context usage updates after your next message."]
|
|
255
|
-
}) : null;
|
|
256
|
-
const recoveryActive = chat && (chat.isRecovering || chat.connectionError || chat.error);
|
|
257
|
-
const submit = ({ text, files, references }, send) => {
|
|
258
|
-
setDismissedCompaction(sessionCompaction?.lastCompaction ?? null);
|
|
259
|
-
const fromLinks = composerDraftToPrompt(text);
|
|
260
|
-
const referenceTokens = references?.map(({ trigger, value }) => trigger ? `${trigger}${value}` : value) ?? [];
|
|
261
|
-
const prompt = parseComposerLinks(text).length ? fromLinks : [...referenceTokens, text.trim()].filter(Boolean).join(" ");
|
|
262
|
-
if (!prompt && !files.length) return;
|
|
263
|
-
return send({
|
|
264
|
-
text: prompt,
|
|
265
|
-
files
|
|
266
|
-
});
|
|
267
|
-
};
|
|
268
|
-
const withWorkspaceFileRenderer = (lane) => /* @__PURE__ */ jsx(WorkspaceFileRendererProvider, {
|
|
269
|
-
renderWorkspaceFile,
|
|
270
|
-
children: lane
|
|
271
|
-
});
|
|
272
|
-
if (loading) return withWorkspaceFileRenderer(/* @__PURE__ */ jsx(AgentChat, {
|
|
273
|
-
showComposer: true,
|
|
274
|
-
...props,
|
|
275
|
-
renderPart: resolvedRenderPart,
|
|
276
|
-
messages: EMPTY_DRAFT_MESSAGES,
|
|
277
|
-
status: "ready",
|
|
278
|
-
notice,
|
|
279
|
-
loading: true
|
|
280
|
-
}));
|
|
281
|
-
if (!chat) {
|
|
282
|
-
if (!draft) throw new Error("ThinkChat.Messages must be used inside <ThinkChat.Provider> or <ThinkChat.Root>, or given a `draft`, or set `loading` while one hydrates.");
|
|
283
|
-
return withWorkspaceFileRenderer(/* @__PURE__ */ jsx(AgentChat, {
|
|
284
|
-
...props,
|
|
285
|
-
renderPart: resolvedRenderPart,
|
|
286
|
-
messages: draft.messages ?? EMPTY_DRAFT_MESSAGES,
|
|
287
|
-
status: draft.status ?? "ready",
|
|
288
|
-
notice: notice ?? sessionCompactionNotice,
|
|
289
|
-
onSubmit: (message) => submit(message, draft.onSubmit)
|
|
290
|
-
}));
|
|
291
|
-
}
|
|
292
|
-
return withWorkspaceFileRenderer(/* @__PURE__ */ jsx(AgentChat, {
|
|
293
|
-
...props,
|
|
294
|
-
renderPart: resolvedRenderPart,
|
|
295
|
-
messages: chat.messages,
|
|
296
|
-
status: toAgentChatStatus(chat),
|
|
297
|
-
onStop: chat.stop,
|
|
298
|
-
onApprovalResponse: chat.addToolApprovalResponse,
|
|
299
|
-
thinkStub: resolvedApprovals.thinkStub,
|
|
300
|
-
onExecutionSettled: resolvedApprovals.onExecutionSettled,
|
|
301
|
-
pendingApprovals: resolvedApprovals.pendingApprovals,
|
|
302
|
-
notice: notice ?? (recoveryActive ? defaultNotice : sessionCompactionNotice),
|
|
303
|
-
onRegenerate: (messageId) => void chat.regenerate({ messageId }),
|
|
304
|
-
onSubmit: (message) => submit(message, chat.sendMessage)
|
|
305
|
-
}));
|
|
306
|
-
}
|
|
307
|
-
const EMPTY_DRAFT_MESSAGES = [];
|
|
308
|
-
/**
|
|
309
|
-
* The ambient chat value from `ThinkChat.Root`/`Provider` — for custom tool
|
|
310
|
-
* panels, cards, or composer actions that need `messages`, `status`, or
|
|
311
|
-
* `sendMessage`. Throws outside a provider.
|
|
312
|
-
*/
|
|
313
|
-
function useThinkChat() {
|
|
314
|
-
return useThinkChatContext("useThinkChat");
|
|
315
|
-
}
|
|
316
|
-
/**
|
|
317
|
-
* Namespace entry point. `Root` + `Messages` is the standard surface;
|
|
318
|
-
* `Provider` + `useThinkChat` when the app owns the chat hook; `Activity`,
|
|
319
|
-
* `renderActivityPart`, and `createActivityRenderer` for custom layouts and
|
|
320
|
-
* app-specific tools.
|
|
321
|
-
*/
|
|
322
|
-
const ThinkChat = {
|
|
323
|
-
Provider: ThinkChatProvider,
|
|
324
|
-
Root: ThinkChatRoot,
|
|
325
|
-
Messages: ThinkChatMessages,
|
|
326
|
-
Activity: ThinkChatActivity,
|
|
327
|
-
RecoveryNotice: ThinkRecoveryNotice,
|
|
328
|
-
renderActivityPart: renderThinkChatActivityPart,
|
|
329
|
-
createActivityRenderer: createThinkChatActivityRenderer
|
|
330
|
-
};
|
|
331
|
-
//#endregion
|
|
332
|
-
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,77 +0,0 @@
|
|
|
1
|
-
import { i as AgentMessageRenderPartContext } from "./AgentMessageParts-C7L-Mv9U.js";
|
|
2
|
-
import { r as AgentChatProps } from "./AgentChat-BLmQghkt.js";
|
|
3
|
-
import { l as ThinkChatPart } from "./ThinkChatToolParts-D4qcnnxt.js";
|
|
4
|
-
import { t as ThinkChatActivityDescription } from "./ThinkChatActivitySummary-BtBQgMg6.js";
|
|
5
|
-
import * as React from "react";
|
|
6
|
-
import { DynamicToolUIPart, ToolUIPart, UIMessage } from "ai";
|
|
7
|
-
import { AgentToolRunState } from "agents/agent-tools";
|
|
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: AgentToolRunState<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<AgentChatProps<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
|
|
77
|
-
export { ThinkChatToolRenderers as a, ThinkChatToolRenderer as i, ThinkChatActivityProps as n, createThinkChatActivityRenderer as o, ThinkChatActivityRendererOptions as r, renderThinkChatActivityPart as s, ThinkChatActivity as t };
|
|
@@ -1,28 +0,0 @@
|
|
|
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
|
|
28
|
-
export { useOptionalThinkChatContext as a, ThinkChatValue as i, ThinkChatLiveContext as n, useOptionalThinkChatLive as o, ThinkChatLiveValue as r, useThinkChatContext as s, ThinkChatContext as t };
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { i as ThinkChatValue } from "./ThinkChatContext-COIgzkYp.js";
|
|
2
|
-
import { UIMessage } from "ai";
|
|
3
|
-
|
|
4
|
-
//#region src/components/agents-sdk/ThinkRecoveryNotice.d.ts
|
|
5
|
-
interface ThinkRecoveryNoticeProps<State = unknown, MessageT extends UIMessage = UIMessage> {
|
|
6
|
-
/** The complete `useAgentChat` value from `@cloudflare/think/react`. */
|
|
7
|
-
chat: ThinkChatValue<State, MessageT>;
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* Native Think recovery, connection, and turn-error content for AgentChat's
|
|
11
|
-
* persistent polite notice region. Think exposes no recovery phase, progress,
|
|
12
|
-
* checkpoint, attempt count, or timeline to the browser, so this adapter does
|
|
13
|
-
* not claim those details.
|
|
14
|
-
*/
|
|
15
|
-
declare function ThinkRecoveryNotice<State = unknown, MessageT extends UIMessage = UIMessage>({
|
|
16
|
-
chat
|
|
17
|
-
}: ThinkRecoveryNoticeProps<State, MessageT>): import("react").JSX.Element | null;
|
|
18
|
-
//#endregion
|
|
19
|
-
export { ThinkRecoveryNoticeProps as n, ThinkRecoveryNotice as t };
|