Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

presentation.ts

621 lines22.5 KB

1import {
2 isToolLifecycleItemType,
3 type AssetResource,
4 type RuntimeItemStatus,
5 type ThreadId,
6 type ToolActivitySource,
7 type ToolLifecycleItemType,
8} from "@t3tools/contracts";
9import { classifyMarkdownImageSource } from "@t3tools/client-runtime/markdown-images";
10import { resolveMediaSource } from "@t3tools/client-runtime/media-source";
11import { isWorkspaceImagePreviewPath } from "@t3tools/shared/filePreview";
12​
13export function isWorktreeSetupActivity(kind: string): boolean {
14 return kind === "setup-script.requested" || kind === "setup-script.started";
16​
17export type WorkLogToolLifecycleStatus = RuntimeItemStatus | "stopped";
18​
19export interface WorkLogPresentationEntry {
20 readonly label: string;
21 readonly toolTitle?: string;
22 readonly toolData?: unknown;
23 readonly tone: "thinking" | "tool" | "info" | "error";
24 readonly command?: string;
25 readonly detail?: string;
26 readonly viewedImagePath?: string;
27 readonly changedFiles?: ReadonlyArray<string>;
28 readonly itemType?: ToolLifecycleItemType;
29 readonly requestKind?: string;
30 readonly turnId?: string | null;
31 readonly toolCallId?: string;
32 readonly toolLifecycleStatus?: string;
33 readonly sourceActivityKind?: string;
34 readonly taskId?: string;
35 readonly toolSource?: ToolActivitySource;
37​
38export type ToolGroupAction =
39 | "read"
40 | "edit"
41 | "command"
42 | "browser"
43 | "code-search"
44 | "search"
45 | "other"
46 | "update";
47​
48export type ToolGroupSummaryKind =
49 | ToolGroupAction
50 | "dynamic-tool"
51 | "agent-tool"
52 | "tone-tool"
53 | "mixed";
54​
55export function normalizeCompactToolLabel(value: string): string {
56 return value.replace(/\s+(?:complete|completed)\s*$/i, "").trim();
58​
59const T3_MCP_TOOL_LABELS: Record<
60 string,
61 readonly [action: string, running: string, completed: string, detail: string]
62> = {
63 orchestrator_capabilities: ["Get", "Getting", "Got", "orchestration capabilities"],
64 delegate_task: ["Delegate", "Delegating", "Delegated", "a child task"],
65 task_status: ["Get", "Getting", "Got", "delegated task status"],
66 task_cancel: ["Cancel", "Canceling", "Canceled", "delegated task"],
67 schedule_task: ["Schedule", "Scheduling", "Scheduled", "a recurring task"],
68 list_scheduled_tasks: ["List", "Listing", "Listed", "scheduled tasks"],
69 update_scheduled_task: ["Update", "Updating", "Updated", "a scheduled task"],
70 delete_scheduled_task: ["Delete", "Deleting", "Deleted", "a scheduled task"],
71 create_threads: ["Create", "Creating", "Created", "T3 threads"],
72 t3_thread_start: ["Start", "Starting", "Started", "a T3 thread"],
73 t3_thread_list: ["List", "Listing", "Listed", "T3 threads"],
74 t3_thread_read: ["Read", "Reading", "Read", "a T3 thread"],
75 t3_thread_send: ["Send", "Sending", "Sent", "to a T3 thread"],
76 t3_thread_wait: ["Wait", "Waiting", "Waited", "for a T3 thread"],
77 t3_thread_interrupt: ["Interrupt", "Interrupting", "Interrupted", "a T3 thread"],
78 t3_worktree_handoff: ["Hand off", "Handing off", "Handed off", "thread to a git worktree"],
79 t3_worktree_status: ["Get", "Getting", "Got", "thread worktree status"],
80 preview_status: ["Get", "Getting", "Got", "preview browser status"],
81 preview_open: ["Open", "Opening", "Opened", "a page in the preview browser"],
82 preview_navigate: ["Navigate", "Navigating", "Navigated", "the preview browser"],
83 preview_snapshot: [
84 "Take a snapshot of",
85 "Taking a snapshot of",
86 "Took a snapshot of",
87 "the preview page",
88 ],
89 preview_click: ["Click", "Clicking", "Clicked", "in the preview browser"],
90 preview_press: ["Press", "Pressing", "Pressed", "a key in the preview browser"],
91 preview_type: ["Type", "Typing", "Typed", "in the preview browser"],
92 preview_scroll: ["Scroll", "Scrolling", "Scrolled", "the preview browser"],
93 preview_resize: ["Resize", "Resizing", "Resized", "the preview browser"],
94 preview_evaluate: ["Evaluate", "Evaluating", "Evaluated", "script in the preview browser"],
95 preview_wait_for: ["Wait", "Waiting", "Waited", "for the preview page"],
96 preview_set_appearance: ["Set", "Setting", "Set", "preview browser appearance"],
97 preview_recording_start: ["Start", "Starting", "Started", "recording the preview browser"],
98 preview_recording_stop: ["Stop", "Stopping", "Stopped", "recording the preview browser"],
99};
100​
101function resolveT3McpToolPresentation(value: string | undefined, status: string | undefined) {
102 if (!value) return null;
103 const name = normalizeCompactToolLabel(value).replace(
104 /^(?:mcp__(?:t3-code|t3_code|t3code)__|(?:t3-code|t3_code|t3code)(?:[.:/]|\s*·\s*))/i,
105 "",
106 );
107 if (!Object.hasOwn(T3_MCP_TOOL_LABELS, name)) return null;
108​
109 const [action, running, completed, detail] = T3_MCP_TOOL_LABELS[name]!;
110 const verb =
111 status === "inProgress"
112 ? running
113 : status === "completed"
114 ? completed
115 : status === "failed"
116 ? `Failed to ${action.toLowerCase()}`
117 : status === "declined"
118 ? `Declined to ${action.toLowerCase()}`
119 : status === "stopped"
120 ? `Stopped ${running.toLowerCase()}`
121 : running;
122​
123 return {
124 displayName: `${verb} ${detail}`,
125 icon: name.startsWith("preview_") ? ("browser" as const) : ("t3-code" as const),
126 };
128​
129/** Latest live activity stays present-tense unless the call itself failed, declined, or stopped. */
130export function liveActivityToolStatus(status: string | undefined, presentTense: boolean) {
131 if (status === "failed" || status === "declined" || status === "stopped") return status;
132 if (presentTense || status === "inProgress") return "inProgress";
133 return "completed";
135​
136/** Resolves tool identity before choosing labels or icons in either client. */
137export function resolveWorkEntryToolPresentation(
138 entry: Pick<WorkLogPresentationEntry, "label" | "toolTitle" | "toolData" | "toolLifecycleStatus">,
139 fallbackStatus?: "inProgress" | "completed",
140) {
141 const status = entry.toolLifecycleStatus ?? fallbackStatus;
142 const data = entry.toolData;
143 if (data !== null && typeof data === "object") {
144 if (
145 "server" in data &&
146 typeof data.server === "string" &&
147 "tool" in data &&
148 typeof data.tool === "string"
149 ) {
150 return resolveT3McpToolPresentation(`${data.server}.${data.tool}`, status);
151 }
152 if ("toolName" in data && typeof data.toolName === "string") {
153 return resolveT3McpToolPresentation(data.toolName, status);
154 }
155 }
156​
157 return (
158 resolveT3McpToolPresentation(entry.toolTitle, status) ??
159 resolveT3McpToolPresentation(entry.label, status)
160 );
162​
163function asRecord(value: unknown): Record<string, unknown> | null {
164 return value !== null && typeof value === "object" && !Array.isArray(value)
165 ? (value as Record<string, unknown>)
166 : null;
168​
169function nonEmptyString(value: unknown): string | null {
170 return typeof value === "string" && value.trim().length > 0 ? value : null;
172​
173function commandResultContent(value: unknown): string | null {
174 const direct = nonEmptyString(value);
175 if (direct) return direct;
176​
177 const directContent = Array.isArray(value) ? value : null;
178 const record = asRecord(value);
179 const content = record?.content;
180 const contentText = nonEmptyString(content);
181 if (contentText) return contentText;
182 const blocks = directContent ?? (Array.isArray(content) ? content : null);
183 if (!blocks) return null;
184​
185 const chunks = blocks.flatMap((entry) => {
186 const text = nonEmptyString(entry) ?? nonEmptyString(asRecord(entry)?.text);
187 return text ? [text] : [];
188 });
189 return chunks.length > 0 ? chunks.join("\n") : null;
191​
192/** Returns provider command output before it is formatted for a work-log row. */
193export function extractCommandOutputText(dataValue: unknown): string | null {
194 const data = asRecord(dataValue);
195 const item = asRecord(data?.item);
196 const itemResult = asRecord(item?.result);
197 const rawOutput = asRecord(data?.rawOutput);
198 const outputStreams = [
199 nonEmptyString(rawOutput?.stdout),
200 nonEmptyString(rawOutput?.stderr),
201 ].filter((value): value is string => value !== null);
202 const acpContent = Array.isArray(data?.content)
203 ? data.content
204 .flatMap((entryValue) => {
205 const entry = asRecord(entryValue);
206 const content = asRecord(entry?.content);
207 const text = entry?.type === "content" ? nonEmptyString(content?.text) : null;
208 return text ? [text] : [];
209 })
210 .join("\n")
211 : null;
212​
213 const candidates = [
214 item?.aggregatedOutput,
215 itemResult?.content,
216 data?.rawOutput,
217 rawOutput?.content,
218 outputStreams.length > 0 ? outputStreams.join("\n") : null,
219 rawOutput?.output,
220 acpContent,
221 data?.result,
222 ];
223 for (const candidate of candidates) {
224 const text = commandResultContent(candidate);
225 if (text) return text;
226 }
227 return null;
229​
230/**
231 * Ingestion caps tool details at 180 chars and appends "...", so a long command
232 * echo no longer equals the command it repeats. Treat a truncated prefix of the
233 * command as the same echo.
234 */
235function textRepeatsCommand(text: string, commands: ReadonlyArray<string | null>): boolean {
236 const truncated = text.endsWith("...")
237 ? text.slice(0, -3)
238 : text.endsWith("\u2026")
239 ? text.slice(0, -1)
240 : null;
241 return commands.some((candidate) => {
242 const command = candidate?.trim();
243 if (!command) return false;
244 if (command === text) return true;
245 return (
246 truncated !== null &&
247 truncated.length > 0 &&
248 command.length > truncated.length &&
249 command.startsWith(truncated)
250 );
251 });
253​
254/**
255 * Decides whether a command row's `detail` is a synthetic echo of the command
256 * rather than real output. OpenCode stores completed output in `detail` with no
257 * other output channel, so plain equality is only treated as synthetic when the
258 * payload shape shows the detail came from the command: Codex item metadata,
259 * an ACP tool call (`data.toolCallId`, `kind: "execute"`), a Claude tool-name
260 * prefix, or no structured command at all.
261 */
262export function commandDetailRepeatsCommand(input: {
263 readonly detail: string;
264 readonly command: string | null;
265 readonly rawCommand: string | null;
266 readonly toolName: unknown;
267 readonly data: unknown;
268}): boolean {
269 const toolName = nonEmptyString(input.toolName)?.trim();
270 const detail = input.detail.trim();
271 const commands = [input.command, input.rawCommand];
272 if (toolName) {
273 const prefix = `${toolName}:`;
274 if (detail.toLowerCase().startsWith(prefix.toLowerCase())) {
275 const unprefixed = detail.slice(prefix.length).trim();
276 if (textRepeatsCommand(unprefixed, commands)) return true;
277 }
278 }
279​
280 if (!textRepeatsCommand(detail, commands)) return false;
281​
282 const data = asRecord(input.data);
283 const item = asRecord(data?.item);
284 const itemInput = asRecord(item?.input);
285 const itemResult = asRecord(item?.result);
286 const hasStructuredCommand = [
287 item?.command,
288 itemInput?.command,
289 itemResult?.command,
290 data?.command,
291 ].some((value) =>
292 Array.isArray(value)
293 ? value.some((part) => nonEmptyString(part) !== null)
294 : nonEmptyString(value) !== null,
295 );
296 return (
297 !hasStructuredCommand ||
298 item !== null ||
299 data?.toolCallId !== undefined ||
300 nonEmptyString(data?.kind)?.toLowerCase() === "execute"
301 );
303​
304export function workLogEntryIsToolLike(entry: WorkLogPresentationEntry): boolean {
305 if (entry.tone === "tool" || entry.tone === "thinking" || entry.tone === "error") return true;
306 if (entry.command !== undefined && entry.command.trim().length > 0) return true;
307 if (entry.requestKind !== undefined) return true;
308 return entry.itemType !== undefined && isToolLifecycleItemType(entry.itemType);
310​
311/** Maps item and task status to the status shown on a work-log row. */
312export function extractWorkLogToolLifecycleStatus(
313 payloadValue: unknown,
314): WorkLogToolLifecycleStatus | undefined {
315 const payload = asRecord(payloadValue);
316 switch (payload?.status) {
317 case "pending":
318 case "running":
319 case "waiting":
320 return "inProgress";
321 case "cancelled":
322 case "interrupted":
323 return "stopped";
324 case "idle":
325 // A batch becomes idle when its parent turn ends. Other idle tasks can resume.
326 return payload.taskType === "subagent_batch" ? "stopped" : undefined;
327 case "inProgress":
328 case "completed":
329 case "failed":
330 case "declined":
331 case "stopped":
332 return payload.status;
333 default:
334 return undefined;
335 }
337​
338// Some providers report completion even when the output describes a failure.
339function toolDetailTextLooksLikeFailure(text: string): boolean {
340 const normalized = text.toLowerCase();
341 return (
342 normalized.includes("file not found") ||
343 normalized.includes("no files found") ||
344 normalized.includes("enoent") ||
345 normalized.includes("no such file or directory") ||
346 normalized.includes("no such file") ||
347 normalized.includes("commandnotfoundexception") ||
348 normalized.includes("command not found") ||
349 (normalized.includes("cannot find path") && normalized.includes("because it does not exist")) ||
350 (normalized.includes("is not recognized") && normalized.includes("the term '")) ||
351 normalized.includes("is not recognized as the name of a cmdlet") ||
352 normalized.includes("a parameter cannot be found that matches parameter name") ||
353 /<exited with exit code\s+[1-9]\d*\s*>/i.test(text) ||
354 /exit(?:ed)? with exit code\s+[1-9]\d*/i.test(text) ||
355 /exit code\s*[:\s]\s*[1-9]\d*\b/i.test(text)
356 );
358​
359function workEntryIndicatesToolFailureFromOutput(
360 entry: WorkLogPresentationEntry,
361 includeCommand: boolean,
362): boolean {
363 if (
364 entry.tone === "error" ||
365 entry.toolLifecycleStatus === "failed" ||
366 entry.toolLifecycleStatus === "declined"
367 ) {
368 return true;
369 }
370 if (!workLogEntryIsToolLike(entry)) return false;
371 const output = includeCommand
372 ? [entry.detail, entry.command].filter(Boolean).join("\n")
373 : (entry.detail ?? "");
374 return output.length > 0 && toolDetailTextLooksLikeFailure(output);
376​
377/** Includes legacy activities that stored error output in the command field. */
378export function workEntryIndicatesToolFailure(entry: WorkLogPresentationEntry): boolean {
379 return workEntryIndicatesToolFailureFromOutput(entry, true);
381​
382/** Checks rendered output without treating the user's command as an error. */
383export function workEntryDisplayIndicatesToolFailure(entry: WorkLogPresentationEntry): boolean {
384 return workEntryIndicatesToolFailureFromOutput(entry, false);
386​
387/** Decides whether the row can show a success marker. */
388export function workEntryIndicatesToolSuccess(entry: WorkLogPresentationEntry): boolean {
389 return (
390 workLogEntryIsToolLike(entry) &&
391 !workEntryIndicatesToolFailure(entry) &&
392 entry.tone !== "thinking" &&
393 entry.toolLifecycleStatus !== "inProgress" &&
394 entry.toolLifecycleStatus !== "stopped"
395 );
397​
398function workLogEntryIsLocalCodeSearch(entry: WorkLogPresentationEntry): boolean {
399 return (
400 entry.itemType === "web_search" &&
401 /\bgrep\b/i.test(normalizeCompactToolLabel(entry.toolTitle ?? entry.label))
402 );
404​
405export function toolGroupAction(entry: WorkLogPresentationEntry): ToolGroupAction {
406 if (
407 entry.sourceActivityKind === "approval.requested" ||
408 entry.sourceActivityKind === "approval.resolved" ||
409 entry.sourceActivityKind === "provider.approval.respond.failed"
410 ) {
411 return "update";
412 }
413 if (resolveWorkEntryToolPresentation(entry)?.icon === "browser") return "browser";
414 if (
415 entry.requestKind === "file-read" ||
416 entry.itemType === "image_view" ||
417 entry.viewedImagePath !== undefined ||
418 (entry.itemType === "dynamic_tool_call" &&
419 entry.toolTitle?.trim().toLowerCase() === "read file")
420 ) {
421 return "read";
422 }
423 if (
424 entry.requestKind === "file-change" ||
425 entry.itemType === "file_change" ||
426 (entry.changedFiles?.length ?? 0) > 0
427 ) {
428 return "edit";
429 }
430 if (entry.requestKind === "command" || entry.itemType === "command_execution" || entry.command) {
431 return "command";
432 }
433 if (workLogEntryIsLocalCodeSearch(entry)) return "code-search";
434 if (entry.itemType === "web_search") return "search";
435 return workLogEntryIsToolLike(entry) ? "other" : "update";
437​
438export function workEntryViewedImagePath(entry: WorkLogPresentationEntry): string | null {
439 const viewedImagePath = entry.viewedImagePath?.trim();
440 if (
441 viewedImagePath !== undefined &&
442 !/[\r\n]/.test(viewedImagePath) &&
443 isWorkspaceImagePreviewPath(viewedImagePath)
444 ) {
445 return viewedImagePath;
446 }
447 const detail = entry.detail?.trim();
448 return toolGroupAction(entry) === "read" &&
449 detail !== undefined &&
450 !/[\r\n]/.test(detail) &&
451 isWorkspaceImagePreviewPath(detail)
452 ? detail
453 : null;
455​
456export interface ViewedImageAsset {
457 readonly resource: Extract<AssetResource, { readonly _tag: "media-file" }>;
458 readonly alt: string;
459 readonly srcFragment: string;
461​
462export function resolveViewedImageAsset(
463 source: string,
464 input: {
465 readonly threadId: ThreadId;
466 readonly workspaceRoot?: string | null | undefined;
467 },
468): ViewedImageAsset | null {
469 // A relative path with no known workspace still names a media-file relative
470 // to the thread's workspace, so classify against "." and drop the prefix.
471 const imageSource = classifyMarkdownImageSource(source, input.workspaceRoot ?? ".");
472 if (imageSource._tag !== "WorkspaceFile") return null;
473 const resolvedFilePath =
474 input.workspaceRoot == null && imageSource.path.startsWith("./")
475 ? imageSource.path.slice(2)
476 : imageSource.path;
477​
478 const media = resolveMediaSource(source, {
479 threadId: input.threadId,
480 workspaceRoot: input.workspaceRoot,
481 resolvedFilePath,
482 });
483 if (media === null || media.access !== "environment") return null;
484 return { resource: media.resource, alt: media.name, srcFragment: media.srcFragment };
486​
487function toolGroupActionCount(
488 action: ToolGroupAction,
489 entries: ReadonlyArray<WorkLogPresentationEntry>,
490): number {
491 if (action !== "edit") return entries.length;
492​
493 const changedFiles = new Set<string>();
494 let editsWithoutFileDetails = 0;
495 for (const entry of entries) {
496 if (!entry.changedFiles || entry.changedFiles.length === 0) {
497 editsWithoutFileDetails += 1;
498 continue;
499 }
500 for (const file of entry.changedFiles) changedFiles.add(file);
501 }
502 return changedFiles.size + editsWithoutFileDetails;
504​
505function toolGroupActionLabel(action: ToolGroupAction, count: number): string {
506 switch (action) {
507 case "read":
508 return `Read ${count} ${count === 1 ? "file" : "files"}`;
509 case "edit":
510 return `Changed ${count} ${count === 1 ? "file" : "files"}`;
511 case "command":
512 return `Ran ${count} ${count === 1 ? "command" : "commands"}`;
513 case "browser":
514 return `Used browser ${count} ${count === 1 ? "time" : "times"}`;
515 case "search":
516 return `Searched the web ${count} ${count === 1 ? "time" : "times"}`;
517 case "code-search":
518 return `Searched code ${count} ${count === 1 ? "time" : "times"}`;
519 case "other":
520 return `Used ${count} ${count === 1 ? "tool" : "tools"}`;
521 case "update":
522 return `Received ${count} ${count === 1 ? "update" : "updates"}`;
523 }
525​
526export function summarizeToolGroup(entries: ReadonlyArray<WorkLogPresentationEntry>): string {
527 const summaryEntries = omitSupersededLifecycleMarkers(entries, (entry) => entry);
528 const sources = new Map<string, ToolActivitySource>();
529 const groupedEntries = new Map<ToolGroupAction, WorkLogPresentationEntry[]>();
530 for (const entry of summaryEntries) {
531 if (entry.toolSource) {
532 sources.set(entry.toolSource.key, entry.toolSource);
533 continue;
534 }
535 const action = toolGroupAction(entry);
536 const group = groupedEntries.get(action);
537 if (group) group.push(entry);
538 else groupedEntries.set(action, [entry]);
539 }
540 const labels = [...groupedEntries].map(([action, actionEntries]) =>
541 toolGroupActionLabel(action, toolGroupActionCount(action, actionEntries)),
542 );
543 if (sources.size > 0) {
544 const sourceValues = [...sources.values()];
545 const sourceNames = sourceValues.map((source) => source.name);
546 const formattedNames =
547 sourceNames.length < 2
548 ? sourceNames[0]!
549 : sourceNames.length === 2
550 ? sourceNames.join(" and ")
551 : `${sourceNames.slice(0, -1).join(", ")}, and ${sourceNames.at(-1)}`;
552 const allIntegrations = sourceValues.every((source) => source.kind === "integration");
553 labels.unshift(
554 `Used ${formattedNames}${allIntegrations ? ` ${sources.size === 1 ? "integration" : "integrations"}` : ""}`,
555 );
556 }
557 const sentenceLabels = labels.map((label, index) =>
558 index === 0 ? label : label.charAt(0).toLowerCase() + label.slice(1),
559 );
560 if (sentenceLabels.length < 2) return sentenceLabels[0] ?? "";
561 if (sentenceLabels.length === 2) return sentenceLabels.join(" and ");
562 return `${sentenceLabels.slice(0, -1).join(", ")}, and ${sentenceLabels.at(-1)}`;
564​
565export function omitSupersededLifecycleMarkers<T>(
566 entries: readonly T[],
567 workEntryFor: (entry: T) => WorkLogPresentationEntry,
568): T[] {
569 const laterTerminalIdentities = new Set<string>();
570 const reversedEntries: T[] = [];
571​
572 for (let index = entries.length - 1; index >= 0; index -= 1) {
573 const entry = entries[index]!;
574 const workEntry = workEntryFor(entry);
575 const normalizedLabel = normalizeCompactToolLabel(workEntry.toolTitle ?? workEntry.label);
576 const identity = [
577 workEntry.turnId ?? "no-turn",
578 workEntry.itemType ?? "",
579 normalizedLabel,
580 ].join("\u001f");
581 const activityKind = workEntry.sourceActivityKind;
582 const isStatuslessIdlessMarker =
583 workEntry.toolCallId === undefined &&
584 workEntry.toolLifecycleStatus === undefined &&
585 (activityKind === "tool.started" || activityKind === "tool.updated");
586 if (isStatuslessIdlessMarker && laterTerminalIdentities.has(identity)) continue;
587​
588 reversedEntries.push(entry);
589 if (
590 activityKind === "tool.completed" ||
591 (workEntry.toolLifecycleStatus !== undefined &&
592 workEntry.toolLifecycleStatus !== "inProgress")
593 ) {
594 laterTerminalIdentities.add(identity);
595 }
596 }
597​
598 return reversedEntries.toReversed();
600​
601export function toolGroupSummaryKind(
602 entries: ReadonlyArray<WorkLogPresentationEntry>,
603): ToolGroupSummaryKind {
604 const actions = new Set(entries.map(toolGroupAction));
605 if (actions.size !== 1) return "mixed";
606​
607 const action = actions.values().next().value!;
608 if (action !== "other") return action;
609​
610 const fallbackKinds = new Set(
611 entries.map((entry): ToolGroupSummaryKind => {
612 if (entry.itemType === "mcp_tool_call") return "other";
613 if (entry.itemType === "dynamic_tool_call") return "dynamic-tool";
614 if (entry.itemType === "collab_agent_tool_call" || entry.taskId) return "agent-tool";
615 if (entry.tone === "thinking") return "agent-tool";
616 if (entry.tone === "tool") return "tone-tool";
617 return "other";
618 }),
619 );
620 return fallbackKinds.size === 1 ? fallbackKinds.values().next().value! : "mixed";