oira666_pi-subagent 0.2.5 → 0.2.6
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 +8 -2
- package/package.json +1 -1
package/index.ts
CHANGED
|
@@ -376,18 +376,20 @@ const RESUME_STATE_KEY = "__piSubagentResumeState";
|
|
|
376
376
|
type SyntheticResumeState = {
|
|
377
377
|
plan: ResumableSubagentCall | null;
|
|
378
378
|
phase: "tool" | "final";
|
|
379
|
+
trigger: "resumePrompt" | "nextRequest";
|
|
379
380
|
};
|
|
380
381
|
|
|
381
382
|
function clearSyntheticResumeState(): void {
|
|
382
383
|
const state = getSyntheticResumeState();
|
|
383
384
|
state.plan = null;
|
|
384
385
|
state.phase = "tool";
|
|
386
|
+
state.trigger = "resumePrompt";
|
|
385
387
|
}
|
|
386
388
|
|
|
387
389
|
function getSyntheticResumeState(): SyntheticResumeState {
|
|
388
390
|
const g = globalThis as any;
|
|
389
391
|
if (!g[RESUME_STATE_KEY]) {
|
|
390
|
-
g[RESUME_STATE_KEY] = { plan: null, phase: "tool" } satisfies SyntheticResumeState;
|
|
392
|
+
g[RESUME_STATE_KEY] = { plan: null, phase: "tool", trigger: "resumePrompt" } satisfies SyntheticResumeState;
|
|
391
393
|
}
|
|
392
394
|
return g[RESUME_STATE_KEY] as SyntheticResumeState;
|
|
393
395
|
}
|
|
@@ -449,7 +451,10 @@ export default function (pi: ExtensionAPI) {
|
|
|
449
451
|
const state = getSyntheticResumeState();
|
|
450
452
|
const plan = state.plan;
|
|
451
453
|
const phase = state.phase;
|
|
452
|
-
|
|
454
|
+
const triggerMatches =
|
|
455
|
+
state.trigger === "nextRequest" ||
|
|
456
|
+
(plan ? isSyntheticResumePrompt(context, plan.tasks.length) : false);
|
|
457
|
+
if (plan && phase === "tool" && triggerMatches) {
|
|
453
458
|
state.phase = "final";
|
|
454
459
|
const toolCall = {
|
|
455
460
|
type: "toolCall" as const,
|
|
@@ -599,6 +604,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
599
604
|
const resumeState = getSyntheticResumeState();
|
|
600
605
|
resumeState.plan = plan;
|
|
601
606
|
resumeState.phase = "tool";
|
|
607
|
+
resumeState.trigger = hasCliInitialPrompt(process.argv) ? "nextRequest" : "resumePrompt";
|
|
602
608
|
modelToRestoreAfterResume = ctx.model;
|
|
603
609
|
resumeModelRegistry = ctx.modelRegistry;
|
|
604
610
|
ensureSubagentToolActive(pi);
|