@kontextmind/kxm 0.7.35 → 0.7.37

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.
@@ -11,7 +11,7 @@
11
11
  "name": "kxm",
12
12
  "source": "./plugins/kxm",
13
13
  "description": "Durable workflows, peer agents, and kxm tui",
14
- "version": "0.7.35",
14
+ "version": "0.7.37",
15
15
  "category": "development",
16
16
  "tags": ["kxm", "multi-agent", "workflows", "mcp"]
17
17
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kontextmind/kxm",
3
- "version": "0.7.35",
3
+ "version": "0.7.37",
4
4
  "description": "KXM local-first multi-agent orchestration and operator dashboard",
5
5
  "type": "module",
6
6
  "author": "KontextMind",
@@ -2,7 +2,7 @@
2
2
  "$schema": "https://json.schemastore.org/claude-code-plugin-manifest.json",
3
3
  "name": "kxm",
4
4
  "displayName": "KXM",
5
- "version": "0.7.35",
5
+ "version": "0.7.37",
6
6
  "description": "Headless multi-agent orchestration, durable workflows, and a live operator dashboard for Pi and Claude Code",
7
7
  "author": {
8
8
  "name": "KontextMind",
@@ -33904,6 +33904,12 @@ async function cmdRouteList(runtime) {
33904
33904
  print(runtime.io, runtime.json, { ok: true, command: "routes list", policy }, [...policy.admitted.map((x2) => `admitted ${x2}`), ...policy.disabled.map((x2) => `disabled ${x2}`)].join("\n") || "no route decisions");
33905
33905
  return 0;
33906
33906
  }
33907
+ async function cmdRouteCount(runtime) {
33908
+ const policy = loadRoutePolicy(runtime.dirs.workdir);
33909
+ const summary = `${policy.admitted.length} admitted / ${policy.disabled.length} disabled`;
33910
+ print(runtime.io, runtime.json, { ok: true, command: "routes count", admitted: policy.admitted.length, disabled: policy.disabled.length, summary }, summary);
33911
+ return 0;
33912
+ }
33907
33913
  async function cmdModelInventoryRefresh(runtime) {
33908
33914
  if (runtime.dryRun) {
33909
33915
  print(runtime.io, runtime.json, { ok: true, command: "models inventory refresh", dryRun: true }, "would refresh .kxm/models/inventory.yaml");
@@ -48805,6 +48811,9 @@ function createProgram(ctx, result) {
48805
48811
  addGlobalOptions(routesCmd.command("list").description("List route decisions")).action(async function routesListAction() {
48806
48812
  result.code = await cmdRouteList(runtimeFrom(ctx, this));
48807
48813
  });
48814
+ addGlobalOptions(routesCmd.command("count").description("Count admitted and disabled routes")).action(async function routesCountAction() {
48815
+ result.code = await cmdRouteCount(runtimeFrom(ctx, this));
48816
+ });
48808
48817
  for (const status of ["admit", "disable"]) {
48809
48818
  addGlobalOptions(routesCmd.command(status).description(`${status === "admit" ? "Admit" : "Disable"} a model route from the inventory`)).option("--model <id>", "Exact model id; omit to choose interactively").action(async function routeChangeAction(options) {
48810
48819
  result.code = await cmdRouteChange(runtimeFrom(ctx, this), status === "admit" ? "admitted" : "disabled", options.model);
@@ -49196,8 +49205,10 @@ function removedMeshInvocation(argv) {
49196
49205
  return { invoked, json };
49197
49206
  }
49198
49207
  async function runCli(argv, env = process.env, io = { stdout: (text) => process.stdout.write(text), stderr: (text) => process.stderr.write(text) }, cwd = process.cwd()) {
49199
- const originalStdout = io.stdout;
49200
- const originalStderr = io.stderr;
49208
+ const nested = io.io;
49209
+ const sink = nested && typeof nested.stdout === "function" && typeof nested.stderr === "function" ? nested : io;
49210
+ const originalStdout = sink.stdout;
49211
+ const originalStderr = sink.stderr;
49201
49212
  io = { ...io, stdout: (text) => originalStdout(redactConfiguredValues(text, env)), stderr: (text) => originalStderr(redactConfiguredValues(text, env)) };
49202
49213
  const mesh = removedMeshInvocation(argv);
49203
49214
  if (mesh.invoked) {
@@ -17121,7 +17121,7 @@ async function deliverInboxNotification(messageId, delivered, notify) {
17121
17121
  }
17122
17122
 
17123
17123
  // plugins/kxm/src/mcp-server.ts
17124
- var VERSION = "0.7.35";
17124
+ var VERSION = "0.7.37";
17125
17125
  var inbox = /* @__PURE__ */ new Map();
17126
17126
  var notifiedInbox = /* @__PURE__ */ new Set();
17127
17127
  var meshClient;
@@ -22503,6 +22503,15 @@ function rebuildVnextRunProjection(context, runId) {
22503
22503
  const last = events[events.length - 1];
22504
22504
  return persistProjection(context, stored, state, last.occurredAt);
22505
22505
  }
22506
+ function projectVnextRunReadOnly(context, runId) {
22507
+ const stored = context.eventStore.run(runId);
22508
+ if (!stored) throw runtimeError("run_unknown", runId, "run does not exist in this event store");
22509
+ const state = foldStoredVnextRun(context, stored);
22510
+ const events = context.eventStore.events(runId, 0, 1e6);
22511
+ if (events.length === 0) throw runtimeError("run_events_corrupt", runId, "run has no events");
22512
+ const last = events[events.length - 1];
22513
+ return { ...stored, status: state.status, updatedAt: last.occurredAt };
22514
+ }
22506
22515
  function persistVnextRunState(context, runId, state, lastSequence) {
22507
22516
  const stored = context.eventStore.runState(runId);
22508
22517
  if (stored) {
@@ -27310,7 +27319,7 @@ async function startVnextRuntimeSupervisorInner(paths, requestedPortOption, now)
27310
27319
  const context = contextFor(projectRoot);
27311
27320
  const bundle = loadVnextProject(projectRoot, {});
27312
27321
  if (request.method === "GET" && !sub) {
27313
- const projected = rebuildVnextRunProjection(context, runId);
27322
+ const projected = projectVnextRunReadOnly(context, runId);
27314
27323
  const folded = foldStoredVnextRun(context, projected);
27315
27324
  const drive = vnextDrivePollProjection(context, runId, folded);
27316
27325
  sendJson(response, 200, { ok: true, run: projected, ...drive !== void 0 ? { drive } : {} });
@@ -30027,6 +30036,7 @@ export {
30027
30036
  probeHarnessesForModel,
30028
30037
  probeHarnessesForModelAsync,
30029
30038
  projectRuntimeKey,
30039
+ projectVnextRunReadOnly,
30030
30040
  pruneSocketDir,
30031
30041
  readVnextRunStatus,
30032
30042
  readVnextSupervisorToken,
@@ -22031,31 +22031,14 @@ function assertStoredProjection(context, run) {
22031
22031
  throw runtimeError("run_projection_divergent", run.runId, "stored run_state does not match the folded projection");
22032
22032
  }
22033
22033
  }
22034
- function persistProjection(context, run, state, now) {
22035
- const canonical = vnextCanonicalJson(state);
22036
- const stored = context.eventStore.runState(run.runId);
22037
- if (stored && stored.state !== canonical) {
22038
- throw runtimeError("run_projection_divergent", run.runId, "stored run_state does not match the folded projection");
22039
- }
22040
- if (!stored) {
22041
- context.eventStore.upsertRunState({
22042
- runId: run.runId,
22043
- lastSequence: context.eventStore.nextSequence(run.runId) - 1,
22044
- state: canonical
22045
- });
22046
- }
22047
- const updated = { ...run, status: state.status, updatedAt: now };
22048
- if (run.status !== state.status) context.eventStore.updateRunStatus(run.runId, state.status, now);
22049
- return updated;
22050
- }
22051
- function rebuildVnextRunProjection(context, runId) {
22034
+ function projectVnextRunReadOnly(context, runId) {
22052
22035
  const stored = context.eventStore.run(runId);
22053
22036
  if (!stored) throw runtimeError("run_unknown", runId, "run does not exist in this event store");
22054
22037
  const state = foldStoredVnextRun(context, stored);
22055
22038
  const events = context.eventStore.events(runId, 0, 1e6);
22056
22039
  if (events.length === 0) throw runtimeError("run_events_corrupt", runId, "run has no events");
22057
22040
  const last = events[events.length - 1];
22058
- return persistProjection(context, stored, state, last.occurredAt);
22041
+ return { ...stored, status: state.status, updatedAt: last.occurredAt };
22059
22042
  }
22060
22043
  function persistVnextRunState(context, runId, state, lastSequence) {
22061
22044
  const stored = context.eventStore.runState(runId);
@@ -26824,7 +26807,7 @@ async function startVnextRuntimeSupervisorInner(paths, requestedPortOption, now)
26824
26807
  const context = contextFor(projectRoot);
26825
26808
  const bundle = loadVnextProject(projectRoot, {});
26826
26809
  if (request.method === "GET" && !sub) {
26827
- const projected = rebuildVnextRunProjection(context, runId);
26810
+ const projected = projectVnextRunReadOnly(context, runId);
26828
26811
  const folded = foldStoredVnextRun(context, projected);
26829
26812
  const drive = vnextDrivePollProjection(context, runId, folded);
26830
26813
  sendJson(response, 200, { ok: true, run: projected, ...drive !== void 0 ? { drive } : {} });
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kxm-claude-plugin",
3
- "version": "0.7.35",
3
+ "version": "0.7.37",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "engines": {
@@ -771,6 +771,13 @@ export async function cmdRouteList(runtime: Runtime): Promise<number> {
771
771
  return 0;
772
772
  }
773
773
 
774
+ export async function cmdRouteCount(runtime: Runtime): Promise<number> {
775
+ const policy = loadRoutePolicy(runtime.dirs.workdir);
776
+ const summary = `${policy.admitted.length} admitted / ${policy.disabled.length} disabled`;
777
+ print(runtime.io, runtime.json, { ok: true, command: "routes count", admitted: policy.admitted.length, disabled: policy.disabled.length, summary }, summary);
778
+ return 0;
779
+ }
780
+
774
781
  export async function cmdModelInventoryRefresh(runtime: Runtime): Promise<number> {
775
782
  if (runtime.dryRun) {
776
783
  print(runtime.io, runtime.json, { ok: true, command: "models inventory refresh", dryRun: true }, "would refresh .kxm/models/inventory.yaml");
@@ -114,6 +114,7 @@ import {
114
114
  cmdRouteChange,
115
115
  cmdModelsScreen,
116
116
  cmdRouteList,
117
+ cmdRouteCount,
117
118
  cmdModelInventoryRefresh,
118
119
  cmdVnextRuntime,
119
120
  } from "./cli/vnext.ts";
@@ -426,6 +427,7 @@ function createProgram(ctx: CliContext, result: { code: number }): Command {
426
427
  const routesCmd = addGlobalOptions(program.command("routes").description("Admit or disable verified model routes"));
427
428
  routesCmd.helpCommand("help", "Show routes help");
428
429
  addGlobalOptions(routesCmd.command("list").description("List route decisions")).action(async function routesListAction(this: Command) { result.code = await cmdRouteList(runtimeFrom(ctx, this)); });
430
+ addGlobalOptions(routesCmd.command("count").description("Count admitted and disabled routes")).action(async function routesCountAction(this: Command) { result.code = await cmdRouteCount(runtimeFrom(ctx, this)); });
429
431
  for (const status of ["admit", "disable"] as const) {
430
432
  addGlobalOptions(routesCmd.command(status).description(`${status === "admit" ? "Admit" : "Disable"} a model route from the inventory`)).option("--model <id>", "Exact model id; omit to choose interactively").action(async function routeChangeAction(this: Command, options: { model?: string }) { result.code = await cmdRouteChange(runtimeFrom(ctx, this), status === "admit" ? "admitted" : "disabled", options.model); });
431
433
  }
@@ -1210,8 +1212,10 @@ export async function runCli(
1210
1212
  io: CliIo = { stdout: (text) => process.stdout.write(text), stderr: (text) => process.stderr.write(text) },
1211
1213
  cwd = process.cwd(),
1212
1214
  ): Promise<number> {
1213
- const originalStdout = io.stdout;
1214
- const originalStderr = io.stderr;
1215
+ const nested = (io as { io?: CliIo }).io;
1216
+ const sink = nested && typeof nested.stdout === "function" && typeof nested.stderr === "function" ? nested : io;
1217
+ const originalStdout = sink.stdout;
1218
+ const originalStderr = sink.stderr;
1215
1219
  io = { ...io, stdout: (text) => originalStdout(redactConfiguredValues(text, env)), stderr: (text) => originalStderr(redactConfiguredValues(text, env)) };
1216
1220
  const mesh = removedMeshInvocation(argv);
1217
1221
  if (mesh.invoked) {
@@ -8,7 +8,7 @@ import { AGENT_COMMANDS_MAP, enforceToolPolicy, getMcpTools, reconcileInbox } fr
8
8
  import { deliverInboxNotification } from "./inbox.ts";
9
9
  import type { HubEvent, MessageRecord } from "./protocol.ts";
10
10
 
11
- const VERSION = "0.7.35";
11
+ const VERSION = "0.7.37";
12
12
  const inbox = new Map<string, MessageRecord>();
13
13
  const notifiedInbox = new Set<string>();
14
14
  let meshClient: HubClient | undefined;
@@ -19,7 +19,7 @@ import {
19
19
  closeVnextRuntimeContext,
20
20
  foldStoredVnextRun,
21
21
  openVnextRuntimeContext,
22
- rebuildVnextRunProjection,
22
+ projectVnextRunReadOnly,
23
23
  type VnextRuntimeContext,
24
24
  } from "./vnext-runtime.ts";
25
25
  import { createVnextOneShotProducer } from "./vnext-oneshot-producer.ts";
@@ -456,7 +456,7 @@ async function startVnextRuntimeSupervisorInner(
456
456
  const context = contextFor(projectRoot);
457
457
  const bundle = loadVnextProject(projectRoot, {});
458
458
  if (request.method === "GET" && !sub) {
459
- const projected = rebuildVnextRunProjection(context, runId);
459
+ const projected = projectVnextRunReadOnly(context, runId);
460
460
  const folded = foldStoredVnextRun(context, projected);
461
461
  const drive = vnextDrivePollProjection(context, runId, folded);
462
462
  sendJson(response, 200, { ok: true, run: projected, ...(drive !== undefined ? { drive } : {}) });
@@ -524,6 +524,20 @@ export function rebuildVnextRunProjection(context: VnextRuntimeContext, runId: s
524
524
  return persistProjection(context, stored, state, last.occurredAt);
525
525
  }
526
526
 
527
+ /** Read-only projection: folds the event log over the stored record without
528
+ * persisting. GET paths must not write (no run_state upsert, no status
529
+ * update, no run_projection_divergent throw) — the event log stays the sole
530
+ * source of truth and the folded status is returned as-is. */
531
+ export function projectVnextRunReadOnly(context: VnextRuntimeContext, runId: string): VnextRunRecord {
532
+ const stored = context.eventStore.run(runId);
533
+ if (!stored) throw runtimeError("run_unknown", runId, "run does not exist in this event store");
534
+ const state = foldStoredVnextRun(context, stored);
535
+ const events = context.eventStore.events(runId, 0, 1_000_000);
536
+ if (events.length === 0) throw runtimeError("run_events_corrupt", runId, "run has no events");
537
+ const last = events[events.length - 1]!;
538
+ return { ...stored, status: state.status, updatedAt: last.occurredAt };
539
+ }
540
+
527
541
  export function persistVnextRunState(context: VnextRuntimeContext, runId: string, state: VnextRunState, lastSequence: number): void {
528
542
  const stored = context.eventStore.runState(runId);
529
543
  if (stored) {