pi-better-harness 0.3.7 → 0.3.8

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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-better-goal",
3
- "version": "0.2.2",
3
+ "version": "0.2.3",
4
4
  "description": "Pi extension for goal tracking with background-aware continuation.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -248,6 +248,15 @@ export default function (pi: ExtensionAPI): void {
248
248
  refreshGoalWidget?.(wasVisible);
249
249
  };
250
250
 
251
+ const pauseGoalOnInterrupt = (ctx: ExtensionContext): void => {
252
+ const goal = getGoal(ctx);
253
+ if (!isPokeable(goal)) {
254
+ return;
255
+ }
256
+ setGoal(goalWithStatus(goal, "paused"), ctx, "runtime");
257
+ notifyGoal(ctx, "Goal paused (interrupted).");
258
+ };
259
+
251
260
  const queueGoalContinuation = (goal: GoalSnapshot): void => {
252
261
  if (!isPokeable(goal) || continuationQueuedFor === goal.goalId) {
253
262
  return;
@@ -728,6 +737,14 @@ export default function (pi: ExtensionAPI): void {
728
737
  clearIdleContinuation();
729
738
  continuationQueuedFor = null;
730
739
  lastAgentEvidence = null;
740
+ const turnSignal = ctx.signal;
741
+ if (turnSignal) {
742
+ if (turnSignal.aborted) {
743
+ pauseGoalOnInterrupt(ctx);
744
+ } else {
745
+ turnSignal.addEventListener("abort", () => pauseGoalOnInterrupt(ctx), { once: true });
746
+ }
747
+ }
731
748
  await publishSnapshot(ctx);
732
749
  });
733
750
 
@@ -738,13 +755,7 @@ export default function (pi: ExtensionAPI): void {
738
755
  // aborted (escape / ctrl+c while streaming), pause the active goal so it does
739
756
  // not auto-continue after the user stopped the agent.
740
757
  if (wasTurnAborted(event.messages)) {
741
- const goal = getGoal(ctx);
742
- if (isPokeable(goal)) {
743
- setGoal(goalWithStatus(goal, "paused"), ctx, "runtime");
744
- if (ctx.hasUI) {
745
- ctx.ui.notify("Goal paused (interrupted).", "info");
746
- }
747
- }
758
+ pauseGoalOnInterrupt(ctx);
748
759
  }
749
760
  });
750
761
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-better-harness",
3
- "version": "0.3.7",
3
+ "version": "0.3.8",
4
4
  "description": "Pi extension bundle for a write sandbox, subagents, background tasks, SSH, goals, and structured plans.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -51,7 +51,7 @@
51
51
  },
52
52
  "dependencies": {
53
53
  "pi-better-background-tasks": "0.2.12",
54
- "pi-better-goal": "0.2.2",
54
+ "pi-better-goal": "0.2.3",
55
55
  "pi-better-plan": "0.1.5",
56
56
  "pi-better-sandbox": "0.3.0",
57
57
  "pi-better-ssh": "0.1.1",