@narumitw/pi-goal 0.17.1 → 0.18.0

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@narumitw/pi-goal",
3
- "version": "0.17.1",
3
+ "version": "0.18.0",
4
4
  "description": "Pi extension for autonomous /goal completion with opt-in experimental ordered queues.",
5
5
  "type": "module",
6
6
  "license": "MIT",
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 (consumeCancelledContinuationPrompt(event.text)) return { action: "handled" as const };
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
@@ -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) {