@tekmidian/pai 0.14.0 → 0.14.1

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.
@@ -6,7 +6,7 @@ import "../db-CmYbAVCD.mjs";
6
6
  import "../helpers-IjZkXBhj.mjs";
7
7
  import "../embeddings-BJPOcbik.mjs";
8
8
  import "../search-HcdKtMla.mjs";
9
- import "../pick-DxS6p2vI.mjs";
9
+ import "../pick-BPlB38eB.mjs";
10
10
  import "../kg-extraction-C8DEUHTS.mjs";
11
11
  import "../factory-Q88X1bAN.mjs";
12
12
  import "../config-C8m-tPhP.mjs";
@@ -5,7 +5,7 @@ import "../db-CmYbAVCD.mjs";
5
5
  import "../helpers-IjZkXBhj.mjs";
6
6
  import "../embeddings-BJPOcbik.mjs";
7
7
  import "../search-HcdKtMla.mjs";
8
- import { C as registerDaemonCommands, D as registerProjectsCommands, E as registerRegistryCommands, O as findMovedPath, S as registerBackupCommands, T as registerMemoryCommands, _ as registerObservationCommands, a as cmdPauseAll, b as registerSetupCommand, c as cmdPause, d as registerKgCommands, f as registerTopicCommands, g as registerSkillCommands, h as registerUpdateCommand, i as cmdClearNames, k as resolveIdentifier, l as registerHelpCommand, m as registerNotifyCommands, n as cmdFind, o as cmdGoto, p as registerTaskCommands, r as cmdList, s as cmdEnd, t as cmdPick, u as registerDbCommands, v as registerZettelCommands, w as registerMcpCommands, x as registerRestoreCommands, y as registerObsidianCommands } from "../pick-DxS6p2vI.mjs";
8
+ import { C as registerDaemonCommands, D as registerProjectsCommands, E as registerRegistryCommands, O as findMovedPath, S as registerBackupCommands, T as registerMemoryCommands, _ as registerObservationCommands, a as cmdPauseAll, b as registerSetupCommand, c as cmdPause, d as registerKgCommands, f as registerTopicCommands, g as registerSkillCommands, h as registerUpdateCommand, i as cmdClearNames, k as resolveIdentifier, l as registerHelpCommand, m as registerNotifyCommands, n as cmdFind, o as cmdGoto, p as registerTaskCommands, r as cmdList, s as cmdEnd, t as cmdPick, u as registerDbCommands, v as registerZettelCommands, w as registerMcpCommands, x as registerRestoreCommands, y as registerObsidianCommands } from "../pick-BPlB38eB.mjs";
9
9
  import "../kg-extraction-C8DEUHTS.mjs";
10
10
  import "../factory-Q88X1bAN.mjs";
11
11
  import "../config-C8m-tPhP.mjs";
@@ -6786,27 +6786,30 @@ var AiBrokerProber = class {
6786
6786
  ], question, this.timeoutSecs * 1e3 + KILL_MARGIN_MS);
6787
6787
  } catch (e) {
6788
6788
  return {
6789
- replied: false,
6789
+ state: "silent",
6790
6790
  reason: e instanceof Error ? e.message : String(e)
6791
6791
  };
6792
6792
  }
6793
6793
  const start = stdout.lastIndexOf("{");
6794
6794
  if (start === -1) return {
6795
- replied: false,
6795
+ state: "silent",
6796
6796
  reason: "aibroker returned no JSON"
6797
6797
  };
6798
6798
  try {
6799
6799
  const wire = JSON.parse(stdout.slice(start));
6800
- return wire.replied === true ? {
6801
- replied: true,
6802
- reply: wire.reply
6803
- } : {
6804
- replied: false,
6805
- reason: wire.reason ?? "no reply"
6800
+ const state = wire.state ?? (wire.replied === true ? "replied" : "silent");
6801
+ if (state === "replied" || state === "busy" || state === "silent" || state === "absent") return {
6802
+ state,
6803
+ reply: wire.reply,
6804
+ reason: wire.reason
6805
+ };
6806
+ return {
6807
+ state: "silent",
6808
+ reason: `unexpected state from aibroker: ${String(wire.state)}`
6806
6809
  };
6807
6810
  } catch {
6808
6811
  return {
6809
- replied: false,
6812
+ state: "silent",
6810
6813
  reason: "aibroker returned malformed JSON"
6811
6814
  };
6812
6815
  }
@@ -7026,6 +7029,12 @@ function loadState$1() {
7026
7029
  function saveState$1(state) {
7027
7030
  writeJsonAtomic(STATE_FILE$1, state, { backup: false });
7028
7031
  }
7032
+ /**
7033
+ * Multiple of the expected duration past which a task is flagged even though it
7034
+ * keeps reporting `busy`. A session can be alive and still wrong — stuck in a
7035
+ * loop, waiting on a prompt that will never come. Liveness is not progress.
7036
+ */
7037
+ const GROSS_OVERRUN_FACTOR = 5;
7029
7038
  async function tick(opts) {
7030
7039
  const now = opts.now ?? Date.now();
7031
7040
  const state = loadState$1();
@@ -7121,21 +7130,30 @@ async function handleProbe(task, elapsed, opts, state) {
7121
7130
  stuck: false
7122
7131
  };
7123
7132
  const answer = await opts.prober.ask(project, `Are you still working on the task "${task.title}"? Reply in one short line.`);
7124
- if (answer.replied) {
7133
+ if (answer.state === "replied" || answer.state === "busy") {
7125
7134
  state.failedProbes[task.id] = 0;
7126
- return {
7135
+ const expected = expectedMinutes(state.history[task.id] ?? []);
7136
+ if (elapsed !== null && elapsed > expected * GROSS_OVERRUN_FACTOR) return {
7137
+ note: `alive but ${el} against an expected ${expected}m — ${GROSS_OVERRUN_FACTOR}x over, worth a look`,
7138
+ stuck: true
7139
+ };
7140
+ return answer.state === "busy" ? {
7141
+ note: `busy after ${el} (mid-turn, nothing sent)`,
7142
+ stuck: false
7143
+ } : {
7127
7144
  note: `alive after ${el}: ${answer.reply ?? "(no detail)"}`,
7128
7145
  stuck: false
7129
7146
  };
7130
7147
  }
7131
7148
  const fails = (state.failedProbes[task.id] ?? 0) + 1;
7132
7149
  state.failedProbes[task.id] = fails;
7150
+ const what = answer.state === "absent" ? "session gone" : "no reply";
7133
7151
  if (fails >= STUCK_AFTER_FAILED_PROBES) return {
7134
- note: `STUCK after ${el} and ${fails} unanswered probes (${answer.reason ?? "no reply"}) — needs attention`,
7152
+ note: `STUCK after ${el} ${what} x${fails} (${answer.reason ?? "no detail"})`,
7135
7153
  stuck: true
7136
7154
  };
7137
7155
  return {
7138
- note: `no reply ${fails}/${STUCK_AFTER_FAILED_PROBES} after ${el}`,
7156
+ note: `${what} ${fails}/${STUCK_AFTER_FAILED_PROBES} after ${el}`,
7139
7157
  stuck: false
7140
7158
  };
7141
7159
  }
@@ -9661,4 +9679,4 @@ async function cmdPick(db, opts = {}) {
9661
9679
 
9662
9680
  //#endregion
9663
9681
  export { registerDaemonCommands as C, registerProjectsCommands as D, registerRegistryCommands as E, findMovedPath as O, registerBackupCommands as S, registerMemoryCommands as T, registerObservationCommands as _, cmdPauseAll as a, registerSetupCommand as b, cmdPause as c, registerKgCommands as d, registerTopicCommands as f, registerSkillCommands as g, registerUpdateCommand as h, cmdClearNames as i, resolveIdentifier as k, registerHelpCommand as l, registerNotifyCommands as m, cmdFind as n, cmdGoto as o, registerTaskCommands as p, cmdList as r, cmdEnd as s, cmdPick as t, registerDbCommands as u, registerZettelCommands as v, registerMcpCommands as w, registerRestoreCommands as x, registerObsidianCommands as y };
9664
- //# sourceMappingURL=pick-DxS6p2vI.mjs.map
9682
+ //# sourceMappingURL=pick-BPlB38eB.mjs.map