@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,496 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @module @kb-labs/rest-api-app/services/historical-metrics
|
|
3
|
-
* Historical metrics collection and storage service
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import type { CacheAdapter } from '@kb-labs/plugin-contracts';
|
|
7
|
-
import { metricsCollector } from '../middleware/metrics.js';
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Historical data point
|
|
11
|
-
*/
|
|
12
|
-
export interface HistoricalDataPoint {
|
|
13
|
-
timestamp: number;
|
|
14
|
-
value: number;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Heatmap cell data
|
|
19
|
-
*/
|
|
20
|
-
export interface HeatmapCell {
|
|
21
|
-
day: string; // 'Mon', 'Tue', etc.
|
|
22
|
-
hour: number; // 0-23
|
|
23
|
-
value: number;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Metrics snapshot for historical storage
|
|
28
|
-
*/
|
|
29
|
-
interface MetricsSnapshot {
|
|
30
|
-
timestamp: number;
|
|
31
|
-
requests: {
|
|
32
|
-
total: number;
|
|
33
|
-
success: number;
|
|
34
|
-
clientErrors: number;
|
|
35
|
-
serverErrors: number;
|
|
36
|
-
};
|
|
37
|
-
latency: {
|
|
38
|
-
average: number;
|
|
39
|
-
min: number;
|
|
40
|
-
max: number;
|
|
41
|
-
p50?: number;
|
|
42
|
-
p95?: number;
|
|
43
|
-
p99?: number;
|
|
44
|
-
};
|
|
45
|
-
uptime: number; // seconds
|
|
46
|
-
perPlugin: Array<{
|
|
47
|
-
pluginId?: string;
|
|
48
|
-
requests: number;
|
|
49
|
-
errors: number;
|
|
50
|
-
avgLatency: number;
|
|
51
|
-
}>;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Historical metrics collector configuration
|
|
56
|
-
*/
|
|
57
|
-
export interface HistoricalMetricsConfig {
|
|
58
|
-
/** Collection interval in milliseconds (default: 5000 = 5s) */
|
|
59
|
-
intervalMs?: number;
|
|
60
|
-
/** Maximum points to store per time range */
|
|
61
|
-
maxPoints?: {
|
|
62
|
-
/** Last 1 minute (default: 12 points at 5s intervals) */
|
|
63
|
-
'1m'?: number;
|
|
64
|
-
/** Last 5 minutes (default: 60 points) */
|
|
65
|
-
'5m'?: number;
|
|
66
|
-
/** Last 10 minutes (default: 120 points) */
|
|
67
|
-
'10m'?: number;
|
|
68
|
-
/** Last 30 minutes (default: 360 points) */
|
|
69
|
-
'30m'?: number;
|
|
70
|
-
/** Last 1 hour (default: 720 points) */
|
|
71
|
-
'1h'?: number;
|
|
72
|
-
};
|
|
73
|
-
/** Enable debug logging */
|
|
74
|
-
debug?: boolean;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
const DEFAULT_CONFIG: Required<HistoricalMetricsConfig> = {
|
|
78
|
-
intervalMs: 5000,
|
|
79
|
-
maxPoints: {
|
|
80
|
-
'1m': 12,
|
|
81
|
-
'5m': 60,
|
|
82
|
-
'10m': 120,
|
|
83
|
-
'30m': 360,
|
|
84
|
-
'1h': 720,
|
|
85
|
-
},
|
|
86
|
-
debug: false,
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* Historical metrics collector service
|
|
91
|
-
*
|
|
92
|
-
* Collects and stores historical metrics data in platform.cache with TTL-based retention.
|
|
93
|
-
* Provides time-series data for dashboards and analytics.
|
|
94
|
-
*/
|
|
95
|
-
export class HistoricalMetricsCollector {
|
|
96
|
-
private cache: CacheAdapter;
|
|
97
|
-
private config: Required<HistoricalMetricsConfig>;
|
|
98
|
-
private intervalHandle: NodeJS.Timeout | null = null;
|
|
99
|
-
private logger: Console | any;
|
|
100
|
-
private startTimeMs: number = Date.now();
|
|
101
|
-
|
|
102
|
-
constructor(cache: CacheAdapter, config: HistoricalMetricsConfig = {}, logger: Console | any = console) {
|
|
103
|
-
this.cache = cache;
|
|
104
|
-
this.config = { ...DEFAULT_CONFIG, ...config, maxPoints: { ...DEFAULT_CONFIG.maxPoints, ...config.maxPoints } };
|
|
105
|
-
this.logger = logger;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* Start background collection
|
|
110
|
-
*/
|
|
111
|
-
start(): void {
|
|
112
|
-
if (this.intervalHandle) {
|
|
113
|
-
this.log('warn', 'Historical metrics collector already started');
|
|
114
|
-
return;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
this.log('info', 'Starting historical metrics collector', {
|
|
118
|
-
intervalMs: this.config.intervalMs,
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
// Collect immediately, then every intervalMs
|
|
122
|
-
this.collect().catch(err => {
|
|
123
|
-
this.log('error', 'Failed to collect initial metrics', { err });
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
this.intervalHandle = setInterval(() => {
|
|
127
|
-
this.collect().catch(err => {
|
|
128
|
-
this.log('error', 'Failed to collect metrics', { err });
|
|
129
|
-
});
|
|
130
|
-
}, this.config.intervalMs);
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
/**
|
|
134
|
-
* Stop background collection
|
|
135
|
-
*/
|
|
136
|
-
stop(): void {
|
|
137
|
-
if (this.intervalHandle) {
|
|
138
|
-
clearInterval(this.intervalHandle);
|
|
139
|
-
this.intervalHandle = null;
|
|
140
|
-
this.log('info', 'Historical metrics collector stopped');
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
/**
|
|
145
|
-
* Collect current metrics snapshot and store in cache
|
|
146
|
-
*/
|
|
147
|
-
private async collect(): Promise<void> {
|
|
148
|
-
const now = Date.now();
|
|
149
|
-
const metrics = metricsCollector.getMetrics();
|
|
150
|
-
|
|
151
|
-
// Build snapshot
|
|
152
|
-
const snapshot: MetricsSnapshot = {
|
|
153
|
-
timestamp: now,
|
|
154
|
-
requests: {
|
|
155
|
-
total: metrics.requests.total,
|
|
156
|
-
success: metrics.requests.success ?? 0,
|
|
157
|
-
clientErrors: metrics.requests.clientErrors ?? 0,
|
|
158
|
-
serverErrors: metrics.requests.serverErrors ?? 0,
|
|
159
|
-
},
|
|
160
|
-
latency: {
|
|
161
|
-
average: metrics.latency.average,
|
|
162
|
-
min: metrics.latency.min === Infinity ? 0 : metrics.latency.min,
|
|
163
|
-
max: metrics.latency.max,
|
|
164
|
-
},
|
|
165
|
-
uptime: (now - metrics.timestamps.startTime) / 1000,
|
|
166
|
-
perPlugin: metrics.perPlugin.map(p => ({
|
|
167
|
-
pluginId: p.pluginId,
|
|
168
|
-
requests: p.total,
|
|
169
|
-
errors: Object.values(p.statuses)
|
|
170
|
-
.filter((_, idx) => Object.keys(p.statuses)[idx]?.startsWith('4') || Object.keys(p.statuses)[idx]?.startsWith('5'))
|
|
171
|
-
.reduce((sum, count) => sum + count, 0),
|
|
172
|
-
avgLatency: p.total > 0 ? p.totalDuration / p.total : 0,
|
|
173
|
-
})),
|
|
174
|
-
};
|
|
175
|
-
|
|
176
|
-
// Store in each time range bucket
|
|
177
|
-
await Promise.all([
|
|
178
|
-
this.appendToTimeSeries('1m', snapshot, 2 * 60 * 1000), // TTL: 2 minutes
|
|
179
|
-
this.appendToTimeSeries('5m', snapshot, 10 * 60 * 1000), // TTL: 10 minutes
|
|
180
|
-
this.appendToTimeSeries('10m', snapshot, 20 * 60 * 1000), // TTL: 20 minutes
|
|
181
|
-
this.appendToTimeSeries('30m', snapshot, 60 * 60 * 1000), // TTL: 1 hour
|
|
182
|
-
this.appendToTimeSeries('1h', snapshot, 2 * 60 * 60 * 1000), // TTL: 2 hours
|
|
183
|
-
]);
|
|
184
|
-
|
|
185
|
-
// Update heatmap aggregation (less frequently - every minute)
|
|
186
|
-
if (now % 60000 < this.config.intervalMs) {
|
|
187
|
-
await this.updateHeatmapAggregation(snapshot).catch(err => {
|
|
188
|
-
this.log('error', 'Failed to update heatmap', { err });
|
|
189
|
-
});
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
this.log('debug', 'Metrics snapshot collected', {
|
|
193
|
-
timestamp: new Date(now).toISOString(),
|
|
194
|
-
requests: snapshot.requests.total,
|
|
195
|
-
latency: snapshot.latency.average.toFixed(2),
|
|
196
|
-
});
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
/**
|
|
200
|
-
* Append snapshot to time series bucket
|
|
201
|
-
*/
|
|
202
|
-
private async appendToTimeSeries(range: keyof typeof DEFAULT_CONFIG.maxPoints, snapshot: MetricsSnapshot, ttlMs: number): Promise<void> {
|
|
203
|
-
const key = `metrics:history:${range}`;
|
|
204
|
-
const maxPoints = this.config.maxPoints[range] ?? 120;
|
|
205
|
-
|
|
206
|
-
// Get existing time series
|
|
207
|
-
let timeSeries = await this.cache.get<MetricsSnapshot[]>(key);
|
|
208
|
-
if (!timeSeries || !Array.isArray(timeSeries)) {
|
|
209
|
-
timeSeries = [];
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
// Append new snapshot
|
|
213
|
-
timeSeries.push(snapshot);
|
|
214
|
-
|
|
215
|
-
// Trim to max points (FIFO)
|
|
216
|
-
if (timeSeries.length > maxPoints) {
|
|
217
|
-
timeSeries = timeSeries.slice(timeSeries.length - maxPoints);
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
// Store back with TTL
|
|
221
|
-
await this.cache.set(key, timeSeries, ttlMs);
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
/**
|
|
225
|
-
* Update heatmap aggregation for weekly patterns
|
|
226
|
-
*/
|
|
227
|
-
private async updateHeatmapAggregation(snapshot: MetricsSnapshot): Promise<void> {
|
|
228
|
-
const key = 'metrics:heatmap:7d';
|
|
229
|
-
const ttlMs = 24 * 60 * 60 * 1000; // 24 hours
|
|
230
|
-
|
|
231
|
-
// Get existing heatmap data
|
|
232
|
-
let heatmapData = await this.cache.get<Record<string, HeatmapCell[]>>(key);
|
|
233
|
-
if (!heatmapData || typeof heatmapData !== 'object') {
|
|
234
|
-
heatmapData = { latency: [], errors: [], requests: [] };
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
// Calculate current day and hour
|
|
238
|
-
const date = new Date(snapshot.timestamp);
|
|
239
|
-
const day = (['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'] as const)[date.getDay() as 0|1|2|3|4|5|6];
|
|
240
|
-
const hour = date.getHours();
|
|
241
|
-
|
|
242
|
-
// Update each metric type
|
|
243
|
-
for (const metricType of ['latency', 'errors', 'requests'] as const) {
|
|
244
|
-
let cells = heatmapData[metricType] || [];
|
|
245
|
-
|
|
246
|
-
// Find or create cell for this day/hour
|
|
247
|
-
const cellIndex = cells.findIndex(c => c.day === day && c.hour === hour);
|
|
248
|
-
|
|
249
|
-
let value = 0;
|
|
250
|
-
if (metricType === 'latency') {
|
|
251
|
-
value = snapshot.latency.average;
|
|
252
|
-
} else if (metricType === 'errors') {
|
|
253
|
-
value = snapshot.requests.clientErrors + snapshot.requests.serverErrors;
|
|
254
|
-
} else {
|
|
255
|
-
value = snapshot.requests.total;
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
if (cellIndex >= 0 && cells[cellIndex]) {
|
|
259
|
-
// Update existing cell (exponential moving average)
|
|
260
|
-
cells[cellIndex]!.value = cells[cellIndex]!.value * 0.9 + value * 0.1;
|
|
261
|
-
} else {
|
|
262
|
-
// Add new cell
|
|
263
|
-
cells.push({ day, hour, value });
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
// Keep only last 7 days worth of unique day/hour combinations (7 * 24 = 168 cells max)
|
|
267
|
-
if (cells.length > 168) {
|
|
268
|
-
cells = cells.slice(cells.length - 168);
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
heatmapData[metricType] = cells;
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
// Store back with TTL
|
|
275
|
-
await this.cache.set(key, heatmapData, ttlMs);
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
/**
|
|
279
|
-
* Query historical time-series data
|
|
280
|
-
*/
|
|
281
|
-
async queryHistory(params: {
|
|
282
|
-
metric: 'requests' | 'errors' | 'latency' | 'uptime';
|
|
283
|
-
range: '1m' | '5m' | '10m' | '30m' | '1h';
|
|
284
|
-
interval?: '5s' | '1m' | '5m';
|
|
285
|
-
}): Promise<HistoricalDataPoint[]> {
|
|
286
|
-
const key = `metrics:history:${params.range}`;
|
|
287
|
-
|
|
288
|
-
// Get time series from cache
|
|
289
|
-
const timeSeries = await this.cache.get<MetricsSnapshot[]>(key);
|
|
290
|
-
if (!timeSeries || !Array.isArray(timeSeries)) {
|
|
291
|
-
return [];
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
// Extract requested metric
|
|
295
|
-
const dataPoints: HistoricalDataPoint[] = timeSeries.map(snapshot => {
|
|
296
|
-
let value = 0;
|
|
297
|
-
|
|
298
|
-
switch (params.metric) {
|
|
299
|
-
case 'requests':
|
|
300
|
-
value = snapshot.requests.total;
|
|
301
|
-
break;
|
|
302
|
-
case 'errors':
|
|
303
|
-
value = snapshot.requests.clientErrors + snapshot.requests.serverErrors;
|
|
304
|
-
break;
|
|
305
|
-
case 'latency':
|
|
306
|
-
value = snapshot.latency.average;
|
|
307
|
-
break;
|
|
308
|
-
case 'uptime':
|
|
309
|
-
value = snapshot.uptime;
|
|
310
|
-
break;
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
return {
|
|
314
|
-
timestamp: snapshot.timestamp,
|
|
315
|
-
value,
|
|
316
|
-
};
|
|
317
|
-
});
|
|
318
|
-
|
|
319
|
-
// Apply interval aggregation if requested
|
|
320
|
-
if (params.interval && params.interval !== '5s') {
|
|
321
|
-
return this.aggregateByInterval(dataPoints, params.interval);
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
return dataPoints;
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
/**
|
|
328
|
-
* Query heatmap data
|
|
329
|
-
*/
|
|
330
|
-
async queryHeatmap(params: {
|
|
331
|
-
metric: 'latency' | 'errors' | 'requests';
|
|
332
|
-
days?: 7 | 14 | 30;
|
|
333
|
-
}): Promise<HeatmapCell[]> {
|
|
334
|
-
const key = 'metrics:heatmap:7d';
|
|
335
|
-
|
|
336
|
-
// Get heatmap data from cache
|
|
337
|
-
const heatmapData = await this.cache.get<Record<string, HeatmapCell[]>>(key);
|
|
338
|
-
if (!heatmapData || typeof heatmapData !== 'object') {
|
|
339
|
-
// Return empty heatmap structure
|
|
340
|
-
return this.generateEmptyHeatmap();
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
const cells = heatmapData[params.metric] || [];
|
|
344
|
-
|
|
345
|
-
// If no data yet, return empty heatmap
|
|
346
|
-
if (cells.length === 0) {
|
|
347
|
-
return this.generateEmptyHeatmap();
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
// Ensure all day/hour combinations exist (fill missing with 0)
|
|
351
|
-
return this.fillHeatmapGaps(cells);
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
/**
|
|
355
|
-
* Generate empty heatmap structure (7 days × 24 hours)
|
|
356
|
-
*/
|
|
357
|
-
private generateEmptyHeatmap(): HeatmapCell[] {
|
|
358
|
-
const days = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'];
|
|
359
|
-
const cells: HeatmapCell[] = [];
|
|
360
|
-
|
|
361
|
-
for (const day of days) {
|
|
362
|
-
for (let hour = 0; hour < 24; hour++) {
|
|
363
|
-
cells.push({ day, hour, value: 0 });
|
|
364
|
-
}
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
return cells;
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
/**
|
|
371
|
-
* Fill gaps in heatmap data (missing day/hour combinations)
|
|
372
|
-
*/
|
|
373
|
-
private fillHeatmapGaps(cells: HeatmapCell[]): HeatmapCell[] {
|
|
374
|
-
const days = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'];
|
|
375
|
-
const cellMap = new Map<string, number>();
|
|
376
|
-
|
|
377
|
-
// Index existing cells
|
|
378
|
-
for (const cell of cells) {
|
|
379
|
-
const key = `${cell.day}:${cell.hour}`;
|
|
380
|
-
cellMap.set(key, cell.value);
|
|
381
|
-
}
|
|
382
|
-
|
|
383
|
-
// Generate complete 7×24 grid
|
|
384
|
-
const complete: HeatmapCell[] = [];
|
|
385
|
-
for (const day of days) {
|
|
386
|
-
for (let hour = 0; hour < 24; hour++) {
|
|
387
|
-
const key = `${day}:${hour}`;
|
|
388
|
-
complete.push({
|
|
389
|
-
day,
|
|
390
|
-
hour,
|
|
391
|
-
value: cellMap.get(key) ?? 0,
|
|
392
|
-
});
|
|
393
|
-
}
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
return complete;
|
|
397
|
-
}
|
|
398
|
-
|
|
399
|
-
/**
|
|
400
|
-
* Aggregate data points by interval
|
|
401
|
-
*/
|
|
402
|
-
private aggregateByInterval(dataPoints: HistoricalDataPoint[], interval: '1m' | '5m'): HistoricalDataPoint[] {
|
|
403
|
-
if (dataPoints.length === 0) {return [];}
|
|
404
|
-
|
|
405
|
-
const intervalMs = interval === '1m' ? 60 * 1000 : 5 * 60 * 1000;
|
|
406
|
-
const aggregated: HistoricalDataPoint[] = [];
|
|
407
|
-
|
|
408
|
-
let bucket: HistoricalDataPoint[] = [];
|
|
409
|
-
let bucketStart = Math.floor(dataPoints[0]!.timestamp / intervalMs) * intervalMs;
|
|
410
|
-
|
|
411
|
-
for (const point of dataPoints) {
|
|
412
|
-
const pointBucket = Math.floor(point.timestamp / intervalMs) * intervalMs;
|
|
413
|
-
|
|
414
|
-
if (pointBucket === bucketStart) {
|
|
415
|
-
bucket.push(point);
|
|
416
|
-
} else {
|
|
417
|
-
// Finalize current bucket
|
|
418
|
-
if (bucket.length > 0) {
|
|
419
|
-
const avgValue = bucket.reduce((sum, p) => sum + p.value, 0) / bucket.length;
|
|
420
|
-
aggregated.push({
|
|
421
|
-
timestamp: bucketStart + intervalMs / 2, // midpoint
|
|
422
|
-
value: avgValue,
|
|
423
|
-
});
|
|
424
|
-
}
|
|
425
|
-
|
|
426
|
-
// Start new bucket
|
|
427
|
-
bucket = [point];
|
|
428
|
-
bucketStart = pointBucket;
|
|
429
|
-
}
|
|
430
|
-
}
|
|
431
|
-
|
|
432
|
-
// Finalize last bucket
|
|
433
|
-
if (bucket.length > 0) {
|
|
434
|
-
const avgValue = bucket.reduce((sum, p) => sum + p.value, 0) / bucket.length;
|
|
435
|
-
aggregated.push({
|
|
436
|
-
timestamp: bucketStart + intervalMs / 2,
|
|
437
|
-
value: avgValue,
|
|
438
|
-
});
|
|
439
|
-
}
|
|
440
|
-
|
|
441
|
-
return aggregated;
|
|
442
|
-
}
|
|
443
|
-
|
|
444
|
-
/**
|
|
445
|
-
* Get collector statistics
|
|
446
|
-
*/
|
|
447
|
-
async getStats(): Promise<{
|
|
448
|
-
running: boolean;
|
|
449
|
-
uptimeSeconds: number;
|
|
450
|
-
timeSeries: Record<string, { points: number; oldestTimestamp: number | null; newestTimestamp: number | null }>;
|
|
451
|
-
heatmap: { cells: number; metrics: string[] };
|
|
452
|
-
}> {
|
|
453
|
-
const stats: any = {
|
|
454
|
-
running: this.intervalHandle !== null,
|
|
455
|
-
uptimeSeconds: (Date.now() - this.startTimeMs) / 1000,
|
|
456
|
-
timeSeries: {},
|
|
457
|
-
heatmap: { cells: 0, metrics: [] },
|
|
458
|
-
};
|
|
459
|
-
|
|
460
|
-
// Check each time range
|
|
461
|
-
for (const range of ['1m', '5m', '10m', '30m', '1h'] as const) {
|
|
462
|
-
const key = `metrics:history:${range}`;
|
|
463
|
-
const timeSeries = await this.cache.get<MetricsSnapshot[]>(key);
|
|
464
|
-
|
|
465
|
-
if (timeSeries && Array.isArray(timeSeries)) {
|
|
466
|
-
stats.timeSeries[range] = {
|
|
467
|
-
points: timeSeries.length,
|
|
468
|
-
oldestTimestamp: timeSeries[0]?.timestamp ?? null,
|
|
469
|
-
newestTimestamp: timeSeries[timeSeries.length - 1]?.timestamp ?? null,
|
|
470
|
-
};
|
|
471
|
-
} else {
|
|
472
|
-
stats.timeSeries[range] = { points: 0, oldestTimestamp: null, newestTimestamp: null };
|
|
473
|
-
}
|
|
474
|
-
}
|
|
475
|
-
|
|
476
|
-
// Check heatmap
|
|
477
|
-
const heatmapData = await this.cache.get<Record<string, HeatmapCell[]>>('metrics:heatmap:7d');
|
|
478
|
-
if (heatmapData && typeof heatmapData === 'object') {
|
|
479
|
-
const metrics = Object.keys(heatmapData);
|
|
480
|
-
const totalCells = metrics.reduce((sum, m) => sum + (heatmapData[m]?.length ?? 0), 0);
|
|
481
|
-
stats.heatmap = { cells: totalCells, metrics };
|
|
482
|
-
}
|
|
483
|
-
|
|
484
|
-
return stats;
|
|
485
|
-
}
|
|
486
|
-
|
|
487
|
-
private log(level: 'info' | 'warn' | 'error' | 'debug', message: string, meta?: any): void {
|
|
488
|
-
if (level === 'debug' && !this.config.debug) {return;}
|
|
489
|
-
|
|
490
|
-
if (this.logger[level]) {
|
|
491
|
-
this.logger[level](`[HistoricalMetrics] ${message}`, meta);
|
|
492
|
-
} else {
|
|
493
|
-
console.log(`[HistoricalMetrics] [${level}] ${message}`, meta);
|
|
494
|
-
}
|
|
495
|
-
}
|
|
496
|
-
}
|