@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.
Files changed (222) hide show
  1. package/ADOPTION.md +833 -0
  2. package/LICENSE +201 -0
  3. package/RADIX-COLORS-LICENSE +21 -0
  4. package/README.md +427 -2
  5. package/components/agent-approval-card.css +70 -0
  6. package/components/agent-approval-card.tsx +109 -0
  7. package/components/agent-ask-question.css +103 -0
  8. package/components/agent-ask-question.tsx +276 -0
  9. package/components/agent-aurora.css +228 -0
  10. package/components/agent-aurora.tsx +96 -0
  11. package/components/agent-changes.css +13 -0
  12. package/components/agent-changes.tsx +167 -0
  13. package/components/agent-chat/agent-chat.css +556 -0
  14. package/components/agent-chat/index.tsx +1037 -0
  15. package/components/agent-chat/tool-diff.tsx +165 -0
  16. package/components/agent-chat/tool-summary/agents.ts +114 -0
  17. package/components/agent-chat/tool-summary/diff.ts +152 -0
  18. package/components/agent-chat/tool-summary/index.ts +928 -0
  19. package/components/agent-chat/tool-summary/parsers.ts +611 -0
  20. package/components/agent-chat/tool-summary/paths.ts +84 -0
  21. package/components/agent-chat/tool-summary/team.ts +401 -0
  22. package/components/agent-command-output.tsx +63 -0
  23. package/components/agent-composer.tsx +263 -0
  24. package/components/agent-context-usage.tsx +181 -0
  25. package/components/agent-conversation-layout.tsx +139 -0
  26. package/components/agent-hero-heading.css +53 -0
  27. package/components/agent-hero-heading.tsx +45 -0
  28. package/components/agent-image-lightbox.tsx +48 -0
  29. package/components/agent-prompt-queue.css +20 -0
  30. package/components/agent-prompt-queue.tsx +350 -0
  31. package/components/agent-pull-request-bar.css +13 -0
  32. package/components/agent-pull-request-bar.tsx +346 -0
  33. package/components/agent-quick-actions.css +19 -0
  34. package/components/agent-quick-actions.tsx +70 -0
  35. package/components/agent-session-row.tsx +183 -0
  36. package/components/agent-welcome-hero-pointer.ts +199 -0
  37. package/components/agent-welcome-hero.css +205 -0
  38. package/components/agent-welcome-hero.tsx +68 -0
  39. package/components/attachment-drop-zone.tsx +154 -0
  40. package/components/badge.tsx +21 -0
  41. package/components/button.tsx +324 -0
  42. package/components/generated-media.tsx +173 -0
  43. package/components/github-icon.tsx +19 -0
  44. package/components/index.ts +133 -0
  45. package/components/markdown.css +490 -0
  46. package/components/markdown.ts +365 -0
  47. package/components/mermaid-block.tsx +722 -0
  48. package/components/mermaid-diagram.ts +1260 -0
  49. package/components/mermaid-dom.ts +301 -0
  50. package/components/message-scroller.css +118 -0
  51. package/components/message-scroller.tsx +114 -0
  52. package/components/search-combobox.css +67 -0
  53. package/components/search-combobox.tsx +433 -0
  54. package/components/session-status.css +19 -0
  55. package/components/session-status.tsx +39 -0
  56. package/components/switch.css +221 -0
  57. package/components/switch.tsx +48 -0
  58. package/components.css +16 -0
  59. package/dist/components/agent-approval-card.d.ts +14 -0
  60. package/dist/components/agent-approval-card.d.ts.map +1 -0
  61. package/dist/components/agent-approval-card.js +12 -0
  62. package/dist/components/agent-approval-card.js.map +1 -0
  63. package/dist/components/agent-ask-question.d.ts +18 -0
  64. package/dist/components/agent-ask-question.d.ts.map +1 -0
  65. package/dist/components/agent-ask-question.js +101 -0
  66. package/dist/components/agent-ask-question.js.map +1 -0
  67. package/dist/components/agent-aurora.d.ts +3 -0
  68. package/dist/components/agent-aurora.d.ts.map +1 -0
  69. package/dist/components/agent-aurora.js +60 -0
  70. package/dist/components/agent-aurora.js.map +1 -0
  71. package/dist/components/agent-changes.d.ts +26 -0
  72. package/dist/components/agent-changes.d.ts.map +1 -0
  73. package/dist/components/agent-changes.js +19 -0
  74. package/dist/components/agent-changes.js.map +1 -0
  75. package/dist/components/agent-chat/disclosure.d.ts +25 -0
  76. package/dist/components/agent-chat/disclosure.d.ts.map +1 -0
  77. package/dist/components/agent-chat/disclosure.js +39 -0
  78. package/dist/components/agent-chat/disclosure.js.map +1 -0
  79. package/dist/components/agent-chat/index.d.ts +140 -0
  80. package/dist/components/agent-chat/index.d.ts.map +1 -0
  81. package/dist/components/agent-chat/index.js +379 -0
  82. package/dist/components/agent-chat/index.js.map +1 -0
  83. package/dist/components/agent-chat/tool-diff.d.ts +32 -0
  84. package/dist/components/agent-chat/tool-diff.d.ts.map +1 -0
  85. package/dist/components/agent-chat/tool-diff.js +97 -0
  86. package/dist/components/agent-chat/tool-diff.js.map +1 -0
  87. package/dist/components/agent-chat/tool-summary/agents.d.ts +10 -0
  88. package/dist/components/agent-chat/tool-summary/agents.d.ts.map +1 -0
  89. package/dist/components/agent-chat/tool-summary/agents.js +100 -0
  90. package/dist/components/agent-chat/tool-summary/agents.js.map +1 -0
  91. package/dist/components/agent-chat/tool-summary/diff.d.ts +22 -0
  92. package/dist/components/agent-chat/tool-summary/diff.d.ts.map +1 -0
  93. package/dist/components/agent-chat/tool-summary/diff.js +127 -0
  94. package/dist/components/agent-chat/tool-summary/diff.js.map +1 -0
  95. package/dist/components/agent-chat/tool-summary/index.d.ts +145 -0
  96. package/dist/components/agent-chat/tool-summary/index.d.ts.map +1 -0
  97. package/dist/components/agent-chat/tool-summary/index.js +663 -0
  98. package/dist/components/agent-chat/tool-summary/index.js.map +1 -0
  99. package/dist/components/agent-chat/tool-summary/parsers.d.ts +114 -0
  100. package/dist/components/agent-chat/tool-summary/parsers.d.ts.map +1 -0
  101. package/dist/components/agent-chat/tool-summary/parsers.js +502 -0
  102. package/dist/components/agent-chat/tool-summary/parsers.js.map +1 -0
  103. package/dist/components/agent-chat/tool-summary/paths.d.ts +10 -0
  104. package/dist/components/agent-chat/tool-summary/paths.d.ts.map +1 -0
  105. package/dist/components/agent-chat/tool-summary/paths.js +88 -0
  106. package/dist/components/agent-chat/tool-summary/paths.js.map +1 -0
  107. package/dist/components/agent-chat/tool-summary/team.d.ts +16 -0
  108. package/dist/components/agent-chat/tool-summary/team.d.ts.map +1 -0
  109. package/dist/components/agent-chat/tool-summary/team.js +283 -0
  110. package/dist/components/agent-chat/tool-summary/team.js.map +1 -0
  111. package/dist/components/agent-command-output.d.ts +14 -0
  112. package/dist/components/agent-command-output.d.ts.map +1 -0
  113. package/dist/components/agent-command-output.js +22 -0
  114. package/dist/components/agent-command-output.js.map +1 -0
  115. package/dist/components/agent-composer.d.ts +34 -0
  116. package/dist/components/agent-composer.d.ts.map +1 -0
  117. package/dist/components/agent-composer.js +65 -0
  118. package/dist/components/agent-composer.js.map +1 -0
  119. package/dist/components/agent-context-usage.d.ts +28 -0
  120. package/dist/components/agent-context-usage.d.ts.map +1 -0
  121. package/dist/components/agent-context-usage.js +51 -0
  122. package/dist/components/agent-context-usage.js.map +1 -0
  123. package/dist/components/agent-conversation-layout.d.ts +30 -0
  124. package/dist/components/agent-conversation-layout.d.ts.map +1 -0
  125. package/dist/components/agent-conversation-layout.js +24 -0
  126. package/dist/components/agent-conversation-layout.js.map +1 -0
  127. package/dist/components/agent-hero-heading.d.ts +2 -0
  128. package/dist/components/agent-hero-heading.d.ts.map +1 -0
  129. package/dist/components/agent-hero-heading.js +20 -0
  130. package/dist/components/agent-hero-heading.js.map +1 -0
  131. package/dist/components/agent-image-lightbox.d.ts +11 -0
  132. package/dist/components/agent-image-lightbox.d.ts.map +1 -0
  133. package/dist/components/agent-image-lightbox.js +8 -0
  134. package/dist/components/agent-image-lightbox.js.map +1 -0
  135. package/dist/components/agent-prompt-queue.d.ts +14 -0
  136. package/dist/components/agent-prompt-queue.d.ts.map +1 -0
  137. package/dist/components/agent-prompt-queue.js +114 -0
  138. package/dist/components/agent-prompt-queue.js.map +1 -0
  139. package/dist/components/agent-pull-request-bar.d.ts +72 -0
  140. package/dist/components/agent-pull-request-bar.d.ts.map +1 -0
  141. package/dist/components/agent-pull-request-bar.js +90 -0
  142. package/dist/components/agent-pull-request-bar.js.map +1 -0
  143. package/dist/components/agent-quick-actions.d.ts +14 -0
  144. package/dist/components/agent-quick-actions.d.ts.map +1 -0
  145. package/dist/components/agent-quick-actions.js +12 -0
  146. package/dist/components/agent-quick-actions.js.map +1 -0
  147. package/dist/components/agent-session-row.d.ts +45 -0
  148. package/dist/components/agent-session-row.d.ts.map +1 -0
  149. package/dist/components/agent-session-row.js +34 -0
  150. package/dist/components/agent-session-row.js.map +1 -0
  151. package/dist/components/agent-welcome-hero-pointer.d.ts +3 -0
  152. package/dist/components/agent-welcome-hero-pointer.d.ts.map +1 -0
  153. package/dist/components/agent-welcome-hero-pointer.js +169 -0
  154. package/dist/components/agent-welcome-hero-pointer.js.map +1 -0
  155. package/dist/components/agent-welcome-hero.d.ts +9 -0
  156. package/dist/components/agent-welcome-hero.d.ts.map +1 -0
  157. package/dist/components/agent-welcome-hero.js +14 -0
  158. package/dist/components/agent-welcome-hero.js.map +1 -0
  159. package/dist/components/attachment-drop-zone.d.ts +15 -0
  160. package/dist/components/attachment-drop-zone.d.ts.map +1 -0
  161. package/dist/components/attachment-drop-zone.js +64 -0
  162. package/dist/components/attachment-drop-zone.js.map +1 -0
  163. package/dist/components/badge.d.ts +5 -0
  164. package/dist/components/badge.d.ts.map +1 -0
  165. package/dist/components/badge.js +7 -0
  166. package/dist/components/badge.js.map +1 -0
  167. package/dist/components/button.d.ts +27 -0
  168. package/dist/components/button.d.ts.map +1 -0
  169. package/dist/components/button.js +209 -0
  170. package/dist/components/button.js.map +1 -0
  171. package/dist/components/generated-media.d.ts +12 -0
  172. package/dist/components/generated-media.d.ts.map +1 -0
  173. package/dist/components/generated-media.js +105 -0
  174. package/dist/components/generated-media.js.map +1 -0
  175. package/dist/components/github-icon.d.ts +3 -0
  176. package/dist/components/github-icon.d.ts.map +1 -0
  177. package/dist/components/github-icon.js +6 -0
  178. package/dist/components/github-icon.js.map +1 -0
  179. package/dist/components/index.d.ts +24 -0
  180. package/dist/components/index.d.ts.map +1 -0
  181. package/dist/components/index.js +25 -0
  182. package/dist/components/index.js.map +1 -0
  183. package/dist/components/markdown.d.ts +48 -0
  184. package/dist/components/markdown.d.ts.map +1 -0
  185. package/dist/components/markdown.js +264 -0
  186. package/dist/components/markdown.js.map +1 -0
  187. package/dist/components/mermaid-block.d.ts +14 -0
  188. package/dist/components/mermaid-block.d.ts.map +1 -0
  189. package/dist/components/mermaid-block.js +339 -0
  190. package/dist/components/mermaid-block.js.map +1 -0
  191. package/dist/components/mermaid-diagram.d.ts +264 -0
  192. package/dist/components/mermaid-diagram.d.ts.map +1 -0
  193. package/dist/components/mermaid-diagram.js +999 -0
  194. package/dist/components/mermaid-diagram.js.map +1 -0
  195. package/dist/components/mermaid-dom.d.ts +51 -0
  196. package/dist/components/mermaid-dom.d.ts.map +1 -0
  197. package/dist/components/mermaid-dom.js +246 -0
  198. package/dist/components/mermaid-dom.js.map +1 -0
  199. package/dist/components/message-scroller.d.ts +23 -0
  200. package/dist/components/message-scroller.d.ts.map +1 -0
  201. package/dist/components/message-scroller.js +31 -0
  202. package/dist/components/message-scroller.js.map +1 -0
  203. package/dist/components/search-combobox.d.ts +44 -0
  204. package/dist/components/search-combobox.d.ts.map +1 -0
  205. package/dist/components/search-combobox.js +191 -0
  206. package/dist/components/search-combobox.js.map +1 -0
  207. package/dist/components/session-status.d.ts +9 -0
  208. package/dist/components/session-status.d.ts.map +1 -0
  209. package/dist/components/session-status.js +11 -0
  210. package/dist/components/session-status.js.map +1 -0
  211. package/dist/components/switch.d.ts +7 -0
  212. package/dist/components/switch.d.ts.map +1 -0
  213. package/dist/components/switch.js +14 -0
  214. package/dist/components/switch.js.map +1 -0
  215. package/package.json +177 -5
  216. package/theme/base.css +83 -0
  217. package/theme/component-theme.css +126 -0
  218. package/theme/index.css +3 -0
  219. package/theme/palette.css +347 -0
  220. package/theme/scoped-tokens.css +503 -0
  221. package/theme/theme.css +90 -0
  222. package/theme/tokens.css +165 -0
@@ -0,0 +1,401 @@
1
+ import { isRecord, normalizeValue } from "./parsers.js";
2
+
3
+ export type ToolAggregate = {
4
+ key: string;
5
+ count: number;
6
+ noun: string;
7
+ pluralNoun?: string;
8
+ completedVerb: string;
9
+ progressVerb: string;
10
+ };
11
+
12
+ export type TeamSummaryResult = {
13
+ label: string;
14
+ details: string[];
15
+ aggregate?: ToolAggregate;
16
+ };
17
+
18
+ export function pluralize(
19
+ count: number,
20
+ singular: string,
21
+ plural = `${singular}s`,
22
+ ): string {
23
+ return `${count} ${count === 1 ? singular : plural}`;
24
+ }
25
+
26
+ function asRecord(value: unknown): Record<string, unknown> | null {
27
+ return isRecord(value) ? value : null;
28
+ }
29
+
30
+ function resultRecords(result: unknown): Record<string, unknown>[] {
31
+ const normalized = normalizeValue(result);
32
+ if (Array.isArray(normalized)) {
33
+ return normalized
34
+ .map(asRecord)
35
+ .filter((item): item is Record<string, unknown> => item !== null);
36
+ }
37
+ const record = asRecord(normalized);
38
+ return record ? [record] : [];
39
+ }
40
+
41
+ function recordString(
42
+ record: Record<string, unknown> | null | undefined,
43
+ key: string,
44
+ fallback = "",
45
+ ): string {
46
+ const value = record?.[key];
47
+ return typeof value === "string" && value.length > 0 ? value : fallback;
48
+ }
49
+
50
+ export function teamSummary(
51
+ toolName: string,
52
+ input: unknown,
53
+ result: unknown,
54
+ inProgress: boolean,
55
+ isError: boolean,
56
+ ): TeamSummaryResult | null {
57
+ if (!toolName.startsWith("team_")) return null;
58
+ if (isError) {
59
+ const failureLabels: Record<string, string> = {
60
+ team_attach_outcome_fragment: "Failed to attach outcome fragment",
61
+ team_await_runs: "Failed while waiting for teammates",
62
+ team_broadcast: "Failed to broadcast message to teammates",
63
+ team_cancel_run: "Failed to cancel teammate run",
64
+ team_cleanup: "Failed to clean up team",
65
+ team_create_outcome: "Failed to create team outcome",
66
+ team_finalize_outcome: "Failed to finalize team outcome",
67
+ team_list_outcomes: "Failed to list team outcomes",
68
+ team_list_runs: "Failed to list teammate runs",
69
+ team_mission_log: "Failed to update mission log",
70
+ team_read_mailbox: "Failed to read team mailbox",
71
+ team_review_outcome_fragment: "Failed to review outcome fragment",
72
+ team_run_task: "Failed to assign team task",
73
+ team_send_message: "Failed to send message",
74
+ team_shutdown_teammate: "Failed to stop teammate",
75
+ team_spawn_teammate: "Failed to spawn teammate",
76
+ team_status: "Failed to check team status",
77
+ team_task: "Failed to update team task",
78
+ };
79
+ return {
80
+ label: failureLabels[toolName] ?? `Failed ${toolName}`,
81
+ details: [],
82
+ };
83
+ }
84
+ const inputRecord = asRecord(normalizeValue(input));
85
+ const records = resultRecords(result);
86
+ const resultRecord = records[0];
87
+ const aggregate = (
88
+ key: string,
89
+ noun: string,
90
+ completedVerb: string,
91
+ progressVerb: string,
92
+ details: string[],
93
+ pluralNoun?: string,
94
+ count = 1,
95
+ ): TeamSummaryResult => ({
96
+ label: `${inProgress ? progressVerb : completedVerb} ${pluralize(
97
+ count,
98
+ noun,
99
+ pluralNoun,
100
+ )}`,
101
+ aggregate: {
102
+ key,
103
+ count,
104
+ noun,
105
+ pluralNoun,
106
+ completedVerb,
107
+ progressVerb,
108
+ },
109
+ details,
110
+ });
111
+ const agentId = recordString(
112
+ resultRecord,
113
+ "agentId",
114
+ recordString(inputRecord, "agentId"),
115
+ );
116
+
117
+ switch (toolName) {
118
+ case "team_spawn_teammate":
119
+ return aggregate(
120
+ "team-spawn",
121
+ "teammate",
122
+ "Spawned",
123
+ "Spawning",
124
+ agentId ? [agentId] : [],
125
+ );
126
+ case "team_run_task": {
127
+ const mode = recordString(
128
+ resultRecord,
129
+ "mode",
130
+ recordString(inputRecord, "runMode", "sync"),
131
+ );
132
+ const status = inProgress
133
+ ? "assigning"
134
+ : recordString(resultRecord, "status", "assigned");
135
+ return aggregate(
136
+ "team-run-task",
137
+ "team task",
138
+ "Assigned",
139
+ "Assigning",
140
+ [mode, agentId, status].filter(Boolean).join(" ")
141
+ ? [[mode, agentId, status].filter(Boolean).join(" ")]
142
+ : [],
143
+ "team tasks",
144
+ );
145
+ }
146
+ case "team_await_runs": {
147
+ const details = records.map((run) =>
148
+ [
149
+ recordString(run, "agentId", recordString(run, "id")),
150
+ recordString(run, "status"),
151
+ ]
152
+ .filter(Boolean)
153
+ .join(" "),
154
+ );
155
+ return {
156
+ label: inProgress ? "Waiting for teammates" : "Waited for teammates",
157
+ details,
158
+ };
159
+ }
160
+ case "team_shutdown_teammate":
161
+ return aggregate(
162
+ "team-shutdown",
163
+ "teammate",
164
+ "Stopped",
165
+ "Stopping",
166
+ agentId ? [agentId] : [],
167
+ );
168
+ case "team_status": {
169
+ const members = Array.isArray(resultRecord?.members)
170
+ ? resultRecord.members
171
+ .map(asRecord)
172
+ .filter((item): item is Record<string, unknown> => item !== null)
173
+ : [];
174
+ return {
175
+ label: inProgress ? "Checking team status" : "Checked team status",
176
+ details: members.map((member) =>
177
+ [recordString(member, "agentId"), recordString(member, "status")]
178
+ .filter(Boolean)
179
+ .join(" "),
180
+ ),
181
+ };
182
+ }
183
+ case "team_task": {
184
+ const action = recordString(
185
+ inputRecord,
186
+ "action",
187
+ recordString(resultRecord, "action", "update"),
188
+ );
189
+ const verbs: Record<string, [string, string]> = {
190
+ create: ["Created", "Creating"],
191
+ list: ["Listed", "Listing"],
192
+ claim: ["Claimed", "Claiming"],
193
+ complete: ["Completed", "Completing"],
194
+ block: ["Blocked", "Blocking"],
195
+ };
196
+ const [completedVerb, progressVerb] = verbs[action] ?? [
197
+ "Updated",
198
+ "Updating",
199
+ ];
200
+ const tasks = Array.isArray(resultRecord?.tasks)
201
+ ? resultRecord.tasks
202
+ .map(asRecord)
203
+ .filter((item): item is Record<string, unknown> => item !== null)
204
+ : records;
205
+ const details = tasks.map((task) =>
206
+ [
207
+ recordString(
208
+ task,
209
+ "taskId",
210
+ recordString(task, "id", recordString(inputRecord, "taskId")),
211
+ ),
212
+ recordString(task, "title", recordString(inputRecord, "title")),
213
+ recordString(task, "status"),
214
+ ]
215
+ .filter(Boolean)
216
+ .join(" "),
217
+ );
218
+ return aggregate(
219
+ `team-task-${action}`,
220
+ "team task",
221
+ completedVerb,
222
+ progressVerb,
223
+ details,
224
+ undefined,
225
+ action === "list" ? tasks.length : 1,
226
+ );
227
+ }
228
+ case "team_list_runs":
229
+ return {
230
+ label: inProgress
231
+ ? "Listing teammate runs"
232
+ : `Listed ${pluralize(records.length, "teammate run")}`,
233
+ details: records.map((run) =>
234
+ [recordString(run, "agentId"), recordString(run, "status")]
235
+ .filter(Boolean)
236
+ .join(" "),
237
+ ),
238
+ };
239
+ case "team_cancel_run":
240
+ return {
241
+ label: inProgress
242
+ ? "Cancelling teammate run"
243
+ : "Cancelled teammate run",
244
+ details: [
245
+ [
246
+ recordString(
247
+ resultRecord,
248
+ "runId",
249
+ recordString(inputRecord, "runId"),
250
+ ),
251
+ recordString(resultRecord, "status"),
252
+ ]
253
+ .filter(Boolean)
254
+ .join(" "),
255
+ ].filter(Boolean),
256
+ };
257
+ case "team_send_message": {
258
+ const recipient = recordString(
259
+ resultRecord,
260
+ "toAgentId",
261
+ recordString(inputRecord, "toAgentId"),
262
+ );
263
+ return aggregate(
264
+ "team-send-message",
265
+ "message",
266
+ "Sent",
267
+ "Sending",
268
+ [recipient, recordString(inputRecord, "subject")].filter(Boolean).length
269
+ ? [
270
+ [recipient, recordString(inputRecord, "subject")]
271
+ .filter(Boolean)
272
+ .join(" "),
273
+ ]
274
+ : [],
275
+ );
276
+ }
277
+ case "team_broadcast": {
278
+ const delivered = resultRecord?.delivered;
279
+ return {
280
+ label: inProgress
281
+ ? "Broadcasting message to teammates"
282
+ : `Broadcast message to ${pluralize(typeof delivered === "number" ? delivered : 0, "teammate")}`,
283
+ details: recordString(inputRecord, "subject")
284
+ ? [recordString(inputRecord, "subject")]
285
+ : [],
286
+ };
287
+ }
288
+ case "team_read_mailbox":
289
+ return {
290
+ label: inProgress
291
+ ? "Reading team mailbox"
292
+ : `Read ${pluralize(records.length, "team message")}`,
293
+ details: records.map((message) =>
294
+ [
295
+ recordString(message, "fromAgentId"),
296
+ recordString(message, "subject"),
297
+ ]
298
+ .filter(Boolean)
299
+ .join(" "),
300
+ ),
301
+ };
302
+ case "team_mission_log":
303
+ return {
304
+ label: inProgress ? "Updating mission log" : "Updated mission log",
305
+ details: [
306
+ [
307
+ recordString(inputRecord, "kind"),
308
+ recordString(inputRecord, "summary"),
309
+ ]
310
+ .filter(Boolean)
311
+ .join(" "),
312
+ ].filter(Boolean),
313
+ };
314
+ case "team_cleanup":
315
+ return {
316
+ label: inProgress ? "Cleaning up team" : "Cleaned up team",
317
+ details: recordString(resultRecord, "status")
318
+ ? [recordString(resultRecord, "status")]
319
+ : [],
320
+ };
321
+ case "team_create_outcome":
322
+ return {
323
+ label: inProgress ? "Creating team outcome" : "Created team outcome",
324
+ details: [
325
+ [
326
+ recordString(resultRecord, "outcomeId"),
327
+ recordString(inputRecord, "title"),
328
+ recordString(resultRecord, "status"),
329
+ ]
330
+ .filter(Boolean)
331
+ .join(" "),
332
+ ].filter(Boolean),
333
+ };
334
+ case "team_attach_outcome_fragment":
335
+ return {
336
+ label: inProgress
337
+ ? "Attaching outcome fragment"
338
+ : "Attached outcome fragment",
339
+ details: [
340
+ [
341
+ recordString(inputRecord, "section"),
342
+ recordString(resultRecord, "status"),
343
+ ]
344
+ .filter(Boolean)
345
+ .join(" "),
346
+ ].filter(Boolean),
347
+ };
348
+ case "team_review_outcome_fragment":
349
+ return {
350
+ label: inProgress
351
+ ? "Reviewing outcome fragment"
352
+ : "Reviewed outcome fragment",
353
+ details: [
354
+ [
355
+ recordString(inputRecord, "fragmentId"),
356
+ typeof inputRecord?.approved === "boolean"
357
+ ? inputRecord.approved
358
+ ? "approved"
359
+ : "rejected"
360
+ : recordString(resultRecord, "status"),
361
+ ]
362
+ .filter(Boolean)
363
+ .join(" "),
364
+ ].filter(Boolean),
365
+ };
366
+ case "team_finalize_outcome":
367
+ return {
368
+ label: inProgress
369
+ ? "Finalizing team outcome"
370
+ : "Finalized team outcome",
371
+ details: [
372
+ [
373
+ recordString(
374
+ resultRecord,
375
+ "outcomeId",
376
+ recordString(inputRecord, "outcomeId"),
377
+ ),
378
+ recordString(resultRecord, "status"),
379
+ ]
380
+ .filter(Boolean)
381
+ .join(" "),
382
+ ].filter(Boolean),
383
+ };
384
+ case "team_list_outcomes":
385
+ return {
386
+ label: inProgress
387
+ ? "Listing team outcomes"
388
+ : `Listed ${pluralize(records.length, "team outcome")}`,
389
+ details: records.map((outcome) =>
390
+ [
391
+ recordString(outcome, "title", recordString(outcome, "id")),
392
+ recordString(outcome, "status"),
393
+ ]
394
+ .filter(Boolean)
395
+ .join(" "),
396
+ ),
397
+ };
398
+ default:
399
+ return null;
400
+ }
401
+ }
@@ -0,0 +1,63 @@
1
+ "use client";
2
+
3
+ import { type ReactNode, useEffect, useRef } from "react";
4
+
5
+ export interface AgentCommandOutputProps {
6
+ output: string;
7
+ isRunning: boolean;
8
+ /** Hosts retain ANSI rendering or control-character normalization. */
9
+ children?: ReactNode;
10
+ tabIndex?: number;
11
+ classNames?: { viewport?: string; cursor?: string };
12
+ }
13
+
14
+ export function AgentCommandOutput({
15
+ output,
16
+ isRunning,
17
+ children = output,
18
+ tabIndex,
19
+ classNames,
20
+ }: AgentCommandOutputProps) {
21
+ const containerRef = useRef<HTMLDivElement>(null);
22
+ const shouldAutoScrollRef = useRef(true);
23
+ useEffect(() => {
24
+ const container = containerRef.current;
25
+ if (container && shouldAutoScrollRef.current) {
26
+ container.scrollTop = output ? container.scrollHeight : 0;
27
+ }
28
+ }, [output]);
29
+
30
+ return (
31
+ <div className="mt-2 space-y-1">
32
+ <div className="text-[11px] uppercase tracking-wide text-cline-ui-muted-foreground/80">
33
+ Output
34
+ </div>
35
+ <div
36
+ aria-label="Command output"
37
+ aria-live="off"
38
+ className={`max-h-64 overflow-auto rounded-md border border-cline-ui-border/70 bg-black/90 p-3 font-cline-ui-mono text-cline-ui-xs leading-relaxed text-zinc-100${classNames?.viewport ? ` ${classNames.viewport}` : ""}`}
39
+ onScroll={(event) => {
40
+ const container = event.currentTarget;
41
+ shouldAutoScrollRef.current =
42
+ container.scrollHeight -
43
+ container.scrollTop -
44
+ container.clientHeight <
45
+ 24;
46
+ }}
47
+ ref={containerRef}
48
+ role="log"
49
+ tabIndex={tabIndex}
50
+ >
51
+ <pre className="whitespace-pre-wrap break-words">
52
+ {children}
53
+ {isRunning ? (
54
+ <span
55
+ aria-hidden="true"
56
+ className={`ml-0.5 inline-block h-3 w-1.5 animate-pulse bg-zinc-100${classNames?.cursor ? ` ${classNames.cursor}` : ""}`}
57
+ />
58
+ ) : null}
59
+ </pre>
60
+ </div>
61
+ </div>
62
+ );
63
+ }