@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,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rows for the lead's tools over its delegated agents: the status tool and
|
|
3
|
+
* the controls. Each says which agent or round it was about, which a bare
|
|
4
|
+
* humanized tool name did not.
|
|
5
|
+
*/
|
|
6
|
+
function isRecord(value) {
|
|
7
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
8
|
+
}
|
|
9
|
+
function ids(record, one, many) {
|
|
10
|
+
const list = [
|
|
11
|
+
...(typeof record[one] === "string" ? [record[one]] : []),
|
|
12
|
+
...(Array.isArray(record[many])
|
|
13
|
+
? record[many].filter((entry) => typeof entry === "string")
|
|
14
|
+
: []),
|
|
15
|
+
]
|
|
16
|
+
.map((entry) => entry.trim())
|
|
17
|
+
.filter(Boolean);
|
|
18
|
+
return list;
|
|
19
|
+
}
|
|
20
|
+
function listed(list, max = 4) {
|
|
21
|
+
return list.length > max
|
|
22
|
+
? `${list.slice(0, max).join(", ")} and ${list.length - max} more`
|
|
23
|
+
: list.join(", ");
|
|
24
|
+
}
|
|
25
|
+
/** The tools this covers. */
|
|
26
|
+
export const AGENT_CONTROL_TOOL_NAMES = new Set([
|
|
27
|
+
"agents_status",
|
|
28
|
+
"requeue_agent",
|
|
29
|
+
"restart_agent",
|
|
30
|
+
"resume_agent",
|
|
31
|
+
"retry_failed",
|
|
32
|
+
"message_agents",
|
|
33
|
+
"stop_agents",
|
|
34
|
+
"await_agents",
|
|
35
|
+
"compact_agents",
|
|
36
|
+
]);
|
|
37
|
+
/** The row label for one of {@link AGENT_CONTROL_TOOL_NAMES}, or undefined. */
|
|
38
|
+
export function agentControlLabel(toolName, input, inProgress) {
|
|
39
|
+
if (!AGENT_CONTROL_TOOL_NAMES.has(toolName)) {
|
|
40
|
+
return undefined;
|
|
41
|
+
}
|
|
42
|
+
const record = isRecord(input) ? input : {};
|
|
43
|
+
const verb = (now, done) => (inProgress ? now : done);
|
|
44
|
+
switch (toolName) {
|
|
45
|
+
case "agents_status": {
|
|
46
|
+
const agents = ids(record, "agent_id", "agent_ids");
|
|
47
|
+
if (agents.length > 0) {
|
|
48
|
+
return `${verb("Checking", "Checked")} agent${agents.length === 1 ? "" : "s"} ${listed(agents)}`;
|
|
49
|
+
}
|
|
50
|
+
if (typeof record.round_id === "string" && record.round_id.trim()) {
|
|
51
|
+
return `${verb("Checking", "Checked")} round ${record.round_id.trim()}`;
|
|
52
|
+
}
|
|
53
|
+
return `${verb("Checking", "Checked")} the agents`;
|
|
54
|
+
}
|
|
55
|
+
case "requeue_agent":
|
|
56
|
+
case "restart_agent":
|
|
57
|
+
case "resume_agent": {
|
|
58
|
+
const agent = ids(record, "agent_id", "agent_ids")[0] ?? "an agent";
|
|
59
|
+
const reason = typeof record.reason === "string" && record.reason.trim()
|
|
60
|
+
? ` (${record.reason.trim()})`
|
|
61
|
+
: "";
|
|
62
|
+
const extra = Number(record.extra_iterations);
|
|
63
|
+
if (toolName === "requeue_agent") {
|
|
64
|
+
return `${verb("Requeuing", "Requeued")} ${agent}${reason}`;
|
|
65
|
+
}
|
|
66
|
+
if (toolName === "restart_agent") {
|
|
67
|
+
return `${verb("Restarting", "Restarted")} ${agent}`;
|
|
68
|
+
}
|
|
69
|
+
const resumed = ids(record, "agent_id", "agent_ids");
|
|
70
|
+
return `${verb("Resuming", "Resumed")} ${resumed.length === 0
|
|
71
|
+
? "every waiting agent"
|
|
72
|
+
: resumed.length === 1
|
|
73
|
+
? agent
|
|
74
|
+
: listed(resumed)}${Number.isFinite(extra) && extra > 0 ? ` (+${extra} iterations)` : ""}`;
|
|
75
|
+
}
|
|
76
|
+
case "retry_failed": {
|
|
77
|
+
const round = typeof record.round_id === "string" ? record.round_id.trim() : "";
|
|
78
|
+
return `${verb("Retrying", "Retried")} the failed agents${round ? ` of ${round}` : ""}`;
|
|
79
|
+
}
|
|
80
|
+
case "message_agents":
|
|
81
|
+
case "stop_agents": {
|
|
82
|
+
const agents = ids(record, "agent", "agents");
|
|
83
|
+
if (toolName === "message_agents") {
|
|
84
|
+
return `${verb("Messaging", "Messaged")} ${agents.length > 0 ? listed(agents) : "every running agent"}`;
|
|
85
|
+
}
|
|
86
|
+
return `${verb("Stopping", "Stopped")} ${agents.length > 0 ? listed(agents) : "every running agent"}`;
|
|
87
|
+
}
|
|
88
|
+
case "compact_agents": {
|
|
89
|
+
const agents = ids(record, "agent", "agents");
|
|
90
|
+
return `${verb("Compacting", "Compacted")} ${agents.length > 0 ? listed(agents) : "no agents"}`;
|
|
91
|
+
}
|
|
92
|
+
case "await_agents": {
|
|
93
|
+
const rounds = ids(record, "round_id", "round_ids");
|
|
94
|
+
return `${verb("Waiting for", "Waited for")} ${rounds.length > 0 ? `round ${listed(rounds)}` : "the running rounds"}`;
|
|
95
|
+
}
|
|
96
|
+
default:
|
|
97
|
+
return undefined;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
//# sourceMappingURL=agents.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agents.js","sourceRoot":"","sources":["../../../../components/agent-chat/tool-summary/agents.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,SAAS,QAAQ,CAAC,KAAc;IAC/B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI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,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,oBAAoB,EAAE,CAAC;QACvH,CAAC;QACD;YACC,OAAO,SAAS,CAAC;IACnB,CAAC;AACF,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/** Honest hunk separator for diffs built from file fragments. */
|
|
2
|
+
export declare const FRAGMENT_HUNK_HEADER = "@@ \u2026 @@";
|
|
3
|
+
export type MakeUnifiedDiffOptions = {
|
|
4
|
+
/**
|
|
5
|
+
* Set when oldText/newText are fragments of a larger file (e.g. editor
|
|
6
|
+
* str_replace payloads) rather than complete file contents. Hunk headers
|
|
7
|
+
* then render as `@@ … @@` instead of fabricating line-1-relative
|
|
8
|
+
* positions that would mislocate the change.
|
|
9
|
+
*/
|
|
10
|
+
fragment?: boolean;
|
|
11
|
+
};
|
|
12
|
+
export declare function makeUnifiedDiff(oldText: string, newText: string, filePath: string, ctx?: number, options?: MakeUnifiedDiffOptions): string;
|
|
13
|
+
export declare function hunkHeader(lines: string[]): string;
|
|
14
|
+
/**
|
|
15
|
+
* Count added/removed lines in a unified diff, ignoring the `---`/`+++`
|
|
16
|
+
* file headers and `@@` hunk headers.
|
|
17
|
+
*/
|
|
18
|
+
export declare function countDiffLines(diff: string): {
|
|
19
|
+
additions: number;
|
|
20
|
+
deletions: number;
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=diff.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diff.d.ts","sourceRoot":"","sources":["../../../../components/agent-chat/tool-summary/diff.ts"],"names":[],"mappings":"AAyCA,iEAAiE;AACjE,eAAO,MAAM,oBAAoB,iBAAY,CAAC;AAE9C,MAAM,MAAM,sBAAsB,GAAG;IACpC;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC;AAEF,wBAAgB,eAAe,CAC9B,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,EAChB,GAAG,SAAI,EACP,OAAO,CAAC,EAAE,sBAAsB,GAC9B,MAAM,CA+DR;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,CAQlD;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG;IAC7C,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CAClB,CASA"}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
function computeLcs(a, b) {
|
|
2
|
+
const m = a.length;
|
|
3
|
+
const n = b.length;
|
|
4
|
+
const dp = Array.from({ length: m + 1 }, () => new Array(n + 1).fill(0));
|
|
5
|
+
for (let i = 1; i <= m; i++) {
|
|
6
|
+
for (let j = 1; j <= n; j++) {
|
|
7
|
+
dp[i][j] =
|
|
8
|
+
a[i - 1] === b[j - 1]
|
|
9
|
+
? dp[i - 1][j - 1] + 1
|
|
10
|
+
: Math.max(dp[i - 1][j], dp[i][j - 1]);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
return dp;
|
|
14
|
+
}
|
|
15
|
+
function diffLines(oldLines, newLines) {
|
|
16
|
+
const dp = computeLcs(oldLines, newLines);
|
|
17
|
+
const result = [];
|
|
18
|
+
let i = oldLines.length;
|
|
19
|
+
let j = newLines.length;
|
|
20
|
+
while (i > 0 || j > 0) {
|
|
21
|
+
if (i > 0 && j > 0 && oldLines[i - 1] === newLines[j - 1]) {
|
|
22
|
+
result.unshift({ type: " ", line: oldLines[i - 1] });
|
|
23
|
+
i--;
|
|
24
|
+
j--;
|
|
25
|
+
}
|
|
26
|
+
else if (j > 0 && (i === 0 || dp[i][j - 1] >= dp[i - 1][j])) {
|
|
27
|
+
result.unshift({ type: "+", line: newLines[j - 1] });
|
|
28
|
+
j--;
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
result.unshift({ type: "-", line: oldLines[i - 1] });
|
|
32
|
+
i--;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return result;
|
|
36
|
+
}
|
|
37
|
+
/** Honest hunk separator for diffs built from file fragments. */
|
|
38
|
+
export const FRAGMENT_HUNK_HEADER = "@@ … @@";
|
|
39
|
+
export function makeUnifiedDiff(oldText, newText, filePath, ctx = 3, options) {
|
|
40
|
+
// Empty text means zero lines, not one blank line — otherwise creating an
|
|
41
|
+
// empty file or deleting all content reports a phantom blank addition.
|
|
42
|
+
const oldArr = oldText ? oldText.split("\n") : [];
|
|
43
|
+
const newArr = newText ? newText.split("\n") : [];
|
|
44
|
+
const ops = diffLines(oldArr, newArr);
|
|
45
|
+
const output = [];
|
|
46
|
+
output.push(`--- a/${filePath}`);
|
|
47
|
+
output.push(`+++ b/${filePath}`);
|
|
48
|
+
let i = 0;
|
|
49
|
+
while (i < ops.length) {
|
|
50
|
+
if (ops[i].type === " ") {
|
|
51
|
+
i++;
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
const hunkStart = Math.max(0, i - ctx);
|
|
55
|
+
let end = i;
|
|
56
|
+
while (end < ops.length) {
|
|
57
|
+
if (ops[end].type !== " ") {
|
|
58
|
+
end++;
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
let next = end;
|
|
62
|
+
while (next < ops.length && ops[next].type === " ")
|
|
63
|
+
next++;
|
|
64
|
+
if (next < ops.length && next - end <= ctx * 2) {
|
|
65
|
+
end = next + 1;
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
break;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
const hunkEnd = Math.min(ops.length, end + ctx);
|
|
72
|
+
let oldCount = 0;
|
|
73
|
+
let newCount = 0;
|
|
74
|
+
for (let k = hunkStart; k < hunkEnd; k++) {
|
|
75
|
+
if (ops[k].type !== "+")
|
|
76
|
+
oldCount++;
|
|
77
|
+
if (ops[k].type !== "-")
|
|
78
|
+
newCount++;
|
|
79
|
+
}
|
|
80
|
+
let oldStart = 1;
|
|
81
|
+
let newStart = 1;
|
|
82
|
+
for (let k = 0; k < hunkStart; k++) {
|
|
83
|
+
if (ops[k].type !== "+")
|
|
84
|
+
oldStart++;
|
|
85
|
+
if (ops[k].type !== "-")
|
|
86
|
+
newStart++;
|
|
87
|
+
}
|
|
88
|
+
output.push(options?.fragment
|
|
89
|
+
? FRAGMENT_HUNK_HEADER
|
|
90
|
+
: `@@ -${oldStart},${oldCount} +${newStart},${newCount} @@`);
|
|
91
|
+
for (let k = hunkStart; k < hunkEnd; k++) {
|
|
92
|
+
const prefix = ops[k].type === " " ? " " : ops[k].type;
|
|
93
|
+
output.push(`${prefix}${ops[k].line}`);
|
|
94
|
+
}
|
|
95
|
+
i = hunkEnd;
|
|
96
|
+
}
|
|
97
|
+
return output.join("\n");
|
|
98
|
+
}
|
|
99
|
+
export function hunkHeader(lines) {
|
|
100
|
+
let oldCount = 0;
|
|
101
|
+
let newCount = 0;
|
|
102
|
+
for (const l of lines) {
|
|
103
|
+
if (!l.startsWith("+"))
|
|
104
|
+
oldCount++;
|
|
105
|
+
if (!l.startsWith("-"))
|
|
106
|
+
newCount++;
|
|
107
|
+
}
|
|
108
|
+
return `@@ -1,${oldCount} +1,${newCount} @@`;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Count added/removed lines in a unified diff, ignoring the `---`/`+++`
|
|
112
|
+
* file headers and `@@` hunk headers.
|
|
113
|
+
*/
|
|
114
|
+
export function countDiffLines(diff) {
|
|
115
|
+
let additions = 0;
|
|
116
|
+
let deletions = 0;
|
|
117
|
+
for (const line of diff.split("\n")) {
|
|
118
|
+
if (line.startsWith("+++") || line.startsWith("---"))
|
|
119
|
+
continue;
|
|
120
|
+
if (line.startsWith("+"))
|
|
121
|
+
additions++;
|
|
122
|
+
else if (line.startsWith("-"))
|
|
123
|
+
deletions++;
|
|
124
|
+
}
|
|
125
|
+
return { additions, deletions };
|
|
126
|
+
}
|
|
127
|
+
//# sourceMappingURL=diff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EAAE,SAAS,EAAE,CAAC;AACjC,CAAC"}
|
|
@@ -0,0 +1,145 @@
|
|
|
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 { type ToolOutputMedia } from "./parsers.js";
|
|
15
|
+
import { type ToolAggregate } from "./team.js";
|
|
16
|
+
export { countDiffLines, FRAGMENT_HUNK_HEADER, type MakeUnifiedDiffOptions, makeUnifiedDiff, } from "./diff.js";
|
|
17
|
+
export { type ApplyPatchFile, type ApplyPatchInfo, type AskQuestionInfo, buildReadFilesKeys, type EditorInfo, extractOutputMedia, extractOutputText, parseApplyPatchInput, parseAskQuestionInput, parseEditorInput, parseEditorResultDiffCounts, parseReadFilesInput, parseRunCommandsInput, parseSearchInput, parseSpawnAgentInput, parseWebFetchInput, type ReadFilesInfo, type RunCommandsInfo, type SearchInfo, type SpawnAgentInfo, type ToolOutputMedia, type WebFetchInfo, } from "./parsers.js";
|
|
18
|
+
export { detectLanguage, displayFileName, shortenPath } from "./paths.js";
|
|
19
|
+
export { type ToolAggregate, teamSummary } from "./team.js";
|
|
20
|
+
export type ToolSummaryPayload = {
|
|
21
|
+
toolName: string;
|
|
22
|
+
/** Structured input, or a JSON string of it (both are accepted). */
|
|
23
|
+
input?: unknown;
|
|
24
|
+
/** Raw tool result: string, content-block array, or record. */
|
|
25
|
+
result?: unknown;
|
|
26
|
+
isError?: boolean;
|
|
27
|
+
inProgress?: boolean;
|
|
28
|
+
};
|
|
29
|
+
export type ToolKind = "read" | "edit" | "command" | "search" | "web" | "spawn" | "team" | "skill" | "mcp" | "question" | "other";
|
|
30
|
+
export type ToolSummaryItem = {
|
|
31
|
+
type: "file";
|
|
32
|
+
path: string;
|
|
33
|
+
displayPath: string;
|
|
34
|
+
startLine?: number;
|
|
35
|
+
endLine?: number;
|
|
36
|
+
language?: string;
|
|
37
|
+
additions?: number;
|
|
38
|
+
deletions?: number;
|
|
39
|
+
/** Unified diff text for this file, when reconstructable. */
|
|
40
|
+
diff?: string;
|
|
41
|
+
/**
|
|
42
|
+
* Raw before/after texts for rich diff renderers (e.g.
|
|
43
|
+
* @pierre/diffs). `oldText` is absent for created files.
|
|
44
|
+
*/
|
|
45
|
+
oldText?: string;
|
|
46
|
+
newText?: string;
|
|
47
|
+
/**
|
|
48
|
+
* True when oldText/newText are fragments of the file rather than
|
|
49
|
+
* complete contents — renderers should hide absolute line numbers.
|
|
50
|
+
*/
|
|
51
|
+
fragment?: boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Per-hunk before/after texts when the change has more than one
|
|
54
|
+
* hunk (apply_patch). Render one diff per hunk — re-diffing
|
|
55
|
+
* concatenated hunks pairs deletions with unrelated additions.
|
|
56
|
+
* When present, prefer it over oldText/newText.
|
|
57
|
+
*/
|
|
58
|
+
hunks?: Array<{
|
|
59
|
+
oldText: string;
|
|
60
|
+
newText: string;
|
|
61
|
+
}>;
|
|
62
|
+
} | {
|
|
63
|
+
type: "command";
|
|
64
|
+
command: string;
|
|
65
|
+
} | {
|
|
66
|
+
type: "query";
|
|
67
|
+
query: string;
|
|
68
|
+
} | {
|
|
69
|
+
type: "url";
|
|
70
|
+
url: string;
|
|
71
|
+
} | {
|
|
72
|
+
type: "text";
|
|
73
|
+
text: string;
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* One styled segment of a row label. Segments with `code: true` carry code
|
|
77
|
+
* (file names, commands, queries, URLs) and should render in a monospace
|
|
78
|
+
* face; plain segments are prose.
|
|
79
|
+
*/
|
|
80
|
+
export type ToolLabelPart = {
|
|
81
|
+
text: string;
|
|
82
|
+
code?: boolean;
|
|
83
|
+
};
|
|
84
|
+
export type ToolSummary = {
|
|
85
|
+
/** Normalized tool name (aliases applied). */
|
|
86
|
+
toolName: string;
|
|
87
|
+
kind: ToolKind;
|
|
88
|
+
/** Row label, e.g. `Read app.tsx (10–80)` or `$ bun test`. */
|
|
89
|
+
label: string;
|
|
90
|
+
/** The label broken into styled segments; joins to `label`. */
|
|
91
|
+
labelParts: ToolLabelPart[];
|
|
92
|
+
/** Present when this call can merge into grouped-row counts. */
|
|
93
|
+
aggregate?: ToolAggregate;
|
|
94
|
+
/** Structured per-item detail for custom rendering. */
|
|
95
|
+
items: ToolSummaryItem[];
|
|
96
|
+
/** Preformatted one-per-line details for the expanded panel. */
|
|
97
|
+
details: string[];
|
|
98
|
+
/** Net line changes, for the trigger's +/- badge. */
|
|
99
|
+
diff?: {
|
|
100
|
+
additions: number;
|
|
101
|
+
deletions: number;
|
|
102
|
+
};
|
|
103
|
+
/** Human-readable text extracted from the result, when useful. */
|
|
104
|
+
outputText?: string;
|
|
105
|
+
/** Validated inline media extracted from the result. */
|
|
106
|
+
outputMedia: ToolOutputMedia[];
|
|
107
|
+
/** Error text when the call failed. */
|
|
108
|
+
errorText?: string;
|
|
109
|
+
};
|
|
110
|
+
export type ToolSummaryOptions = {
|
|
111
|
+
/** How file paths render in labels/details. Default: "shortened". */
|
|
112
|
+
pathStyle?: "shortened" | "basename" | "full";
|
|
113
|
+
/** Cap on extracted output/error text. Default: 64 KiB. */
|
|
114
|
+
maxOutputChars?: number;
|
|
115
|
+
/**
|
|
116
|
+
* Optional cap on inline label text (commands, tasks, questions).
|
|
117
|
+
* Unlimited by default: labels carry the full text (whitespace collapsed
|
|
118
|
+
* to one line) and the consumer's layout ellipsizes at the container
|
|
119
|
+
* edge. Set a number only for width-constrained surfaces like TUIs.
|
|
120
|
+
*/
|
|
121
|
+
maxInlineChars?: number;
|
|
122
|
+
};
|
|
123
|
+
export declare const TOOL_NAME_ALIASES: Record<string, string>;
|
|
124
|
+
export declare function normalizeToolName(toolName: string): string;
|
|
125
|
+
export declare function classifyTool(toolName: string): ToolKind;
|
|
126
|
+
/**
|
|
127
|
+
* Build the presentation summary for one tool call.
|
|
128
|
+
*
|
|
129
|
+
* Single-item calls carry their specifics inline in the label
|
|
130
|
+
* (`Read app.tsx (10–80)`, `Ran bun test`, `Edited chat-view.tsx`); calls
|
|
131
|
+
* over multiple items aggregate (`Read 3 files`) with per-item lines in
|
|
132
|
+
* `details`. Never throws on malformed input.
|
|
133
|
+
*/
|
|
134
|
+
export declare function buildToolSummary(payload: ToolSummaryPayload, options?: ToolSummaryOptions): ToolSummary;
|
|
135
|
+
/**
|
|
136
|
+
* Merge the labels of consecutive tool calls into one grouped-row label.
|
|
137
|
+
* Adjacent same-kind aggregates merge their counts ("Read 3 files"); other
|
|
138
|
+
* labels pass through, joined with " · ".
|
|
139
|
+
*/
|
|
140
|
+
export declare function buildGroupedToolLabel(summaries: Array<{
|
|
141
|
+
label: string;
|
|
142
|
+
aggregate?: ToolAggregate;
|
|
143
|
+
inProgress?: boolean;
|
|
144
|
+
}>): string;
|
|
145
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../components/agent-chat/tool-summary/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAIH,OAAO,EAcN,KAAK,eAAe,EACpB,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAa,KAAK,aAAa,EAAe,MAAM,WAAW,CAAC;AAEvE,OAAO,EACN,cAAc,EACd,oBAAoB,EACpB,KAAK,sBAAsB,EAC3B,eAAe,GACf,MAAM,WAAW,CAAC;AACnB,OAAO,EACN,KAAK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