@narumitw/pi-goal 0.17.0 → 0.17.2
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/goal.ts +9 -2
- package/src/runtime.ts +19 -5
package/package.json
CHANGED
package/src/goal.ts
CHANGED
|
@@ -86,6 +86,7 @@ function registerGoalRuntime(pi: ExtensionAPI, options: GoalOptions = {}) {
|
|
|
86
86
|
const cancelContinuationWork = runtime.cancelContinuationWork.bind(runtime);
|
|
87
87
|
const consumeCancelledContinuationPrompt =
|
|
88
88
|
runtime.consumeCancelledContinuationPrompt.bind(runtime);
|
|
89
|
+
const consumeStaleOwnedGoalPrompt = runtime.consumeStaleOwnedGoalPrompt.bind(runtime);
|
|
89
90
|
const consumePendingGoalPrompt = runtime.consumeOwnedGoalPrompt.bind(runtime);
|
|
90
91
|
const markContinuationStarted = runtime.markContinuationStarted.bind(runtime);
|
|
91
92
|
const hasContinuationWorkForGoal = runtime.hasContinuationWorkForGoal.bind(runtime);
|
|
@@ -623,12 +624,18 @@ function registerGoalRuntime(pi: ExtensionAPI, options: GoalOptions = {}) {
|
|
|
623
624
|
});
|
|
624
625
|
|
|
625
626
|
pi.on("input", (event) => {
|
|
626
|
-
if (runtime.queueFrozen) return;
|
|
627
627
|
if (event.source === "extension") {
|
|
628
|
-
if (
|
|
628
|
+
if (
|
|
629
|
+
consumeCancelledContinuationPrompt(event.text) ||
|
|
630
|
+
consumeStaleOwnedGoalPrompt(event.text)
|
|
631
|
+
) {
|
|
632
|
+
return { action: "handled" as const };
|
|
633
|
+
}
|
|
634
|
+
if (runtime.queueFrozen) return;
|
|
629
635
|
clearGoalRecovery();
|
|
630
636
|
return;
|
|
631
637
|
}
|
|
638
|
+
if (runtime.queueFrozen) return;
|
|
632
639
|
if (/^\/goal(?:\s|$)/u.test(event.text.trimStart())) return;
|
|
633
640
|
clearGoalRecovery();
|
|
634
641
|
clearBudgetWrapUp();
|
package/src/runtime.ts
CHANGED
|
@@ -203,7 +203,7 @@ export class GoalRuntime {
|
|
|
203
203
|
this.continuationIntent = undefined;
|
|
204
204
|
this.continuationDelivery = intent;
|
|
205
205
|
try {
|
|
206
|
-
this.pi.sendUserMessage(intent.prompt);
|
|
206
|
+
this.pi.sendUserMessage(intent.prompt, { deliverAs: "followUp" });
|
|
207
207
|
return true;
|
|
208
208
|
} catch (error) {
|
|
209
209
|
if (this.continuationDelivery?.marker === intent.marker) {
|
|
@@ -350,6 +350,23 @@ export class GoalRuntime {
|
|
|
350
350
|
return marker ? this.cancelledContinuationMarkers.delete(marker) : false;
|
|
351
351
|
}
|
|
352
352
|
|
|
353
|
+
consumeStaleOwnedGoalPrompt(prompt: string) {
|
|
354
|
+
const marker = extractGoalPromptMarker(prompt);
|
|
355
|
+
if (!marker) return false;
|
|
356
|
+
const goalId = this.pendingGoalPromptMarkers.get(marker);
|
|
357
|
+
if (!goalId) return false;
|
|
358
|
+
if (
|
|
359
|
+
!this.queueFrozen &&
|
|
360
|
+
!this.pendingQueueAction &&
|
|
361
|
+
this.activeGoal?.id === goalId &&
|
|
362
|
+
this.activeGoal.status === "active"
|
|
363
|
+
) {
|
|
364
|
+
return false;
|
|
365
|
+
}
|
|
366
|
+
this.pendingGoalPromptMarkers.delete(marker);
|
|
367
|
+
return true;
|
|
368
|
+
}
|
|
369
|
+
|
|
353
370
|
markContinuationStarted(prompt: string) {
|
|
354
371
|
const marker = extractContinuationMarker(prompt);
|
|
355
372
|
if (!marker) {
|
|
@@ -757,10 +774,7 @@ export function truncateNotification(value: string) {
|
|
|
757
774
|
|
|
758
775
|
async function sendPrompt(pi: ExtensionAPI, ctx: StatusContext, prompt: string) {
|
|
759
776
|
try {
|
|
760
|
-
|
|
761
|
-
? (pi.sendUserMessage(prompt) as void | Promise<void>)
|
|
762
|
-
: (pi.sendUserMessage(prompt, { deliverAs: "followUp" }) as void | Promise<void>);
|
|
763
|
-
await sent;
|
|
777
|
+
await pi.sendUserMessage(prompt, { deliverAs: "followUp" });
|
|
764
778
|
return true;
|
|
765
779
|
} catch (error) {
|
|
766
780
|
ctx.ui.notify(`Goal prompt failed: ${formatError(error)}`, "error");
|