@mcp-b/react-components 0.58.0 → 0.59.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/{EmployeeChrome-DsdIek0l.d.ts → EmployeeChrome-QSki0QT4.d.ts} +4 -4
- package/dist/{ResponsiveSidebarShell-DoZlSP30.d.ts → ResponsiveSidebarShell-DzBGlRJF.d.ts} +23 -8
- package/dist/{ThinkChatActivity-BkGjTY4r.d.ts → ThinkChatActivity-C4_hPEmb.d.ts} +20 -4
- package/dist/{ThinkChatActivitySummary-DZVy3uQV.d.ts → ThinkChatActivitySummary-ChJ8Iu2T.d.ts} +3 -3
- package/dist/{ThinkChatToolParts-BucHi63O.d.ts → ThinkChatToolParts-BrntWlpa.d.ts} +29 -3
- package/dist/{WorkspaceConceptPanel-97ZyVpZI.js → WorkspaceConceptPanel-D21iRsWm.js} +7 -4
- package/dist/{WorkspaceFileView-M2jC2P4p.js → WorkspaceFileView-CsWwQA1U.js} +80 -74
- package/dist/app-bar-outlet-CNfNzY4Y.js +6 -0
- package/dist/components/agents-sdk/AgentEvent.js +2 -2
- package/dist/components/agents-sdk/BrowserLiveScreen.js +49 -11
- package/dist/components/agents-sdk/EmployeeApp.d.ts +2 -3
- package/dist/components/agents-sdk/EmployeeApp.js +4 -4
- package/dist/components/agents-sdk/EmployeeChat.js +1 -1
- package/dist/components/agents-sdk/EmployeeChrome.d.ts +1 -1
- package/dist/components/agents-sdk/EmployeeChrome.js +213 -201
- package/dist/components/agents-sdk/EmployeeSchedules.d.ts +1 -1
- package/dist/components/agents-sdk/EmployeeSchedules.js +6 -6
- package/dist/components/agents-sdk/EmployeeStartScreen.d.ts +1 -1
- package/dist/components/agents-sdk/ManagerOfficeScreens.d.ts +1 -1
- package/dist/components/agents-sdk/ManagerOfficeScreens.js +5 -18
- package/dist/components/agents-sdk/ModelSelector.js +1 -1
- package/dist/components/agents-sdk/SubagentRunPanel.d.ts +8 -9
- package/dist/components/agents-sdk/SubagentRunPanel.js +133 -122
- package/dist/components/agents-sdk/ThinkChat.d.ts +1 -1
- package/dist/components/agents-sdk/ThinkChat.js +26 -3
- package/dist/components/agents-sdk/ThinkChatActivity.d.ts +1 -1
- package/dist/components/agents-sdk/ThinkChatActivity.js +110 -110
- package/dist/components/agents-sdk/ThinkChatActivitySummary.d.ts +1 -1
- package/dist/components/agents-sdk/ThinkChatActivitySummary.js +183 -40
- package/dist/components/agents-sdk/ThinkChatToolPanels.d.ts +8 -4
- package/dist/components/agents-sdk/ThinkChatToolPanels.js +308 -62
- package/dist/components/agents-sdk/ThinkChatToolParts.d.ts +2 -2
- package/dist/components/agents-sdk/ThinkChatToolParts.js +71 -1
- package/dist/components/agents-sdk/ThinkExecutionWorkbench.d.ts +3 -4
- package/dist/components/agents-sdk/ThinkExecutionWorkbench.js +5 -5
- package/dist/components/agents-sdk/ThinkFullApp.d.ts +1 -1
- package/dist/components/agents-sdk/ThinkFullApp.js +6 -1
- package/dist/components/agents-sdk/ThinkRoutineActions.js +14 -22
- package/dist/components/agents-sdk/ThinkThreadPicker.js +1 -1
- package/dist/components/agents-sdk/WorkspaceExecution.js +138 -131
- package/dist/components/agents-sdk/WorkspaceExplorer.js +3 -3
- package/dist/components/agents-sdk/WorkspaceFileView.js +1 -1
- package/dist/components/agents-sdk/WorkspaceHeader.js +26 -28
- package/dist/components/agents-sdk/WorkspaceProject.js +1 -1
- package/dist/components/agents-sdk/WorkspaceUserScript.js +1 -1
- package/dist/components/ai-sdk/Activity.d.ts +1 -1
- package/dist/components/ai-sdk/Activity.js +84 -6
- package/dist/components/ai-sdk/AgentChatMessageEditor.js +1 -1
- package/dist/components/ai-sdk/Approval.js +2 -1
- package/dist/components/ai-sdk/ComposerLink.js +1 -1
- package/dist/components/ai-sdk/ConnectedAppCards.js +63 -45
- package/dist/components/ai-sdk/Conversation.js +1 -1
- package/dist/components/ai-sdk/ExpansionState.d.ts +16 -6
- package/dist/components/ai-sdk/ExpansionState.js +25 -7
- package/dist/components/ai-sdk/MediaPreviewCard.js +1 -1
- package/dist/components/ai-sdk/MessageScrollerVirtual.js +98 -11
- package/dist/components/ai-sdk/PromptInput.js +7 -3
- package/dist/components/ai-sdk/PromptInputComposerEditor.js +2 -2
- package/dist/components/ai-sdk/Queue.js +1 -1
- package/dist/components/ai-sdk/ToolInvocation.d.ts +8 -0
- package/dist/components/ai-sdk/ToolInvocation.js +45 -19
- package/dist/components/foundations/ToggleGroup.js +1 -1
- package/dist/components/general-purpose/ResponsiveSidebarShell.d.ts +2 -2
- package/dist/components/general-purpose/ResponsiveSidebarShell.js +162 -87
- package/dist/components/general-purpose/Terminal.js +1 -1
- package/dist/components/general-purpose/WebPreview.js +1 -1
- package/dist/components/nanites/AgentToolDetail.d.ts +1 -3
- package/dist/components/nanites/AgentToolDetail.js +30 -39
- package/dist/merge-refs-DAh6reu8.js +26 -0
- package/dist/styles/activity.css +74 -0
- package/dist/styles/agent-chat.css +7 -0
- package/dist/styles/agent-tool-detail.css +2 -17
- package/dist/styles/app-top-bar.css +6 -7
- package/dist/styles/base.css +1 -1
- package/dist/styles/employee-chrome.css +0 -7
- package/dist/styles/message-scroller.css +8 -0
- package/dist/styles/message.css +1 -1
- package/dist/styles/responsive-sidebar-shell.css +10 -25
- package/dist/styles/scroll-area.css +16 -0
- package/dist/styles/scrollbars.css +55 -41
- package/dist/styles/search-field.css +0 -1
- package/dist/styles/subagent-run.css +36 -196
- package/dist/styles/think-chat-tool-panels.css +38 -5
- package/dist/styles/think-execution-workbench.css +4 -0
- package/dist/styles/think-full-app.css +1 -6
- package/dist/styles/workspace-concepts.css +6 -39
- package/dist/styles/workspace-explorer.css +4 -11
- package/package.json +2 -2
- package/dist/components/agents-sdk/SubagentRunDetails.d.ts +0 -40
- package/dist/components/agents-sdk/SubagentRunDetails.js +0 -98
- package/dist/merge-refs-DF_7w2x_.js +0 -18
|
@@ -1,59 +1,49 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useExpansionNumber } from "../ai-sdk/ExpansionState.js";
|
|
2
2
|
import { Activity, ActivityContent, ActivityItem, ActivityItemGroup, ActivityText, ActivityTrigger } from "../ai-sdk/Activity.js";
|
|
3
3
|
import { Button } from "../foundations/Button.js";
|
|
4
4
|
import { MessageResponse } from "../ai-sdk/Message.js";
|
|
5
|
+
import { ToolInvocationDetails } from "../ai-sdk/ToolInvocation.js";
|
|
5
6
|
import { t as NavigationLink } from "../../navigation-link-kqMa81v5.js";
|
|
6
|
-
import { getSubagentRunName } from "./SubagentRunIndicator.js";
|
|
7
|
-
import { useOptionalAgentToolRuns } from "./AgentToolRunsContext.js";
|
|
8
7
|
import { AgentActivityFavicon, AgentActivityIcon } from "./AgentActivity.js";
|
|
8
|
+
import { useOptionalAgentToolRuns } from "./AgentToolRunsContext.js";
|
|
9
|
+
import { getSubagentRunName } from "./SubagentRunIndicator.js";
|
|
9
10
|
import { useOptionalThinkChatLive } from "./ThinkChatContext.js";
|
|
10
|
-
import { isBrowserToolPart, isExecuteToolPart, isFetchToolPart, isPartWorking, isSessionContextToolPart, isSkillToolPart, isThinkChatActivityPart, isWorkspaceToolPart } from "./ThinkChatToolParts.js";
|
|
11
|
-
import { ThinkChatBrowserPanel, ThinkChatExecutePanel, ThinkChatFetchPanel, ThinkChatSessionContextPanel, ThinkChatSkillPanel, ThinkChatWorkspacePanel } from "./ThinkChatToolPanels.js";
|
|
11
|
+
import { isBrowserToolPart, isExecuteToolPart, isFetchToolPart, isPartWorking, isSessionContextToolPart, isSkillToolPart, isThinkChatActivityPart, isWorkspaceToolPart, thinkToolOutcome } from "./ThinkChatToolParts.js";
|
|
12
|
+
import { ThinkChatBrowserPanel, ThinkChatExecutePanel, ThinkChatFetchPanel, ThinkChatFollowUpPanel, ThinkChatSessionContextPanel, ThinkChatSkillPanel, ThinkChatWorkspacePanel } from "./ThinkChatToolPanels.js";
|
|
12
13
|
import { activityPartIconKind, activityPartUrl, deriveThinkChatActivityHeader, describeThinkChatActivityPart } from "./ThinkChatActivitySummary.js";
|
|
13
14
|
import * as React from "react";
|
|
14
15
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
15
|
-
import { getToolName, isReasoningUIPart, isToolUIPart } from "ai";
|
|
16
|
+
import { getStaticToolName, getToolName, isReasoningUIPart, isStaticToolUIPart, isToolUIPart } from "ai";
|
|
16
17
|
//#region src/components/agents-sdk/ThinkChatActivity.tsx
|
|
17
18
|
function activityPartIcon(part) {
|
|
18
19
|
const url = activityPartUrl(part);
|
|
19
|
-
return url ? /* @__PURE__ */ jsx(AgentActivityFavicon, { url }) : /* @__PURE__ */ jsx(AgentActivityIcon, { kind: activityPartIconKind(part) });
|
|
20
|
+
return url ? /* @__PURE__ */ jsx(AgentActivityFavicon, { url }) : /* @__PURE__ */ jsx(AgentActivityIcon, { kind: activityPartIconKind(part, false) });
|
|
20
21
|
}
|
|
21
22
|
/**
|
|
23
|
+
* The expanded run starts with this many trailing steps. Each "show earlier"
|
|
24
|
+
* click adds one batch of at most the same size. The AI SDK clones streamed
|
|
25
|
+
* messages, but structurally shared unchanged parts can skip row work; capping
|
|
26
|
+
* the initial mounted rows still bounds the DOM for a thousands-of-tools run.
|
|
27
|
+
*/
|
|
28
|
+
const VISIBLE_STEP_LIMIT = 100;
|
|
29
|
+
/**
|
|
22
30
|
* One run of agent work as a collapsed Activity block: while streaming the
|
|
23
31
|
* action shimmers with the live step; settled, it becomes a short summary
|
|
24
32
|
* ("Thought, read 2 files and ran a command") over an expandable step log
|
|
25
33
|
* with per-tool panels. Normally reached through `ThinkChat.MessageContent`;
|
|
26
34
|
* exported for apps that lay out messages themselves.
|
|
27
35
|
*/
|
|
28
|
-
|
|
29
|
-
* An expanded run shows at most this many trailing steps before a "show
|
|
30
|
-
* earlier" reveal. Steps inside the live message get new identities on every
|
|
31
|
-
* streamed delta (the AI SDK clones the streaming message), so memoization
|
|
32
|
-
* can't bound an open log — capping the mounted rows is what keeps a
|
|
33
|
-
* thousands-of-tools run expandable.
|
|
34
|
-
*/
|
|
35
|
-
const VISIBLE_STEP_LIMIT = 100;
|
|
36
|
-
function ThinkChatActivity({ parts, defaultOpen, isStreaming, toolRenderers, settledAction, stateKey }) {
|
|
37
|
-
const steps = parts.flatMap((part, index) => {
|
|
38
|
-
const description = describeThinkChatActivityPart(part, toolRenderers);
|
|
39
|
-
if (!description) return [];
|
|
40
|
-
return [{
|
|
41
|
-
key: isToolUIPart(part) ? part.toolCallId : `${part.type}-${index}`,
|
|
42
|
-
description,
|
|
43
|
-
part
|
|
44
|
-
}];
|
|
45
|
-
});
|
|
36
|
+
function ThinkChatActivity({ parts, defaultOpen, isStreaming, toolRenderers, settledAction, isTerminal, stateKey }) {
|
|
46
37
|
const scope = `run:${stateKey}`;
|
|
47
|
-
const [
|
|
48
|
-
|
|
49
|
-
const
|
|
50
|
-
const visibleSteps = hiddenStepCount ? steps.slice(hiddenStepCount) : steps;
|
|
51
|
-
const streaming = isStreaming ?? parts.some(isPartWorking);
|
|
38
|
+
const [visibleStartIndex, setVisibleStartIndex] = useExpansionNumber(`${scope}:visible-start-index`, -1);
|
|
39
|
+
const hasTerminalSignal = isTerminal ?? settledAction !== void 0;
|
|
40
|
+
const streaming = isStreaming ?? (!hasTerminalSignal && parts.some(isPartWorking));
|
|
52
41
|
const header = deriveThinkChatActivityHeader(parts, {
|
|
53
42
|
isStreaming: streaming,
|
|
54
43
|
toolDescribers: toolRenderers
|
|
55
44
|
});
|
|
56
45
|
if (!header) return null;
|
|
46
|
+
const isTerminalTurn = !streaming && hasTerminalSignal;
|
|
57
47
|
return /* @__PURE__ */ jsxs(Activity, {
|
|
58
48
|
isStreaming: streaming,
|
|
59
49
|
defaultOpen,
|
|
@@ -62,98 +52,104 @@ function ThinkChatActivity({ parts, defaultOpen, isStreaming, toolRenderers, set
|
|
|
62
52
|
icon: header.url ? /* @__PURE__ */ jsx(AgentActivityFavicon, { url: header.url }) : /* @__PURE__ */ jsx(AgentActivityIcon, { kind: header.iconKind }),
|
|
63
53
|
action: !streaming && settledAction ? settledAction : header.action,
|
|
64
54
|
detail: !streaming && settledAction ? void 0 : header.detail
|
|
65
|
-
}), /* @__PURE__ */
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
"Show ",
|
|
72
|
-
hiddenStepCount,
|
|
73
|
-
" earlier ",
|
|
74
|
-
hiddenStepCount === 1 ? "step" : "steps"
|
|
75
|
-
]
|
|
76
|
-
}) : null, visibleSteps.map((step) => /* @__PURE__ */ jsx(ThinkChatActivityStep, {
|
|
77
|
-
stateKey: `${scope}:${step.key}`,
|
|
78
|
-
description: step.description,
|
|
79
|
-
part: step.part,
|
|
55
|
+
}), /* @__PURE__ */ jsx(ActivityContent, { children: /* @__PURE__ */ jsx(ThinkChatActivitySteps, {
|
|
56
|
+
parts,
|
|
57
|
+
scope,
|
|
58
|
+
isTerminalTurn,
|
|
59
|
+
visibleStartIndex,
|
|
60
|
+
setVisibleStartIndex,
|
|
80
61
|
toolRenderers
|
|
81
|
-
}
|
|
62
|
+
}) })]
|
|
82
63
|
});
|
|
83
64
|
}
|
|
84
|
-
function
|
|
65
|
+
function ThinkChatActivitySteps({ parts, scope, isTerminalTurn, visibleStartIndex: storedVisibleStart, setVisibleStartIndex: setStoredVisibleStart, toolRenderers }) {
|
|
66
|
+
const steps = parts.flatMap((part, index) => {
|
|
67
|
+
const description = describeThinkChatActivityPart(part, toolRenderers, isTerminalTurn);
|
|
68
|
+
if (!description) return [];
|
|
69
|
+
return [{
|
|
70
|
+
key: isToolUIPart(part) ? part.toolCallId : `${part.type}-${index}`,
|
|
71
|
+
description,
|
|
72
|
+
part
|
|
73
|
+
}];
|
|
74
|
+
});
|
|
75
|
+
const visibleStart = storedVisibleStart < 0 ? Math.max(0, steps.length - VISIBLE_STEP_LIMIT) : Math.min(storedVisibleStart, Math.max(0, steps.length - VISIBLE_STEP_LIMIT));
|
|
76
|
+
const pendingFocusList = React.useRef(null);
|
|
77
|
+
React.useLayoutEffect(() => {
|
|
78
|
+
const activityList = pendingFocusList.current;
|
|
79
|
+
pendingFocusList.current = null;
|
|
80
|
+
if (!activityList?.isConnected || document.activeElement !== document.body) return;
|
|
81
|
+
const firstNewStep = activityList?.firstElementChild;
|
|
82
|
+
if (!(firstNewStep instanceof HTMLElement)) return;
|
|
83
|
+
const focusTarget = firstNewStep.querySelector(".activity__group-trigger") ?? firstNewStep;
|
|
84
|
+
if (focusTarget === firstNewStep) focusTarget.tabIndex = -1;
|
|
85
|
+
focusTarget.focus({ preventScroll: true });
|
|
86
|
+
}, [visibleStart]);
|
|
87
|
+
if (steps.length === 0) return null;
|
|
88
|
+
const hiddenStepCount = visibleStart;
|
|
89
|
+
const visibleSteps = steps.slice(visibleStart);
|
|
90
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [hiddenStepCount > 0 ? /* @__PURE__ */ jsxs(Button, {
|
|
91
|
+
size: "sm",
|
|
92
|
+
variant: "ghost",
|
|
93
|
+
className: "think-chat-activity__show-earlier",
|
|
94
|
+
onClick: (event) => {
|
|
95
|
+
const nextVisibleStart = Math.max(0, visibleStart - VISIBLE_STEP_LIMIT);
|
|
96
|
+
const activityList = event.currentTarget.parentElement;
|
|
97
|
+
pendingFocusList.current = nextVisibleStart === 0 && document.activeElement === event.currentTarget && activityList instanceof HTMLElement ? activityList : null;
|
|
98
|
+
setStoredVisibleStart(nextVisibleStart);
|
|
99
|
+
},
|
|
100
|
+
children: [
|
|
101
|
+
"Show ",
|
|
102
|
+
Math.min(VISIBLE_STEP_LIMIT, hiddenStepCount),
|
|
103
|
+
" earlier",
|
|
104
|
+
" ",
|
|
105
|
+
Math.min(VISIBLE_STEP_LIMIT, hiddenStepCount) === 1 ? "step" : "steps"
|
|
106
|
+
]
|
|
107
|
+
}) : null, visibleSteps.map((step) => /* @__PURE__ */ jsx(MemoizedThinkChatActivityStep, {
|
|
108
|
+
stateKey: `${scope}:${step.key}`,
|
|
109
|
+
description: step.description,
|
|
110
|
+
part: step.part,
|
|
111
|
+
panelRenderer: isToolUIPart(step.part) ? toolRenderers?.[getToolName(step.part)]?.panel : void 0
|
|
112
|
+
}, step.key))] });
|
|
113
|
+
}
|
|
114
|
+
function ThinkChatActivityStep({ description, part, stateKey, panelRenderer }) {
|
|
85
115
|
const icon = activityPartIcon(part);
|
|
86
116
|
const { action: text, detail } = description;
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
if (customPanel === null) return /* @__PURE__ */ jsx(ActivityItem, {
|
|
90
|
-
icon,
|
|
91
|
-
detail,
|
|
92
|
-
children: text
|
|
93
|
-
});
|
|
94
|
-
if (customPanel !== void 0) return /* @__PURE__ */ jsx(ActivityItemGroup, {
|
|
95
|
-
action: text,
|
|
96
|
-
detail,
|
|
97
|
-
icon,
|
|
98
|
-
stateKey,
|
|
99
|
-
children: customPanel
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
if (isReasoningUIPart(part) && part.text.trim()) return /* @__PURE__ */ jsx(ActivityItemGroup, {
|
|
103
|
-
action: text,
|
|
104
|
-
detail,
|
|
105
|
-
icon,
|
|
106
|
-
stateKey,
|
|
107
|
-
children: /* @__PURE__ */ jsx(ActivityText, { children: /* @__PURE__ */ jsx(MessageResponse, { children: part.text }) })
|
|
108
|
-
});
|
|
109
|
-
if (isWorkspaceToolPart(part) && part.type !== "tool-delete") return /* @__PURE__ */ jsx(ActivityItemGroup, {
|
|
110
|
-
action: text,
|
|
111
|
-
detail,
|
|
112
|
-
icon,
|
|
113
|
-
stateKey,
|
|
114
|
-
children: /* @__PURE__ */ jsx(ThinkChatWorkspacePanel, { part })
|
|
115
|
-
});
|
|
116
|
-
if (isSkillToolPart(part)) return /* @__PURE__ */ jsx(ActivityItemGroup, {
|
|
117
|
-
action: text,
|
|
118
|
-
detail,
|
|
119
|
-
icon,
|
|
120
|
-
stateKey,
|
|
121
|
-
children: /* @__PURE__ */ jsx(ThinkChatSkillPanel, { part })
|
|
122
|
-
});
|
|
123
|
-
if (isSessionContextToolPart(part)) return /* @__PURE__ */ jsx(ActivityItemGroup, {
|
|
124
|
-
action: text,
|
|
125
|
-
detail,
|
|
117
|
+
const panel = activityStepPanel(part, panelRenderer);
|
|
118
|
+
if (panel == null) return /* @__PURE__ */ jsx(ActivityItem, {
|
|
126
119
|
icon,
|
|
127
|
-
stateKey,
|
|
128
|
-
children: /* @__PURE__ */ jsx(ThinkChatSessionContextPanel, { part })
|
|
129
|
-
});
|
|
130
|
-
if (isFetchToolPart(part)) return /* @__PURE__ */ jsx(ActivityItemGroup, {
|
|
131
|
-
action: text,
|
|
132
120
|
detail,
|
|
133
|
-
|
|
134
|
-
stateKey,
|
|
135
|
-
children: /* @__PURE__ */ jsx(ThinkChatFetchPanel, { part })
|
|
136
|
-
});
|
|
137
|
-
if (isBrowserToolPart(part)) return /* @__PURE__ */ jsx(ActivityItemGroup, {
|
|
138
|
-
action: text,
|
|
139
|
-
detail,
|
|
140
|
-
icon,
|
|
141
|
-
stateKey,
|
|
142
|
-
children: /* @__PURE__ */ jsx(ThinkChatBrowserPanel, { part })
|
|
121
|
+
children: text
|
|
143
122
|
});
|
|
144
|
-
|
|
123
|
+
return /* @__PURE__ */ jsx(ActivityItemGroup, {
|
|
145
124
|
action: text,
|
|
146
125
|
detail,
|
|
147
126
|
icon,
|
|
148
127
|
stateKey,
|
|
149
|
-
children:
|
|
128
|
+
children: panel
|
|
150
129
|
});
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
130
|
+
}
|
|
131
|
+
/** A step's disclosure body. Null keeps the step a plain row; a host panel
|
|
132
|
+
renderer wins over the built-in tool panels. */
|
|
133
|
+
function activityStepPanel(part, panelRenderer) {
|
|
134
|
+
if (isToolUIPart(part)) {
|
|
135
|
+
const customPanel = panelRenderer?.(part);
|
|
136
|
+
if (customPanel !== void 0) return customPanel;
|
|
137
|
+
}
|
|
138
|
+
if (isReasoningUIPart(part)) return part.text.trim() ? /* @__PURE__ */ jsx(ActivityText, { children: /* @__PURE__ */ jsx(MessageResponse, { children: part.text }) }) : null;
|
|
139
|
+
if (isWorkspaceToolPart(part) && part.type !== "tool-delete") return /* @__PURE__ */ jsx(ThinkChatWorkspacePanel, { part });
|
|
140
|
+
if (isSkillToolPart(part)) return /* @__PURE__ */ jsx(ThinkChatSkillPanel, { part });
|
|
141
|
+
if (isSessionContextToolPart(part)) return /* @__PURE__ */ jsx(ThinkChatSessionContextPanel, { part });
|
|
142
|
+
if (isFetchToolPart(part)) return /* @__PURE__ */ jsx(ThinkChatFetchPanel, { part });
|
|
143
|
+
if (isBrowserToolPart(part)) return /* @__PURE__ */ jsx(ThinkChatBrowserPanel, { part });
|
|
144
|
+
if (isExecuteToolPart(part)) return /* @__PURE__ */ jsx(ThinkChatExecutePanel, { part });
|
|
145
|
+
if (isStaticToolUIPart(part) && getStaticToolName(part) === "follow_up") return /* @__PURE__ */ jsx(ThinkChatFollowUpPanel, { part });
|
|
146
|
+
if (isToolUIPart(part)) return /* @__PURE__ */ jsx(ToolInvocationDetails, {
|
|
147
|
+
part,
|
|
148
|
+
outputError: thinkToolOutcome(part) === "failed"
|
|
155
149
|
});
|
|
150
|
+
return null;
|
|
156
151
|
}
|
|
152
|
+
const MemoizedThinkChatActivityStep = React.memo(ThinkChatActivityStep, (previous, next) => previous.part === next.part && previous.description.action === next.description.action && previous.description.detail === next.description.detail && previous.stateKey === next.stateKey && previous.panelRenderer === next.panelRenderer);
|
|
157
153
|
function terminalActivityAction(message) {
|
|
158
154
|
const metadata = message.metadata;
|
|
159
155
|
if (typeof metadata !== "object" || metadata === null || !("durationMs" in metadata) || typeof metadata.durationMs !== "number" || !Number.isFinite(metadata.durationMs) || metadata.durationMs < 0) return;
|
|
@@ -163,11 +159,12 @@ function terminalActivityAction(message) {
|
|
|
163
159
|
const duration = minutes ? seconds ? `${minutes}m ${seconds}s` : `${minutes}m` : `${totalSeconds}s`;
|
|
164
160
|
const status = "status" in metadata ? metadata.status : void 0;
|
|
165
161
|
if (status === "completed") return `Worked for ${duration}`;
|
|
162
|
+
if (status === "error") return `Response failed after ${duration}`;
|
|
166
163
|
if (status === "aborted") return `You stopped after ${duration}`;
|
|
167
164
|
}
|
|
168
|
-
function ThinkChatActivityGroup({ message, parts, renderAgentToolRunLink, isTrailing, settledAction, toolRenderers, stateKey }) {
|
|
165
|
+
function ThinkChatActivityGroup({ message, parts, renderAgentToolRunLink, isTrailing, isTerminal, settledAction, toolRenderers, stateKey }) {
|
|
169
166
|
const live = useOptionalThinkChatLive();
|
|
170
|
-
const streaming = isTrailing && (live ? live.isStreaming && live.lastMessageId === message.id : parts.some(isPartWorking));
|
|
167
|
+
const streaming = isTrailing && (live ? live.isStreaming && live.lastMessageId === message.id : !isTerminal && parts.some(isPartWorking));
|
|
171
168
|
const agentTools = useOptionalAgentToolRuns();
|
|
172
169
|
const runs = React.useMemo(() => {
|
|
173
170
|
if (!agentTools || !renderAgentToolRunLink) return [];
|
|
@@ -180,6 +177,7 @@ function ThinkChatActivityGroup({ message, parts, renderAgentToolRunLink, isTrai
|
|
|
180
177
|
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(ThinkChatActivity, {
|
|
181
178
|
parts,
|
|
182
179
|
isStreaming: streaming,
|
|
180
|
+
isTerminal,
|
|
183
181
|
settledAction,
|
|
184
182
|
toolRenderers,
|
|
185
183
|
stateKey
|
|
@@ -233,12 +231,14 @@ function createThinkChatActivityRenderer({ excludeTools, renderAgentToolRunLink,
|
|
|
233
231
|
let end = partIndex;
|
|
234
232
|
while (end + 1 < message.parts.length && runStarts[end + 1] === start) end++;
|
|
235
233
|
const isLastActivityRun = runStarts.findLast((runStart) => runStart !== -1) === start;
|
|
234
|
+
const terminalAction = terminalActivityAction(message);
|
|
236
235
|
return /* @__PURE__ */ jsx(ThinkChatActivityGroup, {
|
|
237
236
|
message,
|
|
238
237
|
parts: message.parts.slice(start, end + 1),
|
|
239
238
|
stateKey: `${message.id}:${start}`,
|
|
240
239
|
isTrailing: end === message.parts.length - 1,
|
|
241
|
-
|
|
240
|
+
isTerminal: terminalAction !== void 0,
|
|
241
|
+
settledAction: isLastActivityRun ? terminalAction : void 0,
|
|
242
242
|
toolRenderers,
|
|
243
243
|
renderAgentToolRunLink
|
|
244
244
|
});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as ThinkChatToolLifecycleSnapshot, c as deriveThinkChatActivityHeader, d as summarizeActivitySteps, i as ThinkChatToolDescribers, l as deriveThinkChatToolLifecycleHeader, n as ThinkChatActivityHeader, o as activityPartIconKind, r as ThinkChatToolDescriber, s as activityPartUrl, t as ThinkChatActivityDescription, u as describeThinkChatActivityPart } from "../../ThinkChatActivitySummary-
|
|
1
|
+
import { a as ThinkChatToolLifecycleSnapshot, c as deriveThinkChatActivityHeader, d as summarizeActivitySteps, i as ThinkChatToolDescribers, l as deriveThinkChatToolLifecycleHeader, n as ThinkChatActivityHeader, o as activityPartIconKind, r as ThinkChatToolDescriber, s as activityPartUrl, t as ThinkChatActivityDescription, u as describeThinkChatActivityPart } from "../../ThinkChatActivitySummary-ChJ8Iu2T.js";
|
|
2
2
|
export { ThinkChatActivityDescription, ThinkChatActivityHeader, ThinkChatToolDescriber, ThinkChatToolDescribers, ThinkChatToolLifecycleSnapshot, activityPartIconKind, activityPartUrl, deriveThinkChatActivityHeader, deriveThinkChatToolLifecycleHeader, describeThinkChatActivityPart, summarizeActivitySteps };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { t as capitalize } from "../../format-CWaZEp5o.js";
|
|
2
2
|
import { getToolDisplayName } from "../ai-sdk/ToolPart.js";
|
|
3
3
|
import { t as summarizeToolInput } from "../../summarize-tool-input-CqTcGRYy.js";
|
|
4
|
-
import { displayUrl, isBrowserToolPart, isExecuteToolPart, isFetchToolPart, isPartFailed, isPartWorking, isSessionContextToolFailure, isSessionContextToolPart, isSkillToolPart, isWorkspaceToolPart } from "./ThinkChatToolParts.js";
|
|
5
|
-
import { getToolName, isReasoningUIPart, isToolUIPart } from "ai";
|
|
4
|
+
import { displayUrl, isBrowserToolPart, isExecuteToolPart, isFetchToolPart, isPartFailed, isPartWorking, isSessionContextToolFailure, isSessionContextToolPart, isSkillToolPart, isWorkspaceToolPart, readFollowUpReceipt, thinkToolOutcome } from "./ThinkChatToolParts.js";
|
|
5
|
+
import { getStaticToolName, getToolName, isReasoningUIPart, isStaticToolUIPart, isToolUIPart } from "ai";
|
|
6
6
|
//#region src/components/agents-sdk/ThinkChatActivitySummary.ts
|
|
7
7
|
function described(action, detail) {
|
|
8
8
|
return detail ? {
|
|
@@ -29,15 +29,13 @@ function getToolOutput(part) {
|
|
|
29
29
|
return part.state === "output-available" ? part.output : void 0;
|
|
30
30
|
}
|
|
31
31
|
const HTTP_URL_PATTERN = /https?:\/\/[^\s"'<>)}\]]+/i;
|
|
32
|
+
const HTTP_URL_HINT_SCAN_LIMIT = 2048;
|
|
32
33
|
function firstHttpUrl(value) {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
text = "";
|
|
39
|
-
}
|
|
40
|
-
const raw = HTTP_URL_PATTERN.exec(text)?.[0]?.replace(/[.,;:!?]+$/, "");
|
|
34
|
+
if (typeof value !== "string") return null;
|
|
35
|
+
const text = value.slice(0, HTTP_URL_HINT_SCAN_LIMIT);
|
|
36
|
+
const match = HTTP_URL_PATTERN.exec(text);
|
|
37
|
+
if (match && value.length > HTTP_URL_HINT_SCAN_LIMIT && match.index + match[0].length === HTTP_URL_HINT_SCAN_LIMIT) return null;
|
|
38
|
+
const raw = match?.[0]?.replace(/[.,;:!?]+$/, "");
|
|
41
39
|
if (!raw) return null;
|
|
42
40
|
try {
|
|
43
41
|
return new URL(raw).origin;
|
|
@@ -45,6 +43,28 @@ function firstHttpUrl(value) {
|
|
|
45
43
|
return null;
|
|
46
44
|
}
|
|
47
45
|
}
|
|
46
|
+
function firstHttpUrlHint(value) {
|
|
47
|
+
const direct = firstHttpUrl(value);
|
|
48
|
+
if (direct || typeof value !== "object" || value === null) return direct;
|
|
49
|
+
const readUrlField = (candidate) => {
|
|
50
|
+
if (typeof candidate !== "object" || candidate === null) return null;
|
|
51
|
+
try {
|
|
52
|
+
return firstHttpUrl(Reflect.get(candidate, "url"));
|
|
53
|
+
} catch {
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
try {
|
|
58
|
+
if (!Array.isArray(value)) return readUrlField(value);
|
|
59
|
+
for (let index = 0; index < Math.min(value.length, 8); index++) {
|
|
60
|
+
const url = readUrlField(value[index]);
|
|
61
|
+
if (url) return url;
|
|
62
|
+
}
|
|
63
|
+
} catch {
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
48
68
|
function genericToolLabels(name, hasUrl) {
|
|
49
69
|
const normalized = name.toLowerCase();
|
|
50
70
|
if (normalized.includes("grep") || normalized.includes("find") || normalized.includes("code")) return {
|
|
@@ -111,15 +131,88 @@ function genericToolPresentation(part, hasUrl) {
|
|
|
111
131
|
}
|
|
112
132
|
function describeGenericToolPart(part) {
|
|
113
133
|
const labels = genericToolPresentation(part, activityPartUrl(part) !== null);
|
|
114
|
-
|
|
134
|
+
const outcome = thinkToolOutcome(part);
|
|
135
|
+
return described(outcome === "denied" ? `${getToolDisplayName(part)} denied` : outcome === "failed" ? labels.failed : part.state === "approval-requested" ? `${getToolDisplayName(part)} awaiting approval` : isPartWorking(part) ? labels.working : labels.done, summarizeToolInput(getToolInput(part)));
|
|
136
|
+
}
|
|
137
|
+
function isRecord(value) {
|
|
138
|
+
return typeof value === "object" && value !== null;
|
|
139
|
+
}
|
|
140
|
+
function readString(value, key) {
|
|
141
|
+
if (!isRecord(value)) return void 0;
|
|
142
|
+
const item = value[key];
|
|
143
|
+
return typeof item === "string" ? item : void 0;
|
|
144
|
+
}
|
|
145
|
+
function describeFollowUpPart(part) {
|
|
146
|
+
const outcome = thinkToolOutcome(part);
|
|
147
|
+
if (outcome === "failed") return described("Follow-up failed");
|
|
148
|
+
if (outcome === "denied") return described("Follow-up denied");
|
|
149
|
+
const input = isRecord(part.input) ? part.input : void 0;
|
|
150
|
+
const operation = input?.operation;
|
|
151
|
+
if (operation !== "schedule" && operation !== "list" && operation !== "cancel") return describeGenericToolPart(part);
|
|
152
|
+
if (part.state === "approval-requested") return described("Follow-up awaiting approval");
|
|
153
|
+
if (isPartWorking(part)) return described(operation === "schedule" ? "Scheduling follow-up" : operation === "list" ? "Listing follow-ups" : "Cancelling follow-up", operation === "schedule" ? readString(input, "at") : operation === "cancel" ? readString(input, "id") : void 0);
|
|
154
|
+
if (part.state !== "output-available" || part.preliminary) return described("Follow-up result unavailable");
|
|
155
|
+
const receipt = readFollowUpReceipt(part);
|
|
156
|
+
if (!receipt) return described("Follow-up result unavailable");
|
|
157
|
+
if (receipt.operation === "schedule") return described("Scheduled follow-up");
|
|
158
|
+
if (receipt.operation === "list") return described("Listed follow-ups");
|
|
159
|
+
return described(receipt.cancelled ? "Cancelled follow-up" : "No follow-up cancelled");
|
|
160
|
+
}
|
|
161
|
+
function describeScheduledTasksPart(part) {
|
|
162
|
+
const outcome = thinkToolOutcome(part);
|
|
163
|
+
if (outcome === "failed") return described("Recurring task action failed");
|
|
164
|
+
if (outcome === "denied") return described("Recurring task action denied");
|
|
165
|
+
const input = isRecord(part.input) ? part.input : void 0;
|
|
166
|
+
const operation = input?.operation;
|
|
167
|
+
const actions = {
|
|
168
|
+
list: "Listed scheduled tasks",
|
|
169
|
+
create: "Created recurring task",
|
|
170
|
+
update: "Updated recurring task",
|
|
171
|
+
set_enabled: input?.enabled === false ? "Disabled recurring task" : "Enabled recurring task",
|
|
172
|
+
run_now: "Started recurring task",
|
|
173
|
+
delete: "Deleted recurring task"
|
|
174
|
+
};
|
|
175
|
+
if (!(typeof operation === "string" ? actions[operation] : void 0)) return describeGenericToolPart(part);
|
|
176
|
+
if (part.state === "approval-requested") return described("Scheduled task awaiting approval");
|
|
177
|
+
if (isPartWorking(part)) return described("Managing recurring task", typeof operation === "string" ? operation : void 0);
|
|
178
|
+
if (part.state !== "output-available" || part.preliminary) return described("Scheduled task result unavailable");
|
|
179
|
+
const output = part.output;
|
|
180
|
+
if (operation === "list") return Array.isArray(output) && output.every(isRoutineReceipt) ? described("Listed scheduled tasks") : described("Scheduled task list result unavailable");
|
|
181
|
+
if (operation === "create" || operation === "update") return isRoutineReceipt(output) ? described(operation === "create" ? "Created recurring task" : "Updated recurring task") : described("Scheduled task result unavailable");
|
|
182
|
+
if (operation === "set_enabled") return isRoutineReceipt(output) ? described(output.enabled ? "Enabled recurring task" : "Disabled recurring task") : described("Scheduled task result unavailable");
|
|
183
|
+
if (operation === "delete") return typeof output === "boolean" ? described(output ? "Deleted recurring task" : "Recurring task not found") : described("Scheduled task result unavailable");
|
|
184
|
+
if (operation === "run_now") return describeScheduledTaskRun(output);
|
|
185
|
+
return described("Scheduled task result unavailable");
|
|
186
|
+
}
|
|
187
|
+
function isRoutineReceipt(value) {
|
|
188
|
+
return isRecord(value) && typeof value.id === "string" && value.id.length > 0 && typeof value.name === "string" && value.name.length > 0 && typeof value.enabled === "boolean" && typeof value.revision === "number" && Number.isInteger(value.revision) && value.revision >= 0 && isRecord(value.owner) && typeof value.owner.id === "string" && typeof value.owner.name === "string" && isRecord(value.task) && isRecord(value.parsedSchedule) && Array.isArray(value.runs) && typeof value.createdAt === "number" && Number.isFinite(value.createdAt) && typeof value.updatedAt === "number" && Number.isFinite(value.updatedAt);
|
|
189
|
+
}
|
|
190
|
+
function describeScheduledTaskRun(value) {
|
|
191
|
+
if (!isRecord(value) || typeof value.submissionId !== "string" || value.submissionId.length === 0 || ![
|
|
192
|
+
"pending",
|
|
193
|
+
"running",
|
|
194
|
+
"completed",
|
|
195
|
+
"aborted",
|
|
196
|
+
"skipped",
|
|
197
|
+
"error"
|
|
198
|
+
].includes(String(value.status)) || !isRecord(value.metadata) || typeof value.metadata.routineId !== "string" || typeof value.metadata.threadId !== "string" || typeof value.createdAt !== "number" || !Number.isFinite(value.createdAt)) return described("Scheduled task run result unavailable");
|
|
199
|
+
switch (value.status) {
|
|
200
|
+
case "pending":
|
|
201
|
+
case "running": return described("Started recurring task");
|
|
202
|
+
case "completed": return described("Completed recurring task");
|
|
203
|
+
case "aborted": return described("Recurring task run aborted");
|
|
204
|
+
case "skipped": return described("Recurring task run skipped");
|
|
205
|
+
case "error": return described("Recurring task run failed");
|
|
206
|
+
default: return described("Scheduled task run result unavailable");
|
|
207
|
+
}
|
|
115
208
|
}
|
|
116
209
|
function activityPartUrl(part) {
|
|
117
210
|
if (isFetchToolPart(part)) return firstHttpUrl(part.input?.url ?? part.input?.path);
|
|
118
211
|
if (isBrowserToolPart(part) && part.type !== "tool-browser_execute") return firstHttpUrl(part.input?.url);
|
|
119
|
-
if (isToolUIPart(part) && !isExecuteToolPart(part)) return
|
|
212
|
+
if (isToolUIPart(part) && !isExecuteToolPart(part)) return firstHttpUrlHint(getToolInput(part)) ?? (part.state === "output-available" ? firstHttpUrlHint(getToolOutput(part)) : null);
|
|
120
213
|
return null;
|
|
121
214
|
}
|
|
122
|
-
function activityPartIconKind(part) {
|
|
215
|
+
function activityPartIconKind(part, hasUrl) {
|
|
123
216
|
if (isReasoningUIPart(part)) return "thought";
|
|
124
217
|
if (isWorkspaceToolPart(part)) switch (part.type) {
|
|
125
218
|
case "tool-read":
|
|
@@ -136,7 +229,7 @@ function activityPartIconKind(part) {
|
|
|
136
229
|
if (isFetchToolPart(part)) return "web";
|
|
137
230
|
if (isBrowserToolPart(part)) return part.type === "tool-browser_execute" ? "browser" : "web";
|
|
138
231
|
if (isExecuteToolPart(part)) return "command";
|
|
139
|
-
if (isToolUIPart(part)) return genericToolLabels(getToolName(part), activityPartUrl(part) !== null).icon;
|
|
232
|
+
if (isToolUIPart(part)) return genericToolLabels(getToolName(part), hasUrl ?? activityPartUrl(part) !== null).icon;
|
|
140
233
|
return "tool";
|
|
141
234
|
}
|
|
142
235
|
function activityPartWorkspaceDestination(part) {
|
|
@@ -165,11 +258,31 @@ function activityPartWorkspaceDestination(part) {
|
|
|
165
258
|
* aren't steps (step-start). Exported so a custom `renderPart` can reuse the
|
|
166
259
|
* built-in labels for tools it doesn't override.
|
|
167
260
|
*/
|
|
168
|
-
function describeThinkChatActivityPart(part, toolRenderers) {
|
|
261
|
+
function describeThinkChatActivityPart(part, toolRenderers, isTerminalTurn = false) {
|
|
169
262
|
if (isToolUIPart(part)) {
|
|
170
263
|
const custom = toolRenderers?.[getToolName(part)]?.describe?.(part);
|
|
171
264
|
if (custom !== void 0) return custom ?? null;
|
|
172
265
|
}
|
|
266
|
+
const description = describeBuiltInThinkChatActivityPart(part);
|
|
267
|
+
if (!isTerminalTurn || !description) return description;
|
|
268
|
+
if (isToolUIPart(part)) {
|
|
269
|
+
if (part.state === "input-streaming") return {
|
|
270
|
+
...description,
|
|
271
|
+
action: "Input incomplete"
|
|
272
|
+
};
|
|
273
|
+
if (part.state === "input-available") return {
|
|
274
|
+
...description,
|
|
275
|
+
action: "No result recorded"
|
|
276
|
+
};
|
|
277
|
+
}
|
|
278
|
+
if (isReasoningUIPart(part) && part.state === "streaming" && !summarizeReasoningTitle(part.text)) return {
|
|
279
|
+
...description,
|
|
280
|
+
action: "Thought"
|
|
281
|
+
};
|
|
282
|
+
return description;
|
|
283
|
+
}
|
|
284
|
+
function describeBuiltInThinkChatActivityPart(part) {
|
|
285
|
+
if (isToolUIPart(part) && thinkToolOutcome(part) === "denied" && (isWorkspaceToolPart(part) || isSkillToolPart(part) || isSessionContextToolPart(part) || isFetchToolPart(part) || isBrowserToolPart(part))) return describeGenericToolPart(part);
|
|
173
286
|
if (isReasoningUIPart(part)) {
|
|
174
287
|
const snippet = summarizeReasoningTitle(part.text);
|
|
175
288
|
const action = part.state === "streaming" ? "Thinking…" : "Thought";
|
|
@@ -181,7 +294,14 @@ function describeThinkChatActivityPart(part, toolRenderers) {
|
|
|
181
294
|
if (isFetchToolPart(part)) return describeFetchToolPart(part);
|
|
182
295
|
if (isBrowserToolPart(part)) return describeBrowserToolPart(part);
|
|
183
296
|
if (isExecuteToolPart(part)) return describeExecuteToolPart(part);
|
|
184
|
-
if (isToolUIPart(part))
|
|
297
|
+
if (isToolUIPart(part)) {
|
|
298
|
+
if (isStaticToolUIPart(part)) {
|
|
299
|
+
const name = getStaticToolName(part);
|
|
300
|
+
if (name === "follow_up") return describeFollowUpPart(part);
|
|
301
|
+
if (name === "scheduled_tasks") return describeScheduledTasksPart(part);
|
|
302
|
+
}
|
|
303
|
+
return describeGenericToolPart(part);
|
|
304
|
+
}
|
|
185
305
|
return null;
|
|
186
306
|
}
|
|
187
307
|
function basename(path) {
|
|
@@ -247,7 +367,7 @@ function describeBrowserToolPart(part) {
|
|
|
247
367
|
if (part.type === "tool-browser_execute") {
|
|
248
368
|
const output = part.state === "output-available" ? part.output : void 0;
|
|
249
369
|
if (failed || output?.status === "error") return described("Browser automation failed");
|
|
250
|
-
if (output?.status === "paused") return described(
|
|
370
|
+
if (output?.status === "paused") return described(isHumanWaitPauseValue(output) ? "Browser waiting for human" : "Browser waiting for approval");
|
|
251
371
|
return described(working ? "Using the browser" : "Used the browser");
|
|
252
372
|
}
|
|
253
373
|
const page = displayUrl(part.input?.url) || "a page";
|
|
@@ -263,11 +383,13 @@ function describeBrowserToolPart(part) {
|
|
|
263
383
|
}
|
|
264
384
|
function describeExecuteToolPart(part) {
|
|
265
385
|
const output = part.state === "output-available" ? part.output : void 0;
|
|
266
|
-
if (output
|
|
267
|
-
const
|
|
386
|
+
if (isRecord(output) && output.status === "paused") return described(isHumanWaitPauseValue(output) ? "Code waiting for human" : "Code waiting for approval");
|
|
387
|
+
const outcome = thinkToolOutcome(part);
|
|
388
|
+
if (outcome === "failed") return described("Code failed");
|
|
389
|
+
if (outcome === "denied") return described("Code denied");
|
|
390
|
+
const explicitSummary = isRecord(part.input) ? part.input.summary : void 0;
|
|
268
391
|
const summary = typeof explicitSummary === "string" ? summarizeToolInput({ summary: explicitSummary }) : null;
|
|
269
392
|
if (summary) return described(summary);
|
|
270
|
-
if (isPartFailed(part) || output?.status === "error") return described("Code failed");
|
|
271
393
|
return described(isPartWorking(part) ? "Running code" : "Ran code", summarizeToolInput(part.input));
|
|
272
394
|
}
|
|
273
395
|
function summarizeReasoningTitle(text) {
|
|
@@ -276,9 +398,9 @@ function summarizeReasoningTitle(text) {
|
|
|
276
398
|
const title = line.replace(/^#{1,6}(?:\s+|$)/, "").replace(/(?:\s+|^)#{1,6}$/, "").replace(/^(?:\*\*|__)/, "").replace(/(?:\*\*|__)$/, "").trim();
|
|
277
399
|
return /^[#*_]*$/.test(title) ? null : summarizeToolInput({ summary: title });
|
|
278
400
|
}
|
|
279
|
-
function
|
|
280
|
-
const pending = output.pending
|
|
281
|
-
return pending.length > 0 && pending.every((action) => action.connector === "human" && action.method === "waitFor");
|
|
401
|
+
function isHumanWaitPauseValue(output) {
|
|
402
|
+
const pending = Array.isArray(output.pending) ? output.pending : [];
|
|
403
|
+
return pending.length > 0 && pending.every((action) => isRecord(action) && action.connector === "human" && action.method === "waitFor");
|
|
282
404
|
}
|
|
283
405
|
function describeFetchToolPart(part) {
|
|
284
406
|
const target = part.input?.url ?? part.input?.path ?? "";
|
|
@@ -349,31 +471,52 @@ function summarizeActivitySteps(parts) {
|
|
|
349
471
|
}
|
|
350
472
|
/** Derive the serializable collapsed header from persisted AI SDK message parts. */
|
|
351
473
|
function deriveThinkChatActivityHeader(parts, options = {}) {
|
|
352
|
-
const steps = parts.flatMap((part) => {
|
|
353
|
-
const description = describeThinkChatActivityPart(part, options.toolDescribers);
|
|
354
|
-
return description ? [{
|
|
355
|
-
description,
|
|
356
|
-
part
|
|
357
|
-
}] : [];
|
|
358
|
-
});
|
|
359
|
-
if (steps.length === 0) return null;
|
|
360
474
|
if (options.isStreaming ?? parts.some(isPartWorking)) {
|
|
361
|
-
|
|
475
|
+
let latest;
|
|
476
|
+
for (let index = parts.length - 1; index >= 0; index--) {
|
|
477
|
+
const part = parts[index];
|
|
478
|
+
const description = describeThinkChatActivityPart(part, options.toolDescribers);
|
|
479
|
+
if (description) {
|
|
480
|
+
latest = {
|
|
481
|
+
part,
|
|
482
|
+
description
|
|
483
|
+
};
|
|
484
|
+
break;
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
if (!latest) return null;
|
|
488
|
+
const url = activityPartUrl(latest.part);
|
|
362
489
|
const workspaceDestination = activityPartWorkspaceDestination(latest.part);
|
|
363
490
|
return boundedActivityHeader({
|
|
364
491
|
...latest.description,
|
|
365
|
-
iconKind: activityPartIconKind(latest.part),
|
|
366
|
-
...
|
|
492
|
+
iconKind: activityPartIconKind(latest.part, url !== null),
|
|
493
|
+
...url ? { url } : {},
|
|
367
494
|
...workspaceDestination ? { workspaceDestination } : {}
|
|
368
495
|
});
|
|
369
496
|
}
|
|
370
|
-
|
|
371
|
-
|
|
497
|
+
let firstDescribed;
|
|
498
|
+
for (const part of parts) {
|
|
499
|
+
const description = describeThinkChatActivityPart(part, options.toolDescribers);
|
|
500
|
+
if (description) {
|
|
501
|
+
firstDescribed = {
|
|
502
|
+
part,
|
|
503
|
+
description
|
|
504
|
+
};
|
|
505
|
+
break;
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
if (!firstDescribed?.description) return null;
|
|
509
|
+
const outcomes = parts.flatMap((part) => isToolUIPart(part) ? [thinkToolOutcome(part)] : []);
|
|
510
|
+
const hasFailedTool = outcomes.includes("failed");
|
|
511
|
+
const hasDeniedTool = outcomes.includes("denied");
|
|
512
|
+
if (hasFailedTool || hasDeniedTool) return boundedActivityHeader({
|
|
513
|
+
action: `${summarizeActivitySteps(parts)} · ${hasFailedTool ? "failed" : "denied"}`,
|
|
372
514
|
iconKind: "approval"
|
|
373
515
|
});
|
|
374
|
-
const
|
|
516
|
+
const iconKindFor = (part) => activityPartIconKind(part, activityPartUrl(part) !== null);
|
|
517
|
+
const workspaceRepresentative = parts.find((part) => iconKindFor(part) === "edit" && activityPartWorkspaceDestination(part)) ?? parts.find((part) => activityPartWorkspaceDestination(part));
|
|
375
518
|
const workspaceDestination = workspaceRepresentative ? activityPartWorkspaceDestination(workspaceRepresentative) : null;
|
|
376
|
-
const representative = parts.find((part) =>
|
|
519
|
+
const representative = parts.find((part) => iconKindFor(part) === "edit") ?? parts.find((part) => activityPartUrl(part)) ?? firstDescribed.part;
|
|
377
520
|
if (!representative) return boundedActivityHeader({
|
|
378
521
|
action: summarizeActivitySteps(parts),
|
|
379
522
|
iconKind: "tool"
|
|
@@ -381,7 +524,7 @@ function deriveThinkChatActivityHeader(parts, options = {}) {
|
|
|
381
524
|
const url = activityPartUrl(representative);
|
|
382
525
|
return boundedActivityHeader({
|
|
383
526
|
action: summarizeActivitySteps(parts),
|
|
384
|
-
iconKind: activityPartIconKind(representative),
|
|
527
|
+
iconKind: activityPartIconKind(representative, url !== null),
|
|
385
528
|
...url ? { url } : {},
|
|
386
529
|
...workspaceDestination ? { workspaceDestination } : {}
|
|
387
530
|
});
|
|
@@ -400,7 +543,7 @@ function deriveThinkChatToolLifecycleHeader(snapshot) {
|
|
|
400
543
|
const workspaceDestination = activityPartWorkspaceDestination(part);
|
|
401
544
|
return boundedActivityHeader({
|
|
402
545
|
...describeThinkChatActivityPart(part) ?? described("Used a tool"),
|
|
403
|
-
iconKind: activityPartIconKind(part),
|
|
546
|
+
iconKind: activityPartIconKind(part, url !== null),
|
|
404
547
|
...url ? { url } : {},
|
|
405
548
|
...workspaceDestination ? { workspaceDestination } : {}
|
|
406
549
|
});
|