@kontextmind/kxm 0.7.20 → 0.7.22
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.
- package/.claude-plugin/marketplace.json +1 -1
- package/package.json +1 -1
- package/plugins/kxm/.claude-plugin/plugin.json +1 -1
- package/plugins/kxm/dist/cli.js +958 -872
- package/plugins/kxm/dist/client.js +2 -2
- package/plugins/kxm/dist/extension.js +85 -67
- package/plugins/kxm/dist/mcp-server.js +3 -3
- package/plugins/kxm/dist/runtime.js +212 -194
- package/plugins/kxm/dist/server.js +46 -26
- package/plugins/kxm/dist/vnext-runtime-supervisor.js +155 -137
- package/plugins/kxm/package.json +1 -1
- package/plugins/kxm/src/cli/system.ts +3 -4
- package/plugins/kxm/src/cli/types.ts +2 -4
- package/plugins/kxm/src/cli/vnext.ts +1 -4
- package/plugins/kxm/src/cli.ts +15 -3
- package/plugins/kxm/src/client.ts +4 -2
- package/plugins/kxm/src/hub-autostart.ts +4 -4
- package/plugins/kxm/src/mcp-server.ts +1 -1
- package/plugins/kxm/src/repo-root.ts +29 -0
- package/plugins/kxm/src/vnext-config.ts +5 -3
- package/plugins/kxm/src/vnext-runtime-supervisor.ts +3 -4
|
@@ -7368,10 +7368,10 @@ var require_dist = __commonJS({
|
|
|
7368
7368
|
|
|
7369
7369
|
// plugins/kxm/src/hub.ts
|
|
7370
7370
|
import { createHash as createHash4, createHmac } from "node:crypto";
|
|
7371
|
-
import { existsSync as
|
|
7371
|
+
import { existsSync as existsSync5 } from "node:fs";
|
|
7372
7372
|
import { createServer } from "node:http";
|
|
7373
7373
|
import { isIP } from "node:net";
|
|
7374
|
-
import { dirname as
|
|
7374
|
+
import { dirname as dirname5, join as join6, resolve as resolve6 } from "node:path";
|
|
7375
7375
|
|
|
7376
7376
|
// plugins/kxm/src/protocol.ts
|
|
7377
7377
|
import { randomUUID } from "node:crypto";
|
|
@@ -10917,7 +10917,7 @@ import { resolve as resolve5 } from "node:path";
|
|
|
10917
10917
|
import {
|
|
10918
10918
|
chmodSync,
|
|
10919
10919
|
copyFileSync,
|
|
10920
|
-
existsSync as
|
|
10920
|
+
existsSync as existsSync4,
|
|
10921
10921
|
lstatSync,
|
|
10922
10922
|
mkdirSync as mkdirSync4,
|
|
10923
10923
|
readdirSync as readdirSync3,
|
|
@@ -10925,7 +10925,7 @@ import {
|
|
|
10925
10925
|
unlinkSync,
|
|
10926
10926
|
writeFileSync as writeFileSync4
|
|
10927
10927
|
} from "node:fs";
|
|
10928
|
-
import { basename as basename3, dirname as
|
|
10928
|
+
import { basename as basename3, dirname as dirname4, join as join5, resolve as resolve4 } from "node:path";
|
|
10929
10929
|
|
|
10930
10930
|
// plugins/kxm/src/sqlite.ts
|
|
10931
10931
|
import { createRequire } from "node:module";
|
|
@@ -10967,8 +10967,7 @@ var DatabaseSync = class {
|
|
|
10967
10967
|
};
|
|
10968
10968
|
|
|
10969
10969
|
// plugins/kxm/src/vnext-config.ts
|
|
10970
|
-
import { basename as basename2, dirname as
|
|
10971
|
-
import { fileURLToPath } from "node:url";
|
|
10970
|
+
import { basename as basename2, dirname as dirname3, extname as extname2, isAbsolute, join as join4, relative, resolve as resolve3, sep } from "node:path";
|
|
10972
10971
|
|
|
10973
10972
|
// plugins/kxm/src/restricted-yaml.mjs
|
|
10974
10973
|
var import_yaml3 = __toESM(require_dist(), 1);
|
|
@@ -10984,6 +10983,25 @@ var VNEXT_YAML_LIMITS = Object.freeze({
|
|
|
10984
10983
|
// plugins/kxm/src/vnext-template.ts
|
|
10985
10984
|
var import_yaml4 = __toESM(require_dist(), 1);
|
|
10986
10985
|
|
|
10986
|
+
// plugins/kxm/src/repo-root.ts
|
|
10987
|
+
import { existsSync as existsSync3 } from "node:fs";
|
|
10988
|
+
import { dirname as dirname2, join as join3 } from "node:path";
|
|
10989
|
+
import { fileURLToPath } from "node:url";
|
|
10990
|
+
var ROOT_MARKERS = ["scripts/kxm-hub.mjs", "scripts/kxm.mjs"];
|
|
10991
|
+
var MAX_WALK_DEPTH = 10;
|
|
10992
|
+
function findKxmRepoRoot(fromUrl = import.meta.url) {
|
|
10993
|
+
let dir = dirname2(fileURLToPath(fromUrl));
|
|
10994
|
+
for (let depth = 0; depth < MAX_WALK_DEPTH; depth += 1) {
|
|
10995
|
+
if (ROOT_MARKERS.some((marker) => existsSync3(join3(dir, marker)))) return dir;
|
|
10996
|
+
const parent = dirname2(dir);
|
|
10997
|
+
if (parent === dir) break;
|
|
10998
|
+
dir = parent;
|
|
10999
|
+
}
|
|
11000
|
+
throw new Error(
|
|
11001
|
+
`kxm: cannot locate the KXM repo root from ${fileURLToPath(fromUrl)} (walked ${MAX_WALK_DEPTH} levels looking for ${ROOT_MARKERS[0]})`
|
|
11002
|
+
);
|
|
11003
|
+
}
|
|
11004
|
+
|
|
10987
11005
|
// plugins/kxm/src/vnext-oneshot-process.ts
|
|
10988
11006
|
var OUTPUT_LIMIT = 8 * 1024 * 1024;
|
|
10989
11007
|
|
|
@@ -11362,8 +11380,10 @@ var VnextConfigError = class extends Error {
|
|
|
11362
11380
|
this.issues = sorted;
|
|
11363
11381
|
}
|
|
11364
11382
|
};
|
|
11365
|
-
|
|
11366
|
-
|
|
11383
|
+
function defaultVnextSchemaDir() {
|
|
11384
|
+
return join4(findKxmRepoRoot(import.meta.url), "schemas", "vnext");
|
|
11385
|
+
}
|
|
11386
|
+
var DEFAULT_SCHEMA_DIR = defaultVnextSchemaDir();
|
|
11367
11387
|
var RESOURCE_SCHEMA = Object.freeze({
|
|
11368
11388
|
project: { identity: "kxm.project.v1", file: "project.schema.json" },
|
|
11369
11389
|
repository: { identity: "kxm.repository.v1", file: "repository.schema.json" },
|
|
@@ -11386,8 +11406,8 @@ function databaseError(code, file, message) {
|
|
|
11386
11406
|
return new VnextConfigError([issue]);
|
|
11387
11407
|
}
|
|
11388
11408
|
function checkedParent(path, description) {
|
|
11389
|
-
const parent =
|
|
11390
|
-
if (!
|
|
11409
|
+
const parent = dirname4(path);
|
|
11410
|
+
if (!existsSync4(parent)) mkdirSync4(parent, { recursive: true, mode: 448 });
|
|
11391
11411
|
const stat = lstatSync(parent, { throwIfNoEntry: false });
|
|
11392
11412
|
if (!stat || stat.isSymbolicLink() || !stat.isDirectory()) {
|
|
11393
11413
|
throw databaseError("runtime_path_invalid", description, `${description} parent must be a regular directory, not a link`);
|
|
@@ -12331,7 +12351,7 @@ function createMeshHub(options = {}) {
|
|
|
12331
12351
|
const webhookWorkflows2 = new Map((options.webhookWorkflows ?? []).map((workflow) => [workflow.id, workflow]));
|
|
12332
12352
|
const logger = options.logger ?? (() => void 0);
|
|
12333
12353
|
const assetsDir2 = options.assetsDir;
|
|
12334
|
-
const hubRepoRoot = options.repoRoot ?? (options.dataPath && options.dataPath !== ":memory:" ? resolve6(
|
|
12354
|
+
const hubRepoRoot = options.repoRoot ?? (options.dataPath && options.dataPath !== ":memory:" ? resolve6(dirname5(dirname5(options.dataPath))) : process.cwd());
|
|
12335
12355
|
const store = new MeshStore(options.dataPath);
|
|
12336
12356
|
const agents = store.agents;
|
|
12337
12357
|
const messages = store.messages;
|
|
@@ -12356,7 +12376,7 @@ function createMeshHub(options = {}) {
|
|
|
12356
12376
|
const workflowRuns = store.workflowRuns;
|
|
12357
12377
|
const journal = store.journal;
|
|
12358
12378
|
const stateProvider = new NativeStateProvider(store);
|
|
12359
|
-
const skillLifecycle = options.skillLifecycle ?? (options.skillsDir ||
|
|
12379
|
+
const skillLifecycle = options.skillLifecycle ?? (options.skillsDir || existsSync5(join6(process.cwd(), ".kxm", "skills")) ? new SkillLifecycle(options.skillsDir ?? join6(process.cwd(), ".kxm", "skills")) : void 0);
|
|
12360
12380
|
const streams = /* @__PURE__ */ new Map();
|
|
12361
12381
|
const opsStreams = /* @__PURE__ */ new Set();
|
|
12362
12382
|
const rateBuckets = /* @__PURE__ */ new Map();
|
|
@@ -14263,11 +14283,11 @@ data: ${JSON.stringify({ agent: publicAgent(current) })}
|
|
|
14263
14283
|
|
|
14264
14284
|
// plugins/kxm/src/server.ts
|
|
14265
14285
|
import { mkdirSync as mkdirSync6, readFileSync as readFileSync4 } from "node:fs";
|
|
14266
|
-
import { dirname as
|
|
14286
|
+
import { dirname as dirname7, join as join7, resolve as resolve7 } from "node:path";
|
|
14267
14287
|
|
|
14268
14288
|
// plugins/kxm/src/logger.ts
|
|
14269
|
-
import { appendFileSync, existsSync as
|
|
14270
|
-
import { dirname as
|
|
14289
|
+
import { appendFileSync, existsSync as existsSync6, mkdirSync as mkdirSync5, renameSync as renameSync3, statSync as statSync2, unlinkSync as unlinkSync2 } from "node:fs";
|
|
14290
|
+
import { dirname as dirname6 } from "node:path";
|
|
14271
14291
|
var LOG_LEVEL_PRIORITY = {
|
|
14272
14292
|
debug: 10,
|
|
14273
14293
|
info: 20,
|
|
@@ -14304,7 +14324,7 @@ function redactLogValue(val, key) {
|
|
|
14304
14324
|
function rotateLogFiles(filePath, maxFiles) {
|
|
14305
14325
|
for (let i = maxFiles; i >= 1; i--) {
|
|
14306
14326
|
const current = `${filePath}.${i}`;
|
|
14307
|
-
if (
|
|
14327
|
+
if (existsSync6(current)) {
|
|
14308
14328
|
if (i >= maxFiles) {
|
|
14309
14329
|
try {
|
|
14310
14330
|
unlinkSync2(current);
|
|
@@ -14318,7 +14338,7 @@ function rotateLogFiles(filePath, maxFiles) {
|
|
|
14318
14338
|
}
|
|
14319
14339
|
}
|
|
14320
14340
|
}
|
|
14321
|
-
if (
|
|
14341
|
+
if (existsSync6(filePath)) {
|
|
14322
14342
|
try {
|
|
14323
14343
|
renameSync3(filePath, `${filePath}.1`);
|
|
14324
14344
|
} catch {
|
|
@@ -14335,7 +14355,7 @@ function createLogger(options) {
|
|
|
14335
14355
|
const shouldStdout = options.stdout ?? !isDaemon;
|
|
14336
14356
|
const correlationDefaults = options.correlation ?? {};
|
|
14337
14357
|
let currentSize = 0;
|
|
14338
|
-
if (filePath &&
|
|
14358
|
+
if (filePath && existsSync6(filePath)) {
|
|
14339
14359
|
try {
|
|
14340
14360
|
currentSize = statSync2(filePath).size;
|
|
14341
14361
|
} catch {
|
|
@@ -14373,7 +14393,7 @@ function createLogger(options) {
|
|
|
14373
14393
|
currentSize = 0;
|
|
14374
14394
|
}
|
|
14375
14395
|
try {
|
|
14376
|
-
mkdirSync5(
|
|
14396
|
+
mkdirSync5(dirname6(filePath), { recursive: true });
|
|
14377
14397
|
appendFileSync(filePath, line, { encoding: "utf8", mode: 384 });
|
|
14378
14398
|
currentSize += lineBytes;
|
|
14379
14399
|
} catch {
|
|
@@ -14419,13 +14439,13 @@ var host = process.env.KXM_HOST ?? "127.0.0.1";
|
|
|
14419
14439
|
var port = Number.parseInt(process.env.KXM_PORT ?? String(DEFAULT_PORT), 10);
|
|
14420
14440
|
var authToken = process.env.KXM_AUTH_TOKEN;
|
|
14421
14441
|
var workspaceDir = resolve7(process.env.KXM_WORKSPACE_DIR?.trim() || ".kxm");
|
|
14422
|
-
var configDir = resolve7(process.env.KXM_CONFIG_DIR?.trim() ||
|
|
14423
|
-
var logsDir = resolve7(process.env.KXM_LOGS_DIR?.trim() ||
|
|
14424
|
-
var assetsDir = resolve7(process.env.KXM_ASSETS_DIR?.trim() ||
|
|
14425
|
-
var stateDir = resolve7(process.env.KXM_STATE_DIR?.trim() ||
|
|
14442
|
+
var configDir = resolve7(process.env.KXM_CONFIG_DIR?.trim() || join7(workspaceDir, "config"));
|
|
14443
|
+
var logsDir = resolve7(process.env.KXM_LOGS_DIR?.trim() || join7(workspaceDir, "logs"));
|
|
14444
|
+
var assetsDir = resolve7(process.env.KXM_ASSETS_DIR?.trim() || join7(workspaceDir, "assets"));
|
|
14445
|
+
var stateDir = resolve7(process.env.KXM_STATE_DIR?.trim() || join7(workspaceDir, "state"));
|
|
14426
14446
|
var dataPathValue = process.env.KXM_DATA_PATH?.trim();
|
|
14427
|
-
var dataPath = dataPathValue === ":memory:" ? dataPathValue : resolve7(dataPathValue ||
|
|
14428
|
-
var logPath = resolve7(process.env.KXM_LOG_PATH?.trim() ||
|
|
14447
|
+
var dataPath = dataPathValue === ":memory:" ? dataPathValue : resolve7(dataPathValue || join7(stateDir, "kxm.db"));
|
|
14448
|
+
var logPath = resolve7(process.env.KXM_LOG_PATH?.trim() || join7(logsDir, "kxm-hub.jsonl"));
|
|
14429
14449
|
var messageTtlMs = Number.parseInt(process.env.KXM_MESSAGE_TTL_MS ?? String(DEFAULT_MESSAGE_TTL_MS), 10);
|
|
14430
14450
|
var messageRetentionMs = Number.parseInt(
|
|
14431
14451
|
process.env.KXM_MESSAGE_RETENTION_MS ?? String(DEFAULT_MESSAGE_RETENTION_MS),
|
|
@@ -14436,7 +14456,7 @@ var rateLimitWindowMs = Number.parseInt(
|
|
|
14436
14456
|
process.env.KXM_RATE_LIMIT_WINDOW_MS ?? String(DEFAULT_RATE_LIMIT_WINDOW_MS),
|
|
14437
14457
|
10
|
|
14438
14458
|
);
|
|
14439
|
-
for (const directory of [configDir, logsDir, assetsDir, stateDir,
|
|
14459
|
+
for (const directory of [configDir, logsDir, assetsDir, stateDir, dirname7(logPath)]) {
|
|
14440
14460
|
mkdirSync6(directory, { recursive: true });
|
|
14441
14461
|
}
|
|
14442
14462
|
var structuredLog = createLogger({
|