@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,204 +0,0 @@
|
|
|
1
|
-
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
|
2
|
-
import Fastify from 'fastify'
|
|
3
|
-
import type { RestApiConfig } from '@kb-labs/rest-api-core'
|
|
4
|
-
import { registerWorkflowRoutes } from '../workflows'
|
|
5
|
-
|
|
6
|
-
const BASE_CONFIG: RestApiConfig = {
|
|
7
|
-
port: 3000,
|
|
8
|
-
basePath: '/api/v1',
|
|
9
|
-
apiVersion: 'test',
|
|
10
|
-
cors: {
|
|
11
|
-
origins: [],
|
|
12
|
-
allowCredentials: true,
|
|
13
|
-
profile: 'dev',
|
|
14
|
-
},
|
|
15
|
-
plugins: [],
|
|
16
|
-
mockMode: false,
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
type EventHandler = (event: unknown) => Promise<void>
|
|
20
|
-
let capturedHandlers: EventHandler[] = []
|
|
21
|
-
|
|
22
|
-
const { mockUnsubscribe, mockSubscribe } = vi.hoisted(() => {
|
|
23
|
-
const mockUnsubscribe = vi.fn()
|
|
24
|
-
const mockSubscribe = vi.fn((_channel: string, handler: EventHandler) => {
|
|
25
|
-
capturedHandlers.push(handler)
|
|
26
|
-
// Immediately emit a terminal event to close the SSE stream,
|
|
27
|
-
// so app.inject() resolves instead of hanging.
|
|
28
|
-
setTimeout(() => {
|
|
29
|
-
handler({ type: 'run.finished', runId: 'run-123', payload: { status: 'success' } })
|
|
30
|
-
}, 10)
|
|
31
|
-
return mockUnsubscribe
|
|
32
|
-
})
|
|
33
|
-
return { mockUnsubscribe, mockSubscribe }
|
|
34
|
-
})
|
|
35
|
-
|
|
36
|
-
vi.mock('@kb-labs/core-runtime', () => ({
|
|
37
|
-
platform: {
|
|
38
|
-
eventBus: {
|
|
39
|
-
subscribe: mockSubscribe,
|
|
40
|
-
},
|
|
41
|
-
},
|
|
42
|
-
}))
|
|
43
|
-
|
|
44
|
-
vi.mock('@kb-labs/workflow-constants', () => ({
|
|
45
|
-
WORKFLOW_REDIS_CHANNEL: 'kb:wf:events',
|
|
46
|
-
}))
|
|
47
|
-
|
|
48
|
-
describe('registerWorkflowRoutes', () => {
|
|
49
|
-
let app: ReturnType<typeof Fastify>
|
|
50
|
-
|
|
51
|
-
beforeEach(async () => {
|
|
52
|
-
vi.clearAllMocks()
|
|
53
|
-
capturedHandlers = []
|
|
54
|
-
app = Fastify({ logger: false })
|
|
55
|
-
await registerWorkflowRoutes(app, BASE_CONFIG)
|
|
56
|
-
})
|
|
57
|
-
|
|
58
|
-
afterEach(async () => {
|
|
59
|
-
await app.close()
|
|
60
|
-
})
|
|
61
|
-
|
|
62
|
-
describe('GET /workflows/runs/:runId/events (SSE)', () => {
|
|
63
|
-
it('returns SSE headers and connected comment', async () => {
|
|
64
|
-
const response = await app.inject({
|
|
65
|
-
method: 'GET',
|
|
66
|
-
url: '/api/v1/workflows/runs/run-123/events',
|
|
67
|
-
})
|
|
68
|
-
|
|
69
|
-
expect(response.headers['content-type']).toBe('text/event-stream')
|
|
70
|
-
expect(response.headers['cache-control']).toBe('no-cache, no-transform')
|
|
71
|
-
expect(response.headers['connection']).toBe('keep-alive')
|
|
72
|
-
expect(response.body).toContain(': connected')
|
|
73
|
-
})
|
|
74
|
-
|
|
75
|
-
it('emits workflow.event for matching runId', async () => {
|
|
76
|
-
const response = await app.inject({
|
|
77
|
-
method: 'GET',
|
|
78
|
-
url: '/api/v1/workflows/runs/run-123/events',
|
|
79
|
-
})
|
|
80
|
-
|
|
81
|
-
expect(response.body).toContain('event: workflow.event')
|
|
82
|
-
expect(response.body).toContain('"type":"run.finished"')
|
|
83
|
-
expect(response.body).toContain('"runId":"run-123"')
|
|
84
|
-
})
|
|
85
|
-
|
|
86
|
-
it('sets CORS headers for localhost:3000', async () => {
|
|
87
|
-
const response = await app.inject({
|
|
88
|
-
method: 'GET',
|
|
89
|
-
url: '/api/v1/workflows/runs/run-123/events',
|
|
90
|
-
headers: { origin: 'http://localhost:3000' },
|
|
91
|
-
})
|
|
92
|
-
|
|
93
|
-
expect(response.headers['access-control-allow-origin']).toBe('http://localhost:3000')
|
|
94
|
-
expect(response.headers['access-control-allow-credentials']).toBe('true')
|
|
95
|
-
})
|
|
96
|
-
|
|
97
|
-
it('sets CORS headers for localhost:5173', async () => {
|
|
98
|
-
const response = await app.inject({
|
|
99
|
-
method: 'GET',
|
|
100
|
-
url: '/api/v1/workflows/runs/run-123/events',
|
|
101
|
-
headers: { origin: 'http://localhost:5173' },
|
|
102
|
-
})
|
|
103
|
-
|
|
104
|
-
expect(response.headers['access-control-allow-origin']).toBe('http://localhost:5173')
|
|
105
|
-
})
|
|
106
|
-
|
|
107
|
-
it('does not set CORS headers for other origins', async () => {
|
|
108
|
-
const response = await app.inject({
|
|
109
|
-
method: 'GET',
|
|
110
|
-
url: '/api/v1/workflows/runs/run-123/events',
|
|
111
|
-
headers: { origin: 'http://evil.com' },
|
|
112
|
-
})
|
|
113
|
-
|
|
114
|
-
expect(response.headers['access-control-allow-origin']).toBeUndefined()
|
|
115
|
-
})
|
|
116
|
-
|
|
117
|
-
it('calls unsubscribe on terminal event', async () => {
|
|
118
|
-
await app.inject({
|
|
119
|
-
method: 'GET',
|
|
120
|
-
url: '/api/v1/workflows/runs/run-123/events',
|
|
121
|
-
})
|
|
122
|
-
|
|
123
|
-
expect(mockUnsubscribe).toHaveBeenCalled()
|
|
124
|
-
})
|
|
125
|
-
|
|
126
|
-
it('filters events by runId — ignores other runs', async () => {
|
|
127
|
-
// Override the mock to emit an event for a different runId first
|
|
128
|
-
mockSubscribe.mockImplementationOnce((_channel, handler: EventHandler) => {
|
|
129
|
-
setTimeout(async () => {
|
|
130
|
-
// Event for a different run — should be ignored
|
|
131
|
-
await handler({ type: 'step.started', runId: 'other-run', payload: {} })
|
|
132
|
-
// Terminal event for our run — closes the stream
|
|
133
|
-
await handler({ type: 'run.finished', runId: 'run-123', payload: {} })
|
|
134
|
-
}, 10)
|
|
135
|
-
return mockUnsubscribe
|
|
136
|
-
})
|
|
137
|
-
|
|
138
|
-
const response = await app.inject({
|
|
139
|
-
method: 'GET',
|
|
140
|
-
url: '/api/v1/workflows/runs/run-123/events',
|
|
141
|
-
})
|
|
142
|
-
|
|
143
|
-
// Should NOT contain the other-run event
|
|
144
|
-
expect(response.body).not.toContain('other-run')
|
|
145
|
-
expect(response.body).toContain('"runId":"run-123"')
|
|
146
|
-
})
|
|
147
|
-
})
|
|
148
|
-
|
|
149
|
-
describe('GET /workflows/runs/:runId/logs (SSE)', () => {
|
|
150
|
-
it('returns SSE headers and connected comment', async () => {
|
|
151
|
-
const response = await app.inject({
|
|
152
|
-
method: 'GET',
|
|
153
|
-
url: '/api/v1/workflows/runs/run-123/logs?follow=1',
|
|
154
|
-
})
|
|
155
|
-
|
|
156
|
-
expect(response.headers['content-type']).toBe('text/event-stream')
|
|
157
|
-
expect(response.headers['cache-control']).toBe('no-cache, no-transform')
|
|
158
|
-
expect(response.headers['connection']).toBe('keep-alive')
|
|
159
|
-
expect(response.body).toContain(': connected')
|
|
160
|
-
})
|
|
161
|
-
|
|
162
|
-
it('emits workflow.log events', async () => {
|
|
163
|
-
const response = await app.inject({
|
|
164
|
-
method: 'GET',
|
|
165
|
-
url: '/api/v1/workflows/runs/run-123/logs',
|
|
166
|
-
})
|
|
167
|
-
|
|
168
|
-
expect(response.body).toContain('event: workflow.log')
|
|
169
|
-
expect(response.body).toContain('"type":"run.finished"')
|
|
170
|
-
expect(response.body).toContain('"runId":"run-123"')
|
|
171
|
-
})
|
|
172
|
-
|
|
173
|
-
it('sets CORS headers for localhost:3000', async () => {
|
|
174
|
-
const response = await app.inject({
|
|
175
|
-
method: 'GET',
|
|
176
|
-
url: '/api/v1/workflows/runs/run-123/logs',
|
|
177
|
-
headers: { origin: 'http://localhost:3000' },
|
|
178
|
-
})
|
|
179
|
-
|
|
180
|
-
expect(response.headers['access-control-allow-origin']).toBe('http://localhost:3000')
|
|
181
|
-
expect(response.headers['access-control-allow-credentials']).toBe('true')
|
|
182
|
-
})
|
|
183
|
-
|
|
184
|
-
it('does not set CORS headers for unknown origins', async () => {
|
|
185
|
-
const response = await app.inject({
|
|
186
|
-
method: 'GET',
|
|
187
|
-
url: '/api/v1/workflows/runs/run-123/logs',
|
|
188
|
-
headers: { origin: 'http://attacker.com' },
|
|
189
|
-
})
|
|
190
|
-
|
|
191
|
-
expect(response.headers['access-control-allow-origin']).toBeUndefined()
|
|
192
|
-
})
|
|
193
|
-
|
|
194
|
-
it('respects custom idleTimeoutMs query param', async () => {
|
|
195
|
-
// Just verify the route accepts the param without error
|
|
196
|
-
const response = await app.inject({
|
|
197
|
-
method: 'GET',
|
|
198
|
-
url: '/api/v1/workflows/runs/run-123/logs?idleTimeoutMs=5000',
|
|
199
|
-
})
|
|
200
|
-
|
|
201
|
-
expect(response.headers['content-type']).toBe('text/event-stream')
|
|
202
|
-
})
|
|
203
|
-
})
|
|
204
|
-
})
|
|
@@ -1,220 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Internal adapter-call endpoint — reverse proxy for Workspace Agent.
|
|
3
|
-
*
|
|
4
|
-
* Receives adapter:call from Gateway (forwarded from Host via WS),
|
|
5
|
-
* executes against platform services, returns result.
|
|
6
|
-
*
|
|
7
|
-
* Flow: Host → WS adapter:call → Gateway → HTTP POST here → platform.adapter.method()
|
|
8
|
-
*
|
|
9
|
-
* Security:
|
|
10
|
-
* - Auth: x-internal-secret (server-to-server, same as /internal/dispatch)
|
|
11
|
-
* - Adapter allowlist enforced (AdapterNameSchema)
|
|
12
|
-
* - Method allowlist per adapter (AdapterRegistry)
|
|
13
|
-
* - Zod validation on input/output
|
|
14
|
-
* - Audit logging on every call
|
|
15
|
-
*
|
|
16
|
-
* @see ADR-0051: Bidirectional Gateway Protocol
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
import type { FastifyInstance, FastifyRequest, FastifyReply } from 'fastify';
|
|
20
|
-
import { z } from 'zod';
|
|
21
|
-
import { platform } from '@kb-labs/core-runtime';
|
|
22
|
-
import { AdapterNameSchema, type AdapterName } from '@kb-labs/gateway-contracts';
|
|
23
|
-
import { restDomainOperationMetrics } from '../middleware/metrics.js';
|
|
24
|
-
|
|
25
|
-
// ── Adapter Registry ──
|
|
26
|
-
|
|
27
|
-
interface AdapterMethodEntry {
|
|
28
|
-
inputSchema: z.ZodType;
|
|
29
|
-
outputSchema: z.ZodType;
|
|
30
|
-
execute: (args: unknown[], context: AdapterCallContext) => Promise<unknown>;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
interface AdapterCallContext {
|
|
34
|
-
namespaceId: string;
|
|
35
|
-
hostId: string;
|
|
36
|
-
workspaceId?: string;
|
|
37
|
-
environmentId?: string;
|
|
38
|
-
executionRequestId?: string;
|
|
39
|
-
userId?: string;
|
|
40
|
-
sessionId?: string;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
class AdapterRegistry {
|
|
44
|
-
private methods = new Map<string, AdapterMethodEntry>();
|
|
45
|
-
|
|
46
|
-
register(
|
|
47
|
-
adapter: AdapterName,
|
|
48
|
-
method: string,
|
|
49
|
-
entry: AdapterMethodEntry,
|
|
50
|
-
): void {
|
|
51
|
-
this.methods.set(`${adapter}.${method}`, entry);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
get(adapter: string, method: string): AdapterMethodEntry | undefined {
|
|
55
|
-
return this.methods.get(`${adapter}.${method}`);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
has(adapter: string, method: string): boolean {
|
|
59
|
-
return this.methods.has(`${adapter}.${method}`);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
// ── Request schema ──
|
|
64
|
-
|
|
65
|
-
const AdapterCallRequestSchema = z.object({
|
|
66
|
-
requestId: z.string(),
|
|
67
|
-
adapter: AdapterNameSchema,
|
|
68
|
-
method: z.string(),
|
|
69
|
-
args: z.array(z.unknown()),
|
|
70
|
-
context: z.object({
|
|
71
|
-
namespaceId: z.string(),
|
|
72
|
-
hostId: z.string(),
|
|
73
|
-
workspaceId: z.string().optional(),
|
|
74
|
-
environmentId: z.string().optional(),
|
|
75
|
-
executionRequestId: z.string().optional(),
|
|
76
|
-
userId: z.string().optional(),
|
|
77
|
-
sessionId: z.string().optional(),
|
|
78
|
-
}),
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
// ── Registry initialization ──
|
|
82
|
-
|
|
83
|
-
function createAdapterRegistry(): AdapterRegistry {
|
|
84
|
-
const registry = new AdapterRegistry();
|
|
85
|
-
|
|
86
|
-
// LLM
|
|
87
|
-
registry.register('llm', 'complete', {
|
|
88
|
-
inputSchema: z.array(z.unknown()),
|
|
89
|
-
outputSchema: z.unknown(),
|
|
90
|
-
execute: async (args) => {
|
|
91
|
-
const llm = platform.getAdapter<any>('llm');
|
|
92
|
-
if (!llm) { throw new Error('LLM adapter not available'); }
|
|
93
|
-
return llm.complete(...args);
|
|
94
|
-
},
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
// Cache
|
|
98
|
-
registry.register('cache', 'get', {
|
|
99
|
-
inputSchema: z.array(z.unknown()),
|
|
100
|
-
outputSchema: z.unknown().nullable(),
|
|
101
|
-
execute: async (args) => platform.cache.get(args[0] as string),
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
registry.register('cache', 'set', {
|
|
105
|
-
inputSchema: z.array(z.unknown()),
|
|
106
|
-
outputSchema: z.void(),
|
|
107
|
-
execute: async (args) => platform.cache.set(args[0] as string, args[1], args[2] as number | undefined),
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
registry.register('cache', 'delete', {
|
|
111
|
-
inputSchema: z.array(z.unknown()),
|
|
112
|
-
outputSchema: z.void(),
|
|
113
|
-
execute: async (args) => platform.cache.delete(args[0] as string),
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
// VectorStore
|
|
117
|
-
registry.register('vectorStore', 'search', {
|
|
118
|
-
inputSchema: z.array(z.unknown()),
|
|
119
|
-
outputSchema: z.unknown(),
|
|
120
|
-
execute: async (args) => {
|
|
121
|
-
const vs = platform.getAdapter<any>('vectorStore');
|
|
122
|
-
if (!vs) { throw new Error('VectorStore adapter not available'); }
|
|
123
|
-
return vs.search(...args);
|
|
124
|
-
},
|
|
125
|
-
});
|
|
126
|
-
|
|
127
|
-
// Embeddings
|
|
128
|
-
registry.register('embeddings', 'embed', {
|
|
129
|
-
inputSchema: z.array(z.unknown()),
|
|
130
|
-
outputSchema: z.unknown(),
|
|
131
|
-
execute: async (args) => {
|
|
132
|
-
const emb = platform.getAdapter<any>('embeddings');
|
|
133
|
-
if (!emb) { throw new Error('Embeddings adapter not available'); }
|
|
134
|
-
return emb.embed(...args);
|
|
135
|
-
},
|
|
136
|
-
});
|
|
137
|
-
|
|
138
|
-
// Storage
|
|
139
|
-
registry.register('storage', 'read', {
|
|
140
|
-
inputSchema: z.array(z.unknown()),
|
|
141
|
-
outputSchema: z.unknown(),
|
|
142
|
-
execute: async (args) => {
|
|
143
|
-
const storage = platform.getAdapter<any>('storage');
|
|
144
|
-
if (!storage) { throw new Error('Storage adapter not available'); }
|
|
145
|
-
return storage.read(...args);
|
|
146
|
-
},
|
|
147
|
-
});
|
|
148
|
-
|
|
149
|
-
registry.register('storage', 'write', {
|
|
150
|
-
inputSchema: z.array(z.unknown()),
|
|
151
|
-
outputSchema: z.void(),
|
|
152
|
-
execute: async (args) => {
|
|
153
|
-
const storage = platform.getAdapter<any>('storage');
|
|
154
|
-
if (!storage) { throw new Error('Storage adapter not available'); }
|
|
155
|
-
return storage.write(...args);
|
|
156
|
-
},
|
|
157
|
-
});
|
|
158
|
-
|
|
159
|
-
return registry;
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
// ── Route registration ──
|
|
163
|
-
|
|
164
|
-
export async function registerAdapterCallRoutes(
|
|
165
|
-
server: FastifyInstance,
|
|
166
|
-
): Promise<void> {
|
|
167
|
-
const registry = createAdapterRegistry();
|
|
168
|
-
const internalSecret = process.env.GATEWAY_INTERNAL_SECRET;
|
|
169
|
-
const logger = platform.logger.child({ layer: 'rest', route: 'adapter-call' });
|
|
170
|
-
|
|
171
|
-
server.post('/api/v1/internal/adapter-call', async (
|
|
172
|
-
request: FastifyRequest,
|
|
173
|
-
reply: FastifyReply,
|
|
174
|
-
) => {
|
|
175
|
-
// 1. Auth: x-internal-secret
|
|
176
|
-
const provided = request.headers['x-internal-secret'] as string | undefined;
|
|
177
|
-
if (!internalSecret || provided !== internalSecret) {
|
|
178
|
-
return reply.code(403).send({ ok: false, error: { code: 'FORBIDDEN', message: 'Invalid internal secret', retryable: false } });
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
// 2. Parse & validate request
|
|
182
|
-
const parsed = AdapterCallRequestSchema.safeParse(request.body);
|
|
183
|
-
if (!parsed.success) {
|
|
184
|
-
return reply.code(400).send({ ok: false, error: { code: 'VALIDATION_ERROR', message: parsed.error.message, retryable: false } });
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
const { requestId, adapter, method, args, context } = parsed.data;
|
|
188
|
-
const startMs = Date.now();
|
|
189
|
-
|
|
190
|
-
// 3. Check registry
|
|
191
|
-
const entry = registry.get(adapter as string, method);
|
|
192
|
-
if (!entry) {
|
|
193
|
-
logger.warn('Adapter call rejected', { requestId, adapter, method, hostId: context.hostId });
|
|
194
|
-
return reply.code(403).send({ ok: false, error: { code: 'ADAPTER_CALL_REJECTED', message: `Method not allowed: ${adapter}.${method}`, retryable: false } });
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
// 4. Execute
|
|
198
|
-
try {
|
|
199
|
-
const operation = `adapter.call.${adapter}.${method}`;
|
|
200
|
-
const result = await restDomainOperationMetrics.observeOperation(operation, async () =>
|
|
201
|
-
entry.execute(args, context),
|
|
202
|
-
);
|
|
203
|
-
const latencyMs = Date.now() - startMs;
|
|
204
|
-
|
|
205
|
-
logger.info('Adapter call success', { requestId, adapter, method, hostId: context.hostId, latencyMs });
|
|
206
|
-
|
|
207
|
-
return { ok: true, result };
|
|
208
|
-
} catch (err) {
|
|
209
|
-
const latencyMs = Date.now() - startMs;
|
|
210
|
-
const message = err instanceof Error ? err.message : String(err);
|
|
211
|
-
|
|
212
|
-
logger.error('Adapter call failed', err instanceof Error ? err : undefined, { requestId, adapter, method, hostId: context.hostId, latencyMs });
|
|
213
|
-
|
|
214
|
-
return reply.code(500).send({
|
|
215
|
-
ok: false,
|
|
216
|
-
error: { code: 'ADAPTER_ERROR', message, retryable: false },
|
|
217
|
-
});
|
|
218
|
-
}
|
|
219
|
-
});
|
|
220
|
-
}
|