@kb-labs/rest-api-app 1.3.0 → 1.4.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 (257) hide show
  1. package/dist/index.d.ts +2 -0
  2. package/dist/index.js +8151 -0
  3. package/dist/index.js.map +1 -0
  4. package/package.json +7 -4
  5. package/.kb/agents/sessions/session-1771531145393-ws3uh6q/turns.json +0 -42
  6. package/.kb/agents/sessions/session-1771548930486-ui6rtvm/turns.json +0 -33
  7. package/.kb/agents/sessions/session-1771549691485-nibqroq/turns.json +0 -133
  8. package/.kb/agents/sessions/session-1771550943182-dkwqdjc/turns.json +0 -130
  9. package/.kb/agents/sessions/session-1771551564182-cr4bwzn/turns.json +0 -349
  10. package/.kb/agents/sessions/session-1771552401370-g4ztwd1/turns.json +0 -206
  11. package/.kb/commit/current/plan.json +0 -248
  12. package/.kb/commit/current/status.json +0 -472
  13. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/commands/health.d.ts +0 -10
  14. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/commands/health.js +0 -215
  15. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/commands/health.js.map +0 -1
  16. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/commands/list.d.ts +0 -10
  17. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/commands/list.js +0 -271
  18. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/commands/list.js.map +0 -1
  19. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/commands/logs.d.ts +0 -10
  20. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/commands/logs.js +0 -230
  21. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/commands/logs.js.map +0 -1
  22. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/commands/metrics.d.ts +0 -10
  23. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/commands/metrics.js +0 -228
  24. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/commands/metrics.js.map +0 -1
  25. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/commands/run.d.ts +0 -11
  26. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/commands/run.js +0 -281
  27. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/commands/run.js.map +0 -1
  28. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/commands/status.d.ts +0 -10
  29. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/commands/status.js +0 -266
  30. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/commands/status.js.map +0 -1
  31. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/commands/workflow-run.d.ts +0 -11
  32. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/commands/workflow-run.js +0 -284
  33. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/commands/workflow-run.js.map +0 -1
  34. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/flags-WLdpSZl4.d.ts +0 -77
  35. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/index.d.ts +0 -2
  36. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/index.js +0 -441
  37. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/index.js.map +0 -1
  38. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/manifest.d.ts +0 -196
  39. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/manifest.js +0 -441
  40. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/manifest.js.map +0 -1
  41. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/cron-list-handler.d.ts +0 -19
  42. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/cron-list-handler.js +0 -48
  43. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/cron-list-handler.js.map +0 -1
  44. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/index.d.ts +0 -6
  45. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/index.js +0 -170
  46. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/index.js.map +0 -1
  47. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/job-cancel-handler.d.ts +0 -12
  48. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/job-cancel-handler.js +0 -52
  49. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/job-cancel-handler.js.map +0 -1
  50. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/job-detail-handler.d.ts +0 -22
  51. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/job-detail-handler.js +0 -52
  52. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/job-detail-handler.js.map +0 -1
  53. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/job-logs-handler.d.ts +0 -13
  54. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/job-logs-handler.js +0 -52
  55. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/job-logs-handler.js.map +0 -1
  56. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/job-steps-handler.d.ts +0 -9
  57. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/job-steps-handler.js +0 -43
  58. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/job-steps-handler.js.map +0 -1
  59. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/jobs-list-handler.d.ts +0 -26
  60. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/jobs-list-handler.js +0 -63
  61. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/jobs-list-handler.js.map +0 -1
  62. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/pending-approvals-handler.d.ts +0 -9
  63. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/pending-approvals-handler.js +0 -46
  64. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/pending-approvals-handler.js.map +0 -1
  65. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/resolve-approval-handler.d.ts +0 -16
  66. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/resolve-approval-handler.js +0 -58
  67. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/resolve-approval-handler.js.map +0 -1
  68. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/run-detail-handler.d.ts +0 -9
  69. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/run-detail-handler.js +0 -46
  70. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/run-detail-handler.js.map +0 -1
  71. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/runs-list-handler.d.ts +0 -11
  72. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/runs-list-handler.js +0 -50
  73. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/runs-list-handler.js.map +0 -1
  74. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/stats-handler.d.ts +0 -7
  75. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/stats-handler.js +0 -39
  76. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/stats-handler.js.map +0 -1
  77. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/workflow-detail-handler.d.ts +0 -10
  78. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/workflow-detail-handler.js +0 -46
  79. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/workflow-detail-handler.js.map +0 -1
  80. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/workflow-run-cancel-handler.d.ts +0 -13
  81. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/workflow-run-cancel-handler.js +0 -47
  82. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/workflow-run-cancel-handler.js.map +0 -1
  83. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/workflow-run-handler.d.ts +0 -14
  84. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/workflow-run-handler.js +0 -53
  85. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/workflow-run-handler.js.map +0 -1
  86. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/workflow-runs-handler.d.ts +0 -13
  87. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/workflow-runs-handler.js +0 -54
  88. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/workflow-runs-handler.js.map +0 -1
  89. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/workflows-list-handler.d.ts +0 -12
  90. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/workflows-list-handler.js +0 -51
  91. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/workflows-list-handler.js.map +0 -1
  92. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/ws/logs-channel.d.ts +0 -17
  93. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/ws/logs-channel.js +0 -133
  94. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/ws/logs-channel.js.map +0 -1
  95. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/ws/progress-channel.d.ts +0 -11
  96. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/ws/progress-channel.js +0 -46
  97. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/ws/progress-channel.js.map +0 -1
  98. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/commands/health.d.ts +0 -10
  99. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/commands/health.js +0 -215
  100. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/commands/health.js.map +0 -1
  101. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/commands/list.d.ts +0 -10
  102. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/commands/list.js +0 -271
  103. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/commands/list.js.map +0 -1
  104. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/commands/logs.d.ts +0 -10
  105. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/commands/logs.js +0 -230
  106. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/commands/logs.js.map +0 -1
  107. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/commands/metrics.d.ts +0 -10
  108. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/commands/metrics.js +0 -228
  109. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/commands/metrics.js.map +0 -1
  110. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/commands/run.d.ts +0 -11
  111. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/commands/run.js +0 -281
  112. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/commands/run.js.map +0 -1
  113. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/commands/status.d.ts +0 -10
  114. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/commands/status.js +0 -266
  115. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/commands/status.js.map +0 -1
  116. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/commands/workflow-run.d.ts +0 -11
  117. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/commands/workflow-run.js +0 -284
  118. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/commands/workflow-run.js.map +0 -1
  119. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/flags-WLdpSZl4.d.ts +0 -77
  120. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/index.d.ts +0 -2
  121. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/index.js +0 -441
  122. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/index.js.map +0 -1
  123. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/manifest.d.ts +0 -196
  124. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/manifest.js +0 -441
  125. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/manifest.js.map +0 -1
  126. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/cron-list-handler.d.ts +0 -19
  127. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/cron-list-handler.js +0 -48
  128. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/cron-list-handler.js.map +0 -1
  129. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/index.d.ts +0 -6
  130. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/index.js +0 -170
  131. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/index.js.map +0 -1
  132. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/job-cancel-handler.d.ts +0 -12
  133. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/job-cancel-handler.js +0 -52
  134. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/job-cancel-handler.js.map +0 -1
  135. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/job-detail-handler.d.ts +0 -22
  136. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/job-detail-handler.js +0 -52
  137. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/job-detail-handler.js.map +0 -1
  138. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/job-logs-handler.d.ts +0 -13
  139. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/job-logs-handler.js +0 -52
  140. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/job-logs-handler.js.map +0 -1
  141. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/job-steps-handler.d.ts +0 -9
  142. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/job-steps-handler.js +0 -43
  143. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/job-steps-handler.js.map +0 -1
  144. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/jobs-list-handler.d.ts +0 -26
  145. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/jobs-list-handler.js +0 -63
  146. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/jobs-list-handler.js.map +0 -1
  147. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/pending-approvals-handler.d.ts +0 -9
  148. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/pending-approvals-handler.js +0 -46
  149. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/pending-approvals-handler.js.map +0 -1
  150. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/resolve-approval-handler.d.ts +0 -16
  151. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/resolve-approval-handler.js +0 -58
  152. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/resolve-approval-handler.js.map +0 -1
  153. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/run-detail-handler.d.ts +0 -9
  154. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/run-detail-handler.js +0 -46
  155. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/run-detail-handler.js.map +0 -1
  156. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/runs-list-handler.d.ts +0 -11
  157. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/runs-list-handler.js +0 -50
  158. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/runs-list-handler.js.map +0 -1
  159. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/stats-handler.d.ts +0 -7
  160. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/stats-handler.js +0 -39
  161. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/stats-handler.js.map +0 -1
  162. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/workflow-detail-handler.d.ts +0 -10
  163. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/workflow-detail-handler.js +0 -46
  164. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/workflow-detail-handler.js.map +0 -1
  165. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/workflow-run-cancel-handler.d.ts +0 -13
  166. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/workflow-run-cancel-handler.js +0 -47
  167. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/workflow-run-cancel-handler.js.map +0 -1
  168. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/workflow-run-handler.d.ts +0 -14
  169. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/workflow-run-handler.js +0 -53
  170. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/workflow-run-handler.js.map +0 -1
  171. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/workflow-runs-handler.d.ts +0 -13
  172. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/workflow-runs-handler.js +0 -54
  173. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/workflow-runs-handler.js.map +0 -1
  174. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/workflows-list-handler.d.ts +0 -12
  175. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/workflows-list-handler.js +0 -51
  176. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/workflows-list-handler.js.map +0 -1
  177. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/ws/logs-channel.d.ts +0 -17
  178. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/ws/logs-channel.js +0 -133
  179. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/ws/logs-channel.js.map +0 -1
  180. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/ws/progress-channel.d.ts +0 -11
  181. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/ws/progress-channel.js +0 -46
  182. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/ws/progress-channel.js.map +0 -1
  183. package/eslint.config.js +0 -23
  184. package/src/.kb/agents/sessions/session-1773470583796-ximqnfk/kpi-baseline.json +0 -17
  185. package/src/.kb/memory/sessions/session-1773470583796-ximqnfk/fact-sheet.json +0 -1
  186. package/src/bootstrap.ts +0 -233
  187. package/src/diagnostics/header-debug.ts +0 -37
  188. package/src/events/hub.ts +0 -60
  189. package/src/events/index.ts +0 -1
  190. package/src/index.ts +0 -13
  191. package/src/manifest.ts +0 -21
  192. package/src/middleware/__tests__/cache.spec.ts +0 -184
  193. package/src/middleware/__tests__/envelope.spec.ts +0 -268
  194. package/src/middleware/__tests__/metrics.redis.spec.ts +0 -64
  195. package/src/middleware/__tests__/rate-limit.spec.ts +0 -283
  196. package/src/middleware/__tests__/request-id.spec.ts +0 -160
  197. package/src/middleware/cache.ts +0 -67
  198. package/src/middleware/envelope.ts +0 -136
  199. package/src/middleware/error-guard.ts +0 -69
  200. package/src/middleware/index.ts +0 -37
  201. package/src/middleware/metrics.ts +0 -810
  202. package/src/middleware/mock-mode.ts +0 -44
  203. package/src/middleware/prom-metrics.ts +0 -284
  204. package/src/middleware/rate-limit-routes.ts +0 -73
  205. package/src/middleware/rate-limit.ts +0 -72
  206. package/src/middleware/request-id.ts +0 -41
  207. package/src/middleware/request-timeout.ts +0 -69
  208. package/src/middleware/security-headers.ts +0 -24
  209. package/src/middleware/startup-guard.ts +0 -107
  210. package/src/observability/service-contract.ts +0 -192
  211. package/src/plugins/index.ts +0 -118
  212. package/src/routes/__tests__/adapters-date-helpers.spec.ts +0 -332
  213. package/src/routes/__tests__/adapters.spec.ts +0 -680
  214. package/src/routes/__tests__/cache.spec.ts +0 -264
  215. package/src/routes/__tests__/events.spec.ts +0 -434
  216. package/src/routes/__tests__/health.spec.ts +0 -414
  217. package/src/routes/__tests__/logs.spec.ts +0 -494
  218. package/src/routes/__tests__/observability.spec.ts +0 -392
  219. package/src/routes/__tests__/plugins.spec.ts +0 -931
  220. package/src/routes/__tests__/workflow-management.spec.ts +0 -698
  221. package/src/routes/__tests__/workflows.spec.ts +0 -204
  222. package/src/routes/adapter-call.ts +0 -220
  223. package/src/routes/adapters.ts +0 -1206
  224. package/src/routes/analytics.ts +0 -328
  225. package/src/routes/cache.ts +0 -104
  226. package/src/routes/debug-routes.ts +0 -95
  227. package/src/routes/events.ts +0 -115
  228. package/src/routes/health.ts +0 -348
  229. package/src/routes/hello.ts +0 -47
  230. package/src/routes/index.ts +0 -395
  231. package/src/routes/jobs.ts +0 -253
  232. package/src/routes/logs.ts +0 -718
  233. package/src/routes/metrics.ts +0 -120
  234. package/src/routes/observability.ts +0 -1388
  235. package/src/routes/openapi.ts +0 -101
  236. package/src/routes/platform.ts +0 -143
  237. package/src/routes/plugins.ts +0 -998
  238. package/src/routes/readiness.ts +0 -83
  239. package/src/routes/workflow-management.ts +0 -469
  240. package/src/routes/workflows.ts +0 -256
  241. package/src/server.ts +0 -203
  242. package/src/services/historical-metrics.ts +0 -496
  243. package/src/services/incident-analyzer.ts +0 -289
  244. package/src/services/incident-detector.ts +0 -691
  245. package/src/services/incident-schema.sql +0 -76
  246. package/src/services/incident-storage.ts +0 -593
  247. package/src/services/system-metrics-collector.ts +0 -244
  248. package/src/types/fastify.d.ts +0 -58
  249. package/src/utils/__tests__/sse-auth.spec.ts +0 -113
  250. package/src/utils/path-helpers.ts +0 -15
  251. package/src/utils/repo.ts +0 -42
  252. package/src/utils/schema.ts +0 -20
  253. package/src/utils/sse-auth.ts +0 -81
  254. package/test-sandbox.sh +0 -105
  255. package/tsconfig.build.json +0 -15
  256. package/tsconfig.json +0 -9
  257. package/tsup.config.ts +0 -18
@@ -1,206 +0,0 @@
1
- [
2
- {
3
- "id": "turn-agent-1771552401376-u17w0",
4
- "type": "assistant",
5
- "sequence": 1,
6
- "startedAt": "2026-02-20T01:53:22.471Z",
7
- "completedAt": "2026-02-20T01:53:42.537Z",
8
- "status": "completed",
9
- "steps": [
10
- {
11
- "type": "tool_use",
12
- "id": "step-1",
13
- "timestamp": "2026-02-20T01:53:23.694Z",
14
- "toolName": "grep_search",
15
- "input": {
16
- "pattern": "agent",
17
- "directory": "src",
18
- "filePattern": "*.ts"
19
- },
20
- "status": "done",
21
- "output": "Directory \"src\" not found (resolved to /Users/kirillbaranov/Desktop/kb-labs/kb-labs-agents/src). Use \".\" to search from project root.\nAvailable directories: docs, packages, scripts",
22
- "durationMs": 3
23
- },
24
- {
25
- "type": "tool_use",
26
- "id": "step-2",
27
- "timestamp": "2026-02-20T01:53:24.925Z",
28
- "toolName": "grep_search",
29
- "input": {
30
- "pattern": "agent",
31
- "directory": "packages",
32
- "filePattern": "*.ts"
33
- },
34
- "status": "done",
35
- "output": "Found 100 match(es) for \"agent\":\n\n packages/agent-task-runner/tsup.config.ts:12\n '@kb-labs/agent-core',\n packages/agent-task-runner/tsup.config.ts:13\n '@kb-labs/agent-contracts',\n packages/agent-task-runner/tsup.config.ts:14\n '@kb-labs/agent-tools',\n packages/agent-task-runner/src/executor.ts:7\n import { Agent } from '@kb-labs/agent-core';\n packages/agent-task-runner/src/executor.ts:8\n import type { AgentConfig } from '@kb-labs/agent-contracts';\n packages/agent-task-runner/src/executor.ts:9\n import type { ToolRegistry } from '@kb-labs/agent-tools';\n packages/agent-task-runner/src/executor.ts:14\n * Working directory for agent execution\n packages/agent-task-runner/src/executor.ts:53\n // Build task description for agent\n packages/agent-task-runner/src/executor.ts:56\n // Create agent config\n packages/agent-task-runner/src/executor.ts:57\n const agentConfig: AgentConfig = {\n packages/agent-task-runner/src/executor.ts:63\n agentId: `step-${step.stepNumber}-executor`,\n packages/agent-task-runner/src/executor.ts:66\n // Execute step with agent\n packages/agent-task-runner/src/executor.ts:67\n const agent = new Agent(agentConfig, this.config.toolRegistry);\n packages/agent-task-runner/src/executor.ts:68\n const result = await agent.execute(task);\n packages/agent-task-runner/src/executor.ts:72\n // Map agent result to step result\n packages/agent-task-runner/src/executor.ts:104\n * Build task description for agent from plan step\n packages/agent-task-runner/src/executor.ts:153\n * Determine step status from agent result\n packages/agent-task-runner/src/executor.ts:182\n * Extract files affected from agent result\n packages/agent-task-runner/src/executor.ts:207\n * Extract tool calls from agent result\n packages/agent-task-runner/src/executor.ts:232\n * Estimate cost from agent result\n packages/agent-task-runner/src/executor.ts:258\n * Extract errors from agent result\n packages/agent-task-runner/src/executor.ts:285\n * Extract warnings from agent result\n packages/agent-task-runner/src/task-runner.ts:7\n import type { ToolRegistry } from '@kb-labs/agent-tools';\n packages/agent-task-runner/src/task-runner.ts:17\n * Working directory for agent execution\n packages/agent-task-runner/src/task-runner.ts:22\n * Tool registry for agent execution\n packages/agent-task-runner/src/planner.ts:114\n **Remember:** You're planning for an AI agent with tools (file ops, search, LLM). The agent is smart but needs clear direction.`;\n packages/agent-tools/src/tools/reporting.ts:2\n * Reporting tools - for sub-agents to communicate with parent agent\n packages/agent-tools/src/tools/reporting.ts:8\n * Ask parent agent for help when stuck or uncertain.\n packages/agent-tools/src/tools/reporting.ts:9\n * Sub-agents use this to escalate to the main agent for guidance.\n packages/agent-tools/src/tools/reporting.ts:17\n description: `Ask the parent agent for help when stuck or need clarification.`,\n packages/agent-tools/src/tools/reporting.ts:23\n description: 'Your question for the parent agent. Be specific about what you need help with.',\n packages/agent-tools/src/tools/reporting.ts:46\n output: '', // Will be populated by parent agent\n packages/agent-tools/src/tools/reporting.ts:59\n * Report findings and exit. Used by agents to provide synthesized answer\n packages/agent-tools/src/tools/reporting.ts:91\n output: '', // Intentionally empty - agent should exit after calling this\n packages/agent-tools/src/tools/reporting.ts:103\n * Reflection tool - agent reflects on progress and decides whether to continue.\n packages/agent-tools/src/tools/reporting.ts:158\n // Anti-hallucination check: If agent claims completion without evidence, reduce confidence\n packages/agent-tools/src/tools/delegation.ts:2\n * Delegation tools — spawn sub-agents for subtask execution\n packages/agent-tools/src/tools/delegation.ts:8\n * Spawn a sub-agent to handle a subtask.\n packages/agent-tools/src/tools/delegation.ts:9\n * Sub-agents have all tools except spawn_agent (no recursion).\n packages/agent-tools/src/tools/delegation.ts:10\n * The parent agent waits for the result synchronously.\n packages/agent-tools/src/tools/delegation.ts:17\n name: 'spawn_agent',\n packages/agent-tools/src/tools/delegation.ts:18\n description: 'Spawn a sub-agent to handle a subtask. The sub-agent works independently and returns its result. Use for: research (\"investigate how X works\"), fixes (\"fix lint errors in module Y\"), or isolated tasks (\"run tests and fix failures\"). You wait for the result.',\n packages/agent-tools/src/tools/delegation.ts:24\n description: 'Clear task description for the sub-agent. Be specific — the sub-agent has no context about your current work.',\n packages/agent-tools/src/tools/delegation.ts:28\n description: 'Max iterations for the sub-agent (default: 10). Use 5 for simple lookups, 10-15 for research/fixes.',\n packages/agent-tools/src/tools/delegation.ts:32\n description: 'Working directory for the sub-agent, relative to project root (e.g. \"kb-labs-agents/packages/agent-tools\"). Default: same as parent.',\n packages/agent-tools/src/tools/delegation.ts:43\n error: 'Sub-agent spawning not available. This agent cannot delegate tasks.',\n packages/agent-tools/src/tools/delegation.ts:58\n const header = result.success ? 'Sub-agent completed successfully' : 'Sub-agent failed';\n packages/agent-tools/src/tools/delegation.ts:66\n error: `Sub-agent execution failed: ${error instanceof Error ? error.message : String(error)}`,\n packages/agent-tools/src/tools/todo.ts:6\n import type { TodoList, TodoItem } from '@kb-labs/agent-contracts';\n packages/agent-tools/src/tools/mass-replace.ts:84\n description: 'REQUIRED: Directory to limit search scope (e.g., \"src\", \"packages/agent-core\", \".\"). Prevents accidental project-wide changes. Use \".\" for current directory only.',\n packages/agent-tools/src/tools/mass-replace.ts:129\n error: 'VALIDATION_ERROR: \"scope\" is required. Specify directory to limit search (e.g., \"src\", \"packages/agent-core\", or \".\" for current dir).',\n packages/agent-tools/src/tools/mass-replace.ts:341\n ? '\\n\\n✅ All changes tracked in file history. Use agent:history and agent:rollback to undo if needed.'\n packages/agent-tools/src/tools/__tests__/search.test.ts:54\n const result = await tool.executor({ pattern: '*.ts', directory: 'agent-tools' });\n packages/agent-tools/src/tools/__tests__/search.test.ts:57\n expect(result.output).toContain('Directory \"agent-tools\" not found');\n packages/agent-tools/src/tools/__tests__/search.test.ts:96\n const result = await tool.executor({ pattern: '*.ts', directory: 'agent-tools' });\n packages/agent-tools/src/tools/__tests__/search.test.ts:98\n expect(result.output).toContain('/root/agent-tools');\n packages/agent-tools/src/tools/filesystem.ts:2\n * Filesystem tools for agent operations\n packages/agent-tools/src/tools/filesystem.ts:7\n * - Clear error messages for agent understanding\n packages/agent-tools/src/tools/memory.ts:11\n * - findings: agent discoveries\n packages/agent-tools/src/tools/memory.ts:18\n import type { MemoryEntry, SessionEntry } from '@kb-labs/agent-contracts';\n packages/agent-tools/src/tools/memory.ts:442\n source: 'agent',\n packages/agent-tools/src/tools/memory.ts:496\n category: 'agent_state',\n packages/agent-tools/src/tools/memory.ts:501\n source: 'agent',\n packages/agent-tools/src/tools/index.ts:54\n // Reporting tools (sub-agent ↔ parent communication)\n packages/agent-tools/src/tools/index.ts:101\n // Register reporting tools (sub-agent ↔ parent communication)\n packages/agent-tools/src/tools/index.ts:105\n // Register delegation tools (only for main agent — sub-agents don't get spawn_agent)\n packages/agent-tools/src/types.ts:5\n import type { ToolDefinition, ToolResult } from '@kb-labs/agent-contracts';\n packages/agent-tools/src/types.ts:21\n * Interface for file change tracking (matches FileChangeTracker from agent-core).\n packages/agent-tools/src/types.ts:22\n * Defined here to avoid circular dependency: agent-tools cannot import agent-core.\n packages/agent-tools/src/types.ts:48\n agentId?: string;\n packages/agent-tools/src/types.ts:49\n /** Spawn sub-agent callback (injected by Agent, not available for sub-agents) */\n packages/agent-tools/src/index.ts:2\n * @kb-labs/agent-tools\n packages/agent-tools/src/index.ts:4\n * Tool implementations for agents (filesystem, shell, search, etc.)\n packages/agent-contracts/src/routes.ts:2\n * REST API & WebSocket route constants for agents plugin\n packages/agent-contracts/src/routes.ts:6\n * Base path for agents REST API routes\n packages/agent-contracts/src/routes.ts:8\n export const AGENTS_BASE_PATH = '/v1/plugins/agents' as const;\n packages/agent-contracts/src/routes.ts:11\n * Base path for agents WebSocket channels\n packages/agent-contracts/src/routes.ts:13\n export const AGENTS_WS_BASE_PATH = '/v1/ws/plugins/agents' as const;\n packages/agent-contracts/src/routes.ts:19\n /** GET - List all available agents */\n packages/agent-contracts/src/routes.ts:22\n /** POST /run - Start a new agent run */\n packages/agent-contracts/src/routes.ts:28\n /** POST /run/:runId/correct - Send user correction to running agent */\n packages/agent-contracts/src/routes.ts:31\n /** POST /run/:runId/stop - Stop running agent */\n packages/agent-contracts/src/ws-messages.ts:2\n * WebSocket message types for agent event streaming\n packages/agent-contracts/src/ws-messages.ts:27\n * Sent when the agent run finishes\n packages/agent-contracts/src/ws-messages.ts:128\n /** Optional: target specific agent (otherwise orchestrator decides) */\n packages/agent-contracts/src/ws-messages.ts:175\n agentId?: string;\n packages/agent-contracts/src/ws-messages.ts:210\n /** Optional: target specific agent */\n packages/agent-contracts/src/ws-messages.ts:268\n /** Active agents (if running) */\n packages/agent-contracts/src/ws-messages.ts:281\n * Agent specification (for listing available agents)\n packages/agent-contracts/src/ws-messages.ts:284\n /** Unique agent identifier */\n packages/agent-contracts/src/ws-messages.ts:288\n /** Description of agent capabilities */\n packages/agent-contracts/src/ws-messages.ts:290\n /** List of tools available to this agent */\n packages/agent-contracts/src/ws-messages.ts:297\n * Response for GET /agents\n packages/agent-contracts/src/ws-messages.ts:300\n /** Available agents */\n packages/agent-contracts/src/ws-messages.ts:301\n agents: AgentSpecification[];\n packages/agent-contracts/src/detailed-trace-types.ts:2\n * Detailed trace event types for incremental agent tracing\n packages/agent-contracts/src/detailed-trace-types.ts:4\n * This file defines 12 trace event types for comprehensive agent debugging:\n packages/agent-contracts/src/detailed-trace-types.ts:276\n agentStack: {\n packages/agent-contracts/src/detailed-trace-types.ts:413\n reasoning: string; // Why agent is stopping/continuing\n packages/agent-contracts/src/analytics.ts:2\n * Analytics event constants for agent system",
36
- "durationMs": 42
37
- },
38
- {
39
- "type": "tool_use",
40
- "id": "step-3",
41
- "timestamp": "2026-02-20T01:53:27.177Z",
42
- "toolName": "fs_read",
43
- "input": {
44
- "path": "packages/agent-task-runner/src/executor.ts",
45
- "limit": 100
46
- },
47
- "status": "done",
48
- "output": "File: packages/agent-task-runner/src/executor.ts\nLines: 1-100 of 319\n(219 more lines after this)\n⚠️ File has 219 more lines after this section\n💡 To read more: fs_read(path=\"packages/agent-task-runner/src/executor.ts\", offset=101, limit=1000)\n💡 Or request specific sections based on what you need\n────────────────────────────────────────────────────────────\n 1→/**\n 2→ * Phase 3: Universal Task Runner - Executor\n 3→ *\n 4→ * Uses Sonnet (medium tier) to execute a single step from the plan\n 5→ */\n 6→\n 7→import { Agent } from '@kb-labs/agent-core';\n 8→import type { AgentConfig } from '@kb-labs/agent-contracts';\n 9→import type { ToolRegistry } from '@kb-labs/agent-tools';\n 10→import type { PlanStep, StepResult, TaskCheckpoint } from './types.js';\n 11→\n 12→export interface ExecutorConfig {\n 13→ /**\n 14→ * Working directory for agent execution\n 15→ */\n 16→ workingDir: string;\n 17→\n 18→ /**\n 19→ * Max iterations per step\n 20→ */\n 21→ maxIterations?: number;\n 22→\n 23→ /**\n 24→ * Tool registry\n 25→ */\n 26→ toolRegistry: ToolRegistry;\n 27→\n 28→ /**\n 29→ * Verbose logging\n 30→ */\n 31→ verbose?: boolean;\n 32→}\n 33→\n 34→export class Executor {\n 35→ private config: ExecutorConfig;\n 36→\n 37→ constructor(config: ExecutorConfig) {\n 38→ this.config = {\n 39→ ...config,\n 40→ maxIterations: config.maxIterations ?? 10,\n 41→ };\n 42→ }\n 43→\n 44→ /**\n 45→ * Execute a single plan step\n 46→ */\n 47→ async executeStep(step: PlanStep, checkpoint: TaskCheckpoint): Promise<StepResult> {\n 48→ this.log(`\\n🔨 Executing Step ${step.stepNumber}: ${step.description}`);\n 49→\n 50→ const startTime = Date.now();\n 51→\n 52→ try {\n 53→ // Build task description for agent\n 54→ const task = this.buildTaskDescription(step, checkpoint);\n 55→\n 56→ // Create agent config\n 57→ const agentConfig: AgentConfig = {\n 58→ workingDir: this.config.workingDir,\n 59→ maxIterations: this.config.maxIterations!,\n 60→ temperature: 0.1, // Focused, deterministic execution\n 61→ tier: 'medium', // Sonnet for execution\n 62→ verbose: this.config.verbose ?? false,\n 63→ agentId: `step-${step.stepNumber}-executor`,\n 64→ };\n 65→\n 66→ // Execute step with agent\n 67→ const agent = new Agent(agentConfig, this.config.toolRegistry);\n 68→ const result = await agent.execute(task);\n 69→\n 70→ const durationMs = Date.now() - startTime;\n 71→\n 72→ // Map agent result to step result\n 73→ const stepResult: StepResult = {\n 74→ stepNumber: step.stepNumber,\n 75→ status: this.determineStatus(result, step),\n 76→ output: result.summary, // Use summary from TaskResult\n 77→ filesAffected: this.extractFilesAffected(result),\n 78→ toolCalls: this.extractToolCalls(result),\n 79→ durationMs,\n 80→ costUsd: this.estimateCost(result),\n 81→ errors: this.extractErrors(result),\n 82→ warnings: this.extractWarnings(result),\n 83→ };\n 84→\n 85→ this.log(`✅ Step ${step.stepNumber} completed in ${durationMs}ms (${stepResult.status})`);\n 86→\n 87→ return stepResult;\n 88→ } catch (error) {\n 89→ const durationMs = Date.now() - startTime;\n 90→\n 91→ this.log(`❌ Step ${step.stepNumber} failed: ${error instanceof Error ? error.message : String(error)}`);\n 92→\n 93→ return {\n 94→ stepNumber: step.stepNumber,\n 95→ status: 'failed',\n 96→ output: '',\n 97→ durationMs,\n 98→ errors: [error instanceof Error ? error.message : String(error)],\n 99→ };\n 100→ }",
49
- "durationMs": 1
50
- },
51
- {
52
- "type": "tool_use",
53
- "id": "step-4",
54
- "timestamp": "2026-02-20T01:53:27.178Z",
55
- "toolName": "fs_read",
56
- "input": {
57
- "path": "packages/agent-tools/src/tools/delegation.ts",
58
- "limit": 100
59
- },
60
- "status": "done",
61
- "output": "File: packages/agent-tools/src/tools/delegation.ts\nLines: 1-72 of 72\n(end of file)\n────────────────────────────────────────────────────────────\n 1→/**\n 2→ * Delegation tools — spawn sub-agents for subtask execution\n 3→ */\n 4→\n 5→import type { Tool, ToolContext } from '../types.js';\n 6→\n 7→/**\n 8→ * Spawn a sub-agent to handle a subtask.\n 9→ * Sub-agents have all tools except spawn_agent (no recursion).\n 10→ * The parent agent waits for the result synchronously.\n 11→ */\n 12→export function createSpawnAgentTool(context: ToolContext): Tool {\n 13→ return {\n 14→ definition: {\n 15→ type: 'function' as const,\n 16→ function: {\n 17→ name: 'spawn_agent',\n 18→ description: 'Spawn a sub-agent to handle a subtask. The sub-agent works independently and returns its result. Use for: research (\"investigate how X works\"), fixes (\"fix lint errors in module Y\"), or isolated tasks (\"run tests and fix failures\"). You wait for the result.',\n 19→ parameters: {\n 20→ type: 'object' as const,\n 21→ properties: {\n 22→ task: {\n 23→ type: 'string' as const,\n 24→ description: 'Clear task description for the sub-agent. Be specific — the sub-agent has no context about your current work.',\n 25→ },\n 26→ maxIterations: {\n 27→ type: 'number' as const,\n 28→ description: 'Max iterations for the sub-agent (default: 10). Use 5 for simple lookups, 10-15 for research/fixes.',\n 29→ },\n 30→ directory: {\n 31→ type: 'string' as const,\n 32→ description: 'Working directory for the sub-agent, relative to project root (e.g. \"kb-labs-agents/packages/agent-tools\"). Default: same as parent.',\n 33→ },\n 34→ },\n 35→ required: ['task'],\n 36→ },\n 37→ },\n 38→ },\n 39→ executor: async (input: Record<string, unknown>) => {\n 40→ if (!context.spawnAgent) {\n 41→ return {\n 42→ success: false,\n 43→ error: 'Sub-agent spawning not available. This agent cannot delegate tasks.',\n 44→ };\n 45→ }\n 46→\n 47→ const task = input.task as string;\n 48→ const maxIterations = (input.maxIterations as number) || 10;\n 49→ const directory = input.directory as string | undefined;\n 50→\n 51→ try {\n 52→ const result = await context.spawnAgent({\n 53→ task,\n 54→ maxIterations,\n 55→ workingDir: directory,\n 56→ });\n 57→\n 58→ const header = result.success ? 'Sub-agent completed successfully' : 'Sub-agent failed';\n 59→ return {\n 60→ success: true,\n 61→ output: `${header} (${result.iterations} iterations, ${result.tokensUsed} tokens):\\n\\n${result.result}`,\n 62→ };\n 63→ } catch (error) {\n 64→ return {\n 65→ success: false,\n 66→ error: `Sub-agent execution failed: ${error instanceof Error ? error.message : String(error)}`,\n 67→ };\n 68→ }\n 69→ },\n 70→ };\n 71→}\n 72→",
62
- "durationMs": 0
63
- },
64
- {
65
- "type": "tool_use",
66
- "id": "step-5",
67
- "timestamp": "2026-02-20T01:53:27.178Z",
68
- "toolName": "fs_read",
69
- "input": {
70
- "path": "packages/agent-tools/src/tools/reporting.ts",
71
- "limit": 100
72
- },
73
- "status": "done",
74
- "output": "File: packages/agent-tools/src/tools/reporting.ts\nLines: 1-100 of 190\n(90 more lines after this)\n────────────────────────────────────────────────────────────\n 1→/**\n 2→ * Reporting tools - for sub-agents to communicate with parent agent\n 3→ */\n 4→\n 5→import type { Tool, ToolContext } from '../types.js';\n 6→\n 7→/**\n 8→ * Ask parent agent for help when stuck or uncertain.\n 9→ * Sub-agents use this to escalate to the main agent for guidance.\n 10→ */\n 11→export function createAskParentTool(_context: ToolContext): Tool {\n 12→ return {\n 13→ definition: {\n 14→ type: 'function' as const,\n 15→ function: {\n 16→ name: 'ask_parent',\n 17→ description: `Ask the parent agent for help when stuck or need clarification.`,\n 18→ parameters: {\n 19→ type: 'object' as const,\n 20→ properties: {\n 21→ question: {\n 22→ type: 'string' as const,\n 23→ description: 'Your question for the parent agent. Be specific about what you need help with.',\n 24→ },\n 25→ reason: {\n 26→ type: 'string' as const,\n 27→ enum: ['stuck', 'uncertain', 'blocker', 'clarification'],\n 28→ description: 'Why are you asking? stuck=repeating tools, uncertain=unclear approach, blocker=cannot proceed, clarification=need more info',\n 29→ },\n 30→ context: {\n 31→ type: 'object' as const,\n 32→ description: 'Relevant context: tools tried, iteration number, what you attempted',\n 33→ },\n 34→ },\n 35→ required: ['question', 'reason'],\n 36→ },\n 37→ },\n 38→ },\n 39→ executor: async (input: Record<string, unknown>) => {\n 40→ const question = input.question as string;\n 41→ const reason = input.reason as string;\n 42→ const context = input.context as Record<string, unknown> | undefined;\n 43→\n 44→ return {\n 45→ success: true,\n 46→ output: '', // Will be populated by parent agent\n 47→ metadata: {\n 48→ question,\n 49→ reason,\n 50→ context,\n 51→ needsParentHelp: true,\n 52→ },\n 53→ };\n 54→ },\n 55→ };\n 56→}\n 57→\n 58→/**\n 59→ * Report findings and exit. Used by agents to provide synthesized answer\n 60→ * and signal early exit when task is complete.\n 61→ */\n 62→export function createReportTool(_context: ToolContext): Tool {\n 63→ return {\n 64→ definition: {\n 65→ type: 'function' as const,\n 66→ function: {\n 67→ name: 'report',\n 68→ description: `Report your answer and exit. Include specific findings with file paths and code snippets as evidence.`,\n 69→ parameters: {\n 70→ type: 'object' as const,\n 71→ properties: {\n 72→ answer: {\n 73→ type: 'string' as const,\n 74→ description: 'Synthesized answer with specific details, file references, and code snippets. Be concise but complete.',\n 75→ },\n 76→ confidence: {\n 77→ type: 'number' as const,\n 78→ description: 'How confident you are in this answer (0.0-1.0). Use 0.8+ if you found concrete evidence, 0.5-0.7 if partial, <0.5 if uncertain.',\n 79→ },\n 80→ },\n 81→ required: ['answer', 'confidence'],\n 82→ },\n 83→ },\n 84→ },\n 85→ executor: async (input: Record<string, unknown>) => {\n 86→ const answer = input.answer as string;\n 87→ const confidence = input.confidence as number;\n 88→\n 89→ return {\n 90→ success: true,\n 91→ output: '', // Intentionally empty - agent should exit after calling this\n 92→ metadata: {\n 93→ answer,\n 94→ confidence,\n 95→ earlyExit: true,\n 96→ },\n 97→ };\n 98→ },\n 99→ };\n 100→}",
75
- "durationMs": 1
76
- },
77
- {
78
- "type": "text",
79
- "id": "step-6",
80
- "timestamp": "2026-02-20T01:53:39.887Z",
81
- "content": "### Как работают агенты в KB Labs\n\nАгенты в KB Labs представляют собой программные компоненты, которые выполняют задачи, используя различные инструменты и методы. Основные аспекты их работы включают:\n\n1. **Структура и конфигурация**:\n - Агенты используют конфигурацию, которая включает рабочую директорию, максимальное количество итераций и реестр инструментов. Например, в файле `executor.ts` определен класс `Executor`, который управляет выполнением шагов плана с помощью агента.\n - Конфигурация агента включает параметры, такие как `temperature` (для управления случайностью выполнения) и `tier` (уровень сложности выполнения).\n\n2. **Выполнение задач**:\n - Агенты могут выполнять шаги плана, создавая описание задачи и используя метод `execute` для выполнения этой задачи. Результаты выполнения включают статус, вывод, затраченное время и другую информацию о выполнении.\n\n3. **Делегирование задач**:\n - Агенты могут создавать подагентов для выполнения подзадач. Это реализовано через функцию `createSpawnAgentTool`, которая позволяет родительскому агенту делегировать задачи подагентам. Подагенты могут выполнять задачи независимо и возвращать результаты родительскому агенту.\n\n4. **Коммуникация и отчетность**:\n - Агенты могут запрашивать помощь у родительского агента, если они сталкиваются с трудностями. Это реализовано через функцию `createAskParentTool`, которая позволяет подагентам сообщать о необходимости помощи.\n - Агенты также могут сообщать о своих находках и завершать выполнение задач с помощью функции `createReportTool`.\n\n### Примеры кода\n\n- **Executor**:\n ```typescript\n const agentConfig: AgentConfig = {\n workingDir: this.config.workingDir,\n maxIterations: this.config.maxIterations!,\n temperature: 0.1,\n tier: 'medium',\n verbose: this.config.verbose ?? false,\n agentId: `step-${step.stepNumber}-executor`,\n };\n const agent = new Agent(agentConfig, this.config.toolRegistry);\n const result = await agent.execute(task);\n ```\n\n- **Делегирование**:\n ```typescript\n export function createSpawnAgentTool(context: ToolContext): Tool {\n return {\n definition: {\n type: 'function',\n function: {\n name: 'spawn_agent',\n description: 'Spawn a sub-agent to handle a subtask.',\n parameters: {\n type: 'object',\n properties: {\n task: { type: 'string' },\n maxIterations: { type: 'number' },\n directory: { type: 'string' },\n },\n required: ['task'],\n },\n },\n },\n executor: async (input: Record<string, unknown>) => {\n // Логика выполнения подагента\n },\n };\n }\n ```\n\n### Заключение\n\nАгенты в KB Labs являются мощным инструментом для автоматизации выполнения задач, делегирования подзадач и взаимодействия между компонентами. Они используют гибкую архитектуру, позволяющую эффективно управлять процессами и обеспечивать высокую степень автоматизации.",
82
- "role": "assistant"
83
- }
84
- ],
85
- "metadata": {
86
- "agentId": "agent-1771552401376-u17w0"
87
- }
88
- },
89
- {
90
- "id": "turn-agent-1771552454972-du6fi",
91
- "type": "assistant",
92
- "sequence": 1,
93
- "startedAt": "2026-02-20T01:54:16.021Z",
94
- "completedAt": "2026-02-20T01:54:43.366Z",
95
- "status": "completed",
96
- "steps": [
97
- {
98
- "type": "tool_use",
99
- "id": "step-1",
100
- "timestamp": "2026-02-20T01:54:17.862Z",
101
- "toolName": "fs_read",
102
- "input": {
103
- "path": "packages/agent-core/src/executor.ts",
104
- "limit": 100
105
- },
106
- "status": "done",
107
- "durationMs": 2
108
- },
109
- {
110
- "type": "tool_use",
111
- "id": "step-2",
112
- "timestamp": "2026-02-20T01:54:19.027Z",
113
- "toolName": "fs_list",
114
- "input": {
115
- "path": "packages/agent-core/src"
116
- },
117
- "status": "done",
118
- "durationMs": 1
119
- },
120
- {
121
- "type": "tool_use",
122
- "id": "step-3",
123
- "timestamp": "2026-02-20T01:54:21.347Z",
124
- "toolName": "fs_list",
125
- "input": {
126
- "path": "packages"
127
- },
128
- "status": "done",
129
- "durationMs": 0
130
- },
131
- {
132
- "type": "tool_use",
133
- "id": "step-4",
134
- "timestamp": "2026-02-20T01:54:23.702Z",
135
- "toolName": "fs_list",
136
- "input": {
137
- "path": "kb-labs-mind/packages"
138
- },
139
- "status": "done",
140
- "output": "📁 kb-labs-mind/packages\n\nDirectories (11):\n 📁 mind-adapters/\n 📁 mind-cli/\n 📁 mind-contracts/\n 📁 mind-core/\n 📁 mind-embeddings/\n 📁 mind-engine/\n 📁 mind-gateway/\n 📁 mind-indexer/\n 📁 mind-orchestrator/\n 📁 mind-types/\n 📁 mind-vector-store/\n",
141
- "durationMs": 1
142
- },
143
- {
144
- "type": "tool_use",
145
- "id": "step-5",
146
- "timestamp": "2026-02-20T01:54:25.028Z",
147
- "toolName": "fs_list",
148
- "input": {
149
- "path": "kb-labs-mind/packages/mind-engine"
150
- },
151
- "status": "done",
152
- "output": "📁 kb-labs-mind/packages/mind-engine\n\nDirectories (5):\n 📁 benchmarks/\n 📁 dist/\n 📁 docs/\n 📁 scripts/\n 📁 src/\n\nFiles (10):\n 📄 BENCHMARKS.md (5.4 KB)\n 📄 README.md (8.2 KB)\n 📄 eslint.config.js (829 bytes)\n 📄 package.json (2.4 KB)\n 📄 tsconfig.build.json (216 bytes)\n 📄 tsconfig.json (201 bytes)\n 📄 tsup.config.bundled_w0fjnqydpn.mjs (1.8 KB)\n 📄 tsup.config.bundled_wu382ygg09.mjs (1.8 KB)\n 📄 tsup.config.ts (354 bytes)\n 📄 vitest.config.ts (509 bytes)",
153
- "durationMs": 0
154
- },
155
- {
156
- "type": "tool_use",
157
- "id": "step-6",
158
- "timestamp": "2026-02-20T01:54:26.234Z",
159
- "toolName": "fs_list",
160
- "input": {
161
- "path": "kb-labs-mind/packages/mind-engine/src"
162
- },
163
- "status": "done",
164
- "output": "📁 kb-labs-mind/packages/mind-engine/src\n\nDirectories (23):\n 📁 __tests__/\n 📁 adapters/\n 📁 chunking/\n 📁 compression/\n 📁 context/\n 📁 deduplication/\n 📁 filtering/\n 📁 index/\n 📁 indexing/\n 📁 learning/\n 📁 optimization/\n 📁 output/\n 📁 parsers/\n 📁 platform/\n 📁 query/\n 📁 rate-limiting/\n 📁 reasoning/\n 📁 reranking/\n 📁 search/\n 📁 snippets/\n 📁 sync/\n 📁 utils/\n 📁 vector-store/\n\nFiles (1):\n 📄 index.ts (88.3 KB)",
165
- "durationMs": 0
166
- },
167
- {
168
- "type": "tool_use",
169
- "id": "step-7",
170
- "timestamp": "2026-02-20T01:54:27.692Z",
171
- "toolName": "fs_read",
172
- "input": {
173
- "path": "kb-labs-mind/packages/mind-engine/src/index.ts",
174
- "limit": 100
175
- },
176
- "status": "done",
177
- "output": "File: kb-labs-mind/packages/mind-engine/src/index.ts\nLines: 1-100 of 2753\n(2653 more lines after this)\n⚠️ File has 2653 more lines after this section\n💡 To read more: fs_read(path=\"kb-labs-mind/packages/mind-engine/src/index.ts\", offset=101, limit=1000)\n💡 Or request specific sections based on what you need\n────────────────────────────────────────────────────────────\n 1→// TODO: docs/tasks/TASK-003-mind-engine-index-splitting.md\n 2→// This file is 2,350 lines (10x max recommended). Split into focused modules.\n 3→import {\n 4→ usePlatform,\n 5→ useLogger,\n 6→ useLLM,\n 7→ useEmbeddings,\n 8→ MemoryHistoryStore,\n 9→ MemoryFeedbackStore,\n 10→ FileHistoryStore,\n 11→ FileFeedbackStore,\n 12→ createKnowledgeError,\n 13→ type ILLM,\n 14→ type KnowledgeChunk,\n 15→ type KnowledgeEngineConfig,\n 16→ type KnowledgeQuery,\n 17→ type KnowledgeResult,\n 18→ type KnowledgeSource,\n 19→ type SpanRange,\n 20→ type KnowledgeEngine,\n 21→ type KnowledgeEngineFactory,\n 22→ type KnowledgeEngineFactoryContext,\n 23→ type KnowledgeEngineRegistry,\n 24→ type KnowledgeExecutionContext,\n 25→ type KnowledgeIndexOptions,\n 26→ type IndexingStats,\n 27→} from '@kb-labs/sdk';\n 28→import * as path from 'node:path';\n 29→import fs from 'fs-extra';\n 30→import fg from 'fast-glob';\n 31→import picomatch from 'picomatch';\n 32→import { createHash } from 'node:crypto';\n 33→import { randomUUID } from 'node:crypto';\n 34→import { getChunkerForFile, type Chunk } from './chunking/index';\n 35→\n 36→// Use SDK logger (lazy initialization)\n 37→const getEngineLogger = () => useLogger().child({ category: 'mind:engine' });\n 38→const logger = {\n 39→ debug: (msg: string, meta?: Record<string, unknown>) => getEngineLogger().debug(msg, meta),\n 40→ info: (msg: string, meta?: Record<string, unknown>) => getEngineLogger().info(msg, meta),\n 41→ warn: (msg: string, meta?: Record<string, unknown>) => getEngineLogger().warn(msg, meta),\n 42→ error: (msg: string, errorOrMeta?: Error | Record<string, unknown>, meta?: Record<string, unknown>) => {\n 43→ if (errorOrMeta instanceof Error) {\n 44→ getEngineLogger().error(msg, errorOrMeta, meta);\n 45→ } else {\n 46→ getEngineLogger().error(msg, undefined, errorOrMeta);\n 47→ }\n 48→ },\n 49→};\n 50→import {\n 51→ type EmbeddingProvider,\n 52→ type EmbeddingProviderConfig,\n 53→} from '@kb-labs/mind-embeddings';\n 54→import type { VectorSearchFilters, VectorSearchMatch } from '@kb-labs/mind-vector-store';\n 55→import type { RuntimeAdapter } from './adapters/runtime-adapter';\n 56→import { createRuntimeAdapter } from './adapters/runtime-adapter';\n 57→import { createVectorStore, type VectorStoreConfig } from './vector-store/index';\n 58→import type { VectorStore } from './vector-store/vector-store';\n 59→import { adaptiveHybridSearch } from './search/adaptive-hybrid';\n 60→import {\n 61→ applyFreshnessRanking,\n 62→ resolveRetrievalMode,\n 63→} from './search/freshness';\n 64→import { applyConflictResolution } from './search/conflicts';\n 65→import { buildConfidenceAdjustments, evaluateReliability } from './search/reliability';\n 66→import { createReranker, type RerankerConfig } from './reranking/index';\n 67→import type { Reranker } from './reranking/reranker';\n 68→import { ContextOptimizer } from './optimization/index';\n 69→import type { LLMCompressor } from './compression/llm-compressor';\n 70→import { OpenAILLMCompressor } from './compression/openai-compressor';\n 71→import { ChunkSummarizer } from './compression/summarizer';\n 72→import { ComplexityDetector } from './reasoning/complexity-detector';\n 73→import { QueryPlanner } from './reasoning/query-planner';\n 74→import { ParallelExecutor } from './reasoning/parallel-executor';\n 75→import { ResultSynthesizer } from './reasoning/synthesizer';\n 76→import { ReasoningEngine } from './reasoning/reasoning-engine';\n 77→import type { QueryHistoryStore, QueryHistoryEntry } from './learning/query-history';\n 78→import type { FeedbackStore, FeedbackEntry } from './learning/feedback';\n 79→import { SelfFeedbackGenerator } from './learning/feedback';\n 80→import { PlatformHistoryStoreAdapter } from './learning/platform-history-store';\n 81→import { PlatformFeedbackStoreAdapter } from './learning/platform-feedback-store';\n 82→import {\n 83→ PopularityBoostCalculator,\n 84→ type PopularityBoost,\n 85→} from './learning/popularity';\n 86→import {\n 87→ QueryPatternMatcher,\n 88→ applyPatternBoost,\n 89→ type QueryPatternMatcher as IQueryPatternMatcher,\n 90→} from './learning/query-patterns';\n 91→import {\n 92→ AdaptiveWeightCalculator,\n 93→ type AdaptiveWeights,\n 94→} from './learning/adaptive-weights';\n 95→import {\n 96→ PlatformEmbeddingProvider,\n 97→ type MindPlatformBindings,\n 98→} from './platform/platform-adapters';\n 99→import { AdaptiveChunkerFactory } from './chunking/adaptive-factory';\n 100→import { MemoryMonitor } from './indexing/memory-monitor';",
178
- "durationMs": 3
179
- },
180
- {
181
- "type": "tool_use",
182
- "id": "step-8",
183
- "timestamp": "2026-02-20T01:54:29.227Z",
184
- "toolName": "fs_read",
185
- "input": {
186
- "path": "kb-labs-mind/packages/mind-engine/src/index.ts",
187
- "offset": 101,
188
- "limit": 1000
189
- },
190
- "status": "done",
191
- "output": "File: kb-labs-mind/packages/mind-engine/src/index.ts\nLines: 101-1100 of 2753\n(1653 more lines after this)\n⚠️ File has 1653 more lines after this section\n💡 To read more: fs_read(path=\"kb-labs-mind/packages/mind-engine/src/index.ts\", offset=1101, limit=1000)\n💡 Or request specific sections based on what you need\n────────────────────────────────────────────────────────────\n 101→import { IndexingPipeline } from './indexing/pipeline';\n 102→import { FileDiscoveryStage } from './indexing/stages/discovery';\n 103→import { FileFilteringStage } from './indexing/stages/filtering';\n 104→import { ParallelChunkingStage } from './indexing/stages/parallel-chunking';\n 105→import { EmbeddingStage } from './indexing/stages/embedding';\n 106→import { StorageStage } from './indexing/stages/storage';\n 107→\n 108→const DEFAULT_INDEX_DIR = '.kb/mind/rag';\n 109→const DEFAULT_CODE_CHUNK_LINES = 120;\n 110→const DEFAULT_DOC_CHUNK_LINES = 80;\n 111→const DEFAULT_CHUNK_OVERLAP = 20;\n 112→\n 113→/**\n 114→ * Progress event for tracking query execution stages\n 115→ */\n 116→export interface ProgressEvent {\n 117→ /** Stage name (e.g., 'generating_embedding', 'searching_vector_store') */\n 118→ stage: string;\n 119→ /** Human-readable details (e.g., '15 matches', '3 subqueries') */\n 120→ details?: string;\n 121→ /** Additional metadata */\n 122→ metadata?: Record<string, unknown>;\n 123→ /** Timestamp in milliseconds */\n 124→ timestamp: number;\n 125→}\n 126→\n 127→export interface MindEngineChunkOptions {\n 128→ codeLines?: number;\n 129→ docLines?: number;\n 130→ overlap?: number;\n 131→}\n 132→\n 133→export interface MindEngineEmbeddingOptions {\n 134→ type?: 'auto' | 'openai' | 'local' | 'deterministic';\n 135→ dimension?: number;\n 136→ provider?: EmbeddingProviderConfig['provider'];\n 137→}\n 138→\n 139→export interface MindEngineVectorStoreOptions {\n 140→ type?: 'local';\n 141→ local?: VectorStoreConfig['local'];\n 142→}\n 143→\n 144→export interface MindEngineSearchOptions {\n 145→ /**\n 146→ * Enable hybrid search (vector + keyword)\n 147→ * Default: false (vector only)\n 148→ */\n 149→ hybrid?: boolean;\n 150→\n 151→ /**\n 152→ * Weight for vector search in hybrid mode (0-1)\n 153→ * Default: 0.7\n 154→ */\n 155→ vectorWeight?: number;\n 156→\n 157→ /**\n 158→ * Weight for keyword search in hybrid mode (0-1)\n 159→ * Default: 0.3\n 160→ */\n 161→ keywordWeight?: number;\n 162→\n 163→ /**\n 164→ * RRF constant for hybrid search\n 165→ * Default: 60\n 166→ */\n 167→ rrfK?: number;\n 168→\n 169→ /**\n 170→ * Freshness-aware ranking adjustments.\n 171→ * Helps prioritize newer docs/ADR chunks over stale ones.\n 172→ */\n 173→ freshness?: {\n 174→ /**\n 175→ * Enable freshness adjustments.\n 176→ * Default: true\n 177→ */\n 178→ enabled?: boolean;\n 179→\n 180→ /**\n 181→ * Freshness weight for docs/ADR-like chunks.\n 182→ * Default: 0.25\n 183→ */\n 184→ docsWeight?: number;\n 185→\n 186→ /**\n 187→ * Freshness weight for code/config chunks.\n 188→ * Default: 0.1\n 189→ */\n 190→ codeWeight?: number;\n 191→\n 192→ /**\n 193→ * Source trust weight.\n 194→ * Default: 0.1\n 195→ */\n 196→ trustWeight?: number;\n 197→\n 198→ /**\n 199→ * Hard cap for total boost added to base score.\n 200→ * Default: 0.3\n 201→ */\n 202→ maxBoost?: number;\n 203→\n 204→ /**\n 205→ * Index staleness thresholds in hours.\n 206→ */\n 207→ staleThresholdHours?: {\n 208→ /**\n 209→ * Soft threshold (warning level).\n 210→ * Default: 72\n 211→ */\n 212→ soft?: number;\n 213→\n 214→ /**\n 215→ * Hard threshold (critical stale level).\n 216→ * Default: 168\n 217→ */\n 218→ hard?: number;\n 219→ };\n 220→ };\n 221→\n 222→ /**\n 223→ * Conflict resolution across docs/ADR candidates.\n 224→ */\n 225→ conflicts?: {\n 226→ /**\n 227→ * Enable deterministic conflict handling.\n 228→ * Default: true\n 229→ */\n 230→ enabled?: boolean;\n 231→\n 232→ /**\n 233→ * Conflict resolution policy.\n 234→ * Default: 'freshness-first'\n 235→ */\n 236→ policy?: 'freshness-first';\n 237→\n 238→ /**\n 239→ * Max losers to penalize in one topic group.\n 240→ * Default: 3\n 241→ */\n 242→ maxLosersPerTopic?: number;\n 243→\n 244→ /**\n 245→ * Score penalty applied to loser chunks.\n 246→ * Default: 0.2\n 247→ */\n 248→ penalty?: number;\n 249→ };\n 250→\n 251→ /**\n 252→ * Reliability policies for agent/thinking consumers.\n 253→ */\n 254→ reliability?: {\n 255→ /**\n 256→ * Fail-closed when staleness is hard and mode is strict.\n 257→ * Default: true\n 258→ */\n 259→ hardStaleFailClosed?: boolean;\n 260→\n 261→ /**\n 262→ * Confidence floor for strict mode.\n 263→ * Default: 0.75\n 264→ */\n 265→ confidenceFloor?: number;\n 266→\n 267→ /**\n 268→ * Treat thinking mode as strict.\n 269→ * Default: true\n 270→ */\n 271→ thinkingModeStrict?: boolean;\n 272→ };\n 273→\n 274→ /**\n 275→ * Re-ranking configuration\n 276→ */\n 277→ reranking?: {\n 278→ /**\n 279→ * Re-ranker type: 'cross-encoder' | 'heuristic' | 'none'\n 280→ * Default: 'none'\n 281→ */\n 282→ type?: 'cross-encoder' | 'heuristic' | 'none';\n 283→\n 284→ /**\n 285→ * Cross-encoder options (when type is 'cross-encoder')\n 286→ */\n 287→ crossEncoder?: {\n 288→ endpoint?: string;\n 289→ apiKey?: string;\n 290→ model?: string;\n 291→ batchSize?: number;\n 292→ timeout?: number;\n 293→ };\n 294→\n 295→ /**\n 296→ * Top-K candidates to re-rank\n 297→ * Default: 20\n 298→ */\n 299→ topK?: number;\n 300→\n 301→ /**\n 302→ * Minimum score threshold\n 303→ * Default: 0\n 304→ */\n 305→ minScore?: number;\n 306→ };\n 307→\n 308→ /**\n 309→ * Self-learning configuration\n 310→ */\n 311→ learning?: {\n 312→ /**\n 313→ * Enable self-learning features\n 314→ * Default: false\n 315→ */\n 316→ enabled?: boolean;\n 317→\n 318→ /**\n 319→ * Store query history\n 320→ * Default: true (when learning enabled)\n 321→ */\n 322→ queryHistory?: boolean;\n 323→\n 324→ /**\n 325→ * Enable feedback collection (implicit + self-feedback)\n 326→ * Default: true (when learning enabled)\n 327→ */\n 328→ feedback?: boolean;\n 329→\n 330→ /**\n 331→ * Enable popularity boost\n 332→ * Default: true (when learning enabled)\n 333→ */\n 334→ popularityBoost?: boolean;\n 335→\n 336→ /**\n 337→ * Enable query pattern learning\n 338→ * Default: true (when learning enabled)\n 339→ */\n 340→ queryPatterns?: boolean;\n 341→\n 342→ /**\n 343→ * Enable adaptive weights\n 344→ * Default: false (requires more data)\n 345→ */\n 346→ adaptiveWeights?: boolean;\n 347→\n 348→ /**\n 349→ * Storage backend for learning data\n 350→ * Default: 'memory'\n 351→ */\n 352→ storage?: 'memory';\n 353→ };\n 354→\n 355→ /**\n 356→ * Context optimization configuration\n 357→ */\n 358→ optimization?: {\n 359→ /**\n 360→ * Enable deduplication\n 361→ * Default: true\n 362→ */\n 363→ deduplication?: boolean;\n 364→\n 365→ /**\n 366→ * Similarity threshold for deduplication (0-1)\n 367→ * Default: 0.9\n 368→ */\n 369→ deduplicationThreshold?: number;\n 370→\n 371→ /**\n 372→ * Enable diversification\n 373→ * Default: true\n 374→ */\n 375→ diversification?: boolean;\n 376→\n 377→ /**\n 378→ * Diversity threshold (0-1)\n 379→ * Default: 0.3\n 380→ */\n 381→ diversityThreshold?: number;\n 382→\n 383→ /**\n 384→ * Maximum chunks per file\n 385→ * Default: 3\n 386→ */\n 387→ maxChunksPerFile?: number;\n 388→\n 389→ /**\n 390→ * Enable adaptive selection based on token budget\n 391→ * Default: false\n 392→ */\n 393→ adaptiveSelection?: boolean;\n 394→\n 395→ /**\n 396→ * Average tokens per chunk (for estimation)\n 397→ * Default: 200\n 398→ */\n 399→ avgTokensPerChunk?: number;\n 400→\n 401→ /**\n 402→ * Compression configuration for token optimization\n 403→ */\n 404→ compression?: {\n 405→ /**\n 406→ * Enable compression features\n 407→ * Default: false\n 408→ */\n 409→ enabled?: boolean;\n 410→\n 411→ /**\n 412→ * Cache strategy for compressed chunks\n 413→ * 'memory' - in-memory cache for the duration of a query\n 414→ * Default: 'memory'\n 415→ */\n 416→ cache?: 'memory';\n 417→\n 418→ /**\n 419→ * Smart truncation configuration\n 420→ */\n 421→ smartTruncation?: {\n 422→ /**\n 423→ * Enable smart truncation with context preservation\n 424→ * Default: true (when compression enabled)\n 425→ */\n 426→ enabled?: boolean;\n 427→\n 428→ /**\n 429→ * Maximum length for chunks before truncation\n 430→ * Default: 2000 characters\n 431→ */\n 432→ maxLength?: number;\n 433→\n 434→ /**\n 435→ * Preserve code structure (function signatures, types, etc.)\n 436→ * Default: true\n 437→ */\n 438→ preserveStructure?: boolean;\n 439→ };\n 440→\n 441→ /**\n 442→ * Metadata-only mode for low-score chunks\n 443→ */\n 444→ metadataOnly?: {\n 445→ /**\n 446→ * Enable metadata-only mode\n 447→ * Default: true (when compression enabled)\n 448→ */\n 449→ enabled?: boolean;\n 450→\n 451→ /**\n 452→ * Score threshold below which chunks are shown as metadata-only\n 453→ * Default: 0.4\n 454→ */\n 455→ scoreThreshold?: number;\n 456→ };\n 457→\n 458→ /**\n 459→ * LLM compression configuration (future)\n 460→ */\n 461→ llm?: {\n 462→ /**\n 463→ * Enable LLM-based compression\n 464→ * Default: false (not implemented yet)\n 465→ */\n 466→ enabled?: boolean;\n 467→\n 468→ /**\n 469→ * LLM model to use for compression\n 470→ */\n 471→ model?: string;\n 472→\n 473→ /**\n 474→ * Maximum tokens for compressed output\n 475→ */\n 476→ maxTokens?: number;\n 477→ };\n 478→ };\n 479→ };\n 480→\n 481→ /**\n 482→ * Reasoning chain configuration\n 483→ */\n 484→ reasoning?: {\n 485→ /**\n 486→ * Enable reasoning chain for complex queries\n 487→ * Default: false\n 488→ */\n 489→ enabled?: boolean;\n 490→\n 491→ /**\n 492→ * Complexity threshold above which reasoning is triggered (0-1)\n 493→ * Default: 0.6\n 494→ */\n 495→ complexityThreshold?: number;\n 496→\n 497→ /**\n 498→ * Maximum depth for recursive reasoning\n 499→ * Default: 3\n 500→ */\n 501→ maxDepth?: number;\n 502→\n 503→ /**\n 504→ * Complexity detection configuration\n 505→ */\n 506→ complexityDetection?: {\n 507→ /**\n 508→ * Enable heuristic-based detection\n 509→ * Default: true\n 510→ */\n 511→ heuristics?: boolean;\n 512→\n 513→ /**\n 514→ * Enable LLM-based detection\n 515→ * Default: false\n 516→ */\n 517→ llmBased?: boolean;\n 518→\n 519→ /**\n 520→ * LLM model for complexity detection\n 521→ */\n 522→ llmModel?: string;\n 523→ };\n 524→\n 525→ /**\n 526→ * Query planning configuration\n 527→ */\n 528→ planning?: {\n 529→ /**\n 530→ * Maximum number of sub-queries to generate\n 531→ * Default: 5\n 532→ */\n 533→ maxSubqueries?: number;\n 534→\n 535→ /**\n 536→ * LLM model for planning\n 537→ */\n 538→ model?: string;\n 539→\n 540→ /**\n 541→ * Temperature for LLM\n 542→ * Default: 0.3\n 543→ */\n 544→ temperature?: number;\n 545→\n 546→ /**\n 547→ * Minimum similarity threshold for sub-queries\n 548→ * Default: 0.85\n 549→ */\n 550→ minSimilarity?: number;\n 551→ };\n 552→\n 553→ /**\n 554→ * Execution configuration\n 555→ */\n 556→ execution?: {\n 557→ /**\n 558→ * Enable parallel execution\n 559→ * Default: true\n 560→ */\n 561→ parallel?: boolean;\n 562→\n 563→ /**\n 564→ * Maximum concurrent queries\n 565→ * Default: 3\n 566→ */\n 567→ maxConcurrency?: number;\n 568→\n 569→ /**\n 570→ * Timeout per query in milliseconds\n 571→ * Default: 30000\n 572→ */\n 573→ timeoutMs?: number;\n 574→\n 575→ /**\n 576→ * Early stopping configuration\n 577→ */\n 578→ earlyStopping?: {\n 579→ /**\n 580→ * Enable early stopping\n 581→ * Default: true\n 582→ */\n 583→ enabled?: boolean;\n 584→\n 585→ /**\n 586→ * Minimum confidence score to stop early\n 587→ * Default: 0.8\n 588→ */\n 589→ minConfidence?: number;\n 590→\n 591→ /**\n 592→ * Minimum chunks found to stop early\n 593→ * Default: 5\n 594→ */\n 595→ minChunksFound?: number;\n 596→ };\n 597→ };\n 598→\n 599→ /**\n 600→ * Synthesis configuration\n 601→ */\n 602→ synthesis?: {\n 603→ /**\n 604→ * Enable synthesis\n 605→ * Default: true\n 606→ */\n 607→ enabled?: boolean;\n 608→\n 609→ /**\n 610→ * Enable deduplication\n 611→ * Default: true\n 612→ */\n 613→ deduplication?: boolean;\n 614→\n 615→ /**\n 616→ * Maximum tokens for synthesized output\n 617→ * Default: 4000\n 618→ */\n 619→ maxTokens?: number;\n 620→\n 621→ /**\n 622→ * LLM model for synthesis\n 623→ */\n 624→ model?: string;\n 625→\n 626→ /**\n 627→ * Temperature for LLM\n 628→ * Default: 0.2\n 629→ */\n 630→ temperature?: number;\n 631→\n 632→ /**\n 633→ * Enable progressive refinement\n 634→ * Default: true\n 635→ */\n 636→ progressiveRefinement?: boolean;\n 637→ };\n 638→\n 639→ /**\n 640→ * Safety limits\n 641→ */\n 642→ safetyLimits?: {\n 643→ /**\n 644→ * Maximum total queries across all depths\n 645→ * Default: 20\n 646→ */\n 647→ maxTotalQueries?: number;\n 648→\n 649→ /**\n 650→ * Maximum tokens per depth level\n 651→ * Default: 10000\n 652→ */\n 653→ maxTokensPerDepth?: number;\n 654→\n 655→ /**\n 656→ * Enable cyclic detection\n 657→ * Default: true\n 658→ */\n 659→ cyclicDetection?: boolean;\n 660→ };\n 661→ };\n 662→}\n 663→\n 664→export interface MindEngineOptions {\n 665→ indexDir?: string;\n 666→ chunk?: MindEngineChunkOptions;\n 667→ embedding?: MindEngineEmbeddingOptions;\n 668→ vectorStore?: MindEngineVectorStoreOptions;\n 669→ search?: MindEngineSearchOptions;\n 670→ learning?: MindEngineSearchOptions['learning'];\n 671→ llmEngineId?: string;\n 672→ platform?: MindPlatformBindings;\n 673→ /**\n 674→ * Progress callback for tracking query execution stages\n 675→ */\n 676→ onProgress?: (event: ProgressEvent) => void;\n 677→ /**\n 678→ * Runtime adapter for sandbox Runtime API\n 679→ * Passed through options to avoid changing knowledge-core interfaces\n 680→ * @internal\n 681→ */\n 682→ _runtime?: RuntimeAdapter | {\n 683→ fetch?: (input: string | { url: string } | { href: string }, init?: {\n 684→ method?: string;\n 685→ headers?: Record<string, string>;\n 686→ body?: string;\n 687→ signal?: { aborted: boolean } | null;\n 688→ [key: string]: unknown;\n 689→ }) => Promise<{\n 690→ ok: boolean;\n 691→ status: number;\n 692→ text(): Promise<string>;\n 693→ json(): Promise<unknown>;\n 694→ [key: string]: unknown;\n 695→ }>;\n 696→ fs?: any;\n 697→ env?: (key: string) => string | undefined;\n 698→ log?: (\n 699→ level: 'debug' | 'info' | 'warn' | 'error',\n 700→ msg: string,\n 701→ meta?: Record<string, unknown>,\n 702→ ) => void;\n 703→ analytics?: {\n 704→ track(event: string, properties?: Record<string, unknown>): void;\n 705→ metric(name: string, value: number, tags?: Record<string, string>): void;\n 706→ };\n 707→ };\n 708→}\n 709→\n 710→interface NormalizedOptions {\n 711→ indexDir: string;\n 712→ chunk: Required<MindEngineChunkOptions>;\n 713→ search: {\n 714→ hybrid: boolean;\n 715→ vectorWeight: number;\n 716→ keywordWeight: number;\n 717→ rrfK: number;\n 718→ freshness: {\n 719→ enabled: boolean;\n 720→ docsWeight: number;\n 721→ codeWeight: number;\n 722→ trustWeight: number;\n 723→ maxBoost: number;\n 724→ staleThresholdHours: {\n 725→ soft: number;\n 726→ hard: number;\n 727→ };\n 728→ };\n 729→ conflicts: {\n 730→ enabled: boolean;\n 731→ policy: 'freshness-first';\n 732→ maxLosersPerTopic: number;\n 733→ penalty: number;\n 734→ };\n 735→ reliability: {\n 736→ hardStaleFailClosed: boolean;\n 737→ confidenceFloor: number;\n 738→ thinkingModeStrict: boolean;\n 739→ };\n 740→ reranking: {\n 741→ enabled: boolean;\n 742→ type: 'cross-encoder' | 'heuristic' | 'none';\n 743→ topK: number;\n 744→ minScore: number;\n 745→ config?: RerankerConfig;\n 746→ };\n 747→ optimization: {\n 748→ enabled: boolean;\n 749→ deduplication: boolean;\n 750→ deduplicationThreshold: number;\n 751→ diversification: boolean;\n 752→ diversityThreshold: number;\n 753→ maxChunksPerFile: number;\n 754→ adaptiveSelection: boolean;\n 755→ avgTokensPerChunk: number;\n 756→ compression: {\n 757→ enabled: boolean;\n 758→ cache: 'memory';\n 759→ smartTruncation: {\n 760→ enabled: boolean;\n 761→ maxLength: number;\n 762→ preserveStructure: boolean;\n 763→ };\n 764→ metadataOnly: {\n 765→ enabled: boolean;\n 766→ scoreThreshold: number;\n 767→ };\n 768→ llm: {\n 769→ enabled: boolean;\n 770→ model?: string;\n 771→ maxTokens?: number;\n 772→ };\n 773→ };\n 774→ };\n 775→ reasoning: {\n 776→ enabled: boolean;\n 777→ complexityThreshold: number;\n 778→ maxDepth: number;\n 779→ complexityDetection: {\n 780→ heuristics: boolean;\n 781→ llmBased: boolean;\n 782→ llmModel?: string;\n 783→ };\n 784→ planning: {\n 785→ maxSubqueries: number;\n 786→ model?: string;\n 787→ temperature: number;\n 788→ minSimilarity: number;\n 789→ };\n 790→ execution: {\n 791→ parallel: boolean;\n 792→ maxConcurrency: number;\n 793→ timeoutMs: number;\n 794→ earlyStopping: {\n 795→ enabled: boolean;\n 796→ minConfidence: number;\n 797→ minChunksFound: number;\n 798→ };\n 799→ };\n 800→ synthesis: {\n 801→ enabled: boolean;\n 802→ deduplication: boolean;\n 803→ maxTokens: number;\n 804→ model?: string;\n 805→ temperature: number;\n 806→ progressiveRefinement: boolean;\n 807→ };\n 808→ safetyLimits: {\n 809→ maxTotalQueries: number;\n 810→ maxTokensPerDepth: number;\n 811→ cyclicDetection: boolean;\n 812→ };\n 813→ };\n 814→ };\n 815→ learning: {\n 816→ enabled: boolean;\n 817→ queryHistory: boolean;\n 818→ feedback: boolean;\n 819→ popularityBoost: boolean;\n 820→ queryPatterns: boolean;\n 821→ adaptiveWeights: boolean;\n 822→ storage: 'platform' | 'memory';\n 823→ storageOptions?: {\n 824→ history?: {\n 825→ basePath?: string;\n 826→ maxRecordsPerFile?: number;\n 827→ maxFiles?: number;\n 828→ };\n 829→ feedback?: {\n 830→ basePath?: string;\n 831→ maxRecordsPerFile?: number;\n 832→ maxFiles?: number;\n 833→ };\n 834→ };\n 835→ };\n 836→}\n 837→\n 838→interface MindChunk {\n 839→ chunkId: string;\n 840→ sourceId: string;\n 841→ path: string;\n 842→ span: SpanRange;\n 843→ text: string;\n 844→ metadata?: Record<string, unknown>;\n 845→}\n 846→\n 847→export class MindKnowledgeEngine implements KnowledgeEngine {\n 848→ readonly id: string;\n 849→ readonly type = 'mind';\n 850→ private readonly workspaceRoot: string;\n 851→ private readonly engineConfigHash: string;\n 852→ private readonly options: NormalizedOptions;\n 853→ private readonly vectorStore: VectorStore;\n 854→ private embeddingProvider: EmbeddingProvider;\n 855→ private readonly llm: ILLM | null;\n 856→ private readonly runtime: RuntimeAdapter;\n 857→ private readonly reranker: Reranker | null;\n 858→ private readonly contextOptimizer: ContextOptimizer;\n 859→ private readonly llmCompressor: LLMCompressor | null;\n 860→ private readonly summarizer: ChunkSummarizer | null;\n 861→ \n 862→ // Self-learning components\n 863→ private readonly queryHistory: QueryHistoryStore | null;\n 864→ private readonly feedbackStore: FeedbackStore | null;\n 865→ private readonly popularityBoost: PopularityBoost | null;\n 866→ private readonly queryPatternMatcher: IQueryPatternMatcher | null;\n 867→ private readonly adaptiveWeights: AdaptiveWeights | null;\n 868→ private readonly selfFeedbackGenerator: SelfFeedbackGenerator | null;\n 869→ \n 870→ // Reasoning components\n 871→ private readonly reasoningEngine: ReasoningEngine | null;\n 872→ \n 873→ // Progress tracking\n 874→ private readonly onProgress?: (event: ProgressEvent) => void;\n 875→\n 876→ /**\n 877→ * Safely call onProgress callback with error handling\n 878→ */\n 879→ private reportProgress(stage: string, details?: string, metadata?: Record<string, unknown>): void {\n 880→ if (!this.onProgress) {return;}\n 881→ try {\n 882→ this.onProgress({\n 883→ stage,\n 884→ details,\n 885→ metadata,\n 886→ timestamp: Date.now(),\n 887→ });\n 888→ } catch (error) {\n 889→ // Log error but don't break the query\n 890→ this.runtime.log?.('warn', 'Progress callback failed', {\n 891→ error: error instanceof Error ? error.message : String(error),\n 892→ stage,\n 893→ });\n 894→ }\n 895→ }\n 896→\n 897→ constructor(\n 898→ config: KnowledgeEngineConfig,\n 899→ context: KnowledgeEngineFactoryContext,\n 900→ ) {\n 901→ this.id = config.id;\n 902→ this.workspaceRoot = context.workspaceRoot ?? (typeof process !== 'undefined' && process.cwd ? process.cwd() : '/');\n 903→ const rawOptions = (config.options ?? {}) as MindEngineOptions;\n 904→ this.options = normalizeOptions(rawOptions);\n 905→ this.engineConfigHash = hashConfigForDeterminism({\n 906→ id: config.id,\n 907→ type: config.type,\n 908→ options: sanitizeEngineOptionsForHash(rawOptions),\n 909→ });\n 910→\n 911→ // Use SDK's usePlatform() as fallback if not explicitly provided\n 912→ const platform = rawOptions.platform ?? usePlatform();\n 913→\n 914→ // DEBUG: Check learning configuration\n 915→ platform?.logger?.debug('MindEngine constructor: Raw learning config', { learning: rawOptions.learning });\n 916→ platform?.logger?.debug('MindEngine constructor: Normalized learning.enabled', { enabled: this.options.learning.enabled });\n 917→\n 918→ this.onProgress = rawOptions.onProgress;\n 919→\n 920→ // Extract runtime adapter from options (passed through from handlers)\n 921→ const runtimeInput = rawOptions._runtime;\n 922→ this.runtime = runtimeInput && 'fetch' in runtimeInput && typeof runtimeInput.fetch === 'function'\n 923→ ? runtimeInput as RuntimeAdapter\n 924→ : createRuntimeAdapter(runtimeInput as any);\n 925→\n 926→ // DEBUG: Check platform.vectorStore\n 927→ platform?.logger?.debug('MindEngine: platform source', { source: rawOptions.platform ? 'rawOptions.platform' : 'usePlatform()' });\n 928→ platform?.logger?.debug('MindEngine: platform.vectorStore exists', { exists: !!platform?.vectorStore });\n 929→ platform?.logger?.debug('MindEngine: platform.vectorStore type', { type: platform?.vectorStore?.constructor?.name });\n 930→\n 931→ const embeddingConfig: EmbeddingProviderConfig = rawOptions.embedding\n 932→ ? {\n 933→ type: rawOptions.embedding.type,\n 934→ provider: rawOptions.embedding.provider,\n 935→ }\n 936→ : { type: 'deterministic' };\n 937→ \n 938→ // Infer dimension: prefer platform embeddings dimension, otherwise fallback to config/deterministic\n 939→ let embeddingDimension = platform?.embeddings?.dimensions ?? 384;\n 940→ if (!platform?.embeddings) {\n 941→ if (embeddingConfig.type === 'openai') {\n 942→ embeddingDimension = 1536;\n 943→ } else if (embeddingConfig.type === 'deterministic') {\n 944→ embeddingDimension = embeddingConfig.provider?.deterministic?.dimension ?? 384;\n 945→ } else if (embeddingConfig.type === 'local') {\n 946→ embeddingDimension = embeddingConfig.provider?.local?.dimension ?? 384;\n 947→ }\n 948→ }\n 949→ \n 950→ // Create vector store using platform abstraction when provided\n 951→ const vectorStoreConfig: VectorStoreConfig = {\n 952→ type: 'local',\n 953→ local: {\n 954→ indexDir: path.resolve(this.workspaceRoot, this.options.indexDir),\n 955→ },\n 956→ };\n 957→ \n 958→ this.vectorStore = createVectorStore(vectorStoreConfig);\n 959→\n 960→ // Create embedding provider - ALWAYS use platform.embeddings (with analytics wrapper)\n 961→ const embeddings = platform?.embeddings ?? useEmbeddings();\n 962→ if (!embeddings) {\n 963→ throw new Error('Embeddings adapter not available. Ensure platform is initialized with embeddings adapter.');\n 964→ }\n 965→ this.embeddingProvider = new PlatformEmbeddingProvider(embeddings);\n 966→ \n 967→ // Use LLM from SDK hook\n 968→ this.llm = useLLM() ?? null;\n 969→\n 970→ // Create LLM compressor if enabled and LLM available\n 971→ if (this.options.search.optimization.compression.llm.enabled && this.llm) {\n 972→ this.llmCompressor = new OpenAILLMCompressor({\n 973→ llm: this.llm,\n 974→ maxTokens: this.options.search.optimization.compression.llm.maxTokens,\n 975→ compressionRatio: 0.5,\n 976→ temperature: 0.2,\n 977→ });\n 978→ this.summarizer = new ChunkSummarizer({\n 979→ llm: this.llm,\n 980→ maxTokens: 150,\n 981→ temperature: 0.3,\n 982→ });\n 983→ } else {\n 984→ this.llmCompressor = null;\n 985→ this.summarizer = null;\n 986→ }\n 987→\n 988→ // Create reranker if enabled\n 989→ if (this.options.search.reranking.enabled && this.options.search.reranking.config) {\n 990→ this.reranker = createReranker(this.options.search.reranking.config, this.runtime);\n 991→ } else {\n 992→ this.reranker = null;\n 993→ }\n 994→\n 995→ // Create context optimizer\n 996→ this.contextOptimizer = new ContextOptimizer();\n 997→\n 998→ // Initialize self-learning components if enabled\n 999→ if (this.options.learning.enabled) {\n 1000→ const storageType = this.options.learning.storage;\n 1001→ const resolvedStorage = platform?.storage;\n 1002→\n 1003→ this.runtime.log?.('debug', 'Initializing self-learning system', {\n 1004→ enabled: this.options.learning.enabled,\n 1005→ storageType,\n 1006→ platformStorage: !!platform?.storage,\n 1007→ resolvedStorage: !!resolvedStorage,\n 1008→ workspaceRoot: this.workspaceRoot,\n 1009→ });\n 1010→\n 1011→ // Initialize query history (platform/fallback storage -> file store; otherwise memory)\n 1012→ if (this.options.learning.queryHistory) {\n 1013→ const historyConfig = this.options.learning.storageOptions?.history;\n 1014→ const historyStoreImpl = storageType === 'platform' && resolvedStorage\n 1015→ ? new FileHistoryStore(resolvedStorage, {\n 1016→ basePath: historyConfig?.basePath ?? '.kb/mind/learning/history/',\n 1017→ maxRecordsPerFile: historyConfig?.maxRecordsPerFile ?? 1000,\n 1018→ maxFiles: historyConfig?.maxFiles ?? 30,\n 1019→ })\n 1020→ : new MemoryHistoryStore();\n 1021→ this.queryHistory = new PlatformHistoryStoreAdapter(historyStoreImpl);\n 1022→ } else {\n 1023→ this.queryHistory = null;\n 1024→ }\n 1025→\n 1026→ // Initialize feedback store (platform/fallback storage -> file store; otherwise memory)\n 1027→ if (this.options.learning.feedback) {\n 1028→ const feedbackConfig = this.options.learning.storageOptions?.feedback;\n 1029→ const feedbackStoreImpl = storageType === 'platform' && resolvedStorage\n 1030→ ? new FileFeedbackStore(resolvedStorage, {\n 1031→ basePath: feedbackConfig?.basePath ?? '.kb/mind/learning/feedback/',\n 1032→ maxRecordsPerFile: feedbackConfig?.maxRecordsPerFile ?? 1000,\n 1033→ maxFiles: feedbackConfig?.maxFiles ?? 30,\n 1034→ })\n 1035→ : new MemoryFeedbackStore();\n 1036→ this.feedbackStore = new PlatformFeedbackStoreAdapter(feedbackStoreImpl);\n 1037→ } else {\n 1038→ this.feedbackStore = null;\n 1039→ }\n 1040→\n 1041→ // Initialize popularity boost\n 1042→ if (this.options.learning.popularityBoost && this.feedbackStore) {\n 1043→ this.popularityBoost = new PopularityBoostCalculator(this.feedbackStore);\n 1044→ } else {\n 1045→ this.popularityBoost = null;\n 1046→ }\n 1047→\n 1048→ // Initialize query pattern matcher\n 1049→ if (this.options.learning.queryPatterns && this.queryHistory) {\n 1050→ this.queryPatternMatcher = new QueryPatternMatcher(this.queryHistory);\n 1051→ } else {\n 1052→ this.queryPatternMatcher = null;\n 1053→ }\n 1054→\n 1055→ // Initialize adaptive weights\n 1056→ if (this.options.learning.adaptiveWeights && this.queryHistory && this.feedbackStore) {\n 1057→ this.adaptiveWeights = new AdaptiveWeightCalculator(this.queryHistory, this.feedbackStore);\n 1058→ } else {\n 1059→ this.adaptiveWeights = null;\n 1060→ }\n 1061→\n 1062→ // Initialize self-feedback generator\n 1063→ if (this.options.learning.feedback) {\n 1064→ this.selfFeedbackGenerator = new SelfFeedbackGenerator(this.runtime);\n 1065→ } else {\n 1066→ this.selfFeedbackGenerator = null;\n 1067→ }\n 1068→ } else {\n 1069→ this.queryHistory = null;\n 1070→ this.feedbackStore = null;\n 1071→ this.popularityBoost = null;\n 1072→ this.queryPatternMatcher = null;\n 1073→ this.adaptiveWeights = null;\n 1074→ this.selfFeedbackGenerator = null;\n 1075→ }\n 1076→\n 1077→ // Initialize reasoning engine if enabled\n 1078→ if (this.options.search.reasoning.enabled) {\n 1079→ const complexityDetector = new ComplexityDetector(\n 1080→ {\n 1081→ threshold: this.options.search.reasoning.complexityThreshold,\n 1082→ heuristics: this.options.search.reasoning.complexityDetection.heuristics,\n 1083→ llmBased: this.options.search.reasoning.complexityDetection.llmBased,\n 1084→ llmModel: this.options.search.reasoning.complexityDetection.llmModel,\n 1085→ },\n 1086→ this.llm,\n 1087→ );\n 1088→\n 1089→ const queryPlanner = new QueryPlanner(\n 1090→ {\n 1091→ maxSubqueries: this.options.search.reasoning.planning.maxSubqueries,\n 1092→ model: this.options.search.reasoning.planning.model,\n 1093→ temperature: this.options.search.reasoning.planning.temperature,\n 1094→ minSimilarity: this.options.search.reasoning.planning.minSimilarity,\n 1095→ },\n 1096→ this.llm,\n 1097→ );\n 1098→\n 1099→ const parallelExecutor = new ParallelExecutor({\n 1100→ parallel: this.options.search.reasoning.execution.parallel,",
192
- "durationMs": 4
193
- },
194
- {
195
- "type": "text",
196
- "id": "step-9",
197
- "timestamp": "2026-02-20T01:54:40.786Z",
198
- "content": "### Key Findings\n\n1. **Agent Architecture**: The agents in KB Labs are designed to execute tasks using various tools and methods, leveraging a modular architecture that allows for flexibility and scalability.\n \n2. **Core Components**: The `index.ts` file in the `mind-engine` package defines several key interfaces and configurations for the Mind Engine, which is central to the agent's functionality. This includes options for embedding, vector storage, search configurations, and learning mechanisms.\n\n3. **Progress Tracking**: The `ProgressEvent` interface is used to track the execution stages of queries, providing insights into the agent's operations.\n\n4. **Search and Ranking**: The Mind Engine supports hybrid search capabilities, allowing for both vector and keyword searches, with adjustable weights for each type. This is crucial for optimizing search results based on user queries.\n\n5. **Learning and Adaptation**: The engine includes self-learning features that enable it to adapt based on user interactions, storing query history and feedback to improve future responses.\n\n### Evidence\n\n- **File Path**: `kb-labs-mind/packages/mind-engine/src/index.ts`\n- **Key Code Snippets**:\n ```typescript\n export interface ProgressEvent {\n stage: string;\n details?: string;\n metadata?: Record<string, unknown>;\n timestamp: number;\n }\n\n export interface MindEngineSearchOptions {\n hybrid?: boolean;\n vectorWeight?: number;\n keywordWeight?: number;\n freshness?: {\n enabled?: boolean;\n docsWeight?: number;\n codeWeight?: number;\n };\n conflicts?: {\n enabled?: boolean;\n policy?: 'freshness-first';\n };\n }\n ```\n\n### Gaps/Uncertainties\n\n- **Detailed Implementation**: While the interfaces and configurations are defined, the actual implementation details of how these components interact during query execution are not fully explored in the current read.\n- **Agent Communication**: The specifics of how agents communicate with each other or with external systems are not covered in the `index.ts` file.\n\n### Recommended Next Checks\n\n1. **Explore Other Modules**: Investigate other directories within the `mind-engine` package, such as `search`, `learning`, and `indexing`, to gain a deeper understanding of the agent's operational flow.\n \n2. **Review Agent Communication**: Look for files that define how agents communicate, possibly in the `adapters` or `platform` directories.\n\n3. **Check for Tests**: Review the `__tests__` directory to see if there are any unit tests that validate the behavior of the agents, which could provide insights into their expected functionality.\n\nWould you like me to explore any specific areas further?",
199
- "role": "assistant"
200
- }
201
- ],
202
- "metadata": {
203
- "agentId": "agent-1771552454972-du6fi"
204
- }
205
- }
206
- ]
@@ -1,248 +0,0 @@
1
- {
2
- "schemaVersion": "1.0",
3
- "createdAt": "2026-01-02T14:08:23.316Z",
4
- "repoRoot": "/Users/kirillbaranov/Desktop/kb-labs/kb-labs-rest-api/apps/rest-api",
5
- "gitStatus": {
6
- "staged": [],
7
- "unstaged": [
8
- ".gitignore",
9
- "apps/rest-api/package.json",
10
- "apps/rest-api/src/bootstrap.ts",
11
- "apps/rest-api/src/events/index.ts",
12
- "apps/rest-api/src/middleware/envelope.ts",
13
- "apps/rest-api/src/middleware/index.ts",
14
- "apps/rest-api/src/middleware/metrics.ts",
15
- "apps/rest-api/src/middleware/request-id.ts",
16
- "apps/rest-api/src/routes/__tests__/workflows.spec.ts",
17
- "apps/rest-api/src/routes/events.ts",
18
- "apps/rest-api/src/routes/health.ts",
19
- "apps/rest-api/src/routes/index.ts",
20
- "apps/rest-api/src/routes/metrics.ts",
21
- "apps/rest-api/src/routes/plugins.ts",
22
- "apps/rest-api/src/server.ts",
23
- "packages/rest-api-contracts/package.json",
24
- "packages/rest-api-contracts/src/index.ts",
25
- "packages/rest-api-contracts/src/studio.ts",
26
- "packages/rest-api-core/package.json",
27
- "packages/rest-api-core/src/config/loader.ts",
28
- "packages/rest-api-core/src/index.ts",
29
- "pnpm-lock.yaml",
30
- "tsconfig.paths.json",
31
- "apps/rest-api/src/events/sse-event-bridge.ts",
32
- "apps/rest-api/src/middleware/__tests__/header-policy.spec.ts",
33
- "apps/rest-api/src/middleware/header-policy.ts",
34
- "apps/rest-api/src/plugins/cli-discovery.ts",
35
- "apps/rest-api/src/plugins/compat.ts",
36
- "apps/rest-api/src/plugins/discovery.ts"
37
- ],
38
- "untracked": [
39
- "apps/rest-api/.kb/commit/current/plan.json",
40
- "apps/rest-api/.kb/commit/current/status.json",
41
- "apps/rest-api/src/middleware/__tests__/cache.spec.ts",
42
- "apps/rest-api/src/middleware/__tests__/envelope.spec.ts",
43
- "apps/rest-api/src/middleware/__tests__/rate-limit.spec.ts",
44
- "apps/rest-api/src/middleware/__tests__/request-id.spec.ts",
45
- "apps/rest-api/src/middleware/prom-metrics.ts",
46
- "apps/rest-api/src/platform.ts",
47
- "apps/rest-api/src/routes/__tests__/adapters-date-helpers.spec.ts",
48
- "apps/rest-api/src/routes/__tests__/adapters.spec.ts",
49
- "apps/rest-api/src/routes/adapters.ts",
50
- "apps/rest-api/src/routes/analytics.ts",
51
- "apps/rest-api/src/routes/cache.ts",
52
- "apps/rest-api/src/routes/logs.ts",
53
- "apps/rest-api/src/routes/observability.ts",
54
- "apps/rest-api/src/routes/platform.ts",
55
- "apps/rest-api/src/routes/workflow-management.ts",
56
- "packages/rest-api-contracts/src/observability.ts",
57
- "packages/rest-api-contracts/src/platform.ts",
58
- "packages/rest-api-core/src/__tests__/config-schema.spec.ts",
59
- "packages/rest-api-core/src/__tests__/studio-registry.spec.ts",
60
- "packages/rest-api-core/src/studio-registry.ts"
61
- ]
62
- },
63
- "commits": [
64
- {
65
- "id": "c1",
66
- "type": "chore",
67
- "scope": "rest-api",
68
- "message": "update dependencies",
69
- "files": [
70
- "apps/rest-api/package.json",
71
- "apps/rest-api/.kb/commit/current/plan.json",
72
- "apps/rest-api/.kb/commit/current/status.json"
73
- ],
74
- "releaseHint": "none",
75
- "breaking": false
76
- },
77
- {
78
- "id": "c2",
79
- "type": "chore",
80
- "scope": "rest-api-contracts",
81
- "message": "update dependencies",
82
- "files": [
83
- "packages/rest-api-contracts/package.json"
84
- ],
85
- "releaseHint": "none",
86
- "breaking": false
87
- },
88
- {
89
- "id": "c3",
90
- "type": "chore",
91
- "scope": "rest-api-core",
92
- "message": "update dependencies",
93
- "files": [
94
- "packages/rest-api-core/package.json",
95
- "packages/rest-api-core/src/__tests__/config-schema.spec.ts"
96
- ],
97
- "releaseHint": "none",
98
- "breaking": false
99
- },
100
- {
101
- "id": "c4",
102
- "type": "feat",
103
- "scope": "middleware",
104
- "message": "add 2 files",
105
- "files": [
106
- "apps/rest-api/src/middleware/header-policy.ts",
107
- "apps/rest-api/src/middleware/__tests__/header-policy.spec.ts"
108
- ],
109
- "releaseHint": "minor",
110
- "breaking": false
111
- },
112
- {
113
- "id": "c5",
114
- "type": "feat",
115
- "scope": "middleware",
116
- "message": "add 2 files",
117
- "files": [
118
- "apps/rest-api/src/middleware/envelope.ts",
119
- "apps/rest-api/src/middleware/__tests__/envelope.spec.ts"
120
- ],
121
- "releaseHint": "minor",
122
- "breaking": false
123
- },
124
- {
125
- "id": "c6",
126
- "type": "feat",
127
- "scope": "middleware",
128
- "message": "add 2 files",
129
- "files": [
130
- "apps/rest-api/src/middleware/request-id.ts",
131
- "apps/rest-api/src/middleware/__tests__/request-id.spec.ts"
132
- ],
133
- "releaseHint": "minor",
134
- "breaking": false
135
- },
136
- {
137
- "id": "c7",
138
- "type": "feat",
139
- "scope": "routes",
140
- "message": "add 2 files",
141
- "files": [
142
- "apps/rest-api/src/routes/adapters.ts",
143
- "apps/rest-api/src/routes/__tests__/adapters.spec.ts"
144
- ],
145
- "releaseHint": "minor",
146
- "breaking": false
147
- },
148
- {
149
- "id": "c8",
150
- "type": "feat",
151
- "message": "add 2 files",
152
- "files": [
153
- "packages/rest-api-core/src/studio-registry.ts",
154
- "packages/rest-api-core/src/__tests__/studio-registry.spec.ts"
155
- ],
156
- "releaseHint": "minor",
157
- "breaking": false
158
- },
159
- {
160
- "id": "c9",
161
- "type": "chore",
162
- "message": "update configuration",
163
- "files": [
164
- ".gitignore",
165
- "tsconfig.paths.json"
166
- ],
167
- "releaseHint": "none",
168
- "breaking": false
169
- },
170
- {
171
- "id": "c10",
172
- "type": "chore",
173
- "message": "update configuration",
174
- "files": [
175
- "apps/rest-api/src/bootstrap.ts",
176
- "apps/rest-api/src/events/index.ts",
177
- "apps/rest-api/src/middleware/index.ts",
178
- "apps/rest-api/src/middleware/metrics.ts",
179
- "apps/rest-api/src/routes/events.ts",
180
- "apps/rest-api/src/routes/health.ts",
181
- "apps/rest-api/src/routes/index.ts",
182
- "apps/rest-api/src/routes/metrics.ts",
183
- "apps/rest-api/src/routes/plugins.ts",
184
- "apps/rest-api/src/server.ts",
185
- "apps/rest-api/src/events/sse-event-bridge.ts",
186
- "apps/rest-api/src/plugins/cli-discovery.ts",
187
- "apps/rest-api/src/plugins/compat.ts",
188
- "apps/rest-api/src/plugins/discovery.ts",
189
- "apps/rest-api/src/middleware/prom-metrics.ts",
190
- "apps/rest-api/src/platform.ts",
191
- "apps/rest-api/src/routes/analytics.ts",
192
- "apps/rest-api/src/routes/cache.ts",
193
- "apps/rest-api/src/routes/logs.ts",
194
- "apps/rest-api/src/routes/observability.ts",
195
- "apps/rest-api/src/routes/platform.ts",
196
- "apps/rest-api/src/routes/workflow-management.ts"
197
- ],
198
- "releaseHint": "none",
199
- "breaking": false
200
- },
201
- {
202
- "id": "c11",
203
- "type": "chore",
204
- "scope": "packages",
205
- "message": "update configuration",
206
- "files": [
207
- "packages/rest-api-contracts/src/index.ts",
208
- "packages/rest-api-contracts/src/studio.ts",
209
- "packages/rest-api-core/src/config/loader.ts",
210
- "packages/rest-api-core/src/index.ts",
211
- "packages/rest-api-contracts/src/observability.ts",
212
- "packages/rest-api-contracts/src/platform.ts"
213
- ],
214
- "releaseHint": "none",
215
- "breaking": false
216
- },
217
- {
218
- "id": "c12",
219
- "type": "chore",
220
- "scope": ".",
221
- "message": "update configuration",
222
- "files": [
223
- "pnpm-lock.yaml"
224
- ],
225
- "releaseHint": "none",
226
- "breaking": false
227
- },
228
- {
229
- "id": "c13",
230
- "type": "test",
231
- "message": "add 4 test files",
232
- "files": [
233
- "apps/rest-api/src/routes/__tests__/workflows.spec.ts",
234
- "apps/rest-api/src/middleware/__tests__/cache.spec.ts",
235
- "apps/rest-api/src/middleware/__tests__/rate-limit.spec.ts",
236
- "apps/rest-api/src/routes/__tests__/adapters-date-helpers.spec.ts"
237
- ],
238
- "releaseHint": "none",
239
- "breaking": false
240
- }
241
- ],
242
- "metadata": {
243
- "totalFiles": 51,
244
- "totalCommits": 13,
245
- "llmUsed": false,
246
- "escalated": false
247
- }
248
- }