pi-agent-flow 1.1.0 → 1.2.0

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.
@@ -22,7 +22,7 @@ import {
22
22
  isFlowError,
23
23
  isFlowSuccess,
24
24
  } from "./types.js";
25
- import { formatCompactStats, formatFlowTypeName, truncateChars, contentBudget } from "./render-utils.js";
25
+ import { formatCompactStats, formatFlowTypeName, truncateChars, tailText, contentBudget } from "./render-utils.js";
26
26
 
27
27
  function shortenPath(p: string): string {
28
28
  const home = os.homedir();
@@ -66,9 +66,10 @@ function formatFlowToolCall(toolName: string, args: Record<string, unknown>, fg:
66
66
  return fg("muted", "find ") + fg("accent", (args.pattern || "*") as string) + fg("dim", ` in ${shortenPath((args.path || ".") as string)}`);
67
67
  case "grep":
68
68
  return fg("muted", "grep ") + fg("accent", `/${(args.pattern || "") as string}/`) + fg("dim", ` in ${shortenPath((args.path || ".") as string)}`);
69
- case "batch": {
69
+ case "batch":
70
+ case "batch_read": {
70
71
  const ops = Array.isArray(args.o) ? args.o : Array.isArray(args.op) ? args.op : Array.isArray(args.operations) ? args.operations : Array.isArray(args) ? args : [];
71
- if (ops.length === 0) return fg("muted", "batch (empty)");
72
+ if (ops.length === 0) return fg("muted", `${toolName} (empty)`);
72
73
  const parts: string[] = [];
73
74
  for (const op of ops) {
74
75
  const opObj = op as Record<string, unknown>;
@@ -84,7 +85,7 @@ function formatFlowToolCall(toolName: string, args: Record<string, unknown>, fg:
84
85
  }
85
86
  }
86
87
  const summary = parts.length <= 3 ? parts.join(", ") : `${parts.slice(0, 2).join(", ")} +${parts.length - 2} more`;
87
- return fg("muted", "batch ") + fg("accent", summary);
88
+ return fg("muted", `${toolName} `) + fg("accent", summary);
88
89
  }
89
90
  default:
90
91
  return fg("accent", toolName) + fg("dim", ` ${JSON.stringify(args)}`);
@@ -290,11 +291,14 @@ function renderFlowCollapsed(
290
291
  }
291
292
 
292
293
  // msg: line (last assistant text or streaming)
293
- if (flowOutput) {
294
- const logContent = truncateChars(flowOutput, contentBudget(10));
294
+ if (r.exitCode === -1 && streamingText) {
295
+ const logContent = tailText(streamingText, contentBudget(10));
296
+ container.addChild(new TruncatedText(`${theme.fg("dim", "└─ msg:")} ${theme.fg("dim", logContent)}`, 0, 0));
297
+ } else if (flowOutput) {
298
+ const logContent = tailText(flowOutput, contentBudget(10));
295
299
  container.addChild(new TruncatedText(`${theme.fg("dim", "└─ msg:")} ${theme.fg("dim", logContent)}`, 0, 0));
296
300
  } else if (streamingText) {
297
- const logContent = truncateChars(streamingText, contentBudget(10));
301
+ const logContent = tailText(streamingText, contentBudget(10));
298
302
  container.addChild(new TruncatedText(`${theme.fg("dim", "└─ msg:")} ${theme.fg("dim", logContent)}`, 0, 0));
299
303
  } else if (error && r.errorMessage) {
300
304
  const logContent = truncateChars(r.errorMessage, contentBudget(10));
@@ -421,10 +425,11 @@ function renderActivityPanel(
421
425
  container.addChild(new TruncatedText(`${theme.fg("dim", indent + "├─ " + actPrefix)}${actContent}`, 0, 0));
422
426
  }
423
427
 
424
- // msg: line (last assistant text)
425
- const lastText = getLastAssistantText(r.messages);
428
+ // msg: line (live streaming text or last assistant text)
429
+ const liveText = r.exitCode === -1 ? r.streamingText : undefined;
430
+ const lastText = liveText || getLastAssistantText(r.messages);
426
431
  if (lastText) {
427
- const logContent = truncateChars(lastText, contentBudget(10));
432
+ const logContent = tailText(lastText, contentBudget(10));
428
433
  container.addChild(new TruncatedText(`${theme.fg("dim", indent + "└─ msg:")} ${theme.fg("dim", logContent)}`, 0, 0));
429
434
  } else if (error && r.errorMessage) {
430
435
  const logContent = truncateChars(r.errorMessage, contentBudget(10));