@ordewell/core 0.10.6 → 0.10.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.
package/dist/index.js CHANGED
@@ -21289,14 +21289,13 @@ var Supervisor = class {
21289
21289
  return { policy: this.policy.snapshot(), wakeUps: [...this.wakeUps] };
21290
21290
  }
21291
21291
  /**
21292
- * Put back a save's gathered state after a restart, and re-arm the debounce
21293
- * from when it was due, so a batch that was inside the window is delivered.
21292
+ * Keep a save's gathered state without waking the planner just because the
21293
+ * session was opened (ADR-0029). A new run event may arm it again.
21294
21294
  */
21295
21295
  restore(snapshot) {
21296
21296
  this.disarm();
21297
21297
  this.policy.restore(snapshot?.policy);
21298
21298
  this.wakeUps = [...snapshot?.wakeUps ?? []];
21299
- this.arm();
21300
21299
  }
21301
21300
  /**
21302
21301
  * A run started. One the user started gives its supervisor a clean record;
@@ -30847,14 +30846,11 @@ var PlannerResend = class {
30847
30846
  landed() {
30848
30847
  this.resentAt = null;
30849
30848
  }
30850
- /** A plan adopted off disk: re-arm the wait it saved. A time already past resends at once. */
30849
+ /** Loading a session preserves the inputs, without scheduling a model call. */
30851
30850
  restore() {
30852
30851
  this.reset();
30853
30852
  const saved = this.host.plan()?.plannerResend;
30854
- if (saved?.at === void 0) return;
30855
- const at = Date.parse(saved.at);
30856
- if (Number.isNaN(at)) delete saved.at;
30857
- else this.waits.arm(WAIT, new Date(at));
30853
+ if (saved) delete saved.at;
30858
30854
  }
30859
30855
  /** The plan is gone: nothing it waited on carries over. */
30860
30856
  reset() {
@@ -30925,6 +30921,8 @@ var PlanTurns = class {
30925
30921
  refusalTold = null;
30926
30922
  /** The user stopped the turn wake-ups waited behind: they wait for the next input to open one, not for the stop's release. */
30927
30923
  quiet = false;
30924
+ /** A loaded session stays idle even if an outgoing turn's release pumps the queue. */
30925
+ restored = false;
30928
30926
  seq = 0;
30929
30927
  resend;
30930
30928
  /** A turn ended on the planner's usage limit: arm the wait for its inputs. Saved with the failure the turn records. */
@@ -30949,8 +30947,9 @@ var PlanTurns = class {
30949
30947
  this.host.persist();
30950
30948
  for (const t of plan.pendingTurns) if (t.source === "user") this.settle(t.id, (w) => w.resolve(plan));
30951
30949
  }
30952
- /** A plan adopted off disk: the wait it saved is armed again. */
30950
+ /** A plan adopted off disk keeps its inputs until a new input asks for a turn. */
30953
30951
  restoreResend() {
30952
+ this.restored = true;
30954
30953
  this.resend.restore();
30955
30954
  }
30956
30955
  /** Whether a turn this module opened is in flight. */
@@ -30995,6 +30994,7 @@ var PlanTurns = class {
30995
30994
  const plan = this.host.plan();
30996
30995
  if (!plan) return Promise.reject(new Error("No planning conversation to continue"));
30997
30996
  const entry = this.pending(input, forced);
30997
+ this.restored = false;
30998
30998
  this.quiet = false;
30999
30999
  if (this.resend.arrived()) this.host.announce();
31000
31000
  const pending = plan.pendingTurns ?? [];
@@ -31024,14 +31024,14 @@ var PlanTurns = class {
31024
31024
  /**
31025
31025
  * Start the next turn if one is due: nothing of ours is in flight, the
31026
31026
  * conversation is free, and inputs wait. The host calls it when any planner
31027
- * turn lets the conversation go, and after a load, to replay what waited.
31027
+ * turn lets the conversation go. A loaded session waits for a new input.
31028
31028
  *
31029
31029
  * Every turn passes the planner gate here, whatever brought its input: it
31030
31030
  * waits for the installed-planner probe, then everything is judged afresh —
31031
31031
  * the plan, what still waits, and the planner in use at that moment.
31032
31032
  */
31033
31033
  pump() {
31034
- if (this.running || this.detecting || this.resend.holds()) return;
31034
+ if (this.restored || this.running || this.detecting || this.resend.holds()) return;
31035
31035
  const plan = this.host.plan();
31036
31036
  if (!plan || this.host.conversationBusy()) return;
31037
31037
  const batch = this.liveBatch(plan);
@@ -31115,6 +31115,7 @@ var PlanTurns = class {
31115
31115
  this.running?.release();
31116
31116
  this.running = null;
31117
31117
  this.quiet = false;
31118
+ this.restored = false;
31118
31119
  for (const waiter of this.waiters.values()) waiter.reject(new PlannerTurnDiscardedError());
31119
31120
  this.waiters.clear();
31120
31121
  }
@@ -35214,6 +35215,9 @@ var Session = class {
35214
35215
  }
35215
35216
  if (adopting) this.usage.restore(plan.plannerUsage);
35216
35217
  if (opts?.sessionId) this.currentSessionId = opts.sessionId;
35218
+ if (adopting) {
35219
+ for (const task of flattenTasks(plan.tasks)) delete task.resumeAt;
35220
+ }
35217
35221
  this.orchestrator.loadPlan(plan.tasks, plan.runners);
35218
35222
  this.syncPlanTasks();
35219
35223
  migratePlanStateIsolation(plan);
@@ -35228,7 +35232,6 @@ var Session = class {
35228
35232
  }
35229
35233
  if (opts?.persist !== false) this.persist();
35230
35234
  if (this.usage.hasUsage) this.broadcast(this.usage.message());
35231
- this.turns.pump();
35232
35235
  }
35233
35236
  destroy() {
35234
35237
  this.closed = true;