@ordewell/core 0.10.10 → 0.10.11

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
@@ -21628,9 +21628,11 @@ function plannerNotReadyFor(config) {
21628
21628
  var TERMINAL_UI_COMMANDS = {
21629
21629
  pickPlanner: "/planner",
21630
21630
  setKey: () => "/key",
21631
- setModel: "/model"
21631
+ // `/planner` walks harness, model and effort in one flow; there is no
21632
+ // separate `/model` (or `/planner-effort`) to point at.
21633
+ setModel: "/planner"
21632
21634
  };
21633
- var CHAT_COMMANDS = { ...TERMINAL_UI_COMMANDS, setModel: "/model set" };
21635
+ var CHAT_COMMANDS = { ...TERMINAL_UI_COMMANDS };
21634
21636
  var HEADLESS_CLI_COMMANDS = {
21635
21637
  pickPlanner: "ordewell planner <id>",
21636
21638
  setKey: (provider) => `ordewell key set ${provider} <key>`,
@@ -21644,7 +21646,7 @@ function harnessPlannerNames() {
21644
21646
  var PLANNER_ESCAPE_HINT = `or pick a coding agent with ${TERMINAL_UI_COMMANDS.pickPlanner}: it plans with no API key`;
21645
21647
  function describePlannerNotReady(reason, commands) {
21646
21648
  if (reason.code === "no_model") {
21647
- return `No planner model selected for ${reason.label}. Pick one with ${commands.setModel}, or switch planner with ${commands.pickPlanner}.`;
21649
+ return commands.setModel === commands.pickPlanner ? `No planner model selected for ${reason.label}. Pick one with ${commands.setModel}.` : `No planner model selected for ${reason.label}. Pick one with ${commands.setModel}, or switch planner with ${commands.pickPlanner}.`;
21648
21650
  }
21649
21651
  const lead = `No planner is ready. Pick one with ${commands.pickPlanner}: ${harnessPlannerNames()} plan with no API key.`;
21650
21652
  if (reason.code === "no_base_url") {
@@ -32377,6 +32379,9 @@ var StructuredSession = class extends AbstractRunnerSession {
32377
32379
  text;
32378
32380
  state = "idle";
32379
32381
  turn = null;
32382
+ /** A `task_complete` report waiting for its turn to close; the verdict is published then. */
32383
+ completionReport = null;
32384
+ completionTimer = null;
32380
32385
  /** A terminal event ends the turn before the adapter releases its send. */
32381
32386
  sending = null;
32382
32387
  turnCount = 0;
@@ -32435,7 +32440,9 @@ var StructuredSession = class extends AbstractRunnerSession {
32435
32440
  create: () => this.launch.createAdapter(this.launch.runner, this.launch.deps),
32436
32441
  issueToken: () => server4.issueTaskToken(scope, {
32437
32442
  taskComplete: async (report) => {
32438
- this.structuredEmitter.emit("taskComplete", report);
32443
+ this.completionReport = report;
32444
+ if (this.completionTimer) clearTimeout(this.completionTimer);
32445
+ this.completionTimer = setTimeout(() => this.flushCompletion(), this.launch.interruptGraceMs);
32439
32446
  return { text: "Recorded. End your turn now." };
32440
32447
  },
32441
32448
  checkpoint: async ({ question }, { signal }) => {
@@ -32467,6 +32474,8 @@ var StructuredSession = class extends AbstractRunnerSession {
32467
32474
  this.toolToken = null;
32468
32475
  }
32469
32476
  baseHandleExit(code) {
32477
+ this.undeliverQueued();
32478
+ this.flushCompletion();
32470
32479
  this.ended.abort();
32471
32480
  this.revokeTools();
32472
32481
  this.undeliverQueued();
@@ -32607,6 +32616,7 @@ var StructuredSession = class extends AbstractRunnerSession {
32607
32616
  * "waiting for input" between the two (F3).
32608
32617
  */
32609
32618
  force(message) {
32619
+ this.discardCompletion();
32610
32620
  message.forced = true;
32611
32621
  const at = this.queue.findIndex((m) => !m.forced);
32612
32622
  this.queue.splice(at < 0 ? this.queue.length : at, 0, message);
@@ -32748,6 +32758,7 @@ var StructuredSession = class extends AbstractRunnerSession {
32748
32758
  /** `message` is what opened the turn: a queued one has an id, one delivered straight from idle only its sender. */
32749
32759
  openTurn(text, message) {
32750
32760
  this.turnCount += 1;
32761
+ this.discardCompletion();
32751
32762
  const turn = { id: this.turnCount, abort: new AbortController(), ended: false, reason: "completed", steerRefused: false };
32752
32763
  this.turn = turn;
32753
32764
  this.state = "working";
@@ -32840,6 +32851,7 @@ var StructuredSession = class extends AbstractRunnerSession {
32840
32851
  } else if (event.type === "permission_request") this.openPermission(adapter, event);
32841
32852
  else if (event.type === "permission_cancelled") this.cancelPermission(adapter, event.id);
32842
32853
  else if (event.type === "message_delivered") {
32854
+ this.discardCompletion();
32843
32855
  const message = this.delivered(event.id);
32844
32856
  if (message) this.emitEvent({ type: "message_delivered", messageId: message.id, text: message.text, ...message.from ? { from: message.from } : {} });
32845
32857
  } else if (event.type === "message_dropped") {
@@ -32920,6 +32932,24 @@ var StructuredSession = class extends AbstractRunnerSession {
32920
32932
  }
32921
32933
  this.emitEvent(event);
32922
32934
  }
32935
+ /** Publish a `task_complete` report whose turn has closed, or that waited out the grace. */
32936
+ flushCompletion() {
32937
+ if (this.completionTimer) {
32938
+ clearTimeout(this.completionTimer);
32939
+ this.completionTimer = null;
32940
+ }
32941
+ const report = this.completionReport;
32942
+ this.completionReport = null;
32943
+ if (report) this.structuredEmitter.emit("taskComplete", report);
32944
+ }
32945
+ /** A message the runner reads, or a turn it opens, voids a report made before it (ADR-0023, D6). */
32946
+ discardCompletion() {
32947
+ if (this.completionTimer) {
32948
+ clearTimeout(this.completionTimer);
32949
+ this.completionTimer = null;
32950
+ }
32951
+ this.completionReport = null;
32952
+ }
32923
32953
  /**
32924
32954
  * A queued message goes out as the turn closes, and the state never passes
32925
32955
  * through `idle` on the way, so a listener told the turn ended can already
@@ -32932,6 +32962,7 @@ var StructuredSession = class extends AbstractRunnerSession {
32932
32962
  turn.ended = true;
32933
32963
  this.text.endTurn();
32934
32964
  this.emitEvent({ type: "turn_end", reason });
32965
+ this.flushCompletion();
32935
32966
  if (reason === "failed") this.undeliverQueued();
32936
32967
  this.state = !this.exited && this.queue.length ? "working" : "idle";
32937
32968
  this.structuredEmitter.emit("turnEnd", reason);