@kontextmind/kxm 0.7.0 → 0.7.5

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.
Files changed (78) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/.kxm/roles/writer.yaml +2 -0
  3. package/docs/README.md +3 -0
  4. package/docs/adr/ADR-0002-browser-automation-steel-doks.md +103 -0
  5. package/docs/agent-skills.md +19 -2
  6. package/docs/browser-automation.md +116 -0
  7. package/docs/configuration.md +10 -1
  8. package/docs/getting-started.md +21 -0
  9. package/docs/kb/how-credentials-retrieved-safely.md +31 -0
  10. package/docs/kb/how-to-capture-and-annotate-section.md +60 -0
  11. package/docs/kb/how-to-connect-playwright-to-steel.md +54 -0
  12. package/docs/kb/how-to-recover-expired-session-or-orphan.md +54 -0
  13. package/docs/kb/how-to-resume-after-mfa.md +28 -0
  14. package/docs/kb/how-to-take-over-session.md +32 -0
  15. package/docs/kb/why-authentication-disappeared.md +32 -0
  16. package/docs/kb/why-automation-opened-different-browser.md +32 -0
  17. package/docs/kb/why-session-viewer-cannot-control.md +31 -0
  18. package/docs/operations.md +24 -0
  19. package/docs/prompts/browser-annotate-feedback.md +41 -0
  20. package/docs/prompts/browser-diagnose-recover.md +38 -0
  21. package/docs/prompts/browser-explore.md +42 -0
  22. package/docs/prompts/browser-repro-fix.md +48 -0
  23. package/docs/prompts/browser-start.md +41 -0
  24. package/docs/prompts/browser-takeover.md +50 -0
  25. package/docs/skills/repo-work-delivery.md +5 -0
  26. package/docs/skills.md +2 -0
  27. package/docs/troubleshooting.md +22 -1
  28. package/package.json +1 -1
  29. package/plugins/kxm/.claude-plugin/plugin.json +1 -1
  30. package/plugins/kxm/dist/cli.js +2257 -439
  31. package/plugins/kxm/dist/core.js +57 -0
  32. package/plugins/kxm/dist/extension.js +40 -3
  33. package/plugins/kxm/dist/mcp-server.js +1 -1
  34. package/plugins/kxm/dist/runtime.js +572 -17
  35. package/plugins/kxm/dist/server.js +129 -4
  36. package/plugins/kxm/dist/vnext-runtime-supervisor.js +136 -13
  37. package/plugins/kxm/package.json +1 -1
  38. package/plugins/kxm/skills/hints.json +30 -0
  39. package/plugins/kxm/skills/kxm-browser-annotate/SKILL.md +90 -0
  40. package/plugins/kxm/skills/kxm-browser-auth/SKILL.md +47 -0
  41. package/plugins/kxm/skills/kxm-browser-diagnostics/SKILL.md +48 -0
  42. package/plugins/kxm/skills/kxm-browser-explore/SKILL.md +48 -0
  43. package/plugins/kxm/skills/kxm-browser-session/SKILL.md +94 -0
  44. package/plugins/kxm/skills/kxm-browser-takeover/SKILL.md +87 -0
  45. package/plugins/kxm/skills/kxm-browser-verify/SKILL.md +71 -0
  46. package/plugins/kxm/skills/kxm-hub-ops/SKILL.md +9 -0
  47. package/plugins/kxm/skills/kxm-project-setup/SKILL.md +9 -2
  48. package/plugins/kxm/src/autocomplete.ts +1 -1
  49. package/plugins/kxm/src/browser.ts +603 -0
  50. package/plugins/kxm/src/cli.ts +507 -9
  51. package/plugins/kxm/src/completion-install.ts +223 -0
  52. package/plugins/kxm/src/database.ts +1 -1
  53. package/plugins/kxm/src/external-effects.ts +1 -1
  54. package/plugins/kxm/src/hub-env.ts +193 -0
  55. package/plugins/kxm/src/init-guide-setup.ts +547 -0
  56. package/plugins/kxm/src/local-snapshot.ts +1 -1
  57. package/plugins/kxm/src/mcp-server.ts +1 -1
  58. package/plugins/kxm/src/protocol.ts +111 -0
  59. package/plugins/kxm/src/role.ts +335 -0
  60. package/plugins/kxm/src/runtime.ts +1 -0
  61. package/plugins/kxm/src/safety-integrity.ts +76 -0
  62. package/plugins/kxm/src/sqlite.ts +76 -0
  63. package/plugins/kxm/src/store.ts +1 -1
  64. package/plugins/kxm/src/vnext-bindings.ts +1 -1
  65. package/plugins/kxm/src/vnext-config.ts +38 -1
  66. package/plugins/kxm/src/vnext-engine-command.ts +2 -0
  67. package/plugins/kxm/src/vnext-engine.ts +16 -0
  68. package/plugins/kxm/src/vnext-harness.ts +4 -2
  69. package/plugins/kxm/src/vnext-oneshot-process.ts +21 -4
  70. package/plugins/kxm/src/vnext-oneshot-producer.ts +18 -0
  71. package/plugins/kxm/src/vnext-runtime-store.ts +1 -1
  72. package/plugins/kxm/src/workflow-tui.ts +1 -1
  73. package/plugins/kxm/src/workflow.ts +144 -0
  74. package/scripts/kxm-bump-version.mjs +146 -0
  75. package/scripts/kxm-hub.mjs +145 -3
  76. package/scripts/kxm-publish-npm.mjs +3 -1
  77. package/scripts/kxm-release-github.mjs +3 -1
  78. package/scripts/kxm.mjs +0 -0
@@ -59,6 +59,61 @@ function parseBoundedInteger(value, field, fallback, min, max) {
59
59
  }
60
60
  return value;
61
61
  }
62
+ var TERMINAL_RECEIPT_SCHEMA = "kxm.terminal-receipt.v1";
63
+ var VALID_TERMINAL_STATUSES = /* @__PURE__ */ new Set(["accepted", "audit_escalation", "rejected", "error"]);
64
+ function validateTerminalReceipt(value) {
65
+ if (!value || typeof value !== "object" || Array.isArray(value)) {
66
+ throw new ProtocolError(400, "terminal receipt must be an object", "invalid_terminal_receipt");
67
+ }
68
+ const record = value;
69
+ if (record.schema !== void 0 && record.schema !== TERMINAL_RECEIPT_SCHEMA) {
70
+ throw new ProtocolError(400, `terminal receipt schema must be ${TERMINAL_RECEIPT_SCHEMA}`, "invalid_terminal_receipt");
71
+ }
72
+ const status = record.status;
73
+ if (!status || !VALID_TERMINAL_STATUSES.has(status)) {
74
+ throw new ProtocolError(
75
+ 400,
76
+ `terminal receipt status must be one of: ${Array.from(VALID_TERMINAL_STATUSES).join(", ")}`,
77
+ "invalid_terminal_receipt"
78
+ );
79
+ }
80
+ const seat = requireString(record.seat, "seat", { max: 64 });
81
+ const runId = requireString(record.runId, "runId", { max: 128 });
82
+ const stageId = requireString(record.stageId, "stageId", { max: 128 });
83
+ const timestamp = requireString(record.timestamp, "timestamp", { max: 64 });
84
+ const host = requireString(record.host, "host", { max: 64 });
85
+ const model = requireString(record.model, "model", { max: 128 });
86
+ let evidence;
87
+ if (record.evidence !== void 0) {
88
+ if (!record.evidence || typeof record.evidence !== "object" || Array.isArray(record.evidence)) {
89
+ throw new ProtocolError(400, "terminal receipt evidence must be an object", "invalid_terminal_receipt");
90
+ }
91
+ evidence = record.evidence;
92
+ }
93
+ let metrics;
94
+ if (record.metrics !== void 0) {
95
+ if (!record.metrics || typeof record.metrics !== "object" || Array.isArray(record.metrics)) {
96
+ throw new ProtocolError(400, "terminal receipt metrics must be an object", "invalid_terminal_receipt");
97
+ }
98
+ metrics = record.metrics;
99
+ }
100
+ const escalationReason = optionalString(record.escalationReason, "escalationReason", 1024);
101
+ const ruling = optionalString(record.ruling, "ruling", 2048);
102
+ return {
103
+ schema: TERMINAL_RECEIPT_SCHEMA,
104
+ status,
105
+ seat,
106
+ runId,
107
+ stageId,
108
+ timestamp,
109
+ host,
110
+ model,
111
+ ...evidence ? { evidence } : {},
112
+ ...metrics ? { metrics } : {},
113
+ ...escalationReason ? { escalationReason } : {},
114
+ ...ruling ? { ruling } : {}
115
+ };
116
+ }
62
117
 
63
118
  // plugins/kxm/src/routing.ts
64
119
  import { createHash } from "node:crypto";
@@ -1957,6 +2012,7 @@ export {
1957
2012
  ROUTING_RECORD_SCHEMA,
1958
2013
  ROUTING_RECORD_V2_SCHEMA,
1959
2014
  ROUTING_REPORT_SCHEMA,
2015
+ TERMINAL_RECEIPT_SCHEMA,
1960
2016
  WORKER_RESULT_SCHEMA,
1961
2017
  WORKER_SCHEMA,
1962
2018
  agentWorker,
@@ -1999,5 +2055,6 @@ export {
1999
2055
  rotateLogFiles,
2000
2056
  sessionTokenPath,
2001
2057
  timingSafeStringCompare,
2058
+ validateTerminalReceipt,
2002
2059
  workerResult
2003
2060
  };
@@ -9647,7 +9647,45 @@ import { join as join7 } from "node:path";
9647
9647
  import { existsSync as existsSync2, readdirSync, readFileSync as readFileSync4 } from "node:fs";
9648
9648
  import { homedir as homedir2 } from "node:os";
9649
9649
  import { isAbsolute, join as join4, resolve as resolve2 } from "node:path";
9650
- import { DatabaseSync } from "node:sqlite";
9650
+
9651
+ // plugins/kxm/src/sqlite.ts
9652
+ import { createRequire } from "node:module";
9653
+ var requireFromHere = createRequire(import.meta.url);
9654
+ function loadNative() {
9655
+ try {
9656
+ const mod = requireFromHere("node:sqlite");
9657
+ if (mod.DatabaseSync) return { Ctor: mod.DatabaseSync, bun: false };
9658
+ } catch {
9659
+ }
9660
+ try {
9661
+ const mod = requireFromHere("bun:sqlite");
9662
+ const Ctor = mod?.DatabaseSync ?? mod?.Database;
9663
+ if (Ctor) return { Ctor, bun: true };
9664
+ } catch {
9665
+ }
9666
+ throw new Error("kxm: no supported sqlite module found (need node:sqlite or bun:sqlite)");
9667
+ }
9668
+ var native = loadNative();
9669
+ var DatabaseSync = class {
9670
+ inner;
9671
+ constructor(path, options) {
9672
+ let normalized = options;
9673
+ if (native.bun && options) {
9674
+ const { readOnly, ...rest } = options;
9675
+ normalized = readOnly === void 0 ? rest : { ...rest, readonly: readOnly };
9676
+ }
9677
+ this.inner = normalized === void 0 ? new native.Ctor(path) : new native.Ctor(path, normalized);
9678
+ }
9679
+ prepare(sql) {
9680
+ return this.inner.prepare(sql);
9681
+ }
9682
+ exec(sql) {
9683
+ return this.inner.exec(sql);
9684
+ }
9685
+ close() {
9686
+ this.inner.close();
9687
+ }
9688
+ };
9651
9689
 
9652
9690
  // plugins/kxm/src/telemetry.ts
9653
9691
  import { appendFileSync, mkdirSync as mkdirSync2, readFileSync as readFileSync3 } from "node:fs";
@@ -10469,7 +10507,6 @@ function kxmSlashCompletions(prefix) {
10469
10507
  // plugins/kxm/src/workflow-tui.ts
10470
10508
  import { existsSync as existsSync6, readFileSync as readFileSync8 } from "node:fs";
10471
10509
  import { join as join9 } from "node:path";
10472
- import { DatabaseSync as DatabaseSync2 } from "node:sqlite";
10473
10510
 
10474
10511
  // plugins/kxm/src/config.ts
10475
10512
  var import_yaml = __toESM(require_dist(), 1);
@@ -10484,7 +10521,7 @@ function loadActiveWorkflowProgress(repoRoot = process.cwd(), targetRunId) {
10484
10521
  if (!existsSync6(dbPath)) return void 0;
10485
10522
  let db;
10486
10523
  try {
10487
- db = new DatabaseSync2(dbPath, { readOnly: true });
10524
+ db = new DatabaseSync(dbPath, { readOnly: true });
10488
10525
  let row;
10489
10526
  if (targetRunId) {
10490
10527
  row = db.prepare("SELECT record FROM workflow_runs WHERE id = ?").get(targetRunId);
@@ -17036,7 +17036,7 @@ async function deliverInboxNotification(messageId, delivered, notify) {
17036
17036
  }
17037
17037
 
17038
17038
  // plugins/kxm/src/mcp-server.ts
17039
- var VERSION = "0.7.0";
17039
+ var VERSION = "0.7.5";
17040
17040
  var inbox = /* @__PURE__ */ new Map();
17041
17041
  var notifiedInbox = /* @__PURE__ */ new Set();
17042
17042
  var meshClient;