@trim21/personal-pi-extensions 0.1.587 → 0.1.588
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 +4 -69
package/package.json
CHANGED
package/src/spawn-agent.ts
CHANGED
|
@@ -52,7 +52,6 @@ import {
|
|
|
52
52
|
SessionManager,
|
|
53
53
|
SettingsManager,
|
|
54
54
|
truncateTail,
|
|
55
|
-
truncateToVisualLines,
|
|
56
55
|
} from "@earendil-works/pi-coding-agent";
|
|
57
56
|
import { Type } from "typebox";
|
|
58
57
|
|
|
@@ -148,7 +147,7 @@ interface UsageStats {
|
|
|
148
147
|
turns: number;
|
|
149
148
|
}
|
|
150
149
|
|
|
151
|
-
/** 子 agent 的一次运行结果:runAgent
|
|
150
|
+
/** 子 agent 的一次运行结果:runAgent 的返回值。 */
|
|
152
151
|
interface SubagentResult {
|
|
153
152
|
agent: string;
|
|
154
153
|
task: string;
|
|
@@ -162,8 +161,6 @@ interface SubagentResult {
|
|
|
162
161
|
}
|
|
163
162
|
|
|
164
163
|
interface SubagentDetails {
|
|
165
|
-
/** 子 agent 运行结果(除 pendant 外的字段都收在这里)。 */
|
|
166
|
-
result: SubagentResult;
|
|
167
164
|
/** 折叠 markdown 面板:父 agent 的 prompt 与父 agent 看到的子 agent 结果。 */
|
|
168
165
|
pendant?: ToolPendant;
|
|
169
166
|
}
|
|
@@ -465,7 +462,7 @@ export async function runAgent(
|
|
|
465
462
|
const footer = usageLine ? `\`${name}\` ${usageLine}` : `\`${name}\``;
|
|
466
463
|
onUpdate?.({
|
|
467
464
|
content: [{ type: "text", text: [...logLines, footer].join("\n") }],
|
|
468
|
-
details: {
|
|
465
|
+
details: {},
|
|
469
466
|
});
|
|
470
467
|
};
|
|
471
468
|
|
|
@@ -591,20 +588,7 @@ export default function spawnAgent(pi: ExtensionAPI) {
|
|
|
591
588
|
text: `Unknown agent "${params.agent}". Available agents: ${formatAgentList(agents)}`,
|
|
592
589
|
},
|
|
593
590
|
],
|
|
594
|
-
details: {
|
|
595
|
-
result: {
|
|
596
|
-
agent: params.agent,
|
|
597
|
-
task: params.task,
|
|
598
|
-
exitCode: 1,
|
|
599
|
-
messages: [],
|
|
600
|
-
stderr: "",
|
|
601
|
-
usage: {
|
|
602
|
-
cost: 0,
|
|
603
|
-
contextTokens: 0,
|
|
604
|
-
turns: 0,
|
|
605
|
-
},
|
|
606
|
-
},
|
|
607
|
-
},
|
|
591
|
+
details: {},
|
|
608
592
|
isError: true,
|
|
609
593
|
};
|
|
610
594
|
}
|
|
@@ -627,7 +611,6 @@ export default function spawnAgent(pi: ExtensionAPI) {
|
|
|
627
611
|
{ type: "text", text: `Subagent "${result.agent}" failed (${reason}):\n${message}` },
|
|
628
612
|
],
|
|
629
613
|
details: {
|
|
630
|
-
result,
|
|
631
614
|
pendant: {
|
|
632
615
|
subtitle: result.agent,
|
|
633
616
|
markdown: formatPendantMarkdown(params.task, message),
|
|
@@ -640,12 +623,11 @@ export default function spawnAgent(pi: ExtensionAPI) {
|
|
|
640
623
|
const output = getFinalOutput(result.messages) || "(no output)";
|
|
641
624
|
const truncation = truncateTail(output, { maxBytes: MAX_OUTPUT_BYTES });
|
|
642
625
|
const text = truncation.truncated
|
|
643
|
-
? `${truncation.content}\n\n[Output truncated to ${formatTokens(truncation.content.length)} bytes.
|
|
626
|
+
? `${truncation.content}\n\n[Output truncated to ${formatTokens(truncation.content.length)} bytes.]`
|
|
644
627
|
: output;
|
|
645
628
|
return {
|
|
646
629
|
content: [{ type: "text", text }],
|
|
647
630
|
details: {
|
|
648
|
-
result,
|
|
649
631
|
pendant: {
|
|
650
632
|
subtitle: result.agent,
|
|
651
633
|
markdown: formatPendantMarkdown(params.task, text),
|
|
@@ -653,52 +635,5 @@ export default function spawnAgent(pi: ExtensionAPI) {
|
|
|
653
635
|
},
|
|
654
636
|
};
|
|
655
637
|
},
|
|
656
|
-
|
|
657
|
-
renderCall(args, theme) {
|
|
658
|
-
const preview = args.task.length > 60 ? `${args.task.slice(0, 60)}...` : args.task;
|
|
659
|
-
const line =
|
|
660
|
-
theme.fg("toolTitle", theme.bold("spawn_agent ")) + theme.fg("accent", args.agent);
|
|
661
|
-
const detail = ` ${theme.fg("dim", preview)}`;
|
|
662
|
-
return {
|
|
663
|
-
render: (width: number) =>
|
|
664
|
-
truncateToVisualLines(`${line}\n${detail}`, 2, width).visualLines,
|
|
665
|
-
invalidate: (): void => undefined,
|
|
666
|
-
};
|
|
667
|
-
},
|
|
668
|
-
|
|
669
|
-
renderResult(result, { expanded }, theme) {
|
|
670
|
-
const details = result.details.result;
|
|
671
|
-
const isError =
|
|
672
|
-
details.exitCode !== 0 ||
|
|
673
|
-
details.stopReason === "error" ||
|
|
674
|
-
details.stopReason === "aborted";
|
|
675
|
-
const icon = isError ? theme.fg("error", "✗") : theme.fg("success", "✓");
|
|
676
|
-
const finalOutput = getFinalOutput(details.messages);
|
|
677
|
-
const usageStr = formatUsageStats(details.usage, details.model);
|
|
678
|
-
|
|
679
|
-
const lines: string[] = [];
|
|
680
|
-
let header = `${icon} ${theme.fg("toolTitle", theme.bold(details.agent))}`;
|
|
681
|
-
if (details.stopReason) header += ` ${theme.fg("error", `[${details.stopReason}]`)}`;
|
|
682
|
-
lines.push(header);
|
|
683
|
-
if (isError && details.errorMessage) {
|
|
684
|
-
lines.push(theme.fg("error", `Error: ${details.errorMessage}`));
|
|
685
|
-
}
|
|
686
|
-
if (expanded) {
|
|
687
|
-
lines.push("", theme.fg("muted", "─── Task ───"), theme.fg("dim", details.task));
|
|
688
|
-
if (finalOutput) {
|
|
689
|
-
lines.push("", theme.fg("muted", "─── Output ───"), finalOutput.trim());
|
|
690
|
-
}
|
|
691
|
-
} else if (finalOutput) {
|
|
692
|
-
lines.push(theme.fg("toolOutput", finalOutput.split("\n").slice(0, 5).join("\n")));
|
|
693
|
-
} else {
|
|
694
|
-
lines.push(theme.fg("muted", "(no output)"));
|
|
695
|
-
}
|
|
696
|
-
if (usageStr) lines.push(theme.fg("dim", usageStr));
|
|
697
|
-
return {
|
|
698
|
-
render: (width: number) =>
|
|
699
|
-
truncateToVisualLines(lines.join("\n"), Infinity, width).visualLines,
|
|
700
|
-
invalidate: (): void => undefined,
|
|
701
|
-
};
|
|
702
|
-
},
|
|
703
638
|
});
|
|
704
639
|
}
|