@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,83 @@
1
+ // Shared readiness state for health and plugin routes
2
+ export interface ReadinessState {
3
+ cliApiInitialized: boolean;
4
+ registryLoaded: boolean;
5
+ registryPartial: boolean;
6
+ registryStale: boolean;
7
+ pluginRoutesMounted: boolean;
8
+ pluginMountInProgress: boolean;
9
+ pluginRoutesCount: number;
10
+ pluginRouteErrors: number;
11
+ pluginRouteFailures: Array<{ id: string; error: string }>;
12
+ lastPluginMountTs?: string | null;
13
+ pluginRoutesLastDurationMs?: number | null;
14
+ redisEnabled: boolean;
15
+ redisConnected: boolean;
16
+ redisStates: {
17
+ publisher: string | null;
18
+ subscriber: string | null;
19
+ cache: string | null;
20
+ };
21
+ }
22
+
23
+ export function createInitialReadinessState(): ReadinessState {
24
+ return {
25
+ cliApiInitialized: false,
26
+ registryLoaded: false,
27
+ registryPartial: false,
28
+ registryStale: false,
29
+ pluginRoutesMounted: false,
30
+ pluginMountInProgress: true,
31
+ pluginRoutesCount: 0,
32
+ pluginRouteErrors: 0,
33
+ pluginRouteFailures: [],
34
+ lastPluginMountTs: null,
35
+ pluginRoutesLastDurationMs: null,
36
+ redisEnabled: false,
37
+ redisConnected: true,
38
+ redisStates: {
39
+ publisher: null,
40
+ subscriber: null,
41
+ cache: null,
42
+ },
43
+ };
44
+ }
45
+
46
+ export function isReady(readiness: ReadinessState): boolean {
47
+ return (
48
+ readiness.cliApiInitialized &&
49
+ readiness.registryLoaded &&
50
+ !readiness.registryPartial &&
51
+ !readiness.registryStale &&
52
+ (!readiness.redisEnabled || readiness.redisConnected)
53
+ );
54
+ }
55
+
56
+ export function resolveReadinessReason(readiness: ReadinessState):
57
+ | 'ready'
58
+ | 'cli_api_not_initialized'
59
+ | 'registry_not_loaded'
60
+ | 'registry_partial'
61
+ | 'registry_snapshot_stale'
62
+ | 'redis_unavailable'
63
+ | 'plugin_mount_in_progress' {
64
+ if (!readiness.cliApiInitialized) {
65
+ return 'cli_api_not_initialized';
66
+ }
67
+ if (!readiness.registryLoaded) {
68
+ if (readiness.registryStale) {
69
+ return 'registry_snapshot_stale';
70
+ }
71
+ if (readiness.registryPartial) {
72
+ return 'registry_partial';
73
+ }
74
+ return 'registry_not_loaded';
75
+ }
76
+ if (readiness.redisEnabled && !readiness.redisConnected) {
77
+ return 'redis_unavailable';
78
+ }
79
+ if (readiness.pluginMountInProgress) {
80
+ return 'plugin_mount_in_progress';
81
+ }
82
+ return 'ready';
83
+ }
@@ -0,0 +1,469 @@
1
+ /**
2
+ * Workflow Management API endpoints
3
+ * Provides CRUD operations and schedule management for workflows
4
+ */
5
+
6
+ import type { FastifyInstance } from 'fastify';
7
+ import type { ZodTypeProvider } from 'fastify-type-provider-zod';
8
+ import { serializerCompiler, validatorCompiler } from 'fastify-type-provider-zod';
9
+ import type { RestApiConfig } from '@kb-labs/rest-api-core';
10
+ import type { IEntityRegistry } from '@kb-labs/core-registry';
11
+ import type { PlatformServices } from '@kb-labs/plugin-contracts';
12
+ import type { IWorkflowEngine, ICronManager } from '@kb-labs/core-platform';
13
+ import {
14
+ WorkflowService,
15
+ WorkflowScheduleManager,
16
+ type WorkflowExecutor,
17
+ } from '@kb-labs/workflow-engine';
18
+ import { z } from 'zod';
19
+ import {
20
+ ListWorkflowsQuerySchema,
21
+ WorkflowsListResponseSchema,
22
+ WorkflowResponseSchema,
23
+ CreateWorkflowBodySchema,
24
+ UpdateWorkflowBodySchema,
25
+ ScheduleConfigBodySchema,
26
+ ValidateWorkflowBodySchema,
27
+ HandlersListResponseSchema,
28
+ ErrorResponseSchema,
29
+ } from '@kb-labs/rest-api-contracts';
30
+ import { normalizeBasePath } from '../utils/path-helpers';
31
+
32
+ // ============================================================================
33
+ // Helper Functions
34
+ // ============================================================================
35
+
36
+ function errPayload(code: string, message: string) {
37
+ return { ok: false as const, message, error: { code, message } };
38
+ }
39
+
40
+ // ============================================================================
41
+ // Route Registration
42
+ // ============================================================================
43
+
44
+ export async function registerWorkflowManagementRoutes(
45
+ server: FastifyInstance,
46
+ config: RestApiConfig,
47
+ registry: IEntityRegistry,
48
+ platform: PlatformServices,
49
+ workflowEngine: IWorkflowEngine | null,
50
+ cronManager: ICronManager | null,
51
+ ): Promise<void> {
52
+ const basePath = normalizeBasePath(config.basePath);
53
+
54
+ // Encapsulate Zod compilers so they don't leak to plugin routes (plain JSON schemas)
55
+ await server.register(async (scope) => {
56
+ scope.setValidatorCompiler(validatorCompiler);
57
+ scope.setSerializerCompiler(serializerCompiler);
58
+ const s = scope.withTypeProvider<ZodTypeProvider>();
59
+
60
+ // Initialize services
61
+ const workflowService = new WorkflowService({
62
+ cliApi: registry,
63
+ platform,
64
+ workflowStorageDir: '.kb/workflows',
65
+ });
66
+
67
+ // Initialize WorkflowScheduleManager to register jobs from manifests
68
+ if (cronManager && workflowEngine) {
69
+ const executor: WorkflowExecutor = {
70
+ async execute(request) {
71
+ const run = await workflowEngine.execute(
72
+ request.workflowId,
73
+ request.input ?? {},
74
+ {
75
+ tags: { trigger: request.trigger },
76
+ }
77
+ );
78
+ return { runId: run.id };
79
+ },
80
+ };
81
+
82
+ const scheduleManager = new WorkflowScheduleManager({
83
+ cronManager,
84
+ workflowService,
85
+ executor,
86
+ platform,
87
+ });
88
+
89
+ // Register all scheduled workflows/jobs from manifests
90
+ await scheduleManager.registerAll();
91
+
92
+ platform.logger?.info('WorkflowScheduleManager initialized and jobs registered');
93
+ } else {
94
+ platform.logger?.warn('WorkflowScheduleManager not initialized: cronManager or workflowEngine unavailable');
95
+ }
96
+
97
+ // ========================================================================
98
+ // Workflow CRUD
99
+ // ========================================================================
100
+
101
+ /**
102
+ * GET /api/v1/workflows
103
+ * List all workflows (manifest + standalone)
104
+ */
105
+ s.route({
106
+ method: 'GET',
107
+ url: `${basePath}/workflows`,
108
+ schema: {
109
+ tags: ['Workflows'],
110
+ summary: 'List all workflows',
111
+ querystring: ListWorkflowsQuerySchema,
112
+ response: {
113
+ 200: WorkflowsListResponseSchema,
114
+ },
115
+ },
116
+ handler: async (request, reply) => {
117
+ const query = request.query;
118
+
119
+ const workflows = await workflowService.listAll({
120
+ source: query.source,
121
+ status: query.status,
122
+ });
123
+
124
+ let filtered = workflows;
125
+
126
+ if (query.tags) {
127
+ const tags = query.tags.split(',').map((t) => t.trim());
128
+ filtered = filtered.filter((w) => (w as any).tags?.some((tag: string) => tags.includes(tag)));
129
+ }
130
+
131
+ if (query.search) {
132
+ const search = query.search.toLowerCase();
133
+ filtered = filtered.filter(
134
+ (w) =>
135
+ (w as any).name?.toLowerCase().includes(search) ||
136
+ (w as any).description?.toLowerCase().includes(search)
137
+ );
138
+ }
139
+
140
+ reply.send({ workflows: filtered as any, total: filtered.length });
141
+ },
142
+ });
143
+
144
+ /**
145
+ * GET /api/v1/workflows/handlers
146
+ * List available workflow handlers (must be before /:id to avoid route conflict)
147
+ */
148
+ s.route({
149
+ method: 'GET',
150
+ url: `${basePath}/workflows/handlers`,
151
+ schema: {
152
+ tags: ['Workflows'],
153
+ summary: 'List available workflow handlers',
154
+ response: {
155
+ 200: HandlersListResponseSchema,
156
+ },
157
+ },
158
+ handler: async (request, reply) => {
159
+ const handlers = await workflowService.getAvailableHandlers();
160
+ reply.send({ handlers: handlers as any, total: handlers.length });
161
+ },
162
+ });
163
+
164
+ /**
165
+ * POST /api/v1/workflows/validate
166
+ * Validate workflow spec (must be before /:id to avoid route conflict)
167
+ */
168
+ s.route({
169
+ method: 'POST',
170
+ url: `${basePath}/workflows/validate`,
171
+ schema: {
172
+ tags: ['Workflows'],
173
+ summary: 'Validate workflow spec',
174
+ body: ValidateWorkflowBodySchema,
175
+ response: {
176
+ 200: z.record(z.string(), z.unknown()),
177
+ },
178
+ },
179
+ handler: async (request, reply) => {
180
+ const result = await workflowService.validate(request.body.spec);
181
+ reply.send(result as any);
182
+ },
183
+ });
184
+
185
+ /**
186
+ * GET /api/v1/workflows/:id
187
+ * Get workflow by ID
188
+ */
189
+ s.route({
190
+ method: 'GET',
191
+ url: `${basePath}/workflows/:id`,
192
+ schema: {
193
+ tags: ['Workflows'],
194
+ summary: 'Get workflow by ID',
195
+ params: z.object({ id: z.string() }),
196
+ response: {
197
+ 200: WorkflowResponseSchema,
198
+ 404: ErrorResponseSchema,
199
+ },
200
+ },
201
+ handler: async (request, reply) => {
202
+ const workflow = await workflowService.get(request.params.id);
203
+
204
+ if (!workflow) {
205
+ return reply.code(404).send(errPayload('WF_NOT_FOUND', `Workflow ${request.params.id} not found`) as any);
206
+ }
207
+
208
+ reply.send({ workflow } as any);
209
+ },
210
+ });
211
+
212
+ /**
213
+ * POST /api/v1/workflows
214
+ * Create new standalone workflow
215
+ */
216
+ s.route({
217
+ method: 'POST',
218
+ url: `${basePath}/workflows`,
219
+ schema: {
220
+ tags: ['Workflows'],
221
+ summary: 'Create standalone workflow',
222
+ body: CreateWorkflowBodySchema,
223
+ response: {
224
+ 201: WorkflowResponseSchema,
225
+ 400: ErrorResponseSchema,
226
+ },
227
+ },
228
+ handler: async (request, reply) => {
229
+ const workflow = await workflowService.create(request.body.spec as any);
230
+ reply.code(201).send({ workflow } as any);
231
+ },
232
+ });
233
+
234
+ /**
235
+ * PUT /api/v1/workflows/:id
236
+ * Update standalone workflow
237
+ */
238
+ s.route({
239
+ method: 'PUT',
240
+ url: `${basePath}/workflows/:id`,
241
+ schema: {
242
+ tags: ['Workflows'],
243
+ summary: 'Update standalone workflow',
244
+ params: z.object({ id: z.string() }),
245
+ body: UpdateWorkflowBodySchema,
246
+ response: {
247
+ 200: WorkflowResponseSchema,
248
+ 400: ErrorResponseSchema,
249
+ 404: ErrorResponseSchema,
250
+ },
251
+ },
252
+ handler: async (request, reply) => {
253
+ const id = request.params.id;
254
+
255
+ const existing = await workflowService.get(id);
256
+ if (!existing) {
257
+ return reply.code(404).send(errPayload('WF_NOT_FOUND', `Workflow ${id} not found`) as any);
258
+ }
259
+
260
+ if ((existing as any).source !== 'standalone') {
261
+ return reply.code(400).send(errPayload('WF_NOT_STANDALONE', `Cannot update manifest-based workflow ${id}`) as any);
262
+ }
263
+
264
+ if (request.body.spec) {
265
+ await workflowService.update(id, request.body.spec);
266
+ }
267
+
268
+ if (request.body.status) {
269
+ if (request.body.status === 'paused') {
270
+ await workflowService.pause(id);
271
+ } else if (request.body.status === 'active') {
272
+ await workflowService.resume(id);
273
+ } else if (request.body.status === 'disabled') {
274
+ await workflowService.disable(id);
275
+ }
276
+ }
277
+
278
+ const workflow = await workflowService.get(id);
279
+ reply.send({ workflow } as any);
280
+ },
281
+ });
282
+
283
+ /**
284
+ * DELETE /api/v1/workflows/:id
285
+ * Delete standalone workflow
286
+ */
287
+ s.route({
288
+ method: 'DELETE',
289
+ url: `${basePath}/workflows/:id`,
290
+ schema: {
291
+ tags: ['Workflows'],
292
+ summary: 'Delete standalone workflow',
293
+ params: z.object({ id: z.string() }),
294
+ response: {
295
+ 204: z.null(),
296
+ 400: ErrorResponseSchema,
297
+ 404: ErrorResponseSchema,
298
+ },
299
+ },
300
+ handler: async (request, reply) => {
301
+ const id = request.params.id;
302
+
303
+ const existing = await workflowService.get(id);
304
+ if (!existing) {
305
+ return reply.code(404).send(errPayload('WF_NOT_FOUND', `Workflow ${id} not found`) as any);
306
+ }
307
+
308
+ if ((existing as any).source !== 'standalone') {
309
+ return reply.code(400).send(errPayload('WF_NOT_STANDALONE', `Cannot delete manifest-based workflow ${id}`) as any);
310
+ }
311
+
312
+ await workflowService.delete(id);
313
+ reply.code(204).send(null);
314
+ },
315
+ });
316
+
317
+ // ========================================================================
318
+ // Schedule Management
319
+ // ========================================================================
320
+
321
+ /**
322
+ * POST /api/v1/workflows/:id/schedule
323
+ * Enable or update workflow schedule
324
+ */
325
+ s.route({
326
+ method: 'POST',
327
+ url: `${basePath}/workflows/:id/schedule`,
328
+ schema: {
329
+ tags: ['Workflows'],
330
+ summary: 'Enable or update workflow schedule',
331
+ params: z.object({ id: z.string() }),
332
+ body: ScheduleConfigBodySchema,
333
+ response: {
334
+ 200: WorkflowResponseSchema,
335
+ 400: ErrorResponseSchema,
336
+ 404: ErrorResponseSchema,
337
+ },
338
+ },
339
+ handler: async (request, reply) => {
340
+ const id = request.params.id;
341
+ const scheduleConfig = request.body;
342
+
343
+ const existing = await workflowService.get(id);
344
+ if (!existing) {
345
+ return reply.code(404).send(errPayload('WF_NOT_FOUND', `Workflow ${id} not found`) as any);
346
+ }
347
+
348
+ if ((existing as any).source !== 'standalone') {
349
+ return reply.code(400).send(errPayload('WF_NOT_STANDALONE', `Cannot modify schedule for manifest-based workflow ${id}`) as any);
350
+ }
351
+
352
+ const workflow = await workflowService.update(id, {
353
+ on: {
354
+ schedule: scheduleConfig.enabled
355
+ ? { cron: scheduleConfig.cron, timezone: scheduleConfig.timezone }
356
+ : undefined,
357
+ },
358
+ });
359
+
360
+ reply.send({ workflow } as any);
361
+ },
362
+ });
363
+
364
+ /**
365
+ * DELETE /api/v1/workflows/:id/schedule
366
+ * Disable workflow schedule
367
+ */
368
+ s.route({
369
+ method: 'DELETE',
370
+ url: `${basePath}/workflows/:id/schedule`,
371
+ schema: {
372
+ tags: ['Workflows'],
373
+ summary: 'Disable workflow schedule',
374
+ params: z.object({ id: z.string() }),
375
+ response: {
376
+ 200: WorkflowResponseSchema,
377
+ 400: ErrorResponseSchema,
378
+ 404: ErrorResponseSchema,
379
+ },
380
+ },
381
+ handler: async (request, reply) => {
382
+ const id = request.params.id;
383
+
384
+ const existing = await workflowService.get(id);
385
+ if (!existing) {
386
+ return reply.code(404).send(errPayload('WF_NOT_FOUND', `Workflow ${id} not found`) as any);
387
+ }
388
+
389
+ if ((existing as any).source !== 'standalone') {
390
+ return reply.code(400).send(errPayload('WF_NOT_STANDALONE', `Cannot modify schedule for manifest-based workflow ${id}`) as any);
391
+ }
392
+
393
+ const workflow = await workflowService.update(id, { on: { schedule: undefined } });
394
+ reply.send({ workflow } as any);
395
+ },
396
+ });
397
+
398
+ /**
399
+ * POST /api/v1/workflows/:id/pause
400
+ * Pause workflow (disable schedule temporarily)
401
+ */
402
+ s.route({
403
+ method: 'POST',
404
+ url: `${basePath}/workflows/:id/pause`,
405
+ schema: {
406
+ tags: ['Workflows'],
407
+ summary: 'Pause workflow (disable schedule temporarily)',
408
+ params: z.object({ id: z.string() }),
409
+ response: {
410
+ 200: WorkflowResponseSchema,
411
+ 400: ErrorResponseSchema,
412
+ 404: ErrorResponseSchema,
413
+ },
414
+ },
415
+ handler: async (request, reply) => {
416
+ const id = request.params.id;
417
+
418
+ const existing = await workflowService.get(id);
419
+ if (!existing) {
420
+ return reply.code(404).send(errPayload('WF_NOT_FOUND', `Workflow ${id} not found`) as any);
421
+ }
422
+
423
+ if ((existing as any).source !== 'standalone') {
424
+ return reply.code(400).send(errPayload('WF_NOT_STANDALONE', `Cannot pause manifest-based workflow ${id}`) as any);
425
+ }
426
+
427
+ await workflowService.pause(id);
428
+ const workflow = await workflowService.get(id);
429
+ reply.send({ workflow } as any);
430
+ },
431
+ });
432
+
433
+ /**
434
+ * POST /api/v1/workflows/:id/resume
435
+ * Resume workflow (re-enable schedule)
436
+ */
437
+ s.route({
438
+ method: 'POST',
439
+ url: `${basePath}/workflows/:id/resume`,
440
+ schema: {
441
+ tags: ['Workflows'],
442
+ summary: 'Resume workflow (re-enable schedule)',
443
+ params: z.object({ id: z.string() }),
444
+ response: {
445
+ 200: WorkflowResponseSchema,
446
+ 400: ErrorResponseSchema,
447
+ 404: ErrorResponseSchema,
448
+ },
449
+ },
450
+ handler: async (request, reply) => {
451
+ const id = request.params.id;
452
+
453
+ const existing = await workflowService.get(id);
454
+ if (!existing) {
455
+ return reply.code(404).send(errPayload('WF_NOT_FOUND', `Workflow ${id} not found`) as any);
456
+ }
457
+
458
+ if ((existing as any).source !== 'standalone') {
459
+ return reply.code(400).send(errPayload('WF_NOT_STANDALONE', `Cannot resume manifest-based workflow ${id}`) as any);
460
+ }
461
+
462
+ await workflowService.resume(id);
463
+ const workflow = await workflowService.get(id);
464
+ reply.send({ workflow } as any);
465
+ },
466
+ });
467
+
468
+ }); // end encapsulated scope
469
+ }