@kb-labs/rest-api-app 1.3.0 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +2 -0
- package/dist/index.js +8151 -0
- package/dist/index.js.map +1 -0
- package/package.json +7 -4
- 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,76 +0,0 @@
|
|
|
1
|
-
-- Incidents table schema for KB Labs
|
|
2
|
-
-- Stores incident history with enriched context data and AI analysis
|
|
3
|
-
|
|
4
|
-
-- Main incidents table
|
|
5
|
-
CREATE TABLE IF NOT EXISTS incidents (
|
|
6
|
-
-- Identity
|
|
7
|
-
id TEXT PRIMARY KEY,
|
|
8
|
-
|
|
9
|
-
-- Classification
|
|
10
|
-
type TEXT NOT NULL CHECK(type IN ('error_rate', 'latency_spike', 'plugin_failure', 'adapter_failure', 'system_health', 'custom')),
|
|
11
|
-
severity TEXT NOT NULL CHECK(severity IN ('critical', 'warning', 'info')),
|
|
12
|
-
|
|
13
|
-
-- Core information
|
|
14
|
-
title TEXT NOT NULL,
|
|
15
|
-
details TEXT NOT NULL,
|
|
16
|
-
|
|
17
|
-
-- Timestamps
|
|
18
|
-
timestamp INTEGER NOT NULL, -- Unix milliseconds when incident occurred
|
|
19
|
-
resolved_at INTEGER, -- Unix milliseconds when resolved (NULL if active)
|
|
20
|
-
created_at INTEGER NOT NULL DEFAULT (strftime('%s', 'now') * 1000),
|
|
21
|
-
|
|
22
|
-
-- Resolution
|
|
23
|
-
resolution_notes TEXT,
|
|
24
|
-
|
|
25
|
-
-- Affected entities (JSON arrays)
|
|
26
|
-
affected_services TEXT, -- JSON: ["service1", "service2"]
|
|
27
|
-
|
|
28
|
-
-- Original metadata from detector (JSON object)
|
|
29
|
-
metadata TEXT, -- JSON: { errorRate: 5.2, threshold: 10, ... }
|
|
30
|
-
|
|
31
|
-
-- NEW: Related data gathered during incident detection
|
|
32
|
-
related_logs_count INTEGER DEFAULT 0,
|
|
33
|
-
related_logs_sample TEXT, -- JSON: ["error msg 1", "error msg 2", ...]
|
|
34
|
-
related_metrics TEXT, -- JSON: { errorRateBefore: 2.1, errorRateDuring: 8.5, ... }
|
|
35
|
-
timeline TEXT, -- JSON: [{ timestamp, event, source }, ...]
|
|
36
|
-
|
|
37
|
-
-- NEW: AI analysis results (stored after analysis)
|
|
38
|
-
ai_analysis TEXT, -- JSON: { summary, patterns, rootCauses, recommendations }
|
|
39
|
-
ai_analyzed_at INTEGER -- Unix milliseconds when AI analysis was run
|
|
40
|
-
);
|
|
41
|
-
|
|
42
|
-
-- Indexes for common query patterns
|
|
43
|
-
CREATE INDEX IF NOT EXISTS idx_incidents_type ON incidents(type);
|
|
44
|
-
CREATE INDEX IF NOT EXISTS idx_incidents_severity ON incidents(severity);
|
|
45
|
-
CREATE INDEX IF NOT EXISTS idx_incidents_timestamp ON incidents(timestamp DESC);
|
|
46
|
-
CREATE INDEX IF NOT EXISTS idx_incidents_resolved ON incidents(resolved_at);
|
|
47
|
-
CREATE INDEX IF NOT EXISTS idx_incidents_created ON incidents(created_at DESC);
|
|
48
|
-
|
|
49
|
-
-- Composite index for active incidents by severity
|
|
50
|
-
CREATE INDEX IF NOT EXISTS idx_incidents_active_severity
|
|
51
|
-
ON incidents(severity, timestamp DESC)
|
|
52
|
-
WHERE resolved_at IS NULL;
|
|
53
|
-
|
|
54
|
-
-- Full-text search on title and details (FTS5)
|
|
55
|
-
CREATE VIRTUAL TABLE IF NOT EXISTS incidents_fts USING fts5(
|
|
56
|
-
title,
|
|
57
|
-
details,
|
|
58
|
-
content=incidents,
|
|
59
|
-
content_rowid=rowid
|
|
60
|
-
);
|
|
61
|
-
|
|
62
|
-
-- Triggers to keep FTS in sync with incidents table
|
|
63
|
-
CREATE TRIGGER IF NOT EXISTS incidents_fts_insert AFTER INSERT ON incidents BEGIN
|
|
64
|
-
INSERT INTO incidents_fts(rowid, title, details)
|
|
65
|
-
VALUES (new.rowid, new.title, new.details);
|
|
66
|
-
END;
|
|
67
|
-
|
|
68
|
-
CREATE TRIGGER IF NOT EXISTS incidents_fts_delete AFTER DELETE ON incidents BEGIN
|
|
69
|
-
DELETE FROM incidents_fts WHERE rowid = old.rowid;
|
|
70
|
-
END;
|
|
71
|
-
|
|
72
|
-
CREATE TRIGGER IF NOT EXISTS incidents_fts_update AFTER UPDATE ON incidents BEGIN
|
|
73
|
-
UPDATE incidents_fts
|
|
74
|
-
SET title = new.title, details = new.details
|
|
75
|
-
WHERE rowid = new.rowid;
|
|
76
|
-
END;
|
|
@@ -1,593 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @module @kb-labs/rest-api-app/services/incident-storage
|
|
3
|
-
* Incident history storage service (SQLite-backed)
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import type { ISQLDatabase } from '@kb-labs/core-platform/adapters';
|
|
7
|
-
import { platform } from '@kb-labs/core-runtime';
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Incident severity levels
|
|
11
|
-
*/
|
|
12
|
-
export type IncidentSeverity = 'critical' | 'warning' | 'info';
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Incident type categories
|
|
16
|
-
*/
|
|
17
|
-
export type IncidentType =
|
|
18
|
-
| 'error_rate'
|
|
19
|
-
| 'latency_spike'
|
|
20
|
-
| 'plugin_failure'
|
|
21
|
-
| 'adapter_failure'
|
|
22
|
-
| 'system_health'
|
|
23
|
-
| 'custom';
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Root cause analysis item
|
|
27
|
-
*/
|
|
28
|
-
export interface RootCauseItem {
|
|
29
|
-
/** Factor contributing to the incident */
|
|
30
|
-
factor: string;
|
|
31
|
-
/** Confidence level (0.0 - 1.0) */
|
|
32
|
-
confidence: number;
|
|
33
|
-
/** Evidence supporting this root cause */
|
|
34
|
-
evidence: string;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Related logs context
|
|
39
|
-
*/
|
|
40
|
-
export interface RelatedLogsData {
|
|
41
|
-
/** Number of error logs in timeframe */
|
|
42
|
-
errorCount: number;
|
|
43
|
-
/** Number of warning logs in timeframe */
|
|
44
|
-
warnCount: number;
|
|
45
|
-
/** Time range [from, to] in Unix ms */
|
|
46
|
-
timeRange: [number, number];
|
|
47
|
-
/** Sample error messages (top 5) */
|
|
48
|
-
sampleErrors: string[];
|
|
49
|
-
/** Top endpoints with errors (NEW) */
|
|
50
|
-
topEndpoints?: Array<{
|
|
51
|
-
endpoint: string;
|
|
52
|
-
count: number;
|
|
53
|
-
sample: string;
|
|
54
|
-
}>;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Slow request details (NEW)
|
|
59
|
-
*/
|
|
60
|
-
export interface SlowRequest {
|
|
61
|
-
/** Request endpoint */
|
|
62
|
-
endpoint: string;
|
|
63
|
-
/** HTTP method */
|
|
64
|
-
method: string;
|
|
65
|
-
/** Request duration in milliseconds */
|
|
66
|
-
durationMs: number;
|
|
67
|
-
/** HTTP status code */
|
|
68
|
-
statusCode?: number;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* Related metrics context
|
|
73
|
-
*/
|
|
74
|
-
export interface RelatedMetricsData {
|
|
75
|
-
/** Metrics before incident */
|
|
76
|
-
before?: Record<string, number>;
|
|
77
|
-
/** Metrics during incident */
|
|
78
|
-
during?: Record<string, number>;
|
|
79
|
-
/** Top slowest requests (NEW - for latency incidents) */
|
|
80
|
-
topSlowest?: SlowRequest[];
|
|
81
|
-
/** Affected endpoints (NEW - which endpoints were slow) */
|
|
82
|
-
affectedEndpoints?: string[];
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* Timeline event
|
|
87
|
-
*/
|
|
88
|
-
export interface TimelineEvent {
|
|
89
|
-
/** Event timestamp (Unix ms) */
|
|
90
|
-
timestamp: number;
|
|
91
|
-
/** Event description */
|
|
92
|
-
event: string;
|
|
93
|
-
/** Source of event */
|
|
94
|
-
source: 'detector' | 'logs' | 'metrics' | 'manual';
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* Related data gathered during incident
|
|
99
|
-
*/
|
|
100
|
-
export interface RelatedData {
|
|
101
|
-
/** Related logs information */
|
|
102
|
-
logs?: RelatedLogsData;
|
|
103
|
-
/** Related metrics information */
|
|
104
|
-
metrics?: RelatedMetricsData;
|
|
105
|
-
/** Timeline of events */
|
|
106
|
-
timeline?: TimelineEvent[];
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* Incident record structure
|
|
111
|
-
*/
|
|
112
|
-
export interface Incident {
|
|
113
|
-
/** Unique incident identifier */
|
|
114
|
-
id: string;
|
|
115
|
-
/** Incident type */
|
|
116
|
-
type: IncidentType;
|
|
117
|
-
/** Severity level */
|
|
118
|
-
severity: IncidentSeverity;
|
|
119
|
-
/** Incident title/summary */
|
|
120
|
-
title: string;
|
|
121
|
-
/** Detailed description */
|
|
122
|
-
details: string;
|
|
123
|
-
/** Root cause analysis (optional) - array of contributing factors */
|
|
124
|
-
rootCause?: RootCauseItem[];
|
|
125
|
-
/** Affected services/plugins */
|
|
126
|
-
affectedServices?: string[];
|
|
127
|
-
/** Timestamp when incident occurred (Unix ms) */
|
|
128
|
-
timestamp: number;
|
|
129
|
-
/** Timestamp when incident was resolved (Unix ms) */
|
|
130
|
-
resolvedAt?: number;
|
|
131
|
-
/** Resolution notes */
|
|
132
|
-
resolutionNotes?: string;
|
|
133
|
-
/** Related metrics/logs (legacy field from detector) */
|
|
134
|
-
metadata?: Record<string, unknown>;
|
|
135
|
-
/** NEW: Related data (logs, metrics, timeline) */
|
|
136
|
-
relatedData?: RelatedData;
|
|
137
|
-
/** NEW: AI analysis results (set after analysis) */
|
|
138
|
-
aiAnalysis?: any; // Will be typed in analyzer module
|
|
139
|
-
/** NEW: When AI analysis was performed */
|
|
140
|
-
aiAnalyzedAt?: number;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
/**
|
|
144
|
-
* Incident create payload (omit id, timestamp is optional - will be set to now if not provided)
|
|
145
|
-
*/
|
|
146
|
-
export type IncidentCreatePayload = Omit<Incident, 'id' | 'timestamp'> & {
|
|
147
|
-
timestamp?: number;
|
|
148
|
-
};
|
|
149
|
-
|
|
150
|
-
/**
|
|
151
|
-
* Incident query options
|
|
152
|
-
*/
|
|
153
|
-
export interface IncidentQueryOptions {
|
|
154
|
-
/** Maximum number of incidents to return (default: 50) */
|
|
155
|
-
limit?: number;
|
|
156
|
-
/** Filter by severity */
|
|
157
|
-
severity?: IncidentSeverity | IncidentSeverity[];
|
|
158
|
-
/** Filter by type */
|
|
159
|
-
type?: IncidentType | IncidentType[];
|
|
160
|
-
/** Filter by time range (from timestamp) */
|
|
161
|
-
from?: number;
|
|
162
|
-
/** Filter by time range (to timestamp) */
|
|
163
|
-
to?: number;
|
|
164
|
-
/** Include resolved incidents (default: false) */
|
|
165
|
-
includeResolved?: boolean;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
/**
|
|
169
|
-
* Incident storage service configuration
|
|
170
|
-
*/
|
|
171
|
-
export interface IncidentStorageConfig {
|
|
172
|
-
/** TTL for incidents in milliseconds (default: 30 days) */
|
|
173
|
-
ttlMs?: number;
|
|
174
|
-
/** Maximum incidents to store (default: 1000) */
|
|
175
|
-
maxIncidents?: number;
|
|
176
|
-
/** Enable debug logging */
|
|
177
|
-
debug?: boolean;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
const DEFAULT_CONFIG: Required<IncidentStorageConfig> = {
|
|
181
|
-
ttlMs: 30 * 24 * 60 * 60 * 1000, // 30 days (not used with SQLite, kept for compatibility)
|
|
182
|
-
maxIncidents: 1000, // Not enforced with SQLite, use retention policy instead
|
|
183
|
-
debug: false,
|
|
184
|
-
};
|
|
185
|
-
|
|
186
|
-
/**
|
|
187
|
-
* Database row structure (matches SQL schema)
|
|
188
|
-
*/
|
|
189
|
-
interface IncidentRow {
|
|
190
|
-
id: string;
|
|
191
|
-
type: string;
|
|
192
|
-
severity: string;
|
|
193
|
-
title: string;
|
|
194
|
-
details: string;
|
|
195
|
-
timestamp: number;
|
|
196
|
-
resolved_at: number | null;
|
|
197
|
-
created_at: number;
|
|
198
|
-
resolution_notes: string | null;
|
|
199
|
-
affected_services: string | null; // JSON
|
|
200
|
-
metadata: string | null; // JSON
|
|
201
|
-
related_logs_count: number;
|
|
202
|
-
related_logs_sample: string | null; // JSON
|
|
203
|
-
related_metrics: string | null; // JSON
|
|
204
|
-
timeline: string | null; // JSON
|
|
205
|
-
ai_analysis: string | null; // JSON
|
|
206
|
-
ai_analyzed_at: number | null;
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
/**
|
|
210
|
-
* Incident storage service
|
|
211
|
-
*
|
|
212
|
-
* Stores incident history in SQLite database for persistence.
|
|
213
|
-
* Provides CRUD operations, query filtering, and full-text search.
|
|
214
|
-
*/
|
|
215
|
-
export class IncidentStorage {
|
|
216
|
-
private db: ISQLDatabase;
|
|
217
|
-
private config: Required<IncidentStorageConfig>;
|
|
218
|
-
private logger: Console | any;
|
|
219
|
-
|
|
220
|
-
constructor(db: ISQLDatabase, config: IncidentStorageConfig = {}, logger: Console | any = console) {
|
|
221
|
-
this.db = db;
|
|
222
|
-
this.config = { ...DEFAULT_CONFIG, ...config };
|
|
223
|
-
this.logger = logger;
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
/**
|
|
227
|
-
* Create a new incident record
|
|
228
|
-
*/
|
|
229
|
-
async createIncident(payload: IncidentCreatePayload): Promise<Incident> {
|
|
230
|
-
// Generate unique ID
|
|
231
|
-
const id = `inc-${Date.now()}-${Math.random().toString(36).substring(2, 9)}`;
|
|
232
|
-
const timestamp = payload.timestamp ?? Date.now();
|
|
233
|
-
|
|
234
|
-
// Validate required fields
|
|
235
|
-
if (!payload.type || !payload.severity || !payload.title) {
|
|
236
|
-
throw new Error('Incident must have type, severity, and title');
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
// Extract related data for denormalized storage
|
|
240
|
-
const relatedLogsCount = payload.relatedData?.logs?.errorCount ?? 0;
|
|
241
|
-
// Store entire logs structure (includes sampleErrors, topEndpoints, etc.)
|
|
242
|
-
const relatedLogsSample = payload.relatedData?.logs
|
|
243
|
-
? JSON.stringify(payload.relatedData.logs)
|
|
244
|
-
: null;
|
|
245
|
-
const relatedMetrics = payload.relatedData?.metrics
|
|
246
|
-
? JSON.stringify(payload.relatedData.metrics)
|
|
247
|
-
: null;
|
|
248
|
-
const timeline = payload.relatedData?.timeline
|
|
249
|
-
? JSON.stringify(payload.relatedData.timeline)
|
|
250
|
-
: null;
|
|
251
|
-
|
|
252
|
-
// Insert into database
|
|
253
|
-
await this.db.query(
|
|
254
|
-
`INSERT INTO incidents (
|
|
255
|
-
id, type, severity, title, details, timestamp,
|
|
256
|
-
resolved_at, resolution_notes,
|
|
257
|
-
affected_services, metadata,
|
|
258
|
-
related_logs_count, related_logs_sample, related_metrics, timeline
|
|
259
|
-
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
|
|
260
|
-
[
|
|
261
|
-
id,
|
|
262
|
-
payload.type,
|
|
263
|
-
payload.severity,
|
|
264
|
-
payload.title,
|
|
265
|
-
payload.details,
|
|
266
|
-
timestamp,
|
|
267
|
-
payload.resolvedAt ?? null,
|
|
268
|
-
payload.resolutionNotes ?? null,
|
|
269
|
-
payload.affectedServices ? JSON.stringify(payload.affectedServices) : null,
|
|
270
|
-
payload.metadata ? JSON.stringify(payload.metadata) : null,
|
|
271
|
-
relatedLogsCount,
|
|
272
|
-
relatedLogsSample,
|
|
273
|
-
relatedMetrics,
|
|
274
|
-
timeline,
|
|
275
|
-
]
|
|
276
|
-
);
|
|
277
|
-
|
|
278
|
-
this.log('info', 'Incident created', {
|
|
279
|
-
id,
|
|
280
|
-
type: payload.type,
|
|
281
|
-
severity: payload.severity,
|
|
282
|
-
});
|
|
283
|
-
|
|
284
|
-
// Fetch and return the created incident
|
|
285
|
-
const created = await this.getIncident(id);
|
|
286
|
-
if (!created) {
|
|
287
|
-
throw new Error('Failed to retrieve created incident');
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
return created;
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
/**
|
|
294
|
-
* Get incident by ID
|
|
295
|
-
*/
|
|
296
|
-
async getIncident(id: string): Promise<Incident | null> {
|
|
297
|
-
const result = await this.db.query<IncidentRow>(
|
|
298
|
-
'SELECT * FROM incidents WHERE id = ?',
|
|
299
|
-
[id]
|
|
300
|
-
);
|
|
301
|
-
|
|
302
|
-
if (result.rows.length === 0) {
|
|
303
|
-
return null;
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
return this.rowToIncident(result.rows[0]!);
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
/**
|
|
310
|
-
* Query incidents with filters
|
|
311
|
-
*/
|
|
312
|
-
async queryIncidents(options: IncidentQueryOptions = {}): Promise<Incident[]> {
|
|
313
|
-
const {
|
|
314
|
-
limit = 50,
|
|
315
|
-
severity,
|
|
316
|
-
type,
|
|
317
|
-
from,
|
|
318
|
-
to,
|
|
319
|
-
includeResolved = false,
|
|
320
|
-
} = options;
|
|
321
|
-
|
|
322
|
-
// Build WHERE clause dynamically
|
|
323
|
-
const conditions: string[] = [];
|
|
324
|
-
const params: unknown[] = [];
|
|
325
|
-
|
|
326
|
-
// Filter by severity
|
|
327
|
-
if (severity) {
|
|
328
|
-
const severityList = Array.isArray(severity) ? severity : [severity];
|
|
329
|
-
conditions.push(`severity IN (${severityList.map(() => '?').join(', ')})`);
|
|
330
|
-
params.push(...severityList);
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
// Filter by type
|
|
334
|
-
if (type) {
|
|
335
|
-
const typeList = Array.isArray(type) ? type : [type];
|
|
336
|
-
conditions.push(`type IN (${typeList.map(() => '?').join(', ')})`);
|
|
337
|
-
params.push(...typeList);
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
// Filter by time range
|
|
341
|
-
if (from) {
|
|
342
|
-
conditions.push('timestamp >= ?');
|
|
343
|
-
params.push(from);
|
|
344
|
-
}
|
|
345
|
-
if (to) {
|
|
346
|
-
conditions.push('timestamp <= ?');
|
|
347
|
-
params.push(to);
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
// Filter resolved incidents
|
|
351
|
-
if (!includeResolved) {
|
|
352
|
-
conditions.push('resolved_at IS NULL');
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
const whereClause = conditions.length > 0 ? `WHERE ${conditions.join(' AND ')}` : '';
|
|
356
|
-
|
|
357
|
-
const sql = `
|
|
358
|
-
SELECT * FROM incidents
|
|
359
|
-
${whereClause}
|
|
360
|
-
ORDER BY timestamp DESC
|
|
361
|
-
LIMIT ?
|
|
362
|
-
`;
|
|
363
|
-
|
|
364
|
-
const result = await this.db.query<IncidentRow>(sql, [...params, limit]);
|
|
365
|
-
|
|
366
|
-
return result.rows.map(row => this.rowToIncident(row));
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
/**
|
|
370
|
-
* Resolve an incident
|
|
371
|
-
*/
|
|
372
|
-
async resolveIncident(id: string, resolutionNotes?: string): Promise<Incident | null> {
|
|
373
|
-
const resolvedAt = Date.now();
|
|
374
|
-
|
|
375
|
-
const result = await this.db.query(
|
|
376
|
-
`UPDATE incidents
|
|
377
|
-
SET resolved_at = ?, resolution_notes = ?
|
|
378
|
-
WHERE id = ?`,
|
|
379
|
-
[resolvedAt, resolutionNotes ?? null, id]
|
|
380
|
-
);
|
|
381
|
-
|
|
382
|
-
if (result.rowCount === 0) {
|
|
383
|
-
return null; // Not found
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
this.log('info', 'Incident resolved', { id, resolvedAt });
|
|
387
|
-
|
|
388
|
-
const incident = await this.getIncident(id);
|
|
389
|
-
|
|
390
|
-
// Track analytics event
|
|
391
|
-
if (incident && platform.analytics) {
|
|
392
|
-
const durationMs = resolvedAt - incident.timestamp;
|
|
393
|
-
const durationMinutes = Math.floor(durationMs / 60000);
|
|
394
|
-
|
|
395
|
-
platform.analytics.track('incident.resolved', {
|
|
396
|
-
incidentId: id,
|
|
397
|
-
type: incident.type,
|
|
398
|
-
severity: incident.severity,
|
|
399
|
-
durationMs,
|
|
400
|
-
durationMinutes,
|
|
401
|
-
hasResolutionNotes: !!resolutionNotes,
|
|
402
|
-
wasAnalyzed: !!incident.aiAnalysis,
|
|
403
|
-
}).catch(() => {
|
|
404
|
-
// Silently ignore analytics errors
|
|
405
|
-
});
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
return incident;
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
/**
|
|
412
|
-
* Delete an incident
|
|
413
|
-
*/
|
|
414
|
-
async deleteIncident(id: string): Promise<boolean> {
|
|
415
|
-
// Get incident before deleting for analytics
|
|
416
|
-
const incident = await this.getIncident(id);
|
|
417
|
-
|
|
418
|
-
const result = await this.db.query('DELETE FROM incidents WHERE id = ?', [id]);
|
|
419
|
-
|
|
420
|
-
const deleted = result.rowCount > 0;
|
|
421
|
-
|
|
422
|
-
if (deleted) {
|
|
423
|
-
this.log('info', 'Incident deleted', { id });
|
|
424
|
-
|
|
425
|
-
// Track analytics event
|
|
426
|
-
if (incident && platform.analytics) {
|
|
427
|
-
platform.analytics.track('incident.deleted', {
|
|
428
|
-
incidentId: id,
|
|
429
|
-
type: incident.type,
|
|
430
|
-
severity: incident.severity,
|
|
431
|
-
wasResolved: !!incident.resolvedAt,
|
|
432
|
-
wasAnalyzed: !!incident.aiAnalysis,
|
|
433
|
-
}).catch(() => {
|
|
434
|
-
// Silently ignore analytics errors
|
|
435
|
-
});
|
|
436
|
-
}
|
|
437
|
-
}
|
|
438
|
-
|
|
439
|
-
return deleted;
|
|
440
|
-
}
|
|
441
|
-
|
|
442
|
-
/**
|
|
443
|
-
* Get statistics about stored incidents
|
|
444
|
-
*/
|
|
445
|
-
async getStats(): Promise<{
|
|
446
|
-
total: number;
|
|
447
|
-
bySeverity: Record<IncidentSeverity, number>;
|
|
448
|
-
byType: Record<string, number>;
|
|
449
|
-
resolved: number;
|
|
450
|
-
unresolved: number;
|
|
451
|
-
oldestTimestamp: number | null;
|
|
452
|
-
newestTimestamp: number | null;
|
|
453
|
-
}> {
|
|
454
|
-
// Get total and timestamp range
|
|
455
|
-
const totalResult = await this.db.query<{
|
|
456
|
-
total: number;
|
|
457
|
-
oldest: number | null;
|
|
458
|
-
newest: number | null;
|
|
459
|
-
}>(`
|
|
460
|
-
SELECT
|
|
461
|
-
COUNT(*) as total,
|
|
462
|
-
MIN(timestamp) as oldest,
|
|
463
|
-
MAX(timestamp) as newest
|
|
464
|
-
FROM incidents
|
|
465
|
-
`);
|
|
466
|
-
|
|
467
|
-
const { total, oldest, newest } = totalResult.rows[0]!;
|
|
468
|
-
|
|
469
|
-
// Get counts by severity
|
|
470
|
-
const severityResult = await this.db.query<{
|
|
471
|
-
severity: IncidentSeverity;
|
|
472
|
-
count: number;
|
|
473
|
-
}>('SELECT severity, COUNT(*) as count FROM incidents GROUP BY severity');
|
|
474
|
-
|
|
475
|
-
const bySeverity: Record<IncidentSeverity, number> = {
|
|
476
|
-
critical: 0,
|
|
477
|
-
warning: 0,
|
|
478
|
-
info: 0,
|
|
479
|
-
};
|
|
480
|
-
for (const row of severityResult.rows) {
|
|
481
|
-
bySeverity[row.severity] = row.count;
|
|
482
|
-
}
|
|
483
|
-
|
|
484
|
-
// Get counts by type
|
|
485
|
-
const typeResult = await this.db.query<{
|
|
486
|
-
type: string;
|
|
487
|
-
count: number;
|
|
488
|
-
}>('SELECT type, COUNT(*) as count FROM incidents GROUP BY type');
|
|
489
|
-
|
|
490
|
-
const byType: Record<string, number> = {};
|
|
491
|
-
for (const row of typeResult.rows) {
|
|
492
|
-
byType[row.type] = row.count;
|
|
493
|
-
}
|
|
494
|
-
|
|
495
|
-
// Get resolved/unresolved counts
|
|
496
|
-
const resolvedResult = await this.db.query<{
|
|
497
|
-
resolved: number;
|
|
498
|
-
unresolved: number;
|
|
499
|
-
}>(`
|
|
500
|
-
SELECT
|
|
501
|
-
SUM(CASE WHEN resolved_at IS NOT NULL THEN 1 ELSE 0 END) as resolved,
|
|
502
|
-
SUM(CASE WHEN resolved_at IS NULL THEN 1 ELSE 0 END) as unresolved
|
|
503
|
-
FROM incidents
|
|
504
|
-
`);
|
|
505
|
-
|
|
506
|
-
const { resolved, unresolved } = resolvedResult.rows[0]!;
|
|
507
|
-
|
|
508
|
-
return {
|
|
509
|
-
total,
|
|
510
|
-
bySeverity,
|
|
511
|
-
byType,
|
|
512
|
-
resolved: resolved ?? 0,
|
|
513
|
-
unresolved: unresolved ?? 0,
|
|
514
|
-
oldestTimestamp: oldest,
|
|
515
|
-
newestTimestamp: newest,
|
|
516
|
-
};
|
|
517
|
-
}
|
|
518
|
-
|
|
519
|
-
/**
|
|
520
|
-
* Clear all incidents (admin function)
|
|
521
|
-
*/
|
|
522
|
-
async clearAll(): Promise<void> {
|
|
523
|
-
await this.db.query('DELETE FROM incidents');
|
|
524
|
-
this.log('warn', 'All incidents cleared');
|
|
525
|
-
}
|
|
526
|
-
|
|
527
|
-
/**
|
|
528
|
-
* Update AI analysis for an incident
|
|
529
|
-
*/
|
|
530
|
-
async updateAIAnalysis(id: string, analysis: any): Promise<void> {
|
|
531
|
-
await this.db.query(
|
|
532
|
-
`UPDATE incidents
|
|
533
|
-
SET ai_analysis = ?, ai_analyzed_at = ?
|
|
534
|
-
WHERE id = ?`,
|
|
535
|
-
[JSON.stringify(analysis), Date.now(), id]
|
|
536
|
-
);
|
|
537
|
-
|
|
538
|
-
this.log('debug', 'AI analysis updated', { id });
|
|
539
|
-
}
|
|
540
|
-
|
|
541
|
-
/**
|
|
542
|
-
* Convert database row to Incident object
|
|
543
|
-
* @private
|
|
544
|
-
*/
|
|
545
|
-
private rowToIncident(row: IncidentRow): Incident {
|
|
546
|
-
// Parse JSON fields
|
|
547
|
-
const affectedServices = row.affected_services
|
|
548
|
-
? (JSON.parse(row.affected_services) as string[])
|
|
549
|
-
: undefined;
|
|
550
|
-
const metadata = row.metadata ? (JSON.parse(row.metadata) as Record<string, unknown>) : undefined;
|
|
551
|
-
const aiAnalysis = row.ai_analysis ? JSON.parse(row.ai_analysis) : undefined;
|
|
552
|
-
|
|
553
|
-
// Reconstruct related data
|
|
554
|
-
const relatedData: RelatedData | undefined =
|
|
555
|
-
row.related_logs_sample || row.related_metrics || row.timeline
|
|
556
|
-
? {
|
|
557
|
-
logs: row.related_logs_sample
|
|
558
|
-
? (JSON.parse(row.related_logs_sample) as RelatedLogsData)
|
|
559
|
-
: undefined,
|
|
560
|
-
metrics: row.related_metrics
|
|
561
|
-
? (JSON.parse(row.related_metrics) as RelatedMetricsData)
|
|
562
|
-
: undefined,
|
|
563
|
-
timeline: row.timeline ? (JSON.parse(row.timeline) as TimelineEvent[]) : undefined,
|
|
564
|
-
}
|
|
565
|
-
: undefined;
|
|
566
|
-
|
|
567
|
-
return {
|
|
568
|
-
id: row.id,
|
|
569
|
-
type: row.type as IncidentType,
|
|
570
|
-
severity: row.severity as IncidentSeverity,
|
|
571
|
-
title: row.title,
|
|
572
|
-
details: row.details,
|
|
573
|
-
timestamp: row.timestamp,
|
|
574
|
-
resolvedAt: row.resolved_at ?? undefined,
|
|
575
|
-
resolutionNotes: row.resolution_notes ?? undefined,
|
|
576
|
-
affectedServices,
|
|
577
|
-
metadata,
|
|
578
|
-
relatedData,
|
|
579
|
-
aiAnalysis,
|
|
580
|
-
aiAnalyzedAt: row.ai_analyzed_at ?? undefined,
|
|
581
|
-
};
|
|
582
|
-
}
|
|
583
|
-
|
|
584
|
-
private log(level: 'info' | 'warn' | 'error' | 'debug', message: string, meta?: any): void {
|
|
585
|
-
if (level === 'debug' && !this.config.debug) {return;}
|
|
586
|
-
|
|
587
|
-
if (this.logger[level]) {
|
|
588
|
-
this.logger[level](`[IncidentStorage] ${message}`, meta);
|
|
589
|
-
} else {
|
|
590
|
-
console.log(`[IncidentStorage] [${level}] ${message}`, meta);
|
|
591
|
-
}
|
|
592
|
-
}
|
|
593
|
-
}
|