@narumitw/pi-goal 0.54.8 → 0.54.10

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.54.8",
3
+ "version": "0.54.10",
4
4
  "description": "Pi extension for autonomous single-objective /goal completion.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -39,9 +39,9 @@
39
39
  "typebox": "*"
40
40
  },
41
41
  "devDependencies": {
42
- "@earendil-works/pi-ai": "0.86.0",
43
- "@earendil-works/pi-coding-agent": "0.86.0",
44
- "@earendil-works/pi-tui": "0.86.0",
42
+ "@earendil-works/pi-ai": "1.0.2",
43
+ "@earendil-works/pi-coding-agent": "1.0.2",
44
+ "@earendil-works/pi-tui": "1.0.2",
45
45
  "esbuild": "0.28.2",
46
46
  "typebox": "1.3.34",
47
47
  "typescript": "7.0.2"
@@ -83,10 +83,9 @@ function reconcileContract(
83
83
  },
84
84
  ) {
85
85
  if (latestGoalContractContent(messages) === expected.content) return messages;
86
- const summaryBoundary = leadingSummaryBoundary(messages);
87
- if (!hasGoalContextContractHistory(messages) && hasLeadingSummary(messages, summaryBoundary)) {
88
- return [...messages.slice(0, summaryBoundary), expected, ...messages.slice(summaryBoundary)];
89
- }
86
+ // Match Pi's immediate persisted-message position after retained history.
87
+ // Streaming publication can be deferred past new output; tail insertion alone
88
+ // does not preserve the prefix across that separate delivery boundary.
90
89
  return [...messages, expected];
91
90
  }
92
91
 
@@ -98,21 +97,6 @@ function latestGoalContractContent(messages: readonly unknown[]) {
98
97
  return undefined;
99
98
  }
100
99
 
101
- function leadingSummaryBoundary(messages: readonly unknown[]) {
102
- let index = unwrapMessage(messages[0]).role === "system" ? 1 : 0;
103
- while (index < messages.length) {
104
- const role = unwrapMessage(messages[index]).role;
105
- if (role !== "compactionSummary" && role !== "branchSummary") break;
106
- index += 1;
107
- }
108
- return index;
109
- }
110
-
111
- function hasLeadingSummary(messages: readonly unknown[], boundary: number): boolean {
112
- const summaryStart = unwrapMessage(messages[0]).role === "system" ? 1 : 0;
113
- return boundary > summaryStart;
114
- }
115
-
116
100
  function unwrapMessage(message: unknown): ContractMessage {
117
101
  const entry = message as ContractSessionEntry | undefined;
118
102
  if (entry?.type === "custom_message") return entry;
package/src/lifecycle.ts CHANGED
@@ -192,6 +192,7 @@ export function registerGoalLifecycle(
192
192
  if (!sessionActive) return;
193
193
  if (runtime.activeGoal?.status !== "active" || !runtime.ownsWorkflow(runtime.activeGoal)) {
194
194
  runtime.clearGoalRecovery();
195
+ runtime.ensureInactiveGoalContextContract(ctx);
195
196
  return;
196
197
  }
197
198
 
package/src/wait.ts CHANGED
@@ -61,6 +61,12 @@ export class GoalWaitTimer {
61
61
  this.timer = setTimeout(() => {
62
62
  if (generation !== this.generation) return;
63
63
  this.timer = undefined;
64
+ // Timer delays do not track wall-clock corrections. Preserve the absolute
65
+ // deadline when a backward correction or a capped delay makes this fire early.
66
+ if (Date.now() < resumeAt) {
67
+ this.schedule(resumeAt, onDue);
68
+ return;
69
+ }
64
70
  onDue();
65
71
  }, delay);
66
72
  }