@kb-labs/rest-api-app 1.3.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 (255) hide show
  1. package/.kb/agents/sessions/session-1771531145393-ws3uh6q/turns.json +42 -0
  2. package/.kb/agents/sessions/session-1771548930486-ui6rtvm/turns.json +33 -0
  3. package/.kb/agents/sessions/session-1771549691485-nibqroq/turns.json +133 -0
  4. package/.kb/agents/sessions/session-1771550943182-dkwqdjc/turns.json +130 -0
  5. package/.kb/agents/sessions/session-1771551564182-cr4bwzn/turns.json +349 -0
  6. package/.kb/agents/sessions/session-1771552401370-g4ztwd1/turns.json +206 -0
  7. package/.kb/commit/current/plan.json +248 -0
  8. package/.kb/commit/current/status.json +472 -0
  9. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/commands/health.d.ts +10 -0
  10. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/commands/health.js +215 -0
  11. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/commands/health.js.map +1 -0
  12. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/commands/list.d.ts +10 -0
  13. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/commands/list.js +271 -0
  14. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/commands/list.js.map +1 -0
  15. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/commands/logs.d.ts +10 -0
  16. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/commands/logs.js +230 -0
  17. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/commands/logs.js.map +1 -0
  18. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/commands/metrics.d.ts +10 -0
  19. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/commands/metrics.js +228 -0
  20. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/commands/metrics.js.map +1 -0
  21. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/commands/run.d.ts +11 -0
  22. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/commands/run.js +281 -0
  23. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/commands/run.js.map +1 -0
  24. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/commands/status.d.ts +10 -0
  25. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/commands/status.js +266 -0
  26. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/commands/status.js.map +1 -0
  27. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/commands/workflow-run.d.ts +11 -0
  28. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/commands/workflow-run.js +284 -0
  29. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/commands/workflow-run.js.map +1 -0
  30. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/flags-WLdpSZl4.d.ts +77 -0
  31. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/index.d.ts +2 -0
  32. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/index.js +441 -0
  33. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/index.js.map +1 -0
  34. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/manifest.d.ts +196 -0
  35. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/manifest.js +441 -0
  36. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/manifest.js.map +1 -0
  37. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/cron-list-handler.d.ts +19 -0
  38. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/cron-list-handler.js +48 -0
  39. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/cron-list-handler.js.map +1 -0
  40. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/index.d.ts +6 -0
  41. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/index.js +170 -0
  42. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/index.js.map +1 -0
  43. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/job-cancel-handler.d.ts +12 -0
  44. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/job-cancel-handler.js +52 -0
  45. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/job-cancel-handler.js.map +1 -0
  46. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/job-detail-handler.d.ts +22 -0
  47. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/job-detail-handler.js +52 -0
  48. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/job-detail-handler.js.map +1 -0
  49. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/job-logs-handler.d.ts +13 -0
  50. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/job-logs-handler.js +52 -0
  51. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/job-logs-handler.js.map +1 -0
  52. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/job-steps-handler.d.ts +9 -0
  53. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/job-steps-handler.js +43 -0
  54. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/job-steps-handler.js.map +1 -0
  55. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/jobs-list-handler.d.ts +26 -0
  56. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/jobs-list-handler.js +63 -0
  57. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/jobs-list-handler.js.map +1 -0
  58. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/pending-approvals-handler.d.ts +9 -0
  59. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/pending-approvals-handler.js +46 -0
  60. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/pending-approvals-handler.js.map +1 -0
  61. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/resolve-approval-handler.d.ts +16 -0
  62. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/resolve-approval-handler.js +58 -0
  63. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/resolve-approval-handler.js.map +1 -0
  64. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/run-detail-handler.d.ts +9 -0
  65. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/run-detail-handler.js +46 -0
  66. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/run-detail-handler.js.map +1 -0
  67. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/runs-list-handler.d.ts +11 -0
  68. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/runs-list-handler.js +50 -0
  69. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/runs-list-handler.js.map +1 -0
  70. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/stats-handler.d.ts +7 -0
  71. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/stats-handler.js +39 -0
  72. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/stats-handler.js.map +1 -0
  73. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/workflow-detail-handler.d.ts +10 -0
  74. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/workflow-detail-handler.js +46 -0
  75. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/workflow-detail-handler.js.map +1 -0
  76. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/workflow-run-cancel-handler.d.ts +13 -0
  77. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/workflow-run-cancel-handler.js +47 -0
  78. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/workflow-run-cancel-handler.js.map +1 -0
  79. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/workflow-run-handler.d.ts +14 -0
  80. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/workflow-run-handler.js +53 -0
  81. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/workflow-run-handler.js.map +1 -0
  82. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/workflow-runs-handler.d.ts +13 -0
  83. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/workflow-runs-handler.js +54 -0
  84. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/workflow-runs-handler.js.map +1 -0
  85. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/workflows-list-handler.d.ts +12 -0
  86. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/workflows-list-handler.js +51 -0
  87. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/workflows-list-handler.js.map +1 -0
  88. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/ws/logs-channel.d.ts +17 -0
  89. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/ws/logs-channel.js +133 -0
  90. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/ws/logs-channel.js.map +1 -0
  91. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/ws/progress-channel.d.ts +11 -0
  92. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/ws/progress-channel.js +46 -0
  93. package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/ws/progress-channel.js.map +1 -0
  94. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/commands/health.d.ts +10 -0
  95. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/commands/health.js +215 -0
  96. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/commands/health.js.map +1 -0
  97. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/commands/list.d.ts +10 -0
  98. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/commands/list.js +271 -0
  99. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/commands/list.js.map +1 -0
  100. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/commands/logs.d.ts +10 -0
  101. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/commands/logs.js +230 -0
  102. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/commands/logs.js.map +1 -0
  103. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/commands/metrics.d.ts +10 -0
  104. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/commands/metrics.js +228 -0
  105. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/commands/metrics.js.map +1 -0
  106. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/commands/run.d.ts +11 -0
  107. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/commands/run.js +281 -0
  108. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/commands/run.js.map +1 -0
  109. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/commands/status.d.ts +10 -0
  110. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/commands/status.js +266 -0
  111. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/commands/status.js.map +1 -0
  112. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/commands/workflow-run.d.ts +11 -0
  113. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/commands/workflow-run.js +284 -0
  114. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/commands/workflow-run.js.map +1 -0
  115. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/flags-WLdpSZl4.d.ts +77 -0
  116. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/index.d.ts +2 -0
  117. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/index.js +441 -0
  118. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/index.js.map +1 -0
  119. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/manifest.d.ts +196 -0
  120. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/manifest.js +441 -0
  121. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/manifest.js.map +1 -0
  122. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/cron-list-handler.d.ts +19 -0
  123. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/cron-list-handler.js +48 -0
  124. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/cron-list-handler.js.map +1 -0
  125. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/index.d.ts +6 -0
  126. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/index.js +170 -0
  127. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/index.js.map +1 -0
  128. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/job-cancel-handler.d.ts +12 -0
  129. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/job-cancel-handler.js +52 -0
  130. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/job-cancel-handler.js.map +1 -0
  131. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/job-detail-handler.d.ts +22 -0
  132. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/job-detail-handler.js +52 -0
  133. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/job-detail-handler.js.map +1 -0
  134. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/job-logs-handler.d.ts +13 -0
  135. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/job-logs-handler.js +52 -0
  136. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/job-logs-handler.js.map +1 -0
  137. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/job-steps-handler.d.ts +9 -0
  138. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/job-steps-handler.js +43 -0
  139. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/job-steps-handler.js.map +1 -0
  140. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/jobs-list-handler.d.ts +26 -0
  141. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/jobs-list-handler.js +63 -0
  142. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/jobs-list-handler.js.map +1 -0
  143. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/pending-approvals-handler.d.ts +9 -0
  144. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/pending-approvals-handler.js +46 -0
  145. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/pending-approvals-handler.js.map +1 -0
  146. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/resolve-approval-handler.d.ts +16 -0
  147. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/resolve-approval-handler.js +58 -0
  148. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/resolve-approval-handler.js.map +1 -0
  149. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/run-detail-handler.d.ts +9 -0
  150. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/run-detail-handler.js +46 -0
  151. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/run-detail-handler.js.map +1 -0
  152. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/runs-list-handler.d.ts +11 -0
  153. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/runs-list-handler.js +50 -0
  154. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/runs-list-handler.js.map +1 -0
  155. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/stats-handler.d.ts +7 -0
  156. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/stats-handler.js +39 -0
  157. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/stats-handler.js.map +1 -0
  158. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/workflow-detail-handler.d.ts +10 -0
  159. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/workflow-detail-handler.js +46 -0
  160. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/workflow-detail-handler.js.map +1 -0
  161. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/workflow-run-cancel-handler.d.ts +13 -0
  162. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/workflow-run-cancel-handler.js +47 -0
  163. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/workflow-run-cancel-handler.js.map +1 -0
  164. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/workflow-run-handler.d.ts +14 -0
  165. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/workflow-run-handler.js +53 -0
  166. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/workflow-run-handler.js.map +1 -0
  167. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/workflow-runs-handler.d.ts +13 -0
  168. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/workflow-runs-handler.js +54 -0
  169. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/workflow-runs-handler.js.map +1 -0
  170. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/workflows-list-handler.d.ts +12 -0
  171. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/workflows-list-handler.js +51 -0
  172. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/workflows-list-handler.js.map +1 -0
  173. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/ws/logs-channel.d.ts +17 -0
  174. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/ws/logs-channel.js +133 -0
  175. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/ws/logs-channel.js.map +1 -0
  176. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/ws/progress-channel.d.ts +11 -0
  177. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/ws/progress-channel.js +46 -0
  178. package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/ws/progress-channel.js.map +1 -0
  179. package/README.md +54 -0
  180. package/eslint.config.js +23 -0
  181. package/package.json +72 -0
  182. package/src/.kb/agents/sessions/session-1773470583796-ximqnfk/kpi-baseline.json +17 -0
  183. package/src/.kb/memory/sessions/session-1773470583796-ximqnfk/fact-sheet.json +1 -0
  184. package/src/bootstrap.ts +233 -0
  185. package/src/diagnostics/header-debug.ts +37 -0
  186. package/src/events/hub.ts +60 -0
  187. package/src/events/index.ts +1 -0
  188. package/src/index.ts +13 -0
  189. package/src/manifest.ts +21 -0
  190. package/src/middleware/__tests__/cache.spec.ts +184 -0
  191. package/src/middleware/__tests__/envelope.spec.ts +268 -0
  192. package/src/middleware/__tests__/metrics.redis.spec.ts +64 -0
  193. package/src/middleware/__tests__/rate-limit.spec.ts +283 -0
  194. package/src/middleware/__tests__/request-id.spec.ts +160 -0
  195. package/src/middleware/cache.ts +67 -0
  196. package/src/middleware/envelope.ts +136 -0
  197. package/src/middleware/error-guard.ts +69 -0
  198. package/src/middleware/index.ts +37 -0
  199. package/src/middleware/metrics.ts +810 -0
  200. package/src/middleware/mock-mode.ts +44 -0
  201. package/src/middleware/prom-metrics.ts +284 -0
  202. package/src/middleware/rate-limit-routes.ts +73 -0
  203. package/src/middleware/rate-limit.ts +72 -0
  204. package/src/middleware/request-id.ts +41 -0
  205. package/src/middleware/request-timeout.ts +69 -0
  206. package/src/middleware/security-headers.ts +24 -0
  207. package/src/middleware/startup-guard.ts +107 -0
  208. package/src/observability/service-contract.ts +192 -0
  209. package/src/plugins/index.ts +118 -0
  210. package/src/routes/__tests__/adapters-date-helpers.spec.ts +332 -0
  211. package/src/routes/__tests__/adapters.spec.ts +680 -0
  212. package/src/routes/__tests__/cache.spec.ts +264 -0
  213. package/src/routes/__tests__/events.spec.ts +434 -0
  214. package/src/routes/__tests__/health.spec.ts +414 -0
  215. package/src/routes/__tests__/logs.spec.ts +494 -0
  216. package/src/routes/__tests__/observability.spec.ts +392 -0
  217. package/src/routes/__tests__/plugins.spec.ts +931 -0
  218. package/src/routes/__tests__/workflow-management.spec.ts +698 -0
  219. package/src/routes/__tests__/workflows.spec.ts +204 -0
  220. package/src/routes/adapter-call.ts +220 -0
  221. package/src/routes/adapters.ts +1206 -0
  222. package/src/routes/analytics.ts +328 -0
  223. package/src/routes/cache.ts +104 -0
  224. package/src/routes/debug-routes.ts +95 -0
  225. package/src/routes/events.ts +115 -0
  226. package/src/routes/health.ts +348 -0
  227. package/src/routes/hello.ts +47 -0
  228. package/src/routes/index.ts +395 -0
  229. package/src/routes/jobs.ts +253 -0
  230. package/src/routes/logs.ts +718 -0
  231. package/src/routes/metrics.ts +120 -0
  232. package/src/routes/observability.ts +1388 -0
  233. package/src/routes/openapi.ts +101 -0
  234. package/src/routes/platform.ts +143 -0
  235. package/src/routes/plugins.ts +998 -0
  236. package/src/routes/readiness.ts +83 -0
  237. package/src/routes/workflow-management.ts +469 -0
  238. package/src/routes/workflows.ts +256 -0
  239. package/src/server.ts +203 -0
  240. package/src/services/historical-metrics.ts +496 -0
  241. package/src/services/incident-analyzer.ts +289 -0
  242. package/src/services/incident-detector.ts +691 -0
  243. package/src/services/incident-schema.sql +76 -0
  244. package/src/services/incident-storage.ts +593 -0
  245. package/src/services/system-metrics-collector.ts +244 -0
  246. package/src/types/fastify.d.ts +58 -0
  247. package/src/utils/__tests__/sse-auth.spec.ts +113 -0
  248. package/src/utils/path-helpers.ts +15 -0
  249. package/src/utils/repo.ts +42 -0
  250. package/src/utils/schema.ts +20 -0
  251. package/src/utils/sse-auth.ts +81 -0
  252. package/test-sandbox.sh +105 -0
  253. package/tsconfig.build.json +15 -0
  254. package/tsconfig.json +9 -0
  255. package/tsup.config.ts +18 -0
@@ -0,0 +1,107 @@
1
+ /**
2
+ * @module @kb-labs/rest-api-app/middleware/startup-guard
3
+ * Guard to prevent request storms during startup
4
+ */
5
+
6
+ import type { FastifyInstance } from 'fastify';
7
+ import type { RestApiConfig } from '@kb-labs/rest-api-core';
8
+ import { isReady } from '../routes/readiness';
9
+
10
+ type StartupCounters = {
11
+ inFlight: number;
12
+ };
13
+
14
+ type StartupConfig = {
15
+ maxConcurrent?: number;
16
+ queueLimit?: number;
17
+ timeoutMs?: number;
18
+ retryAfterSeconds?: number;
19
+ };
20
+
21
+ export function registerStartupGuard(
22
+ server: FastifyInstance,
23
+ config: RestApiConfig
24
+ ): void {
25
+ const startupConfig = (config as RestApiConfig & { startup?: StartupConfig }).startup;
26
+ if (!startupConfig) {
27
+ return;
28
+ }
29
+
30
+ const counters: StartupCounters = {
31
+ inFlight: 0,
32
+ };
33
+
34
+ server.kbStartupGuard = counters;
35
+
36
+ const maxConcurrent = startupConfig.maxConcurrent ?? 32;
37
+ const queueLimit = startupConfig.queueLimit ?? 128;
38
+ const timeoutMs = startupConfig.timeoutMs ?? 5000;
39
+ const retryAfterSeconds = startupConfig.retryAfterSeconds ?? 2;
40
+
41
+ server.addHook('onRequest', (request, reply, done) => {
42
+ const readiness = server.kbReadiness;
43
+ const infraReady = readiness ? isReady(readiness) : false;
44
+
45
+ if (infraReady) {
46
+ done();
47
+ return;
48
+ }
49
+
50
+ if (counters.inFlight >= queueLimit) {
51
+ reply
52
+ .code(503)
53
+ .header('Retry-After', retryAfterSeconds.toString())
54
+ .send({
55
+ schema: 'kb.startup/1',
56
+ status: 'initializing',
57
+ reason: 'startup_queue_limit',
58
+ maxConcurrent,
59
+ queueLimit,
60
+ });
61
+ return;
62
+ }
63
+
64
+ counters.inFlight += 1;
65
+ request.kbStartupGuardActive = true;
66
+
67
+ const timer = setTimeout(() => {
68
+ if (!reply.sent) {
69
+ reply
70
+ .code(504)
71
+ .header('Retry-After', retryAfterSeconds.toString())
72
+ .send({
73
+ schema: 'kb.startup/1',
74
+ status: 'timeout',
75
+ reason: 'startup_timeout',
76
+ timeoutMs,
77
+ });
78
+ }
79
+ }, timeoutMs);
80
+ timer.unref();
81
+ request.kbStartupGuardTimer = timer;
82
+
83
+ if (counters.inFlight > maxConcurrent) {
84
+ if ((request as any).kbLogger) {
85
+ (request as any).kbLogger.warn('Startup guard concurrency threshold exceeded', {
86
+ inFlight: counters.inFlight,
87
+ maxConcurrent,
88
+ });
89
+ }
90
+ }
91
+
92
+ done();
93
+ });
94
+
95
+ server.addHook('onResponse', (request, _reply, done) => {
96
+ if (request.kbStartupGuardActive) {
97
+ counters.inFlight = Math.max(0, counters.inFlight - 1);
98
+ if (request.kbStartupGuardTimer) {
99
+ clearTimeout(request.kbStartupGuardTimer);
100
+ request.kbStartupGuardTimer = undefined;
101
+ }
102
+ request.kbStartupGuardActive = false;
103
+ }
104
+ done();
105
+ });
106
+ }
107
+
@@ -0,0 +1,192 @@
1
+ import { hostname } from 'node:os';
2
+ import {
3
+ OBSERVABILITY_CONTRACT_VERSION,
4
+ OBSERVABILITY_SCHEMA,
5
+ CANONICAL_OBSERVABILITY_METRICS,
6
+ type ObservabilityCheck,
7
+ } from '@kb-labs/core-contracts';
8
+ import type {
9
+ ServiceObservabilityDescribe,
10
+ ServiceObservabilityHealth,
11
+ ServiceOperationSample,
12
+ } from '@kb-labs/core-contracts';
13
+ import {
14
+ createServiceObservabilityDescribe,
15
+ createServiceObservabilityHealth,
16
+ } from '@kb-labs/shared-http';
17
+ import type { SystemHealthSnapshot } from '@kb-labs/core-registry';
18
+ import type { ReadinessState } from '../routes/readiness.js';
19
+ import { restDomainOperationMetrics, type MetricsSnapshot } from '../middleware/metrics.js';
20
+ import { getLatestSystemMetrics } from '../services/system-metrics-collector.js';
21
+
22
+ declare const __REST_API_VERSION__: string;
23
+ const REST_VERSION = typeof __REST_API_VERSION__ !== 'undefined' ? __REST_API_VERSION__ : '0.0.0';
24
+
25
+ function resolveInstanceId(): string {
26
+ return `${hostname()}:${process.pid}`;
27
+ }
28
+
29
+ function mergeTopOperations(
30
+ httpOperations: ServiceOperationSample[],
31
+ domainOperations: ServiceOperationSample[],
32
+ limit = 5,
33
+ ): ServiceOperationSample[] {
34
+ const merged = new Map<string, ServiceOperationSample>();
35
+
36
+ for (const item of [...httpOperations, ...domainOperations]) {
37
+ const existing = merged.get(item.operation);
38
+ if (!existing) {
39
+ merged.set(item.operation, { ...item });
40
+ continue;
41
+ }
42
+
43
+ const count = (existing.count ?? 0) + (item.count ?? 0);
44
+ const totalDurationMs =
45
+ (existing.avgDurationMs ?? 0) * (existing.count ?? 0) +
46
+ (item.avgDurationMs ?? 0) * (item.count ?? 0);
47
+
48
+ merged.set(item.operation, {
49
+ operation: item.operation,
50
+ count,
51
+ avgDurationMs: count > 0 ? totalDurationMs / count : 0,
52
+ maxDurationMs: Math.max(existing.maxDurationMs ?? 0, item.maxDurationMs ?? 0),
53
+ errorCount: (existing.errorCount ?? 0) + (item.errorCount ?? 0),
54
+ });
55
+ }
56
+
57
+ const ranked = Array.from(merged.values())
58
+ .sort((a, b) => (b.count ?? 0) - (a.count ?? 0) || (b.maxDurationMs ?? 0) - (a.maxDurationMs ?? 0))
59
+ const sliced = ranked.slice(0, limit);
60
+
61
+ if (domainOperations.length === 0 || sliced.some((item) => !item.operation.startsWith('http.'))) {
62
+ return sliced;
63
+ }
64
+
65
+ const firstDomainOperation = ranked.find((item) => !item.operation.startsWith('http.'));
66
+ if (!firstDomainOperation) {
67
+ return sliced;
68
+ }
69
+
70
+ return [...sliced.slice(0, Math.max(0, limit - 1)), firstDomainOperation];
71
+ }
72
+
73
+ function finiteNumberOrUndefined(value: number | null | undefined): number | undefined {
74
+ return typeof value === 'number' && Number.isFinite(value) ? value : undefined;
75
+ }
76
+
77
+ export function buildRestObservabilityDescribe(basePath: string): ServiceObservabilityDescribe {
78
+ return createServiceObservabilityDescribe({
79
+ schema: OBSERVABILITY_SCHEMA,
80
+ contractVersion: OBSERVABILITY_CONTRACT_VERSION,
81
+ serviceId: 'rest',
82
+ instanceId: resolveInstanceId(),
83
+ serviceType: 'http-api',
84
+ version: REST_VERSION,
85
+ environment: process.env.NODE_ENV ?? 'development',
86
+ startedAt: new Date(Date.now() - process.uptime() * 1000).toISOString(),
87
+ dependencies: [
88
+ {
89
+ serviceId: 'workflow',
90
+ required: true,
91
+ description: 'Workflow daemon for workflow and jobs APIs',
92
+ },
93
+ {
94
+ serviceId: 'state-daemon',
95
+ required: false,
96
+ description: 'State broker and cache-backed storage',
97
+ },
98
+ ],
99
+ metricsEndpoint: `${basePath}/metrics`,
100
+ healthEndpoint: `${basePath}/observability/health`,
101
+ logsSource: 'rest',
102
+ capabilities: ['httpMetrics', 'eventLoopMetrics', 'operationMetrics', 'logCorrelation'],
103
+ metricFamilies: [...CANONICAL_OBSERVABILITY_METRICS],
104
+ });
105
+ }
106
+
107
+ export function buildRestObservabilityHealth(
108
+ basePath: string,
109
+ healthSnapshot: SystemHealthSnapshot,
110
+ readiness: ReadinessState,
111
+ metrics: MetricsSnapshot,
112
+ ): ServiceObservabilityHealth {
113
+ const runtimeMetrics = getLatestSystemMetrics();
114
+ const checks: ObservabilityCheck[] = [
115
+ {
116
+ id: 'registry',
117
+ status: readiness.registryLoaded && !readiness.registryPartial && !readiness.registryStale
118
+ ? 'ok'
119
+ : readiness.registryLoaded ? 'warn' : 'error',
120
+ message: readiness.registryLoaded ? 'Registry snapshot loaded' : 'Registry snapshot incomplete',
121
+ },
122
+ {
123
+ id: 'plugin-routes',
124
+ status: readiness.pluginRouteErrors > 0 ? 'warn' : readiness.pluginRoutesMounted ? 'ok' : 'warn',
125
+ message: readiness.pluginRoutesMounted
126
+ ? `${readiness.pluginRoutesCount} plugin routes mounted`
127
+ : 'Plugin routes are still mounting',
128
+ },
129
+ {
130
+ id: 'redis',
131
+ status: !readiness.redisEnabled ? 'ok' : readiness.redisConnected ? 'ok' : 'warn',
132
+ message: !readiness.redisEnabled
133
+ ? 'Redis integration disabled'
134
+ : readiness.redisConnected
135
+ ? 'Redis healthy'
136
+ : 'Redis unavailable',
137
+ },
138
+ ];
139
+
140
+ const httpTopOperations = metrics.latency.histogram
141
+ .slice()
142
+ .sort((a, b) => b.count - a.count || b.max - a.max)
143
+ .slice(0, 5)
144
+ .map((entry) => ({
145
+ operation: `http.${entry.route}`,
146
+ count: entry.count,
147
+ avgDurationMs: entry.count > 0 ? entry.total / entry.count : 0,
148
+ maxDurationMs: entry.max,
149
+ errorCount: Object.entries(entry.byStatus)
150
+ .filter(([status]) => Number(status) >= 400)
151
+ .reduce((sum, [, count]) => sum + count, 0),
152
+ }));
153
+ const topOperations = mergeTopOperations(httpTopOperations, restDomainOperationMetrics.getTopOperations(5));
154
+
155
+ const latestOperation = topOperations[0];
156
+ const state = healthSnapshot.status === 'healthy'
157
+ ? 'active'
158
+ : runtimeMetrics || latestOperation
159
+ ? 'partial_observability'
160
+ : 'insufficient_data';
161
+
162
+ return createServiceObservabilityHealth({
163
+ schema: OBSERVABILITY_SCHEMA,
164
+ contractVersion: OBSERVABILITY_CONTRACT_VERSION,
165
+ serviceId: 'rest',
166
+ instanceId: resolveInstanceId(),
167
+ observedAt: healthSnapshot.ts,
168
+ status: healthSnapshot.status === 'healthy' ? 'healthy' : healthSnapshot.status === 'degraded' ? 'degraded' : 'unhealthy',
169
+ uptimeSec: healthSnapshot.uptimeSec,
170
+ metricsEndpoint: `${basePath}/metrics`,
171
+ logsSource: 'rest',
172
+ capabilities: ['httpMetrics', 'eventLoopMetrics', 'operationMetrics', 'logCorrelation'],
173
+ checks,
174
+ snapshot: {
175
+ cpuPercent: finiteNumberOrUndefined(runtimeMetrics?.cpu.percentage),
176
+ rssBytes: finiteNumberOrUndefined(runtimeMetrics?.memory.rss),
177
+ heapUsedBytes: finiteNumberOrUndefined(runtimeMetrics?.memory.heapUsed),
178
+ eventLoopLagMs: finiteNumberOrUndefined(runtimeMetrics?.eventLoopLagMs),
179
+ activeOperations: runtimeMetrics?.activeOperations ?? metrics.requests.active,
180
+ },
181
+ topOperations,
182
+ state,
183
+ meta: {
184
+ serviceHealthEndpoint: `${basePath}/health`,
185
+ readyEndpoint: `${basePath}/ready`,
186
+ runtimeMetricsCollectedAt: runtimeMetrics ? new Date(runtimeMetrics.timestamp).toISOString() : null,
187
+ lastRequestAt: metrics.timestamps.lastRequest
188
+ ? new Date(metrics.timestamps.lastRequest).toISOString()
189
+ : null,
190
+ },
191
+ });
192
+ }
@@ -0,0 +1,118 @@
1
+ /**
2
+ * @module @kb-labs/rest-api-app/plugins
3
+ * Fastify plugins registration
4
+ */
5
+
6
+ import type {
7
+ FastifyInstance,
8
+ FastifyPluginCallback,
9
+ FastifyBaseLogger,
10
+ RawServerDefault,
11
+ FastifyTypeProviderDefault,
12
+ } from 'fastify';
13
+ import type { RestApiConfig } from '@kb-labs/rest-api-core';
14
+ import fastifyCors, { type FastifyCorsOptions } from '@fastify/cors';
15
+ import fastifyRateLimit, { type RateLimitPluginOptions } from '@fastify/rate-limit';
16
+ import { registerOpenAPI } from '@kb-labs/shared-http';
17
+
18
+ /**
19
+ * Register all Fastify plugins
20
+ */
21
+ export async function registerPlugins(
22
+ server: FastifyInstance,
23
+ config: RestApiConfig
24
+ ): Promise<void> {
25
+ // CORS plugin with profile support
26
+ const corsProfile = config.cors.profile || 'dev';
27
+ let corsOrigins: string[] | boolean = config.cors.origins;
28
+
29
+ if (corsProfile === 'dev') {
30
+ // Dev: allow localhost origins
31
+ corsOrigins = config.cors.origins.length > 0
32
+ ? config.cors.origins
33
+ : ['http://localhost:3000', 'http://localhost:5173']; // Vite default + Studio
34
+ } else if (corsProfile === 'preview') {
35
+ // Preview: specific staging domains
36
+ corsOrigins = config.cors.origins.length > 0
37
+ ? config.cors.origins
38
+ : false; // Disable if not configured
39
+ } else if (corsProfile === 'prod') {
40
+ // Prod: strict whitelist
41
+ corsOrigins = config.cors.origins.length > 0
42
+ ? config.cors.origins
43
+ : false; // Disable if not configured
44
+ }
45
+
46
+ const corsOptions: FastifyCorsOptions = {
47
+ origin: corsOrigins,
48
+ credentials: config.cors.allowCredentials,
49
+ methods: ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS', 'HEAD'],
50
+ allowedHeaders: [
51
+ 'Content-Type',
52
+ 'Authorization',
53
+ 'X-Request-Id',
54
+ 'X-Trace-Id', // Added for Studio widget tracing
55
+ 'Idempotency-Key',
56
+ 'X-Client-Version'
57
+ ],
58
+ exposedHeaders: ['X-Request-Id', 'X-Schema-Version', 'X-RateLimit-Limit', 'X-RateLimit-Remaining', 'Retry-After'],
59
+ preflightContinue: false,
60
+ };
61
+
62
+ const corsPlugin: FastifyPluginCallback<
63
+ FastifyCorsOptions,
64
+ RawServerDefault,
65
+ FastifyTypeProviderDefault,
66
+ FastifyBaseLogger
67
+ > = fastifyCors;
68
+
69
+ await server.register(corsPlugin, corsOptions);
70
+
71
+ // Add Vary: Origin header for CORS caching
72
+ server.addHook('onSend', async (request, reply) => {
73
+ if (corsProfile !== 'prod') {
74
+ try {
75
+ if (!reply.raw.headersSent) {
76
+ reply.header('Vary', 'Origin');
77
+ }
78
+ } catch (err) {
79
+ // Headers already sent, ignore
80
+ }
81
+ }
82
+ });
83
+
84
+ // Rate limit plugin
85
+ if (config.rateLimit) {
86
+ const rateLimitOpts: RateLimitPluginOptions = {
87
+ max: config.rateLimit.max,
88
+ timeWindow: config.rateLimit.timeWindow,
89
+ addHeaders: {
90
+ 'x-ratelimit-limit': true,
91
+ 'x-ratelimit-remaining': true,
92
+ 'x-ratelimit-reset': true,
93
+ },
94
+ };
95
+
96
+ const rateLimitPlugin: FastifyPluginCallback<
97
+ RateLimitPluginOptions,
98
+ RawServerDefault,
99
+ FastifyTypeProviderDefault,
100
+ FastifyBaseLogger
101
+ > = fastifyRateLimit;
102
+
103
+ await server.register(rateLimitPlugin, rateLimitOpts);
104
+ }
105
+
106
+ // OpenAPI / Swagger UI
107
+ // Must be registered after other plugins and before routes.
108
+ // Spec is at /openapi.json — canonical across all services.
109
+ // UI is disabled in production (hideUntagged: true keeps internal routes invisible).
110
+ await registerOpenAPI(server, {
111
+ title: 'KB Labs REST API',
112
+ description: 'Main platform REST API — jobs, workflows, plugins, adapters',
113
+ version: '1.0.0',
114
+ servers: [{ url: 'http://localhost:5050', description: 'Local dev' }],
115
+ ui: corsProfile !== 'prod',
116
+ });
117
+ }
118
+