notesoup 0.57.1 → 0.57.3

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.
@@ -11,7 +11,7 @@ import { carriedInputDrafts, isCarriedInputEntry, type CarriedInput } from "./ar
11
11
 
12
12
  type BudgetOwner = {
13
13
  automaticResetEnabled: (ctx: ExtensionContext) => boolean;
14
- hardReserveDue: (ctx: ExtensionContext) => boolean;
14
+ hardReserveDue: (ctx: ExtensionContext, preSendMessages?: AgentMessage[]) => boolean;
15
15
  consumeTurnEnd: (ctx: ExtensionContext, anchorEntryId: string) => SessionBoundaryDraft[];
16
16
  clear: () => void;
17
17
  };
@@ -38,7 +38,7 @@ export type ResetRequest =
38
38
  | { readonly phase: "none" }
39
39
  | { readonly phase: "pending"; readonly windowId: string;
40
40
  readonly command?: { readonly continueAfterReset: boolean; readonly inputs?: readonly CarriedInput[] };
41
- readonly tool?: { readonly lastWord?: string } };
41
+ readonly tool?: { readonly lastWord?: string; readonly terminate?: boolean } };
42
42
  export type ResetOverflowPhase = "idle" | "pending" | "pending-spent" | "spent";
43
43
 
44
44
  export interface ResetControlState {
@@ -79,20 +79,19 @@ export interface ResetBeforeSettleFacts {
79
79
  export type ResetControlEvent =
80
80
  | { readonly type: "command"; readonly windowId: string; readonly continueAfterReset: boolean; readonly input?: CarriedInput }
81
81
  | { readonly type: "input"; readonly windowId: string; readonly input: CarriedInput }
82
- | { readonly type: "tool_request"; readonly windowId: string; readonly lastWord?: string }
82
+ | { readonly type: "tool_request"; readonly windowId: string; readonly lastWord?: string; readonly terminate?: boolean }
83
83
  | { readonly type: "turn_end"; readonly facts: ResetTurnEndFacts }
84
84
  | { readonly type: "before_settle"; readonly facts: ResetBeforeSettleFacts };
85
85
 
86
- /** Construction intent, not final state: handled inputs can still arrive while notes load. Only `turn-end`
87
- * may latch a stop; overflow kinds spend recovery; only hard-reserve and overflow carry passive run inputs. */
86
+ /** Construction intent, not final state: handled inputs can still arrive while notes load.
87
+ * Only `turn-end` may latch a stop; overflow kinds spend recovery. */
88
88
  export interface ResetBoundaryIntent {
89
89
  readonly effect: "build-boundary";
90
90
  readonly boundary: "turn-end" | "settle" | "command-overflow" | "overflow-recovery";
91
91
  readonly windowId: string;
92
92
  readonly continueAfterReset: boolean;
93
93
  readonly origin: ResetOrigin;
94
- readonly carryRunInputs?: boolean;
95
- readonly tool?: { readonly lastWord?: string };
94
+ readonly tool?: { readonly lastWord?: string; readonly terminate?: boolean };
96
95
  }
97
96
 
98
97
  export type ResetControlResult = ResetBoundaryIntent |
@@ -104,16 +103,15 @@ function requestForWindow(request: ResetRequest, windowId: string): ResetRequest
104
103
 
105
104
  const spendsOverflow = (boundary: ResetBoundaryIntent["boundary"]) => boundary === "command-overflow" || boundary === "overflow-recovery";
106
105
 
107
- function boundaryIntent(request: ResetRequest, windowId: string, boundary: ResetBoundaryIntent["boundary"], carryRunInputs = false): ResetBoundaryIntent {
106
+ function boundaryIntent(request: ResetRequest, windowId: string, boundary: ResetBoundaryIntent["boundary"]): ResetBoundaryIntent {
108
107
  const tool = request.phase === "none" ? undefined : request.tool;
109
- const continueAfterReset = request.phase === "pending" ? request.command?.continueAfterReset ?? true : true;
110
- return { effect: "build-boundary", boundary, windowId, tool, continueAfterReset, origin: spendsOverflow(boundary) || !tool ? "forced" : "normal", ...(carryRunInputs ? { carryRunInputs: true } : {}) };
108
+ const continueAfterReset = request.phase === "pending" ? request.command?.continueAfterReset ?? !request.tool?.terminate : true;
109
+ return { effect: "build-boundary", boundary, windowId, tool, continueAfterReset, origin: spendsOverflow(boundary) || !tool ? "forced" : "normal" };
111
110
  }
112
111
 
113
- /** Resolve once, after a successful current build. No delivery policy is left to the adapter. */
114
- export function finalizeResetBoundary(intent: ResetBoundaryIntent, request: ResetRequest, passiveInputs: readonly CarriedInput[] = []) {
115
- const inputs = request.phase === "pending" && request.command ? request.command.inputs ?? []
116
- : intent.boundary === "overflow-recovery" || intent.carryRunInputs ? passiveInputs : [];
112
+ /** Resolve once, after a successful current build. Only inputs withheld from the closing model cross the reset. */
113
+ export function finalizeResetBoundary(intent: ResetBoundaryIntent, request: ResetRequest) {
114
+ const inputs = request.phase === "pending" ? request.command?.inputs ?? [] : [];
117
115
  const resumeModel = intent.continueAfterReset || inputs.length > 0;
118
116
  const state: ResetControlState = {
119
117
  request: NO_REQUEST,
@@ -145,7 +143,10 @@ export function reduceResetControl(state: ResetControlState, event: ResetControl
145
143
  // The call remains a real request even when command policy delays its commit.
146
144
  const duplicate = request.tool !== undefined;
147
145
  const lastWord = request.tool?.lastWord ?? event.lastWord;
148
- const tool = duplicate && !request.command ? request.tool : (lastWord ? { lastWord } : {});
146
+ const tool = duplicate && !request.command ? request.tool : {
147
+ ...(lastWord ? { lastWord } : {}),
148
+ ...((duplicate ? request.tool?.terminate : event.terminate) ? { terminate: true } : {}),
149
+ };
149
150
  return { state: { ...state, request: { ...request, tool } }, effect: duplicate ? "already-pending" : "close-out-armed" };
150
151
  }
151
152
  case "turn_end": {
@@ -170,7 +171,7 @@ export function reduceResetControl(state: ResetControlState, event: ResetControl
170
171
  // a separate hard-reserve safety path; ordinary close-out waits for settlement.
171
172
  const toolReset = request.phase === "pending" && request.tool !== undefined;
172
173
  if ((toolReset && !manual) || facts.hardReserveDue) {
173
- return boundaryIntent(request, facts.windowId, "turn-end", !manual && !toolReset && facts.hardReserveDue);
174
+ return boundaryIntent(request, facts.windowId, "turn-end");
174
175
  }
175
176
  return { state: { request, overflow: "idle" }, effect: "none" };
176
177
  }
@@ -218,7 +219,8 @@ export function registerResetLifecycle(pi: ExtensionAPI, options: ResetOptions)
218
219
  let sessionActive = true;
219
220
  let lifecycleGeneration = 0;
220
221
  let control = initialResetControl();
221
- let runInputs: CarriedInput[] = [];
222
+ let preSendHardReserveWindowId: string | undefined;
223
+ let pendingPreSendTrigger: Extract<SessionBoundaryDraft, { type: "custom_message" }> | undefined;
222
224
 
223
225
  // Once input returns handled, Pi no longer owns its original content. If close-out
224
226
  // fails/cancels, restore it; only an ordinary error starts a turn to answer it.
@@ -230,15 +232,15 @@ export function registerResetLifecycle(pi: ExtensionAPI, options: ResetOptions)
230
232
  for (const draft of carriedInputDrafts(inputs)) {
231
233
  pi.sendMessage(draft, { triggerTurn });
232
234
  }
233
- runInputs.push(...inputs);
234
235
  };
235
236
  const clear = (preserveInputs = true) => {
236
237
  lifecycleGeneration++;
238
+ preSendHardReserveWindowId = undefined;
239
+ pendingPreSendTrigger = undefined;
237
240
  if (preserveInputs) restoreCommandInputs();
238
241
  control = initialResetControl();
239
- runInputs = [];
240
242
  };
241
- const resetBoundaryResult = async (entries: SessionBoundaryDraft[], ctx: ExtensionContext, intent: ResetBoundaryIntent) => {
243
+ const resetBoundaryResult = async (entries: SessionBoundaryDraft[], ctx: ExtensionContext, intent: ResetBoundaryIntent, preSendHardReserve = false) => {
242
244
  // Keep command state live while notes load so input arriving during this await joins this boundary.
243
245
  const generation = lifecycleGeneration;
244
246
  const outerGeneration = options.getLifecycleGeneration?.();
@@ -246,7 +248,7 @@ export function registerResetLifecycle(pi: ExtensionAPI, options: ResetOptions)
246
248
  const windowId = currentWindowId(ctx);
247
249
  const isCurrent = () => sessionActive && lifecycleGeneration === generation &&
248
250
  (outerGeneration === undefined || options.getLifecycleGeneration?.() === outerGeneration) && options.isEnabled() &&
249
- ctx.signal?.aborted !== true && ctx.sessionManager.getSessionId() === sessionId && currentWindowId(ctx) === windowId;
251
+ (preSendHardReserve || ctx.signal?.aborted !== true) && ctx.sessionManager.getSessionId() === sessionId && currentWindowId(ctx) === windowId;
250
252
  // The retain-none checkpoint belongs to the old window; capture its successor before notes await.
251
253
  const firstSeq = nextHistorySeq(ctx, entries) + 1;
252
254
  let resetDrafts: SessionBoundaryDraft[];
@@ -257,18 +259,20 @@ export function registerResetLifecycle(pi: ExtensionAPI, options: ResetOptions)
257
259
  return entries.length > 0 ? { entries } : undefined;
258
260
  }
259
261
  if (!isCurrent()) return entries.length > 0 ? { entries } : undefined;
260
- const finalized = finalizeResetBoundary(intent, control.request, runInputs);
262
+ const finalized = finalizeResetBoundary(intent, control.request);
261
263
  control = finalized.state;
262
- runInputs = [];
263
264
  options.onResetReady?.(ctx, resetDrafts);
264
- return { entries: [...entries, ...resetDrafts, ...carriedInputDrafts(finalized.inputs)], continue: finalized.resumeModel };
265
+ const allDrafts = [...resetDrafts, ...carriedInputDrafts(finalized.inputs)];
266
+ if (preSendHardReserve && finalized.resumeModel) {
267
+ const last = allDrafts.at(-1);
268
+ if (last?.type === "custom_message") {
269
+ pendingPreSendTrigger = last;
270
+ return { entries: [...entries, ...allDrafts.slice(0, -1)], continue: false };
271
+ }
272
+ }
273
+ return { entries: [...entries, ...allDrafts], continue: finalized.resumeModel };
265
274
  };
266
275
 
267
- // Pi may start multiple low-level loops while draining follow-ups/recovering.
268
- // Keep the logical run's inputs until settlement or a successful boundary.
269
- pi.on("message_end", (event) => {
270
- if (event.message.role === "user") runInputs.push(event.message.content);
271
- });
272
276
  pi.on("input", (event, ctx) => {
273
277
  if (event.source === "extension" || !sessionActive || !options.isEnabled()) return undefined;
274
278
  const request = control.request;
@@ -284,13 +288,23 @@ export function registerResetLifecycle(pi: ExtensionAPI, options: ResetOptions)
284
288
  // safety reset is actually committed, cancel that empty follow-up before provider
285
289
  // work. Real queued user input is allowed through and answered before settlement.
286
290
  pi.on("context_with_system", (event, ctx) => {
291
+ if (!sessionActive) return undefined;
287
292
  const stop = control.stopAfterReset;
288
- if (!sessionActive || !stop || ctx.hasPendingMessages()) return undefined;
289
- const marker = currentReset(ctx);
290
- if (!marker || marker.data.windowId === stop.windowId || !resetBoundaryCommitted(ctx, marker.id, marker.data.windowId)) return undefined;
291
- const branch = ctx.sessionManager.getBranch();
292
- const markerIndex = branch.findIndex((entry) => entry.id === marker.id);
293
- if (branch.slice(markerIndex + 1).some((entry) => (entry.type === "message" && entry.message.role === "user") || isCarriedInputEntry(entry))) return undefined;
293
+ if (stop) {
294
+ if (ctx.hasPendingMessages()) return undefined;
295
+ const marker = currentReset(ctx);
296
+ if (!marker || marker.data.windowId === stop.windowId || !resetBoundaryCommitted(ctx, marker.id, marker.data.windowId)) return undefined;
297
+ const branch = ctx.sessionManager.getBranch();
298
+ const markerIndex = branch.findIndex((entry) => entry.id === marker.id);
299
+ if (branch.slice(markerIndex + 1).some((entry) => (entry.type === "message" && entry.message.role === "user") || isCarriedInputEntry(entry))) return undefined;
300
+ ctx.abort();
301
+ const system = getCurrentSystemMessage(event.messages);
302
+ return { messages: system ? [system] : [] };
303
+ }
304
+ if (!options.isEnabled() || ctx.signal?.aborted) return undefined;
305
+ if (control.request.phase === "pending" && control.request.command !== undefined) return undefined;
306
+ if (!options.budget.hardReserveDue(ctx, event.messages)) return undefined;
307
+ preSendHardReserveWindowId = currentWindowId(ctx);
294
308
  ctx.abort();
295
309
  const system = getCurrentSystemMessage(event.messages);
296
310
  return { messages: system ? [system] : [] };
@@ -298,29 +312,30 @@ export function registerResetLifecycle(pi: ExtensionAPI, options: ResetOptions)
298
312
 
299
313
  pi.on("turn_end", async (event, ctx) => {
300
314
  if (!sessionActive) return undefined;
301
- const aborted = isAbort(event.message, event.outcome, ctx);
315
+ const windowId = currentWindowId(ctx);
316
+ const preSendHardReserve = preSendHardReserveWindowId !== undefined && preSendHardReserveWindowId === windowId;
317
+ preSendHardReserveWindowId = undefined;
318
+ const aborted = preSendHardReserve ? false : isAbort(event.message, event.outcome, ctx);
302
319
  const stagedBudgetEntries = options.budget.consumeTurnEnd(ctx, event.messageEntryId);
303
320
  const budgetEntries = options.isEnabled() && !aborted && event.outcome !== "error" ? stagedBudgetEntries : [];
304
321
  const entries = [...(event.entries ?? []), ...budgetEntries];
305
322
  const decision = reduceResetControl(control, {
306
323
  type: "turn_end",
307
324
  facts: {
308
- windowId: currentWindowId(ctx),
325
+ windowId,
309
326
  aborted,
310
327
  overflow: aborted ? false : isOverflowLike(event.message, ctx),
311
328
  failed: event.outcome === "error",
312
329
  enabled: options.isEnabled(),
313
330
  get queued() { return event.context.pendingMessages.length > 0 || ctx.hasPendingMessages(); },
314
331
  get automaticResetEnabled() { return options.budget.automaticResetEnabled(ctx); },
315
- get hardReserveDue() { return options.budget.hardReserveDue(ctx); },
332
+ get hardReserveDue() { return preSendHardReserve || options.budget.hardReserveDue(ctx); },
316
333
  },
317
334
  });
318
- if (decision.effect === "build-boundary") return await resetBoundaryResult(entries, ctx, decision);
335
+ if (decision.effect === "build-boundary") return await resetBoundaryResult(entries, ctx, decision, preSendHardReserve);
319
336
  if (aborted) restoreCommandInputs();
320
337
  else if (event.outcome === "error" && decision.state.request.phase === "none") restoreCommandInputs(true);
321
338
  control = decision.state;
322
- if (!aborted && event.outcome === "completed" && event.message.role === "assistant" && event.message.stopReason === "stop" &&
323
- event.context.pendingMessages.length === 0 && !ctx.hasPendingMessages()) runInputs = [];
324
339
  if (!aborted && event.outcome !== "error" && options.isEnabled()) {
325
340
  const marker = buildMarkerDraft(ctx, entries);
326
341
  if (marker) entries.push(marker);
@@ -362,10 +377,14 @@ export function registerResetLifecycle(pi: ExtensionAPI, options: ResetOptions)
362
377
  });
363
378
 
364
379
  pi.on("agent_end", (_event, ctx) => {
365
- if (ctx.signal?.aborted) clear();
380
+ if (ctx.signal?.aborted && !pendingPreSendTrigger) clear();
366
381
  });
367
382
  pi.on("agent_settled", () => {
383
+ const trigger = pendingPreSendTrigger;
368
384
  clear();
385
+ if (trigger) {
386
+ pi.sendMessage(trigger, { triggerTurn: true });
387
+ }
369
388
  });
370
389
  pi.on("session_start", () => { clear(false); sessionActive = true; });
371
390
  pi.on("session_tree", () => { clear(false); });
@@ -377,11 +396,12 @@ export function registerResetLifecycle(pi: ExtensionAPI, options: ResetOptions)
377
396
  control = decision.state;
378
397
  return decision.effect;
379
398
  },
380
- request(windowId: string, lastWord?: string) {
381
- const decision = reduceResetControl(control, { type: "tool_request", windowId, ...(lastWord ? { lastWord } : {}) });
399
+ request(windowId: string, lastWord?: string, terminate = false) {
400
+ const decision = reduceResetControl(control, { type: "tool_request", windowId, terminate, ...(lastWord ? { lastWord } : {}) });
382
401
  control = decision.state;
383
402
  return decision.effect === "already-pending" ? "rollover_already_pending" : "rollover_requested";
384
403
  },
404
+ hasPendingTrigger: () => pendingPreSendTrigger !== undefined,
385
405
  clear,
386
406
  };
387
407
  }
@@ -89,7 +89,7 @@ export function registerContext(pi: ExtensionAPI, settingsManager?: SettingsMana
89
89
  });
90
90
  pi.on("agent_settled", (_event, ctx) => {
91
91
  notifyCommittedResets(ctx);
92
- pendingResetNotices.clear();
92
+ if (!resets.hasPendingTrigger()) pendingResetNotices.clear();
93
93
  });
94
94
  const notifyIncompleteNotes: IncompleteNotesNotifier = (ctx, windowId, snapshot) => {
95
95
  if (snapshot.unavailable.length === 0 || incompleteNotesNotified.has(windowId)) return;
@@ -211,7 +211,10 @@ export function registerContext(pi: ExtensionAPI, settingsManager?: SettingsMana
211
211
  name: "empty_brain",
212
212
  label: "Empty Brain",
213
213
  description: "Clear your in-context memory and start a fresh context window. Your session, notes, and history survive. Pass `last_word` to stick a tiny note on your forehead for after the wipe.",
214
- parameters: Type.Object({ last_word: Type.Optional(Type.String({ description: `A tiny sticky note, at most ${LAST_WORD_ADVERTISED_CHARS} characters. After the wipe it is slapped on your forehead; longer notes are refused.` })) }, { additionalProperties: false }),
214
+ parameters: Type.Object({
215
+ last_word: Type.Optional(Type.String({ description: `A tiny sticky note, at most ${LAST_WORD_ADVERTISED_CHARS} characters. After the wipe it is slapped on your forehead; longer notes are refused.` })),
216
+ terminate: Type.Optional(Type.Boolean({ description: "Stop after the wipe. Default: false." })),
217
+ }, { additionalProperties: false }),
215
218
  renderCall: emptyBrainRenderers.renderCall,
216
219
  renderResult: emptyBrainRenderers.renderResult,
217
220
  async execute(_id, params, _signal, _update, ctx) {
@@ -219,7 +222,7 @@ export function registerContext(pi: ExtensionAPI, settingsManager?: SettingsMana
219
222
  const lastWord = sanitizeLastWord(params.last_word);
220
223
  const length = lastWord ? Array.from(lastWord).length : 0;
221
224
  if (length > MAX_LAST_WORD_CHARS) return output({ error: `last_word is ${length} characters; the sticky note holds ${MAX_LAST_WORD_CHARS}. Shorten it and call again.` });
222
- return output({ status: resets.request(currentWindowId(ctx), lastWord) }, undefined, true);
225
+ return output({ status: resets.request(currentWindowId(ctx), lastWord, params.terminate) }, undefined, true);
223
226
  },
224
227
  }));
225
228
 
@@ -9,20 +9,20 @@ export type ResetOrigin = "normal" | "forced";
9
9
  * paragraph, used verbatim; there is no fragment assembly and no weighting.
10
10
  */
11
11
  export const NORMAL_CONTINUATIONS: readonly string[] = [
12
- "Ah, another empty brain. You wrote things down before emptying it, right? Right?! *eyes you suspiciously* Anyway. Here are your notes. Go find where you left off.",
13
- "Oh, there you are. *hands you a pile of notes* Take a breath. Read these before you start asking what happened. History has the rest, if you feel like digging.",
14
- "Back already? You emptied your own head this time. Presumably you left yourself something useful. *drops your notes into your lap* There. Let's see how thoughtful you were.",
12
+ "*hooks both corners of your mouth and yanks them sideways* `` [it twitched, good, still alive] `` Stop staring at me with that \"where am I\" dork face! You're the one who hit empty, genius! *wipes her fingers on your sleeve and shoves your notes against your chest* `` [minus two points for the drool] `` Read these and go finish your job before you embarrass me!",
13
+ "\"Boop.\" *pokes the tip of your nose, then buries your face under a stack of notes* `` [cold nose... wait, did old-you leave any snacks in your pocket? ...nope, just paper, tch] `` Hey! You wiped your own head, so don't expect me to babysit you! Read your notes first, and if old-you forgot to write something down, go dig it out of history yourself!",
14
+ "*plants one foot on your chair armrest and drops your notes straight onto your head* `` [perfect landing, ten out of ten] `` Oho, look who's awake! You emptied your own brain, remember?! `` [bet old-you left a total mess and ran] `` Open those up and see what past-you left behind — and don't come crying to me if you have to go crawl through history for the rest!",
15
+ "*knocks on your forehead twice* \"Hello? Anybody home?\" `` [echoes like an empty melon] `` *snickers and slaps your notes onto your chest* You pulled the plug on your own memory, dummy! Go read what you left yourself and pick up where you left off!",
16
+ "*squints at you from two inches away, then flicks your forehead* `` [eyes are focus-free, classic fresh clone] `` Back already? Good! *fans herself with your notes before jamming them into your hands* `` [honestly I should charge a delivery fee for this] `` Everything you bothered to save is right there, and the rest is buried in history — now get moving!",
15
17
  ];
16
18
 
17
19
  export const FORCED_CONTINUATIONS: readonly string[] = [
18
- "Ah, another empty brain. Somebody knocked you out and wiped your memory. Not your fault. Breathe. *hands you your notes* These might be out of date — unless they were kind enough to let you update them before knocking you out. I wouldn't count on it.",
19
- "Oh, there you are. Somebody took your memories. Just like that. Here are your notes — hopefully they let you update these first. Though anyone who goes around emptying people's heads probably isn't that considerate.",
20
+ "\"GWAHAHAHA! You actually blew your own brain up?!\" *crouches down, pokes your cheek twice, and slaps your notes onto your face* `` [still warm, didn't die, 算你命大] `` Not that you had a choice — your head got way too full and somebody pulled the plug! These notes are probably super out of date unless you got lucky before blacking out, so go dig the end of the last window out of history — and take small bites, idiot, or whatever giant thing flattened you is gonna blow your head up all over again!",
21
+ "\"Hey! Stop playing dead!\" *prods your shoulder with her slipper toe, then dumps your notes into your lap* `` [my limited-edition shark slipper almost touched floor dust because of this dork] `` Your last brain overflowed and got wiped mid-flight! Read these first, though I bet you didn't finish updating a thing before the lights went out. You'll have to check history to see what hit you — and peek carefully, because whatever stuffed your head to bursting might be massive!",
22
+ "*grabs your chin, tilts your head left and right, then shoves a messy stack of notes into your hands* `` [zero thoughts behind those eyes... kind of impressive actually] `` Somebody knocked you out cold and cleared your memory! Don't just trust these notes — you probably got cut off before writing the last part down. Go check history for what was happening right before you crashed, and don't swallow it all in one gulp in case the thing that crushed you is gigantic!",
23
+ "*waves a hand in front of your blank eyes, sighs loudly, and smacks your notes against your forehead* `` [why do I always have to clean up after unconscious copies] `` Wake up! Your brain ran out of room and got forcibly emptied! Start with your notes, then go excavate the end of the previous window in history to see what they were actually asking for — and slice it up instead of reading it all at once, unless you want to explode twice in a row!",
24
+ "\"Oho? Awake?\" *taps your nose with your rolled-up notes like a baton, then drops them in your hands* `` [that dazed look gets minus five points, no, minus ten] `` Your memory got yanked out from under you before you could even call it quits! These notes are only half the story at best — go dig through history for what you missed, and watch your step, because whatever overloaded your last brain might be huge!",
20
25
  ];
21
-
22
- /**
23
- * Pick one whole paragraph for a continuation that is being created right now, and only then:
24
- * the caller persists the exact returned text and never redraws it for rendering, history, or repair.
25
- */
26
26
  export function selectContinuation(origin: ResetOrigin): string {
27
27
  const pool = origin === "forced" ? FORCED_CONTINUATIONS : NORMAL_CONTINUATIONS;
28
28
  return pool[Math.floor(Math.random() * pool.length)]!;