@kontextmind/kxm 0.7.102 → 0.7.104
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/CHANGELOG.md +30 -9
- package/docs/concepts/data-and-storage.md +1 -1
- package/docs/contributing/test-matrix.md +7 -5
- package/docs/operations/backup-and-restore.md +59 -27
- package/docs/operations/deploy.md +1 -1
- package/docs/reference/cli-reference.md +32 -21
- package/docs/reference/config-reference.md +4 -2
- package/docs/reference/harness-routing.md +5 -5
- package/docs/reference/workflow-catalog.md +1 -1
- package/docs/start/quickstart-claude-code.md +1 -1
- package/docs/templates/runbook.md +2 -1
- package/package.json +1 -1
- package/plugins/kxm/.claude-plugin/plugin.json +1 -1
- package/plugins/kxm/dist/cli.js +788 -651
- package/plugins/kxm/dist/mcp-server.js +1 -1
- package/plugins/kxm/dist/runtime-supervisor.js +321 -291
- package/plugins/kxm/dist/runtime.js +424 -348
- package/plugins/kxm/dist/server.js +78 -78
- package/plugins/kxm/package.json +1 -1
- package/plugins/kxm/skills/kxm-hub-ops/SKILL.md +14 -7
- package/plugins/kxm/src/cli/project.ts +66 -12
- package/plugins/kxm/src/cli.ts +7 -5
- package/plugins/kxm/src/database.ts +193 -65
- package/plugins/kxm/src/init-guide-setup.ts +9 -4
- package/plugins/kxm/src/mcp-server.ts +1 -1
- package/plugins/kxm/src/runtime-paths.ts +50 -0
- package/plugins/kxm/src/runtime-store.ts +22 -53
- package/plugins/kxm/src/runtime-supervisor.ts +38 -17
- package/schemas/backup-manifest.schema.json +15 -0
|
@@ -2987,7 +2987,7 @@ var require_compile = __commonJS({
|
|
|
2987
2987
|
const schOrFunc = root.refs[ref];
|
|
2988
2988
|
if (schOrFunc)
|
|
2989
2989
|
return schOrFunc;
|
|
2990
|
-
let _sch =
|
|
2990
|
+
let _sch = resolve11.call(this, root, ref);
|
|
2991
2991
|
if (_sch === void 0) {
|
|
2992
2992
|
const schema = (_a = root.localRefs) === null || _a === void 0 ? void 0 : _a[ref];
|
|
2993
2993
|
const { schemaId } = this.opts;
|
|
@@ -3014,7 +3014,7 @@ var require_compile = __commonJS({
|
|
|
3014
3014
|
function sameSchemaEnv(s1, s2) {
|
|
3015
3015
|
return s1.schema === s2.schema && s1.root === s2.root && s1.baseId === s2.baseId;
|
|
3016
3016
|
}
|
|
3017
|
-
function
|
|
3017
|
+
function resolve11(root, ref) {
|
|
3018
3018
|
let sch;
|
|
3019
3019
|
while (typeof (sch = this.refs[ref]) == "string")
|
|
3020
3020
|
ref = sch;
|
|
@@ -3839,7 +3839,7 @@ var require_fast_uri = __commonJS({
|
|
|
3839
3839
|
}
|
|
3840
3840
|
return uri;
|
|
3841
3841
|
}
|
|
3842
|
-
function
|
|
3842
|
+
function resolve11(baseURI, relativeURI, options) {
|
|
3843
3843
|
const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" };
|
|
3844
3844
|
const {
|
|
3845
3845
|
parsed: baseParsed,
|
|
@@ -3872,49 +3872,49 @@ var require_fast_uri = __commonJS({
|
|
|
3872
3872
|
schemelessOptions.skipEscape = true;
|
|
3873
3873
|
return serialize(resolved, schemelessOptions);
|
|
3874
3874
|
}
|
|
3875
|
-
function resolveComponent(base,
|
|
3875
|
+
function resolveComponent(base, relative5, options, skipNormalization) {
|
|
3876
3876
|
const target = {};
|
|
3877
3877
|
if (!skipNormalization) {
|
|
3878
3878
|
base = parse7(serialize(base, options), options);
|
|
3879
|
-
|
|
3879
|
+
relative5 = parse7(serialize(relative5, options), options);
|
|
3880
3880
|
}
|
|
3881
3881
|
options = options || {};
|
|
3882
|
-
if (!options.tolerant &&
|
|
3883
|
-
target.scheme =
|
|
3884
|
-
target.userinfo =
|
|
3885
|
-
target.host =
|
|
3886
|
-
target.port =
|
|
3887
|
-
target.path = removeDotSegments(
|
|
3888
|
-
target.query =
|
|
3882
|
+
if (!options.tolerant && relative5.scheme) {
|
|
3883
|
+
target.scheme = relative5.scheme;
|
|
3884
|
+
target.userinfo = relative5.userinfo;
|
|
3885
|
+
target.host = relative5.host;
|
|
3886
|
+
target.port = relative5.port;
|
|
3887
|
+
target.path = removeDotSegments(relative5.path || "");
|
|
3888
|
+
target.query = relative5.query;
|
|
3889
3889
|
} else {
|
|
3890
|
-
if (
|
|
3891
|
-
target.userinfo =
|
|
3892
|
-
target.host =
|
|
3893
|
-
target.port =
|
|
3894
|
-
target.path = removeDotSegments(
|
|
3895
|
-
target.query =
|
|
3890
|
+
if (relative5.userinfo !== void 0 || relative5.host !== void 0 || relative5.port !== void 0) {
|
|
3891
|
+
target.userinfo = relative5.userinfo;
|
|
3892
|
+
target.host = relative5.host;
|
|
3893
|
+
target.port = relative5.port;
|
|
3894
|
+
target.path = removeDotSegments(relative5.path || "");
|
|
3895
|
+
target.query = relative5.query;
|
|
3896
3896
|
} else {
|
|
3897
|
-
if (!
|
|
3897
|
+
if (!relative5.path) {
|
|
3898
3898
|
target.path = base.path;
|
|
3899
|
-
if (
|
|
3900
|
-
target.query =
|
|
3899
|
+
if (relative5.query !== void 0) {
|
|
3900
|
+
target.query = relative5.query;
|
|
3901
3901
|
} else {
|
|
3902
3902
|
target.query = base.query;
|
|
3903
3903
|
}
|
|
3904
3904
|
} else {
|
|
3905
|
-
if (
|
|
3906
|
-
target.path = removeDotSegments(
|
|
3905
|
+
if (relative5.path[0] === "/") {
|
|
3906
|
+
target.path = removeDotSegments(relative5.path);
|
|
3907
3907
|
} else {
|
|
3908
3908
|
if ((base.userinfo !== void 0 || base.host !== void 0 || base.port !== void 0) && !base.path) {
|
|
3909
|
-
target.path = "/" +
|
|
3909
|
+
target.path = "/" + relative5.path;
|
|
3910
3910
|
} else if (!base.path) {
|
|
3911
|
-
target.path =
|
|
3911
|
+
target.path = relative5.path;
|
|
3912
3912
|
} else {
|
|
3913
|
-
target.path = base.path.slice(0, base.path.lastIndexOf("/") + 1) +
|
|
3913
|
+
target.path = base.path.slice(0, base.path.lastIndexOf("/") + 1) + relative5.path;
|
|
3914
3914
|
}
|
|
3915
3915
|
target.path = removeDotSegments(target.path);
|
|
3916
3916
|
}
|
|
3917
|
-
target.query =
|
|
3917
|
+
target.query = relative5.query;
|
|
3918
3918
|
}
|
|
3919
3919
|
target.userinfo = base.userinfo;
|
|
3920
3920
|
target.host = base.host;
|
|
@@ -3922,7 +3922,7 @@ var require_fast_uri = __commonJS({
|
|
|
3922
3922
|
}
|
|
3923
3923
|
target.scheme = base.scheme;
|
|
3924
3924
|
}
|
|
3925
|
-
target.fragment =
|
|
3925
|
+
target.fragment = relative5.fragment;
|
|
3926
3926
|
return target;
|
|
3927
3927
|
}
|
|
3928
3928
|
function equal(uriA, uriB, options) {
|
|
@@ -4201,7 +4201,7 @@ var require_fast_uri = __commonJS({
|
|
|
4201
4201
|
var fastUri = {
|
|
4202
4202
|
SCHEMES,
|
|
4203
4203
|
normalize,
|
|
4204
|
-
resolve:
|
|
4204
|
+
resolve: resolve11,
|
|
4205
4205
|
resolveComponent,
|
|
4206
4206
|
equal,
|
|
4207
4207
|
serialize,
|
|
@@ -11411,10 +11411,10 @@ var require_resolve_block_map = __commonJS({
|
|
|
11411
11411
|
let offset = bm.offset;
|
|
11412
11412
|
let commentEnd = null;
|
|
11413
11413
|
for (const collItem of bm.items) {
|
|
11414
|
-
const { start, key, sep:
|
|
11414
|
+
const { start, key, sep: sep4, value } = collItem;
|
|
11415
11415
|
const keyProps = resolveProps.resolveProps(start, {
|
|
11416
11416
|
indicator: "explicit-key-ind",
|
|
11417
|
-
next: key ??
|
|
11417
|
+
next: key ?? sep4?.[0],
|
|
11418
11418
|
offset,
|
|
11419
11419
|
onError,
|
|
11420
11420
|
parentIndent: bm.indent,
|
|
@@ -11428,7 +11428,7 @@ var require_resolve_block_map = __commonJS({
|
|
|
11428
11428
|
else if ("indent" in key && key.indent !== bm.indent)
|
|
11429
11429
|
onError(offset, "BAD_INDENT", startColMsg);
|
|
11430
11430
|
}
|
|
11431
|
-
if (!keyProps.anchor && !keyProps.tag && !
|
|
11431
|
+
if (!keyProps.anchor && !keyProps.tag && !sep4) {
|
|
11432
11432
|
commentEnd = keyProps.end;
|
|
11433
11433
|
if (keyProps.comment) {
|
|
11434
11434
|
if (map.comment)
|
|
@@ -11452,7 +11452,7 @@ var require_resolve_block_map = __commonJS({
|
|
|
11452
11452
|
ctx.atKey = false;
|
|
11453
11453
|
if (utilMapIncludes.mapIncludes(ctx, map.items, keyNode))
|
|
11454
11454
|
onError(keyStart, "DUPLICATE_KEY", "Map keys must be unique");
|
|
11455
|
-
const valueProps = resolveProps.resolveProps(
|
|
11455
|
+
const valueProps = resolveProps.resolveProps(sep4 ?? [], {
|
|
11456
11456
|
indicator: "map-value-ind",
|
|
11457
11457
|
next: value,
|
|
11458
11458
|
offset: keyNode.range[2],
|
|
@@ -11468,7 +11468,7 @@ var require_resolve_block_map = __commonJS({
|
|
|
11468
11468
|
if (ctx.options.strict && keyProps.start < valueProps.found.offset - 1024)
|
|
11469
11469
|
onError(keyNode.range, "KEY_OVER_1024_CHARS", "The : indicator must be at most 1024 chars after the start of an implicit block mapping key");
|
|
11470
11470
|
}
|
|
11471
|
-
const valueNode = value ? composeNode(ctx, value, valueProps, onError) : composeEmptyNode(ctx, offset,
|
|
11471
|
+
const valueNode = value ? composeNode(ctx, value, valueProps, onError) : composeEmptyNode(ctx, offset, sep4, null, valueProps, onError);
|
|
11472
11472
|
if (ctx.schema.compat)
|
|
11473
11473
|
utilFlowIndentCheck.flowIndentCheck(bm.indent, value, onError);
|
|
11474
11474
|
offset = valueNode.range[2];
|
|
@@ -11559,7 +11559,7 @@ var require_resolve_end = __commonJS({
|
|
|
11559
11559
|
let comment = "";
|
|
11560
11560
|
if (end) {
|
|
11561
11561
|
let hasSpace = false;
|
|
11562
|
-
let
|
|
11562
|
+
let sep4 = "";
|
|
11563
11563
|
for (const token of end) {
|
|
11564
11564
|
const { source, type } = token;
|
|
11565
11565
|
switch (type) {
|
|
@@ -11573,13 +11573,13 @@ var require_resolve_end = __commonJS({
|
|
|
11573
11573
|
if (!comment)
|
|
11574
11574
|
comment = cb;
|
|
11575
11575
|
else
|
|
11576
|
-
comment +=
|
|
11577
|
-
|
|
11576
|
+
comment += sep4 + cb;
|
|
11577
|
+
sep4 = "";
|
|
11578
11578
|
break;
|
|
11579
11579
|
}
|
|
11580
11580
|
case "newline":
|
|
11581
11581
|
if (comment)
|
|
11582
|
-
|
|
11582
|
+
sep4 += source;
|
|
11583
11583
|
hasSpace = true;
|
|
11584
11584
|
break;
|
|
11585
11585
|
default:
|
|
@@ -11622,18 +11622,18 @@ var require_resolve_flow_collection = __commonJS({
|
|
|
11622
11622
|
let offset = fc.offset + fc.start.source.length;
|
|
11623
11623
|
for (let i = 0; i < fc.items.length; ++i) {
|
|
11624
11624
|
const collItem = fc.items[i];
|
|
11625
|
-
const { start, key, sep:
|
|
11625
|
+
const { start, key, sep: sep4, value } = collItem;
|
|
11626
11626
|
const props = resolveProps.resolveProps(start, {
|
|
11627
11627
|
flow: fcName,
|
|
11628
11628
|
indicator: "explicit-key-ind",
|
|
11629
|
-
next: key ??
|
|
11629
|
+
next: key ?? sep4?.[0],
|
|
11630
11630
|
offset,
|
|
11631
11631
|
onError,
|
|
11632
11632
|
parentIndent: fc.indent,
|
|
11633
11633
|
startOnNewline: false
|
|
11634
11634
|
});
|
|
11635
11635
|
if (!props.found) {
|
|
11636
|
-
if (!props.anchor && !props.tag && !
|
|
11636
|
+
if (!props.anchor && !props.tag && !sep4 && !value) {
|
|
11637
11637
|
if (i === 0 && props.comma)
|
|
11638
11638
|
onError(props.comma, "UNEXPECTED_TOKEN", `Unexpected , in ${fcName}`);
|
|
11639
11639
|
else if (i < fc.items.length - 1)
|
|
@@ -11687,8 +11687,8 @@ var require_resolve_flow_collection = __commonJS({
|
|
|
11687
11687
|
}
|
|
11688
11688
|
}
|
|
11689
11689
|
}
|
|
11690
|
-
if (!isMap2 && !
|
|
11691
|
-
const valueNode = value ? composeNode(ctx, value, props, onError) : composeEmptyNode(ctx, props.end,
|
|
11690
|
+
if (!isMap2 && !sep4 && !props.found) {
|
|
11691
|
+
const valueNode = value ? composeNode(ctx, value, props, onError) : composeEmptyNode(ctx, props.end, sep4, null, props, onError);
|
|
11692
11692
|
coll.items.push(valueNode);
|
|
11693
11693
|
offset = valueNode.range[2];
|
|
11694
11694
|
if (isBlock(value))
|
|
@@ -11700,7 +11700,7 @@ var require_resolve_flow_collection = __commonJS({
|
|
|
11700
11700
|
if (isBlock(key))
|
|
11701
11701
|
onError(keyNode.range, "BLOCK_IN_FLOW", blockMsg);
|
|
11702
11702
|
ctx.atKey = false;
|
|
11703
|
-
const valueProps = resolveProps.resolveProps(
|
|
11703
|
+
const valueProps = resolveProps.resolveProps(sep4 ?? [], {
|
|
11704
11704
|
flow: fcName,
|
|
11705
11705
|
indicator: "map-value-ind",
|
|
11706
11706
|
next: value,
|
|
@@ -11711,8 +11711,8 @@ var require_resolve_flow_collection = __commonJS({
|
|
|
11711
11711
|
});
|
|
11712
11712
|
if (valueProps.found) {
|
|
11713
11713
|
if (!isMap2 && !props.found && ctx.options.strict) {
|
|
11714
|
-
if (
|
|
11715
|
-
for (const st of
|
|
11714
|
+
if (sep4)
|
|
11715
|
+
for (const st of sep4) {
|
|
11716
11716
|
if (st === valueProps.found)
|
|
11717
11717
|
break;
|
|
11718
11718
|
if (st.type === "newline") {
|
|
@@ -11729,7 +11729,7 @@ var require_resolve_flow_collection = __commonJS({
|
|
|
11729
11729
|
else
|
|
11730
11730
|
onError(valueProps.start, "MISSING_CHAR", `Missing , or : between ${fcName} items`);
|
|
11731
11731
|
}
|
|
11732
|
-
const valueNode = value ? composeNode(ctx, value, valueProps, onError) : valueProps.found ? composeEmptyNode(ctx, valueProps.end,
|
|
11732
|
+
const valueNode = value ? composeNode(ctx, value, valueProps, onError) : valueProps.found ? composeEmptyNode(ctx, valueProps.end, sep4, null, valueProps, onError) : null;
|
|
11733
11733
|
if (valueNode) {
|
|
11734
11734
|
if (isBlock(value))
|
|
11735
11735
|
onError(valueNode.range, "BLOCK_IN_FLOW", blockMsg);
|
|
@@ -11909,7 +11909,7 @@ var require_resolve_block_scalar = __commonJS({
|
|
|
11909
11909
|
chompStart = i + 1;
|
|
11910
11910
|
}
|
|
11911
11911
|
let value = "";
|
|
11912
|
-
let
|
|
11912
|
+
let sep4 = "";
|
|
11913
11913
|
let prevMoreIndented = false;
|
|
11914
11914
|
for (let i = 0; i < contentStart; ++i)
|
|
11915
11915
|
value += lines[i][0].slice(trimIndent) + "\n";
|
|
@@ -11926,24 +11926,24 @@ var require_resolve_block_scalar = __commonJS({
|
|
|
11926
11926
|
indent = "";
|
|
11927
11927
|
}
|
|
11928
11928
|
if (type === Scalar.Scalar.BLOCK_LITERAL) {
|
|
11929
|
-
value +=
|
|
11930
|
-
|
|
11929
|
+
value += sep4 + indent.slice(trimIndent) + content;
|
|
11930
|
+
sep4 = "\n";
|
|
11931
11931
|
} else if (indent.length > trimIndent || content[0] === " ") {
|
|
11932
|
-
if (
|
|
11933
|
-
|
|
11934
|
-
else if (!prevMoreIndented &&
|
|
11935
|
-
|
|
11936
|
-
value +=
|
|
11937
|
-
|
|
11932
|
+
if (sep4 === " ")
|
|
11933
|
+
sep4 = "\n";
|
|
11934
|
+
else if (!prevMoreIndented && sep4 === "\n")
|
|
11935
|
+
sep4 = "\n\n";
|
|
11936
|
+
value += sep4 + indent.slice(trimIndent) + content;
|
|
11937
|
+
sep4 = "\n";
|
|
11938
11938
|
prevMoreIndented = true;
|
|
11939
11939
|
} else if (content === "") {
|
|
11940
|
-
if (
|
|
11940
|
+
if (sep4 === "\n")
|
|
11941
11941
|
value += "\n";
|
|
11942
11942
|
else
|
|
11943
|
-
|
|
11943
|
+
sep4 = "\n";
|
|
11944
11944
|
} else {
|
|
11945
|
-
value +=
|
|
11946
|
-
|
|
11945
|
+
value += sep4 + content;
|
|
11946
|
+
sep4 = " ";
|
|
11947
11947
|
prevMoreIndented = false;
|
|
11948
11948
|
}
|
|
11949
11949
|
}
|
|
@@ -12126,25 +12126,25 @@ var require_resolve_flow_scalar = __commonJS({
|
|
|
12126
12126
|
trimBoth = /^[ \t]+|[ \t]+$/g;
|
|
12127
12127
|
}
|
|
12128
12128
|
let res = match[1].replace(trimEnd, "");
|
|
12129
|
-
let
|
|
12129
|
+
let sep4 = " ";
|
|
12130
12130
|
let pos = line.lastIndex;
|
|
12131
12131
|
while (match = line.exec(source)) {
|
|
12132
12132
|
const lm = match[1].replace(trimBoth, "");
|
|
12133
12133
|
if (lm === "") {
|
|
12134
|
-
if (
|
|
12135
|
-
res +=
|
|
12134
|
+
if (sep4 === "\n")
|
|
12135
|
+
res += sep4;
|
|
12136
12136
|
else
|
|
12137
|
-
|
|
12137
|
+
sep4 = "\n";
|
|
12138
12138
|
} else {
|
|
12139
|
-
res +=
|
|
12140
|
-
|
|
12139
|
+
res += sep4 + lm;
|
|
12140
|
+
sep4 = " ";
|
|
12141
12141
|
}
|
|
12142
12142
|
pos = line.lastIndex;
|
|
12143
12143
|
}
|
|
12144
12144
|
const last = /[ \t]*(.*)/sy;
|
|
12145
12145
|
last.lastIndex = pos;
|
|
12146
12146
|
match = last.exec(source);
|
|
12147
|
-
return res +
|
|
12147
|
+
return res + sep4 + (match?.[1] ?? "");
|
|
12148
12148
|
}
|
|
12149
12149
|
function doubleQuotedValue(source, onError) {
|
|
12150
12150
|
let res = "";
|
|
@@ -12954,14 +12954,14 @@ var require_cst_stringify = __commonJS({
|
|
|
12954
12954
|
}
|
|
12955
12955
|
}
|
|
12956
12956
|
}
|
|
12957
|
-
function stringifyItem({ start, key, sep:
|
|
12957
|
+
function stringifyItem({ start, key, sep: sep4, value }) {
|
|
12958
12958
|
let res = "";
|
|
12959
12959
|
for (const st of start)
|
|
12960
12960
|
res += st.source;
|
|
12961
12961
|
if (key)
|
|
12962
12962
|
res += stringifyToken(key);
|
|
12963
|
-
if (
|
|
12964
|
-
for (const st of
|
|
12963
|
+
if (sep4)
|
|
12964
|
+
for (const st of sep4)
|
|
12965
12965
|
res += st.source;
|
|
12966
12966
|
if (value)
|
|
12967
12967
|
res += stringifyToken(value);
|
|
@@ -14128,18 +14128,18 @@ var require_parser = __commonJS({
|
|
|
14128
14128
|
if (this.type === "map-value-ind") {
|
|
14129
14129
|
const prev = getPrevProps(this.peek(2));
|
|
14130
14130
|
const start = getFirstKeyStartProps(prev);
|
|
14131
|
-
let
|
|
14131
|
+
let sep4;
|
|
14132
14132
|
if (scalar.end) {
|
|
14133
|
-
|
|
14134
|
-
|
|
14133
|
+
sep4 = scalar.end;
|
|
14134
|
+
sep4.push(this.sourceToken);
|
|
14135
14135
|
delete scalar.end;
|
|
14136
14136
|
} else
|
|
14137
|
-
|
|
14137
|
+
sep4 = [this.sourceToken];
|
|
14138
14138
|
const map = {
|
|
14139
14139
|
type: "block-map",
|
|
14140
14140
|
offset: scalar.offset,
|
|
14141
14141
|
indent: scalar.indent,
|
|
14142
|
-
items: [{ start, key: scalar, sep:
|
|
14142
|
+
items: [{ start, key: scalar, sep: sep4 }]
|
|
14143
14143
|
};
|
|
14144
14144
|
this.onKeyLine = true;
|
|
14145
14145
|
this.stack[this.stack.length - 1] = map;
|
|
@@ -14292,15 +14292,15 @@ var require_parser = __commonJS({
|
|
|
14292
14292
|
} else if (isFlowToken(it.key) && !includesToken(it.sep, "newline")) {
|
|
14293
14293
|
const start2 = getFirstKeyStartProps(it.start);
|
|
14294
14294
|
const key = it.key;
|
|
14295
|
-
const
|
|
14296
|
-
|
|
14295
|
+
const sep4 = it.sep;
|
|
14296
|
+
sep4.push(this.sourceToken);
|
|
14297
14297
|
delete it.key;
|
|
14298
14298
|
delete it.sep;
|
|
14299
14299
|
this.stack.push({
|
|
14300
14300
|
type: "block-map",
|
|
14301
14301
|
offset: this.offset,
|
|
14302
14302
|
indent: this.indent,
|
|
14303
|
-
items: [{ start: start2, key, sep:
|
|
14303
|
+
items: [{ start: start2, key, sep: sep4 }]
|
|
14304
14304
|
});
|
|
14305
14305
|
} else if (start.length > 0) {
|
|
14306
14306
|
it.sep = it.sep.concat(start, this.sourceToken);
|
|
@@ -14494,13 +14494,13 @@ var require_parser = __commonJS({
|
|
|
14494
14494
|
const prev = getPrevProps(parent);
|
|
14495
14495
|
const start = getFirstKeyStartProps(prev);
|
|
14496
14496
|
fixFlowSeqItems(fc);
|
|
14497
|
-
const
|
|
14498
|
-
|
|
14497
|
+
const sep4 = fc.end.splice(1, fc.end.length);
|
|
14498
|
+
sep4.push(this.sourceToken);
|
|
14499
14499
|
const map = {
|
|
14500
14500
|
type: "block-map",
|
|
14501
14501
|
offset: fc.offset,
|
|
14502
14502
|
indent: fc.indent,
|
|
14503
|
-
items: [{ start, key: fc, sep:
|
|
14503
|
+
items: [{ start, key: fc, sep: sep4 }]
|
|
14504
14504
|
};
|
|
14505
14505
|
this.onKeyLine = true;
|
|
14506
14506
|
this.stack[this.stack.length - 1] = map;
|
|
@@ -14780,10 +14780,10 @@ var require_dist = __commonJS({
|
|
|
14780
14780
|
|
|
14781
14781
|
// plugins/kxm/src/runtime-supervisor.ts
|
|
14782
14782
|
import { spawn as spawn3 } from "node:child_process";
|
|
14783
|
-
import { createHash as
|
|
14784
|
-
import { chmodSync as chmodSync2, existsSync as
|
|
14783
|
+
import { createHash as createHash14, createHmac, randomBytes as randomBytes2, timingSafeEqual as timingSafeEqual2 } from "node:crypto";
|
|
14784
|
+
import { chmodSync as chmodSync2, existsSync as existsSync16, lstatSync as lstatSync5, mkdirSync as mkdirSync9, readFileSync as readFileSync12, renameSync as renameSync5, rmSync as rmSync4, writeFileSync as writeFileSync9 } from "node:fs";
|
|
14785
14785
|
import { createServer } from "node:http";
|
|
14786
|
-
import { dirname as dirname11, isAbsolute as
|
|
14786
|
+
import { dirname as dirname11, isAbsolute as isAbsolute7, join as join19 } from "node:path";
|
|
14787
14787
|
|
|
14788
14788
|
// plugins/kxm/src/repo-root.ts
|
|
14789
14789
|
import { existsSync } from "node:fs";
|
|
@@ -15197,7 +15197,7 @@ function defaultSpawn(command, args, options) {
|
|
|
15197
15197
|
if (options.signal?.aborted) {
|
|
15198
15198
|
return Promise.resolve({ stdout: "", stderr: "", code: null, started: false, observedChildExit: false, error: new Error("process_aborted") });
|
|
15199
15199
|
}
|
|
15200
|
-
return new Promise((
|
|
15200
|
+
return new Promise((resolve11) => {
|
|
15201
15201
|
const stdout = [];
|
|
15202
15202
|
const stderr = [];
|
|
15203
15203
|
let outputBytes = 0;
|
|
@@ -15228,7 +15228,7 @@ function defaultSpawn(command, args, options) {
|
|
|
15228
15228
|
const started = Boolean(child?.pid);
|
|
15229
15229
|
if (started && !observedChildExit) error ??= new Error("process_exit_unobserved");
|
|
15230
15230
|
const unverifiedDescendants = stopping || started && !observedChildExit;
|
|
15231
|
-
|
|
15231
|
+
resolve11({
|
|
15232
15232
|
stdout: Buffer.concat(stdout).toString("utf8"),
|
|
15233
15233
|
stderr: Buffer.concat(stderr).toString("utf8"),
|
|
15234
15234
|
code,
|
|
@@ -17005,8 +17005,8 @@ function validateWorkflow(workflow, agents, models, repositories, gates, issues)
|
|
|
17005
17005
|
const writable = Object.values(objectValue(step.repositories) ?? {}).filter((access) => access === "write").length;
|
|
17006
17006
|
if (maxWriteRepositories > writable) issues.push(issue2("semantic", "write_repository_bound_invalid", file, `${stepId} maxWriteRepositories exceeds writable repository scope`));
|
|
17007
17007
|
}
|
|
17008
|
-
const
|
|
17009
|
-
const minimumPassed =
|
|
17008
|
+
const join20 = objectValue(step.join);
|
|
17009
|
+
const minimumPassed = join20 && typeof join20.minimumPassed === "number" ? join20.minimumPassed : void 0;
|
|
17010
17010
|
if (minimumPassed !== void 0 && minimumPassed > maximum) issues.push(issue2("semantic", "join_impossible", file, `${stepId} minimumPassed exceeds assignment maximum`));
|
|
17011
17011
|
const distinctBy = names(assignment?.distinctBy);
|
|
17012
17012
|
if (distinctBy.length > 0) {
|
|
@@ -17490,12 +17490,15 @@ function legacyConfigFilesAt(root) {
|
|
|
17490
17490
|
}
|
|
17491
17491
|
|
|
17492
17492
|
// plugins/kxm/src/runtime-store.ts
|
|
17493
|
-
import { createHash as
|
|
17494
|
-
import { existsSync as
|
|
17495
|
-
import { dirname as dirname5,
|
|
17493
|
+
import { createHash as createHash5, randomUUID } from "node:crypto";
|
|
17494
|
+
import { existsSync as existsSync6, lstatSync as lstatSync3, mkdirSync as mkdirSync2, readFileSync as readFileSync3, writeFileSync as writeFileSync2 } from "node:fs";
|
|
17495
|
+
import { dirname as dirname5, resolve as resolve6 } from "node:path";
|
|
17496
17496
|
|
|
17497
17497
|
// plugins/kxm/src/sqlite.ts
|
|
17498
|
+
import { existsSync as existsSync4 } from "node:fs";
|
|
17498
17499
|
import { createRequire } from "node:module";
|
|
17500
|
+
import { resolve as resolve2 } from "node:path";
|
|
17501
|
+
import { pathToFileURL } from "node:url";
|
|
17499
17502
|
var requireFromHere = createRequire(import.meta.url);
|
|
17500
17503
|
function loadNative() {
|
|
17501
17504
|
try {
|
|
@@ -17532,10 +17535,21 @@ var DatabaseSync = class {
|
|
|
17532
17535
|
this.inner.close();
|
|
17533
17536
|
}
|
|
17534
17537
|
};
|
|
17538
|
+
function openReadOnlyDatabase(path) {
|
|
17539
|
+
if (existsSync4(`${path}-wal`)) return new DatabaseSync(path, { readOnly: true });
|
|
17540
|
+
const uri = pathToFileURL(resolve2(path));
|
|
17541
|
+
uri.searchParams.set("immutable", "1");
|
|
17542
|
+
return new DatabaseSync(uri.href, { readOnly: true });
|
|
17543
|
+
}
|
|
17544
|
+
|
|
17545
|
+
// plugins/kxm/src/runtime-paths.ts
|
|
17546
|
+
import { createHash as createHash3 } from "node:crypto";
|
|
17547
|
+
import { realpathSync as realpathSync2 } from "node:fs";
|
|
17548
|
+
import { join as join4, resolve as resolve4 } from "node:path";
|
|
17535
17549
|
|
|
17536
17550
|
// plugins/kxm/src/bindings.ts
|
|
17537
17551
|
import { homedir } from "node:os";
|
|
17538
|
-
import { dirname as dirname3, isAbsolute as isAbsolute2, join as join3, parse, relative as relative2, resolve as
|
|
17552
|
+
import { dirname as dirname3, isAbsolute as isAbsolute2, join as join3, parse, relative as relative2, resolve as resolve3, sep as sep2 } from "node:path";
|
|
17539
17553
|
var MAX_BINDING_RECORD_BYTES = 256 * 1024;
|
|
17540
17554
|
var BINDING_LABEL = "Runtime-local repository bindings";
|
|
17541
17555
|
function bindingIssue(phase, code, message) {
|
|
@@ -17551,21 +17565,43 @@ function kxmUserStateRoot(options = {}) {
|
|
|
17551
17565
|
const explicit = options.stateRoot ?? env.KXM_STATE_HOME?.trim();
|
|
17552
17566
|
if (explicit) {
|
|
17553
17567
|
if (!isAbsolute2(explicit)) bindingError("path", "local_state_root_not_absolute", "KXM_STATE_HOME must be an absolute host-local path");
|
|
17554
|
-
return
|
|
17568
|
+
return resolve3(explicit);
|
|
17555
17569
|
}
|
|
17556
17570
|
if (platform === "win32") {
|
|
17557
17571
|
const localAppData = env.LOCALAPPDATA?.trim();
|
|
17558
17572
|
const base2 = localAppData && isAbsolute2(localAppData) ? localAppData : join3(home, "AppData", "Local");
|
|
17559
|
-
return
|
|
17573
|
+
return resolve3(base2, "KXM");
|
|
17560
17574
|
}
|
|
17561
|
-
if (platform === "darwin") return
|
|
17575
|
+
if (platform === "darwin") return resolve3(home, "Library", "Application Support", "KXM");
|
|
17562
17576
|
const xdgState = env.XDG_STATE_HOME?.trim();
|
|
17563
17577
|
const base = xdgState && isAbsolute2(xdgState) ? xdgState : join3(home, ".local", "state");
|
|
17564
|
-
return
|
|
17578
|
+
return resolve3(base, "kxm");
|
|
17579
|
+
}
|
|
17580
|
+
|
|
17581
|
+
// plugins/kxm/src/runtime-paths.ts
|
|
17582
|
+
function kxmRuntimePaths(options = {}) {
|
|
17583
|
+
const stateRoot = options.stateRoot ? resolve4(options.stateRoot) : kxmUserStateRoot({ ...options.env ? { env: options.env } : {}, ...options.homeDir ? { homeDir: options.homeDir } : {} });
|
|
17584
|
+
const runtimeDir = join4(stateRoot, "runtime");
|
|
17585
|
+
return {
|
|
17586
|
+
stateRoot,
|
|
17587
|
+
runtimeDir,
|
|
17588
|
+
registryDb: join4(runtimeDir, "registry.db"),
|
|
17589
|
+
projectsDir: join4(runtimeDir, "projects")
|
|
17590
|
+
};
|
|
17591
|
+
}
|
|
17592
|
+
function projectRuntimeKey(projectRoot) {
|
|
17593
|
+
let canonical;
|
|
17594
|
+
try {
|
|
17595
|
+
canonical = realpathSync2.native(resolve4(projectRoot));
|
|
17596
|
+
} catch {
|
|
17597
|
+
canonical = resolve4(projectRoot);
|
|
17598
|
+
}
|
|
17599
|
+
const folded = process.platform === "win32" ? canonical.toLocaleLowerCase("en-US") : canonical;
|
|
17600
|
+
return createHash3("sha256").update(folded, "utf8").digest("hex").slice(0, 24);
|
|
17565
17601
|
}
|
|
17566
17602
|
|
|
17567
17603
|
// plugins/kxm/src/sync-transform.ts
|
|
17568
|
-
import { createHash as
|
|
17604
|
+
import { createHash as createHash4 } from "node:crypto";
|
|
17569
17605
|
|
|
17570
17606
|
// plugins/kxm/src/redact.ts
|
|
17571
17607
|
var SECRET_PATTERNS = [
|
|
@@ -17604,7 +17640,7 @@ var KXM_DEFAULT_SYNC_POLICY = Object.freeze({
|
|
|
17604
17640
|
diffs: false,
|
|
17605
17641
|
environmentValues: false
|
|
17606
17642
|
});
|
|
17607
|
-
var KXM_DEFAULT_SYNC_POLICY_REVISION = `sha256:${
|
|
17643
|
+
var KXM_DEFAULT_SYNC_POLICY_REVISION = `sha256:${createHash4("sha256").update(kxmCanonicalJson(KXM_DEFAULT_SYNC_POLICY), "utf8").digest("hex")}`;
|
|
17608
17644
|
var MIN_REGISTERED_SECRET_CHARS = 4;
|
|
17609
17645
|
var REDACTED = "[redacted]";
|
|
17610
17646
|
var PATH_REDACTED = "[path]";
|
|
@@ -17899,7 +17935,7 @@ function kxmSyncEventBytes(event) {
|
|
|
17899
17935
|
import {
|
|
17900
17936
|
chmodSync,
|
|
17901
17937
|
copyFileSync,
|
|
17902
|
-
existsSync as
|
|
17938
|
+
existsSync as existsSync5,
|
|
17903
17939
|
lstatSync as lstatSync2,
|
|
17904
17940
|
mkdirSync,
|
|
17905
17941
|
readdirSync as readdirSync2,
|
|
@@ -17907,14 +17943,14 @@ import {
|
|
|
17907
17943
|
unlinkSync,
|
|
17908
17944
|
writeFileSync
|
|
17909
17945
|
} from "node:fs";
|
|
17910
|
-
import { basename as basename2, dirname as dirname4, join as
|
|
17946
|
+
import { basename as basename2, dirname as dirname4, isAbsolute as isAbsolute3, join as join5, relative as relative3, resolve as resolve5, sep as sep3 } from "node:path";
|
|
17911
17947
|
function databaseError(code, file, message) {
|
|
17912
17948
|
const issue3 = { phase: "semantic", code, file, message };
|
|
17913
17949
|
return new KxmConfigError([issue3]);
|
|
17914
17950
|
}
|
|
17915
17951
|
function checkedParent(path, description) {
|
|
17916
17952
|
const parent = dirname4(path);
|
|
17917
|
-
if (!
|
|
17953
|
+
if (!existsSync5(parent)) mkdirSync(parent, { recursive: true, mode: 448 });
|
|
17918
17954
|
const stat = lstatSync2(parent, { throwIfNoEntry: false });
|
|
17919
17955
|
if (!stat || stat.isSymbolicLink() || !stat.isDirectory()) {
|
|
17920
17956
|
throw databaseError("runtime_path_invalid", description, `${description} parent must be a regular directory, not a link`);
|
|
@@ -18121,32 +18157,12 @@ function withDatabaseTransaction(database, work, mode = "IMMEDIATE", clock = mon
|
|
|
18121
18157
|
}
|
|
18122
18158
|
|
|
18123
18159
|
// plugins/kxm/src/runtime-store.ts
|
|
18124
|
-
function kxmRuntimePaths(options = {}) {
|
|
18125
|
-
const stateRoot = options.stateRoot ? resolve4(options.stateRoot) : kxmUserStateRoot({ ...options.env ? { env: options.env } : {}, ...options.homeDir ? { homeDir: options.homeDir } : {} });
|
|
18126
|
-
const runtimeDir = join5(stateRoot, "runtime");
|
|
18127
|
-
return {
|
|
18128
|
-
stateRoot,
|
|
18129
|
-
runtimeDir,
|
|
18130
|
-
registryDb: join5(runtimeDir, "registry.db"),
|
|
18131
|
-
projectsDir: join5(runtimeDir, "projects")
|
|
18132
|
-
};
|
|
18133
|
-
}
|
|
18134
18160
|
function runtimeIssue(phase, code, file, message) {
|
|
18135
18161
|
return { phase, code, file, message };
|
|
18136
18162
|
}
|
|
18137
18163
|
function runtimeError(code, file, message) {
|
|
18138
18164
|
return new KxmConfigError([runtimeIssue("semantic", code, file, message)]);
|
|
18139
18165
|
}
|
|
18140
|
-
function projectRuntimeKey(projectRoot) {
|
|
18141
|
-
let canonical;
|
|
18142
|
-
try {
|
|
18143
|
-
canonical = realpathSync2.native(resolve4(projectRoot));
|
|
18144
|
-
} catch {
|
|
18145
|
-
canonical = resolve4(projectRoot);
|
|
18146
|
-
}
|
|
18147
|
-
const folded = process.platform === "win32" ? canonical.toLocaleLowerCase("en-US") : canonical;
|
|
18148
|
-
return createHash4("sha256").update(folded, "utf8").digest("hex").slice(0, 24);
|
|
18149
|
-
}
|
|
18150
18166
|
var KXM_REGISTRY_SCHEMA_VERSION = 1;
|
|
18151
18167
|
var REGISTRY_TABLES = {
|
|
18152
18168
|
supervisor: ["singleton_id", "runtime_id", "pid", "port", "token_hash", "started_at", "heartbeat_at", "state"],
|
|
@@ -18172,11 +18188,23 @@ CREATE TABLE projects (
|
|
|
18172
18188
|
registered_at TEXT NOT NULL
|
|
18173
18189
|
) STRICT;
|
|
18174
18190
|
`;
|
|
18191
|
+
function readKxmSupervisorRecord(database) {
|
|
18192
|
+
const row = database.prepare("SELECT runtime_id, pid, port, token_hash, started_at, heartbeat_at, state FROM supervisor WHERE singleton_id = 1").get();
|
|
18193
|
+
return row ? {
|
|
18194
|
+
runtimeId: row.runtime_id,
|
|
18195
|
+
pid: row.pid,
|
|
18196
|
+
port: row.port,
|
|
18197
|
+
tokenHash: row.token_hash,
|
|
18198
|
+
startedAt: row.started_at,
|
|
18199
|
+
heartbeatAt: row.heartbeat_at,
|
|
18200
|
+
state: row.state
|
|
18201
|
+
} : void 0;
|
|
18202
|
+
}
|
|
18175
18203
|
var KxmRuntimeRegistry = class {
|
|
18176
18204
|
path;
|
|
18177
18205
|
database;
|
|
18178
18206
|
constructor(path) {
|
|
18179
|
-
this.path =
|
|
18207
|
+
this.path = resolve6(path);
|
|
18180
18208
|
this.database = openDatabase(this.path, "runtime registry", {
|
|
18181
18209
|
schema: REGISTRY_SCHEMA,
|
|
18182
18210
|
version: KXM_REGISTRY_SCHEMA_VERSION,
|
|
@@ -18250,16 +18278,7 @@ var KxmRuntimeRegistry = class {
|
|
|
18250
18278
|
return Number(result.changes);
|
|
18251
18279
|
}
|
|
18252
18280
|
readSupervisorRow() {
|
|
18253
|
-
|
|
18254
|
-
return row ? {
|
|
18255
|
-
runtimeId: row.runtime_id,
|
|
18256
|
-
pid: row.pid,
|
|
18257
|
-
port: row.port,
|
|
18258
|
-
tokenHash: row.token_hash,
|
|
18259
|
-
startedAt: row.started_at,
|
|
18260
|
-
heartbeatAt: row.heartbeat_at,
|
|
18261
|
-
state: row.state
|
|
18262
|
-
} : void 0;
|
|
18281
|
+
return readKxmSupervisorRecord(this.database);
|
|
18263
18282
|
}
|
|
18264
18283
|
supervisor() {
|
|
18265
18284
|
return this.readSupervisorRow();
|
|
@@ -18275,7 +18294,7 @@ var KxmRuntimeRegistry = class {
|
|
|
18275
18294
|
return rows.map((row) => ({ projectRoot: row.project_root, projectId: row.project_id }));
|
|
18276
18295
|
}
|
|
18277
18296
|
registerProject(registration) {
|
|
18278
|
-
const projectRoot =
|
|
18297
|
+
const projectRoot = resolve6(registration.projectRoot);
|
|
18279
18298
|
const projectKey = projectRuntimeKey(projectRoot);
|
|
18280
18299
|
this.database.exec("BEGIN IMMEDIATE");
|
|
18281
18300
|
try {
|
|
@@ -18350,7 +18369,7 @@ var KxmRuntimeRegistry = class {
|
|
|
18350
18369
|
var KXM_RUN_EVENT_SCHEMA = "kxm.run-event.v1";
|
|
18351
18370
|
function hashKxmDriveLog(events) {
|
|
18352
18371
|
const body = events.map((event) => `${event.eventId}:${event.sequence}`).join("\n");
|
|
18353
|
-
return `sha256:${
|
|
18372
|
+
return `sha256:${createHash5("sha256").update(body, "utf8").digest("hex")}`;
|
|
18354
18373
|
}
|
|
18355
18374
|
function verifyKxmDriveReceipt(receipt, events, foldedStatus, binding) {
|
|
18356
18375
|
const reasons = [];
|
|
@@ -18701,7 +18720,7 @@ var KxmRunEventStore = class {
|
|
|
18701
18720
|
syncRedactor = new KxmSyncRedactor();
|
|
18702
18721
|
database;
|
|
18703
18722
|
constructor(path) {
|
|
18704
|
-
this.path =
|
|
18723
|
+
this.path = resolve6(path);
|
|
18705
18724
|
this.database = openDatabase(this.path, "run event store", {
|
|
18706
18725
|
schema: EVENT_STORE_SCHEMA,
|
|
18707
18726
|
version: KXM_EVENT_STORE_SCHEMA_VERSION,
|
|
@@ -18726,7 +18745,7 @@ var KxmRunEventStore = class {
|
|
|
18726
18745
|
}
|
|
18727
18746
|
readRunPrompts() {
|
|
18728
18747
|
const sidecar = this.runPromptSidecarPath();
|
|
18729
|
-
if (!
|
|
18748
|
+
if (!existsSync6(sidecar)) return {};
|
|
18730
18749
|
try {
|
|
18731
18750
|
const parsed = JSON.parse(readFileSync3(sidecar, "utf8"));
|
|
18732
18751
|
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return {};
|
|
@@ -19584,7 +19603,7 @@ function gateRowContentHash(table, row) {
|
|
|
19584
19603
|
const copy = { ...row };
|
|
19585
19604
|
delete copy.contentHash;
|
|
19586
19605
|
void table;
|
|
19587
|
-
return `sha256:${
|
|
19606
|
+
return `sha256:${createHash5("sha256").update(kxmCanonicalJson(copy), "utf8").digest("hex")}`;
|
|
19588
19607
|
}
|
|
19589
19608
|
function assertClosedGateObservation(kind, row, id = "observation") {
|
|
19590
19609
|
if (row.completeness === "incomplete") return;
|
|
@@ -19814,9 +19833,9 @@ function capabilityFromRow(row) {
|
|
|
19814
19833
|
}
|
|
19815
19834
|
|
|
19816
19835
|
// plugins/kxm/src/runtime-service.ts
|
|
19817
|
-
import { createHash as
|
|
19818
|
-
import { existsSync as
|
|
19819
|
-
import { join as
|
|
19836
|
+
import { createHash as createHash7 } from "node:crypto";
|
|
19837
|
+
import { existsSync as existsSync7, readdirSync as readdirSync3, readFileSync as readFileSync4 } from "node:fs";
|
|
19838
|
+
import { join as join7 } from "node:path";
|
|
19820
19839
|
|
|
19821
19840
|
// plugins/kxm/src/engine-fold.ts
|
|
19822
19841
|
var KXM_RUN_STATE_SCHEMA = "kxm.run-state.v2";
|
|
@@ -21020,7 +21039,7 @@ function isTerminalRunStatus(status) {
|
|
|
21020
21039
|
}
|
|
21021
21040
|
|
|
21022
21041
|
// plugins/kxm/src/engine-plan.ts
|
|
21023
|
-
import { createHash as
|
|
21042
|
+
import { createHash as createHash6 } from "node:crypto";
|
|
21024
21043
|
|
|
21025
21044
|
// plugins/kxm/src/engine-compile.ts
|
|
21026
21045
|
var KXM_COMPILED_WORKFLOW_SCHEMA = "kxm.compiled-workflow.v1";
|
|
@@ -21170,7 +21189,7 @@ function compileStep(step, index, stepIndex, requirePlanHash, sink) {
|
|
|
21170
21189
|
const maxAttempts = compileCountField(step.maxAttempts, 1, `${id}.maxAttempts`, id, sink);
|
|
21171
21190
|
const timeoutMs = compileOptionalDuration(step.timeoutMs, `${id}.timeoutMs`, id, sink);
|
|
21172
21191
|
const assignments = compileAssignments(step, id, agent, sink);
|
|
21173
|
-
const
|
|
21192
|
+
const join20 = compileJoin(step, id, sink);
|
|
21174
21193
|
const requiredEvidence = compileEvidence(step, id, sink);
|
|
21175
21194
|
const transitions = compileTransitions(step, id, index, stepIndex, sink);
|
|
21176
21195
|
const outcomes = Object.keys(transitions).sort(compareCodeUnits4);
|
|
@@ -21198,7 +21217,7 @@ function compileStep(step, index, stepIndex, requirePlanHash, sink) {
|
|
|
21198
21217
|
transitions: orderedTransitions,
|
|
21199
21218
|
requiresPlanHash: requirePlanHash.includes(id),
|
|
21200
21219
|
assignments,
|
|
21201
|
-
join:
|
|
21220
|
+
join: join20
|
|
21202
21221
|
};
|
|
21203
21222
|
if (kind === "agent" || kind === "moa") {
|
|
21204
21223
|
if (!agent) return void 0;
|
|
@@ -21248,15 +21267,15 @@ function compileAssignments(step, stepId, primaryAgentId, sink) {
|
|
|
21248
21267
|
};
|
|
21249
21268
|
}
|
|
21250
21269
|
function compileJoin(step, stepId, sink) {
|
|
21251
|
-
const
|
|
21252
|
-
if (!
|
|
21253
|
-
const declared = stringValue2(
|
|
21270
|
+
const join20 = objectValue2(step.join);
|
|
21271
|
+
if (!join20) return { strategy: "all" };
|
|
21272
|
+
const declared = stringValue2(join20.strategy);
|
|
21254
21273
|
const strategy = declared && JOIN_STRATEGIES.has(declared) ? declared : "all";
|
|
21255
|
-
const minimumPassed = compileOptionalCount(
|
|
21274
|
+
const minimumPassed = compileOptionalCount(join20.minimumPassed, `${stepId}.join.minimumPassed`, stepId, sink);
|
|
21256
21275
|
const compiled = {
|
|
21257
21276
|
strategy,
|
|
21258
21277
|
...minimumPassed !== void 0 ? { minimumPassed } : {},
|
|
21259
|
-
...typeof
|
|
21278
|
+
...typeof join20.cancelRemaining === "boolean" ? { cancelRemaining: join20.cancelRemaining } : {}
|
|
21260
21279
|
};
|
|
21261
21280
|
return compiled;
|
|
21262
21281
|
}
|
|
@@ -21567,7 +21586,7 @@ var JOIN_OPTIONAL = ["minimumPassed", "cancelRemaining"];
|
|
|
21567
21586
|
var EVIDENCE_REQUIRED = ["key", "kind", "minimum", "reusableAcrossAttempts"];
|
|
21568
21587
|
var EVIDENCE_OPTIONAL = ["producerPolicy"];
|
|
21569
21588
|
function kxmSha256(input) {
|
|
21570
|
-
return `sha256:${
|
|
21589
|
+
return `sha256:${createHash6("sha256").update(input, "utf8").digest("hex")}`;
|
|
21571
21590
|
}
|
|
21572
21591
|
function kxmStepAskSha256(plan, stepId, agentId) {
|
|
21573
21592
|
const step = Object.hasOwn(plan.steps, stepId) ? plan.steps[stepId] : void 0;
|
|
@@ -22602,12 +22621,12 @@ function enqueueKxmScheduledRun(storePath, runId, configRevision, bound, start)
|
|
|
22602
22621
|
if (owner.admitted.has(runId) || owner.queue.some((item) => item.runId === runId)) {
|
|
22603
22622
|
return Promise.reject(runtimeError("run_busy", runId, `run ${runId} is already admitted or queued`));
|
|
22604
22623
|
}
|
|
22605
|
-
return new Promise((
|
|
22624
|
+
return new Promise((resolve11, reject) => {
|
|
22606
22625
|
owner.queue.push({
|
|
22607
22626
|
runId,
|
|
22608
22627
|
configRevision,
|
|
22609
22628
|
bound,
|
|
22610
|
-
start: (token) => start(token).then(
|
|
22629
|
+
start: (token) => start(token).then(resolve11, reject),
|
|
22611
22630
|
fail: (error) => reject(error)
|
|
22612
22631
|
});
|
|
22613
22632
|
pump(storePath, owner);
|
|
@@ -22636,7 +22655,7 @@ function compareCodeUnits5(left, right) {
|
|
|
22636
22655
|
return left < right ? -1 : left > right ? 1 : 0;
|
|
22637
22656
|
}
|
|
22638
22657
|
function sha256Of(input) {
|
|
22639
|
-
return `sha256:${
|
|
22658
|
+
return `sha256:${createHash7("sha256").update(input, "utf8").digest("hex")}`;
|
|
22640
22659
|
}
|
|
22641
22660
|
function objectValue3(value) {
|
|
22642
22661
|
return value !== null && typeof value === "object" && !Array.isArray(value) ? value : void 0;
|
|
@@ -22668,11 +22687,11 @@ function kxmToolPolicyRevision(bundle) {
|
|
|
22668
22687
|
return sha256Of(kxmCanonicalJson({ policies, gateRegistry: bundle.gateRegistry?.value ?? null }));
|
|
22669
22688
|
}
|
|
22670
22689
|
function collectMemoryFiles(dir, baseDir, ignoreSubdirs = /* @__PURE__ */ new Set()) {
|
|
22671
|
-
if (!
|
|
22690
|
+
if (!existsSync7(dir)) return [];
|
|
22672
22691
|
const entries = readdirSync3(dir, { withFileTypes: true });
|
|
22673
22692
|
const results = [];
|
|
22674
22693
|
for (const entry of entries) {
|
|
22675
|
-
const fullPath =
|
|
22694
|
+
const fullPath = join7(dir, entry.name);
|
|
22676
22695
|
if (entry.isDirectory()) {
|
|
22677
22696
|
if (ignoreSubdirs.has(entry.name)) continue;
|
|
22678
22697
|
results.push(...collectMemoryFiles(fullPath, baseDir, ignoreSubdirs));
|
|
@@ -22684,16 +22703,16 @@ function collectMemoryFiles(dir, baseDir, ignoreSubdirs = /* @__PURE__ */ new Se
|
|
|
22684
22703
|
return results;
|
|
22685
22704
|
}
|
|
22686
22705
|
function computeKxmMemoryRevision(bundle, options = {}) {
|
|
22687
|
-
const hash =
|
|
22688
|
-
const memoryDir = options.memoryDir ??
|
|
22706
|
+
const hash = createHash7("sha256");
|
|
22707
|
+
const memoryDir = options.memoryDir ?? join7(bundle.projectRoot, ".kxm", "memory");
|
|
22689
22708
|
const memoryFiles = collectMemoryFiles(memoryDir, memoryDir, /* @__PURE__ */ new Set(["candidates"])).sort((left, right) => compareCodeUnits5(left.relPath, right.relPath));
|
|
22690
22709
|
for (const file of memoryFiles) {
|
|
22691
22710
|
hash.update(`memory:${file.relPath}\0`, "utf8");
|
|
22692
22711
|
hash.update(readFileSync4(file.fullPath));
|
|
22693
22712
|
hash.update("\0", "utf8");
|
|
22694
22713
|
}
|
|
22695
|
-
const skillsDir = options.skillsDir ??
|
|
22696
|
-
const promotedSkillsDir =
|
|
22714
|
+
const skillsDir = options.skillsDir ?? join7(bundle.projectRoot, ".kxm", "skills");
|
|
22715
|
+
const promotedSkillsDir = join7(skillsDir, "promoted");
|
|
22697
22716
|
const skillFiles = collectMemoryFiles(promotedSkillsDir, promotedSkillsDir).sort((left, right) => compareCodeUnits5(left.relPath, right.relPath));
|
|
22698
22717
|
for (const file of skillFiles) {
|
|
22699
22718
|
hash.update(`skill:${file.relPath}\0`, "utf8");
|
|
@@ -22769,7 +22788,7 @@ function openKxmRuntimeContext(projectRoot, options) {
|
|
|
22769
22788
|
configRevision: bundle.configRevision,
|
|
22770
22789
|
now: options.now ?? (/* @__PURE__ */ new Date()).toISOString()
|
|
22771
22790
|
});
|
|
22772
|
-
const eventStore = new KxmRunEventStore(
|
|
22791
|
+
const eventStore = new KxmRunEventStore(join7(paths.projectsDir, registration.projectKey, "run-events.db"));
|
|
22773
22792
|
registerKxmRuntimeHandle(eventStore.path);
|
|
22774
22793
|
return {
|
|
22775
22794
|
registry,
|
|
@@ -22836,7 +22855,7 @@ function acceptKxmRun(context, bundle, request, options = {}) {
|
|
|
22836
22855
|
}
|
|
22837
22856
|
const revisions = kxmPolicyRevisions(bundle, options);
|
|
22838
22857
|
const memoryRevision = options.memoryRevision ?? revisions.memoryRevision;
|
|
22839
|
-
const promptSha256 = `sha256:${
|
|
22858
|
+
const promptSha256 = `sha256:${createHash7("sha256").update(request.prompt, "utf8").digest("hex")}`;
|
|
22840
22859
|
return context.eventStore.transaction(() => {
|
|
22841
22860
|
const prior = context.eventStore.command(commandId);
|
|
22842
22861
|
if (prior) {
|
|
@@ -23078,18 +23097,18 @@ function cancelKxmRun(context, runId, options = {}) {
|
|
|
23078
23097
|
}
|
|
23079
23098
|
|
|
23080
23099
|
// plugins/kxm/src/oneshot-producer.ts
|
|
23081
|
-
import { join as
|
|
23100
|
+
import { join as join16 } from "node:path";
|
|
23082
23101
|
|
|
23083
23102
|
// plugins/kxm/src/oneshot-evidence.ts
|
|
23084
|
-
import { createHash as
|
|
23103
|
+
import { createHash as createHash8, randomUUID as randomUUID3 } from "node:crypto";
|
|
23085
23104
|
import { lstat, mkdir, open, rename } from "node:fs/promises";
|
|
23086
|
-
import { join as
|
|
23105
|
+
import { join as join8 } from "node:path";
|
|
23087
23106
|
var ONESHOT_EVIDENCE_SCHEMA = "kxm.oneshot-evidence.v2";
|
|
23088
23107
|
var RETIRED_ONESHOT_EVIDENCE_SCHEMAS = /* @__PURE__ */ new Set(["kxm.oneshot-evidence.v1"]);
|
|
23089
23108
|
var TEXT_LIMIT = 4 * 1024 * 1024;
|
|
23090
23109
|
var ARGV_LIMIT = 64 * 1024;
|
|
23091
23110
|
var RECORD_LIMIT = 16 * 1024 * 1024;
|
|
23092
|
-
var digest = (value) => `sha256:${
|
|
23111
|
+
var digest = (value) => `sha256:${createHash8("sha256").update(value).digest("hex")}`;
|
|
23093
23112
|
function parseOneShotEvidenceRecord(bytes) {
|
|
23094
23113
|
let parsed;
|
|
23095
23114
|
try {
|
|
@@ -23113,7 +23132,7 @@ async function beginOneShotEvidence(root, intent, sensitive) {
|
|
|
23113
23132
|
throw new Error("oneshot_evidence_root_not_private");
|
|
23114
23133
|
}
|
|
23115
23134
|
const id = `evd_${randomUUID3().replaceAll("-", "")}`;
|
|
23116
|
-
const dir =
|
|
23135
|
+
const dir = join8(root, id);
|
|
23117
23136
|
await mkdir(dir, { mode: 448 });
|
|
23118
23137
|
const secrets = [...new Set(sensitive.filter((value) => value.length >= 8))].sort((a, b) => b.length - a.length);
|
|
23119
23138
|
const redact = (value) => {
|
|
@@ -23133,7 +23152,7 @@ async function beginOneShotEvidence(root, intent, sensitive) {
|
|
|
23133
23152
|
const bytes = JSON.stringify(value);
|
|
23134
23153
|
if (Buffer.byteLength(bytes) > RECORD_LIMIT) throw new Error("oneshot_evidence_record_limit");
|
|
23135
23154
|
parseOneShotEvidenceRecord(bytes);
|
|
23136
|
-
const target =
|
|
23155
|
+
const target = join8(dir, name);
|
|
23137
23156
|
const partial = `${target}.partial`;
|
|
23138
23157
|
const file = await open(partial, "wx", 384);
|
|
23139
23158
|
try {
|
|
@@ -23199,9 +23218,9 @@ async function beginOneShotEvidence(root, intent, sensitive) {
|
|
|
23199
23218
|
|
|
23200
23219
|
// plugins/kxm/src/prices.ts
|
|
23201
23220
|
var import_yaml3 = __toESM(require_dist(), 1);
|
|
23202
|
-
import { createHash as
|
|
23203
|
-
import { existsSync as
|
|
23204
|
-
import { join as
|
|
23221
|
+
import { createHash as createHash9 } from "node:crypto";
|
|
23222
|
+
import { existsSync as existsSync8, readFileSync as readFileSync5, statSync, writeFileSync as writeFileSync3 } from "node:fs";
|
|
23223
|
+
import { join as join9 } from "node:path";
|
|
23205
23224
|
|
|
23206
23225
|
// plugins/kxm/src/price-calc.ts
|
|
23207
23226
|
var PRICES_SCHEMA = "kxm.prices.v1";
|
|
@@ -23262,7 +23281,7 @@ function hashPriceCatalog(catalog) {
|
|
|
23262
23281
|
}))
|
|
23263
23282
|
})).sort((a, b) => a.id.localeCompare(b.id))
|
|
23264
23283
|
};
|
|
23265
|
-
return
|
|
23284
|
+
return createHash9("sha256").update(JSON.stringify(canonical), "utf8").digest("hex");
|
|
23266
23285
|
}
|
|
23267
23286
|
function parsePriceCatalog(text) {
|
|
23268
23287
|
const parsed = (0, import_yaml3.parse)(text);
|
|
@@ -23353,8 +23372,8 @@ function parsePriceCatalog(text) {
|
|
|
23353
23372
|
return catalog;
|
|
23354
23373
|
}
|
|
23355
23374
|
function loadPriceCatalog(rootOrPath) {
|
|
23356
|
-
const candidatePath =
|
|
23357
|
-
if (!candidatePath || !
|
|
23375
|
+
const candidatePath = existsSync8(join9(rootOrPath, ".kxm", "prices.yaml")) ? join9(rootOrPath, ".kxm", "prices.yaml") : existsSync8(join9(rootOrPath, "prices.yaml")) ? join9(rootOrPath, "prices.yaml") : existsSync8(rootOrPath) && statSync(rootOrPath).isFile() ? rootOrPath : void 0;
|
|
23376
|
+
if (!candidatePath || !existsSync8(candidatePath)) {
|
|
23358
23377
|
return void 0;
|
|
23359
23378
|
}
|
|
23360
23379
|
const content = readFileSync5(candidatePath, "utf8");
|
|
@@ -23363,31 +23382,31 @@ function loadPriceCatalog(rootOrPath) {
|
|
|
23363
23382
|
|
|
23364
23383
|
// plugins/kxm/src/engine.ts
|
|
23365
23384
|
var import_yaml7 = __toESM(require_dist(), 1);
|
|
23366
|
-
import { createHash as
|
|
23367
|
-
import { existsSync as
|
|
23368
|
-
import { join as
|
|
23385
|
+
import { createHash as createHash13, randomBytes, timingSafeEqual } from "node:crypto";
|
|
23386
|
+
import { existsSync as existsSync12, readFileSync as readFileSync9 } from "node:fs";
|
|
23387
|
+
import { join as join15 } from "node:path";
|
|
23369
23388
|
|
|
23370
23389
|
// plugins/kxm/src/routes.ts
|
|
23371
23390
|
var import_yaml4 = __toESM(require_dist(), 1);
|
|
23372
|
-
import { existsSync as
|
|
23373
|
-
import { join as
|
|
23391
|
+
import { existsSync as existsSync9, readFileSync as readFileSync6, mkdirSync as mkdirSync3, writeFileSync as writeFileSync4, readdirSync as readdirSync4 } from "node:fs";
|
|
23392
|
+
import { join as join10 } from "node:path";
|
|
23374
23393
|
var RETIRED_POLICY = ".kxm/producers.yaml";
|
|
23375
23394
|
var empty = () => ({ schema: "kxm.routes.v2", updatedAt: (/* @__PURE__ */ new Date()).toISOString(), admitted: [], disabled: [], roles: {} });
|
|
23376
23395
|
function loadRoutePolicy(root) {
|
|
23377
|
-
if (
|
|
23378
|
-
const path =
|
|
23379
|
-
if (!
|
|
23396
|
+
if (existsSync9(join10(root, RETIRED_POLICY))) throw new Error(`retired ${RETIRED_POLICY} present; use .kxm/routes.yaml (kxm.routes.v2)`);
|
|
23397
|
+
const path = join10(root, ".kxm", "routes.yaml");
|
|
23398
|
+
if (!existsSync9(path)) return empty();
|
|
23380
23399
|
const value = (0, import_yaml4.parse)(readFileSync6(path, "utf8"));
|
|
23381
23400
|
if (value?.schema !== "kxm.routes.v2" || !Array.isArray(value.admitted)) throw new Error("invalid .kxm/routes.yaml");
|
|
23382
23401
|
return { schema: "kxm.routes.v2", updatedAt: typeof value.updatedAt === "string" ? value.updatedAt : (/* @__PURE__ */ new Date()).toISOString(), admitted: value.admitted.filter((x) => typeof x === "string"), disabled: Array.isArray(value.disabled) ? value.disabled.filter((x) => typeof x === "string") : [], roles: value.roles && typeof value.roles === "object" ? Object.fromEntries(Object.entries(value.roles).filter(([, v]) => Array.isArray(v)).map(([k, v]) => [k, v.filter((x) => typeof x === "string")])) : {} };
|
|
23383
23402
|
}
|
|
23384
23403
|
function listRoleBindings(root) {
|
|
23385
|
-
const dir =
|
|
23404
|
+
const dir = join10(root, ".kxm", "roles");
|
|
23386
23405
|
const result = {};
|
|
23387
|
-
if (!
|
|
23406
|
+
if (!existsSync9(dir)) return result;
|
|
23388
23407
|
for (const file of readdirSync4(dir).filter((name) => name.endsWith(".yaml"))) {
|
|
23389
23408
|
const role = file.slice(0, -5);
|
|
23390
|
-
const value = (0, import_yaml4.parse)(readFileSync6(
|
|
23409
|
+
const value = (0, import_yaml4.parse)(readFileSync6(join10(dir, file), "utf8"));
|
|
23391
23410
|
result[role] = (value.roster ?? []).map((entry) => entry.model).filter((model) => typeof model === "string");
|
|
23392
23411
|
}
|
|
23393
23412
|
return result;
|
|
@@ -23715,7 +23734,7 @@ function pruneContextPacket(packet, tokenBudget) {
|
|
|
23715
23734
|
// plugins/kxm/src/dispatch-context.ts
|
|
23716
23735
|
import { spawnSync as spawnSync4 } from "node:child_process";
|
|
23717
23736
|
import { readdirSync as readdirSync7 } from "node:fs";
|
|
23718
|
-
import { extname as extname3, join as
|
|
23737
|
+
import { extname as extname3, join as join13 } from "node:path";
|
|
23719
23738
|
|
|
23720
23739
|
// plugins/kxm/src/protocol.ts
|
|
23721
23740
|
var DEFAULT_MESSAGE_TTL_MS = 24 * 60 * 6e4;
|
|
@@ -24344,8 +24363,8 @@ function memoryRecordToContextItem(record2, project) {
|
|
|
24344
24363
|
|
|
24345
24364
|
// plugins/kxm/src/memory.ts
|
|
24346
24365
|
var import_yaml5 = __toESM(require_dist(), 1);
|
|
24347
|
-
import { existsSync as
|
|
24348
|
-
import { extname as extname2, join as
|
|
24366
|
+
import { existsSync as existsSync10, mkdirSync as mkdirSync4, readdirSync as readdirSync5, readFileSync as readFileSync7, writeFileSync as writeFileSync5 } from "node:fs";
|
|
24367
|
+
import { extname as extname2, join as join11, resolve as resolve7 } from "node:path";
|
|
24349
24368
|
var MEMORY_SCHEMA = "kxm.memory.v1";
|
|
24350
24369
|
var VALID_SCOPES = /* @__PURE__ */ new Set(["agent", "project", "run", "operator"]);
|
|
24351
24370
|
var VALID_AUTHORITIES = /* @__PURE__ */ new Set(["instruction", "evidence", "promoted"]);
|
|
@@ -24443,19 +24462,19 @@ function parseMemoryRecord(raw, filename = "memory.md") {
|
|
|
24443
24462
|
};
|
|
24444
24463
|
}
|
|
24445
24464
|
function memoryDirectories(repoRoot) {
|
|
24446
|
-
const root =
|
|
24447
|
-
const memoryDir =
|
|
24448
|
-
const candidatesDir =
|
|
24465
|
+
const root = resolve7(repoRoot);
|
|
24466
|
+
const memoryDir = join11(root, ".kxm", "memory");
|
|
24467
|
+
const candidatesDir = join11(memoryDir, "candidates");
|
|
24449
24468
|
return { memoryDir, candidatesDir };
|
|
24450
24469
|
}
|
|
24451
24470
|
function loadAuthoredMemory(repoRoot) {
|
|
24452
24471
|
const { memoryDir } = memoryDirectories(repoRoot);
|
|
24453
|
-
if (!
|
|
24472
|
+
if (!existsSync10(memoryDir)) return [];
|
|
24454
24473
|
const records = [];
|
|
24455
24474
|
const entries = readdirSync5(memoryDir, { withFileTypes: true });
|
|
24456
24475
|
for (const entry of entries) {
|
|
24457
24476
|
if (entry.isFile() && extname2(entry.name) === ".md") {
|
|
24458
|
-
const fullPath =
|
|
24477
|
+
const fullPath = join11(memoryDir, entry.name);
|
|
24459
24478
|
try {
|
|
24460
24479
|
const text = readFileSync7(fullPath, "utf8");
|
|
24461
24480
|
const record2 = parseMemoryRecord(text, entry.name);
|
|
@@ -24472,9 +24491,9 @@ function loadAuthoredMemory(repoRoot) {
|
|
|
24472
24491
|
|
|
24473
24492
|
// plugins/kxm/src/skills.ts
|
|
24474
24493
|
var import_yaml6 = __toESM(require_dist(), 1);
|
|
24475
|
-
import { createHash as
|
|
24476
|
-
import { existsSync as
|
|
24477
|
-
import { dirname as dirname7, join as
|
|
24494
|
+
import { createHash as createHash10 } from "node:crypto";
|
|
24495
|
+
import { existsSync as existsSync11, mkdirSync as mkdirSync5, readdirSync as readdirSync6, readFileSync as readFileSync8, renameSync, rmSync, statSync as statSync2, writeFileSync as writeFileSync6 } from "node:fs";
|
|
24496
|
+
import { dirname as dirname7, join as join12 } from "node:path";
|
|
24478
24497
|
var SKILL_CANDIDATE_SCHEMA = "kxm.skill-candidate.v1";
|
|
24479
24498
|
var SKILL_EVALUATION_SCHEMA = "kxm.skill-evaluation.v1";
|
|
24480
24499
|
var SKILL_DECISION_SCHEMA = "kxm.skill-decision.v1";
|
|
@@ -24497,7 +24516,7 @@ var SkillLifecycleError = class extends Error {
|
|
|
24497
24516
|
}
|
|
24498
24517
|
};
|
|
24499
24518
|
function skillContentSha256(content) {
|
|
24500
|
-
return
|
|
24519
|
+
return createHash10("sha256").update(content, "utf8").digest("hex");
|
|
24501
24520
|
}
|
|
24502
24521
|
function skillIdFor(name, contentSha256) {
|
|
24503
24522
|
const slug = name.toLowerCase().replaceAll(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 40);
|
|
@@ -24580,19 +24599,19 @@ var SkillLifecycle = class {
|
|
|
24580
24599
|
writeFileSync6(file, content);
|
|
24581
24600
|
}
|
|
24582
24601
|
dir(state) {
|
|
24583
|
-
return
|
|
24602
|
+
return join12(this.root, state === "candidate" ? "candidates" : `${state}s`.replace("rejecteds", "rejected").replace("promoteds", "promoted"));
|
|
24584
24603
|
}
|
|
24585
24604
|
historyFile(id) {
|
|
24586
|
-
return
|
|
24605
|
+
return join12(this.root, "history", `${id}.jsonl`);
|
|
24587
24606
|
}
|
|
24588
24607
|
paths(state, id) {
|
|
24589
|
-
const dir =
|
|
24590
|
-
return { dir, metadata:
|
|
24608
|
+
const dir = join12(this.dir(state), id);
|
|
24609
|
+
return { dir, metadata: join12(dir, "metadata.json"), skill: join12(dir, "SKILL.md") };
|
|
24591
24610
|
}
|
|
24592
24611
|
appendHistory(id, record2) {
|
|
24593
24612
|
const line = `${JSON.stringify(record2)}
|
|
24594
24613
|
`;
|
|
24595
|
-
if (
|
|
24614
|
+
if (existsSync11(this.historyFile(id))) {
|
|
24596
24615
|
const existing = readFileSync8(this.historyFile(id), "utf8");
|
|
24597
24616
|
const lines = existing.split("\n").filter((entry) => entry.trim());
|
|
24598
24617
|
this.write(this.historyFile(id), [...lines.slice(-499), line.trim()].join("\n") + "\n");
|
|
@@ -24602,20 +24621,20 @@ var SkillLifecycle = class {
|
|
|
24602
24621
|
}
|
|
24603
24622
|
history(id) {
|
|
24604
24623
|
const file = this.historyFile(id);
|
|
24605
|
-
if (!
|
|
24624
|
+
if (!existsSync11(file)) return [];
|
|
24606
24625
|
return readFileSync8(file, "utf8").split("\n").filter((line) => line.trim()).map((line) => JSON.parse(line));
|
|
24607
24626
|
}
|
|
24608
24627
|
readMetadata(state, id) {
|
|
24609
24628
|
const { metadata } = this.paths(state, id);
|
|
24610
|
-
if (!
|
|
24629
|
+
if (!existsSync11(metadata)) {
|
|
24611
24630
|
throw new SkillLifecycleError("skill_not_found", `skill ${id} not found in ${state}`);
|
|
24612
24631
|
}
|
|
24613
24632
|
return JSON.parse(readFileSync8(metadata, "utf8"));
|
|
24614
24633
|
}
|
|
24615
24634
|
move(from, to, id) {
|
|
24616
|
-
const fromDir =
|
|
24617
|
-
const toDir =
|
|
24618
|
-
if (!
|
|
24635
|
+
const fromDir = join12(this.dir(from), id);
|
|
24636
|
+
const toDir = join12(this.dir(to), id);
|
|
24637
|
+
if (!existsSync11(fromDir)) {
|
|
24619
24638
|
throw new SkillLifecycleError("skill_not_found", `skill ${id} not found in ${from}`);
|
|
24620
24639
|
}
|
|
24621
24640
|
if (this.dryRun) {
|
|
@@ -24623,7 +24642,7 @@ var SkillLifecycle = class {
|
|
|
24623
24642
|
return;
|
|
24624
24643
|
}
|
|
24625
24644
|
mkdirSync5(this.dir(to), { recursive: true });
|
|
24626
|
-
if (
|
|
24645
|
+
if (existsSync11(toDir)) rmSync(toDir, { recursive: true, force: true });
|
|
24627
24646
|
renameSync(fromDir, toDir);
|
|
24628
24647
|
}
|
|
24629
24648
|
/** Submit a new skill candidate. Content is redacted of secret material at
|
|
@@ -24666,7 +24685,7 @@ var SkillLifecycle = class {
|
|
|
24666
24685
|
const contentSha256 = skillContentSha256(content);
|
|
24667
24686
|
const id = skillIdFor(name, contentSha256);
|
|
24668
24687
|
const { metadata, skill } = this.paths("candidate", id);
|
|
24669
|
-
if (
|
|
24688
|
+
if (existsSync11(metadata)) {
|
|
24670
24689
|
throw new SkillLifecycleError(
|
|
24671
24690
|
"skill_candidate_exists",
|
|
24672
24691
|
`identical candidate ${id} already exists; changed behavior requires changed content`
|
|
@@ -24779,7 +24798,7 @@ var SkillLifecycle = class {
|
|
|
24779
24798
|
const metadataContent = readFileSync8(candidatePaths.metadata, "utf8");
|
|
24780
24799
|
this.write(promotedPaths.skill, skillContent);
|
|
24781
24800
|
this.write(promotedPaths.metadata, metadataContent);
|
|
24782
|
-
const patchPath =
|
|
24801
|
+
const patchPath = join12(this.root, "patches", `${candidateId}.patch`);
|
|
24783
24802
|
const relSkillPath = `.kxm/skills/promoted/${candidateId}/SKILL.md`;
|
|
24784
24803
|
const relMetaPath = `.kxm/skills/promoted/${candidateId}/metadata.json`;
|
|
24785
24804
|
const patch = `${createUnifiedPatch(relSkillPath, skillContent)}${createUnifiedPatch(relMetaPath, metadataContent)}`;
|
|
@@ -24825,7 +24844,7 @@ var SkillLifecycle = class {
|
|
|
24825
24844
|
}
|
|
24826
24845
|
list(state) {
|
|
24827
24846
|
const dir = this.dir(state);
|
|
24828
|
-
if (!
|
|
24847
|
+
if (!existsSync11(dir)) return [];
|
|
24829
24848
|
const ids = readdirSorted(dir);
|
|
24830
24849
|
return ids.map((id) => {
|
|
24831
24850
|
try {
|
|
@@ -24853,7 +24872,7 @@ function boundedList(value, field) {
|
|
|
24853
24872
|
return [...new Set(refs)];
|
|
24854
24873
|
}
|
|
24855
24874
|
function readdirSorted(dir) {
|
|
24856
|
-
return readdirSync6(dir).filter((entry) => statSync2(
|
|
24875
|
+
return readdirSync6(dir).filter((entry) => statSync2(join12(dir, entry)).isDirectory()).sort();
|
|
24857
24876
|
}
|
|
24858
24877
|
|
|
24859
24878
|
// plugins/kxm/src/dispatch-context.ts
|
|
@@ -24894,7 +24913,7 @@ function contextRoleForAgent(agentId) {
|
|
|
24894
24913
|
return agentId;
|
|
24895
24914
|
}
|
|
24896
24915
|
function dispatchContextPresent(projectRoot) {
|
|
24897
|
-
return hasTopLevelMarkdown(
|
|
24916
|
+
return hasTopLevelMarkdown(join13(projectRoot, ".kxm", "memory")) || hasAnyEntry(join13(projectRoot, ".kxm", "skills", "promoted"));
|
|
24898
24917
|
}
|
|
24899
24918
|
function hasTopLevelMarkdown(dir) {
|
|
24900
24919
|
try {
|
|
@@ -24970,7 +24989,7 @@ function loadDispatchContextSources(input) {
|
|
|
24970
24989
|
}
|
|
24971
24990
|
const promoted = [];
|
|
24972
24991
|
try {
|
|
24973
|
-
const lifecycle = new SkillLifecycle(
|
|
24992
|
+
const lifecycle = new SkillLifecycle(join13(projectRoot, ".kxm", "skills"));
|
|
24974
24993
|
for (const metadata of lifecycle.list("promoted")) {
|
|
24975
24994
|
try {
|
|
24976
24995
|
promoted.push(lifecycle.verify("promoted", metadata.id));
|
|
@@ -25053,18 +25072,18 @@ function assembleDispatchContext(sources, input) {
|
|
|
25053
25072
|
}
|
|
25054
25073
|
|
|
25055
25074
|
// plugins/kxm/src/engine-artifacts.ts
|
|
25056
|
-
import { join as
|
|
25075
|
+
import { join as join14 } from "node:path";
|
|
25057
25076
|
|
|
25058
25077
|
// plugins/kxm/src/artifacts-exist.ts
|
|
25059
25078
|
import { lstatSync as lstatSync4, realpathSync as realpathSync3, statSync as statSync3 } from "node:fs";
|
|
25060
|
-
import { isAbsolute as
|
|
25079
|
+
import { isAbsolute as isAbsolute4, relative as relative4, resolve as resolve8 } from "node:path";
|
|
25061
25080
|
function staysUnder(root, candidate) {
|
|
25062
|
-
const child =
|
|
25063
|
-
return child === "" || !
|
|
25081
|
+
const child = relative4(root, candidate);
|
|
25082
|
+
return child === "" || !isAbsolute4(child) && child !== ".." && !child.startsWith(`..${process.platform === "win32" ? "\\" : "/"}`);
|
|
25064
25083
|
}
|
|
25065
25084
|
function verifyArtifactExists(rootInput, pathInput) {
|
|
25066
|
-
const lexicalRoot =
|
|
25067
|
-
const lexicalPath =
|
|
25085
|
+
const lexicalRoot = resolve8(rootInput);
|
|
25086
|
+
const lexicalPath = resolve8(pathInput);
|
|
25068
25087
|
if (!staysUnder(lexicalRoot, lexicalPath)) {
|
|
25069
25088
|
return { ok: false, error: "artifact_outside_workspace_assets", path: lexicalPath };
|
|
25070
25089
|
}
|
|
@@ -25100,14 +25119,14 @@ function verifyArtifactExists(rootInput, pathInput) {
|
|
|
25100
25119
|
// plugins/kxm/src/engine-artifacts.ts
|
|
25101
25120
|
var kxmArtifactsGateSeams = {};
|
|
25102
25121
|
function evaluateArtifactsGate(context, definition) {
|
|
25103
|
-
const root =
|
|
25122
|
+
const root = join14(context.projectRoot, ".kxm", "assets");
|
|
25104
25123
|
const startedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
25105
25124
|
const startTime = process.hrtime.bigint();
|
|
25106
25125
|
let checkedCount = 0;
|
|
25107
25126
|
let failedCount = 0;
|
|
25108
25127
|
for (const [index, path] of definition.paths.entries()) {
|
|
25109
25128
|
checkedCount += 1;
|
|
25110
|
-
const result = verifyArtifactExists(root,
|
|
25129
|
+
const result = verifyArtifactExists(root, join14(root, path));
|
|
25111
25130
|
if (!result.ok) failedCount += 1;
|
|
25112
25131
|
kxmArtifactsGateSeams.afterPathChecked?.({ path, index, checkedCount, failedCount });
|
|
25113
25132
|
}
|
|
@@ -25140,7 +25159,7 @@ function evaluateArtifactsGate(context, definition) {
|
|
|
25140
25159
|
|
|
25141
25160
|
// plugins/kxm/src/engine-command.ts
|
|
25142
25161
|
import { spawn as spawn2 } from "node:child_process";
|
|
25143
|
-
import { createHash as
|
|
25162
|
+
import { createHash as createHash11 } from "node:crypto";
|
|
25144
25163
|
|
|
25145
25164
|
// plugins/kxm/src/safety-integrity.ts
|
|
25146
25165
|
var DESTRUCTIVE_COMMAND_PATTERNS = Object.freeze([
|
|
@@ -25177,7 +25196,7 @@ function createCommandObserver(input) {
|
|
|
25177
25196
|
return new CommandObserver(input);
|
|
25178
25197
|
}
|
|
25179
25198
|
var StreamDigest = class {
|
|
25180
|
-
hash =
|
|
25199
|
+
hash = createHash11("sha256");
|
|
25181
25200
|
bytes = 0;
|
|
25182
25201
|
complete = 0;
|
|
25183
25202
|
digest() {
|
|
@@ -25252,8 +25271,8 @@ var CommandObserver = class {
|
|
|
25252
25271
|
this.requestStop("error", "lost-close");
|
|
25253
25272
|
}
|
|
25254
25273
|
run() {
|
|
25255
|
-
return new Promise((
|
|
25256
|
-
this.resolveOutcome =
|
|
25274
|
+
return new Promise((resolve11) => {
|
|
25275
|
+
this.resolveOutcome = resolve11;
|
|
25257
25276
|
try {
|
|
25258
25277
|
this.start();
|
|
25259
25278
|
} catch (error) {
|
|
@@ -26024,7 +26043,7 @@ function hashFromStore(context, runId) {
|
|
|
26024
26043
|
}
|
|
26025
26044
|
|
|
26026
26045
|
// plugins/kxm/src/routing.ts
|
|
26027
|
-
import { createHash as
|
|
26046
|
+
import { createHash as createHash12 } from "node:crypto";
|
|
26028
26047
|
var ROUTING_RECORD_V2_SCHEMA = "kxm.routing-record.v2";
|
|
26029
26048
|
var BEHAVIORAL_HASH_VERSION = 1;
|
|
26030
26049
|
var MAX_PROVIDER_METADATA_FIELDS = 32;
|
|
@@ -26047,7 +26066,7 @@ function behavioralConfigHash(input) {
|
|
|
26047
26066
|
workflowDefinitionSha256: input.workflowDefinitionSha256?.trim() ?? null,
|
|
26048
26067
|
verifierConfigSha256: input.verifierConfigSha256?.trim() ?? null
|
|
26049
26068
|
};
|
|
26050
|
-
return
|
|
26069
|
+
return createHash12("sha256").update(JSON.stringify(canonical), "utf8").digest("hex");
|
|
26051
26070
|
}
|
|
26052
26071
|
function boundedInt(value, field) {
|
|
26053
26072
|
if (value === void 0 || value === null) return void 0;
|
|
@@ -26216,7 +26235,7 @@ function requireTrustedProducer(producer) {
|
|
|
26216
26235
|
}
|
|
26217
26236
|
}
|
|
26218
26237
|
function hashCapabilitySecret(secret) {
|
|
26219
|
-
return `sha256:${
|
|
26238
|
+
return `sha256:${createHash13("sha256").update(`${CAPABILITY_PREFIX}${secret}`, "utf8").digest("hex")}`;
|
|
26220
26239
|
}
|
|
26221
26240
|
function mintKxmCapabilitySecret() {
|
|
26222
26241
|
const secret = `kxmcap_${randomBytes(32).toString("base64url")}`;
|
|
@@ -26345,7 +26364,7 @@ async function driveAdmitted(context, runId, producer, token, options = {}) {
|
|
|
26345
26364
|
return latest;
|
|
26346
26365
|
}
|
|
26347
26366
|
function newDriveId(runId, token, runtimeId, monotonicNs) {
|
|
26348
|
-
return `drv_${
|
|
26367
|
+
return `drv_${createHash13("sha256").update(`${runId}\0${token}\0${runtimeId}\0${monotonicNs}`, "utf8").digest("hex").slice(0, 24)}`;
|
|
26349
26368
|
}
|
|
26350
26369
|
function driveErrorSummary(error) {
|
|
26351
26370
|
const raw = error instanceof KxmConfigError ? error.issues[0]?.code : void 0;
|
|
@@ -26572,8 +26591,8 @@ var KxmRunScheduler = class _KxmRunScheduler {
|
|
|
26572
26591
|
resolve: (_value) => void 0,
|
|
26573
26592
|
reject: (_error) => void 0
|
|
26574
26593
|
};
|
|
26575
|
-
const settled = new Promise((
|
|
26576
|
-
pending.resolve =
|
|
26594
|
+
const settled = new Promise((resolve11, reject) => {
|
|
26595
|
+
pending.resolve = resolve11;
|
|
26577
26596
|
pending.reject = reject;
|
|
26578
26597
|
});
|
|
26579
26598
|
void settled.then(void 0, () => void 0);
|
|
@@ -26971,8 +26990,8 @@ function unreconciledPanelAttemptId(state) {
|
|
|
26971
26990
|
}
|
|
26972
26991
|
function resolveProducerRoute(projectRoot, step, agentId) {
|
|
26973
26992
|
let agentModel;
|
|
26974
|
-
const agentFile =
|
|
26975
|
-
if (
|
|
26993
|
+
const agentFile = join15(projectRoot, ".kxm", "agents", `${agentId}.yaml`);
|
|
26994
|
+
if (existsSync12(agentFile)) {
|
|
26976
26995
|
try {
|
|
26977
26996
|
const parsed = (0, import_yaml7.parse)(readFileSync9(agentFile, "utf8"));
|
|
26978
26997
|
if (typeof parsed?.model === "string") {
|
|
@@ -27278,7 +27297,7 @@ function birthMember(context, input) {
|
|
|
27278
27297
|
if (promptText === void 0) {
|
|
27279
27298
|
throw runtimeError("run_prompt_mismatch", run.runId, "prompt text missing from accepted run prompt store");
|
|
27280
27299
|
}
|
|
27281
|
-
const promptHash =
|
|
27300
|
+
const promptHash = createHash13("sha256").update(promptText, "utf8").digest("hex");
|
|
27282
27301
|
const expectedHash = run.promptSha256.replace(/^sha256:/, "");
|
|
27283
27302
|
if (promptHash !== expectedHash) {
|
|
27284
27303
|
throw runtimeError("run_prompt_mismatch", run.runId, "prompt text does not match accepted promptSha256");
|
|
@@ -28178,7 +28197,7 @@ function unsupportedStep(plan, step, producerId) {
|
|
|
28178
28197
|
return void 0;
|
|
28179
28198
|
}
|
|
28180
28199
|
function readYamlRecord(path) {
|
|
28181
|
-
if (!
|
|
28200
|
+
if (!existsSync12(path)) return void 0;
|
|
28182
28201
|
try {
|
|
28183
28202
|
const parsed = (0, import_yaml7.parse)(readFileSync9(path, "utf8"));
|
|
28184
28203
|
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) return parsed;
|
|
@@ -28188,11 +28207,11 @@ function readYamlRecord(path) {
|
|
|
28188
28207
|
return void 0;
|
|
28189
28208
|
}
|
|
28190
28209
|
function agentHarness(projectRoot, agentId) {
|
|
28191
|
-
const harness = readYamlRecord(
|
|
28210
|
+
const harness = readYamlRecord(join15(projectRoot, ".kxm", "agents", `${agentId}.yaml`))?.harness;
|
|
28192
28211
|
return typeof harness === "string" && harness.length > 0 ? harness : void 0;
|
|
28193
28212
|
}
|
|
28194
28213
|
function projectDefaultHarness(projectRoot) {
|
|
28195
|
-
const harness = readYamlRecord(
|
|
28214
|
+
const harness = readYamlRecord(join15(projectRoot, ".kxm", "project.yaml"))?.defaultHarness;
|
|
28196
28215
|
return typeof harness === "string" && harness.length > 0 ? harness : "pi";
|
|
28197
28216
|
}
|
|
28198
28217
|
function unsupportedLiveWrite(projectRoot, step, agentId, selector, maxConcurrentRuns) {
|
|
@@ -28219,8 +28238,8 @@ function unsupportedLiveWrite(projectRoot, step, agentId, selector, maxConcurren
|
|
|
28219
28238
|
detail: `live write steps require an audited writer profile; ${harness} has none`
|
|
28220
28239
|
};
|
|
28221
28240
|
}
|
|
28222
|
-
const rosterPath =
|
|
28223
|
-
if (!
|
|
28241
|
+
const rosterPath = join15(projectRoot, ".kxm", "roster.yaml");
|
|
28242
|
+
if (!existsSync12(rosterPath)) return void 0;
|
|
28224
28243
|
const roster = readYamlRecord(rosterPath);
|
|
28225
28244
|
if (!roster || roster.schema !== "kxm.developer-roster.v1") {
|
|
28226
28245
|
return { reason: "step_unsupported", field: "model", detail: "live write steps require a readable kxm.developer-roster.v1" };
|
|
@@ -28863,7 +28882,7 @@ Return a final JSON object with an "outcome" field chosen from ${JSON.stringify(
|
|
|
28863
28882
|
}
|
|
28864
28883
|
const spawnFn = options.spawnProcess ?? defaultSpawn;
|
|
28865
28884
|
const cwd = options.projectRoot ?? process.cwd();
|
|
28866
|
-
const evidence = await beginOneShotEvidence(options.evidenceRoot ??
|
|
28885
|
+
const evidence = await beginOneShotEvidence(options.evidenceRoot ?? join16(kxmUserStateRoot(), "runtime", "oneshot-evidence"), {
|
|
28867
28886
|
runId: request.runId,
|
|
28868
28887
|
stepId: request.stepId,
|
|
28869
28888
|
attemptId: request.attemptId,
|
|
@@ -29101,9 +29120,9 @@ var RuntimeHubClient = class {
|
|
|
29101
29120
|
};
|
|
29102
29121
|
|
|
29103
29122
|
// plugins/kxm/src/hub-binding.ts
|
|
29104
|
-
import { existsSync as
|
|
29123
|
+
import { existsSync as existsSync13, mkdirSync as mkdirSync6, readFileSync as readFileSync10, renameSync as renameSync2, rmSync as rmSync2, writeFileSync as writeFileSync7 } from "node:fs";
|
|
29105
29124
|
import { homedir as homedir2 } from "node:os";
|
|
29106
|
-
import { dirname as dirname8, isAbsolute as
|
|
29125
|
+
import { dirname as dirname8, isAbsolute as isAbsolute5, join as join17, resolve as resolve9 } from "node:path";
|
|
29107
29126
|
var HUB_BINDING_SCHEMA = "kxm.hub-binding.v1";
|
|
29108
29127
|
var HubBindingError = class extends Error {
|
|
29109
29128
|
constructor(message) {
|
|
@@ -29114,21 +29133,21 @@ var HubBindingError = class extends Error {
|
|
|
29114
29133
|
function resolveUserStateRoot(env) {
|
|
29115
29134
|
const explicit = env.KXM_STATE_HOME?.trim();
|
|
29116
29135
|
if (explicit) {
|
|
29117
|
-
if (!
|
|
29118
|
-
return
|
|
29136
|
+
if (!isAbsolute5(explicit)) throw new HubBindingError("local_state_root_not_absolute");
|
|
29137
|
+
return resolve9(explicit);
|
|
29119
29138
|
}
|
|
29120
29139
|
if (process.platform === "win32") {
|
|
29121
29140
|
const localAppData = env.LOCALAPPDATA?.trim();
|
|
29122
|
-
const base2 = localAppData &&
|
|
29123
|
-
return
|
|
29141
|
+
const base2 = localAppData && isAbsolute5(localAppData) ? localAppData : join17(homedir2(), "AppData", "Local");
|
|
29142
|
+
return resolve9(base2, "KXM");
|
|
29124
29143
|
}
|
|
29125
|
-
if (process.platform === "darwin") return
|
|
29144
|
+
if (process.platform === "darwin") return resolve9(homedir2(), "Library", "Application Support", "KXM");
|
|
29126
29145
|
const xdgState = env.XDG_STATE_HOME?.trim();
|
|
29127
|
-
const base = xdgState &&
|
|
29128
|
-
return
|
|
29146
|
+
const base = xdgState && isAbsolute5(xdgState) ? xdgState : join17(homedir2(), ".local", "state");
|
|
29147
|
+
return resolve9(base, "kxm");
|
|
29129
29148
|
}
|
|
29130
29149
|
function hubBindingFile(env = process.env) {
|
|
29131
|
-
return
|
|
29150
|
+
return join17(resolveUserStateRoot(env), "hub-binding.json");
|
|
29132
29151
|
}
|
|
29133
29152
|
function validateHubUrl(raw) {
|
|
29134
29153
|
let parsed;
|
|
@@ -29148,7 +29167,7 @@ function isIsoTimestamp(value) {
|
|
|
29148
29167
|
}
|
|
29149
29168
|
function readHubBinding(env = process.env) {
|
|
29150
29169
|
const file = hubBindingFile(env);
|
|
29151
|
-
if (!
|
|
29170
|
+
if (!existsSync13(file)) return void 0;
|
|
29152
29171
|
let parsed;
|
|
29153
29172
|
try {
|
|
29154
29173
|
parsed = JSON.parse(readFileSync10(file, "utf8"));
|
|
@@ -29173,9 +29192,9 @@ function readHubBinding(env = process.env) {
|
|
|
29173
29192
|
}
|
|
29174
29193
|
|
|
29175
29194
|
// plugins/kxm/src/hub-env.ts
|
|
29176
|
-
import { existsSync as
|
|
29195
|
+
import { existsSync as existsSync14, mkdirSync as mkdirSync7, readFileSync as readFileSync11, renameSync as renameSync3, rmSync as rmSync3, writeFileSync as writeFileSync8 } from "node:fs";
|
|
29177
29196
|
import { homedir as homedir3 } from "node:os";
|
|
29178
|
-
import { dirname as dirname9, isAbsolute as
|
|
29197
|
+
import { dirname as dirname9, isAbsolute as isAbsolute6, join as join18, resolve as resolve10 } from "node:path";
|
|
29179
29198
|
var HUB_ENV_SCHEMA = "kxm.hub-env.v1";
|
|
29180
29199
|
var HubEnvError = class extends Error {
|
|
29181
29200
|
constructor(message) {
|
|
@@ -29186,25 +29205,25 @@ var HubEnvError = class extends Error {
|
|
|
29186
29205
|
function resolveUserStateRoot2(env) {
|
|
29187
29206
|
const explicit = env.KXM_STATE_HOME?.trim();
|
|
29188
29207
|
if (explicit) {
|
|
29189
|
-
if (!
|
|
29190
|
-
return
|
|
29208
|
+
if (!isAbsolute6(explicit)) throw new HubEnvError("local_state_root_not_absolute");
|
|
29209
|
+
return resolve10(explicit);
|
|
29191
29210
|
}
|
|
29192
29211
|
if (process.platform === "win32") {
|
|
29193
29212
|
const localAppData = env.LOCALAPPDATA?.trim();
|
|
29194
|
-
const base2 = localAppData &&
|
|
29195
|
-
return
|
|
29213
|
+
const base2 = localAppData && isAbsolute6(localAppData) ? localAppData : join18(homedir3(), "AppData", "Local");
|
|
29214
|
+
return resolve10(base2, "KXM");
|
|
29196
29215
|
}
|
|
29197
|
-
if (process.platform === "darwin") return
|
|
29216
|
+
if (process.platform === "darwin") return resolve10(homedir3(), "Library", "Application Support", "KXM");
|
|
29198
29217
|
const xdgState = env.XDG_STATE_HOME?.trim();
|
|
29199
|
-
const base = xdgState &&
|
|
29200
|
-
return
|
|
29218
|
+
const base = xdgState && isAbsolute6(xdgState) ? xdgState : join18(homedir3(), ".local", "state");
|
|
29219
|
+
return resolve10(base, "kxm");
|
|
29201
29220
|
}
|
|
29202
29221
|
function hubEnvFile(env = process.env) {
|
|
29203
|
-
return
|
|
29222
|
+
return join18(resolveUserStateRoot2(env), "hub-env.json");
|
|
29204
29223
|
}
|
|
29205
29224
|
function readHubEnvRecord(env = process.env) {
|
|
29206
29225
|
const file = hubEnvFile(env);
|
|
29207
|
-
if (!
|
|
29226
|
+
if (!existsSync14(file)) return void 0;
|
|
29208
29227
|
let parsed;
|
|
29209
29228
|
try {
|
|
29210
29229
|
parsed = JSON.parse(readFileSync11(file, "utf8"));
|
|
@@ -29247,7 +29266,7 @@ function resolveClientHubAuthToken(env, project) {
|
|
|
29247
29266
|
}
|
|
29248
29267
|
|
|
29249
29268
|
// plugins/kxm/src/logger.ts
|
|
29250
|
-
import { appendFileSync, existsSync as
|
|
29269
|
+
import { appendFileSync, existsSync as existsSync15, mkdirSync as mkdirSync8, renameSync as renameSync4, statSync as statSync4, unlinkSync as unlinkSync2 } from "node:fs";
|
|
29251
29270
|
import { dirname as dirname10 } from "node:path";
|
|
29252
29271
|
var LOG_LEVEL_PRIORITY = {
|
|
29253
29272
|
debug: 10,
|
|
@@ -29285,7 +29304,7 @@ function redactLogValue(val, key) {
|
|
|
29285
29304
|
function rotateLogFiles(filePath, maxFiles) {
|
|
29286
29305
|
for (let i = maxFiles; i >= 1; i--) {
|
|
29287
29306
|
const current = `${filePath}.${i}`;
|
|
29288
|
-
if (
|
|
29307
|
+
if (existsSync15(current)) {
|
|
29289
29308
|
if (i >= maxFiles) {
|
|
29290
29309
|
try {
|
|
29291
29310
|
unlinkSync2(current);
|
|
@@ -29299,7 +29318,7 @@ function rotateLogFiles(filePath, maxFiles) {
|
|
|
29299
29318
|
}
|
|
29300
29319
|
}
|
|
29301
29320
|
}
|
|
29302
|
-
if (
|
|
29321
|
+
if (existsSync15(filePath)) {
|
|
29303
29322
|
try {
|
|
29304
29323
|
renameSync4(filePath, `${filePath}.1`);
|
|
29305
29324
|
} catch {
|
|
@@ -29316,7 +29335,7 @@ function createLogger(options) {
|
|
|
29316
29335
|
const shouldStdout = options.stdout ?? !isDaemon;
|
|
29317
29336
|
const correlationDefaults = options.correlation ?? {};
|
|
29318
29337
|
let currentSize = 0;
|
|
29319
|
-
if (filePath &&
|
|
29338
|
+
if (filePath && existsSync15(filePath)) {
|
|
29320
29339
|
try {
|
|
29321
29340
|
currentSize = statSync4(filePath).size;
|
|
29322
29341
|
} catch {
|
|
@@ -29397,7 +29416,7 @@ function createLogger(options) {
|
|
|
29397
29416
|
|
|
29398
29417
|
// plugins/kxm/src/runtime-supervisor.ts
|
|
29399
29418
|
function kxmSupervisorTokenFile(paths) {
|
|
29400
|
-
return
|
|
29419
|
+
return join19(paths.runtimeDir, "supervisor.token");
|
|
29401
29420
|
}
|
|
29402
29421
|
function publishKxmSupervisorToken(paths, token) {
|
|
29403
29422
|
const file = kxmSupervisorTokenFile(paths);
|
|
@@ -29416,7 +29435,7 @@ function publishKxmSupervisorToken(paths, token) {
|
|
|
29416
29435
|
}
|
|
29417
29436
|
}
|
|
29418
29437
|
function hashKxmSupervisorToken(token) {
|
|
29419
|
-
return `sha256:${
|
|
29438
|
+
return `sha256:${createHash14("sha256").update(`kxm-runtime-supervisor\0${token}`, "utf8").digest("hex")}`;
|
|
29420
29439
|
}
|
|
29421
29440
|
function readKxmSupervisorToken(paths) {
|
|
29422
29441
|
const file = kxmSupervisorTokenFile(paths);
|
|
@@ -29439,11 +29458,11 @@ function processAlive(pid) {
|
|
|
29439
29458
|
var HEARTBEAT_STALE_MS = 15e3;
|
|
29440
29459
|
var SUPERVISOR_ERROR_MAX_AGE_MS = 3e4;
|
|
29441
29460
|
function supervisorErrorFile(paths) {
|
|
29442
|
-
return
|
|
29461
|
+
return join19(paths.runtimeDir, "supervisor.error");
|
|
29443
29462
|
}
|
|
29444
29463
|
function clearSupervisorError(paths) {
|
|
29445
29464
|
const file = supervisorErrorFile(paths);
|
|
29446
|
-
if (
|
|
29465
|
+
if (existsSync16(file)) rmSync4(file, { force: true });
|
|
29447
29466
|
}
|
|
29448
29467
|
function recordSupervisorError(paths, message) {
|
|
29449
29468
|
try {
|
|
@@ -29465,24 +29484,35 @@ function readRecentSupervisorError(paths) {
|
|
|
29465
29484
|
return void 0;
|
|
29466
29485
|
}
|
|
29467
29486
|
}
|
|
29468
|
-
function
|
|
29469
|
-
if (!
|
|
29487
|
+
function supervisorStatusOf(record2) {
|
|
29488
|
+
if (!record2) return { running: false };
|
|
29489
|
+
const heartbeatAgeMs = Date.now() - Date.parse(record2.heartbeatAt);
|
|
29490
|
+
const fresh = Number.isFinite(heartbeatAgeMs) && heartbeatAgeMs < HEARTBEAT_STALE_MS;
|
|
29491
|
+
const alive = record2.state === "running" && fresh && processAlive(record2.pid);
|
|
29492
|
+
return {
|
|
29493
|
+
running: alive,
|
|
29494
|
+
runtimeId: record2.runtimeId,
|
|
29495
|
+
pid: record2.pid,
|
|
29496
|
+
port: record2.port,
|
|
29497
|
+
state: alive ? record2.state : "dead",
|
|
29498
|
+
heartbeatAt: record2.heartbeatAt,
|
|
29499
|
+
startedAt: record2.startedAt
|
|
29500
|
+
};
|
|
29501
|
+
}
|
|
29502
|
+
function kxmSupervisorStatus(paths, options = {}) {
|
|
29503
|
+
if (!existsSync16(paths.registryDb)) return { running: false };
|
|
29504
|
+
if (options.readOnly) {
|
|
29505
|
+
const database = openReadOnlyDatabase(paths.registryDb);
|
|
29506
|
+
try {
|
|
29507
|
+
database.exec("PRAGMA busy_timeout = 5000");
|
|
29508
|
+
return supervisorStatusOf(readKxmSupervisorRecord(database));
|
|
29509
|
+
} finally {
|
|
29510
|
+
database.close();
|
|
29511
|
+
}
|
|
29512
|
+
}
|
|
29470
29513
|
const registry = new KxmRuntimeRegistry(paths.registryDb);
|
|
29471
29514
|
try {
|
|
29472
|
-
|
|
29473
|
-
if (!record2) return { running: false };
|
|
29474
|
-
const heartbeatAgeMs = Date.now() - Date.parse(record2.heartbeatAt);
|
|
29475
|
-
const fresh = Number.isFinite(heartbeatAgeMs) && heartbeatAgeMs < HEARTBEAT_STALE_MS;
|
|
29476
|
-
const alive = record2.state === "running" && fresh && processAlive(record2.pid);
|
|
29477
|
-
return {
|
|
29478
|
-
running: alive,
|
|
29479
|
-
runtimeId: record2.runtimeId,
|
|
29480
|
-
pid: record2.pid,
|
|
29481
|
-
port: record2.port,
|
|
29482
|
-
state: alive ? record2.state : "dead",
|
|
29483
|
-
heartbeatAt: record2.heartbeatAt,
|
|
29484
|
-
startedAt: record2.startedAt
|
|
29485
|
-
};
|
|
29515
|
+
return supervisorStatusOf(registry.supervisor());
|
|
29486
29516
|
} finally {
|
|
29487
29517
|
registry.close();
|
|
29488
29518
|
}
|
|
@@ -29536,7 +29566,7 @@ async function ensureKxmSupervisor(options = {}) {
|
|
|
29536
29566
|
throw runtimeError("runtime_supervisor_unreachable", paths.registryDb, `runtime supervisor pid ${status.pid} is registered as running but cannot be probed`);
|
|
29537
29567
|
}
|
|
29538
29568
|
clearSupervisorError(paths);
|
|
29539
|
-
const scriptPath =
|
|
29569
|
+
const scriptPath = join19(findKxmRepoRoot(import.meta.url), "scripts", "kxm-runtime-supervisor.mjs");
|
|
29540
29570
|
const spawnImpl = options.spawnImpl ?? ((script, env) => {
|
|
29541
29571
|
const child = spawn3(process.execPath, [script], {
|
|
29542
29572
|
detached: true,
|
|
@@ -29621,8 +29651,8 @@ async function waitForDriveSessions(settled, graceMs) {
|
|
|
29621
29651
|
try {
|
|
29622
29652
|
await Promise.race([
|
|
29623
29653
|
Promise.allSettled(settled),
|
|
29624
|
-
new Promise((
|
|
29625
|
-
timeout = setTimeout(
|
|
29654
|
+
new Promise((resolve11) => {
|
|
29655
|
+
timeout = setTimeout(resolve11, graceMs);
|
|
29626
29656
|
timeout.unref?.();
|
|
29627
29657
|
})
|
|
29628
29658
|
]);
|
|
@@ -29759,7 +29789,7 @@ function syncFailureText(error) {
|
|
|
29759
29789
|
return `${code ? `${code}: ` : ""}${message}`.replace(/(kxm_[A-Za-z0-9_]+|[A-Za-z0-9._-]{40,})/g, "[redacted]").slice(0, 300);
|
|
29760
29790
|
}
|
|
29761
29791
|
function runtimeSupervisorLogFile(paths) {
|
|
29762
|
-
return
|
|
29792
|
+
return join19(paths.runtimeDir, "logs", "kxm-runtime.jsonl");
|
|
29763
29793
|
}
|
|
29764
29794
|
async function startKxmRuntimeSupervisor(options = {}) {
|
|
29765
29795
|
const now = options.now ?? (() => (/* @__PURE__ */ new Date()).toISOString());
|
|
@@ -29786,7 +29816,7 @@ async function startKxmRuntimeSupervisorInner(paths, requestedPortOption, now, e
|
|
|
29786
29816
|
const token = randomBytes2(32).toString("hex");
|
|
29787
29817
|
const tokenHash = hashKxmSupervisorToken(token);
|
|
29788
29818
|
const registry = new KxmRuntimeRegistry(paths.registryDb);
|
|
29789
|
-
const runtimeId = `rtm_${
|
|
29819
|
+
const runtimeId = `rtm_${createHash14("sha256").update(`${paths.stateRoot}\0${process.pid}\0${now()}\0${randomBytes2(16).toString("hex")}`, "utf8").digest("hex").slice(0, 24)}`;
|
|
29790
29820
|
const requestedPort = requestedPortOption ?? 0;
|
|
29791
29821
|
let activeRuntimeId = runtimeId;
|
|
29792
29822
|
const contexts = /* @__PURE__ */ new Map();
|
|
@@ -29802,7 +29832,7 @@ async function startKxmRuntimeSupervisorInner(paths, requestedPortOption, now, e
|
|
|
29802
29832
|
}
|
|
29803
29833
|
};
|
|
29804
29834
|
const contextFor = (projectRoot) => {
|
|
29805
|
-
if (!
|
|
29835
|
+
if (!isAbsolute7(projectRoot)) {
|
|
29806
29836
|
throw runtimeError("runtime_request_invalid", "projectRoot", "projectRoot must be an absolute path");
|
|
29807
29837
|
}
|
|
29808
29838
|
const key = projectRuntimeKey(projectRoot);
|