@kb-labs/rest-api-app 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.kb/agents/sessions/session-1771531145393-ws3uh6q/turns.json +42 -0
- package/.kb/agents/sessions/session-1771548930486-ui6rtvm/turns.json +33 -0
- package/.kb/agents/sessions/session-1771549691485-nibqroq/turns.json +133 -0
- package/.kb/agents/sessions/session-1771550943182-dkwqdjc/turns.json +130 -0
- package/.kb/agents/sessions/session-1771551564182-cr4bwzn/turns.json +349 -0
- package/.kb/agents/sessions/session-1771552401370-g4ztwd1/turns.json +206 -0
- package/.kb/commit/current/plan.json +248 -0
- package/.kb/commit/current/status.json +472 -0
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/commands/health.d.ts +10 -0
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/commands/health.js +215 -0
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/commands/health.js.map +1 -0
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/commands/list.d.ts +10 -0
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/commands/list.js +271 -0
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/commands/list.js.map +1 -0
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/commands/logs.d.ts +10 -0
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/commands/logs.js +230 -0
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/commands/logs.js.map +1 -0
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/commands/metrics.d.ts +10 -0
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/commands/metrics.js +228 -0
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/commands/metrics.js.map +1 -0
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/commands/run.d.ts +11 -0
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/commands/run.js +281 -0
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/commands/run.js.map +1 -0
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/commands/status.d.ts +10 -0
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/commands/status.js +266 -0
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/commands/status.js.map +1 -0
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/commands/workflow-run.d.ts +11 -0
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/commands/workflow-run.js +284 -0
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/commands/workflow-run.js.map +1 -0
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/flags-WLdpSZl4.d.ts +77 -0
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/index.d.ts +2 -0
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/index.js +441 -0
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/index.js.map +1 -0
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/manifest.d.ts +196 -0
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/manifest.js +441 -0
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/manifest.js.map +1 -0
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/cron-list-handler.d.ts +19 -0
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/cron-list-handler.js +48 -0
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/cron-list-handler.js.map +1 -0
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/index.d.ts +6 -0
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/index.js +170 -0
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/index.js.map +1 -0
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/job-cancel-handler.d.ts +12 -0
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/job-cancel-handler.js +52 -0
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/job-cancel-handler.js.map +1 -0
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/job-detail-handler.d.ts +22 -0
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/job-detail-handler.js +52 -0
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/job-detail-handler.js.map +1 -0
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/job-logs-handler.d.ts +13 -0
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/job-logs-handler.js +52 -0
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/job-logs-handler.js.map +1 -0
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/job-steps-handler.d.ts +9 -0
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/job-steps-handler.js +43 -0
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/job-steps-handler.js.map +1 -0
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/jobs-list-handler.d.ts +26 -0
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/jobs-list-handler.js +63 -0
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/jobs-list-handler.js.map +1 -0
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/pending-approvals-handler.d.ts +9 -0
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/pending-approvals-handler.js +46 -0
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/pending-approvals-handler.js.map +1 -0
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/resolve-approval-handler.d.ts +16 -0
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/resolve-approval-handler.js +58 -0
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/resolve-approval-handler.js.map +1 -0
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/run-detail-handler.d.ts +9 -0
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/run-detail-handler.js +46 -0
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/run-detail-handler.js.map +1 -0
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/runs-list-handler.d.ts +11 -0
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/runs-list-handler.js +50 -0
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/runs-list-handler.js.map +1 -0
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/stats-handler.d.ts +7 -0
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/stats-handler.js +39 -0
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/stats-handler.js.map +1 -0
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/workflow-detail-handler.d.ts +10 -0
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/workflow-detail-handler.js +46 -0
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/workflow-detail-handler.js.map +1 -0
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/workflow-run-cancel-handler.d.ts +13 -0
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/workflow-run-cancel-handler.js +47 -0
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/workflow-run-cancel-handler.js.map +1 -0
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/workflow-run-handler.d.ts +14 -0
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/workflow-run-handler.js +53 -0
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/workflow-run-handler.js.map +1 -0
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/workflow-runs-handler.d.ts +13 -0
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/workflow-runs-handler.js +54 -0
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/workflow-runs-handler.js.map +1 -0
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/workflows-list-handler.d.ts +12 -0
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/workflows-list-handler.js +51 -0
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/rest/workflows-list-handler.js.map +1 -0
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/ws/logs-channel.d.ts +17 -0
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/ws/logs-channel.js +133 -0
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/ws/logs-channel.js.map +1 -0
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/ws/progress-channel.d.ts +11 -0
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/ws/progress-channel.js +46 -0
- package/.kb/runtime/workspaces/ws_94c2deab-4cf9-49cb-94ac-3958062754a1/ws/progress-channel.js.map +1 -0
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/commands/health.d.ts +10 -0
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/commands/health.js +215 -0
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/commands/health.js.map +1 -0
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/commands/list.d.ts +10 -0
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/commands/list.js +271 -0
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/commands/list.js.map +1 -0
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/commands/logs.d.ts +10 -0
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/commands/logs.js +230 -0
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/commands/logs.js.map +1 -0
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/commands/metrics.d.ts +10 -0
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/commands/metrics.js +228 -0
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/commands/metrics.js.map +1 -0
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/commands/run.d.ts +11 -0
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/commands/run.js +281 -0
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/commands/run.js.map +1 -0
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/commands/status.d.ts +10 -0
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/commands/status.js +266 -0
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/commands/status.js.map +1 -0
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/commands/workflow-run.d.ts +11 -0
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/commands/workflow-run.js +284 -0
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/commands/workflow-run.js.map +1 -0
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/flags-WLdpSZl4.d.ts +77 -0
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/index.d.ts +2 -0
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/index.js +441 -0
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/index.js.map +1 -0
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/manifest.d.ts +196 -0
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/manifest.js +441 -0
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/manifest.js.map +1 -0
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/cron-list-handler.d.ts +19 -0
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/cron-list-handler.js +48 -0
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/cron-list-handler.js.map +1 -0
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/index.d.ts +6 -0
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/index.js +170 -0
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/index.js.map +1 -0
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/job-cancel-handler.d.ts +12 -0
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/job-cancel-handler.js +52 -0
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/job-cancel-handler.js.map +1 -0
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/job-detail-handler.d.ts +22 -0
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/job-detail-handler.js +52 -0
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/job-detail-handler.js.map +1 -0
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/job-logs-handler.d.ts +13 -0
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/job-logs-handler.js +52 -0
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/job-logs-handler.js.map +1 -0
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/job-steps-handler.d.ts +9 -0
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/job-steps-handler.js +43 -0
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/job-steps-handler.js.map +1 -0
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/jobs-list-handler.d.ts +26 -0
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/jobs-list-handler.js +63 -0
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/jobs-list-handler.js.map +1 -0
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/pending-approvals-handler.d.ts +9 -0
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/pending-approvals-handler.js +46 -0
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/pending-approvals-handler.js.map +1 -0
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/resolve-approval-handler.d.ts +16 -0
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/resolve-approval-handler.js +58 -0
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/resolve-approval-handler.js.map +1 -0
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/run-detail-handler.d.ts +9 -0
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/run-detail-handler.js +46 -0
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/run-detail-handler.js.map +1 -0
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/runs-list-handler.d.ts +11 -0
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/runs-list-handler.js +50 -0
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/runs-list-handler.js.map +1 -0
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/stats-handler.d.ts +7 -0
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/stats-handler.js +39 -0
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/stats-handler.js.map +1 -0
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/workflow-detail-handler.d.ts +10 -0
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/workflow-detail-handler.js +46 -0
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/workflow-detail-handler.js.map +1 -0
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/workflow-run-cancel-handler.d.ts +13 -0
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/workflow-run-cancel-handler.js +47 -0
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/workflow-run-cancel-handler.js.map +1 -0
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/workflow-run-handler.d.ts +14 -0
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/workflow-run-handler.js +53 -0
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/workflow-run-handler.js.map +1 -0
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/workflow-runs-handler.d.ts +13 -0
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/workflow-runs-handler.js +54 -0
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/workflow-runs-handler.js.map +1 -0
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/workflows-list-handler.d.ts +12 -0
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/workflows-list-handler.js +51 -0
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/rest/workflows-list-handler.js.map +1 -0
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/ws/logs-channel.d.ts +17 -0
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/ws/logs-channel.js +133 -0
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/ws/logs-channel.js.map +1 -0
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/ws/progress-channel.d.ts +11 -0
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/ws/progress-channel.js +46 -0
- package/.kb/runtime/workspaces/ws_f0f301b8-388d-4dc4-b301-475f2bc95f02/ws/progress-channel.js.map +1 -0
- package/README.md +54 -0
- package/eslint.config.js +23 -0
- package/package.json +72 -0
- package/src/.kb/agents/sessions/session-1773470583796-ximqnfk/kpi-baseline.json +17 -0
- package/src/.kb/memory/sessions/session-1773470583796-ximqnfk/fact-sheet.json +1 -0
- package/src/bootstrap.ts +233 -0
- package/src/diagnostics/header-debug.ts +37 -0
- package/src/events/hub.ts +60 -0
- package/src/events/index.ts +1 -0
- package/src/index.ts +13 -0
- package/src/manifest.ts +21 -0
- package/src/middleware/__tests__/cache.spec.ts +184 -0
- package/src/middleware/__tests__/envelope.spec.ts +268 -0
- package/src/middleware/__tests__/metrics.redis.spec.ts +64 -0
- package/src/middleware/__tests__/rate-limit.spec.ts +283 -0
- package/src/middleware/__tests__/request-id.spec.ts +160 -0
- package/src/middleware/cache.ts +67 -0
- package/src/middleware/envelope.ts +136 -0
- package/src/middleware/error-guard.ts +69 -0
- package/src/middleware/index.ts +37 -0
- package/src/middleware/metrics.ts +810 -0
- package/src/middleware/mock-mode.ts +44 -0
- package/src/middleware/prom-metrics.ts +284 -0
- package/src/middleware/rate-limit-routes.ts +73 -0
- package/src/middleware/rate-limit.ts +72 -0
- package/src/middleware/request-id.ts +41 -0
- package/src/middleware/request-timeout.ts +69 -0
- package/src/middleware/security-headers.ts +24 -0
- package/src/middleware/startup-guard.ts +107 -0
- package/src/observability/service-contract.ts +192 -0
- package/src/plugins/index.ts +118 -0
- package/src/routes/__tests__/adapters-date-helpers.spec.ts +332 -0
- package/src/routes/__tests__/adapters.spec.ts +680 -0
- package/src/routes/__tests__/cache.spec.ts +264 -0
- package/src/routes/__tests__/events.spec.ts +434 -0
- package/src/routes/__tests__/health.spec.ts +414 -0
- package/src/routes/__tests__/logs.spec.ts +494 -0
- package/src/routes/__tests__/observability.spec.ts +392 -0
- package/src/routes/__tests__/plugins.spec.ts +931 -0
- package/src/routes/__tests__/workflow-management.spec.ts +698 -0
- package/src/routes/__tests__/workflows.spec.ts +204 -0
- package/src/routes/adapter-call.ts +220 -0
- package/src/routes/adapters.ts +1206 -0
- package/src/routes/analytics.ts +328 -0
- package/src/routes/cache.ts +104 -0
- package/src/routes/debug-routes.ts +95 -0
- package/src/routes/events.ts +115 -0
- package/src/routes/health.ts +348 -0
- package/src/routes/hello.ts +47 -0
- package/src/routes/index.ts +395 -0
- package/src/routes/jobs.ts +253 -0
- package/src/routes/logs.ts +718 -0
- package/src/routes/metrics.ts +120 -0
- package/src/routes/observability.ts +1388 -0
- package/src/routes/openapi.ts +101 -0
- package/src/routes/platform.ts +143 -0
- package/src/routes/plugins.ts +998 -0
- package/src/routes/readiness.ts +83 -0
- package/src/routes/workflow-management.ts +469 -0
- package/src/routes/workflows.ts +256 -0
- package/src/server.ts +203 -0
- package/src/services/historical-metrics.ts +496 -0
- package/src/services/incident-analyzer.ts +289 -0
- package/src/services/incident-detector.ts +691 -0
- package/src/services/incident-schema.sql +76 -0
- package/src/services/incident-storage.ts +593 -0
- package/src/services/system-metrics-collector.ts +244 -0
- package/src/types/fastify.d.ts +58 -0
- package/src/utils/__tests__/sse-auth.spec.ts +113 -0
- package/src/utils/path-helpers.ts +15 -0
- package/src/utils/repo.ts +42 -0
- package/src/utils/schema.ts +20 -0
- package/src/utils/sse-auth.ts +81 -0
- package/test-sandbox.sh +105 -0
- package/tsconfig.build.json +15 -0
- package/tsconfig.json +9 -0
- package/tsup.config.ts +18 -0
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module @kb-labs/rest-api-app/routes/workflows
|
|
3
|
+
* Workflow SSE streaming endpoint.
|
|
4
|
+
*
|
|
5
|
+
* All CRUD operations (list runs, get run, cancel, run workflow) are handled
|
|
6
|
+
* by the workflow plugin via plugin routes (/plugins/workflow/...).
|
|
7
|
+
* This file only provides the SSE event stream which requires a long-lived
|
|
8
|
+
* connection that cannot go through the plugin execution backend.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import type { FastifyInstance } from 'fastify'
|
|
12
|
+
import type { RestApiConfig } from '@kb-labs/rest-api-core'
|
|
13
|
+
import { WORKFLOW_REDIS_CHANNEL } from '@kb-labs/workflow-constants'
|
|
14
|
+
import { platform } from '@kb-labs/core-runtime'
|
|
15
|
+
import { normalizeBasePath } from '../utils/path-helpers'
|
|
16
|
+
|
|
17
|
+
const TERMINAL_EVENT_TYPES = ['run.finished', 'run.failed', 'run.cancelled']
|
|
18
|
+
const KEEP_ALIVE_MS = 30_000
|
|
19
|
+
const IDLE_TIMEOUT_MS = 60_000
|
|
20
|
+
const EVENT_BUS_KEY = `eventbus:${WORKFLOW_REDIS_CHANNEL}`
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Replay past events for a runId from the Redis sorted set.
|
|
24
|
+
* Returns true if a terminal event was found (run already finished).
|
|
25
|
+
*/
|
|
26
|
+
async function replayHistory(
|
|
27
|
+
runId: string,
|
|
28
|
+
sendEvent: (type: string, payload: unknown, timestamp?: string) => void,
|
|
29
|
+
): Promise<boolean> {
|
|
30
|
+
let hasTerminal = false
|
|
31
|
+
try {
|
|
32
|
+
const cache = platform.cache
|
|
33
|
+
if (!cache?.zrangebyscore) {return false}
|
|
34
|
+
|
|
35
|
+
const stored = await cache.zrangebyscore(EVENT_BUS_KEY, 0, Date.now())
|
|
36
|
+
for (const raw of stored) {
|
|
37
|
+
try {
|
|
38
|
+
const wrapper = JSON.parse(raw) as { data: { type: string; runId: string; payload?: unknown; timestamp?: string } }
|
|
39
|
+
const event = wrapper.data
|
|
40
|
+
if (event.runId !== runId) {continue}
|
|
41
|
+
sendEvent(event.type, event.payload, event.timestamp)
|
|
42
|
+
if (TERMINAL_EVENT_TYPES.includes(event.type)) {
|
|
43
|
+
hasTerminal = true
|
|
44
|
+
}
|
|
45
|
+
} catch { /* skip malformed entries */ }
|
|
46
|
+
}
|
|
47
|
+
} catch { /* cache unavailable — skip replay */ }
|
|
48
|
+
return hasTerminal
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export async function registerWorkflowRoutes(
|
|
52
|
+
server: FastifyInstance,
|
|
53
|
+
config: RestApiConfig,
|
|
54
|
+
): Promise<void> {
|
|
55
|
+
const basePath = normalizeBasePath(config.basePath)
|
|
56
|
+
|
|
57
|
+
// SSE stream of workflow run events via shared IEventBus.
|
|
58
|
+
// No local engine needed — events arrive through the distributed event bus
|
|
59
|
+
// (state broker / Redis / Kafka). The daemon publishes, we subscribe.
|
|
60
|
+
server.route({
|
|
61
|
+
method: 'GET',
|
|
62
|
+
url: `${basePath}/workflows/runs/:runId/events`,
|
|
63
|
+
handler: async (request, reply) => {
|
|
64
|
+
const runId = getRunId(request.params)
|
|
65
|
+
|
|
66
|
+
// SSE response — hijack from Fastify
|
|
67
|
+
reply.hijack()
|
|
68
|
+
const raw = reply.raw
|
|
69
|
+
|
|
70
|
+
const origin = request.headers.origin
|
|
71
|
+
if (typeof origin === 'string' && (origin === 'http://localhost:3000' || origin === 'http://localhost:5173')) {
|
|
72
|
+
raw.setHeader('Access-Control-Allow-Origin', origin)
|
|
73
|
+
raw.setHeader('Access-Control-Allow-Credentials', 'true')
|
|
74
|
+
}
|
|
75
|
+
raw.setHeader('Content-Type', 'text/event-stream')
|
|
76
|
+
raw.setHeader('Cache-Control', 'no-cache, no-transform')
|
|
77
|
+
raw.setHeader('Connection', 'keep-alive')
|
|
78
|
+
raw.flushHeaders?.()
|
|
79
|
+
raw.write(': connected\n\n')
|
|
80
|
+
|
|
81
|
+
const sentIds = new Set<string>()
|
|
82
|
+
|
|
83
|
+
const sendEvent = (type: string, payload: unknown, timestamp?: string) => {
|
|
84
|
+
if (raw.writableEnded) {return}
|
|
85
|
+
const data = { type, runId, payload, timestamp: timestamp ?? new Date().toISOString() }
|
|
86
|
+
// Dedup by type+timestamp to avoid replaying events that also arrive live
|
|
87
|
+
const dedup = `${type}:${data.timestamp}`
|
|
88
|
+
if (sentIds.has(dedup)) {return}
|
|
89
|
+
sentIds.add(dedup)
|
|
90
|
+
raw.write(`event: workflow.event\n`)
|
|
91
|
+
raw.write(`data: ${JSON.stringify(data)}\n\n`)
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// Replay history — send past events for this run
|
|
95
|
+
const alreadyFinished = await replayHistory(runId, sendEvent)
|
|
96
|
+
if (alreadyFinished) {
|
|
97
|
+
raw.end()
|
|
98
|
+
return
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
let idleTimer: ReturnType<typeof setTimeout> | null = null
|
|
102
|
+
|
|
103
|
+
const resetIdle = () => {
|
|
104
|
+
if (idleTimer) {clearTimeout(idleTimer)}
|
|
105
|
+
idleTimer = setTimeout(() => {
|
|
106
|
+
cleanup()
|
|
107
|
+
}, IDLE_TIMEOUT_MS)
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
const keepAliveTimer = setInterval(() => {
|
|
111
|
+
if (raw.writableEnded) {return}
|
|
112
|
+
raw.write(': keep-alive\n\n')
|
|
113
|
+
}, KEEP_ALIVE_MS)
|
|
114
|
+
|
|
115
|
+
const unsubscribe = platform.eventBus.subscribe(WORKFLOW_REDIS_CHANNEL, async (rawEvent: unknown) => {
|
|
116
|
+
const event = rawEvent as { type: string; runId: string; payload?: unknown; timestamp?: string }
|
|
117
|
+
if (event.runId !== runId) {return}
|
|
118
|
+
sendEvent(event.type, event.payload, event.timestamp)
|
|
119
|
+
resetIdle()
|
|
120
|
+
if (TERMINAL_EVENT_TYPES.includes(event.type)) {
|
|
121
|
+
cleanup()
|
|
122
|
+
}
|
|
123
|
+
})
|
|
124
|
+
|
|
125
|
+
const cleanup = () => {
|
|
126
|
+
unsubscribe()
|
|
127
|
+
if (idleTimer) {clearTimeout(idleTimer)}
|
|
128
|
+
clearInterval(keepAliveTimer)
|
|
129
|
+
if (!raw.writableEnded) {
|
|
130
|
+
raw.write(`event: workflow.done\ndata: {}\n\n`)
|
|
131
|
+
raw.end()
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
resetIdle()
|
|
136
|
+
request.raw.on('close', cleanup)
|
|
137
|
+
},
|
|
138
|
+
})
|
|
139
|
+
|
|
140
|
+
// SSE stream of workflow run logs via shared IEventBus.
|
|
141
|
+
// Sends all events for a run as `workflow.log` entries with jobId/stepId context.
|
|
142
|
+
server.route({
|
|
143
|
+
method: 'GET',
|
|
144
|
+
url: `${basePath}/workflows/runs/:runId/logs`,
|
|
145
|
+
handler: async (request, reply) => {
|
|
146
|
+
const runId = getRunId(request.params)
|
|
147
|
+
const query = request.query as { idleTimeoutMs?: string }
|
|
148
|
+
const idleTimeout = query.idleTimeoutMs ? parseInt(query.idleTimeoutMs, 10) : IDLE_TIMEOUT_MS
|
|
149
|
+
|
|
150
|
+
reply.hijack()
|
|
151
|
+
const raw = reply.raw
|
|
152
|
+
|
|
153
|
+
const origin = request.headers.origin
|
|
154
|
+
if (typeof origin === 'string' && (origin === 'http://localhost:3000' || origin === 'http://localhost:5173')) {
|
|
155
|
+
raw.setHeader('Access-Control-Allow-Origin', origin)
|
|
156
|
+
raw.setHeader('Access-Control-Allow-Credentials', 'true')
|
|
157
|
+
}
|
|
158
|
+
raw.setHeader('Content-Type', 'text/event-stream')
|
|
159
|
+
raw.setHeader('Cache-Control', 'no-cache, no-transform')
|
|
160
|
+
raw.setHeader('Connection', 'keep-alive')
|
|
161
|
+
raw.flushHeaders?.()
|
|
162
|
+
raw.write(': connected\n\n')
|
|
163
|
+
|
|
164
|
+
const sentLogIds = new Set<string>()
|
|
165
|
+
|
|
166
|
+
const sendLog = (event: { type: string; runId: string; jobId?: string; stepId?: string; payload?: unknown; timestamp?: string }) => {
|
|
167
|
+
if (raw.writableEnded) {return}
|
|
168
|
+
const ts = event.timestamp ?? new Date().toISOString()
|
|
169
|
+
const dedup = `${event.type}:${event.jobId ?? ''}:${event.stepId ?? ''}:${ts}`
|
|
170
|
+
if (sentLogIds.has(dedup)) {return}
|
|
171
|
+
sentLogIds.add(dedup)
|
|
172
|
+
raw.write(`event: workflow.log\n`)
|
|
173
|
+
raw.write(`data: ${JSON.stringify({
|
|
174
|
+
type: event.type,
|
|
175
|
+
runId: event.runId,
|
|
176
|
+
jobId: event.jobId,
|
|
177
|
+
stepId: event.stepId,
|
|
178
|
+
payload: event.payload,
|
|
179
|
+
timestamp: ts,
|
|
180
|
+
})}\n\n`)
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
// Replay history for logs
|
|
184
|
+
let logsAlreadyFinished = false
|
|
185
|
+
try {
|
|
186
|
+
const cache = platform.cache
|
|
187
|
+
if (cache?.zrangebyscore) {
|
|
188
|
+
const stored = await cache.zrangebyscore(EVENT_BUS_KEY, 0, Date.now())
|
|
189
|
+
for (const rawStr of stored) {
|
|
190
|
+
try {
|
|
191
|
+
const wrapper = JSON.parse(rawStr) as { data: { type: string; runId: string; jobId?: string; stepId?: string; payload?: unknown; timestamp?: string } }
|
|
192
|
+
const ev = wrapper.data
|
|
193
|
+
if (ev.runId !== runId) {continue}
|
|
194
|
+
sendLog(ev)
|
|
195
|
+
if (TERMINAL_EVENT_TYPES.includes(ev.type)) {logsAlreadyFinished = true}
|
|
196
|
+
} catch { /* skip */ }
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
} catch { /* cache unavailable */ }
|
|
200
|
+
|
|
201
|
+
if (logsAlreadyFinished) {
|
|
202
|
+
raw.write(`event: workflow.done\ndata: {}\n\n`)
|
|
203
|
+
raw.end()
|
|
204
|
+
return
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
let idleTimer: ReturnType<typeof setTimeout> | null = null
|
|
208
|
+
|
|
209
|
+
const resetIdle = () => {
|
|
210
|
+
if (idleTimer) {clearTimeout(idleTimer)}
|
|
211
|
+
idleTimer = setTimeout(() => {
|
|
212
|
+
cleanup()
|
|
213
|
+
}, idleTimeout)
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
const keepAliveTimer = setInterval(() => {
|
|
217
|
+
if (raw.writableEnded) {return}
|
|
218
|
+
raw.write(': keep-alive\n\n')
|
|
219
|
+
}, KEEP_ALIVE_MS)
|
|
220
|
+
|
|
221
|
+
const unsubscribe = platform.eventBus.subscribe(WORKFLOW_REDIS_CHANNEL, async (rawEvent: unknown) => {
|
|
222
|
+
const event = rawEvent as { type: string; runId: string; jobId?: string; stepId?: string; payload?: unknown; timestamp?: string }
|
|
223
|
+
if (event.runId !== runId) {return}
|
|
224
|
+
sendLog(event)
|
|
225
|
+
resetIdle()
|
|
226
|
+
if (TERMINAL_EVENT_TYPES.includes(event.type)) {
|
|
227
|
+
cleanup()
|
|
228
|
+
}
|
|
229
|
+
})
|
|
230
|
+
|
|
231
|
+
const cleanup = () => {
|
|
232
|
+
unsubscribe()
|
|
233
|
+
if (idleTimer) {clearTimeout(idleTimer)}
|
|
234
|
+
clearInterval(keepAliveTimer)
|
|
235
|
+
if (!raw.writableEnded) {
|
|
236
|
+
raw.write(`event: workflow.done\ndata: {}\n\n`)
|
|
237
|
+
raw.end()
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
resetIdle()
|
|
242
|
+
request.raw.on('close', cleanup)
|
|
243
|
+
},
|
|
244
|
+
})
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
function getRunId(params: unknown): string {
|
|
248
|
+
const runId = (params as { runId?: unknown } | undefined)?.runId
|
|
249
|
+
if (!runId || typeof runId !== 'string') {
|
|
250
|
+
const error = new Error('runId must be provided')
|
|
251
|
+
;(error as any).statusCode = 400
|
|
252
|
+
;(error as any).code = 'WF_RUN_ID_REQUIRED'
|
|
253
|
+
throw error
|
|
254
|
+
}
|
|
255
|
+
return runId
|
|
256
|
+
}
|
package/src/server.ts
ADDED
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module @kb-labs/rest-api-app/server
|
|
3
|
+
* Fastify server setup
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import Fastify from 'fastify';
|
|
7
|
+
import type { FastifyInstance } from 'fastify';
|
|
8
|
+
import type { RestApiConfig } from '@kb-labs/rest-api-core';
|
|
9
|
+
import type { IEntityRegistry } from '@kb-labs/core-registry';
|
|
10
|
+
import { registerRoutes } from './routes/index';
|
|
11
|
+
import { registerPlugins } from './plugins/index';
|
|
12
|
+
import { registerMiddleware } from './middleware/index';
|
|
13
|
+
import { platform } from '@kb-labs/core-runtime';
|
|
14
|
+
import { randomUUID } from 'node:crypto';
|
|
15
|
+
import { readFileSync } from 'node:fs';
|
|
16
|
+
import { existsSync } from 'node:fs';
|
|
17
|
+
import type { ILogger } from '@kb-labs/core-platform';
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Fastify internal symbol to disable request logging
|
|
21
|
+
*/
|
|
22
|
+
const kDisableRequestLogging = Symbol.for('fastify.disableRequestLogging');
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Create a Pino-compatible wrapper for ILogger
|
|
26
|
+
* Fastify 5 expects a Pino instance, but we want vendor independence
|
|
27
|
+
*/
|
|
28
|
+
function createPinoCompatibleLogger(logger: ILogger): any {
|
|
29
|
+
const levels = {
|
|
30
|
+
trace: 10,
|
|
31
|
+
debug: 20,
|
|
32
|
+
info: 30,
|
|
33
|
+
warn: 40,
|
|
34
|
+
error: 50,
|
|
35
|
+
fatal: 60,
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
return {
|
|
39
|
+
// Pino log levels
|
|
40
|
+
trace: (msg: string | object, ...args: any[]) => {
|
|
41
|
+
if (typeof msg === 'object') {
|
|
42
|
+
logger.debug(JSON.stringify(msg), msg as Record<string, unknown>);
|
|
43
|
+
} else {
|
|
44
|
+
logger.debug(msg, ...args);
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
debug: (msg: string | object, ...args: any[]) => {
|
|
48
|
+
if (typeof msg === 'object') {
|
|
49
|
+
logger.debug(JSON.stringify(msg), msg as Record<string, unknown>);
|
|
50
|
+
} else {
|
|
51
|
+
logger.debug(msg, ...args);
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
info: (msg: string | object, ...args: any[]) => {
|
|
55
|
+
if (typeof msg === 'object') {
|
|
56
|
+
logger.info(JSON.stringify(msg), msg as Record<string, unknown>);
|
|
57
|
+
} else {
|
|
58
|
+
logger.info(msg, ...args);
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
warn: (msg: string | object, ...args: any[]) => {
|
|
62
|
+
if (typeof msg === 'object') {
|
|
63
|
+
logger.warn(JSON.stringify(msg), msg as Record<string, unknown>);
|
|
64
|
+
} else {
|
|
65
|
+
logger.warn(msg, ...args);
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
error: (msg: string | object, ...args: any[]) => {
|
|
69
|
+
if (typeof msg === 'object') {
|
|
70
|
+
logger.error(JSON.stringify(msg), msg instanceof Error ? msg : undefined);
|
|
71
|
+
} else {
|
|
72
|
+
logger.error(msg, args[0] instanceof Error ? args[0] : undefined);
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
fatal: (msg: string | object, ...args: any[]) => {
|
|
76
|
+
if (typeof msg === 'object') {
|
|
77
|
+
logger.error(`[FATAL] ${JSON.stringify(msg)}`, msg instanceof Error ? msg : undefined);
|
|
78
|
+
} else {
|
|
79
|
+
logger.error(`[FATAL] ${msg}`, args[0] instanceof Error ? args[0] : undefined);
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
// Pino child method
|
|
83
|
+
child: (bindings: Record<string, unknown>) => {
|
|
84
|
+
const childLogger = logger.child(bindings);
|
|
85
|
+
return createPinoCompatibleLogger(childLogger);
|
|
86
|
+
},
|
|
87
|
+
// Pino required properties for Fastify 5
|
|
88
|
+
level: 'info',
|
|
89
|
+
levels: {
|
|
90
|
+
values: levels,
|
|
91
|
+
labels: { 10: 'trace', 20: 'debug', 30: 'info', 40: 'warn', 50: 'error', 60: 'fatal' },
|
|
92
|
+
},
|
|
93
|
+
silent: false,
|
|
94
|
+
// Pino version symbol (required by Fastify 5 validation)
|
|
95
|
+
[Symbol.for('pino.version')]: '8.0.0',
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Create and configure Fastify server
|
|
101
|
+
*/
|
|
102
|
+
export async function createServer(
|
|
103
|
+
config: RestApiConfig,
|
|
104
|
+
repoRoot: string,
|
|
105
|
+
registry: IEntityRegistry
|
|
106
|
+
): Promise<FastifyInstance> {
|
|
107
|
+
// HTTP/2 configuration (requires HTTPS)
|
|
108
|
+
const useHttp2 = config.http2?.enabled ?? false;
|
|
109
|
+
const allowHTTP1 = config.http2?.allowHTTP1 ?? true;
|
|
110
|
+
|
|
111
|
+
// SSL configuration
|
|
112
|
+
let httpsOptions: { allowHTTP1: boolean; key: Buffer; cert: Buffer } | undefined;
|
|
113
|
+
if (useHttp2 && config.ssl?.keyPath && config.ssl?.certPath) {
|
|
114
|
+
const keyPath = config.ssl.keyPath;
|
|
115
|
+
const certPath = config.ssl.certPath;
|
|
116
|
+
|
|
117
|
+
if (existsSync(keyPath) && existsSync(certPath)) {
|
|
118
|
+
httpsOptions = {
|
|
119
|
+
allowHTTP1,
|
|
120
|
+
key: readFileSync(keyPath),
|
|
121
|
+
cert: readFileSync(certPath),
|
|
122
|
+
};
|
|
123
|
+
} else {
|
|
124
|
+
platform.logger.warn('HTTP/2 enabled but SSL certificates not found, falling back to HTTP/1.1', {
|
|
125
|
+
keyPath,
|
|
126
|
+
certPath,
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// Create platform logger child for REST layer
|
|
132
|
+
const restLogger = platform.logger.child({
|
|
133
|
+
layer: 'rest',
|
|
134
|
+
service: 'server',
|
|
135
|
+
traceId: randomUUID(),
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
// Fastify 5 is too strict with logger validation, so disable it and use hooks
|
|
139
|
+
const server = useHttp2 && httpsOptions
|
|
140
|
+
? Fastify({
|
|
141
|
+
logger: false,
|
|
142
|
+
requestIdHeader: 'X-Request-Id',
|
|
143
|
+
requestIdLogLabel: 'requestId',
|
|
144
|
+
disableRequestLogging: true,
|
|
145
|
+
requestTimeout: config.timeouts?.requestTimeout || 30000,
|
|
146
|
+
bodyLimit: config.timeouts?.bodyLimit || 10485760,
|
|
147
|
+
http2: true,
|
|
148
|
+
https: httpsOptions,
|
|
149
|
+
})
|
|
150
|
+
: Fastify({
|
|
151
|
+
logger: false,
|
|
152
|
+
requestIdHeader: 'X-Request-Id',
|
|
153
|
+
requestIdLogLabel: 'requestId',
|
|
154
|
+
disableRequestLogging: true,
|
|
155
|
+
requestTimeout: config.timeouts?.requestTimeout || 30000,
|
|
156
|
+
bodyLimit: config.timeouts?.bodyLimit || 10485760,
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
// Add our own logger to server instance
|
|
160
|
+
(server as any).log = restLogger;
|
|
161
|
+
|
|
162
|
+
// Override child logger factory to return our custom logger with disable flag
|
|
163
|
+
server.setChildLoggerFactory((logger, bindings, opts, rawReq) => {
|
|
164
|
+
const customLogger = {
|
|
165
|
+
[kDisableRequestLogging]: true, // Disable Fastify's built-in request logging
|
|
166
|
+
debug: (obj: any, msg?: string) => {},
|
|
167
|
+
info: (obj: any, msg?: string) => {},
|
|
168
|
+
warn: (obj: any, msg?: string) => {},
|
|
169
|
+
error: (obj: any, msg?: string) => {},
|
|
170
|
+
fatal: (obj: any, msg?: string) => {},
|
|
171
|
+
trace: (obj: any, msg?: string) => {},
|
|
172
|
+
child: () => customLogger,
|
|
173
|
+
level: 'silent',
|
|
174
|
+
};
|
|
175
|
+
return customLogger as any;
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
// Log protocol being used
|
|
179
|
+
if (useHttp2 && httpsOptions) {
|
|
180
|
+
restLogger.info('HTTP/2 enabled with HTTPS', {
|
|
181
|
+
allowHTTP1Fallback: allowHTTP1,
|
|
182
|
+
});
|
|
183
|
+
} else if (useHttp2) {
|
|
184
|
+
restLogger.warn('HTTP/2 requested but SSL certificates missing, using HTTP/1.1');
|
|
185
|
+
} else {
|
|
186
|
+
restLogger.info('Using HTTP/1.1');
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
// Store registry in server instance
|
|
190
|
+
server.registry = registry;
|
|
191
|
+
|
|
192
|
+
// Register plugins
|
|
193
|
+
await registerPlugins(server as unknown as FastifyInstance, config);
|
|
194
|
+
|
|
195
|
+
// Register middleware
|
|
196
|
+
registerMiddleware(server as unknown as FastifyInstance, config);
|
|
197
|
+
|
|
198
|
+
// Register routes
|
|
199
|
+
await registerRoutes(server as unknown as FastifyInstance, config, repoRoot, registry);
|
|
200
|
+
|
|
201
|
+
return server as unknown as FastifyInstance;
|
|
202
|
+
}
|
|
203
|
+
|