@kb-labs/mcp-app 2.96.0 → 2.98.0

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/dist/bin.cjs CHANGED
@@ -62,11 +62,20 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
62
62
  if (typeof require !== "undefined") return require.apply(this, arguments);
63
63
  throw Error('Dynamic require of "' + x + '" is not supported');
64
64
  });
65
- var __esm = (fn, res) => function __init() {
66
- return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
65
+ var __esm = (fn, res, err) => function __init() {
66
+ if (err) throw err[0];
67
+ try {
68
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
69
+ } catch (e) {
70
+ throw err = [e], e;
71
+ }
67
72
  };
68
73
  var __commonJS = (cb, mod) => function __require3() {
69
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
74
+ try {
75
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
76
+ } catch (e) {
77
+ throw mod = 0, e;
78
+ }
70
79
  };
71
80
  var __export = (target, all) => {
72
81
  for (var name in all)
@@ -17375,11 +17384,14 @@ var require_data = __commonJS({
17375
17384
  }
17376
17385
  });
17377
17386
 
17378
- // ../../../node_modules/.pnpm/fast-uri@3.1.0/node_modules/fast-uri/lib/utils.js
17387
+ // ../../../node_modules/.pnpm/fast-uri@3.1.2/node_modules/fast-uri/lib/utils.js
17379
17388
  var require_utils = __commonJS({
17380
- "../../../node_modules/.pnpm/fast-uri@3.1.0/node_modules/fast-uri/lib/utils.js"(exports$1, module) {
17389
+ "../../../node_modules/.pnpm/fast-uri@3.1.2/node_modules/fast-uri/lib/utils.js"(exports$1, module) {
17381
17390
  var isUUID = RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu);
17382
17391
  var isIPv4 = RegExp.prototype.test.bind(/^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u);
17392
+ var isHexPair = RegExp.prototype.test.bind(/^[\da-f]{2}$/iu);
17393
+ var isUnreserved = RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu);
17394
+ var isPathCharacter = RegExp.prototype.test.bind(/^[\da-z\-._~!$&'()*+,;=:@/]$/iu);
17383
17395
  function stringArrayToHexStripped(input) {
17384
17396
  let acc = "";
17385
17397
  let code = 0;
@@ -17572,27 +17584,77 @@ var require_utils = __commonJS({
17572
17584
  }
17573
17585
  return output.join("");
17574
17586
  }
17575
- function normalizeComponentEncoding(component, esc2) {
17576
- const func = esc2 !== true ? escape : unescape;
17577
- if (component.scheme !== void 0) {
17578
- component.scheme = func(component.scheme);
17579
- }
17580
- if (component.userinfo !== void 0) {
17581
- component.userinfo = func(component.userinfo);
17582
- }
17583
- if (component.host !== void 0) {
17584
- component.host = func(component.host);
17587
+ var HOST_DELIMS = { "@": "%40", "/": "%2F", "?": "%3F", "#": "%23", ":": "%3A" };
17588
+ var HOST_DELIM_RE = /[@/?#:]/g;
17589
+ var HOST_DELIM_NO_COLON_RE = /[@/?#]/g;
17590
+ function reescapeHostDelimiters(host, isIP) {
17591
+ const re = isIP ? HOST_DELIM_NO_COLON_RE : HOST_DELIM_RE;
17592
+ re.lastIndex = 0;
17593
+ return host.replace(re, (ch) => HOST_DELIMS[ch]);
17594
+ }
17595
+ function normalizePercentEncoding(input, decodeUnreserved = false) {
17596
+ if (input.indexOf("%") === -1) {
17597
+ return input;
17585
17598
  }
17586
- if (component.path !== void 0) {
17587
- component.path = func(component.path);
17599
+ let output = "";
17600
+ for (let i = 0; i < input.length; i++) {
17601
+ if (input[i] === "%" && i + 2 < input.length) {
17602
+ const hex3 = input.slice(i + 1, i + 3);
17603
+ if (isHexPair(hex3)) {
17604
+ const normalizedHex = hex3.toUpperCase();
17605
+ const decoded = String.fromCharCode(parseInt(normalizedHex, 16));
17606
+ if (decodeUnreserved && isUnreserved(decoded)) {
17607
+ output += decoded;
17608
+ } else {
17609
+ output += "%" + normalizedHex;
17610
+ }
17611
+ i += 2;
17612
+ continue;
17613
+ }
17614
+ }
17615
+ output += input[i];
17588
17616
  }
17589
- if (component.query !== void 0) {
17590
- component.query = func(component.query);
17617
+ return output;
17618
+ }
17619
+ function normalizePathEncoding(input) {
17620
+ let output = "";
17621
+ for (let i = 0; i < input.length; i++) {
17622
+ if (input[i] === "%" && i + 2 < input.length) {
17623
+ const hex3 = input.slice(i + 1, i + 3);
17624
+ if (isHexPair(hex3)) {
17625
+ const normalizedHex = hex3.toUpperCase();
17626
+ const decoded = String.fromCharCode(parseInt(normalizedHex, 16));
17627
+ if (decoded !== "." && isUnreserved(decoded)) {
17628
+ output += decoded;
17629
+ } else {
17630
+ output += "%" + normalizedHex;
17631
+ }
17632
+ i += 2;
17633
+ continue;
17634
+ }
17635
+ }
17636
+ if (isPathCharacter(input[i])) {
17637
+ output += input[i];
17638
+ } else {
17639
+ output += escape(input[i]);
17640
+ }
17591
17641
  }
17592
- if (component.fragment !== void 0) {
17593
- component.fragment = func(component.fragment);
17642
+ return output;
17643
+ }
17644
+ function escapePreservingEscapes(input) {
17645
+ let output = "";
17646
+ for (let i = 0; i < input.length; i++) {
17647
+ if (input[i] === "%" && i + 2 < input.length) {
17648
+ const hex3 = input.slice(i + 1, i + 3);
17649
+ if (isHexPair(hex3)) {
17650
+ output += "%" + hex3.toUpperCase();
17651
+ i += 2;
17652
+ continue;
17653
+ }
17654
+ }
17655
+ output += escape(input[i]);
17594
17656
  }
17595
- return component;
17657
+ return output;
17596
17658
  }
17597
17659
  function recomposeAuthority(component) {
17598
17660
  const uriTokens = [];
@@ -17607,7 +17669,7 @@ var require_utils = __commonJS({
17607
17669
  if (ipV6res.isIPV6 === true) {
17608
17670
  host = `[${ipV6res.escapedHost}]`;
17609
17671
  } else {
17610
- host = component.host;
17672
+ host = reescapeHostDelimiters(host, false);
17611
17673
  }
17612
17674
  }
17613
17675
  uriTokens.push(host);
@@ -17621,7 +17683,10 @@ var require_utils = __commonJS({
17621
17683
  module.exports = {
17622
17684
  nonSimpleDomain,
17623
17685
  recomposeAuthority,
17624
- normalizeComponentEncoding,
17686
+ reescapeHostDelimiters,
17687
+ normalizePercentEncoding,
17688
+ normalizePathEncoding,
17689
+ escapePreservingEscapes,
17625
17690
  removeDotSegments,
17626
17691
  isIPv4,
17627
17692
  isUUID,
@@ -17631,9 +17696,9 @@ var require_utils = __commonJS({
17631
17696
  }
17632
17697
  });
17633
17698
 
17634
- // ../../../node_modules/.pnpm/fast-uri@3.1.0/node_modules/fast-uri/lib/schemes.js
17699
+ // ../../../node_modules/.pnpm/fast-uri@3.1.2/node_modules/fast-uri/lib/schemes.js
17635
17700
  var require_schemes = __commonJS({
17636
- "../../../node_modules/.pnpm/fast-uri@3.1.0/node_modules/fast-uri/lib/schemes.js"(exports$1, module) {
17701
+ "../../../node_modules/.pnpm/fast-uri@3.1.2/node_modules/fast-uri/lib/schemes.js"(exports$1, module) {
17637
17702
  var { isUUID } = require_utils();
17638
17703
  var URN_REG = /([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu;
17639
17704
  var supportedSchemeNames = (
@@ -17840,15 +17905,15 @@ var require_schemes = __commonJS({
17840
17905
  }
17841
17906
  });
17842
17907
 
17843
- // ../../../node_modules/.pnpm/fast-uri@3.1.0/node_modules/fast-uri/index.js
17908
+ // ../../../node_modules/.pnpm/fast-uri@3.1.2/node_modules/fast-uri/index.js
17844
17909
  var require_fast_uri = __commonJS({
17845
- "../../../node_modules/.pnpm/fast-uri@3.1.0/node_modules/fast-uri/index.js"(exports$1, module) {
17846
- var { normalizeIPv6, removeDotSegments, recomposeAuthority, normalizeComponentEncoding, isIPv4, nonSimpleDomain } = require_utils();
17910
+ "../../../node_modules/.pnpm/fast-uri@3.1.2/node_modules/fast-uri/index.js"(exports$1, module) {
17911
+ var { normalizeIPv6, removeDotSegments, recomposeAuthority, normalizePercentEncoding, normalizePathEncoding, escapePreservingEscapes, reescapeHostDelimiters, isIPv4, nonSimpleDomain } = require_utils();
17847
17912
  var { SCHEMES, getSchemeHandler } = require_schemes();
17848
17913
  function normalize4(uri, options) {
17849
17914
  if (typeof uri === "string") {
17850
17915
  uri = /** @type {T} */
17851
- serialize2(parse5(uri, options), options);
17916
+ normalizeString(uri, options);
17852
17917
  } else if (typeof uri === "object") {
17853
17918
  uri = /** @type {T} */
17854
17919
  parse5(serialize2(uri, options), options);
@@ -17915,19 +17980,9 @@ var require_fast_uri = __commonJS({
17915
17980
  return target;
17916
17981
  }
17917
17982
  function equal(uriA, uriB, options) {
17918
- if (typeof uriA === "string") {
17919
- uriA = unescape(uriA);
17920
- uriA = serialize2(normalizeComponentEncoding(parse5(uriA, options), true), { ...options, skipEscape: true });
17921
- } else if (typeof uriA === "object") {
17922
- uriA = serialize2(normalizeComponentEncoding(uriA, true), { ...options, skipEscape: true });
17923
- }
17924
- if (typeof uriB === "string") {
17925
- uriB = unescape(uriB);
17926
- uriB = serialize2(normalizeComponentEncoding(parse5(uriB, options), true), { ...options, skipEscape: true });
17927
- } else if (typeof uriB === "object") {
17928
- uriB = serialize2(normalizeComponentEncoding(uriB, true), { ...options, skipEscape: true });
17929
- }
17930
- return uriA.toLowerCase() === uriB.toLowerCase();
17983
+ const normalizedA = normalizeComparableURI(uriA, options);
17984
+ const normalizedB = normalizeComparableURI(uriB, options);
17985
+ return normalizedA !== void 0 && normalizedB !== void 0 && normalizedA.toLowerCase() === normalizedB.toLowerCase();
17931
17986
  }
17932
17987
  function serialize2(cmpts, opts) {
17933
17988
  const component = {
@@ -17952,12 +18007,12 @@ var require_fast_uri = __commonJS({
17952
18007
  if (schemeHandler && schemeHandler.serialize) schemeHandler.serialize(component, options);
17953
18008
  if (component.path !== void 0) {
17954
18009
  if (!options.skipEscape) {
17955
- component.path = escape(component.path);
18010
+ component.path = escapePreservingEscapes(component.path);
17956
18011
  if (component.scheme !== void 0) {
17957
18012
  component.path = component.path.split("%3A").join(":");
17958
18013
  }
17959
18014
  } else {
17960
- component.path = unescape(component.path);
18015
+ component.path = normalizePercentEncoding(component.path);
17961
18016
  }
17962
18017
  }
17963
18018
  if (options.reference !== "suffix" && component.scheme) {
@@ -17992,7 +18047,16 @@ var require_fast_uri = __commonJS({
17992
18047
  return uriTokens.join("");
17993
18048
  }
17994
18049
  var URI_PARSE = /^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;
17995
- function parse5(uri, opts) {
18050
+ function getParseError(parsed, matches) {
18051
+ if (matches[2] !== void 0 && parsed.path && parsed.path[0] !== "/") {
18052
+ return 'URI path must start with "/" when authority is present.';
18053
+ }
18054
+ if (typeof parsed.port === "number" && (parsed.port < 0 || parsed.port > 65535)) {
18055
+ return "URI port is malformed.";
18056
+ }
18057
+ return void 0;
18058
+ }
18059
+ function parseWithStatus(uri, opts) {
17996
18060
  const options = Object.assign({}, opts);
17997
18061
  const parsed = {
17998
18062
  scheme: void 0,
@@ -18003,6 +18067,7 @@ var require_fast_uri = __commonJS({
18003
18067
  query: void 0,
18004
18068
  fragment: void 0
18005
18069
  };
18070
+ let malformedAuthorityOrPort = false;
18006
18071
  let isIP = false;
18007
18072
  if (options.reference === "suffix") {
18008
18073
  if (options.scheme) {
@@ -18023,6 +18088,11 @@ var require_fast_uri = __commonJS({
18023
18088
  if (isNaN(parsed.port)) {
18024
18089
  parsed.port = matches[5];
18025
18090
  }
18091
+ const parseError = getParseError(parsed, matches);
18092
+ if (parseError !== void 0) {
18093
+ parsed.error = parsed.error || parseError;
18094
+ malformedAuthorityOrPort = true;
18095
+ }
18026
18096
  if (parsed.host) {
18027
18097
  const ipv4result = isIPv4(parsed.host);
18028
18098
  if (ipv4result === false) {
@@ -18061,14 +18131,18 @@ var require_fast_uri = __commonJS({
18061
18131
  parsed.scheme = unescape(parsed.scheme);
18062
18132
  }
18063
18133
  if (parsed.host !== void 0) {
18064
- parsed.host = unescape(parsed.host);
18134
+ parsed.host = reescapeHostDelimiters(unescape(parsed.host), isIP);
18065
18135
  }
18066
18136
  }
18067
18137
  if (parsed.path) {
18068
- parsed.path = escape(unescape(parsed.path));
18138
+ parsed.path = normalizePathEncoding(parsed.path);
18069
18139
  }
18070
18140
  if (parsed.fragment) {
18071
- parsed.fragment = encodeURI(decodeURIComponent(parsed.fragment));
18141
+ try {
18142
+ parsed.fragment = encodeURI(decodeURIComponent(parsed.fragment));
18143
+ } catch {
18144
+ parsed.error = parsed.error || "URI malformed";
18145
+ }
18072
18146
  }
18073
18147
  }
18074
18148
  if (schemeHandler && schemeHandler.parse) {
@@ -18077,7 +18151,29 @@ var require_fast_uri = __commonJS({
18077
18151
  } else {
18078
18152
  parsed.error = parsed.error || "URI can not be parsed.";
18079
18153
  }
18080
- return parsed;
18154
+ return { parsed, malformedAuthorityOrPort };
18155
+ }
18156
+ function parse5(uri, opts) {
18157
+ return parseWithStatus(uri, opts).parsed;
18158
+ }
18159
+ function normalizeString(uri, opts) {
18160
+ return normalizeStringWithStatus(uri, opts).normalized;
18161
+ }
18162
+ function normalizeStringWithStatus(uri, opts) {
18163
+ const { parsed, malformedAuthorityOrPort } = parseWithStatus(uri, opts);
18164
+ return {
18165
+ normalized: malformedAuthorityOrPort ? uri : serialize2(parsed, opts),
18166
+ malformedAuthorityOrPort
18167
+ };
18168
+ }
18169
+ function normalizeComparableURI(uri, opts) {
18170
+ if (typeof uri === "string") {
18171
+ const { normalized, malformedAuthorityOrPort } = normalizeStringWithStatus(uri, opts);
18172
+ return malformedAuthorityOrPort ? void 0 : normalized;
18173
+ }
18174
+ if (typeof uri === "object") {
18175
+ return serialize2(uri, opts);
18176
+ }
18081
18177
  }
18082
18178
  var fastUri = {
18083
18179
  SCHEMES,
@@ -79431,9 +79527,9 @@ var require_bcryptjs = __commonJS({
79431
79527
  }
79432
79528
  });
79433
79529
 
79434
- // ../../../node_modules/.pnpm/@hono+node-server@1.19.13_hono@4.12.14/node_modules/@hono/node-server/dist/index.js
79530
+ // ../../../node_modules/.pnpm/@hono+node-server@1.19.13_hono@4.12.25/node_modules/@hono/node-server/dist/index.js
79435
79531
  var require_dist7 = __commonJS({
79436
- "../../../node_modules/.pnpm/@hono+node-server@1.19.13_hono@4.12.14/node_modules/@hono/node-server/dist/index.js"(exports$1, module) {
79532
+ "../../../node_modules/.pnpm/@hono+node-server@1.19.13_hono@4.12.25/node_modules/@hono/node-server/dist/index.js"(exports$1, module) {
79437
79533
  var __create2 = Object.create;
79438
79534
  var __defProp6 = Object.defineProperty;
79439
79535
  var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
@@ -84410,8 +84506,13 @@ async function resolveRoots(options = {}) {
84410
84506
  // ../../../core/runtime/dist/index.js
84411
84507
  var __defProp3 = Object.defineProperty;
84412
84508
  var __getOwnPropNames3 = Object.getOwnPropertyNames;
84413
- var __esm3 = (fn, res) => function __init() {
84414
- return fn && (res = (0, fn[__getOwnPropNames3(fn)[0]])(fn = 0)), res;
84509
+ var __esm3 = (fn, res, err) => function __init() {
84510
+ if (err) throw err[0];
84511
+ try {
84512
+ return fn && (res = (0, fn[__getOwnPropNames3(fn)[0]])(fn = 0)), res;
84513
+ } catch (e) {
84514
+ throw err = [e], e;
84515
+ }
84415
84516
  };
84416
84517
  var __export3 = (target, all) => {
84417
84518
  for (var name in all)
@@ -89920,13 +90021,16 @@ async function loadPlatformConfig(options = {}) {
89920
90021
  const platformConfigPath = findConfigAtRoot(roots.platformRoot);
89921
90022
  let platformDefaults;
89922
90023
  let platformDefaultsSource;
90024
+ let rawPlatformConfig;
89923
90025
  const samePath = !!platformConfigPath && !!projectConfigPath && path13__namespace.default.resolve(platformConfigPath) === path13__namespace.default.resolve(projectConfigPath);
89924
90026
  if (samePath && projectConfigData) {
89925
90027
  platformDefaults = projectConfigData.platformSection;
90028
+ rawPlatformConfig = projectConfigData.rawConfig;
89926
90029
  projectPlatformConfig = void 0;
89927
90030
  } else if (platformConfigPath) {
89928
- const { platformSection } = await readConfigFile(platformConfigPath);
90031
+ const { platformSection, rawConfig } = await readConfigFile(platformConfigPath);
89929
90032
  platformDefaults = platformSection;
90033
+ rawPlatformConfig = rawConfig;
89930
90034
  platformDefaultsSource = platformConfigPath;
89931
90035
  }
89932
90036
  const mergeResult = mergeWithFieldPolicy(
@@ -89963,6 +90067,7 @@ async function loadPlatformConfig(options = {}) {
89963
90067
  return {
89964
90068
  platformConfig: effective,
89965
90069
  rawConfig: rawProjectConfig,
90070
+ rawPlatformConfig,
89966
90071
  effectiveConfig,
89967
90072
  platformRoot: roots.platformRoot,
89968
90073
  projectRoot: roots.projectRoot,
@@ -105922,7 +106027,7 @@ var range = (a, b, str) => {
105922
106027
  return result;
105923
106028
  };
105924
106029
 
105925
- // ../../../node_modules/.pnpm/brace-expansion@5.0.5/node_modules/brace-expansion/dist/esm/index.js
106030
+ // ../../../node_modules/.pnpm/brace-expansion@5.0.6/node_modules/brace-expansion/dist/esm/index.js
105926
106031
  var escSlash = "\0SLASH" + Math.random() + "\0";
105927
106032
  var escOpen = "\0OPEN" + Math.random() + "\0";
105928
106033
  var escClose = "\0CLOSE" + Math.random() + "\0";
@@ -106040,7 +106145,7 @@ function expand_(str, max, isTop) {
106040
106145
  }
106041
106146
  const pad = n.some(isPadded);
106042
106147
  N = [];
106043
- for (let i = x; test(i, y); i += incr) {
106148
+ for (let i = x; test(i, y) && N.length < max; i += incr) {
106044
106149
  let c;
106045
106150
  if (isAlphaSequence) {
106046
106151
  c = String.fromCharCode(i);
@@ -112595,8 +112700,13 @@ var CredentialsManager = class {
112595
112700
  path13__namespace.join(os3__namespace.homedir(), ".kb", "agent.sock");
112596
112701
  var __defProp5 = Object.defineProperty;
112597
112702
  var __getOwnPropNames5 = Object.getOwnPropertyNames;
112598
- var __esm5 = (fn, res) => function __init() {
112599
- return fn && (res = (0, fn[__getOwnPropNames5(fn)[0]])(fn = 0)), res;
112703
+ var __esm5 = (fn, res, err) => function __init() {
112704
+ if (err) throw err[0];
112705
+ try {
112706
+ return fn && (res = (0, fn[__getOwnPropNames5(fn)[0]])(fn = 0)), res;
112707
+ } catch (e) {
112708
+ throw err = [e], e;
112709
+ }
112600
112710
  };
112601
112711
  var __export5 = (target, all) => {
112602
112712
  for (var name in all)
@@ -116789,6 +116899,169 @@ defineSystemCommand({
116789
116899
  return { ok: true };
116790
116900
  }
116791
116901
  });
116902
+ var SENSITIVE_FIELD_PATTERN = /key|secret|token|password|jwt|credential/i;
116903
+ function isSensitiveField(dottedField) {
116904
+ return dottedField.split(".").some((segment) => SENSITIVE_FIELD_PATTERN.test(segment));
116905
+ }
116906
+ var REDACTED = "***REDACTED***";
116907
+ function flatten(prefix, value, out) {
116908
+ if (value !== null && typeof value === "object" && !Array.isArray(value)) {
116909
+ const entries = Object.entries(value);
116910
+ if (entries.length === 0) {
116911
+ out.push({ field: prefix, value: {} });
116912
+ return;
116913
+ }
116914
+ for (const [key, nested] of entries) {
116915
+ flatten(prefix ? `${prefix}.${key}` : key, nested, out);
116916
+ }
116917
+ return;
116918
+ }
116919
+ out.push({ field: prefix, value });
116920
+ }
116921
+ function redactLeaf(field, value) {
116922
+ if (isSensitiveField(field)) {
116923
+ return REDACTED;
116924
+ }
116925
+ return redactNested(field, value);
116926
+ }
116927
+ function redactNested(fieldPath, value) {
116928
+ if (Array.isArray(value)) {
116929
+ return value.map((item) => redactNested(fieldPath, item));
116930
+ }
116931
+ if (value !== null && typeof value === "object") {
116932
+ const out = {};
116933
+ for (const [key, nested] of Object.entries(value)) {
116934
+ const childPath = fieldPath ? `${fieldPath}.${key}` : key;
116935
+ out[key] = isSensitiveField(childPath) ? REDACTED : redactNested(childPath, nested);
116936
+ }
116937
+ return out;
116938
+ }
116939
+ return value;
116940
+ }
116941
+ var PLATFORM_SCOPE_FIELDS = /* @__PURE__ */ new Set(["platform", "adapters", "adapterOptions", "core", "execution"]);
116942
+ function buildRows(result) {
116943
+ const rows = [];
116944
+ const fieldSources = result.sources.fields ?? {};
116945
+ const defaultOtherSource = result.sameLocation ? "both" : "project";
116946
+ const platformConfig = result.platformConfig;
116947
+ for (const [topField, rawSource] of Object.entries(fieldSources)) {
116948
+ const value = platformConfig[topField];
116949
+ if (value === void 0) {
116950
+ continue;
116951
+ }
116952
+ const source = result.sameLocation ? "both" : rawSource;
116953
+ const leaves = [];
116954
+ flatten(topField, value, leaves);
116955
+ for (const leaf of leaves) {
116956
+ rows.push({ source, field: leaf.field, value: redactLeaf(leaf.field, leaf.value) });
116957
+ }
116958
+ }
116959
+ for (const ignoredField of result.sources.ignoredProjectFields ?? []) {
116960
+ const value = platformConfig[ignoredField];
116961
+ const leaves = [];
116962
+ flatten(ignoredField, value, leaves);
116963
+ for (const leaf of leaves) {
116964
+ rows.push({ source: "ignored", field: leaf.field, value: redactLeaf(leaf.field, leaf.value) });
116965
+ }
116966
+ }
116967
+ const rawPlatformConfig = result.rawPlatformConfig ?? {};
116968
+ const effectiveConfig = result.effectiveConfig ?? {};
116969
+ const otherTopFields = /* @__PURE__ */ new Set([...Object.keys(rawPlatformConfig), ...Object.keys(effectiveConfig)]);
116970
+ for (const topField of otherTopFields) {
116971
+ if (PLATFORM_SCOPE_FIELDS.has(topField)) {
116972
+ continue;
116973
+ }
116974
+ const hasPlatform = rawPlatformConfig[topField] !== void 0;
116975
+ const hasProject = effectiveConfig[topField] !== void 0;
116976
+ let source;
116977
+ let value;
116978
+ if (result.sameLocation) {
116979
+ source = "both";
116980
+ value = hasProject ? effectiveConfig[topField] : rawPlatformConfig[topField];
116981
+ } else if (hasPlatform && hasProject) {
116982
+ source = "both";
116983
+ value = effectiveConfig[topField];
116984
+ } else if (hasProject) {
116985
+ source = defaultOtherSource;
116986
+ value = effectiveConfig[topField];
116987
+ } else {
116988
+ source = "platform";
116989
+ value = rawPlatformConfig[topField];
116990
+ }
116991
+ const leaves = [];
116992
+ flatten(topField, value, leaves);
116993
+ for (const leaf of leaves) {
116994
+ rows.push({ source, field: leaf.field, value: redactLeaf(leaf.field, leaf.value) });
116995
+ }
116996
+ }
116997
+ rows.sort((a, b) => a.source === b.source ? a.field.localeCompare(b.field) : a.source.localeCompare(b.source));
116998
+ return rows;
116999
+ }
117000
+ function formatValue(value) {
117001
+ if (typeof value === "string") {
117002
+ return value;
117003
+ }
117004
+ return JSON.stringify(value);
117005
+ }
117006
+ defineSystemCommand({
117007
+ name: "show",
117008
+ description: "Show the effective (merged) platform config with per-field provenance",
117009
+ longDescription: "Resolves the fully-merged platform config (platform root + project overrides) and prints each field alongside where it came from: platform, project, both, or ignored (a project attempt to override a platform-only field). Sensitive values (keys, secrets, tokens, passwords, credentials) are always redacted.",
117010
+ category: "config",
117011
+ aliases: [],
117012
+ examples: generateExamples("config show", "kb", [
117013
+ { flags: {} },
117014
+ { flags: { json: true } }
117015
+ ]),
117016
+ flags: {
117017
+ json: { type: "boolean", description: "Output machine-readable JSON" }
117018
+ },
117019
+ async handler(ctx) {
117020
+ const cwd = getContextCwd(ctx);
117021
+ const result = await loadPlatformConfig({ startDir: cwd, loadEnvFile: false });
117022
+ const rows = buildRows(result);
117023
+ return {
117024
+ ok: true,
117025
+ status: "success",
117026
+ rows,
117027
+ sameLocation: result.sameLocation,
117028
+ platformRoot: result.platformRoot,
117029
+ projectRoot: result.projectRoot
117030
+ };
117031
+ },
117032
+ formatter(result, ctx, flags) {
117033
+ const rows = result.rows ?? [];
117034
+ if (flags.json) {
117035
+ ctx.ui?.json?.({
117036
+ sameLocation: result.sameLocation,
117037
+ platformRoot: result.platformRoot,
117038
+ projectRoot: result.projectRoot,
117039
+ fields: rows
117040
+ });
117041
+ return;
117042
+ }
117043
+ if (rows.length === 0) {
117044
+ ctx.ui.success("Effective Config", {
117045
+ sections: [{ header: "Config", items: ["No config fields resolved."] }]
117046
+ });
117047
+ return;
117048
+ }
117049
+ const fieldWidth = Math.max(...rows.map((r) => r.field.length), "FIELD".length);
117050
+ const sourceWidth = Math.max(...rows.map((r) => r.source.length), "SOURCE".length);
117051
+ const lines = [
117052
+ `${"SOURCE".padEnd(sourceWidth)} ${"FIELD".padEnd(fieldWidth)} VALUE`,
117053
+ ...rows.map(
117054
+ (r) => `${r.source.padEnd(sourceWidth)} ${r.field.padEnd(fieldWidth)} ${formatValue(r.value)}`
117055
+ )
117056
+ ];
117057
+ if (result.sameLocation) {
117058
+ lines.push("", "(sameLocation: platform and project resolve to the same file \u2014 merge is a no-op)");
117059
+ }
117060
+ ctx.ui.success("Effective Config", {
117061
+ sections: [{ header: "Config", items: lines }]
117062
+ });
117063
+ }
117064
+ });
116792
117065
  path13__namespace.default.join(os3__namespace.default.homedir(), ".config", "kb", "completion.zsh");
116793
117066
  platform.logger.child({ module: "cli:shutdown" });
116794
117067
  function flagToProperty(flag) {
@@ -116864,6 +117137,24 @@ function toCommandManifest(decl, entry) {
116864
117137
  pkgRoot: entry.pluginRoot
116865
117138
  };
116866
117139
  }
117140
+ function buildTool(entry, decl) {
117141
+ if (typeof decl.path !== "string" || decl.path.trim().length === 0) {
117142
+ throw new Error(
117143
+ `command "${decl.id ?? "(unknown)"}" in plugin "${entry.pluginId}" has no "path" field \u2014 skipping`
117144
+ );
117145
+ }
117146
+ return {
117147
+ name: toolName(entry.pluginId, decl.path),
117148
+ description: decl.describe,
117149
+ inputSchema: generateCommandSchema(toCommandManifest(decl, entry)),
117150
+ pluginId: entry.pluginId,
117151
+ pluginRoot: entry.pluginRoot,
117152
+ handlerPath: decl.handler,
117153
+ version: entry.manifest.version ?? "0.0.0",
117154
+ operationType: decl.operationType,
117155
+ permissions: getHandlerPermissions(entry.manifest, "cli", decl.path)
117156
+ };
117157
+ }
116867
117158
  function filterTools(snapshot, permits) {
116868
117159
  const tools = [];
116869
117160
  for (const entry of snapshot.manifests) {
@@ -116871,21 +117162,31 @@ function filterTools(snapshot, permits) {
116871
117162
  if (!permits(decl.operationType, entry.pluginId)) {
116872
117163
  continue;
116873
117164
  }
116874
- tools.push({
116875
- name: toolName(entry.pluginId, decl.path),
116876
- description: decl.describe,
116877
- inputSchema: generateCommandSchema(toCommandManifest(decl, entry)),
116878
- pluginId: entry.pluginId,
116879
- pluginRoot: entry.pluginRoot,
116880
- handlerPath: decl.handler,
116881
- version: entry.manifest.version ?? "0.0.0",
116882
- operationType: decl.operationType,
116883
- permissions: getHandlerPermissions(entry.manifest, "cli", decl.path)
116884
- });
117165
+ try {
117166
+ tools.push(buildTool(entry, decl));
117167
+ } catch {
117168
+ }
116885
117169
  }
116886
117170
  }
116887
117171
  return tools;
116888
117172
  }
117173
+ function validateManifests2(snapshot) {
117174
+ const diagnostics = [];
117175
+ for (const entry of snapshot.manifests) {
117176
+ for (const decl of entry.manifest.cli?.commands ?? []) {
117177
+ try {
117178
+ buildTool(entry, decl);
117179
+ } catch (error2) {
117180
+ diagnostics.push({
117181
+ pluginId: entry.pluginId,
117182
+ commandId: decl.id ?? decl.path ?? "(unknown)",
117183
+ error: error2 instanceof Error ? error2.message : String(error2)
117184
+ });
117185
+ }
117186
+ }
117187
+ }
117188
+ return diagnostics;
117189
+ }
116889
117190
  init_dist();
116890
117191
  function resolveHandlerPath(pluginRoot, handler) {
116891
117192
  const relative2 = handler.split("#")[0] ?? handler;
@@ -117014,6 +117315,14 @@ var McpObservabilityCollector = class {
117014
117315
  requestsTotal = 0;
117015
117316
  errorsTotal = 0;
117016
117317
  ops = new OperationMetricsTracker();
117318
+ manifestDiagnostics = [];
117319
+ /** Record the manifest diagnostics found by validateManifests() at startup. */
117320
+ setManifestDiagnostics(diagnostics) {
117321
+ this.manifestDiagnostics = diagnostics;
117322
+ }
117323
+ getManifestDiagnostics() {
117324
+ return this.manifestDiagnostics;
117325
+ }
117017
117326
  /**
117018
117327
  * Register Fastify hooks that track HTTP-level request counts and duration.
117019
117328
  * Must be called before routes are registered so the hooks apply to all routes.
@@ -117104,6 +117413,11 @@ var McpObservabilityCollector = class {
117104
117413
  id: "execution",
117105
117414
  status: "ok",
117106
117415
  message: `mode=${executionMode}`
117416
+ },
117417
+ {
117418
+ id: "manifests",
117419
+ status: this.manifestDiagnostics.length === 0 ? "ok" : "warn",
117420
+ message: this.manifestDiagnostics.length === 0 ? "all commands loaded cleanly" : `${this.manifestDiagnostics.length} command(s) skipped \u2014 see /observability/diagnostics`
117107
117421
  }
117108
117422
  ],
117109
117423
  topOperations: this.ops.getTopOperations(5)
@@ -117133,6 +117447,17 @@ var McpObservabilityCollector = class {
117133
117447
  };
117134
117448
 
117135
117449
  // src/server.ts
117450
+ var DIAGNOSTICS_TOOL = {
117451
+ name: "kb-labs__mcp_diagnostics",
117452
+ description: "List plugin commands that failed to load as MCP tools (malformed manifests), with the reason for each.",
117453
+ inputSchema: { type: "object", properties: {} }
117454
+ };
117455
+ function renderManifestDiagnostics(diagnostics) {
117456
+ if (diagnostics.length === 0) {
117457
+ return "All plugin commands loaded cleanly \u2014 no manifest issues.";
117458
+ }
117459
+ return diagnostics.map((d) => `[${d.pluginId}] ${d.commandId}: ${d.error}`).join("\n");
117460
+ }
117136
117461
  var McpDaemonServer = class {
117137
117462
  opts;
117138
117463
  resolvePlatform;
@@ -117157,6 +117482,15 @@ var McpDaemonServer = class {
117157
117482
  platformRoot: this.opts.platformRoot,
117158
117483
  cache: this.opts.cache
117159
117484
  });
117485
+ const manifestDiagnostics = validateManifests2(this.registry.snapshot());
117486
+ this.collector.setManifestDiagnostics(manifestDiagnostics);
117487
+ for (const diag2 of manifestDiagnostics) {
117488
+ this.opts.logger.warn("MCP tool skipped \u2014 invalid manifest command", {
117489
+ pluginId: diag2.pluginId,
117490
+ commandId: diag2.commandId,
117491
+ error: diag2.error
117492
+ });
117493
+ }
117160
117494
  const execMode = process.env.KB_MCP_EXECUTION_MODE ?? "subprocess";
117161
117495
  const observabilityAdapter = {
117162
117496
  register: (server) => this.collector.register(server),
@@ -117181,6 +117515,9 @@ var McpDaemonServer = class {
117181
117515
  }
117182
117516
  async registerMcpRoutes(server) {
117183
117517
  const { cache, logger: logger2, jwtConfig } = this.opts;
117518
+ server.get("/observability/diagnostics", async () => ({
117519
+ diagnostics: this.collector.getManifestDiagnostics()
117520
+ }));
117184
117521
  server.all("/api/v1/mcp", async (request, reply) => {
117185
117522
  reply.header("Access-Control-Allow-Origin", "*").header("Access-Control-Allow-Methods", "GET, POST, OPTIONS").header("Access-Control-Allow-Headers", "Authorization, Content-Type, Mcp-Session-Id");
117186
117523
  if (request.method === "OPTIONS") {
@@ -117207,15 +117544,24 @@ var McpDaemonServer = class {
117207
117544
  { capabilities: { tools: {} } }
117208
117545
  );
117209
117546
  mcp.setRequestHandler(ListToolsRequestSchema, async () => ({
117210
- tools: visibleTools.map((t) => ({
117211
- name: t.name,
117212
- description: t.description,
117213
- inputSchema: t.inputSchema
117214
- }))
117547
+ tools: [
117548
+ ...visibleTools.map((t) => ({
117549
+ name: t.name,
117550
+ description: t.description,
117551
+ inputSchema: t.inputSchema
117552
+ })),
117553
+ // Authenticated callers only — mirrors the visibility gate above.
117554
+ ...permits ? [DIAGNOSTICS_TOOL] : []
117555
+ ]
117215
117556
  }));
117216
- mcp.setRequestHandler(
117217
- CallToolRequestSchema,
117218
- async ({ params }) => executeToolCall({
117557
+ mcp.setRequestHandler(CallToolRequestSchema, async ({ params }) => {
117558
+ if (params.name === DIAGNOSTICS_TOOL.name) {
117559
+ if (!permits) {
117560
+ return { content: [{ type: "text", text: `Not authorized: ${params.name}` }], isError: true };
117561
+ }
117562
+ return { content: [{ type: "text", text: renderManifestDiagnostics(this.collector.getManifestDiagnostics()) }], isError: false };
117563
+ }
117564
+ return executeToolCall({
117219
117565
  name: params.name,
117220
117566
  args: params.arguments ?? {},
117221
117567
  visibleTools,
@@ -117224,8 +117570,8 @@ var McpDaemonServer = class {
117224
117570
  resolvePlatform: this.resolvePlatform,
117225
117571
  analytics: this.opts.platform.analytics,
117226
117572
  collector: this.collector
117227
- })
117228
- );
117573
+ });
117574
+ });
117229
117575
  const transport = new StreamableHTTPServerTransport({ sessionIdGenerator: void 0 });
117230
117576
  try {
117231
117577
  await mcp.connect(transport);