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
|
@@ -1,100 +1,252 @@
|
|
|
1
|
-
import { CancellationError } from "../errors.js";
|
|
1
|
+
import { CancellationError, InvalidParamsError } from "../errors.js";
|
|
2
2
|
import { executePipeline } from "../pipeline.js";
|
|
3
|
+
import { sanitizeDelegateFailureText } from "./diagnostics.js";
|
|
4
|
+
// A corrective retry only makes sense when enough of the end-to-end ceiling is
|
|
5
|
+
// left for a provider to actually answer; below this it would just time out.
|
|
6
|
+
export const DELEGATE_CORRECTIVE_RETRY_MIN_REMAINING_SECONDS = 30;
|
|
7
|
+
export const DELEGATE_CORRECTIVE_SUFFIX_MAX_CHARS = 1500;
|
|
8
|
+
export const DELEGATE_CORRECTIVE_RETRY_FAILURE_SUFFIX = "(after 1 corrective JSON retry)";
|
|
9
|
+
const CORRECTIVE_RETRY_ELIGIBLE_VIOLATIONS = new Set([
|
|
10
|
+
"invalid_json",
|
|
11
|
+
"non_object_json",
|
|
12
|
+
"json_salvaged",
|
|
13
|
+
"json_block_count",
|
|
14
|
+
"raw_fallback",
|
|
15
|
+
]);
|
|
16
|
+
// A truncated or killed response is not a formatting mistake the provider can
|
|
17
|
+
// correct by being asked again; retrying would only burn the remaining budget.
|
|
18
|
+
const CORRECTIVE_RETRY_BLOCKING_VIOLATIONS = new Set([
|
|
19
|
+
"capture_truncated",
|
|
20
|
+
"response_truncated",
|
|
21
|
+
"terminated",
|
|
22
|
+
]);
|
|
23
|
+
const PROVIDER_ERROR_SNIPPET_MAX_CHARS = 200;
|
|
3
24
|
export async function runContextBuilderDelegateCall(input) {
|
|
4
25
|
const child = new AbortController();
|
|
5
|
-
|
|
6
|
-
|
|
26
|
+
const state = {
|
|
27
|
+
timedOut: false,
|
|
28
|
+
parentCancelled: input.signal?.aborted === true,
|
|
29
|
+
};
|
|
7
30
|
const timeoutMs = Math.max(0, Math.floor(input.timeout_seconds * 1_000));
|
|
31
|
+
// One deadline covers both attempts: delegate.timeout_seconds is an
|
|
32
|
+
// end-to-end ceiling, so a retry only gets what the first attempt left.
|
|
33
|
+
const deadlineMs = Date.now() + timeoutMs;
|
|
8
34
|
const timeout = setTimeout(() => {
|
|
9
|
-
timedOut = true;
|
|
35
|
+
state.timedOut = true;
|
|
10
36
|
child.abort();
|
|
11
37
|
}, timeoutMs);
|
|
12
38
|
const abortFromParent = () => {
|
|
13
|
-
parentCancelled = true;
|
|
39
|
+
state.parentCancelled = true;
|
|
14
40
|
child.abort();
|
|
15
41
|
};
|
|
16
|
-
if (parentCancelled) {
|
|
42
|
+
if (state.parentCancelled) {
|
|
17
43
|
child.abort();
|
|
18
44
|
}
|
|
19
45
|
else {
|
|
20
46
|
input.signal?.addEventListener("abort", abortFromParent, { once: true });
|
|
21
47
|
}
|
|
48
|
+
try {
|
|
49
|
+
const first = await runDelegateAttempt(input, input.prompt, input.timeout_seconds, input.sessionLogOwner, child.signal, state);
|
|
50
|
+
if (first.result.ok || first.correctiveViolations == null) {
|
|
51
|
+
return first.result;
|
|
52
|
+
}
|
|
53
|
+
const remainingSeconds = (deadlineMs - Date.now()) / 1_000;
|
|
54
|
+
if (remainingSeconds < DELEGATE_CORRECTIVE_RETRY_MIN_REMAINING_SECONDS) {
|
|
55
|
+
return first.result;
|
|
56
|
+
}
|
|
57
|
+
if (state.parentCancelled) {
|
|
58
|
+
throw new CancellationError();
|
|
59
|
+
}
|
|
60
|
+
if (state.timedOut) {
|
|
61
|
+
return failure("timeout", "context_builder delegate call timed out");
|
|
62
|
+
}
|
|
63
|
+
const second = await runDelegateAttempt(input, `${input.prompt}${buildCorrectiveSuffix(first.correctiveViolations)}`, remainingSeconds, withAttempt(input.sessionLogOwner, 2), child.signal, state);
|
|
64
|
+
if (second.result.ok) {
|
|
65
|
+
return {
|
|
66
|
+
...second.result,
|
|
67
|
+
corrective_retry: { attempted: true, outcome: "succeeded" },
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
// A different-class second failure would otherwise hide why the corrective
|
|
71
|
+
// retry was scheduled; keep the first machine reason code (never provider
|
|
72
|
+
// text) as a breadcrumb. The retry suffix stays last.
|
|
73
|
+
const firstFailureBreadcrumb = first.result.reason === second.result.reason
|
|
74
|
+
? ""
|
|
75
|
+
: `; first_failure=${first.result.reason}`;
|
|
76
|
+
return {
|
|
77
|
+
...second.result,
|
|
78
|
+
message: `${second.result.message}${firstFailureBreadcrumb} ${DELEGATE_CORRECTIVE_RETRY_FAILURE_SUFFIX}`,
|
|
79
|
+
corrective_retry: { attempted: true, outcome: "failed" },
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
finally {
|
|
83
|
+
clearTimeout(timeout);
|
|
84
|
+
input.signal?.removeEventListener("abort", abortFromParent);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
async function runDelegateAttempt(input, prompt, timeoutSeconds, sessionLogOwner, signal, state) {
|
|
22
88
|
try {
|
|
23
89
|
const clinkInput = {
|
|
24
|
-
prompt
|
|
90
|
+
prompt,
|
|
25
91
|
cli_name: input.provider.cli_name,
|
|
26
92
|
role: input.provider.role,
|
|
27
93
|
expect_json: true,
|
|
28
94
|
max_response_chars: input.max_response_chars,
|
|
29
|
-
timeout_seconds:
|
|
95
|
+
timeout_seconds: timeoutSeconds,
|
|
30
96
|
debug: false,
|
|
31
97
|
debug_keep_artifacts: false,
|
|
98
|
+
...(input.provider.model === undefined
|
|
99
|
+
? {}
|
|
100
|
+
: { model: input.provider.model }),
|
|
101
|
+
...(input.provider.effort === undefined
|
|
102
|
+
? {}
|
|
103
|
+
: { effort: input.provider.effort }),
|
|
32
104
|
};
|
|
33
105
|
const pipeline = await executePipeline(clinkInput, input.registry, {
|
|
34
|
-
signal
|
|
106
|
+
signal,
|
|
35
107
|
jsonFidelity: "strict",
|
|
36
108
|
allowTimeoutBelowAdapter: true,
|
|
109
|
+
// An adapter's short startup idle must not undercut the delegate's own
|
|
110
|
+
// ceiling (slow-to-first-token providers on large packets).
|
|
111
|
+
minIdleStartupSeconds: timeoutSeconds,
|
|
112
|
+
...(sessionLogOwner == null ? {} : { sessionLogOwner }),
|
|
37
113
|
});
|
|
38
|
-
|
|
39
|
-
if (parentCancelled) {
|
|
40
|
-
throw new CancellationError();
|
|
41
|
-
}
|
|
42
|
-
if (termination?.timedOut === true || termination?.reason === "wall") {
|
|
43
|
-
return failure("timeout", "context_builder delegate call timed out", pipeline);
|
|
44
|
-
}
|
|
45
|
-
if (termination?.reason === "cancel") {
|
|
46
|
-
throw new CancellationError();
|
|
47
|
-
}
|
|
48
|
-
const fidelity = pipeline.jsonFidelity;
|
|
49
|
-
const strict = fidelity?.strict;
|
|
50
|
-
if (fidelity == null ||
|
|
51
|
-
fidelity.mode !== "strict" ||
|
|
52
|
-
strict?.acceptable !== true) {
|
|
53
|
-
return failure("strict_json_fidelity", strictJsonFidelityMessage(fidelity), pipeline);
|
|
54
|
-
}
|
|
55
|
-
if (pipeline.isError === true) {
|
|
56
|
-
return failure("pipeline_error", "context_builder delegate pipeline returned an error", pipeline);
|
|
57
|
-
}
|
|
58
|
-
const raw = pipeline.content[0]?.text?.trim() ?? "";
|
|
59
|
-
if (raw.length === 0 || raw === "(no output)") {
|
|
60
|
-
return failure("empty_output", "context_builder delegate returned empty output", pipeline);
|
|
61
|
-
}
|
|
62
|
-
try {
|
|
63
|
-
const parsed = JSON.parse(raw);
|
|
64
|
-
if (parsed == null ||
|
|
65
|
-
typeof parsed !== "object" ||
|
|
66
|
-
Array.isArray(parsed)) {
|
|
67
|
-
return failure("invalid_json", "context_builder delegate output must be one JSON object", pipeline);
|
|
68
|
-
}
|
|
69
|
-
return {
|
|
70
|
-
ok: true,
|
|
71
|
-
json: parsed,
|
|
72
|
-
raw,
|
|
73
|
-
pipeline,
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
catch {
|
|
77
|
-
return failure("invalid_json", "context_builder delegate output was not valid JSON", pipeline);
|
|
78
|
-
}
|
|
114
|
+
return classifyPipelineResult(pipeline, state);
|
|
79
115
|
}
|
|
80
116
|
catch (err) {
|
|
81
117
|
if (err instanceof CancellationError) {
|
|
82
|
-
if (parentCancelled) {
|
|
118
|
+
if (state.parentCancelled) {
|
|
83
119
|
throw err;
|
|
84
120
|
}
|
|
85
|
-
if (timedOut) {
|
|
86
|
-
return failure("timeout", "context_builder delegate call timed out");
|
|
121
|
+
if (state.timedOut) {
|
|
122
|
+
return notEligible(failure("timeout", "context_builder delegate call timed out"));
|
|
87
123
|
}
|
|
88
124
|
throw err;
|
|
89
125
|
}
|
|
90
|
-
|
|
126
|
+
// Unsupported invocation overrides are request errors, not delegate
|
|
127
|
+
// execution failures. Preserve the original error so handleToolError (or
|
|
128
|
+
// the workflow admission/dispatch bridge) emits MCP -32602 instead of
|
|
129
|
+
// degrading to pipeline_error and, under fallback, silently proceeding.
|
|
130
|
+
if (err instanceof InvalidParamsError) {
|
|
131
|
+
throw err;
|
|
132
|
+
}
|
|
133
|
+
return notEligible(failure("pipeline_error", err instanceof Error
|
|
91
134
|
? `context_builder delegate pipeline failed: ${err.message}`
|
|
92
|
-
: "context_builder delegate pipeline failed");
|
|
135
|
+
: "context_builder delegate pipeline failed"));
|
|
93
136
|
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
137
|
+
}
|
|
138
|
+
function classifyPipelineResult(pipeline, state) {
|
|
139
|
+
const fidelity = pipeline.jsonFidelity;
|
|
140
|
+
const termination = fidelity?.termination;
|
|
141
|
+
if (state.parentCancelled) {
|
|
142
|
+
throw new CancellationError();
|
|
143
|
+
}
|
|
144
|
+
// Termination outranks everything: the strict block also flags a killed run
|
|
145
|
+
// as a fidelity violation, which would otherwise mislabel an idle stall as a
|
|
146
|
+
// permanent JSON failure.
|
|
147
|
+
if (termination?.timedOut === true ||
|
|
148
|
+
termination?.reason === "wall" ||
|
|
149
|
+
termination?.reason === "idle") {
|
|
150
|
+
return notEligible(failure("timeout", termination.reason === "idle"
|
|
151
|
+
? "context_builder delegate call timed out (idle: provider produced no output)"
|
|
152
|
+
: "context_builder delegate call timed out", pipeline));
|
|
153
|
+
}
|
|
154
|
+
if (termination?.reason === "cancel") {
|
|
155
|
+
throw new CancellationError();
|
|
156
|
+
}
|
|
157
|
+
// A provider failure (bad model, billing error, non-zero exit) is flagged
|
|
158
|
+
// isError before the strict block runs; only a JSON-shaped primary failure
|
|
159
|
+
// belongs to strict fidelity.
|
|
160
|
+
if (fidelity?.preStrictIsError === true &&
|
|
161
|
+
fidelity.semanticFailureReason !== "invalid_json_output") {
|
|
162
|
+
return notEligible(failure("pipeline_error", providerErrorMessage(pipeline), pipeline));
|
|
163
|
+
}
|
|
164
|
+
const strict = fidelity?.strict;
|
|
165
|
+
if (fidelity == null ||
|
|
166
|
+
fidelity.mode !== "strict" ||
|
|
167
|
+
strict?.acceptable !== true) {
|
|
168
|
+
return {
|
|
169
|
+
result: failure("strict_json_fidelity", strictJsonFidelityMessage(fidelity), pipeline),
|
|
170
|
+
correctiveViolations: correctiveViolations(strict?.violations ?? []),
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
if (pipeline.isError === true) {
|
|
174
|
+
return notEligible(failure("pipeline_error", "context_builder delegate pipeline returned an error", pipeline));
|
|
175
|
+
}
|
|
176
|
+
const raw = pipeline.content[0]?.text?.trim() ?? "";
|
|
177
|
+
if (raw.length === 0 || raw === "(no output)") {
|
|
178
|
+
return notEligible(failure("empty_output", "context_builder delegate returned empty output", pipeline));
|
|
179
|
+
}
|
|
180
|
+
let parsed;
|
|
181
|
+
try {
|
|
182
|
+
parsed = JSON.parse(raw);
|
|
97
183
|
}
|
|
184
|
+
catch {
|
|
185
|
+
return {
|
|
186
|
+
result: failure("invalid_json", "context_builder delegate output was not valid JSON", pipeline),
|
|
187
|
+
correctiveViolations: ["invalid_json"],
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
if (parsed == null || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
191
|
+
return {
|
|
192
|
+
result: failure("invalid_json", "context_builder delegate output must be one JSON object", pipeline),
|
|
193
|
+
correctiveViolations: ["non_object_json"],
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
return {
|
|
197
|
+
result: {
|
|
198
|
+
ok: true,
|
|
199
|
+
json: parsed,
|
|
200
|
+
raw,
|
|
201
|
+
pipeline,
|
|
202
|
+
},
|
|
203
|
+
correctiveViolations: null,
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
function notEligible(result) {
|
|
207
|
+
return { result, correctiveViolations: null };
|
|
208
|
+
}
|
|
209
|
+
function correctiveViolations(violations) {
|
|
210
|
+
if (violations.some((v) => CORRECTIVE_RETRY_BLOCKING_VIOLATIONS.has(v))) {
|
|
211
|
+
return null;
|
|
212
|
+
}
|
|
213
|
+
const eligible = violations.filter((v) => CORRECTIVE_RETRY_ELIGIBLE_VIOLATIONS.has(v));
|
|
214
|
+
return eligible.length === 0 ? null : eligible;
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Appended to the ORIGINAL prompt only (never to a previous corrective
|
|
218
|
+
* prompt), so at most one suffix is ever present.
|
|
219
|
+
*/
|
|
220
|
+
function buildCorrectiveSuffix(violations) {
|
|
221
|
+
const head = "\n\n---\nCORRECTIVE RETRY: your previous response was rejected by the " +
|
|
222
|
+
"server's strict JSON check (violations: ";
|
|
223
|
+
const tail = "). Answer the task above again. Respond with exactly one JSON object and " +
|
|
224
|
+
"nothing else: no prose, no markdown code fences, no second JSON value. " +
|
|
225
|
+
"Keep the same output schema the task requires.\n";
|
|
226
|
+
const budget = DELEGATE_CORRECTIVE_SUFFIX_MAX_CHARS - head.length - tail.length;
|
|
227
|
+
let list = violations.join(", ");
|
|
228
|
+
if (list.length > budget) {
|
|
229
|
+
list = `${list.slice(0, Math.max(0, budget - 3))}...`;
|
|
230
|
+
}
|
|
231
|
+
return `${head}${list}${tail}`;
|
|
232
|
+
}
|
|
233
|
+
function withAttempt(owner, attempt) {
|
|
234
|
+
if (owner == null) {
|
|
235
|
+
return undefined;
|
|
236
|
+
}
|
|
237
|
+
// Only owners that already carry attempt identity get a new lane; stamping
|
|
238
|
+
// attempt onto one without it would violate the owner schema.
|
|
239
|
+
if (owner.family === "activity" || owner.attempt === undefined) {
|
|
240
|
+
return owner;
|
|
241
|
+
}
|
|
242
|
+
return { ...owner, attempt };
|
|
243
|
+
}
|
|
244
|
+
function providerErrorMessage(pipeline) {
|
|
245
|
+
const text = pipeline.content[0]?.text ?? "";
|
|
246
|
+
const snippet = sanitizeDelegateFailureText(text, PROVIDER_ERROR_SNIPPET_MAX_CHARS);
|
|
247
|
+
return snippet.length === 0
|
|
248
|
+
? "context_builder delegate pipeline returned an error"
|
|
249
|
+
: `context_builder delegate pipeline returned an error: ${snippet}`;
|
|
98
250
|
}
|
|
99
251
|
function failure(reason, message, pipeline) {
|
|
100
252
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"delegate.js","sourceRoot":"","sources":["../../src/context-builder/delegate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"delegate.js","sourceRoot":"","sources":["../../src/context-builder/delegate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AACrE,OAAO,EAAE,eAAe,EAAuB,MAAM,gBAAgB,CAAC;AAGtE,OAAO,EAAE,2BAA2B,EAAE,MAAM,kBAAkB,CAAC;AA0C/D,+EAA+E;AAC/E,6EAA6E;AAC7E,MAAM,CAAC,MAAM,+CAA+C,GAAG,EAAE,CAAC;AAClE,MAAM,CAAC,MAAM,oCAAoC,GAAG,IAAI,CAAC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AAE,CAAC;YACjC,OAAO,CAAC,IAAI,CAAC,SAAS,QAAQ,CAAC,WAAW,EAAE,CAAC,CAAC;QAChD,CAAC;QACD,IAAI,QAAQ,CAAC,MAAM,EAAE,UAAU,KAAK,IAAI,EAAE,CAAC;YACzC,OAAO,CAAC,IAAI,CAAC,+BAA+B,CAAC,CAAC;QAChD,CAAC;QACD,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC,MAAM,IAAI,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC;YAClD,OAAO,CAAC,IAAI,CAAC,cAAc,QAAQ,CAAC,MAAO,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACvE,CAAC;IACH,CAAC;IAED,OAAO,OAAO,CAAC,MAAM,KAAK,CAAC;QACzB,CAAC,CAAC,wDAAwD;QAC1D,CAAC,CAAC,2DAA2D,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;AACtF,CAAC"}
|
|
@@ -11,7 +11,7 @@ export type ContextBuilderOmission = {
|
|
|
11
11
|
omitted_path_count?: number;
|
|
12
12
|
};
|
|
13
13
|
export declare const CONTEXT_BUILDER_REQUESTED_EVIDENCE_OMISSION_REASON = "requested_evidence_omission";
|
|
14
|
-
export type ContextBuilderRequestedEvidenceOmissionKind = "unavailable" | "too_large" | "candidate_cap" | "discovery_candidate_cap" | "packet_token_cap" | "
|
|
14
|
+
export type ContextBuilderRequestedEvidenceOmissionKind = "unavailable" | "too_large" | "candidate_cap" | "discovery_candidate_cap" | "packet_token_cap" | "packet_json_byte_cap";
|
|
15
15
|
export declare function requestedEvidenceOmission(input: {
|
|
16
16
|
root_index?: number;
|
|
17
17
|
kind: ContextBuilderRequestedEvidenceOmissionKind;
|
|
@@ -22,6 +22,15 @@ export declare function isRequestedEvidenceOmission(omission: Pick<ContextBuilde
|
|
|
22
22
|
export declare function boundContextBuilderWarnings(warnings: ContextBuilderWarning[], caps?: Pick<ContextBuilderInternalCaps, "max_warnings">): ContextBuilderWarning[];
|
|
23
23
|
export declare function boundContextBuilderOmissions(omissions: ContextBuilderOmission[], caps?: Pick<ContextBuilderInternalCaps, "max_omissions" | "max_paths_per_omission">): ContextBuilderOmission[];
|
|
24
24
|
export declare function boundContextBuilderPathList(paths: string[], maxPaths?: number): string[];
|
|
25
|
-
export declare function sanitizeDiagnosticText(text: string): string;
|
|
25
|
+
export declare function sanitizeDiagnosticText(text: string, allowSecrets?: boolean): string;
|
|
26
|
+
/**
|
|
27
|
+
* Bounded sanitizer dedicated to delegate-failure reasons. Applies the exact
|
|
28
|
+
* redaction guarantees of sanitizeDiagnosticText (whitespace collapse,
|
|
29
|
+
* secret-material fail-closed redaction, embedded absolute-path redaction) but
|
|
30
|
+
* with a wider ceiling and an explicit truncation marker instead of a bare
|
|
31
|
+
* trailing "...", so a truncated failure reason is never mistaken for a
|
|
32
|
+
* complete one.
|
|
33
|
+
*/
|
|
34
|
+
export declare function sanitizeDelegateFailureText(text: string, maxLength?: number): string;
|
|
26
35
|
export declare function hasEmbeddedAbsolutePath(text: string): boolean;
|
|
27
36
|
export declare function sanitizeProgressMessage(message: string): string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CONTEXT_BUILDER_INTERNAL_CAP_DEFAULTS, } from "./config.js";
|
|
2
|
-
import { hasHighConfidenceSecret, scanSecretPath } from "./secrets.js";
|
|
2
|
+
import { hasDisallowedSecretMaterial, hasHighConfidenceSecret, scanSecretPath, } from "./secrets.js";
|
|
3
3
|
export const CONTEXT_BUILDER_REQUESTED_EVIDENCE_OMISSION_REASON = "requested_evidence_omission";
|
|
4
4
|
export function requestedEvidenceOmission(input) {
|
|
5
5
|
return {
|
|
@@ -15,7 +15,17 @@ export function isRequestedEvidenceOmission(omission) {
|
|
|
15
15
|
const MAX_DIAGNOSTIC_TEXT_LENGTH = 240;
|
|
16
16
|
const MAX_PROGRESS_TEXT_LENGTH = 120;
|
|
17
17
|
const MAX_PATH_TEXT_LENGTH = 300;
|
|
18
|
-
|
|
18
|
+
// Dedicated ceiling for delegate-failure reasons. These messages aggregate
|
|
19
|
+
// many per-omission entries, so the general 240-char diagnostic bound silently
|
|
20
|
+
// dropped every entry past the first one or two. The wider bound is scoped to
|
|
21
|
+
// this one error path; other callers keep MAX_DIAGNOSTIC_TEXT_LENGTH.
|
|
22
|
+
const MAX_DELEGATE_FAILURE_TEXT_LENGTH = 2000;
|
|
23
|
+
const DELEGATE_FAILURE_TRUNCATION_MARKER = " [truncated]";
|
|
24
|
+
// Leading boundary is the negated class [^\w] to bias toward over-redaction: any
|
|
25
|
+
// non-word char before an absolute-path start counts as a boundary, so delimiter-glued
|
|
26
|
+
// paths can't slip through. Word-char glue is left unflagged on purpose (word/Users is a
|
|
27
|
+
// relative path, not an absolute disclosure).
|
|
28
|
+
const EMBEDDED_ABSOLUTE_PATH_PATTERN = /(^|[^\w])((?:~\/|\/(?!\/)|[A-Za-z]:[\\/]|\\\\)[^\s"'`,;)\]}]*)/g;
|
|
19
29
|
export function boundContextBuilderWarnings(warnings, caps = CONTEXT_BUILDER_INTERNAL_CAP_DEFAULTS) {
|
|
20
30
|
return warnings.slice(0, caps.max_warnings).map((warning) => ({
|
|
21
31
|
code: sanitizeDiagnosticText(warning.code),
|
|
@@ -38,16 +48,39 @@ export function boundContextBuilderOmissions(omissions, caps = CONTEXT_BUILDER_I
|
|
|
38
48
|
export function boundContextBuilderPathList(paths, maxPaths = CONTEXT_BUILDER_INTERNAL_CAP_DEFAULTS.max_paths_per_omission) {
|
|
39
49
|
return paths.slice(0, maxPaths).map(sanitizePathText);
|
|
40
50
|
}
|
|
41
|
-
export function sanitizeDiagnosticText(text) {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
return "[redacted-sensitive]";
|
|
51
|
+
export function sanitizeDiagnosticText(text, allowSecrets = false) {
|
|
52
|
+
if (allowSecrets === true) {
|
|
53
|
+
return text;
|
|
45
54
|
}
|
|
55
|
+
const collapsed = collapseAndRedactDiagnosticText(text);
|
|
46
56
|
const bounded = collapsed.length > MAX_DIAGNOSTIC_TEXT_LENGTH
|
|
47
57
|
? `${collapsed.slice(0, MAX_DIAGNOSTIC_TEXT_LENGTH - 3)}...`
|
|
48
58
|
: collapsed;
|
|
49
59
|
return bounded;
|
|
50
60
|
}
|
|
61
|
+
/**
|
|
62
|
+
* Bounded sanitizer dedicated to delegate-failure reasons. Applies the exact
|
|
63
|
+
* redaction guarantees of sanitizeDiagnosticText (whitespace collapse,
|
|
64
|
+
* secret-material fail-closed redaction, embedded absolute-path redaction) but
|
|
65
|
+
* with a wider ceiling and an explicit truncation marker instead of a bare
|
|
66
|
+
* trailing "...", so a truncated failure reason is never mistaken for a
|
|
67
|
+
* complete one.
|
|
68
|
+
*/
|
|
69
|
+
export function sanitizeDelegateFailureText(text, maxLength = MAX_DELEGATE_FAILURE_TEXT_LENGTH) {
|
|
70
|
+
const collapsed = collapseAndRedactDiagnosticText(text);
|
|
71
|
+
if (collapsed.length <= maxLength) {
|
|
72
|
+
return collapsed;
|
|
73
|
+
}
|
|
74
|
+
const sliceLength = Math.max(0, maxLength - DELEGATE_FAILURE_TRUNCATION_MARKER.length);
|
|
75
|
+
return `${collapsed.slice(0, sliceLength)}${DELEGATE_FAILURE_TRUNCATION_MARKER}`;
|
|
76
|
+
}
|
|
77
|
+
function collapseAndRedactDiagnosticText(text) {
|
|
78
|
+
const collapsedWhitespace = text.replace(/\s+/g, " ").trim();
|
|
79
|
+
if (hasDisallowedSecretMaterial(collapsedWhitespace, false)) {
|
|
80
|
+
return "[redacted-sensitive]";
|
|
81
|
+
}
|
|
82
|
+
return redactEmbeddedAbsolutePaths(collapsedWhitespace);
|
|
83
|
+
}
|
|
51
84
|
export function hasEmbeddedAbsolutePath(text) {
|
|
52
85
|
EMBEDDED_ABSOLUTE_PATH_PATTERN.lastIndex = 0;
|
|
53
86
|
return EMBEDDED_ABSOLUTE_PATH_PATTERN.test(text);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"diagnostics.js","sourceRoot":"","sources":["../../src/context-builder/diagnostics.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qCAAqC,GAEtC,MAAM,aAAa,CAAC;AACrB,OAAO,
|
|
1
|
+
{"version":3,"file":"diagnostics.js","sourceRoot":"","sources":["../../src/context-builder/diagnostics.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qCAAqC,GAEtC,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,2BAA2B,EAC3B,uBAAuB,EACvB,cAAc,GACf,MAAM,cAAc,CAAC;AAetB,MAAM,CAAC,MAAM,kDAAkD,GAC7D,6BAA6B,CAAC;AAUhC,MAAM,UAAU,yBAAyB,CAAC,KAKzC;IACC,OAAO;QACL,GAAG,CAAC,KAAK,CAAC,UAAU,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,KAAK,CAAC,UAAU,EAAE,CAAC;QACrE,MAAM,EAAE,kDAAkD;QAC1D,OAAO,EAAE,qCAAqC,KAAK,CAAC,IAAI,MAAM,KAAK,CAAC,OAAO,EAAE;QAC7E,GAAG,CAAC,KAAK,CAAC,KAAK,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,CAAC;KACvD,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,2BAA2B,CACzC,QAAgD;IAEhD,OAAO,QAAQ,CAAC,MAAM,KAAK,kDAAkD,CAAC;AAChF,CAAC;AAED,MAAM,0BAA0B,GAAG,GAAG,CAAC;AACvC,MAAM,wBAAwB,GAAG,GAAG,CAAC;AACrC,MAAM,oBAAoB,GAAG,GAAG,CAAC;AACjC,2EAA2E;AAC3E,+EAA+E;AAC/E,8EAA8E;AAC9E,sEAAsE;AACtE,MAAM,gCAAgC,GAAG,IAAI,CAAC;AAC9C,MAAM,kCAAkC,GAAG,cAAc,CAAC;AAC1D,iFA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OAAO,sBAAsB,CAAC;IAChC,CAAC;IACD,OAAO,2BAA2B,CAAC,mBAAmB,CAAC,CAAC;AAC1D,CAAC;AAED,MAAM,UAAU,uBAAuB,CAAC,IAAY;IAClD,8BAA8B,CAAC,SAAS,GAAG,CAAC,CAAC;IAC7C,OAAO,8BAA8B,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACnD,CAAC;AAED,SAAS,2BAA2B,CAAC,IAAY;IAC/C,8BAA8B,CAAC,SAAS,GAAG,CAAC,CAAC;IAC7C,OAAO,IAAI,CAAC,OAAO,CACjB,8BAA8B,EAC9B,4BAA4B,CAC7B,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,uBAAuB,CAAC,OAAe;IACrD,MAAM,SAAS,GAAG,sBAAsB,CAAC,OAAO,CAAC,CAAC;IAClD,OAAO,SAAS,CAAC,MAAM,GAAG,wBAAwB;QAChD,CAAC,CAAC,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC,EAAE,wBAAwB,GAAG,CAAC,CAAC,KAAK;QAC1D,CAAC,CAAC,SAAS,CAAC;AAChB,CAAC;AAED,SAAS,gBAAgB,CAAC,IAAY;IACpC,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,eAAe,EAAE,GAAG,CAAC,CAAC;IACtD,IACE,cAAc,CAAC,UAAU,CAAC,CAAC,MAAM,GAAG,CAAC;QACrC,uBAAuB,CAAC,UAAU,CAAC,EACnC,CAAC;QACD,OAAO,2BAA2B,CAAC;IACrC,CAAC;IAED,MAAM,OAAO,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC,EAAE,oBAAoB,CAAC,CAAC;IAE1D,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { ContextBuilderDiscoveryMetrics } from "./discovery.js";
|
|
2
|
+
import type { ContextBuilderLifecycleController } from "./lifecycle-observer.js";
|
|
3
|
+
/** Discovery invokes the progress sink at most once per this many file boundaries. */
|
|
4
|
+
export declare const CONTEXT_BUILDER_SCAN_PROGRESS_EVERY_FILES = 250;
|
|
5
|
+
/** Minimum wall-clock gap between two published mid-scan transitions. */
|
|
6
|
+
export declare const CONTEXT_BUILDER_SCAN_PROGRESS_MIN_INTERVAL_MS = 2000;
|
|
7
|
+
export type ContextBuilderScanProgressPublisher = (metrics: Readonly<ContextBuilderDiscoveryMetrics>) => void;
|
|
8
|
+
/**
|
|
9
|
+
* Throttled mid-scan lifecycle publisher for the discovery walk: turns
|
|
10
|
+
* sampled discovery metrics into `scanning → scanning` count transitions so a
|
|
11
|
+
* long scan stays observable in `state.json` and `workflow_run_status`.
|
|
12
|
+
*
|
|
13
|
+
* Emits at most once per {@link CONTEXT_BUILDER_SCAN_PROGRESS_EVERY_FILES}
|
|
14
|
+
* newly seen files AND {@link CONTEXT_BUILDER_SCAN_PROGRESS_MIN_INTERVAL_MS}
|
|
15
|
+
* apart. No final emission: the handler's `searching` transition publishes the
|
|
16
|
+
* authoritative end-of-scan counts.
|
|
17
|
+
*
|
|
18
|
+
* Fire-and-forget: the walk never awaits publication, and a rejected
|
|
19
|
+
* transition is swallowed here so it never becomes an unhandled rejection. The
|
|
20
|
+
* controller's own fail-closed contract still applies — an observer rejection
|
|
21
|
+
* poisons the controller, so the next awaited transition fails the run.
|
|
22
|
+
*/
|
|
23
|
+
export declare function createScanProgressPublisher(lifecycle: Pick<ContextBuilderLifecycleController, "transition"> | undefined, options?: {
|
|
24
|
+
readonly now?: () => number;
|
|
25
|
+
}): ContextBuilderScanProgressPublisher;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/** Discovery invokes the progress sink at most once per this many file boundaries. */
|
|
2
|
+
export const CONTEXT_BUILDER_SCAN_PROGRESS_EVERY_FILES = 250;
|
|
3
|
+
/** Minimum wall-clock gap between two published mid-scan transitions. */
|
|
4
|
+
export const CONTEXT_BUILDER_SCAN_PROGRESS_MIN_INTERVAL_MS = 2_000;
|
|
5
|
+
/**
|
|
6
|
+
* Throttled mid-scan lifecycle publisher for the discovery walk: turns
|
|
7
|
+
* sampled discovery metrics into `scanning → scanning` count transitions so a
|
|
8
|
+
* long scan stays observable in `state.json` and `workflow_run_status`.
|
|
9
|
+
*
|
|
10
|
+
* Emits at most once per {@link CONTEXT_BUILDER_SCAN_PROGRESS_EVERY_FILES}
|
|
11
|
+
* newly seen files AND {@link CONTEXT_BUILDER_SCAN_PROGRESS_MIN_INTERVAL_MS}
|
|
12
|
+
* apart. No final emission: the handler's `searching` transition publishes the
|
|
13
|
+
* authoritative end-of-scan counts.
|
|
14
|
+
*
|
|
15
|
+
* Fire-and-forget: the walk never awaits publication, and a rejected
|
|
16
|
+
* transition is swallowed here so it never becomes an unhandled rejection. The
|
|
17
|
+
* controller's own fail-closed contract still applies — an observer rejection
|
|
18
|
+
* poisons the controller, so the next awaited transition fails the run.
|
|
19
|
+
*/
|
|
20
|
+
export function createScanProgressPublisher(lifecycle, options = {}) {
|
|
21
|
+
if (lifecycle == null) {
|
|
22
|
+
return () => { };
|
|
23
|
+
}
|
|
24
|
+
const now = options.now ?? (() => performance.now());
|
|
25
|
+
let lastFilesSeen = 0;
|
|
26
|
+
let lastEmittedAt;
|
|
27
|
+
return (metrics) => {
|
|
28
|
+
if (metrics.files_seen - lastFilesSeen < CONTEXT_BUILDER_SCAN_PROGRESS_EVERY_FILES) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
const at = now();
|
|
32
|
+
if (lastEmittedAt != null &&
|
|
33
|
+
at - lastEmittedAt < CONTEXT_BUILDER_SCAN_PROGRESS_MIN_INTERVAL_MS) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
lastFilesSeen = metrics.files_seen;
|
|
37
|
+
lastEmittedAt = at;
|
|
38
|
+
try {
|
|
39
|
+
lifecycle
|
|
40
|
+
.transition("scanning", { counts: scanCountsFromMetrics(metrics) })
|
|
41
|
+
.catch(() => { });
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
// A synchronously throwing controller is equally non-fatal to discovery.
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Mid-scan projection of the counts shape `lifecycleCountsFromDiscovery`
|
|
50
|
+
* publishes at `searching`. Omissions, search results, selection, and writes
|
|
51
|
+
* are not known until the walk ends, so they stay zero here.
|
|
52
|
+
*/
|
|
53
|
+
function scanCountsFromMetrics(metrics) {
|
|
54
|
+
return {
|
|
55
|
+
files_seen: metrics.files_seen,
|
|
56
|
+
files_considered: metrics.files_considered,
|
|
57
|
+
files_selected: 0,
|
|
58
|
+
files_omitted: 0,
|
|
59
|
+
search_results: 0,
|
|
60
|
+
bytes_read: metrics.bytes_read,
|
|
61
|
+
bytes_written: 0,
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=discovery-progress.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"discovery-progress.js","sourceRoot":"","sources":["../../src/context-builder/discovery-progress.ts"],"names":[],"mappings":"AAMA,sFAAsF;AACtF,MAAM,CAAC,MAAM,yCAAyC,GAAG,GAAG,CAAC;AAE7D,yEAAyE;AACzE,MAAM,CAAC,MAAM,6CAA6C,GAAG,KAAK,CAAC;AAMnE;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,2BAA2B,CACzC,SAA4E,EAC5E,UAA2C,EAAE;IAE7C,IAAI,SAAS,IAAI,IAAI,EAAE,CAAC;QACtB,OAAO,GAAG,EAAE,GAAE,CAAC,CAAC;IAClB,CAAC;IACD,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC,WAAW,CAAC,GAAG,EAAE,CAAC,CAAC;IACrD,IAAI,aAAa,GAAG,CAAC,CAAC;IACtB,IAAI,aAAiC,CAAC;IACtC,OAAO,CAAC,OAAO,EAAE,EAAE;QACjB,IAAI,OAAO,CAAC,UAAU,GAAG,aAAa,GAAG,yCAAyC,EAAE,CAAC;YACnF,OAAO;QACT,CAAC;QACD,MAAM,EAAE,GAAG,GAAG,EAAE,CAAC;QACjB,IACE,aAAa,IAAI,IAAI;YACrB,EAAE,GAAG,aAAa,GAAG,6CAA6C,EAClE,CAAC;YACD,OAAO;QACT,CAAC;QACD,aAAa,GAAG,OAAO,CAAC,UAAU,CAAC;QACnC,aAAa,GAAG,EAAE,CAAC;QACnB,IAAI,CAAC;YACH,SAAS;iBACN,UAAU,CAAC,UAAU,EAAE,EAAE,MAAM,EAAE,qBAAqB,CAAC,OAAO,CAAC,EAAE,CAAC;iBAClE,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;QACrB,CAAC;QAAC,MAAM,CAAC;YACP,yEAAyE;QAC3E,CAAC;IACH,CAAC,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,SAAS,qBAAqB,CAC5B,OAAiD;IAEjD,OAAO;QACL,UAAU,EAAE,OAAO,CAAC,UAAU;QAC9B,gBAAgB,EAAE,OAAO,CAAC,gBAAgB;QAC1C,cAAc,EAAE,CAAC;QACjB,aAAa,EAAE,CAAC;QAChB,cAAc,EAAE,CAAC;QACjB,UAAU,EAAE,OAAO,CAAC,UAAU;QAC9B,aAAa,EAAE,CAAC;KACjB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/** Same window as the write watchdog and the dashboard write-phase stale overlay. */
|
|
2
|
+
export declare const CONTEXT_BUILDER_DISCOVERY_WATCHDOG_MS: number;
|
|
3
|
+
/**
|
|
4
|
+
* Bound the discovery/scanning phase wall clock. MCP cancel still wins when
|
|
5
|
+
* the caller signal aborts first; a watchdog-only abort becomes
|
|
6
|
+
* ExecutionError so the lifecycle records a failure, not a cancellation.
|
|
7
|
+
*
|
|
8
|
+
* The abort is observed at the walk's file-boundary checks and event-loop
|
|
9
|
+
* yields, so a single synchronous stretch (one sanitize call) runs to
|
|
10
|
+
* completion before the timer can take effect.
|
|
11
|
+
*/
|
|
12
|
+
export declare function withContextBuilderDiscoveryWatchdog<T>(work: (signal: AbortSignal) => Promise<T>, options?: {
|
|
13
|
+
readonly signal?: AbortSignal | undefined;
|
|
14
|
+
readonly timeoutMs?: number;
|
|
15
|
+
}): Promise<T>;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { ExecutionError } from "../errors.js";
|
|
2
|
+
/** Same window as the write watchdog and the dashboard write-phase stale overlay. */
|
|
3
|
+
export const CONTEXT_BUILDER_DISCOVERY_WATCHDOG_MS = 10 * 60 * 1_000;
|
|
4
|
+
/**
|
|
5
|
+
* Bound the discovery/scanning phase wall clock. MCP cancel still wins when
|
|
6
|
+
* the caller signal aborts first; a watchdog-only abort becomes
|
|
7
|
+
* ExecutionError so the lifecycle records a failure, not a cancellation.
|
|
8
|
+
*
|
|
9
|
+
* The abort is observed at the walk's file-boundary checks and event-loop
|
|
10
|
+
* yields, so a single synchronous stretch (one sanitize call) runs to
|
|
11
|
+
* completion before the timer can take effect.
|
|
12
|
+
*/
|
|
13
|
+
export async function withContextBuilderDiscoveryWatchdog(work, options = {}) {
|
|
14
|
+
const timeoutMs = options.timeoutMs ?? CONTEXT_BUILDER_DISCOVERY_WATCHDOG_MS;
|
|
15
|
+
if (!Number.isSafeInteger(timeoutMs) || timeoutMs < 1) {
|
|
16
|
+
throw new ExecutionError("context_builder discovery watchdog timeout is invalid");
|
|
17
|
+
}
|
|
18
|
+
const watchdog = new AbortController();
|
|
19
|
+
const timer = setTimeout(() => {
|
|
20
|
+
watchdog.abort();
|
|
21
|
+
}, timeoutMs);
|
|
22
|
+
timer.unref();
|
|
23
|
+
const signal = options.signal == null
|
|
24
|
+
? watchdog.signal
|
|
25
|
+
: AbortSignal.any([options.signal, watchdog.signal]);
|
|
26
|
+
try {
|
|
27
|
+
return await work(signal);
|
|
28
|
+
}
|
|
29
|
+
catch (error) {
|
|
30
|
+
if (watchdog.signal.aborted && options.signal?.aborted !== true) {
|
|
31
|
+
throw new ExecutionError(`context_builder discovery phase exceeded ${String(timeoutMs)}ms`);
|
|
32
|
+
}
|
|
33
|
+
throw error;
|
|
34
|
+
}
|
|
35
|
+
finally {
|
|
36
|
+
clearTimeout(timer);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=discovery-watchdog.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"discovery-watchdog.js","sourceRoot":"","sources":["../../src/context-builder/discovery-watchdog.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9C,qFAAqF;AACrF,MAAM,CAAC,MAAM,qCAAqC,GAAG,EAAE,GAAG,EAAE,GAAG,KAAK,CAAC;AAErE;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,mCAAmC,CACvD,IAAyC,EACzC,UAGI,EAAE;IAEN,MAAM,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,qCAAqC,CAAC;IAC7E,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,SAAS,CAAC,IAAI,SAAS,GAAG,CAAC,EAAE,CAAC;QACtD,MAAM,IAAI,cAAc,CAAC,uDAAuD,CAAC,CAAC;IACpF,CAAC;IACD,MAAM,QAAQ,GAAG,IAAI,eAAe,EAAE,CAAC;IACvC,MAAM,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE;QAC5B,QAAQ,CAAC,KAAK,EAAE,CAAC;IACnB,CAAC,EAAE,SAAS,CAAC,CAAC;IACd,KAAK,CAAC,KAAK,EAAE,CAAC;IACd,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,IAAI,IAAI;QACnC,CAAC,CAAC,QAAQ,CAAC,MAAM;QACjB,CAAC,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;IACvD,IAAI,CAAC;QACH,OAAO,MAAM,IAAI,CAAC,MAAM,CAAC,CAAC;IAC5B,CAAC;IAAC,OA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