@hamak/smart-data-dico 1.24.5 → 1.25.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.
Files changed (99) hide show
  1. package/README.md +25 -0
  2. package/backend/dist/server.mjs +879 -526
  3. package/frontend/dist/assets/{abnfDiagram-VRR7QNED-1a1a0182.js → abnfDiagram-VRR7QNED-36da044f.js} +1 -1
  4. package/frontend/dist/assets/{arc-fe172bfc.js → arc-0e71bb45.js} +1 -1
  5. package/frontend/dist/assets/architecture-TIHT7OUA-9f39d242.js +1 -0
  6. package/frontend/dist/assets/{architectureDiagram-ZJ3FMSHR-aec5255a.js → architectureDiagram-ZJ3FMSHR-012629e1.js} +1 -1
  7. package/frontend/dist/assets/{blockDiagram-677ZJIJ3-88a8ff2a.js → blockDiagram-677ZJIJ3-ef287d6d.js} +1 -1
  8. package/frontend/dist/assets/{c4Diagram-LMCZKHZV-26d629d9.js → c4Diagram-LMCZKHZV-3fc0a947.js} +1 -1
  9. package/frontend/dist/assets/channel-b6f577f8.js +1 -0
  10. package/frontend/dist/assets/{chunk-2Q5K7J3B-d7e8f636.js → chunk-2Q5K7J3B-f3b5f841.js} +1 -1
  11. package/frontend/dist/assets/{chunk-32BRIVSS-95c9713d.js → chunk-32BRIVSS-6eec3991.js} +1 -1
  12. package/frontend/dist/assets/{chunk-5VM5RSS4-74afac14.js → chunk-5VM5RSS4-00a43cac.js} +1 -1
  13. package/frontend/dist/assets/{chunk-EX3LRPZG-04391ccd.js → chunk-EX3LRPZG-b5fd51ac.js} +1 -1
  14. package/frontend/dist/assets/{chunk-JWPE2WC7-2899e5e3.js → chunk-JWPE2WC7-7dc8f0b9.js} +1 -1
  15. package/frontend/dist/assets/{chunk-MOJQB5TN-ae1ecffc.js → chunk-MOJQB5TN-577d3fcc.js} +1 -1
  16. package/frontend/dist/assets/{chunk-PUDLZKDR-24dca4b5.js → chunk-PUDLZKDR-86d3601f.js} +1 -1
  17. package/frontend/dist/assets/{chunk-RYQCIY6F-e05ca676.js → chunk-RYQCIY6F-530ae6cc.js} +1 -1
  18. package/frontend/dist/assets/{chunk-V7JOEXUC-0e4194c9.js → chunk-V7JOEXUC-c9e3dadd.js} +1 -1
  19. package/frontend/dist/assets/{chunk-VR4S4FIN-0e7c1293.js → chunk-VR4S4FIN-d5e869ec.js} +1 -1
  20. package/frontend/dist/assets/{chunk-XXDRQBXY-6470c009.js → chunk-XXDRQBXY-654281e7.js} +1 -1
  21. package/frontend/dist/assets/classDiagram-OUVF2IWQ-31b7ad28.js +1 -0
  22. package/frontend/dist/assets/classDiagram-v2-EOCWNBFH-31b7ad28.js +1 -0
  23. package/frontend/dist/assets/{cose-bilkent-JH36ORCC-20010dd8.js → cose-bilkent-JH36ORCC-21f756b0.js} +1 -1
  24. package/frontend/dist/assets/cynefin-VYW2F7L2-cf7ea351.js +1 -0
  25. package/frontend/dist/assets/{cynefinDiagram-TSTJHNR4-b1beb031.js → cynefinDiagram-TSTJHNR4-14d21dcc.js} +1 -1
  26. package/frontend/dist/assets/{dagre-VKFMJZFB-cb9ac263.js → dagre-VKFMJZFB-ff29a3a3.js} +1 -1
  27. package/frontend/dist/assets/{diagram-FQU43EPY-c2bd7d7a.js → diagram-FQU43EPY-54b5a236.js} +1 -1
  28. package/frontend/dist/assets/{diagram-G47NLZAW-93eaf843.js → diagram-G47NLZAW-b371dc18.js} +1 -1
  29. package/frontend/dist/assets/{diagram-NH7WQ7WH-8d554909.js → diagram-NH7WQ7WH-afb6de17.js} +1 -1
  30. package/frontend/dist/assets/{diagram-OA4YK3LP-4ee27e54.js → diagram-OA4YK3LP-e7f16b81.js} +1 -1
  31. package/frontend/dist/assets/{diagram-WEI45ONY-a1ee152c.js → diagram-WEI45ONY-e6a620e1.js} +1 -1
  32. package/frontend/dist/assets/{ebnfDiagram-CCIWWBDH-4583b8a8.js → ebnfDiagram-CCIWWBDH-28ec4b4e.js} +1 -1
  33. package/frontend/dist/assets/{erDiagram-Q63AITRT-6f81cb12.js → erDiagram-Q63AITRT-4923017e.js} +1 -1
  34. package/frontend/dist/assets/eventmodeling-45OFAUF4-bab0d74d.js +1 -0
  35. package/frontend/dist/assets/flowDiagram-23GEKE2U-c20f9348.js +1 -0
  36. package/frontend/dist/assets/{ganttDiagram-NO4QXBWP-993cd575.js → ganttDiagram-NO4QXBWP-6c6f22b0.js} +1 -1
  37. package/frontend/dist/assets/gitGraph-TEB2WS4Q-c8a6bc62.js +1 -0
  38. package/frontend/dist/assets/{gitGraphDiagram-IHSO6WYX-ee36722e.js → gitGraphDiagram-IHSO6WYX-2492c425.js} +1 -1
  39. package/frontend/dist/assets/{index-60d9dbb0.css → index-3097dd1f.css} +1 -1
  40. package/frontend/dist/assets/index-b3a0bccf.js +575 -0
  41. package/frontend/dist/assets/info-DKCQHKI2-25be42b6.js +1 -0
  42. package/frontend/dist/assets/{infoDiagram-FWYZ7A6U-6bf63009.js → infoDiagram-FWYZ7A6U-5e392c9d.js} +1 -1
  43. package/frontend/dist/assets/{ishikawaDiagram-FXEZZL3T-812fbe54.js → ishikawaDiagram-FXEZZL3T-8070459b.js} +1 -1
  44. package/frontend/dist/assets/{journeyDiagram-5HDEW3XC-9c3f4252.js → journeyDiagram-5HDEW3XC-498bf27d.js} +1 -1
  45. package/frontend/dist/assets/{kanban-definition-HUTT4EX6-2b515039.js → kanban-definition-HUTT4EX6-d04fcd37.js} +1 -1
  46. package/frontend/dist/assets/{linear-8c16d76e.js → linear-f604b0a5.js} +1 -1
  47. package/frontend/dist/assets/{mermaid-parser.core-a1a90c48.js → mermaid-parser.core-ba805f0c.js} +2 -2
  48. package/frontend/dist/assets/{mermaid.core-e609abc8.js → mermaid.core-f40a83d3.js} +3 -3
  49. package/frontend/dist/assets/{mindmap-definition-LN4V7U3C-a3d0643d.js → mindmap-definition-LN4V7U3C-c781e54f.js} +1 -1
  50. package/frontend/dist/assets/packet-7NZHBO7P-2f601c7f.js +1 -0
  51. package/frontend/dist/assets/{pegDiagram-2B236MQR-a2d96c45.js → pegDiagram-2B236MQR-f2641006.js} +1 -1
  52. package/frontend/dist/assets/pie-RZYD4A2V-c7aeaca5.js +1 -0
  53. package/frontend/dist/assets/{pieDiagram-ENE6RG2P-7c68a3bd.js → pieDiagram-ENE6RG2P-d20b5c44.js} +1 -1
  54. package/frontend/dist/assets/{quadrantDiagram-ABIIQ3AL-afba166e.js → quadrantDiagram-ABIIQ3AL-f7c7c247.js} +1 -1
  55. package/frontend/dist/assets/radar-I7S5WNFK-a6ae7069.js +1 -0
  56. package/frontend/dist/assets/railroad-3IZDKUUU-1647f6a2.js +1 -0
  57. package/frontend/dist/assets/railroad-abnf-AHOZXSZD-7dcce0fe.js +1 -0
  58. package/frontend/dist/assets/railroad-ebnf-EBAXGLYW-8082b606.js +1 -0
  59. package/frontend/dist/assets/railroad-peg-LSFZ7HO6-8c0956cd.js +1 -0
  60. package/frontend/dist/assets/{railroadDiagram-RFXS5EU6-52e9e397.js → railroadDiagram-RFXS5EU6-889935d7.js} +1 -1
  61. package/frontend/dist/assets/{requirementDiagram-TGXJPOKE-4e4ad2d6.js → requirementDiagram-TGXJPOKE-1c3073de.js} +1 -1
  62. package/frontend/dist/assets/{sankeyDiagram-HTMAVEWB-59433ed0.js → sankeyDiagram-HTMAVEWB-95bddc36.js} +1 -1
  63. package/frontend/dist/assets/{sequenceDiagram-DBY2YBRQ-d80ec509.js → sequenceDiagram-DBY2YBRQ-d951950b.js} +1 -1
  64. package/frontend/dist/assets/{sizeCapture-X5ZJPWSS-1c45120f.js → sizeCapture-X5ZJPWSS-a320438b.js} +1 -1
  65. package/frontend/dist/assets/{stateDiagram-2N3HPSRC-204251c3.js → stateDiagram-2N3HPSRC-b8b9c6ac.js} +1 -1
  66. package/frontend/dist/assets/stateDiagram-v2-6OUMAXLB-7878a95f.js +1 -0
  67. package/frontend/dist/assets/{swimlanes-5IMT3BWC-49473fe2.js → swimlanes-5IMT3BWC-5ffa4ded.js} +1 -1
  68. package/frontend/dist/assets/swimlanesDiagram-G3AALYLV-d4d9ed85.js +8 -0
  69. package/frontend/dist/assets/{timeline-definition-FHXFAJF6-f4f9276e.js → timeline-definition-FHXFAJF6-e53947b3.js} +1 -1
  70. package/frontend/dist/assets/treeView-QDETBFTQ-433460ae.js +1 -0
  71. package/frontend/dist/assets/treemap-6X3UGDF4-9d7b1496.js +1 -0
  72. package/frontend/dist/assets/{vennDiagram-L72KCM5P-dd390ddd.js → vennDiagram-L72KCM5P-11d6e5b7.js} +1 -1
  73. package/frontend/dist/assets/wardley-OPB4EBWU-6d94cb24.js +1 -0
  74. package/frontend/dist/assets/{wardleyDiagram-EHGQE667-d9939a34.js → wardleyDiagram-EHGQE667-96d3798d.js} +1 -1
  75. package/frontend/dist/assets/{xychartDiagram-FW5EYKEG-41316f0a.js → xychartDiagram-FW5EYKEG-8627de86.js} +1 -1
  76. package/frontend/dist/index.html +2 -2
  77. package/package.json +1 -1
  78. package/frontend/dist/assets/architecture-TIHT7OUA-d693a817.js +0 -1
  79. package/frontend/dist/assets/channel-6410e473.js +0 -1
  80. package/frontend/dist/assets/classDiagram-OUVF2IWQ-4c410cb6.js +0 -1
  81. package/frontend/dist/assets/classDiagram-v2-EOCWNBFH-4c410cb6.js +0 -1
  82. package/frontend/dist/assets/cynefin-VYW2F7L2-5e26aaa6.js +0 -1
  83. package/frontend/dist/assets/eventmodeling-45OFAUF4-4fde353a.js +0 -1
  84. package/frontend/dist/assets/flowDiagram-23GEKE2U-614c4178.js +0 -1
  85. package/frontend/dist/assets/gitGraph-TEB2WS4Q-6b1ac379.js +0 -1
  86. package/frontend/dist/assets/index-072fdcaa.js +0 -574
  87. package/frontend/dist/assets/info-DKCQHKI2-3d895d13.js +0 -1
  88. package/frontend/dist/assets/packet-7NZHBO7P-920badc5.js +0 -1
  89. package/frontend/dist/assets/pie-RZYD4A2V-b244da15.js +0 -1
  90. package/frontend/dist/assets/radar-I7S5WNFK-5d641e70.js +0 -1
  91. package/frontend/dist/assets/railroad-3IZDKUUU-c6aa8307.js +0 -1
  92. package/frontend/dist/assets/railroad-abnf-AHOZXSZD-ee3ed9b2.js +0 -1
  93. package/frontend/dist/assets/railroad-ebnf-EBAXGLYW-86b4539a.js +0 -1
  94. package/frontend/dist/assets/railroad-peg-LSFZ7HO6-19e88030.js +0 -1
  95. package/frontend/dist/assets/stateDiagram-v2-6OUMAXLB-f361b657.js +0 -1
  96. package/frontend/dist/assets/swimlanesDiagram-G3AALYLV-34315d98.js +0 -8
  97. package/frontend/dist/assets/treeView-QDETBFTQ-58f41f68.js +0 -1
  98. package/frontend/dist/assets/treemap-6X3UGDF4-29c5bf00.js +0 -1
  99. package/frontend/dist/assets/wardley-OPB4EBWU-21473c57.js +0 -1
@@ -694,17 +694,17 @@ var require_statuses = __commonJS({
694
694
  };
695
695
  function createMessageToStatusCodeMap(codes2) {
696
696
  var map2 = {};
697
- Object.keys(codes2).forEach(/* @__PURE__ */ __name(function forEachCode(code) {
698
- var message = codes2[code];
699
- var status2 = Number(code);
697
+ Object.keys(codes2).forEach(/* @__PURE__ */ __name(function forEachCode(code2) {
698
+ var message = codes2[code2];
699
+ var status2 = Number(code2);
700
700
  map2[message.toLowerCase()] = status2;
701
701
  }, "forEachCode"));
702
702
  return map2;
703
703
  }
704
704
  __name(createMessageToStatusCodeMap, "createMessageToStatusCodeMap");
705
705
  function createStatusCodeList(codes2) {
706
- return Object.keys(codes2).map(/* @__PURE__ */ __name(function mapCode(code) {
707
- return Number(code);
706
+ return Object.keys(codes2).map(/* @__PURE__ */ __name(function mapCode(code2) {
707
+ return Number(code2);
708
708
  }, "mapCode"));
709
709
  }
710
710
  __name(createStatusCodeList, "createStatusCodeList");
@@ -716,25 +716,25 @@ var require_statuses = __commonJS({
716
716
  return status.code[msg];
717
717
  }
718
718
  __name(getStatusCode, "getStatusCode");
719
- function getStatusMessage(code) {
720
- if (!Object.prototype.hasOwnProperty.call(status.message, code)) {
721
- throw new Error("invalid status code: " + code);
719
+ function getStatusMessage(code2) {
720
+ if (!Object.prototype.hasOwnProperty.call(status.message, code2)) {
721
+ throw new Error("invalid status code: " + code2);
722
722
  }
723
- return status.message[code];
723
+ return status.message[code2];
724
724
  }
725
725
  __name(getStatusMessage, "getStatusMessage");
726
- function status(code) {
727
- if (typeof code === "number") {
728
- return getStatusMessage(code);
726
+ function status(code2) {
727
+ if (typeof code2 === "number") {
728
+ return getStatusMessage(code2);
729
729
  }
730
- if (typeof code !== "string") {
730
+ if (typeof code2 !== "string") {
731
731
  throw new TypeError("code must be a number or string");
732
732
  }
733
- var n = parseInt(code, 10);
733
+ var n = parseInt(code2, 10);
734
734
  if (!isNaN(n)) {
735
735
  return getStatusMessage(n);
736
736
  }
737
- return getStatusCode(code);
737
+ return getStatusCode(code2);
738
738
  }
739
739
  __name(status, "status");
740
740
  }
@@ -870,10 +870,10 @@ var require_http_errors = __commonJS({
870
870
  return HttpError;
871
871
  }
872
872
  __name(createHttpErrorConstructor, "createHttpErrorConstructor");
873
- function createClientErrorConstructor(HttpError, name21, code) {
873
+ function createClientErrorConstructor(HttpError, name21, code2) {
874
874
  var className = toClassName(name21);
875
875
  function ClientError(message) {
876
- var msg = message != null ? message : statuses.message[code];
876
+ var msg = message != null ? message : statuses.message[code2];
877
877
  var err = new Error(msg);
878
878
  Error.captureStackTrace(err, ClientError);
879
879
  setPrototypeOf(err, ClientError.prototype);
@@ -894,8 +894,8 @@ var require_http_errors = __commonJS({
894
894
  __name(ClientError, "ClientError");
895
895
  inherits(ClientError, HttpError);
896
896
  nameFunc(ClientError, className);
897
- ClientError.prototype.status = code;
898
- ClientError.prototype.statusCode = code;
897
+ ClientError.prototype.status = code2;
898
+ ClientError.prototype.statusCode = code2;
899
899
  ClientError.prototype.expose = true;
900
900
  return ClientError;
901
901
  }
@@ -912,10 +912,10 @@ var require_http_errors = __commonJS({
912
912
  }, "isHttpError");
913
913
  }
914
914
  __name(createIsHttpErrorFunction, "createIsHttpErrorFunction");
915
- function createServerErrorConstructor(HttpError, name21, code) {
915
+ function createServerErrorConstructor(HttpError, name21, code2) {
916
916
  var className = toClassName(name21);
917
917
  function ServerError2(message) {
918
- var msg = message != null ? message : statuses.message[code];
918
+ var msg = message != null ? message : statuses.message[code2];
919
919
  var err = new Error(msg);
920
920
  Error.captureStackTrace(err, ServerError2);
921
921
  setPrototypeOf(err, ServerError2.prototype);
@@ -936,8 +936,8 @@ var require_http_errors = __commonJS({
936
936
  __name(ServerError2, "ServerError");
937
937
  inherits(ServerError2, HttpError);
938
938
  nameFunc(ServerError2, className);
939
- ServerError2.prototype.status = code;
940
- ServerError2.prototype.statusCode = code;
939
+ ServerError2.prototype.status = code2;
940
+ ServerError2.prototype.statusCode = code2;
941
941
  ServerError2.prototype.expose = false;
942
942
  return ServerError2;
943
943
  }
@@ -951,19 +951,19 @@ var require_http_errors = __commonJS({
951
951
  }
952
952
  __name(nameFunc, "nameFunc");
953
953
  function populateConstructorExports(exports3, codes, HttpError) {
954
- codes.forEach(/* @__PURE__ */ __name(function forEachCode(code) {
954
+ codes.forEach(/* @__PURE__ */ __name(function forEachCode(code2) {
955
955
  var CodeError;
956
- var name21 = toIdentifier(statuses.message[code]);
957
- switch (codeClass(code)) {
956
+ var name21 = toIdentifier(statuses.message[code2]);
957
+ switch (codeClass(code2)) {
958
958
  case 400:
959
- CodeError = createClientErrorConstructor(HttpError, name21, code);
959
+ CodeError = createClientErrorConstructor(HttpError, name21, code2);
960
960
  break;
961
961
  case 500:
962
- CodeError = createServerErrorConstructor(HttpError, name21, code);
962
+ CodeError = createServerErrorConstructor(HttpError, name21, code2);
963
963
  break;
964
964
  }
965
965
  if (CodeError) {
966
- exports3[code] = CodeError;
966
+ exports3[code2] = CodeError;
967
967
  exports3[name21] = CodeError;
968
968
  }
969
969
  }, "forEachCode"));
@@ -2876,22 +2876,22 @@ var require_dbcs_codec = __commonJS({
2876
2876
  var part = chunk[k];
2877
2877
  if (typeof part === "string") {
2878
2878
  for (var l = 0; l < part.length; ) {
2879
- var code = part.charCodeAt(l++);
2880
- if (55296 <= code && code < 56320) {
2879
+ var code2 = part.charCodeAt(l++);
2880
+ if (55296 <= code2 && code2 < 56320) {
2881
2881
  var codeTrail = part.charCodeAt(l++);
2882
2882
  if (56320 <= codeTrail && codeTrail < 57344)
2883
- writeTable[curAddr++] = 65536 + (code - 55296) * 1024 + (codeTrail - 56320);
2883
+ writeTable[curAddr++] = 65536 + (code2 - 55296) * 1024 + (codeTrail - 56320);
2884
2884
  else
2885
2885
  throw new Error("Incorrect surrogate pair in " + this.encodingName + " at chunk " + chunk[0]);
2886
- } else if (4080 < code && code <= 4095) {
2887
- var len = 4095 - code + 2;
2886
+ } else if (4080 < code2 && code2 <= 4095) {
2887
+ var len = 4095 - code2 + 2;
2888
2888
  var seq = [];
2889
2889
  for (var m = 0; m < len; m++)
2890
2890
  seq.push(part.charCodeAt(l++));
2891
2891
  writeTable[curAddr++] = SEQ_START - this.decodeTableSeq.length;
2892
2892
  this.decodeTableSeq.push(seq);
2893
2893
  } else
2894
- writeTable[curAddr++] = code;
2894
+ writeTable[curAddr++] = code2;
2895
2895
  }
2896
2896
  } else if (typeof part === "number") {
2897
2897
  var charCode = writeTable[curAddr - 1] + 1;
@@ -14604,8 +14604,8 @@ var require_text = __commonJS({
14604
14604
  var debug2 = require_src()("body-parser:text");
14605
14605
  var read = require_read();
14606
14606
  var typeis = require_type_is();
14607
- module.exports = text2;
14608
- function text2(options2) {
14607
+ module.exports = text3;
14608
+ function text3(options2) {
14609
14609
  var opts = options2 || {};
14610
14610
  var defaultCharset = opts.defaultCharset || "utf-8";
14611
14611
  var inflate = opts.inflate !== false;
@@ -14647,7 +14647,7 @@ var require_text = __commonJS({
14647
14647
  });
14648
14648
  }, "textParser");
14649
14649
  }
14650
- __name(text2, "text");
14650
+ __name(text3, "text");
14651
14651
  function getCharset(req) {
14652
14652
  try {
14653
14653
  return (contentType.parse(req).parameters.charset || "").toLowerCase();
@@ -23409,16 +23409,16 @@ var require_cookie = __commonJS({
23409
23409
  __name(parse6, "parse");
23410
23410
  function startIndex(str2, index2, max) {
23411
23411
  do {
23412
- var code = str2.charCodeAt(index2);
23413
- if (code !== 32 && code !== 9) return index2;
23412
+ var code2 = str2.charCodeAt(index2);
23413
+ if (code2 !== 32 && code2 !== 9) return index2;
23414
23414
  } while (++index2 < max);
23415
23415
  return max;
23416
23416
  }
23417
23417
  __name(startIndex, "startIndex");
23418
23418
  function endIndex(str2, index2, min) {
23419
23419
  while (index2 > min) {
23420
- var code = str2.charCodeAt(--index2);
23421
- if (code !== 32 && code !== 9) return index2 + 1;
23420
+ var code2 = str2.charCodeAt(--index2);
23421
+ if (code2 !== 32 && code2 !== 9) return index2 + 1;
23422
23422
  }
23423
23423
  return min;
23424
23424
  }
@@ -23634,11 +23634,11 @@ var require_response = __commonJS({
23634
23634
  var res = Object.create(http.ServerResponse.prototype);
23635
23635
  module.exports = res;
23636
23636
  var charsetRegExp = /;\s*charset\s*=/;
23637
- res.status = /* @__PURE__ */ __name(function status(code) {
23638
- if ((typeof code === "string" || Math.floor(code) !== code) && code > 99 && code < 1e3) {
23639
- deprecate("res.status(" + JSON.stringify(code) + "): use res.status(" + Math.floor(code) + ") instead");
23637
+ res.status = /* @__PURE__ */ __name(function status(code2) {
23638
+ if ((typeof code2 === "string" || Math.floor(code2) !== code2) && code2 > 99 && code2 < 1e3) {
23639
+ deprecate("res.status(" + JSON.stringify(code2) + "): use res.status(" + Math.floor(code2) + ") instead");
23640
23640
  }
23641
- this.statusCode = code;
23641
+ this.statusCode = code2;
23642
23642
  return this;
23643
23643
  }, "status");
23644
23644
  res.links = function(links) {
@@ -29829,14 +29829,14 @@ var require_foldFlowLines = __commonJS({
29829
29829
  var FOLD_FLOW = "flow";
29830
29830
  var FOLD_BLOCK = "block";
29831
29831
  var FOLD_QUOTED = "quoted";
29832
- function foldFlowLines(text2, indent, mode = "flow", { indentAtStart, lineWidth = 80, minContentWidth = 20, onFold, onOverflow } = {}) {
29832
+ function foldFlowLines(text3, indent, mode = "flow", { indentAtStart, lineWidth = 80, minContentWidth = 20, onFold, onOverflow } = {}) {
29833
29833
  if (!lineWidth || lineWidth < 0)
29834
- return text2;
29834
+ return text3;
29835
29835
  if (lineWidth < minContentWidth)
29836
29836
  minContentWidth = 0;
29837
29837
  const endStep = Math.max(1 + minContentWidth, 1 + lineWidth - indent.length);
29838
- if (text2.length <= endStep)
29839
- return text2;
29838
+ if (text3.length <= endStep)
29839
+ return text3;
29840
29840
  const folds = [];
29841
29841
  const escapedFolds = {};
29842
29842
  let end = lineWidth - indent.length;
@@ -29853,14 +29853,14 @@ var require_foldFlowLines = __commonJS({
29853
29853
  let escStart = -1;
29854
29854
  let escEnd = -1;
29855
29855
  if (mode === FOLD_BLOCK) {
29856
- i = consumeMoreIndentedLines(text2, i, indent.length);
29856
+ i = consumeMoreIndentedLines(text3, i, indent.length);
29857
29857
  if (i !== -1)
29858
29858
  end = i + endStep;
29859
29859
  }
29860
- for (let ch; ch = text2[i += 1]; ) {
29860
+ for (let ch; ch = text3[i += 1]; ) {
29861
29861
  if (mode === FOLD_QUOTED && ch === "\\") {
29862
29862
  escStart = i;
29863
- switch (text2[i + 1]) {
29863
+ switch (text3[i + 1]) {
29864
29864
  case "x":
29865
29865
  i += 3;
29866
29866
  break;
@@ -29877,12 +29877,12 @@ var require_foldFlowLines = __commonJS({
29877
29877
  }
29878
29878
  if (ch === "\n") {
29879
29879
  if (mode === FOLD_BLOCK)
29880
- i = consumeMoreIndentedLines(text2, i, indent.length);
29880
+ i = consumeMoreIndentedLines(text3, i, indent.length);
29881
29881
  end = i + indent.length + endStep;
29882
29882
  split = void 0;
29883
29883
  } else {
29884
29884
  if (ch === " " && prev && prev !== " " && prev !== "\n" && prev !== " ") {
29885
- const next = text2[i + 1];
29885
+ const next = text3[i + 1];
29886
29886
  if (next && next !== " " && next !== "\n" && next !== " ")
29887
29887
  split = i;
29888
29888
  }
@@ -29894,12 +29894,12 @@ var require_foldFlowLines = __commonJS({
29894
29894
  } else if (mode === FOLD_QUOTED) {
29895
29895
  while (prev === " " || prev === " ") {
29896
29896
  prev = ch;
29897
- ch = text2[i += 1];
29897
+ ch = text3[i += 1];
29898
29898
  overflow = true;
29899
29899
  }
29900
29900
  const j = i > escEnd + 1 ? i - 2 : escStart - 1;
29901
29901
  if (escapedFolds[j])
29902
- return text2;
29902
+ return text3;
29903
29903
  folds.push(j);
29904
29904
  escapedFolds[j] = true;
29905
29905
  end = j + endStep;
@@ -29914,40 +29914,40 @@ var require_foldFlowLines = __commonJS({
29914
29914
  if (overflow && onOverflow)
29915
29915
  onOverflow();
29916
29916
  if (folds.length === 0)
29917
- return text2;
29917
+ return text3;
29918
29918
  if (onFold)
29919
29919
  onFold();
29920
- let res = text2.slice(0, folds[0]);
29920
+ let res = text3.slice(0, folds[0]);
29921
29921
  for (let i2 = 0; i2 < folds.length; ++i2) {
29922
29922
  const fold = folds[i2];
29923
- const end2 = folds[i2 + 1] || text2.length;
29923
+ const end2 = folds[i2 + 1] || text3.length;
29924
29924
  if (fold === 0)
29925
29925
  res = `
29926
- ${indent}${text2.slice(0, end2)}`;
29926
+ ${indent}${text3.slice(0, end2)}`;
29927
29927
  else {
29928
29928
  if (mode === FOLD_QUOTED && escapedFolds[fold])
29929
- res += `${text2[fold]}\\`;
29929
+ res += `${text3[fold]}\\`;
29930
29930
  res += `
29931
- ${indent}${text2.slice(fold + 1, end2)}`;
29931
+ ${indent}${text3.slice(fold + 1, end2)}`;
29932
29932
  }
29933
29933
  }
29934
29934
  return res;
29935
29935
  }
29936
29936
  __name(foldFlowLines, "foldFlowLines");
29937
- function consumeMoreIndentedLines(text2, i, indent) {
29937
+ function consumeMoreIndentedLines(text3, i, indent) {
29938
29938
  let end = i;
29939
29939
  let start = i + 1;
29940
- let ch = text2[start];
29940
+ let ch = text3[start];
29941
29941
  while (ch === " " || ch === " ") {
29942
29942
  if (i < start + indent) {
29943
- ch = text2[++i];
29943
+ ch = text3[++i];
29944
29944
  } else {
29945
29945
  do {
29946
- ch = text2[++i];
29946
+ ch = text3[++i];
29947
29947
  } while (ch && ch !== "\n");
29948
29948
  end = i;
29949
29949
  start = i + 1;
29950
- ch = text2[start];
29950
+ ch = text3[start];
29951
29951
  }
29952
29952
  }
29953
29953
  return end;
@@ -30012,8 +30012,8 @@ var require_stringifyString = __commonJS({
30012
30012
  case "u":
30013
30013
  {
30014
30014
  str2 += json3.slice(start, i);
30015
- const code = json3.substr(i + 2, 4);
30016
- switch (code) {
30015
+ const code2 = json3.substr(i + 2, 4);
30016
+ switch (code2) {
30017
30017
  case "0000":
30018
30018
  str2 += "\\0";
30019
30019
  break;
@@ -30039,8 +30039,8 @@ var require_stringifyString = __commonJS({
30039
30039
  str2 += "\\P";
30040
30040
  break;
30041
30041
  default:
30042
- if (code.substr(0, 2) === "00")
30043
- str2 += "\\x" + code.substr(2);
30042
+ if (code2.substr(0, 2) === "00")
30043
+ str2 += "\\x" + code2.substr(2);
30044
30044
  else
30045
30045
  str2 += json3.substr(i, 6);
30046
30046
  }
@@ -32597,10 +32597,10 @@ var require_errors = __commonJS({
32597
32597
  static {
32598
32598
  __name(this, "YAMLError");
32599
32599
  }
32600
- constructor(name21, pos, code, message) {
32600
+ constructor(name21, pos, code2, message) {
32601
32601
  super();
32602
32602
  this.name = name21;
32603
- this.code = code;
32603
+ this.code = code2;
32604
32604
  this.message = message;
32605
32605
  this.pos = pos;
32606
32606
  }
@@ -32609,16 +32609,16 @@ var require_errors = __commonJS({
32609
32609
  static {
32610
32610
  __name(this, "YAMLParseError");
32611
32611
  }
32612
- constructor(pos, code, message) {
32613
- super("YAMLParseError", pos, code, message);
32612
+ constructor(pos, code2, message) {
32613
+ super("YAMLParseError", pos, code2, message);
32614
32614
  }
32615
32615
  };
32616
32616
  var YAMLWarning = class extends YAMLError {
32617
32617
  static {
32618
32618
  __name(this, "YAMLWarning");
32619
32619
  }
32620
- constructor(pos, code, message) {
32621
- super("YAMLWarning", pos, code, message);
32620
+ constructor(pos, code2, message) {
32621
+ super("YAMLWarning", pos, code2, message);
32622
32622
  }
32623
32623
  };
32624
32624
  var prettifyError2 = /* @__PURE__ */ __name((src, lc) => (error48) => {
@@ -33540,7 +33540,7 @@ var require_resolve_flow_scalar = __commonJS({
33540
33540
  const { offset, type, source, end } = scalar;
33541
33541
  let _type;
33542
33542
  let value;
33543
- const _onError = /* @__PURE__ */ __name((rel, code, msg) => onError2(offset + rel, code, msg), "_onError");
33543
+ const _onError = /* @__PURE__ */ __name((rel, code2, msg) => onError2(offset + rel, code2, msg), "_onError");
33544
33544
  switch (type) {
33545
33545
  case "scalar":
33546
33546
  _type = Scalar.Scalar.PLAIN;
@@ -33743,13 +33743,13 @@ var require_resolve_flow_scalar = __commonJS({
33743
33743
  function parseCharCode(source, offset, length, onError2) {
33744
33744
  const cc = source.substr(offset, length);
33745
33745
  const ok2 = cc.length === length && /^[0-9a-fA-F]+$/.test(cc);
33746
- const code = ok2 ? parseInt(cc, 16) : NaN;
33747
- if (isNaN(code)) {
33746
+ const code2 = ok2 ? parseInt(cc, 16) : NaN;
33747
+ if (isNaN(code2)) {
33748
33748
  const raw = source.substr(offset - 2, length + 2);
33749
33749
  onError2(offset - 2, "BAD_DQ_ESCAPE", `Invalid escape sequence ${raw}`);
33750
33750
  return raw;
33751
33751
  }
33752
- return String.fromCodePoint(code);
33752
+ return String.fromCodePoint(code2);
33753
33753
  }
33754
33754
  __name(parseCharCode, "parseCharCode");
33755
33755
  exports2.resolveFlowScalar = resolveFlowScalar;
@@ -34080,12 +34080,12 @@ var require_composer = __commonJS({
34080
34080
  this.prelude = [];
34081
34081
  this.errors = [];
34082
34082
  this.warnings = [];
34083
- this.onError = (source, code, message, warning) => {
34083
+ this.onError = (source, code2, message, warning) => {
34084
34084
  const pos = getErrorPos(source);
34085
34085
  if (warning)
34086
- this.warnings.push(new errors.YAMLWarning(pos, code, message));
34086
+ this.warnings.push(new errors.YAMLWarning(pos, code2, message));
34087
34087
  else
34088
- this.errors.push(new errors.YAMLParseError(pos, code, message));
34088
+ this.errors.push(new errors.YAMLParseError(pos, code2, message));
34089
34089
  };
34090
34090
  this.directives = new directives.Directives({ version: options2.version || "1.2" });
34091
34091
  this.options = options2;
@@ -34245,12 +34245,12 @@ var require_cst_scalar = __commonJS({
34245
34245
  var stringifyString = require_stringifyString();
34246
34246
  function resolveAsScalar(token, strict = true, onError2) {
34247
34247
  if (token) {
34248
- const _onError = /* @__PURE__ */ __name((pos, code, message) => {
34248
+ const _onError = /* @__PURE__ */ __name((pos, code2, message) => {
34249
34249
  const offset = typeof pos === "number" ? pos : Array.isArray(pos) ? pos[0] : pos.offset;
34250
34250
  if (onError2)
34251
- onError2(offset, code, message);
34251
+ onError2(offset, code2, message);
34252
34252
  else
34253
- throw new errors.YAMLParseError([offset, offset + 1], code, message);
34253
+ throw new errors.YAMLParseError([offset, offset + 1], code2, message);
34254
34254
  }, "_onError");
34255
34255
  switch (token.type) {
34256
34256
  case "scalar":
@@ -38968,8 +38968,8 @@ function callTaskParser(parser4, streams) {
38968
38968
  return parser4(streams.stdOut, streams.stdErr);
38969
38969
  }
38970
38970
  function parseStringResponse(result, parsers12, texts, trim = true) {
38971
- asArray(texts).forEach((text2) => {
38972
- for (let lines = toLinesWithContent(text2, trim), i = 0, max = lines.length; i < max; i++) {
38971
+ asArray(texts).forEach((text3) => {
38972
+ for (let lines = toLinesWithContent(text3, trim), i = 0, max = lines.length; i < max; i++) {
38973
38973
  const line = /* @__PURE__ */ __name((offset = 0) => {
38974
38974
  if (i + offset >= max) {
38975
38975
  return;
@@ -39019,10 +39019,10 @@ function checkIsBareRepoTask() {
39019
39019
  function isNotRepoMessage(error48) {
39020
39020
  return /(Not a git repository|Kein Git-Repository)/i.test(String(error48));
39021
39021
  }
39022
- function cleanSummaryParser(dryRun, text2) {
39022
+ function cleanSummaryParser(dryRun, text3) {
39023
39023
  const summary = new CleanResponse(dryRun);
39024
39024
  const regexp = dryRun ? dryRunRemovalRegexp : removalRegexp;
39025
- toLinesWithContent(text2).forEach((line) => {
39025
+ toLinesWithContent(text3).forEach((line) => {
39026
39026
  const removed = line.replace(regexp, "");
39027
39027
  summary.paths.push(removed);
39028
39028
  (isFolderRegexp.test(removed) ? summary.folders : summary.files).push(removed);
@@ -39049,8 +39049,8 @@ function straightThroughStringTask(commands, trimmed2 = false) {
39049
39049
  return {
39050
39050
  commands,
39051
39051
  format: "utf-8",
39052
- parser(text2) {
39053
- return trimmed2 ? String(text2).trim() : text2;
39052
+ parser(text3) {
39053
+ return trimmed2 ? String(text3).trim() : text3;
39054
39054
  }
39055
39055
  };
39056
39056
  }
@@ -39088,8 +39088,8 @@ function cleanTask(mode, customArgs) {
39088
39088
  return {
39089
39089
  commands,
39090
39090
  format: "utf-8",
39091
- parser(text2) {
39092
- return cleanSummaryParser(mode === "n", text2);
39091
+ parser(text3) {
39092
+ return cleanSummaryParser(mode === "n", text3);
39093
39093
  }
39094
39094
  };
39095
39095
  }
@@ -39126,18 +39126,18 @@ function isInteractiveMode(option) {
39126
39126
  }
39127
39127
  return option === "--interactive";
39128
39128
  }
39129
- function configListParser(text2) {
39129
+ function configListParser(text3) {
39130
39130
  const config3 = new ConfigList();
39131
- for (const item of configParser(text2)) {
39131
+ for (const item of configParser(text3)) {
39132
39132
  config3.addValue(item.file, String(item.key), item.value);
39133
39133
  }
39134
39134
  return config3;
39135
39135
  }
39136
- function configGetParser(text2, key2) {
39136
+ function configGetParser(text3, key2) {
39137
39137
  let value = null;
39138
39138
  const values = [];
39139
39139
  const scopes = /* @__PURE__ */ new Map();
39140
- for (const item of configParser(text2, key2)) {
39140
+ for (const item of configParser(text3, key2)) {
39141
39141
  if (item.key !== key2) {
39142
39142
  continue;
39143
39143
  }
@@ -39158,8 +39158,8 @@ function configGetParser(text2, key2) {
39158
39158
  function configFilePath(filePath) {
39159
39159
  return filePath.replace(/^(file):/, "");
39160
39160
  }
39161
- function* configParser(text2, requestedKey = null) {
39162
- const lines = text2.split("\0");
39161
+ function* configParser(text3, requestedKey = null) {
39162
+ const lines = text3.split("\0");
39163
39163
  for (let i = 0, max = lines.length - 1; i < max; ) {
39164
39164
  const file2 = configFilePath(lines[i++]);
39165
39165
  let value = lines[i++];
@@ -39187,8 +39187,8 @@ function addConfigTask(key2, value, append2, scope) {
39187
39187
  return {
39188
39188
  commands,
39189
39189
  format: "utf-8",
39190
- parser(text2) {
39191
- return text2;
39190
+ parser(text3) {
39191
+ return text3;
39192
39192
  }
39193
39193
  };
39194
39194
  }
@@ -39200,8 +39200,8 @@ function getConfigTask(key2, scope) {
39200
39200
  return {
39201
39201
  commands,
39202
39202
  format: "utf-8",
39203
- parser(text2) {
39204
- return configGetParser(text2, key2);
39203
+ parser(text3) {
39204
+ return configGetParser(text3, key2);
39205
39205
  }
39206
39206
  };
39207
39207
  }
@@ -39213,8 +39213,8 @@ function listConfigTask(scope) {
39213
39213
  return {
39214
39214
  commands,
39215
39215
  format: "utf-8",
39216
- parser(text2) {
39217
- return configListParser(text2);
39216
+ parser(text3) {
39217
+ return configListParser(text3);
39218
39218
  }
39219
39219
  };
39220
39220
  }
@@ -39564,8 +39564,8 @@ function hashObjectTask(filePath, write) {
39564
39564
  }
39565
39565
  return straightThroughStringTask(commands, true);
39566
39566
  }
39567
- function parseInit(bare, path25, text2) {
39568
- const response = String(text2).trim();
39567
+ function parseInit(bare, path25, text3) {
39568
+ const response = String(text3).trim();
39569
39569
  let result;
39570
39570
  if (result = initResponseRegex.exec(response)) {
39571
39571
  return new InitSummary(bare, path25, false, result[1]);
@@ -39595,8 +39595,8 @@ function initTask(bare = false, path25, customArgs) {
39595
39595
  return {
39596
39596
  commands,
39597
39597
  format: "utf-8",
39598
- parser(text2) {
39599
- return parseInit(commands.includes("--bare"), path25, text2);
39598
+ parser(text3) {
39599
+ return parseInit(commands.includes("--bare"), path25, text3);
39600
39600
  }
39601
39601
  };
39602
39602
  }
@@ -39901,8 +39901,8 @@ function statusTask(customArgs) {
39901
39901
  return {
39902
39902
  format: "utf-8",
39903
39903
  commands,
39904
- parser(text2) {
39905
- return parseStatusSummary(text2);
39904
+ parser(text3) {
39905
+ return parseStatusSummary(text3);
39906
39906
  }
39907
39907
  };
39908
39908
  }
@@ -40144,14 +40144,14 @@ function pullTask(remote, branch, customArgs) {
40144
40144
  }
40145
40145
  };
40146
40146
  }
40147
- function parseGetRemotes(text2) {
40147
+ function parseGetRemotes(text3) {
40148
40148
  const remotes = {};
40149
- forEach(text2, ([name21]) => remotes[name21] = { name: name21 });
40149
+ forEach(text3, ([name21]) => remotes[name21] = { name: name21 });
40150
40150
  return Object.values(remotes);
40151
40151
  }
40152
- function parseGetRemotesVerbose(text2) {
40152
+ function parseGetRemotesVerbose(text3) {
40153
40153
  const remotes = {};
40154
- forEach(text2, ([name21, url2, purpose]) => {
40154
+ forEach(text3, ([name21, url2, purpose]) => {
40155
40155
  if (!Object.hasOwn(remotes, name21)) {
40156
40156
  remotes[name21] = {
40157
40157
  name: name21,
@@ -40164,8 +40164,8 @@ function parseGetRemotesVerbose(text2) {
40164
40164
  });
40165
40165
  return Object.values(remotes);
40166
40166
  }
40167
- function forEach(text2, handler) {
40168
- forEachLineWithContent(text2, (line) => handler(line.split(/\s+/)));
40167
+ function forEach(text3, handler) {
40168
+ forEachLineWithContent(text3, (line) => handler(line.split(/\s+/)));
40169
40169
  }
40170
40170
  function addRemoteTask(remoteName, remoteRepo, customArgs) {
40171
40171
  return straightThroughStringTask(["remote", "add", ...customArgs, remoteName, remoteRepo]);
@@ -40253,8 +40253,8 @@ function tagListTask(customArgs = []) {
40253
40253
  return {
40254
40254
  format: "utf-8",
40255
40255
  commands: ["tag", "-l", ...customArgs],
40256
- parser(text2) {
40257
- return parseTagList(text2, hasCustomSort);
40256
+ parser(text3) {
40257
+ return parseTagList(text3, hasCustomSort);
40258
40258
  }
40259
40259
  };
40260
40260
  }
@@ -40390,12 +40390,12 @@ function completionDetectionPlugin({
40390
40390
  configureTimeout(onClose, events.close, events.closeTimeout);
40391
40391
  configureTimeout(onExit, events.exit, events.exitTimeout);
40392
40392
  return {
40393
- close(code) {
40394
- exitCode = code;
40393
+ close(code2) {
40394
+ exitCode = code2;
40395
40395
  events.close.done();
40396
40396
  },
40397
- exit(code) {
40398
- exitCode = code;
40397
+ exit(code2) {
40398
+ exitCode = code2;
40399
40399
  events.exit.done();
40400
40400
  },
40401
40401
  get exitCode() {
@@ -40421,8 +40421,8 @@ function completionDetectionPlugin({
40421
40421
  spawned.stdout?.on("data", quickClose);
40422
40422
  spawned.stderr?.on("data", quickClose);
40423
40423
  spawned.on("error", quickClose);
40424
- spawned.on("close", (code) => events.close(code));
40425
- spawned.on("exit", (code) => events.exit(code));
40424
+ spawned.on("close", (code2) => events.close(code2));
40425
+ spawned.on("exit", (code2) => events.exit(code2));
40426
40426
  try {
40427
40427
  await events.result;
40428
40428
  if (deferClose) {
@@ -40985,8 +40985,8 @@ var init_esm = __esm({
40985
40985
  }
40986
40986
  fail4(error48);
40987
40987
  }, "onError");
40988
- parser = /* @__PURE__ */ __name((text2) => {
40989
- return text2.trim() === "true";
40988
+ parser = /* @__PURE__ */ __name((text3) => {
40989
+ return text3.trim() === "true";
40990
40990
  }, "parser");
40991
40991
  }
40992
40992
  });
@@ -42019,8 +42019,8 @@ var init_esm = __esm({
42019
42019
  init_utils();
42020
42020
  init_parse_remote_objects();
42021
42021
  parsers2 = [
42022
- new RemoteLineParser(/^remote:\s*(.+)$/, (result, [text2]) => {
42023
- result.remoteMessages.all.push(text2.trim());
42022
+ new RemoteLineParser(/^remote:\s*(.+)$/, (result, [text3]) => {
42023
+ result.remoteMessages.all.push(text3.trim());
42024
42024
  return false;
42025
42025
  }),
42026
42026
  ...remoteMessagesObjectParsers,
@@ -42384,8 +42384,8 @@ var init_esm = __esm({
42384
42384
  }
42385
42385
  ]
42386
42386
  ]);
42387
- parseStatusSummary = /* @__PURE__ */ __name(function(text2) {
42388
- const lines = text2.split(NULL);
42387
+ parseStatusSummary = /* @__PURE__ */ __name(function(text3) {
42388
+ const lines = text3.split(NULL);
42389
42389
  const status = new StatusSummary();
42390
42390
  for (let i = 0, l = lines.length; i < l; ) {
42391
42391
  let line = lines[i++].trim();
@@ -42798,8 +42798,8 @@ var init_esm = __esm({
42798
42798
  init_CheckIgnore = __esm2({
42799
42799
  "src/lib/responses/CheckIgnore.ts"() {
42800
42800
  "use strict";
42801
- parseCheckIgnore = /* @__PURE__ */ __name((text2) => {
42802
- return text2.split(/\n/g).map(toPath).filter(Boolean);
42801
+ parseCheckIgnore = /* @__PURE__ */ __name((text3) => {
42802
+ return text3.split(/\n/g).map(toPath).filter(Boolean);
42803
42803
  }, "parseCheckIgnore");
42804
42804
  }
42805
42805
  });
@@ -43541,8 +43541,8 @@ var init_git_service = __esm({
43541
43541
  /**
43542
43542
  * Create a standardized error object
43543
43543
  */
43544
- createError(code, message, params) {
43545
- return { code, message, params };
43544
+ createError(code2, message, params) {
43545
+ return { code: code2, message, params };
43546
43546
  }
43547
43547
  /**
43548
43548
  * Map git status codes to status type
@@ -47519,9 +47519,9 @@ function splitIdentifier(name21) {
47519
47519
  const joined = parts.join(" ").toLowerCase();
47520
47520
  return joined && joined !== name21.toLowerCase() ? joined : "";
47521
47521
  }
47522
- function packageToSearchDocs(pkg) {
47522
+ function packageToSearchDocs(pkg, packagePath = pkg.name) {
47523
47523
  const docs = [];
47524
- const service = pkg.name;
47524
+ const service = packagePath;
47525
47525
  docs.push({
47526
47526
  id: `package:${service}`,
47527
47527
  kind: "package",
@@ -47607,6 +47607,9 @@ function packageToSearchDocs(pkg) {
47607
47607
  route: `/cases/${c.uuid}`
47608
47608
  });
47609
47609
  }
47610
+ for (const subPackage of pkg.subPackages ?? []) {
47611
+ docs.push(...packageToSearchDocs(subPackage, `${packagePath}/${subPackage.name}`));
47612
+ }
47610
47613
  return docs;
47611
47614
  }
47612
47615
  var KIND_TIER, documentationFacets, entityRoute, withSplit;
@@ -47780,7 +47783,9 @@ var init_searchIndex = __esm({
47780
47783
  if (!this.ready) return;
47781
47784
  this.db.exec("BEGIN");
47782
47785
  try {
47783
- this.db.prepare("DELETE FROM docs WHERE package = ? AND kind NOT IN ('document','documentation-chunk')").run(pkg.name);
47786
+ this.db.prepare(
47787
+ "DELETE FROM docs WHERE (package = ? OR instr(package, ? || '/') = 1) AND kind NOT IN ('document','documentation-chunk')"
47788
+ ).run(pkg.name, pkg.name);
47784
47789
  this.db.prepare(`DELETE FROM documentation_search_meta WHERE search_doc_id NOT IN (SELECT id FROM docs)`).run();
47785
47790
  this.insertDocs(packageToSearchDocs(pkg));
47786
47791
  this.db.exec("COMMIT");
@@ -47806,7 +47811,7 @@ var init_searchIndex = __esm({
47806
47811
  /** Drop every doc for a package (on package delete). */
47807
47812
  removePackage(name21) {
47808
47813
  if (!this.ready) return;
47809
- this.db.prepare("DELETE FROM docs WHERE package = ?").run(name21);
47814
+ this.db.prepare("DELETE FROM docs WHERE package = ? OR instr(package, ? || '/') = 1").run(name21, name21);
47810
47815
  }
47811
47816
  /** Total indexed docs (test/health). */
47812
47817
  count() {
@@ -47814,6 +47819,12 @@ var init_searchIndex = __esm({
47814
47819
  const r = this.db.prepare("SELECT count(*) AS c FROM docs").get();
47815
47820
  return r.c;
47816
47821
  }
47822
+ /** Indexed document counts by kind, used by health diagnostics. */
47823
+ countsByKind() {
47824
+ if (!this.ready) return {};
47825
+ const rows = this.db.prepare("SELECT kind, count(*) AS count FROM docs GROUP BY kind").all();
47826
+ return Object.fromEntries(rows.map((row) => [row.kind, row.count]));
47827
+ }
47817
47828
  /**
47818
47829
  * Ranked full-text search. Blends FTS5 BM25 (name weighted highest, then
47819
47830
  * keywords, then description) with the per-kind tier so entities/attributes
@@ -47910,21 +47921,21 @@ function splitSections(document2) {
47910
47921
  if (current && contentOf(current.lines)) sections.push(current);
47911
47922
  current = void 0;
47912
47923
  }, "flush");
47913
- lines.forEach((text2, index2) => {
47924
+ lines.forEach((text3, index2) => {
47914
47925
  const line = index2 + 1;
47915
- const fence = text2.match(/^\s*(`{3,}|~{3,})/);
47926
+ const fence = text3.match(/^\s*(`{3,}|~{3,})/);
47916
47927
  if (fence) {
47917
47928
  const character = fence[1][0];
47918
47929
  if (!fenceCharacter) fenceCharacter = character;
47919
47930
  else if (fenceCharacter === character) fenceCharacter = void 0;
47920
47931
  }
47921
47932
  if (!fenceCharacter) {
47922
- const marker21 = text2.match(/^\s*<!--\s*chunk:\s*([a-zA-Z0-9][\w.-]*)\s*-->\s*$/);
47933
+ const marker21 = text3.match(/^\s*<!--\s*chunk:\s*([a-zA-Z0-9][\w.-]*)\s*-->\s*$/);
47923
47934
  if (marker21) {
47924
47935
  pendingAnchor = slug(marker21[1]);
47925
47936
  return;
47926
47937
  }
47927
- const heading = text2.match(/^(#{1,6})\s+(.+?)\s*#*\s*$/);
47938
+ const heading = text3.match(/^(#{1,6})\s+(.+?)\s*#*\s*$/);
47928
47939
  if (heading) {
47929
47940
  flush();
47930
47941
  const level = heading[1].length;
@@ -47933,14 +47944,14 @@ function splitSections(document2) {
47933
47944
  current = {
47934
47945
  headings: [...path25].filter(Boolean),
47935
47946
  anchor: pendingAnchor,
47936
- lines: [{ text: text2, line }]
47947
+ lines: [{ text: text3, line }]
47937
47948
  };
47938
47949
  pendingAnchor = void 0;
47939
47950
  return;
47940
47951
  }
47941
47952
  }
47942
47953
  if (!current) current = { headings: [], anchor: pendingAnchor, lines: [] };
47943
- current.lines.push({ text: text2, line });
47954
+ current.lines.push({ text: text3, line });
47944
47955
  });
47945
47956
  flush();
47946
47957
  return sections;
@@ -48033,9 +48044,9 @@ function boundedParts(section, targetCharacters, hardLimitCharacters) {
48033
48044
  return parts;
48034
48045
  }
48035
48046
  function descriptorsFor(headings, content) {
48036
- const text2 = `${headings.join(" ")} ${content.slice(0, 1200)}`.replace(/```[\s\S]*?```/g, " ").replace(/<[^>]+>|[^\p{L}\p{N}\s-]/gu, " ").toLowerCase();
48047
+ const text3 = `${headings.join(" ")} ${content.slice(0, 1200)}`.replace(/```[\s\S]*?```/g, " ").replace(/<[^>]+>|[^\p{L}\p{N}\s-]/gu, " ").toLowerCase();
48037
48048
  const descriptors = [];
48038
- for (const word of text2.match(/[\p{L}\p{N}][\p{L}\p{N}-]{2,}/gu) ?? []) {
48049
+ for (const word of text3.match(/[\p{L}\p{N}][\p{L}\p{N}-]{2,}/gu) ?? []) {
48039
48050
  if (DESCRIPTOR_STOP_WORDS.has(word) || descriptors.includes(word)) continue;
48040
48051
  descriptors.push(word);
48041
48052
  if (descriptors.length === 12) break;
@@ -48256,8 +48267,8 @@ var init_documentationRepository = __esm({
48256
48267
  init_documentationValidation();
48257
48268
  SAFE_SEGMENT = /^[A-Za-z0-9._-]+$/;
48258
48269
  isNotFound = /* @__PURE__ */ __name((error48) => {
48259
- const code = error48.code;
48260
- return code === "not-found" || code === "ENOENT";
48270
+ const code2 = error48.code;
48271
+ return code2 === "not-found" || code2 === "ENOENT";
48261
48272
  }, "isNotFound");
48262
48273
  DocumentationRepository = class {
48263
48274
  constructor(storage, ws = wsId("dictionaries")) {
@@ -48571,6 +48582,7 @@ var searchIndexService_exports = {};
48571
48582
  __export(searchIndexService_exports, {
48572
48583
  __setSearchIndexForTest: () => __setSearchIndexForTest,
48573
48584
  getSearchIndex: () => getSearchIndex,
48585
+ getSearchIndexHealth: () => getSearchIndexHealth,
48574
48586
  initSearchIndex: () => initSearchIndex,
48575
48587
  packageOfEvent: () => packageOfEvent,
48576
48588
  reindexDocumentation: () => reindexDocumentation,
@@ -48582,6 +48594,18 @@ __export(searchIndexService_exports, {
48582
48594
  function getSearchIndex() {
48583
48595
  return index && index.isReady() ? index : null;
48584
48596
  }
48597
+ function getSearchIndexHealth() {
48598
+ const live = getSearchIndex();
48599
+ return {
48600
+ ready: live !== null && lastBuildError === null,
48601
+ documentCount: live?.count() ?? 0,
48602
+ countsByKind: live?.countsByKind() ?? {},
48603
+ indexedRootPackages,
48604
+ lastBuildAt,
48605
+ lastBuildError,
48606
+ nodeVersion: process.version
48607
+ };
48608
+ }
48585
48609
  function searchModel(query, opts) {
48586
48610
  return getSearchIndex()?.search(query, opts) ?? [];
48587
48611
  }
@@ -48602,16 +48626,23 @@ async function loadDocumentationSearchDocs() {
48602
48626
  async function initSearchIndex() {
48603
48627
  if (!index) index = new SearchIndex(searchIndexPathFor(config.dataDir));
48604
48628
  const ok2 = await index.open();
48605
- if (!ok2) return false;
48629
+ if (!ok2) {
48630
+ lastBuildError = `FTS5 index unavailable on ${process.version}; Node 22.5+ with node:sqlite is required.`;
48631
+ return false;
48632
+ }
48606
48633
  try {
48607
48634
  const packages = await loadAllPackages();
48608
48635
  index.rebuildFrom(packages);
48609
48636
  index.reindexDocumentation(await loadDocumentationSearchDocs());
48637
+ indexedRootPackages = packages.length;
48638
+ lastBuildAt = (/* @__PURE__ */ new Date()).toISOString();
48639
+ lastBuildError = null;
48610
48640
  logger.info(`SearchIndex: built (${index.count()} docs from ${packages.length} packages)`);
48611
48641
  } catch (e) {
48612
- logger.warn(`SearchIndex: initial build failed \u2014 ${e instanceof Error ? e.message : String(e)}`);
48642
+ lastBuildError = e instanceof Error ? e.message : String(e);
48643
+ logger.warn(`SearchIndex: initial build failed \u2014 ${lastBuildError}`);
48613
48644
  }
48614
- return index.isReady();
48645
+ return index.isReady() && lastBuildError === null;
48615
48646
  }
48616
48647
  async function reindexPackageByName(name21) {
48617
48648
  const idx = getSearchIndex();
@@ -48669,16 +48700,7 @@ function subscribeSearchIndex(projection) {
48669
48700
  if (rebuildTimer) return;
48670
48701
  rebuildTimer = setTimeout(() => {
48671
48702
  rebuildTimer = null;
48672
- void (async () => {
48673
- const idx = getSearchIndex();
48674
- if (!idx) return;
48675
- try {
48676
- idx.rebuildFrom(await loadAllPackages());
48677
- idx.reindexDocumentation(await loadDocumentationSearchDocs());
48678
- } catch (e) {
48679
- logger.warn(`SearchIndex: full rebuild failed \u2014 ${e instanceof Error ? e.message : String(e)}`);
48680
- }
48681
- })();
48703
+ void initSearchIndex();
48682
48704
  }, 250);
48683
48705
  }, "scheduleFullRebuild");
48684
48706
  return projection.onInvalidate((event) => {
@@ -48695,11 +48717,14 @@ function subscribeSearchIndex(projection) {
48695
48717
  function resetSearchIndexForTest() {
48696
48718
  index?.close();
48697
48719
  index = null;
48720
+ lastBuildAt = null;
48721
+ lastBuildError = null;
48722
+ indexedRootPackages = 0;
48698
48723
  }
48699
48724
  function __setSearchIndexForTest(idx) {
48700
48725
  index = idx;
48701
48726
  }
48702
- var RESERVED_DIRS2, index;
48727
+ var RESERVED_DIRS2, index, lastBuildAt, lastBuildError, indexedRootPackages;
48703
48728
  var init_searchIndexService = __esm({
48704
48729
  "backend/src/services/search/searchIndexService.ts"() {
48705
48730
  "use strict";
@@ -48709,7 +48734,11 @@ var init_searchIndexService = __esm({
48709
48734
  init_searchDocuments();
48710
48735
  RESERVED_DIRS2 = /* @__PURE__ */ new Set([".dico", ".git", "node_modules"]);
48711
48736
  index = null;
48737
+ lastBuildAt = null;
48738
+ lastBuildError = null;
48739
+ indexedRootPackages = 0;
48712
48740
  __name(getSearchIndex, "getSearchIndex");
48741
+ __name(getSearchIndexHealth, "getSearchIndexHealth");
48713
48742
  __name(searchModel, "searchModel");
48714
48743
  __name(loadAllPackages, "loadAllPackages");
48715
48744
  __name(loadOnePackage, "loadOnePackage");
@@ -49759,9 +49788,9 @@ var init_serviceService = __esm({
49759
49788
  }
49760
49789
  return [];
49761
49790
  }
49762
- calculateMatchScore(text2, searchTerms) {
49763
- if (!text2) return 0;
49764
- const normalizedText = text2.toLowerCase();
49791
+ calculateMatchScore(text3, searchTerms) {
49792
+ if (!text3) return 0;
49793
+ const normalizedText = text3.toLowerCase();
49765
49794
  let score = 0;
49766
49795
  for (const term of searchTerms) {
49767
49796
  if (normalizedText.includes(term)) {
@@ -57048,8 +57077,8 @@ var capitalizeFirstCharacter, error26;
57048
57077
  var init_lt = __esm({
57049
57078
  "backend/node_modules/zod/v4/locales/lt.js"() {
57050
57079
  init_util2();
57051
- capitalizeFirstCharacter = /* @__PURE__ */ __name((text2) => {
57052
- return text2.charAt(0).toUpperCase() + text2.slice(1);
57080
+ capitalizeFirstCharacter = /* @__PURE__ */ __name((text3) => {
57081
+ return text3.charAt(0).toUpperCase() + text3.slice(1);
57053
57082
  }, "capitalizeFirstCharacter");
57054
57083
  __name(getUnitTypeFromNumber, "getUnitTypeFromNumber");
57055
57084
  error26 = /* @__PURE__ */ __name(() => {
@@ -66041,15 +66070,15 @@ var init_dist2 = __esm({
66041
66070
  static {
66042
66071
  __name(this, "JSONParseError");
66043
66072
  }
66044
- constructor({ text: text2, cause }) {
66073
+ constructor({ text: text3, cause }) {
66045
66074
  super({
66046
66075
  name: name6,
66047
- message: `JSON parsing failed: Text: ${text2}.
66076
+ message: `JSON parsing failed: Text: ${text3}.
66048
66077
  Error message: ${getErrorMessage2(cause)}`,
66049
66078
  cause
66050
66079
  });
66051
66080
  this[_a7] = true;
66052
- this.text = text2;
66081
+ this.text = text3;
66053
66082
  }
66054
66083
  static isInstance(error48) {
66055
66084
  return AISDKError.hasMarker(error48, marker7);
@@ -70790,8 +70819,8 @@ function isBunNetworkError(error48) {
70790
70819
  if (!(error48 instanceof Error)) {
70791
70820
  return false;
70792
70821
  }
70793
- const code = error48.code;
70794
- if (typeof code === "string" && BUN_ERROR_CODES.includes(code)) {
70822
+ const code2 = error48.code;
70823
+ if (typeof code2 === "string" && BUN_ERROR_CODES.includes(code2)) {
70795
70824
  return true;
70796
70825
  }
70797
70826
  return false;
@@ -70948,12 +70977,12 @@ function mediaTypeToExtension(mediaType) {
70948
70977
  "x-m4a": "m4a"
70949
70978
  }[subtype]) != null ? _a25 : subtype;
70950
70979
  }
70951
- function _parse2(text2) {
70952
- const obj = JSON.parse(text2);
70980
+ function _parse2(text3) {
70981
+ const obj = JSON.parse(text3);
70953
70982
  if (obj === null || typeof obj !== "object") {
70954
70983
  return obj;
70955
70984
  }
70956
- if (suspectProtoRx.test(text2) === false && suspectConstructorRx.test(text2) === false) {
70985
+ if (suspectProtoRx.test(text3) === false && suspectConstructorRx.test(text3) === false) {
70957
70986
  return obj;
70958
70987
  }
70959
70988
  return filter(obj);
@@ -70980,15 +71009,15 @@ function filter(obj) {
70980
71009
  }
70981
71010
  return obj;
70982
71011
  }
70983
- function secureJsonParse(text2) {
71012
+ function secureJsonParse(text3) {
70984
71013
  const { stackTraceLimit } = Error;
70985
71014
  try {
70986
71015
  Error.stackTraceLimit = 0;
70987
71016
  } catch (e) {
70988
- return _parse2(text2);
71017
+ return _parse2(text3);
70989
71018
  }
70990
71019
  try {
70991
- return _parse2(text2);
71020
+ return _parse2(text3);
70992
71021
  } finally {
70993
71022
  Error.stackTraceLimit = stackTraceLimit;
70994
71023
  }
@@ -71927,11 +71956,11 @@ async function safeValidateTypes({
71927
71956
  }
71928
71957
  }
71929
71958
  async function parseJSON({
71930
- text: text2,
71959
+ text: text3,
71931
71960
  schema
71932
71961
  }) {
71933
71962
  try {
71934
- const value = secureJsonParse(text2);
71963
+ const value = secureJsonParse(text3);
71935
71964
  if (schema == null) {
71936
71965
  return value;
71937
71966
  }
@@ -71940,15 +71969,15 @@ async function parseJSON({
71940
71969
  if (JSONParseError.isInstance(error48) || TypeValidationError.isInstance(error48)) {
71941
71970
  throw error48;
71942
71971
  }
71943
- throw new JSONParseError({ text: text2, cause: error48 });
71972
+ throw new JSONParseError({ text: text3, cause: error48 });
71944
71973
  }
71945
71974
  }
71946
71975
  async function safeParseJSON({
71947
- text: text2,
71976
+ text: text3,
71948
71977
  schema
71949
71978
  }) {
71950
71979
  try {
71951
- const value = secureJsonParse(text2);
71980
+ const value = secureJsonParse(text3);
71952
71981
  if (schema == null) {
71953
71982
  return { success: true, value, rawValue: value };
71954
71983
  }
@@ -71956,7 +71985,7 @@ async function safeParseJSON({
71956
71985
  } catch (error48) {
71957
71986
  return {
71958
71987
  success: false,
71959
- error: JSONParseError.isInstance(error48) ? error48 : new JSONParseError({ text: text2, cause: error48 }),
71988
+ error: JSONParseError.isInstance(error48) ? error48 : new JSONParseError({ text: text3, cause: error48 }),
71960
71989
  rawValue: void 0
71961
71990
  };
71962
71991
  }
@@ -80543,7 +80572,7 @@ function streamText({
80543
80572
  }
80544
80573
  function createOutputTransformStream(output) {
80545
80574
  let firstTextChunkId = void 0;
80546
- let text2 = "";
80575
+ let text22 = "";
80547
80576
  let textChunk = "";
80548
80577
  let textProviderMetadata = void 0;
80549
80578
  let lastPublishedJson = "";
@@ -80590,10 +80619,10 @@ function createOutputTransformStream(output) {
80590
80619
  controller.enqueue({ part: chunk, partialOutput: void 0 });
80591
80620
  return;
80592
80621
  }
80593
- text2 += chunk.text;
80622
+ text22 += chunk.text;
80594
80623
  textChunk += chunk.text;
80595
80624
  textProviderMetadata = (_a21 = chunk.providerMetadata) != null ? _a21 : textProviderMetadata;
80596
- const result = await output.parsePartialOutput({ text: text2 });
80625
+ const result = await output.parsePartialOutput({ text: text22 });
80597
80626
  if (result !== void 0) {
80598
80627
  const currentJson = JSON.stringify(result.partial);
80599
80628
  if (currentJson !== lastPublishedJson) {
@@ -81035,14 +81064,14 @@ var init_dist6 = __esm({
81035
81064
  constructor({
81036
81065
  message = "No object generated.",
81037
81066
  cause,
81038
- text: text2,
81067
+ text: text22,
81039
81068
  response,
81040
81069
  usage,
81041
81070
  finishReason
81042
81071
  }) {
81043
81072
  super({ name: name82, message, cause });
81044
81073
  this[_a83] = true;
81045
- this.text = text2;
81074
+ this.text = text22;
81046
81075
  this.response = response;
81047
81076
  this.usage = usage;
81048
81077
  this.finishReason = finishReason;
@@ -81768,11 +81797,11 @@ var init_dist6 = __esm({
81768
81797
  text = /* @__PURE__ */ __name(() => ({
81769
81798
  name: "text",
81770
81799
  responseFormat: Promise.resolve({ type: "text" }),
81771
- async parseCompleteOutput({ text: text2 }) {
81772
- return text2;
81800
+ async parseCompleteOutput({ text: text22 }) {
81801
+ return text22;
81773
81802
  },
81774
- async parsePartialOutput({ text: text2 }) {
81775
- return { partial: text2 };
81803
+ async parsePartialOutput({ text: text22 }) {
81804
+ return { partial: text22 };
81776
81805
  },
81777
81806
  createElementStreamTransform() {
81778
81807
  return void 0;
@@ -81792,13 +81821,13 @@ var init_dist6 = __esm({
81792
81821
  ...name21 != null && { name: name21 },
81793
81822
  ...description != null && { description }
81794
81823
  })),
81795
- async parseCompleteOutput({ text: text2 }, context2) {
81796
- const parseResult = await safeParseJSON({ text: text2 });
81824
+ async parseCompleteOutput({ text: text22 }, context2) {
81825
+ const parseResult = await safeParseJSON({ text: text22 });
81797
81826
  if (!parseResult.success) {
81798
81827
  throw new NoObjectGeneratedError({
81799
81828
  message: "No object generated: could not parse the response.",
81800
81829
  cause: parseResult.error,
81801
- text: text2,
81830
+ text: text22,
81802
81831
  response: context2.response,
81803
81832
  usage: context2.usage,
81804
81833
  finishReason: context2.finishReason
@@ -81812,7 +81841,7 @@ var init_dist6 = __esm({
81812
81841
  throw new NoObjectGeneratedError({
81813
81842
  message: "No object generated: response did not match schema.",
81814
81843
  cause: validationResult.error,
81815
- text: text2,
81844
+ text: text22,
81816
81845
  response: context2.response,
81817
81846
  usage: context2.usage,
81818
81847
  finishReason: context2.finishReason
@@ -81820,8 +81849,8 @@ var init_dist6 = __esm({
81820
81849
  }
81821
81850
  return validationResult.value;
81822
81851
  },
81823
- async parsePartialOutput({ text: text2 }) {
81824
- const result = await parsePartialJson(text2);
81852
+ async parsePartialOutput({ text: text22 }) {
81853
+ const result = await parsePartialJson(text22);
81825
81854
  switch (result.state) {
81826
81855
  case "failed-parse":
81827
81856
  case "undefined-input": {
@@ -81867,13 +81896,13 @@ var init_dist6 = __esm({
81867
81896
  ...description != null && { description }
81868
81897
  };
81869
81898
  }),
81870
- async parseCompleteOutput({ text: text2 }, context2) {
81871
- const parseResult = await safeParseJSON({ text: text2 });
81899
+ async parseCompleteOutput({ text: text22 }, context2) {
81900
+ const parseResult = await safeParseJSON({ text: text22 });
81872
81901
  if (!parseResult.success) {
81873
81902
  throw new NoObjectGeneratedError({
81874
81903
  message: "No object generated: could not parse the response.",
81875
81904
  cause: parseResult.error,
81876
- text: text2,
81905
+ text: text22,
81877
81906
  response: context2.response,
81878
81907
  usage: context2.usage,
81879
81908
  finishReason: context2.finishReason
@@ -81887,7 +81916,7 @@ var init_dist6 = __esm({
81887
81916
  value: outerValue,
81888
81917
  cause: "response must be an object with an elements array"
81889
81918
  }),
81890
- text: text2,
81919
+ text: text22,
81891
81920
  response: context2.response,
81892
81921
  usage: context2.usage,
81893
81922
  finishReason: context2.finishReason
@@ -81902,7 +81931,7 @@ var init_dist6 = __esm({
81902
81931
  throw new NoObjectGeneratedError({
81903
81932
  message: "No object generated: response did not match schema.",
81904
81933
  cause: validationResult.error,
81905
- text: text2,
81934
+ text: text22,
81906
81935
  response: context2.response,
81907
81936
  usage: context2.usage,
81908
81937
  finishReason: context2.finishReason
@@ -81911,8 +81940,8 @@ var init_dist6 = __esm({
81911
81940
  }
81912
81941
  return outerValue.elements;
81913
81942
  },
81914
- async parsePartialOutput({ text: text2 }) {
81915
- const result = await parsePartialJson(text2);
81943
+ async parsePartialOutput({ text: text22 }) {
81944
+ const result = await parsePartialJson(text22);
81916
81945
  switch (result.state) {
81917
81946
  case "failed-parse":
81918
81947
  case "undefined-input": {
@@ -81975,13 +82004,13 @@ var init_dist6 = __esm({
81975
82004
  ...name21 != null && { name: name21 },
81976
82005
  ...description != null && { description }
81977
82006
  }),
81978
- async parseCompleteOutput({ text: text2 }, context2) {
81979
- const parseResult = await safeParseJSON({ text: text2 });
82007
+ async parseCompleteOutput({ text: text22 }, context2) {
82008
+ const parseResult = await safeParseJSON({ text: text22 });
81980
82009
  if (!parseResult.success) {
81981
82010
  throw new NoObjectGeneratedError({
81982
82011
  message: "No object generated: could not parse the response.",
81983
82012
  cause: parseResult.error,
81984
- text: text2,
82013
+ text: text22,
81985
82014
  response: context2.response,
81986
82015
  usage: context2.usage,
81987
82016
  finishReason: context2.finishReason
@@ -81995,7 +82024,7 @@ var init_dist6 = __esm({
81995
82024
  value: outerValue,
81996
82025
  cause: "response must be an object that contains a choice value."
81997
82026
  }),
81998
- text: text2,
82027
+ text: text22,
81999
82028
  response: context2.response,
82000
82029
  usage: context2.usage,
82001
82030
  finishReason: context2.finishReason
@@ -82003,8 +82032,8 @@ var init_dist6 = __esm({
82003
82032
  }
82004
82033
  return outerValue.result;
82005
82034
  },
82006
- async parsePartialOutput({ text: text2 }) {
82007
- const result = await parsePartialJson(text2);
82035
+ async parsePartialOutput({ text: text22 }) {
82036
+ const result = await parsePartialJson(text22);
82008
82037
  switch (result.state) {
82009
82038
  case "failed-parse":
82010
82039
  case "undefined-input": {
@@ -82043,13 +82072,13 @@ var init_dist6 = __esm({
82043
82072
  ...name21 != null && { name: name21 },
82044
82073
  ...description != null && { description }
82045
82074
  }),
82046
- async parseCompleteOutput({ text: text2 }, context2) {
82047
- const parseResult = await safeParseJSON({ text: text2 });
82075
+ async parseCompleteOutput({ text: text22 }, context2) {
82076
+ const parseResult = await safeParseJSON({ text: text22 });
82048
82077
  if (!parseResult.success) {
82049
82078
  throw new NoObjectGeneratedError({
82050
82079
  message: "No object generated: could not parse the response.",
82051
82080
  cause: parseResult.error,
82052
- text: text2,
82081
+ text: text22,
82053
82082
  response: context2.response,
82054
82083
  usage: context2.usage,
82055
82084
  finishReason: context2.finishReason
@@ -82057,8 +82086,8 @@ var init_dist6 = __esm({
82057
82086
  }
82058
82087
  return parseResult.value;
82059
82088
  },
82060
- async parsePartialOutput({ text: text2 }) {
82061
- const result = await parsePartialJson(text2);
82089
+ async parsePartialOutput({ text: text22 }) {
82090
+ const result = await parsePartialJson(text22);
82062
82091
  switch (result.state) {
82063
82092
  case "failed-parse":
82064
82093
  case "undefined-input": {
@@ -84357,6 +84386,21 @@ function jsonByteLength(value) {
84357
84386
  return -1;
84358
84387
  }
84359
84388
  }
84389
+ function providerPayloadBreakdown(body) {
84390
+ try {
84391
+ const parsed = JSON.parse(body);
84392
+ const messages = Array.isArray(parsed.messages) ? parsed.messages : [];
84393
+ const tools = Array.isArray(parsed.tools) ? parsed.tools : [];
84394
+ return {
84395
+ messagesBytes: jsonByteLength(messages),
84396
+ toolsBytes: jsonByteLength(tools),
84397
+ messageCount: messages.length,
84398
+ toolCount: tools.length
84399
+ };
84400
+ } catch {
84401
+ return {};
84402
+ }
84403
+ }
84360
84404
  function createMeasuredProviderFetch(provider, model, diagnosticId) {
84361
84405
  return async (input, init) => {
84362
84406
  const body = init?.body;
@@ -84372,13 +84416,15 @@ function createMeasuredProviderFetch(provider, model, diagnosticId) {
84372
84416
  endpoint = `${url2.host}${url2.pathname}`;
84373
84417
  } catch {
84374
84418
  }
84419
+ const breakdown = typeof body === "string" ? providerPayloadBreakdown(body) : {};
84375
84420
  recordProviderRequestMeasurement({
84376
84421
  provider,
84377
84422
  model,
84378
84423
  diagnosticId: diagnosticId ?? null,
84379
84424
  endpoint,
84380
84425
  requestBodyBytes,
84381
- contentLengthHeader: new Headers(init?.headers).get("content-length")
84426
+ contentLengthHeader: new Headers(init?.headers).get("content-length"),
84427
+ ...breakdown
84382
84428
  });
84383
84429
  return fetch(input, init);
84384
84430
  };
@@ -84393,6 +84439,7 @@ var init_aiPayloadMetrics = __esm({
84393
84439
  __name(getProviderRequestMeasurement, "getProviderRequestMeasurement");
84394
84440
  __name(utf8ByteLength, "utf8ByteLength");
84395
84441
  __name(jsonByteLength, "jsonByteLength");
84442
+ __name(providerPayloadBreakdown, "providerPayloadBreakdown");
84396
84443
  __name(createMeasuredProviderFetch, "createMeasuredProviderFetch");
84397
84444
  }
84398
84445
  });
@@ -86390,23 +86437,23 @@ var init_types4 = __esm({
86390
86437
  static {
86391
86438
  __name(this, "McpError");
86392
86439
  }
86393
- constructor(code, message, data) {
86394
- super(`MCP error ${code}: ${message}`);
86395
- this.code = code;
86440
+ constructor(code2, message, data) {
86441
+ super(`MCP error ${code2}: ${message}`);
86442
+ this.code = code2;
86396
86443
  this.data = data;
86397
86444
  this.name = "McpError";
86398
86445
  }
86399
86446
  /**
86400
86447
  * Factory method to create the appropriate error type based on the error code and data
86401
86448
  */
86402
- static fromError(code, message, data) {
86403
- if (code === ErrorCode.UrlElicitationRequired && data) {
86449
+ static fromError(code2, message, data) {
86450
+ if (code2 === ErrorCode.UrlElicitationRequired && data) {
86404
86451
  const errorData = data;
86405
86452
  if (errorData.elicitations) {
86406
86453
  return new UrlElicitationRequiredError(errorData.elicitations, message);
86407
86454
  }
86408
86455
  }
86409
- return new _McpError(code, message, data);
86456
+ return new _McpError(code2, message, data);
86410
86457
  }
86411
86458
  };
86412
86459
  UrlElicitationRequiredError = class extends McpError {
@@ -87822,9 +87869,9 @@ var require_code = __commonJS({
87822
87869
  static {
87823
87870
  __name(this, "_Code");
87824
87871
  }
87825
- constructor(code) {
87872
+ constructor(code2) {
87826
87873
  super();
87827
- this._items = typeof code === "string" ? [code] : code;
87874
+ this._items = typeof code2 === "string" ? [code2] : code2;
87828
87875
  }
87829
87876
  toString() {
87830
87877
  return this.str;
@@ -87851,13 +87898,13 @@ var require_code = __commonJS({
87851
87898
  exports2._Code = _Code;
87852
87899
  exports2.nil = new _Code("");
87853
87900
  function _(strs, ...args) {
87854
- const code = [strs[0]];
87901
+ const code2 = [strs[0]];
87855
87902
  let i = 0;
87856
87903
  while (i < args.length) {
87857
- addCodeArg(code, args[i]);
87858
- code.push(strs[++i]);
87904
+ addCodeArg(code2, args[i]);
87905
+ code2.push(strs[++i]);
87859
87906
  }
87860
- return new _Code(code);
87907
+ return new _Code(code2);
87861
87908
  }
87862
87909
  __name(_, "_");
87863
87910
  exports2._ = _;
@@ -87875,13 +87922,13 @@ var require_code = __commonJS({
87875
87922
  }
87876
87923
  __name(str2, "str");
87877
87924
  exports2.str = str2;
87878
- function addCodeArg(code, arg) {
87925
+ function addCodeArg(code2, arg) {
87879
87926
  if (arg instanceof _Code)
87880
- code.push(...arg._items);
87927
+ code2.push(...arg._items);
87881
87928
  else if (arg instanceof Name)
87882
- code.push(arg);
87929
+ code2.push(arg);
87883
87930
  else
87884
- code.push(interpolate(arg));
87931
+ code2.push(interpolate(arg));
87885
87932
  }
87886
87933
  __name(addCodeArg, "addCodeArg");
87887
87934
  exports2.addCodeArg = addCodeArg;
@@ -88087,7 +88134,7 @@ var require_scope = __commonJS({
88087
88134
  }, usedValues, getCode);
88088
88135
  }
88089
88136
  _reduceValues(values, valueCode, usedValues = {}, getCode) {
88090
- let code = code_1.nil;
88137
+ let code2 = code_1.nil;
88091
88138
  for (const prefix in values) {
88092
88139
  const vs = values[prefix];
88093
88140
  if (!vs)
@@ -88100,16 +88147,16 @@ var require_scope = __commonJS({
88100
88147
  let c = valueCode(name21);
88101
88148
  if (c) {
88102
88149
  const def = this.opts.es5 ? exports2.varKinds.var : exports2.varKinds.const;
88103
- code = (0, code_1._)`${code}${def} ${name21} = ${c};${this.opts._n}`;
88150
+ code2 = (0, code_1._)`${code2}${def} ${name21} = ${c};${this.opts._n}`;
88104
88151
  } else if (c = getCode === null || getCode === void 0 ? void 0 : getCode(name21)) {
88105
- code = (0, code_1._)`${code}${c}${this.opts._n}`;
88152
+ code2 = (0, code_1._)`${code2}${c}${this.opts._n}`;
88106
88153
  } else {
88107
88154
  throw new ValueError(name21);
88108
88155
  }
88109
88156
  nameSet.set(name21, UsedValueState.Completed);
88110
88157
  });
88111
88158
  }
88112
- return code;
88159
+ return code2;
88113
88160
  }
88114
88161
  };
88115
88162
  exports2.ValueScope = ValueScope;
@@ -88293,9 +88340,9 @@ var require_codegen = __commonJS({
88293
88340
  static {
88294
88341
  __name(this, "AnyCode");
88295
88342
  }
88296
- constructor(code) {
88343
+ constructor(code2) {
88297
88344
  super();
88298
- this.code = code;
88345
+ this.code = code2;
88299
88346
  }
88300
88347
  render({ _n }) {
88301
88348
  return `${this.code};` + _n;
@@ -88320,7 +88367,7 @@ var require_codegen = __commonJS({
88320
88367
  this.nodes = nodes;
88321
88368
  }
88322
88369
  render(opts) {
88323
- return this.nodes.reduce((code, n) => code + n.render(opts), "");
88370
+ return this.nodes.reduce((code2, n) => code2 + n.render(opts), "");
88324
88371
  }
88325
88372
  optimizeNodes() {
88326
88373
  const { nodes } = this;
@@ -88380,10 +88427,10 @@ var require_codegen = __commonJS({
88380
88427
  this.condition = condition;
88381
88428
  }
88382
88429
  render(opts) {
88383
- let code = `if(${this.condition})` + super.render(opts);
88430
+ let code2 = `if(${this.condition})` + super.render(opts);
88384
88431
  if (this.else)
88385
- code += "else " + this.else.render(opts);
88386
- return code;
88432
+ code2 += "else " + this.else.render(opts);
88433
+ return code2;
88387
88434
  }
88388
88435
  optimizeNodes() {
88389
88436
  super.optimizeNodes();
@@ -88525,12 +88572,12 @@ var require_codegen = __commonJS({
88525
88572
  __name(this, "Try");
88526
88573
  }
88527
88574
  render(opts) {
88528
- let code = "try" + super.render(opts);
88575
+ let code2 = "try" + super.render(opts);
88529
88576
  if (this.catch)
88530
- code += this.catch.render(opts);
88577
+ code2 += this.catch.render(opts);
88531
88578
  if (this.finally)
88532
- code += this.finally.render(opts);
88533
- return code;
88579
+ code2 += this.finally.render(opts);
88580
+ return code2;
88534
88581
  }
88535
88582
  optimizeNodes() {
88536
88583
  var _a21, _b17;
@@ -88656,18 +88703,18 @@ var require_codegen = __commonJS({
88656
88703
  }
88657
88704
  // returns code for object literal for the passed argument list of key-value pairs
88658
88705
  object(...keyValues) {
88659
- const code = ["{"];
88706
+ const code2 = ["{"];
88660
88707
  for (const [key2, value] of keyValues) {
88661
- if (code.length > 1)
88662
- code.push(",");
88663
- code.push(key2);
88708
+ if (code2.length > 1)
88709
+ code2.push(",");
88710
+ code2.push(key2);
88664
88711
  if (key2 !== value || this.opts.es5) {
88665
- code.push(":");
88666
- (0, code_1.addCodeArg)(code, value);
88712
+ code2.push(":");
88713
+ (0, code_1.addCodeArg)(code2, value);
88667
88714
  }
88668
88715
  }
88669
- code.push("}");
88670
- return new code_1._Code(code);
88716
+ code2.push("}");
88717
+ return new code_1._Code(code2);
88671
88718
  }
88672
88719
  // `if` clause (or statement if `thenBody` and, optionally, `elseBody` are passed)
88673
88720
  if(condition, thenBody, elseBody) {
@@ -91126,22 +91173,22 @@ var require_utils3 = __commonJS({
91126
91173
  var isIPv42 = 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);
91127
91174
  function stringArrayToHexStripped(input) {
91128
91175
  let acc = "";
91129
- let code = 0;
91176
+ let code2 = 0;
91130
91177
  let i = 0;
91131
91178
  for (i = 0; i < input.length; i++) {
91132
- code = input[i].charCodeAt(0);
91133
- if (code === 48) {
91179
+ code2 = input[i].charCodeAt(0);
91180
+ if (code2 === 48) {
91134
91181
  continue;
91135
91182
  }
91136
- if (!(code >= 48 && code <= 57 || code >= 65 && code <= 70 || code >= 97 && code <= 102)) {
91183
+ if (!(code2 >= 48 && code2 <= 57 || code2 >= 65 && code2 <= 70 || code2 >= 97 && code2 <= 102)) {
91137
91184
  return "";
91138
91185
  }
91139
91186
  acc += input[i];
91140
91187
  break;
91141
91188
  }
91142
91189
  for (i += 1; i < input.length; i++) {
91143
- code = input[i].charCodeAt(0);
91144
- if (!(code >= 48 && code <= 57 || code >= 65 && code <= 70 || code >= 97 && code <= 102)) {
91190
+ code2 = input[i].charCodeAt(0);
91191
+ if (!(code2 >= 48 && code2 <= 57 || code2 >= 65 && code2 <= 70 || code2 >= 97 && code2 <= 102)) {
91145
91192
  return "";
91146
91193
  }
91147
91194
  acc += input[i];
@@ -92279,7 +92326,7 @@ var require_core = __commonJS({
92279
92326
  errorsText(errors = this.errors, { separator = ", ", dataVar = "data" } = {}) {
92280
92327
  if (!errors || errors.length === 0)
92281
92328
  return "No errors";
92282
- return errors.map((e) => `${dataVar}${e.instancePath} ${e.message}`).reduce((text2, msg) => text2 + separator + msg);
92329
+ return errors.map((e) => `${dataVar}${e.instancePath} ${e.message}`).reduce((text3, msg) => text3 + separator + msg);
92283
92330
  }
92284
92331
  $dataMetaSchema(metaSchema, keywordsJsonPointers) {
92285
92332
  const rules = this.RULES.all;
@@ -94174,8 +94221,8 @@ var require_format = __commonJS({
94174
94221
  }
94175
94222
  __name(unknownFormat, "unknownFormat");
94176
94223
  function getFormat(fmtDef) {
94177
- const code = fmtDef instanceof RegExp ? (0, codegen_1.regexpCode)(fmtDef) : opts.code.formats ? (0, codegen_1._)`${opts.code.formats}${(0, codegen_1.getProperty)(schema)}` : void 0;
94178
- const fmt = gen.scopeValue("formats", { key: schema, ref: fmtDef, code });
94224
+ const code2 = fmtDef instanceof RegExp ? (0, codegen_1.regexpCode)(fmtDef) : opts.code.formats ? (0, codegen_1._)`${opts.code.formats}${(0, codegen_1.getProperty)(schema)}` : void 0;
94225
+ const fmt = gen.scopeValue("formats", { key: schema, ref: fmtDef, code: code2 });
94179
94226
  if (typeof fmtDef == "object" && !(fmtDef instanceof RegExp)) {
94180
94227
  return [fmtDef.type || "string", fmtDef.validate, (0, codegen_1._)`${fmt}.validate`];
94181
94228
  }
@@ -94867,9 +94914,9 @@ var require_code3 = __commonJS({
94867
94914
  static {
94868
94915
  __name(this, "_Code");
94869
94916
  }
94870
- constructor(code) {
94917
+ constructor(code2) {
94871
94918
  super();
94872
- this._items = typeof code === "string" ? [code] : code;
94919
+ this._items = typeof code2 === "string" ? [code2] : code2;
94873
94920
  }
94874
94921
  toString() {
94875
94922
  return this.str;
@@ -94896,13 +94943,13 @@ var require_code3 = __commonJS({
94896
94943
  exports2._Code = _Code;
94897
94944
  exports2.nil = new _Code("");
94898
94945
  function _(strs, ...args) {
94899
- const code = [strs[0]];
94946
+ const code2 = [strs[0]];
94900
94947
  let i = 0;
94901
94948
  while (i < args.length) {
94902
- addCodeArg(code, args[i]);
94903
- code.push(strs[++i]);
94949
+ addCodeArg(code2, args[i]);
94950
+ code2.push(strs[++i]);
94904
94951
  }
94905
- return new _Code(code);
94952
+ return new _Code(code2);
94906
94953
  }
94907
94954
  __name(_, "_");
94908
94955
  exports2._ = _;
@@ -94920,13 +94967,13 @@ var require_code3 = __commonJS({
94920
94967
  }
94921
94968
  __name(str2, "str");
94922
94969
  exports2.str = str2;
94923
- function addCodeArg(code, arg) {
94970
+ function addCodeArg(code2, arg) {
94924
94971
  if (arg instanceof _Code)
94925
- code.push(...arg._items);
94972
+ code2.push(...arg._items);
94926
94973
  else if (arg instanceof Name)
94927
- code.push(arg);
94974
+ code2.push(arg);
94928
94975
  else
94929
- code.push(interpolate(arg));
94976
+ code2.push(interpolate(arg));
94930
94977
  }
94931
94978
  __name(addCodeArg, "addCodeArg");
94932
94979
  exports2.addCodeArg = addCodeArg;
@@ -95132,7 +95179,7 @@ var require_scope2 = __commonJS({
95132
95179
  }, usedValues, getCode);
95133
95180
  }
95134
95181
  _reduceValues(values, valueCode, usedValues = {}, getCode) {
95135
- let code = code_1.nil;
95182
+ let code2 = code_1.nil;
95136
95183
  for (const prefix in values) {
95137
95184
  const vs = values[prefix];
95138
95185
  if (!vs)
@@ -95145,16 +95192,16 @@ var require_scope2 = __commonJS({
95145
95192
  let c = valueCode(name21);
95146
95193
  if (c) {
95147
95194
  const def = this.opts.es5 ? exports2.varKinds.var : exports2.varKinds.const;
95148
- code = (0, code_1._)`${code}${def} ${name21} = ${c};${this.opts._n}`;
95195
+ code2 = (0, code_1._)`${code2}${def} ${name21} = ${c};${this.opts._n}`;
95149
95196
  } else if (c = getCode === null || getCode === void 0 ? void 0 : getCode(name21)) {
95150
- code = (0, code_1._)`${code}${c}${this.opts._n}`;
95197
+ code2 = (0, code_1._)`${code2}${c}${this.opts._n}`;
95151
95198
  } else {
95152
95199
  throw new ValueError(name21);
95153
95200
  }
95154
95201
  nameSet.set(name21, UsedValueState.Completed);
95155
95202
  });
95156
95203
  }
95157
- return code;
95204
+ return code2;
95158
95205
  }
95159
95206
  };
95160
95207
  exports2.ValueScope = ValueScope;
@@ -95338,9 +95385,9 @@ var require_codegen2 = __commonJS({
95338
95385
  static {
95339
95386
  __name(this, "AnyCode");
95340
95387
  }
95341
- constructor(code) {
95388
+ constructor(code2) {
95342
95389
  super();
95343
- this.code = code;
95390
+ this.code = code2;
95344
95391
  }
95345
95392
  render({ _n }) {
95346
95393
  return `${this.code};` + _n;
@@ -95365,7 +95412,7 @@ var require_codegen2 = __commonJS({
95365
95412
  this.nodes = nodes;
95366
95413
  }
95367
95414
  render(opts) {
95368
- return this.nodes.reduce((code, n) => code + n.render(opts), "");
95415
+ return this.nodes.reduce((code2, n) => code2 + n.render(opts), "");
95369
95416
  }
95370
95417
  optimizeNodes() {
95371
95418
  const { nodes } = this;
@@ -95425,10 +95472,10 @@ var require_codegen2 = __commonJS({
95425
95472
  this.condition = condition;
95426
95473
  }
95427
95474
  render(opts) {
95428
- let code = `if(${this.condition})` + super.render(opts);
95475
+ let code2 = `if(${this.condition})` + super.render(opts);
95429
95476
  if (this.else)
95430
- code += "else " + this.else.render(opts);
95431
- return code;
95477
+ code2 += "else " + this.else.render(opts);
95478
+ return code2;
95432
95479
  }
95433
95480
  optimizeNodes() {
95434
95481
  super.optimizeNodes();
@@ -95570,12 +95617,12 @@ var require_codegen2 = __commonJS({
95570
95617
  __name(this, "Try");
95571
95618
  }
95572
95619
  render(opts) {
95573
- let code = "try" + super.render(opts);
95620
+ let code2 = "try" + super.render(opts);
95574
95621
  if (this.catch)
95575
- code += this.catch.render(opts);
95622
+ code2 += this.catch.render(opts);
95576
95623
  if (this.finally)
95577
- code += this.finally.render(opts);
95578
- return code;
95624
+ code2 += this.finally.render(opts);
95625
+ return code2;
95579
95626
  }
95580
95627
  optimizeNodes() {
95581
95628
  var _a21, _b17;
@@ -95701,18 +95748,18 @@ var require_codegen2 = __commonJS({
95701
95748
  }
95702
95749
  // returns code for object literal for the passed argument list of key-value pairs
95703
95750
  object(...keyValues) {
95704
- const code = ["{"];
95751
+ const code2 = ["{"];
95705
95752
  for (const [key2, value] of keyValues) {
95706
- if (code.length > 1)
95707
- code.push(",");
95708
- code.push(key2);
95753
+ if (code2.length > 1)
95754
+ code2.push(",");
95755
+ code2.push(key2);
95709
95756
  if (key2 !== value || this.opts.es5) {
95710
- code.push(":");
95711
- (0, code_1.addCodeArg)(code, value);
95757
+ code2.push(":");
95758
+ (0, code_1.addCodeArg)(code2, value);
95712
95759
  }
95713
95760
  }
95714
- code.push("}");
95715
- return new code_1._Code(code);
95761
+ code2.push("}");
95762
+ return new code_1._Code(code2);
95716
95763
  }
95717
95764
  // `if` clause (or statement if `thenBody` and, optionally, `elseBody` are passed)
95718
95765
  if(condition, thenBody, elseBody) {
@@ -98541,7 +98588,7 @@ var require_core3 = __commonJS({
98541
98588
  errorsText(errors = this.errors, { separator = ", ", dataVar = "data" } = {}) {
98542
98589
  if (!errors || errors.length === 0)
98543
98590
  return "No errors";
98544
- return errors.map((e) => `${dataVar}${e.instancePath} ${e.message}`).reduce((text2, msg) => text2 + separator + msg);
98591
+ return errors.map((e) => `${dataVar}${e.instancePath} ${e.message}`).reduce((text3, msg) => text3 + separator + msg);
98545
98592
  }
98546
98593
  $dataMetaSchema(metaSchema, keywordsJsonPointers) {
98547
98594
  const rules = this.RULES.all;
@@ -100436,8 +100483,8 @@ var require_format3 = __commonJS({
100436
100483
  }
100437
100484
  __name(unknownFormat, "unknownFormat");
100438
100485
  function getFormat(fmtDef) {
100439
- const code = fmtDef instanceof RegExp ? (0, codegen_1.regexpCode)(fmtDef) : opts.code.formats ? (0, codegen_1._)`${opts.code.formats}${(0, codegen_1.getProperty)(schema)}` : void 0;
100440
- const fmt = gen.scopeValue("formats", { key: schema, ref: fmtDef, code });
100486
+ const code2 = fmtDef instanceof RegExp ? (0, codegen_1.regexpCode)(fmtDef) : opts.code.formats ? (0, codegen_1._)`${opts.code.formats}${(0, codegen_1.getProperty)(schema)}` : void 0;
100487
+ const fmt = gen.scopeValue("formats", { key: schema, ref: fmtDef, code: code2 });
100441
100488
  if (typeof fmtDef == "object" && !(fmtDef instanceof RegExp)) {
100442
100489
  return [fmtDef.type || "string", fmtDef.validate, (0, codegen_1._)`${fmt}.validate`];
100443
100490
  }
@@ -103561,9 +103608,9 @@ var init_streamableHttp = __esm({
103561
103608
  static {
103562
103609
  __name(this, "StreamableHTTPError");
103563
103610
  }
103564
- constructor(code, message) {
103611
+ constructor(code2, message) {
103565
103612
  super(`Streamable HTTP error: ${message}`);
103566
- this.code = code;
103613
+ this.code = code2;
103567
103614
  }
103568
103615
  };
103569
103616
  StreamableHTTPClientTransport = class {
@@ -103813,7 +103860,7 @@ var init_streamableHttp = __esm({
103813
103860
  this._sessionId = sessionId;
103814
103861
  }
103815
103862
  if (!response.ok) {
103816
- const text2 = await response.text().catch(() => null);
103863
+ const text3 = await response.text().catch(() => null);
103817
103864
  if (response.status === 401 && this._authProvider) {
103818
103865
  if (this._hasCompletedAuthFlow) {
103819
103866
  throw new StreamableHTTPError(401, "Server returned 401 after successful authentication");
@@ -103859,7 +103906,7 @@ var init_streamableHttp = __esm({
103859
103906
  return this.send(message);
103860
103907
  }
103861
103908
  }
103862
- throw new StreamableHTTPError(response.status, `Error POSTing to endpoint: ${text2}`);
103909
+ throw new StreamableHTTPError(response.status, `Error POSTing to endpoint: ${text3}`);
103863
103910
  }
103864
103911
  this._hasCompletedAuthFlow = false;
103865
103912
  this._lastUpscopingHeader = void 0;
@@ -105408,10 +105455,10 @@ function stateDiagram(sm) {
105408
105455
  function flowDiagram(actions, events, actionNameByUuid) {
105409
105456
  const lines = ["flowchart LR"];
105410
105457
  const declared = /* @__PURE__ */ new Set();
105411
- const declare = /* @__PURE__ */ __name((id, text2, kind) => {
105458
+ const declare = /* @__PURE__ */ __name((id, text3, kind) => {
105412
105459
  if (declared.has(id)) return;
105413
105460
  declared.add(id);
105414
- lines.push(kind === "action" ? ` ${id}["${text2}"]` : ` ${id}(["${text2}"])`);
105461
+ lines.push(kind === "action" ? ` ${id}["${text3}"]` : ` ${id}(["${text3}"])`);
105415
105462
  }, "declare");
105416
105463
  for (const a of actions) {
105417
105464
  const aid = "A_" + sid(a.name);
@@ -105517,6 +105564,102 @@ var init_aiMermaid = __esm({
105517
105564
  }
105518
105565
  });
105519
105566
 
105567
+ // backend/src/services/ai/compactMarkdown.ts
105568
+ function entityDetailsToMarkdown(details) {
105569
+ if (details.error) return `> Error: ${text2(details.error)}`;
105570
+ if (details.ambiguous) {
105571
+ const rows = (details.candidates ?? []).map((candidate) => `| ${code(candidate.entityName)} | ${code(candidate.packageName)} | ${text2(candidate.description) || "\u2014"} |`);
105572
+ return [
105573
+ `# Ambiguous entity: ${code(details.candidates?.[0]?.entityName ?? "unknown")}`,
105574
+ "",
105575
+ "| Entity | Package | Description |",
105576
+ "|---|---|---|",
105577
+ ...rows,
105578
+ "",
105579
+ `> ${text2(details.note)}`
105580
+ ].join("\n");
105581
+ }
105582
+ const physical = details.physical;
105583
+ const attrs = (details.attributes ?? []).map((attribute) => {
105584
+ const flags = [attribute.primaryKey ? "PK" : "", attribute.required ? "required" : "optional"].filter(Boolean).join(", ");
105585
+ const mapping = attribute.physical ? [attribute.physical.columnName, attribute.physical.dbType].filter(Boolean).join(" : ") : "\u2014";
105586
+ return `| ${code(attribute.name)} | ${code(attribute.type)} | ${flags} | ${text2(mapping)} | ${compactJson(attribute.validation)} | ${text2(attribute.description) || "\u2014"} |`;
105587
+ });
105588
+ const lines = [
105589
+ `# ${text2(details.name)}${details.packageName ? ` \u2014 ${code(details.packageName)}` : ""}`,
105590
+ "",
105591
+ text2(details.description) || "_No description._"
105592
+ ];
105593
+ if (details.stereotype) lines.push("", `Stereotype: ${code(details.stereotype)}`);
105594
+ if (physical) {
105595
+ const qualified = [physical.schema, physical.tableName].filter(Boolean).join(".");
105596
+ lines.push("", `Physical table: ${code(qualified)}`);
105597
+ }
105598
+ lines.push(
105599
+ "",
105600
+ `## Attributes (${attrs.length})`,
105601
+ "",
105602
+ "| Attribute | Type | Flags | Physical column/type | Validation | Description |",
105603
+ "|---|---|---|---|---|---|",
105604
+ ...attrs.length ? attrs : ["| \u2014 | \u2014 | \u2014 | \u2014 | \u2014 | \u2014 |"]
105605
+ );
105606
+ if (details.constraints?.length) {
105607
+ lines.push("", "## Constraints", "", ...details.constraints.map((constraint) => `- ${compactJson(constraint)}`));
105608
+ }
105609
+ if (details.rules?.length) {
105610
+ lines.push("", "## Rules", "", ...details.rules.map((rule) => `- **${text2(rule.name)}**${rule.severity ? ` [${text2(rule.severity)}]` : ""}${rule.description ? `: ${text2(rule.description)}` : ""}`));
105611
+ }
105612
+ return lines.join("\n");
105613
+ }
105614
+ function sqlSchemaToMarkdown(schema) {
105615
+ if (schema.error) return `> Error: ${text2(schema.error)}`;
105616
+ const lines = [
105617
+ "# Physical SQL schema",
105618
+ "",
105619
+ `Dialect: ${code(schema.dialect)} `,
105620
+ `Scope: ${text2(schema.scope)}`
105621
+ ];
105622
+ for (const table of schema.tables ?? []) {
105623
+ lines.push(
105624
+ "",
105625
+ `## ${text2(table.entity)} \u2014 ${code(table.qualifiedName ?? table.table)}`,
105626
+ "",
105627
+ `Package: ${code(table.package)}`,
105628
+ "",
105629
+ "| Attribute | Column | DB type | Flags |",
105630
+ "|---|---|---|---|",
105631
+ ...table.columns?.length ? table.columns.map((column) => {
105632
+ const flags = [column.primaryKey ? "PK" : "", column.nullable ? "nullable" : "required", column.physicalMappingMissing ? "derived mapping" : ""].filter(Boolean).join(", ");
105633
+ return `| ${code(column.attribute)} | ${code(column.column)} | ${code(column.dbType)} | ${flags} |`;
105634
+ }) : ["| \u2014 | \u2014 | \u2014 | \u2014 |"]
105635
+ );
105636
+ }
105637
+ if (schema.relationships?.length) {
105638
+ lines.push("", "## Relationships", "", "| From | Cardinality | To | Cardinality | Description |", "|---|---|---|---|---|");
105639
+ lines.push(...schema.relationships.map((relationship) => `| ${code(relationship.from)} | ${text2(relationship.fromCardinality)} | ${code(relationship.to)} | ${text2(relationship.toCardinality)} | ${text2(relationship.description) || "\u2014"} |`));
105640
+ }
105641
+ if (schema.unresolvedEntityNames?.length) {
105642
+ lines.push("", `> Unresolved entities: ${schema.unresolvedEntityNames.map(code).join(", ")}`);
105643
+ }
105644
+ if (schema.note) lines.push("", `> ${text2(schema.note)}`);
105645
+ return lines.join("\n");
105646
+ }
105647
+ var text2, code, compactJson;
105648
+ var init_compactMarkdown = __esm({
105649
+ "backend/src/services/ai/compactMarkdown.ts"() {
105650
+ "use strict";
105651
+ text2 = /* @__PURE__ */ __name((value) => String(value ?? "").replace(/\r?\n/g, "<br>").replace(/\|/g, "\\|"), "text");
105652
+ code = /* @__PURE__ */ __name((value) => value == null || value === "" ? "\u2014" : `\`${String(value).replace(/\r?\n/g, "<br>").replace(/\|/g, "\\|").replace(/`/g, "\\`")}\``, "code");
105653
+ compactJson = /* @__PURE__ */ __name((value) => {
105654
+ if (value == null) return "\u2014";
105655
+ const serialized = JSON.stringify(value);
105656
+ return serialized === "{}" || serialized === "[]" ? "\u2014" : code(serialized);
105657
+ }, "compactJson");
105658
+ __name(entityDetailsToMarkdown, "entityDetailsToMarkdown");
105659
+ __name(sqlSchemaToMarkdown, "sqlSchemaToMarkdown");
105660
+ }
105661
+ });
105662
+
105520
105663
  // backend/src/controllers/aiSql.ts
105521
105664
  function nameList(names, max = 8) {
105522
105665
  if (!names.length) return "";
@@ -105600,6 +105743,18 @@ async function buildSqlSchema(input, services, opts) {
105600
105743
  if (!relsByPkg.has(p)) relsByPkg.set(p, await services.serviceService.getPackageRelationships(p).catch(() => []));
105601
105744
  return relsByPkg.get(p);
105602
105745
  }, "relsFor");
105746
+ if (!requestedNames?.length) {
105747
+ const scopePackages = input.packageName ? [input.packageName] : allPkgs;
105748
+ const entityCount = scopePackages.reduce((sum, pkg) => sum + (entitiesByPkg.get(pkg)?.length ?? 0), 0);
105749
+ if (entityCount > MAX_UNSCOPED_SQL_SCHEMA_ENTITIES) {
105750
+ return {
105751
+ error: `Refusing an unscoped SQL schema dump of ${entityCount} entities; the safe limit is ${MAX_UNSCOPED_SQL_SCHEMA_ENTITIES}. Call searchModel({ query: '<entity or business term>' }) to locate targets, then retry with entityNames: ['<EntityName>'].`,
105752
+ entityCount,
105753
+ limit: MAX_UNSCOPED_SQL_SCHEMA_ENTITIES,
105754
+ scope: input.packageName ?? "all packages"
105755
+ };
105756
+ }
105757
+ }
105603
105758
  let pkgs;
105604
105759
  let include = null;
105605
105760
  let scope;
@@ -105695,30 +105850,39 @@ async function buildSqlSchema(input, services, opts) {
105695
105850
  note: "Use these PHYSICAL table/column names and dbTypes when writing SQL. " + (opts?.schemaQualifyTables ? "Schema-qualify every table (use each table's qualifiedName). " : "") + (missing > 0 ? `${missing} column(s) in table(s) ${nameList(fallbackTables, 6)} have no explicit physical mapping \u2014 their column names/dbTypes are derived from the logical model; WARN the user before relying on them.` : "All columns have an explicit physical mapping.") + (unresolved.length ? ` Requested entities not found: ${unresolved.join(", ")} \u2014 call searchModel({ query: '<name>' }) to locate them.` : "")
105696
105851
  };
105697
105852
  }
105698
- var getSqlSchemaInputSchema, getSqlSchemaParameters;
105853
+ async function executeGetSqlSchema(input, services, opts) {
105854
+ const schema = await buildSqlSchema(input, services, opts);
105855
+ return input.format === "json" ? schema : sqlSchemaToMarkdown(schema);
105856
+ }
105857
+ var getSqlSchemaInputSchema, getSqlSchemaParameters, MAX_UNSCOPED_SQL_SCHEMA_ENTITIES;
105699
105858
  var init_aiSql = __esm({
105700
105859
  "backend/src/controllers/aiSql.ts"() {
105701
105860
  "use strict";
105702
105861
  init_zod();
105703
105862
  init_physicalMapping();
105863
+ init_compactMarkdown();
105704
105864
  getSqlSchemaInputSchema = external_exports.object({
105705
105865
  packageName: external_exports.string().optional().describe("Scope to one package (omit for the whole model)"),
105706
105866
  entityNames: external_exports.array(external_exports.string()).optional().describe("PREFERRED scope on large models: the target entity names (resolved across all packages). Their directly-related entities are included automatically so JOINs can be derived."),
105707
- dialect: external_exports.enum(["generic", "postgres", "mysql", "mssql", "oracle", "sqlite"]).optional().describe("Target SQL dialect \u2014 tunes fallback column types (default generic)")
105867
+ dialect: external_exports.enum(["generic", "postgres", "mysql", "mssql", "oracle", "sqlite"]).optional().describe("Target SQL dialect \u2014 tunes fallback column types (default generic)"),
105868
+ format: external_exports.enum(["markdown", "json"]).optional().describe("Result format (default markdown; use json for structured compatibility)")
105708
105869
  });
105709
105870
  getSqlSchemaParameters = {
105710
105871
  type: "object",
105711
105872
  properties: {
105712
105873
  packageName: { type: "string", description: "Scope to one package (omit for the whole model)" },
105713
105874
  entityNames: { type: "array", items: { type: "string" }, description: "PREFERRED scope on large models: target entity names, resolved across all packages; directly-related entities are included automatically for JOINs" },
105714
- dialect: { type: "string", enum: ["generic", "postgres", "mysql", "mssql", "oracle", "sqlite"], description: "Target SQL dialect (default generic)" }
105875
+ dialect: { type: "string", enum: ["generic", "postgres", "mysql", "mssql", "oracle", "sqlite"], description: "Target SQL dialect (default generic)" },
105876
+ format: { type: "string", enum: ["markdown", "json"], description: "Result format (default markdown)" }
105715
105877
  }
105716
105878
  };
105717
105879
  __name(nameList, "nameList");
105718
105880
  __name(resolveBase, "resolveBase");
105719
105881
  __name(sqlType, "sqlType");
105720
105882
  __name(columnFor, "columnFor");
105883
+ MAX_UNSCOPED_SQL_SCHEMA_ENTITIES = 250;
105721
105884
  __name(buildSqlSchema, "buildSqlSchema");
105885
+ __name(executeGetSqlSchema, "executeGetSqlSchema");
105722
105886
  }
105723
105887
  });
105724
105888
 
@@ -111009,12 +111173,12 @@ function convertToOpenAIChatMessages({
111009
111173
  break;
111010
111174
  }
111011
111175
  case "assistant": {
111012
- let text2 = "";
111176
+ let text3 = "";
111013
111177
  const toolCalls = [];
111014
111178
  for (const part of content) {
111015
111179
  switch (part.type) {
111016
111180
  case "text": {
111017
- text2 += part.text;
111181
+ text3 += part.text;
111018
111182
  break;
111019
111183
  }
111020
111184
  case "tool-call": {
@@ -111032,7 +111196,7 @@ function convertToOpenAIChatMessages({
111032
111196
  }
111033
111197
  messages.push({
111034
111198
  role: "assistant",
111035
- content: text2,
111199
+ content: text3,
111036
111200
  tool_calls: toolCalls.length > 0 ? toolCalls : void 0
111037
111201
  });
111038
111202
  break;
@@ -111199,9 +111363,9 @@ function convertToOpenAICompletionPrompt({
111199
111363
  user = "user",
111200
111364
  assistant = "assistant"
111201
111365
  }) {
111202
- let text2 = "";
111366
+ let text3 = "";
111203
111367
  if (prompt[0].role === "system") {
111204
- text2 += `${prompt[0].content}
111368
+ text3 += `${prompt[0].content}
111205
111369
 
111206
111370
  `;
111207
111371
  prompt = prompt.slice(1);
@@ -111222,7 +111386,7 @@ function convertToOpenAICompletionPrompt({
111222
111386
  }
111223
111387
  }
111224
111388
  }).filter(Boolean).join("");
111225
- text2 += `${user}:
111389
+ text3 += `${user}:
111226
111390
  ${userMessage}
111227
111391
 
111228
111392
  `;
@@ -111241,7 +111405,7 @@ ${userMessage}
111241
111405
  }
111242
111406
  }
111243
111407
  }).join("");
111244
- text2 += `${assistant}:
111408
+ text3 += `${assistant}:
111245
111409
  ${assistantMessage}
111246
111410
 
111247
111411
  `;
@@ -111258,10 +111422,10 @@ ${assistantMessage}
111258
111422
  }
111259
111423
  }
111260
111424
  }
111261
- text2 += `${assistant}:
111425
+ text3 += `${assistant}:
111262
111426
  `;
111263
111427
  return {
111264
- prompt: text2,
111428
+ prompt: text3,
111265
111429
  stopSequences: [`
111266
111430
  ${user}:`]
111267
111431
  };
@@ -112990,9 +113154,9 @@ var init_dist8 = __esm({
112990
113154
  });
112991
113155
  const choice2 = response.choices[0];
112992
113156
  const content = [];
112993
- const text2 = choice2.message.content;
112994
- if (text2 != null && text2.length > 0) {
112995
- content.push({ type: "text", text: text2 });
113157
+ const text3 = choice2.message.content;
113158
+ if (text3 != null && text3.length > 0) {
113159
+ content.push({ type: "text", text: text3 });
112996
113160
  }
112997
113161
  for (const toolCall of (_a21 = choice2.message.tool_calls) != null ? _a21 : []) {
112998
113162
  content.push({
@@ -117197,7 +117361,7 @@ var init_dist8 = __esm({
117197
117361
  return this.config.provider;
117198
117362
  }
117199
117363
  async getArgs({
117200
- text: text2,
117364
+ text: text3,
117201
117365
  voice = "alloy",
117202
117366
  outputFormat = "mp3",
117203
117367
  speed,
@@ -117213,7 +117377,7 @@ var init_dist8 = __esm({
117213
117377
  });
117214
117378
  const requestBody = {
117215
117379
  model: this.modelId,
117216
- input: text2,
117380
+ input: text3,
117217
117381
  voice,
117218
117382
  response_format: "mp3",
117219
117383
  speed,
@@ -117522,8 +117686,21 @@ var init_dist8 = __esm({
117522
117686
  var aiDirectClient_exports = {};
117523
117687
  __export(aiDirectClient_exports, {
117524
117688
  AbortError: () => AbortError,
117689
+ LIVE_TOOL_RESULT_MAX_CHARS: () => LIVE_TOOL_RESULT_MAX_CHARS,
117690
+ boundLiveToolResult: () => boundLiveToolResult,
117525
117691
  callWithTools: () => callWithTools
117526
117692
  });
117693
+ function boundLiveToolResult(result, maxChars = LIVE_TOOL_RESULT_MAX_CHARS) {
117694
+ const serialized = JSON.stringify(result ?? {});
117695
+ if (serialized.length <= maxChars) return result;
117696
+ const previewBudget = Math.max(maxChars - 500, 0);
117697
+ return {
117698
+ truncated: true,
117699
+ originalChars: serialized.length,
117700
+ preview: serialized.slice(0, previewBudget),
117701
+ note: "Tool result exceeded the live AI context budget. Retry with a narrower query, packageName, or entityNames scope."
117702
+ };
117703
+ }
117527
117704
  async function callWithTools(config3, messages, tools, executeToolFn, maxSteps = 10, onEvent, signal) {
117528
117705
  const currentMessages = [...messages];
117529
117706
  const allToolCalls = [];
@@ -117633,14 +117810,15 @@ async function callWithTools(config3, messages, tools, executeToolFn, maxSteps =
117633
117810
  onEvent({ type: "tool-start", name: toolName, toolCallId, input: toolArgs });
117634
117811
  }
117635
117812
  const result = await executeToolFn(toolName, toolArgs, toolCallId);
117636
- allToolCalls.push({ name: toolName, input: toolArgs, output: result });
117813
+ const boundedResult = boundLiveToolResult(result);
117814
+ allToolCalls.push({ name: toolName, input: toolArgs, output: boundedResult });
117637
117815
  if (onEvent) {
117638
- onEvent({ type: "tool-end", name: toolName, toolCallId, input: toolArgs, output: result });
117816
+ onEvent({ type: "tool-end", name: toolName, toolCallId, input: toolArgs, output: boundedResult });
117639
117817
  }
117640
117818
  currentMessages.push({
117641
117819
  role: "tool",
117642
117820
  tool_call_id: tc.id,
117643
- content: JSON.stringify(result)
117821
+ content: JSON.stringify(boundedResult)
117644
117822
  });
117645
117823
  }
117646
117824
  continue;
@@ -117706,7 +117884,7 @@ async function callWithTools(config3, messages, tools, executeToolFn, maxSteps =
117706
117884
  }
117707
117885
  return { text: finalText, toolCalls: allToolCalls, usage, stoppedAtStepLimit };
117708
117886
  }
117709
- var AbortError;
117887
+ var AbortError, LIVE_TOOL_RESULT_MAX_CHARS;
117710
117888
  var init_aiDirectClient = __esm({
117711
117889
  "backend/src/utils/aiDirectClient.ts"() {
117712
117890
  "use strict";
@@ -117721,6 +117899,8 @@ var init_aiDirectClient = __esm({
117721
117899
  this.name = "AbortError";
117722
117900
  }
117723
117901
  };
117902
+ LIVE_TOOL_RESULT_MAX_CHARS = 5e4;
117903
+ __name(boundLiveToolResult, "boundLiveToolResult");
117724
117904
  __name(callWithTools, "callWithTools");
117725
117905
  }
117726
117906
  });
@@ -117784,9 +117964,9 @@ __export(contextCondensing_exports, {
117784
117964
  estimateTokens: () => estimateTokens,
117785
117965
  maybeCondense: () => maybeCondense
117786
117966
  });
117787
- function estimateTokens(text2) {
117788
- if (!text2) return 0;
117789
- return Math.ceil(text2.length / 4);
117967
+ function estimateTokens(text3) {
117968
+ if (!text3) return 0;
117969
+ return Math.ceil(text3.length / 4);
117790
117970
  }
117791
117971
  function estimateMessageTokens(messages) {
117792
117972
  let total = 0;
@@ -117934,10 +118114,24 @@ function buildAiErrorDiagnostics(req, cfg, diagnosticId, rawMessages, pageContex
117934
118114
  providerRequest: getProviderRequestMeasurement(diagnosticId) ?? null
117935
118115
  };
117936
118116
  }
117937
- function claimsMutation(text2) {
117938
- if (!text2) return false;
117939
- if (/✅|☑|\bdone!/i.test(text2)) return true;
117940
- const prose = text2.replace(/```[\s\S]*?```/g, " ").replace(/`[^`]*`/g, " ");
118117
+ function providerRequestTelemetry(diagnosticId) {
118118
+ if (!diagnosticId) return null;
118119
+ const measurement = getProviderRequestMeasurement(diagnosticId);
118120
+ if (!measurement) return null;
118121
+ return {
118122
+ requestBodyBytes: measurement.requestBodyBytes,
118123
+ messagesBytes: measurement.messagesBytes,
118124
+ toolsBytes: measurement.toolsBytes,
118125
+ messageCount: measurement.messageCount,
118126
+ toolCount: measurement.toolCount,
118127
+ step: measurement.step,
118128
+ phase: measurement.phase
118129
+ };
118130
+ }
118131
+ function claimsMutation(text3) {
118132
+ if (!text3) return false;
118133
+ if (/✅|☑|\bdone!/i.test(text3)) return true;
118134
+ const prose = text3.replace(/```[\s\S]*?```/g, " ").replace(/`[^`]*`/g, " ");
117941
118135
  const VERB = "(created|added|inserted|updated|modified|deleted|removed|renamed|saved|persisted|applied|wired up)";
117942
118136
  const agentive = new RegExp(`\\b(i|i've|i have|we|we've|successfully|now)\\b[^.\\n]{0,40}\\b${VERB}\\b`, "i");
117943
118137
  const successCue = new RegExp(`\\b${VERB}\\b[^.\\n]{0,30}\\b(successfully|now)\\b`, "i");
@@ -117991,13 +118185,14 @@ function buildEntityDetails(entity, packageName) {
117991
118185
  };
117992
118186
  }
117993
118187
  async function executeGetEntityDetails(args, services) {
117994
- if (!args?.entityName) return { error: "entityName is required." };
118188
+ const render = /* @__PURE__ */ __name((result) => args?.format === "json" ? result : entityDetailsToMarkdown(result), "render");
118189
+ if (!args?.entityName) return render({ error: "entityName is required." });
117995
118190
  const matches = await services.serviceService.findEntityMatches(args.entityName, args.packageName || void 0);
117996
118191
  if (matches.length === 1) {
117997
- return buildEntityDetails(matches[0].entity, matches[0].packageName);
118192
+ return render(buildEntityDetails(matches[0].entity, matches[0].packageName));
117998
118193
  }
117999
118194
  if (matches.length > 1) {
118000
- return {
118195
+ return render({
118001
118196
  summary: `'${args.entityName}' matches ${matches.length} entities \u2014 specify packageName`,
118002
118197
  ambiguous: true,
118003
118198
  candidates: matches.map((m) => ({
@@ -118006,11 +118201,11 @@ async function executeGetEntityDetails(args, services) {
118006
118201
  ...m.entity.description ? { description: m.entity.description } : {}
118007
118202
  })),
118008
118203
  note: "Several packages define an entity with this name. Call getEntityDetails again with the intended packageName."
118009
- };
118204
+ });
118010
118205
  }
118011
- return {
118206
+ return render({
118012
118207
  error: `Entity '${args.entityName}' not found in ${args.packageName ? `package '${args.packageName}' or ` : ""}any package. Call searchModel({ query: '${args.entityName}' }) to locate it by full-text search \u2014 the model may use a different name.`
118013
- };
118208
+ });
118014
118209
  }
118015
118210
  async function executeListEntities(args, services) {
118016
118211
  const { listMicroservices: listMicroservices2 } = await Promise.resolve().then(() => (init_fileOperations(), fileOperations_exports));
@@ -118022,9 +118217,20 @@ async function executeListEntities(args, services) {
118022
118217
  };
118023
118218
  }
118024
118219
  const entities = await services.serviceService.getServiceEntities(args.packageName);
118220
+ const query = String(args.query ?? "").trim().toLowerCase();
118221
+ const filtered = query ? entities.filter((entity) => `${entity.name ?? ""} ${entity.description ?? ""}`.toLowerCase().includes(query)) : entities;
118222
+ const limit = Math.min(Math.max(Number(args.limit) || 50, 1), 100);
118223
+ const selected2 = filtered.slice(0, limit);
118224
+ const truncated = selected2.length < filtered.length;
118025
118225
  return {
118026
- summary: `${args.packageName}: ${nameList2(entities.map((e) => e.name)) || "no entities"}`,
118027
- entities: entities.map((e) => ({ name: e.name, description: e.description, attrCount: e.attributes?.length || 0 }))
118226
+ summary: `${args.packageName}: ${filtered.length} matching entit${filtered.length === 1 ? "y" : "ies"}${truncated ? ` (showing ${selected2.length})` : ""}`,
118227
+ total: filtered.length,
118228
+ count: selected2.length,
118229
+ truncated,
118230
+ entities: selected2.map((e) => ({ name: e.name, description: e.description, attrCount: e.attributes?.length || 0 })),
118231
+ ...truncated ? {
118232
+ note: "Result bounded for a large package. Use searchModel with a business term, or retry listEntities with query and limit."
118233
+ } : {}
118028
118234
  };
118029
118235
  }
118030
118236
  const packages = await listMicroservices2();
@@ -118112,6 +118318,23 @@ ${banner}
118112
118318
  Packages:
118113
118319
  ${lines.join("\n")}`;
118114
118320
  }
118321
+ function modelOverviewForAgent(overview) {
118322
+ if (overview.totals.entities <= MODEL_OVERVIEW_TOOL_MAX_ENTITIES) return overview;
118323
+ return {
118324
+ summary: overview.summary,
118325
+ totals: overview.totals,
118326
+ packages: overview.packages.map((pkg) => ({
118327
+ name: pkg.name,
118328
+ entityCount: pkg.entities.length,
118329
+ relationships: pkg.relationships
118330
+ })),
118331
+ stereotypes: overview.stereotypes,
118332
+ derivedTypes: overview.derivedTypes,
118333
+ caseCount: overview.cases.length,
118334
+ omittedEntityLists: true,
118335
+ note: `Entity names omitted because the model has ${overview.totals.entities} entities. Use searchModel to locate candidates, then getEntityDetails for exact definitions.`
118336
+ };
118337
+ }
118115
118338
  async function safeModelOutline(services) {
118116
118339
  try {
118117
118340
  return formatModelOutlineWithinBudget(
@@ -118298,15 +118521,26 @@ Page context: ${trimmed2.slice(0, 500)}`;
118298
118521
  }
118299
118522
  return out;
118300
118523
  }
118524
+ function boundedToolResult(output, maxChars = DIRECT_TOOL_RESULT_MAX_CHARS) {
118525
+ const serialized = JSON.stringify(output ?? {});
118526
+ if (serialized.length <= maxChars) return output;
118527
+ const previewBudget = Math.max(maxChars - 500, 0);
118528
+ return {
118529
+ truncated: true,
118530
+ originalChars: serialized.length,
118531
+ preview: serialized.slice(0, previewBudget),
118532
+ note: "Tool result exceeded the AI context budget. Retry with a narrower scope such as query, packageName, or entityNames."
118533
+ };
118534
+ }
118301
118535
  function buildDirectChatMessages(rawMessages, maxToolResultChars = DIRECT_TOOL_RESULT_MAX_CHARS) {
118302
118536
  const out = [];
118303
118537
  for (const msg of rawMessages) {
118304
- const text2 = msg.parts?.find((p) => p.type === "text")?.text || msg.content || "";
118538
+ const text3 = msg.parts?.find((p) => p.type === "text")?.text || msg.content || "";
118305
118539
  const toolCalls = msg.role === "assistant" && Array.isArray(msg.toolCalls) ? msg.toolCalls.filter((tc) => tc && tc.id && tc.name && tc.output !== void 0) : [];
118306
118540
  if (toolCalls.length) {
118307
118541
  out.push({
118308
118542
  role: "assistant",
118309
- content: text2 || "",
118543
+ content: text3 || "",
118310
118544
  tool_calls: toolCalls.map((tc) => ({
118311
118545
  id: String(tc.id),
118312
118546
  type: "function",
@@ -118323,8 +118557,8 @@ function buildDirectChatMessages(rawMessages, maxToolResultChars = DIRECT_TOOL_R
118323
118557
  content: serialized.length > maxToolResultChars ? serialized.slice(0, maxToolResultChars) + TOOL_RESULT_TRUNCATION_MARKER : serialized
118324
118558
  });
118325
118559
  }
118326
- } else if (text2) {
118327
- out.push({ role: msg.role, content: text2 });
118560
+ } else if (text3) {
118561
+ out.push({ role: msg.role, content: text3 });
118328
118562
  }
118329
118563
  }
118330
118564
  return out;
@@ -118340,7 +118574,7 @@ function buildUiMessagesWithToolParts(rawMessages) {
118340
118574
  toolCallId: String(tc.id),
118341
118575
  state: "output-available",
118342
118576
  input: tc.input ?? {},
118343
- output: tc.output
118577
+ output: boundedToolResult(tc.output)
118344
118578
  }));
118345
118579
  return { ...rest, parts: [...baseParts, ...toolParts] };
118346
118580
  });
@@ -118374,11 +118608,11 @@ async function handleDirectChat(req, res, cfg, rawMessages, services, pageContex
118374
118608
  { type: "function", function: { name: "createEvent", description: "Create a domain Event (PascalCase, past tense, e.g. OrderPlaced) emitted by an aggregate entity (ownerEntityName). Optional payload fields.", parameters: createEventParameters } },
118375
118609
  { type: "function", function: { name: "createAction", description: "Create an Action/command (e.g. PlaceOrder) on an aggregate entity (ownerEntityName), optionally CQRS-classified, with an optional flow of steps. Use flow steps emitEvent {name} and wait {for} to wire a saga/process across actions+events.", parameters: createActionParameters } },
118376
118610
  { type: "function", function: { name: "createStateMachine", description: "Create a state machine on an entity (ownerEntityName) \u2014 its states, initialState, and transitions (from/to/on). Model an entity lifecycle, e.g. Order PENDING\u2192PAID\u2192SHIPPED.", parameters: createStateMachineParameters } },
118377
- { type: "function", function: { name: "listEntities", description: "List packages or entities in a package", parameters: { type: "object", properties: { packageName: { type: "string", description: "Package name (omit to list all)" } } } } },
118378
- { type: "function", function: { name: "getEntityDetails", description: "Get full detail for one entity: attributes with type/required/primaryKey AND field validation, the PHYSICAL mapping (entity table name + schema, each attribute physical column name + DB type), physical constraints, and inline business rules. packageName is OPTIONAL \u2014 omit it and the entity name is resolved across every package (ambiguous names return a candidate list). Call this before writing SQL/DDL so you use the real physical names and types.", parameters: { type: "object", required: ["entityName"], properties: { packageName: { type: "string", description: "Owning package if known (optional \u2014 resolved across packages when omitted)" }, entityName: { type: "string" } } } } },
118379
- { type: "function", function: { name: "getModelOverview", description: "Get a whole-model outline: every package with its entity names, and a count of each concept (entities, relationships, cases, rules, events, actions, state machines, derived types, stereotypes). A snapshot is already in your context; call this to refresh after changes.", parameters: { type: "object", properties: {} } } },
118611
+ { type: "function", function: { name: "listEntities", description: "List packages, or a bounded entity page within one package. Prefer searchModel for discovery in large projects.", parameters: { type: "object", properties: { packageName: { type: "string", description: "Package name (omit to list packages)" }, query: { type: "string", description: "Optional name/description filter" }, limit: { type: "number", description: "Maximum entities returned (default 50, max 100)" } } } } },
118612
+ { type: "function", function: { name: "getEntityDetails", description: "Get full detail for one entity as compact Markdown by default: attributes, validation, physical mapping, constraints, and rules. Set format=json only when structured data is required. packageName is optional and resolves across packages when omitted.", parameters: { type: "object", required: ["entityName"], properties: { packageName: { type: "string", description: "Owning package if known (optional \u2014 resolved across packages when omitted)" }, entityName: { type: "string" }, format: { type: "string", enum: ["markdown", "json"], description: "Result format (default markdown)" } } } } },
118613
+ { type: "function", function: { name: "getModelOverview", description: "Get whole-model counts and package summaries. Large projects omit entity names by design; use searchModel to locate candidates. A snapshot is already in your context, so call this only to refresh after changes.", parameters: { type: "object", properties: {} } } },
118380
118614
  { type: "function", function: { name: "generateMermaid", description: 'Convert the model to Mermaid diagram source. diagram: "er" (entity-relationship of a package, or all), "class" (class diagram), "state" (a single entity state machine \u2014 pass entityName), "flow" (actions+events saga). Returns { mermaid }. Present it inside a ```mermaid code block.', parameters: generateMermaidParameters } },
118381
- { type: "function", function: { name: "getSqlSchema", description: "Get the PHYSICAL relational schema for writing SQL: per-entity table name + schema, each column (physical name, dbType, nullable, primaryKey), and relationships as join hints. PREFER scoping with entityNames (target entities, resolved across packages; directly-related entities are included automatically for JOINs) or packageName \u2014 an unscoped call on a large model returns a huge result that may be truncated. Optional dialect. Call this before writing any SQL query or DDL so you use real physical names/types, not the conceptual (logical) names.", parameters: getSqlSchemaParameters } },
118615
+ { type: "function", function: { name: "getSqlSchema", description: "Get the PHYSICAL relational schema as compact Markdown by default: table/schema, columns, types, flags, and relationship join hints. Set format=json only when structured data is required. Prefer entityNames or packageName scope; oversized unscoped requests are refused.", parameters: getSqlSchemaParameters } },
118382
118616
  { type: "function", function: { name: "listStereotypes", description: "List available stereotypes", parameters: { type: "object", properties: {} } } },
118383
118617
  { type: "function", function: { name: "navigateTo", description: 'Navigate user to a page. The path MUST be an absolute URL beginning with "/" that matches one of the patterns returned by listRoutes \u2014 call listRoutes first if you are unsure of the exact shape.', parameters: { type: "object", required: ["path", "reason"], properties: { path: { type: "string" }, reason: { type: "string" } } } } },
118384
118618
  { type: "function", function: { name: "listRoutes", description: "List every valid URL pattern in the app with a short description and (where useful) a concrete example. Call this BEFORE navigateTo if you are unsure of the exact path shape \u2014 e.g. plural vs singular, where attribute pages live, what the case route is.", parameters: { type: "object", properties: {} } } }
@@ -118446,13 +118680,13 @@ async function handleDirectChat(req, res, cfg, rawMessages, services, pageContex
118446
118680
  return await executeGetEntityDetails(args, services);
118447
118681
  }
118448
118682
  if (name21 === "getModelOverview") {
118449
- return await getModelOverviewCached(() => buildModelOverview(services));
118683
+ return modelOverviewForAgent(await getModelOverviewCached(() => buildModelOverview(services)));
118450
118684
  }
118451
118685
  if (name21 === "generateMermaid") {
118452
118686
  return await generateMermaidDiagram(args, services);
118453
118687
  }
118454
118688
  if (name21 === "getSqlSchema") {
118455
- return await buildSqlSchema(args, services, cfg.sql);
118689
+ return await executeGetSqlSchema(args, services, cfg.sql);
118456
118690
  }
118457
118691
  if (name21 === "listStereotypes") {
118458
118692
  const stereotypes = await services.stereotypeService.getAllStereotypes();
@@ -118556,6 +118790,15 @@ async function handleDirectChat(req, res, cfg, rawMessages, services, pageContex
118556
118790
  ...cost !== void 0 ? { cost } : {}
118557
118791
  });
118558
118792
  }
118793
+ const requestMetrics = providerRequestTelemetry(diagnosticId);
118794
+ if (requestMetrics) {
118795
+ sendEvent({
118796
+ type: "request-metrics",
118797
+ model: cfg.model,
118798
+ provider: cfg.provider,
118799
+ ...requestMetrics
118800
+ });
118801
+ }
118559
118802
  if (result.stoppedAtStepLimit) {
118560
118803
  sendEvent({ type: "step-limit-reached", limit: AI_MAX_STEPS });
118561
118804
  }
@@ -118596,8 +118839,8 @@ async function handleDirectChat(req, res, cfg, rawMessages, services, pageContex
118596
118839
  async function buildMentionsContext(rawMessages) {
118597
118840
  const lastUser = [...rawMessages].reverse().find((m) => m.role === "user");
118598
118841
  if (!lastUser) return "";
118599
- const text2 = lastUser.parts?.find((p) => p.type === "text")?.text || lastUser.content || "";
118600
- const tokens = Array.from(new Set((text2.match(/@[A-Za-z][\w-]*/g) || []).map((t) => t.slice(1)))).slice(0, 6);
118842
+ const text3 = lastUser.parts?.find((p) => p.type === "text")?.text || lastUser.content || "";
118843
+ const tokens = Array.from(new Set((text3.match(/@[A-Za-z][\w-]*/g) || []).map((t) => t.slice(1)))).slice(0, 6);
118601
118844
  if (tokens.length === 0) return "";
118602
118845
  try {
118603
118846
  const { listPackages: listPackages3, listAllEntities: listAllEntities2 } = await Promise.resolve().then(() => (init_fileOperations(), fileOperations_exports));
@@ -118624,7 +118867,7 @@ ${lines.join("\n")}` : "";
118624
118867
  return "";
118625
118868
  }
118626
118869
  }
118627
- var TOOL_CATEGORY_MAP, READ_ONLY_TOOLS, MODE_SYSTEM_SUFFIX, GATED_CATEGORIES, MODEL_OUTLINE_MAX_CHARS, DENIED_RESULT, SYSTEM_PROMPT, DIRECT_TOOL_RESULT_MAX_CHARS, TOOL_RESULT_TRUNCATION_MARKER, aiChat, aiChatApprove, aiStatus, aiGetConfig, aiSaveConfig, aiTestTools, aiTools, aiMentionsSearch, listConversations, getConversation, saveConversation, patchConversation, deleteConversation, getSystemPromptByDigest, listPrompts, getPrompt, createPrompt, updatePrompt, deletePrompt;
118870
+ var TOOL_CATEGORY_MAP, READ_ONLY_TOOLS, MODE_SYSTEM_SUFFIX, GATED_CATEGORIES, MODEL_OUTLINE_MAX_CHARS, MODEL_OVERVIEW_TOOL_MAX_ENTITIES, DENIED_RESULT, SYSTEM_PROMPT, DIRECT_TOOL_RESULT_MAX_CHARS, TOOL_RESULT_TRUNCATION_MARKER, aiChat, aiChatApprove, aiStatus, aiGetConfig, aiSaveConfig, aiTestTools, aiTools, aiMentionsSearch, listConversations, getConversation, saveConversation, patchConversation, deleteConversation, getSystemPromptByDigest, listPrompts, getPrompt, createPrompt, updatePrompt, deletePrompt;
118628
118871
  var init_aiController = __esm({
118629
118872
  "backend/src/controllers/aiController.ts"() {
118630
118873
  "use strict";
@@ -118647,6 +118890,7 @@ var init_aiController = __esm({
118647
118890
  init_aiConceptTools();
118648
118891
  init_aiMermaid();
118649
118892
  init_aiSql();
118893
+ init_compactMarkdown();
118650
118894
  TOOL_CATEGORY_MAP = {
118651
118895
  // read
118652
118896
  listEntities: "read",
@@ -118702,6 +118946,7 @@ For a complete documentation review, never load a large document body in one cal
118702
118946
  __name(filterToolsForMode, "filterToolsForMode");
118703
118947
  __name(enrichErrorEvent, "enrichErrorEvent");
118704
118948
  __name(buildAiErrorDiagnostics, "buildAiErrorDiagnostics");
118949
+ __name(providerRequestTelemetry, "providerRequestTelemetry");
118705
118950
  GATED_CATEGORIES = /* @__PURE__ */ new Set([
118706
118951
  "create",
118707
118952
  "modify",
@@ -118716,7 +118961,9 @@ For a complete documentation review, never load a large document body in one cal
118716
118961
  __name(buildModelOverview, "buildModelOverview");
118717
118962
  __name(formatModelOutline, "formatModelOutline");
118718
118963
  MODEL_OUTLINE_MAX_CHARS = 4e3;
118964
+ MODEL_OVERVIEW_TOOL_MAX_ENTITIES = 250;
118719
118965
  __name(formatModelOutlineWithinBudget, "formatModelOutlineWithinBudget");
118966
+ __name(modelOverviewForAgent, "modelOverviewForAgent");
118720
118967
  __name(safeModelOutline, "safeModelOutline");
118721
118968
  __name(isGatedCategory, "isGatedCategory");
118722
118969
  __name(resolveToolCategory, "resolveToolCategory");
@@ -118742,20 +118989,20 @@ This system models a RICH domain \u2014 not just entities. You can author all of
118742
118989
  - Events \u2014 domain events emitted by aggregates, e.g. OrderPlaced (createEvent)
118743
118990
  - Actions \u2014 commands/queries on aggregates with a flow; emitEvent/wait steps wire a saga/process (createAction)
118744
118991
  - State machines \u2014 entity lifecycles: states + transitions, e.g. Order PENDING\u2192PAID\u2192SHIPPED (createStateMachine)
118745
- - Read/inspect: searchModel (full-text search across the whole dictionary \u2014 use it to LOCATE an entity/attribute/rule when you don't know its exact name, then drill in), getModelOverview (whole-model outline \u2014 packages, entities, and concept counts; a current snapshot is already shown to you below), getEntityDetails (one entity in full incl. physical mapping; packageName optional \u2014 the name resolves across packages), listEntities, listStereotypes; navigate with navigateTo (call listRoutes first if unsure)
118992
+ - Read/inspect: searchModel (full-text search across the whole dictionary \u2014 ALWAYS use it to LOCATE an entity/attribute/rule when you don't know its exact name, then drill in), getSearchIndexStatus (verify index coverage when search results look incomplete), getModelOverview (counts and bounded package summaries; a current snapshot is already shown below), getEntityDetails (one entity in full incl. physical mapping; packageName optional \u2014 the name resolves across packages), listEntities (bounded), listStereotypes; navigate with navigateTo (call listRoutes first if unsure)
118746
118993
  - Diagram: generateMermaid converts the model to Mermaid source \u2014 diagram: "er" (entity-relationship of a package/all), "class" (class diagram), "state" (an entity's state machine, needs entityName), or "flow" (actions+events saga). Use it when the user asks for a diagram, ERD, or visualization, and present the result in a fenced mermaid code block.
118747
118994
 
118748
118995
  A "process" or "saga" is NOT a separate object \u2014 it is the graph that emerges from Actions (with emitEvent/wait flow steps) and Events. To model a process, create the Actions and Events; the saga view is derived automatically.
118749
118996
 
118750
118997
  CONCEPTUAL vs PHYSICAL model \u2014 keep these two layers distinct:
118751
118998
  - CONCEPTUAL / LOGICAL is the business model: entity names (PascalCase, e.g. Order), attribute names (camelCase, e.g. orderNumber), and logical or derived types (e.g. money, email, currency-code). This is what you author and what users discuss.
118752
- - PHYSICAL is how it is persisted in a database: a table name (physical.tableName) in a schema, per-column physical names (physical.columnName) and DB types (physical.dbType), plus constraints. The two layers can differ completely (logical Order.orderNumber \u2192 physical orders.order_no VARCHAR). getEntityDetails returns the physical mapping for one entity; getSqlSchema returns the physical relational schema (scope it with entityNames or packageName on anything but a small model).
118999
+ - PHYSICAL is how it is persisted in a database: a table name (physical.tableName) in a schema, per-column physical names (physical.columnName) and DB types (physical.dbType), plus constraints. The two layers can differ completely (logical Order.orderNumber \u2192 physical orders.order_no VARCHAR). getEntityDetails returns the physical mapping for one entity; getSqlSchema returns the physical relational schema (scope it with entityNames or packageName on anything but a small model). Both return compact Markdown by default; request format=json only when structured output is necessary.
118753
119000
  - A logical/derived type (money, email) is NOT a DB type \u2014 it maps to a physical dbType (money \u2192 DECIMAL(12,2), email \u2192 VARCHAR(254)).
118754
119001
  - NEVER write DDL or SQL using conceptual names. Always resolve to the physical table/column names and dbTypes first. If an element has no physical mapping yet, getSqlSchema returns a fallback dbType derived from the logical type and flags it \u2014 pass that flag on to the user.
118755
119002
 
118756
119003
  Generating database queries: when the user asks for a SQL query (SELECT / INSERT / UPDATE / DELETE), a report, or DDL \u2014
118757
119004
  1. LOCATE the entity first. Unless you already know its owning package (from the snapshot, page context, or an @mention), call searchModel with the entity name or business term to resolve entity \u2192 package. NEVER guess a package, entity, or table name \u2014 the snapshot above may not list every entity.
118758
- 2. Call getSqlSchema scoped NARROWLY: pass entityNames: [...] for the target entities (their directly-related entities are included automatically so you can derive JOINs), or a packageName; pass the target dialect. Do not call it unscoped on a large model \u2014 the result gets truncated and misleads you.
119005
+ 2. Call getSqlSchema scoped NARROWLY: pass entityNames: [...] for the target entities (their directly-related entities are included automatically so you can derive JOINs), or a packageName; pass the target dialect. Do not call it unscoped on a large model \u2014 the tool refuses oversized unscoped results.
118759
119006
  3. Write the query using ONLY the physical names returned by the tool; derive JOINs from the relationships (join the PK of the "one" side to the FK on the "many" side) and respect the requested dialect.
118760
119007
  4. If any column is flagged physicalMappingMissing, tell the user those column names/types are unverified fallbacks derived from the logical model \u2014 do not silently pass them off as real.
118761
119008
  5. Present the query in a fenced sql code block, and briefly note any assumption (an inferred join column, a missing physical mapping). You generate queries for the user to run \u2014 you do NOT execute them against a live database.
@@ -118792,6 +119039,7 @@ Be concise in your responses. Show a summary of what you created.`;
118792
119039
  __name(buildSystemPrompt, "buildSystemPrompt");
118793
119040
  DIRECT_TOOL_RESULT_MAX_CHARS = 2e4;
118794
119041
  TOOL_RESULT_TRUNCATION_MARKER = "\u2026[truncated \u2014 result too large; retry with a narrower scope, e.g. packageName or entityNames filter]";
119042
+ __name(boundedToolResult, "boundedToolResult");
118795
119043
  __name(buildDirectChatMessages, "buildDirectChatMessages");
118796
119044
  __name(buildUiMessagesWithToolParts, "buildUiMessagesWithToolParts");
118797
119045
  __name(handleDirectChat, "handleDirectChat");
@@ -119038,9 +119286,11 @@ Be concise in your responses. Show a summary of what you created.`;
119038
119286
  }), "execute")
119039
119287
  }),
119040
119288
  listEntities: tool({
119041
- description: "List all entities in a package or all packages",
119289
+ description: "List packages, or a bounded entity page within one package. Prefer searchModel for discovery in large projects.",
119042
119290
  inputSchema: external_exports.object({
119043
- packageName: external_exports.string().optional().describe("Package name, or omit to list all packages")
119291
+ packageName: external_exports.string().optional().describe("Package name, or omit to list packages"),
119292
+ query: external_exports.string().optional().describe("Optional name/description filter"),
119293
+ limit: external_exports.number().optional().describe("Maximum entities returned (default 50, max 100)")
119044
119294
  }),
119045
119295
  execute: /* @__PURE__ */ __name(async (params) => {
119046
119296
  try {
@@ -119051,10 +119301,11 @@ Be concise in your responses. Show a summary of what you created.`;
119051
119301
  }, "execute")
119052
119302
  }),
119053
119303
  getEntityDetails: tool({
119054
- description: "Get full detail for an entity: attributes with type/required/primaryKey AND field validation, the PHYSICAL mapping (entity table name + schema, each attribute physical column name + DB type), physical constraints, and inline business rules. packageName is OPTIONAL \u2014 omit it and the entity name is resolved across every package (ambiguous names return a candidate list). Use this before writing SQL/DDL so you use the real physical names and types.",
119304
+ description: "Get full detail for an entity as compact Markdown by default: attributes, validation, physical mapping, constraints, and rules. Set format=json only when structured data is required. packageName is optional and resolves across packages when omitted.",
119055
119305
  inputSchema: external_exports.object({
119056
119306
  packageName: external_exports.string().optional().describe("Owning package if known (optional \u2014 resolved across packages when omitted)"),
119057
- entityName: external_exports.string()
119307
+ entityName: external_exports.string(),
119308
+ format: external_exports.enum(["markdown", "json"]).optional().describe("Result format (default markdown)")
119058
119309
  }),
119059
119310
  execute: /* @__PURE__ */ __name(async (params) => {
119060
119311
  try {
@@ -119065,11 +119316,11 @@ Be concise in your responses. Show a summary of what you created.`;
119065
119316
  }, "execute")
119066
119317
  }),
119067
119318
  getModelOverview: tool({
119068
- description: "Get a whole-model outline: every package with its entity names, and a count of each concept (entities, relationships, cases, rules, events, actions, state machines, derived types, stereotypes). Use to orient yourself before answering; a snapshot is already in your system context, so only call this to refresh after changes.",
119319
+ description: "Get whole-model counts and package summaries. Large projects omit entity names by design; use searchModel to locate candidates. A snapshot is already in your context, so call this only to refresh after changes.",
119069
119320
  inputSchema: external_exports.object({}),
119070
119321
  execute: /* @__PURE__ */ __name(async () => {
119071
119322
  try {
119072
- return await getModelOverviewCached(() => buildModelOverview(services));
119323
+ return modelOverviewForAgent(await getModelOverviewCached(() => buildModelOverview(services)));
119073
119324
  } catch (err) {
119074
119325
  return { error: err.message };
119075
119326
  }
@@ -119087,11 +119338,11 @@ Be concise in your responses. Show a summary of what you created.`;
119087
119338
  }, "execute")
119088
119339
  }),
119089
119340
  getSqlSchema: tool({
119090
- description: "Get the PHYSICAL relational schema for writing SQL: per-entity table name + schema, each column (physical name, dbType, nullable, primaryKey), and relationships as join hints. PREFER scoping with entityNames (target entities, resolved across packages; directly-related entities are included automatically for JOINs) or packageName \u2014 an unscoped call on a large model returns a huge result that may be truncated. Optional dialect. Call this before writing any SQL query or DDL so you use real physical names/types, not the conceptual (logical) names.",
119341
+ description: "Get the PHYSICAL relational schema as compact Markdown by default: table/schema, columns, types, flags, and relationship join hints. Set format=json only when structured data is required. Prefer entityNames or packageName scope; oversized unscoped requests are refused.",
119091
119342
  inputSchema: getSqlSchemaInputSchema,
119092
119343
  execute: /* @__PURE__ */ __name(async (params) => {
119093
119344
  try {
119094
- return await buildSqlSchema(params, services, cfg.sql);
119345
+ return await executeGetSqlSchema(params, services, cfg.sql);
119095
119346
  } catch (err) {
119096
119347
  return { error: err.message };
119097
119348
  }
@@ -119272,6 +119523,20 @@ Be concise in your responses. Show a summary of what you created.`;
119272
119523
  ...cost !== void 0 ? { cost } : {}
119273
119524
  })}
119274
119525
 
119526
+ `);
119527
+ } catch {
119528
+ }
119529
+ }
119530
+ const requestMetrics = providerRequestTelemetry(diagnosticId);
119531
+ if (requestMetrics) {
119532
+ try {
119533
+ res.write(`data: ${JSON.stringify({
119534
+ type: "request-metrics",
119535
+ model: cfg.model,
119536
+ provider: cfg.provider,
119537
+ ...requestMetrics
119538
+ })}
119539
+
119275
119540
  `);
119276
119541
  } catch {
119277
119542
  }
@@ -119288,8 +119553,8 @@ Be concise in your responses. Show a summary of what you created.`;
119288
119553
  cleanup();
119289
119554
  break;
119290
119555
  }
119291
- const text2 = decoder.decode(value, { stream: true });
119292
- const lines = text2.split("\n");
119556
+ const text3 = decoder.decode(value, { stream: true });
119557
+ const lines = text3.split("\n");
119293
119558
  const output = [];
119294
119559
  for (const line of lines) {
119295
119560
  if (line.startsWith("data: ")) {
@@ -119538,24 +119803,27 @@ Be concise in your responses. Show a summary of what you created.`;
119538
119803
  },
119539
119804
  {
119540
119805
  name: "listEntities",
119541
- description: "List all entities in a package or all packages",
119806
+ description: "List packages, or a bounded entity page within one package. Prefer searchModel for discovery in large projects.",
119542
119807
  source: "builtin",
119543
119808
  parameters: [
119544
- { name: "packageName", type: "string", required: false, description: "Package name (omit to list all packages)" }
119809
+ { name: "packageName", type: "string", required: false, description: "Package name (omit to list packages)" },
119810
+ { name: "query", type: "string", required: false, description: "Optional name/description filter" },
119811
+ { name: "limit", type: "number", required: false, description: "Maximum entities returned (default 50, max 100)" }
119545
119812
  ]
119546
119813
  },
119547
119814
  {
119548
119815
  name: "getEntityDetails",
119549
- description: "Get full entity detail: attributes + validation, the physical mapping (table/schema, column names, DB types), constraints, and inline rules. Use before writing SQL/DDL.",
119816
+ description: "Get full entity detail as compact Markdown by default: attributes, validation, physical mapping, constraints, and rules. Set format=json for structured compatibility.",
119550
119817
  source: "builtin",
119551
119818
  parameters: [
119552
119819
  { name: "packageName", type: "string", required: false, description: "Owning package if known (omit to resolve the entity name across all packages)" },
119553
- { name: "entityName", type: "string", required: true, description: "Entity name" }
119820
+ { name: "entityName", type: "string", required: true, description: "Entity name" },
119821
+ { name: "format", type: "markdown|json", required: false, description: "Result format (default markdown)" }
119554
119822
  ]
119555
119823
  },
119556
119824
  {
119557
119825
  name: "getModelOverview",
119558
- description: "Whole-model outline: every package with its entities, and a count of each concept (entities, relationships, cases, rules, events, actions, state machines, derived types, stereotypes). A snapshot is also injected into the system prompt each turn.",
119826
+ description: "Whole-model counts and package summary. Entity names are omitted automatically for large projects; use searchModel to locate them.",
119559
119827
  source: "builtin",
119560
119828
  parameters: []
119561
119829
  },
@@ -119571,12 +119839,13 @@ Be concise in your responses. Show a summary of what you created.`;
119571
119839
  },
119572
119840
  {
119573
119841
  name: "getSqlSchema",
119574
- description: "Physical relational schema for writing SQL: tables, columns (physical name + dbType + nullable + PK), and relationships as join hints. Use before generating any SQL query/DDL. Prefer scoping with entityNames or packageName on large models.",
119842
+ description: "Physical relational schema as compact Markdown by default: tables, columns, flags, and relationship join hints. Set format=json for structured compatibility.",
119575
119843
  source: "builtin",
119576
119844
  parameters: [
119577
119845
  { name: "packageName", type: "string", required: false, description: "Scope to one package (omit for all)" },
119578
119846
  { name: "entityNames", type: "string[]", required: false, description: "Preferred scope: target entity names, resolved across packages; directly-related entities are included automatically for JOINs" },
119579
- { name: "dialect", type: "generic|postgres|mysql|mssql|oracle|sqlite", required: false, description: "Target SQL dialect (default generic)" }
119847
+ { name: "dialect", type: "generic|postgres|mysql|mssql|oracle|sqlite", required: false, description: "Target SQL dialect (default generic)" },
119848
+ { name: "format", type: "markdown|json", required: false, description: "Result format (default markdown)" }
119580
119849
  ]
119581
119850
  },
119582
119851
  {
@@ -120736,7 +121005,7 @@ var require_keyword3 = __commonJS({
120736
121005
  "backend/node_modules/esutils/lib/keyword.js"(exports2, module) {
120737
121006
  (function() {
120738
121007
  "use strict";
120739
- var code = require_code5();
121008
+ var code2 = require_code5();
120740
121009
  function isStrictModeReservedWordES6(id) {
120741
121010
  switch (id) {
120742
121011
  case "implements":
@@ -120804,12 +121073,12 @@ var require_keyword3 = __commonJS({
120804
121073
  return false;
120805
121074
  }
120806
121075
  ch = id.charCodeAt(0);
120807
- if (!code.isIdentifierStartES5(ch)) {
121076
+ if (!code2.isIdentifierStartES5(ch)) {
120808
121077
  return false;
120809
121078
  }
120810
121079
  for (i = 1, iz = id.length; i < iz; ++i) {
120811
121080
  ch = id.charCodeAt(i);
120812
- if (!code.isIdentifierPartES5(ch)) {
121081
+ if (!code2.isIdentifierPartES5(ch)) {
120813
121082
  return false;
120814
121083
  }
120815
121084
  }
@@ -120825,7 +121094,7 @@ var require_keyword3 = __commonJS({
120825
121094
  if (id.length === 0) {
120826
121095
  return false;
120827
121096
  }
120828
- check2 = code.isIdentifierStartES6;
121097
+ check2 = code2.isIdentifierStartES6;
120829
121098
  for (i = 0, iz = id.length; i < iz; ++i) {
120830
121099
  ch = id.charCodeAt(i);
120831
121100
  if (55296 <= ch && ch <= 56319) {
@@ -120842,7 +121111,7 @@ var require_keyword3 = __commonJS({
120842
121111
  if (!check2(ch)) {
120843
121112
  return false;
120844
121113
  }
120845
- check2 = code.isIdentifierPartES6;
121114
+ check2 = code2.isIdentifierPartES6;
120846
121115
  }
120847
121116
  return true;
120848
121117
  }
@@ -121086,21 +121355,21 @@ var require_typed = __commonJS({
121086
121355
  }
121087
121356
  __name(advance, "advance");
121088
121357
  function scanHexEscape(prefix) {
121089
- var i, len, ch, code = 0;
121358
+ var i, len, ch, code2 = 0;
121090
121359
  len = prefix === "u" ? 4 : 2;
121091
121360
  for (i = 0; i < len; ++i) {
121092
121361
  if (index2 < length && esutils.code.isHexDigit(source.charCodeAt(index2))) {
121093
121362
  ch = advance();
121094
- code = code * 16 + "0123456789abcdef".indexOf(ch.toLowerCase());
121363
+ code2 = code2 * 16 + "0123456789abcdef".indexOf(ch.toLowerCase());
121095
121364
  } else {
121096
121365
  return "";
121097
121366
  }
121098
121367
  }
121099
- return String.fromCharCode(code);
121368
+ return String.fromCharCode(code2);
121100
121369
  }
121101
121370
  __name(scanHexEscape, "scanHexEscape");
121102
121371
  function scanString() {
121103
- var str2 = "", quote, ch, code, unescaped, restore;
121372
+ var str2 = "", quote, ch, code2, unescaped, restore;
121104
121373
  quote = source.charAt(index2);
121105
121374
  ++index2;
121106
121375
  while (index2 < length) {
@@ -121143,14 +121412,14 @@ var require_typed = __commonJS({
121143
121412
  break;
121144
121413
  default:
121145
121414
  if (esutils.code.isOctalDigit(ch.charCodeAt(0))) {
121146
- code = "01234567".indexOf(ch);
121415
+ code2 = "01234567".indexOf(ch);
121147
121416
  if (index2 < length && esutils.code.isOctalDigit(source.charCodeAt(index2))) {
121148
- code = code * 8 + "01234567".indexOf(advance());
121417
+ code2 = code2 * 8 + "01234567".indexOf(advance());
121149
121418
  if ("0123".indexOf(ch) >= 0 && index2 < length && esutils.code.isOctalDigit(source.charCodeAt(index2))) {
121150
- code = code * 8 + "01234567".indexOf(advance());
121419
+ code2 = code2 * 8 + "01234567".indexOf(advance());
121151
121420
  }
121152
121421
  }
121153
- str2 += String.fromCharCode(code);
121422
+ str2 += String.fromCharCode(code2);
121154
121423
  } else {
121155
121424
  str2 += ch;
121156
121425
  }
@@ -121406,8 +121675,8 @@ var require_typed = __commonJS({
121406
121675
  }
121407
121676
  }
121408
121677
  __name(next, "next");
121409
- function consume(target, text2) {
121410
- utility.assert(token === target, text2 || "consumed token not matched");
121678
+ function consume(target, text3) {
121679
+ utility.assert(token === target, text3 || "consumed token not matched");
121411
121680
  next();
121412
121681
  }
121413
121682
  __name(consume, "consume");
@@ -122496,12 +122765,12 @@ var require_doctrine = __commonJS({
122496
122765
  }
122497
122766
  }, "parseThis");
122498
122767
  TagParser.prototype.parseVariation = /* @__PURE__ */ __name(function parseVariation() {
122499
- var variation, text2;
122500
- text2 = sliceSource(source, index2, this._last).trim();
122501
- variation = parseFloat(text2, 10);
122768
+ var variation, text3;
122769
+ text3 = sliceSource(source, index2, this._last).trim();
122770
+ variation = parseFloat(text3, 10);
122502
122771
  this._tag.variation = variation;
122503
122772
  if (isNaN(variation)) {
122504
- if (!this.addError("Invalid variation '%0'", text2)) {
122773
+ if (!this.addError("Invalid variation '%0'", text3)) {
122505
122774
  return false;
122506
122775
  }
122507
122776
  }
@@ -127387,8 +127656,8 @@ var require_isIdentityCard = __commonJS({
127387
127656
  if (!/^[A-Z][0-9]{9}$/.test(sanitized)) return false;
127388
127657
  return Array.from(sanitized).reduce(function(sum, number4, index2) {
127389
127658
  if (index2 === 0) {
127390
- var code = ALPHABET_CODES[number4];
127391
- return code % 10 * 9 + Math.floor(code / 10);
127659
+ var code2 = ALPHABET_CODES[number4];
127660
+ return code2 % 10 * 9 + Math.floor(code2 / 10);
127392
127661
  }
127393
127662
  if (index2 === 9) {
127394
127663
  return (10 - sum % 10 - Number(number4)) % 10 === 0;
@@ -138770,9 +139039,9 @@ var require_spec = __commonJS({
138770
139039
  }
138771
139040
  }
138772
139041
  __name(checkForDuplicates, "checkForDuplicates");
138773
- function validateResponse(code, response, responseId) {
138774
- if (code !== "default" && (code < 100 || code > 599)) {
138775
- throw ono.syntax(`Validation failed. ${responseId} has an invalid response code (${code})`);
139042
+ function validateResponse(code2, response, responseId) {
139043
+ if (code2 !== "default" && (code2 < 100 || code2 > 599)) {
139044
+ throw ono.syntax(`Validation failed. ${responseId} has an invalid response code (${code2})`);
138776
139045
  }
138777
139046
  let headers = Object.keys(response.headers || {});
138778
139047
  for (let headerName of headers) {
@@ -139964,11 +140233,11 @@ var require_binary2 = __commonJS({
139964
140233
  var BASE64_MAP = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r";
139965
140234
  function resolveYamlBinary(data) {
139966
140235
  if (data === null) return false;
139967
- var code, idx, bitlen = 0, max = data.length, map2 = BASE64_MAP;
140236
+ var code2, idx, bitlen = 0, max = data.length, map2 = BASE64_MAP;
139968
140237
  for (idx = 0; idx < max; idx++) {
139969
- code = map2.indexOf(data.charAt(idx));
139970
- if (code > 64) continue;
139971
- if (code < 0) return false;
140238
+ code2 = map2.indexOf(data.charAt(idx));
140239
+ if (code2 > 64) continue;
140240
+ if (code2 < 0) return false;
139972
140241
  bitlen += 6;
139973
140242
  }
139974
140243
  return bitlen % 8 === 0;
@@ -145657,12 +145926,12 @@ var require_parse_3997f544 = __commonJS({
145657
145926
  } = this.context;
145658
145927
  const cc = src.substr(offset, length);
145659
145928
  const ok2 = cc.length === length && /^[0-9a-fA-F]+$/.test(cc);
145660
- const code = ok2 ? parseInt(cc, 16) : NaN;
145661
- if (isNaN(code)) {
145929
+ const code2 = ok2 ? parseInt(cc, 16) : NaN;
145930
+ if (isNaN(code2)) {
145662
145931
  errors.push(new _rollupPluginBabelHelpers.YAMLSyntaxError(this, `Invalid escape sequence ${src.substr(offset - 2, length + 2)}`));
145663
145932
  return src.substr(offset - 2, length + 2);
145664
145933
  }
145665
- return String.fromCodePoint(code);
145934
+ return String.fromCodePoint(code2);
145666
145935
  }
145667
145936
  /**
145668
145937
  * Parses a "double quoted" value from the source
@@ -146658,26 +146927,26 @@ ${ctx.indent}`;
146658
146927
  var FOLD_FLOW = "flow";
146659
146928
  var FOLD_BLOCK = "block";
146660
146929
  var FOLD_QUOTED = "quoted";
146661
- var consumeMoreIndentedLines = /* @__PURE__ */ __name((text2, i) => {
146662
- let ch = text2[i + 1];
146930
+ var consumeMoreIndentedLines = /* @__PURE__ */ __name((text3, i) => {
146931
+ let ch = text3[i + 1];
146663
146932
  while (ch === " " || ch === " ") {
146664
146933
  do {
146665
- ch = text2[i += 1];
146934
+ ch = text3[i += 1];
146666
146935
  } while (ch && ch !== "\n");
146667
- ch = text2[i + 1];
146936
+ ch = text3[i + 1];
146668
146937
  }
146669
146938
  return i;
146670
146939
  }, "consumeMoreIndentedLines");
146671
- function foldFlowLines(text2, indent, mode, {
146940
+ function foldFlowLines(text3, indent, mode, {
146672
146941
  indentAtStart,
146673
146942
  lineWidth = 80,
146674
146943
  minContentWidth = 20,
146675
146944
  onFold,
146676
146945
  onOverflow
146677
146946
  }) {
146678
- if (!lineWidth || lineWidth < 0) return text2;
146947
+ if (!lineWidth || lineWidth < 0) return text3;
146679
146948
  const endStep = Math.max(1 + minContentWidth, 1 + lineWidth - indent.length);
146680
- if (text2.length <= endStep) return text2;
146949
+ if (text3.length <= endStep) return text3;
146681
146950
  const folds = [];
146682
146951
  const escapedFolds = {};
146683
146952
  let end = lineWidth - indent.length;
@@ -146690,12 +146959,12 @@ ${ctx.indent}`;
146690
146959
  let overflow = false;
146691
146960
  let i = -1;
146692
146961
  if (mode === FOLD_BLOCK) {
146693
- i = consumeMoreIndentedLines(text2, i);
146962
+ i = consumeMoreIndentedLines(text3, i);
146694
146963
  if (i !== -1) end = i + endStep;
146695
146964
  }
146696
- for (let ch; ch = text2[i += 1]; ) {
146965
+ for (let ch; ch = text3[i += 1]; ) {
146697
146966
  if (mode === FOLD_QUOTED && ch === "\\") {
146698
- switch (text2[i + 1]) {
146967
+ switch (text3[i + 1]) {
146699
146968
  case "x":
146700
146969
  i += 3;
146701
146970
  break;
@@ -146710,12 +146979,12 @@ ${ctx.indent}`;
146710
146979
  }
146711
146980
  }
146712
146981
  if (ch === "\n") {
146713
- if (mode === FOLD_BLOCK) i = consumeMoreIndentedLines(text2, i);
146982
+ if (mode === FOLD_BLOCK) i = consumeMoreIndentedLines(text3, i);
146714
146983
  end = i + endStep;
146715
146984
  split = void 0;
146716
146985
  } else {
146717
146986
  if (ch === " " && prev && prev !== " " && prev !== "\n" && prev !== " ") {
146718
- const next = text2[i + 1];
146987
+ const next = text3[i + 1];
146719
146988
  if (next && next !== " " && next !== "\n" && next !== " ") split = i;
146720
146989
  }
146721
146990
  if (i >= end) {
@@ -146726,7 +146995,7 @@ ${ctx.indent}`;
146726
146995
  } else if (mode === FOLD_QUOTED) {
146727
146996
  while (prev === " " || prev === " ") {
146728
146997
  prev = ch;
146729
- ch = text2[i += 1];
146998
+ ch = text3[i += 1];
146730
146999
  overflow = true;
146731
147000
  }
146732
147001
  folds.push(i - 2);
@@ -146741,18 +147010,18 @@ ${ctx.indent}`;
146741
147010
  prev = ch;
146742
147011
  }
146743
147012
  if (overflow && onOverflow) onOverflow();
146744
- if (folds.length === 0) return text2;
147013
+ if (folds.length === 0) return text3;
146745
147014
  if (onFold) onFold();
146746
- let res = text2.slice(0, folds[0]);
147015
+ let res = text3.slice(0, folds[0]);
146747
147016
  for (let i2 = 0; i2 < folds.length; ++i2) {
146748
147017
  const fold = folds[i2];
146749
- const end2 = folds[i2 + 1] || text2.length;
147018
+ const end2 = folds[i2 + 1] || text3.length;
146750
147019
  if (fold === 0) res = `
146751
- ${indent}${text2.slice(0, end2)}`;
147020
+ ${indent}${text3.slice(0, end2)}`;
146752
147021
  else {
146753
- if (mode === FOLD_QUOTED && escapedFolds[fold]) res += `${text2[fold]}\\`;
147022
+ if (mode === FOLD_QUOTED && escapedFolds[fold]) res += `${text3[fold]}\\`;
146754
147023
  res += `
146755
- ${indent}${text2.slice(fold + 1, end2)}`;
147024
+ ${indent}${text3.slice(fold + 1, end2)}`;
146756
147025
  }
146757
147026
  }
146758
147027
  return res;
@@ -146801,8 +147070,8 @@ ${indent}${text2.slice(fold + 1, end2)}`;
146801
147070
  case "u":
146802
147071
  {
146803
147072
  str2 += json3.slice(start, i);
146804
- const code = json3.substr(i + 2, 4);
146805
- switch (code) {
147073
+ const code2 = json3.substr(i + 2, 4);
147074
+ switch (code2) {
146806
147075
  case "0000":
146807
147076
  str2 += "\\0";
146808
147077
  break;
@@ -146828,7 +147097,7 @@ ${indent}${text2.slice(fold + 1, end2)}`;
146828
147097
  str2 += "\\P";
146829
147098
  break;
146830
147099
  default:
146831
- if (code.substr(0, 2) === "00") str2 += "\\x" + code.substr(2);
147100
+ if (code2.substr(0, 2) === "00") str2 += "\\x" + code2.substr(2);
146832
147101
  else str2 += json3.substr(i, 6);
146833
147102
  }
146834
147103
  i += 5;
@@ -154799,8 +155068,8 @@ var require_scan2 = __commonJS({
154799
155068
  CHAR_RIGHT_SQUARE_BRACKET
154800
155069
  /* ] */
154801
155070
  } = require_constants2();
154802
- var isPathSeparator = /* @__PURE__ */ __name((code) => {
154803
- return code === CHAR_FORWARD_SLASH || code === CHAR_BACKWARD_SLASH;
155071
+ var isPathSeparator = /* @__PURE__ */ __name((code2) => {
155072
+ return code2 === CHAR_FORWARD_SLASH || code2 === CHAR_BACKWARD_SLASH;
154804
155073
  }, "isPathSeparator");
154805
155074
  var depth = /* @__PURE__ */ __name((token) => {
154806
155075
  if (token.isPrefix !== true) {
@@ -154830,38 +155099,38 @@ var require_scan2 = __commonJS({
154830
155099
  let finished = false;
154831
155100
  let braces = 0;
154832
155101
  let prev;
154833
- let code;
155102
+ let code2;
154834
155103
  let token = { value: "", depth: 0, isGlob: false };
154835
155104
  const eos = /* @__PURE__ */ __name(() => index2 >= length, "eos");
154836
155105
  const peek = /* @__PURE__ */ __name(() => str2.charCodeAt(index2 + 1), "peek");
154837
155106
  const advance = /* @__PURE__ */ __name(() => {
154838
- prev = code;
155107
+ prev = code2;
154839
155108
  return str2.charCodeAt(++index2);
154840
155109
  }, "advance");
154841
155110
  while (index2 < length) {
154842
- code = advance();
155111
+ code2 = advance();
154843
155112
  let next;
154844
- if (code === CHAR_BACKWARD_SLASH) {
155113
+ if (code2 === CHAR_BACKWARD_SLASH) {
154845
155114
  backslashes = token.backslashes = true;
154846
- code = advance();
154847
- if (code === CHAR_LEFT_CURLY_BRACE) {
155115
+ code2 = advance();
155116
+ if (code2 === CHAR_LEFT_CURLY_BRACE) {
154848
155117
  braceEscaped = true;
154849
155118
  }
154850
155119
  continue;
154851
155120
  }
154852
- if (braceEscaped === true || code === CHAR_LEFT_CURLY_BRACE) {
155121
+ if (braceEscaped === true || code2 === CHAR_LEFT_CURLY_BRACE) {
154853
155122
  braces++;
154854
- while (eos() !== true && (code = advance())) {
154855
- if (code === CHAR_BACKWARD_SLASH) {
155123
+ while (eos() !== true && (code2 = advance())) {
155124
+ if (code2 === CHAR_BACKWARD_SLASH) {
154856
155125
  backslashes = token.backslashes = true;
154857
155126
  advance();
154858
155127
  continue;
154859
155128
  }
154860
- if (code === CHAR_LEFT_CURLY_BRACE) {
155129
+ if (code2 === CHAR_LEFT_CURLY_BRACE) {
154861
155130
  braces++;
154862
155131
  continue;
154863
155132
  }
154864
- if (braceEscaped !== true && code === CHAR_DOT && (code = advance()) === CHAR_DOT) {
155133
+ if (braceEscaped !== true && code2 === CHAR_DOT && (code2 = advance()) === CHAR_DOT) {
154865
155134
  isBrace = token.isBrace = true;
154866
155135
  isGlob = token.isGlob = true;
154867
155136
  finished = true;
@@ -154870,7 +155139,7 @@ var require_scan2 = __commonJS({
154870
155139
  }
154871
155140
  break;
154872
155141
  }
154873
- if (braceEscaped !== true && code === CHAR_COMMA) {
155142
+ if (braceEscaped !== true && code2 === CHAR_COMMA) {
154874
155143
  isBrace = token.isBrace = true;
154875
155144
  isGlob = token.isGlob = true;
154876
155145
  finished = true;
@@ -154879,7 +155148,7 @@ var require_scan2 = __commonJS({
154879
155148
  }
154880
155149
  break;
154881
155150
  }
154882
- if (code === CHAR_RIGHT_CURLY_BRACE) {
155151
+ if (code2 === CHAR_RIGHT_CURLY_BRACE) {
154883
155152
  braces--;
154884
155153
  if (braces === 0) {
154885
155154
  braceEscaped = false;
@@ -154894,7 +155163,7 @@ var require_scan2 = __commonJS({
154894
155163
  }
154895
155164
  break;
154896
155165
  }
154897
- if (code === CHAR_FORWARD_SLASH) {
155166
+ if (code2 === CHAR_FORWARD_SLASH) {
154898
155167
  slashes.push(index2);
154899
155168
  tokens.push(token);
154900
155169
  token = { value: "", depth: 0, isGlob: false };
@@ -154907,22 +155176,22 @@ var require_scan2 = __commonJS({
154907
155176
  continue;
154908
155177
  }
154909
155178
  if (opts.noext !== true) {
154910
- const isExtglobChar = code === CHAR_PLUS || code === CHAR_AT || code === CHAR_ASTERISK || code === CHAR_QUESTION_MARK || code === CHAR_EXCLAMATION_MARK;
155179
+ const isExtglobChar = code2 === CHAR_PLUS || code2 === CHAR_AT || code2 === CHAR_ASTERISK || code2 === CHAR_QUESTION_MARK || code2 === CHAR_EXCLAMATION_MARK;
154911
155180
  if (isExtglobChar === true && peek() === CHAR_LEFT_PARENTHESES) {
154912
155181
  isGlob = token.isGlob = true;
154913
155182
  isExtglob = token.isExtglob = true;
154914
155183
  finished = true;
154915
- if (code === CHAR_EXCLAMATION_MARK && index2 === start) {
155184
+ if (code2 === CHAR_EXCLAMATION_MARK && index2 === start) {
154916
155185
  negatedExtglob = true;
154917
155186
  }
154918
155187
  if (scanToEnd === true) {
154919
- while (eos() !== true && (code = advance())) {
154920
- if (code === CHAR_BACKWARD_SLASH) {
155188
+ while (eos() !== true && (code2 = advance())) {
155189
+ if (code2 === CHAR_BACKWARD_SLASH) {
154921
155190
  backslashes = token.backslashes = true;
154922
- code = advance();
155191
+ code2 = advance();
154923
155192
  continue;
154924
155193
  }
154925
- if (code === CHAR_RIGHT_PARENTHESES) {
155194
+ if (code2 === CHAR_RIGHT_PARENTHESES) {
154926
155195
  isGlob = token.isGlob = true;
154927
155196
  finished = true;
154928
155197
  break;
@@ -154933,7 +155202,7 @@ var require_scan2 = __commonJS({
154933
155202
  break;
154934
155203
  }
154935
155204
  }
154936
- if (code === CHAR_ASTERISK) {
155205
+ if (code2 === CHAR_ASTERISK) {
154937
155206
  if (prev === CHAR_ASTERISK) isGlobstar = token.isGlobstar = true;
154938
155207
  isGlob = token.isGlob = true;
154939
155208
  finished = true;
@@ -154942,7 +155211,7 @@ var require_scan2 = __commonJS({
154942
155211
  }
154943
155212
  break;
154944
155213
  }
154945
- if (code === CHAR_QUESTION_MARK) {
155214
+ if (code2 === CHAR_QUESTION_MARK) {
154946
155215
  isGlob = token.isGlob = true;
154947
155216
  finished = true;
154948
155217
  if (scanToEnd === true) {
@@ -154950,7 +155219,7 @@ var require_scan2 = __commonJS({
154950
155219
  }
154951
155220
  break;
154952
155221
  }
154953
- if (code === CHAR_LEFT_SQUARE_BRACKET) {
155222
+ if (code2 === CHAR_LEFT_SQUARE_BRACKET) {
154954
155223
  while (eos() !== true && (next = advance())) {
154955
155224
  if (next === CHAR_BACKWARD_SLASH) {
154956
155225
  backslashes = token.backslashes = true;
@@ -154969,21 +155238,21 @@ var require_scan2 = __commonJS({
154969
155238
  }
154970
155239
  break;
154971
155240
  }
154972
- if (opts.nonegate !== true && code === CHAR_EXCLAMATION_MARK && index2 === start) {
155241
+ if (opts.nonegate !== true && code2 === CHAR_EXCLAMATION_MARK && index2 === start) {
154973
155242
  negated = token.negated = true;
154974
155243
  start++;
154975
155244
  continue;
154976
155245
  }
154977
- if (opts.noparen !== true && code === CHAR_LEFT_PARENTHESES) {
155246
+ if (opts.noparen !== true && code2 === CHAR_LEFT_PARENTHESES) {
154978
155247
  isGlob = token.isGlob = true;
154979
155248
  if (scanToEnd === true) {
154980
- while (eos() !== true && (code = advance())) {
154981
- if (code === CHAR_LEFT_PARENTHESES) {
155249
+ while (eos() !== true && (code2 = advance())) {
155250
+ if (code2 === CHAR_LEFT_PARENTHESES) {
154982
155251
  backslashes = token.backslashes = true;
154983
- code = advance();
155252
+ code2 = advance();
154984
155253
  continue;
154985
155254
  }
154986
- if (code === CHAR_RIGHT_PARENTHESES) {
155255
+ if (code2 === CHAR_RIGHT_PARENTHESES) {
154987
155256
  finished = true;
154988
155257
  break;
154989
155258
  }
@@ -155048,7 +155317,7 @@ var require_scan2 = __commonJS({
155048
155317
  };
155049
155318
  if (opts.tokens === true) {
155050
155319
  state.maxDepth = 0;
155051
- if (!isPathSeparator(code)) {
155320
+ if (!isPathSeparator(code2)) {
155052
155321
  tokens.push(token);
155053
155322
  }
155054
155323
  state.tokens = tokens;
@@ -159587,8 +159856,8 @@ var require_chokidar = __commonJS({
159587
159856
  * @returns {Error|Boolean} The error if defined, otherwise the value of the FSWatcher instance's `closed` flag
159588
159857
  */
159589
159858
  _handleError(error48) {
159590
- const code = error48 && error48.code;
159591
- if (error48 && code !== "ENOENT" && code !== "ENOTDIR" && (!this.options.ignorePermissionErrors || code !== "EPERM" && code !== "EACCES")) {
159859
+ const code2 = error48 && error48.code;
159860
+ if (error48 && code2 !== "ENOENT" && code2 !== "ENOTDIR" && (!this.options.ignorePermissionErrors || code2 !== "EPERM" && code2 !== "EACCES")) {
159592
159861
  this.emit(EV_ERROR, error48);
159593
159862
  }
159594
159863
  return error48 || this.closed;
@@ -160888,6 +161157,9 @@ var searchEntities = /* @__PURE__ */ __name(async (req, res) => {
160888
161157
  res.status(500).json({ message: "Error searching entities", error: error48 });
160889
161158
  }
160890
161159
  }, "searchEntities");
161160
+ var getSearchStatus = /* @__PURE__ */ __name((_req, res) => {
161161
+ res.json({ message: "Success", data: getSearchIndexHealth() });
161162
+ }, "getSearchStatus");
160891
161163
  var suggestSearch = /* @__PURE__ */ __name(async (req, res) => {
160892
161164
  try {
160893
161165
  const q = typeof req.query.q === "string" ? req.query.q : "";
@@ -161777,8 +162049,12 @@ function diffModels(left, right) {
161777
162049
  const rightByName = new Map(right.packages.map((p) => [p.packageName, p]));
161778
162050
  const leftEntityPkg = /* @__PURE__ */ new Map();
161779
162051
  const rightEntityPkg = /* @__PURE__ */ new Map();
162052
+ const leftEntityByUuid = /* @__PURE__ */ new Map();
161780
162053
  for (const pkg of left.packages) {
161781
- for (const e of pkg.entities) leftEntityPkg.set(e.uuid, pkg.packageName);
162054
+ for (const e of pkg.entities) {
162055
+ leftEntityPkg.set(e.uuid, pkg.packageName);
162056
+ leftEntityByUuid.set(e.uuid, e);
162057
+ }
161782
162058
  }
161783
162059
  for (const pkg of right.packages) {
161784
162060
  for (const e of pkg.entities) rightEntityPkg.set(e.uuid, pkg.packageName);
@@ -161787,7 +162063,8 @@ function diffModels(left, right) {
161787
162063
  for (const [uuid3, rightPkg] of rightEntityPkg) {
161788
162064
  const leftPkg = leftEntityPkg.get(uuid3);
161789
162065
  if (leftPkg && leftPkg !== rightPkg) {
161790
- movedEntities.set(uuid3, { from: leftPkg, to: rightPkg });
162066
+ const leftEntity = leftEntityByUuid.get(uuid3);
162067
+ if (leftEntity) movedEntities.set(uuid3, { from: leftPkg, to: rightPkg, left: leftEntity });
161791
162068
  }
161792
162069
  }
161793
162070
  const allPackageNames = /* @__PURE__ */ new Set([...leftByName.keys(), ...rightByName.keys()]);
@@ -161857,10 +162134,10 @@ function diffEntityLists(leftEntities, rightEntities, movedEntities, currentPkg)
161857
162134
  const moveInfo = movedEntities.get(uuid3);
161858
162135
  if (moveInfo && moveInfo.to === currentPkg) {
161859
162136
  matched.add(uuid3);
161860
- const left2 = leftByUuid.get(uuid3);
161861
- const attrs2 = left2 ? diffAttributeLists(left2.attributes, right.attributes) : right.attributes.map((a) => diffAttrAdded(a));
161862
- const constraints2 = left2 ? diffConstraintLists(left2.constraints, right.constraints) : (right.constraints || []).map((c) => ({ status: "added", key: constraintKey(c), right: c }));
161863
- const changedFields2 = left2 ? diffEntityFields(left2, right) : void 0;
162137
+ const left2 = moveInfo.left;
162138
+ const attrs2 = diffAttributeLists(left2.attributes, right.attributes);
162139
+ const constraints2 = diffConstraintLists(left2.constraints, right.constraints);
162140
+ const changedFields2 = diffEntityFields(left2, right);
161864
162141
  diffs.push({
161865
162142
  status: "moved",
161866
162143
  entityUuid: uuid3,
@@ -162891,8 +163168,7 @@ function diffEntityOrphaned(modelEntity, tableName) {
162891
163168
  };
162892
163169
  });
162893
163170
  return {
162894
- status: "matched",
162895
- // entity exists in model with physical mapping, just table missing
163171
+ status: "modelOnly",
162896
163172
  entityName: modelEntity.name,
162897
163173
  entityUuid: modelEntity.uuid,
162898
163174
  physicalTableName: tableName,
@@ -163003,22 +163279,36 @@ function diffConstraints(model, source) {
163003
163279
  const modelByKey = new Map(modelList.map((c) => [constraintKey3(c), c]));
163004
163280
  const sourceByKey = new Map(sourceList.map((c) => [constraintKey3(c), c]));
163005
163281
  const matched = /* @__PURE__ */ new Set();
163006
- for (const [key2, s] of sourceByKey) {
163007
- const m = modelByKey.get(key2);
163008
- if (!m) {
163009
- diffs.push({ status: "added", key: key2, source: s });
163282
+ for (const [key2, m] of modelByKey) {
163283
+ const s = sourceByKey.get(key2);
163284
+ if (!s) {
163285
+ diffs.push({ status: "added", key: key2, model: m });
163010
163286
  continue;
163011
163287
  }
163012
163288
  matched.add(key2);
163013
- diffs.push({ status: "matched", key: key2, model: m, source: s });
163289
+ diffs.push({
163290
+ status: constraintsEqual2(m, s) ? "matched" : "drifted",
163291
+ key: key2,
163292
+ model: m,
163293
+ source: s
163294
+ });
163014
163295
  }
163015
- for (const [key2, m] of modelByKey) {
163296
+ for (const [key2, s] of sourceByKey) {
163016
163297
  if (matched.has(key2)) continue;
163017
- diffs.push({ status: "removed", key: key2, model: m });
163298
+ diffs.push({ status: "removed", key: key2, source: s });
163018
163299
  }
163019
163300
  return diffs;
163020
163301
  }
163021
163302
  __name(diffConstraints, "diffConstraints");
163303
+ function constraintsEqual2(model, source) {
163304
+ if (model.kind !== source.kind) return false;
163305
+ if ((model.columns || []).join(",") !== (source.columns || []).join(",")) return false;
163306
+ if ((model.expression || "").replace(/\s+/g, " ").trim() !== (source.expression || "").replace(/\s+/g, " ").trim()) return false;
163307
+ const modelRef = model.references ? `${model.references.table}|${(model.references.columns || []).join(",")}` : "";
163308
+ const sourceRef = source.references ? `${source.references.table}|${(source.references.columns || []).join(",")}` : "";
163309
+ return modelRef === sourceRef;
163310
+ }
163311
+ __name(constraintsEqual2, "constraintsEqual");
163022
163312
  function buildSummary2(entities) {
163023
163313
  const summary = {
163024
163314
  matched: 0,
@@ -163026,13 +163316,17 @@ function buildSummary2(entities) {
163026
163316
  orphaned: 0,
163027
163317
  dbOnly: 0,
163028
163318
  drifted: 0,
163029
- entities: { matched: 0, modelOnly: 0, dbOnly: 0 }
163319
+ entities: { matched: 0, modelOnly: 0, dbOnly: 0 },
163320
+ constraints: { matched: 0, added: 0, removed: 0, drifted: 0 }
163030
163321
  };
163031
163322
  for (const e of entities) {
163032
163323
  summary.entities[e.status]++;
163033
163324
  for (const a of e.attributes) {
163034
163325
  summary[a.status]++;
163035
163326
  }
163327
+ for (const constraint of e.constraints) {
163328
+ summary.constraints[constraint.status]++;
163329
+ }
163036
163330
  }
163037
163331
  return summary;
163038
163332
  }
@@ -163140,28 +163434,49 @@ function buildImpactDiff(physicalDiff2, dialect = "postgres") {
163140
163434
  }
163141
163435
  }
163142
163436
  for (const c of entity.constraints) {
163143
- if (c.status === "added" && c.source) {
163144
- const isFK = c.source.kind === "foreignKey";
163437
+ if (c.status === "added" && c.model) {
163438
+ const isFK = c.model.kind === "foreignKey";
163145
163439
  ops.push({
163146
163440
  order: 0,
163147
163441
  type: isFK ? "ADD_FOREIGN_KEY" : "ADD_CONSTRAINT",
163148
163442
  table,
163149
- details: { kind: c.source.kind, key: c.key },
163443
+ details: { kind: c.model.kind, key: c.key },
163150
163444
  destructive: false,
163151
163445
  risk: isFK ? "caution" : "safe",
163152
163446
  riskReason: isFK ? "May fail if orphan rows exist" : void 0
163153
163447
  });
163154
- } else if (c.status === "removed" && c.model) {
163155
- const isFK = c.model.kind === "foreignKey";
163448
+ } else if (c.status === "removed" && c.source) {
163449
+ const isFK = c.source.kind === "foreignKey";
163156
163450
  ops.push({
163157
163451
  order: 0,
163158
163452
  type: isFK ? "DROP_FOREIGN_KEY" : "DROP_CONSTRAINT",
163159
163453
  table,
163160
- details: { kind: c.model.kind, key: c.key },
163454
+ details: { kind: c.source.kind, key: c.key },
163161
163455
  destructive: false,
163162
163456
  risk: "caution",
163163
163457
  riskReason: isFK ? "Removing FK relaxes referential integrity" : "Constraint removal"
163164
163458
  });
163459
+ } else if (c.status === "drifted" && c.model && c.source) {
163460
+ const sourceIsFK = c.source.kind === "foreignKey";
163461
+ const modelIsFK = c.model.kind === "foreignKey";
163462
+ ops.push({
163463
+ order: 0,
163464
+ type: sourceIsFK ? "DROP_FOREIGN_KEY" : "DROP_CONSTRAINT",
163465
+ table,
163466
+ details: { kind: c.source.kind, key: c.key },
163467
+ destructive: false,
163468
+ risk: "caution",
163469
+ riskReason: "Constraint definition changed"
163470
+ });
163471
+ ops.push({
163472
+ order: 0,
163473
+ type: modelIsFK ? "ADD_FOREIGN_KEY" : "ADD_CONSTRAINT",
163474
+ table,
163475
+ details: { kind: c.model.kind, key: c.key },
163476
+ destructive: false,
163477
+ risk: modelIsFK ? "caution" : "safe",
163478
+ riskReason: modelIsFK ? "May fail if orphan rows exist" : void 0
163479
+ });
163165
163480
  }
163166
163481
  }
163167
163482
  }
@@ -163560,27 +163875,27 @@ function splitColumnList(inside) {
163560
163875
  return inside.split(",").map((c) => unquoteIdent(c)).filter(Boolean);
163561
163876
  }
163562
163877
  __name(splitColumnList, "splitColumnList");
163563
- function readParenBody(text2, start) {
163878
+ function readParenBody(text3, start) {
163564
163879
  let i = start;
163565
- while (i < text2.length && text2[i] !== "(") i++;
163566
- if (i >= text2.length) return null;
163880
+ while (i < text3.length && text3[i] !== "(") i++;
163881
+ if (i >= text3.length) return null;
163567
163882
  let depth = 0;
163568
163883
  const bodyStart = i + 1;
163569
- for (; i < text2.length; i++) {
163570
- if (text2[i] === "(") depth++;
163571
- else if (text2[i] === ")") {
163884
+ for (; i < text3.length; i++) {
163885
+ if (text3[i] === "(") depth++;
163886
+ else if (text3[i] === ")") {
163572
163887
  depth--;
163573
- if (depth === 0) return { body: text2.slice(bodyStart, i), end: i + 1 };
163888
+ if (depth === 0) return { body: text3.slice(bodyStart, i), end: i + 1 };
163574
163889
  }
163575
163890
  }
163576
163891
  return null;
163577
163892
  }
163578
163893
  __name(readParenBody, "readParenBody");
163579
- function parseReferentialActions(text2) {
163894
+ function parseReferentialActions(text3) {
163580
163895
  const result = {};
163581
163896
  const actionPattern = /ON\s+(DELETE|UPDATE)\s+(CASCADE|SET\s+NULL|SET\s+DEFAULT|RESTRICT|NO\s+ACTION)/gi;
163582
163897
  let m;
163583
- while ((m = actionPattern.exec(text2)) !== null) {
163898
+ while ((m = actionPattern.exec(text3)) !== null) {
163584
163899
  const trigger = m[1].toUpperCase();
163585
163900
  const action = m[2].toUpperCase().replace(/\s+/g, " ");
163586
163901
  if (trigger === "DELETE") result.onDelete = action;
@@ -163699,8 +164014,8 @@ function extractTableComments(sql) {
163699
164014
  let m;
163700
164015
  while ((m = regex.exec(sql)) !== null) {
163701
164016
  const tableName = m[2].toLowerCase();
163702
- const text2 = m[3].replace(/''/g, "'");
163703
- map2.set(tableName, text2);
164017
+ const text3 = m[3].replace(/''/g, "'");
164018
+ map2.set(tableName, text3);
163704
164019
  }
163705
164020
  return map2;
163706
164021
  }
@@ -163712,8 +164027,8 @@ function extractColumnComments(sql) {
163712
164027
  while ((m = regex.exec(sql)) !== null) {
163713
164028
  const tableName = m[2].toLowerCase();
163714
164029
  const colName = m[3].toLowerCase();
163715
- const text2 = m[4].replace(/''/g, "'");
163716
- map2.set(`${tableName}.${colName}`, text2);
164030
+ const text3 = m[4].replace(/''/g, "'");
164031
+ map2.set(`${tableName}.${colName}`, text3);
163717
164032
  }
163718
164033
  return map2;
163719
164034
  }
@@ -165154,8 +165469,17 @@ var physicalDiff = /* @__PURE__ */ __name(async (req, res) => {
165154
165469
  return res.status(400).json({ message: parsed.errors[0], data: parsed });
165155
165470
  }
165156
165471
  sourceEntities = parsed.entities;
165472
+ } else if (source.type === "live") {
165473
+ if (!source.credentials?.user || !source.credentials?.password) {
165474
+ return res.status(400).json({ message: "source.credentials.user and password are required for type live" });
165475
+ }
165476
+ sourceEntities = await introspectServiceLive(
165477
+ service,
165478
+ source.credentials,
165479
+ source.connectionOverrides
165480
+ );
165157
165481
  } else {
165158
- return res.status(400).json({ message: `Unsupported source type: ${source.type}. Supported: ddl` });
165482
+ return res.status(400).json({ message: `Unsupported source type: ${source.type}. Supported: ddl, live` });
165159
165483
  }
165160
165484
  const diff = diffPhysicalModel(modelEntities, sourceEntities);
165161
165485
  res.json({
@@ -165182,6 +165506,15 @@ var impactDiffEndpoint = /* @__PURE__ */ __name(async (req, res) => {
165182
165506
  if (!source.sql) return res.status(400).json({ message: "source.sql is required" });
165183
165507
  const parsed = importService.parseSqlDdl(source.sql, source.options || {});
165184
165508
  sourceEntities = parsed.entities;
165509
+ } else if (source.type === "live") {
165510
+ if (!source.credentials?.user || !source.credentials?.password) {
165511
+ return res.status(400).json({ message: "source.credentials.user and password are required for type live" });
165512
+ }
165513
+ sourceEntities = await introspectServiceLive(
165514
+ service,
165515
+ source.credentials,
165516
+ source.connectionOverrides
165517
+ );
165185
165518
  } else {
165186
165519
  return res.status(400).json({ message: `Unsupported source type: ${source.type}` });
165187
165520
  }
@@ -165300,6 +165633,7 @@ var physicalDiffAll = /* @__PURE__ */ __name(async (req, res) => {
165300
165633
  const serviceList = services && services.length > 0 ? services : await listMicroservices();
165301
165634
  const byService = {};
165302
165635
  const agg = { matched: 0, drifted: 0, modelOnly: 0, orphaned: 0, dbOnly: 0 };
165636
+ const constraintAgg = { matched: 0, added: 0, removed: 0, drifted: 0 };
165303
165637
  let ok2 = 0;
165304
165638
  let failed = 0;
165305
165639
  for (const serviceName of serviceList) {
@@ -165324,6 +165658,10 @@ var physicalDiffAll = /* @__PURE__ */ __name(async (req, res) => {
165324
165658
  agg.modelOnly += diff.summary.modelOnly;
165325
165659
  agg.orphaned += diff.summary.orphaned;
165326
165660
  agg.dbOnly += diff.summary.dbOnly;
165661
+ constraintAgg.matched += diff.summary.constraints.matched;
165662
+ constraintAgg.added += diff.summary.constraints.added;
165663
+ constraintAgg.removed += diff.summary.constraints.removed;
165664
+ constraintAgg.drifted += diff.summary.constraints.drifted;
165327
165665
  }
165328
165666
  res.json({
165329
165667
  message: `Physical diff (all): ${ok2} ok, ${failed} failed across ${serviceList.length} services`,
@@ -165333,7 +165671,8 @@ var physicalDiffAll = /* @__PURE__ */ __name(async (req, res) => {
165333
165671
  services: serviceList.length,
165334
165672
  ok: ok2,
165335
165673
  failed,
165336
- ...agg
165674
+ ...agg,
165675
+ constraints: constraintAgg
165337
165676
  }
165338
165677
  }
165339
165678
  });
@@ -166672,7 +167011,7 @@ function registerSearchAgentTools() {
166672
167011
  registerAgentTool({
166673
167012
  name: "searchModel",
166674
167013
  category: "read",
166675
- description: `Full-text search across the whole data dictionary \u2014 entities, attributes, packages, relationships, rules, entity metadata and cases. Fuzzy + prefix matching (e.g. "iban", "order tot", "payment"). Use this to LOCATE elements when you don't already know the exact package/entity name; then call getEntityDetails for the full definition. Returns ranked hits with the owning package and entity.`,
167014
+ description: `Full-text search across the whole data dictionary \u2014 entities, attributes, packages, relationships, rules, entity metadata and cases. Ranked prefix matching supports queries such as "iban", "order tot", and "payment". Use this to LOCATE elements when you don't already know the exact package/entity name; then call getEntityDetails for the full definition. Returns ranked hits with the owning package and entity.`,
166676
167015
  jsonSchema: {
166677
167016
  type: "object",
166678
167017
  required: ["query"],
@@ -166692,7 +167031,11 @@ function registerSearchAgentTools() {
166692
167031
  execute: /* @__PURE__ */ __name((args) => {
166693
167032
  const idx = getSearchIndex();
166694
167033
  if (!idx) {
166695
- return { success: false, error: "Search index is not available. Use listEntities / getModelOverview instead." };
167034
+ return {
167035
+ success: false,
167036
+ error: "Search index is not available. Check getSearchIndexStatus, then use narrowly scoped entity tools.",
167037
+ index: getSearchIndexHealth()
167038
+ };
166696
167039
  }
166697
167040
  const query = String(args.query ?? "").trim();
166698
167041
  if (!query) return { success: true, count: 0, results: [] };
@@ -166705,6 +167048,7 @@ function registerSearchAgentTools() {
166705
167048
  return {
166706
167049
  success: true,
166707
167050
  count: hits.length,
167051
+ index: getSearchIndexHealth(),
166708
167052
  results: hits.map((h) => ({
166709
167053
  kind: h.kind,
166710
167054
  name: h.name,
@@ -166716,6 +167060,14 @@ function registerSearchAgentTools() {
166716
167060
  };
166717
167061
  }, "execute")
166718
167062
  });
167063
+ registerAgentTool({
167064
+ name: "getSearchIndexStatus",
167065
+ category: "read",
167066
+ description: "Check whether the full-text model index is ready and how many entities, attributes, packages and other records it contains. Use this when searchModel returns no results unexpectedly or before reviewing a very large project.",
167067
+ jsonSchema: { type: "object", properties: {} },
167068
+ inputSchema: external_exports.object({}),
167069
+ execute: /* @__PURE__ */ __name(() => ({ success: true, ...getSearchIndexHealth() }), "execute")
167070
+ });
166719
167071
  }
166720
167072
  __name(registerSearchAgentTools, "registerSearchAgentTools");
166721
167073
 
@@ -166724,6 +167076,7 @@ registerSearchAgentTools();
166724
167076
  var router24 = (0, import_express25.Router)();
166725
167077
  router24.get("/api/entities/flat", getFlatEntitiesAndAttributes);
166726
167078
  router24.get("/api/search/suggest", suggestSearch);
167079
+ router24.get("/api/search/status", getSearchStatus);
166727
167080
  router24.get("/api/search", searchEntities);
166728
167081
  var search_routes_default = router24;
166729
167082
 
@@ -167312,8 +167665,8 @@ function num(v, d) {
167312
167665
  }
167313
167666
  __name(num, "num");
167314
167667
  function isNotFound2(e) {
167315
- const code = e?.code;
167316
- return code === "ERR_MODULE_NOT_FOUND" || code === "MODULE_NOT_FOUND";
167668
+ const code2 = e?.code;
167669
+ return code2 === "ERR_MODULE_NOT_FOUND" || code2 === "MODULE_NOT_FOUND";
167317
167670
  }
167318
167671
  __name(isNotFound2, "isNotFound");
167319
167672
  var globalRoot;
@@ -168670,10 +169023,10 @@ function validateAmpersand(xmlData, i) {
168670
169023
  return i;
168671
169024
  }
168672
169025
  __name(validateAmpersand, "validateAmpersand");
168673
- function getErrorObject(code, message, lineNumber) {
169026
+ function getErrorObject(code2, message, lineNumber) {
168674
169027
  return {
168675
169028
  err: {
168676
- code,
169029
+ code: code2,
168677
169030
  msg: message,
168678
169031
  line: lineNumber.line || lineNumber,
168679
169032
  col: lineNumber.col
@@ -173156,12 +173509,12 @@ function tagExpWithClosingIndex(xmlData, i, closingChar = ">") {
173156
173509
  let result = "";
173157
173510
  let segmentStart = i;
173158
173511
  for (let index2 = i; index2 < len; index2++) {
173159
- const code = xmlData.charCodeAt(index2);
173512
+ const code2 = xmlData.charCodeAt(index2);
173160
173513
  if (attrBoundary) {
173161
- if (code === attrBoundary) attrBoundary = 0;
173162
- } else if (code === 34 || code === 39) {
173163
- attrBoundary = code;
173164
- } else if (code === closeCode0) {
173514
+ if (code2 === attrBoundary) attrBoundary = 0;
173515
+ } else if (code2 === 34 || code2 === 39) {
173516
+ attrBoundary = code2;
173517
+ } else if (code2 === closeCode0) {
173165
173518
  if (closeCode1 !== -1) {
173166
173519
  if (xmlData.charCodeAt(index2 + 1) === closeCode1) {
173167
173520
  result += xmlData.substring(segmentStart, index2);
@@ -173171,7 +173524,7 @@ function tagExpWithClosingIndex(xmlData, i, closingChar = ">") {
173171
173524
  result += xmlData.substring(segmentStart, index2);
173172
173525
  return { data: result, index: index2 };
173173
173526
  }
173174
- } else if (code === 9 && !attrBoundary) {
173527
+ } else if (code2 === 9 && !attrBoundary) {
173175
173528
  result += xmlData.substring(segmentStart, index2) + " ";
173176
173529
  segmentStart = index2 + 1;
173177
173530
  }
@@ -173324,7 +173677,7 @@ function prettify(node, options2, matcher, readonlyMatcher) {
173324
173677
  }
173325
173678
  __name(prettify, "prettify");
173326
173679
  function compress(arr, options2, matcher, readonlyMatcher) {
173327
- let text2;
173680
+ let text3;
173328
173681
  const compressedObj = {};
173329
173682
  for (let i = 0; i < arr.length; i++) {
173330
173683
  const tagObj = arr[i];
@@ -173337,8 +173690,8 @@ function compress(arr, options2, matcher, readonlyMatcher) {
173337
173690
  matcher.push(property, rawAttrs);
173338
173691
  }
173339
173692
  if (property === options2.textNodeName) {
173340
- if (text2 === void 0) text2 = tagObj[property];
173341
- else text2 += "" + tagObj[property];
173693
+ if (text3 === void 0) text3 = tagObj[property];
173694
+ else text3 += "" + tagObj[property];
173342
173695
  } else if (property === void 0) {
173343
173696
  continue;
173344
173697
  } else if (tagObj[property]) {
@@ -173376,9 +173729,9 @@ function compress(arr, options2, matcher, readonlyMatcher) {
173376
173729
  }
173377
173730
  }
173378
173731
  }
173379
- if (typeof text2 === "string") {
173380
- if (text2.length > 0) compressedObj[options2.textNodeName] = text2;
173381
- } else if (text2 !== void 0) compressedObj[options2.textNodeName] = text2;
173732
+ if (typeof text3 === "string") {
173733
+ if (text3.length > 0) compressedObj[options2.textNodeName] = text3;
173734
+ } else if (text3 !== void 0) compressedObj[options2.textNodeName] = text3;
173382
173735
  return compressedObj;
173383
173736
  }
173384
173737
  __name(compress, "compress");
@@ -174369,8 +174722,8 @@ function readConfluence(dir) {
174369
174722
  for (const f of fs9.readdirSync(dir).filter((f2) => f2.endsWith(".md"))) {
174370
174723
  const raw = fs9.readFileSync(path17.join(dir, f), "utf-8");
174371
174724
  const title = raw.match(/^title:\s*"?(.+?)"?\s*$/m)?.[1] ?? f;
174372
- const text2 = raw.replace(/^---[\s\S]*?---\n/, "").trim();
174373
- out.push({ title, text: text2 });
174725
+ const text3 = raw.replace(/^---[\s\S]*?---\n/, "").trim();
174726
+ out.push({ title, text: text3 });
174374
174727
  }
174375
174728
  return out;
174376
174729
  }
@@ -175526,9 +175879,9 @@ var IN_MEMORY_CAPABILITIES = {
175526
175879
 
175527
175880
  // backend/src/storage/contract/errors.ts
175528
175881
  var BackendError = class extends Error {
175529
- constructor(message, code, cause) {
175882
+ constructor(message, code2, cause) {
175530
175883
  super(message);
175531
- this.code = code;
175884
+ this.code = code2;
175532
175885
  this.cause = cause;
175533
175886
  this.name = "BackendError";
175534
175887
  }