@trim21/personal-pi-extensions 0.1.588 → 0.1.589
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/spawn-agent.ts +37 -6
package/package.json
CHANGED
package/src/spawn-agent.ts
CHANGED
|
@@ -22,7 +22,10 @@
|
|
|
22
22
|
* so one log entry is always exactly one rendered line. The final line is
|
|
23
23
|
* always the subagent name as a code span (`` `scout` ``), followed by the
|
|
24
24
|
* live usage stats when there are any; it rides outside the rolling window so
|
|
25
|
-
* it is never trimmed.
|
|
25
|
+
* it is never trimmed. While the model is thinking, a transient
|
|
26
|
+
* `thinking ( N chars )` line sits between the log and the footer showing the
|
|
27
|
+
* live character count of the streamed thinking; it disappears when the
|
|
28
|
+
* thinking block ends.
|
|
26
29
|
*
|
|
27
30
|
* Security default: without an explicit `tools:` in the frontmatter, the
|
|
28
31
|
* subagent only gets read-only tools (read/grep/find/ls) — no bash/write/edit.
|
|
@@ -418,6 +421,9 @@ export async function runAgent(
|
|
|
418
421
|
// 不同名按调用顺序罗列;任何非工具行都会打断合并。
|
|
419
422
|
let toolLineSegments: string[] = [];
|
|
420
423
|
let toolLine: { name: string; count: number } | undefined;
|
|
424
|
+
// 思考中状态:thinking_start 打开、thinking_delta 累计字符数、thinking_end
|
|
425
|
+
// 关闭;非 undefined 时 emitUpdate 在 footer 上方插一行瞬态 thinking 状态。
|
|
426
|
+
let thinkingChars: number | undefined;
|
|
421
427
|
|
|
422
428
|
const pushLogLine = (line: string) => {
|
|
423
429
|
logLines.push(line);
|
|
@@ -460,8 +466,11 @@ export async function runAgent(
|
|
|
460
466
|
const usageLine = formatUsageStats(result.usage, result.model);
|
|
461
467
|
const name = sanitizeProgressLine(result.agent);
|
|
462
468
|
const footer = usageLine ? `\`${name}\` ${usageLine}` : `\`${name}\``;
|
|
469
|
+
const lines = [...logLines];
|
|
470
|
+
if (thinkingChars !== undefined) lines.push(`thinking ( ${thinkingChars} chars )`);
|
|
471
|
+
lines.push(footer);
|
|
463
472
|
onUpdate?.({
|
|
464
|
-
content: [{ type: "text", text:
|
|
473
|
+
content: [{ type: "text", text: lines.join("\n") }],
|
|
465
474
|
details: {},
|
|
466
475
|
});
|
|
467
476
|
};
|
|
@@ -470,11 +479,33 @@ export async function runAgent(
|
|
|
470
479
|
switch (event.type) {
|
|
471
480
|
case "message_update": {
|
|
472
481
|
// A completed text block (text_end carries the full content) becomes a
|
|
473
|
-
// `text:` log line. Deltas
|
|
482
|
+
// `text:` log line. Deltas are intentionally not logged; thinking
|
|
483
|
+
// deltas feed the transient `thinking ( N chars )` status line instead.
|
|
474
484
|
const delta = event.assistantMessageEvent;
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
485
|
+
switch (delta.type) {
|
|
486
|
+
case "text_end": {
|
|
487
|
+
pushLogLine(`text: ${foldProgressLine(sanitizeProgressLine(delta.content))}`);
|
|
488
|
+
emitUpdate();
|
|
489
|
+
break;
|
|
490
|
+
}
|
|
491
|
+
case "thinking_start": {
|
|
492
|
+
// 思考横跨轮次边界:打断工具行合并,下一批工具调用另起一行。
|
|
493
|
+
toolLine = undefined;
|
|
494
|
+
thinkingChars = 0;
|
|
495
|
+
emitUpdate();
|
|
496
|
+
break;
|
|
497
|
+
}
|
|
498
|
+
case "thinking_delta": {
|
|
499
|
+
thinkingChars = (thinkingChars ?? 0) + delta.delta.length;
|
|
500
|
+
emitUpdate();
|
|
501
|
+
break;
|
|
502
|
+
}
|
|
503
|
+
case "thinking_end": {
|
|
504
|
+
thinkingChars = undefined;
|
|
505
|
+
emitUpdate();
|
|
506
|
+
break;
|
|
507
|
+
}
|
|
508
|
+
// No default
|
|
478
509
|
}
|
|
479
510
|
|
|
480
511
|
break;
|