@yusukeshib/pi-babysit 0.3.15 → 0.3.16
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/index.ts +18 -1
- package/package.json +1 -1
package/index.ts
CHANGED
|
@@ -1285,6 +1285,8 @@ export interface Progress {
|
|
|
1285
1285
|
turns: number;
|
|
1286
1286
|
toolCalls: ToolCall[];
|
|
1287
1287
|
finalText: string;
|
|
1288
|
+
/** Best-effort text from the currently streaming assistant message. */
|
|
1289
|
+
streamingText: string;
|
|
1288
1290
|
/** Context size reported by the most recent assistant response. */
|
|
1289
1291
|
tokens?: number;
|
|
1290
1292
|
/** Cumulative model usage for the current subagent task. */
|
|
@@ -1339,6 +1341,7 @@ function emptyProgress(): Progress {
|
|
|
1339
1341
|
turns: 0,
|
|
1340
1342
|
toolCalls: [],
|
|
1341
1343
|
finalText: "",
|
|
1344
|
+
streamingText: "",
|
|
1342
1345
|
modelCalls: 0,
|
|
1343
1346
|
usageTokens: 0,
|
|
1344
1347
|
inputTokens: 0,
|
|
@@ -1417,7 +1420,17 @@ function parseEventLine(progress: Progress, raw: string): void {
|
|
|
1417
1420
|
switch (event.type) {
|
|
1418
1421
|
case "turn_start":
|
|
1419
1422
|
progress.turns++;
|
|
1423
|
+
progress.streamingText = "";
|
|
1420
1424
|
break;
|
|
1425
|
+
case "message_update": {
|
|
1426
|
+
const update = event.assistantMessageEvent as
|
|
1427
|
+
| { type?: string; delta?: string }
|
|
1428
|
+
| undefined;
|
|
1429
|
+
if (update?.type === "text_delta" && typeof update.delta === "string") {
|
|
1430
|
+
progress.streamingText += update.delta;
|
|
1431
|
+
}
|
|
1432
|
+
break;
|
|
1433
|
+
}
|
|
1421
1434
|
case "tool_execution_start": {
|
|
1422
1435
|
const name = String(event.toolName ?? "tool");
|
|
1423
1436
|
progress.toolCalls.push({
|
|
@@ -1448,6 +1461,7 @@ function parseEventLine(progress: Progress, raw: string): void {
|
|
|
1448
1461
|
.map((content) => content.text)
|
|
1449
1462
|
.join("");
|
|
1450
1463
|
if (text.trim()) progress.finalText = text;
|
|
1464
|
+
progress.streamingText = "";
|
|
1451
1465
|
if (message.usage) {
|
|
1452
1466
|
const finite = (value: number | undefined) =>
|
|
1453
1467
|
typeof value === "number" && Number.isFinite(value) ? value : 0;
|
|
@@ -1531,6 +1545,7 @@ export function buildSubagentExitDiagnostic(
|
|
|
1531
1545
|
): string {
|
|
1532
1546
|
const body = clip(
|
|
1533
1547
|
progress.errorMsg ||
|
|
1548
|
+
progress.streamingText.trim() ||
|
|
1534
1549
|
progress.finalText.trim() ||
|
|
1535
1550
|
"(no structured error was emitted; inspect the full log)",
|
|
1536
1551
|
ANSWER_MAX_BYTES,
|
|
@@ -2525,7 +2540,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
2525
2540
|
: "failed";
|
|
2526
2541
|
const output = await inlineOutput(session.id, session, NOTIFY_OUTPUT_MAX_BYTES);
|
|
2527
2542
|
const runtime = meta.startedAt
|
|
2528
|
-
? `${Math.round((Date.now() - meta.startedAt) / 1000)}s`
|
|
2543
|
+
? `${Math.round(((meta.completionObservedAt ?? Date.now()) - meta.startedAt) / 1000)}s`
|
|
2529
2544
|
: "?";
|
|
2530
2545
|
const summary = ok
|
|
2531
2546
|
? `Process "${session.id}" completed successfully after ${runtime}.`
|
|
@@ -2545,6 +2560,8 @@ export default function (pi: ExtensionAPI) {
|
|
|
2545
2560
|
});
|
|
2546
2561
|
}
|
|
2547
2562
|
|
|
2563
|
+
if (prepared.length === 0) return;
|
|
2564
|
+
|
|
2548
2565
|
// Output loading above is asynchronous. Refresh sessions and metadata
|
|
2549
2566
|
// immediately before the single send so concurrent wait/kill calls and newly
|
|
2550
2567
|
// started notification-group members are honored.
|