@mcp-b/react-components 0.16.0 → 0.17.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/{AgentChat-CrlpbvQJ.d.ts → AgentChat-CRuMi1Pb.d.ts} +4 -10
- package/dist/AgentMessageParts-CyD2UB3V.d.ts +46 -0
- package/dist/AgentToolRunsContext-BVe4stgw.d.ts +21 -0
- package/dist/{CodeBlock-BmB4Xaqq.js → CodeBlock-Co1noLbC.js} +2 -2
- package/dist/{CodeBlock-BRajW4QU.d.ts → CodeBlock-Dnpr88ZQ.d.ts} +2 -2
- package/dist/Collapsible-N64ASIQr.d.ts +119 -0
- package/dist/{Combobox-B9Fcd6q-.d.ts → Combobox-CYc37s5l.d.ts} +11 -33
- package/dist/{FileTree-CkVbIMWV.js → FileTree-B7bBsUyU.js} +7 -7
- package/dist/{Menu-Bgu-ufb5.d.ts → Menu-L6MZm-7N.d.ts} +15 -56
- package/dist/{Message-BkMdE3bS.js → Message-C4eYRogZ.js} +3 -3
- package/dist/{ModelSelector-SlJNgwKY.js → ModelSelector-BNrZlY_Y.js} +5 -5
- package/dist/{PromptInput-BWTuXMOD.d.ts → PromptInput-OLfXPuHM.d.ts} +39 -67
- package/dist/{ResponsiveSidebarShell-Dd9DCcBT.d.ts → ResponsiveSidebarShell-CsAh4NyL.d.ts} +1 -0
- package/dist/{Select-BeEsefzh.d.ts → Select-CwSqP07Y.d.ts} +14 -42
- package/dist/{Tabs-3Zc4tb9D.d.ts → Tabs-9zddXDQo.d.ts} +5 -19
- package/dist/{ThinkChat-CzC-zNGA.js → ThinkChat-DInElus-.js} +53 -26
- package/dist/{ThinkChatActivity-BFQnb2ct.d.ts → ThinkChatActivity-BgesTfZ4.d.ts} +12 -4
- package/dist/{ThinkChatContext-C3Eb1Xpi.d.ts → ThinkChatContext-DrsZqdaO.d.ts} +1 -1
- package/dist/ThinkRecoveryNotice-DFIcG9UX.d.ts +19 -0
- package/dist/{Toggle-CAAlNl-M.d.ts → Toggle-DaXpe1Lc.d.ts} +1 -1
- package/dist/{ToggleGroup-8hPv-b69.d.ts → ToggleGroup-yseEWkOC.d.ts} +3 -4
- package/dist/{Workspace-D39LxGvP.d.ts → Workspace-C9RFoxcu.d.ts} +1 -1
- package/dist/WorkspaceExplorer-sZewzT2O.d.ts +32 -0
- package/dist/{WorkspaceFile-DOZkPwzu.d.ts → WorkspaceFile-C8UzuSH4.d.ts} +1 -1
- package/dist/{WorkspaceFileView-rSN_yT0L.js → WorkspaceFileView-DNdGAEiX.js} +5 -5
- package/dist/{WorkspaceLink-DIPbXrUM.js → WorkspaceLink-B1ykV1dS.js} +15 -29
- package/dist/class-names-Bk-QLWWI.js +11 -0
- package/dist/components/Accordion.d.ts +5 -15
- package/dist/components/Accordion.js +11 -10
- package/dist/components/Activity.d.ts +5 -10
- package/dist/components/Activity.js +2 -2
- package/dist/components/AgentActivity.js +1 -1
- package/dist/components/AgentActivityPreview.js +2 -2
- package/dist/components/AgentAttention.d.ts +1 -1
- package/dist/components/AgentAttention.js +1 -1
- package/dist/components/AgentChat.d.ts +2 -2
- package/dist/components/AgentChat.js +27 -164
- package/dist/components/AgentChatMessageEditor.js +1 -1
- package/dist/components/AgentConnection.js +4 -4
- package/dist/components/AgentMessageParts.d.ts +2 -0
- package/dist/components/AgentMessageParts.js +119 -0
- package/dist/components/AgentToolDetail.d.ts +55 -0
- package/dist/components/AgentToolDetail.js +98 -0
- package/dist/components/AgentToolRunsContext.d.ts +2 -0
- package/dist/components/AgentToolRunsContext.js +16 -0
- package/dist/components/AlertDialog.d.ts +7 -19
- package/dist/components/AlertDialog.js +21 -32
- package/dist/components/AppTopBar.d.ts +4 -1
- package/dist/components/AppTopBar.js +5 -5
- package/dist/components/Approval.d.ts +102 -0
- package/dist/components/Approval.js +227 -0
- package/dist/components/Artifact.d.ts +2 -4
- package/dist/components/Artifact.js +3 -3
- package/dist/components/Autocomplete.d.ts +11 -33
- package/dist/components/Autocomplete.js +23 -30
- package/dist/components/Avatar.d.ts +3 -11
- package/dist/components/Avatar.js +13 -12
- package/dist/components/BrowserLiveView.js +2 -2
- package/dist/components/BrowserReplay.js +2 -2
- package/dist/components/BrowserRunPanel.js +58 -78
- package/dist/components/Button.js +4 -9
- package/dist/components/ChainOfThought.d.ts +5 -11
- package/dist/components/ChainOfThought.js +3 -2
- package/dist/components/ChatGptSignInScreen.js +3 -3
- package/dist/components/Checkbox.d.ts +2 -4
- package/dist/components/Checkbox.js +6 -5
- package/dist/components/CheckboxGroup.d.ts +1 -3
- package/dist/components/CheckboxGroup.js +15 -14
- package/dist/components/Checkpoint.d.ts +64 -0
- package/dist/components/Checkpoint.js +63 -0
- package/dist/components/CodeBlock.d.ts +1 -1
- package/dist/components/CodeBlock.js +1 -1
- package/dist/components/CodexModelSelector.d.ts +1 -1
- package/dist/components/CodexModelSelector.js +2 -2
- package/dist/components/Collapsible.d.ts +1 -124
- package/dist/components/Collapsible.js +7 -10
- package/dist/components/Combobox.d.ts +1 -1
- package/dist/components/Combobox.js +23 -30
- package/dist/components/Commit.d.ts +5 -11
- package/dist/components/Commit.js +6 -5
- package/dist/components/Context.js +1 -1
- package/dist/components/ContextMenu.d.ts +21 -37
- package/dist/components/ContextMenu.js +34 -51
- package/dist/components/Conversation.d.ts +2 -4
- package/dist/components/Conversation.js +2 -2
- package/dist/components/DescriptionListParts.js +1 -1
- package/dist/components/Dialog.d.ts +6 -17
- package/dist/components/Dialog.js +17 -24
- package/dist/components/EnvironmentVariables.d.ts +1 -1
- package/dist/components/EnvironmentVariables.js +4 -3
- package/dist/components/Field.d.ts +17 -20
- package/dist/components/Field.js +16 -16
- package/dist/components/Fieldset.d.ts +2 -7
- package/dist/components/Fieldset.js +7 -6
- package/dist/components/FileTree.js +1 -1
- package/dist/components/Form.d.ts +1 -4
- package/dist/components/Form.js +3 -2
- package/dist/components/GithubMotionMark.js +1 -1
- package/dist/components/InlineCitation.d.ts +66 -0
- package/dist/components/InlineCitation.js +142 -0
- package/dist/components/Input.d.ts +1 -4
- package/dist/components/Input.js +3 -2
- package/dist/components/Marker.js +1 -1
- package/dist/components/McpConnectionRequest.js +2 -2
- package/dist/components/McpServerPicker.d.ts +1 -1
- package/dist/components/McpServerPicker.js +6 -5
- package/dist/components/Menu.d.ts +1 -1
- package/dist/components/Menu.js +33 -52
- package/dist/components/Menubar.d.ts +22 -43
- package/dist/components/Menubar.js +36 -53
- package/dist/components/Message.d.ts +3 -6
- package/dist/components/Message.js +1 -1
- package/dist/components/MessageScroller.d.ts +1 -1
- package/dist/components/MessageScroller.js +3 -3
- package/dist/components/Meter.d.ts +5 -20
- package/dist/components/Meter.js +11 -10
- package/dist/components/ModelSelector.d.ts +2 -6
- package/dist/components/ModelSelector.js +1 -1
- package/dist/components/NavigationMenu.d.ts +11 -33
- package/dist/components/NavigationMenu.js +23 -30
- package/dist/components/NumberField.d.ts +6 -24
- package/dist/components/NumberField.js +13 -12
- package/dist/components/Plan.d.ts +103 -0
- package/dist/components/Plan.js +113 -0
- package/dist/components/Popover.d.ts +9 -36
- package/dist/components/Popover.js +23 -34
- package/dist/components/PreviewCard.d.ts +6 -24
- package/dist/components/PreviewCard.js +13 -24
- package/dist/components/PricingBillingToggle.js +1 -1
- package/dist/components/PricingFAQ.js +1 -1
- package/dist/components/PricingPlanCard.js +3 -3
- package/dist/components/PricingUsageCalculator.js +2 -2
- package/dist/components/Progress.d.ts +3 -8
- package/dist/components/Progress.js +7 -10
- package/dist/components/PromptInput.d.ts +2 -2
- package/dist/components/PromptInput.js +52 -200
- package/dist/components/Queue.d.ts +6 -16
- package/dist/components/Queue.js +2 -2
- package/dist/components/RadioGroup.d.ts +3 -8
- package/dist/components/RadioGroup.js +7 -10
- package/dist/components/Reasoning.d.ts +4 -8
- package/dist/components/Reasoning.js +3 -3
- package/dist/components/ResizableSidePanel.js +2 -2
- package/dist/components/ResponsiveSidebarShell.d.ts +1 -1
- package/dist/components/ResponsiveSidebarShell.js +4 -3
- package/dist/components/ScrollArea.d.ts +5 -20
- package/dist/components/ScrollArea.js +11 -10
- package/dist/components/Select.d.ts +1 -1
- package/dist/components/Select.js +32 -55
- package/dist/components/Separator.d.ts +1 -5
- package/dist/components/Separator.js +3 -6
- package/dist/components/Slider.d.ts +6 -19
- package/dist/components/Slider.js +15 -14
- package/dist/components/Sources.d.ts +4 -9
- package/dist/components/Sources.js +3 -2
- package/dist/components/Stepper.js +2 -2
- package/dist/components/SubagentRunDetails.js +1 -1
- package/dist/components/SubagentRunIndicator.js +2 -2
- package/dist/components/SubagentRunList.js +1 -2
- package/dist/components/SubagentRunSelector.d.ts +2 -11
- package/dist/components/SubagentRunSelector.js +16 -15
- package/dist/components/Switch.d.ts +2 -5
- package/dist/components/Switch.js +5 -8
- package/dist/components/Tabs.d.ts +2 -2
- package/dist/components/Tabs.js +10 -16
- package/dist/components/Task.d.ts +4 -9
- package/dist/components/Task.js +4 -3
- package/dist/components/Terminal.d.ts +2 -3
- package/dist/components/Terminal.js +3 -3
- package/dist/components/TestResults.d.ts +4 -9
- package/dist/components/TestResults.js +3 -2
- package/dist/components/Textarea.js +1 -1
- package/dist/components/ThemeModeControl.js +1 -1
- package/dist/components/ThinkChat.d.ts +21 -11
- package/dist/components/ThinkChat.js +5 -3
- package/dist/components/ThinkChatActivity.d.ts +1 -1
- package/dist/components/ThinkChatActivity.js +26 -7
- package/dist/components/ThinkChatContext.d.ts +1 -1
- package/dist/components/ThinkChatToolPanels.js +2 -2
- package/dist/components/ThinkExecutionDetail.js +2 -2
- package/dist/components/ThinkExecutionStatus.js +2 -2
- package/dist/components/ThinkExecutionWorkbench.js +2 -2
- package/dist/components/ThinkFullApp.d.ts +33 -9
- package/dist/components/ThinkFullApp.js +118 -64
- package/dist/components/ThinkFullAppViewSwitch.d.ts +1 -1
- package/dist/components/ThinkFullAppViewSwitch.js +2 -2
- package/dist/components/ThinkPendingApproval.d.ts +60 -0
- package/dist/components/ThinkPendingApproval.js +99 -0
- package/dist/components/ThinkRecoveryNotice.d.ts +2 -0
- package/dist/components/ThinkRecoveryNotice.js +40 -0
- package/dist/components/ThinkRoutine.js +1 -0
- package/dist/components/ThinkRoutineBrowser.js +6 -6
- package/dist/components/ThinkRoutineDetail.js +1 -1
- package/dist/components/ThinkRoutineForm.js +2 -2
- package/dist/components/ThinkRoutineLibrary.d.ts +9 -0
- package/dist/components/ThinkRoutineLibrary.js +67 -20
- package/dist/components/ThinkRoutineRuns.js +1 -1
- package/dist/components/ThinkThreadPicker.js +2 -2
- package/dist/components/ThinkThreadShell.d.ts +1 -1
- package/dist/components/Toast.d.ts +7 -28
- package/dist/components/Toast.js +15 -14
- package/dist/components/Toggle.d.ts +1 -1
- package/dist/components/Toggle.js +5 -5
- package/dist/components/ToggleGroup.d.ts +1 -1
- package/dist/components/ToggleGroup.js +8 -15
- package/dist/components/ToolApproval.d.ts +28 -0
- package/dist/components/ToolApproval.js +35 -0
- package/dist/components/ToolInvocation.d.ts +26 -0
- package/dist/components/ToolInvocation.js +72 -0
- package/dist/components/Toolbar.d.ts +6 -24
- package/dist/components/Toolbar.js +13 -12
- package/dist/components/Tooltip.d.ts +3 -9
- package/dist/components/Tooltip.js +7 -10
- package/dist/components/WebPreview.d.ts +1 -2
- package/dist/components/WebPreview.js +4 -3
- package/dist/components/Workspace.d.ts +1 -1
- package/dist/components/Workspace.js +5 -20
- package/dist/components/WorkspaceBrowser.d.ts +1 -1
- package/dist/components/WorkspaceBrowser.js +3 -3
- package/dist/components/WorkspaceExplorer.d.ts +3 -31
- package/dist/components/WorkspaceExplorer.js +3 -3
- package/dist/components/WorkspaceFile.d.ts +1 -1
- package/dist/components/WorkspaceFileView.d.ts +1 -1
- package/dist/components/WorkspaceFileView.js +1 -1
- package/dist/components/WorkspaceHeader.js +1 -1
- package/dist/components/WorkspaceLink.js +1 -1
- package/dist/components/icons.d.ts +2 -2
- package/dist/components/icons.js +2 -2
- package/dist/{copy-button-DtPMgN7e.d.ts → copy-button-CQx3LQAC.d.ts} +1 -2
- package/dist/{copy-button-Dejn5heL.js → copy-button-cYsJBauI.js} +1 -1
- package/dist/{icons-CpfUer49.js → icons--FqCZEc3.js} +3 -2
- package/dist/{icons-GQd1xF4e.d.ts → icons-DpUqY8Mp.d.ts} +6 -1
- package/dist/styles/agent-activity-preview.css +13 -11
- package/dist/styles/agent-attention.css +19 -13
- package/dist/styles/agent-chat.css +0 -41
- package/dist/styles/agent-connection.css +9 -21
- package/dist/styles/agent-tool-detail.css +54 -0
- package/dist/styles/alert-dialog.css +11 -11
- package/dist/styles/app-top-bar.css +9 -7
- package/dist/styles/approval.css +172 -0
- package/dist/styles/artifact.css +0 -12
- package/dist/styles/browser-run-panel.css +5 -2
- package/dist/styles/card.css +8 -8
- package/dist/styles/chain-of-thought.css +5 -13
- package/dist/styles/checkpoint.css +58 -0
- package/dist/styles/codex-model-selector.css +3 -3
- package/dist/styles/combobox.css +3 -2
- package/dist/styles/commit.css +0 -21
- package/dist/styles/context-menu.css +1 -9
- package/dist/styles/dialog.css +11 -11
- package/dist/styles/environment-variables.css +0 -13
- package/dist/styles/field.css +14 -14
- package/dist/styles/fieldset.css +5 -5
- package/dist/styles/file-tree.css +0 -16
- package/dist/styles/index.css +8 -4
- package/dist/styles/inline-citation.css +107 -0
- package/dist/styles/mcp-connection-request.css +3 -3
- package/dist/styles/mcp-server-picker.css +1 -30
- package/dist/styles/menu.css +1 -30
- package/dist/styles/menubar.css +0 -8
- package/dist/styles/message-scroller.css +0 -12
- package/dist/styles/message.css +0 -12
- package/dist/styles/model-selector.css +18 -32
- package/dist/styles/plan.css +127 -0
- package/dist/styles/popover.css +7 -43
- package/dist/styles/preview-card.css +1 -1
- package/dist/styles/prompt-input.css +2 -195
- package/dist/styles/recipes.css +139 -12
- package/dist/styles/responsive-sidebar-shell.css +16 -19
- package/dist/styles/select.css +3 -3
- package/dist/styles/sources.css +6 -14
- package/dist/styles/subagent-run.css +12 -70
- package/dist/styles/task.css +17 -26
- package/dist/styles/test-results.css +17 -23
- package/dist/styles/textarea.css +1 -1
- package/dist/styles/think-execution-workbench.css +9 -9
- package/dist/styles/think-full-app.css +49 -33
- package/dist/styles/think-routine-library.css +30 -38
- package/dist/styles/think-thread-picker.css +15 -0
- package/dist/styles/toast.css +4 -11
- package/dist/styles/tooltip.css +1 -1
- package/dist/styles/utilities.css +31 -0
- package/dist/styles/web-preview.css +0 -21
- package/dist/styles/workspace-explorer.css +20 -65
- package/dist/think-agent-Cip5KAPj.d.ts +7 -0
- package/dist/utils/codex-model-catalog.d.ts +4 -4
- package/dist/utils/structured-code.d.ts +1 -1
- package/dist/workspace-path-L_KmjRjq.js +26 -0
- package/package.json +3 -4
- package/dist/class-names-9UtZwb0J.js +0 -12
- package/dist/components/AppFrame.d.ts +0 -24
- package/dist/components/AppFrame.js +0 -25
- package/dist/components/Shell.d.ts +0 -163
- package/dist/components/Shell.js +0 -137
- package/dist/components/SubagentRun.d.ts +0 -86
- package/dist/components/SubagentRun.js +0 -108
- package/dist/styles/app-frame.css +0 -15
- package/dist/styles/shell.css +0 -122
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { t as cx } from "../class-names-
|
|
2
|
-
import {
|
|
1
|
+
import { t as cx } from "../class-names-Bk-QLWWI.js";
|
|
2
|
+
import { C as InfoIcon, N as PauseIcon, V as SpinnerIcon, X as XIcon, s as CheckIcon } from "../icons--FqCZEc3.js";
|
|
3
3
|
import { Tooltip } from "./Tooltip.js";
|
|
4
4
|
import { formatThinkExecutionStatus, getThinkExecutionRunStatus, getThinkExecutionRunStatusTone } from "./ThinkExecutionRun.js";
|
|
5
5
|
import "react";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { t as cx } from "../class-names-
|
|
2
|
-
import {
|
|
1
|
+
import { t as cx } from "../class-names-Bk-QLWWI.js";
|
|
2
|
+
import { R as RefreshIcon, g as EllipsisIcon } from "../icons--FqCZEc3.js";
|
|
3
3
|
import { Button } from "./Button.js";
|
|
4
4
|
import { Tooltip } from "./Tooltip.js";
|
|
5
5
|
import { Menu } from "./Menu.js";
|
|
@@ -1,21 +1,18 @@
|
|
|
1
1
|
import { l as WorkspaceNavigationAdapter } from "../WorkspaceLink-DK1DWMHe.js";
|
|
2
|
-
import { r as WorkspaceFileAssetResolver } from "../WorkspaceFile-
|
|
3
|
-
import { r as WorkspaceSource } from "../Workspace-
|
|
2
|
+
import { r as WorkspaceFileAssetResolver } from "../WorkspaceFile-C8UzuSH4.js";
|
|
3
|
+
import { r as WorkspaceSource } from "../Workspace-C9RFoxcu.js";
|
|
4
4
|
import { ThinkChatMessagesProps } from "./ThinkChat.js";
|
|
5
|
+
import { t as ThinkAgent } from "../think-agent-Cip5KAPj.js";
|
|
5
6
|
import { t as ThinkExecutionRun } from "../ThinkExecutionRun-ChhWhOoU.js";
|
|
6
7
|
import { ThinkFullAppView } from "./ThinkFullAppViewSwitch.js";
|
|
7
8
|
import { ThinkThreadStatusSummary } from "./ThinkThreadPicker.js";
|
|
8
9
|
import { ThinkThreadShell } from "./ThinkThreadShell.js";
|
|
9
10
|
import * as React from "react";
|
|
10
|
-
import { useAgentChat } from "@cloudflare/think/react";
|
|
11
11
|
import { UIMessage } from "ai";
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
12
|
+
import { useAgentChat } from "@cloudflare/think/react";
|
|
13
|
+
import { UseAgentOptions, useAgent } from "agents/react";
|
|
14
|
+
import { AgentToolRunState } from "agents/agent-tools";
|
|
14
15
|
|
|
15
|
-
//#region src/components/_internal/think-agent.d.ts
|
|
16
|
-
/** Shared complete Think specialization for stateful React agent hooks. */
|
|
17
|
-
type ThinkAgent<State = unknown> = Think<object, State>;
|
|
18
|
-
//#endregion
|
|
19
16
|
//#region src/components/ThinkFullApp.d.ts
|
|
20
17
|
type ThinkFullAppMobileView = "chat" | "workbench";
|
|
21
18
|
type ThinkFullAppAgent<State = unknown> = ThinkAgent<State>;
|
|
@@ -65,6 +62,26 @@ interface ThinkFullAppProps<AgentT extends ThinkFullAppAgent<State>, State = unk
|
|
|
65
62
|
messages?: ThinkChatMessagesProps<MessageT>;
|
|
66
63
|
/** Extra workbench panels appended after the built-in Files and Execution panels. */
|
|
67
64
|
workbenchPanels?: readonly ThinkFullAppPanel<AgentT, State, MessageT>[];
|
|
65
|
+
/** Show retained Agent Tool runs from the parent connection. Defaults to true. */
|
|
66
|
+
showAgentTools?: boolean;
|
|
67
|
+
/** Selected retained run id. Omit for internal selection state. */
|
|
68
|
+
selectedAgentToolRunId?: string | null;
|
|
69
|
+
/** Initial retained run selection when uncontrolled. */
|
|
70
|
+
defaultSelectedAgentToolRunId?: string | null;
|
|
71
|
+
/** Receives the complete upstream retained run selected from a Nanite pill. */
|
|
72
|
+
onSelectedAgentToolRunChange?: (run: AgentToolRunState<MessageT["parts"][number]> | null) => void;
|
|
73
|
+
/**
|
|
74
|
+
* Whole upstream connection options for child routing, including app auth or
|
|
75
|
+
* query configuration. The selected run's `subAgent` segment is appended.
|
|
76
|
+
*/
|
|
77
|
+
agentToolChildConnection?: UseAgentOptions<unknown>;
|
|
78
|
+
/** Child transcript rendering overrides; the composer remains hidden. */
|
|
79
|
+
agentToolMessages?: ThinkChatMessagesProps<MessageT>;
|
|
80
|
+
/**
|
|
81
|
+
* App-owned detail for retained children that do not expose Think chat or
|
|
82
|
+
* require a product-specific route. The whole upstream run stays intact.
|
|
83
|
+
*/
|
|
84
|
+
renderAgentToolDetail?: (run: AgentToolRunState<MessageT["parts"][number]>, onBack: () => void) => React.ReactNode;
|
|
68
85
|
/**
|
|
69
86
|
* Optional parent-owned thread picker/sidebar rendered beside the selected child app.
|
|
70
87
|
* Use the render form to close the compact drawer after selecting a thread.
|
|
@@ -92,22 +109,29 @@ interface ThinkFullAppProps<AgentT extends ThinkFullAppAgent<State>, State = unk
|
|
|
92
109
|
/** Combines ThinkChat with an optional resizable workbench shell. */
|
|
93
110
|
declare function ThinkFullApp<AgentT extends ThinkFullAppAgent<State>, State = unknown, MessageT extends UIMessage = UIMessage>({
|
|
94
111
|
agent,
|
|
112
|
+
agentToolChildConnection,
|
|
113
|
+
agentToolMessages,
|
|
95
114
|
appBarActions,
|
|
96
115
|
appBarLeading,
|
|
97
116
|
appBarTitle,
|
|
98
117
|
chat,
|
|
99
118
|
className,
|
|
100
119
|
defaultMobileView,
|
|
120
|
+
defaultSelectedAgentToolRunId,
|
|
101
121
|
defaultWorkbenchView,
|
|
102
122
|
defaultThreadSidebarOpen,
|
|
103
123
|
messages,
|
|
104
124
|
mobileView,
|
|
105
125
|
onMobileViewChange,
|
|
126
|
+
onSelectedAgentToolRunChange,
|
|
106
127
|
onSelectedExecutionRunChange,
|
|
107
128
|
onThreadSidebarOpenChange,
|
|
108
129
|
onWorkbenchViewChange,
|
|
109
130
|
ref,
|
|
131
|
+
renderAgentToolDetail,
|
|
132
|
+
selectedAgentToolRunId,
|
|
110
133
|
selectedExecutionRun,
|
|
134
|
+
showAgentTools,
|
|
111
135
|
showExecutionWorkbench,
|
|
112
136
|
style,
|
|
113
137
|
threadSidebar,
|
|
@@ -1,25 +1,28 @@
|
|
|
1
|
-
import { t as cx } from "../class-names-
|
|
2
|
-
import {
|
|
1
|
+
import { t as cx } from "../class-names-Bk-QLWWI.js";
|
|
2
|
+
import { K as TerminalIcon, c as ChevronDownIcon, y as FileIcon } from "../icons--FqCZEc3.js";
|
|
3
3
|
import { Button } from "./Button.js";
|
|
4
|
-
import { a as WorkspaceNavigationRestorationBoundary, i as WorkspaceNavigationFocusRestorer, n as WorkspaceNavigationProvider } from "../WorkspaceLink-
|
|
4
|
+
import { a as WorkspaceNavigationRestorationBoundary, i as WorkspaceNavigationFocusRestorer, n as WorkspaceNavigationProvider } from "../WorkspaceLink-B1ykV1dS.js";
|
|
5
5
|
import { n as mergeRefs } from "../merge-refs-DF_7w2x_.js";
|
|
6
6
|
import { AppTopBar } from "./AppTopBar.js";
|
|
7
|
-
import {
|
|
8
|
-
import { o as useThinkPendingApprovals, s as resolveThinkApprovalProps, t as ThinkChat } from "../ThinkChat-
|
|
7
|
+
import { NaniteMark } from "./NaniteScene.js";
|
|
8
|
+
import { o as useThinkPendingApprovals, s as resolveThinkApprovalProps, t as ThinkChat } from "../ThinkChat-DInElus-.js";
|
|
9
9
|
import { useWorkspace } from "./Workspace.js";
|
|
10
10
|
import { WorkspaceExplorer } from "./WorkspaceExplorer.js";
|
|
11
|
+
import { SelectedAgentToolChild } from "./AgentToolDetail.js";
|
|
12
|
+
import { ResizableSidePanel } from "./ResizableSidePanel.js";
|
|
11
13
|
import { ThinkExecutionWorkbench } from "./ThinkExecutionWorkbench.js";
|
|
12
14
|
import { ThinkFullAppViewSwitch } from "./ThinkFullAppViewSwitch.js";
|
|
13
15
|
import { ThinkThreadStatusIndicators } from "./ThinkThreadPicker.js";
|
|
14
16
|
import { ThinkThreadShell } from "./ThinkThreadShell.js";
|
|
15
17
|
import * as React from "react";
|
|
16
18
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
19
|
+
import { useAgentToolEvents } from "agents/react";
|
|
17
20
|
//#region src/components/ThinkFullApp.tsx
|
|
18
21
|
const workbenchPanelDefaultWidth = 340;
|
|
19
22
|
const workbenchPanelMinWidth = 300;
|
|
20
23
|
const workbenchPanelMaxWidth = 600;
|
|
21
24
|
const workbenchPanelKeyboardStep = 24;
|
|
22
|
-
function WorkspacePanel({ config }) {
|
|
25
|
+
function WorkspacePanel({ config, workbenchNavigation }) {
|
|
23
26
|
return /* @__PURE__ */ jsx(WorkspaceExplorer, {
|
|
24
27
|
className: "think-full-app__workbench",
|
|
25
28
|
workspace: useWorkspace({
|
|
@@ -29,13 +32,14 @@ function WorkspacePanel({ config }) {
|
|
|
29
32
|
maxInlineAssetBytes: config.maxInlineAssetBytes
|
|
30
33
|
}),
|
|
31
34
|
navigation: config.navigation,
|
|
32
|
-
leading: config.leading,
|
|
35
|
+
leading: workbenchNavigation || config.leading ? /* @__PURE__ */ jsxs(Fragment, { children: [workbenchNavigation, config.leading] }) : void 0,
|
|
33
36
|
actions: config.actions
|
|
34
37
|
});
|
|
35
38
|
}
|
|
36
39
|
/** Combines ThinkChat with an optional resizable workbench shell. */
|
|
37
|
-
function ThinkFullApp({ agent, appBarActions, appBarLeading, appBarTitle, chat, className, defaultMobileView, defaultWorkbenchView, defaultThreadSidebarOpen, messages, mobileView, onMobileViewChange, onSelectedExecutionRunChange, onThreadSidebarOpenChange, onWorkbenchViewChange, ref, selectedExecutionRun, showExecutionWorkbench = true, style, threadSidebar, threadSidebarOpen, threadStatusSummary, workbenchPanels, workbenchView, workspace, ...props }) {
|
|
40
|
+
function ThinkFullApp({ agent, agentToolChildConnection, agentToolMessages, appBarActions, appBarLeading, appBarTitle, chat, className, defaultMobileView, defaultSelectedAgentToolRunId, defaultWorkbenchView, defaultThreadSidebarOpen, messages, mobileView, onMobileViewChange, onSelectedAgentToolRunChange, onSelectedExecutionRunChange, onThreadSidebarOpenChange, onWorkbenchViewChange, ref, renderAgentToolDetail, selectedAgentToolRunId, selectedExecutionRun, showAgentTools = true, showExecutionWorkbench = true, style, threadSidebar, threadSidebarOpen, threadStatusSummary, workbenchPanels, workbenchView, workspace, ...props }) {
|
|
38
41
|
const appRef = React.useRef(null);
|
|
42
|
+
const agentToolTriggerRef = React.useRef(null);
|
|
39
43
|
const approvals = useThinkPendingApprovals(agent.stub, `${chat.messages.length}:${chat.status}`);
|
|
40
44
|
const resolvedMessages = React.useMemo(() => {
|
|
41
45
|
const approvalProps = resolveThinkApprovalProps({
|
|
@@ -59,6 +63,49 @@ function ThinkFullApp({ agent, appBarActions, appBarLeading, appBarTitle, chat,
|
|
|
59
63
|
]);
|
|
60
64
|
const [innerMobileView, setInnerMobileView] = React.useState(defaultMobileView ?? "chat");
|
|
61
65
|
const [innerWorkbenchView, setInnerWorkbenchView] = React.useState(defaultWorkbenchView ?? "files");
|
|
66
|
+
const [innerSelectedAgentToolRunId, setInnerSelectedAgentToolRunId] = React.useState(defaultSelectedAgentToolRunId ?? null);
|
|
67
|
+
const agentTools = useAgentToolEvents({ agent });
|
|
68
|
+
const agentIdentity = JSON.stringify(agent.path);
|
|
69
|
+
const requestedMobileView = mobileView ?? innerMobileView;
|
|
70
|
+
const requestedWorkbenchView = workbenchView ?? innerWorkbenchView;
|
|
71
|
+
const activeAgentToolRunId = selectedAgentToolRunId ?? innerSelectedAgentToolRunId;
|
|
72
|
+
const selectedAgentToolRun = activeAgentToolRunId ? agentTools.runsById[activeAgentToolRunId] : void 0;
|
|
73
|
+
React.useEffect(() => {
|
|
74
|
+
agentTools.resetLocalState();
|
|
75
|
+
setInnerSelectedAgentToolRunId(null);
|
|
76
|
+
}, [agentIdentity]);
|
|
77
|
+
const setWorkbenchView = React.useCallback((next) => {
|
|
78
|
+
if (workbenchView === void 0) setInnerWorkbenchView(next);
|
|
79
|
+
onWorkbenchViewChange?.(next);
|
|
80
|
+
}, [onWorkbenchViewChange, workbenchView]);
|
|
81
|
+
const setMobileView = React.useCallback((next) => {
|
|
82
|
+
if (mobileView === void 0) setInnerMobileView(next);
|
|
83
|
+
onMobileViewChange?.(next);
|
|
84
|
+
}, [mobileView, onMobileViewChange]);
|
|
85
|
+
const updateSelectedAgentToolRun = React.useCallback((run) => {
|
|
86
|
+
if (selectedAgentToolRunId === void 0) setInnerSelectedAgentToolRunId(run?.runId ?? null);
|
|
87
|
+
onSelectedAgentToolRunChange?.(run);
|
|
88
|
+
}, [onSelectedAgentToolRunChange, selectedAgentToolRunId]);
|
|
89
|
+
const selectAgentToolRun = React.useCallback((run) => {
|
|
90
|
+
const trigger = document.activeElement;
|
|
91
|
+
if (trigger instanceof HTMLElement && appRef.current?.contains(trigger)) agentToolTriggerRef.current = trigger;
|
|
92
|
+
updateSelectedAgentToolRun(run);
|
|
93
|
+
setWorkbenchView("agent-tool");
|
|
94
|
+
setMobileView("workbench");
|
|
95
|
+
}, [
|
|
96
|
+
setMobileView,
|
|
97
|
+
setWorkbenchView,
|
|
98
|
+
updateSelectedAgentToolRun
|
|
99
|
+
]);
|
|
100
|
+
const closeAgentToolDetail = React.useCallback(() => {
|
|
101
|
+
const trigger = agentToolTriggerRef.current;
|
|
102
|
+
agentToolTriggerRef.current = null;
|
|
103
|
+
updateSelectedAgentToolRun(null);
|
|
104
|
+
setMobileView("chat");
|
|
105
|
+
requestAnimationFrame(() => {
|
|
106
|
+
if (trigger?.isConnected) trigger.focus();
|
|
107
|
+
});
|
|
108
|
+
}, [setMobileView, updateSelectedAgentToolRun]);
|
|
62
109
|
const panelContext = React.useMemo(() => ({
|
|
63
110
|
agent,
|
|
64
111
|
chat,
|
|
@@ -68,53 +115,66 @@ function ThinkFullApp({ agent, appBarActions, appBarLeading, appBarTitle, chat,
|
|
|
68
115
|
chat,
|
|
69
116
|
workspace
|
|
70
117
|
]);
|
|
71
|
-
const availableWorkbenchPanels =
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
118
|
+
const availableWorkbenchPanels = [];
|
|
119
|
+
if (workspace !== void 0) availableWorkbenchPanels.push({
|
|
120
|
+
id: "files",
|
|
121
|
+
label: "Files",
|
|
122
|
+
icon: /* @__PURE__ */ jsx(FileIcon, {}),
|
|
123
|
+
render: () => /* @__PURE__ */ jsx(WorkspacePanel, {
|
|
124
|
+
config: workspace,
|
|
125
|
+
workbenchNavigation
|
|
126
|
+
})
|
|
127
|
+
});
|
|
128
|
+
if (showExecutionWorkbench) availableWorkbenchPanels.push({
|
|
129
|
+
id: "execution",
|
|
130
|
+
label: "Execution",
|
|
131
|
+
icon: /* @__PURE__ */ jsx(TerminalIcon, {}),
|
|
132
|
+
render: ({ agent }) => /* @__PURE__ */ jsx(ThinkExecutionWorkbench, {
|
|
133
|
+
source: agent.stub,
|
|
134
|
+
title: "Execution",
|
|
135
|
+
backButton: workbenchNavigation,
|
|
136
|
+
selectedRun: selectedExecutionRun,
|
|
137
|
+
onSelectedRunChange: onSelectedExecutionRunChange
|
|
138
|
+
})
|
|
139
|
+
});
|
|
140
|
+
if (showAgentTools && selectedAgentToolRun) availableWorkbenchPanels.push({
|
|
141
|
+
id: "agent-tool",
|
|
142
|
+
label: "Agent",
|
|
143
|
+
icon: /* @__PURE__ */ jsx(NaniteMark, { index: selectedAgentToolRun.order }),
|
|
144
|
+
render: () => renderAgentToolDetail ? renderAgentToolDetail(selectedAgentToolRun, closeAgentToolDetail) : /* @__PURE__ */ jsx(SelectedAgentToolChild, {
|
|
145
|
+
run: selectedAgentToolRun,
|
|
146
|
+
parentAgent: agent,
|
|
147
|
+
connectionOptions: agentToolChildConnection,
|
|
148
|
+
messages: agentToolMessages,
|
|
149
|
+
onBack: closeAgentToolDetail
|
|
150
|
+
}, selectedAgentToolRun.runId)
|
|
151
|
+
});
|
|
152
|
+
if (workbenchPanels) availableWorkbenchPanels.push(...workbenchPanels);
|
|
100
153
|
const activePanel = availableWorkbenchPanels.find((panel) => panel.id === requestedWorkbenchView) ?? availableWorkbenchPanels[0];
|
|
101
154
|
const activeWorkbenchView = activePanel?.id;
|
|
102
155
|
const hasWorkbench = activePanel !== void 0;
|
|
103
156
|
const activeMobileView = hasWorkbench ? requestedMobileView : "chat";
|
|
104
157
|
const showWorkbenchViewSwitch = availableWorkbenchPanels.length > 1;
|
|
105
158
|
const workbenchViews = availableWorkbenchPanels;
|
|
106
|
-
const
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
const
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
159
|
+
const canEmbedWorkbenchNavigation = activeWorkbenchView === "files" || activeWorkbenchView === "execution";
|
|
160
|
+
const hasApplicationChrome = Boolean(appBarActions || appBarLeading || appBarTitle || threadSidebar);
|
|
161
|
+
const shouldRenderInlineAppBar = !threadSidebar && (hasApplicationChrome || hasWorkbench);
|
|
162
|
+
const hasCompactAppBar = shouldRenderInlineAppBar && !hasApplicationChrome && canEmbedWorkbenchNavigation;
|
|
163
|
+
const hasAppBarRow = shouldRenderInlineAppBar && !hasCompactAppBar;
|
|
164
|
+
const workbenchNavigation = showWorkbenchViewSwitch ? /* @__PURE__ */ jsx(ThinkFullAppViewSwitch, {
|
|
165
|
+
className: "think-full-app__embedded-view-switch",
|
|
166
|
+
views: workbenchViews,
|
|
167
|
+
value: activeWorkbenchView,
|
|
168
|
+
onValueChange: (next) => {
|
|
169
|
+
if (next) setWorkbenchView(next);
|
|
170
|
+
},
|
|
171
|
+
"aria-label": "Workbench views"
|
|
172
|
+
}) : null;
|
|
114
173
|
const renderAppTopBar = (sidebarControls) => /* @__PURE__ */ jsxs(AppTopBar.Root, {
|
|
115
174
|
className: "think-full-app__app-bar",
|
|
116
175
|
"aria-label": "Workbench controls",
|
|
117
176
|
"data-mobile-view": activeMobileView,
|
|
177
|
+
"data-compact-only": hasCompactAppBar ? "true" : void 0,
|
|
118
178
|
children: [
|
|
119
179
|
/* @__PURE__ */ jsxs(AppTopBar.Leading, { children: [sidebarControls?.sidebarToggle, appBarLeading] }),
|
|
120
180
|
appBarTitle || sidebarControls ? /* @__PURE__ */ jsxs(AppTopBar.Title, { children: [appBarTitle ? /* @__PURE__ */ jsx("span", {
|
|
@@ -140,7 +200,7 @@ function ThinkFullApp({ agent, appBarActions, appBarLeading, appBarTitle, chat,
|
|
|
140
200
|
}) : null] }) : null,
|
|
141
201
|
/* @__PURE__ */ jsxs(AppTopBar.Trailing, { children: [
|
|
142
202
|
appBarActions,
|
|
143
|
-
showWorkbenchViewSwitch && activeWorkbenchView ? /* @__PURE__ */ jsx(ThinkFullAppViewSwitch, {
|
|
203
|
+
showWorkbenchViewSwitch && activeWorkbenchView && !canEmbedWorkbenchNavigation ? /* @__PURE__ */ jsx(ThinkFullAppViewSwitch, {
|
|
144
204
|
className: "think-full-app__workbench-view-switch",
|
|
145
205
|
views: workbenchViews,
|
|
146
206
|
value: activeWorkbenchView,
|
|
@@ -178,36 +238,30 @@ function ThinkFullApp({ agent, appBarActions, appBarLeading, appBarTitle, chat,
|
|
|
178
238
|
keyboardStep: workbenchPanelKeyboardStep,
|
|
179
239
|
"data-has-thread-sidebar": threadSidebar ? "true" : "false",
|
|
180
240
|
"data-has-workbench": hasWorkbench ? "true" : "false",
|
|
181
|
-
"data-has-workbench-topbar":
|
|
241
|
+
"data-has-workbench-topbar": hasAppBarRow ? "true" : "false",
|
|
242
|
+
"data-has-compact-app-bar": hasCompactAppBar ? "true" : "false",
|
|
182
243
|
"data-mobile-view": activeMobileView,
|
|
183
244
|
style,
|
|
184
245
|
...props,
|
|
185
246
|
children: [
|
|
186
|
-
|
|
247
|
+
shouldRenderInlineAppBar ? renderAppTopBar() : null,
|
|
187
248
|
/* @__PURE__ */ jsx("section", {
|
|
188
249
|
className: "think-full-app__chat-surface",
|
|
189
250
|
"data-workspace-restoration-scope": "chat",
|
|
190
251
|
"aria-label": "Chat",
|
|
191
252
|
children: /* @__PURE__ */ jsx("div", {
|
|
192
253
|
className: "think-full-app__chat",
|
|
193
|
-
children: /* @__PURE__ */
|
|
254
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
194
255
|
className: "think-full-app__chat-inner",
|
|
195
|
-
children:
|
|
256
|
+
children: /* @__PURE__ */ jsx(ThinkChat.Provider, {
|
|
196
257
|
chat,
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
color: "neutral",
|
|
205
|
-
size: "xs",
|
|
206
|
-
className: "think-full-app__error-dismiss",
|
|
207
|
-
onClick: () => chat.clearError(),
|
|
208
|
-
children: "Dismiss"
|
|
209
|
-
})]
|
|
210
|
-
}) : null]
|
|
258
|
+
agentTools,
|
|
259
|
+
children: /* @__PURE__ */ jsx(ThinkChat.Messages, {
|
|
260
|
+
...resolvedMessages,
|
|
261
|
+
selectedAgentToolRunId: activeAgentToolRunId,
|
|
262
|
+
onAgentToolRunSelect: showAgentTools ? selectAgentToolRun : void 0
|
|
263
|
+
})
|
|
264
|
+
})
|
|
211
265
|
})
|
|
212
266
|
})
|
|
213
267
|
}),
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { n as mergeBaseClassName } from "../class-names-Bk-QLWWI.js";
|
|
2
2
|
import { AppTopBar } from "./AppTopBar.js";
|
|
3
3
|
import { ToggleGroup } from "./ToggleGroup.js";
|
|
4
4
|
import "react";
|
|
@@ -11,7 +11,7 @@ import { jsx } from "react/jsx-runtime";
|
|
|
11
11
|
*/
|
|
12
12
|
function ThinkFullAppViewSwitch({ allowEmpty = false, className, onValueChange, value, views, ...props }) {
|
|
13
13
|
return /* @__PURE__ */ jsx(ToggleGroup.Root, {
|
|
14
|
-
className:
|
|
14
|
+
className: mergeBaseClassName("think-full-app__view-switch", className),
|
|
15
15
|
size: "sm",
|
|
16
16
|
value: value ? [value] : [],
|
|
17
17
|
onValueChange: (nextValue, eventDetails) => {
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { DynamicToolUIPart, ToolUIPart } from "ai";
|
|
3
|
+
import { PendingApproval, Think } from "@cloudflare/think";
|
|
4
|
+
import { AgentStub } from "agents/client";
|
|
5
|
+
import { ProxyToolOutput } from "@cloudflare/codemode";
|
|
6
|
+
|
|
7
|
+
//#region src/components/ThinkPendingApproval.d.ts
|
|
8
|
+
type PausedExecution = Extract<ProxyToolOutput, {
|
|
9
|
+
status: "paused";
|
|
10
|
+
}>;
|
|
11
|
+
/** Structural match for any upstream tool binding of the Codemode execute runtime. */
|
|
12
|
+
declare function getPausedExecution(part: ToolUIPart | DynamicToolUIPart): PausedExecution | undefined;
|
|
13
|
+
interface SharedThinkApprovalProps {
|
|
14
|
+
thinkStub: AgentStub<Think>;
|
|
15
|
+
onSettled?: () => void | Promise<void>;
|
|
16
|
+
onSkip?: () => void;
|
|
17
|
+
count?: number;
|
|
18
|
+
question?: React.ReactNode;
|
|
19
|
+
}
|
|
20
|
+
interface ThinkPendingApprovalProps extends React.HTMLAttributes<HTMLDivElement>, SharedThinkApprovalProps {
|
|
21
|
+
/** Whole entry returned by Think `pendingApprovals()`. */
|
|
22
|
+
approval: PendingApproval;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Durable Think approval adapter. It renders the complete upstream descriptor
|
|
26
|
+
* and resolves only through the full Think stub's idempotent execution RPCs.
|
|
27
|
+
*/
|
|
28
|
+
declare function ThinkPendingApproval({
|
|
29
|
+
approval,
|
|
30
|
+
className,
|
|
31
|
+
count,
|
|
32
|
+
onSettled,
|
|
33
|
+
onSkip,
|
|
34
|
+
question,
|
|
35
|
+
ref,
|
|
36
|
+
thinkStub,
|
|
37
|
+
...props
|
|
38
|
+
}: ThinkPendingApprovalProps & {
|
|
39
|
+
ref?: React.Ref<HTMLDivElement>;
|
|
40
|
+
}): React.JSX.Element;
|
|
41
|
+
interface ThinkExecutionApprovalProps extends Omit<React.HTMLAttributes<HTMLDivElement>, "part">, SharedThinkApprovalProps {
|
|
42
|
+
/** Whole AI SDK tool part whose upstream Codemode output may be paused. */
|
|
43
|
+
part: ToolUIPart | DynamicToolUIPart;
|
|
44
|
+
}
|
|
45
|
+
/** Actionable adapter for Think's in-band paused Codemode execution output. */
|
|
46
|
+
declare function ThinkExecutionApproval({
|
|
47
|
+
className,
|
|
48
|
+
count,
|
|
49
|
+
onSettled,
|
|
50
|
+
onSkip,
|
|
51
|
+
part,
|
|
52
|
+
question,
|
|
53
|
+
ref,
|
|
54
|
+
thinkStub,
|
|
55
|
+
...props
|
|
56
|
+
}: ThinkExecutionApprovalProps & {
|
|
57
|
+
ref?: React.Ref<HTMLDivElement>;
|
|
58
|
+
}): React.JSX.Element | null;
|
|
59
|
+
//#endregion
|
|
60
|
+
export { ThinkExecutionApproval, ThinkExecutionApprovalProps, ThinkPendingApproval, ThinkPendingApprovalProps, getPausedExecution };
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { Approval, ApprovalCount, ApprovalDecision, ApprovalHeader, ApprovalInputPreview, ApprovalPreview, ApprovalPreviewRow, ApprovalQuestion, formatApprovalValue } from "./Approval.js";
|
|
2
|
+
import "react";
|
|
3
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
+
import { getToolName } from "ai";
|
|
5
|
+
import { getToolOutput } from "@cloudflare/think/react";
|
|
6
|
+
//#region src/components/ThinkPendingApproval.tsx
|
|
7
|
+
/** Structural match for any upstream tool binding of the Codemode execute runtime. */
|
|
8
|
+
function getPausedExecution(part) {
|
|
9
|
+
if (part.state !== "output-available") return void 0;
|
|
10
|
+
const output = getToolOutput(part);
|
|
11
|
+
return output?.status === "paused" && typeof output.executionId === "string" ? output : void 0;
|
|
12
|
+
}
|
|
13
|
+
function titleCase(value) {
|
|
14
|
+
return value.split("-").map((word) => `${word.charAt(0).toUpperCase()}${word.slice(1)}`).join(" ");
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Durable Think approval adapter. It renders the complete upstream descriptor
|
|
18
|
+
* and resolves only through the full Think stub's idempotent execution RPCs.
|
|
19
|
+
*/
|
|
20
|
+
function ThinkPendingApproval({ approval, className, count, onSettled, onSkip, question, ref, thinkStub, ...props }) {
|
|
21
|
+
const { descriptor } = approval;
|
|
22
|
+
const permissions = descriptor.permissions.length ? descriptor.permissions.join(", ") : "None requested";
|
|
23
|
+
const source = approval.source === "action" ? "Action" : "Codemode";
|
|
24
|
+
return /* @__PURE__ */ jsxs(Approval, {
|
|
25
|
+
ref,
|
|
26
|
+
className,
|
|
27
|
+
"aria-label": `Approve ${descriptor.action}`,
|
|
28
|
+
...props,
|
|
29
|
+
children: [
|
|
30
|
+
/* @__PURE__ */ jsxs(ApprovalHeader, { children: [/* @__PURE__ */ jsx(ApprovalQuestion, { children: question ?? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
31
|
+
"Do you want to allow ",
|
|
32
|
+
/* @__PURE__ */ jsx("code", { children: descriptor.summary }),
|
|
33
|
+
"?"
|
|
34
|
+
] }) }), count && count > 1 ? /* @__PURE__ */ jsxs(ApprovalCount, { children: ["1 of ", count] }) : null] }),
|
|
35
|
+
/* @__PURE__ */ jsxs(ApprovalPreview, { children: [
|
|
36
|
+
/* @__PURE__ */ jsx(ApprovalPreviewRow, {
|
|
37
|
+
label: "source",
|
|
38
|
+
children: source
|
|
39
|
+
}),
|
|
40
|
+
/* @__PURE__ */ jsx(ApprovalPreviewRow, {
|
|
41
|
+
label: "kind",
|
|
42
|
+
children: titleCase(descriptor.kind)
|
|
43
|
+
}),
|
|
44
|
+
/* @__PURE__ */ jsx(ApprovalPreviewRow, {
|
|
45
|
+
label: "risk",
|
|
46
|
+
children: descriptor.risk ? titleCase(descriptor.risk) : "Not specified"
|
|
47
|
+
}),
|
|
48
|
+
/* @__PURE__ */ jsx(ApprovalPreviewRow, {
|
|
49
|
+
label: "permissions",
|
|
50
|
+
children: permissions
|
|
51
|
+
})
|
|
52
|
+
] }),
|
|
53
|
+
descriptor.input !== void 0 ? /* @__PURE__ */ jsx(ApprovalInputPreview, { input: descriptor.input }) : null,
|
|
54
|
+
/* @__PURE__ */ jsx(ApprovalDecision, {
|
|
55
|
+
subject: descriptor.summary,
|
|
56
|
+
onSkip,
|
|
57
|
+
onDecision: async ({ approved, reason }) => {
|
|
58
|
+
try {
|
|
59
|
+
await (approved ? thinkStub.approveExecution(approval.executionId) : thinkStub.rejectExecution(approval.executionId, reason));
|
|
60
|
+
} finally {
|
|
61
|
+
await onSettled?.();
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}, approval.executionId)
|
|
65
|
+
]
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
/** Actionable adapter for Think's in-band paused Codemode execution output. */
|
|
69
|
+
function ThinkExecutionApproval({ className, count, onSettled, onSkip, part, question, ref, thinkStub, ...props }) {
|
|
70
|
+
const paused = getPausedExecution(part);
|
|
71
|
+
if (!paused) return null;
|
|
72
|
+
const toolName = part.title ?? getToolName(part);
|
|
73
|
+
return /* @__PURE__ */ jsxs(Approval, {
|
|
74
|
+
ref,
|
|
75
|
+
className,
|
|
76
|
+
"aria-label": `Approve ${toolName}`,
|
|
77
|
+
...props,
|
|
78
|
+
children: [
|
|
79
|
+
/* @__PURE__ */ jsxs(ApprovalHeader, { children: [/* @__PURE__ */ jsx(ApprovalQuestion, { children: question ?? /* @__PURE__ */ jsx(Fragment, { children: "The agent's code is paused on these calls. Allow it to continue?" }) }), count && count > 1 ? /* @__PURE__ */ jsxs(ApprovalCount, { children: ["1 of ", count] }) : null] }),
|
|
80
|
+
/* @__PURE__ */ jsx(ApprovalPreview, { children: paused.pending.map((action) => /* @__PURE__ */ jsx(ApprovalPreviewRow, {
|
|
81
|
+
label: `${action.connector}.${action.method}`,
|
|
82
|
+
children: action.args === void 0 ? null : formatApprovalValue(action.args)
|
|
83
|
+
}, action.seq)) }),
|
|
84
|
+
/* @__PURE__ */ jsx(ApprovalDecision, {
|
|
85
|
+
subject: toolName,
|
|
86
|
+
onSkip,
|
|
87
|
+
onDecision: async ({ approved, reason }) => {
|
|
88
|
+
try {
|
|
89
|
+
await (approved ? thinkStub.approveExecution(paused.executionId) : thinkStub.rejectExecution(paused.executionId, reason));
|
|
90
|
+
} finally {
|
|
91
|
+
await onSettled?.();
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}, `${paused.executionId}:${paused.pending[0]?.seq ?? "pending"}`)
|
|
95
|
+
]
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
//#endregion
|
|
99
|
+
export { ThinkExecutionApproval, ThinkPendingApproval, getPausedExecution };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { AgentChatTurnError } from "./AgentChatTurnError.js";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
//#region src/components/ThinkRecoveryNotice.tsx
|
|
4
|
+
function connectionReason(error) {
|
|
5
|
+
return error.reason.trim() || error.message.trim();
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Native Think recovery, connection, and turn-error content for AgentChat's
|
|
9
|
+
* persistent polite notice region. Think exposes no recovery phase, progress,
|
|
10
|
+
* checkpoint, attempt count, or timeline to the browser, so this adapter does
|
|
11
|
+
* not claim those details.
|
|
12
|
+
*/
|
|
13
|
+
function ThinkRecoveryNotice({ chat }) {
|
|
14
|
+
if (chat.isRecovering) return /* @__PURE__ */ jsx("span", {
|
|
15
|
+
"data-slot": "think-recovery-notice",
|
|
16
|
+
children: "Recovering the interrupted response…"
|
|
17
|
+
});
|
|
18
|
+
if (chat.connectionError) {
|
|
19
|
+
const reason = connectionReason(chat.connectionError);
|
|
20
|
+
return /* @__PURE__ */ jsxs("span", {
|
|
21
|
+
"data-slot": "think-recovery-notice",
|
|
22
|
+
"data-tone": "danger",
|
|
23
|
+
children: ["Connection lost", reason ? ` — ${reason}` : "."]
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
if (chat.error) {
|
|
27
|
+
const retryMessageId = chat.messages.findLast((message) => message.role !== "system")?.id;
|
|
28
|
+
return /* @__PURE__ */ jsx(AgentChatTurnError, {
|
|
29
|
+
error: chat.error,
|
|
30
|
+
onDismiss: chat.clearError,
|
|
31
|
+
onRetry: retryMessageId ? () => {
|
|
32
|
+
chat.clearError();
|
|
33
|
+
chat.regenerate({ messageId: retryMessageId });
|
|
34
|
+
} : void 0
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
//#endregion
|
|
40
|
+
export { ThinkRecoveryNotice };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
//#region src/components/ThinkRoutine.ts
|
|
2
2
|
function getThinkRoutineNextRun(routine) {
|
|
3
|
+
if (!routine.enabled) return "Paused";
|
|
3
4
|
return routine.schedule ? formatThinkExecutionDate(routine.schedule.time * 1e3, "Not scheduled") : "Pending reconciliation";
|
|
4
5
|
}
|
|
5
6
|
function formatThinkExecutionDate(value, fallback) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { t as cx } from "../class-names-
|
|
2
|
-
import {
|
|
1
|
+
import { t as cx } from "../class-names-Bk-QLWWI.js";
|
|
2
|
+
import { I as PlusIcon, z as SearchIcon } from "../icons--FqCZEc3.js";
|
|
3
3
|
import { Button } from "./Button.js";
|
|
4
4
|
import { Tooltip } from "./Tooltip.js";
|
|
5
5
|
import { Field } from "./Field.js";
|
|
@@ -34,7 +34,7 @@ function ThinkRoutineBrowser({ className, routines, selectedRoutineId, onSelecte
|
|
|
34
34
|
...props,
|
|
35
35
|
children: [
|
|
36
36
|
/* @__PURE__ */ jsx("h2", {
|
|
37
|
-
className: "think-routine-library__title",
|
|
37
|
+
className: "think-routine-library__title sigvelo-visually-hidden",
|
|
38
38
|
children: "Schedules"
|
|
39
39
|
}),
|
|
40
40
|
/* @__PURE__ */ jsxs("div", {
|
|
@@ -79,7 +79,7 @@ function ThinkRoutineBrowser({ className, routines, selectedRoutineId, onSelecte
|
|
|
79
79
|
className: "think-routine-library__search",
|
|
80
80
|
name: "routine-search",
|
|
81
81
|
children: [/* @__PURE__ */ jsx(Field.Label, {
|
|
82
|
-
className: "think-routine-library__title",
|
|
82
|
+
className: "think-routine-library__title sigvelo-visually-hidden",
|
|
83
83
|
children: "Search schedules"
|
|
84
84
|
}), /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx(SearchIcon, {}), /* @__PURE__ */ jsx(Field.Control, {
|
|
85
85
|
className: "think-routine-browser__search-control",
|
|
@@ -94,7 +94,7 @@ function ThinkRoutineBrowser({ className, routines, selectedRoutineId, onSelecte
|
|
|
94
94
|
})] })]
|
|
95
95
|
}),
|
|
96
96
|
/* @__PURE__ */ jsxs("p", {
|
|
97
|
-
className: "think-routine-library__status",
|
|
97
|
+
className: "think-routine-library__status sigvelo-visually-hidden",
|
|
98
98
|
role: "status",
|
|
99
99
|
"aria-atomic": "true",
|
|
100
100
|
children: [
|
|
@@ -126,7 +126,7 @@ function ThinkRoutineBrowser({ className, routines, selectedRoutineId, onSelecte
|
|
|
126
126
|
"aria-hidden": "true"
|
|
127
127
|
}),
|
|
128
128
|
/* @__PURE__ */ jsx("span", {
|
|
129
|
-
className: "think-routine-library__title",
|
|
129
|
+
className: "think-routine-library__title sigvelo-visually-hidden",
|
|
130
130
|
children: routine.enabled ? "Active" : "Paused"
|
|
131
131
|
}),
|
|
132
132
|
/* @__PURE__ */ jsxs("span", {
|