oira666_pi-subagent 0.6.1 → 0.6.3

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/README.md CHANGED
@@ -85,6 +85,14 @@ Workers receive durable human names. Call `message_subagent(name, message, max_s
85
85
  { "name": "John", "message": "Now update the tests." }
86
86
  ```
87
87
 
88
+ Send the same message to several workers with an array of names:
89
+
90
+ ```json
91
+ { "name": ["John", "Maria"], "message": "The shared API changed. Use the new signature." }
92
+ ```
93
+
94
+ Each recipient receives only the message text, not the recipient list. Duplicate names receive one copy. Running workers are steered and idle workers resume concurrently. Delivery failures are reported per recipient without undoing successful deliveries. An optional `max_subagents_allowed` applies separately to each recipient.
95
+
88
96
  A message steers a running worker or resumes an idle worker with its saved context. It does not wait for the worker to finish. `agent` selects a definition at launch; `name` identifies an existing worker. Messaging or resuming a named worker consumes no new worker slot. An optional budget increase can reserve additional descendant slots. See [sessions and budgets](docs/sessions.md) for cap overrides, forks, and crash recovery.
89
97
 
90
98
  A child calls `message_lead_agent(message)` to send nonblocking steering to its lead:
@@ -128,7 +136,7 @@ Collapsed results show each child's name, task, status, and most recent activity
128
136
 
129
137
  A live single line above the editor shows `Running N: Name elapsed · Name elapsed`, with `+N` for names that do not fit and a separate idle count. It uses live handles and snapshots, not session metadata or disk reads on timer ticks.
130
138
 
131
- `/subagent-expand <name>` opens a saved worker transcript. With no name, it opens a searchable picker. Running workers come first in depth order, with top-level workers before nested workers. Live idle parents waiting for children come next; completed or stopped history comes last. Name completion is fuzzy. Each task or resumed turn shows its actual provider/model and thinking level from the worker's session, not the parent's settings. Selected presets also appear as an intelligence label, kept separately for each run. Missing historical model/thinking metadata appears as `unknown`.
139
+ `/subagent-expand <name>` opens a saved worker transcript. Its top section shows the current descendant-slot budget: allowed, used/reserved, and remaining. Used slots include allowances reserved for children and their descendants, not just currently running processes. Missing legacy budgets show as unknown. With no name, it opens a searchable picker. Running workers come first in depth order, with top-level workers before nested workers. Live idle parents waiting for children come next; completed or stopped history comes last. Name completion is fuzzy. Each task or resumed turn shows its actual provider/model and thinking level from the worker's session, not the parent's settings. Selected presets also appear as an intelligence label, kept separately for each run. Missing historical model/thinking metadata appears as `unknown`.
132
140
 
133
141
  [Model presets](docs/configuration.md#caller-selected-intelligence) show labels such as `Nicolas (Junior/code-writer)` in regular tool results. One enabled preset applies automatically to new launches without exposing an `intelligence` argument. Two or more require an explicit `intelligence` choice on every launch item. Omitted or `null` choices reject the whole launch batch before any worker starts. Zero or disabled presets keep the existing launch defaults and show no intelligence label. Without an agent type, labels show `Nicolas (Junior)`; without either qualifier, they show just `Nicolas`. `message_subagent` does not accept `intelligence`; workers retain the original effective model, thinking, and label, even after configuration or parent settings change.
134
142
 
package/docs/sessions.md CHANGED
@@ -6,7 +6,7 @@ Workers run asynchronously. Budget reservations and lifetime descendant-cap sema
6
6
 
7
7
  `subagents` returns `started` immediately and runs workers in the background. Each worker's completion arrives as steering to its lead and wakes the lead if idle. The launch acknowledgement is not a final result.
8
8
 
9
- Workers keep durable names and saved sessions after completing a turn. `message_subagent(name, message, max_subagents_allowed?)` steers a running worker or resumes an idle worker with its saved context. It returns without waiting for completion. A running worker receives steering rather than a second concurrent turn on the same session.
9
+ Workers keep durable names and saved sessions after completing a turn. `message_subagent(name, message, max_subagents_allowed?)` steers a running worker or resumes an idle worker with its saved context. It returns without waiting for completion. A running worker receives steering rather than a second concurrent turn on the same session. Set `name` to an array to contact several workers with one message. The registered schema uses arrays, including for one recipient; older single-name string calls are normalized automatically. Recipients receive only the message text. Failures are reported individually, and an optional allowance override applies separately to each recipient.
10
10
 
11
11
  A child can call `message_lead_agent(message)` without blocking. The message becomes lead steering and wakes an idle lead. It does not finish the child's turn or wait for a reply. The lead replies through `message_subagent`.
12
12
 
@@ -1,3 +1,4 @@
1
+ import { readDetailBudget } from "../ui/detail-budget.js";
1
2
  import { statSync } from "node:fs";
2
3
  import { buildSubagentDetail, findNameRecord, sessionFilesIn, type SubagentDetail } from "../detail.js";
3
4
  import { readNamesRegistry, type NamesRegistry, type SubagentNameRecord } from "../names.js";
@@ -146,7 +147,12 @@ export function registerSubagentExpandCommand(state: ExtensionState): void {
146
147
  try {
147
148
  const sessionDir = resolveDetailSessionDir(state, selected);
148
149
  const files = sessionFilesIn(sessionDir);
149
- const signature = JSON.stringify([selected, sessionDir, files.map((file) => [file, fileSignature(file)])]);
150
+ const signature = JSON.stringify([
151
+ selected,
152
+ readDetailBudget(selected.budget),
153
+ sessionDir,
154
+ files.map((file) => [file, fileSignature(file)]),
155
+ ]);
150
156
  const key = selected.name.toLowerCase();
151
157
  const cached = detailCache.get(key);
152
158
  let detail = cached?.signature === signature ? cached.detail : undefined;
@@ -7,11 +7,13 @@ export function startedResult(
7
7
  name: string | undefined,
8
8
  budget: SubagentBudget | undefined,
9
9
  sessionDir: string,
10
+ intelligence?: string,
10
11
  ): SingleResult {
11
12
  return {
12
13
  agent: task.agent,
13
14
  task: task.task,
14
15
  name,
16
+ intelligence,
15
17
  budget,
16
18
  sessionDir,
17
19
  agentSource: "unknown",
@@ -233,7 +233,6 @@ export function registerSubagentsTool(state: ExtensionState) {
233
233
  if (resumePlanIndex >= 0) state.pendingResumePlans.splice(resumePlanIndex, 1);
234
234
  state.recoveryPlansByToolCallId?.delete(toolCallId);
235
235
 
236
- // Names are unique across the tree and reused during recovery.
237
236
  const names: Array<string | undefined> = tasks.map(
238
237
  (_task, index) => resumePlan?.details?.results[index]?.name,
239
238
  );
@@ -317,6 +316,7 @@ export function registerSubagentsTool(state: ExtensionState) {
317
316
  names[index],
318
317
  budgets[index],
319
318
  getSessionDirForTask(state, resumePlan?.previousToolCallId ?? toolCallId, index),
319
+ selectIntelligence(state.intelligencePresets, task.intelligence, state.settings)?.name,
320
320
  ),
321
321
  ),
322
322
  ),
@@ -0,0 +1,127 @@
1
+ import { Container } from "@earendil-works/pi-tui";
2
+ import type { ToolDefinition } from "@earendil-works/pi-coding-agent";
3
+ import { buildSubagentDetails, DEFAULT_DELEGATION_MODE } from "../types.js";
4
+ import { isRecord } from "../types/records.js";
5
+ import { renderMessageResult } from "../render.js";
6
+ import { MessageSubagentParams, SingleMessageSubagentParams, validatePreparedArguments } from "./schemas.js";
7
+ import type { ExtensionState } from "./state.js";
8
+
9
+ type SingleTool = ToolDefinition<typeof SingleMessageSubagentParams>;
10
+
11
+ /** Fan out locally. Recipient names never become part of a child's prompt. */
12
+ export function registerMessageBatchTool(state: ExtensionState, single: SingleTool): void {
13
+ state.pi.registerTool({
14
+ ...single,
15
+ parameters: MessageSubagentParams,
16
+ description: `${single.description}\nname accepts one name or an array of names to receive the same message concurrently. Each receives only the message, not the recipient list. Duplicate names are contacted once. Optional max_subagents_allowed applies separately to each recipient. Delivery failures are reported per recipient; other deliveries are not rolled back.`,
17
+ prepareArguments(args) {
18
+ if (!isRecord(args)) return validatePreparedArguments(MessageSubagentParams, args);
19
+ const normalized: Record<string, unknown> = {
20
+ ...args,
21
+ name: typeof args.name === "string" ? [args.name] : args.name,
22
+ };
23
+ if (normalized.max_subagents_allowed === null) delete normalized.max_subagents_allowed;
24
+ return validatePreparedArguments(MessageSubagentParams, normalized);
25
+ },
26
+ async execute(id, params, signal, onUpdate, ctx) {
27
+ if (!Array.isArray(params?.name))
28
+ return single.execute(id, { ...params, name: params?.name }, signal, onUpdate, ctx);
29
+ try {
30
+ const validated = validatePreparedArguments(MessageSubagentParams, params);
31
+ const names = [...new Set(validated.name)];
32
+ if (names.length === 1) return single.execute(id, { ...validated, name: names[0] }, signal, onUpdate, ctx);
33
+ const results = await Promise.all(
34
+ names.map(async (name, index) => {
35
+ const childId = `${id}/recipient-${index}`;
36
+ try {
37
+ return await single.execute(childId, { ...validated, name }, signal, undefined, ctx);
38
+ } finally {
39
+ state.forcedErrorToolCallIds.delete(childId);
40
+ }
41
+ }),
42
+ );
43
+ const recipients = results.map((result, index) => ({
44
+ ...(isRecord(result.details) && isRecord(result.details.recipient) ? result.details.recipient : {}),
45
+ name: names[index],
46
+ isError: Reflect.get(result, "isError") === true,
47
+ status: result.content
48
+ .filter((part) => part.type === "text")
49
+ .map((part) => part.text)
50
+ .join("\n"),
51
+ }));
52
+ const isError = recipients.some((recipient) => recipient.isError);
53
+ if (isError) state.forcedErrorToolCallIds.add(id);
54
+ return {
55
+ content: [
56
+ { type: "text", text: recipients.map((recipient) => `${recipient.name}: ${recipient.status}`).join("\n") },
57
+ ],
58
+ details: Object.assign(buildSubagentDetails("parallel", DEFAULT_DELEGATION_MODE, null, []), { recipients }),
59
+ ...(isError ? { isError: true } : {}),
60
+ };
61
+ } catch (error) {
62
+ state.forcedErrorToolCallIds.add(id);
63
+ return {
64
+ content: [{ type: "text", text: error instanceof Error ? error.message : String(error) }],
65
+ details: buildSubagentDetails("parallel", DEFAULT_DELEGATION_MODE, null, []),
66
+ isError: true,
67
+ };
68
+ }
69
+ },
70
+ renderCall(args, theme, context) {
71
+ if (!Array.isArray(args.name)) {
72
+ const singleArgs = { ...args, name: args.name };
73
+ return single.renderCall!(singleArgs, theme, { ...context, args: singleArgs });
74
+ }
75
+ const container = new Container();
76
+ const caches = (context.state.recipientStates ??= new Map());
77
+ for (const name of new Set(args.name)) {
78
+ if (!caches.has(name)) caches.set(name, {});
79
+ const singleArgs = { ...args, name };
80
+ container.addChild(
81
+ single.renderCall!(singleArgs, theme, { ...context, args: singleArgs, state: caches.get(name) }),
82
+ );
83
+ }
84
+ return container;
85
+ },
86
+ renderResult(result, options, theme, context) {
87
+ if (!Array.isArray(context.args.name) || (isRecord(result.details) && isRecord(result.details.recipient))) {
88
+ return single.renderResult!(result, options, theme, {
89
+ ...context,
90
+ args: { ...context.args, name: Array.isArray(context.args.name) ? context.args.name[0] : context.args.name },
91
+ });
92
+ }
93
+ const recipients =
94
+ isRecord(result.details) && Array.isArray(result.details.recipients) ? result.details.recipients : [];
95
+ if (!recipients.length)
96
+ return renderMessageResult(result, options.expanded, theme, {
97
+ ...context,
98
+ args: { message: context.args.message },
99
+ });
100
+ const container = new Container();
101
+ for (const recipient of recipients) {
102
+ if (!isRecord(recipient)) continue;
103
+ container.addChild(
104
+ renderMessageResult(
105
+ {
106
+ content: [
107
+ {
108
+ type: "text",
109
+ text: `${recipient.isError === true ? `${recipient.name}: ` : ""}${typeof recipient.status === "string" ? recipient.status : ""}`,
110
+ },
111
+ ],
112
+ details: { recipient },
113
+ },
114
+ options.expanded,
115
+ theme,
116
+ {
117
+ ...context,
118
+ args: { name: typeof recipient.name === "string" ? recipient.name : "", message: context.args.message },
119
+ isError: recipient.isError === true,
120
+ },
121
+ ),
122
+ );
123
+ }
124
+ return container;
125
+ },
126
+ });
127
+ }
@@ -0,0 +1,19 @@
1
+ import { readCurrentRegistry } from "./expand-command.js";
2
+ import type { ExtensionState } from "./state.js";
3
+
4
+ export interface MessageRecipient {
5
+ name: string;
6
+ agent?: string;
7
+ intelligence?: string;
8
+ }
9
+
10
+ /** Original launch identity, never inferred from the lead's model or current presets. */
11
+ export function resolveMessageRecipient(state: ExtensionState, name: string): MessageRecipient {
12
+ try {
13
+ const record = readCurrentRegistry(state)?.agents[name];
14
+ if (record) return { name: record.name, agent: record.agent, intelligence: record.intelligence };
15
+ } catch {
16
+ // A missing registry must not break historical rendering or live steering.
17
+ }
18
+ return { name };
19
+ }
@@ -14,6 +14,8 @@ import {
14
14
  updateNameRecord,
15
15
  } from "../names.js";
16
16
  import { originalModelSettings } from "../storage/session-settings.js";
17
+ import { formatSubagentLabel } from "../ui/agent-label.js";
18
+ import { resolveMessageRecipient, type MessageRecipient } from "./message-identity.js";
17
19
  import { recordToolCallStart, renderMessageResult } from "../render.js";
18
20
  import { buildSubagentDetails, DEFAULT_DELEGATION_MODE } from "../types.js";
19
21
  import { startBackground } from "./async-jobs.js";
@@ -23,18 +25,19 @@ import { executeParallel } from "./execution.js";
23
25
  import { resumableSubagentsDisabled } from "./policy.js";
24
26
  import { trackProgress } from "./progress.js";
25
27
  import { ensureBudget } from "./runtime.js";
26
- import { MessageSubagentParams, validatePreparedArguments } from "./schemas.js";
28
+ import { SingleMessageSubagentParams as MessageSubagentParams, validatePreparedArguments } from "./schemas.js";
29
+ import { registerMessageBatchTool } from "./message-batch.js";
27
30
  import type { ExtensionState } from "./state.js";
28
31
 
29
32
  export function registerMessageSubagentTool(state: ExtensionState) {
30
33
  if (resumableSubagentsDisabled(state.settings) && !state.resumeToolRegistered) return;
31
34
  state.resumeToolRegistered = true;
32
- state.pi.registerTool({
35
+ registerMessageBatchTool(state, {
33
36
  name: "message_subagent",
34
37
  label: "Message subagent",
35
38
  description:
36
39
  state.configuredToolPrompts.message_subagent ??
37
- "Send a message to one named subagent. Running subagents are steered; idle subagents resume with their saved context and original model settings. Returns without waiting for completion. Optional max_subagents_allowed replaces its lifetime descendant cap without resetting spending or refunding reserved slots. Omit to retain its allowance.",
40
+ "Send the same message to one or more named subagents. Running subagents are steered; idle subagents resume with their saved context and original model settings. Returns without waiting for completion. Optional max_subagents_allowed replaces its lifetime descendant cap without resetting spending or refunding reserved slots. Omit to retain its allowance.",
38
41
  parameters: MessageSubagentParams,
39
42
  prepareArguments: (args) => {
40
43
  if (args && typeof args === "object" && "max_subagents_allowed" in args && args.max_subagents_allowed === null) {
@@ -49,6 +52,7 @@ export function registerMessageSubagentTool(state: ExtensionState) {
49
52
  const namesFile = state.currentNamesFile;
50
53
  const ownerId = state.currentOwnerId;
51
54
  const localGuards = state.activeResumeNames;
55
+ let recipient: MessageRecipient | undefined;
52
56
  let guardedName: string | undefined;
53
57
  let marked = false;
54
58
  let backgroundOwnsCleanup = false;
@@ -66,10 +70,14 @@ export function registerMessageSubagentTool(state: ExtensionState) {
66
70
  };
67
71
  const result = (text: string) => ({
68
72
  content: [{ type: "text" as const, text }],
69
- details: buildSubagentDetails("parallel", DEFAULT_DELEGATION_MODE, null, []),
73
+ details: Object.assign(
74
+ buildSubagentDetails("parallel", DEFAULT_DELEGATION_MODE, null, []),
75
+ recipient ? { recipient } : {},
76
+ ),
70
77
  });
71
78
  try {
72
79
  const { name, message, max_subagents_allowed } = validatePreparedArguments(MessageSubagentParams, rawParams);
80
+ recipient = resolveMessageRecipient(state, name);
73
81
  checkCurrent();
74
82
  if (!state.canDelegate || resumableSubagentsDisabled(state.settings))
75
83
  throw new Error("Subagent messaging is disabled for this session.");
@@ -144,6 +152,11 @@ export function registerMessageSubagentTool(state: ExtensionState) {
144
152
  const resolution = await resolveResumeTarget(namesFile, name, ownerId);
145
153
  checkCurrent();
146
154
  if ("error" in resolution) throw new Error(resolution.error);
155
+ recipient = {
156
+ name: resolution.record.name,
157
+ agent: resolution.record.agent,
158
+ intelligence: resolution.record.intelligence,
159
+ };
147
160
  const definition = discovery.agents.find((agent) => agent.name === resolution.record.agent);
148
161
  if (definition && !isAgentEnabledAtLayer(definition, state.currentDepth + 1, state.maxDepth)) {
149
162
  throw new Error(
@@ -235,12 +248,16 @@ export function registerMessageSubagentTool(state: ExtensionState) {
235
248
  }
236
249
  },
237
250
 
238
- renderCall: (args, theme) =>
239
- new Text(
240
- `${theme.fg("toolTitle", theme.bold("message subagent "))}${theme.fg("accent", typeof args.name === "string" ? args.name : "")}`,
251
+ renderCall: (args, theme, context) => {
252
+ const name = typeof args.name === "string" ? args.name : "";
253
+ const cache = context?.state ?? {};
254
+ if (!cache.recipient || cache.recipient.name !== name) cache.recipient = resolveMessageRecipient(state, name);
255
+ return new Text(
256
+ `${theme.fg("toolTitle", theme.bold("message subagent "))}${theme.fg("accent", formatSubagentLabel(cache.recipient))}`,
241
257
  0,
242
258
  0,
243
- ),
259
+ );
260
+ },
244
261
  renderResult: (result, { expanded }, theme, context) => renderMessageResult(result, expanded, theme, context),
245
262
  });
246
263
  }
@@ -49,7 +49,7 @@ ${
49
49
 
50
50
  Launches return immediately with durable worker names. Each worker's completion arrives as a steering message, waking you if idle. Keep working rather than waiting on the launch tool.
51
51
 
52
- Use \`message_subagent\` with { "name": "John", "message": "Now also update the tests." } to steer a running worker or wake an idle worker with its saved context and original model settings.
52
+ Use \`message_subagent\` with { "name": "John", "message": "Now also update the tests." } to steer a running worker or wake an idle worker with its saved context and original model settings. Set "name" to an array, e.g. ["John", "Maria"], to send the same message to several workers concurrently. Each recipient sees only the message, never the recipient list.
53
53
 
54
54
  Optional \`max_subagents_allowed\` changes the lifetime descendant cap without resetting spending. Omit it to keep the current allowance. Increases reserve slots from the original launcher; decreases do not refund slots. Names survive restarts.
55
55
 
@@ -68,7 +68,7 @@ export const ResumeSubagentsParams = Type.Object(
68
68
  { additionalProperties: false },
69
69
  );
70
70
 
71
- export const MessageSubagentParams = Type.Object(
71
+ export const SingleMessageSubagentParams = Type.Object(
72
72
  {
73
73
  name: Type.String({ minLength: 1, pattern: "\\S", description: "Name returned by a previous subagents run." }),
74
74
  message: Type.String({
@@ -82,6 +82,18 @@ export const MessageSubagentParams = Type.Object(
82
82
  { additionalProperties: false },
83
83
  );
84
84
 
85
+ export const MessageSubagentParams = Type.Object(
86
+ {
87
+ ...SingleMessageSubagentParams.properties,
88
+ name: Type.Array(SingleMessageSubagentParams.properties.name, {
89
+ minItems: 1,
90
+ description:
91
+ "Names receiving the same message. Use a one-element array for one recipient. Legacy single-name strings are also accepted. Recipients see only the message, not the list.",
92
+ }),
93
+ },
94
+ { additionalProperties: false },
95
+ );
96
+
85
97
  export function createIntelligenceSchemas(
86
98
  presets: IntelligencePreset[] = [],
87
99
  settings?: SubagentSettings,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oira666_pi-subagent",
3
- "version": "0.6.1",
3
+ "version": "0.6.3",
4
4
  "description": "Subagent extension for Pi coding agent. Delegate tasks to specialized agents.",
5
5
  "type": "module",
6
6
  "main": "index.ts",
package/render.ts CHANGED
@@ -14,6 +14,7 @@ const fitLine = (text: string, width: number) =>
14
14
  truncateToWidth(text, width, "").replace(/\u001b\[0m/g, "\u001b[22;23;24;25;27;28;29;39m");
15
15
 
16
16
  import { MAX_LIVE_LOG_ENTRIES, isSubagentDetails, type SubagentDetails } from "./types.js";
17
+ import { isRecord } from "./types/records.js";
17
18
  import { formatSubagentLabel } from "./ui/agent-label.js";
18
19
  import {
19
20
  type ThemeFg,
@@ -168,7 +169,14 @@ export function renderMessageResult(
168
169
  ): Component {
169
170
  const message = context?.args?.message;
170
171
  if (context?.isError || typeof message !== "string") return renderResult(result, expanded, theme, context);
171
- const prefix = ` ${statusEmoji("success", theme)} ${theme.fg("accent", context?.args?.name ?? "")} `;
172
+ const recipient =
173
+ isRecord(result.details) && isRecord(result.details.recipient) ? result.details.recipient : undefined;
174
+ const label = formatSubagentLabel({
175
+ name: recipient?.name ?? context?.args?.name,
176
+ agent: recipient?.agent,
177
+ intelligence: recipient?.intelligence,
178
+ });
179
+ const prefix = ` ${statusEmoji("success", theme)} ${theme.fg("accent", label)} `;
172
180
  return {
173
181
  render: (width) =>
174
182
  expanded
package/runner/single.ts CHANGED
@@ -163,7 +163,7 @@ export async function runAgentSubprocess(opts: RunAgentOptions): Promise<SingleR
163
163
  opts.settings,
164
164
  );
165
165
  const prompt =
166
- result.budget && readBudget(result.budget).limit > 0
166
+ opts.rawPrompt !== true && result.budget && readBudget(result.budget).limit > 0
167
167
  ? `${taskPrompt}\n\n${budgetPrompt(result.budget)}`
168
168
  : taskPrompt;
169
169
  let wasAborted = false;
@@ -0,0 +1,24 @@
1
+ import { readBudget, type SubagentBudget } from "../budget.js";
2
+
3
+ export interface DetailBudget {
4
+ allowed: number;
5
+ used: number;
6
+ remaining: number;
7
+ }
8
+
9
+ /** Read only the selected agent's ledger, never walk its descendants. */
10
+ export function readDetailBudget(budget?: SubagentBudget): DetailBudget | undefined {
11
+ if (!budget) return undefined;
12
+ try {
13
+ const { limit, remaining } = readBudget(budget);
14
+ return { allowed: limit, used: limit - remaining, remaining };
15
+ } catch {
16
+ return undefined;
17
+ }
18
+ }
19
+
20
+ export function detailBudgetLine(budget?: DetailBudget): string {
21
+ return budget
22
+ ? `Subagent budget: ${budget.allowed} allowed • ${budget.used} used/reserved • ${budget.remaining} remaining`
23
+ : "Subagent budget: unknown";
24
+ }
@@ -1,3 +1,4 @@
1
+ import { detailBudgetLine } from "./detail-budget.js";
1
2
  import { truncateToWidth, visibleWidth, wrapTextWithAnsi } from "@earendil-works/pi-tui";
2
3
  import { RESUME_SUBAGENTS_TOOL_NAME } from "../types.js";
3
4
  import { displayIntelligence } from "../intelligence.js";
@@ -85,6 +86,7 @@ export function renderTurnOverviewLines(
85
86
  .filter(Boolean)
86
87
  .join(" • ");
87
88
  out.wrap(meta, "", "dim");
89
+ out.wrap(detailBudgetLine(detail.budget), "", "accent");
88
90
  out.wrap(
89
91
  `Model: ${block.model ?? "unknown"} • Thinking: ${block.thinkingLevel ?? "unknown"}${block.intelligence ? ` • Intelligence: ${displayIntelligence(block.intelligence)}` : ""}`,
90
92
  "",
@@ -254,6 +256,7 @@ export function renderActivityLines(detail: SubagentDetail, width: number, theme
254
256
  "",
255
257
  "dim",
256
258
  );
259
+ out.wrap(detailBudgetLine(detail.budget), "", "accent");
257
260
  out.wrap(`session total: ${usageLine(detail.usage)}`, "", "dim");
258
261
  for (const note of detail.notes) out.wrap(note, "", "warning");
259
262
  if (tools.length) out.wrap("Press T to inspect tools across all messages", "", "muted");
@@ -1,3 +1,5 @@
1
+ import type { DetailBudget } from "./detail-budget.js";
2
+
1
3
  export interface DetailChildRef {
2
4
  name?: string;
3
5
  agent: string;
@@ -43,6 +45,7 @@ export interface SubagentDetail {
43
45
  model?: string;
44
46
  thinkingLevel?: string;
45
47
  tools?: string[];
48
+ budget?: DetailBudget;
46
49
  createdAt?: number;
47
50
  sessionDir: string;
48
51
  sessionFile?: string;
@@ -1,3 +1,4 @@
1
+ import { readDetailBudget } from "./detail-budget.js";
1
2
  import { sessionFilesIn, readSessionEntries } from "./session.js";
2
3
  import { SUBAGENT_INTELLIGENCE_CUSTOM_TYPE } from "../intelligence.js";
3
4
  export { sessionFilesIn, readSessionMessages } from "./session.js";
@@ -40,7 +41,7 @@ export function describeToolArgs(toolName: string, rawArgs: unknown): string {
40
41
  };
41
42
  switch (toolName) {
42
43
  case "message_subagent":
43
- return `${clip(args.name, 40)}: ${clip(args.message, 120)}`;
44
+ return `${clip(Array.isArray(args.name) ? args.name.filter((name) => typeof name === "string").join(", ") : args.name, 40)}: ${clip(args.message, 120)}`;
44
45
  case "message_lead_agent":
45
46
  return clip(args.message, 120);
46
47
  case "bash":
@@ -292,6 +293,7 @@ export function buildSubagentDetail(record: SubagentNameRecord, options: { sessi
292
293
  model,
293
294
  thinkingLevel,
294
295
  tools: record.tools,
296
+ budget: readDetailBudget(record.budget),
295
297
  createdAt: record.createdAt,
296
298
  sessionDir,
297
299
  sessionFile,
package/ui/tree-live.ts CHANGED
@@ -40,7 +40,10 @@ function formatToolArgPreview(toolName: unknown, rawArgs: unknown): string {
40
40
  .join(", ");
41
41
  }
42
42
  case "message_subagent":
43
- return truncateTo(`${stringValue(args.name)}: ${stringValue(args.message).replace(/\s+/g, " ").trim()}`, 80);
43
+ return truncateTo(
44
+ `${Array.isArray(args.name) ? args.name.map((name) => stringValue(name)).join(", ") : stringValue(args.name)}: ${stringValue(args.message).replace(/\s+/g, " ").trim()}`,
45
+ 80,
46
+ );
44
47
  case "message_lead_agent":
45
48
  return truncateTo(stringValue(args.message).replace(/\s+/g, " ").trim(), 80);
46
49
  case "resume_subagents": {