@arhen/pi-core-subagent 1.0.5 → 1.0.6
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/package.json +1 -1
- package/src/index.ts +27 -22
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arhen/pi-core-subagent",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.6",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "pi extension: fast in-process subagents with single/parallel/chain, background runs, intercom and agent-to-agent mailbox. Leader defines agents inline.",
|
|
6
6
|
"license": "MIT",
|
package/src/index.ts
CHANGED
|
@@ -253,7 +253,7 @@ function compactLines(run: RunSnapshot): string[] {
|
|
|
253
253
|
*/
|
|
254
254
|
class SubagentsWidget implements Component {
|
|
255
255
|
constructor(
|
|
256
|
-
private readonly
|
|
256
|
+
private readonly getRuns: () => RunSnapshot[],
|
|
257
257
|
private readonly theme: Theme,
|
|
258
258
|
) {}
|
|
259
259
|
|
|
@@ -262,28 +262,33 @@ class SubagentsWidget implements Component {
|
|
|
262
262
|
}
|
|
263
263
|
|
|
264
264
|
render(width: number): string[] {
|
|
265
|
-
const
|
|
266
|
-
if (
|
|
267
|
-
const
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
const
|
|
276
|
-
const
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
265
|
+
const runs = this.getRuns();
|
|
266
|
+
if (runs.length === 0) return [];
|
|
267
|
+
const lines: string[] = [];
|
|
268
|
+
runs.forEach((run, ri) => {
|
|
269
|
+
if (run.tasks.length === 0) return;
|
|
270
|
+
if (ri > 0) lines.push("");
|
|
271
|
+
const done = run.tasks.filter((t) => TERMINAL.includes(t.status)).length;
|
|
272
|
+
const active = !TERMINAL.includes(run.status);
|
|
273
|
+
const head = active ? "accent" : "dim";
|
|
274
|
+
lines.push(truncateToWidth(`${this.theme.fg(head, active ? "●" : "○")} ${this.theme.fg(head, `Subagents (${done}/${run.tasks.length})`)}`, width, "…"));
|
|
275
|
+
const allDone = TERMINAL.includes(run.status);
|
|
276
|
+
const visible = run.tasks.slice(0, MAX_TASKS);
|
|
277
|
+
visible.forEach((task, i) => {
|
|
278
|
+
const last = i === visible.length - 1 && run.tasks.length <= MAX_TASKS;
|
|
279
|
+
const conn = this.theme.fg("dim", last ? "└─" : "├─");
|
|
280
|
+
const activity =
|
|
281
|
+
!TERMINAL.includes(task.status) && task.lastActivity
|
|
282
|
+
? `${this.theme.fg("dim", `→ ${task.lastActivity}`)} · `
|
|
283
|
+
: "";
|
|
284
|
+
// Finished run: dim everything except the agent name.
|
|
285
|
+
const line = allDone
|
|
286
|
+
? `${this.theme.fg("dim", `${statusIcon(task.status)} `)}${task.agent} ${this.theme.fg("dim", `· ${taskStatsWithUsage(task)} · ${taskTimer(task)}`)}`
|
|
287
|
+
: `${statusIcon(task.status)} ${task.agent} · ${activity}${taskStatsWithUsage(task)} · ${taskTimer(task)}`;
|
|
288
|
+
lines.push(truncateToWidth(`${conn} ${line}`, width, "…"));
|
|
289
|
+
});
|
|
290
|
+
if (run.tasks.length > MAX_TASKS) lines.push(`${this.theme.fg("dim", "└─")} ${this.theme.fg("dim", `+${run.tasks.length - MAX_TASKS} more`)}`);
|
|
285
291
|
});
|
|
286
|
-
if (run.tasks.length > MAX_TASKS) lines.push(`${this.theme.fg("dim", "└─")} ${this.theme.fg("dim", `+${run.tasks.length - MAX_TASKS} more`)}`);
|
|
287
292
|
return lines;
|
|
288
293
|
}
|
|
289
294
|
}
|