@ordewell/core 0.10.6 → 0.10.7

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.mjs CHANGED
@@ -18082,14 +18082,13 @@ var Supervisor = class {
18082
18082
  return { policy: this.policy.snapshot(), wakeUps: [...this.wakeUps] };
18083
18083
  }
18084
18084
  /**
18085
- * Put back a save's gathered state after a restart, and re-arm the debounce
18086
- * from when it was due, so a batch that was inside the window is delivered.
18085
+ * Keep a save's gathered state without waking the planner just because the
18086
+ * session was opened (ADR-0029). A new run event may arm it again.
18087
18087
  */
18088
18088
  restore(snapshot) {
18089
18089
  this.disarm();
18090
18090
  this.policy.restore(snapshot?.policy);
18091
18091
  this.wakeUps = [...snapshot?.wakeUps ?? []];
18092
- this.arm();
18093
18092
  }
18094
18093
  /**
18095
18094
  * A run started. One the user started gives its supervisor a clean record;
@@ -27568,14 +27567,11 @@ var PlannerResend = class {
27568
27567
  landed() {
27569
27568
  this.resentAt = null;
27570
27569
  }
27571
- /** A plan adopted off disk: re-arm the wait it saved. A time already past resends at once. */
27570
+ /** Loading a session preserves the inputs, without scheduling a model call. */
27572
27571
  restore() {
27573
27572
  this.reset();
27574
27573
  const saved = this.host.plan()?.plannerResend;
27575
- if (saved?.at === void 0) return;
27576
- const at = Date.parse(saved.at);
27577
- if (Number.isNaN(at)) delete saved.at;
27578
- else this.waits.arm(WAIT, new Date(at));
27574
+ if (saved) delete saved.at;
27579
27575
  }
27580
27576
  /** The plan is gone: nothing it waited on carries over. */
27581
27577
  reset() {
@@ -27646,6 +27642,8 @@ var PlanTurns = class {
27646
27642
  refusalTold = null;
27647
27643
  /** The user stopped the turn wake-ups waited behind: they wait for the next input to open one, not for the stop's release. */
27648
27644
  quiet = false;
27645
+ /** A loaded session stays idle even if an outgoing turn's release pumps the queue. */
27646
+ restored = false;
27649
27647
  seq = 0;
27650
27648
  resend;
27651
27649
  /** A turn ended on the planner's usage limit: arm the wait for its inputs. Saved with the failure the turn records. */
@@ -27670,8 +27668,9 @@ var PlanTurns = class {
27670
27668
  this.host.persist();
27671
27669
  for (const t of plan.pendingTurns) if (t.source === "user") this.settle(t.id, (w) => w.resolve(plan));
27672
27670
  }
27673
- /** A plan adopted off disk: the wait it saved is armed again. */
27671
+ /** A plan adopted off disk keeps its inputs until a new input asks for a turn. */
27674
27672
  restoreResend() {
27673
+ this.restored = true;
27675
27674
  this.resend.restore();
27676
27675
  }
27677
27676
  /** Whether a turn this module opened is in flight. */
@@ -27716,6 +27715,7 @@ var PlanTurns = class {
27716
27715
  const plan = this.host.plan();
27717
27716
  if (!plan) return Promise.reject(new Error("No planning conversation to continue"));
27718
27717
  const entry = this.pending(input, forced);
27718
+ this.restored = false;
27719
27719
  this.quiet = false;
27720
27720
  if (this.resend.arrived()) this.host.announce();
27721
27721
  const pending = plan.pendingTurns ?? [];
@@ -27745,14 +27745,14 @@ var PlanTurns = class {
27745
27745
  /**
27746
27746
  * Start the next turn if one is due: nothing of ours is in flight, the
27747
27747
  * conversation is free, and inputs wait. The host calls it when any planner
27748
- * turn lets the conversation go, and after a load, to replay what waited.
27748
+ * turn lets the conversation go. A loaded session waits for a new input.
27749
27749
  *
27750
27750
  * Every turn passes the planner gate here, whatever brought its input: it
27751
27751
  * waits for the installed-planner probe, then everything is judged afresh —
27752
27752
  * the plan, what still waits, and the planner in use at that moment.
27753
27753
  */
27754
27754
  pump() {
27755
- if (this.running || this.detecting || this.resend.holds()) return;
27755
+ if (this.restored || this.running || this.detecting || this.resend.holds()) return;
27756
27756
  const plan = this.host.plan();
27757
27757
  if (!plan || this.host.conversationBusy()) return;
27758
27758
  const batch = this.liveBatch(plan);
@@ -27836,6 +27836,7 @@ var PlanTurns = class {
27836
27836
  this.running?.release();
27837
27837
  this.running = null;
27838
27838
  this.quiet = false;
27839
+ this.restored = false;
27839
27840
  for (const waiter of this.waiters.values()) waiter.reject(new PlannerTurnDiscardedError());
27840
27841
  this.waiters.clear();
27841
27842
  }
@@ -31769,6 +31770,9 @@ var Session = class {
31769
31770
  }
31770
31771
  if (adopting) this.usage.restore(plan.plannerUsage);
31771
31772
  if (opts?.sessionId) this.currentSessionId = opts.sessionId;
31773
+ if (adopting) {
31774
+ for (const task of flattenTasks(plan.tasks)) delete task.resumeAt;
31775
+ }
31772
31776
  this.orchestrator.loadPlan(plan.tasks, plan.runners);
31773
31777
  this.syncPlanTasks();
31774
31778
  migratePlanStateIsolation(plan);
@@ -31783,7 +31787,6 @@ var Session = class {
31783
31787
  }
31784
31788
  if (opts?.persist !== false) this.persist();
31785
31789
  if (this.usage.hasUsage) this.broadcast(this.usage.message());
31786
- this.turns.pump();
31787
31790
  }
31788
31791
  destroy() {
31789
31792
  this.closed = true;