clinkx 0.3.0 → 1.1.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 +119 -0
- package/LICENSE +10 -0
- package/README.md +154 -26
- 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/chairman-knobs.d.ts +24 -0
- package/clinkx-workflows/dist/chairman-knobs.js +27 -0
- package/clinkx-workflows/dist/chairman-knobs.js.map +1 -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 +12 -1
- package/clinkx-workflows/dist/clink-client.js +56 -5
- package/clinkx-workflows/dist/clink-client.js.map +1 -1
- package/clinkx-workflows/dist/config.d.ts +173 -16
- package/clinkx-workflows/dist/config.js +417 -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 +189 -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-execution-policy.d.ts +68 -0
- package/clinkx-workflows/dist/council-execution-policy.js +110 -0
- package/clinkx-workflows/dist/council-execution-policy.js.map +1 -0
- package/clinkx-workflows/dist/council-expander.d.ts +10 -9
- package/clinkx-workflows/dist/council-expander.js +20 -10
- package/clinkx-workflows/dist/council-expander.js.map +1 -1
- package/clinkx-workflows/dist/dashboard/activity-contract.d.ts +5718 -0
- package/clinkx-workflows/dist/dashboard/activity-contract.js +157 -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 +90 -0
- package/clinkx-workflows/dist/dashboard/activity-reader.js +493 -0
- package/clinkx-workflows/dist/dashboard/activity-reader.js.map +1 -0
- package/clinkx-workflows/dist/dashboard/api-routes.d.ts +40 -0
- package/clinkx-workflows/dist/dashboard/api-routes.js +1155 -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-builder-invocation-contract.d.ts +3865 -0
- package/clinkx-workflows/dist/dashboard/context-builder-invocation-contract.js +69 -0
- package/clinkx-workflows/dist/dashboard/context-builder-invocation-contract.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 +256 -0
- package/clinkx-workflows/dist/dashboard/context-run-reader.js +1301 -0
- package/clinkx-workflows/dist/dashboard/context-run-reader.js.map +1 -0
- package/clinkx-workflows/dist/dashboard/contracts.d.ts +28483 -0
- package/clinkx-workflows/dist/dashboard/contracts.js +1284 -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 +32 -0
- package/clinkx-workflows/dist/dashboard/index.js +20 -0
- package/clinkx-workflows/dist/dashboard/index.js.map +1 -0
- package/clinkx-workflows/dist/dashboard/invocation-contract.d.ts +786 -0
- package/clinkx-workflows/dist/dashboard/invocation-contract.js +201 -0
- package/clinkx-workflows/dist/dashboard/invocation-contract.js.map +1 -0
- package/clinkx-workflows/dist/dashboard/lazy-content.d.ts +114 -0
- package/clinkx-workflows/dist/dashboard/lazy-content.js +799 -0
- package/clinkx-workflows/dist/dashboard/lazy-content.js.map +1 -0
- package/clinkx-workflows/dist/dashboard/native-transcript/contract.d.ts +90 -0
- package/clinkx-workflows/dist/dashboard/native-transcript/contract.js +31 -0
- package/clinkx-workflows/dist/dashboard/native-transcript/contract.js.map +1 -0
- package/clinkx-workflows/dist/dashboard/native-transcript/projection.d.ts +12 -0
- package/clinkx-workflows/dist/dashboard/native-transcript/projection.js +286 -0
- package/clinkx-workflows/dist/dashboard/native-transcript/projection.js.map +1 -0
- package/clinkx-workflows/dist/dashboard/progress-report-contract.d.ts +446 -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 +529 -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 +29 -0
- package/clinkx-workflows/dist/dashboard/progress-report-status-store.js +111 -0
- package/clinkx-workflows/dist/dashboard/progress-report-status-store.js.map +1 -0
- package/clinkx-workflows/dist/dashboard/prompt-builder-library-contract.d.ts +194 -0
- package/clinkx-workflows/dist/dashboard/prompt-builder-library-contract.js +89 -0
- package/clinkx-workflows/dist/dashboard/prompt-builder-library-contract.js.map +1 -0
- package/clinkx-workflows/dist/dashboard/prompt-builder-library-store.d.ts +26 -0
- package/clinkx-workflows/dist/dashboard/prompt-builder-library-store.js +102 -0
- package/clinkx-workflows/dist/dashboard/prompt-builder-library-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 +130 -0
- package/clinkx-workflows/dist/dashboard/request-admission.js.map +1 -0
- package/clinkx-workflows/dist/dashboard/scanner.d.ts +78 -0
- package/clinkx-workflows/dist/dashboard/scanner.js +1154 -0
- package/clinkx-workflows/dist/dashboard/scanner.js.map +1 -0
- package/clinkx-workflows/dist/dashboard/server-factory.d.ts +63 -0
- package/clinkx-workflows/dist/dashboard/server-factory.js +483 -0
- package/clinkx-workflows/dist/dashboard/server-factory.js.map +1 -0
- package/clinkx-workflows/dist/dashboard/session-log-contract.d.ts +2778 -0
- package/clinkx-workflows/dist/dashboard/session-log-contract.js +506 -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 +529 -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 +14 -0
- package/clinkx-workflows/dist/dashboard/session-log-redaction.js +1101 -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-JPHQVtn9.js +106 -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-DOMHk-j6.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-finalizer-policy.d.ts +26 -0
- package/clinkx-workflows/dist/delegate-finalizer-policy.js +72 -0
- package/clinkx-workflows/dist/delegate-finalizer-policy.js.map +1 -0
- package/clinkx-workflows/dist/delegate-signature.d.ts +14 -0
- package/clinkx-workflows/dist/delegate-signature.js +14 -0
- package/clinkx-workflows/dist/delegate-signature.js.map +1 -0
- package/clinkx-workflows/dist/delegate-validate.d.ts +108 -0
- package/clinkx-workflows/dist/delegate-validate.js +148 -0
- package/clinkx-workflows/dist/delegate-validate.js.map +1 -0
- package/clinkx-workflows/dist/engine.d.ts +251 -0
- package/clinkx-workflows/dist/engine.js +1342 -92
- package/clinkx-workflows/dist/engine.js.map +1 -1
- package/clinkx-workflows/dist/errors.d.ts +24 -2
- package/clinkx-workflows/dist/errors.js +30 -2
- package/clinkx-workflows/dist/errors.js.map +1 -1
- package/clinkx-workflows/dist/fidelity.d.ts +47 -1
- package/clinkx-workflows/dist/fidelity.js +54 -1
- package/clinkx-workflows/dist/fidelity.js.map +1 -1
- package/clinkx-workflows/dist/fingerprint.d.ts +25 -7
- package/clinkx-workflows/dist/fingerprint.js +33 -10
- package/clinkx-workflows/dist/fingerprint.js.map +1 -1
- package/clinkx-workflows/dist/index.d.ts +19 -0
- package/clinkx-workflows/dist/index.js +68 -1
- 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/logger.d.ts +1 -1
- package/clinkx-workflows/dist/logger.js +17 -3
- package/clinkx-workflows/dist/logger.js.map +1 -1
- package/clinkx-workflows/dist/monotonic-clock.d.ts +19 -0
- package/clinkx-workflows/dist/monotonic-clock.js +22 -0
- package/clinkx-workflows/dist/monotonic-clock.js.map +1 -0
- 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/roster-contract.d.ts +889 -0
- package/clinkx-workflows/dist/roster-contract.js +180 -0
- package/clinkx-workflows/dist/roster-contract.js.map +1 -0
- package/clinkx-workflows/dist/rosters.d.ts +14 -0
- package/clinkx-workflows/dist/rosters.js +169 -0
- package/clinkx-workflows/dist/rosters.js.map +1 -0
- package/clinkx-workflows/dist/run-health.d.ts +7 -0
- package/clinkx-workflows/dist/run-health.js +25 -0
- package/clinkx-workflows/dist/run-health.js.map +1 -0
- 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 +140 -21
- package/clinkx-workflows/dist/schema.js +34 -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 +84 -52
- package/clinkx-workflows/dist/server.js.map +1 -1
- package/clinkx-workflows/dist/shutdown.d.ts +29 -18
- package/clinkx-workflows/dist/shutdown.js +90 -64
- package/clinkx-workflows/dist/shutdown.js.map +1 -1
- package/clinkx-workflows/dist/state-schema.d.ts +61 -0
- package/clinkx-workflows/dist/state.d.ts +175 -3
- package/clinkx-workflows/dist/state.js +1398 -44
- package/clinkx-workflows/dist/state.js.map +1 -1
- package/clinkx-workflows/dist/stdio-watchdog.d.ts +52 -0
- package/clinkx-workflows/dist/stdio-watchdog.js +212 -0
- package/clinkx-workflows/dist/stdio-watchdog.js.map +1 -0
- 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 +20 -2
- package/clinkx-workflows/dist/validators/council.d.ts +334 -101
- 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 +118 -3
- package/clinkx-workflows/dist/workflow-tools.js +2110 -175
- 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-chairman.txt +3 -0
- package/clinkx-workflows/templates/council/answer-cross-reviewer.txt +3 -0
- package/clinkx-workflows/templates/council/answer-specialist.txt +5 -1
- package/clinkx-workflows/templates/council/chairman.txt +3 -0
- package/clinkx-workflows/templates/council/code-review-chairman.txt +16 -0
- package/clinkx-workflows/templates/council/code-review-cross-reviewer.txt +7 -1
- package/clinkx-workflows/templates/council/code-review-reviewer.txt +22 -3
- package/clinkx-workflows/templates/council/debug-chairman.txt +3 -0
- package/clinkx-workflows/templates/council/debug-cross-reviewer.txt +3 -0
- package/clinkx-workflows/templates/council/debug-debugger.txt +5 -1
- package/clinkx-workflows/templates/council/discover-analyst.txt +5 -1
- package/clinkx-workflows/templates/council/discover-chairman.txt +3 -0
- package/clinkx-workflows/templates/council/discover-cross-reviewer.txt +3 -0
- package/clinkx-workflows/templates/council/member.txt +5 -1
- package/clinkx-workflows/templates/council/plan-review-chairman.txt +71 -0
- package/clinkx-workflows/templates/council/plan-review-cross-reviewer.txt +54 -0
- package/clinkx-workflows/templates/council/plan-review-reviewer.txt +63 -0
- package/clinkx-workflows/templates/council/reviewer.txt +3 -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 +100 -8
- package/clinkx-workflows/workflows/council-code-review.yaml +106 -8
- package/clinkx-workflows/workflows/council-debug.yaml +100 -8
- package/clinkx-workflows/workflows/council-default.yaml +104 -8
- package/clinkx-workflows/workflows/council-discover.yaml +100 -8
- package/clinkx-workflows/workflows/council-plan-review.yaml +253 -0
- package/clinkx-workflows/workflows/plan-review-receipts.yaml +230 -0
- package/conf/adapters/agy.json +56 -0
- package/conf/adapters/claude.json +12 -0
- package/conf/adapters/codex-app-server.json +44 -0
- package/conf/adapters/codex.json +14 -2
- package/conf/adapters/glm.json +24 -3
- package/conf/adapters/grok.json +67 -0
- package/conf/adapters/hapi/agy.json +59 -0
- package/conf/adapters/hapi/claude.json +12 -0
- package/conf/adapters/hapi/codex.json +14 -2
- package/conf/adapters/hapi/glm.json +25 -4
- package/conf/rosters/default-council.json +21 -0
- package/dist/activity-journal.d.ts +56 -0
- package/dist/activity-journal.js +706 -0
- package/dist/activity-journal.js.map +1 -0
- package/dist/allowed-roots.d.ts +41 -0
- package/dist/allowed-roots.js +125 -3
- package/dist/allowed-roots.js.map +1 -1
- 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 +1306 -0
- package/dist/codex/agent-tools.js.map +1 -0
- package/dist/codex/app-server-client.d.ts +79 -0
- package/dist/codex/app-server-client.js +593 -0
- package/dist/codex/app-server-client.js.map +1 -0
- package/dist/codex/app-server-registry.d.ts +407 -0
- package/dist/codex/app-server-registry.js +1493 -0
- package/dist/codex/app-server-registry.js.map +1 -0
- package/dist/codex/client-types.d.ts +115 -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 +386 -23
- package/dist/config.js +184 -15
- package/dist/config.js.map +1 -1
- package/dist/context-builder/anchors.d.ts +1 -0
- package/dist/context-builder/anchors.js +3 -0
- package/dist/context-builder/anchors.js.map +1 -1
- package/dist/context-builder/bundle.d.ts +48 -2
- package/dist/context-builder/bundle.js +388 -2417
- package/dist/context-builder/bundle.js.map +1 -1
- package/dist/context-builder/codemap.d.ts +5 -0
- package/dist/context-builder/codemap.js +387 -13
- package/dist/context-builder/codemap.js.map +1 -1
- package/dist/context-builder/config.d.ts +1 -0
- package/dist/context-builder/config.js +12 -0
- package/dist/context-builder/config.js.map +1 -1
- 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-finalizer-effective.d.ts +33 -0
- package/dist/context-builder/delegate-finalizer-effective.js +82 -0
- package/dist/context-builder/delegate-finalizer-effective.js.map +1 -0
- package/dist/context-builder/delegate-packet.d.ts +55 -0
- package/dist/context-builder/delegate-packet.js +430 -74
- package/dist/context-builder/delegate-packet.js.map +1 -1
- package/dist/context-builder/delegate-reconstruction.d.ts +29 -0
- package/dist/context-builder/delegate-reconstruction.js +110 -41
- package/dist/context-builder/delegate-reconstruction.js.map +1 -1
- package/dist/context-builder/delegate-validation.d.ts +41 -1
- package/dist/context-builder/delegate-validation.js +237 -48
- package/dist/context-builder/delegate-validation.js.map +1 -1
- package/dist/context-builder/delegate.d.ts +11 -0
- package/dist/context-builder/delegate.js +210 -58
- package/dist/context-builder/delegate.js.map +1 -1
- package/dist/context-builder/diagnostics.d.ts +11 -2
- package/dist/context-builder/diagnostics.js +39 -6
- package/dist/context-builder/diagnostics.js.map +1 -1
- package/dist/context-builder/discovery-progress.d.ts +25 -0
- package/dist/context-builder/discovery-progress.js +64 -0
- package/dist/context-builder/discovery-progress.js.map +1 -0
- package/dist/context-builder/discovery-watchdog.d.ts +15 -0
- package/dist/context-builder/discovery-watchdog.js +39 -0
- package/dist/context-builder/discovery-watchdog.js.map +1 -0
- package/dist/context-builder/discovery.d.ts +36 -1
- package/dist/context-builder/discovery.js +584 -172
- package/dist/context-builder/discovery.js.map +1 -1
- package/dist/context-builder/external-gaps.d.ts +73 -0
- package/dist/context-builder/external-gaps.js +248 -0
- package/dist/context-builder/external-gaps.js.map +1 -0
- package/dist/context-builder/globs.d.ts +1 -0
- package/dist/context-builder/globs.js +25 -10
- package/dist/context-builder/globs.js.map +1 -1
- package/dist/context-builder/handler.d.ts +67 -2
- package/dist/context-builder/handler.js +1810 -2440
- package/dist/context-builder/handler.js.map +1 -1
- package/dist/context-builder/invocation-sidecar.d.ts +41 -0
- package/dist/context-builder/invocation-sidecar.js +189 -0
- package/dist/context-builder/invocation-sidecar.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/mutation-lock.d.ts +32 -0
- package/dist/context-builder/mutation-lock.js +321 -0
- package/dist/context-builder/mutation-lock.js.map +1 -0
- package/dist/context-builder/path-signals.js +9 -5
- package/dist/context-builder/path-signals.js.map +1 -1
- package/dist/context-builder/progress.d.ts +3 -1
- package/dist/context-builder/progress.js +23 -0
- package/dist/context-builder/progress.js.map +1 -1
- package/dist/context-builder/receipt.d.ts +6 -4
- package/dist/context-builder/receipt.js +12 -1
- package/dist/context-builder/receipt.js.map +1 -1
- 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 +116 -0
- package/dist/context-builder/review-coverage.js +544 -0
- package/dist/context-builder/review-coverage.js.map +1 -0
- package/dist/context-builder/schema.d.ts +315 -2
- package/dist/context-builder/schema.js +133 -7
- package/dist/context-builder/schema.js.map +1 -1
- package/dist/context-builder/secrets.d.ts +59 -0
- package/dist/context-builder/secrets.js +2255 -44
- package/dist/context-builder/secrets.js.map +1 -1
- package/dist/context-builder/selection.d.ts +7 -3
- package/dist/context-builder/selection.js +200 -738
- package/dist/context-builder/selection.js.map +1 -1
- 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 +23 -2
- package/dist/context-builder/status.js +60 -4
- package/dist/context-builder/status.js.map +1 -1
- package/dist/context-builder/storage.d.ts +59 -2
- package/dist/context-builder/storage.js +500 -168
- package/dist/context-builder/storage.js.map +1 -1
- package/dist/context-builder/token-estimate.d.ts +13 -2
- package/dist/context-builder/token-estimate.js +77 -4
- package/dist/context-builder/token-estimate.js.map +1 -1
- package/dist/context-builder/versions.d.ts +44 -0
- package/dist/context-builder/versions.js +45 -0
- package/dist/context-builder/versions.js.map +1 -0
- package/dist/context-builder/workflow-runner.d.ts +75 -0
- package/dist/context-builder/workflow-runner.js +1241 -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 +53 -0
- package/dist/dashboard-adapter-catalog.js.map +1 -0
- package/dist/dashboard-cli.d.ts +81 -0
- package/dist/dashboard-cli.js +623 -0
- package/dist/dashboard-cli.js.map +1 -0
- package/dist/dashboard-companion/client.d.ts +37 -0
- package/dist/dashboard-companion/client.js +229 -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 +458 -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 +12 -0
- package/dist/dashboard-gateway/index.js +786 -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 +15 -2
- package/dist/handler.js.map +1 -1
- package/dist/index.d.ts +20 -2
- package/dist/index.js +154 -6
- 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/logger.d.ts +1 -1
- package/dist/logger.js +18 -3
- package/dist/logger.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/agy-stream-json.d.ts +14 -0
- package/dist/parsers/agy-stream-json.js +172 -0
- package/dist/parsers/agy-stream-json.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 +16 -4
- package/dist/parsers/extract.js.map +1 -1
- package/dist/parsers/observed-invocation.d.ts +20 -0
- package/dist/parsers/observed-invocation.js +42 -0
- package/dist/parsers/observed-invocation.js.map +1 -0
- package/dist/pipeline.d.ts +17 -0
- package/dist/pipeline.js +181 -10
- package/dist/pipeline.js.map +1 -1
- package/dist/progress-report/lock.d.ts +74 -0
- package/dist/progress-report/lock.js +343 -0
- package/dist/progress-report/lock.js.map +1 -0
- package/dist/progress-report/schema.d.ts +808 -0
- package/dist/progress-report/schema.js +119 -0
- package/dist/progress-report/schema.js.map +1 -0
- package/dist/progress-report/store.d.ts +66 -0
- package/dist/progress-report/store.js +766 -0
- package/dist/progress-report/store.js.map +1 -0
- package/dist/progress-report/tools.d.ts +20 -0
- package/dist/progress-report/tools.js +141 -0
- package/dist/progress-report/tools.js.map +1 -0
- package/dist/prompt-mode.d.ts +1 -1
- package/dist/prompt-mode.js +7 -2
- package/dist/prompt-mode.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 +20 -0
- package/dist/runner.js +192 -16
- package/dist/runner.js.map +1 -1
- package/dist/safety.d.ts +54 -4
- package/dist/safety.js +186 -5
- package/dist/safety.js.map +1 -1
- package/dist/schema.d.ts +15 -7
- package/dist/schema.js +20 -0
- package/dist/schema.js.map +1 -1
- package/dist/server.d.ts +7 -1
- package/dist/server.js +451 -23
- package/dist/server.js.map +1 -1
- package/dist/session-log-stream.d.ts +18 -0
- package/dist/session-log-stream.js +566 -0
- package/dist/session-log-stream.js.map +1 -0
- package/dist/stdio-activity.d.ts +28 -0
- package/dist/stdio-activity.js +72 -0
- package/dist/stdio-activity.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/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,706 @@
|
|
|
1
|
+
import { createHash, randomUUID } from "node:crypto";
|
|
2
|
+
import { constants as fsConstants } from "node:fs";
|
|
3
|
+
import { chmod, lstat, mkdir, open, readFile, readdir, rename, rm, stat, } from "node:fs/promises";
|
|
4
|
+
import { dirname, join } from "node:path";
|
|
5
|
+
import { ACTIVITY_RESULT_FILENAME, ACTIVITY_STATE_FILENAME, ActivityIdSchema, ActivityStateReadSchema, ActivityStateV1Schema, ActivityStateV2Schema, ActivityStateV3Schema, DEFAULT_ACTIVITY_HEARTBEAT_INTERVAL_MS, DEFAULT_ACTIVITY_MAX_AGE_MS, DEFAULT_MAX_ACTIVITY_ENTRIES, DEFAULT_MAX_ACTIVITY_RESULT_BYTES, DEFAULT_MAX_ACTIVITY_TOTAL_BYTES, MAX_ACTIVITY_STATE_BYTES, } from "../clinkx-workflows/dist/dashboard/activity-contract.js";
|
|
6
|
+
import { createDashboardActivityReader } from "../clinkx-workflows/dist/dashboard/activity-reader.js";
|
|
7
|
+
import { deriveActivityGeneration } from "../clinkx-workflows/dist/dashboard/generation.js";
|
|
8
|
+
import { removeSessionLogGeneration } from "../clinkx-workflows/dist/dashboard/session-log-retention.js";
|
|
9
|
+
import { createSessionLogGeneration, readSessionLogGeneration, } from "../clinkx-workflows/dist/dashboard/session-log-identity.js";
|
|
10
|
+
import { invocationAuditV2PersistenceEnabled, observedInvocationPersistenceEnabled, } from "../clinkx-workflows/dist/config.js";
|
|
11
|
+
import { resolveOpenedDescriptorPath } from "../clinkx-workflows/dist/contained-file.js";
|
|
12
|
+
import { logger } from "./logger.js";
|
|
13
|
+
export { ACTIVITY_RESULT_FILENAME, ACTIVITY_STATE_FILENAME, ActivityIdSchema, ActivityKindSchema, ActivityOutcomeKindSchema, ActivityPhaseSchema, ActivityResultReferenceSchema, ActivityStateReadSchema, ActivityStateV1Schema, ActivityStateV2Schema, ActivityStateV3Schema, ActivityTerminalStatusSchema, DEFAULT_ACTIVITY_HEARTBEAT_INTERVAL_MS, DEFAULT_ACTIVITY_MAX_AGE_MS, DEFAULT_MAX_ACTIVITY_ENTRIES, DEFAULT_MAX_ACTIVITY_RESULT_BYTES, DEFAULT_MAX_ACTIVITY_TOTAL_BYTES, MAX_ACTIVITY_STATE_BYTES, } from "../clinkx-workflows/dist/dashboard/activity-contract.js";
|
|
14
|
+
export const ACTIVITY_RETAIN_RESULT_ENV = "CLINKX_DASHBOARD_ACTIVITY_RETAIN_RESULT";
|
|
15
|
+
const SESSION_LOG_GENERATION_FILE_BYTES = 44;
|
|
16
|
+
const NOOP_OBSERVATION = Object.freeze({
|
|
17
|
+
async transition() { },
|
|
18
|
+
async observe() { },
|
|
19
|
+
async complete() { },
|
|
20
|
+
});
|
|
21
|
+
class UnsafeActivityDirectoryError extends Error {
|
|
22
|
+
}
|
|
23
|
+
async function inspectActivityDirectory(activityDir, activityId) {
|
|
24
|
+
let linked;
|
|
25
|
+
try {
|
|
26
|
+
linked = await lstat(activityDir);
|
|
27
|
+
}
|
|
28
|
+
catch (error) {
|
|
29
|
+
if (isFileSystemError(error, "ENOENT"))
|
|
30
|
+
return undefined;
|
|
31
|
+
throw error;
|
|
32
|
+
}
|
|
33
|
+
if (linked.isSymbolicLink() || !linked.isDirectory()) {
|
|
34
|
+
throw new UnsafeActivityDirectoryError();
|
|
35
|
+
}
|
|
36
|
+
let handle;
|
|
37
|
+
try {
|
|
38
|
+
handle = await open(activityDir, fsConstants.O_RDONLY |
|
|
39
|
+
(fsConstants.O_DIRECTORY ?? 0) |
|
|
40
|
+
(fsConstants.O_NOFOLLOW ?? 0));
|
|
41
|
+
}
|
|
42
|
+
catch {
|
|
43
|
+
throw new UnsafeActivityDirectoryError();
|
|
44
|
+
}
|
|
45
|
+
try {
|
|
46
|
+
const opened = await handle.stat({ bigint: true });
|
|
47
|
+
const canonicalPath = await resolveOpenedDescriptorPath(handle.fd, activityDir);
|
|
48
|
+
if (!opened.isDirectory() ||
|
|
49
|
+
opened.nlink === 0n ||
|
|
50
|
+
BigInt(linked.dev) !== opened.dev ||
|
|
51
|
+
BigInt(linked.ino) !== opened.ino ||
|
|
52
|
+
canonicalPath === undefined) {
|
|
53
|
+
throw new UnsafeActivityDirectoryError();
|
|
54
|
+
}
|
|
55
|
+
return {
|
|
56
|
+
activityId,
|
|
57
|
+
path: canonicalPath,
|
|
58
|
+
handle,
|
|
59
|
+
identity: { dev: opened.dev, ino: opened.ino },
|
|
60
|
+
localGeneration: deriveActivityGeneration(activityId, linked),
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
catch (error) {
|
|
64
|
+
await handle.close().catch(() => undefined);
|
|
65
|
+
throw error;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
async function verifyActivityDirectory(path, admitted) {
|
|
69
|
+
const linked = await lstat(path).catch(() => undefined);
|
|
70
|
+
const opened = await admitted.handle.stat({ bigint: true }).catch(() => undefined);
|
|
71
|
+
if (linked === undefined ||
|
|
72
|
+
opened === undefined ||
|
|
73
|
+
linked.isSymbolicLink() ||
|
|
74
|
+
!linked.isDirectory() ||
|
|
75
|
+
!opened.isDirectory() ||
|
|
76
|
+
opened.nlink === 0n ||
|
|
77
|
+
BigInt(linked.dev) !== admitted.identity.dev ||
|
|
78
|
+
BigInt(linked.ino) !== admitted.identity.ino ||
|
|
79
|
+
opened.dev !== admitted.identity.dev ||
|
|
80
|
+
opened.ino !== admitted.identity.ino ||
|
|
81
|
+
deriveActivityGeneration(admitted.activityId, linked) !==
|
|
82
|
+
admitted.localGeneration ||
|
|
83
|
+
await resolveOpenedDescriptorPath(admitted.handle.fd, path) !== path) {
|
|
84
|
+
throw new UnsafeActivityDirectoryError();
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
function captureActivityDirectoryIncarnation(admitted) {
|
|
88
|
+
return Object.freeze({
|
|
89
|
+
activityId: admitted.activityId,
|
|
90
|
+
path: admitted.path,
|
|
91
|
+
identity: admitted.identity,
|
|
92
|
+
localGeneration: admitted.localGeneration,
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
async function reopenActivityDirectory(incarnation) {
|
|
96
|
+
const admitted = await inspectActivityDirectory(incarnation.path, incarnation.activityId);
|
|
97
|
+
if (admitted === undefined)
|
|
98
|
+
return undefined;
|
|
99
|
+
if (admitted.path !== incarnation.path ||
|
|
100
|
+
admitted.identity.dev !== incarnation.identity.dev ||
|
|
101
|
+
admitted.identity.ino !== incarnation.identity.ino ||
|
|
102
|
+
admitted.localGeneration !== incarnation.localGeneration) {
|
|
103
|
+
await admitted.handle.close().catch(() => undefined);
|
|
104
|
+
throw new UnsafeActivityDirectoryError();
|
|
105
|
+
}
|
|
106
|
+
return admitted;
|
|
107
|
+
}
|
|
108
|
+
async function writeActivityFileAtomic(directory, filename, content) {
|
|
109
|
+
const admitted = await reopenActivityDirectory(directory);
|
|
110
|
+
if (admitted === undefined)
|
|
111
|
+
throw new UnsafeActivityDirectoryError();
|
|
112
|
+
try {
|
|
113
|
+
const filePath = join(admitted.path, filename);
|
|
114
|
+
const temporaryPath = `${filePath}.${randomUUID()}.tmp`;
|
|
115
|
+
const handle = await open(temporaryPath, "wx", 0o600);
|
|
116
|
+
try {
|
|
117
|
+
await verifyActivityDirectory(admitted.path, admitted);
|
|
118
|
+
await handle.writeFile(content);
|
|
119
|
+
await handle.sync();
|
|
120
|
+
await handle.chmod(0o600);
|
|
121
|
+
// Bind the commit, not merely the temp creation, to the short-lived
|
|
122
|
+
// descriptor re-admitted for this exact incarnation.
|
|
123
|
+
await verifyActivityDirectory(admitted.path, admitted);
|
|
124
|
+
await rename(temporaryPath, filePath);
|
|
125
|
+
}
|
|
126
|
+
catch (error) {
|
|
127
|
+
await rm(temporaryPath, { force: true }).catch(() => undefined);
|
|
128
|
+
throw error;
|
|
129
|
+
}
|
|
130
|
+
finally {
|
|
131
|
+
await handle.close().catch(() => undefined);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
finally {
|
|
135
|
+
await admitted.handle.close().catch(() => undefined);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
function isFileSystemError(error, code) {
|
|
139
|
+
return typeof error === "object" && error !== null &&
|
|
140
|
+
"code" in error && error.code === code;
|
|
141
|
+
}
|
|
142
|
+
function serializedState(state) {
|
|
143
|
+
const parsed = state.schemaVersion === "clinkx-dashboard-activity-v3"
|
|
144
|
+
? ActivityStateV3Schema.parse(state)
|
|
145
|
+
: state.schemaVersion === "clinkx-dashboard-activity-v2"
|
|
146
|
+
? ActivityStateV2Schema.parse(state)
|
|
147
|
+
: ActivityStateV1Schema.parse(state);
|
|
148
|
+
const serialized = `${JSON.stringify(parsed, null, 2)}\n`;
|
|
149
|
+
if (Buffer.byteLength(serialized, "utf8") > MAX_ACTIVITY_STATE_BYTES) {
|
|
150
|
+
throw new Error("activity state exceeds the producer byte cap");
|
|
151
|
+
}
|
|
152
|
+
return serialized;
|
|
153
|
+
}
|
|
154
|
+
async function pruneActivities(rootDir, sessionLogRootDir, now, maxAgeMs, maxEntries, maxTotalBytes, reservedBytes, testHooks) {
|
|
155
|
+
const entries = await readdir(rootDir, { withFileTypes: true });
|
|
156
|
+
await Promise.all(entries.map(async (entry) => {
|
|
157
|
+
if (!entry.isDirectory() || !ActivityIdSchema.safeParse(entry.name).success) {
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
const activityDir = join(rootDir, entry.name);
|
|
161
|
+
let admitted;
|
|
162
|
+
try {
|
|
163
|
+
admitted = await inspectActivityDirectory(activityDir, entry.name);
|
|
164
|
+
if (admitted === undefined)
|
|
165
|
+
return;
|
|
166
|
+
const incarnation = captureActivityDirectoryIncarnation(admitted);
|
|
167
|
+
const parsed = ActivityStateReadSchema.safeParse(JSON.parse(await readFile(join(admitted.path, ACTIVITY_STATE_FILENAME), "utf8")));
|
|
168
|
+
await verifyActivityDirectory(admitted.path, admitted);
|
|
169
|
+
if (!parsed.success ||
|
|
170
|
+
parsed.data.phase !== "terminal" ||
|
|
171
|
+
parsed.data.completedAt === undefined) {
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
if (now.getTime() - Date.parse(parsed.data.completedAt) > maxAgeMs) {
|
|
175
|
+
await pruneActivityDirectory({
|
|
176
|
+
sessionLogRootDir,
|
|
177
|
+
activityId: entry.name,
|
|
178
|
+
incarnation,
|
|
179
|
+
testHooks,
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
catch (error) {
|
|
184
|
+
if (error.code !== "ENOENT") {
|
|
185
|
+
logger.debug({
|
|
186
|
+
activity_id: entry.name,
|
|
187
|
+
err: error instanceof Error ? error.message : String(error),
|
|
188
|
+
}, "activity journal could not inspect a retention candidate");
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
finally {
|
|
192
|
+
await admitted?.handle.close().catch(() => undefined);
|
|
193
|
+
}
|
|
194
|
+
}));
|
|
195
|
+
const survivors = await readdir(rootDir, { withFileTypes: true });
|
|
196
|
+
const terminal = [];
|
|
197
|
+
let totalBytes = 0;
|
|
198
|
+
for (const entry of survivors) {
|
|
199
|
+
if (!entry.isDirectory())
|
|
200
|
+
continue;
|
|
201
|
+
const activityDir = join(rootDir, entry.name);
|
|
202
|
+
let admitted;
|
|
203
|
+
let activityBytes = 0;
|
|
204
|
+
let bytesBoundToIncarnation = false;
|
|
205
|
+
if (!ActivityIdSchema.safeParse(entry.name).success) {
|
|
206
|
+
try {
|
|
207
|
+
for (const child of await readdir(activityDir, { withFileTypes: true })) {
|
|
208
|
+
if (!child.isFile())
|
|
209
|
+
continue;
|
|
210
|
+
activityBytes += (await stat(join(activityDir, child.name))).size;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
catch {
|
|
214
|
+
// An unreadable non-activity directory still occupies entry capacity.
|
|
215
|
+
}
|
|
216
|
+
totalBytes += activityBytes;
|
|
217
|
+
continue;
|
|
218
|
+
}
|
|
219
|
+
try {
|
|
220
|
+
admitted = await inspectActivityDirectory(activityDir, entry.name);
|
|
221
|
+
if (admitted === undefined)
|
|
222
|
+
continue;
|
|
223
|
+
const incarnation = captureActivityDirectoryIncarnation(admitted);
|
|
224
|
+
for (const child of await readdir(admitted.path, { withFileTypes: true })) {
|
|
225
|
+
if (!child.isFile())
|
|
226
|
+
continue;
|
|
227
|
+
activityBytes += (await stat(join(admitted.path, child.name))).size;
|
|
228
|
+
}
|
|
229
|
+
await verifyActivityDirectory(admitted.path, admitted);
|
|
230
|
+
totalBytes += activityBytes;
|
|
231
|
+
bytesBoundToIncarnation = true;
|
|
232
|
+
const parsed = ActivityStateReadSchema.safeParse(JSON.parse(await readFile(join(admitted.path, ACTIVITY_STATE_FILENAME), "utf8")));
|
|
233
|
+
await verifyActivityDirectory(admitted.path, admitted);
|
|
234
|
+
if (parsed.success &&
|
|
235
|
+
parsed.data.phase === "terminal" &&
|
|
236
|
+
parsed.data.completedAt !== undefined) {
|
|
237
|
+
terminal.push({
|
|
238
|
+
activityId: entry.name,
|
|
239
|
+
completedAtMs: Date.parse(parsed.data.completedAt),
|
|
240
|
+
bytes: activityBytes,
|
|
241
|
+
incarnation,
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
catch {
|
|
246
|
+
// Unreadable entries are not producer-owned retention candidates. If
|
|
247
|
+
// identity churn prevented a bound scan, account the current path only.
|
|
248
|
+
if (!bytesBoundToIncarnation) {
|
|
249
|
+
activityBytes = 0;
|
|
250
|
+
try {
|
|
251
|
+
for (const child of await readdir(activityDir, { withFileTypes: true })) {
|
|
252
|
+
if (!child.isFile())
|
|
253
|
+
continue;
|
|
254
|
+
activityBytes += (await stat(join(activityDir, child.name))).size;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
catch {
|
|
258
|
+
// Entry capacity still prevents unsafe admission at the count cap.
|
|
259
|
+
}
|
|
260
|
+
totalBytes += activityBytes;
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
finally {
|
|
264
|
+
await admitted?.handle.close().catch(() => undefined);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
terminal.sort((left, right) => left.completedAtMs - right.completedAtMs);
|
|
268
|
+
let entryCount = survivors.filter((entry) => entry.isDirectory()).length;
|
|
269
|
+
while (entryCount >= maxEntries && terminal.length > 0) {
|
|
270
|
+
const victim = terminal.shift();
|
|
271
|
+
if (await pruneActivityDirectory({
|
|
272
|
+
sessionLogRootDir,
|
|
273
|
+
activityId: victim.activityId,
|
|
274
|
+
incarnation: victim.incarnation,
|
|
275
|
+
testHooks,
|
|
276
|
+
})) {
|
|
277
|
+
entryCount -= 1;
|
|
278
|
+
totalBytes -= victim.bytes;
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
while (totalBytes + reservedBytes > maxTotalBytes &&
|
|
282
|
+
terminal.length > 0) {
|
|
283
|
+
const victim = terminal.shift();
|
|
284
|
+
if (await pruneActivityDirectory({
|
|
285
|
+
sessionLogRootDir,
|
|
286
|
+
activityId: victim.activityId,
|
|
287
|
+
incarnation: victim.incarnation,
|
|
288
|
+
testHooks,
|
|
289
|
+
})) {
|
|
290
|
+
entryCount -= 1;
|
|
291
|
+
totalBytes -= victim.bytes;
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
return entryCount < maxEntries &&
|
|
295
|
+
totalBytes + reservedBytes <= maxTotalBytes;
|
|
296
|
+
}
|
|
297
|
+
async function pruneActivityDirectory(input) {
|
|
298
|
+
const removed = await removeActivityDirectoryIncarnation({
|
|
299
|
+
activityId: input.activityId,
|
|
300
|
+
incarnation: input.incarnation,
|
|
301
|
+
reason: "retention",
|
|
302
|
+
testHooks: input.testHooks,
|
|
303
|
+
});
|
|
304
|
+
if (removed.kind !== "removed") {
|
|
305
|
+
logger.debug({ activity_id: input.activityId, removal: removed.kind }, "activity retention skipped because exact generation was unavailable");
|
|
306
|
+
return false;
|
|
307
|
+
}
|
|
308
|
+
await cleanupActivitySessionLog({
|
|
309
|
+
sessionLogRootDir: input.sessionLogRootDir,
|
|
310
|
+
activityId: input.activityId,
|
|
311
|
+
localGeneration: input.incarnation.localGeneration,
|
|
312
|
+
sessionLogIdentity: removed.sessionLogIdentity,
|
|
313
|
+
});
|
|
314
|
+
return true;
|
|
315
|
+
}
|
|
316
|
+
async function removeActivityDirectoryIncarnation(input) {
|
|
317
|
+
let admitted;
|
|
318
|
+
try {
|
|
319
|
+
admitted = await reopenActivityDirectory(input.incarnation);
|
|
320
|
+
if (admitted === undefined)
|
|
321
|
+
return { kind: "missing" };
|
|
322
|
+
const activityDir = admitted.path;
|
|
323
|
+
const quarantinePath = join(dirname(activityDir), `.retired-${input.activityId}-${randomUUID()}`);
|
|
324
|
+
await verifyActivityDirectory(activityDir, admitted);
|
|
325
|
+
await input.testHooks.beforeActivityDirectoryQuarantine?.(input.activityId, input.reason);
|
|
326
|
+
try {
|
|
327
|
+
await rename(activityDir, quarantinePath);
|
|
328
|
+
}
|
|
329
|
+
catch (error) {
|
|
330
|
+
return isFileSystemError(error, "ENOENT")
|
|
331
|
+
? { kind: "missing" }
|
|
332
|
+
: { kind: "unavailable" };
|
|
333
|
+
}
|
|
334
|
+
try {
|
|
335
|
+
await verifyActivityDirectory(quarantinePath, admitted);
|
|
336
|
+
}
|
|
337
|
+
catch (error) {
|
|
338
|
+
// A same-ID replacement was moved instead of the admitted incarnation.
|
|
339
|
+
// Restore it only while the public name remains free; never delete it.
|
|
340
|
+
if (await lstat(activityDir).catch(() => undefined) === undefined) {
|
|
341
|
+
await rename(quarantinePath, activityDir).catch(() => undefined);
|
|
342
|
+
}
|
|
343
|
+
throw error;
|
|
344
|
+
}
|
|
345
|
+
const sessionLogIdentity = await readSessionLogGeneration(quarantinePath);
|
|
346
|
+
await verifyActivityDirectory(quarantinePath, admitted);
|
|
347
|
+
try {
|
|
348
|
+
await rm(quarantinePath, { recursive: true, force: false });
|
|
349
|
+
}
|
|
350
|
+
catch (error) {
|
|
351
|
+
if (await lstat(activityDir).catch(() => undefined) === undefined) {
|
|
352
|
+
await rename(quarantinePath, activityDir).catch(() => undefined);
|
|
353
|
+
}
|
|
354
|
+
return isFileSystemError(error, "ENOENT")
|
|
355
|
+
? { kind: "unsafe" }
|
|
356
|
+
: { kind: "unavailable" };
|
|
357
|
+
}
|
|
358
|
+
return { kind: "removed", sessionLogIdentity };
|
|
359
|
+
}
|
|
360
|
+
catch (error) {
|
|
361
|
+
return error instanceof UnsafeActivityDirectoryError
|
|
362
|
+
? { kind: "unsafe" }
|
|
363
|
+
: { kind: "unavailable" };
|
|
364
|
+
}
|
|
365
|
+
finally {
|
|
366
|
+
await admitted?.handle.close().catch(() => undefined);
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
async function cleanupActivitySessionLog(input) {
|
|
370
|
+
const sessionLogGeneration = input.sessionLogIdentity.kind === "available"
|
|
371
|
+
? input.sessionLogIdentity.sessionLogGeneration
|
|
372
|
+
: input.sessionLogIdentity.kind === "legacy"
|
|
373
|
+
? input.localGeneration
|
|
374
|
+
: undefined;
|
|
375
|
+
if (sessionLogGeneration === undefined) {
|
|
376
|
+
logger.warn({ activity_id: input.activityId }, "activity parent pruned but portable session-log identity was unsafe");
|
|
377
|
+
return;
|
|
378
|
+
}
|
|
379
|
+
try {
|
|
380
|
+
const cleanup = await removeSessionLogGeneration({
|
|
381
|
+
rootDir: input.sessionLogRootDir,
|
|
382
|
+
family: "activity",
|
|
383
|
+
generation: sessionLogGeneration,
|
|
384
|
+
});
|
|
385
|
+
if (cleanup.kind === "unsafe" || cleanup.kind === "unavailable") {
|
|
386
|
+
logger.warn({ activity_id: input.activityId, cleanup: cleanup.kind }, "activity parent pruned but exact session-log cleanup was unavailable");
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
catch {
|
|
390
|
+
logger.warn({ activity_id: input.activityId }, "activity parent pruned but exact session-log cleanup failed");
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
function truncateUtf8(text, maxBytes) {
|
|
394
|
+
const source = Buffer.from(text, "utf8");
|
|
395
|
+
if (source.byteLength <= maxBytes) {
|
|
396
|
+
return { bytes: source, truncated: false };
|
|
397
|
+
}
|
|
398
|
+
const decoder = new TextDecoder("utf-8", { fatal: true });
|
|
399
|
+
let end = maxBytes;
|
|
400
|
+
while (end > 0) {
|
|
401
|
+
const candidate = source.subarray(0, end);
|
|
402
|
+
try {
|
|
403
|
+
decoder.decode(candidate);
|
|
404
|
+
return { bytes: candidate, truncated: true };
|
|
405
|
+
}
|
|
406
|
+
catch {
|
|
407
|
+
end -= 1;
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
return { bytes: Buffer.alloc(0), truncated: true };
|
|
411
|
+
}
|
|
412
|
+
class FileActivityObservation {
|
|
413
|
+
activityDirectory;
|
|
414
|
+
options;
|
|
415
|
+
identity;
|
|
416
|
+
state;
|
|
417
|
+
writeChain = Promise.resolve();
|
|
418
|
+
terminal = false;
|
|
419
|
+
heartbeat;
|
|
420
|
+
constructor(activityDirectory, options, initialState, identity) {
|
|
421
|
+
this.activityDirectory = activityDirectory;
|
|
422
|
+
this.options = options;
|
|
423
|
+
this.identity = identity;
|
|
424
|
+
this.state = initialState;
|
|
425
|
+
if (options.heartbeatIntervalMs > 0) {
|
|
426
|
+
this.heartbeat = setInterval(() => {
|
|
427
|
+
void this.enqueue(async () => {
|
|
428
|
+
if (this.terminal)
|
|
429
|
+
return;
|
|
430
|
+
const timestamp = this.options.now().toISOString();
|
|
431
|
+
this.state = {
|
|
432
|
+
...this.state,
|
|
433
|
+
stateUpdatedAt: timestamp,
|
|
434
|
+
leaseUpdatedAt: timestamp,
|
|
435
|
+
};
|
|
436
|
+
await this.persistState();
|
|
437
|
+
});
|
|
438
|
+
}, options.heartbeatIntervalMs);
|
|
439
|
+
this.heartbeat.unref();
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
async transition(phase) {
|
|
443
|
+
await this.enqueue(async () => {
|
|
444
|
+
if (this.terminal)
|
|
445
|
+
return;
|
|
446
|
+
const timestamp = this.options.now().toISOString();
|
|
447
|
+
this.state = {
|
|
448
|
+
...this.state,
|
|
449
|
+
phase,
|
|
450
|
+
stateUpdatedAt: timestamp,
|
|
451
|
+
leaseUpdatedAt: timestamp,
|
|
452
|
+
};
|
|
453
|
+
await this.persistState();
|
|
454
|
+
});
|
|
455
|
+
}
|
|
456
|
+
async observe(observed) {
|
|
457
|
+
await this.enqueue(async () => {
|
|
458
|
+
if (this.terminal)
|
|
459
|
+
return;
|
|
460
|
+
if (!observedInvocationPersistenceEnabled())
|
|
461
|
+
return;
|
|
462
|
+
// The first observation is sticky; later conflicting ones are ignored.
|
|
463
|
+
if (this.observedInvocationRecorded())
|
|
464
|
+
return;
|
|
465
|
+
try {
|
|
466
|
+
this.state = this.withObservedInvocation(this.state, observed);
|
|
467
|
+
await this.persistState();
|
|
468
|
+
}
|
|
469
|
+
catch (error) {
|
|
470
|
+
logger.warn({
|
|
471
|
+
activity_id: this.state.activityId,
|
|
472
|
+
err: error instanceof Error ? error.message : String(error),
|
|
473
|
+
}, "activity observed-invocation persistence failed; clink execution remains authoritative");
|
|
474
|
+
}
|
|
475
|
+
});
|
|
476
|
+
}
|
|
477
|
+
async complete(completion) {
|
|
478
|
+
await this.enqueue(async () => {
|
|
479
|
+
if (this.terminal)
|
|
480
|
+
return;
|
|
481
|
+
this.terminal = true;
|
|
482
|
+
if (this.heartbeat !== undefined) {
|
|
483
|
+
clearInterval(this.heartbeat);
|
|
484
|
+
this.heartbeat = undefined;
|
|
485
|
+
}
|
|
486
|
+
let result;
|
|
487
|
+
try {
|
|
488
|
+
result = await this.persistResult(completion.resultText);
|
|
489
|
+
}
|
|
490
|
+
catch (error) {
|
|
491
|
+
logger.warn({
|
|
492
|
+
activity_id: this.state.activityId,
|
|
493
|
+
err: error instanceof Error ? error.message : String(error),
|
|
494
|
+
}, "activity result persistence failed; committing terminal metadata without content");
|
|
495
|
+
}
|
|
496
|
+
const timestamp = this.options.now().toISOString();
|
|
497
|
+
let nextState = {
|
|
498
|
+
...this.state,
|
|
499
|
+
phase: "terminal",
|
|
500
|
+
status: completion.status,
|
|
501
|
+
stateUpdatedAt: timestamp,
|
|
502
|
+
completedAt: timestamp,
|
|
503
|
+
outcome: { kind: completion.outcomeKind },
|
|
504
|
+
...(result === undefined ? {} : { result }),
|
|
505
|
+
};
|
|
506
|
+
if (completion.observedInvocation !== undefined &&
|
|
507
|
+
observedInvocationPersistenceEnabled() &&
|
|
508
|
+
!this.observedInvocationRecorded()) {
|
|
509
|
+
try {
|
|
510
|
+
nextState = this.withObservedInvocation(nextState, completion.observedInvocation);
|
|
511
|
+
}
|
|
512
|
+
catch (error) {
|
|
513
|
+
logger.warn({
|
|
514
|
+
activity_id: this.state.activityId,
|
|
515
|
+
err: error instanceof Error ? error.message : String(error),
|
|
516
|
+
}, "activity observed-invocation persistence failed; committing terminal metadata without it");
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
this.state = nextState;
|
|
520
|
+
await this.persistState();
|
|
521
|
+
});
|
|
522
|
+
}
|
|
523
|
+
observedInvocationRecorded() {
|
|
524
|
+
return this.state.schemaVersion === "clinkx-dashboard-activity-v3" &&
|
|
525
|
+
this.state.observedInvocation !== undefined;
|
|
526
|
+
}
|
|
527
|
+
/**
|
|
528
|
+
* Best-effort V3 upgrade carrying any existing pre-dispatch audit (a V2
|
|
529
|
+
* begin) plus the runtime observation; a V1 begin upgrades with the
|
|
530
|
+
* observation alone.
|
|
531
|
+
*/
|
|
532
|
+
withObservedInvocation(state, observed) {
|
|
533
|
+
return ActivityStateV3Schema.parse({
|
|
534
|
+
...state,
|
|
535
|
+
schemaVersion: "clinkx-dashboard-activity-v3",
|
|
536
|
+
observedInvocation: observed,
|
|
537
|
+
});
|
|
538
|
+
}
|
|
539
|
+
async enqueue(task) {
|
|
540
|
+
const next = this.writeChain.then(task, task).catch((error) => {
|
|
541
|
+
logger.warn({
|
|
542
|
+
activity_id: this.state.activityId,
|
|
543
|
+
err: error instanceof Error ? error.message : String(error),
|
|
544
|
+
}, "activity journal write failed; clink execution remains authoritative");
|
|
545
|
+
});
|
|
546
|
+
this.writeChain = next;
|
|
547
|
+
await next;
|
|
548
|
+
}
|
|
549
|
+
async persistResult(resultText) {
|
|
550
|
+
if (!this.options.retainResult || resultText === undefined)
|
|
551
|
+
return undefined;
|
|
552
|
+
const { bytes, truncated } = truncateUtf8(resultText, this.options.maxResultBytes);
|
|
553
|
+
await writeActivityFileAtomic(this.activityDirectory, ACTIVITY_RESULT_FILENAME, bytes);
|
|
554
|
+
return {
|
|
555
|
+
path: ACTIVITY_RESULT_FILENAME,
|
|
556
|
+
bytes: bytes.byteLength,
|
|
557
|
+
sha256: createHash("sha256").update(bytes).digest("hex"),
|
|
558
|
+
truncated,
|
|
559
|
+
};
|
|
560
|
+
}
|
|
561
|
+
async persistState() {
|
|
562
|
+
await writeActivityFileAtomic(this.activityDirectory, ACTIVITY_STATE_FILENAME, serializedState(this.state));
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
export function createActivityJournal(options) {
|
|
566
|
+
const activityIdentityReader = createDashboardActivityReader();
|
|
567
|
+
const sessionLogRootDir = options.sessionLogRootDir ??
|
|
568
|
+
join(options.rootDir, "..", "session-logs");
|
|
569
|
+
const now = options.now ?? (() => new Date());
|
|
570
|
+
const persistInvocationAuditV2 = invocationAuditV2PersistenceEnabled();
|
|
571
|
+
const testHooks = options.testHooks ?? {};
|
|
572
|
+
const maxResultBytes = Number.isSafeInteger(options.maxResultBytes) &&
|
|
573
|
+
(options.maxResultBytes ?? 0) > 0
|
|
574
|
+
? Math.min(options.maxResultBytes, DEFAULT_MAX_ACTIVITY_RESULT_BYTES)
|
|
575
|
+
: DEFAULT_MAX_ACTIVITY_RESULT_BYTES;
|
|
576
|
+
const normalized = {
|
|
577
|
+
retainResult: options.retainResult ?? false,
|
|
578
|
+
maxResultBytes,
|
|
579
|
+
heartbeatIntervalMs: options.heartbeatIntervalMs ?? DEFAULT_ACTIVITY_HEARTBEAT_INTERVAL_MS,
|
|
580
|
+
now,
|
|
581
|
+
};
|
|
582
|
+
const maxAgeMs = options.maxAgeMs ?? DEFAULT_ACTIVITY_MAX_AGE_MS;
|
|
583
|
+
const maxEntries = options.maxEntries ?? DEFAULT_MAX_ACTIVITY_ENTRIES;
|
|
584
|
+
const maxTotalBytes = options.maxTotalBytes ?? DEFAULT_MAX_ACTIVITY_TOTAL_BYTES;
|
|
585
|
+
const reservedBytes = MAX_ACTIVITY_STATE_BYTES +
|
|
586
|
+
SESSION_LOG_GENERATION_FILE_BYTES +
|
|
587
|
+
(normalized.retainResult ? normalized.maxResultBytes : 0);
|
|
588
|
+
let admissionChain = Promise.resolve();
|
|
589
|
+
async function beginOne(input) {
|
|
590
|
+
let claimedDirectory;
|
|
591
|
+
try {
|
|
592
|
+
const parsed = ActivityIdSchema.parse(input.activityId);
|
|
593
|
+
const admissionTime = now();
|
|
594
|
+
const timestamp = admissionTime.toISOString();
|
|
595
|
+
const commonState = {
|
|
596
|
+
activityId: parsed,
|
|
597
|
+
kind: input.kind,
|
|
598
|
+
phase: "resolving",
|
|
599
|
+
status: "running",
|
|
600
|
+
adapter: input.adapter,
|
|
601
|
+
role: input.role,
|
|
602
|
+
startedAt: timestamp,
|
|
603
|
+
stateUpdatedAt: timestamp,
|
|
604
|
+
leaseUpdatedAt: timestamp,
|
|
605
|
+
...(input.projectFolders === undefined || input.projectFolders.length === 0
|
|
606
|
+
? {}
|
|
607
|
+
: { projectFolders: [...input.projectFolders] }),
|
|
608
|
+
};
|
|
609
|
+
const initialState = !persistInvocationAuditV2 || input.invocation === undefined
|
|
610
|
+
? ActivityStateV1Schema.parse({
|
|
611
|
+
schemaVersion: "clinkx-dashboard-activity-v1",
|
|
612
|
+
...commonState,
|
|
613
|
+
})
|
|
614
|
+
: ActivityStateV2Schema.parse({
|
|
615
|
+
schemaVersion: "clinkx-dashboard-activity-v2",
|
|
616
|
+
...commonState,
|
|
617
|
+
invocation: input.invocation,
|
|
618
|
+
});
|
|
619
|
+
// Admission is transactional from this point forward: validate both the
|
|
620
|
+
// complete schema and the producer byte cap before mkdir or retention can
|
|
621
|
+
// mutate observable state.
|
|
622
|
+
const initialStateBytes = serializedState(initialState);
|
|
623
|
+
await mkdir(options.rootDir, { recursive: true, mode: 0o700 });
|
|
624
|
+
await chmod(options.rootDir, 0o700);
|
|
625
|
+
try {
|
|
626
|
+
const admitted = await pruneActivities(options.rootDir, sessionLogRootDir, admissionTime, maxAgeMs, maxEntries, maxTotalBytes, reservedBytes, testHooks);
|
|
627
|
+
if (!admitted) {
|
|
628
|
+
logger.warn({ activity_id: input.activityId }, "activity journal capacity is occupied by live or unreadable records; observation disabled");
|
|
629
|
+
return NOOP_OBSERVATION;
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
catch (error) {
|
|
633
|
+
logger.warn({
|
|
634
|
+
activity_id: input.activityId,
|
|
635
|
+
err: error instanceof Error ? error.message : String(error),
|
|
636
|
+
}, "activity journal pruning failed; observation disabled");
|
|
637
|
+
return NOOP_OBSERVATION;
|
|
638
|
+
}
|
|
639
|
+
const activityDir = join(options.rootDir, parsed);
|
|
640
|
+
await mkdir(activityDir, { mode: 0o700 });
|
|
641
|
+
const admittedDirectory = await inspectActivityDirectory(activityDir, parsed);
|
|
642
|
+
if (admittedDirectory === undefined) {
|
|
643
|
+
throw new Error("activity journal directory identity unavailable");
|
|
644
|
+
}
|
|
645
|
+
claimedDirectory = captureActivityDirectoryIncarnation(admittedDirectory);
|
|
646
|
+
const createdSessionLogGeneration = await (async () => {
|
|
647
|
+
try {
|
|
648
|
+
await admittedDirectory.handle.chmod(0o700);
|
|
649
|
+
await verifyActivityDirectory(admittedDirectory.path, admittedDirectory);
|
|
650
|
+
const generation = await createSessionLogGeneration(admittedDirectory.path);
|
|
651
|
+
await verifyActivityDirectory(admittedDirectory.path, admittedDirectory);
|
|
652
|
+
return generation;
|
|
653
|
+
}
|
|
654
|
+
finally {
|
|
655
|
+
await admittedDirectory.handle.close().catch(() => undefined);
|
|
656
|
+
}
|
|
657
|
+
})();
|
|
658
|
+
await writeActivityFileAtomic(claimedDirectory, ACTIVITY_STATE_FILENAME, initialStateBytes);
|
|
659
|
+
const identity = await activityIdentityReader.resolveCurrent(options.rootDir, parsed);
|
|
660
|
+
if (identity.kind !== "resolved" ||
|
|
661
|
+
identity.activityGeneration !== claimedDirectory.localGeneration) {
|
|
662
|
+
throw new Error("activity journal directory identity unavailable");
|
|
663
|
+
}
|
|
664
|
+
return new FileActivityObservation(claimedDirectory, normalized, initialState, Object.freeze({
|
|
665
|
+
activityId: parsed,
|
|
666
|
+
activityGeneration: createdSessionLogGeneration,
|
|
667
|
+
}));
|
|
668
|
+
}
|
|
669
|
+
catch (error) {
|
|
670
|
+
if (claimedDirectory !== undefined) {
|
|
671
|
+
try {
|
|
672
|
+
const removed = await removeActivityDirectoryIncarnation({
|
|
673
|
+
activityId: claimedDirectory.activityId,
|
|
674
|
+
incarnation: claimedDirectory,
|
|
675
|
+
reason: "admission_cleanup",
|
|
676
|
+
testHooks,
|
|
677
|
+
});
|
|
678
|
+
if (removed.kind === "removed") {
|
|
679
|
+
await cleanupActivitySessionLog({
|
|
680
|
+
sessionLogRootDir,
|
|
681
|
+
activityId: claimedDirectory.activityId,
|
|
682
|
+
localGeneration: claimedDirectory.localGeneration,
|
|
683
|
+
sessionLogIdentity: removed.sessionLogIdentity,
|
|
684
|
+
});
|
|
685
|
+
}
|
|
686
|
+
}
|
|
687
|
+
catch {
|
|
688
|
+
// Cleanup is best-effort, but never widens beyond the exact incarnation.
|
|
689
|
+
}
|
|
690
|
+
}
|
|
691
|
+
logger.warn({
|
|
692
|
+
activity_id: input.activityId,
|
|
693
|
+
err: error instanceof Error ? error.message : String(error),
|
|
694
|
+
}, "activity journal start failed; clink execution remains authoritative");
|
|
695
|
+
return NOOP_OBSERVATION;
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
return {
|
|
699
|
+
begin(input) {
|
|
700
|
+
const next = admissionChain.then(() => beginOne(input), () => beginOne(input));
|
|
701
|
+
admissionChain = next.then(() => undefined, () => undefined);
|
|
702
|
+
return next;
|
|
703
|
+
},
|
|
704
|
+
};
|
|
705
|
+
}
|
|
706
|
+
//# sourceMappingURL=activity-journal.js.map
|