@cerebriline/ui 0.0.0-stage → 4.100.313
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/ADOPTION.md +833 -0
- package/LICENSE +201 -0
- package/RADIX-COLORS-LICENSE +21 -0
- package/README.md +427 -2
- package/components/agent-approval-card.css +70 -0
- package/components/agent-approval-card.tsx +109 -0
- package/components/agent-ask-question.css +103 -0
- package/components/agent-ask-question.tsx +276 -0
- package/components/agent-aurora.css +228 -0
- package/components/agent-aurora.tsx +96 -0
- package/components/agent-changes.css +13 -0
- package/components/agent-changes.tsx +167 -0
- package/components/agent-chat/agent-chat.css +556 -0
- package/components/agent-chat/index.tsx +1037 -0
- package/components/agent-chat/tool-diff.tsx +165 -0
- package/components/agent-chat/tool-summary/agents.ts +114 -0
- package/components/agent-chat/tool-summary/diff.ts +152 -0
- package/components/agent-chat/tool-summary/index.ts +928 -0
- package/components/agent-chat/tool-summary/parsers.ts +611 -0
- package/components/agent-chat/tool-summary/paths.ts +84 -0
- package/components/agent-chat/tool-summary/team.ts +401 -0
- package/components/agent-command-output.tsx +63 -0
- package/components/agent-composer.tsx +263 -0
- package/components/agent-context-usage.tsx +181 -0
- package/components/agent-conversation-layout.tsx +139 -0
- package/components/agent-hero-heading.css +53 -0
- package/components/agent-hero-heading.tsx +45 -0
- package/components/agent-image-lightbox.tsx +48 -0
- package/components/agent-prompt-queue.css +20 -0
- package/components/agent-prompt-queue.tsx +350 -0
- package/components/agent-pull-request-bar.css +13 -0
- package/components/agent-pull-request-bar.tsx +346 -0
- package/components/agent-quick-actions.css +19 -0
- package/components/agent-quick-actions.tsx +70 -0
- package/components/agent-session-row.tsx +183 -0
- package/components/agent-welcome-hero-pointer.ts +199 -0
- package/components/agent-welcome-hero.css +205 -0
- package/components/agent-welcome-hero.tsx +68 -0
- package/components/attachment-drop-zone.tsx +154 -0
- package/components/badge.tsx +21 -0
- package/components/button.tsx +324 -0
- package/components/generated-media.tsx +173 -0
- package/components/github-icon.tsx +19 -0
- package/components/index.ts +133 -0
- package/components/markdown.css +490 -0
- package/components/markdown.ts +365 -0
- package/components/mermaid-block.tsx +722 -0
- package/components/mermaid-diagram.ts +1260 -0
- package/components/mermaid-dom.ts +301 -0
- package/components/message-scroller.css +118 -0
- package/components/message-scroller.tsx +114 -0
- package/components/search-combobox.css +67 -0
- package/components/search-combobox.tsx +433 -0
- package/components/session-status.css +19 -0
- package/components/session-status.tsx +39 -0
- package/components/switch.css +221 -0
- package/components/switch.tsx +48 -0
- package/components.css +16 -0
- package/dist/components/agent-approval-card.d.ts +14 -0
- package/dist/components/agent-approval-card.d.ts.map +1 -0
- package/dist/components/agent-approval-card.js +12 -0
- package/dist/components/agent-approval-card.js.map +1 -0
- package/dist/components/agent-ask-question.d.ts +18 -0
- package/dist/components/agent-ask-question.d.ts.map +1 -0
- package/dist/components/agent-ask-question.js +101 -0
- package/dist/components/agent-ask-question.js.map +1 -0
- package/dist/components/agent-aurora.d.ts +3 -0
- package/dist/components/agent-aurora.d.ts.map +1 -0
- package/dist/components/agent-aurora.js +60 -0
- package/dist/components/agent-aurora.js.map +1 -0
- package/dist/components/agent-changes.d.ts +26 -0
- package/dist/components/agent-changes.d.ts.map +1 -0
- package/dist/components/agent-changes.js +19 -0
- package/dist/components/agent-changes.js.map +1 -0
- package/dist/components/agent-chat/disclosure.d.ts +25 -0
- package/dist/components/agent-chat/disclosure.d.ts.map +1 -0
- package/dist/components/agent-chat/disclosure.js +39 -0
- package/dist/components/agent-chat/disclosure.js.map +1 -0
- package/dist/components/agent-chat/index.d.ts +140 -0
- package/dist/components/agent-chat/index.d.ts.map +1 -0
- package/dist/components/agent-chat/index.js +379 -0
- package/dist/components/agent-chat/index.js.map +1 -0
- package/dist/components/agent-chat/tool-diff.d.ts +32 -0
- package/dist/components/agent-chat/tool-diff.d.ts.map +1 -0
- package/dist/components/agent-chat/tool-diff.js +97 -0
- package/dist/components/agent-chat/tool-diff.js.map +1 -0
- package/dist/components/agent-chat/tool-summary/agents.d.ts +10 -0
- package/dist/components/agent-chat/tool-summary/agents.d.ts.map +1 -0
- package/dist/components/agent-chat/tool-summary/agents.js +100 -0
- package/dist/components/agent-chat/tool-summary/agents.js.map +1 -0
- package/dist/components/agent-chat/tool-summary/diff.d.ts +22 -0
- package/dist/components/agent-chat/tool-summary/diff.d.ts.map +1 -0
- package/dist/components/agent-chat/tool-summary/diff.js +127 -0
- package/dist/components/agent-chat/tool-summary/diff.js.map +1 -0
- package/dist/components/agent-chat/tool-summary/index.d.ts +145 -0
- package/dist/components/agent-chat/tool-summary/index.d.ts.map +1 -0
- package/dist/components/agent-chat/tool-summary/index.js +663 -0
- package/dist/components/agent-chat/tool-summary/index.js.map +1 -0
- package/dist/components/agent-chat/tool-summary/parsers.d.ts +114 -0
- package/dist/components/agent-chat/tool-summary/parsers.d.ts.map +1 -0
- package/dist/components/agent-chat/tool-summary/parsers.js +502 -0
- package/dist/components/agent-chat/tool-summary/parsers.js.map +1 -0
- package/dist/components/agent-chat/tool-summary/paths.d.ts +10 -0
- package/dist/components/agent-chat/tool-summary/paths.d.ts.map +1 -0
- package/dist/components/agent-chat/tool-summary/paths.js +88 -0
- package/dist/components/agent-chat/tool-summary/paths.js.map +1 -0
- package/dist/components/agent-chat/tool-summary/team.d.ts +16 -0
- package/dist/components/agent-chat/tool-summary/team.d.ts.map +1 -0
- package/dist/components/agent-chat/tool-summary/team.js +283 -0
- package/dist/components/agent-chat/tool-summary/team.js.map +1 -0
- package/dist/components/agent-command-output.d.ts +14 -0
- package/dist/components/agent-command-output.d.ts.map +1 -0
- package/dist/components/agent-command-output.js +22 -0
- package/dist/components/agent-command-output.js.map +1 -0
- package/dist/components/agent-composer.d.ts +34 -0
- package/dist/components/agent-composer.d.ts.map +1 -0
- package/dist/components/agent-composer.js +65 -0
- package/dist/components/agent-composer.js.map +1 -0
- package/dist/components/agent-context-usage.d.ts +28 -0
- package/dist/components/agent-context-usage.d.ts.map +1 -0
- package/dist/components/agent-context-usage.js +51 -0
- package/dist/components/agent-context-usage.js.map +1 -0
- package/dist/components/agent-conversation-layout.d.ts +30 -0
- package/dist/components/agent-conversation-layout.d.ts.map +1 -0
- package/dist/components/agent-conversation-layout.js +24 -0
- package/dist/components/agent-conversation-layout.js.map +1 -0
- package/dist/components/agent-hero-heading.d.ts +2 -0
- package/dist/components/agent-hero-heading.d.ts.map +1 -0
- package/dist/components/agent-hero-heading.js +20 -0
- package/dist/components/agent-hero-heading.js.map +1 -0
- package/dist/components/agent-image-lightbox.d.ts +11 -0
- package/dist/components/agent-image-lightbox.d.ts.map +1 -0
- package/dist/components/agent-image-lightbox.js +8 -0
- package/dist/components/agent-image-lightbox.js.map +1 -0
- package/dist/components/agent-prompt-queue.d.ts +14 -0
- package/dist/components/agent-prompt-queue.d.ts.map +1 -0
- package/dist/components/agent-prompt-queue.js +114 -0
- package/dist/components/agent-prompt-queue.js.map +1 -0
- package/dist/components/agent-pull-request-bar.d.ts +72 -0
- package/dist/components/agent-pull-request-bar.d.ts.map +1 -0
- package/dist/components/agent-pull-request-bar.js +90 -0
- package/dist/components/agent-pull-request-bar.js.map +1 -0
- package/dist/components/agent-quick-actions.d.ts +14 -0
- package/dist/components/agent-quick-actions.d.ts.map +1 -0
- package/dist/components/agent-quick-actions.js +12 -0
- package/dist/components/agent-quick-actions.js.map +1 -0
- package/dist/components/agent-session-row.d.ts +45 -0
- package/dist/components/agent-session-row.d.ts.map +1 -0
- package/dist/components/agent-session-row.js +34 -0
- package/dist/components/agent-session-row.js.map +1 -0
- package/dist/components/agent-welcome-hero-pointer.d.ts +3 -0
- package/dist/components/agent-welcome-hero-pointer.d.ts.map +1 -0
- package/dist/components/agent-welcome-hero-pointer.js +169 -0
- package/dist/components/agent-welcome-hero-pointer.js.map +1 -0
- package/dist/components/agent-welcome-hero.d.ts +9 -0
- package/dist/components/agent-welcome-hero.d.ts.map +1 -0
- package/dist/components/agent-welcome-hero.js +14 -0
- package/dist/components/agent-welcome-hero.js.map +1 -0
- package/dist/components/attachment-drop-zone.d.ts +15 -0
- package/dist/components/attachment-drop-zone.d.ts.map +1 -0
- package/dist/components/attachment-drop-zone.js +64 -0
- package/dist/components/attachment-drop-zone.js.map +1 -0
- package/dist/components/badge.d.ts +5 -0
- package/dist/components/badge.d.ts.map +1 -0
- package/dist/components/badge.js +7 -0
- package/dist/components/badge.js.map +1 -0
- package/dist/components/button.d.ts +27 -0
- package/dist/components/button.d.ts.map +1 -0
- package/dist/components/button.js +209 -0
- package/dist/components/button.js.map +1 -0
- package/dist/components/generated-media.d.ts +12 -0
- package/dist/components/generated-media.d.ts.map +1 -0
- package/dist/components/generated-media.js +105 -0
- package/dist/components/generated-media.js.map +1 -0
- package/dist/components/github-icon.d.ts +3 -0
- package/dist/components/github-icon.d.ts.map +1 -0
- package/dist/components/github-icon.js +6 -0
- package/dist/components/github-icon.js.map +1 -0
- package/dist/components/index.d.ts +24 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/index.js +25 -0
- package/dist/components/index.js.map +1 -0
- package/dist/components/markdown.d.ts +48 -0
- package/dist/components/markdown.d.ts.map +1 -0
- package/dist/components/markdown.js +264 -0
- package/dist/components/markdown.js.map +1 -0
- package/dist/components/mermaid-block.d.ts +14 -0
- package/dist/components/mermaid-block.d.ts.map +1 -0
- package/dist/components/mermaid-block.js +339 -0
- package/dist/components/mermaid-block.js.map +1 -0
- package/dist/components/mermaid-diagram.d.ts +264 -0
- package/dist/components/mermaid-diagram.d.ts.map +1 -0
- package/dist/components/mermaid-diagram.js +999 -0
- package/dist/components/mermaid-diagram.js.map +1 -0
- package/dist/components/mermaid-dom.d.ts +51 -0
- package/dist/components/mermaid-dom.d.ts.map +1 -0
- package/dist/components/mermaid-dom.js +246 -0
- package/dist/components/mermaid-dom.js.map +1 -0
- package/dist/components/message-scroller.d.ts +23 -0
- package/dist/components/message-scroller.d.ts.map +1 -0
- package/dist/components/message-scroller.js +31 -0
- package/dist/components/message-scroller.js.map +1 -0
- package/dist/components/search-combobox.d.ts +44 -0
- package/dist/components/search-combobox.d.ts.map +1 -0
- package/dist/components/search-combobox.js +191 -0
- package/dist/components/search-combobox.js.map +1 -0
- package/dist/components/session-status.d.ts +9 -0
- package/dist/components/session-status.d.ts.map +1 -0
- package/dist/components/session-status.js +11 -0
- package/dist/components/session-status.js.map +1 -0
- package/dist/components/switch.d.ts +7 -0
- package/dist/components/switch.d.ts.map +1 -0
- package/dist/components/switch.js +14 -0
- package/dist/components/switch.js.map +1 -0
- package/package.json +177 -5
- package/theme/base.css +83 -0
- package/theme/component-theme.css +126 -0
- package/theme/index.css +3 -0
- package/theme/palette.css +347 -0
- package/theme/scoped-tokens.css +503 -0
- package/theme/theme.css +90 -0
- package/theme/tokens.css +165 -0
|
@@ -0,0 +1,663 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared, framework-free presentation logic for agent tool calls.
|
|
3
|
+
*
|
|
4
|
+
* Consumers (desktop app, cloud dashboard, future clients) feed the raw
|
|
5
|
+
* `{ toolName, input, result }` payload of a tool call in and get back a
|
|
6
|
+
* structured summary — label, per-item details, diff counts, extracted
|
|
7
|
+
* output text — which they render with the agent-chat primitives
|
|
8
|
+
* (`ToolActivityTrigger`, `ToolActivityDetails`, …) and their own icons.
|
|
9
|
+
*
|
|
10
|
+
* This module is pure data-in/data-out: no React, no DOM, no Node APIs, and
|
|
11
|
+
* no dependency on runtime schemas. Inputs are `unknown` and parsing is
|
|
12
|
+
* defensive; a malformed payload degrades to a generic label, never a throw.
|
|
13
|
+
*/
|
|
14
|
+
import { AGENT_CONTROL_TOOL_NAMES, agentControlLabel } from "./agents.js";
|
|
15
|
+
import { countDiffLines, makeUnifiedDiff } from "./diff.js";
|
|
16
|
+
import { extractOutputMedia, extractOutputText, isRecord, normalizeValue, parseApplyPatchInput, parseAskQuestionInput, parseEditorInput, parseEditorResultDiffCounts, parseReadFilesInput, parseRunCommandsInput, parseSearchInput, parseSpawnAgentInput, parseWebFetchInput, } from "./parsers.js";
|
|
17
|
+
import { detectLanguage, displayFileName, shortenPath } from "./paths.js";
|
|
18
|
+
import { pluralize, teamSummary } from "./team.js";
|
|
19
|
+
export { countDiffLines, FRAGMENT_HUNK_HEADER, makeUnifiedDiff, } from "./diff.js";
|
|
20
|
+
export { buildReadFilesKeys, extractOutputMedia, extractOutputText, parseApplyPatchInput, parseAskQuestionInput, parseEditorInput, parseEditorResultDiffCounts, parseReadFilesInput, parseRunCommandsInput, parseSearchInput, parseSpawnAgentInput, parseWebFetchInput, } from "./parsers.js";
|
|
21
|
+
export { detectLanguage, displayFileName, shortenPath } from "./paths.js";
|
|
22
|
+
export { teamSummary } from "./team.js";
|
|
23
|
+
const DEFAULT_OPTIONS = {
|
|
24
|
+
pathStyle: "shortened",
|
|
25
|
+
maxOutputChars: 64 * 1024,
|
|
26
|
+
maxInlineChars: Number.POSITIVE_INFINITY,
|
|
27
|
+
};
|
|
28
|
+
export const TOOL_NAME_ALIASES = {
|
|
29
|
+
"apply-patch": "apply_patch",
|
|
30
|
+
bash: "run_commands",
|
|
31
|
+
edit: "editor",
|
|
32
|
+
edit_file: "editor",
|
|
33
|
+
"file-read": "read_files",
|
|
34
|
+
file_read: "read_files",
|
|
35
|
+
read_file: "read_files",
|
|
36
|
+
search: "search_codebase",
|
|
37
|
+
"spawn-agent": "spawn_agent",
|
|
38
|
+
spawn_agent_tool: "spawn_agent",
|
|
39
|
+
"spawn-swarm": "spawn_swarm",
|
|
40
|
+
"web-fetch": "fetch_web_content",
|
|
41
|
+
web_fetch: "fetch_web_content",
|
|
42
|
+
};
|
|
43
|
+
export function normalizeToolName(toolName) {
|
|
44
|
+
const normalized = toolName.toLowerCase();
|
|
45
|
+
return TOOL_NAME_ALIASES[normalized] ?? normalized;
|
|
46
|
+
}
|
|
47
|
+
export function classifyTool(toolName) {
|
|
48
|
+
const name = normalizeToolName(toolName);
|
|
49
|
+
if (name === "read_files")
|
|
50
|
+
return "read";
|
|
51
|
+
if (name === "editor" || name === "apply_patch")
|
|
52
|
+
return "edit";
|
|
53
|
+
if (name === "run_commands")
|
|
54
|
+
return "command";
|
|
55
|
+
if (name === "search_codebase")
|
|
56
|
+
return "search";
|
|
57
|
+
if (name === "fetch_web_content")
|
|
58
|
+
return "web";
|
|
59
|
+
if (name === "spawn_agent" ||
|
|
60
|
+
name === "spawn_swarm" ||
|
|
61
|
+
name.startsWith("subagent_"))
|
|
62
|
+
return "spawn";
|
|
63
|
+
if (name === "team" ||
|
|
64
|
+
name === "teams" ||
|
|
65
|
+
name.startsWith("team_") ||
|
|
66
|
+
AGENT_CONTROL_TOOL_NAMES.has(name))
|
|
67
|
+
return "team";
|
|
68
|
+
if (name === "skills" || name === "skill")
|
|
69
|
+
return "skill";
|
|
70
|
+
if (name === "ask_question" || name === "ask_followup_question")
|
|
71
|
+
return "question";
|
|
72
|
+
if (name === "mcp" || name.startsWith("mcp_") || name.startsWith("mcp-"))
|
|
73
|
+
return "mcp";
|
|
74
|
+
// Fuzzy fallbacks for runtimes with their own tool names.
|
|
75
|
+
if (name.includes("command") || name.includes("terminal"))
|
|
76
|
+
return "command";
|
|
77
|
+
if (name.includes("read"))
|
|
78
|
+
return "read";
|
|
79
|
+
if (name.includes("edit") || name.includes("write"))
|
|
80
|
+
return "edit";
|
|
81
|
+
if (name.includes("search") || name.includes("grep"))
|
|
82
|
+
return "search";
|
|
83
|
+
if (name.includes("browser") ||
|
|
84
|
+
name.includes("fetch") ||
|
|
85
|
+
name.includes("web"))
|
|
86
|
+
return "web";
|
|
87
|
+
if (name.includes("mcp"))
|
|
88
|
+
return "mcp";
|
|
89
|
+
return "other";
|
|
90
|
+
}
|
|
91
|
+
function truncate(text, maxLen) {
|
|
92
|
+
const collapsed = text.replace(/\s+/g, " ").trim();
|
|
93
|
+
if (collapsed.length <= maxLen)
|
|
94
|
+
return collapsed;
|
|
95
|
+
return `${collapsed.slice(0, Math.max(1, maxLen - 1)).trimEnd()}…`;
|
|
96
|
+
}
|
|
97
|
+
function humanizeToolName(toolName) {
|
|
98
|
+
const cleaned = toolName
|
|
99
|
+
.replace(/^mcp[-_]+/i, "")
|
|
100
|
+
.replace(/[-_]+/g, " ")
|
|
101
|
+
.trim();
|
|
102
|
+
if (!cleaned)
|
|
103
|
+
return toolName;
|
|
104
|
+
return cleaned.charAt(0).toUpperCase() + cleaned.slice(1);
|
|
105
|
+
}
|
|
106
|
+
function formatPath(path, style) {
|
|
107
|
+
if (style === "basename")
|
|
108
|
+
return displayFileName(path);
|
|
109
|
+
if (style === "full")
|
|
110
|
+
return path;
|
|
111
|
+
return shortenPath(path);
|
|
112
|
+
}
|
|
113
|
+
/** ` (10–80)` / ` (10+)` label suffix for a partial-file read. */
|
|
114
|
+
function lineRangeLabelSuffix(startLine, endLine) {
|
|
115
|
+
if (startLine !== undefined && endLine !== undefined)
|
|
116
|
+
return ` (${startLine}–${endLine})`;
|
|
117
|
+
if (startLine !== undefined)
|
|
118
|
+
return ` (${startLine}+)`;
|
|
119
|
+
if (endLine !== undefined)
|
|
120
|
+
return ` (1–${endLine})`;
|
|
121
|
+
return "";
|
|
122
|
+
}
|
|
123
|
+
/** `:10-80` detail suffix for a partial-file read. */
|
|
124
|
+
function lineRangeDetailSuffix(startLine, endLine) {
|
|
125
|
+
if (startLine !== undefined && endLine !== undefined)
|
|
126
|
+
return `:${startLine}-${endLine}`;
|
|
127
|
+
if (startLine !== undefined)
|
|
128
|
+
return `:${startLine}+`;
|
|
129
|
+
if (endLine !== undefined)
|
|
130
|
+
return `:1-${endLine}`;
|
|
131
|
+
return "";
|
|
132
|
+
}
|
|
133
|
+
function capText(text, maxChars) {
|
|
134
|
+
if (text === undefined)
|
|
135
|
+
return undefined;
|
|
136
|
+
if (text.length <= maxChars)
|
|
137
|
+
return text;
|
|
138
|
+
return `${text.slice(0, maxChars)}\n\n[output truncated]`;
|
|
139
|
+
}
|
|
140
|
+
function extractErrorText(result, maxChars) {
|
|
141
|
+
const normalized = normalizeValue(result);
|
|
142
|
+
if (isRecord(normalized) && typeof normalized.error === "string") {
|
|
143
|
+
return capText(normalized.error, maxChars);
|
|
144
|
+
}
|
|
145
|
+
return capText(extractOutputText(normalized), maxChars);
|
|
146
|
+
}
|
|
147
|
+
function fallbackLabel(kind, toolName, inProgress) {
|
|
148
|
+
switch (kind) {
|
|
149
|
+
case "read":
|
|
150
|
+
return inProgress ? "Reading file" : "Read file";
|
|
151
|
+
case "edit":
|
|
152
|
+
return inProgress ? "Editing file" : "Edited file";
|
|
153
|
+
case "command":
|
|
154
|
+
return inProgress ? "Running command" : "Ran command";
|
|
155
|
+
case "search":
|
|
156
|
+
return inProgress ? "Searching" : "Searched";
|
|
157
|
+
case "web":
|
|
158
|
+
return inProgress ? "Fetching web content" : "Fetched web content";
|
|
159
|
+
case "spawn":
|
|
160
|
+
return inProgress ? "Spawning agent" : "Spawned agent";
|
|
161
|
+
case "skill":
|
|
162
|
+
return inProgress ? "Using skill" : "Used skill";
|
|
163
|
+
case "question":
|
|
164
|
+
return inProgress ? "Asking a question" : "Asked a question";
|
|
165
|
+
case "mcp":
|
|
166
|
+
return inProgress ? "Calling MCP tool" : "Called MCP tool";
|
|
167
|
+
default:
|
|
168
|
+
return inProgress
|
|
169
|
+
? `Running ${humanizeToolName(toolName)}`
|
|
170
|
+
: humanizeToolName(toolName);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
const READ_AGGREGATE = {
|
|
174
|
+
key: "read-files",
|
|
175
|
+
noun: "file",
|
|
176
|
+
completedVerb: "Read",
|
|
177
|
+
progressVerb: "Reading",
|
|
178
|
+
};
|
|
179
|
+
const EDIT_AGGREGATE = {
|
|
180
|
+
key: "edited-files",
|
|
181
|
+
noun: "file",
|
|
182
|
+
completedVerb: "Edited",
|
|
183
|
+
progressVerb: "Editing",
|
|
184
|
+
};
|
|
185
|
+
const COMMAND_AGGREGATE = {
|
|
186
|
+
key: "commands",
|
|
187
|
+
noun: "command",
|
|
188
|
+
completedVerb: "Ran",
|
|
189
|
+
progressVerb: "Running",
|
|
190
|
+
};
|
|
191
|
+
const SEARCH_AGGREGATE = {
|
|
192
|
+
key: "searches",
|
|
193
|
+
noun: "search",
|
|
194
|
+
pluralNoun: "searches",
|
|
195
|
+
completedVerb: "Explored",
|
|
196
|
+
progressVerb: "Exploring",
|
|
197
|
+
};
|
|
198
|
+
const WEB_AGGREGATE = {
|
|
199
|
+
key: "links",
|
|
200
|
+
noun: "link",
|
|
201
|
+
completedVerb: "Explored",
|
|
202
|
+
progressVerb: "Exploring",
|
|
203
|
+
};
|
|
204
|
+
const SPAWN_AGGREGATE = {
|
|
205
|
+
key: "spawned-agents",
|
|
206
|
+
noun: "agent",
|
|
207
|
+
completedVerb: "Spawned",
|
|
208
|
+
progressVerb: "Spawning",
|
|
209
|
+
};
|
|
210
|
+
function aggregateLabel(aggregate, count, inProgress) {
|
|
211
|
+
const verb = inProgress ? aggregate.progressVerb : aggregate.completedVerb;
|
|
212
|
+
return `${verb} ${pluralize(count, aggregate.noun, aggregate.pluralNoun)}`;
|
|
213
|
+
}
|
|
214
|
+
/** Derive the plain-text label and its styled segments together. */
|
|
215
|
+
function labeled(parts) {
|
|
216
|
+
return { label: parts.map((part) => part.text).join(""), labelParts: parts };
|
|
217
|
+
}
|
|
218
|
+
// Fallback summaries (unparsable or absent input) still carry an aggregate
|
|
219
|
+
// so consecutive calls merge into grouped counts ("Spawned 3 agents") rather
|
|
220
|
+
// than repeating the generic label.
|
|
221
|
+
const FALLBACK_AGGREGATES = {
|
|
222
|
+
command: COMMAND_AGGREGATE,
|
|
223
|
+
edit: EDIT_AGGREGATE,
|
|
224
|
+
read: READ_AGGREGATE,
|
|
225
|
+
search: SEARCH_AGGREGATE,
|
|
226
|
+
spawn: SPAWN_AGGREGATE,
|
|
227
|
+
web: WEB_AGGREGATE,
|
|
228
|
+
};
|
|
229
|
+
/**
|
|
230
|
+
* Build the presentation summary for one tool call.
|
|
231
|
+
*
|
|
232
|
+
* Single-item calls carry their specifics inline in the label
|
|
233
|
+
* (`Read app.tsx (10–80)`, `Ran bun test`, `Edited chat-view.tsx`); calls
|
|
234
|
+
* over multiple items aggregate (`Read 3 files`) with per-item lines in
|
|
235
|
+
* `details`. Never throws on malformed input.
|
|
236
|
+
*/
|
|
237
|
+
export function buildToolSummary(payload, options) {
|
|
238
|
+
const opts = { ...DEFAULT_OPTIONS, ...options };
|
|
239
|
+
const toolName = normalizeToolName(payload.toolName || "tool");
|
|
240
|
+
const kind = classifyTool(toolName);
|
|
241
|
+
const inProgress = payload.inProgress ?? false;
|
|
242
|
+
const isError = payload.isError ?? false;
|
|
243
|
+
const input = normalizeValue(payload.input);
|
|
244
|
+
const fallbackAggregate = FALLBACK_AGGREGATES[kind];
|
|
245
|
+
const base = {
|
|
246
|
+
toolName,
|
|
247
|
+
kind,
|
|
248
|
+
...labeled([{ text: fallbackLabel(kind, toolName, inProgress) }]),
|
|
249
|
+
aggregate: fallbackAggregate
|
|
250
|
+
? { ...fallbackAggregate, count: 1 }
|
|
251
|
+
: undefined,
|
|
252
|
+
items: [],
|
|
253
|
+
details: [],
|
|
254
|
+
outputMedia: extractOutputMedia(payload.result),
|
|
255
|
+
};
|
|
256
|
+
if (isError) {
|
|
257
|
+
base.errorText = extractErrorText(payload.result, opts.maxOutputChars);
|
|
258
|
+
}
|
|
259
|
+
const control = agentControlLabel(toolName, input, inProgress);
|
|
260
|
+
if (control) {
|
|
261
|
+
return {
|
|
262
|
+
...base,
|
|
263
|
+
...labeled([{ text: control }]),
|
|
264
|
+
outputText: isError
|
|
265
|
+
? undefined
|
|
266
|
+
: capText(extractOutputText(payload.result), opts.maxOutputChars),
|
|
267
|
+
};
|
|
268
|
+
}
|
|
269
|
+
if (kind === "team") {
|
|
270
|
+
const team = teamSummary(toolName, input, payload.result, inProgress, isError);
|
|
271
|
+
if (team) {
|
|
272
|
+
return {
|
|
273
|
+
...base,
|
|
274
|
+
...labeled([{ text: team.label }]),
|
|
275
|
+
aggregate: team.aggregate,
|
|
276
|
+
details: team.details,
|
|
277
|
+
items: team.details.map((text) => ({ type: "text", text })),
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
if (toolName === "read_files") {
|
|
282
|
+
const info = parseReadFilesInput(input);
|
|
283
|
+
if (info) {
|
|
284
|
+
const items = info.files.map((file) => ({
|
|
285
|
+
type: "file",
|
|
286
|
+
path: file.path,
|
|
287
|
+
displayPath: formatPath(file.path, opts.pathStyle),
|
|
288
|
+
startLine: file.startLine,
|
|
289
|
+
endLine: file.endLine,
|
|
290
|
+
language: detectLanguage(file.path),
|
|
291
|
+
}));
|
|
292
|
+
const single = info.files.length === 1 ? info.files[0] : null;
|
|
293
|
+
return {
|
|
294
|
+
...base,
|
|
295
|
+
...labeled(single
|
|
296
|
+
? [
|
|
297
|
+
{ text: `${inProgress ? "Reading" : "Read"} file ` },
|
|
298
|
+
{
|
|
299
|
+
text: `${displayFileName(single.path)}${lineRangeLabelSuffix(single.startLine, single.endLine)}`,
|
|
300
|
+
code: true,
|
|
301
|
+
},
|
|
302
|
+
]
|
|
303
|
+
: [
|
|
304
|
+
{
|
|
305
|
+
text: aggregateLabel(READ_AGGREGATE, info.files.length, inProgress),
|
|
306
|
+
},
|
|
307
|
+
]),
|
|
308
|
+
aggregate: { ...READ_AGGREGATE, count: info.files.length },
|
|
309
|
+
items,
|
|
310
|
+
details: info.files.map((file) => `${formatPath(file.path, opts.pathStyle)}${lineRangeDetailSuffix(file.startLine, file.endLine)}`),
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
if (toolName === "run_commands") {
|
|
315
|
+
const info = parseRunCommandsInput(input);
|
|
316
|
+
if (info) {
|
|
317
|
+
const commands = info.commands.map((command) => command.trim());
|
|
318
|
+
const singleInline = commands.length === 1
|
|
319
|
+
? truncate(commands[0], opts.maxInlineChars)
|
|
320
|
+
: null;
|
|
321
|
+
return {
|
|
322
|
+
...base,
|
|
323
|
+
// Single commands lead with the action, command in mono after.
|
|
324
|
+
...labeled(singleInline !== null
|
|
325
|
+
? [
|
|
326
|
+
{ text: `${inProgress ? "Running" : "Ran"} command ` },
|
|
327
|
+
{ text: singleInline, code: true },
|
|
328
|
+
]
|
|
329
|
+
: [
|
|
330
|
+
{
|
|
331
|
+
text: aggregateLabel(COMMAND_AGGREGATE, commands.length, inProgress),
|
|
332
|
+
},
|
|
333
|
+
]),
|
|
334
|
+
aggregate: { ...COMMAND_AGGREGATE, count: commands.length },
|
|
335
|
+
items: commands.map((command) => ({ type: "command", command })),
|
|
336
|
+
// The label may be ellipsized by the consumer's layout, so the
|
|
337
|
+
// expanded panel always carries the full command text.
|
|
338
|
+
details: commands,
|
|
339
|
+
outputText: isError
|
|
340
|
+
? undefined
|
|
341
|
+
: capText(extractOutputText(payload.result), opts.maxOutputChars),
|
|
342
|
+
};
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
if (toolName === "search_codebase") {
|
|
346
|
+
const info = parseSearchInput(input);
|
|
347
|
+
if (info) {
|
|
348
|
+
return {
|
|
349
|
+
...base,
|
|
350
|
+
...labeled(info.queries.length === 1
|
|
351
|
+
? [
|
|
352
|
+
{ text: `${inProgress ? "Searching" : "Searched"} ` },
|
|
353
|
+
{
|
|
354
|
+
text: truncate(info.queries[0], opts.maxInlineChars),
|
|
355
|
+
code: true,
|
|
356
|
+
},
|
|
357
|
+
]
|
|
358
|
+
: [
|
|
359
|
+
{
|
|
360
|
+
text: aggregateLabel(SEARCH_AGGREGATE, info.queries.length, inProgress),
|
|
361
|
+
},
|
|
362
|
+
]),
|
|
363
|
+
aggregate: { ...SEARCH_AGGREGATE, count: info.queries.length },
|
|
364
|
+
items: info.queries.map((query) => ({ type: "query", query })),
|
|
365
|
+
details: info.queries,
|
|
366
|
+
};
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
if (toolName === "fetch_web_content") {
|
|
370
|
+
const info = parseWebFetchInput(input);
|
|
371
|
+
if (info) {
|
|
372
|
+
return {
|
|
373
|
+
...base,
|
|
374
|
+
...labeled(info.urls.length === 1
|
|
375
|
+
? [
|
|
376
|
+
{ text: `${inProgress ? "Fetching" : "Fetched"} ` },
|
|
377
|
+
{
|
|
378
|
+
text: truncate(info.urls[0], opts.maxInlineChars),
|
|
379
|
+
code: true,
|
|
380
|
+
},
|
|
381
|
+
]
|
|
382
|
+
: [
|
|
383
|
+
{
|
|
384
|
+
text: aggregateLabel(WEB_AGGREGATE, info.urls.length, inProgress),
|
|
385
|
+
},
|
|
386
|
+
]),
|
|
387
|
+
aggregate: { ...WEB_AGGREGATE, count: info.urls.length },
|
|
388
|
+
items: info.urls.map((url) => ({ type: "url", url })),
|
|
389
|
+
details: info.urls,
|
|
390
|
+
};
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
if (toolName === "apply_patch") {
|
|
394
|
+
const info = parseApplyPatchInput(input);
|
|
395
|
+
if (info) {
|
|
396
|
+
const single = info.files.length === 1 ? info.files[0] : null;
|
|
397
|
+
const actionVerb = (action) => action === "add"
|
|
398
|
+
? inProgress
|
|
399
|
+
? "Creating file"
|
|
400
|
+
: "Created file"
|
|
401
|
+
: action === "delete"
|
|
402
|
+
? inProgress
|
|
403
|
+
? "Deleting file"
|
|
404
|
+
: "Deleted file"
|
|
405
|
+
: inProgress
|
|
406
|
+
? "Editing file"
|
|
407
|
+
: "Edited file";
|
|
408
|
+
// Renames display as `old → new`.
|
|
409
|
+
const fileLabel = (file) => file.movedTo
|
|
410
|
+
? `${displayFileName(file.path)} → ${displayFileName(file.movedTo)}`
|
|
411
|
+
: displayFileName(file.path);
|
|
412
|
+
const filePathDetail = (file) => file.movedTo
|
|
413
|
+
? `${formatPath(file.path, opts.pathStyle)} → ${formatPath(file.movedTo, opts.pathStyle)}`
|
|
414
|
+
: formatPath(file.path, opts.pathStyle);
|
|
415
|
+
return {
|
|
416
|
+
...base,
|
|
417
|
+
...labeled(single
|
|
418
|
+
? [
|
|
419
|
+
{ text: `${actionVerb(single.action)} ` },
|
|
420
|
+
{ text: fileLabel(single), code: true },
|
|
421
|
+
]
|
|
422
|
+
: [
|
|
423
|
+
{
|
|
424
|
+
text: aggregateLabel(EDIT_AGGREGATE, info.files.length, inProgress),
|
|
425
|
+
},
|
|
426
|
+
]),
|
|
427
|
+
aggregate: { ...EDIT_AGGREGATE, count: info.files.length },
|
|
428
|
+
diff: { additions: info.additions, deletions: info.deletions },
|
|
429
|
+
items: info.files.map((file) => ({
|
|
430
|
+
type: "file",
|
|
431
|
+
path: file.movedTo ?? file.path,
|
|
432
|
+
displayPath: formatPath(file.movedTo ?? file.path, opts.pathStyle),
|
|
433
|
+
language: detectLanguage(file.movedTo ?? file.path),
|
|
434
|
+
additions: file.additions,
|
|
435
|
+
deletions: file.deletions,
|
|
436
|
+
diff: file.diff,
|
|
437
|
+
// Deletions have no meaningful rich diff; single-hunk changes
|
|
438
|
+
// expose plain texts, multi-hunk changes must render per hunk.
|
|
439
|
+
oldText: file.action !== "delete" && file.hunks.length === 1
|
|
440
|
+
? file.action === "add"
|
|
441
|
+
? undefined
|
|
442
|
+
: file.hunks[0].oldText
|
|
443
|
+
: undefined,
|
|
444
|
+
newText: file.action !== "delete" && file.hunks.length === 1
|
|
445
|
+
? file.hunks[0].newText
|
|
446
|
+
: undefined,
|
|
447
|
+
hunks: file.action !== "delete" && file.hunks.length > 1
|
|
448
|
+
? file.hunks
|
|
449
|
+
: undefined,
|
|
450
|
+
fragment: file.action !== "add",
|
|
451
|
+
})),
|
|
452
|
+
details: info.files.map((file) => file.action === "delete"
|
|
453
|
+
? `Deleted ${filePathDetail(file)}`
|
|
454
|
+
: `${filePathDetail(file)} +${file.additions} -${file.deletions}`),
|
|
455
|
+
};
|
|
456
|
+
}
|
|
457
|
+
return {
|
|
458
|
+
...base,
|
|
459
|
+
...labeled([{ text: inProgress ? "Applying patch" : "Applied patch" }]),
|
|
460
|
+
aggregate: { ...EDIT_AGGREGATE, count: 1 },
|
|
461
|
+
};
|
|
462
|
+
}
|
|
463
|
+
if (toolName === "editor") {
|
|
464
|
+
const info = parseEditorInput(input);
|
|
465
|
+
const inputRecord = isRecord(input) ? input : null;
|
|
466
|
+
const path = info?.path ??
|
|
467
|
+
(typeof inputRecord?.path === "string" ? inputRecord.path : undefined);
|
|
468
|
+
// The editor schema has no `command`; derive the action from the shape.
|
|
469
|
+
const command = typeof inputRecord?.command === "string"
|
|
470
|
+
? inputRecord.command
|
|
471
|
+
: inputRecord?.insert_line != null
|
|
472
|
+
? "insert"
|
|
473
|
+
: typeof inputRecord?.old_text === "string"
|
|
474
|
+
? "str_replace"
|
|
475
|
+
: typeof inputRecord?.new_text === "string"
|
|
476
|
+
? "create"
|
|
477
|
+
: "edit";
|
|
478
|
+
const verb = inProgress
|
|
479
|
+
? command === "create"
|
|
480
|
+
? "Creating file"
|
|
481
|
+
: command === "insert"
|
|
482
|
+
? "Inserting into"
|
|
483
|
+
: "Editing file"
|
|
484
|
+
: command === "create"
|
|
485
|
+
? "Created file"
|
|
486
|
+
: command === "insert"
|
|
487
|
+
? "Inserted into"
|
|
488
|
+
: "Edited file";
|
|
489
|
+
let diff;
|
|
490
|
+
let diffText;
|
|
491
|
+
if (info && (info.oldText !== undefined || command === "create")) {
|
|
492
|
+
// str_replace texts are fragments of the file, not whole contents;
|
|
493
|
+
// fragment mode keeps the hunk header from claiming line positions.
|
|
494
|
+
diffText = makeUnifiedDiff(info.oldText ?? "", info.newText, info.path, 3, {
|
|
495
|
+
fragment: command !== "create",
|
|
496
|
+
});
|
|
497
|
+
diff = countDiffLines(diffText);
|
|
498
|
+
}
|
|
499
|
+
else {
|
|
500
|
+
diff = parseEditorResultDiffCounts(payload.result) ?? undefined;
|
|
501
|
+
}
|
|
502
|
+
if (path) {
|
|
503
|
+
return {
|
|
504
|
+
...base,
|
|
505
|
+
...labeled([
|
|
506
|
+
{ text: `${verb} ` },
|
|
507
|
+
{ text: displayFileName(path), code: true },
|
|
508
|
+
]),
|
|
509
|
+
aggregate: { ...EDIT_AGGREGATE, count: 1 },
|
|
510
|
+
diff,
|
|
511
|
+
items: [
|
|
512
|
+
{
|
|
513
|
+
type: "file",
|
|
514
|
+
path,
|
|
515
|
+
displayPath: formatPath(path, opts.pathStyle),
|
|
516
|
+
language: detectLanguage(path),
|
|
517
|
+
additions: diff?.additions,
|
|
518
|
+
deletions: diff?.deletions,
|
|
519
|
+
diff: diffText,
|
|
520
|
+
oldText: info?.oldText,
|
|
521
|
+
newText: info?.newText,
|
|
522
|
+
fragment: command !== "create",
|
|
523
|
+
},
|
|
524
|
+
],
|
|
525
|
+
// The label carries the basename; the expanded panel leads with
|
|
526
|
+
// the fuller path above the diff, matching read rows.
|
|
527
|
+
details: [formatPath(path, opts.pathStyle)],
|
|
528
|
+
};
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
if (toolName === "spawn_swarm") {
|
|
532
|
+
// A swarm's own shape: how many workers, not one task. The count is
|
|
533
|
+
// what a reader wants -- a round of six reads very differently from a
|
|
534
|
+
// round of one, and the per-worker tasks are in the digest.
|
|
535
|
+
const swarm = input;
|
|
536
|
+
const tasks = Array.isArray(swarm?.tasks) ? swarm.tasks.length : undefined;
|
|
537
|
+
const count = tasks ??
|
|
538
|
+
(typeof swarm?.count === "number"
|
|
539
|
+
? swarm.count
|
|
540
|
+
: swarm?.count === "max"
|
|
541
|
+
? undefined
|
|
542
|
+
: 1);
|
|
543
|
+
const how = count === undefined ? "as many agents as fit" : `${count} agents`;
|
|
544
|
+
return {
|
|
545
|
+
...base,
|
|
546
|
+
...labeled([{ text: `${inProgress ? "Spawning" : "Spawned"} ${how}` }]),
|
|
547
|
+
aggregate: { ...SPAWN_AGGREGATE, count: count ?? 1 },
|
|
548
|
+
};
|
|
549
|
+
}
|
|
550
|
+
if (toolName === "spawn_agent" || toolName.startsWith("subagent_")) {
|
|
551
|
+
const info = parseSpawnAgentInput(input);
|
|
552
|
+
if (info) {
|
|
553
|
+
return {
|
|
554
|
+
...base,
|
|
555
|
+
...labeled([
|
|
556
|
+
{ text: `${inProgress ? "Spawning" : "Spawned"} agent: ` },
|
|
557
|
+
{ text: truncate(info.task, opts.maxInlineChars) },
|
|
558
|
+
]),
|
|
559
|
+
aggregate: { ...SPAWN_AGGREGATE, count: 1 },
|
|
560
|
+
items: [{ type: "text", text: info.task }],
|
|
561
|
+
details: [info.task],
|
|
562
|
+
};
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
if (kind === "skill") {
|
|
566
|
+
const record = isRecord(input) ? input : null;
|
|
567
|
+
const skill = typeof record?.skill === "string" ? record.skill : "";
|
|
568
|
+
const args = typeof record?.args === "string" ? record.args : "";
|
|
569
|
+
if (skill) {
|
|
570
|
+
const detail = args ? `${skill} ${args}` : skill;
|
|
571
|
+
return {
|
|
572
|
+
...base,
|
|
573
|
+
...labeled([
|
|
574
|
+
{ text: `${inProgress ? "Using" : "Used"} skill ` },
|
|
575
|
+
{ text: truncate(skill, opts.maxInlineChars), code: true },
|
|
576
|
+
]),
|
|
577
|
+
items: [{ type: "text", text: detail }],
|
|
578
|
+
details: [detail],
|
|
579
|
+
};
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
if (kind === "question") {
|
|
583
|
+
const info = parseAskQuestionInput(input);
|
|
584
|
+
if (info) {
|
|
585
|
+
return {
|
|
586
|
+
...base,
|
|
587
|
+
...labeled([
|
|
588
|
+
{
|
|
589
|
+
text: `${inProgress ? "Asking" : "Asked"} "${truncate(info.question, opts.maxInlineChars)}"`,
|
|
590
|
+
},
|
|
591
|
+
]),
|
|
592
|
+
items: [
|
|
593
|
+
{ type: "text", text: info.question },
|
|
594
|
+
...info.options.map((option) => {
|
|
595
|
+
return { type: "text", text: option };
|
|
596
|
+
}),
|
|
597
|
+
],
|
|
598
|
+
details: info.options,
|
|
599
|
+
outputText: isError
|
|
600
|
+
? undefined
|
|
601
|
+
: capText(extractOutputText(payload.result), opts.maxOutputChars),
|
|
602
|
+
};
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
// Unknown/MCP tools: humanized name, plus whatever text the result holds.
|
|
606
|
+
const normalizedResult = normalizeValue(payload.result);
|
|
607
|
+
const resultRecord = isRecord(normalizedResult) ? normalizedResult : null;
|
|
608
|
+
const query = typeof resultRecord?.query === "string" ? resultRecord.query : "";
|
|
609
|
+
return {
|
|
610
|
+
...base,
|
|
611
|
+
...(query ? labeled([{ text: truncate(query, opts.maxInlineChars) }]) : {}),
|
|
612
|
+
outputText: isError
|
|
613
|
+
? undefined
|
|
614
|
+
: capText(extractOutputText(normalizedResult), opts.maxOutputChars),
|
|
615
|
+
};
|
|
616
|
+
}
|
|
617
|
+
/**
|
|
618
|
+
* Merge the labels of consecutive tool calls into one grouped-row label.
|
|
619
|
+
* Adjacent same-kind aggregates merge their counts ("Read 3 files"); other
|
|
620
|
+
* labels pass through, joined with " · ".
|
|
621
|
+
*/
|
|
622
|
+
export function buildGroupedToolLabel(summaries) {
|
|
623
|
+
if (summaries.length === 1) {
|
|
624
|
+
return summaries[0]?.label ?? "Tool";
|
|
625
|
+
}
|
|
626
|
+
const segments = [];
|
|
627
|
+
for (const summary of summaries) {
|
|
628
|
+
const aggregate = summary.aggregate;
|
|
629
|
+
if (!aggregate) {
|
|
630
|
+
segments.push({ type: "label", label: summary.label });
|
|
631
|
+
continue;
|
|
632
|
+
}
|
|
633
|
+
const previous = segments.at(-1);
|
|
634
|
+
if (previous?.type === "aggregate" &&
|
|
635
|
+
previous.aggregate.key === aggregate.key) {
|
|
636
|
+
segments[segments.length - 1] = {
|
|
637
|
+
type: "aggregate",
|
|
638
|
+
aggregate: {
|
|
639
|
+
...previous.aggregate,
|
|
640
|
+
count: previous.aggregate.count + aggregate.count,
|
|
641
|
+
inProgress: previous.aggregate.inProgress || (summary.inProgress ?? false),
|
|
642
|
+
},
|
|
643
|
+
};
|
|
644
|
+
continue;
|
|
645
|
+
}
|
|
646
|
+
segments.push({
|
|
647
|
+
type: "aggregate",
|
|
648
|
+
aggregate: { ...aggregate, inProgress: summary.inProgress ?? false },
|
|
649
|
+
});
|
|
650
|
+
}
|
|
651
|
+
return segments
|
|
652
|
+
.map((segment) => {
|
|
653
|
+
if (segment.type === "label")
|
|
654
|
+
return segment.label;
|
|
655
|
+
const { aggregate } = segment;
|
|
656
|
+
const verb = aggregate.inProgress
|
|
657
|
+
? aggregate.progressVerb
|
|
658
|
+
: aggregate.completedVerb;
|
|
659
|
+
return `${verb} ${pluralize(aggregate.count, aggregate.noun, aggregate.pluralNoun)}`;
|
|
660
|
+
})
|
|
661
|
+
.join(" · ");
|
|
662
|
+
}
|
|
663
|
+
//# sourceMappingURL=index.js.map
|