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

subagentDisplay.ts

25 lines1.1 KB

1import type { OrchestrationV2TurnItemStatus } from "@t3tools/contracts";
2​
3/** Summarizes one adjacent group, without changing its member identities or order. */
4export function subagentGroupSummary(
5 members: ReadonlyArray<{ readonly status: OrchestrationV2TurnItemStatus }>,
6) {
7 const active = members.some(
8 ({ status }) => status === "pending" || status === "running" || status === "waiting",
9 );
10 return {
11 label: `${active ? "Kicked off" : "Ran"} ${members.length} ${members.length === 1 ? "subagent" : "subagents"}`,
12 active,
13 failed: members.some(({ status }) => status === "failed"),
14 };
16​
17/** Formats Codex task paths for display while leaving provider identity untouched. */
18export function formatSubagentDisplayTitle(title: string): string {
19 const displayTitle = title.replace(/^Subagent:\s*/i, "");
20 const path = /^\/root\/(?:[^/]+\/)*([^/]+)\/?$/u.exec(displayTitle);
21 if (path === null) return displayTitle;
22​
23 const name = path[1]!.replace(/[_\s]+/gu, " ").trim();
24 return name.replace(/(^|\s)\S/gu, (letter) => letter.toUpperCase()) || displayTitle;