@kb-labs/rest-api-app 1.3.0 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +2 -0
- package/dist/index.js +8151 -0
- package/dist/index.js.map +1 -0
- package/package.json +23 -20
- package/.kb/agents/sessions/session-1771531145393-ws3uh6q/turns.json +0 -42
- package/.kb/agents/sessions/session-1771548930486-ui6rtvm/turns.json +0 -33
- package/.kb/agents/sessions/session-1771549691485-nibqroq/turns.json +0 -133
- package/.kb/agents/sessions/session-1771550943182-dkwqdjc/turns.json +0 -130
- package/.kb/agents/sessions/session-1771551564182-cr4bwzn/turns.json +0 -349
- package/.kb/agents/sessions/session-1771552401370-g4ztwd1/turns.json +0 -206
- package/.kb/commit/current/plan.json +0 -248
- package/.kb/commit/current/status.json +0 -472
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/commands/health.d.ts +0 -10
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/commands/health.js +0 -215
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/commands/health.js.map +0 -1
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/commands/list.d.ts +0 -10
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/commands/list.js +0 -271
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/commands/list.js.map +0 -1
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/commands/logs.d.ts +0 -10
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/commands/logs.js +0 -230
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/commands/logs.js.map +0 -1
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/commands/metrics.d.ts +0 -10
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/commands/metrics.js +0 -228
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/commands/metrics.js.map +0 -1
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/commands/run.d.ts +0 -11
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/commands/run.js +0 -281
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/commands/run.js.map +0 -1
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/commands/status.d.ts +0 -10
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/commands/status.js +0 -266
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/commands/status.js.map +0 -1
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/commands/workflow-run.d.ts +0 -11
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/commands/workflow-run.js +0 -284
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/commands/workflow-run.js.map +0 -1
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/flags-WLdpSZl4.d.ts +0 -77
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/index.d.ts +0 -2
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/index.js +0 -441
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/index.js.map +0 -1
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/manifest.d.ts +0 -196
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/manifest.js +0 -441
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/manifest.js.map +0 -1
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/cron-list-handler.d.ts +0 -19
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/cron-list-handler.js +0 -48
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/cron-list-handler.js.map +0 -1
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/index.d.ts +0 -6
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/index.js +0 -170
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/index.js.map +0 -1
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/job-cancel-handler.d.ts +0 -12
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/job-cancel-handler.js +0 -52
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/job-cancel-handler.js.map +0 -1
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/job-detail-handler.d.ts +0 -22
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/job-detail-handler.js +0 -52
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/job-detail-handler.js.map +0 -1
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/job-logs-handler.d.ts +0 -13
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/job-logs-handler.js +0 -52
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/job-logs-handler.js.map +0 -1
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/job-steps-handler.d.ts +0 -9
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/job-steps-handler.js +0 -43
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/job-steps-handler.js.map +0 -1
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/jobs-list-handler.d.ts +0 -26
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/jobs-list-handler.js +0 -63
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/jobs-list-handler.js.map +0 -1
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/pending-approvals-handler.d.ts +0 -9
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/pending-approvals-handler.js +0 -46
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/pending-approvals-handler.js.map +0 -1
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/resolve-approval-handler.d.ts +0 -16
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/resolve-approval-handler.js +0 -58
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/resolve-approval-handler.js.map +0 -1
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/run-detail-handler.d.ts +0 -9
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/run-detail-handler.js +0 -46
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/run-detail-handler.js.map +0 -1
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/runs-list-handler.d.ts +0 -11
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/runs-list-handler.js +0 -50
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/runs-list-handler.js.map +0 -1
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/stats-handler.d.ts +0 -7
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/stats-handler.js +0 -39
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/stats-handler.js.map +0 -1
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/workflow-detail-handler.d.ts +0 -10
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/workflow-detail-handler.js +0 -46
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/workflow-detail-handler.js.map +0 -1
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/workflow-run-cancel-handler.d.ts +0 -13
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/workflow-run-cancel-handler.js +0 -47
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/workflow-run-cancel-handler.js.map +0 -1
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/workflow-run-handler.d.ts +0 -14
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/workflow-run-handler.js +0 -53
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/workflow-run-handler.js.map +0 -1
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/workflow-runs-handler.d.ts +0 -13
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/workflow-runs-handler.js +0 -54
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/workflow-runs-handler.js.map +0 -1
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/workflows-list-handler.d.ts +0 -12
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/workflows-list-handler.js +0 -51
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/workflows-list-handler.js.map +0 -1
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/ws/logs-channel.d.ts +0 -17
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/ws/logs-channel.js +0 -133
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/ws/logs-channel.js.map +0 -1
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/ws/progress-channel.d.ts +0 -11
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/ws/progress-channel.js +0 -46
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/ws/progress-channel.js.map +0 -1
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/commands/health.d.ts +0 -10
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/commands/health.js +0 -215
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/commands/health.js.map +0 -1
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/commands/list.d.ts +0 -10
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/commands/list.js +0 -271
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/commands/list.js.map +0 -1
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/commands/logs.d.ts +0 -10
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/commands/logs.js +0 -230
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/commands/logs.js.map +0 -1
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/commands/metrics.d.ts +0 -10
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/commands/metrics.js +0 -228
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/commands/metrics.js.map +0 -1
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/commands/run.d.ts +0 -11
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/commands/run.js +0 -281
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/commands/run.js.map +0 -1
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/commands/status.d.ts +0 -10
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/commands/status.js +0 -266
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/commands/status.js.map +0 -1
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/commands/workflow-run.d.ts +0 -11
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/commands/workflow-run.js +0 -284
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/commands/workflow-run.js.map +0 -1
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/flags-WLdpSZl4.d.ts +0 -77
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/index.d.ts +0 -2
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/index.js +0 -441
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/index.js.map +0 -1
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/manifest.d.ts +0 -196
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/manifest.js +0 -441
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/manifest.js.map +0 -1
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/cron-list-handler.d.ts +0 -19
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/cron-list-handler.js +0 -48
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/cron-list-handler.js.map +0 -1
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/index.d.ts +0 -6
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/index.js +0 -170
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/index.js.map +0 -1
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/job-cancel-handler.d.ts +0 -12
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/job-cancel-handler.js +0 -52
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/job-cancel-handler.js.map +0 -1
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/job-detail-handler.d.ts +0 -22
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/job-detail-handler.js +0 -52
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/job-detail-handler.js.map +0 -1
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/job-logs-handler.d.ts +0 -13
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/job-logs-handler.js +0 -52
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/job-logs-handler.js.map +0 -1
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/job-steps-handler.d.ts +0 -9
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/job-steps-handler.js +0 -43
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/job-steps-handler.js.map +0 -1
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/jobs-list-handler.d.ts +0 -26
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/jobs-list-handler.js +0 -63
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/jobs-list-handler.js.map +0 -1
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/pending-approvals-handler.d.ts +0 -9
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/pending-approvals-handler.js +0 -46
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/pending-approvals-handler.js.map +0 -1
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/resolve-approval-handler.d.ts +0 -16
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/resolve-approval-handler.js +0 -58
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/resolve-approval-handler.js.map +0 -1
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/run-detail-handler.d.ts +0 -9
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/run-detail-handler.js +0 -46
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/run-detail-handler.js.map +0 -1
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/runs-list-handler.d.ts +0 -11
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/runs-list-handler.js +0 -50
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/runs-list-handler.js.map +0 -1
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/stats-handler.d.ts +0 -7
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/stats-handler.js +0 -39
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/stats-handler.js.map +0 -1
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/workflow-detail-handler.d.ts +0 -10
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/workflow-detail-handler.js +0 -46
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/workflow-detail-handler.js.map +0 -1
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/workflow-run-cancel-handler.d.ts +0 -13
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/workflow-run-cancel-handler.js +0 -47
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/workflow-run-cancel-handler.js.map +0 -1
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/workflow-run-handler.d.ts +0 -14
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/workflow-run-handler.js +0 -53
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/workflow-run-handler.js.map +0 -1
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/workflow-runs-handler.d.ts +0 -13
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/workflow-runs-handler.js +0 -54
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/workflow-runs-handler.js.map +0 -1
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/workflows-list-handler.d.ts +0 -12
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/workflows-list-handler.js +0 -51
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/workflows-list-handler.js.map +0 -1
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/ws/logs-channel.d.ts +0 -17
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/ws/logs-channel.js +0 -133
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/ws/logs-channel.js.map +0 -1
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/ws/progress-channel.d.ts +0 -11
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/ws/progress-channel.js +0 -46
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/ws/progress-channel.js.map +0 -1
- package/eslint.config.js +0 -23
- package/src/.kb/agents/sessions/session-1773470583796-ximqnfk/kpi-baseline.json +0 -17
- package/src/.kb/memory/sessions/session-1773470583796-ximqnfk/fact-sheet.json +0 -1
- package/src/bootstrap.ts +0 -233
- package/src/diagnostics/header-debug.ts +0 -37
- package/src/events/hub.ts +0 -60
- package/src/events/index.ts +0 -1
- package/src/index.ts +0 -13
- package/src/manifest.ts +0 -21
- package/src/middleware/__tests__/cache.spec.ts +0 -184
- package/src/middleware/__tests__/envelope.spec.ts +0 -268
- package/src/middleware/__tests__/metrics.redis.spec.ts +0 -64
- package/src/middleware/__tests__/rate-limit.spec.ts +0 -283
- package/src/middleware/__tests__/request-id.spec.ts +0 -160
- package/src/middleware/cache.ts +0 -67
- package/src/middleware/envelope.ts +0 -136
- package/src/middleware/error-guard.ts +0 -69
- package/src/middleware/index.ts +0 -37
- package/src/middleware/metrics.ts +0 -810
- package/src/middleware/mock-mode.ts +0 -44
- package/src/middleware/prom-metrics.ts +0 -284
- package/src/middleware/rate-limit-routes.ts +0 -73
- package/src/middleware/rate-limit.ts +0 -72
- package/src/middleware/request-id.ts +0 -41
- package/src/middleware/request-timeout.ts +0 -69
- package/src/middleware/security-headers.ts +0 -24
- package/src/middleware/startup-guard.ts +0 -107
- package/src/observability/service-contract.ts +0 -192
- package/src/plugins/index.ts +0 -118
- package/src/routes/__tests__/adapters-date-helpers.spec.ts +0 -332
- package/src/routes/__tests__/adapters.spec.ts +0 -680
- package/src/routes/__tests__/cache.spec.ts +0 -264
- package/src/routes/__tests__/events.spec.ts +0 -434
- package/src/routes/__tests__/health.spec.ts +0 -414
- package/src/routes/__tests__/logs.spec.ts +0 -494
- package/src/routes/__tests__/observability.spec.ts +0 -392
- package/src/routes/__tests__/plugins.spec.ts +0 -931
- package/src/routes/__tests__/workflow-management.spec.ts +0 -698
- package/src/routes/__tests__/workflows.spec.ts +0 -204
- package/src/routes/adapter-call.ts +0 -220
- package/src/routes/adapters.ts +0 -1206
- package/src/routes/analytics.ts +0 -328
- package/src/routes/cache.ts +0 -104
- package/src/routes/debug-routes.ts +0 -95
- package/src/routes/events.ts +0 -115
- package/src/routes/health.ts +0 -348
- package/src/routes/hello.ts +0 -47
- package/src/routes/index.ts +0 -395
- package/src/routes/jobs.ts +0 -253
- package/src/routes/logs.ts +0 -718
- package/src/routes/metrics.ts +0 -120
- package/src/routes/observability.ts +0 -1388
- package/src/routes/openapi.ts +0 -101
- package/src/routes/platform.ts +0 -143
- package/src/routes/plugins.ts +0 -998
- package/src/routes/readiness.ts +0 -83
- package/src/routes/workflow-management.ts +0 -469
- package/src/routes/workflows.ts +0 -256
- package/src/server.ts +0 -203
- package/src/services/historical-metrics.ts +0 -496
- package/src/services/incident-analyzer.ts +0 -289
- package/src/services/incident-detector.ts +0 -691
- package/src/services/incident-schema.sql +0 -76
- package/src/services/incident-storage.ts +0 -593
- package/src/services/system-metrics-collector.ts +0 -244
- package/src/types/fastify.d.ts +0 -58
- package/src/utils/__tests__/sse-auth.spec.ts +0 -113
- package/src/utils/path-helpers.ts +0 -15
- package/src/utils/repo.ts +0 -42
- package/src/utils/schema.ts +0 -20
- package/src/utils/sse-auth.ts +0 -81
- package/test-sandbox.sh +0 -105
- package/tsconfig.build.json +0 -15
- package/tsconfig.json +0 -9
- package/tsup.config.ts +0 -18
|
@@ -1,264 +0,0 @@
|
|
|
1
|
-
import { beforeEach, describe, expect, it, vi, afterEach } from 'vitest';
|
|
2
|
-
import Fastify from 'fastify';
|
|
3
|
-
import type { IEntityRegistry, RegistrySnapshot } from '@kb-labs/core-registry';
|
|
4
|
-
import type { RestApiConfig } from '@kb-labs/rest-api-core';
|
|
5
|
-
import { registerCacheRoutes } from '../cache';
|
|
6
|
-
|
|
7
|
-
const BASE_CONFIG: RestApiConfig = {
|
|
8
|
-
port: 3000,
|
|
9
|
-
basePath: '/api/v1',
|
|
10
|
-
apiVersion: 'test',
|
|
11
|
-
cors: {
|
|
12
|
-
origins: [],
|
|
13
|
-
allowCredentials: true,
|
|
14
|
-
profile: 'dev',
|
|
15
|
-
},
|
|
16
|
-
plugins: [],
|
|
17
|
-
mockMode: false,
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
function createMockSnapshot(rev: number): RegistrySnapshot {
|
|
21
|
-
return {
|
|
22
|
-
schema: 'kb.registry/1',
|
|
23
|
-
rev,
|
|
24
|
-
version: '1.0.0',
|
|
25
|
-
generatedAt: new Date().toISOString(),
|
|
26
|
-
expiresAt: new Date(Date.now() + 60_000).toISOString(),
|
|
27
|
-
ttlMs: 60_000,
|
|
28
|
-
partial: false,
|
|
29
|
-
stale: false,
|
|
30
|
-
source: { platformVersion: 'test', cwd: process.cwd() },
|
|
31
|
-
corrupted: false,
|
|
32
|
-
plugins: [],
|
|
33
|
-
manifests: [],
|
|
34
|
-
ts: Date.now(),
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
describe('registerCacheRoutes', () => {
|
|
39
|
-
let app: ReturnType<typeof Fastify>;
|
|
40
|
-
let mockCliApi: IEntityRegistry;
|
|
41
|
-
|
|
42
|
-
beforeEach(async () => {
|
|
43
|
-
vi.clearAllMocks();
|
|
44
|
-
app = Fastify({ logger: false });
|
|
45
|
-
|
|
46
|
-
mockCliApi = {
|
|
47
|
-
snapshot: vi.fn(),
|
|
48
|
-
refresh: vi.fn(),
|
|
49
|
-
listPlugins: vi.fn(),
|
|
50
|
-
} as unknown as IEntityRegistry;
|
|
51
|
-
|
|
52
|
-
await registerCacheRoutes(app, BASE_CONFIG, mockCliApi);
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
afterEach(async () => {
|
|
56
|
-
await app.close();
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
describe('POST /api/v1/cache/invalidate', () => {
|
|
60
|
-
it('successfully invalidates cache and refreshes registry', async () => {
|
|
61
|
-
const beforeSnapshot = createMockSnapshot(1);
|
|
62
|
-
const afterSnapshot = createMockSnapshot(2);
|
|
63
|
-
const plugins = [
|
|
64
|
-
{ id: '@kb-labs/plugin-1', version: '1.0.0', source: { kind: 'local' as const, path: '/plugins/plugin-1' } },
|
|
65
|
-
{ id: '@kb-labs/plugin-2', version: '1.0.0', source: { kind: 'local' as const, path: '/plugins/plugin-2' } },
|
|
66
|
-
];
|
|
67
|
-
|
|
68
|
-
vi.mocked(mockCliApi.snapshot)
|
|
69
|
-
.mockReturnValueOnce(beforeSnapshot)
|
|
70
|
-
.mockReturnValueOnce(afterSnapshot);
|
|
71
|
-
vi.mocked(mockCliApi.refresh).mockResolvedValue(undefined);
|
|
72
|
-
vi.mocked(mockCliApi.listPlugins).mockResolvedValue(plugins);
|
|
73
|
-
|
|
74
|
-
const response = await app.inject({
|
|
75
|
-
method: 'POST',
|
|
76
|
-
url: '/api/v1/cache/invalidate',
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
expect(response.statusCode).toBe(200);
|
|
80
|
-
const payload = response.json();
|
|
81
|
-
|
|
82
|
-
expect(payload.ok).toBe(true);
|
|
83
|
-
expect(payload.data.invalidated).toBe(true);
|
|
84
|
-
expect(payload.data.previousRev).toBe(1);
|
|
85
|
-
expect(payload.data.newRev).toBe(2);
|
|
86
|
-
expect(payload.data.pluginsDiscovered).toBe(2);
|
|
87
|
-
expect(payload.data.timestamp).toBeDefined();
|
|
88
|
-
expect(payload.meta.requestId).toBeDefined();
|
|
89
|
-
expect(payload.meta.durationMs).toBeGreaterThanOrEqual(0);
|
|
90
|
-
expect(payload.meta.apiVersion).toBe('1.0.0');
|
|
91
|
-
|
|
92
|
-
expect(mockCliApi.snapshot).toHaveBeenCalledTimes(2);
|
|
93
|
-
expect(mockCliApi.refresh).toHaveBeenCalledTimes(1);
|
|
94
|
-
expect(mockCliApi.listPlugins).toHaveBeenCalledTimes(1);
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
it('returns previous and new revision numbers', async () => {
|
|
98
|
-
const beforeSnapshot = createMockSnapshot(42);
|
|
99
|
-
const afterSnapshot = createMockSnapshot(43);
|
|
100
|
-
|
|
101
|
-
vi.mocked(mockCliApi.snapshot)
|
|
102
|
-
.mockReturnValueOnce(beforeSnapshot)
|
|
103
|
-
.mockReturnValueOnce(afterSnapshot);
|
|
104
|
-
vi.mocked(mockCliApi.refresh).mockResolvedValue(undefined);
|
|
105
|
-
vi.mocked(mockCliApi.listPlugins).mockResolvedValue([]);
|
|
106
|
-
|
|
107
|
-
const response = await app.inject({
|
|
108
|
-
method: 'POST',
|
|
109
|
-
url: '/api/v1/cache/invalidate',
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
expect(response.statusCode).toBe(200);
|
|
113
|
-
const payload = response.json();
|
|
114
|
-
expect(payload.data.previousRev).toBe(42);
|
|
115
|
-
expect(payload.data.newRev).toBe(43);
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
it('includes plugin registry count', async () => {
|
|
119
|
-
const snapshot = createMockSnapshot(1);
|
|
120
|
-
const plugins = Array.from({ length: 15 }, (_, i) => ({
|
|
121
|
-
id: `@kb-labs/plugin-${i}`,
|
|
122
|
-
version: '1.0.0',
|
|
123
|
-
source: { kind: 'local' as const, path: `/plugins/plugin-${i}` },
|
|
124
|
-
}));
|
|
125
|
-
|
|
126
|
-
vi.mocked(mockCliApi.snapshot).mockReturnValue(snapshot);
|
|
127
|
-
vi.mocked(mockCliApi.refresh).mockResolvedValue(undefined);
|
|
128
|
-
vi.mocked(mockCliApi.listPlugins).mockResolvedValue(plugins);
|
|
129
|
-
|
|
130
|
-
const response = await app.inject({
|
|
131
|
-
method: 'POST',
|
|
132
|
-
url: '/api/v1/cache/invalidate',
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
expect(response.statusCode).toBe(200);
|
|
136
|
-
const payload = response.json();
|
|
137
|
-
expect(payload.data.pluginsDiscovered).toBe(15);
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
it('handles cache refresh errors gracefully', async () => {
|
|
141
|
-
const beforeSnapshot = createMockSnapshot(1);
|
|
142
|
-
const error = new Error('Registry refresh failed');
|
|
143
|
-
|
|
144
|
-
vi.mocked(mockCliApi.snapshot).mockReturnValue(beforeSnapshot);
|
|
145
|
-
vi.mocked(mockCliApi.refresh).mockRejectedValue(error);
|
|
146
|
-
|
|
147
|
-
const response = await app.inject({
|
|
148
|
-
method: 'POST',
|
|
149
|
-
url: '/api/v1/cache/invalidate',
|
|
150
|
-
});
|
|
151
|
-
|
|
152
|
-
expect(response.statusCode).toBe(500);
|
|
153
|
-
const payload = response.json();
|
|
154
|
-
|
|
155
|
-
expect(payload.ok).toBe(false);
|
|
156
|
-
expect(payload.error.code).toBe('CACHE_INVALIDATION_FAILED');
|
|
157
|
-
expect(payload.error.message).toBe('Registry refresh failed');
|
|
158
|
-
expect(payload.meta.requestId).toBeDefined();
|
|
159
|
-
expect(payload.meta.durationMs).toBeGreaterThanOrEqual(0);
|
|
160
|
-
|
|
161
|
-
expect(mockCliApi.refresh).toHaveBeenCalledTimes(1);
|
|
162
|
-
expect(mockCliApi.listPlugins).not.toHaveBeenCalled();
|
|
163
|
-
});
|
|
164
|
-
|
|
165
|
-
it('handles non-Error exceptions', async () => {
|
|
166
|
-
const beforeSnapshot = createMockSnapshot(1);
|
|
167
|
-
|
|
168
|
-
vi.mocked(mockCliApi.snapshot).mockReturnValue(beforeSnapshot);
|
|
169
|
-
vi.mocked(mockCliApi.refresh).mockRejectedValue('String error');
|
|
170
|
-
|
|
171
|
-
const response = await app.inject({
|
|
172
|
-
method: 'POST',
|
|
173
|
-
url: '/api/v1/cache/invalidate',
|
|
174
|
-
});
|
|
175
|
-
|
|
176
|
-
expect(response.statusCode).toBe(500);
|
|
177
|
-
const payload = response.json();
|
|
178
|
-
|
|
179
|
-
expect(payload.ok).toBe(false);
|
|
180
|
-
expect(payload.error.code).toBe('CACHE_INVALIDATION_FAILED');
|
|
181
|
-
expect(payload.error.message).toBe('Cache invalidation failed');
|
|
182
|
-
});
|
|
183
|
-
|
|
184
|
-
it('handles snapshot() errors', async () => {
|
|
185
|
-
vi.mocked(mockCliApi.snapshot).mockImplementation(() => {
|
|
186
|
-
throw new Error('Registry snapshot unavailable');
|
|
187
|
-
});
|
|
188
|
-
|
|
189
|
-
const response = await app.inject({
|
|
190
|
-
method: 'POST',
|
|
191
|
-
url: '/api/v1/cache/invalidate',
|
|
192
|
-
});
|
|
193
|
-
|
|
194
|
-
expect(response.statusCode).toBe(500);
|
|
195
|
-
const payload = response.json();
|
|
196
|
-
expect(payload.ok).toBe(false);
|
|
197
|
-
expect(payload.error.message).toBe('Registry snapshot unavailable');
|
|
198
|
-
});
|
|
199
|
-
|
|
200
|
-
it('tracks request timing in metadata', async () => {
|
|
201
|
-
const snapshot = createMockSnapshot(1);
|
|
202
|
-
|
|
203
|
-
vi.mocked(mockCliApi.snapshot).mockReturnValue(snapshot);
|
|
204
|
-
vi.mocked(mockCliApi.refresh).mockImplementation(async () => {
|
|
205
|
-
await new Promise((resolve) => {
|
|
206
|
-
setTimeout(resolve, 10);
|
|
207
|
-
});
|
|
208
|
-
});
|
|
209
|
-
vi.mocked(mockCliApi.listPlugins).mockResolvedValue([]);
|
|
210
|
-
|
|
211
|
-
const response = await app.inject({
|
|
212
|
-
method: 'POST',
|
|
213
|
-
url: '/api/v1/cache/invalidate',
|
|
214
|
-
});
|
|
215
|
-
|
|
216
|
-
expect(response.statusCode).toBe(200);
|
|
217
|
-
const payload = response.json();
|
|
218
|
-
expect(payload.meta.durationMs).toBeGreaterThanOrEqual(10);
|
|
219
|
-
});
|
|
220
|
-
|
|
221
|
-
it('includes timestamp in ISO format', async () => {
|
|
222
|
-
const snapshot = createMockSnapshot(1);
|
|
223
|
-
|
|
224
|
-
vi.mocked(mockCliApi.snapshot).mockReturnValue(snapshot);
|
|
225
|
-
vi.mocked(mockCliApi.refresh).mockResolvedValue(undefined);
|
|
226
|
-
vi.mocked(mockCliApi.listPlugins).mockResolvedValue([]);
|
|
227
|
-
|
|
228
|
-
const before = new Date();
|
|
229
|
-
const response = await app.inject({
|
|
230
|
-
method: 'POST',
|
|
231
|
-
url: '/api/v1/cache/invalidate',
|
|
232
|
-
});
|
|
233
|
-
const after = new Date();
|
|
234
|
-
|
|
235
|
-
expect(response.statusCode).toBe(200);
|
|
236
|
-
const payload = response.json();
|
|
237
|
-
const timestamp = new Date(payload.data.timestamp);
|
|
238
|
-
|
|
239
|
-
expect(timestamp).toBeInstanceOf(Date);
|
|
240
|
-
expect(timestamp.getTime()).toBeGreaterThanOrEqual(before.getTime());
|
|
241
|
-
expect(timestamp.getTime()).toBeLessThanOrEqual(after.getTime());
|
|
242
|
-
});
|
|
243
|
-
|
|
244
|
-
it('handles empty plugin list after refresh', async () => {
|
|
245
|
-
const beforeSnapshot = createMockSnapshot(1);
|
|
246
|
-
const afterSnapshot = createMockSnapshot(2);
|
|
247
|
-
|
|
248
|
-
vi.mocked(mockCliApi.snapshot)
|
|
249
|
-
.mockReturnValueOnce(beforeSnapshot)
|
|
250
|
-
.mockReturnValueOnce(afterSnapshot);
|
|
251
|
-
vi.mocked(mockCliApi.refresh).mockResolvedValue(undefined);
|
|
252
|
-
vi.mocked(mockCliApi.listPlugins).mockResolvedValue([]);
|
|
253
|
-
|
|
254
|
-
const response = await app.inject({
|
|
255
|
-
method: 'POST',
|
|
256
|
-
url: '/api/v1/cache/invalidate',
|
|
257
|
-
});
|
|
258
|
-
|
|
259
|
-
expect(response.statusCode).toBe(200);
|
|
260
|
-
const payload = response.json();
|
|
261
|
-
expect(payload.data.pluginsDiscovered).toBe(0);
|
|
262
|
-
});
|
|
263
|
-
});
|
|
264
|
-
});
|
|
@@ -1,434 +0,0 @@
|
|
|
1
|
-
import { beforeEach, describe, expect, it, vi, afterEach } from 'vitest';
|
|
2
|
-
import Fastify from 'fastify';
|
|
3
|
-
import type { IEntityRegistry, RegistrySnapshot, SystemHealthSnapshot } from '@kb-labs/core-registry';
|
|
4
|
-
import type { RestApiConfig } from '@kb-labs/rest-api-core';
|
|
5
|
-
import type { EventHub, BroadcastEvent } from '../../events/hub';
|
|
6
|
-
import type { ReadinessState } from '../readiness';
|
|
7
|
-
import { registerEventRoutes } from '../events';
|
|
8
|
-
|
|
9
|
-
// Mock dependencies
|
|
10
|
-
vi.mock('../../middleware/metrics', () => ({
|
|
11
|
-
metricsCollector: {
|
|
12
|
-
getLastPluginMountSnapshot: vi.fn(() => ({
|
|
13
|
-
succeeded: 5,
|
|
14
|
-
failed: 1,
|
|
15
|
-
})),
|
|
16
|
-
},
|
|
17
|
-
}));
|
|
18
|
-
|
|
19
|
-
vi.mock('../../utils/sse-auth', () => ({
|
|
20
|
-
buildRegistrySseAuthHook: vi.fn(() => null),
|
|
21
|
-
}));
|
|
22
|
-
|
|
23
|
-
const BASE_CONFIG: RestApiConfig = {
|
|
24
|
-
port: 3000,
|
|
25
|
-
basePath: '/api/v1',
|
|
26
|
-
apiVersion: 'test',
|
|
27
|
-
cors: {
|
|
28
|
-
origins: [],
|
|
29
|
-
allowCredentials: true,
|
|
30
|
-
profile: 'dev',
|
|
31
|
-
},
|
|
32
|
-
plugins: [],
|
|
33
|
-
mockMode: false,
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
function createMockSnapshot(): RegistrySnapshot {
|
|
37
|
-
return {
|
|
38
|
-
schema: 'kb.registry/1',
|
|
39
|
-
rev: 42,
|
|
40
|
-
version: '1.0.0',
|
|
41
|
-
generatedAt: new Date().toISOString(),
|
|
42
|
-
expiresAt: new Date(Date.now() + 60_000).toISOString(),
|
|
43
|
-
ttlMs: 60_000,
|
|
44
|
-
partial: false,
|
|
45
|
-
stale: false,
|
|
46
|
-
source: { platformVersion: 'test', cwd: process.cwd() },
|
|
47
|
-
corrupted: false,
|
|
48
|
-
plugins: [],
|
|
49
|
-
manifests: [],
|
|
50
|
-
ts: Date.now(),
|
|
51
|
-
checksum: 'abc123',
|
|
52
|
-
checksumAlgorithm: 'sha256',
|
|
53
|
-
previousChecksum: 'def456',
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
function createMockHealthSnapshot(): SystemHealthSnapshot {
|
|
58
|
-
return {
|
|
59
|
-
schema: 'kb.health/1',
|
|
60
|
-
ts: new Date().toISOString(),
|
|
61
|
-
uptimeSec: 42,
|
|
62
|
-
version: {
|
|
63
|
-
kbLabs: '1.0.0',
|
|
64
|
-
rest: '1.0.0',
|
|
65
|
-
},
|
|
66
|
-
registry: {
|
|
67
|
-
total: 5,
|
|
68
|
-
withRest: 3,
|
|
69
|
-
withStudio: 2,
|
|
70
|
-
errors: 0,
|
|
71
|
-
generatedAt: new Date().toISOString(),
|
|
72
|
-
expiresAt: new Date(Date.now() + 60_000).toISOString(),
|
|
73
|
-
partial: false,
|
|
74
|
-
stale: false,
|
|
75
|
-
},
|
|
76
|
-
status: 'healthy',
|
|
77
|
-
components: [],
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
function createMockReadinessState(): ReadinessState {
|
|
82
|
-
return {
|
|
83
|
-
cliApiInitialized: true,
|
|
84
|
-
registryLoaded: true,
|
|
85
|
-
registryPartial: false,
|
|
86
|
-
registryStale: false,
|
|
87
|
-
pluginRoutesMounted: true,
|
|
88
|
-
pluginMountInProgress: false,
|
|
89
|
-
pluginRoutesCount: 5,
|
|
90
|
-
pluginRouteErrors: 0,
|
|
91
|
-
pluginRouteFailures: [],
|
|
92
|
-
lastPluginMountTs: new Date().toISOString(),
|
|
93
|
-
pluginRoutesLastDurationMs: 128,
|
|
94
|
-
redisEnabled: false,
|
|
95
|
-
redisConnected: false,
|
|
96
|
-
redisStates: {
|
|
97
|
-
publisher: null,
|
|
98
|
-
subscriber: null,
|
|
99
|
-
cache: null,
|
|
100
|
-
},
|
|
101
|
-
};
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
describe('registerEventRoutes', () => {
|
|
105
|
-
let app: ReturnType<typeof Fastify>;
|
|
106
|
-
let mockCliApi: IEntityRegistry;
|
|
107
|
-
let mockEventHub: EventHub;
|
|
108
|
-
let readiness: ReadinessState;
|
|
109
|
-
let subscribers: Array<(event: BroadcastEvent) => void> = [];
|
|
110
|
-
|
|
111
|
-
beforeEach(async () => {
|
|
112
|
-
vi.clearAllMocks();
|
|
113
|
-
subscribers = [];
|
|
114
|
-
app = Fastify({ logger: false });
|
|
115
|
-
|
|
116
|
-
mockCliApi = {
|
|
117
|
-
snapshot: vi.fn(() => createMockSnapshot()),
|
|
118
|
-
getSystemHealth: vi.fn(() => Promise.resolve(createMockHealthSnapshot())),
|
|
119
|
-
getRedisStatus: vi.fn(() => ({
|
|
120
|
-
enabled: false,
|
|
121
|
-
healthy: true,
|
|
122
|
-
roles: {
|
|
123
|
-
publisher: null,
|
|
124
|
-
subscriber: null,
|
|
125
|
-
cache: null,
|
|
126
|
-
},
|
|
127
|
-
})),
|
|
128
|
-
} as unknown as IEntityRegistry;
|
|
129
|
-
|
|
130
|
-
mockEventHub = {
|
|
131
|
-
subscribe: vi.fn((callback: (event: BroadcastEvent) => void) => {
|
|
132
|
-
subscribers.push(callback);
|
|
133
|
-
return () => {
|
|
134
|
-
const index = subscribers.indexOf(callback);
|
|
135
|
-
if (index > -1) {subscribers.splice(index, 1);}
|
|
136
|
-
};
|
|
137
|
-
}),
|
|
138
|
-
publish: vi.fn((event: BroadcastEvent) => {
|
|
139
|
-
subscribers.forEach((sub) => sub(event));
|
|
140
|
-
}),
|
|
141
|
-
} as any;
|
|
142
|
-
|
|
143
|
-
readiness = createMockReadinessState();
|
|
144
|
-
|
|
145
|
-
await registerEventRoutes(
|
|
146
|
-
app,
|
|
147
|
-
'/api/v1',
|
|
148
|
-
mockCliApi,
|
|
149
|
-
readiness,
|
|
150
|
-
mockEventHub,
|
|
151
|
-
BASE_CONFIG
|
|
152
|
-
);
|
|
153
|
-
});
|
|
154
|
-
|
|
155
|
-
afterEach(async () => {
|
|
156
|
-
await app.close();
|
|
157
|
-
});
|
|
158
|
-
|
|
159
|
-
describe('GET /api/v1/events/registry', () => {
|
|
160
|
-
it('returns SSE stream with correct headers', async () => {
|
|
161
|
-
const response = await app.inject({
|
|
162
|
-
method: 'GET',
|
|
163
|
-
url: '/api/v1/events/registry',
|
|
164
|
-
});
|
|
165
|
-
|
|
166
|
-
// SSE uses response hijacking, so status code is 0
|
|
167
|
-
// Check headers instead
|
|
168
|
-
expect(response.headers['content-type']).toBe('text/event-stream');
|
|
169
|
-
expect(response.headers['cache-control']).toBe('no-cache, no-transform');
|
|
170
|
-
expect(response.headers['connection']).toBe('keep-alive');
|
|
171
|
-
});
|
|
172
|
-
|
|
173
|
-
it('sends initial registry event', async () => {
|
|
174
|
-
const snapshot = createMockSnapshot();
|
|
175
|
-
vi.mocked(mockCliApi.snapshot).mockReturnValue(snapshot);
|
|
176
|
-
|
|
177
|
-
const response = await app.inject({
|
|
178
|
-
method: 'GET',
|
|
179
|
-
url: '/api/v1/events/registry',
|
|
180
|
-
});
|
|
181
|
-
|
|
182
|
-
const body = response.body;
|
|
183
|
-
expect(body).toContain('event: registry');
|
|
184
|
-
expect(body).toContain('"rev":42');
|
|
185
|
-
expect(body).toContain('"partial":false');
|
|
186
|
-
expect(body).toContain('"stale":false');
|
|
187
|
-
expect(body).toContain('"checksum":"abc123"');
|
|
188
|
-
expect(body).toContain('"checksumAlgorithm":"sha256"');
|
|
189
|
-
});
|
|
190
|
-
|
|
191
|
-
it('sends health event after registry event', async () => {
|
|
192
|
-
const health = createMockHealthSnapshot();
|
|
193
|
-
vi.mocked(mockCliApi.getSystemHealth).mockResolvedValue(health);
|
|
194
|
-
|
|
195
|
-
const response = await app.inject({
|
|
196
|
-
method: 'GET',
|
|
197
|
-
url: '/api/v1/events/registry',
|
|
198
|
-
});
|
|
199
|
-
|
|
200
|
-
// Wait for async health fetch
|
|
201
|
-
await new Promise((resolve) => {
|
|
202
|
-
setTimeout(resolve, 10);
|
|
203
|
-
});
|
|
204
|
-
|
|
205
|
-
const body = response.body;
|
|
206
|
-
expect(body).toContain('event: health');
|
|
207
|
-
expect(body).toContain('"status":"healthy"');
|
|
208
|
-
expect(body).toContain('"ready":true');
|
|
209
|
-
expect(body).toContain('"pluginRoutesMounted":true');
|
|
210
|
-
});
|
|
211
|
-
|
|
212
|
-
it('subscribes to event hub', async () => {
|
|
213
|
-
await app.inject({
|
|
214
|
-
method: 'GET',
|
|
215
|
-
url: '/api/v1/events/registry',
|
|
216
|
-
});
|
|
217
|
-
|
|
218
|
-
expect(mockEventHub.subscribe).toHaveBeenCalledTimes(1);
|
|
219
|
-
expect(mockEventHub.subscribe).toHaveBeenCalledWith(expect.any(Function));
|
|
220
|
-
});
|
|
221
|
-
|
|
222
|
-
it('includes Redis status in health event when Redis is enabled', async () => {
|
|
223
|
-
vi.mocked((mockCliApi as any).getRedisStatus).mockReturnValue({
|
|
224
|
-
enabled: true,
|
|
225
|
-
healthy: true,
|
|
226
|
-
roles: {
|
|
227
|
-
publisher: 'ready',
|
|
228
|
-
subscriber: 'ready',
|
|
229
|
-
cache: 'ready',
|
|
230
|
-
},
|
|
231
|
-
});
|
|
232
|
-
|
|
233
|
-
const response = await app.inject({
|
|
234
|
-
method: 'GET',
|
|
235
|
-
url: '/api/v1/events/registry',
|
|
236
|
-
});
|
|
237
|
-
|
|
238
|
-
await new Promise((resolve) => {
|
|
239
|
-
setTimeout(resolve, 10);
|
|
240
|
-
});
|
|
241
|
-
|
|
242
|
-
const body = response.body;
|
|
243
|
-
expect(body).toContain('"redisEnabled":true');
|
|
244
|
-
expect(body).toContain('"redisHealthy":true');
|
|
245
|
-
expect(body).toContain('"publisher":"ready"');
|
|
246
|
-
});
|
|
247
|
-
|
|
248
|
-
it('includes plugin mount statistics in health event', async () => {
|
|
249
|
-
const response = await app.inject({
|
|
250
|
-
method: 'GET',
|
|
251
|
-
url: '/api/v1/events/registry',
|
|
252
|
-
});
|
|
253
|
-
|
|
254
|
-
await new Promise((resolve) => {
|
|
255
|
-
setTimeout(resolve, 10);
|
|
256
|
-
});
|
|
257
|
-
|
|
258
|
-
const body = response.body;
|
|
259
|
-
expect(body).toContain('"pluginsMounted":5');
|
|
260
|
-
expect(body).toContain('"pluginsFailed":1');
|
|
261
|
-
expect(body).toContain('"pluginRoutesLastDurationMs":128');
|
|
262
|
-
});
|
|
263
|
-
|
|
264
|
-
it('includes readiness state in health event', async () => {
|
|
265
|
-
readiness.registryPartial = true;
|
|
266
|
-
readiness.pluginMountInProgress = true;
|
|
267
|
-
|
|
268
|
-
const response = await app.inject({
|
|
269
|
-
method: 'GET',
|
|
270
|
-
url: '/api/v1/events/registry',
|
|
271
|
-
});
|
|
272
|
-
|
|
273
|
-
await new Promise((resolve) => {
|
|
274
|
-
setTimeout(resolve, 10);
|
|
275
|
-
});
|
|
276
|
-
|
|
277
|
-
const body = response.body;
|
|
278
|
-
expect(body).toContain('"registryPartial":true');
|
|
279
|
-
expect(body).toContain('"pluginMountInProgress":true');
|
|
280
|
-
expect(body).toContain('"reason":"plugin_mount_in_progress"');
|
|
281
|
-
});
|
|
282
|
-
|
|
283
|
-
it('handles system health fetch errors gracefully', async () => {
|
|
284
|
-
vi.mocked(mockCliApi.getSystemHealth).mockRejectedValue(
|
|
285
|
-
new Error('Health fetch failed')
|
|
286
|
-
);
|
|
287
|
-
|
|
288
|
-
const response = await app.inject({
|
|
289
|
-
method: 'GET',
|
|
290
|
-
url: '/api/v1/events/registry',
|
|
291
|
-
});
|
|
292
|
-
|
|
293
|
-
await new Promise((resolve) => {
|
|
294
|
-
setTimeout(resolve, 10);
|
|
295
|
-
});
|
|
296
|
-
|
|
297
|
-
// Should still send registry event, just not health event
|
|
298
|
-
const body = response.body;
|
|
299
|
-
expect(body).toContain('event: registry');
|
|
300
|
-
// Should not crash
|
|
301
|
-
});
|
|
302
|
-
|
|
303
|
-
it('sets CORS headers for localhost:3000 origin', async () => {
|
|
304
|
-
const response = await app.inject({
|
|
305
|
-
method: 'GET',
|
|
306
|
-
url: '/api/v1/events/registry',
|
|
307
|
-
headers: {
|
|
308
|
-
origin: 'http://localhost:3000',
|
|
309
|
-
},
|
|
310
|
-
});
|
|
311
|
-
|
|
312
|
-
expect(response.headers['access-control-allow-origin']).toBe(
|
|
313
|
-
'http://localhost:3000'
|
|
314
|
-
);
|
|
315
|
-
expect(response.headers['access-control-allow-credentials']).toBe('true');
|
|
316
|
-
});
|
|
317
|
-
|
|
318
|
-
it('sets CORS headers for localhost:5173 origin (Vite dev)', async () => {
|
|
319
|
-
const response = await app.inject({
|
|
320
|
-
method: 'GET',
|
|
321
|
-
url: '/api/v1/events/registry',
|
|
322
|
-
headers: {
|
|
323
|
-
origin: 'http://localhost:5173',
|
|
324
|
-
},
|
|
325
|
-
});
|
|
326
|
-
|
|
327
|
-
expect(response.headers['access-control-allow-origin']).toBe(
|
|
328
|
-
'http://localhost:5173'
|
|
329
|
-
);
|
|
330
|
-
expect(response.headers['access-control-allow-credentials']).toBe('true');
|
|
331
|
-
});
|
|
332
|
-
|
|
333
|
-
it('does not set CORS headers for other origins', async () => {
|
|
334
|
-
const response = await app.inject({
|
|
335
|
-
method: 'GET',
|
|
336
|
-
url: '/api/v1/events/registry',
|
|
337
|
-
headers: {
|
|
338
|
-
origin: 'http://evil.com',
|
|
339
|
-
},
|
|
340
|
-
});
|
|
341
|
-
|
|
342
|
-
expect(response.headers['access-control-allow-origin']).toBeUndefined();
|
|
343
|
-
});
|
|
344
|
-
|
|
345
|
-
it('handles snapshot with missing checksum fields', async () => {
|
|
346
|
-
const snapshot = createMockSnapshot();
|
|
347
|
-
delete (snapshot as any).checksum;
|
|
348
|
-
delete (snapshot as any).checksumAlgorithm;
|
|
349
|
-
delete (snapshot as any).previousChecksum;
|
|
350
|
-
|
|
351
|
-
vi.mocked(mockCliApi.snapshot).mockReturnValue(snapshot);
|
|
352
|
-
|
|
353
|
-
const response = await app.inject({
|
|
354
|
-
method: 'GET',
|
|
355
|
-
url: '/api/v1/events/registry',
|
|
356
|
-
});
|
|
357
|
-
|
|
358
|
-
const body = response.body;
|
|
359
|
-
expect(body).toContain('event: registry');
|
|
360
|
-
expect(body).not.toContain('"checksum"');
|
|
361
|
-
expect(body).not.toContain('"checksumAlgorithm"');
|
|
362
|
-
});
|
|
363
|
-
|
|
364
|
-
it('handles snapshot with null expiration fields', async () => {
|
|
365
|
-
const snapshot = createMockSnapshot();
|
|
366
|
-
(snapshot as any).expiresAt = null;
|
|
367
|
-
(snapshot as any).ttlMs = null;
|
|
368
|
-
|
|
369
|
-
vi.mocked(mockCliApi.snapshot).mockReturnValue(snapshot);
|
|
370
|
-
|
|
371
|
-
const response = await app.inject({
|
|
372
|
-
method: 'GET',
|
|
373
|
-
url: '/api/v1/events/registry',
|
|
374
|
-
});
|
|
375
|
-
|
|
376
|
-
const body = response.body;
|
|
377
|
-
expect(body).toContain('"expiresAt":null');
|
|
378
|
-
expect(body).toContain('"ttlMs":null');
|
|
379
|
-
});
|
|
380
|
-
|
|
381
|
-
it('handles missing getRedisStatus method gracefully', async () => {
|
|
382
|
-
delete (mockCliApi as any).getRedisStatus;
|
|
383
|
-
|
|
384
|
-
const response = await app.inject({
|
|
385
|
-
method: 'GET',
|
|
386
|
-
url: '/api/v1/events/registry',
|
|
387
|
-
});
|
|
388
|
-
|
|
389
|
-
await new Promise((resolve) => {
|
|
390
|
-
setTimeout(resolve, 10);
|
|
391
|
-
});
|
|
392
|
-
|
|
393
|
-
const body = response.body;
|
|
394
|
-
expect(body).toContain('"redisEnabled":false');
|
|
395
|
-
expect(body).toContain('"redisHealthy":true');
|
|
396
|
-
});
|
|
397
|
-
|
|
398
|
-
it('handles missing plugin mount snapshot', async () => {
|
|
399
|
-
const { metricsCollector } = await import('../../middleware/metrics');
|
|
400
|
-
vi.mocked(metricsCollector.getLastPluginMountSnapshot).mockReturnValue(null);
|
|
401
|
-
|
|
402
|
-
const response = await app.inject({
|
|
403
|
-
method: 'GET',
|
|
404
|
-
url: '/api/v1/events/registry',
|
|
405
|
-
});
|
|
406
|
-
|
|
407
|
-
await new Promise((resolve) => {
|
|
408
|
-
setTimeout(resolve, 10);
|
|
409
|
-
});
|
|
410
|
-
|
|
411
|
-
const body = response.body;
|
|
412
|
-
expect(body).toContain('"pluginsMounted":0');
|
|
413
|
-
expect(body).toContain('"pluginsFailed":0');
|
|
414
|
-
});
|
|
415
|
-
|
|
416
|
-
it('handles null lastPluginMountTs', async () => {
|
|
417
|
-
readiness.lastPluginMountTs = null;
|
|
418
|
-
readiness.pluginRoutesLastDurationMs = null;
|
|
419
|
-
|
|
420
|
-
const response = await app.inject({
|
|
421
|
-
method: 'GET',
|
|
422
|
-
url: '/api/v1/events/registry',
|
|
423
|
-
});
|
|
424
|
-
|
|
425
|
-
await new Promise((resolve) => {
|
|
426
|
-
setTimeout(resolve, 10);
|
|
427
|
-
});
|
|
428
|
-
|
|
429
|
-
const body = response.body;
|
|
430
|
-
expect(body).toContain('"lastPluginMountTs":null');
|
|
431
|
-
expect(body).toContain('"pluginRoutesLastDurationMs":null');
|
|
432
|
-
});
|
|
433
|
-
});
|
|
434
|
-
});
|