oira666_pi-subagent 0.2.10 → 0.2.11
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 +22 -15
- package/package.json +1 -1
package/index.ts
CHANGED
|
@@ -373,7 +373,7 @@ const RESUME_PROVIDER = "pi-subagent-resume";
|
|
|
373
373
|
const RESUME_MODEL_ID = "synthetic-tool-call";
|
|
374
374
|
const RESUME_STATE_KEY = "__piSubagentResumeState";
|
|
375
375
|
const SUBAGENT_FALLBACK_MODEL_ENV = "PI_SUBAGENT_FALLBACK_MODEL";
|
|
376
|
-
const RESUME_INTERACTIVE_DELAY_MS =
|
|
376
|
+
const RESUME_INTERACTIVE_DELAY_MS = 50;
|
|
377
377
|
|
|
378
378
|
type SyntheticResumeState = {
|
|
379
379
|
plan: ResumableSubagentCall | null;
|
|
@@ -472,6 +472,7 @@ function getRestorableModel(ctx: any): any | undefined {
|
|
|
472
472
|
export default function (pi: ExtensionAPI) {
|
|
473
473
|
let resumeModelRegistry: any | undefined;
|
|
474
474
|
let lastRestorableModel: any | undefined;
|
|
475
|
+
let pendingInteractiveResumePrompt: string | null = null;
|
|
475
476
|
|
|
476
477
|
async function streamWithRealModelFallback(context: any, options: any, fallback: any) {
|
|
477
478
|
if (!fallback) return null;
|
|
@@ -685,20 +686,12 @@ export default function (pi: ExtensionAPI) {
|
|
|
685
686
|
if (hasCliInitialPrompt(process.argv)) {
|
|
686
687
|
if (ctx.hasUI) ctx.ui.notify(`Resuming ${plan.tasks.length} subagents...`, "info");
|
|
687
688
|
} else {
|
|
688
|
-
// Do not start the synthetic resume turn
|
|
689
|
-
//
|
|
690
|
-
//
|
|
691
|
-
//
|
|
692
|
-
//
|
|
693
|
-
|
|
694
|
-
setTimeout(() => {
|
|
695
|
-
try {
|
|
696
|
-
pi.sendUserMessage(`Resuming ${plan.tasks.length} subagents...`);
|
|
697
|
-
} catch (err) {
|
|
698
|
-
console.error("[pi-subagent] Failed to start deferred resume turn:", err);
|
|
699
|
-
void restoreModelAfterResumeFailure(ctx);
|
|
700
|
-
}
|
|
701
|
-
}, RESUME_INTERACTIVE_DELAY_MS);
|
|
689
|
+
// Do not start the synthetic resume turn from session_start. Pi renders
|
|
690
|
+
// the resumed chat only after session_start/resources_discover complete;
|
|
691
|
+
// starting now lets that render wipe out the live tool component, so no
|
|
692
|
+
// real-time updates appear. Queue it for resources_discover instead,
|
|
693
|
+
// which is the last extension hook before the initial chat render.
|
|
694
|
+
pendingInteractiveResumePrompt = `Resuming ${plan.tasks.length} subagents...`;
|
|
702
695
|
}
|
|
703
696
|
} catch (err) {
|
|
704
697
|
console.error("[pi-subagent] Error in session_start:", err);
|
|
@@ -710,6 +703,20 @@ export default function (pi: ExtensionAPI) {
|
|
|
710
703
|
await restoreModelAfterResumeFailure();
|
|
711
704
|
});
|
|
712
705
|
|
|
706
|
+
pi.on("resources_discover", (_event, ctx) => {
|
|
707
|
+
const prompt = pendingInteractiveResumePrompt;
|
|
708
|
+
if (!prompt) return;
|
|
709
|
+
pendingInteractiveResumePrompt = null;
|
|
710
|
+
setTimeout(() => {
|
|
711
|
+
try {
|
|
712
|
+
pi.sendUserMessage(prompt);
|
|
713
|
+
} catch (err) {
|
|
714
|
+
console.error("[pi-subagent] Failed to start deferred resume turn:", err);
|
|
715
|
+
void restoreModelAfterResumeFailure(ctx);
|
|
716
|
+
}
|
|
717
|
+
}, RESUME_INTERACTIVE_DELAY_MS);
|
|
718
|
+
});
|
|
719
|
+
|
|
713
720
|
// Inject available agents into the system prompt
|
|
714
721
|
pi.on("before_agent_start", async (event) => {
|
|
715
722
|
try {
|