@kontextmind/kxm 0.7.86 → 0.7.88
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/docs/configuration.md +2 -0
- package/package.json +1 -1
- package/plugins/kxm/.claude-plugin/plugin.json +1 -1
- package/plugins/kxm/dist/cli.js +897 -500
- package/plugins/kxm/dist/core.js +2 -2
- package/plugins/kxm/dist/extension.js +72 -63
- package/plugins/kxm/dist/mcp-server.js +3 -3
- package/plugins/kxm/dist/runtime.js +44 -26
- package/plugins/kxm/dist/server.js +56 -31
- package/plugins/kxm/package.json +1 -1
- package/plugins/kxm/src/cli/context-skills.ts +51 -6
- package/plugins/kxm/src/cli/hub.ts +39 -14
- package/plugins/kxm/src/cli/project.ts +78 -23
- package/plugins/kxm/src/cli/roles.ts +48 -4
- package/plugins/kxm/src/cli/system.ts +18 -1
- package/plugins/kxm/src/cli/tasks.ts +34 -5
- package/plugins/kxm/src/cli/types.ts +30 -0
- package/plugins/kxm/src/cli/workflows.ts +20 -4
- package/plugins/kxm/src/cli.ts +57 -0
- package/plugins/kxm/src/commands.ts +2 -2
- package/plugins/kxm/src/config.ts +4 -3
- package/plugins/kxm/src/context/providers.ts +4 -0
- package/plugins/kxm/src/database.ts +72 -33
- package/plugins/kxm/src/hub.ts +26 -8
- package/plugins/kxm/src/local-snapshot.ts +4 -4
- package/plugins/kxm/src/mcp-server.ts +1 -1
- package/plugins/kxm/src/memory.ts +10 -7
- package/plugins/kxm/src/role.ts +18 -6
- package/plugins/kxm/src/session-work.ts +4 -1
- package/plugins/kxm/src/skills.ts +29 -15
- package/plugins/kxm/src/sqlite.ts +18 -0
- package/plugins/kxm/src/state.ts +4 -1
- package/plugins/kxm/src/task-manager.ts +20 -13
- package/plugins/kxm/src/workflow-manager.ts +12 -4
package/plugins/kxm/dist/core.js
CHANGED
|
@@ -1567,8 +1567,8 @@ var AGENT_COMMANDS = [
|
|
|
1567
1567
|
summary: { type: "string", description: "Promotion summary" },
|
|
1568
1568
|
authority: {
|
|
1569
1569
|
type: "string",
|
|
1570
|
-
enum: ["
|
|
1571
|
-
description: "Authority class"
|
|
1570
|
+
enum: ["evidence", "hypothesis"],
|
|
1571
|
+
description: "Authority class; an agent's proposal is peer origin, so evidence at most"
|
|
1572
1572
|
},
|
|
1573
1573
|
confidence: {
|
|
1574
1574
|
type: "string",
|
|
@@ -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 =
|
|
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
|
|
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
|
|
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:
|
|
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
|
|
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((
|
|
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
|
-
|
|
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((
|
|
14913
|
+
if (!this.stopped) await new Promise((resolve8) => setTimeout(resolve8, this.options.reconnectMs));
|
|
14914
14914
|
}
|
|
14915
14915
|
}
|
|
14916
14916
|
headers(includeIdentity = true) {
|
|
@@ -15670,8 +15670,8 @@ var AGENT_COMMANDS = [
|
|
|
15670
15670
|
summary: { type: "string", description: "Promotion summary" },
|
|
15671
15671
|
authority: {
|
|
15672
15672
|
type: "string",
|
|
15673
|
-
enum: ["
|
|
15674
|
-
description: "Authority class"
|
|
15673
|
+
enum: ["evidence", "hypothesis"],
|
|
15674
|
+
description: "Authority class; an agent's proposal is peer origin, so evidence at most"
|
|
15675
15675
|
},
|
|
15676
15676
|
confidence: {
|
|
15677
15677
|
type: "string",
|
|
@@ -18281,7 +18281,7 @@ function closeServerGracefully(server) {
|
|
|
18281
18281
|
server.close();
|
|
18282
18282
|
}
|
|
18283
18283
|
function startCallbackServer(expectedState) {
|
|
18284
|
-
return new Promise((
|
|
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
|
-
|
|
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((
|
|
18983
|
-
this.resolveFinalResult =
|
|
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((
|
|
19014
|
-
this.waiting.push(
|
|
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((
|
|
20334
|
-
this.resolveFinalResult =
|
|
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((
|
|
20365
|
-
this.waiting.push(
|
|
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((
|
|
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((
|
|
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
|
-
|
|
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((
|
|
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(
|
|
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((
|
|
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((
|
|
35494
|
-
wake =
|
|
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((
|
|
35516
|
-
queue.push({ msg, resolve:
|
|
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((
|
|
35928
|
-
queryCtx.pendingToolCalls.set(toolCallId, { toolName: tool.name, resolve:
|
|
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
|
|
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
|
|
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
|
|
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 ?
|
|
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 &&
|
|
36647
|
-
return
|
|
36655
|
+
if (options?.kxmStateRoot && existsSync8(options.kxmStateRoot)) {
|
|
36656
|
+
return resolve7(options.kxmStateRoot);
|
|
36648
36657
|
}
|
|
36649
|
-
if (
|
|
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) &&
|
|
36655
|
-
return
|
|
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 =
|
|
36670
|
+
base = resolve7(base, "KXM");
|
|
36662
36671
|
} else if (process.platform === "darwin") {
|
|
36663
|
-
base =
|
|
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 =
|
|
36676
|
+
base = resolve7(base, "kxm");
|
|
36668
36677
|
}
|
|
36669
|
-
if (
|
|
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 (
|
|
36689
|
+
if (existsSync8(dataPath)) {
|
|
36681
36690
|
hasLegacy = true;
|
|
36682
|
-
const database =
|
|
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 (
|
|
36713
|
+
if (existsSync8(registryDbPath)) {
|
|
36705
36714
|
hasKxm = true;
|
|
36706
36715
|
try {
|
|
36707
|
-
const regDb =
|
|
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 (
|
|
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 (
|
|
36741
|
+
if (existsSync8(eventDbPath)) {
|
|
36733
36742
|
hasKxm = true;
|
|
36734
36743
|
try {
|
|
36735
|
-
const eventDb =
|
|
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 (
|
|
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 =
|
|
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
|
|
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 (!
|
|
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 (!
|
|
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 (!
|
|
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
|
|
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 (!
|
|
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 (
|
|
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 (
|
|
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
|
}
|
|
@@ -16981,8 +16981,8 @@ var AGENT_COMMANDS = [
|
|
|
16981
16981
|
summary: { type: "string", description: "Promotion summary" },
|
|
16982
16982
|
authority: {
|
|
16983
16983
|
type: "string",
|
|
16984
|
-
enum: ["
|
|
16985
|
-
description: "Authority class"
|
|
16984
|
+
enum: ["evidence", "hypothesis"],
|
|
16985
|
+
description: "Authority class; an agent's proposal is peer origin, so evidence at most"
|
|
16986
16986
|
},
|
|
16987
16987
|
confidence: {
|
|
16988
16988
|
type: "string",
|
|
@@ -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.
|
|
17185
|
+
var VERSION = "0.7.88";
|
|
17186
17186
|
var inbox = /* @__PURE__ */ new Map();
|
|
17187
17187
|
var notifiedInbox = /* @__PURE__ */ new Set();
|
|
17188
17188
|
var meshClient;
|
|
@@ -18372,7 +18372,7 @@ function discoverProjectStores(projectRoot, options = {}) {
|
|
|
18372
18372
|
}
|
|
18373
18373
|
return stores;
|
|
18374
18374
|
}
|
|
18375
|
-
function
|
|
18375
|
+
function planBackup(options = {}) {
|
|
18376
18376
|
const projectRoot = options.projectRoot ? resolve3(options.projectRoot) : process.cwd();
|
|
18377
18377
|
const stores = discoverProjectStores(projectRoot, {
|
|
18378
18378
|
...options.hubDataPath !== void 0 ? { hubDataPath: options.hubDataPath } : {}
|
|
@@ -18380,30 +18380,35 @@ function createBackup(options = {}) {
|
|
|
18380
18380
|
if (stores.length === 0) {
|
|
18381
18381
|
throw databaseError("backup_no_stores", projectRoot, "no existing SQLite stores found to backup");
|
|
18382
18382
|
}
|
|
18383
|
-
const
|
|
18384
|
-
const timestamp =
|
|
18385
|
-
const backupId = `bk_${randomBytes(8).toString("hex")}`;
|
|
18383
|
+
const createdAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
18384
|
+
const timestamp = createdAt.replace(/[:.]/g, "-");
|
|
18386
18385
|
const outDir = options.outDir ? resolve3(options.outDir) : join4(projectRoot, ".kxm", "backups", `backup-${timestamp}`);
|
|
18387
|
-
if (!existsSync4(outDir)) {
|
|
18388
|
-
mkdirSync(outDir, { recursive: true, mode: 448 });
|
|
18389
|
-
}
|
|
18390
|
-
const backedUpStores = [];
|
|
18391
18386
|
const usedFilenames = /* @__PURE__ */ new Set();
|
|
18392
|
-
|
|
18387
|
+
const planned = stores.map((store) => {
|
|
18393
18388
|
let filename = basename2(store.sourcePath);
|
|
18394
18389
|
if (usedFilenames.has(filename)) {
|
|
18395
18390
|
const sanitizedId = store.storeId.replace(/[^a-zA-Z0-9_.-]/g, "_");
|
|
18396
18391
|
filename = `${sanitizedId}-${filename}`;
|
|
18397
18392
|
}
|
|
18398
18393
|
usedFilenames.add(filename);
|
|
18399
|
-
|
|
18400
|
-
|
|
18401
|
-
|
|
18394
|
+
return { storeId: store.storeId, sourcePath: store.sourcePath, backupFile: filename };
|
|
18395
|
+
});
|
|
18396
|
+
return { projectRoot, outDir, createdAt, stores: planned };
|
|
18397
|
+
}
|
|
18398
|
+
function createBackup(options = {}) {
|
|
18399
|
+
const { projectRoot, outDir, createdAt, stores } = planBackup(options);
|
|
18400
|
+
const backupId = `bk_${randomBytes(8).toString("hex")}`;
|
|
18401
|
+
if (!existsSync4(outDir)) {
|
|
18402
|
+
mkdirSync(outDir, { recursive: true, mode: 448 });
|
|
18403
|
+
}
|
|
18404
|
+
const backedUpStores = [];
|
|
18405
|
+
for (const store of stores) {
|
|
18406
|
+
backedUpStores.push(backupDatabaseFile(store.sourcePath, join4(outDir, store.backupFile), store.storeId));
|
|
18402
18407
|
}
|
|
18403
18408
|
const manifest = {
|
|
18404
18409
|
schema: "kxm.backup-manifest.v1",
|
|
18405
18410
|
backupId,
|
|
18406
|
-
createdAt
|
|
18411
|
+
createdAt,
|
|
18407
18412
|
projectRoot,
|
|
18408
18413
|
stores: backedUpStores
|
|
18409
18414
|
};
|
|
@@ -18415,7 +18420,7 @@ function createBackup(options = {}) {
|
|
|
18415
18420
|
writeFileSync(manifestPath, finalJson, "utf8");
|
|
18416
18421
|
return { manifest, outDir };
|
|
18417
18422
|
}
|
|
18418
|
-
function
|
|
18423
|
+
function planRestore(manifestPathOrDir, options = {}) {
|
|
18419
18424
|
let manifestPath = resolve3(manifestPathOrDir);
|
|
18420
18425
|
const stat = lstatSync2(manifestPath, { throwIfNoEntry: false });
|
|
18421
18426
|
if (!stat) {
|
|
@@ -18438,7 +18443,7 @@ function restoreBackup(manifestPathOrDir, options = {}) {
|
|
|
18438
18443
|
if (manifest.schema !== "kxm.backup-manifest.v1" || !Array.isArray(manifest.stores) || manifest.stores.length === 0) {
|
|
18439
18444
|
throw databaseError("restore_manifest_invalid", manifestPath, "manifest is not a valid kxm.backup-manifest.v1 document");
|
|
18440
18445
|
}
|
|
18441
|
-
const
|
|
18446
|
+
const stores = [];
|
|
18442
18447
|
for (const store of manifest.stores) {
|
|
18443
18448
|
const backupFilePath = join4(manifestDir, store.backupFile);
|
|
18444
18449
|
if (!existsSync4(backupFilePath)) {
|
|
@@ -18452,24 +18457,35 @@ function restoreBackup(manifestPathOrDir, options = {}) {
|
|
|
18452
18457
|
`backup file ${store.backupFile} sha256 ${actualSha256} does not match manifest hash ${store.sha256}`
|
|
18453
18458
|
);
|
|
18454
18459
|
}
|
|
18455
|
-
const
|
|
18460
|
+
const maxSupportedVersion = kxmBackupCeiling(store.storeId);
|
|
18461
|
+
if (store.schemaVersion > maxSupportedVersion) {
|
|
18462
|
+
throw databaseError(
|
|
18463
|
+
"runtime_schema_newer",
|
|
18464
|
+
backupFilePath,
|
|
18465
|
+
`backup store ${store.storeId} schema version ${store.schemaVersion} is newer than supported maximum ${maxSupportedVersion}`
|
|
18466
|
+
);
|
|
18467
|
+
}
|
|
18456
18468
|
let targetPath = store.sourcePath;
|
|
18457
18469
|
if (options.projectRoot && manifest.projectRoot && targetPath.startsWith(manifest.projectRoot)) {
|
|
18458
18470
|
const rel = targetPath.slice(manifest.projectRoot.length).replace(/^[\\/]+/, "");
|
|
18459
18471
|
targetPath = join4(resolve3(options.projectRoot), rel);
|
|
18460
18472
|
}
|
|
18461
|
-
|
|
18462
|
-
backupFilePath,
|
|
18463
|
-
targetPath,
|
|
18464
|
-
store.storeId,
|
|
18465
|
-
store.schemaVersion,
|
|
18466
|
-
maxSupported
|
|
18467
|
-
);
|
|
18468
|
-
restoredStores.push(result);
|
|
18473
|
+
stores.push({ storeId: store.storeId, backupFilePath, targetPath, schemaVersion: store.schemaVersion, maxSupportedVersion });
|
|
18469
18474
|
}
|
|
18475
|
+
return { manifestPath, backupId: manifest.backupId, stores };
|
|
18476
|
+
}
|
|
18477
|
+
function restoreBackup(manifestPathOrDir, options = {}) {
|
|
18478
|
+
const plan = planRestore(manifestPathOrDir, options);
|
|
18479
|
+
const restoredStores = plan.stores.map((store) => restoreDatabaseFile(
|
|
18480
|
+
store.backupFilePath,
|
|
18481
|
+
store.targetPath,
|
|
18482
|
+
store.storeId,
|
|
18483
|
+
store.schemaVersion,
|
|
18484
|
+
store.maxSupportedVersion
|
|
18485
|
+
));
|
|
18470
18486
|
return {
|
|
18471
|
-
manifestPath,
|
|
18472
|
-
backupId:
|
|
18487
|
+
manifestPath: plan.manifestPath,
|
|
18488
|
+
backupId: plan.backupId,
|
|
18473
18489
|
restoredStores
|
|
18474
18490
|
};
|
|
18475
18491
|
}
|
|
@@ -31436,7 +31452,9 @@ export {
|
|
|
31436
31452
|
parsePiOneShotUsage,
|
|
31437
31453
|
parseSshConfig,
|
|
31438
31454
|
persistKxmRunState,
|
|
31455
|
+
planBackup,
|
|
31439
31456
|
planHarnessUpdate,
|
|
31457
|
+
planRestore,
|
|
31440
31458
|
probeHarnessAssignment,
|
|
31441
31459
|
probeHarnessAssignmentAsync,
|
|
31442
31460
|
probeHarnesses,
|