@athenaintel/react 0.17.0 → 0.19.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/README.md +179 -43
- package/dist/AthenaContext-B1QMhIP-.cjs.map +1 -1
- package/dist/AthenaContext-MOslgOmE.js.map +1 -1
- package/dist/SuperGroupingCard-BsWbHyV_.js +795 -0
- package/dist/SuperGroupingCard-BsWbHyV_.js.map +1 -0
- package/dist/SuperGroupingCard-CRRFUgjN.cjs +794 -0
- package/dist/SuperGroupingCard-CRRFUgjN.cjs.map +1 -0
- package/dist/chat/StatewireApprovalCard.d.ts +59 -2
- package/dist/chat/StatewireClientToolBridge.d.ts +3 -3
- package/dist/chat/StatewireQueuedMessages.d.ts +105 -6
- package/dist/chat/statewire-approval.d.ts +1 -1
- package/dist/chat/statewire-banners.d.ts +5 -9
- package/dist/chat/statewire-client-tools.d.ts +15 -21
- package/dist/chat/super-grouping/CollapsibleGroup.d.ts +52 -11
- package/dist/chat/super-grouping/SuperGroupingCard.d.ts +78 -21
- package/dist/chat/super-grouping/activity-timeline.d.ts +91 -0
- package/dist/chat/super-grouping/grouping-function.d.ts +13 -10
- package/dist/chat/super-grouping/index.d.ts +12 -0
- package/dist/chat/super-grouping/toolkit-map.d.ts +8 -1
- package/dist/chat/use-statewire-approval-request.d.ts +44 -0
- package/dist/chat-ui/header/conversation-history-panel.d.ts +11 -1
- package/dist/chat-ui/index.d.ts +9 -0
- package/dist/chat-ui/mentions/suggestions/data/api-client.d.ts +24 -0
- package/dist/chat-ui/mentions/suggestions/data/sources/index.d.ts +5 -0
- package/dist/chat-ui/mentions/suggestions/data/use-mention-suggestions.d.ts +1 -1
- package/dist/chat-ui/mentions/suggestions/shims.d.ts +0 -4
- package/dist/chat-ui/messages/continue-pill.d.ts +13 -0
- package/dist/chat-ui/messages/message-components.d.ts +7 -2
- package/dist/chat-ui/messages/runtime-message.d.ts +21 -0
- package/dist/chat-ui/messages/statewire-continue-run.d.ts +82 -0
- package/dist/chat-ui/messages/user-edit-composer.d.ts +5 -2
- package/dist/chat-ui/statewire.d.ts +19 -0
- package/dist/chat-ui/thread/chat-composer-dock.d.ts +1 -1
- package/dist/chat-ui/thread/chat-thread-shell.d.ts +7 -1
- package/dist/chat-ui/thread/statewire-history-edge.d.ts +52 -0
- package/dist/chat-ui-statewire.cjs +25 -0
- package/dist/chat-ui-statewire.cjs.map +1 -0
- package/dist/chat-ui-statewire.js +25 -0
- package/dist/chat-ui-statewire.js.map +1 -0
- package/dist/chat-ui.cjs +292 -252
- package/dist/chat-ui.cjs.map +1 -1
- package/dist/chat-ui.js +289 -248
- package/dist/chat-ui.js.map +1 -1
- package/dist/diagnostics/athena-diagnostics.d.ts +1 -1
- package/dist/diagnostics/errors.d.ts +4 -4
- package/dist/index.cjs +20237 -26233
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +25 -14
- package/dist/index.js +18465 -24458
- package/dist/index.js.map +1 -1
- package/dist/lib/athena-urls.d.ts +0 -2
- package/dist/lib/posthog/wrap-posthog-client.d.ts +3 -1
- package/dist/misc-tool-uis-B2e0Okkn.cjs +43 -0
- package/dist/misc-tool-uis-B2e0Okkn.cjs.map +1 -0
- package/dist/misc-tool-uis-gAiQw0Yl.js +44 -0
- package/dist/misc-tool-uis-gAiQw0Yl.js.map +1 -0
- package/dist/provider/AthenaContext.d.ts +0 -7
- package/dist/provider/AthenaProvider.d.ts +28 -52
- package/dist/provider/config.d.ts +19 -15
- package/dist/provider/statewire-lifecycle-context.d.ts +3 -4
- package/dist/provider/statewire-window-context.d.ts +12 -0
- package/dist/provider/types.d.ts +0 -1
- package/dist/runtime/statewire-auth-headers.d.ts +38 -0
- package/dist/runtime/statewire-lifecycle.d.ts +25 -1
- package/dist/runtime/statewire-run-config.d.ts +18 -5
- package/dist/runtime/statewire-session-key.d.ts +13 -0
- package/dist/runtime/useAthenaStatewireRuntime.d.ts +42 -16
- package/dist/statewire-continue-run-D34gS7_1.js +132 -0
- package/dist/statewire-continue-run-D34gS7_1.js.map +1 -0
- package/dist/statewire-continue-run-nE9VCKUh.cjs +131 -0
- package/dist/statewire-continue-run-nE9VCKUh.cjs.map +1 -0
- package/dist/statewire-history-edge-C8uyTEjX.cjs +1711 -0
- package/dist/statewire-history-edge-C8uyTEjX.cjs.map +1 -0
- package/dist/statewire-history-edge-CPohUKMt.js +1712 -0
- package/dist/statewire-history-edge-CPohUKMt.js.map +1 -0
- package/dist/styles.css +1 -1
- package/dist/super-grouping.cjs +22 -0
- package/dist/super-grouping.cjs.map +1 -0
- package/dist/super-grouping.js +22 -0
- package/dist/super-grouping.js.map +1 -0
- package/dist/threads/ThreadList.d.ts +6 -1
- package/dist/threads/mint-thread-id.d.ts +8 -0
- package/dist/threads/statewire-thread-list.d.ts +26 -9
- package/dist/threads/thread-id-context.d.ts +9 -0
- package/dist/threads/use-statewire-conversation-history.d.ts +2 -0
- package/dist/threads/useAthenaThreadManager.d.ts +24 -12
- package/dist/tool-fallback-DkQ3DLkn.js +4281 -0
- package/dist/tool-fallback-DkQ3DLkn.js.map +1 -0
- package/dist/tool-fallback-kfhpJQZa.cjs +4297 -0
- package/dist/tool-fallback-kfhpJQZa.cjs.map +1 -0
- package/dist/tools/index.d.ts +14 -0
- package/dist/tools/misc-tool-uis.d.ts +2 -0
- package/dist/tools/primitives.d.ts +41 -0
- package/dist/tools/tool-fallback.d.ts +78 -6
- package/dist/tools/tool-icons.d.ts +10 -0
- package/dist/tools/tool-uis.d.ts +1 -23
- package/dist/tools.cjs +41 -0
- package/dist/tools.cjs.map +1 -0
- package/dist/tools.js +41 -0
- package/dist/tools.js.map +1 -0
- package/dist/trash-2-B5OaNAL7.cjs +5096 -0
- package/dist/trash-2-B5OaNAL7.cjs.map +1 -0
- package/dist/trash-2-CCwSURL-.js +5081 -0
- package/dist/trash-2-CCwSURL-.js.map +1 -0
- package/dist/{use-rest-conversation-history-BdnG8jEP.cjs → use-rest-conversation-history-Cm8qMRxp.cjs} +985 -5405
- package/dist/use-rest-conversation-history-Cm8qMRxp.cjs.map +1 -0
- package/dist/{use-rest-conversation-history-DpEswBqQ.js → use-rest-conversation-history-veDZS-oL.js} +1035 -5455
- package/dist/use-rest-conversation-history-veDZS-oL.js.map +1 -0
- package/dist/wrench-BEf72cyP.cjs +417 -0
- package/dist/wrench-BEf72cyP.cjs.map +1 -0
- package/dist/wrench-CbrOlVYm.js +418 -0
- package/dist/wrench-CbrOlVYm.js.map +1 -0
- package/dist/x-Dfd2NzK0.cjs +42 -0
- package/dist/x-Dfd2NzK0.cjs.map +1 -0
- package/dist/x-_DntAa_a.js +43 -0
- package/dist/x-_DntAa_a.js.map +1 -0
- package/package.json +29 -11
- package/dist/chat/super-grouping/tool-status-labels.d.ts +0 -1
- package/dist/runtime/converter.d.ts +0 -5
- package/dist/runtime/external-message-converter.d.ts +0 -21
- package/dist/runtime/schemas.d.ts +0 -24
- package/dist/runtime/transport.d.ts +0 -39
- package/dist/runtime/useAthenaRuntime.d.ts +0 -47
- package/dist/threads/adapter.d.ts +0 -42
- package/dist/threads/useActiveThreadStateHydration.d.ts +0 -12
- package/dist/threads/useThreadTitlePolling.d.ts +0 -14
- package/dist/use-rest-conversation-history-BdnG8jEP.cjs.map +0 -1
- package/dist/use-rest-conversation-history-DpEswBqQ.js.map +0 -1
|
@@ -0,0 +1,794 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const jsxRuntime = require("react/jsx-runtime");
|
|
3
|
+
const react = require("@assistant-ui/react");
|
|
4
|
+
const React = require("react");
|
|
5
|
+
const toolFallback = require("./tool-fallback-kfhpJQZa.cjs");
|
|
6
|
+
const trash2 = require("./trash-2-B5OaNAL7.cjs");
|
|
7
|
+
require("@assistant-ui/tap");
|
|
8
|
+
require("statewire");
|
|
9
|
+
require("@assistant-ui/react-statewire");
|
|
10
|
+
require("@assistant-ui/store");
|
|
11
|
+
require("@assistant-ui/core");
|
|
12
|
+
const x = require("./x-Dfd2NzK0.cjs");
|
|
13
|
+
/**
|
|
14
|
+
* @license lucide-react v0.575.0 - ISC
|
|
15
|
+
*
|
|
16
|
+
* This source code is licensed under the ISC license.
|
|
17
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
18
|
+
*/
|
|
19
|
+
const __iconNode = [["path", { d: "m18 15-6-6-6 6", key: "153udz" }]];
|
|
20
|
+
const ChevronUp = trash2.createLucideIcon("chevron-up", __iconNode);
|
|
21
|
+
const NO_TOOLS = /* @__PURE__ */ new Set();
|
|
22
|
+
function toolCallStatus(part, messageStatus) {
|
|
23
|
+
if (part.result !== void 0) return { type: "complete" };
|
|
24
|
+
if ((messageStatus == null ? void 0 : messageStatus.type) === "incomplete") {
|
|
25
|
+
return {
|
|
26
|
+
type: "incomplete",
|
|
27
|
+
reason: messageStatus.reason === "tool-calls" ? "other" : messageStatus.reason,
|
|
28
|
+
error: messageStatus.error
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
if ((messageStatus == null ? void 0 : messageStatus.type) === "complete") return { type: "complete" };
|
|
32
|
+
if ((messageStatus == null ? void 0 : messageStatus.type) === "requires-action") {
|
|
33
|
+
return { type: "requires-action", reason: messageStatus.reason };
|
|
34
|
+
}
|
|
35
|
+
if ((messageStatus == null ? void 0 : messageStatus.type) === "running") return { type: "running" };
|
|
36
|
+
return void 0;
|
|
37
|
+
}
|
|
38
|
+
function getActivityToolState(part, messageStatus, { waitingTools = NO_TOOLS, passThroughTools = NO_TOOLS } = {}) {
|
|
39
|
+
var _a, _b, _c, _d;
|
|
40
|
+
if (((_a = part.approval) == null ? void 0 : _a.approved) === false || toolFallback.readRejectedToolResult(part.result) !== null) {
|
|
41
|
+
return "rejected";
|
|
42
|
+
}
|
|
43
|
+
if (((_b = part.approval) == null ? void 0 : _b.resolution) === "cancelled" || ((_c = part.approval) == null ? void 0 : _c.resolution) === "expired") {
|
|
44
|
+
return "cancelled";
|
|
45
|
+
}
|
|
46
|
+
const unresolved = part.result === void 0;
|
|
47
|
+
const messageIsActive = messageStatus === void 0 || messageStatus.type === "running" || messageStatus.type === "requires-action";
|
|
48
|
+
if (unresolved && (((_d = part.interrupt) == null ? void 0 : _d.type) === "human" || part.approval !== void 0 && part.approval.approved === void 0 && part.approval.resolution === void 0 || waitingTools.has(part.toolName) && messageIsActive)) {
|
|
49
|
+
return "waiting";
|
|
50
|
+
}
|
|
51
|
+
const classification = toolFallback.classifyToolResult({
|
|
52
|
+
status: toolCallStatus(part, messageStatus),
|
|
53
|
+
result: part.result,
|
|
54
|
+
isError: part.isError,
|
|
55
|
+
passThroughPayload: passThroughTools.has(part.toolName)
|
|
56
|
+
});
|
|
57
|
+
if (classification.state === "requires-action") return "waiting";
|
|
58
|
+
return classification.state;
|
|
59
|
+
}
|
|
60
|
+
function buildActivityTimeline(content, messageStatus, options = {}) {
|
|
61
|
+
if (!(content == null ? void 0 : content.length)) return [];
|
|
62
|
+
const lastPartIndex = content.length - 1;
|
|
63
|
+
const timeline = [];
|
|
64
|
+
for (let index = 0; index < content.length; index += 1) {
|
|
65
|
+
const part = content[index];
|
|
66
|
+
if (part.type === "tool-call") {
|
|
67
|
+
timeline.push({
|
|
68
|
+
kind: "tool",
|
|
69
|
+
toolName: part.toolName,
|
|
70
|
+
state: getActivityToolState(part, messageStatus, options)
|
|
71
|
+
});
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
if (part.type !== "reasoning") continue;
|
|
75
|
+
const text = typeof part.text === "string" ? part.text : "";
|
|
76
|
+
const stillStreaming = (messageStatus == null ? void 0 : messageStatus.type) === "running" && index === lastPartIndex;
|
|
77
|
+
if (!stillStreaming && text.trim() === "") continue;
|
|
78
|
+
timeline.push({ kind: "reasoning", text, state: stillStreaming ? "running" : "complete" });
|
|
79
|
+
}
|
|
80
|
+
return timeline;
|
|
81
|
+
}
|
|
82
|
+
function countActivityTools(timeline) {
|
|
83
|
+
return timeline.reduce((count, item) => item.kind === "tool" ? count + 1 : count, 0);
|
|
84
|
+
}
|
|
85
|
+
function resolveActivityPhase(status, timeline, { waitingForInput = false } = {}) {
|
|
86
|
+
if (waitingForInput || (status == null ? void 0 : status.type) === "requires-action" || timeline.some((item) => item.kind === "tool" && item.state === "waiting")) {
|
|
87
|
+
return "waiting";
|
|
88
|
+
}
|
|
89
|
+
if ((status == null ? void 0 : status.type) === "running") return "running";
|
|
90
|
+
if ((status == null ? void 0 : status.type) === "incomplete") return "error";
|
|
91
|
+
return "complete";
|
|
92
|
+
}
|
|
93
|
+
function getActivityItemLabel(item, resolveToolDisplayName) {
|
|
94
|
+
if (item.kind === "reasoning") {
|
|
95
|
+
return item.state === "running" ? "Thinking" : "Thought through the next step";
|
|
96
|
+
}
|
|
97
|
+
return toolFallback.toolStatusLabel(item.toolName, item.state, resolveToolDisplayName == null ? void 0 : resolveToolDisplayName(item.toolName));
|
|
98
|
+
}
|
|
99
|
+
function getActivitySummary(timeline) {
|
|
100
|
+
const toolCount = countActivityTools(timeline);
|
|
101
|
+
const hasIssue = timeline.some(
|
|
102
|
+
(item) => item.kind === "tool" && (item.state === "error" || item.state === "rejected")
|
|
103
|
+
);
|
|
104
|
+
if (hasIssue) return "Completed with issues";
|
|
105
|
+
if (timeline.some((item) => item.kind === "tool" && item.state === "cancelled")) {
|
|
106
|
+
return "Action cancelled";
|
|
107
|
+
}
|
|
108
|
+
if (timeline.some((item) => item.kind === "tool" && item.state === "paused")) {
|
|
109
|
+
return "Paused during tool use";
|
|
110
|
+
}
|
|
111
|
+
if (toolCount > 0) return `Used ${toolCount} ${toolCount === 1 ? "tool" : "tools"}`;
|
|
112
|
+
return "Reasoning complete";
|
|
113
|
+
}
|
|
114
|
+
function getFinalText(content) {
|
|
115
|
+
var _a;
|
|
116
|
+
if (!(content == null ? void 0 : content.length)) return null;
|
|
117
|
+
let lastToolIndex = -1;
|
|
118
|
+
for (let index = content.length - 1; index >= 0; index -= 1) {
|
|
119
|
+
if (((_a = content[index]) == null ? void 0 : _a.type) === "tool-call") {
|
|
120
|
+
lastToolIndex = index;
|
|
121
|
+
break;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
const texts = [];
|
|
125
|
+
for (let index = lastToolIndex + 1; index < content.length; index += 1) {
|
|
126
|
+
const part = content[index];
|
|
127
|
+
if ((part == null ? void 0 : part.type) === "text" && part.text) texts.push(part.text);
|
|
128
|
+
}
|
|
129
|
+
return texts.length > 0 ? texts.join("\n\n") : null;
|
|
130
|
+
}
|
|
131
|
+
function excludeFinalTextFromGroups(grouping) {
|
|
132
|
+
return (parts) => {
|
|
133
|
+
const lastToolIndex = parts.findLastIndex((part) => (part == null ? void 0 : part.type) === "tool-call");
|
|
134
|
+
return grouping(parts).map((group) => ({
|
|
135
|
+
...group,
|
|
136
|
+
indices: group.indices.filter(
|
|
137
|
+
(index) => {
|
|
138
|
+
var _a;
|
|
139
|
+
return ((_a = parts[index]) == null ? void 0 : _a.type) !== "text" || index <= lastToolIndex;
|
|
140
|
+
}
|
|
141
|
+
)
|
|
142
|
+
})).filter((group) => group.indices.length > 0);
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
const createToolBasedGroupingFunction = (getToolGroupKey) => (parts) => {
|
|
146
|
+
const calledToolNames = /* @__PURE__ */ new Set();
|
|
147
|
+
for (const part of parts) {
|
|
148
|
+
if (part.type === "tool-call" && part.toolName) calledToolNames.add(part.toolName);
|
|
149
|
+
}
|
|
150
|
+
const groups = [];
|
|
151
|
+
let currentGroup = null;
|
|
152
|
+
for (let idx = 0; idx < parts.length; idx++) {
|
|
153
|
+
const part = parts[idx];
|
|
154
|
+
if ((part == null ? void 0 : part.type) === "reasoning") {
|
|
155
|
+
if (currentGroup) {
|
|
156
|
+
currentGroup.indices.push(idx);
|
|
157
|
+
} else {
|
|
158
|
+
groups.push({ groupKey: void 0, indices: [idx] });
|
|
159
|
+
}
|
|
160
|
+
continue;
|
|
161
|
+
}
|
|
162
|
+
let key;
|
|
163
|
+
if ((part == null ? void 0 : part.type) === "tool-call" && part.toolName) {
|
|
164
|
+
key = getToolGroupKey(part.toolName, {
|
|
165
|
+
preferredGroupKey: currentGroup == null ? void 0 : currentGroup.groupKey,
|
|
166
|
+
calledToolNames
|
|
167
|
+
});
|
|
168
|
+
} else if ((part == null ? void 0 : part.type) === "text") {
|
|
169
|
+
const prevKey = currentGroup == null ? void 0 : currentGroup.groupKey;
|
|
170
|
+
let nextKey;
|
|
171
|
+
for (let lookIdx = idx + 1; lookIdx < parts.length; lookIdx++) {
|
|
172
|
+
const lookPart = parts[lookIdx];
|
|
173
|
+
if ((lookPart == null ? void 0 : lookPart.type) === "reasoning" || (lookPart == null ? void 0 : lookPart.type) === "text") continue;
|
|
174
|
+
if ((lookPart == null ? void 0 : lookPart.type) === "tool-call" && lookPart.toolName) {
|
|
175
|
+
nextKey = getToolGroupKey(lookPart.toolName, {
|
|
176
|
+
preferredGroupKey: currentGroup == null ? void 0 : currentGroup.groupKey,
|
|
177
|
+
calledToolNames
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
break;
|
|
181
|
+
}
|
|
182
|
+
if (prevKey && nextKey && prevKey === nextKey) {
|
|
183
|
+
key = prevKey;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
if (currentGroup && currentGroup.groupKey === key) {
|
|
187
|
+
currentGroup.indices.push(idx);
|
|
188
|
+
} else {
|
|
189
|
+
if (currentGroup) groups.push(currentGroup);
|
|
190
|
+
currentGroup = { groupKey: key, indices: [idx] };
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
if (currentGroup) groups.push(currentGroup);
|
|
194
|
+
return groups;
|
|
195
|
+
};
|
|
196
|
+
const DEFAULT_TOOL_TO_TOOLKIT = {
|
|
197
|
+
// Web
|
|
198
|
+
search: "Web",
|
|
199
|
+
browse: "Web",
|
|
200
|
+
web_search: "Web",
|
|
201
|
+
search_web: "Web",
|
|
202
|
+
web_scrape: "Web",
|
|
203
|
+
scrape_web: "Web",
|
|
204
|
+
// Document
|
|
205
|
+
create_new_document: "Document",
|
|
206
|
+
create_document_from_markdown: "Document",
|
|
207
|
+
append_markdown_to_athena_document: "Document",
|
|
208
|
+
replace_markdown_in_athena_document: "Document",
|
|
209
|
+
delete_blocks_from_athena_document: "Document",
|
|
210
|
+
convert_athena_doc_to_pdf: "Document",
|
|
211
|
+
convert_to_pdf: "Document",
|
|
212
|
+
// Word document (Studio)
|
|
213
|
+
CreateDocument: "Document (Word)",
|
|
214
|
+
CreateParagraph: "Document (Word)",
|
|
215
|
+
OpenDocument: "Document (Word)",
|
|
216
|
+
execute_word_commands: "Document (Word)",
|
|
217
|
+
create_new_word_document: "Document (Word)",
|
|
218
|
+
// Spreadsheet
|
|
219
|
+
create_new_sheet: "Spreadsheet",
|
|
220
|
+
update_sheet_range: "Spreadsheet",
|
|
221
|
+
format_sheet_range: "Spreadsheet",
|
|
222
|
+
bulk_format_sheet_range: "Spreadsheet",
|
|
223
|
+
create_table: "Spreadsheet",
|
|
224
|
+
update_table: "Spreadsheet",
|
|
225
|
+
create_chart: "Spreadsheet",
|
|
226
|
+
update_chart: "Spreadsheet",
|
|
227
|
+
// Studio sheet PTC
|
|
228
|
+
CreateWorkbook: "Spreadsheet",
|
|
229
|
+
AddSheet: "Spreadsheet",
|
|
230
|
+
OpenWorkbook: "Spreadsheet",
|
|
231
|
+
// Presentation
|
|
232
|
+
create_powerpoint_deck: "Presentation",
|
|
233
|
+
create_presentation_pptx_studio: "Presentation",
|
|
234
|
+
execute_presentation_code: "Presentation",
|
|
235
|
+
capture_slide_screenshot: "Presentation",
|
|
236
|
+
// Studio presentation PTC
|
|
237
|
+
CreatePresentation: "Presentation",
|
|
238
|
+
OpenPresentation: "Presentation",
|
|
239
|
+
AddSlide: "Presentation",
|
|
240
|
+
// Notebook
|
|
241
|
+
create_new_notebook: "Notebook",
|
|
242
|
+
run_notebook_cell: "Notebook",
|
|
243
|
+
// Python / code execution
|
|
244
|
+
run_python_code: "Python",
|
|
245
|
+
run_python: "Python",
|
|
246
|
+
// Database
|
|
247
|
+
run_sql: "Database",
|
|
248
|
+
run_database_sql: "Database",
|
|
249
|
+
run_sql_query_tool: "Database",
|
|
250
|
+
execute_sql: "Database",
|
|
251
|
+
describe_database: "Database",
|
|
252
|
+
list_database_tables: "Database",
|
|
253
|
+
get_database_table_schema: "Database",
|
|
254
|
+
// Email / calendar
|
|
255
|
+
search_email: "Email",
|
|
256
|
+
unified_email_search: "Email",
|
|
257
|
+
// Media
|
|
258
|
+
capture_moment: "Computer"
|
|
259
|
+
};
|
|
260
|
+
const UNGROUPED_TOOLS = [
|
|
261
|
+
"read_asset",
|
|
262
|
+
"read_full_asset",
|
|
263
|
+
"ask",
|
|
264
|
+
"open_asset_in_workspace",
|
|
265
|
+
"create_email_draft",
|
|
266
|
+
"unified_email_create_draft",
|
|
267
|
+
"unified_email_send",
|
|
268
|
+
"unified_email_edit_draft"
|
|
269
|
+
];
|
|
270
|
+
const CONTEXT_ONLY_TOOLS = [
|
|
271
|
+
"execute",
|
|
272
|
+
"ls",
|
|
273
|
+
"read_file",
|
|
274
|
+
"write_file",
|
|
275
|
+
"edit_file",
|
|
276
|
+
"glob",
|
|
277
|
+
"grep"
|
|
278
|
+
];
|
|
279
|
+
const SANDBOX_TOOLKIT_GROUPS = ["Notebook", "Computer", "Session Sandbox"];
|
|
280
|
+
const defaultGetToolGroupKey = (toolName, options) => {
|
|
281
|
+
if (UNGROUPED_TOOLS.includes(toolName)) return void 0;
|
|
282
|
+
if (CONTEXT_ONLY_TOOLS.includes(toolName)) {
|
|
283
|
+
const preferred = options == null ? void 0 : options.preferredGroupKey;
|
|
284
|
+
return preferred && SANDBOX_TOOLKIT_GROUPS.includes(preferred) ? preferred : void 0;
|
|
285
|
+
}
|
|
286
|
+
return DEFAULT_TOOL_TO_TOOLKIT[toolName];
|
|
287
|
+
};
|
|
288
|
+
const TOOLKIT_THEMES = {
|
|
289
|
+
Web: { color: "#7BCCFA" },
|
|
290
|
+
Document: { color: "#4586F9" },
|
|
291
|
+
"Document (Word)": { color: "#4586F9" },
|
|
292
|
+
Notebook: { color: "#FFAB00" },
|
|
293
|
+
Python: { color: "#00A76F" },
|
|
294
|
+
Spreadsheet: { color: "#00A76F" },
|
|
295
|
+
Email: { color: "#B584FF" },
|
|
296
|
+
AOP: { color: "#336DFF" },
|
|
297
|
+
App: { color: "#7336F5" },
|
|
298
|
+
Presentation: { color: "#F56B36" },
|
|
299
|
+
"User Interface": { color: "#7336F5" },
|
|
300
|
+
Canvas: { color: "#002542" },
|
|
301
|
+
Computer: { color: "#3E0042" },
|
|
302
|
+
Database: { color: "#7336F5" },
|
|
303
|
+
"Chrome Browser": { color: "#4285F4" }
|
|
304
|
+
};
|
|
305
|
+
const DEFAULT_TOOLKIT_THEME = { color: "#919EAB" };
|
|
306
|
+
const DEFAULT_GROUPING = createToolBasedGroupingFunction(defaultGetToolGroupKey);
|
|
307
|
+
const SuperGroupingContext = React.createContext(null);
|
|
308
|
+
const SuperGroupingProvider = SuperGroupingContext.Provider;
|
|
309
|
+
const CollapsibleGroup = ({
|
|
310
|
+
groupKey,
|
|
311
|
+
indices,
|
|
312
|
+
children,
|
|
313
|
+
themes,
|
|
314
|
+
forceOpen = false,
|
|
315
|
+
compactWhileRunning = false,
|
|
316
|
+
headerActions,
|
|
317
|
+
groupingFunction,
|
|
318
|
+
className
|
|
319
|
+
}) => {
|
|
320
|
+
var _a;
|
|
321
|
+
const panelId = React.useId();
|
|
322
|
+
const isMessageRunning = react.useAuiState((s) => {
|
|
323
|
+
var _a2;
|
|
324
|
+
return ((_a2 = s.message.status) == null ? void 0 : _a2.type) === "running";
|
|
325
|
+
});
|
|
326
|
+
const messageContent = react.useAuiState(
|
|
327
|
+
(s) => s.message.role === "assistant" ? s.message.content : void 0
|
|
328
|
+
);
|
|
329
|
+
const contextGrouping = (_a = React.useContext(SuperGroupingContext)) == null ? void 0 : _a.groupingFunction;
|
|
330
|
+
const grouping = groupingFunction ?? contextGrouping ?? DEFAULT_GROUPING;
|
|
331
|
+
const lastIndex = indices.at(-1);
|
|
332
|
+
const isLastGroup = React.useMemo(() => {
|
|
333
|
+
if (!messageContent) return false;
|
|
334
|
+
const lastGroup = grouping(messageContent).filter((group) => group.indices.length > 1).at(-1);
|
|
335
|
+
return (lastGroup == null ? void 0 : lastGroup.indices.at(-1)) === lastIndex;
|
|
336
|
+
}, [messageContent, grouping, lastIndex]);
|
|
337
|
+
const toolCallCount = React.useMemo(
|
|
338
|
+
() => messageContent ? indices.reduce(
|
|
339
|
+
(count, index) => {
|
|
340
|
+
var _a2;
|
|
341
|
+
return ((_a2 = messageContent[index]) == null ? void 0 : _a2.type) === "tool-call" ? count + 1 : count;
|
|
342
|
+
},
|
|
343
|
+
0
|
|
344
|
+
) : 0,
|
|
345
|
+
[messageContent, indices]
|
|
346
|
+
);
|
|
347
|
+
const theme = React.useMemo(
|
|
348
|
+
() => groupKey ? { ...TOOLKIT_THEMES, ...themes }[groupKey] ?? DEFAULT_TOOLKIT_THEME : DEFAULT_TOOLKIT_THEME,
|
|
349
|
+
[groupKey, themes]
|
|
350
|
+
);
|
|
351
|
+
const [userOpened, setOpen] = React.useState();
|
|
352
|
+
const autoOpen = isLastGroup && isMessageRunning && !compactWhileRunning;
|
|
353
|
+
const open = userOpened ?? (autoOpen || forceOpen);
|
|
354
|
+
if (!groupKey || indices.length <= 1) return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children });
|
|
355
|
+
const toggle = () => setOpen(!open);
|
|
356
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
357
|
+
"div",
|
|
358
|
+
{
|
|
359
|
+
"data-slot": "collapsible-group",
|
|
360
|
+
"data-group-key": groupKey,
|
|
361
|
+
className: trash2.cn("my-4 rounded-2xl border shadow-sm", className),
|
|
362
|
+
style: {
|
|
363
|
+
borderColor: `${theme.color}33`,
|
|
364
|
+
background: `linear-gradient(to right, ${theme.color}0d, transparent, ${theme.color}0d)`
|
|
365
|
+
},
|
|
366
|
+
children: [
|
|
367
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex w-full items-center rounded-2xl", children: [
|
|
368
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
369
|
+
"button",
|
|
370
|
+
{
|
|
371
|
+
type: "button",
|
|
372
|
+
onClick: toggle,
|
|
373
|
+
"aria-expanded": open,
|
|
374
|
+
"aria-controls": panelId,
|
|
375
|
+
className: "flex min-w-0 flex-1 items-center justify-between gap-3 rounded-2xl px-5 py-3 text-left transition-colors hover:bg-black/5 dark:hover:bg-white/5",
|
|
376
|
+
children: [
|
|
377
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "flex min-w-0 items-center gap-3 text-foreground/90", children: [
|
|
378
|
+
theme.icon ? /* @__PURE__ */ jsxRuntime.jsx("img", { src: theme.icon, alt: "", "aria-hidden": "true", className: "size-5 shrink-0" }) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
379
|
+
"span",
|
|
380
|
+
{
|
|
381
|
+
className: "inline-block size-2 shrink-0 rounded-full",
|
|
382
|
+
style: { backgroundColor: theme.color },
|
|
383
|
+
"aria-hidden": "true"
|
|
384
|
+
}
|
|
385
|
+
),
|
|
386
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "truncate text-sm font-semibold", children: [
|
|
387
|
+
isMessageRunning ? "Using " : "Used ",
|
|
388
|
+
groupKey,
|
|
389
|
+
" Toolkit"
|
|
390
|
+
] })
|
|
391
|
+
] }),
|
|
392
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "shrink-0 text-xs font-medium text-muted-foreground", children: [
|
|
393
|
+
toolCallCount,
|
|
394
|
+
" tool ",
|
|
395
|
+
toolCallCount === 1 ? "call" : "calls"
|
|
396
|
+
] })
|
|
397
|
+
]
|
|
398
|
+
}
|
|
399
|
+
),
|
|
400
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex shrink-0 items-center gap-1 pr-3 pl-1", children: [
|
|
401
|
+
headerActions,
|
|
402
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
403
|
+
"button",
|
|
404
|
+
{
|
|
405
|
+
type: "button",
|
|
406
|
+
onClick: toggle,
|
|
407
|
+
"aria-label": open ? "Collapse toolkit group" : "Expand toolkit group",
|
|
408
|
+
"aria-expanded": open,
|
|
409
|
+
"aria-controls": panelId,
|
|
410
|
+
className: "flex items-center justify-center rounded-md p-1 text-muted-foreground transition-colors hover:bg-black/5 dark:hover:bg-white/5",
|
|
411
|
+
children: open ? /* @__PURE__ */ jsxRuntime.jsx(ChevronUp, { size: 16 }) : /* @__PURE__ */ jsxRuntime.jsx(trash2.ChevronDown, { size: 16 })
|
|
412
|
+
}
|
|
413
|
+
)
|
|
414
|
+
] })
|
|
415
|
+
] }),
|
|
416
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
417
|
+
"div",
|
|
418
|
+
{
|
|
419
|
+
id: panelId,
|
|
420
|
+
className: trash2.cn(
|
|
421
|
+
"grid overflow-hidden border-t transition-[grid-template-rows] duration-200 ease-in-out motion-reduce:transition-none",
|
|
422
|
+
open ? "grid-rows-[1fr]" : "grid-rows-[0fr]"
|
|
423
|
+
),
|
|
424
|
+
style: { borderColor: `${theme.color}33` },
|
|
425
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "space-y-2 px-5 py-4", children }) })
|
|
426
|
+
}
|
|
427
|
+
)
|
|
428
|
+
]
|
|
429
|
+
}
|
|
430
|
+
);
|
|
431
|
+
};
|
|
432
|
+
const DEFAULT_MAX_VISIBLE_STEPS = 3;
|
|
433
|
+
const MAX_REMEMBERED_EXPANSIONS = 200;
|
|
434
|
+
const EMPTY_TIMELINE = [];
|
|
435
|
+
const EMPTY_CONTENT = [];
|
|
436
|
+
const rememberedExpansions = /* @__PURE__ */ new Map();
|
|
437
|
+
function rememberExpansion(key, expanded) {
|
|
438
|
+
rememberedExpansions.delete(key);
|
|
439
|
+
rememberedExpansions.set(key, expanded);
|
|
440
|
+
while (rememberedExpansions.size > MAX_REMEMBERED_EXPANSIONS) {
|
|
441
|
+
const oldestKey = rememberedExpansions.keys().next().value;
|
|
442
|
+
if (oldestKey === void 0) break;
|
|
443
|
+
rememberedExpansions.delete(oldestKey);
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
function resetRememberedExpansionsForTests() {
|
|
447
|
+
rememberedExpansions.clear();
|
|
448
|
+
}
|
|
449
|
+
function useActivityExpansion({
|
|
450
|
+
expansionKey,
|
|
451
|
+
phase,
|
|
452
|
+
expandWhileWaiting = false
|
|
453
|
+
}) {
|
|
454
|
+
const [userExpanded, setUserExpanded] = React.useState(
|
|
455
|
+
() => rememberedExpansions.get(expansionKey)
|
|
456
|
+
);
|
|
457
|
+
const [waitingAutoExpanded, setWaitingAutoExpanded] = React.useState(false);
|
|
458
|
+
const previousRef = React.useRef({ expansionKey, phase });
|
|
459
|
+
React.useEffect(() => {
|
|
460
|
+
setUserExpanded(rememberedExpansions.get(expansionKey));
|
|
461
|
+
setWaitingAutoExpanded(false);
|
|
462
|
+
}, [expansionKey]);
|
|
463
|
+
React.useEffect(() => {
|
|
464
|
+
const previous = previousRef.current;
|
|
465
|
+
if (expandWhileWaiting && previous.expansionKey === expansionKey) {
|
|
466
|
+
if (previous.phase !== "waiting" && phase === "waiting") {
|
|
467
|
+
setWaitingAutoExpanded(true);
|
|
468
|
+
} else if (previous.phase === "waiting" && phase !== "waiting") {
|
|
469
|
+
setWaitingAutoExpanded(false);
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
previousRef.current = { expansionKey, phase };
|
|
473
|
+
}, [expansionKey, phase, expandWhileWaiting]);
|
|
474
|
+
const expanded = waitingAutoExpanded || (userExpanded ?? (expandWhileWaiting && phase === "waiting"));
|
|
475
|
+
const toggleExpanded = () => {
|
|
476
|
+
const next = !expanded;
|
|
477
|
+
setWaitingAutoExpanded(false);
|
|
478
|
+
rememberExpansion(expansionKey, next);
|
|
479
|
+
setUserExpanded(next);
|
|
480
|
+
};
|
|
481
|
+
return { expanded, toggleExpanded };
|
|
482
|
+
}
|
|
483
|
+
function PulsingDots() {
|
|
484
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "inline-flex items-center gap-[3px]", "aria-hidden": "true", children: [
|
|
485
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "size-[5px] rounded-full bg-foreground/80 animate-[aui-sg-pulse-dot_1.4s_ease-in-out_infinite]" }),
|
|
486
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "size-[5px] rounded-full bg-foreground/80 animate-[aui-sg-pulse-dot_1.4s_ease-in-out_0.2s_infinite]" }),
|
|
487
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "size-[5px] rounded-full bg-foreground/80 animate-[aui-sg-pulse-dot_1.4s_ease-in-out_0.4s_infinite]" }),
|
|
488
|
+
/* @__PURE__ */ jsxRuntime.jsx("style", { children: `
|
|
489
|
+
@keyframes aui-sg-pulse-dot {
|
|
490
|
+
0%, 80%, 100% { opacity: 0.2; transform: scale(0.8); }
|
|
491
|
+
40% { opacity: 1; transform: scale(1); }
|
|
492
|
+
}
|
|
493
|
+
@keyframes aui-sg-shimmer-bar {
|
|
494
|
+
0% { transform: translateX(-100%); }
|
|
495
|
+
100% { transform: translateX(400%); }
|
|
496
|
+
}
|
|
497
|
+
` })
|
|
498
|
+
] });
|
|
499
|
+
}
|
|
500
|
+
function StepIcon({ item }) {
|
|
501
|
+
if (item.kind === "reasoning") {
|
|
502
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
503
|
+
toolFallback.Brain,
|
|
504
|
+
{
|
|
505
|
+
"aria-hidden": "true",
|
|
506
|
+
className: trash2.cn(
|
|
507
|
+
"mt-[1px] size-3.5 shrink-0",
|
|
508
|
+
item.state === "running" ? "text-blue-500 motion-safe:animate-pulse" : "text-muted-foreground"
|
|
509
|
+
)
|
|
510
|
+
}
|
|
511
|
+
);
|
|
512
|
+
}
|
|
513
|
+
switch (item.state) {
|
|
514
|
+
case "complete":
|
|
515
|
+
return /* @__PURE__ */ jsxRuntime.jsx(x.Check, { "aria-hidden": "true", className: "mt-[1px] size-3.5 shrink-0 text-emerald-500" });
|
|
516
|
+
case "rejected":
|
|
517
|
+
return /* @__PURE__ */ jsxRuntime.jsx(x.X, { "aria-hidden": "true", className: "mt-[1px] size-3.5 shrink-0 text-muted-foreground" });
|
|
518
|
+
case "cancelled":
|
|
519
|
+
return /* @__PURE__ */ jsxRuntime.jsx(x.Circle, { "aria-hidden": "true", className: "mt-[1px] size-3.5 shrink-0 text-muted-foreground" });
|
|
520
|
+
case "error":
|
|
521
|
+
return /* @__PURE__ */ jsxRuntime.jsx(trash2.CircleAlert, { "aria-hidden": "true", className: "mt-[1px] size-3.5 shrink-0 text-destructive" });
|
|
522
|
+
case "waiting":
|
|
523
|
+
return /* @__PURE__ */ jsxRuntime.jsx(x.Circle, { "aria-hidden": "true", className: "mt-[1px] size-3.5 shrink-0 text-amber-500" });
|
|
524
|
+
case "paused":
|
|
525
|
+
return /* @__PURE__ */ jsxRuntime.jsx(trash2.Pause, { "aria-hidden": "true", className: "mt-[1px] size-3.5 shrink-0 text-amber-600" });
|
|
526
|
+
case "running":
|
|
527
|
+
return /* @__PURE__ */ jsxRuntime.jsx("span", { className: "flex size-3.5 shrink-0 items-center justify-center", "aria-hidden": "true", children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "size-1.5 rounded-full bg-blue-500 motion-safe:animate-pulse" }) });
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
function SummaryIcon({ timeline }) {
|
|
531
|
+
const tools = timeline.filter((item) => item.kind === "tool");
|
|
532
|
+
if (tools.some((item) => item.state === "error" || item.state === "rejected")) {
|
|
533
|
+
return /* @__PURE__ */ jsxRuntime.jsx(x.X, { "aria-hidden": "true", className: "size-3.5 shrink-0 text-muted-foreground" });
|
|
534
|
+
}
|
|
535
|
+
if (tools.some((item) => item.state === "cancelled")) {
|
|
536
|
+
return /* @__PURE__ */ jsxRuntime.jsx(x.Circle, { "aria-hidden": "true", className: "size-3.5 shrink-0 text-muted-foreground" });
|
|
537
|
+
}
|
|
538
|
+
if (tools.some((item) => item.state === "paused")) {
|
|
539
|
+
return /* @__PURE__ */ jsxRuntime.jsx(trash2.Pause, { "aria-hidden": "true", className: "size-3.5 shrink-0 text-amber-600" });
|
|
540
|
+
}
|
|
541
|
+
return /* @__PURE__ */ jsxRuntime.jsx(x.Check, { "aria-hidden": "true", className: "size-3.5 shrink-0 text-emerald-500" });
|
|
542
|
+
}
|
|
543
|
+
const SuperGroupingCard = React.memo(function SuperGroupingCard2({
|
|
544
|
+
toolUIs,
|
|
545
|
+
ToolFallback: ToolFallbackComponent = toolFallback.ToolFallback,
|
|
546
|
+
TextComponent,
|
|
547
|
+
ReasoningComponent,
|
|
548
|
+
GroupComponent = CollapsibleGroup,
|
|
549
|
+
getToolGroupKey = defaultGetToolGroupKey,
|
|
550
|
+
groupingFunction,
|
|
551
|
+
waitingTools,
|
|
552
|
+
passThroughTools,
|
|
553
|
+
waitingForInput = false,
|
|
554
|
+
resolveToolDisplayName,
|
|
555
|
+
expansionKey: expansionKeyProp,
|
|
556
|
+
expandWhileWaiting = false,
|
|
557
|
+
maxVisibleSteps = DEFAULT_MAX_VISIBLE_STEPS,
|
|
558
|
+
summaryDetails,
|
|
559
|
+
renderHeaderActions,
|
|
560
|
+
renderRunningMeta,
|
|
561
|
+
className,
|
|
562
|
+
classNames
|
|
563
|
+
}) {
|
|
564
|
+
const messageId = react.useAuiState((s) => s.message.id);
|
|
565
|
+
const messageContent = react.useAuiState(
|
|
566
|
+
(s) => s.message.role === "assistant" ? s.message.content : EMPTY_CONTENT
|
|
567
|
+
);
|
|
568
|
+
const messageStatus = react.useAuiState((s) => s.message.status);
|
|
569
|
+
const timeline = React.useMemo(() => {
|
|
570
|
+
const items = buildActivityTimeline(messageContent, messageStatus, {
|
|
571
|
+
waitingTools,
|
|
572
|
+
passThroughTools
|
|
573
|
+
});
|
|
574
|
+
return items.length > 0 ? items : EMPTY_TIMELINE;
|
|
575
|
+
}, [messageContent, messageStatus, waitingTools, passThroughTools]);
|
|
576
|
+
const phase = React.useMemo(
|
|
577
|
+
() => resolveActivityPhase(messageStatus, timeline, { waitingForInput }),
|
|
578
|
+
[messageStatus, timeline, waitingForInput]
|
|
579
|
+
);
|
|
580
|
+
const toolCount = countActivityTools(timeline);
|
|
581
|
+
const { expanded, toggleExpanded } = useActivityExpansion({
|
|
582
|
+
expansionKey: expansionKeyProp ?? messageId,
|
|
583
|
+
phase,
|
|
584
|
+
expandWhileWaiting
|
|
585
|
+
});
|
|
586
|
+
const generatedId = React.useId().replace(/[^A-Za-z0-9_-]/g, "");
|
|
587
|
+
const detailsPanelId = `aui-sg-details-${generatedId}`;
|
|
588
|
+
const statusId = `aui-sg-status-${generatedId}`;
|
|
589
|
+
const primaryDisclosureRef = React.useRef(null);
|
|
590
|
+
const grouping = React.useMemo(
|
|
591
|
+
() => excludeFinalTextFromGroups(groupingFunction ?? createToolBasedGroupingFunction(getToolGroupKey)),
|
|
592
|
+
[groupingFunction, getToolGroupKey]
|
|
593
|
+
);
|
|
594
|
+
const groupingContext = React.useMemo(() => ({ groupingFunction: grouping }), [grouping]);
|
|
595
|
+
const components = React.useMemo(
|
|
596
|
+
() => ({
|
|
597
|
+
tools: { ...toolUIs ? { by_name: toolUIs } : {}, Fallback: ToolFallbackComponent },
|
|
598
|
+
Text: TextComponent,
|
|
599
|
+
...ReasoningComponent ? { Reasoning: ReasoningComponent } : {},
|
|
600
|
+
Group: GroupComponent
|
|
601
|
+
}),
|
|
602
|
+
[toolUIs, ToolFallbackComponent, TextComponent, ReasoningComponent, GroupComponent]
|
|
603
|
+
);
|
|
604
|
+
const isActive = phase === "running" || phase === "waiting";
|
|
605
|
+
const hasActivity = timeline.length > 0 || phase !== "complete";
|
|
606
|
+
if (!hasActivity) return null;
|
|
607
|
+
const detailsMounted = isActive || expanded;
|
|
608
|
+
const visibleItems = timeline.slice(-Math.max(1, maxVisibleSteps));
|
|
609
|
+
const hiddenCount = timeline.length - visibleItems.length;
|
|
610
|
+
const latestStatus = phase === "waiting" ? "Waiting for your input" : phase === "error" ? "Something went wrong" : timeline.length > 0 ? getActivityItemLabel(timeline[timeline.length - 1], resolveToolDisplayName) : "Planning approach";
|
|
611
|
+
const summary = [getActivitySummary(timeline), ...summaryDetails ?? []].join(" · ");
|
|
612
|
+
const headerActions = renderHeaderActions == null ? void 0 : renderHeaderActions({ phase, messageContent });
|
|
613
|
+
const runningMeta = isActive ? renderRunningMeta == null ? void 0 : renderRunningMeta({ phase }) : null;
|
|
614
|
+
const hideDetails = () => {
|
|
615
|
+
toggleExpanded();
|
|
616
|
+
queueMicrotask(() => {
|
|
617
|
+
var _a;
|
|
618
|
+
return (_a = primaryDisclosureRef.current) == null ? void 0 : _a.focus();
|
|
619
|
+
});
|
|
620
|
+
};
|
|
621
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
622
|
+
"section",
|
|
623
|
+
{
|
|
624
|
+
"data-slot": "super-grouping-card",
|
|
625
|
+
"data-phase": phase,
|
|
626
|
+
"data-tool-count": toolCount,
|
|
627
|
+
className: trash2.cn(
|
|
628
|
+
"my-3 min-w-0 overflow-hidden rounded-2xl border transition-colors duration-200",
|
|
629
|
+
phase === "error" ? "border-destructive/30 bg-destructive/5" : phase === "waiting" ? "border-amber-200 bg-amber-50/40 dark:border-amber-500/30 dark:bg-amber-500/10" : "border-border/60 bg-muted/10",
|
|
630
|
+
className,
|
|
631
|
+
classNames == null ? void 0 : classNames.root
|
|
632
|
+
),
|
|
633
|
+
"aria-busy": phase === "running" ? "true" : "false",
|
|
634
|
+
"aria-describedby": statusId,
|
|
635
|
+
children: [
|
|
636
|
+
phase === "complete" ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex w-full items-center", children: [
|
|
637
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
638
|
+
"button",
|
|
639
|
+
{
|
|
640
|
+
ref: primaryDisclosureRef,
|
|
641
|
+
type: "button",
|
|
642
|
+
onClick: toggleExpanded,
|
|
643
|
+
"aria-expanded": expanded,
|
|
644
|
+
"aria-controls": detailsPanelId,
|
|
645
|
+
className: "flex min-w-0 flex-1 items-center gap-2 px-4 py-3 text-left transition-colors hover:bg-muted/30 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring",
|
|
646
|
+
children: [
|
|
647
|
+
/* @__PURE__ */ jsxRuntime.jsx(SummaryIcon, { timeline }),
|
|
648
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "min-w-0 flex-1 truncate text-[12px] text-muted-foreground", children: summary })
|
|
649
|
+
]
|
|
650
|
+
}
|
|
651
|
+
),
|
|
652
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex shrink-0 items-center gap-1 pr-3 pl-1", children: [
|
|
653
|
+
headerActions,
|
|
654
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
655
|
+
"button",
|
|
656
|
+
{
|
|
657
|
+
type: "button",
|
|
658
|
+
onClick: toggleExpanded,
|
|
659
|
+
"aria-label": expanded ? "Hide run details" : "Show run details",
|
|
660
|
+
"aria-expanded": expanded,
|
|
661
|
+
"aria-controls": detailsPanelId,
|
|
662
|
+
className: "flex items-center justify-center rounded-md p-1 text-muted-foreground transition-colors hover:bg-muted/40 hover:text-foreground",
|
|
663
|
+
children: expanded ? /* @__PURE__ */ jsxRuntime.jsx(trash2.ChevronDown, { className: "size-3.5" }) : /* @__PURE__ */ jsxRuntime.jsx(x.ChevronRight, { className: "size-3.5" })
|
|
664
|
+
}
|
|
665
|
+
)
|
|
666
|
+
] })
|
|
667
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
668
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex min-w-0 items-center justify-between gap-2 px-4 pt-4 pb-2", children: [
|
|
669
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex min-w-0 items-center gap-2", children: [
|
|
670
|
+
/* @__PURE__ */ jsxRuntime.jsx("h3", { className: "truncate text-[13px] font-semibold text-foreground", children: phase === "error" ? "Something went wrong" : phase === "waiting" ? "Waiting for you" : "Athena is working" }),
|
|
671
|
+
phase === "running" ? /* @__PURE__ */ jsxRuntime.jsx(PulsingDots, {}) : null
|
|
672
|
+
] }),
|
|
673
|
+
headerActions ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex shrink-0 items-center gap-1", children: headerActions }) : null
|
|
674
|
+
] }),
|
|
675
|
+
runningMeta ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "px-4 pb-1", children: runningMeta }) : null,
|
|
676
|
+
phase === "running" ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "px-4 pb-1", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-[2px] w-full overflow-hidden rounded-full bg-muted/40", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-full w-1/3 rounded-full bg-gradient-to-r from-blue-400 to-indigo-400 animate-[aui-sg-shimmer-bar_1.5s_ease-in-out_infinite] motion-reduce:animate-none" }) }) }) : null,
|
|
677
|
+
visibleItems.length > 0 ? /* @__PURE__ */ jsxRuntime.jsxs("ul", { className: "space-y-1 px-4 pt-1.5 pb-1", "aria-label": "Work status updates", children: [
|
|
678
|
+
hiddenCount > 0 ? /* @__PURE__ */ jsxRuntime.jsxs("li", { className: "pl-[22px] text-[11px] text-muted-foreground/70", children: [
|
|
679
|
+
hiddenCount,
|
|
680
|
+
" earlier ",
|
|
681
|
+
hiddenCount === 1 ? "step" : "steps"
|
|
682
|
+
] }) : null,
|
|
683
|
+
visibleItems.map((item, index) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
684
|
+
"li",
|
|
685
|
+
{
|
|
686
|
+
className: "flex min-w-0 items-start gap-2 text-[12px]",
|
|
687
|
+
children: [
|
|
688
|
+
/* @__PURE__ */ jsxRuntime.jsx(StepIcon, { item }),
|
|
689
|
+
item.kind === "reasoning" ? item.text.trim() ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "line-clamp-2 min-w-0 flex-1 italic leading-relaxed text-muted-foreground", children: item.text }) : /* @__PURE__ */ jsxRuntime.jsx("span", { className: "shimmer min-w-0 flex-1 leading-relaxed text-muted-foreground", children: "Thinking…" }) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
690
|
+
"span",
|
|
691
|
+
{
|
|
692
|
+
className: trash2.cn(
|
|
693
|
+
"min-w-0 flex-1 truncate leading-relaxed",
|
|
694
|
+
item.state === "complete" ? "text-muted-foreground/70" : "text-foreground/80"
|
|
695
|
+
),
|
|
696
|
+
children: getActivityItemLabel(item, resolveToolDisplayName)
|
|
697
|
+
}
|
|
698
|
+
)
|
|
699
|
+
]
|
|
700
|
+
},
|
|
701
|
+
`${item.kind}-${hiddenCount + index}`
|
|
702
|
+
))
|
|
703
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "px-4 pt-1 pb-2", children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "shimmer text-[12px] text-muted-foreground", children: "Planning approach..." }) }),
|
|
704
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "px-4 pb-3 pt-0.5", children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
705
|
+
"button",
|
|
706
|
+
{
|
|
707
|
+
ref: primaryDisclosureRef,
|
|
708
|
+
type: "button",
|
|
709
|
+
onClick: toggleExpanded,
|
|
710
|
+
"aria-expanded": expanded,
|
|
711
|
+
"aria-controls": detailsPanelId,
|
|
712
|
+
className: "flex items-center gap-1 rounded px-1 py-0.5 text-[11px] font-medium text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
|
|
713
|
+
children: [
|
|
714
|
+
expanded ? /* @__PURE__ */ jsxRuntime.jsx(trash2.ChevronDown, { className: "size-3" }) : /* @__PURE__ */ jsxRuntime.jsx(x.ChevronRight, { className: "size-3" }),
|
|
715
|
+
expanded ? "Hide details" : "Show details"
|
|
716
|
+
]
|
|
717
|
+
}
|
|
718
|
+
) })
|
|
719
|
+
] }),
|
|
720
|
+
/* @__PURE__ */ jsxRuntime.jsx("output", { id: statusId, "aria-live": "polite", "aria-atomic": "true", className: "sr-only", children: latestStatus }),
|
|
721
|
+
detailsMounted ? /* @__PURE__ */ jsxRuntime.jsxs(
|
|
722
|
+
"div",
|
|
723
|
+
{
|
|
724
|
+
id: detailsPanelId,
|
|
725
|
+
role: "region",
|
|
726
|
+
"aria-label": "Run details",
|
|
727
|
+
hidden: !expanded,
|
|
728
|
+
className: trash2.cn(
|
|
729
|
+
"space-y-2 overflow-hidden border-t border-border/60 bg-background/80 px-4 py-4",
|
|
730
|
+
classNames == null ? void 0 : classNames.details
|
|
731
|
+
),
|
|
732
|
+
children: [
|
|
733
|
+
/* @__PURE__ */ jsxRuntime.jsx(SuperGroupingProvider, { value: groupingContext, children: /* @__PURE__ */ jsxRuntime.jsx(react.MessagePrimitive.Unstable_PartsGrouped, { groupingFunction: grouping, components }) }),
|
|
734
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
735
|
+
"button",
|
|
736
|
+
{
|
|
737
|
+
type: "button",
|
|
738
|
+
onClick: hideDetails,
|
|
739
|
+
"aria-controls": detailsPanelId,
|
|
740
|
+
"aria-expanded": "true",
|
|
741
|
+
className: "mx-auto mt-3 flex items-center gap-1 rounded-md px-3 py-1.5 text-[11px] font-medium text-muted-foreground transition-colors hover:bg-muted/40 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
|
|
742
|
+
children: [
|
|
743
|
+
/* @__PURE__ */ jsxRuntime.jsx(ChevronUp, { className: "size-3" }),
|
|
744
|
+
"Hide details"
|
|
745
|
+
]
|
|
746
|
+
}
|
|
747
|
+
)
|
|
748
|
+
]
|
|
749
|
+
}
|
|
750
|
+
) : null
|
|
751
|
+
]
|
|
752
|
+
}
|
|
753
|
+
);
|
|
754
|
+
});
|
|
755
|
+
const SuperGroupingFinalText = React.memo(function SuperGroupingFinalText2({
|
|
756
|
+
TextComponent
|
|
757
|
+
}) {
|
|
758
|
+
const messageContent = react.useAuiState(
|
|
759
|
+
(s) => s.message.role === "assistant" ? s.message.content : EMPTY_CONTENT
|
|
760
|
+
);
|
|
761
|
+
const statusType = react.useAuiState((s) => {
|
|
762
|
+
var _a;
|
|
763
|
+
return (_a = s.message.status) == null ? void 0 : _a.type;
|
|
764
|
+
});
|
|
765
|
+
const finalText = React.useMemo(() => getFinalText(messageContent), [messageContent]);
|
|
766
|
+
if (!finalText) return null;
|
|
767
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
768
|
+
TextComponent,
|
|
769
|
+
{
|
|
770
|
+
type: "text",
|
|
771
|
+
text: finalText,
|
|
772
|
+
status: statusType === "running" || statusType === "requires-action" ? { type: "running" } : { type: "complete" }
|
|
773
|
+
}
|
|
774
|
+
);
|
|
775
|
+
});
|
|
776
|
+
exports.CollapsibleGroup = CollapsibleGroup;
|
|
777
|
+
exports.DEFAULT_TOOLKIT_THEME = DEFAULT_TOOLKIT_THEME;
|
|
778
|
+
exports.SuperGroupingCard = SuperGroupingCard;
|
|
779
|
+
exports.SuperGroupingFinalText = SuperGroupingFinalText;
|
|
780
|
+
exports.SuperGroupingProvider = SuperGroupingProvider;
|
|
781
|
+
exports.TOOLKIT_THEMES = TOOLKIT_THEMES;
|
|
782
|
+
exports.buildActivityTimeline = buildActivityTimeline;
|
|
783
|
+
exports.countActivityTools = countActivityTools;
|
|
784
|
+
exports.createToolBasedGroupingFunction = createToolBasedGroupingFunction;
|
|
785
|
+
exports.defaultGetToolGroupKey = defaultGetToolGroupKey;
|
|
786
|
+
exports.excludeFinalTextFromGroups = excludeFinalTextFromGroups;
|
|
787
|
+
exports.getActivityItemLabel = getActivityItemLabel;
|
|
788
|
+
exports.getActivitySummary = getActivitySummary;
|
|
789
|
+
exports.getActivityToolState = getActivityToolState;
|
|
790
|
+
exports.getFinalText = getFinalText;
|
|
791
|
+
exports.resetRememberedExpansionsForTests = resetRememberedExpansionsForTests;
|
|
792
|
+
exports.resolveActivityPhase = resolveActivityPhase;
|
|
793
|
+
exports.useActivityExpansion = useActivityExpansion;
|
|
794
|
+
//# sourceMappingURL=SuperGroupingCard-CRRFUgjN.cjs.map
|