@kontextmind/kxm 0.7.85 → 0.7.87

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.
@@ -10319,7 +10319,7 @@ var require_compile = __commonJS({
10319
10319
  const schOrFunc = root.refs[ref];
10320
10320
  if (schOrFunc)
10321
10321
  return schOrFunc;
10322
- let _sch = resolve7.call(this, root, ref);
10322
+ let _sch = resolve8.call(this, root, ref);
10323
10323
  if (_sch === void 0) {
10324
10324
  const schema = (_a3 = root.localRefs) === null || _a3 === void 0 ? void 0 : _a3[ref];
10325
10325
  const { schemaId } = this.opts;
@@ -10346,7 +10346,7 @@ var require_compile = __commonJS({
10346
10346
  function sameSchemaEnv(s1, s2) {
10347
10347
  return s1.schema === s2.schema && s1.root === s2.root && s1.baseId === s2.baseId;
10348
10348
  }
10349
- function resolve7(root, ref) {
10349
+ function resolve8(root, ref) {
10350
10350
  let sch;
10351
10351
  while (typeof (sch = this.refs[ref]) == "string")
10352
10352
  ref = sch;
@@ -11171,7 +11171,7 @@ var require_fast_uri = __commonJS({
11171
11171
  }
11172
11172
  return uri;
11173
11173
  }
11174
- function resolve7(baseURI, relativeURI, options) {
11174
+ function resolve8(baseURI, relativeURI, options) {
11175
11175
  const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" };
11176
11176
  const {
11177
11177
  parsed: baseParsed,
@@ -11533,7 +11533,7 @@ var require_fast_uri = __commonJS({
11533
11533
  var fastUri = {
11534
11534
  SCHEMES,
11535
11535
  normalize,
11536
- resolve: resolve7,
11536
+ resolve: resolve8,
11537
11537
  resolveComponent,
11538
11538
  equal,
11539
11539
  serialize,
@@ -14524,7 +14524,7 @@ var require_dist2 = __commonJS({
14524
14524
 
14525
14525
  // plugins/kxm/src/extension.ts
14526
14526
  import { spawnSync as spawnSync2 } from "node:child_process";
14527
- import { existsSync as existsSync11, mkdirSync as mkdirSync9, readFileSync as readFileSync14, renameSync as renameSync5, rmSync as rmSync4, writeFileSync as writeFileSync7 } from "node:fs";
14527
+ import { existsSync as existsSync12, mkdirSync as mkdirSync9, readFileSync as readFileSync14, renameSync as renameSync5, rmSync as rmSync4, writeFileSync as writeFileSync7 } from "node:fs";
14528
14528
  import { dirname as dirname7, join as join15 } from "node:path";
14529
14529
 
14530
14530
  // plugins/kxm/src/commands.ts
@@ -14847,7 +14847,7 @@ var HubClient = class {
14847
14847
  if (signal?.aborted) throw new MeshWaitError("aborted", messageId);
14848
14848
  const message = await this.getMessage(messageId);
14849
14849
  if (["replied", "cancelled", "expired", "error"].includes(message.status)) return message;
14850
- await new Promise((resolve7, reject) => {
14850
+ await new Promise((resolve8, reject) => {
14851
14851
  const onAbort = () => {
14852
14852
  signal?.removeEventListener("abort", onAbort);
14853
14853
  clearTimeout(timer);
@@ -14855,7 +14855,7 @@ var HubClient = class {
14855
14855
  };
14856
14856
  const timer = setTimeout(() => {
14857
14857
  signal?.removeEventListener("abort", onAbort);
14858
- resolve7();
14858
+ resolve8();
14859
14859
  }, Math.min(500, Math.max(1, deadline - Date.now())));
14860
14860
  signal?.addEventListener("abort", onAbort, { once: true });
14861
14861
  if (signal?.aborted) onAbort();
@@ -14910,7 +14910,7 @@ var HubClient = class {
14910
14910
  } catch (error2) {
14911
14911
  if (this.stopped || error2 instanceof Error && error2.name === "AbortError") return;
14912
14912
  }
14913
- if (!this.stopped) await new Promise((resolve7) => setTimeout(resolve7, this.options.reconnectMs));
14913
+ if (!this.stopped) await new Promise((resolve8) => setTimeout(resolve8, this.options.reconnectMs));
14914
14914
  }
14915
14915
  }
14916
14916
  headers(includeIdentity = true) {
@@ -18281,7 +18281,7 @@ function closeServerGracefully(server) {
18281
18281
  server.close();
18282
18282
  }
18283
18283
  function startCallbackServer(expectedState) {
18284
- return new Promise((resolve7, reject) => {
18284
+ return new Promise((resolve8, reject) => {
18285
18285
  let settled = false;
18286
18286
  let timeout;
18287
18287
  let resolveCode;
@@ -18360,7 +18360,7 @@ function startCallbackServer(expectedState) {
18360
18360
  finish(() => rejectCode(new Error("OAuth callback timed out waiting for browser login")));
18361
18361
  close();
18362
18362
  }, OAUTH_CALLBACK_TIMEOUT_MS);
18363
- resolve7({ server, waitForCode: () => codePromise, cleanup });
18363
+ resolve8({ server, waitForCode: () => codePromise, cleanup });
18364
18364
  });
18365
18365
  });
18366
18366
  }
@@ -18979,8 +18979,8 @@ var AssistantMessageEventStream = class {
18979
18979
  finalResultPromise;
18980
18980
  resolveFinalResult;
18981
18981
  constructor() {
18982
- this.finalResultPromise = new Promise((resolve7) => {
18983
- this.resolveFinalResult = resolve7;
18982
+ this.finalResultPromise = new Promise((resolve8) => {
18983
+ this.resolveFinalResult = resolve8;
18984
18984
  });
18985
18985
  }
18986
18986
  push(event) {
@@ -19010,8 +19010,8 @@ var AssistantMessageEventStream = class {
19010
19010
  } else if (this.done) {
19011
19011
  return;
19012
19012
  } else {
19013
- const next = await new Promise((resolve7) => {
19014
- this.waiting.push(resolve7);
19013
+ const next = await new Promise((resolve8) => {
19014
+ this.waiting.push(resolve8);
19015
19015
  });
19016
19016
  if (next.done) return;
19017
19017
  if (next.value) yield next.value;
@@ -20330,8 +20330,8 @@ var AssistantMessageEventStream2 = class {
20330
20330
  finalResultPromise;
20331
20331
  resolveFinalResult;
20332
20332
  constructor() {
20333
- this.finalResultPromise = new Promise((resolve7) => {
20334
- this.resolveFinalResult = resolve7;
20333
+ this.finalResultPromise = new Promise((resolve8) => {
20334
+ this.resolveFinalResult = resolve8;
20335
20335
  });
20336
20336
  }
20337
20337
  push(event) {
@@ -20361,8 +20361,8 @@ var AssistantMessageEventStream2 = class {
20361
20361
  } else if (this.done) {
20362
20362
  return;
20363
20363
  } else {
20364
- const next = await new Promise((resolve7) => {
20365
- this.waiting.push(resolve7);
20364
+ const next = await new Promise((resolve8) => {
20365
+ this.waiting.push(resolve8);
20366
20366
  });
20367
20367
  if (next.done) return;
20368
20368
  if (next.value) yield next.value;
@@ -33420,7 +33420,7 @@ var Protocol = class {
33420
33420
  return;
33421
33421
  }
33422
33422
  const pollInterval = task2.pollInterval ?? this._options?.defaultTaskPollInterval ?? 1e3;
33423
- await new Promise((resolve7) => setTimeout(resolve7, pollInterval));
33423
+ await new Promise((resolve8) => setTimeout(resolve8, pollInterval));
33424
33424
  options?.signal?.throwIfAborted();
33425
33425
  }
33426
33426
  } catch (error2) {
@@ -33437,7 +33437,7 @@ var Protocol = class {
33437
33437
  */
33438
33438
  request(request, resultSchema, options) {
33439
33439
  const { relatedRequestId, resumptionToken, onresumptiontoken, task, relatedTask } = options ?? {};
33440
- return new Promise((resolve7, reject) => {
33440
+ return new Promise((resolve8, reject) => {
33441
33441
  const earlyReject = (error2) => {
33442
33442
  reject(error2);
33443
33443
  };
@@ -33515,7 +33515,7 @@ var Protocol = class {
33515
33515
  if (!parseResult.success) {
33516
33516
  reject(parseResult.error);
33517
33517
  } else {
33518
- resolve7(parseResult.data);
33518
+ resolve8(parseResult.data);
33519
33519
  }
33520
33520
  } catch (error2) {
33521
33521
  reject(error2);
@@ -33776,12 +33776,12 @@ var Protocol = class {
33776
33776
  }
33777
33777
  } catch {
33778
33778
  }
33779
- return new Promise((resolve7, reject) => {
33779
+ return new Promise((resolve8, reject) => {
33780
33780
  if (signal.aborted) {
33781
33781
  reject(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
33782
33782
  return;
33783
33783
  }
33784
- const timeoutId = setTimeout(resolve7, interval);
33784
+ const timeoutId = setTimeout(resolve8, interval);
33785
33785
  signal.addEventListener("abort", () => {
33786
33786
  clearTimeout(timeoutId);
33787
33787
  reject(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
@@ -34872,7 +34872,7 @@ var McpServer = class {
34872
34872
  let task = createTaskResult.task;
34873
34873
  const pollInterval = task.pollInterval ?? 5e3;
34874
34874
  while (task.status !== "completed" && task.status !== "failed" && task.status !== "cancelled") {
34875
- await new Promise((resolve7) => setTimeout(resolve7, pollInterval));
34875
+ await new Promise((resolve8) => setTimeout(resolve8, pollInterval));
34876
34876
  const updatedTask = await extra.taskStore.getTask(taskId);
34877
34877
  if (!updatedTask) {
34878
34878
  throw new McpError(ErrorCode.InternalError, `Task ${taskId} not found during polling`);
@@ -35490,8 +35490,8 @@ function makePromptStream() {
35490
35490
  try {
35491
35491
  while (true) {
35492
35492
  while (queue.length === 0 && !done && !failure) {
35493
- await new Promise((resolve7) => {
35494
- wake = resolve7;
35493
+ await new Promise((resolve8) => {
35494
+ wake = resolve8;
35495
35495
  });
35496
35496
  }
35497
35497
  if (failure) throw failure;
@@ -35512,8 +35512,8 @@ function makePromptStream() {
35512
35512
  }
35513
35513
  return {
35514
35514
  stream: gen(),
35515
- push: (msg) => failure || done ? Promise.reject(failure ?? new Error("prompt stream closed")) : new Promise((resolve7, reject) => {
35516
- queue.push({ msg, resolve: resolve7, reject });
35515
+ push: (msg) => failure || done ? Promise.reject(failure ?? new Error("prompt stream closed")) : new Promise((resolve8, reject) => {
35516
+ queue.push({ msg, resolve: resolve8, reject });
35517
35517
  kick();
35518
35518
  }),
35519
35519
  end: () => {
@@ -35924,8 +35924,8 @@ function buildMcpServers(tools, queryCtx) {
35924
35924
  queryCtx.pendingResults.delete(toolCallId);
35925
35925
  return result2;
35926
35926
  }
35927
- return new Promise((resolve7) => {
35928
- queryCtx.pendingToolCalls.set(toolCallId, { toolName: tool.name, resolve: resolve7 });
35927
+ return new Promise((resolve8) => {
35928
+ queryCtx.pendingToolCalls.set(toolCallId, { toolName: tool.name, resolve: resolve8 });
35929
35929
  });
35930
35930
  }
35931
35931
  }));
@@ -36431,16 +36431,19 @@ async function consumeWorkerRecoveryEnvelope(client, stateDir, agentName, projec
36431
36431
  // plugins/kxm/src/session-work.ts
36432
36432
  import { spawnSync } from "node:child_process";
36433
36433
  import { randomUUID } from "node:crypto";
36434
- import { existsSync as existsSync9, mkdirSync as mkdirSync8, readFileSync as readFileSync12, renameSync as renameSync4, writeFileSync as writeFileSync6 } from "node:fs";
36434
+ import { existsSync as existsSync10, mkdirSync as mkdirSync8, readFileSync as readFileSync12, renameSync as renameSync4, writeFileSync as writeFileSync6 } from "node:fs";
36435
36435
  import { join as join13 } from "node:path";
36436
36436
 
36437
36437
  // plugins/kxm/src/local-snapshot.ts
36438
- import { existsSync as existsSync7, readdirSync, readFileSync as readFileSync10 } from "node:fs";
36438
+ import { existsSync as existsSync8, readdirSync, readFileSync as readFileSync10 } from "node:fs";
36439
36439
  import { homedir as homedir6 } from "node:os";
36440
- import { isAbsolute as isAbsolute3, join as join11, resolve as resolve6 } from "node:path";
36440
+ import { isAbsolute as isAbsolute3, join as join11, resolve as resolve7 } from "node:path";
36441
36441
 
36442
36442
  // plugins/kxm/src/sqlite.ts
36443
+ import { existsSync as existsSync7 } from "node:fs";
36443
36444
  import { createRequire as createRequire2 } from "node:module";
36445
+ import { resolve as resolve6 } from "node:path";
36446
+ import { pathToFileURL } from "node:url";
36444
36447
  var requireFromHere = createRequire2(import.meta.url);
36445
36448
  function loadNative() {
36446
36449
  try {
@@ -36477,6 +36480,12 @@ var DatabaseSync = class {
36477
36480
  this.inner.close();
36478
36481
  }
36479
36482
  };
36483
+ function openReadOnlyDatabase(path) {
36484
+ if (existsSync7(`${path}-wal`)) return new DatabaseSync(path, { readOnly: true });
36485
+ const uri = pathToFileURL(resolve6(path));
36486
+ uri.searchParams.set("immutable", "1");
36487
+ return new DatabaseSync(uri.href, { readOnly: true });
36488
+ }
36480
36489
 
36481
36490
  // plugins/kxm/src/telemetry.ts
36482
36491
  import { appendFileSync, mkdirSync as mkdirSync6, readFileSync as readFileSync9 } from "node:fs";
@@ -36639,34 +36648,34 @@ function readOpenMessageMetadata(database) {
36639
36648
  function resolveKxmSnapshotPaths(cwd, env = process.env) {
36640
36649
  const stateDir = env.KXM_STATE_DIR?.trim() || join11(cwd, ".kxm", "state");
36641
36650
  const configured = env.KXM_DATA_PATH?.trim();
36642
- const dataPath = configured ? resolve6(cwd, configured) : join11(stateDir, "kxm.db");
36651
+ const dataPath = configured ? resolve7(cwd, configured) : join11(stateDir, "kxm.db");
36643
36652
  return { dataPath, stateDir };
36644
36653
  }
36645
36654
  function resolveKxmStateRoot(stateDir, options) {
36646
- if (options?.kxmStateRoot && existsSync7(options.kxmStateRoot)) {
36647
- return resolve6(options.kxmStateRoot);
36655
+ if (options?.kxmStateRoot && existsSync8(options.kxmStateRoot)) {
36656
+ return resolve7(options.kxmStateRoot);
36648
36657
  }
36649
- if (existsSync7(join11(stateDir, "runtime", "registry.db")) || existsSync7(join11(stateDir, "runtime", "projects"))) {
36658
+ if (existsSync8(join11(stateDir, "runtime", "registry.db")) || existsSync8(join11(stateDir, "runtime", "projects"))) {
36650
36659
  return stateDir;
36651
36660
  }
36652
36661
  const env = options?.env ?? process.env;
36653
36662
  const explicit = env.KXM_STATE_HOME?.trim() || env.KXM_USER_STATE_DIR?.trim() || env.KXM_STATE_ROOT?.trim();
36654
- if (explicit && isAbsolute3(explicit) && existsSync7(resolve6(explicit))) {
36655
- return resolve6(explicit);
36663
+ if (explicit && isAbsolute3(explicit) && existsSync8(resolve7(explicit))) {
36664
+ return resolve7(explicit);
36656
36665
  }
36657
36666
  let base;
36658
36667
  if (process.platform === "win32") {
36659
36668
  const localAppData = env.LOCALAPPDATA?.trim();
36660
36669
  base = localAppData && isAbsolute3(localAppData) ? localAppData : join11(homedir6(), "AppData", "Local");
36661
- base = resolve6(base, "KXM");
36670
+ base = resolve7(base, "KXM");
36662
36671
  } else if (process.platform === "darwin") {
36663
- base = resolve6(homedir6(), "Library", "Application Support", "KXM");
36672
+ base = resolve7(homedir6(), "Library", "Application Support", "KXM");
36664
36673
  } else {
36665
36674
  const xdgState = env.XDG_STATE_HOME?.trim();
36666
36675
  base = xdgState && isAbsolute3(xdgState) ? xdgState : join11(homedir6(), ".local", "state");
36667
- base = resolve6(base, "kxm");
36676
+ base = resolve7(base, "kxm");
36668
36677
  }
36669
- if (existsSync7(base)) return base;
36678
+ if (existsSync8(base)) return base;
36670
36679
  return void 0;
36671
36680
  }
36672
36681
  function loadLocalMeshSnapshot(dataPath, stateDir, options) {
@@ -36677,9 +36686,9 @@ function loadLocalMeshSnapshot(dataPath, stateDir, options) {
36677
36686
  let legacyRuns = [];
36678
36687
  let legacyRunTotal = 0;
36679
36688
  let plans = [];
36680
- if (existsSync7(dataPath)) {
36689
+ if (existsSync8(dataPath)) {
36681
36690
  hasLegacy = true;
36682
- const database = new DatabaseSync(dataPath, { readOnly: true });
36691
+ const database = openReadOnlyDatabase(dataPath);
36683
36692
  try {
36684
36693
  database.exec("PRAGMA busy_timeout = 5000");
36685
36694
  agents = readJsonRows(database, "SELECT record FROM agents");
@@ -36701,10 +36710,10 @@ function loadLocalMeshSnapshot(dataPath, stateDir, options) {
36701
36710
  const registryDbPath = join11(runtimeDir, "registry.db");
36702
36711
  const projectsDir = join11(runtimeDir, "projects");
36703
36712
  const projectKeys = /* @__PURE__ */ new Set();
36704
- if (existsSync7(registryDbPath)) {
36713
+ if (existsSync8(registryDbPath)) {
36705
36714
  hasKxm = true;
36706
36715
  try {
36707
- const regDb = new DatabaseSync(registryDbPath, { readOnly: true });
36716
+ const regDb = openReadOnlyDatabase(registryDbPath);
36708
36717
  try {
36709
36718
  regDb.exec("PRAGMA busy_timeout = 5000");
36710
36719
  const pRows = regDb.prepare("SELECT project_key FROM projects").all();
@@ -36717,7 +36726,7 @@ function loadLocalMeshSnapshot(dataPath, stateDir, options) {
36717
36726
  } catch {
36718
36727
  }
36719
36728
  }
36720
- if (existsSync7(projectsDir)) {
36729
+ if (existsSync8(projectsDir)) {
36721
36730
  try {
36722
36731
  for (const entry of readdirSync(projectsDir, { withFileTypes: true })) {
36723
36732
  if (entry.isDirectory()) {
@@ -36729,10 +36738,10 @@ function loadLocalMeshSnapshot(dataPath, stateDir, options) {
36729
36738
  }
36730
36739
  for (const key of projectKeys) {
36731
36740
  const eventDbPath = join11(projectsDir, key, "run-events.db");
36732
- if (existsSync7(eventDbPath)) {
36741
+ if (existsSync8(eventDbPath)) {
36733
36742
  hasKxm = true;
36734
36743
  try {
36735
- const eventDb = new DatabaseSync(eventDbPath, { readOnly: true });
36744
+ const eventDb = openReadOnlyDatabase(eventDbPath);
36736
36745
  try {
36737
36746
  eventDb.exec("PRAGMA busy_timeout = 5000");
36738
36747
  const runRows = eventDb.prepare(`
@@ -36759,7 +36768,7 @@ function loadLocalMeshSnapshot(dataPath, stateDir, options) {
36759
36768
  }
36760
36769
  }
36761
36770
  const pids = [];
36762
- if (existsSync7(stateDir)) {
36771
+ if (existsSync8(stateDir)) {
36763
36772
  for (const file of readdirSync(stateDir).filter((name) => name.endsWith(".pid"))) {
36764
36773
  try {
36765
36774
  const record2 = JSON.parse(readFileSync10(join11(stateDir, file), "utf8"));
@@ -36802,7 +36811,7 @@ function loadLocalMeshSnapshot(dataPath, stateDir, options) {
36802
36811
  source = "legacy";
36803
36812
  }
36804
36813
  const telemetryFile = join11(stateDir, "telemetry.jsonl");
36805
- const spend = existsSync7(telemetryFile) ? readRoutingRecords(telemetryFile) : [];
36814
+ const spend = existsSync8(telemetryFile) ? readRoutingRecords(telemetryFile) : [];
36806
36815
  return {
36807
36816
  source,
36808
36817
  agents: agents.sort((a, b) => Number(b.online) - Number(a.online) || a.name.localeCompare(b.name)),
@@ -36817,13 +36826,13 @@ function loadLocalMeshSnapshot(dataPath, stateDir, options) {
36817
36826
  }
36818
36827
 
36819
36828
  // plugins/kxm/src/kxm-update.ts
36820
- import { existsSync as existsSync8, readFileSync as readFileSync11, writeFileSync as writeFileSync5, mkdirSync as mkdirSync7 } from "node:fs";
36829
+ import { existsSync as existsSync9, readFileSync as readFileSync11, writeFileSync as writeFileSync5, mkdirSync as mkdirSync7 } from "node:fs";
36821
36830
  import { join as join12 } from "node:path";
36822
36831
  var KXM_UPDATE_CACHE = "update-check.json";
36823
36832
  var CACHE_TTL_MS = 6 * 60 * 60 * 1e3;
36824
36833
  function readUpdateCache(stateDir, now = Date.now()) {
36825
36834
  const path = join12(stateDir, KXM_UPDATE_CACHE);
36826
- if (!existsSync8(path)) return void 0;
36835
+ if (!existsSync9(path)) return void 0;
36827
36836
  try {
36828
36837
  const row = JSON.parse(readFileSync11(path, "utf8"));
36829
36838
  if (typeof row.checkedAt !== "number" || !row.notice || now - row.checkedAt > CACHE_TTL_MS) return void 0;
@@ -36994,7 +37003,7 @@ function buildSessionBrief(snapshot, current, hub, ship, updateLatest, cost, ses
36994
37003
  function readCachedSessionBrief(stateDir) {
36995
37004
  const file = join13(stateDir, "session-brief.json");
36996
37005
  try {
36997
- if (!existsSync9(file)) return void 0;
37006
+ if (!existsSync10(file)) return void 0;
36998
37007
  const raw = readFileSync12(file, "utf8");
36999
37008
  const parsed = JSON.parse(raw);
37000
37009
  if (parsed && parsed.schema === "kxm.session-brief.v1" && typeof parsed.generatedAt === "string") {
@@ -37021,7 +37030,7 @@ function writeCachedSessionBrief(stateDir, brief) {
37021
37030
  function estimateSessionCost(stateDir) {
37022
37031
  try {
37023
37032
  const telemetryFile = join13(stateDir, "telemetry.jsonl");
37024
- if (!existsSync9(telemetryFile)) return void 0;
37033
+ if (!existsSync10(telemetryFile)) return void 0;
37025
37034
  const records = readRoutingRecords(telemetryFile);
37026
37035
  if (records.length === 0) return void 0;
37027
37036
  let totalCost = 0;
@@ -37125,7 +37134,7 @@ function loadSessionBrief(cwd, env = process.env, current, hub, options = {}) {
37125
37134
  options.sessionToken
37126
37135
  );
37127
37136
  }
37128
- writeCachedSessionBrief(paths.stateDir, brief);
37137
+ if (options.writeCache !== false) writeCachedSessionBrief(paths.stateDir, brief);
37129
37138
  return brief;
37130
37139
  }
37131
37140
  async function loadSessionBriefAsync(cwd, env = process.env, current, hub, options = {}) {
@@ -37196,11 +37205,11 @@ function kxmSlashCompletions(prefix) {
37196
37205
  }
37197
37206
 
37198
37207
  // plugins/kxm/src/workflow-tui.ts
37199
- import { existsSync as existsSync10, readFileSync as readFileSync13 } from "node:fs";
37208
+ import { existsSync as existsSync11, readFileSync as readFileSync13 } from "node:fs";
37200
37209
  import { join as join14 } from "node:path";
37201
37210
  function loadActiveWorkflowProgress(repoRoot = process.cwd(), targetRunId) {
37202
37211
  const dbPath = join14(repoConfigDirectory(repoRoot), "state", "kxm.db");
37203
- if (!existsSync10(dbPath)) return void 0;
37212
+ if (!existsSync11(dbPath)) return void 0;
37204
37213
  let db;
37205
37214
  try {
37206
37215
  db = new DatabaseSync(dbPath, { readOnly: true });
@@ -37237,7 +37246,7 @@ function loadActiveWorkflowProgress(repoRoot = process.cwd(), targetRunId) {
37237
37246
  try {
37238
37247
  const logsDir = join14(repoConfigDirectory(repoRoot), "logs");
37239
37248
  const telemFile = telemetryPath(logsDir);
37240
- if (existsSync10(telemFile)) {
37249
+ if (existsSync11(telemFile)) {
37241
37250
  const records = readRoutingRecords(telemFile);
37242
37251
  const routingRunId = (routing) => "runId" in routing ? routing.runId : routing.workflowRunId;
37243
37252
  let matching = records.filter((r) => routingRunId(r.routing) === runId);
@@ -38149,7 +38158,7 @@ function piMeshExtension(pi) {
38149
38158
  let memText = res.status === 0 && res.stdout ? res.stdout.trim() : "";
38150
38159
  if (!memText) {
38151
38160
  const script = join15(cwd, "scripts", "kxm.mjs");
38152
- if (existsSync11(script)) {
38161
+ if (existsSync12(script)) {
38153
38162
  const scriptRes = spawnSync2(process.execPath, [script, "memory", "brief"], { cwd, encoding: "utf8", windowsHide: true });
38154
38163
  if (scriptRes.status === 0 && scriptRes.stdout) memText = scriptRes.stdout.trim();
38155
38164
  }
@@ -17182,7 +17182,7 @@ async function deliverInboxNotification(messageId, delivered, notify) {
17182
17182
  }
17183
17183
 
17184
17184
  // plugins/kxm/src/mcp-server.ts
17185
- var VERSION = "0.7.85";
17185
+ var VERSION = "0.7.87";
17186
17186
  var inbox = /* @__PURE__ */ new Map();
17187
17187
  var notifiedInbox = /* @__PURE__ */ new Set();
17188
17188
  var meshClient;
@@ -28483,17 +28483,38 @@ async function startKxmRuntimeSupervisorInner(paths, requestedPortOption, now, e
28483
28483
  }
28484
28484
  }, 1e3);
28485
28485
  heartbeat.unref();
28486
- for (const reg of registry.projectsForRuntime(activeRuntimeId)) {
28487
- try {
28488
- contextFor(reg.projectRoot);
28489
- } catch {
28490
- logger.warn({
28491
- event: "runtime_sync_context_unavailable",
28492
- projectId: reg.projectId,
28493
- message: `cannot reopen ${reg.projectRoot}: its outbox rows stay pending`
28494
- });
28486
+ const reopenRegisteredProjects = () => {
28487
+ for (const reg of registry.projectsForRuntime(activeRuntimeId)) {
28488
+ const key = projectRuntimeKey(reg.projectRoot);
28489
+ if (contexts.has(key)) continue;
28490
+ try {
28491
+ contextFor(reg.projectRoot);
28492
+ syncStatuses.delete(key);
28493
+ } catch (error) {
28494
+ const reason = syncFailureText(error);
28495
+ const prior = syncStatuses.get(key);
28496
+ if (prior === void 0 || prior.lastError !== reason) {
28497
+ logger.warn({
28498
+ event: "runtime_sync_context_unavailable",
28499
+ projectId: reg.projectId,
28500
+ message: `cannot reopen ${reg.projectRoot}: its outbox rows stay pending`,
28501
+ reason
28502
+ });
28503
+ }
28504
+ syncStatuses.set(key, {
28505
+ projectId: reg.projectId,
28506
+ projectRoot: reg.projectRoot,
28507
+ homeRuntimeId: activeRuntimeId,
28508
+ state: "blocked",
28509
+ outbox: { pending: 0, acked: 0, refused: 0, refusals: [] },
28510
+ storeReadable: false,
28511
+ consecutiveFailures: 1,
28512
+ lastError: reason
28513
+ });
28514
+ }
28495
28515
  }
28496
- }
28516
+ };
28517
+ reopenRegisteredProjects();
28497
28518
  const recordSyncStatus = (context, next) => {
28498
28519
  const key = projectRuntimeKey(context.projectRoot);
28499
28520
  const previous = syncStatuses.get(key);
@@ -28522,6 +28543,7 @@ async function startKxmRuntimeSupervisorInner(paths, requestedPortOption, now, e
28522
28543
  if (syncing || stopping) return;
28523
28544
  syncing = true;
28524
28545
  void (async () => {
28546
+ reopenRegisteredProjects();
28525
28547
  for (const context of [...contexts.values()]) {
28526
28548
  const key = projectRuntimeKey(context.projectRoot);
28527
28549
  const prior = syncStatuses.get(key);