clinkx 0.2.3 → 1.0.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/CHANGELOG.md +33 -0
- package/LICENSE +10 -0
- package/README.md +113 -18
- package/clinkx-workflows/dist/allowed-roots.d.ts +1 -0
- package/clinkx-workflows/dist/allowed-roots.js +5 -0
- package/clinkx-workflows/dist/allowed-roots.js.map +1 -0
- package/clinkx-workflows/dist/artifacts.d.ts +20 -1
- package/clinkx-workflows/dist/artifacts.js +38 -9
- package/clinkx-workflows/dist/artifacts.js.map +1 -1
- package/clinkx-workflows/dist/backend.d.ts +4 -0
- package/clinkx-workflows/dist/citation-check.d.ts +40 -0
- package/clinkx-workflows/dist/citation-check.js +348 -0
- package/clinkx-workflows/dist/citation-check.js.map +1 -0
- package/clinkx-workflows/dist/clink-client.d.ts +2 -1
- package/clinkx-workflows/dist/clink-client.js +17 -4
- package/clinkx-workflows/dist/clink-client.js.map +1 -1
- package/clinkx-workflows/dist/config.d.ts +145 -16
- package/clinkx-workflows/dist/config.js +384 -26
- package/clinkx-workflows/dist/config.js.map +1 -1
- package/clinkx-workflows/dist/contained-file.d.ts +172 -0
- package/clinkx-workflows/dist/contained-file.js +483 -0
- package/clinkx-workflows/dist/contained-file.js.map +1 -0
- package/clinkx-workflows/dist/context-builder-lifecycle-contract.d.ts +416 -0
- package/clinkx-workflows/dist/context-builder-lifecycle-contract.js +328 -0
- package/clinkx-workflows/dist/context-builder-lifecycle-contract.js.map +1 -0
- package/clinkx-workflows/dist/context-builder-lifecycle-router.d.ts +24 -0
- package/clinkx-workflows/dist/context-builder-lifecycle-router.js +39 -0
- package/clinkx-workflows/dist/context-builder-lifecycle-router.js.map +1 -0
- package/clinkx-workflows/dist/context-cache-key.d.ts +53 -0
- package/clinkx-workflows/dist/context-cache-key.js +91 -0
- package/clinkx-workflows/dist/context-cache-key.js.map +1 -0
- package/clinkx-workflows/dist/context-mode-resolver.d.ts +27 -0
- package/clinkx-workflows/dist/context-mode-resolver.js +126 -0
- package/clinkx-workflows/dist/context-mode-resolver.js.map +1 -0
- package/clinkx-workflows/dist/context-preflight.d.ts +184 -0
- package/clinkx-workflows/dist/context-preflight.js +91 -0
- package/clinkx-workflows/dist/context-preflight.js.map +1 -0
- package/clinkx-workflows/dist/council-expander.d.ts +1 -1
- package/clinkx-workflows/dist/council-expander.js +2 -1
- package/clinkx-workflows/dist/council-expander.js.map +1 -1
- package/clinkx-workflows/dist/dashboard/activity-contract.d.ts +165 -0
- package/clinkx-workflows/dist/dashboard/activity-contract.js +105 -0
- package/clinkx-workflows/dist/dashboard/activity-contract.js.map +1 -0
- package/clinkx-workflows/dist/dashboard/activity-lease.d.ts +25 -0
- package/clinkx-workflows/dist/dashboard/activity-lease.js +34 -0
- package/clinkx-workflows/dist/dashboard/activity-lease.js.map +1 -0
- package/clinkx-workflows/dist/dashboard/activity-reader.d.ts +86 -0
- package/clinkx-workflows/dist/dashboard/activity-reader.js +480 -0
- package/clinkx-workflows/dist/dashboard/activity-reader.js.map +1 -0
- package/clinkx-workflows/dist/dashboard/api-routes.d.ts +36 -0
- package/clinkx-workflows/dist/dashboard/api-routes.js +1047 -0
- package/clinkx-workflows/dist/dashboard/api-routes.js.map +1 -0
- package/clinkx-workflows/dist/dashboard/artifact-index.d.ts +37 -0
- package/clinkx-workflows/dist/dashboard/artifact-index.js +145 -0
- package/clinkx-workflows/dist/dashboard/artifact-index.js.map +1 -0
- package/clinkx-workflows/dist/dashboard/auth/challenge-store.d.ts +31 -0
- package/clinkx-workflows/dist/dashboard/auth/challenge-store.js +65 -0
- package/clinkx-workflows/dist/dashboard/auth/challenge-store.js.map +1 -0
- package/clinkx-workflows/dist/dashboard/auth/controller.d.ts +26 -0
- package/clinkx-workflows/dist/dashboard/auth/controller.js +596 -0
- package/clinkx-workflows/dist/dashboard/auth/controller.js.map +1 -0
- package/clinkx-workflows/dist/dashboard/auth/credential-store.d.ts +60 -0
- package/clinkx-workflows/dist/dashboard/auth/credential-store.js +776 -0
- package/clinkx-workflows/dist/dashboard/auth/credential-store.js.map +1 -0
- package/clinkx-workflows/dist/dashboard/auth/enrollment-gate.d.ts +9 -0
- package/clinkx-workflows/dist/dashboard/auth/enrollment-gate.js +44 -0
- package/clinkx-workflows/dist/dashboard/auth/enrollment-gate.js.map +1 -0
- package/clinkx-workflows/dist/dashboard/auth/session-store.d.ts +17 -0
- package/clinkx-workflows/dist/dashboard/auth/session-store.js +77 -0
- package/clinkx-workflows/dist/dashboard/auth/session-store.js.map +1 -0
- package/clinkx-workflows/dist/dashboard/auth/webauthn-service.d.ts +25 -0
- package/clinkx-workflows/dist/dashboard/auth/webauthn-service.js +71 -0
- package/clinkx-workflows/dist/dashboard/auth/webauthn-service.js.map +1 -0
- package/clinkx-workflows/dist/dashboard/context-run-liveness.d.ts +37 -0
- package/clinkx-workflows/dist/dashboard/context-run-liveness.js +49 -0
- package/clinkx-workflows/dist/dashboard/context-run-liveness.js.map +1 -0
- package/clinkx-workflows/dist/dashboard/context-run-reader.d.ts +222 -0
- package/clinkx-workflows/dist/dashboard/context-run-reader.js +1178 -0
- package/clinkx-workflows/dist/dashboard/context-run-reader.js.map +1 -0
- package/clinkx-workflows/dist/dashboard/contracts.d.ts +8936 -0
- package/clinkx-workflows/dist/dashboard/contracts.js +1157 -0
- package/clinkx-workflows/dist/dashboard/contracts.js.map +1 -0
- package/clinkx-workflows/dist/dashboard/generation.d.ts +14 -0
- package/clinkx-workflows/dist/dashboard/generation.js +41 -0
- package/clinkx-workflows/dist/dashboard/generation.js.map +1 -0
- package/clinkx-workflows/dist/dashboard/index.d.ts +28 -0
- package/clinkx-workflows/dist/dashboard/index.js +16 -0
- package/clinkx-workflows/dist/dashboard/index.js.map +1 -0
- package/clinkx-workflows/dist/dashboard/lazy-content.d.ts +101 -0
- package/clinkx-workflows/dist/dashboard/lazy-content.js +748 -0
- package/clinkx-workflows/dist/dashboard/lazy-content.js.map +1 -0
- package/clinkx-workflows/dist/dashboard/progress-report-contract.d.ts +303 -0
- package/clinkx-workflows/dist/dashboard/progress-report-contract.js +221 -0
- package/clinkx-workflows/dist/dashboard/progress-report-contract.js.map +1 -0
- package/clinkx-workflows/dist/dashboard/progress-report-reader.d.ts +50 -0
- package/clinkx-workflows/dist/dashboard/progress-report-reader.js +581 -0
- package/clinkx-workflows/dist/dashboard/progress-report-reader.js.map +1 -0
- package/clinkx-workflows/dist/dashboard/progress-report-status-overlay.d.ts +89 -0
- package/clinkx-workflows/dist/dashboard/progress-report-status-overlay.js +71 -0
- package/clinkx-workflows/dist/dashboard/progress-report-status-overlay.js.map +1 -0
- package/clinkx-workflows/dist/dashboard/progress-report-status-store.d.ts +28 -0
- package/clinkx-workflows/dist/dashboard/progress-report-status-store.js +110 -0
- package/clinkx-workflows/dist/dashboard/progress-report-status-store.js.map +1 -0
- package/clinkx-workflows/dist/dashboard/read-model.d.ts +86 -0
- package/clinkx-workflows/dist/dashboard/read-model.js +440 -0
- package/clinkx-workflows/dist/dashboard/read-model.js.map +1 -0
- package/clinkx-workflows/dist/dashboard/request-admission.d.ts +31 -0
- package/clinkx-workflows/dist/dashboard/request-admission.js +126 -0
- package/clinkx-workflows/dist/dashboard/request-admission.js.map +1 -0
- package/clinkx-workflows/dist/dashboard/scanner.d.ts +75 -0
- package/clinkx-workflows/dist/dashboard/scanner.js +1110 -0
- package/clinkx-workflows/dist/dashboard/scanner.js.map +1 -0
- package/clinkx-workflows/dist/dashboard/server-factory.d.ts +50 -0
- package/clinkx-workflows/dist/dashboard/server-factory.js +431 -0
- package/clinkx-workflows/dist/dashboard/server-factory.js.map +1 -0
- package/clinkx-workflows/dist/dashboard/session-log-contract.d.ts +2611 -0
- package/clinkx-workflows/dist/dashboard/session-log-contract.js +480 -0
- package/clinkx-workflows/dist/dashboard/session-log-contract.js.map +1 -0
- package/clinkx-workflows/dist/dashboard/session-log-identity.d.ts +21 -0
- package/clinkx-workflows/dist/dashboard/session-log-identity.js +101 -0
- package/clinkx-workflows/dist/dashboard/session-log-identity.js.map +1 -0
- package/clinkx-workflows/dist/dashboard/session-log-journal.d.ts +43 -0
- package/clinkx-workflows/dist/dashboard/session-log-journal.js +522 -0
- package/clinkx-workflows/dist/dashboard/session-log-journal.js.map +1 -0
- package/clinkx-workflows/dist/dashboard/session-log-reader.d.ts +61 -0
- package/clinkx-workflows/dist/dashboard/session-log-reader.js +378 -0
- package/clinkx-workflows/dist/dashboard/session-log-reader.js.map +1 -0
- package/clinkx-workflows/dist/dashboard/session-log-redaction.d.ts +6 -0
- package/clinkx-workflows/dist/dashboard/session-log-redaction.js +367 -0
- package/clinkx-workflows/dist/dashboard/session-log-redaction.js.map +1 -0
- package/clinkx-workflows/dist/dashboard/session-log-retention.d.ts +23 -0
- package/clinkx-workflows/dist/dashboard/session-log-retention.js +212 -0
- package/clinkx-workflows/dist/dashboard/session-log-retention.js.map +1 -0
- package/clinkx-workflows/dist/dashboard/static-responses.d.ts +10 -0
- package/clinkx-workflows/dist/dashboard/static-responses.js +94 -0
- package/clinkx-workflows/dist/dashboard/static-responses.js.map +1 -0
- package/clinkx-workflows/dist/dashboard/worker-lock-observer.d.ts +28 -0
- package/clinkx-workflows/dist/dashboard/worker-lock-observer.js +241 -0
- package/clinkx-workflows/dist/dashboard/worker-lock-observer.js.map +1 -0
- package/clinkx-workflows/dist/dashboard-ui/assets/ibm-plex-mono-latin-400-normal-CvHOgSBP.woff +0 -0
- package/clinkx-workflows/dist/dashboard-ui/assets/ibm-plex-mono-latin-400-normal-DMJ8VG8y.woff2 +0 -0
- package/clinkx-workflows/dist/dashboard-ui/assets/ibm-plex-mono-latin-500-normal-CB9ihrfo.woff +0 -0
- package/clinkx-workflows/dist/dashboard-ui/assets/ibm-plex-mono-latin-500-normal-DSY6xOcd.woff2 +0 -0
- package/clinkx-workflows/dist/dashboard-ui/assets/ibm-plex-sans-latin-400-normal-CDDApCn2.woff2 +0 -0
- package/clinkx-workflows/dist/dashboard-ui/assets/ibm-plex-sans-latin-400-normal-CYLoc0-x.woff +0 -0
- package/clinkx-workflows/dist/dashboard-ui/assets/ibm-plex-sans-latin-500-normal-6ng42L7E.woff2 +0 -0
- package/clinkx-workflows/dist/dashboard-ui/assets/ibm-plex-sans-latin-500-normal-BgVn5rGT.woff +0 -0
- package/clinkx-workflows/dist/dashboard-ui/assets/ibm-plex-sans-latin-600-normal-Cu4Hd6ag.woff +0 -0
- package/clinkx-workflows/dist/dashboard-ui/assets/ibm-plex-sans-latin-600-normal-CuJfVYMP.woff2 +0 -0
- package/clinkx-workflows/dist/dashboard-ui/assets/index-DOkMXTfB.js +25 -0
- package/clinkx-workflows/dist/dashboard-ui/assets/jetbrains-mono-latin-400-normal-6-qcROiO.woff +0 -0
- package/clinkx-workflows/dist/dashboard-ui/assets/jetbrains-mono-latin-400-normal-V6pRDFza.woff2 +0 -0
- package/clinkx-workflows/dist/dashboard-ui/assets/jetbrains-mono-latin-500-normal-BWZEU5yA.woff2 +0 -0
- package/clinkx-workflows/dist/dashboard-ui/assets/jetbrains-mono-latin-500-normal-CJOVTJB7.woff +0 -0
- package/clinkx-workflows/dist/dashboard-ui/assets/style-ChJsn0KD.css +1 -0
- package/clinkx-workflows/dist/dashboard-ui/contracts/council-plan-review-input-v1.json +158 -0
- package/clinkx-workflows/dist/dashboard-ui/index.html +15 -0
- package/clinkx-workflows/dist/dashboard-ui/licenses/IBM-Plex-Mono-OFL.txt +93 -0
- package/clinkx-workflows/dist/dashboard-ui/licenses/IBM-Plex-Sans-OFL.txt +93 -0
- package/clinkx-workflows/dist/dashboard-ui/licenses/JetBrains-Mono-OFL.txt +93 -0
- package/clinkx-workflows/dist/dashboard-ui/licenses/NOTICE.md +32 -0
- package/clinkx-workflows/dist/dashboard-ui/theme-init.js +8 -0
- package/clinkx-workflows/dist/definition-normalizer.d.ts +19 -0
- package/clinkx-workflows/dist/definition-normalizer.js.map +1 -1
- package/clinkx-workflows/dist/delegate-validate.d.ts +78 -0
- package/clinkx-workflows/dist/delegate-validate.js +97 -0
- package/clinkx-workflows/dist/delegate-validate.js.map +1 -0
- package/clinkx-workflows/dist/engine.d.ts +141 -0
- package/clinkx-workflows/dist/engine.js +882 -28
- package/clinkx-workflows/dist/engine.js.map +1 -1
- package/clinkx-workflows/dist/errors.d.ts +2 -0
- package/clinkx-workflows/dist/errors.js.map +1 -1
- package/clinkx-workflows/dist/fingerprint.d.ts +1 -1
- package/clinkx-workflows/dist/fingerprint.js +1 -1
- package/clinkx-workflows/dist/index.d.ts +19 -0
- package/clinkx-workflows/dist/index.js +15 -0
- package/clinkx-workflows/dist/index.js.map +1 -1
- package/clinkx-workflows/dist/loader.d.ts +9 -3
- package/clinkx-workflows/dist/loader.js +92 -21
- package/clinkx-workflows/dist/loader.js.map +1 -1
- package/clinkx-workflows/dist/plan-review/admission.d.ts +160 -0
- package/clinkx-workflows/dist/plan-review/admission.js +290 -0
- package/clinkx-workflows/dist/plan-review/admission.js.map +1 -0
- package/clinkx-workflows/dist/plan-review/context-policy.d.ts +55 -0
- package/clinkx-workflows/dist/plan-review/context-policy.js +146 -0
- package/clinkx-workflows/dist/plan-review/context-policy.js.map +1 -0
- package/clinkx-workflows/dist/plan-review/contract.d.ts +763 -0
- package/clinkx-workflows/dist/plan-review/contract.js +289 -0
- package/clinkx-workflows/dist/plan-review/contract.js.map +1 -0
- package/clinkx-workflows/dist/plan-review/digest.d.ts +68 -0
- package/clinkx-workflows/dist/plan-review/digest.js +241 -0
- package/clinkx-workflows/dist/plan-review/digest.js.map +1 -0
- package/clinkx-workflows/dist/plan-review/discovery.d.ts +45 -0
- package/clinkx-workflows/dist/plan-review/discovery.js +36 -0
- package/clinkx-workflows/dist/plan-review/discovery.js.map +1 -0
- package/clinkx-workflows/dist/plan-review/execution-contract.d.ts +298 -0
- package/clinkx-workflows/dist/plan-review/execution-contract.js +194 -0
- package/clinkx-workflows/dist/plan-review/execution-contract.js.map +1 -0
- package/clinkx-workflows/dist/plan-review/expander.d.ts +48 -0
- package/clinkx-workflows/dist/plan-review/expander.js +243 -0
- package/clinkx-workflows/dist/plan-review/expander.js.map +1 -0
- package/clinkx-workflows/dist/plan-review/projector.d.ts +126 -0
- package/clinkx-workflows/dist/plan-review/projector.js +437 -0
- package/clinkx-workflows/dist/plan-review/projector.js.map +1 -0
- package/clinkx-workflows/dist/plan-review/publication.d.ts +95 -0
- package/clinkx-workflows/dist/plan-review/publication.js +182 -0
- package/clinkx-workflows/dist/plan-review/publication.js.map +1 -0
- package/clinkx-workflows/dist/plan-review/ranking-reducer.d.ts +34 -0
- package/clinkx-workflows/dist/plan-review/ranking-reducer.js +139 -0
- package/clinkx-workflows/dist/plan-review/ranking-reducer.js.map +1 -0
- package/clinkx-workflows/dist/plan-review/resume.d.ts +38 -0
- package/clinkx-workflows/dist/plan-review/resume.js +122 -0
- package/clinkx-workflows/dist/plan-review/resume.js.map +1 -0
- package/clinkx-workflows/dist/plan-review/rubric.d.ts +7 -0
- package/clinkx-workflows/dist/plan-review/rubric.js +24 -0
- package/clinkx-workflows/dist/plan-review/rubric.js.map +1 -0
- package/clinkx-workflows/dist/plan-review/run-state.d.ts +398 -0
- package/clinkx-workflows/dist/plan-review/run-state.js +183 -0
- package/clinkx-workflows/dist/plan-review/run-state.js.map +1 -0
- package/clinkx-workflows/dist/plan-review/runtime-policy.d.ts +74 -0
- package/clinkx-workflows/dist/plan-review/runtime-policy.js +186 -0
- package/clinkx-workflows/dist/plan-review/runtime-policy.js.map +1 -0
- package/clinkx-workflows/dist/plan-review/snapshot.d.ts +81 -0
- package/clinkx-workflows/dist/plan-review/snapshot.js +170 -0
- package/clinkx-workflows/dist/plan-review/snapshot.js.map +1 -0
- package/clinkx-workflows/dist/plan-review/stage-error.d.ts +19 -0
- package/clinkx-workflows/dist/plan-review/stage-error.js +20 -0
- package/clinkx-workflows/dist/plan-review/stage-error.js.map +1 -0
- package/clinkx-workflows/dist/post-processors/index.d.ts +20 -0
- package/clinkx-workflows/dist/post-processors/index.js +21 -0
- package/clinkx-workflows/dist/post-processors/index.js.map +1 -0
- package/clinkx-workflows/dist/prompt-budget.d.ts +7 -0
- package/clinkx-workflows/dist/prompt-budget.js +7 -1
- package/clinkx-workflows/dist/prompt-budget.js.map +1 -1
- package/clinkx-workflows/dist/reducers/index.js +2 -0
- package/clinkx-workflows/dist/reducers/index.js.map +1 -1
- package/clinkx-workflows/dist/run-lock-heartbeat.d.ts +2 -0
- package/clinkx-workflows/dist/run-lock-heartbeat.js +3 -0
- package/clinkx-workflows/dist/run-lock-heartbeat.js.map +1 -0
- package/clinkx-workflows/dist/run-summary/cards/council-plan-review.d.ts +34 -0
- package/clinkx-workflows/dist/run-summary/cards/council-plan-review.js +74 -0
- package/clinkx-workflows/dist/run-summary/cards/council-plan-review.js.map +1 -0
- package/clinkx-workflows/dist/run-summary/cards/index.js +5 -0
- package/clinkx-workflows/dist/run-summary/cards/index.js.map +1 -1
- package/clinkx-workflows/dist/run-summary.d.ts +13 -0
- package/clinkx-workflows/dist/run-summary.js +29 -1
- package/clinkx-workflows/dist/run-summary.js.map +1 -1
- package/clinkx-workflows/dist/schema.d.ts +76 -21
- package/clinkx-workflows/dist/schema.js +10 -1
- package/clinkx-workflows/dist/schema.js.map +1 -1
- package/clinkx-workflows/dist/seed-terms.d.ts +30 -0
- package/clinkx-workflows/dist/seed-terms.js +176 -0
- package/clinkx-workflows/dist/seed-terms.js.map +1 -0
- package/clinkx-workflows/dist/server.d.ts +5 -2
- package/clinkx-workflows/dist/server.js +82 -52
- package/clinkx-workflows/dist/server.js.map +1 -1
- package/clinkx-workflows/dist/shutdown.d.ts +18 -20
- package/clinkx-workflows/dist/shutdown.js +43 -61
- package/clinkx-workflows/dist/shutdown.js.map +1 -1
- package/clinkx-workflows/dist/state-schema.d.ts +38 -0
- package/clinkx-workflows/dist/state.d.ts +170 -3
- package/clinkx-workflows/dist/state.js +1275 -28
- package/clinkx-workflows/dist/state.js.map +1 -1
- package/clinkx-workflows/dist/transport.d.ts +15 -0
- package/clinkx-workflows/dist/transport.js +19 -10
- package/clinkx-workflows/dist/transport.js.map +1 -1
- package/clinkx-workflows/dist/types.d.ts +14 -2
- package/clinkx-workflows/dist/validators/council.d.ts +318 -85
- package/clinkx-workflows/dist/validators/council.js +52 -13
- package/clinkx-workflows/dist/validators/council.js.map +1 -1
- package/clinkx-workflows/dist/validators/index.d.ts +1 -0
- package/clinkx-workflows/dist/validators/index.js +3 -0
- package/clinkx-workflows/dist/validators/index.js.map +1 -1
- package/clinkx-workflows/dist/validators/plan-review.d.ts +398 -0
- package/clinkx-workflows/dist/validators/plan-review.js +316 -0
- package/clinkx-workflows/dist/validators/plan-review.js.map +1 -0
- package/clinkx-workflows/dist/workflow-receipt.js +188 -4
- package/clinkx-workflows/dist/workflow-receipt.js.map +1 -1
- package/clinkx-workflows/dist/workflow-tools.d.ts +48 -3
- package/clinkx-workflows/dist/workflow-tools.js +1402 -59
- package/clinkx-workflows/dist/workflow-tools.js.map +1 -1
- package/clinkx-workflows/dist/workspace-signature.d.ts +16 -0
- package/clinkx-workflows/dist/workspace-signature.js +388 -0
- package/clinkx-workflows/dist/workspace-signature.js.map +1 -0
- package/clinkx-workflows/templates/council/answer-specialist.txt +2 -1
- package/clinkx-workflows/templates/council/code-review-chairman.txt +13 -0
- package/clinkx-workflows/templates/council/code-review-cross-reviewer.txt +4 -1
- package/clinkx-workflows/templates/council/code-review-reviewer.txt +19 -3
- package/clinkx-workflows/templates/council/debug-debugger.txt +2 -1
- package/clinkx-workflows/templates/council/discover-analyst.txt +2 -1
- package/clinkx-workflows/templates/council/member.txt +2 -1
- package/clinkx-workflows/templates/council/plan-review-chairman.txt +68 -0
- package/clinkx-workflows/templates/council/plan-review-cross-reviewer.txt +51 -0
- package/clinkx-workflows/templates/council/plan-review-reviewer.txt +60 -0
- package/clinkx-workflows/templates/plan-review/chairman.txt +48 -0
- package/clinkx-workflows/templates/plan-review/cross-review.txt +52 -0
- package/clinkx-workflows/templates/plan-review/ranking.txt +16 -0
- package/clinkx-workflows/templates/plan-review/reviewer.txt +57 -0
- package/clinkx-workflows/workflows/council-answer.yaml +97 -8
- package/clinkx-workflows/workflows/council-code-review.yaml +103 -8
- package/clinkx-workflows/workflows/council-debug.yaml +97 -8
- package/clinkx-workflows/workflows/council-default.yaml +97 -8
- package/clinkx-workflows/workflows/council-discover.yaml +97 -8
- package/clinkx-workflows/workflows/council-plan-review.yaml +250 -0
- package/clinkx-workflows/workflows/plan-review-receipts.yaml +230 -0
- package/conf/adapters/agy.json +49 -0
- package/conf/adapters/claude.json +5 -0
- package/conf/adapters/codex-app-server.json +44 -0
- package/conf/adapters/codex.json +7 -2
- package/conf/adapters/glm.json +5 -0
- package/conf/adapters/grok.json +60 -0
- package/conf/adapters/hapi/agy.json +52 -0
- package/conf/adapters/hapi/claude.json +5 -0
- package/conf/adapters/hapi/codex.json +7 -2
- package/conf/adapters/hapi/glm.json +5 -0
- package/conf/prompts/json-codereviewer.txt +1 -0
- package/conf/prompts/json.txt +1 -0
- package/dist/activity-journal.d.ts +42 -0
- package/dist/activity-journal.js +381 -0
- package/dist/activity-journal.js.map +1 -0
- package/dist/allowed-roots.d.ts +53 -0
- package/dist/allowed-roots.js +216 -0
- package/dist/allowed-roots.js.map +1 -0
- package/dist/codex/activity-session-log.d.ts +14 -0
- package/dist/codex/activity-session-log.js +206 -0
- package/dist/codex/activity-session-log.js.map +1 -0
- package/dist/codex/agent-tools.d.ts +23 -0
- package/dist/codex/agent-tools.js +1270 -0
- package/dist/codex/agent-tools.js.map +1 -0
- package/dist/codex/app-server-client.d.ts +76 -0
- package/dist/codex/app-server-client.js +582 -0
- package/dist/codex/app-server-client.js.map +1 -0
- package/dist/codex/app-server-registry.d.ts +389 -0
- package/dist/codex/app-server-registry.js +1407 -0
- package/dist/codex/app-server-registry.js.map +1 -0
- package/dist/codex/client-types.d.ts +109 -0
- package/dist/codex/client-types.js +2 -0
- package/dist/codex/client-types.js.map +1 -0
- package/dist/codex/protocol.d.ts +5375 -0
- package/dist/codex/protocol.js +614 -0
- package/dist/codex/protocol.js.map +1 -0
- package/dist/codex/session.d.ts +263 -0
- package/dist/codex/session.js +466 -0
- package/dist/codex/session.js.map +1 -0
- package/dist/config.d.ts +185 -19
- package/dist/config.js +82 -16
- package/dist/config.js.map +1 -1
- package/dist/context-builder/anchors.d.ts +12 -0
- package/dist/context-builder/anchors.js +22 -0
- package/dist/context-builder/anchors.js.map +1 -0
- package/dist/context-builder/bundle.d.ts +109 -0
- package/dist/context-builder/bundle.js +1498 -0
- package/dist/context-builder/bundle.js.map +1 -0
- package/dist/context-builder/codemap.d.ts +22 -0
- package/dist/context-builder/codemap.js +675 -0
- package/dist/context-builder/codemap.js.map +1 -0
- package/dist/context-builder/config.d.ts +61 -0
- package/dist/context-builder/config.js +216 -0
- package/dist/context-builder/config.js.map +1 -0
- package/dist/context-builder/context-run-catalog.d.ts +17 -0
- package/dist/context-builder/context-run-catalog.js +99 -0
- package/dist/context-builder/context-run-catalog.js.map +1 -0
- package/dist/context-builder/delegate-packet.d.ts +219 -0
- package/dist/context-builder/delegate-packet.js +1190 -0
- package/dist/context-builder/delegate-packet.js.map +1 -0
- package/dist/context-builder/delegate-reconstruction.d.ts +13 -0
- package/dist/context-builder/delegate-reconstruction.js +220 -0
- package/dist/context-builder/delegate-reconstruction.js.map +1 -0
- package/dist/context-builder/delegate-validation.d.ts +27 -0
- package/dist/context-builder/delegate-validation.js +479 -0
- package/dist/context-builder/delegate-validation.js.map +1 -0
- package/dist/context-builder/delegate.d.ts +26 -0
- package/dist/context-builder/delegate.js +134 -0
- package/dist/context-builder/delegate.js.map +1 -0
- package/dist/context-builder/diagnostics.d.ts +36 -0
- package/dist/context-builder/diagnostics.js +107 -0
- package/dist/context-builder/diagnostics.js.map +1 -0
- package/dist/context-builder/discovery.d.ts +146 -0
- package/dist/context-builder/discovery.js +2129 -0
- package/dist/context-builder/discovery.js.map +1 -0
- package/dist/context-builder/globs.d.ts +14 -0
- package/dist/context-builder/globs.js +175 -0
- package/dist/context-builder/globs.js.map +1 -0
- package/dist/context-builder/handler.d.ts +41 -0
- package/dist/context-builder/handler.js +2590 -0
- package/dist/context-builder/handler.js.map +1 -0
- package/dist/context-builder/lifecycle-contract.d.ts +424 -0
- package/dist/context-builder/lifecycle-contract.js +523 -0
- package/dist/context-builder/lifecycle-contract.js.map +1 -0
- package/dist/context-builder/lifecycle-journal.d.ts +62 -0
- package/dist/context-builder/lifecycle-journal.js +88 -0
- package/dist/context-builder/lifecycle-journal.js.map +1 -0
- package/dist/context-builder/lifecycle-observer.d.ts +102 -0
- package/dist/context-builder/lifecycle-observer.js +258 -0
- package/dist/context-builder/lifecycle-observer.js.map +1 -0
- package/dist/context-builder/lifecycle-reconcile.d.ts +32 -0
- package/dist/context-builder/lifecycle-reconcile.js +191 -0
- package/dist/context-builder/lifecycle-reconcile.js.map +1 -0
- package/dist/context-builder/lifecycle-recovery.d.ts +2 -0
- package/dist/context-builder/lifecycle-recovery.js +14 -0
- package/dist/context-builder/lifecycle-recovery.js.map +1 -0
- package/dist/context-builder/path-signals.d.ts +7 -0
- package/dist/context-builder/path-signals.js +70 -0
- package/dist/context-builder/path-signals.js.map +1 -0
- package/dist/context-builder/paths.d.ts +30 -0
- package/dist/context-builder/paths.js +153 -0
- package/dist/context-builder/paths.js.map +1 -0
- package/dist/context-builder/progress.d.ts +17 -0
- package/dist/context-builder/progress.js +93 -0
- package/dist/context-builder/progress.js.map +1 -0
- package/dist/context-builder/receipt.d.ts +91 -0
- package/dist/context-builder/receipt.js +180 -0
- package/dist/context-builder/receipt.js.map +1 -0
- package/dist/context-builder/refine-handler.d.ts +14 -0
- package/dist/context-builder/refine-handler.js +790 -0
- package/dist/context-builder/refine-handler.js.map +1 -0
- package/dist/context-builder/review-coverage.d.ts +84 -0
- package/dist/context-builder/review-coverage.js +437 -0
- package/dist/context-builder/review-coverage.js.map +1 -0
- package/dist/context-builder/run-id.d.ts +7 -0
- package/dist/context-builder/run-id.js +31 -0
- package/dist/context-builder/run-id.js.map +1 -0
- package/dist/context-builder/schema.d.ts +669 -0
- package/dist/context-builder/schema.js +399 -0
- package/dist/context-builder/schema.js.map +1 -0
- package/dist/context-builder/secrets.d.ts +41 -0
- package/dist/context-builder/secrets.js +1651 -0
- package/dist/context-builder/secrets.js.map +1 -0
- package/dist/context-builder/selection.d.ts +56 -0
- package/dist/context-builder/selection.js +1111 -0
- package/dist/context-builder/selection.js.map +1 -0
- package/dist/context-builder/session-log-identity.d.ts +1 -0
- package/dist/context-builder/session-log-identity.js +66 -0
- package/dist/context-builder/session-log-identity.js.map +1 -0
- package/dist/context-builder/slice-range-math.d.ts +16 -0
- package/dist/context-builder/slice-range-math.js +137 -0
- package/dist/context-builder/slice-range-math.js.map +1 -0
- package/dist/context-builder/status.d.ts +66 -0
- package/dist/context-builder/status.js +160 -0
- package/dist/context-builder/status.js.map +1 -0
- package/dist/context-builder/storage.d.ts +118 -0
- package/dist/context-builder/storage.js +1003 -0
- package/dist/context-builder/storage.js.map +1 -0
- package/dist/context-builder/token-estimate.d.ts +19 -0
- package/dist/context-builder/token-estimate.js +90 -0
- package/dist/context-builder/token-estimate.js.map +1 -0
- package/dist/context-builder/versions.d.ts +29 -0
- package/dist/context-builder/versions.js +30 -0
- package/dist/context-builder/versions.js.map +1 -0
- package/dist/context-builder/workflow-runner.d.ts +69 -0
- package/dist/context-builder/workflow-runner.js +1051 -0
- package/dist/context-builder/workflow-runner.js.map +1 -0
- package/dist/context-builder/write-watchdog.d.ts +14 -0
- package/dist/context-builder/write-watchdog.js +38 -0
- package/dist/context-builder/write-watchdog.js.map +1 -0
- package/dist/dashboard-adapter-catalog.d.ts +9 -0
- package/dist/dashboard-adapter-catalog.js +46 -0
- package/dist/dashboard-adapter-catalog.js.map +1 -0
- package/dist/dashboard-cli.d.ts +79 -0
- package/dist/dashboard-cli.js +585 -0
- package/dist/dashboard-cli.js.map +1 -0
- package/dist/dashboard-companion/client.d.ts +36 -0
- package/dist/dashboard-companion/client.js +210 -0
- package/dist/dashboard-companion/client.js.map +1 -0
- package/dist/dashboard-companion/config.d.ts +8 -0
- package/dist/dashboard-companion/config.js +52 -0
- package/dist/dashboard-companion/config.js.map +1 -0
- package/dist/dashboard-companion/http-proxy.d.ts +10 -0
- package/dist/dashboard-companion/http-proxy.js +234 -0
- package/dist/dashboard-companion/http-proxy.js.map +1 -0
- package/dist/dashboard-companion/protocol.d.ts +80 -0
- package/dist/dashboard-companion/protocol.js +455 -0
- package/dist/dashboard-companion/protocol.js.map +1 -0
- package/dist/dashboard-companion/standalone-assets.d.ts +12 -0
- package/dist/dashboard-companion/standalone-assets.js +72 -0
- package/dist/dashboard-companion/standalone-assets.js.map +1 -0
- package/dist/dashboard-companion/standalone-entry.d.ts +1 -0
- package/dist/dashboard-companion/standalone-entry.js +17 -0
- package/dist/dashboard-companion/standalone-entry.js.map +1 -0
- package/dist/dashboard-gateway/config.d.ts +9 -0
- package/dist/dashboard-gateway/config.js +44 -0
- package/dist/dashboard-gateway/config.js.map +1 -0
- package/dist/dashboard-gateway/index.d.ts +11 -0
- package/dist/dashboard-gateway/index.js +755 -0
- package/dist/dashboard-gateway/index.js.map +1 -0
- package/dist/dashboard-gateway/main.d.ts +1 -0
- package/dist/dashboard-gateway/main.js +25 -0
- package/dist/dashboard-gateway/main.js.map +1 -0
- package/dist/dashboard-pairing-token.d.ts +1 -0
- package/dist/dashboard-pairing-token.js +5 -0
- package/dist/dashboard-pairing-token.js.map +1 -0
- package/dist/elaris/client.d.ts +73 -0
- package/dist/elaris/client.js +825 -0
- package/dist/elaris/client.js.map +1 -0
- package/dist/elaris/config.d.ts +18 -0
- package/dist/elaris/config.js +75 -0
- package/dist/elaris/config.js.map +1 -0
- package/dist/elaris/errors.d.ts +41 -0
- package/dist/elaris/errors.js +205 -0
- package/dist/elaris/errors.js.map +1 -0
- package/dist/elaris/github-repo.d.ts +18 -0
- package/dist/elaris/github-repo.js +89 -0
- package/dist/elaris/github-repo.js.map +1 -0
- package/dist/elaris/index.d.ts +10 -0
- package/dist/elaris/index.js +11 -0
- package/dist/elaris/index.js.map +1 -0
- package/dist/elaris/redact.d.ts +89 -0
- package/dist/elaris/redact.js +423 -0
- package/dist/elaris/redact.js.map +1 -0
- package/dist/elaris/run-id.d.ts +5 -0
- package/dist/elaris/run-id.js +20 -0
- package/dist/elaris/run-id.js.map +1 -0
- package/dist/elaris/status.d.ts +45 -0
- package/dist/elaris/status.js +122 -0
- package/dist/elaris/status.js.map +1 -0
- package/dist/elaris/tool-schemas.d.ts +314 -0
- package/dist/elaris/tool-schemas.js +208 -0
- package/dist/elaris/tool-schemas.js.map +1 -0
- package/dist/elaris/tools.d.ts +73 -0
- package/dist/elaris/tools.js +1065 -0
- package/dist/elaris/tools.js.map +1 -0
- package/dist/elaris/types.d.ts +1541 -0
- package/dist/elaris/types.js +252 -0
- package/dist/elaris/types.js.map +1 -0
- package/dist/errors.d.ts +16 -0
- package/dist/errors.js +19 -0
- package/dist/errors.js.map +1 -1
- package/dist/handler.d.ts +4 -0
- package/dist/handler.js +10 -1
- package/dist/handler.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +13 -3
- package/dist/index.js.map +1 -1
- package/dist/local-clink-backend.d.ts +3 -0
- package/dist/local-clink-backend.js +4 -0
- package/dist/local-clink-backend.js.map +1 -1
- package/dist/package-info.d.ts +2 -0
- package/dist/package-info.js +18 -0
- package/dist/package-info.js.map +1 -0
- package/dist/parsers/codex-jsonl.js +48 -3
- package/dist/parsers/codex-jsonl.js.map +1 -1
- package/dist/parsers/extract.d.ts +10 -1
- package/dist/parsers/extract.js +11 -3
- package/dist/parsers/extract.js.map +1 -1
- package/dist/paths.d.ts +8 -0
- package/dist/paths.js +31 -43
- package/dist/paths.js.map +1 -1
- package/dist/pipeline.d.ts +51 -3
- package/dist/pipeline.js +264 -47
- package/dist/pipeline.js.map +1 -1
- package/dist/run-dir.d.ts +24 -0
- package/dist/run-dir.js +201 -2
- package/dist/run-dir.js.map +1 -1
- package/dist/runner.d.ts +13 -0
- package/dist/runner.js +184 -15
- package/dist/runner.js.map +1 -1
- package/dist/safety.d.ts +4 -4
- package/dist/safety.js +4 -4
- package/dist/schema.d.ts +7 -7
- package/dist/server.d.ts +2 -0
- package/dist/server.js +396 -24
- package/dist/server.js.map +1 -1
- package/dist/session-log-stream.d.ts +18 -0
- package/dist/session-log-stream.js +319 -0
- package/dist/session-log-stream.js.map +1 -0
- package/package.json +47 -5
- package/conf/adapters/gemini.json +0 -44
- package/conf/adapters/hapi/gemini.json +0 -47
- package/dist/artifacts.d.ts +0 -9
- package/dist/artifacts.js +0 -24
- package/dist/artifacts.js.map +0 -1
- package/dist/parsers/gemini-json.d.ts +0 -2
- package/dist/parsers/gemini-json.js +0 -72
- package/dist/parsers/gemini-json.js.map +0 -1
|
@@ -0,0 +1,1047 @@
|
|
|
1
|
+
import { randomBytes } from "node:crypto";
|
|
2
|
+
import { dirname, join } from "node:path";
|
|
3
|
+
import { listWorkflows } from "../loader.js";
|
|
4
|
+
import { logger } from "../logger.js";
|
|
5
|
+
import { CONTEXT_BUILDER_LIFECYCLE_DIRECTORY } from "../context-builder-lifecycle-contract.js";
|
|
6
|
+
import { AdaptersResponseSchema, ActivityDetailSchema, ActivityListResponseSchema, ActivityRouteParamsSchema, CallRouteParamsSchema, ContextRunArtifactRouteParamsSchema, ContextRunListQuerySchema, ContextRunListResponseSchema, ContextRunRouteParamsSchema, ContextRunRowSchema, DashboardAgentInstanceIdSchema, DashboardConnectionResponseSchema, EnvironmentResponseSchema, EmptyQuerySchema, GenerationQuerySchema, PaginationQuerySchema, ProgressReportDetailResponseSchema, ProgressReportListResponseSchema, RunRouteParamsSchema, SessionLogLaneIndexQuerySchema, SessionLogLaneIndexResponseSchema, SessionLogLaneRouteParamsSchema, SessionLogPageQuerySchema, SessionLogWorkflowRouteParamsSchema, StructuredDetailQuerySchema, WorkflowDescriptorSchema, WorkflowsResponseSchema, MAX_DASHBOARD_ADAPTERS, SafeAdapterDescriptorSchema, } from "./contracts.js";
|
|
7
|
+
import { DashboardInvalidCursorError } from "./artifact-index.js";
|
|
8
|
+
import { createDashboardRunScanner, DashboardReadModelError, } from "./scanner.js";
|
|
9
|
+
import { createDashboardActivityReader, } from "./activity-reader.js";
|
|
10
|
+
import { ContextRunSourceUnavailableError, createContextRunReader, } from "./context-run-reader.js";
|
|
11
|
+
import { createSessionLogReader, } from "./session-log-reader.js";
|
|
12
|
+
import { readSessionLogGeneration } from "./session-log-identity.js";
|
|
13
|
+
import { ProgressReportSessionIdSchema } from "./progress-report-contract.js";
|
|
14
|
+
import { createDashboardProgressReportReader, } from "./progress-report-reader.js";
|
|
15
|
+
import { isProgressReportStatusOverrideSegments, ProgressReportStatusOverrideRequestSchema, } from "./progress-report-status-overlay.js";
|
|
16
|
+
import { createProgressReportStatusOverrideStore, } from "./progress-report-status-store.js";
|
|
17
|
+
function queryMultimap(query) {
|
|
18
|
+
const values = Object.create(null);
|
|
19
|
+
for (const [key, value] of query) {
|
|
20
|
+
(values[key] ??= []).push(value);
|
|
21
|
+
}
|
|
22
|
+
return values;
|
|
23
|
+
}
|
|
24
|
+
function parseSessionLogRouteQuery(query, page) {
|
|
25
|
+
if (page) {
|
|
26
|
+
const parsed = SessionLogPageQuerySchema.safeParse(query);
|
|
27
|
+
return parsed.success
|
|
28
|
+
? {
|
|
29
|
+
generation: parsed.data.generation,
|
|
30
|
+
pageQuery: {
|
|
31
|
+
sequence: parsed.data.sequence,
|
|
32
|
+
limit: parsed.data.limit,
|
|
33
|
+
},
|
|
34
|
+
}
|
|
35
|
+
: undefined;
|
|
36
|
+
}
|
|
37
|
+
const parsed = SessionLogLaneIndexQuerySchema.safeParse(query);
|
|
38
|
+
return parsed.success ? { generation: parsed.data.generation } : undefined;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Content-Type for a served context-run artifact body. JSON variants are served
|
|
42
|
+
* as `application/json`; newline-delimited JSONL as `application/x-ndjson`;
|
|
43
|
+
* the bundle as `text/markdown`. All include an explicit charset.
|
|
44
|
+
*/
|
|
45
|
+
function artifactContentType(artifactKey) {
|
|
46
|
+
switch (artifactKey) {
|
|
47
|
+
case "manifest_json":
|
|
48
|
+
case "summary_json":
|
|
49
|
+
case "tree_json":
|
|
50
|
+
return "application/json; charset=utf-8";
|
|
51
|
+
case "selected_context_jsonl":
|
|
52
|
+
case "search_jsonl":
|
|
53
|
+
case "slices_jsonl":
|
|
54
|
+
case "codemap_jsonl":
|
|
55
|
+
return "application/x-ndjson; charset=utf-8";
|
|
56
|
+
case "bundle_md":
|
|
57
|
+
return "text/markdown; charset=utf-8";
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
function sendBytes(request, response, status, contentType, bytes, headers = {}) {
|
|
61
|
+
response.writeHead(status, {
|
|
62
|
+
"Cache-Control": "no-store",
|
|
63
|
+
"Content-Length": bytes.byteLength,
|
|
64
|
+
"Content-Type": contentType,
|
|
65
|
+
...headers,
|
|
66
|
+
});
|
|
67
|
+
response.end(request.method === "HEAD" ? undefined : bytes);
|
|
68
|
+
}
|
|
69
|
+
function sendJson(request, response, status, value, headers = {}) {
|
|
70
|
+
sendBytes(request, response, status, "application/json; charset=utf-8", Buffer.from(`${JSON.stringify(value)}\n`, "utf8"), headers);
|
|
71
|
+
}
|
|
72
|
+
function sendError(request, response, status, code, headers = {}) {
|
|
73
|
+
sendJson(request, response, status, { error: { code } }, headers);
|
|
74
|
+
}
|
|
75
|
+
const PROGRESS_REPORT_STATUS_OVERRIDE_BODY_MAX_BYTES = 4 * 1024;
|
|
76
|
+
class ProgressReportStatusOverrideBodyError extends Error {
|
|
77
|
+
status;
|
|
78
|
+
code;
|
|
79
|
+
constructor(status, code) {
|
|
80
|
+
super(code);
|
|
81
|
+
this.name = "ProgressReportStatusOverrideBodyError";
|
|
82
|
+
this.status = status;
|
|
83
|
+
this.code = code;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
function singleDistinctHeader(request, name) {
|
|
87
|
+
const values = request.headersDistinct[name];
|
|
88
|
+
return values?.length === 1 ? values[0] : undefined;
|
|
89
|
+
}
|
|
90
|
+
function parseProgressReportStatusOverrideContentLength(request) {
|
|
91
|
+
const values = request.headersDistinct["content-length"];
|
|
92
|
+
if (values != null && values.length !== 1) {
|
|
93
|
+
throw new ProgressReportStatusOverrideBodyError(400, "invalid_request");
|
|
94
|
+
}
|
|
95
|
+
const raw = values?.[0];
|
|
96
|
+
if (raw == null)
|
|
97
|
+
return;
|
|
98
|
+
if (!/^(0|[1-9]\d*)$/.test(raw)) {
|
|
99
|
+
throw new ProgressReportStatusOverrideBodyError(400, "invalid_request");
|
|
100
|
+
}
|
|
101
|
+
const length = Number(raw);
|
|
102
|
+
if (!Number.isSafeInteger(length)) {
|
|
103
|
+
throw new ProgressReportStatusOverrideBodyError(400, "invalid_request");
|
|
104
|
+
}
|
|
105
|
+
if (length > PROGRESS_REPORT_STATUS_OVERRIDE_BODY_MAX_BYTES) {
|
|
106
|
+
throw new ProgressReportStatusOverrideBodyError(413, "content_too_large_for_dashboard");
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
async function readProgressReportStatusOverrideJsonBody(request) {
|
|
110
|
+
const contentType = singleDistinctHeader(request, "content-type");
|
|
111
|
+
if (contentType == null || contentType.toLowerCase() !== "application/json") {
|
|
112
|
+
throw new ProgressReportStatusOverrideBodyError(400, "invalid_request");
|
|
113
|
+
}
|
|
114
|
+
parseProgressReportStatusOverrideContentLength(request);
|
|
115
|
+
const chunks = [];
|
|
116
|
+
let total = 0;
|
|
117
|
+
for await (const chunk of request) {
|
|
118
|
+
const bytes = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);
|
|
119
|
+
total += bytes.byteLength;
|
|
120
|
+
if (total > PROGRESS_REPORT_STATUS_OVERRIDE_BODY_MAX_BYTES) {
|
|
121
|
+
request.resume();
|
|
122
|
+
throw new ProgressReportStatusOverrideBodyError(413, "content_too_large_for_dashboard");
|
|
123
|
+
}
|
|
124
|
+
chunks.push(bytes);
|
|
125
|
+
}
|
|
126
|
+
let text;
|
|
127
|
+
try {
|
|
128
|
+
text = new TextDecoder("utf-8", { fatal: true }).decode(Buffer.concat(chunks));
|
|
129
|
+
}
|
|
130
|
+
catch {
|
|
131
|
+
throw new ProgressReportStatusOverrideBodyError(400, "invalid_request");
|
|
132
|
+
}
|
|
133
|
+
let value;
|
|
134
|
+
try {
|
|
135
|
+
value = JSON.parse(text);
|
|
136
|
+
}
|
|
137
|
+
catch {
|
|
138
|
+
throw new ProgressReportStatusOverrideBodyError(400, "invalid_request");
|
|
139
|
+
}
|
|
140
|
+
const parsed = ProgressReportStatusOverrideRequestSchema.safeParse(value);
|
|
141
|
+
if (!parsed.success) {
|
|
142
|
+
throw new ProgressReportStatusOverrideBodyError(400, "invalid_request");
|
|
143
|
+
}
|
|
144
|
+
return parsed.data;
|
|
145
|
+
}
|
|
146
|
+
function serializeContextRunList(rows, truncated) {
|
|
147
|
+
const serverNow = new Date().toISOString();
|
|
148
|
+
const parsed = ContextRunListResponseSchema.safeParse({
|
|
149
|
+
contextRuns: rows,
|
|
150
|
+
serverNow,
|
|
151
|
+
truncated,
|
|
152
|
+
});
|
|
153
|
+
if (parsed.success)
|
|
154
|
+
return parsed.data;
|
|
155
|
+
logger.error({ issues: parsed.error.issues.slice(0, 8) }, "context run list schema rejected; dropping invalid rows");
|
|
156
|
+
const kept = [];
|
|
157
|
+
for (const row of rows) {
|
|
158
|
+
const one = ContextRunRowSchema.safeParse(row);
|
|
159
|
+
if (one.success) {
|
|
160
|
+
kept.push(one.data);
|
|
161
|
+
continue;
|
|
162
|
+
}
|
|
163
|
+
logger.warn({
|
|
164
|
+
id: typeof row === "object" && row !== null && "id" in row
|
|
165
|
+
? row.id
|
|
166
|
+
: undefined,
|
|
167
|
+
issues: one.error.issues.slice(0, 4),
|
|
168
|
+
}, "dropped invalid context run row");
|
|
169
|
+
}
|
|
170
|
+
return ContextRunListResponseSchema.parse({
|
|
171
|
+
contextRuns: kept,
|
|
172
|
+
serverNow,
|
|
173
|
+
truncated: true,
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
function projectWorkflow(definition) {
|
|
177
|
+
const descriptor = {
|
|
178
|
+
name: definition.name,
|
|
179
|
+
version: definition.version,
|
|
180
|
+
description: definition.description.slice(0, 4_096),
|
|
181
|
+
stageCount: definition.stages.length,
|
|
182
|
+
callCount: definition.stages.reduce((count, stage) => count + stage.calls.length, 0),
|
|
183
|
+
variables: Object.entries(definition.variables)
|
|
184
|
+
.sort(([left], [right]) => left < right ? -1 : left > right ? 1 : 0)
|
|
185
|
+
.map(([name, variable]) => ({
|
|
186
|
+
name,
|
|
187
|
+
type: variable.type,
|
|
188
|
+
required: variable.required,
|
|
189
|
+
})),
|
|
190
|
+
};
|
|
191
|
+
return WorkflowDescriptorSchema.parse(descriptor);
|
|
192
|
+
}
|
|
193
|
+
function createWorkflowResponse(workflowsPath, loader) {
|
|
194
|
+
const workflows = [...loader(workflowsPath).values()]
|
|
195
|
+
.map(projectWorkflow)
|
|
196
|
+
.sort((left, right) => left.name < right.name ? -1 : left.name > right.name ? 1 : 0)
|
|
197
|
+
.map((workflow) => Object.freeze(workflow));
|
|
198
|
+
WorkflowsResponseSchema.parse({ workflows });
|
|
199
|
+
return Object.freeze({
|
|
200
|
+
workflows: Object.freeze(workflows),
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
function quoteEtag(stateRevision) {
|
|
204
|
+
return `"${stateRevision}"`;
|
|
205
|
+
}
|
|
206
|
+
function handleLazyResult(request, response, result) {
|
|
207
|
+
if (result.kind === "run_generation_changed") {
|
|
208
|
+
sendError(request, response, 409, "run_generation_changed");
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
211
|
+
if (result.kind === "run_state_changed") {
|
|
212
|
+
sendError(request, response, 409, "run_state_changed");
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
if (result.kind === "unavailable") {
|
|
216
|
+
if (result.reason === "content_too_large_for_dashboard") {
|
|
217
|
+
sendError(request, response, 413, "content_too_large_for_dashboard");
|
|
218
|
+
}
|
|
219
|
+
else {
|
|
220
|
+
sendError(request, response, 404, "not_found");
|
|
221
|
+
}
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
sendBytes(request, response, 200, result.mediaType, Buffer.from(result.content, "utf8"), {
|
|
225
|
+
ETag: quoteEtag(result.stateRevision),
|
|
226
|
+
...(result.validatorSchemaId === undefined
|
|
227
|
+
? {}
|
|
228
|
+
: { "X-ClinkX-Validator-Schema-Id": result.validatorSchemaId }),
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
function handleActivityResult(request, response, result) {
|
|
232
|
+
if (result.kind === "activity_generation_changed") {
|
|
233
|
+
sendError(request, response, 409, "activity_generation_changed");
|
|
234
|
+
return;
|
|
235
|
+
}
|
|
236
|
+
if (result.kind === "activity_state_changed") {
|
|
237
|
+
sendError(request, response, 409, "activity_state_changed");
|
|
238
|
+
return;
|
|
239
|
+
}
|
|
240
|
+
if (result.kind === "unavailable") {
|
|
241
|
+
sendError(request, response, result.reason === "too_large" ? 413 : 404, result.reason === "too_large"
|
|
242
|
+
? "content_too_large_for_dashboard"
|
|
243
|
+
: "not_found");
|
|
244
|
+
return;
|
|
245
|
+
}
|
|
246
|
+
sendBytes(request, response, 200, result.mediaType, Buffer.from(result.content, "utf8"), { ETag: quoteEtag(result.stateRevision) });
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* Build the authenticated dashboard route module from immutable launch-time
|
|
250
|
+
* configuration and one long-lived Phase 1 scanner/generation authority.
|
|
251
|
+
*/
|
|
252
|
+
export function createDashboardApiHandler(adapterCatalog, options) {
|
|
253
|
+
const agentInstanceId = DashboardAgentInstanceIdSchema.parse(options.agentInstanceId ?? randomBytes(16).toString("base64url"));
|
|
254
|
+
const scanner = options.scanner ?? createDashboardRunScanner({
|
|
255
|
+
maxStateBytes: options.maxStateBytes,
|
|
256
|
+
});
|
|
257
|
+
const activityReader = options.activityReader ?? createDashboardActivityReader();
|
|
258
|
+
const activitiesRoot = options.activitiesRoot ?? join(dirname(options.runsRoot), "activities");
|
|
259
|
+
const contextRunsRoot = options.contextRunsRoot;
|
|
260
|
+
const contextRunReader = options.contextRunReader ?? createContextRunReader();
|
|
261
|
+
const sessionLogsRoot = options.sessionLogsRoot ?? join(dirname(options.runsRoot), "session-logs");
|
|
262
|
+
const sessionLogReader = options.sessionLogReader ?? createSessionLogReader({
|
|
263
|
+
rootDir: sessionLogsRoot,
|
|
264
|
+
});
|
|
265
|
+
const progressReportsRoot = options.progressReportsRoot ?? join(dirname(options.runsRoot), "progress-reports");
|
|
266
|
+
const progressReportOverrideStore = options.progressReportOverrideStore ?? createProgressReportStatusOverrideStore();
|
|
267
|
+
const progressReportReader = options.progressReportReader ??
|
|
268
|
+
createDashboardProgressReportReader({
|
|
269
|
+
overrideStore: progressReportOverrideStore,
|
|
270
|
+
});
|
|
271
|
+
const safeAdapters = [];
|
|
272
|
+
for (const adapter of adapterCatalog) {
|
|
273
|
+
const result = SafeAdapterDescriptorSchema.safeParse(adapter);
|
|
274
|
+
if (!result.success)
|
|
275
|
+
continue;
|
|
276
|
+
Object.freeze(result.data.roleNames);
|
|
277
|
+
Object.freeze(result.data.environmentKeys);
|
|
278
|
+
Object.freeze(result.data.resultContract);
|
|
279
|
+
if (result.data.usableVia !== undefined)
|
|
280
|
+
Object.freeze(result.data.usableVia);
|
|
281
|
+
safeAdapters.push(Object.freeze(result.data));
|
|
282
|
+
if (safeAdapters.length === MAX_DASHBOARD_ADAPTERS)
|
|
283
|
+
break;
|
|
284
|
+
}
|
|
285
|
+
const boundedAdapters = Object.freeze(safeAdapters);
|
|
286
|
+
AdaptersResponseSchema.parse({ adapters: boundedAdapters });
|
|
287
|
+
const adaptersResponse = Object.freeze({ adapters: boundedAdapters });
|
|
288
|
+
const environmentResponse = Object.freeze(EnvironmentResponseSchema.parse(options.environment));
|
|
289
|
+
const workflowsResponse = createWorkflowResponse(options.workflowsPath, options.loadWorkflows ??
|
|
290
|
+
((workflowsPath) => listWorkflows(workflowsPath, {
|
|
291
|
+
failOnInvalidExternal: true,
|
|
292
|
+
templatesRoot: options.environment.templatesPath,
|
|
293
|
+
})));
|
|
294
|
+
async function handleSessionLogRead(request, response, scope, laneId, pageQuery) {
|
|
295
|
+
if (laneId === undefined) {
|
|
296
|
+
const result = await sessionLogReader.listLanes(scope);
|
|
297
|
+
if (result.kind === "unavailable") {
|
|
298
|
+
sendError(request, response, 503, "session_logs_unavailable");
|
|
299
|
+
return;
|
|
300
|
+
}
|
|
301
|
+
sendJson(request, response, 200, SessionLogLaneIndexResponseSchema.parse({
|
|
302
|
+
schemaVersion: "session-log-index-v1",
|
|
303
|
+
availability: result.kind === "not_retained"
|
|
304
|
+
? {
|
|
305
|
+
availability: "not_retained",
|
|
306
|
+
reason: "producer_did_not_retain",
|
|
307
|
+
}
|
|
308
|
+
: { availability: "available" },
|
|
309
|
+
lanes: result.kind === "available" ? result.lanes : [],
|
|
310
|
+
}));
|
|
311
|
+
return;
|
|
312
|
+
}
|
|
313
|
+
const result = await sessionLogReader.readPage(scope, laneId, pageQuery);
|
|
314
|
+
if (result.kind === "unavailable") {
|
|
315
|
+
sendError(request, response, 503, "session_logs_unavailable");
|
|
316
|
+
return;
|
|
317
|
+
}
|
|
318
|
+
if (result.kind === "missing") {
|
|
319
|
+
sendError(request, response, 404, "not_found");
|
|
320
|
+
return;
|
|
321
|
+
}
|
|
322
|
+
sendJson(request, response, 200, result.page);
|
|
323
|
+
}
|
|
324
|
+
async function dispatch(request, response, target) {
|
|
325
|
+
const segments = target.segments;
|
|
326
|
+
const query = queryMultimap(target.query);
|
|
327
|
+
if (segments.length === 2 && segments[1] === "connection") {
|
|
328
|
+
if (!EmptyQuerySchema.safeParse(query).success) {
|
|
329
|
+
sendError(request, response, 400, "invalid_request");
|
|
330
|
+
return;
|
|
331
|
+
}
|
|
332
|
+
sendJson(request, response, 200, DashboardConnectionResponseSchema.parse({
|
|
333
|
+
schemaVersion: "dashboard-connection-v1",
|
|
334
|
+
agentInstanceId,
|
|
335
|
+
}));
|
|
336
|
+
return;
|
|
337
|
+
}
|
|
338
|
+
if (segments.length === 2 && segments[1] === "context-runs") {
|
|
339
|
+
const parsed = ContextRunListQuerySchema.safeParse(query);
|
|
340
|
+
if (!parsed.success) {
|
|
341
|
+
sendError(request, response, 400, "invalid_request");
|
|
342
|
+
return;
|
|
343
|
+
}
|
|
344
|
+
const result = contextRunsRoot === undefined
|
|
345
|
+
? { rows: [], truncated: false }
|
|
346
|
+
: await contextRunReader.list({
|
|
347
|
+
runsDir: contextRunsRoot,
|
|
348
|
+
maxRows: parsed.data.limit,
|
|
349
|
+
});
|
|
350
|
+
sendJson(request, response, 200, serializeContextRunList(result.rows, result.truncated));
|
|
351
|
+
return;
|
|
352
|
+
}
|
|
353
|
+
if (segments[1] === "context-runs" &&
|
|
354
|
+
(segments.length === 4 || segments.length === 5) &&
|
|
355
|
+
segments[3] === "session-logs") {
|
|
356
|
+
const route = ContextRunRouteParamsSchema.safeParse({ id: segments[2] });
|
|
357
|
+
const lane = segments.length === 5
|
|
358
|
+
? SessionLogLaneRouteParamsSchema.safeParse({ laneId: segments[4] })
|
|
359
|
+
: undefined;
|
|
360
|
+
const parsedQuery = parseSessionLogRouteQuery(query, segments.length === 5);
|
|
361
|
+
if (!route.success) {
|
|
362
|
+
sendError(request, response, 404, "not_found");
|
|
363
|
+
return;
|
|
364
|
+
}
|
|
365
|
+
if (parsedQuery === undefined || (lane !== undefined && !lane.success)) {
|
|
366
|
+
sendError(request, response, 400, "invalid_request");
|
|
367
|
+
return;
|
|
368
|
+
}
|
|
369
|
+
if (contextRunsRoot === undefined) {
|
|
370
|
+
sendError(request, response, 404, "not_found");
|
|
371
|
+
return;
|
|
372
|
+
}
|
|
373
|
+
const authority = await contextRunReader.readDetail({ runsDir: contextRunsRoot }, route.data.id, parsedQuery.generation);
|
|
374
|
+
if (authority.kind === "context_generation_changed") {
|
|
375
|
+
sendError(request, response, 409, "context_generation_changed");
|
|
376
|
+
return;
|
|
377
|
+
}
|
|
378
|
+
if (authority.kind === "missing") {
|
|
379
|
+
sendError(request, response, 404, "not_found");
|
|
380
|
+
return;
|
|
381
|
+
}
|
|
382
|
+
if (authority.kind === "unavailable") {
|
|
383
|
+
sendError(request, response, 503, "context_runs_unavailable");
|
|
384
|
+
return;
|
|
385
|
+
}
|
|
386
|
+
const contextRunDir = authority.row.source === "journal"
|
|
387
|
+
? join(contextRunsRoot, CONTEXT_BUILDER_LIFECYCLE_DIRECTORY, route.data.id)
|
|
388
|
+
: join(contextRunsRoot, route.data.id);
|
|
389
|
+
const identity = await readSessionLogGeneration(contextRunDir);
|
|
390
|
+
if (identity.kind === "unavailable") {
|
|
391
|
+
sendError(request, response, 503, "session_logs_unavailable");
|
|
392
|
+
return;
|
|
393
|
+
}
|
|
394
|
+
const confirmedAuthority = await contextRunReader.readDetail({ runsDir: contextRunsRoot }, route.data.id, parsedQuery.generation);
|
|
395
|
+
if (confirmedAuthority.kind === "context_generation_changed") {
|
|
396
|
+
sendError(request, response, 409, "context_generation_changed");
|
|
397
|
+
return;
|
|
398
|
+
}
|
|
399
|
+
if (confirmedAuthority.kind === "missing") {
|
|
400
|
+
sendError(request, response, 404, "not_found");
|
|
401
|
+
return;
|
|
402
|
+
}
|
|
403
|
+
if (confirmedAuthority.kind === "unavailable") {
|
|
404
|
+
sendError(request, response, 503, "context_runs_unavailable");
|
|
405
|
+
return;
|
|
406
|
+
}
|
|
407
|
+
await handleSessionLogRead(request, response, {
|
|
408
|
+
family: "context",
|
|
409
|
+
contextRunId: route.data.id,
|
|
410
|
+
contextGeneration: identity.kind === "available"
|
|
411
|
+
? identity.sessionLogGeneration
|
|
412
|
+
: parsedQuery.generation,
|
|
413
|
+
}, lane?.success === true ? lane.data.laneId : undefined, parsedQuery.pageQuery);
|
|
414
|
+
return;
|
|
415
|
+
}
|
|
416
|
+
if (segments[1] === "context-runs" &&
|
|
417
|
+
segments.length === 5 &&
|
|
418
|
+
segments[3] === "artifacts") {
|
|
419
|
+
// Bounded single-artifact body endpoint. Mirrors the session-logs
|
|
420
|
+
// authority pattern: readDetail resolves the run, readArtifact serves the
|
|
421
|
+
// body from the resolved artifact directory (the journal row's linked
|
|
422
|
+
// artifactRunId, NOT the operation id), then readDetail re-confirms to
|
|
423
|
+
// close a journal-state-swap TOCTOU. Param-parse failure → 404 (matches
|
|
424
|
+
// the established "reject malformed route IDs" convention).
|
|
425
|
+
const detailQuery = StructuredDetailQuerySchema.safeParse(query);
|
|
426
|
+
if (!detailQuery.success) {
|
|
427
|
+
sendError(request, response, 400, "invalid_request");
|
|
428
|
+
return;
|
|
429
|
+
}
|
|
430
|
+
const route = ContextRunArtifactRouteParamsSchema.safeParse({
|
|
431
|
+
id: segments[2],
|
|
432
|
+
artifactKey: segments[4],
|
|
433
|
+
});
|
|
434
|
+
if (!route.success) {
|
|
435
|
+
sendError(request, response, 404, "not_found");
|
|
436
|
+
return;
|
|
437
|
+
}
|
|
438
|
+
if (contextRunsRoot === undefined) {
|
|
439
|
+
sendError(request, response, 404, "not_found");
|
|
440
|
+
return;
|
|
441
|
+
}
|
|
442
|
+
const firstRead = await contextRunReader.readDetail({ runsDir: contextRunsRoot }, route.data.id, detailQuery.data.generation);
|
|
443
|
+
if (firstRead.kind === "context_generation_changed") {
|
|
444
|
+
sendError(request, response, 409, "context_generation_changed");
|
|
445
|
+
return;
|
|
446
|
+
}
|
|
447
|
+
if (firstRead.kind === "missing") {
|
|
448
|
+
sendError(request, response, 404, "not_found");
|
|
449
|
+
return;
|
|
450
|
+
}
|
|
451
|
+
if (firstRead.kind === "unavailable") {
|
|
452
|
+
sendError(request, response, 503, "context_runs_unavailable");
|
|
453
|
+
return;
|
|
454
|
+
}
|
|
455
|
+
const result = await contextRunReader.readArtifact({ runsDir: contextRunsRoot }, route.data.id, route.data.artifactKey, detailQuery.data.generation);
|
|
456
|
+
if (result.kind === "content_too_large") {
|
|
457
|
+
sendError(request, response, 413, "content_too_large_for_dashboard");
|
|
458
|
+
return;
|
|
459
|
+
}
|
|
460
|
+
if (result.kind === "context_generation_changed") {
|
|
461
|
+
sendError(request, response, 409, "context_generation_changed");
|
|
462
|
+
return;
|
|
463
|
+
}
|
|
464
|
+
if (result.kind === "missing") {
|
|
465
|
+
sendError(request, response, 404, "not_found");
|
|
466
|
+
return;
|
|
467
|
+
}
|
|
468
|
+
if (result.kind === "unavailable") {
|
|
469
|
+
sendError(request, response, 503, "context_runs_unavailable");
|
|
470
|
+
return;
|
|
471
|
+
}
|
|
472
|
+
// Re-confirm authority: for a journal row, artifactRunId is sourced from
|
|
473
|
+
// .context-runs/<id>/state.json, and readArtifact's generation check pins
|
|
474
|
+
// the artifact dir, not the journal dir. A state swap mid-request could
|
|
475
|
+
// otherwise serve an artifact for an artifactRunId the current state no
|
|
476
|
+
// longer points to. Every non-available outcome — including the run
|
|
477
|
+
// disappearing entirely (missing) or being recycled to a shape with no
|
|
478
|
+
// resolvable artifactRunId (lifecycle null) — must bail rather than fall
|
|
479
|
+
// through to a stale 200.
|
|
480
|
+
const confirmedRead = await contextRunReader.readDetail({ runsDir: contextRunsRoot }, route.data.id, detailQuery.data.generation);
|
|
481
|
+
if (confirmedRead.kind === "missing") {
|
|
482
|
+
sendError(request, response, 404, "not_found");
|
|
483
|
+
return;
|
|
484
|
+
}
|
|
485
|
+
if (confirmedRead.kind === "context_generation_changed") {
|
|
486
|
+
sendError(request, response, 409, "context_generation_changed");
|
|
487
|
+
return;
|
|
488
|
+
}
|
|
489
|
+
if (confirmedRead.kind === "unavailable") {
|
|
490
|
+
sendError(request, response, 503, "context_runs_unavailable");
|
|
491
|
+
return;
|
|
492
|
+
}
|
|
493
|
+
if (confirmedRead.row.lifecycle === null) {
|
|
494
|
+
sendError(request, response, 409, "context_generation_changed");
|
|
495
|
+
return;
|
|
496
|
+
}
|
|
497
|
+
const currentArtifactRunId = confirmedRead.row.source === "journal"
|
|
498
|
+
? confirmedRead.row.lifecycle.artifactRunId
|
|
499
|
+
: confirmedRead.row.id;
|
|
500
|
+
if (currentArtifactRunId !== result.artifactRunId) {
|
|
501
|
+
sendError(request, response, 409, "context_generation_changed");
|
|
502
|
+
return;
|
|
503
|
+
}
|
|
504
|
+
const contentType = artifactContentType(route.data.artifactKey);
|
|
505
|
+
sendBytes(request, response, 200, contentType, Buffer.from(result.content, "utf8"));
|
|
506
|
+
return;
|
|
507
|
+
}
|
|
508
|
+
if (segments[1] === "context-runs" && segments.length === 3) {
|
|
509
|
+
const detailQuery = StructuredDetailQuerySchema.safeParse(query);
|
|
510
|
+
if (!detailQuery.success) {
|
|
511
|
+
sendError(request, response, 400, "invalid_request");
|
|
512
|
+
return;
|
|
513
|
+
}
|
|
514
|
+
const route = ContextRunRouteParamsSchema.safeParse({ id: segments[2] });
|
|
515
|
+
if (!route.success) {
|
|
516
|
+
sendError(request, response, 404, "not_found");
|
|
517
|
+
return;
|
|
518
|
+
}
|
|
519
|
+
if (contextRunsRoot === undefined) {
|
|
520
|
+
sendError(request, response, 404, "not_found");
|
|
521
|
+
return;
|
|
522
|
+
}
|
|
523
|
+
const result = await contextRunReader.readDetail({ runsDir: contextRunsRoot }, route.data.id, detailQuery.data.generation);
|
|
524
|
+
if (result.kind === "missing") {
|
|
525
|
+
sendError(request, response, 404, "not_found");
|
|
526
|
+
return;
|
|
527
|
+
}
|
|
528
|
+
if (result.kind === "context_generation_changed") {
|
|
529
|
+
sendError(request, response, 409, "context_generation_changed");
|
|
530
|
+
return;
|
|
531
|
+
}
|
|
532
|
+
if (result.kind === "unavailable") {
|
|
533
|
+
sendError(request, response, 503, "context_runs_unavailable");
|
|
534
|
+
return;
|
|
535
|
+
}
|
|
536
|
+
const detail = ContextRunRowSchema.safeParse(result.row);
|
|
537
|
+
if (!detail.success) {
|
|
538
|
+
logger.error({ issues: detail.error.issues.slice(0, 8), id: result.row.id }, "context run detail schema rejected");
|
|
539
|
+
sendError(request, response, 500, "internal_error");
|
|
540
|
+
return;
|
|
541
|
+
}
|
|
542
|
+
sendJson(request, response, 200, detail.data);
|
|
543
|
+
return;
|
|
544
|
+
}
|
|
545
|
+
if (segments.length === 2 && segments[1] === "activities") {
|
|
546
|
+
const parsed = PaginationQuerySchema.safeParse(query);
|
|
547
|
+
if (!parsed.success) {
|
|
548
|
+
sendError(request, response, 400, "invalid_request");
|
|
549
|
+
return;
|
|
550
|
+
}
|
|
551
|
+
const result = await activityReader.list(activitiesRoot, parsed.data);
|
|
552
|
+
sendJson(request, response, 200, ActivityListResponseSchema.parse(result));
|
|
553
|
+
return;
|
|
554
|
+
}
|
|
555
|
+
if (segments.length === 2 && segments[1] === "progress-reports") {
|
|
556
|
+
if (!EmptyQuerySchema.safeParse(query).success) {
|
|
557
|
+
sendError(request, response, 400, "invalid_request");
|
|
558
|
+
return;
|
|
559
|
+
}
|
|
560
|
+
// Absent root → 200 with empty list (reader maps ENOENT to empty).
|
|
561
|
+
const result = await progressReportReader.list(progressReportsRoot);
|
|
562
|
+
sendJson(request, response, 200, ProgressReportListResponseSchema.parse({
|
|
563
|
+
progressReports: result.rows,
|
|
564
|
+
serverNow: new Date().toISOString(),
|
|
565
|
+
truncated: result.truncated,
|
|
566
|
+
}));
|
|
567
|
+
return;
|
|
568
|
+
}
|
|
569
|
+
if (segments[1] === "progress-reports" &&
|
|
570
|
+
segments.length === 4 &&
|
|
571
|
+
segments[3] === "data") {
|
|
572
|
+
if (!EmptyQuerySchema.safeParse(query).success) {
|
|
573
|
+
sendError(request, response, 400, "invalid_request");
|
|
574
|
+
return;
|
|
575
|
+
}
|
|
576
|
+
const sessionId = segments[2];
|
|
577
|
+
if (sessionId === undefined || !ProgressReportSessionIdSchema.safeParse(sessionId).success) {
|
|
578
|
+
sendError(request, response, 404, "not_found");
|
|
579
|
+
return;
|
|
580
|
+
}
|
|
581
|
+
const result = await progressReportReader.readDetail(progressReportsRoot, sessionId);
|
|
582
|
+
if (result.kind === "absent") {
|
|
583
|
+
sendError(request, response, 404, "not_found");
|
|
584
|
+
return;
|
|
585
|
+
}
|
|
586
|
+
if (result.kind === "malformed") {
|
|
587
|
+
sendError(request, response, 404, "progress_report_malformed");
|
|
588
|
+
return;
|
|
589
|
+
}
|
|
590
|
+
if (result.kind === "oversized") {
|
|
591
|
+
sendError(request, response, 413, "content_too_large_for_dashboard");
|
|
592
|
+
return;
|
|
593
|
+
}
|
|
594
|
+
sendJson(request, response, 200, ProgressReportDetailResponseSchema.parse({
|
|
595
|
+
progressReport: result.document,
|
|
596
|
+
serverNow: new Date().toISOString(),
|
|
597
|
+
omittedSections: result.omittedSections,
|
|
598
|
+
...(result.publishedSessionStatus === undefined
|
|
599
|
+
? {}
|
|
600
|
+
: { publishedSessionStatus: result.publishedSessionStatus }),
|
|
601
|
+
}));
|
|
602
|
+
return;
|
|
603
|
+
}
|
|
604
|
+
if (isProgressReportStatusOverrideSegments(segments)) {
|
|
605
|
+
if (request.method !== "POST") {
|
|
606
|
+
sendError(request, response, 405, "method_not_allowed", { Allow: "POST" });
|
|
607
|
+
return;
|
|
608
|
+
}
|
|
609
|
+
if (!EmptyQuerySchema.safeParse(query).success) {
|
|
610
|
+
sendError(request, response, 400, "invalid_request");
|
|
611
|
+
return;
|
|
612
|
+
}
|
|
613
|
+
const sessionId = segments[2];
|
|
614
|
+
if (sessionId === undefined) {
|
|
615
|
+
sendError(request, response, 404, "not_found");
|
|
616
|
+
return;
|
|
617
|
+
}
|
|
618
|
+
let overrideRequest;
|
|
619
|
+
try {
|
|
620
|
+
overrideRequest = await readProgressReportStatusOverrideJsonBody(request);
|
|
621
|
+
}
|
|
622
|
+
catch (error) {
|
|
623
|
+
if (error instanceof ProgressReportStatusOverrideBodyError) {
|
|
624
|
+
sendError(request, response, error.status, error.code);
|
|
625
|
+
return;
|
|
626
|
+
}
|
|
627
|
+
throw error;
|
|
628
|
+
}
|
|
629
|
+
const detail = await progressReportReader.readDetail(progressReportsRoot, sessionId);
|
|
630
|
+
if (detail.kind === "absent") {
|
|
631
|
+
sendError(request, response, 404, "not_found");
|
|
632
|
+
return;
|
|
633
|
+
}
|
|
634
|
+
if (detail.kind === "malformed") {
|
|
635
|
+
sendError(request, response, 404, "progress_report_malformed");
|
|
636
|
+
return;
|
|
637
|
+
}
|
|
638
|
+
if (detail.kind === "oversized") {
|
|
639
|
+
sendError(request, response, 413, "content_too_large_for_dashboard");
|
|
640
|
+
return;
|
|
641
|
+
}
|
|
642
|
+
const session = detail.document.session;
|
|
643
|
+
const outcome = await progressReportOverrideStore.write(progressReportsRoot, sessionId, overrideRequest, {
|
|
644
|
+
status: detail.publishedSessionStatus ?? session.status,
|
|
645
|
+
startedAt: session.startedAt,
|
|
646
|
+
updatedAt: session.updatedAt,
|
|
647
|
+
});
|
|
648
|
+
if (outcome.kind === "unwritable") {
|
|
649
|
+
sendError(request, response, 503, "progress_report_overrides_unavailable");
|
|
650
|
+
return;
|
|
651
|
+
}
|
|
652
|
+
if (outcome.kind === "too_large") {
|
|
653
|
+
sendError(request, response, 413, "content_too_large_for_dashboard");
|
|
654
|
+
return;
|
|
655
|
+
}
|
|
656
|
+
response.writeHead(204, { "Cache-Control": "no-store" });
|
|
657
|
+
response.end();
|
|
658
|
+
return;
|
|
659
|
+
}
|
|
660
|
+
if (segments.length === 2 && segments[1] === "runs") {
|
|
661
|
+
const parsed = PaginationQuerySchema.safeParse(query);
|
|
662
|
+
if (!parsed.success) {
|
|
663
|
+
sendError(request, response, 400, "invalid_request");
|
|
664
|
+
return;
|
|
665
|
+
}
|
|
666
|
+
sendJson(request, response, 200, await scanner.scan(options.runsRoot, parsed.data));
|
|
667
|
+
return;
|
|
668
|
+
}
|
|
669
|
+
if (segments.length === 2 && segments[1] === "artifacts") {
|
|
670
|
+
const parsed = PaginationQuerySchema.safeParse(query);
|
|
671
|
+
if (!parsed.success) {
|
|
672
|
+
sendError(request, response, 400, "invalid_request");
|
|
673
|
+
return;
|
|
674
|
+
}
|
|
675
|
+
sendJson(request, response, 200, await scanner.listArtifacts(options.runsRoot, parsed.data));
|
|
676
|
+
return;
|
|
677
|
+
}
|
|
678
|
+
if (segments.length === 2 && ["adapters", "env", "workflows"].includes(segments[1] ?? "")) {
|
|
679
|
+
if (Object.keys(query).length !== 0) {
|
|
680
|
+
sendError(request, response, 400, "invalid_request");
|
|
681
|
+
return;
|
|
682
|
+
}
|
|
683
|
+
if (segments[1] === "adapters")
|
|
684
|
+
sendJson(request, response, 200, adaptersResponse);
|
|
685
|
+
if (segments[1] === "env")
|
|
686
|
+
sendJson(request, response, 200, environmentResponse);
|
|
687
|
+
if (segments[1] === "workflows")
|
|
688
|
+
sendJson(request, response, 200, workflowsResponse);
|
|
689
|
+
return;
|
|
690
|
+
}
|
|
691
|
+
if (segments[1] === "activities") {
|
|
692
|
+
const activity = ActivityRouteParamsSchema.safeParse({
|
|
693
|
+
activityId: segments[2],
|
|
694
|
+
});
|
|
695
|
+
if (!activity.success) {
|
|
696
|
+
sendError(request, response, 404, "not_found");
|
|
697
|
+
return;
|
|
698
|
+
}
|
|
699
|
+
if ((segments.length === 4 || segments.length === 5) &&
|
|
700
|
+
segments[3] === "session-logs") {
|
|
701
|
+
const lane = segments.length === 5
|
|
702
|
+
? SessionLogLaneRouteParamsSchema.safeParse({ laneId: segments[4] })
|
|
703
|
+
: undefined;
|
|
704
|
+
const parsedQuery = parseSessionLogRouteQuery(query, segments.length === 5);
|
|
705
|
+
if (parsedQuery === undefined || (lane !== undefined && !lane.success)) {
|
|
706
|
+
sendError(request, response, 400, "invalid_request");
|
|
707
|
+
return;
|
|
708
|
+
}
|
|
709
|
+
const authority = await activityReader.readDetail(activitiesRoot, activity.data.activityId, parsedQuery.generation);
|
|
710
|
+
if (authority.kind === "activity_generation_changed") {
|
|
711
|
+
sendError(request, response, 409, "activity_generation_changed");
|
|
712
|
+
return;
|
|
713
|
+
}
|
|
714
|
+
if (authority.kind === "activity_state_changed") {
|
|
715
|
+
sendError(request, response, 409, "activity_state_changed");
|
|
716
|
+
return;
|
|
717
|
+
}
|
|
718
|
+
if (authority.kind === "unavailable") {
|
|
719
|
+
sendError(request, response, 404, "not_found");
|
|
720
|
+
return;
|
|
721
|
+
}
|
|
722
|
+
const identity = await readSessionLogGeneration(join(activitiesRoot, activity.data.activityId));
|
|
723
|
+
if (identity.kind === "unavailable") {
|
|
724
|
+
sendError(request, response, 503, "session_logs_unavailable");
|
|
725
|
+
return;
|
|
726
|
+
}
|
|
727
|
+
const confirmedAuthority = await activityReader.readDetail(activitiesRoot, activity.data.activityId, parsedQuery.generation);
|
|
728
|
+
if (confirmedAuthority.kind === "activity_generation_changed") {
|
|
729
|
+
sendError(request, response, 409, "activity_generation_changed");
|
|
730
|
+
return;
|
|
731
|
+
}
|
|
732
|
+
if (confirmedAuthority.kind === "activity_state_changed") {
|
|
733
|
+
sendError(request, response, 409, "activity_state_changed");
|
|
734
|
+
return;
|
|
735
|
+
}
|
|
736
|
+
if (confirmedAuthority.kind === "unavailable") {
|
|
737
|
+
sendError(request, response, 404, "not_found");
|
|
738
|
+
return;
|
|
739
|
+
}
|
|
740
|
+
await handleSessionLogRead(request, response, {
|
|
741
|
+
family: "activity",
|
|
742
|
+
activityId: activity.data.activityId,
|
|
743
|
+
activityGeneration: identity.kind === "available"
|
|
744
|
+
? identity.sessionLogGeneration
|
|
745
|
+
: parsedQuery.generation,
|
|
746
|
+
}, lane?.success === true ? lane.data.laneId : undefined, parsedQuery.pageQuery);
|
|
747
|
+
return;
|
|
748
|
+
}
|
|
749
|
+
if (segments.length === 3) {
|
|
750
|
+
const detailQuery = StructuredDetailQuerySchema.safeParse(query);
|
|
751
|
+
if (!detailQuery.success) {
|
|
752
|
+
sendError(request, response, 400, "invalid_request");
|
|
753
|
+
return;
|
|
754
|
+
}
|
|
755
|
+
let activityGeneration = detailQuery.data.generation;
|
|
756
|
+
if (activityGeneration === undefined) {
|
|
757
|
+
const current = await activityReader.resolveCurrent(activitiesRoot, activity.data.activityId);
|
|
758
|
+
if (current.kind === "missing") {
|
|
759
|
+
sendError(request, response, 404, "not_found");
|
|
760
|
+
return;
|
|
761
|
+
}
|
|
762
|
+
activityGeneration = current.activityGeneration;
|
|
763
|
+
}
|
|
764
|
+
const result = await activityReader.readDetail(activitiesRoot, activity.data.activityId, activityGeneration);
|
|
765
|
+
if (result.kind === "unavailable") {
|
|
766
|
+
sendError(request, response, 404, "not_found");
|
|
767
|
+
}
|
|
768
|
+
if (result.kind === "activity_generation_changed") {
|
|
769
|
+
sendError(request, response, 409, "activity_generation_changed");
|
|
770
|
+
}
|
|
771
|
+
if (result.kind === "activity_state_changed") {
|
|
772
|
+
sendError(request, response, 409, "activity_state_changed");
|
|
773
|
+
}
|
|
774
|
+
if (result.kind === "available") {
|
|
775
|
+
sendJson(request, response, 200, ActivityDetailSchema.parse(result.detail));
|
|
776
|
+
}
|
|
777
|
+
return;
|
|
778
|
+
}
|
|
779
|
+
if (segments.length === 4 && segments[3] === "result") {
|
|
780
|
+
const generation = GenerationQuerySchema.safeParse(query);
|
|
781
|
+
if (!generation.success) {
|
|
782
|
+
sendError(request, response, 400, "invalid_request");
|
|
783
|
+
return;
|
|
784
|
+
}
|
|
785
|
+
handleActivityResult(request, response, await activityReader.readResult({
|
|
786
|
+
activitiesRoot,
|
|
787
|
+
activityId: activity.data.activityId,
|
|
788
|
+
activityGeneration: generation.data.generation,
|
|
789
|
+
}));
|
|
790
|
+
return;
|
|
791
|
+
}
|
|
792
|
+
sendError(request, response, 404, "not_found");
|
|
793
|
+
return;
|
|
794
|
+
}
|
|
795
|
+
const run = RunRouteParamsSchema.safeParse({ runId: segments[2] });
|
|
796
|
+
if (!run.success) {
|
|
797
|
+
sendError(request, response, 404, "not_found");
|
|
798
|
+
return;
|
|
799
|
+
}
|
|
800
|
+
if (segments.length === 3) {
|
|
801
|
+
const detailQuery = StructuredDetailQuerySchema.safeParse(query);
|
|
802
|
+
if (!detailQuery.success) {
|
|
803
|
+
sendError(request, response, 400, "invalid_request");
|
|
804
|
+
return;
|
|
805
|
+
}
|
|
806
|
+
let runGeneration = detailQuery.data.generation;
|
|
807
|
+
if (runGeneration === undefined) {
|
|
808
|
+
const current = await scanner.resolveCurrent(options.runsRoot, run.data.runId);
|
|
809
|
+
if (current.kind === "missing" || current.kind === "unavailable") {
|
|
810
|
+
sendError(request, response, 404, "not_found");
|
|
811
|
+
return;
|
|
812
|
+
}
|
|
813
|
+
runGeneration = current.runGeneration;
|
|
814
|
+
}
|
|
815
|
+
const result = await scanner.readDetail(options.runsRoot, run.data.runId, runGeneration);
|
|
816
|
+
if (result.kind === "missing")
|
|
817
|
+
sendError(request, response, 404, "not_found");
|
|
818
|
+
if (result.kind === "run_generation_changed") {
|
|
819
|
+
sendError(request, response, 409, "run_generation_changed");
|
|
820
|
+
}
|
|
821
|
+
if (result.kind === "run_state_changed") {
|
|
822
|
+
sendError(request, response, 409, "run_state_changed");
|
|
823
|
+
}
|
|
824
|
+
if (result.kind === "available")
|
|
825
|
+
sendJson(request, response, 200, result.detail);
|
|
826
|
+
return;
|
|
827
|
+
}
|
|
828
|
+
if (segments.length === 4 && segments[3] === "result") {
|
|
829
|
+
const generation = GenerationQuerySchema.safeParse(query);
|
|
830
|
+
if (!generation.success) {
|
|
831
|
+
sendError(request, response, 400, "invalid_request");
|
|
832
|
+
return;
|
|
833
|
+
}
|
|
834
|
+
handleLazyResult(request, response, await scanner.readResult({
|
|
835
|
+
runsRoot: options.runsRoot,
|
|
836
|
+
runId: run.data.runId,
|
|
837
|
+
runGeneration: generation.data.generation,
|
|
838
|
+
}));
|
|
839
|
+
return;
|
|
840
|
+
}
|
|
841
|
+
if ((segments.length === 8 || segments.length === 9) &&
|
|
842
|
+
segments[3] === "stages" &&
|
|
843
|
+
segments[5] === "calls" &&
|
|
844
|
+
segments[7] === "session-logs") {
|
|
845
|
+
const route = SessionLogWorkflowRouteParamsSchema.safeParse({
|
|
846
|
+
runId: segments[2],
|
|
847
|
+
stageId: segments[4],
|
|
848
|
+
callId: segments[6],
|
|
849
|
+
});
|
|
850
|
+
const lane = segments.length === 9
|
|
851
|
+
? SessionLogLaneRouteParamsSchema.safeParse({ laneId: segments[8] })
|
|
852
|
+
: undefined;
|
|
853
|
+
const parsedQuery = parseSessionLogRouteQuery(query, segments.length === 9);
|
|
854
|
+
if (!route.success) {
|
|
855
|
+
sendError(request, response, 404, "not_found");
|
|
856
|
+
return;
|
|
857
|
+
}
|
|
858
|
+
if (parsedQuery === undefined || (lane !== undefined && !lane.success)) {
|
|
859
|
+
sendError(request, response, 400, "invalid_request");
|
|
860
|
+
return;
|
|
861
|
+
}
|
|
862
|
+
const authority = await scanner.readDetail(options.runsRoot, route.data.runId, parsedQuery.generation);
|
|
863
|
+
if (authority.kind === "run_generation_changed") {
|
|
864
|
+
sendError(request, response, 409, "run_generation_changed");
|
|
865
|
+
return;
|
|
866
|
+
}
|
|
867
|
+
if (authority.kind === "run_state_changed") {
|
|
868
|
+
sendError(request, response, 409, "run_state_changed");
|
|
869
|
+
return;
|
|
870
|
+
}
|
|
871
|
+
if (authority.kind === "missing") {
|
|
872
|
+
sendError(request, response, 404, "not_found");
|
|
873
|
+
return;
|
|
874
|
+
}
|
|
875
|
+
if (authority.kind !== "available") {
|
|
876
|
+
sendError(request, response, 503, "session_logs_unavailable");
|
|
877
|
+
return;
|
|
878
|
+
}
|
|
879
|
+
const identity = await readSessionLogGeneration(join(options.runsRoot, route.data.runId));
|
|
880
|
+
if (identity.kind === "unavailable") {
|
|
881
|
+
sendError(request, response, 503, "session_logs_unavailable");
|
|
882
|
+
return;
|
|
883
|
+
}
|
|
884
|
+
// Close the sidecar-read race against same-ID parent replacement. The
|
|
885
|
+
// URL generation remains the sole parent authority; the portable token
|
|
886
|
+
// is used only after that authority is re-confirmed.
|
|
887
|
+
const confirmedAuthority = await scanner.readDetail(options.runsRoot, route.data.runId, parsedQuery.generation);
|
|
888
|
+
if (confirmedAuthority.kind === "run_generation_changed") {
|
|
889
|
+
sendError(request, response, 409, "run_generation_changed");
|
|
890
|
+
return;
|
|
891
|
+
}
|
|
892
|
+
if (confirmedAuthority.kind === "run_state_changed") {
|
|
893
|
+
sendError(request, response, 409, "run_state_changed");
|
|
894
|
+
return;
|
|
895
|
+
}
|
|
896
|
+
if (confirmedAuthority.kind === "missing") {
|
|
897
|
+
sendError(request, response, 404, "not_found");
|
|
898
|
+
return;
|
|
899
|
+
}
|
|
900
|
+
if (confirmedAuthority.kind !== "available") {
|
|
901
|
+
sendError(request, response, 503, "session_logs_unavailable");
|
|
902
|
+
return;
|
|
903
|
+
}
|
|
904
|
+
await handleSessionLogRead(request, response, {
|
|
905
|
+
family: "workflow",
|
|
906
|
+
runId: route.data.runId,
|
|
907
|
+
runGeneration: identity.kind === "available"
|
|
908
|
+
? identity.sessionLogGeneration
|
|
909
|
+
: parsedQuery.generation,
|
|
910
|
+
stageId: route.data.stageId,
|
|
911
|
+
callId: route.data.callId,
|
|
912
|
+
}, lane?.success === true ? lane.data.laneId : undefined, parsedQuery.pageQuery);
|
|
913
|
+
return;
|
|
914
|
+
}
|
|
915
|
+
// Preflight (curator/finalizer) session logs: the workflow-embedded context
|
|
916
|
+
// preflight's delegate calls emit context-family session logs. Authority is
|
|
917
|
+
// the run generation (workflow scanner), and the context-generation sidecar
|
|
918
|
+
// lives under <runDir>/.context-preflight (resolved here, not on the client).
|
|
919
|
+
if ((segments.length === 5 || segments.length === 6) &&
|
|
920
|
+
segments[3] === "context-preflight" &&
|
|
921
|
+
segments[4] === "session-logs") {
|
|
922
|
+
const route = RunRouteParamsSchema.safeParse({ runId: segments[2] });
|
|
923
|
+
const lane = segments.length === 6
|
|
924
|
+
? SessionLogLaneRouteParamsSchema.safeParse({ laneId: segments[5] })
|
|
925
|
+
: undefined;
|
|
926
|
+
const parsedQuery = parseSessionLogRouteQuery(query, segments.length === 6);
|
|
927
|
+
if (!route.success) {
|
|
928
|
+
sendError(request, response, 404, "not_found");
|
|
929
|
+
return;
|
|
930
|
+
}
|
|
931
|
+
if (parsedQuery === undefined || (lane !== undefined && !lane.success)) {
|
|
932
|
+
sendError(request, response, 400, "invalid_request");
|
|
933
|
+
return;
|
|
934
|
+
}
|
|
935
|
+
const authority = await scanner.readDetail(options.runsRoot, route.data.runId, parsedQuery.generation);
|
|
936
|
+
if (authority.kind === "run_generation_changed") {
|
|
937
|
+
sendError(request, response, 409, "run_generation_changed");
|
|
938
|
+
return;
|
|
939
|
+
}
|
|
940
|
+
if (authority.kind === "run_state_changed") {
|
|
941
|
+
sendError(request, response, 409, "run_state_changed");
|
|
942
|
+
return;
|
|
943
|
+
}
|
|
944
|
+
if (authority.kind === "missing") {
|
|
945
|
+
sendError(request, response, 404, "not_found");
|
|
946
|
+
return;
|
|
947
|
+
}
|
|
948
|
+
if (authority.kind !== "available") {
|
|
949
|
+
sendError(request, response, 503, "session_logs_unavailable");
|
|
950
|
+
return;
|
|
951
|
+
}
|
|
952
|
+
if (authority.detail.availability !== "available") {
|
|
953
|
+
sendError(request, response, 404, "not_found");
|
|
954
|
+
return;
|
|
955
|
+
}
|
|
956
|
+
const preflight = authority.detail.contextPreflight;
|
|
957
|
+
if (preflight === undefined || preflight.availability !== "current") {
|
|
958
|
+
sendError(request, response, 404, "not_found");
|
|
959
|
+
return;
|
|
960
|
+
}
|
|
961
|
+
const contextRunId = preflight.contextRunId;
|
|
962
|
+
if (contextRunId === undefined) {
|
|
963
|
+
sendError(request, response, 404, "not_found");
|
|
964
|
+
return;
|
|
965
|
+
}
|
|
966
|
+
const identity = await readSessionLogGeneration(join(options.runsRoot, route.data.runId, ".context-preflight"));
|
|
967
|
+
if (identity.kind === "unavailable" || identity.kind === "legacy") {
|
|
968
|
+
sendError(request, response, 503, "session_logs_unavailable");
|
|
969
|
+
return;
|
|
970
|
+
}
|
|
971
|
+
// Re-confirm run authority after the sidecar read (TOCTOU guard).
|
|
972
|
+
const confirmedAuthority = await scanner.readDetail(options.runsRoot, route.data.runId, parsedQuery.generation);
|
|
973
|
+
if (confirmedAuthority.kind === "run_generation_changed") {
|
|
974
|
+
sendError(request, response, 409, "run_generation_changed");
|
|
975
|
+
return;
|
|
976
|
+
}
|
|
977
|
+
if (confirmedAuthority.kind === "run_state_changed") {
|
|
978
|
+
sendError(request, response, 409, "run_state_changed");
|
|
979
|
+
return;
|
|
980
|
+
}
|
|
981
|
+
if (confirmedAuthority.kind === "missing") {
|
|
982
|
+
sendError(request, response, 404, "not_found");
|
|
983
|
+
return;
|
|
984
|
+
}
|
|
985
|
+
if (confirmedAuthority.kind !== "available") {
|
|
986
|
+
sendError(request, response, 503, "session_logs_unavailable");
|
|
987
|
+
return;
|
|
988
|
+
}
|
|
989
|
+
await handleSessionLogRead(request, response, {
|
|
990
|
+
family: "context",
|
|
991
|
+
contextRunId,
|
|
992
|
+
contextGeneration: identity.sessionLogGeneration,
|
|
993
|
+
}, lane?.success === true ? lane.data.laneId : undefined, parsedQuery.pageQuery);
|
|
994
|
+
return;
|
|
995
|
+
}
|
|
996
|
+
const call = CallRouteParamsSchema.safeParse({
|
|
997
|
+
runId: segments[2],
|
|
998
|
+
stageId: segments[4],
|
|
999
|
+
callId: segments[6],
|
|
1000
|
+
contentKind: segments[7],
|
|
1001
|
+
});
|
|
1002
|
+
if (!call.success) {
|
|
1003
|
+
sendError(request, response, 404, "not_found");
|
|
1004
|
+
return;
|
|
1005
|
+
}
|
|
1006
|
+
const generation = GenerationQuerySchema.safeParse(query);
|
|
1007
|
+
if (!generation.success) {
|
|
1008
|
+
sendError(request, response, 400, "invalid_request");
|
|
1009
|
+
return;
|
|
1010
|
+
}
|
|
1011
|
+
handleLazyResult(request, response, await scanner.readCallContent({
|
|
1012
|
+
runsRoot: options.runsRoot,
|
|
1013
|
+
runId: call.data.runId,
|
|
1014
|
+
runGeneration: generation.data.generation,
|
|
1015
|
+
stageId: call.data.stageId,
|
|
1016
|
+
callId: call.data.callId,
|
|
1017
|
+
kind: call.data.contentKind,
|
|
1018
|
+
}));
|
|
1019
|
+
}
|
|
1020
|
+
return (request, response, target) => {
|
|
1021
|
+
void dispatch(request, response, target).catch((error) => {
|
|
1022
|
+
if (!(error instanceof DashboardReadModelError) &&
|
|
1023
|
+
!(error instanceof DashboardInvalidCursorError) &&
|
|
1024
|
+
!(error instanceof ContextRunSourceUnavailableError)) {
|
|
1025
|
+
logger.error({ err: error }, "dashboard API request failed");
|
|
1026
|
+
}
|
|
1027
|
+
if (response.headersSent) {
|
|
1028
|
+
response.destroy(error instanceof Error ? error : undefined);
|
|
1029
|
+
return;
|
|
1030
|
+
}
|
|
1031
|
+
if (error instanceof DashboardReadModelError) {
|
|
1032
|
+
sendError(request, response, error.status, error.code);
|
|
1033
|
+
return;
|
|
1034
|
+
}
|
|
1035
|
+
if (error instanceof DashboardInvalidCursorError) {
|
|
1036
|
+
sendError(request, response, 400, "invalid_request");
|
|
1037
|
+
return;
|
|
1038
|
+
}
|
|
1039
|
+
if (error instanceof ContextRunSourceUnavailableError) {
|
|
1040
|
+
sendError(request, response, 503, "context_runs_unavailable");
|
|
1041
|
+
return;
|
|
1042
|
+
}
|
|
1043
|
+
sendError(request, response, 500, "internal_error");
|
|
1044
|
+
});
|
|
1045
|
+
};
|
|
1046
|
+
}
|
|
1047
|
+
//# sourceMappingURL=api-routes.js.map
|