@tekmidian/pai 0.14.1 → 0.14.2

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-BPlB38eB.mjs";
9
+ import "../pick-gne3kOJG.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-BPlB38eB.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-gne3kOJG.mjs";
9
9
  import "../kg-extraction-C8DEUHTS.mjs";
10
10
  import "../factory-Q88X1bAN.mjs";
11
11
  import "../config-C8m-tPhP.mjs";
@@ -7008,8 +7008,11 @@ const HISTORY_LIMIT = 5;
7008
7008
  const EMPTY = {
7009
7009
  ...EMPTY_RUN_STATE,
7010
7010
  history: {},
7011
- lastReported: {}
7011
+ lastReported: {},
7012
+ failedDispatches: {}
7012
7013
  };
7014
+ /** Consecutive failed dispatches before a task is reported as needing attention. */
7015
+ const DISPATCH_FAILURES_BEFORE_ALARM = 3;
7013
7016
  /**
7014
7017
  * Run state is a rebuildable cache, so a damaged file must not block the
7015
7018
  * scheduler forever — starting fresh is the correct recovery here, which is
@@ -7061,10 +7064,15 @@ async function tick(opts) {
7061
7064
  case "running":
7062
7065
  note = `${d.elapsedMinutes}m elapsed`;
7063
7066
  break;
7064
- case "dispatch":
7065
- note = await handleDispatch(task, d.overdueMinutes, opts, state, now);
7066
- if (!opts.dryRun) report.dispatched++;
7067
+ case "dispatch": {
7068
+ const r = await handleDispatch(task, d.overdueMinutes, opts, state, now);
7069
+ note = r.note;
7070
+ if (!opts.dryRun) {
7071
+ report.dispatched++;
7072
+ if (r.alarm) report.stuck++;
7073
+ }
7067
7074
  break;
7075
+ }
7068
7076
  case "complete":
7069
7077
  note = await handleComplete(task, d.durationMinutes, opts, state);
7070
7078
  if (!opts.dryRun) report.completed++;
@@ -7090,8 +7098,14 @@ async function tick(opts) {
7090
7098
  }
7091
7099
  async function handleDispatch(task, overdue, opts, state, now) {
7092
7100
  const late = overdue > 5 ? ` (${overdue}m late)` : "";
7093
- if (opts.dryRun) return `would dispatch to ${task.owner.project ?? "nobody"}${late}`;
7094
- if (!task.owner.project) return "unrouted — cannot dispatch";
7101
+ if (opts.dryRun) return {
7102
+ note: `would dispatch to ${task.owner.project ?? "nobody"}${late}`,
7103
+ alarm: false
7104
+ };
7105
+ if (!task.owner.project) return {
7106
+ note: "unrouted — cannot dispatch",
7107
+ alarm: false
7108
+ };
7095
7109
  const result = await dispatchTask(task, {
7096
7110
  transport: opts.transport,
7097
7111
  autoDispatch: opts.autoDispatch,
@@ -7101,9 +7115,23 @@ async function handleDispatch(task, overdue, opts, state, now) {
7101
7115
  await opts.provider.setLabels(task.id, [...task.labels, RUNNING_LABEL]);
7102
7116
  state.startedAt[task.id] = now;
7103
7117
  delete state.failedProbes[task.id];
7104
- return `${result.outcome} to ${result.session}${late}`;
7118
+ delete state.failedDispatches[task.id];
7119
+ return {
7120
+ note: `${result.outcome} to ${result.session}${late}`,
7121
+ alarm: false
7122
+ };
7105
7123
  }
7106
- return `not dispatched: ${result.outcome}${result.reason ? " — " + result.reason : ""}`;
7124
+ const fails = (state.failedDispatches[task.id] ?? 0) + 1;
7125
+ state.failedDispatches[task.id] = fails;
7126
+ const detail = `${result.outcome}${result.reason ? " — " + result.reason : ""}`;
7127
+ if (fails >= DISPATCH_FAILURES_BEFORE_ALARM) return {
7128
+ note: `NOT RUNNING — ${fails} failed dispatches: ${detail}`,
7129
+ alarm: true
7130
+ };
7131
+ return {
7132
+ note: `not dispatched (${fails}/${DISPATCH_FAILURES_BEFORE_ALARM}): ${detail}`,
7133
+ alarm: false
7134
+ };
7107
7135
  }
7108
7136
  async function handleComplete(task, durationMinutes, opts, state) {
7109
7137
  if (opts.dryRun) return `would clear ${RUNNING_LABEL}, ${durationMinutes ?? "?"}m`;
@@ -9679,4 +9707,4 @@ async function cmdPick(db, opts = {}) {
9679
9707
 
9680
9708
  //#endregion
9681
9709
  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 };
9682
- //# sourceMappingURL=pick-BPlB38eB.mjs.map
9710
+ //# sourceMappingURL=pick-gne3kOJG.mjs.map