notesoup 0.51.2 → 0.51.4

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.
@@ -0,0 +1,29 @@
1
+ import { z } from "zod";
2
+
3
+ export const NOTES_OP_KIND = "notes-op";
4
+ export const NOTES_OP_TOOLS = ["notes_read", "notes_write", "notes_update"] as const;
5
+ export type NotesOpTool = (typeof NOTES_OP_TOOLS)[number];
6
+
7
+ /** Card data stays small: the plugin timeline refuses payloads over 64 KB. */
8
+ export const READ_TEXT_MAX_CHARS = 4000;
9
+ export const DIFF_MAX_CHARS = 8000;
10
+ export const PREVIEW_MAX_CHARS = 4000;
11
+
12
+ export const notesOpSchema = z.object({
13
+ op: z.enum(["read", "write", "update"]),
14
+ address: z.string(),
15
+ status: z.enum(["running", "completed", "failed"]),
16
+ error: z.string().optional(),
17
+ // read
18
+ text: z.string().optional(),
19
+ totalChars: z.number().optional(),
20
+ // write
21
+ outcome: z.string().optional(),
22
+ preview: z.string().optional(),
23
+ // update
24
+ changeKind: z.string().optional(),
25
+ diff: z.string().optional(),
26
+ renamedFrom: z.string().optional(),
27
+ truncated: z.boolean().optional(),
28
+ });
29
+ export type NotesOp = z.infer<typeof notesOpSchema>;
@@ -0,0 +1,129 @@
1
+ import assert from "node:assert/strict";
2
+ import test from "node:test";
3
+ import { notesOpTransformer } from "../client/notes-op-transformer.ts";
4
+ import { DIFF_MAX_CHARS, PREVIEW_MAX_CHARS, READ_TEXT_MAX_CHARS, notesOpSchema } from "../shared/notes-op.ts";
5
+
6
+ function toolCall(overrides: Record<string, unknown>) {
7
+ return {
8
+ type: "tool_call" as const,
9
+ callId: "call-1",
10
+ name: "notes_read",
11
+ status: "completed" as const,
12
+ error: null,
13
+ detail: { type: "unknown" as const, input: { address: "@self/foo.md" }, output: {} },
14
+ ...overrides,
15
+ };
16
+ }
17
+
18
+ const transform = (overrides: Record<string, unknown>) => notesOpTransformer.transform({ item: toolCall(overrides) as never });
19
+
20
+ test("notes_read renders the structured window, marks continuation as truncated", () => {
21
+ const result = transform({
22
+ detail: {
23
+ type: "unknown",
24
+ input: { address: "@self/foo.md" },
25
+ output: { structuredContent: { address: "@self/foo.md", text: "hello note", total_chars: 9999, next_offset_chars: 4000 } },
26
+ },
27
+ });
28
+ const data = notesOpSchema.parse(result!.items[0]!.data);
29
+ assert.deepEqual(data, { op: "read", address: "@self/foo.md", status: "completed", text: "hello note", totalChars: 9999, truncated: true });
30
+ });
31
+
32
+ test("notes_write carries outcome and a clipped content preview", () => {
33
+ const result = transform({
34
+ name: "notes_write",
35
+ detail: {
36
+ type: "unknown",
37
+ input: { address: "session.md", content: "x".repeat(PREVIEW_MAX_CHARS + 10) },
38
+ output: { structuredContent: { address: "session.md", outcome: "created" } },
39
+ },
40
+ });
41
+ const data = notesOpSchema.parse(result!.items[0]!.data);
42
+ assert.equal(data.op, "write");
43
+ assert.equal(data.outcome, "created");
44
+ assert.equal(data.preview!.length, PREVIEW_MAX_CHARS);
45
+ assert.equal(data.truncated, true);
46
+ });
47
+
48
+ test("notes_update carries change kind, rename, and clipped diff", () => {
49
+ const result = transform({
50
+ name: "notes_update",
51
+ detail: {
52
+ type: "unknown",
53
+ input: { address: "@project/a.md" },
54
+ output: { structuredContent: { address: "@project/b.md", change_kind: "moved", rename_from: "@project/a.md", diff: "y".repeat(DIFF_MAX_CHARS + 10) } },
55
+ },
56
+ });
57
+ const data = notesOpSchema.parse(result!.items[0]!.data);
58
+ assert.equal(data.changeKind, "moved");
59
+ assert.equal(data.renamedFrom, "@project/a.md");
60
+ assert.equal(data.diff!.length, DIFF_MAX_CHARS);
61
+ assert.equal(data.truncated, true);
62
+ });
63
+
64
+ test("wire errors and failed calls surface the refusal text", () => {
65
+ const refused = transform({
66
+ detail: { type: "unknown", input: { address: "@self/foo.md" }, output: { structuredContent: { error: "No note at @self/foo.md.", code: "not_found" } } },
67
+ });
68
+ assert.equal(notesOpSchema.parse(refused!.items[0]!.data).error, "No note at @self/foo.md.");
69
+
70
+ const failed = transform({
71
+ status: "failed",
72
+ error: { message: "boom" },
73
+ detail: { type: "unknown", input: { address: "@self/foo.md" }, output: { content: [{ type: "text", text: "io failed" }] } },
74
+ });
75
+ assert.equal(notesOpSchema.parse(failed!.items[0]!.data).error, "io failed");
76
+ });
77
+
78
+ test("running calls render from input alone; long reads clip to the card budget", () => {
79
+ const running = transform({ status: "running", detail: { type: "unknown", input: { address: "@human/map.md" }, output: null } });
80
+ assert.deepEqual(notesOpSchema.parse(running!.items[0]!.data), { op: "read", address: "@human/map.md", status: "running" });
81
+
82
+ const long = transform({
83
+ detail: { type: "unknown", input: { address: "big.md" }, output: { structuredContent: { address: "big.md", text: "z".repeat(READ_TEXT_MAX_CHARS + 500), total_chars: 50000, next_offset_chars: null } } },
84
+ });
85
+ const data = notesOpSchema.parse(long!.items[0]!.data);
86
+ assert.equal(data.text!.length, READ_TEXT_MAX_CHARS);
87
+ assert.equal(data.truncated, true);
88
+ assert.ok(JSON.stringify(result_items(long)).length < 64 * 1024, "plugin payload stays under the timeline limit");
89
+ });
90
+
91
+ test("history replay has no structured payload: the rendered text is parsed instead", () => {
92
+ const read = transform({
93
+ detail: { type: "unknown", input: { address: "@self/foo.md" }, output: { content: [{ type: "text", text: "@self/foo.md\norigin self | created 2026-10-15 | updated 2026-10-15\n\nbody line one\nbody line two" }] } },
94
+ });
95
+ assert.equal(notesOpSchema.parse(read!.items[0]!.data).text, "body line one\nbody line two");
96
+
97
+ const write = transform({
98
+ name: "notes_write",
99
+ detail: { type: "unknown", input: { address: "a.md", content: "ignored" }, output: { content: [{ type: "text", text: "overwrote a.md (project pi-context)" }] } },
100
+ });
101
+ const writeData = notesOpSchema.parse(write!.items[0]!.data);
102
+ assert.equal(writeData.outcome, "overwrote");
103
+ assert.equal(writeData.preview, undefined, "replay has no input preview authority beyond the address");
104
+
105
+ const update = transform({
106
+ name: "notes_update",
107
+ detail: { type: "unknown", input: { address: "a.md" }, output: { content: [{ type: "text", text: "updated a.md\ndiff:\n- 1 - old\n+ 1 + new" }] } },
108
+ });
109
+ const updateData = notesOpSchema.parse(update!.items[0]!.data);
110
+ assert.equal(updateData.changeKind, "body");
111
+ assert.equal(updateData.diff, "- 1 - old\n+ 1 + new");
112
+
113
+ const moved = transform({
114
+ name: "notes_update",
115
+ detail: { type: "unknown", input: { address: "a.md" }, output: { content: [{ type: "text", text: "moved a.md -> b.md" }] } },
116
+ });
117
+ assert.equal(notesOpSchema.parse(moved!.items[0]!.data).changeKind, "moved");
118
+ });
119
+
120
+ test("non-notes tools, unknown shapes and missing addresses stay untouched", () => {
121
+ assert.equal(notesOpTransformer.transform({ item: toolCall({ name: "bash" }) as never }), undefined);
122
+ assert.equal(notesOpTransformer.transform({ item: toolCall({ detail: { type: "plain_text", text: "hi" } }) as never }), undefined);
123
+ assert.equal(notesOpTransformer.transform({ item: toolCall({ detail: { type: "unknown", input: {}, output: {} } }) as never }), undefined);
124
+ assert.equal(notesOpTransformer.transform({ item: { type: "user_message", text: "hi" } as never }), undefined);
125
+ });
126
+
127
+ function result_items(result: { items: Array<{ data: unknown }> } | undefined) {
128
+ return result!.items.map((item) => item.data);
129
+ }
@@ -5,7 +5,7 @@ import { NOTES_NAMESPACE, registerOperation } from "../tool-result.js";
5
5
  import type { NoteChange } from "../../../src/notes/index.js";
6
6
 
7
7
  function renderDiff(change: NoteChange): string {
8
- return change.kind === "none" ? "" : generateDiffString(change.before, change.after).diff;
8
+ return change.kind === "none" ? "" : generateDiffString(change.before, change.after, 1).diff;
9
9
  }
10
10
 
11
11
  /** Register the five shared note operations; each one supplies Pi's session identity and nothing else. */
@@ -38,8 +38,6 @@ function isOverflowLike(message: AgentMessage, ctx: ExtensionContext): boolean {
38
38
 
39
39
  export type ResetRequest =
40
40
  | { readonly phase: "none" }
41
- // A hard-reserve reset may precede the end of Pi's tool-batch continuation.
42
- | { readonly phase: "stop-pending"; readonly windowId: string; readonly tool?: { readonly lastWord?: string } }
43
41
  | { readonly phase: "pending"; readonly windowId: string;
44
42
  readonly command?: { readonly continueAfterReset: boolean; readonly inputs?: readonly CarriedInput[] };
45
43
  readonly tool?: { readonly lastWord?: string } };
@@ -47,6 +45,8 @@ export type ResetOverflowPhase = "idle" | "pending" | "pending-spent" | "spent";
47
45
 
48
46
  export interface ResetControlState {
49
47
  readonly request: ResetRequest;
48
+ /** Await settlement after a safety reset; retain its intent to retry if it never committed. */
49
+ readonly stopAfterReset?: ResetBoundaryIntent;
50
50
  readonly overflow: ResetOverflowPhase;
51
51
  }
52
52
 
@@ -85,47 +85,48 @@ export type ResetControlEvent =
85
85
  | { readonly type: "turn_end"; readonly facts: ResetTurnEndFacts }
86
86
  | { readonly type: "before_settle"; readonly facts: ResetBeforeSettleFacts };
87
87
 
88
- export type ResetControlEffect =
89
- | "none"
90
- | "close-out-armed"
91
- | "already-pending"
92
- | "commit-boundary"
93
- | "commit-boundary-stop"
94
- | "stop"
95
- | "recover-overflow";
96
-
97
- export interface ResetControlResult {
98
- readonly state: ResetControlState;
99
- readonly effect: ResetControlEffect;
100
- readonly lastWord?: string;
101
- /** The origin of the boundary this decision commits. Absent means no `empty_brain` call was recorded, so forced. */
102
- readonly origin?: ResetOrigin;
88
+ /** Construction intent, not final state: handled inputs can still arrive while notes load. Only `turn-end`
89
+ * may latch a stop; overflow kinds spend recovery; only `overflow-recovery` carries passive run inputs. */
90
+ export interface ResetBoundaryIntent {
91
+ readonly effect: "build-boundary";
92
+ readonly boundary: "turn-end" | "settle" | "command-overflow" | "overflow-recovery";
93
+ readonly windowId: string;
94
+ readonly continueAfterReset: boolean;
95
+ readonly origin: ResetOrigin;
96
+ readonly tool?: { readonly lastWord?: string };
103
97
  }
104
98
 
99
+ export type ResetControlResult = ResetBoundaryIntent |
100
+ { readonly state: ResetControlState; readonly effect: "none" | "close-out-armed" | "already-pending" | "stop" };
101
+
105
102
  function requestForWindow(request: ResetRequest, windowId: string): ResetRequest {
106
- return request.phase === "stop-pending" || (request.phase !== "none" && request.windowId === windowId) ? request : NO_REQUEST;
103
+ return request.phase === "pending" && request.windowId === windowId ? request : NO_REQUEST;
107
104
  }
108
105
 
109
- function commandContinues(request: Extract<ResetRequest, { phase: "pending" }>): boolean {
110
- return request.command?.continueAfterReset === true || (request.command?.inputs?.length ?? 0) > 0;
111
- }
106
+ const spendsOverflow = (boundary: ResetBoundaryIntent["boundary"]) => boundary === "command-overflow" || boundary === "overflow-recovery";
112
107
 
113
- function commandCommit(request: Extract<ResetRequest, { phase: "pending" }>, overflow = false): ResetControlResult {
114
- return {
115
- state: { request: NO_REQUEST, overflow: overflow ? "spent" : "idle" },
116
- effect: commandContinues(request) ? "commit-boundary" : "commit-boundary-stop",
117
- ...requestDetails(request),
118
- ...(overflow ? { origin: "forced" as const } : {}),
119
- };
108
+ function boundaryIntent(request: ResetRequest, windowId: string, boundary: ResetBoundaryIntent["boundary"]): ResetBoundaryIntent {
109
+ const tool = request.phase === "none" ? undefined : request.tool;
110
+ const continueAfterReset = request.phase === "pending" ? request.command?.continueAfterReset ?? true : true;
111
+ return { effect: "build-boundary", boundary, windowId, tool, continueAfterReset, origin: spendsOverflow(boundary) || !tool ? "forced" : "normal" };
120
112
  }
121
113
 
122
- /** The tool request itself is the origin fact; the stop latch retains it for construction retry. */
123
- function requestDetails(request: ResetRequest): { origin: ResetOrigin; lastWord?: string } {
124
- const tool = request.phase === "none" ? undefined : request.tool;
125
- return { origin: tool ? "normal" : "forced", ...tool };
114
+ /** Resolve once, after a successful current build. No delivery policy is left to the adapter. */
115
+ export function finalizeResetBoundary(intent: ResetBoundaryIntent, request: ResetRequest, passiveInputs: readonly CarriedInput[] = []) {
116
+ const inputs = request.phase === "pending" && request.command ? request.command.inputs ?? []
117
+ : intent.boundary === "overflow-recovery" ? passiveInputs : [];
118
+ const resumeModel = intent.continueAfterReset || inputs.length > 0;
119
+ const state: ResetControlState = {
120
+ request: NO_REQUEST,
121
+ ...(intent.boundary === "turn-end" && !resumeModel ? { stopAfterReset: intent } : {}),
122
+ overflow: spendsOverflow(intent.boundary) ? "spent" : "idle",
123
+ };
124
+ return { state, inputs, resumeModel };
126
125
  }
127
126
 
128
127
  /** Pure transitions: command policy schedules a reset without disguising actual tool calls. */
128
+ export function reduceResetControl(state: ResetControlState, event: Extract<ResetControlEvent, { type: "input" | "command" | "tool_request" }>): Extract<ResetControlResult, { state: ResetControlState }>;
129
+ export function reduceResetControl(state: ResetControlState, event: ResetControlEvent): ResetControlResult;
129
130
  export function reduceResetControl(state: ResetControlState, event: ResetControlEvent): ResetControlResult {
130
131
  switch (event.type) {
131
132
  case "input": {
@@ -135,8 +136,8 @@ export function reduceResetControl(state: ResetControlState, event: ResetControl
135
136
  }
136
137
  case "command":
137
138
  case "tool_request": {
139
+ if (state.stopAfterReset) return { state, effect: "already-pending" };
138
140
  const current = requestForWindow(state.request, event.windowId);
139
- if (current.phase === "stop-pending") return { state, effect: "already-pending" };
140
141
  const request = current.phase === "pending" ? current : { phase: "pending" as const, windowId: event.windowId };
141
142
  if (event.type === "command") {
142
143
  if (request.command) return { state, effect: "already-pending" };
@@ -152,7 +153,7 @@ export function reduceResetControl(state: ResetControlState, event: ResetControl
152
153
  const facts = event.facts;
153
154
  const request = requestForWindow(state.request, facts.windowId);
154
155
  if (facts.aborted) return { state: initialResetControl(), effect: "none" };
155
- if (request.phase === "stop-pending") return { state: { request, overflow: "idle" }, effect: "none" };
156
+ if (state.stopAfterReset) return { state: { ...state, overflow: "idle" }, effect: "none" };
156
157
  const manual = request.phase === "pending" && request.command !== undefined;
157
158
  if (facts.overflow) {
158
159
  const pending = manual ? facts.enabled : !facts.queued && facts.enabled && facts.automaticResetEnabled;
@@ -169,9 +170,7 @@ export function reduceResetControl(state: ResetControlState, event: ResetControl
169
170
  // A direct tool request commits after the whole tool batch. The budget cutoff is
170
171
  // a separate hard-reserve safety path; ordinary close-out waits for settlement.
171
172
  if ((request.phase === "pending" && request.tool && !manual) || facts.hardReserveDue) {
172
- if (manual && commandContinues(request)) return commandCommit(request);
173
- if (manual) return { state: { request: { phase: "stop-pending", windowId: facts.windowId, ...(request.tool ? { tool: request.tool } : {}) }, overflow: "idle" }, effect: "commit-boundary-stop", ...requestDetails(request) };
174
- return { state: { request: NO_REQUEST, overflow: "idle" }, effect: "commit-boundary", ...requestDetails(request) };
173
+ return boundaryIntent(request, facts.windowId, "turn-end");
175
174
  }
176
175
  return { state: { request, overflow: "idle" }, effect: "none" };
177
176
  }
@@ -179,12 +178,12 @@ export function reduceResetControl(state: ResetControlState, event: ResetControl
179
178
  const facts = event.facts;
180
179
  if (facts.aborted) return { state: initialResetControl(), effect: "none" };
181
180
  const request = requestForWindow(state.request, facts.windowId);
182
- if (request.phase === "stop-pending") {
181
+ if (state.stopAfterReset) {
183
182
  if (facts.queued) return { state, effect: "none" };
184
- // Only retry construction if the safety boundary never committed. Otherwise
185
- // stop without a second wipe, even if a queued turn subsequently failed.
186
- if (request.windowId !== facts.windowId) return { state: initialResetControl(), effect: "stop" };
187
- return { state: initialResetControl(), effect: facts.failed || !facts.enabled ? "none" : "commit-boundary-stop", ...requestDetails(request) };
183
+ // A changed window confirms commit: stop without wiping twice. Otherwise retry.
184
+ if (state.stopAfterReset.windowId !== facts.windowId) return { state: initialResetControl(), effect: "stop" };
185
+ if (facts.failed || !facts.enabled) return { state: initialResetControl(), effect: "none" };
186
+ return { ...state.stopAfterReset, boundary: "settle" };
188
187
  }
189
188
  const manual = request.phase === "pending" && request.command !== undefined;
190
189
  if (state.overflow === "pending" || state.overflow === "pending-spent") {
@@ -193,18 +192,19 @@ export function reduceResetControl(state: ResetControlState, event: ResetControl
193
192
  }
194
193
  // An explicit manual wipe is not an automatic recovery/retry. It must still
195
194
  // clear on overflow, including when automatic reset is disabled.
196
- if (manual && facts.enabled) return commandCommit(request, true);
195
+ if (manual && facts.enabled) return boundaryIntent(request, facts.windowId, "command-overflow");
197
196
  const spent = state.overflow === "pending-spent";
198
197
  if (!facts.enabled || !facts.automaticResetEnabled) {
199
198
  return { state: { request: facts.failed ? NO_REQUEST : request, overflow: spent ? "spent" : "idle" }, effect: "none" };
200
199
  }
201
- return { state: { request: NO_REQUEST, overflow: "spent" }, effect: spent ? "none" : "recover-overflow", ...requestDetails(request) };
200
+ if (spent) return { state: { request: NO_REQUEST, overflow: "spent" }, effect: "none" };
201
+ return boundaryIntent(request, facts.windowId, "overflow-recovery");
202
202
  }
203
203
  if (facts.failed || !facts.enabled || !manual) {
204
204
  return { state: { ...state, request: NO_REQUEST }, effect: "none" };
205
205
  }
206
206
  if (facts.queued) return { state: { ...state, request }, effect: "none" };
207
- return commandCommit(request);
207
+ return boundaryIntent(request, facts.windowId, "settle");
208
208
  }
209
209
  }
210
210
  }
@@ -234,16 +234,15 @@ export function registerResetLifecycle(pi: ExtensionAPI, options: ResetOptions)
234
234
  runInputs.push(...inputs);
235
235
  };
236
236
  const clear = (preserveInputs = true) => {
237
+ lifecycleGeneration++;
237
238
  if (preserveInputs) restoreCommandInputs();
238
239
  control = initialResetControl();
239
240
  runInputs = [];
240
241
  commandId = undefined;
241
242
  };
242
- const resetBoundaryResult = async (entries: SessionBoundaryDraft[], ctx: ExtensionContext, decision: ResetControlResult) => {
243
+ const resetBoundaryResult = async (entries: SessionBoundaryDraft[], ctx: ExtensionContext, intent: ResetBoundaryIntent) => {
243
244
  // Keep command state live while notes load: input arriving during this await must
244
245
  // join this very boundary even if its steer cannot reach the closing model.
245
- const passiveInputs = decision.effect === "recover-overflow" ? runInputs : [];
246
- const origin = decision.origin ?? "forced";
247
246
  const generation = lifecycleGeneration;
248
247
  const outerGeneration = options.getLifecycleGeneration?.();
249
248
  const sessionId = ctx.sessionManager.getSessionId();
@@ -255,19 +254,17 @@ export function registerResetLifecycle(pi: ExtensionAPI, options: ResetOptions)
255
254
  const firstSeq = nextHistorySeq(ctx, entries) + 1;
256
255
  let resetDrafts: SessionBoundaryDraft[];
257
256
  try {
258
- resetDrafts = await options.buildReset(ctx, isCurrent, decision.lastWord, firstSeq, origin);
257
+ resetDrafts = await options.buildReset(ctx, isCurrent, intent.tool?.lastWord, firstSeq, intent.origin);
259
258
  } catch (error) {
260
259
  if (isCurrent()) ctx.ui.notify(`🥣 Brain still full: ${errorMessage(error)}`, "warning");
261
260
  return entries.length > 0 ? { entries } : undefined;
262
261
  }
263
262
  if (!isCurrent()) return entries.length > 0 ? { entries } : undefined;
264
- const request = control.request;
265
- const inputs = request.phase === "pending" && request.command ? request.command.inputs ?? [] : passiveInputs;
266
- control = decision.state;
267
- if (inputs.length > 0 && control.request.phase === "stop-pending") control = { ...control, request: NO_REQUEST };
263
+ const finalized = finalizeResetBoundary(intent, control.request, runInputs);
264
+ control = finalized.state;
268
265
  runInputs = [];
269
266
  options.onResetReady?.(ctx, resetDrafts);
270
- return { entries: [...entries, ...resetDrafts, ...carriedInputDrafts(inputs)], continue: inputs.length > 0 || decision.effect !== "commit-boundary-stop" };
267
+ return { entries: [...entries, ...resetDrafts, ...carriedInputDrafts(finalized.inputs)], continue: finalized.resumeModel };
271
268
  };
272
269
 
273
270
  // Pi may start multiple low-level loops while draining follow-ups/recovering.
@@ -304,9 +301,10 @@ export function registerResetLifecycle(pi: ExtensionAPI, options: ResetOptions)
304
301
  request.windowId === currentWindowId(ctx) && details?.windowId === request.windowId && commandId !== undefined && details?.commandId === commandId;
305
302
  });
306
303
  const filtered = messages.length === event.messages.length ? undefined : { messages };
307
- if (!sessionActive || request.phase !== "stop-pending" || ctx.hasPendingMessages()) return filtered;
304
+ const stop = control.stopAfterReset;
305
+ if (!sessionActive || !stop || ctx.hasPendingMessages()) return filtered;
308
306
  const marker = currentReset(ctx);
309
- if (!marker || marker.data.windowId === request.windowId || !resetBoundaryCommitted(ctx, marker.id, marker.data.windowId)) return filtered;
307
+ if (!marker || marker.data.windowId === stop.windowId || !resetBoundaryCommitted(ctx, marker.id, marker.data.windowId)) return filtered;
310
308
  const branch = ctx.sessionManager.getBranch();
311
309
  const markerIndex = branch.findIndex((entry) => entry.id === marker.id);
312
310
  if (branch.slice(markerIndex + 1).some((entry) => (entry.type === "message" && entry.message.role === "user") || isCarriedInputEntry(entry))) return filtered;
@@ -334,7 +332,7 @@ export function registerResetLifecycle(pi: ExtensionAPI, options: ResetOptions)
334
332
  get hardReserveDue() { return options.budget.hardReserveDue(ctx); },
335
333
  },
336
334
  });
337
- if (decision.effect === "commit-boundary" || decision.effect === "commit-boundary-stop") return await resetBoundaryResult(entries, ctx, decision);
335
+ if (decision.effect === "build-boundary") return await resetBoundaryResult(entries, ctx, decision);
338
336
  if (aborted || (event.outcome === "error" && decision.state.request.phase === "none")) restoreCommandInputs();
339
337
  control = decision.state;
340
338
  return entries.length > 0 ? { entries } : undefined;
@@ -353,7 +351,7 @@ export function registerResetLifecycle(pi: ExtensionAPI, options: ResetOptions)
353
351
  failed: event.outcome === "error",
354
352
  },
355
353
  });
356
- if (decision.effect === "commit-boundary" || decision.effect === "commit-boundary-stop" || decision.effect === "recover-overflow") return await resetBoundaryResult(event.entries, ctx, decision);
354
+ if (decision.effect === "build-boundary") return await resetBoundaryResult(event.entries, ctx, decision);
357
355
  if (decision.state.request.phase === "none") restoreCommandInputs();
358
356
  control = decision.state;
359
357
  if (decision.effect === "stop") return { entries: event.entries, continue: false };
@@ -379,9 +377,9 @@ export function registerResetLifecycle(pi: ExtensionAPI, options: ResetOptions)
379
377
  pi.on("agent_settled", () => {
380
378
  clear();
381
379
  });
382
- pi.on("session_start", () => { lifecycleGeneration++; clear(false); sessionActive = true; });
383
- pi.on("session_tree", () => { lifecycleGeneration++; clear(false); });
384
- pi.on("session_shutdown", () => { lifecycleGeneration++; clear(false); options.budget.clear(); sessionActive = false; });
380
+ pi.on("session_start", () => { clear(false); sessionActive = true; });
381
+ pi.on("session_tree", () => { clear(false); });
382
+ pi.on("session_shutdown", () => { clear(false); options.budget.clear(); sessionActive = false; });
385
383
 
386
384
  return {
387
385
  command(windowId: string, continueAfterReset: boolean, input?: CarriedInput) {