@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,244 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @module @kb-labs/rest-api-app/services/system-metrics-collector
|
|
3
|
-
* System metrics collector for REST API instances.
|
|
4
|
-
*
|
|
5
|
-
* Collects CPU, memory, uptime, and load average metrics from the current instance
|
|
6
|
-
* and writes them to platform.cache with TTL for automatic cleanup.
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
import { platform } from '@kb-labs/core-runtime';
|
|
10
|
-
import * as os from 'node:os';
|
|
11
|
-
import * as process from 'node:process';
|
|
12
|
-
import { monitorEventLoopDelay } from 'node:perf_hooks';
|
|
13
|
-
import { updateRuntimeObservabilityMetrics } from '../middleware/prom-metrics.js';
|
|
14
|
-
|
|
15
|
-
let latestSystemMetricsSnapshot: SystemMetrics | null = null;
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* System metrics data structure
|
|
19
|
-
*/
|
|
20
|
-
export interface SystemMetrics {
|
|
21
|
-
/** Instance identifier (hostname) */
|
|
22
|
-
instanceId: string;
|
|
23
|
-
|
|
24
|
-
/** Timestamp when metrics were collected (ms since epoch) */
|
|
25
|
-
timestamp: number;
|
|
26
|
-
|
|
27
|
-
/** CPU usage information */
|
|
28
|
-
cpu: {
|
|
29
|
-
/** User CPU time in microseconds */
|
|
30
|
-
user: number;
|
|
31
|
-
/** System CPU time in microseconds */
|
|
32
|
-
system: number;
|
|
33
|
-
/** CPU usage percentage (0-100) */
|
|
34
|
-
percentage: number;
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
/** Memory usage information */
|
|
38
|
-
memory: {
|
|
39
|
-
/** Resident Set Size (bytes) - total memory allocated */
|
|
40
|
-
rss: number;
|
|
41
|
-
/** Heap total (bytes) - allocated heap */
|
|
42
|
-
heapTotal: number;
|
|
43
|
-
/** Heap used (bytes) - actual heap used */
|
|
44
|
-
heapUsed: number;
|
|
45
|
-
/** External memory (bytes) - C++ objects bound to JS */
|
|
46
|
-
external: number;
|
|
47
|
-
/** Array buffers (bytes) */
|
|
48
|
-
arrayBuffers: number;
|
|
49
|
-
/** RSS usage percentage (0-100) */
|
|
50
|
-
rssPercentage: number;
|
|
51
|
-
/** Heap usage percentage (0-100) */
|
|
52
|
-
heapPercentage: number;
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
/** Process uptime (seconds) */
|
|
56
|
-
uptime: number;
|
|
57
|
-
eventLoopLagMs: number;
|
|
58
|
-
activeOperations: number;
|
|
59
|
-
|
|
60
|
-
/** System load average (1, 5, 15 minutes) */
|
|
61
|
-
loadAvg: [number, number, number];
|
|
62
|
-
|
|
63
|
-
/** Total system memory (bytes) */
|
|
64
|
-
totalMemory: number;
|
|
65
|
-
|
|
66
|
-
/** Free system memory (bytes) */
|
|
67
|
-
freeMemory: number;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
function toFiniteNumber(value: number): number {
|
|
71
|
-
return Number.isFinite(value) ? value : 0;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* System metrics collector
|
|
76
|
-
* Periodically collects system metrics and writes to platform.cache
|
|
77
|
-
*/
|
|
78
|
-
export class SystemMetricsCollector {
|
|
79
|
-
private intervalId: NodeJS.Timeout | null = null;
|
|
80
|
-
private instanceId: string;
|
|
81
|
-
private lastCpuUsage = process.cpuUsage();
|
|
82
|
-
private lastCpuTime = Date.now();
|
|
83
|
-
private eventLoopDelay = monitorEventLoopDelay({ resolution: 20 });
|
|
84
|
-
private latestMetrics: SystemMetrics | null = null;
|
|
85
|
-
|
|
86
|
-
constructor(
|
|
87
|
-
private readonly serviceId: string = 'rest',
|
|
88
|
-
private readonly getActiveOperations: () => number = () => 0,
|
|
89
|
-
) {
|
|
90
|
-
this.instanceId = `${os.hostname()}:${process.pid}`;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* Calculate CPU percentage based on delta
|
|
95
|
-
*/
|
|
96
|
-
private calculateCpuPercentage(): number {
|
|
97
|
-
const currentUsage = process.cpuUsage(this.lastCpuUsage);
|
|
98
|
-
const currentTime = Date.now();
|
|
99
|
-
const deltaTime = currentTime - this.lastCpuTime;
|
|
100
|
-
|
|
101
|
-
// Update for next calculation
|
|
102
|
-
this.lastCpuUsage = process.cpuUsage();
|
|
103
|
-
this.lastCpuTime = currentTime;
|
|
104
|
-
|
|
105
|
-
// Calculate CPU percentage
|
|
106
|
-
// cpuUsage() returns microseconds, convert to milliseconds and calculate percentage
|
|
107
|
-
const cpuTimeMs = (currentUsage.user + currentUsage.system) / 1000;
|
|
108
|
-
const percentage = (cpuTimeMs / deltaTime) * 100;
|
|
109
|
-
|
|
110
|
-
// Cap at 100% (can exceed on multi-core systems)
|
|
111
|
-
return Math.min(percentage, 100);
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* Collect current system metrics
|
|
116
|
-
*/
|
|
117
|
-
private collectMetrics(): SystemMetrics {
|
|
118
|
-
const memoryUsage = process.memoryUsage();
|
|
119
|
-
const totalMemory = os.totalmem();
|
|
120
|
-
const heapPercentageRaw =
|
|
121
|
-
memoryUsage.heapTotal > 0 ? (memoryUsage.heapUsed / memoryUsage.heapTotal) * 100 : 0;
|
|
122
|
-
const eventLoopLagMs = toFiniteNumber(Number((this.eventLoopDelay.mean / 1_000_000).toFixed(2)));
|
|
123
|
-
const cpuPercentage = toFiniteNumber(this.calculateCpuPercentage());
|
|
124
|
-
|
|
125
|
-
return {
|
|
126
|
-
instanceId: this.instanceId,
|
|
127
|
-
timestamp: Date.now(),
|
|
128
|
-
cpu: {
|
|
129
|
-
user: this.lastCpuUsage.user,
|
|
130
|
-
system: this.lastCpuUsage.system,
|
|
131
|
-
percentage: cpuPercentage,
|
|
132
|
-
},
|
|
133
|
-
memory: {
|
|
134
|
-
rss: memoryUsage.rss,
|
|
135
|
-
heapTotal: memoryUsage.heapTotal,
|
|
136
|
-
heapUsed: memoryUsage.heapUsed,
|
|
137
|
-
external: memoryUsage.external,
|
|
138
|
-
arrayBuffers: memoryUsage.arrayBuffers,
|
|
139
|
-
rssPercentage: toFiniteNumber((memoryUsage.rss / totalMemory) * 100),
|
|
140
|
-
heapPercentage: toFiniteNumber(heapPercentageRaw),
|
|
141
|
-
},
|
|
142
|
-
uptime: process.uptime(),
|
|
143
|
-
eventLoopLagMs,
|
|
144
|
-
activeOperations: this.getActiveOperations(),
|
|
145
|
-
loadAvg: os.loadavg() as [number, number, number],
|
|
146
|
-
totalMemory,
|
|
147
|
-
freeMemory: os.freemem(),
|
|
148
|
-
};
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
/**
|
|
152
|
-
* Start collecting metrics at regular intervals
|
|
153
|
-
* @param intervalMs - Collection interval in milliseconds (default: 10000ms = 10s)
|
|
154
|
-
* @param ttlMs - Time-to-live for cache entries (default: 60000ms = 60s)
|
|
155
|
-
*/
|
|
156
|
-
async start(intervalMs: number = 10000, ttlMs: number = 60000): Promise<void> {
|
|
157
|
-
if (this.intervalId) {
|
|
158
|
-
platform.logger.warn('SystemMetricsCollector already started');
|
|
159
|
-
return;
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
platform.logger.info('Starting system metrics collector', {
|
|
163
|
-
serviceId: this.serviceId,
|
|
164
|
-
instanceId: this.instanceId,
|
|
165
|
-
intervalMs,
|
|
166
|
-
ttlMs,
|
|
167
|
-
});
|
|
168
|
-
|
|
169
|
-
this.eventLoopDelay.enable();
|
|
170
|
-
|
|
171
|
-
// Collect immediately on start
|
|
172
|
-
await this.collect(ttlMs);
|
|
173
|
-
|
|
174
|
-
// Then collect at intervals
|
|
175
|
-
this.intervalId = setInterval(async () => {
|
|
176
|
-
await this.collect(ttlMs);
|
|
177
|
-
}, intervalMs);
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
/**
|
|
181
|
-
* Collect metrics and write to cache
|
|
182
|
-
*/
|
|
183
|
-
private async collect(ttlMs: number): Promise<void> {
|
|
184
|
-
try {
|
|
185
|
-
const metrics = this.collectMetrics();
|
|
186
|
-
this.latestMetrics = metrics;
|
|
187
|
-
latestSystemMetricsSnapshot = metrics;
|
|
188
|
-
|
|
189
|
-
// Write to platform.cache with TTL
|
|
190
|
-
// Key pattern: system-metrics:{instanceId}
|
|
191
|
-
await platform.cache.set(
|
|
192
|
-
`system-metrics:${this.instanceId}`,
|
|
193
|
-
metrics,
|
|
194
|
-
ttlMs
|
|
195
|
-
);
|
|
196
|
-
|
|
197
|
-
updateRuntimeObservabilityMetrics({
|
|
198
|
-
cpuPercent: metrics.cpu.percentage,
|
|
199
|
-
rssBytes: metrics.memory.rss,
|
|
200
|
-
heapUsedBytes: metrics.memory.heapUsed,
|
|
201
|
-
eventLoopLagMs: metrics.eventLoopLagMs,
|
|
202
|
-
activeOperations: metrics.activeOperations,
|
|
203
|
-
});
|
|
204
|
-
|
|
205
|
-
platform.logger.debug('System metrics collected', {
|
|
206
|
-
serviceId: this.serviceId,
|
|
207
|
-
instanceId: this.instanceId,
|
|
208
|
-
cpu: metrics.cpu.percentage.toFixed(1) + '%',
|
|
209
|
-
memory: metrics.memory.rssPercentage.toFixed(1) + '%',
|
|
210
|
-
eventLoopLagMs: metrics.eventLoopLagMs,
|
|
211
|
-
activeOperations: metrics.activeOperations,
|
|
212
|
-
uptime: Math.floor(metrics.uptime) + 's',
|
|
213
|
-
});
|
|
214
|
-
|
|
215
|
-
this.eventLoopDelay.reset();
|
|
216
|
-
} catch (error) {
|
|
217
|
-
platform.logger.error('Failed to collect system metrics', error instanceof Error ? error : new Error(String(error)));
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
getInstanceId(): string {
|
|
222
|
-
return this.instanceId;
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
getLatestMetrics(): SystemMetrics | null {
|
|
226
|
-
return this.latestMetrics;
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
/**
|
|
230
|
-
* Stop collecting metrics
|
|
231
|
-
*/
|
|
232
|
-
stop(): void {
|
|
233
|
-
if (this.intervalId) {
|
|
234
|
-
clearInterval(this.intervalId);
|
|
235
|
-
this.intervalId = null;
|
|
236
|
-
platform.logger.info('System metrics collector stopped');
|
|
237
|
-
}
|
|
238
|
-
this.eventLoopDelay.disable();
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
export function getLatestSystemMetrics(): SystemMetrics | null {
|
|
243
|
-
return latestSystemMetricsSnapshot;
|
|
244
|
-
}
|
package/src/types/fastify.d.ts
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @module @kb-labs/rest-api-app/types/fastify
|
|
3
|
-
* Fastify type extensions
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import type { FastifyBaseLogger } from 'fastify/types/logger';
|
|
7
|
-
import type { FastifySchema } from 'fastify/types/schema';
|
|
8
|
-
import type { FastifyTypeProvider, FastifyTypeProviderDefault } from 'fastify/types/type-provider';
|
|
9
|
-
import type { ContextConfigDefault, RawReplyDefaultExpression, RawRequestDefaultExpression, RawServerBase, RawServerDefault } from 'fastify/types/utils';
|
|
10
|
-
import type { IEntityRegistry } from '@kb-labs/core-registry';
|
|
11
|
-
import type { ReadinessState } from '../routes/readiness';
|
|
12
|
-
import '@fastify/type-provider-typebox';
|
|
13
|
-
import type { EventHub } from '../events/hub';
|
|
14
|
-
|
|
15
|
-
declare module 'fastify/types/instance' {
|
|
16
|
-
interface FastifyInstance<
|
|
17
|
-
RawServer extends RawServerBase = RawServerDefault,
|
|
18
|
-
RawRequest extends RawRequestDefaultExpression<RawServer> = RawRequestDefaultExpression<RawServer>,
|
|
19
|
-
RawReply extends RawReplyDefaultExpression<RawServer> = RawReplyDefaultExpression<RawServer>,
|
|
20
|
-
Logger extends FastifyBaseLogger = FastifyBaseLogger,
|
|
21
|
-
TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault,
|
|
22
|
-
SchemaCompiler extends FastifySchema = FastifySchema,
|
|
23
|
-
ContextConfig = ContextConfigDefault
|
|
24
|
-
> {
|
|
25
|
-
registry?: IEntityRegistry;
|
|
26
|
-
kbReadiness?: ReadinessState;
|
|
27
|
-
kbStartupGuard?: {
|
|
28
|
-
inFlight: number;
|
|
29
|
-
};
|
|
30
|
-
kbEventHub?: EventHub;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
declare module 'fastify' {
|
|
35
|
-
interface FastifyInstance {
|
|
36
|
-
registry?: IEntityRegistry;
|
|
37
|
-
kbReadiness?: ReadinessState;
|
|
38
|
-
kbStartupGuard?: {
|
|
39
|
-
inFlight: number;
|
|
40
|
-
};
|
|
41
|
-
kbEventHub?: EventHub;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
declare module 'fastify/types/request' {
|
|
46
|
-
interface FastifyRequest {
|
|
47
|
-
mockMode?: boolean;
|
|
48
|
-
kbStartupGuardActive?: boolean;
|
|
49
|
-
kbStartupGuardTimer?: NodeJS.Timeout;
|
|
50
|
-
kbMetricsStart?: number;
|
|
51
|
-
kbHeaderState?: {
|
|
52
|
-
vary: Set<string>;
|
|
53
|
-
sensitive: Set<string>;
|
|
54
|
-
rateLimitKeys: Record<string, string>;
|
|
55
|
-
sanitized: Record<string, string>;
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
}
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it, vi } from 'vitest';
|
|
2
|
-
import type { RestApiConfig } from '@kb-labs/rest-api-core';
|
|
3
|
-
import { buildRegistrySseAuthHook } from '../sse-auth';
|
|
4
|
-
|
|
5
|
-
function baseConfig(overrides: Partial<RestApiConfig> = {}): RestApiConfig {
|
|
6
|
-
const { events, ...rest } = overrides;
|
|
7
|
-
const config: RestApiConfig = {
|
|
8
|
-
port: 5050,
|
|
9
|
-
basePath: '/api/v1',
|
|
10
|
-
apiVersion: 'test',
|
|
11
|
-
cors: {
|
|
12
|
-
origins: [],
|
|
13
|
-
allowCredentials: true,
|
|
14
|
-
profile: 'dev',
|
|
15
|
-
},
|
|
16
|
-
plugins: [],
|
|
17
|
-
mockMode: false,
|
|
18
|
-
...rest,
|
|
19
|
-
events: events
|
|
20
|
-
? {
|
|
21
|
-
registry: events.registry
|
|
22
|
-
? {
|
|
23
|
-
token: events.registry.token,
|
|
24
|
-
headerName: events.registry.headerName ?? 'authorization',
|
|
25
|
-
queryParam: events.registry.queryParam ?? 'access_token',
|
|
26
|
-
}
|
|
27
|
-
: undefined,
|
|
28
|
-
}
|
|
29
|
-
: undefined,
|
|
30
|
-
};
|
|
31
|
-
return config;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
describe('buildRegistrySseAuthHook', () => {
|
|
35
|
-
it('returns undefined when auth is not configured', () => {
|
|
36
|
-
const hook = buildRegistrySseAuthHook(baseConfig());
|
|
37
|
-
expect(hook).toBeUndefined();
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
it('allows requests with valid bearer token', () => {
|
|
41
|
-
const hook = buildRegistrySseAuthHook(
|
|
42
|
-
baseConfig({
|
|
43
|
-
events: {
|
|
44
|
-
registry: {
|
|
45
|
-
token: 'secret',
|
|
46
|
-
headerName: 'authorization',
|
|
47
|
-
queryParam: 'access_token',
|
|
48
|
-
},
|
|
49
|
-
},
|
|
50
|
-
})
|
|
51
|
-
);
|
|
52
|
-
expect(hook).toBeDefined();
|
|
53
|
-
const done = vi.fn();
|
|
54
|
-
const request = {
|
|
55
|
-
headers: {
|
|
56
|
-
authorization: 'Bearer secret',
|
|
57
|
-
},
|
|
58
|
-
query: {},
|
|
59
|
-
};
|
|
60
|
-
const reply = {
|
|
61
|
-
code: vi.fn().mockReturnThis(),
|
|
62
|
-
header: vi.fn().mockReturnThis(),
|
|
63
|
-
send: vi.fn(),
|
|
64
|
-
};
|
|
65
|
-
hook?.(request as any, reply as any, done as any);
|
|
66
|
-
expect(done).toHaveBeenCalledTimes(1);
|
|
67
|
-
expect(reply.send).not.toHaveBeenCalled();
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
it('rejects requests with invalid token', () => {
|
|
71
|
-
const hook = buildRegistrySseAuthHook(
|
|
72
|
-
baseConfig({
|
|
73
|
-
events: {
|
|
74
|
-
registry: {
|
|
75
|
-
token: 'secret',
|
|
76
|
-
headerName: 'x-api-token',
|
|
77
|
-
queryParam: 'auth',
|
|
78
|
-
},
|
|
79
|
-
},
|
|
80
|
-
})
|
|
81
|
-
);
|
|
82
|
-
const done = vi.fn();
|
|
83
|
-
const request = {
|
|
84
|
-
headers: {
|
|
85
|
-
'x-api-token': 'wrong',
|
|
86
|
-
},
|
|
87
|
-
query: { auth: 'wrong' },
|
|
88
|
-
};
|
|
89
|
-
const reply = {
|
|
90
|
-
statusCode: undefined as number | undefined,
|
|
91
|
-
payload: undefined as unknown,
|
|
92
|
-
code(status: number) {
|
|
93
|
-
this.statusCode = status;
|
|
94
|
-
return this;
|
|
95
|
-
},
|
|
96
|
-
header() {
|
|
97
|
-
return this;
|
|
98
|
-
},
|
|
99
|
-
send(payload: unknown) {
|
|
100
|
-
this.payload = payload;
|
|
101
|
-
},
|
|
102
|
-
};
|
|
103
|
-
hook?.(request as any, reply as any, done as any);
|
|
104
|
-
expect(done).not.toHaveBeenCalled();
|
|
105
|
-
expect(reply.statusCode).toBe(401);
|
|
106
|
-
expect(reply.payload).toMatchObject({
|
|
107
|
-
status: 'unauthorized',
|
|
108
|
-
reason: 'invalid_token',
|
|
109
|
-
});
|
|
110
|
-
});
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export function normalizeBasePath(basePath?: string): string {
|
|
2
|
-
if (!basePath || basePath === '/') {
|
|
3
|
-
return '';
|
|
4
|
-
}
|
|
5
|
-
return basePath.endsWith('/') ? basePath.slice(0, -1) : basePath;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export function resolvePaths(basePath: string, route: string): string[] {
|
|
9
|
-
const normalizedRoute = route.startsWith('/') ? route : `/${route}`;
|
|
10
|
-
if (!basePath) {
|
|
11
|
-
return [normalizedRoute];
|
|
12
|
-
}
|
|
13
|
-
const base = normalizeBasePath(basePath);
|
|
14
|
-
return Array.from(new Set([normalizedRoute, `${base}${normalizedRoute}`]));
|
|
15
|
-
}
|
package/src/utils/repo.ts
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @module @kb-labs/rest-api-app/utils/repo
|
|
3
|
-
* Repository utilities
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import * as path from 'node:path';
|
|
7
|
-
import { promises as fs } from 'node:fs';
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Find monorepo root (prefer pnpm-workspace.yaml or .git over package.json)
|
|
11
|
-
*/
|
|
12
|
-
export async function findMonorepoRoot(startDir: string): Promise<string> {
|
|
13
|
-
let dir = path.resolve(startDir);
|
|
14
|
-
let foundRoot: string | null = null;
|
|
15
|
-
|
|
16
|
-
while (true) {
|
|
17
|
-
try {
|
|
18
|
-
const hasGit = await fs.access(path.join(dir, '.git')).then(() => true).catch(() => false);
|
|
19
|
-
const hasWorkspace = await fs.access(path.join(dir, 'pnpm-workspace.yaml')).then(() => true).catch(() => false);
|
|
20
|
-
|
|
21
|
-
if (hasGit && hasWorkspace) {
|
|
22
|
-
foundRoot = dir;
|
|
23
|
-
}
|
|
24
|
-
} catch {
|
|
25
|
-
// Continue
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
const parent = path.dirname(dir);
|
|
29
|
-
if (parent === dir) {
|
|
30
|
-
break;
|
|
31
|
-
}
|
|
32
|
-
dir = parent;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
if (foundRoot) {
|
|
36
|
-
return foundRoot;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
// Fallback: use startDir
|
|
40
|
-
return path.resolve(startDir);
|
|
41
|
-
}
|
|
42
|
-
|
package/src/utils/schema.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @module @kb-labs/rest-api-app/utils/schema
|
|
3
|
-
* Schema utilities for Fastify routes.
|
|
4
|
-
* Route-level Zod schemas live in @kb-labs/rest-api-contracts/route-schemas.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Error response schema for Fastify's built-in error serialization.
|
|
9
|
-
* Used in non-Zod routes (health, metrics, internal).
|
|
10
|
-
*/
|
|
11
|
-
export const errorSchema = {
|
|
12
|
-
type: 'object',
|
|
13
|
-
properties: {
|
|
14
|
-
statusCode: { type: 'number' },
|
|
15
|
-
error: { type: 'string' },
|
|
16
|
-
message: { type: 'string' },
|
|
17
|
-
code: { type: 'string' },
|
|
18
|
-
},
|
|
19
|
-
additionalProperties: true,
|
|
20
|
-
} as const;
|
package/src/utils/sse-auth.ts
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @module @kb-labs/rest-api-app/utils/sse-auth
|
|
3
|
-
* Helpers for SSE token validation
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import type { FastifyReply, FastifyRequest, HookHandlerDoneFunction } from 'fastify';
|
|
7
|
-
import type { RestApiConfig } from '@kb-labs/rest-api-core';
|
|
8
|
-
|
|
9
|
-
type RegistryAuthConfig = {
|
|
10
|
-
token: string;
|
|
11
|
-
headerName: string;
|
|
12
|
-
queryParam: string;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
function extractTokenFromHeader(headerValue: unknown, headerName: string): string | undefined {
|
|
16
|
-
if (typeof headerValue === 'string') {
|
|
17
|
-
if (headerName === 'authorization') {
|
|
18
|
-
const match = headerValue.match(/^Bearer\s+(.+)$/i);
|
|
19
|
-
return match ? match[1] : undefined;
|
|
20
|
-
}
|
|
21
|
-
return headerValue;
|
|
22
|
-
}
|
|
23
|
-
if (Array.isArray(headerValue)) {
|
|
24
|
-
return headerValue[0];
|
|
25
|
-
}
|
|
26
|
-
return undefined;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
function extractToken(request: FastifyRequest, config: RegistryAuthConfig): string | undefined {
|
|
30
|
-
const headerName = (config.headerName ?? 'authorization').toLowerCase();
|
|
31
|
-
const queryParam = config.queryParam ?? 'access_token';
|
|
32
|
-
|
|
33
|
-
const explicitHeader = extractTokenFromHeader(request.headers[headerName], headerName);
|
|
34
|
-
if (explicitHeader) {
|
|
35
|
-
return explicitHeader;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
if (headerName !== 'authorization' && typeof request.headers.authorization === 'string') {
|
|
39
|
-
const fallback = extractTokenFromHeader(request.headers.authorization, 'authorization');
|
|
40
|
-
if (fallback) {
|
|
41
|
-
return fallback;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
const query = request.query as Record<string, string | undefined>;
|
|
46
|
-
return query?.[queryParam] ?? query?.access_token;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export function buildRegistrySseAuthHook(config: RestApiConfig) {
|
|
50
|
-
const registryAuth = config.events?.registry;
|
|
51
|
-
if (!registryAuth?.token) {
|
|
52
|
-
return undefined;
|
|
53
|
-
}
|
|
54
|
-
const authConfig: RegistryAuthConfig = {
|
|
55
|
-
token: registryAuth.token,
|
|
56
|
-
headerName: registryAuth.headerName ?? 'authorization',
|
|
57
|
-
queryParam: registryAuth.queryParam ?? 'access_token',
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
return function registrySseAuthHook(
|
|
61
|
-
request: FastifyRequest,
|
|
62
|
-
reply: FastifyReply,
|
|
63
|
-
done: HookHandlerDoneFunction
|
|
64
|
-
) {
|
|
65
|
-
const provided = extractToken(request, authConfig);
|
|
66
|
-
if (provided === authConfig.token) {
|
|
67
|
-
done();
|
|
68
|
-
return;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
reply
|
|
72
|
-
.code(401)
|
|
73
|
-
.header('content-type', 'application/json')
|
|
74
|
-
.send({
|
|
75
|
-
status: 'unauthorized',
|
|
76
|
-
reason: 'invalid_token',
|
|
77
|
-
});
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
|
package/test-sandbox.sh
DELETED
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
|
|
3
|
-
# Test script for KB Labs REST API with sandbox execution
|
|
4
|
-
# Usage: ./test-sandbox.sh
|
|
5
|
-
|
|
6
|
-
set -e
|
|
7
|
-
|
|
8
|
-
echo "🧪 Testing KB Labs REST API Sandbox Execution"
|
|
9
|
-
echo "=============================================="
|
|
10
|
-
echo ""
|
|
11
|
-
|
|
12
|
-
# Colors
|
|
13
|
-
GREEN='\033[0;32m'
|
|
14
|
-
RED='\033[0;31m'
|
|
15
|
-
YELLOW='\033[1;33m'
|
|
16
|
-
NC='\033[0m' # No Color
|
|
17
|
-
|
|
18
|
-
API_URL="${API_URL:-http://localhost:3000}"
|
|
19
|
-
BASE_PATH="/api/v1"
|
|
20
|
-
|
|
21
|
-
echo "📡 API URL: ${API_URL}"
|
|
22
|
-
echo ""
|
|
23
|
-
|
|
24
|
-
# Test 1: Check if server is running
|
|
25
|
-
echo "1️⃣ Testing server health..."
|
|
26
|
-
if curl -s -f "${API_URL}${BASE_PATH}/health" > /dev/null; then
|
|
27
|
-
echo -e "${GREEN}✅ Server is running${NC}"
|
|
28
|
-
else
|
|
29
|
-
echo -e "${RED}❌ Server is not running. Start it with: npm run dev${NC}"
|
|
30
|
-
exit 1
|
|
31
|
-
fi
|
|
32
|
-
|
|
33
|
-
# Test 2: Check plugin registry
|
|
34
|
-
echo ""
|
|
35
|
-
echo "2️⃣ Testing plugin registry..."
|
|
36
|
-
REGISTRY_RESPONSE=$(curl -s "${API_URL}${BASE_PATH}/plugins/registry")
|
|
37
|
-
if echo "$REGISTRY_RESPONSE" | grep -q "mind"; then
|
|
38
|
-
echo -e "${GREEN}✅ Mind plugin found in registry${NC}"
|
|
39
|
-
echo " Found plugins: $(echo "$REGISTRY_RESPONSE" | jq -r '.manifests[].id' 2>/dev/null || echo 'unknown')"
|
|
40
|
-
else
|
|
41
|
-
echo -e "${YELLOW}⚠️ Mind plugin not found in registry${NC}"
|
|
42
|
-
echo " Response: $REGISTRY_RESPONSE"
|
|
43
|
-
fi
|
|
44
|
-
|
|
45
|
-
# Test 3: Test Mind query endpoint (sandbox execution)
|
|
46
|
-
echo ""
|
|
47
|
-
echo "3️⃣ Testing Mind query endpoint (sandbox execution)..."
|
|
48
|
-
QUERY_RESPONSE=$(curl -s -X POST "${API_URL}${BASE_PATH}/plugins/mind/query" \
|
|
49
|
-
-H "Content-Type: application/json" \
|
|
50
|
-
-d '{
|
|
51
|
-
"query": "meta",
|
|
52
|
-
"params": {},
|
|
53
|
-
"options": {
|
|
54
|
-
"cwd": ".",
|
|
55
|
-
"json": true
|
|
56
|
-
}
|
|
57
|
-
}')
|
|
58
|
-
|
|
59
|
-
if echo "$QUERY_RESPONSE" | grep -q "ok"; then
|
|
60
|
-
echo -e "${GREEN}✅ Query endpoint responded successfully${NC}"
|
|
61
|
-
echo " Response structure:"
|
|
62
|
-
echo "$QUERY_RESPONSE" | jq '.' 2>/dev/null || echo "$QUERY_RESPONSE"
|
|
63
|
-
else
|
|
64
|
-
echo -e "${RED}❌ Query endpoint failed${NC}"
|
|
65
|
-
echo " Response: $QUERY_RESPONSE"
|
|
66
|
-
fi
|
|
67
|
-
|
|
68
|
-
# Test 4: Check for sandbox execution metrics
|
|
69
|
-
echo ""
|
|
70
|
-
echo "4️⃣ Checking for execution metrics..."
|
|
71
|
-
if echo "$QUERY_RESPONSE" | grep -q "meta"; then
|
|
72
|
-
echo -e "${GREEN}✅ Execution metrics found${NC}"
|
|
73
|
-
METRICS=$(echo "$QUERY_RESPONSE" | jq -r '.meta.exec' 2>/dev/null || echo '{}')
|
|
74
|
-
echo " Metrics: $METRICS"
|
|
75
|
-
else
|
|
76
|
-
echo -e "${YELLOW}⚠️ No metrics found in response${NC}"
|
|
77
|
-
fi
|
|
78
|
-
|
|
79
|
-
# Test 5: Test error handling (invalid request)
|
|
80
|
-
echo ""
|
|
81
|
-
echo "5️⃣ Testing error handling..."
|
|
82
|
-
ERROR_RESPONSE=$(curl -s -X POST "${API_URL}${BASE_PATH}/plugins/mind/query" \
|
|
83
|
-
-H "Content-Type: application/json" \
|
|
84
|
-
-d '{
|
|
85
|
-
"invalid": "request"
|
|
86
|
-
}')
|
|
87
|
-
|
|
88
|
-
if echo "$ERROR_RESPONSE" | grep -q "error\|status.*error"; then
|
|
89
|
-
echo -e "${GREEN}✅ Error handling works${NC}"
|
|
90
|
-
echo " Error response:"
|
|
91
|
-
echo "$ERROR_RESPONSE" | jq '.' 2>/dev/null || echo "$ERROR_RESPONSE"
|
|
92
|
-
else
|
|
93
|
-
echo -e "${YELLOW}⚠️ Unexpected error response format${NC}"
|
|
94
|
-
echo " Response: $ERROR_RESPONSE"
|
|
95
|
-
fi
|
|
96
|
-
|
|
97
|
-
echo ""
|
|
98
|
-
echo "=============================================="
|
|
99
|
-
echo -e "${GREEN}✅ Sandbox execution test complete!${NC}"
|
|
100
|
-
echo ""
|
|
101
|
-
echo "💡 Tips:"
|
|
102
|
-
echo " - Set KB_PLUGIN_DEV_MODE=true for in-process execution"
|
|
103
|
-
echo " - Check logs for detailed execution info"
|
|
104
|
-
echo " - Use --json flag in plugin responses for AI agents"
|
|
105
|
-
|