@kontextmind/kxm 0.7.24 → 0.7.26

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.24",
14
+ "version": "0.7.26",
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.24",
3
+ "version": "0.7.26",
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.24",
5
+ "version": "0.7.26",
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",
@@ -33642,6 +33642,9 @@ ${RUN_ENGINE_NOTICE}`);
33642
33642
  return 1;
33643
33643
  }
33644
33644
  }
33645
+ function formatCancelledStatus(reason) {
33646
+ return reason.length > 0 ? `cancelled (${reason})` : "cancelled";
33647
+ }
33645
33648
  function formatDriveStatusLine(runStatus, drive) {
33646
33649
  if (!drive || typeof drive.driveId !== "string" || drive.driveId.length === 0) return void 0;
33647
33650
  const receipt = drive.receipt ?? null;
@@ -33659,11 +33662,20 @@ function formatDriveStatusLine(runStatus, drive) {
33659
33662
  if (kind === "handoff") {
33660
33663
  return drive.verified === true ? `drive ${drive.driveId}: handoff (receipt verified)` : `drive ${drive.driveId}: handoff`;
33661
33664
  }
33665
+ if (receipt.settlement?.status === "cancelled") {
33666
+ const label = formatCancelledStatus(reason);
33667
+ return drive.verified === true ? `drive ${drive.driveId}: ${label} (receipt verified)` : `drive ${drive.driveId}: ${label}`;
33668
+ }
33662
33669
  if (drive.verified === true) {
33663
33670
  return `drive ${drive.driveId}: completed (receipt verified)`;
33664
33671
  }
33665
33672
  return `drive ${drive.driveId}: completed`;
33666
33673
  }
33674
+ function formatRunStatusLine(run, drive) {
33675
+ const reason = typeof drive?.receipt?.settlement?.reason === "string" ? drive.receipt.settlement.reason : "";
33676
+ const statusLabel = run.status === "cancelled" ? formatCancelledStatus(reason) : run.status;
33677
+ return `run ${run.runId}: ${statusLabel} (workflow ${run.workflowId}, updated ${run.updatedAt})`;
33678
+ }
33667
33679
  async function cmdVnextRunStatus(runtime, runId) {
33668
33680
  try {
33669
33681
  const projectRoot = discoverVnextProjectRoot(runtime.cwd);
@@ -33680,7 +33692,7 @@ async function cmdVnextRunStatus(runtime, runId) {
33680
33692
  runtime.io,
33681
33693
  runtime.json,
33682
33694
  { ok: true, command: "runs status", run, ...drive !== void 0 ? { drive } : {} },
33683
- `run ${run.runId}: ${run.status} (workflow ${run.workflowId}, updated ${run.updatedAt})${driveLine ? `
33695
+ `${formatRunStatusLine(run, drive)}${driveLine ? `
33684
33696
  ${driveLine}` : ""}`
33685
33697
  );
33686
33698
  return 0;
@@ -33693,7 +33705,21 @@ ${driveLine}` : ""}`
33693
33705
  return 1;
33694
33706
  }
33695
33707
  }
33696
- async function cmdVnextRunDrive(runtime, runId, simulated) {
33708
+ var DEFAULT_DRIVE_WAIT_MS = 6e4;
33709
+ var MAX_DRIVE_WAIT_MS = 6e5;
33710
+ function parseDriveWaitTimeoutMs(raw) {
33711
+ if (raw === void 0) return DEFAULT_DRIVE_WAIT_MS;
33712
+ const value = typeof raw === "number" ? raw : Number(typeof raw === "string" ? raw.trim() : raw);
33713
+ if (!Number.isInteger(value) || value < 1 || value > MAX_DRIVE_WAIT_MS) return void 0;
33714
+ return value;
33715
+ }
33716
+ function sleepMs(ms) {
33717
+ return new Promise((resolve31) => setTimeout(resolve31, ms));
33718
+ }
33719
+ function driveWaitCompleted(drive) {
33720
+ return drive?.verified === true && drive.receipt?.settlement?.kind === "terminal" && drive.receipt.settlement.status === "completed";
33721
+ }
33722
+ async function cmdVnextRunDrive(runtime, runId, simulated, options = {}) {
33697
33723
  try {
33698
33724
  const projectRoot = discoverVnextProjectRoot(runtime.cwd);
33699
33725
  if (!projectRoot) {
@@ -33705,8 +33731,19 @@ async function cmdVnextRunDrive(runtime, runId, simulated) {
33705
33731
  print(runtime.io, runtime.json, { ok: true, command: "runs drive", dryRun: true, runId, mode }, `drive plan: run ${runId} in ${mode} mode (no events written)`);
33706
33732
  return 0;
33707
33733
  }
33734
+ const timeoutMs = options.wait === true ? parseDriveWaitTimeoutMs(options.timeoutMs) : DEFAULT_DRIVE_WAIT_MS;
33735
+ if (options.wait === true && timeoutMs === void 0) {
33736
+ print(
33737
+ runtime.io,
33738
+ runtime.json,
33739
+ { ok: false, command: "runs drive", error: "run_drive_timeout_invalid" },
33740
+ `run drive --wait --timeout-ms must be an integer between 1 and ${MAX_DRIVE_WAIT_MS}`
33741
+ );
33742
+ return 1;
33743
+ }
33708
33744
  const supervisor = await (vnextDriveCliSeams.ensureSupervisor ?? ensureVnextSupervisor)({ env: runtime.env });
33709
- const result = await (vnextDriveCliSeams.runtimeRequest ?? vnextRuntimeRequest)(supervisor, "POST", `/v1/runs/${encodeURIComponent(runId)}/drive?projectRoot=${encodeURIComponent(projectRoot)}`, { mode });
33745
+ const request = vnextDriveCliSeams.runtimeRequest ?? vnextRuntimeRequest;
33746
+ const result = await request(supervisor, "POST", `/v1/runs/${encodeURIComponent(runId)}/drive?projectRoot=${encodeURIComponent(projectRoot)}`, { mode });
33710
33747
  const driveId = result.driveId;
33711
33748
  const poll = result.poll;
33712
33749
  const status = result.status;
@@ -33714,13 +33751,36 @@ async function cmdVnextRunDrive(runtime, runId, simulated) {
33714
33751
  print(runtime.io, runtime.json, { ok: false, command: "runs drive", error: "run_drive_io_failed" }, "run drive failed because a local operation did not complete");
33715
33752
  return 1;
33716
33753
  }
33717
- print(
33718
- runtime.io,
33719
- runtime.json,
33720
- { ok: true, command: "runs drive", runId, driveId, poll, mode, status },
33721
- `drive ${driveId}: accepted (poll ${poll})`
33722
- );
33723
- return 0;
33754
+ if (options.wait !== true) {
33755
+ print(
33756
+ runtime.io,
33757
+ runtime.json,
33758
+ { ok: true, command: "runs drive", runId, driveId, poll, mode, status },
33759
+ `drive ${driveId}: accepted (poll ${poll})`
33760
+ );
33761
+ return 0;
33762
+ }
33763
+ const deadline = Date.now() + timeoutMs;
33764
+ let interval = 25;
33765
+ while (true) {
33766
+ const stateResult = await request(supervisor, "GET", `/v1/runs/${encodeURIComponent(runId)}?projectRoot=${encodeURIComponent(projectRoot)}`);
33767
+ const drive = stateResult.drive;
33768
+ if (drive?.receipt) {
33769
+ print(
33770
+ runtime.io,
33771
+ runtime.json,
33772
+ { ok: driveWaitCompleted(drive), command: "runs drive", receipt: drive.receipt, verified: drive.verified === true },
33773
+ JSON.stringify(drive.receipt, null, 2)
33774
+ );
33775
+ return driveWaitCompleted(drive) ? 0 : 1;
33776
+ }
33777
+ const remaining = deadline - Date.now();
33778
+ if (remaining <= 0) break;
33779
+ await sleepMs(Math.min(interval, remaining));
33780
+ interval = Math.min(Math.floor(interval * 1.5), 250);
33781
+ }
33782
+ print(runtime.io, runtime.json, { ok: false, command: "runs drive", error: "timeout" }, "drive wait timed out");
33783
+ return 1;
33724
33784
  } catch (error) {
33725
33785
  if (error instanceof VnextConfigError) {
33726
33786
  print(runtime.io, runtime.json, { ok: false, command: "runs drive", error: "run_drive_failed", issues: error.issues }, `run drive failed: ${error.message}`);
@@ -33908,6 +33968,45 @@ async function cmdVnextRuntime(runtime, action) {
33908
33968
  return 1;
33909
33969
  }
33910
33970
  }
33971
+ async function cmdVnextRunReceipt(runtime, runId, options = {}) {
33972
+ try {
33973
+ const projectRoot = discoverVnextProjectRoot(runtime.cwd);
33974
+ if (!projectRoot) {
33975
+ print(runtime.io, runtime.json, { ok: false, command: "runs receipt", error: "project_required" }, "kxm runs receipt requires a vNext project (run kxm init first)");
33976
+ return 1;
33977
+ }
33978
+ const supervisor = await (vnextDriveCliSeams.ensureSupervisor ?? ensureVnextSupervisor)({ env: runtime.env });
33979
+ const result = await (vnextDriveCliSeams.runtimeRequest ?? vnextRuntimeRequest)(
33980
+ supervisor,
33981
+ "GET",
33982
+ `/v1/runs/${encodeURIComponent(runId)}/drive?projectRoot=${encodeURIComponent(projectRoot)}`
33983
+ );
33984
+ if (!Array.isArray(result.receipts)) {
33985
+ print(runtime.io, runtime.json, { ok: false, command: "runs receipt", error: "run_receipt_io_failed" }, "run receipt failed because a local operation did not complete");
33986
+ return 1;
33987
+ }
33988
+ const receipts = result.receipts;
33989
+ if (receipts.length === 0) {
33990
+ print(runtime.io, runtime.json, { ok: false, command: "runs receipt", error: "no_receipts" }, `run ${runId} has no drive receipts`);
33991
+ return 1;
33992
+ }
33993
+ if (options.all === true) {
33994
+ print(runtime.io, runtime.json, { ok: true, command: "runs receipt", receipts }, JSON.stringify(receipts, null, 2));
33995
+ return 0;
33996
+ }
33997
+ const latest = receipts[0];
33998
+ const settlement = latest && typeof latest === "object" && "settlement" in latest ? latest.settlement : latest;
33999
+ print(runtime.io, runtime.json, { ok: true, command: "runs receipt", receipt: latest }, JSON.stringify(settlement, null, 2));
34000
+ return 0;
34001
+ } catch (error) {
34002
+ if (error instanceof VnextConfigError) {
34003
+ print(runtime.io, runtime.json, { ok: false, command: "runs receipt", error: "run_receipt_failed", issues: error.issues }, `run receipt failed: ${error.message}`);
34004
+ return 1;
34005
+ }
34006
+ print(runtime.io, runtime.json, { ok: false, command: "runs receipt", error: "run_receipt_io_failed" }, "run receipt failed because a local operation did not complete");
34007
+ return 1;
34008
+ }
34009
+ }
33911
34010
 
33912
34011
  // plugins/kxm/src/cli/tasks.ts
33913
34012
  async function cmdSuggest(runtime, promptParts) {
@@ -48683,8 +48782,14 @@ function createProgram(ctx, result) {
48683
48782
  addGlobalOptions(runCmd.command("status").description("Show the projected status of a run, including durable drive receipt state (open / receipt verified / unsettled / orphaned)")).argument("<runId>", "Run id").action(async function runStatusAction(runId) {
48684
48783
  result.code = await cmdVnextRunStatus(runtimeFrom(ctx, this), runId);
48685
48784
  });
48686
- addGlobalOptions(runCmd.command("drive").description("Drive a run with an explicit model-free simulation")).argument("<runId>", "Run id").option("--simulated", "Use the model-free simulation producer").action(async function runDriveAction(runId, options) {
48687
- result.code = await cmdVnextRunDrive(runtimeFrom(ctx, this), runId, options.simulated === true);
48785
+ addGlobalOptions(runCmd.command("drive").description("Drive a run with an explicit model-free simulation")).argument("<runId>", "Run id").option("--simulated", "Use the model-free simulation producer").option("--wait", "Wait until a drive receipt is recorded; exits 0 only for a VERIFIED COMPLETED settlement").option("--timeout-ms <n>", "Wait timeout in milliseconds (default 60000, max 600000)").action(async function runDriveAction(runId, options) {
48786
+ result.code = await cmdVnextRunDrive(runtimeFrom(ctx, this), runId, options.simulated === true, {
48787
+ wait: options.wait === true,
48788
+ ...options.timeoutMs !== void 0 ? { timeoutMs: options.timeoutMs } : {}
48789
+ });
48790
+ });
48791
+ addGlobalOptions(runCmd.command("receipt").description("Print the newest drive receipt for a run")).argument("<runId>", "Run id").option("--all", "Print the capped receipt list for the run").action(async function runReceiptAction(runId, options) {
48792
+ result.code = await cmdVnextRunReceipt(runtimeFrom(ctx, this), runId, { all: options.all === true });
48688
48793
  });
48689
48794
  addGlobalOptions(runCmd.command("cancel").description("Durably request cancellation of a run")).argument("<runId>", "Run id").action(async function runCancelAction(runId) {
48690
48795
  result.code = await cmdVnextRunCancel(runtimeFrom(ctx, this), runId);
@@ -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.24";
17124
+ var VERSION = "0.7.26";
17125
17125
  var inbox = /* @__PURE__ */ new Map();
17126
17126
  var notifiedInbox = /* @__PURE__ */ new Set();
17127
17127
  var meshClient;