toolroll 0.9.141 → 0.9.142
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 +18 -0
- package/dist/attest.js +1 -1
- package/dist/browser/{chunk-agents-live-view.9f4367c89c6366769a567e729ac9181ccaa898bf3a168d3dc618f3cface887c7.js → chunk-agents-live-view.1b1c797cec2734229d36186796ae378527a7b5f7aa936897671a6c1f3a8cb19a.js} +5 -5
- package/dist/browser/chunk-agents-live-view.1b1c797cec2734229d36186796ae378527a7b5f7aa936897671a6c1f3a8cb19a.js.br +0 -0
- package/dist/browser/chunk-agents-live-view.1b1c797cec2734229d36186796ae378527a7b5f7aa936897671a6c1f3a8cb19a.js.gz +0 -0
- package/dist/browser/chunk-bundle.089b2471028b3dcf578cb4363ea4757738b28eda5459e6194f92707364033cd7.js +2 -0
- package/dist/browser/chunk-bundle.089b2471028b3dcf578cb4363ea4757738b28eda5459e6194f92707364033cd7.js.br +0 -0
- package/dist/browser/chunk-bundle.089b2471028b3dcf578cb4363ea4757738b28eda5459e6194f92707364033cd7.js.gz +0 -0
- package/dist/browser/chunk-chat-parts.51c73684050c98bc25724e417e4180981c14590934bb37fd9a1617942a7d32d3.js +4 -0
- package/dist/browser/chunk-chat-parts.51c73684050c98bc25724e417e4180981c14590934bb37fd9a1617942a7d32d3.js.br +0 -0
- package/dist/browser/chunk-chat-parts.51c73684050c98bc25724e417e4180981c14590934bb37fd9a1617942a7d32d3.js.gz +0 -0
- package/dist/browser/{chunk-core.5490609e81c3a5f78da3e06b9795d71c287016ebc7fd02794b1122b474ebb07f.js → chunk-core.6128decfe528d89de1445dc1ec36e9f13dabd76eba61d13310fc1302db2252eb.js} +11 -11
- package/dist/browser/chunk-core.6128decfe528d89de1445dc1ec36e9f13dabd76eba61d13310fc1302db2252eb.js.br +0 -0
- package/dist/browser/chunk-core.6128decfe528d89de1445dc1ec36e9f13dabd76eba61d13310fc1302db2252eb.js.gz +0 -0
- package/dist/browser/{chunk-flow-view.f5d74c7f072b739a7a0ed86ff35cafa7b8a041233372d1eeaab9eb941ddfc11e.js → chunk-flow-view.f9a4db9db350a9311ce5b11e9358c6e7de4ad9b3cd7a1f058e6c78eedee6dec6.js} +1 -1
- package/dist/browser/chunk-flow-view.f9a4db9db350a9311ce5b11e9358c6e7de4ad9b3cd7a1f058e6c78eedee6dec6.js.br +0 -0
- package/dist/browser/chunk-flow-view.f9a4db9db350a9311ce5b11e9358c6e7de4ad9b3cd7a1f058e6c78eedee6dec6.js.gz +0 -0
- package/dist/browser/{chunk-flows-extra-view.01ebf93780b729363eda11ba21c764fe593bcd3e684aa833c9b86147f780fd41.js → chunk-flows-extra-view.3151cd05656fd35f80588863c323b4799b6b1f0060243ec8bc9b5da94d8d6052.js} +1 -1
- package/dist/browser/chunk-flows-extra-view.3151cd05656fd35f80588863c323b4799b6b1f0060243ec8bc9b5da94d8d6052.js.br +0 -0
- package/dist/browser/chunk-flows-extra-view.3151cd05656fd35f80588863c323b4799b6b1f0060243ec8bc9b5da94d8d6052.js.gz +0 -0
- package/dist/browser/chunk-more-views.70ab484b8f1f1ebc31c3c27061a88c86607d86bb9bc34d277b57f3f4fa0ce291.js +2 -0
- package/dist/browser/chunk-more-views.70ab484b8f1f1ebc31c3c27061a88c86607d86bb9bc34d277b57f3f4fa0ce291.js.br +0 -0
- package/dist/browser/chunk-more-views.70ab484b8f1f1ebc31c3c27061a88c86607d86bb9bc34d277b57f3f4fa0ce291.js.gz +0 -0
- package/dist/browser/{chunk-pages-bundle.e18059f0cb4fbb63e3698971d4c1830ad0945c3645235babc93010cd0b725c1d.js → chunk-pages-bundle.3b596e7529dfb499a536353c9095d0b9a8255e5b7f782211c22aced869905bb0.js} +1 -1
- package/dist/browser/chunk-pages-bundle.3b596e7529dfb499a536353c9095d0b9a8255e5b7f782211c22aced869905bb0.js.br +0 -0
- package/dist/browser/chunk-pages-bundle.3b596e7529dfb499a536353c9095d0b9a8255e5b7f782211c22aced869905bb0.js.gz +0 -0
- package/dist/browser/chunk-result-view.f319cf5973ad4c9e7e495e00e77070ec242da669f87f848d52878e223ba87343.js +2 -0
- package/dist/browser/chunk-result-view.f319cf5973ad4c9e7e495e00e77070ec242da669f87f848d52878e223ba87343.js.br +0 -0
- package/dist/browser/chunk-result-view.f319cf5973ad4c9e7e495e00e77070ec242da669f87f848d52878e223ba87343.js.gz +0 -0
- package/dist/browser/chunk-settings-view.653e09ec0c7cce54c68ae7e968cc015c774fb6fa6e1493fd9f5423281d1e24fe.js +20 -0
- package/dist/browser/chunk-settings-view.653e09ec0c7cce54c68ae7e968cc015c774fb6fa6e1493fd9f5423281d1e24fe.js.br +0 -0
- package/dist/browser/chunk-settings-view.653e09ec0c7cce54c68ae7e968cc015c774fb6fa6e1493fd9f5423281d1e24fe.js.gz +0 -0
- package/dist/browser/chunk-shared.0c0231ce259937612ec120a251373e6b63f68c37fa031567570a9cfd6d6b2eef.js +2 -0
- package/dist/browser/chunk-shared.0c0231ce259937612ec120a251373e6b63f68c37fa031567570a9cfd6d6b2eef.js.br +0 -0
- package/dist/browser/chunk-shared.0c0231ce259937612ec120a251373e6b63f68c37fa031567570a9cfd6d6b2eef.js.gz +0 -0
- package/dist/browser/{chunk-shared.02c0b692de21a9bb80d1761aa887d8532431171945c02e663884c9f45b796753.js → chunk-shared.1bdbb9b057d17e95221becb4ed515b546d671390e4a817a6e72a799480fe14ad.js} +1 -1
- package/dist/browser/chunk-shared.1bdbb9b057d17e95221becb4ed515b546d671390e4a817a6e72a799480fe14ad.js.br +0 -0
- package/dist/browser/chunk-shared.1bdbb9b057d17e95221becb4ed515b546d671390e4a817a6e72a799480fe14ad.js.gz +0 -0
- package/dist/browser/{chunk-shared.c3e5be1c5f441e94905a4bc2005d816d2a0b0e4108bae43e37ec274a911c6847.js → chunk-shared.2d678087d03dcf2430b5bf48656220dbff5fb622188004aae7a76e0e5e5d18f8.js} +1 -1
- package/dist/browser/chunk-shared.2d678087d03dcf2430b5bf48656220dbff5fb622188004aae7a76e0e5e5d18f8.js.br +0 -0
- package/dist/browser/chunk-shared.2d678087d03dcf2430b5bf48656220dbff5fb622188004aae7a76e0e5e5d18f8.js.gz +0 -0
- package/dist/browser/{chunk-shared.6d0b8728b3e309886cfb6eaf596d3f20592939e521bb60bb090824f34da6b086.js → chunk-shared.66f18526381931b1ff69c090bad48c408a035a0d256bcff19b19b51ea988612a.js} +1 -1
- package/dist/browser/chunk-shared.66f18526381931b1ff69c090bad48c408a035a0d256bcff19b19b51ea988612a.js.br +0 -0
- package/dist/browser/chunk-shared.66f18526381931b1ff69c090bad48c408a035a0d256bcff19b19b51ea988612a.js.gz +0 -0
- package/dist/browser/{chunk-shared.0874336833f8101a63b169d8c2e55ca0f281e43e65d4bd6604555c791ea9dd87.js → chunk-shared.782659379fb982a9c2606c051bb711fd0fe38a547b8b4f4620cf2d14a832df25.js} +1 -1
- package/dist/browser/chunk-shared.782659379fb982a9c2606c051bb711fd0fe38a547b8b4f4620cf2d14a832df25.js.br +0 -0
- package/dist/browser/chunk-shared.782659379fb982a9c2606c051bb711fd0fe38a547b8b4f4620cf2d14a832df25.js.gz +0 -0
- package/dist/browser/{chunk-shared.d1f25785c8c168cc75aa99c4be8ca56abfc5eafa3490f8817ff15e61cb901915.js → chunk-shared.8940b7334ec79bcd25cb8e2d41958eecfe71d31340cf8de3c3d99f813cd126af.js} +1 -1
- package/dist/browser/chunk-shared.8940b7334ec79bcd25cb8e2d41958eecfe71d31340cf8de3c3d99f813cd126af.js.br +0 -0
- package/dist/browser/chunk-shared.8940b7334ec79bcd25cb8e2d41958eecfe71d31340cf8de3c3d99f813cd126af.js.gz +0 -0
- package/dist/browser/{chunk-shared.26bb0114998968cccb7bae5f6ffa8979ddecfafd8bc18bb6985760f6bcc030e6.js → chunk-shared.a7e4c6f386cee4623300b0d1b471260a09e05f6e236d56c7814dffc06088fb5c.js} +1 -1
- package/dist/browser/chunk-shared.a7e4c6f386cee4623300b0d1b471260a09e05f6e236d56c7814dffc06088fb5c.js.br +0 -0
- package/dist/browser/chunk-shared.a7e4c6f386cee4623300b0d1b471260a09e05f6e236d56c7814dffc06088fb5c.js.gz +0 -0
- package/dist/browser/{chunk-shared.fd5f2699d3b0017797e5b5e1e1d92eb98818740ebf20a95364bbb7deea0c8242.js → chunk-shared.c9025f6af91453ae8672099cb32126c5967384f769d10c662908e35c31b62478.js} +3 -3
- package/dist/browser/chunk-shared.c9025f6af91453ae8672099cb32126c5967384f769d10c662908e35c31b62478.js.br +0 -0
- package/dist/browser/chunk-shared.c9025f6af91453ae8672099cb32126c5967384f769d10c662908e35c31b62478.js.gz +0 -0
- package/dist/browser/{chunk-sonner.2472e1da55de10b11dc002c80a840966061e817c47793f5e216f1af6c6dbedff.js → chunk-sonner.76904479204cc1375093ccf9b2d60309bf4fb25e41bd0f0523b254404d9a4a11.js} +1 -1
- package/dist/browser/chunk-sonner.76904479204cc1375093ccf9b2d60309bf4fb25e41bd0f0523b254404d9a4a11.js.br +0 -0
- package/dist/browser/chunk-sonner.76904479204cc1375093ccf9b2d60309bf4fb25e41bd0f0523b254404d9a4a11.js.gz +0 -0
- package/dist/browser/chunk-task-view.6fcf84b20eddbbedc54103ca36c5c245ce6e7ccbb161ae0bef4b27027064b771.js +2 -0
- package/dist/browser/chunk-task-view.6fcf84b20eddbbedc54103ca36c5c245ce6e7ccbb161ae0bef4b27027064b771.js.br +0 -0
- package/dist/browser/chunk-task-view.6fcf84b20eddbbedc54103ca36c5c245ce6e7ccbb161ae0bef4b27027064b771.js.gz +0 -0
- package/dist/browser/chunk-team-chat.4cea27fe351f9ce5344da7c4b87240da49394496c12dc95f9e0de0590bb0d720.js +2 -0
- package/dist/browser/chunk-team-chat.4cea27fe351f9ce5344da7c4b87240da49394496c12dc95f9e0de0590bb0d720.js.br +0 -0
- package/dist/browser/chunk-team-chat.4cea27fe351f9ce5344da7c4b87240da49394496c12dc95f9e0de0590bb0d720.js.gz +0 -0
- package/dist/browser/manifest.json +204 -189
- package/dist/browser/{workspace.aebb60d4e5ef4509a80cfaccf0af5f7246867ec7531a1734dd8e28c59594950e.js → workspace.1bd4819cccc49c2c8208df3c1d31e13d3df426ecea80e734ac284cea47b49459.js} +2 -2
- package/dist/browser/workspace.1bd4819cccc49c2c8208df3c1d31e13d3df426ecea80e734ac284cea47b49459.js.br +0 -0
- package/dist/browser/workspace.1bd4819cccc49c2c8208df3c1d31e13d3df426ecea80e734ac284cea47b49459.js.gz +0 -0
- package/dist/browser-lazy-parts.js +1 -1
- package/dist/build-review.js +3 -2
- package/dist/builder.js +4 -3
- package/dist/chat-actions.js +2 -2
- package/dist/code-map-acts.js +1 -1
- package/dist/code-map-admission.js +2 -2
- package/dist/code-map-cli.js +2 -2
- package/dist/companion/push.js +3 -3
- package/dist/contracts/chat-actions.js +1 -1
- package/dist/contracts/console-api.js +1 -1
- package/dist/dispose.js +1 -1
- package/dist/lead-contract.js +1 -1
- package/dist/lead-doors.js +2 -2
- package/dist/local-owner.js +1 -1
- package/dist/operate.js +22 -13
- package/dist/planner.js +1 -1
- package/dist/project-knowledge.js +1 -1
- package/dist/push-line.js +1 -0
- package/dist/push.js +1 -1
- package/dist/review-switch.js +1 -1
- package/dist/runner.js +2 -2
- package/dist/server/pages-assets.js +2 -2
- package/dist/server/route-table.js +1 -1
- package/dist/server/settings.js +2 -2
- package/dist/server/task-view-data.js +2 -2
- package/dist/server/task-views.js +1 -1
- package/dist/ssr-workspace.js +86 -86
- package/dist/surface.js +1 -1
- package/dist/toolroll-update.js +2 -2
- package/package.json +1 -1
- package/dist/browser/chunk-agents-live-view.9f4367c89c6366769a567e729ac9181ccaa898bf3a168d3dc618f3cface887c7.js.br +0 -0
- package/dist/browser/chunk-agents-live-view.9f4367c89c6366769a567e729ac9181ccaa898bf3a168d3dc618f3cface887c7.js.gz +0 -0
- package/dist/browser/chunk-bundle.ac5952c82c76e2efcdcf5a097c4fa235d6f1045dcc36d02ee921ff4be976a46a.js +0 -2
- package/dist/browser/chunk-bundle.ac5952c82c76e2efcdcf5a097c4fa235d6f1045dcc36d02ee921ff4be976a46a.js.br +0 -0
- package/dist/browser/chunk-bundle.ac5952c82c76e2efcdcf5a097c4fa235d6f1045dcc36d02ee921ff4be976a46a.js.gz +0 -0
- package/dist/browser/chunk-chat-parts.2a0b0b723508c5c48379f6a3d441f07a18c8b91ed64fd018962931c5ae43331e.js +0 -4
- package/dist/browser/chunk-chat-parts.2a0b0b723508c5c48379f6a3d441f07a18c8b91ed64fd018962931c5ae43331e.js.br +0 -0
- package/dist/browser/chunk-chat-parts.2a0b0b723508c5c48379f6a3d441f07a18c8b91ed64fd018962931c5ae43331e.js.gz +0 -0
- package/dist/browser/chunk-core.5490609e81c3a5f78da3e06b9795d71c287016ebc7fd02794b1122b474ebb07f.js.br +0 -0
- package/dist/browser/chunk-core.5490609e81c3a5f78da3e06b9795d71c287016ebc7fd02794b1122b474ebb07f.js.gz +0 -0
- package/dist/browser/chunk-flow-view.f5d74c7f072b739a7a0ed86ff35cafa7b8a041233372d1eeaab9eb941ddfc11e.js.br +0 -0
- package/dist/browser/chunk-flow-view.f5d74c7f072b739a7a0ed86ff35cafa7b8a041233372d1eeaab9eb941ddfc11e.js.gz +0 -0
- package/dist/browser/chunk-flows-extra-view.01ebf93780b729363eda11ba21c764fe593bcd3e684aa833c9b86147f780fd41.js.br +0 -0
- package/dist/browser/chunk-flows-extra-view.01ebf93780b729363eda11ba21c764fe593bcd3e684aa833c9b86147f780fd41.js.gz +0 -0
- package/dist/browser/chunk-pages-bundle.e18059f0cb4fbb63e3698971d4c1830ad0945c3645235babc93010cd0b725c1d.js.br +0 -0
- package/dist/browser/chunk-pages-bundle.e18059f0cb4fbb63e3698971d4c1830ad0945c3645235babc93010cd0b725c1d.js.gz +0 -0
- package/dist/browser/chunk-result-view.fc6a6494b316aa786807b7d17035c59defae1bfb0c03bf9c3795679b3a35dd77.js +0 -2
- package/dist/browser/chunk-result-view.fc6a6494b316aa786807b7d17035c59defae1bfb0c03bf9c3795679b3a35dd77.js.br +0 -0
- package/dist/browser/chunk-result-view.fc6a6494b316aa786807b7d17035c59defae1bfb0c03bf9c3795679b3a35dd77.js.gz +0 -0
- package/dist/browser/chunk-settings-view.6dd3a64ded7bd8c047650270918dfb455c9a514a5a40b84c7eb5f443f76fe66f.js +0 -20
- package/dist/browser/chunk-settings-view.6dd3a64ded7bd8c047650270918dfb455c9a514a5a40b84c7eb5f443f76fe66f.js.br +0 -0
- package/dist/browser/chunk-settings-view.6dd3a64ded7bd8c047650270918dfb455c9a514a5a40b84c7eb5f443f76fe66f.js.gz +0 -0
- package/dist/browser/chunk-shared.02c0b692de21a9bb80d1761aa887d8532431171945c02e663884c9f45b796753.js.br +0 -0
- package/dist/browser/chunk-shared.02c0b692de21a9bb80d1761aa887d8532431171945c02e663884c9f45b796753.js.gz +0 -0
- package/dist/browser/chunk-shared.0874336833f8101a63b169d8c2e55ca0f281e43e65d4bd6604555c791ea9dd87.js.br +0 -0
- package/dist/browser/chunk-shared.0874336833f8101a63b169d8c2e55ca0f281e43e65d4bd6604555c791ea9dd87.js.gz +0 -0
- package/dist/browser/chunk-shared.2413dd78f32995fbca67f51ac8c21baf4727cd64f185ea739aa2a058e569b0ed.js +0 -2
- package/dist/browser/chunk-shared.2413dd78f32995fbca67f51ac8c21baf4727cd64f185ea739aa2a058e569b0ed.js.br +0 -0
- package/dist/browser/chunk-shared.2413dd78f32995fbca67f51ac8c21baf4727cd64f185ea739aa2a058e569b0ed.js.gz +0 -0
- package/dist/browser/chunk-shared.26bb0114998968cccb7bae5f6ffa8979ddecfafd8bc18bb6985760f6bcc030e6.js.br +0 -0
- package/dist/browser/chunk-shared.26bb0114998968cccb7bae5f6ffa8979ddecfafd8bc18bb6985760f6bcc030e6.js.gz +0 -0
- package/dist/browser/chunk-shared.6d0b8728b3e309886cfb6eaf596d3f20592939e521bb60bb090824f34da6b086.js.br +0 -0
- package/dist/browser/chunk-shared.6d0b8728b3e309886cfb6eaf596d3f20592939e521bb60bb090824f34da6b086.js.gz +0 -0
- package/dist/browser/chunk-shared.c3e5be1c5f441e94905a4bc2005d816d2a0b0e4108bae43e37ec274a911c6847.js.br +0 -0
- package/dist/browser/chunk-shared.c3e5be1c5f441e94905a4bc2005d816d2a0b0e4108bae43e37ec274a911c6847.js.gz +0 -0
- package/dist/browser/chunk-shared.d1f25785c8c168cc75aa99c4be8ca56abfc5eafa3490f8817ff15e61cb901915.js.br +0 -0
- package/dist/browser/chunk-shared.d1f25785c8c168cc75aa99c4be8ca56abfc5eafa3490f8817ff15e61cb901915.js.gz +0 -0
- package/dist/browser/chunk-shared.fd5f2699d3b0017797e5b5e1e1d92eb98818740ebf20a95364bbb7deea0c8242.js.br +0 -0
- package/dist/browser/chunk-shared.fd5f2699d3b0017797e5b5e1e1d92eb98818740ebf20a95364bbb7deea0c8242.js.gz +0 -0
- package/dist/browser/chunk-sonner.2472e1da55de10b11dc002c80a840966061e817c47793f5e216f1af6c6dbedff.js.br +0 -0
- package/dist/browser/chunk-sonner.2472e1da55de10b11dc002c80a840966061e817c47793f5e216f1af6c6dbedff.js.gz +0 -0
- package/dist/browser/chunk-task-view.bbeddc793a5e8a6d1f66b6cc5f0ce1da18414137e85c49ccd07be0e20f61ac12.js +0 -2
- package/dist/browser/chunk-task-view.bbeddc793a5e8a6d1f66b6cc5f0ce1da18414137e85c49ccd07be0e20f61ac12.js.br +0 -0
- package/dist/browser/chunk-task-view.bbeddc793a5e8a6d1f66b6cc5f0ce1da18414137e85c49ccd07be0e20f61ac12.js.gz +0 -0
- package/dist/browser/chunk-team-chat.c3255a5a1d94e39d559c07438c4690543602b1552b2c2bf57b8791d7f989141d.js +0 -2
- package/dist/browser/chunk-team-chat.c3255a5a1d94e39d559c07438c4690543602b1552b2c2bf57b8791d7f989141d.js.br +0 -0
- package/dist/browser/chunk-team-chat.c3255a5a1d94e39d559c07438c4690543602b1552b2c2bf57b8791d7f989141d.js.gz +0 -0
- package/dist/browser/workspace.aebb60d4e5ef4509a80cfaccf0af5f7246867ec7531a1734dd8e28c59594950e.js.br +0 -0
- package/dist/browser/workspace.aebb60d4e5ef4509a80cfaccf0af5f7246867ec7531a1734dd8e28c59594950e.js.gz +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
import{localOwnerRefusal}from"../local-owner.js";import{broughtInOnBranch,keptHandoffOf,landingHistoryOf,landingOf,publishesThroughPullRequests}from"../local-landing.js";import{requestContext}from"./request-context.js";import{heldFindingCount}from"../findings.js";import{familyInWebReach}from"../findings.js";import{existsSync}from"node:fs";import{resultRecordWordsOf}from"../route-results.js";import{selectionEvidenceWords}from"../route-rules.js";import{feedbackImageProblem}from"../result-actions.js";import{parseFeedbackImage}from"../result-review.js";import{releaseViewOf}from"../release-view.js";import{RELEASE_STEPS}from"../release.js";import{agentSaidOf,releaseProgressFor,shipChecksForTask}from"../store.js";import{releaseCiRunningOf}from"../release-ci-hold.js";import{releaseObligationsOf}from"../release-recheck.js";import{approvalProofOf,freshnessFor,withFreshness}from"../scope.js";import{sessionYesPossible}from"./send-back-build.js";import{approvalPasswordField}from"../approval-password.js";import{fastChangeProblem,fastStarted}from"../fast-start.js";import{routeChangeOf}from"../route-change.js";import{liveAttemptOf,steerControlsFor}from"../steer-controls.js";import{originOf}from"../task-source.js";import{recentGitReads,taskBaseOf}from"../task-base.js";import{landedNowOf}from"../merge-checklist.js";import{assignmentPresentationOf,assignmentStatusOf,assignmentWithEvidence,historicalAssessmentReason}from"../assignment-presentation.js";import{assignmentOf,personCompletionRefusal}from"../assignment.js";import{codexOfflineDependencySuggestion,failedAttemptSentence,failingCheckSuggestion,GENERAL_SUGGESTION,isInternalErrorReason,latestFinishedAttempt,missedRequirementLine,missedRequirementSuggestion,NO_REASON_RECORDED,stopSuggestionOf}from"../needs-you.js";import{planAutoPending}from"../plan-auto.js";import{planSourceOf,retryPinsOf}from"../local-owner-acts.js";import{planBackoffFor,planStoppedFor}from"../engine-reads.js";import{readKnowledgeSnapshot}from"../project-knowledge.js";import{learningView}from"../project-learning.js";import{readSkillsSnapshot,skillTestResult}from"../project-skills.js";import{newestPullRequestOf,publishingOf,pullRequestBlocker}from"../pull-request-flow.js";import{structuredHandoffView,terminalDiffView}from"../result-evidence-readers.js";import{resultCheckLevel}from"../result-follow-ups.js";import{projectCheckSet}from"../check-levels.js";import{archiveOf}from"../store.js";import{runActivityOf}from"../task-activity.js";import{taskFingerprint}from"../task-live.js";import{pullRequestFactOf}from"../task-status.js";import{openWorkDecisionOf}from"../work-summary.js";import{stepRowsOf}from"../workspace-projection.js";import{lastIncludedWords}from"../memory-use.js";import{plural}from"../design/kit.js";import{createHash,randomBytes,randomUUID}from"node:crypto";import"node:http";import{agentChoicesFor,routeOfTask}from"../agentconfig.js";import{rulesSummary}from"../approval-policy.js";import{hasForbiddenControls}from"../decision.js";import{diagnoseTaskDispatch}from"../dispatch.js";import{readVerifiedArtifact,readVerifiedReport}from"../evidence.js";import{computeGaps}from"../gaps.js";import{projectRoute}from"../phase-routing.js";import{milestonesOf,parseExecutionPlanDocument}from"../plan.js";import{contractChangesOf,decodePlanContractRecord,describeContractChanges}from"../planner-source.js";import{projectName}from"../project.js";import{isRevisionFeedback}from"../result-review.js";import{buildReviewOf}from"../review-switch.js";import{isAlive as runnerAlive}from"../runner.js";import{approvalOf}from"../scope.js";import{oneLineOf}from"../plain-words.js";import"./screen.js";import{refuse}from"./refuse.js";import{chatResultHref,refusedInPlace,taskChatHref,taskHref}from"./http.js";import{decisionsFor}from"./chat-projection.js";import"../task-projection.js";import{completionReceiptView,diffFileAnchor,evidenceLinksFor,followUpsFor,orderChangedFiles,parseReviewDiff,proofBundleView,receiptStatusOf,withinSignedTouches}from"../result-projection.js";import{approvalSummaryOf,summaryContextOf}from"../approval-summary.js";import{approvalDecisionFor}from"../approval-decision.js";import{approvalFormDigest,consentDoorOf,nonceHashOf,publicationFactsOf,resumeDigestOf}from"../task-projection.js";import{buildTaskView,followThroughData}from"./task-view-data.js";import"./session.js";import{mergeReadyViewOf}from"./merge-ready-view.js";import{machineChecked,machineCheckWords}from"../machine-check.js";import{budgetHoldWords,budgetLabel,monthOf}from"../spend.js";import"../store.js";import{taskControlOf}from"../task-control.js";import{taskLinkFromLegacy,taskLinkOf}from"../task-link.js";import{lastErrorLineOf,missedRequirementOf,workStatusOf}from"../workspace-projection.js";export function createTaskViews(runtime){const baseGit=recentGitReads();function guided(rootId,now){if(runtime.store.isDemo())return!1;if(runtime.store.firstSuccessAt(now)===null)return!0;const first=runtime.store.handle.prepare("SELECT id FROM task ORDER BY created_at, rowid LIMIT 1").get();return first!==void 0&&String(first.id)===rootId}function projectFamilyPeek(repo,now){const row=runtime.projectCounts(now).find(one=>one.repo===repo);return{waiting:row?.totals["needs-you"]??0,running:row?.totals.running??0,queued:row?.queued??0,doneRecently:row?.doneRecently??0}}function familiesInView(project,options={}){return runtime.store.taskFamiliesAdmitted(project===null?runtime.admissionList():runtime.visible(project)?[project]:[],runtime.visible(null),options)}function familyTasksInView(project,state,limit=200){return familiesInView(project,{...state===void 0?{}:{states:[state]},limit}).map(family=>({...family.current,id:family.root.id,title:family.root.title}))}function revisionDestination(child,back){const root=runtime.familyOf(child)?.root.id??child;if(!back.startsWith("/chat?"))return`${taskHref(root)}?version=${encodeURIComponent(child)}`;const conversation=new URL(back,"http://localhost").searchParams.get("conversation");return`${taskChatHref(root)}&revision=${encodeURIComponent(child)}${conversation?"&conversation="+encodeURIComponent(conversation):""}`}function earlierLiveVersions(family,now){const ids=family.versions.filter(one=>one.id!==family.current.id).map(one=>one.id);return ids.length===0?[]:runtime.store.taskActivityCandidates(family.root.repo===null?[]:[family.root.repo],family.root.repo===null,now,ids).filter(task=>workRowOf(task,now).status.views.includes("running")).map(task=>task.id)}function freshAssignment(assignment,receipt){if(assignment===null)return null;const value=assignmentWithEvidence(assignment,receipt===null?null:receiptStatusOf(receipt),receipt?.runId??null);return receipt===null?value:{...value,attention:[...new Set([...value.attention,...receipt.facts.evidenceProblems,...receipt.caveats.filter(reason=>!historicalAssessmentReason(reason))])]}}function workRowOf(task,now,receipt){const ref=runtime.store.lookupRef(task.id),runs=ref===null?[]:runtime.store.runsFor(ref.id),latest=runs.find(runIsTaskResult)??null,verdict=latest===null?null:runtime.store.proofVerdictFor(latest.id),live=runs.find(one=>runIsLive(one))??null,facts={id:task.id,heldFindings:heldFindingCount(runtime.store,task.id),title:task.title,repo:task.repo,state:task.state,updatedAt:task.updatedAt,dispatch:diagnoseTaskDispatch(runtime.store,task.id,now),result:task.state!=="done"||latest===null?null:{runId:latest.id,role:latest.role,outcome:latest.outcome,verdict:verdict?.verdict??null,reasons:verdict?.reasons??[],accepted:runtime.store.proofAcceptance(latest.id)!==null,checkLevel:resultCheckLevel(runtime.store,latest.id,now),...ref?.repo==null?{}:{checkSet:projectCheckSet(runtime.store,ref.repo)},review:runtime.reviewFactsFor(latest.id),...latest.outcome!=="no-change"?{}:{recordComplete:(()=>{const kinds=new Set(runtime.store.artifactsFor(latest.id).map(one=>one.kind));return kinds.has("handoff")&&kinds.has("terminal-diff")})()}},publication:latest===null?null:publicationFactsOf(runtime.store.publicationForRun(latest.id)),liveRunId:live===null?null:live.id,...machineChecked(runtime.store,task.id)?{machine:!0}:{},openDecision:ref===null?null:openWorkDecisionOf(runtime.store,ref.id,now),unfinishedRunId:runs.find(one=>one.outcome===null&&one.role!=="reviewer")?.id??null,control:ref===null?{kind:"none"}:taskControlOf(runtime.store,ref.id,now)},result=receipt===void 0&&task.state==="done"&&latest!==null&&(latest.outcome==="built"||latest.outcome==="no-change")?completionReceiptView(runtime.store,latest,runtime.store.artifactsFor(latest.id),runtime.evidenceRoot,runtime.reviewFactsFor(latest.id)):receipt,status=workStatusOf(facts,result==null?void 0:receiptStatusOf(result)),earlierLive=task.family===void 0?[]:earlierLiveVersions(task.family,now);earlierLive.length>0&&!status.views.includes("running")&&(status.views=[...status.views,"running"]);const otherActive=new Set([...task.family?.otherActive.map(one=>one.id)??[],...earlierLive]).size,recordedAssignment=task.family===void 0?null:assignmentOf(runtime.store,task.id,now,runtime.workAccess(),runtime.evidenceRoot),assignment=freshAssignment(recordedAssignment,result??null),assignmentStatus=assignment===null?status:assignmentStatusOf(assignment,status);return status.views.includes("running")&&!assignmentStatus.views.includes("running")&&(assignmentStatus.views=[...assignmentStatus.views,"running"]),{...facts,executionId:task.id,id:task.family?.root.id??task.id,title:task.family?.root.title??task.title,familyNotice:task.family?.problem??(otherActive?`${otherActive} earlier version${otherActive===1?" is":"s are"} still waiting or running. Open History.`:null),status:assignment===null?status:{...assignmentStatus,diagnostics:assignmentPresentationOf(assignment,{workStatus:status,diagnostics:[...status.diagnostics??[],...status.tone==="problem"&&status.detail!==assignment.detail?[status]:[]]}).diagnostics},assignment,assignmentProblem:status.tone==="problem",resultRunId:latest===null?null:latest.id}}function runIsLive(run){return run.outcome===null&&runtime.store.currentLiveLease(run.taskRef,runtime.clock())===run.leaseId}const runIsTaskResult=run=>run.finishedAt!==null&&(run.role==="builder"||run.role==="scout");function revisionViewOf(ref){if(ref===null||ref.revisionBriefArtifact===null)return null;const artifact=runtime.store.getArtifact(ref.revisionBriefArtifact);if(artifact===null)return{problem:"the revision brief is missing from this build's records"};const read=readVerifiedArtifact(runtime.evidenceRoot,artifact);if(!read.ok)return{problem:`the revision brief no longer verifies — ${read.problem}`};try{const parsed=JSON.parse(read.content.toString("utf8"));return{sourceTask:String(parsed.sourceTask??"?"),sourceRun:Number(parsed.sourceRun??0),kind:parsed.kind==="ci-repair"?"ci-repair":parsed.kind==="criterion-repair"?"criterion-repair":"annotations",lineage:runtime.store.revisionLineageOf(ref.externalId,runtime.clock()),comments:(parsed.comments??[]).slice(0,100).map(one=>({id:typeof one.id=="number"&&Number.isSafeInteger(one.id)?one.id:null,path:one.path===null||one.path===void 0?null:String(one.path),line:one.line===null||one.line===void 0?null:Number(one.line),note:String(one.note??""),author:String(one.author??"?"),image:parseFeedbackImage(one.image)||null}))}}catch{return{problem:"the revision brief did not parse"}}}function taskViewData(taskId,who,problem,render={}){const found=runtime.store.getTask(taskId);if(found===null)return null;const ref=runtime.store.lookupRef(taskId);if(ref!==null&&!runtime.visible(ref.repo))return null;const now=runtime.clock(),scope=runtime.store.getScope(taskId),revision=revisionViewOf(ref),revisionBroken=revision!==null&&"problem"in revision,planView=ref===null?null:planViewOf(ref.id),routeView=routeViewOf(taskId,ref,scope,now,who),approvalSummary=scope===null?null:approvalSummaryOf(scope,summaryContextOf(runtime.store,taskId,scope,now,routeView?.evidence??null)),approvalDigest=scope===null?null:approvalFormDigest(scope.digest,planView?.sha256??null,approvalSummary?.key??null),nonce=who.via==="cookie"&&scope!==null&&approvalDigest!==null&&!approvalOf(scope).approved&&!revisionBroken&&ref?.plan!=="requested"&&consentDoorOf(scope,routeView).open?render.mintNonce===!1?"unminted":runtime.mintApprovalNonce(who.name,taskId,approvalDigest):"",runs=ref===null?[]:runtime.store.runsFor(ref.id),completion=(()=>{const latest=runs.find(runIsTaskResult);if(latest===void 0)return null;const artifacts=runtime.store.artifactsFor(latest.id),verdict=runtime.store.proofVerdictFor(latest.id),review=runtime.reviewFactsFor(latest.id);return{runId:latest.id,outcome:latest.outcome,hasTerminalDiff:artifacts.some(one=>one.kind==="terminal-diff"),hasHandoff:artifacts.some(one=>one.kind==="handoff"),proofVerdict:verdict?.verdict??null,machineVerdict:verdict?.machineVerdict??null,proofReasons:verdict?.reasons??[],proofMatrix:verdict?.matrix??[],proofMatrixLinks:evidenceLinksFor(artifacts),proofAccepted:runtime.store.proofAcceptance(latest.id)!==null,qualityMode:latest.qualityMode??"default",repairChain:runtime.store.repairChainFor(latest.id)??runtime.store.repairChainForDraft(taskId),reviewRetry:runtime.store.reviewRetryStateOf(latest.id),review,receipt:latest.outcome==="built"||latest.outcome==="no-change"?completionReceiptView(runtime.store,latest,artifacts,runtime.evidenceRoot,review):null}})(),planRevisions=ref===null?null:revisionLedgerOf(ref.id),milestoneProgress=ref===null?null:progressOf(ref.id,planRevisions?.current?.document??null),family=runtime.familyOf(taskId),recordedAssignment=family?.current.id!==taskId?null:assignmentOf(runtime.store,taskId,now,runtime.workAccess(),runtime.evidenceRoot),assignment=freshAssignment(recordedAssignment,completion?.receipt??null),progressRun=runs.find(one=>runIsLive(one))?.id??completion?.runId??null;return{guide:guided(family?.root.id??taskId,now),assignment,checkProgress:progressRun===null?null:runtime.store.checkProgress(progressRun),task:found,status:workRowOf({...found,repo:ref?.repo??null},now,completion?.receipt).status,dispatch:diagnoseTaskDispatch(runtime.store,taskId,now),control:ref===null?{kind:"none"}:taskControlOf(runtime.store,ref.id,now),canRetryReview:who.via==="cookie"&&who.role==="approver",strikes:ref?.strikes??0,filer:runtime.store.taskFiler(taskId),budgetHold:(()=>{if(ref===null||found.state!=="queued")return null;const hold=runtime.store.budgetGate(now)({...runtime.store.budgetSubject(ref.id),agents:runtime.store.agentsFor([runtime.store.getScope(taskId)?.approvedProfile?.provider??"claude"])});return hold.over===null?null:hold.why==="unpriced"?`${budgetHoldWords(hold,monthOf(now).name)}; this waits until then`:`${budgetLabel(hold.over)} monthly budget is used up, so this waits until next month or a higher budget`})(),policyHold:(()=>{if(ref===null||found.state!=="queued")return null;const base=runtime.store.getScope(taskId)?.approvedProfile??null;if(base===null)return null;const verdict=runtime.store.runPolicy(base);return verdict.ok?verdict.lowered:`${verdict.message.replace(/ An instance operator can change it in Settings → Policy\.$/,"")} It waits until the policy allows it.`})(),approvalRules:(()=>{const repo=ref?.repo??null;if(repo===null)return null;const rules=runtime.store.approvalRules(repo);if(!rules.notRequester&&!rules.protectProject&&rules.protectedPaths.length===0)return null;const gate=runtime.store.approvalGate(taskId,"\0nobody","person");return{words:rulesSummary(rules),votes:runtime.store.approvalVotes(taskId).map(one=>one.approver),needsTwo:gate.verdict==="vote"||gate.verdict==="seal"&&gate.protectedWork}})(),plan:ref?.plan??null,planAuto:planAutoPending(runtime.store,taskId,now),planSource:planSourceOf(runtime.store,taskId),retryPins:retryPinsOf(runtime.store,taskId),planStopped:planStoppedFor(runtime.store,taskId),planBackoff:planBackoffFor(runtime.store,taskId,now),planDocument:planView?.document??null,planSha:planView?.sha256??null,planContract:ref===null||planView===null?null:planContractViewOf(ref.id,scope),deliverable:ref?.deliverable??"branch",report:ref===null?null:readVerifiedReport(runtime.store,runtime.evidenceRoot,ref.id),revision,planRevisions,milestoneProgress,repairChain:completion!==null?null:runtime.store.repairChainForDraft(taskId),repo:ref?.repo??null,filedVia:runtime.store.filedViaOf(taskId),origin:(()=>{const repos=runtime.workAccess().repos;return originOf(runtime.store,taskId,repo=>repos===null||repos.includes(repo))})(),coordinator:(()=>{const who2=runtime.store.coordinatorProvenanceOf(taskId);if(who2===null)return null;const ago=who2.filedAt===null?null:(()=>{const minutes=Math.max(0,Math.round((now.getTime()-new Date(who2.filedAt).getTime())/6e4));return minutes<60?`${minutes}m ago`:minutes<1440?`${Math.round(minutes/60)}h ago`:`${Math.round(minutes/1440)}d ago`})();return{label:who2.label,filedAgo:ago}})(),holds:ref===null?[]:runtime.store.activeHolds(ref.id,now),claimed:ref===null?!1:runtime.store.hasLiveClaim(ref.id,now),waitsFor:runtime.store.blockers(taskId).map(blockerId=>{const blockerRef=runtime.store.lookupRef(blockerId),admitted=blockerRef!==null&&runtime.visible(blockerRef.repo),blocker=admitted?runtime.store.getTask(blockerId):null;return{id:!admitted&&runtime.restricted()?"restricted task":blockerId,title:blocker===null?null:blocker.title,state:blocker===null?null:blocker.state,admitted}}),waitCandidates:(()=>{if(who.via!=="cookie")return[];const candidateRepo=ref?.repo??who.session.project;return candidateRepo===null?[]:runtime.store.listTasksScoped(candidateRepo,void 0,100,null).filter(one=>one.id!==taskId&&(one.state==="queued"||one.state==="running")&&runtime.visible(one.repo)).map(one=>({id:one.id,title:one.title}))})(),liveRunId:(()=>{if(ref===null)return null;const found2=runtime.store.runsFor(ref.id).find(one=>runIsLive(one));return found2===void 0?null:found2.id})(),livePause:(()=>{const run=ref===null?null:runtime.store.liveInputRun(ref.id,now);if(run===null)return null;const pause=runtime.store.livePauseOf(run),until=pause?.pausedAt==null||pause.limitMs===null?null:new Date(Date.parse(pause.pausedAt)+pause.limitMs).toISOString();return{run,state:pause?.state??null,until,limitMs:pause?.limitMs??null}})(),worker:(()=>{const runners=runtime.store.listRunners().filter(one=>one.retiredAt===null),eligible=ref?.repo===null||ref?.repo===void 0?[]:runners.filter(one=>one.repos.includes(ref.repo));return{answering:eligible.filter(one=>runnerAlive(one,now)).length,registered:eligible.length,totalRegistered:runtime.restricted()?eligible.length:runners.length,lastHeard:eligible.map(one=>one.heartbeatAt).sort().at(-1)??null}})(),gaps:ref?.repo===null||ref?.repo===void 0?[]:computeGaps(runtime.store,ref.repo,now).filter(one=>one.unblocks.includes(taskId)||one.alsoBlocks.includes(taskId)),peekable:runtime.options.localRunner!==void 0,position:runtime.store.queuePosition(taskId),mirror:runtime.store.mirrorByTask(taskId),scope,approvalDigest,approvalSummary,approvalDecision:scope===null||approvalOf(scope).approved?null:approvalDecisionFor(runtime.store,taskId,scope,now,{evidenceRoot:runtime.evidenceRoot,access:runtime.workAccess(),viewer:who.name,canSee:repo=>runtime.visible(repo)}),route:routeView,canEditRoute:who.role==="approver",...who.via==="cookie"&&who.authority==="local-owner"&&who.role==="approver"?{routeSignIn:localOwnerRefusal(runtime.store.accountOf(who.name)?.passwordSet===!0,taskHref(taskId))}:{},resultRecord:resultRecordWordsOf(runtime.store,taskId,runtime.evidenceRoot,now),spendDefaults:runtime.store.getSpendDefaults(),permissionDefault:runtime.store.permissionDefault().mode,permissionMode:ref?.permissionMode??null,qualityDefault:runtime.store.qualityDefault().mode,qualityMode:ref?.qualityMode??null,publication:(()=>{if(ref===null)return null;for(const one of runtime.store.runsFor(ref.id)){const found2=runtime.store.publicationForRun(one.id);if(found2!==null)return found2}return null})(),runs,completion,decisions:ref===null?[]:runtime.store.decisionsForTask(ref.id),incidents:ref===null?[]:runtime.store.incidentsForTask(ref.id),coordinatorProposals:(()=>{if(ref===null||ref.repo===null||who.role!=="approver")return null;const rows=runtime.store.listCoordinatorProposals({repos:[ref.repo],taskId});return{rows,decisions:decisionsFor(runtime.store,rows),now}})(),steering:ref===null?[]:runtime.store.listSteerNotes(ref.id),base:taskBaseOf(runtime.store,taskId,baseGit),steeringLive:ref!==null&&runtime.store.steeringLiveBuild(ref.id,now)!==null,steeringRun:ref===null?null:runtime.store.steeringLiveBuild(ref.id,now),release:ref===null?null:releaseViewOf(runtime.store,ref.externalId,now,authority=>releaseObligationsOf(runtime.store,runtime.evidenceRoot,authority)),canStopRelease:who.role==="approver"&&who.via==="cookie",autoRelease:ref===null?null:autoReleaseOf(runtime.store.getScope(ref.externalId)),releaseCiRunning:ref!==null&&releaseCiRunningOf(runtime.store,ref.externalId)!==null,approvalProof:(()=>{const scope2=ref===null?null:runtime.store.getScope(ref.externalId);return scope2===null||scope2.approvedBy===null||scope2.approvedDigest===null?null:approvalProofOf(runtime.store,ref.externalId,scope2.approvedBy,scope2.approvedDigest)})(),...(()=>{const scope2=ref===null?null:runtime.store.getScope(ref.externalId);if(scope2===null||ref===null||who?.via!=="cookie")return{approvalFresh:null,approvalLocal:null};const fresh=withFreshness("approve-standard",()=>freshnessFor(who.name,Date.now(),!0)),field=approvalPasswordField(runtime.store,{name:who.name,taskId:ref.externalId,scope:scope2,passwordless:!1,localOwner:who.authority==="local-owner",freshAt:fresh?.at??null,returnTo:taskHref(ref.externalId)});return{approvalFresh:field.field==="remembered"?field.since:null,approvalLocal:field.field==="none"&&field.why==="local-owner"?{eligible:!0}:field.field==="local-refused"?{eligible:!1,message:field.message,href:field.href,action:field.action}:null}})(),routeChange:ref===null?null:routeChangeOf(runtime.store,ref.externalId),followThroughData:who===void 0||familyInWebReach(runtime.store,who,taskId,runtime.visible)===null?null:followThroughData(runtime.store,runtime.evidenceRoot,taskId,taskHref(taskId),who.role==="approver"&&who.via==="cookie"&&!runtime.store.isDemo(),runtime.clock()),fastGrown:(()=>{if(ref===null||runtime.store.getTask(ref.externalId)?.state!=="done"||!fastStarted(runtime.store,ref.externalId))return null;const last=runtime.store.lastBuilderRun(ref.id);return last===null?null:fastChangeProblem(runtime.store,ref.externalId,last.id)})(),steerRecent:ref===null?[]:runtime.store.runsFor(ref.id).filter(one=>one.outcome!==null).map(one=>one.id).sort((a,b)=>b-a).slice(0,5),steerComposer:(()=>{const run=ref===null?null:liveAttemptOf(runtime.store,ref.id,now);return run===null?null:steerControlsFor(runtime.store,ref.externalId,run,now,who?.role==="approver")})(),grant:ref===null||ref.repo===null?null:runtime.store.publicationGrantFor(ref.repo),csrf:who.via==="cookie"?who.session.csrf:"",nonce,problem,now}}function routeViewOf(taskId,ref,scope,now,who){if(ref===null)return null;const routed=routeOfTask(runtime.store,taskId,ref,now);if(routed===null)return null;const live=runtime.store.hasLiveClaim(ref.id,now),shared={overrides:ref.routeOverrides??[],editable:who.role==="approver"&&!live,editableWhy:who.role!=="approver"?"your login can watch — choosing agents is an approver's act":live?"this task is running — its agents cannot change under a live claim":null,replanOnPlanChange:ref.plan==="drafted"&&scope!==null&&!approvalOf(scope).approved,digest:scope?.digest??null,choices:agentChoicesFor(runtime.store,ref.repo,routed.kind==="route"?routed.route:null),evidence:routed.kind==="route"?selectionEvidenceWords(runtime.store,routed.route,now):null};return routed.kind==="route"?{kind:"route",source:routed.source,projection:projectRoute(routed.route,runtime.store.readinessLookupFor(ref.repo,ref.assignedRunner,now)),legacy:null,problem:null,...shared}:routed.kind==="legacy"?{kind:"legacy",source:null,projection:null,legacy:{provider:routed.profile.provider,model:routed.profile.model,repairModel:routed.profile.repairModel==="inherit"?routed.profile.model:routed.profile.repairModel,approved:routed.approved},problem:null,...shared}:{kind:"unreadable",source:null,projection:null,legacy:null,problem:routed.problem,...shared}}function taskChatFocus(taskId,now,who,options={}){if(taskId===null||taskId.length===0||taskId.length>64||hasForbiddenControls(taskId))return null;const family=runtime.familyOf(taskId);if(family===null)return null;taskId=family.current.id;const task=family.current,ref=runtime.store.lookupRef(taskId),scope=runtime.store.getScope(taskId),view=who===void 0||family.problem!==null?null:taskViewData(taskId,who,null,options),runs=view?.runs??runtime.store.runsFor(ref.id),latest=runs.find(runIsTaskResult)??null,approval=approvalOf(scope),live=runs.find(one=>runIsLive(one))??null,planRevisions=view?.planRevisions??revisionLedgerOf(ref.id);return{id:family.root.id,executionId:task.id,family,guide:guided(family.root.id,now),historyData:familyHistoryData(family),title:family.root.title,state:task.state,status:view?.status??workRowOf({...task,repo:ref.repo},now).status,assignment:view?.assignment??assignmentOf(runtime.store,task.id,now,runtime.workAccess(),runtime.evidenceRoot),project:ref.repo===null?null:projectName(ref.repo),now,dispatch:diagnoseTaskDispatch(runtime.store,taskId,now),scope:scope===null?"none":approval.approved?"approved":"needs approval",plan:ref.plan,planRevisions,milestoneProgress:view?.milestoneProgress??progressOf(ref.id,planRevisions?.current?.document??null),failure:task.state==="failed"?failureOf(family.versions.flatMap(version=>runtime.store.runsFor(version.refId)),view?.assignment??assignmentOf(runtime.store,task.id,now,runtime.workAccess(),runtime.evidenceRoot)):null,claimed:view?.claimed??runtime.store.hasLiveClaim(ref.id,now),liveRun:live===null?null:{id:live.id,runner:live.runner,startedAt:live.startedAt,phase:live.phase},checkProgress:view?.checkProgress??(live===null&&latest===null?null:runtime.store.checkProgress((live??latest).id)),control:view?.control??taskControlOf(runtime.store,ref.id,now),route:view?.route??null,approval:view===null||who?.role!=="approver"||scope===null||approval.approved?null:{scope,nonce:view.nonce,digest:view.approvalDigest??scope.digest,summary:view.approvalSummary??null,planDocument:view.planDocument,planContract:view.planContract??null,deliverable:view.deliverable??"branch",revision:view.revision??null,coordinator:view.coordinator??null,origin:view.origin??null,repairChain:view.repairChain??null,releaseCiRunning:view.releaseCiRunning===!0},decisions:(view?.decisions??runtime.store.decisionsForTask(ref.id)).filter(one=>one.state==="open"||one.state==="expired").map(one=>({...one,taskId:task.id,repo:ref.repo})),publication:view?.publication??null,result:view?.completion?.receipt!==void 0&&view.completion.receipt!==null?view.completion.receipt:latest===null||latest.outcome!=="built"&&latest.outcome!=="no-change"?null:completionReceiptView(runtime.store,latest,runtime.store.artifactsFor(latest.id),runtime.evidenceRoot,runtime.reviewFactsFor(latest.id))}}function pullRequestTargetOf(runId){const run=runtime.store.getRun(runId),publishing=publishingOf(runtime.store,run===null?null:runtime.store.refById(run.taskRef)?.repo??null);return!publishing.on||publishing.legacy||runtime.store.publicationForRun(runId)!==null||pullRequestBlocker(runtime.store,runId)!==null?null:`${publishing.githubRepo} into ${publishing.base}`}function taskPullRequestOf(taskId,who){const family=runtime.familyOf(taskId),rootId=family?.root.id??taskId,repo=runtime.store.lookupRef(taskId)?.repo??null,publishing=publishingOf(runtime.store,repo),target=publishing.on?publishing.base:null,view=newestPullRequestOf(runtime.store,family===null?[taskId]:family.versions.map(one=>one.id));if(view!==null){const publication=runtime.store.publicationForRun(view.runId),fact=publication===null?null:{...pullRequestFactOf({...publication,merged:view.state==="merged"}),note:view.state==="merged"?`${view.detail}${view.mergeCommit===null?"":` Merge commit ${view.mergeCommit.slice(0,12)}.`}`:null};return{taskId:rootId,view:{...view,canMerge:view.canMerge&&who.role==="approver"&&who.via==="cookie"},offer:null,target,fact}}if(!publishing.on||who.via!=="cookie"||who.role!=="approver")return null;const assignment=assignmentOf(runtime.store,taskId,runtime.clock(),runtime.workAccess(),runtime.evidenceRoot),receipt=assignment?.receipt??null;return assignment?.state!=="complete"||receipt===null||runtime.store.publicationForRun(receipt.runId)!==null||pullRequestBlocker(runtime.store,receipt.runId)!==null?null:{taskId:rootId,view:null,offer:{taskId:receipt.taskId,runId:receipt.runId,digest:receipt.digest},target}}function taskLandingOf(taskId,who){const repo=runtime.store.lookupRef(taskId)?.repo??null;if(repo===null||publishesThroughPullRequests(runtime.store,repo))return null;const rootId=runtime.familyOf(taskId)?.root.id??taskId,record=landingOf(runtime.store,rootId),assignment=assignmentOf(runtime.store,taskId,runtime.clock(),runtime.workAccess(),runtime.evidenceRoot),complete=assignment?.state==="complete";if(!complete&&record===null)return null;const person=who.via==="cookie"&&who.role==="approver",history=landingHistoryOf(runtime.store,repo,rootId,complete?assignment?.receipt?.head??null:null,baseGit);if(history!==null&&!history.recorded)return{taskId:rootId,landed:history.words,onBranch:!0,canLand:!1,canUndo:person&&!history.reverted&&broughtInOnBranch(runtime.store,repo,rootId,baseGit)};const standing=history,kept=complete&&(record===null||record.undone)?keptHandoffOf(runtime.store,repo,rootId,assignment?.receipt?.head??null):null;return{taskId:rootId,landed:standing?.words??null,onBranch:standing?.landed===!0,canLand:person&&complete&&(record===null||record.undone),canUndo:person&&record!==null&&!record.undone&&standing?.reverted!==!0,...kept===null?{}:{kept}}}function failureOf(runs,assignment,readLog=!0){const last=latestFinishedAttempt(runs);if(last===null)return{kind:"reason",line:NO_REASON_RECORDED,evidence:null,suggestion:GENERAL_SUGGESTION,link:null};const full=runtime.store.getRun(last.id);return full===null?{kind:"reason",line:failedAttemptSentence(last.reason),evidence:null,suggestion:stopSuggestionOf(last.reason),link:null}:explainAttempt(full,assignment?.receipt?.runId===last.id?assignment.receipt:null,readLog)}function explainAttempt(run,receipt,readLog=!0){const taskId=runtime.store.externalIdFor(run.taskRef)??"",page=taskLinkOf({task:taskId,run:run.id}),see=taskId===""?null:{label:`See build #${run.id}`,href:page},artifacts=runtime.store.artifactsFor(run.id),logArtifact=readLog?receipt?.checks.status==="failed"&&receipt.checks.logArtifactId!==null?artifacts.find(one=>one.id===receipt.checks.logArtifactId)??null:[...artifacts].reverse().find(one=>one.kind==="check-log")??null:null;if(logArtifact!==null){let read=null;try{read=readVerifiedArtifact(runtime.evidenceRoot,logArtifact)}catch{read=null}const text=read!==null&&read.ok?read.content.toString("utf8"):null,exit=text===null?null:/^\(exit (-?[0-9]+)\)$/m.exec(text),failedCheck=receipt?.checks.status==="failed"||exit!=null&&Number(exit[1])!==0,found=text!==null&&failedCheck?lastErrorLineOf(text):null;if(found!==null){const line=oneLineOf(found.text,140);return{kind:"check",line:`The check failed: ${line}`,evidence:null,suggestion:failingCheckSuggestion(line),link:taskId===""?null:{label:`Check output, line ${found.line}`,href:taskLinkOf({task:taskId,run:run.id,section:"checks",anchor:`check-log-L${found.line}`})}}}}const verdict=runtime.store.proofVerdictFor(run.id),missed=verdict===null?null:missedRequirementOf(verdict.matrix);if(missed!==null)return{kind:"requirement",line:missedRequirementLine(missed.statement),evidence:missed.evidence===null?null:oneLineOf(missed.evidence,240),suggestion:missedRequirementSuggestion(missed.statement),link:see};const internal=isInternalErrorReason(run.reason);let codexHint=null;if(run.provider==="codex"){const repo=taskId===""?null:runtime.store.lookupRef(taskId)?.repo??null;codexHint=codexOfflineDependencySuggestion({provider:run.provider,agentSaid:agentSaidOf(runtime.store,run.id),hasSetup:repo!==null&&runtime.store.liveWorktreeSetup(repo)!==null})}return{kind:"reason",line:failedAttemptSentence(run.reason),evidence:null,suggestion:codexHint??stopSuggestionOf(run.reason),link:internal?{label:"The recorded error",href:`/r/${run.id}?record=1#run-reason-detail`}:see}}function runChecksHere(runId,who,returnTo){if(runId===null||who.via!=="cookie"||who.role!=="approver"||runtime.store.isDemo())return null;const run=runtime.store.getRun(runId),followUps=run===null?null:followUpsFor(runtime.store,runtime.evidenceRoot,run,runtime.clock());return followUps===null||!(followUps.quick||followUps.full)||followUps.checks.some(one=>one.state==="waiting"||one.state==="running")?null:{action:`/r/${runId}/checks`,level:followUps.full?"full":"quick",returnTo}}function onePageView(view,family,runs,extras){const root=family?.root.id??view.id,current=family?.current.id??view.id,versions=new Set(family?.versions.map(one=>one.id)??[view.id]),results=new Map(runs.filter(run=>runIsTaskResult(run)&&(extras.admissible===void 0||extras.admissible.has(run.id))).map(run=>[run.id,run.taskId])),tabHref=(taskId,run,section,hash)=>`${taskHref(root)}?${taskId!==current?`version=${encodeURIComponent(taskId)}&`:""}tab=result${run===null?"":`&run=${run}`}${section===null||section==="summary"?"":`§ion=${section}`}${hash}`,toTab=href=>{const canonical=taskLinkFromLegacy(href)??href,result=/^\/t\/([A-Za-z0-9._~%-]{1,200})\?tab=result(?:&run=([0-9]{1,15}))?(?:§ion=(summary|changes|checks))?(#[A-Za-z0-9_.:-]{1,160})?$/.exec(canonical);if(result!==null){const named=decodeURIComponent(result[1]),run=result[2]===void 0?null:Number(result[2]),taskId=run!==null&&named===root&&results.has(run)?results.get(run):named;if(versions.has(taskId))return tabHref(taskId,run,result[3]??null,result[4]??"")}const record=/^\/r\/([0-9]{1,15})$/.exec(href);return record!==null&&results.has(Number(record[1]))?tabHref(results.get(Number(record[1])),Number(record[1]),null,""):href},link=one=>one===null?null:{...one,href:one.href===null?null:toTab(one.href)},status=view.status===null?null:{...view.status,action:view.status.action===null?null:link(view.status.action),status:{...view.status.status,details:view.status.status.details.map(one=>({...one,href:one.href===null?null:toTab(one.href),action:one.action===null?null:link(one.action)}))}},selected=extras.result?.selected??null,builds=runs.filter(run=>run.role==="builder"||run.role==="scout"||run.role==="repair").map(run=>run.id).sort((a,b)=>a-b),attempts=[...results.entries()].sort((a,b)=>b[0]-a[0]).map(([id,taskId])=>{const run=runs.find(one=>one.id===id),outcome=run.outcome==="built"?"result":run.outcome==="no-change"?"no change":run.outcome===null?"never finished":run.outcome,at=builds.indexOf(id);return{label:`${at<0?`Build #${id}`:`Attempt ${at+1}`} · ${outcome}`,href:tabHref(taskId,id,null,""),current:selected?.build===id}});return{...view,status,...view.failure==null?{}:{failure:{...view.failure,link:link(view.failure.link)}},...view.earlier==null?{}:{earlier:{...view.earlier,attempts:view.earlier.attempts.map(one=>({...one,href:toTab(one.href)}))}},...view.thread===void 0?{}:{thread:view.thread.map(one=>({...one,link:link(one.link)}))},sections:selected===null?view.sections:view.sections.filter(one=>one.id!=="result"),tab:extras.tab??"activity",result:selected===null?null:{selected,current:extras.result.current,attempts,revision:createHash("sha256").update(JSON.stringify(selected).replace(/\b[a-f0-9]{32}\b/g,"")).digest("hex").slice(0,16)}}}function taskScreen(response,who,taskId,problem,status,scopeDraft,cancelDraft,editPlan=!1,extras={}){if(problem!==null&&refusedInPlace(response,status,problem))return;const admittedFamily=runtime.familyOf(taskId);if(admittedFamily?.problem!=null)return runtime.sendScreen(response,status,{title:admittedFamily.root.title,chrome:runtime.chromeFor(admittedFamily.root.repo,"tasks"),workspace:{view:{kind:"task-history-problem",title:admittedFamily.root.title,state:admittedFamily.current.state,problem:admittedFamily.problem,result:extras.result==null?null:{selected:extras.result.selected,current:extras.result.current}}}});const data=taskViewData(taskId,who,problem,{mintNonce:requestContext.getStore()?.readPurpose!=="prefetch"});if(data===null)return refuse(response,who,404,"no such task","/");const family=runtime.familyOf(taskId),presentedData={...data,rootId:family?.root.id??taskId,rootTitle:family?.root.title??data.task.title,...family===null||data.assignment!=null?{}:{historyData:familyHistoryData(family)},versionLabel:family!==null&&family.current.id!==taskId?`Viewing ${family.versions.findIndex(one=>one.id===taskId)===0?"Original":`Revision ${family.versions.findIndex(one=>one.id===taskId)}`} · ${family.current.state==="running"?"A newer revision is running":"A newer revision is current"}`:null,archived:archiveOf(runtime.store,taskId),canPutAway:who.via==="cookie"&&who.role==="approver",...scopeDraft===void 0?{}:{scopeDraft},...cancelDraft===void 0?{}:{cancelDraft},...editPlan?{editPlan:!0}:{},pullRequest:taskPullRequestOf(taskId,who),landing:taskLandingOf(taskId,who),demo:runtime.store.isDemo()};family!==null&&family.problem===null&&(presentedData.family={root:{id:family.root.id,title:family.root.title,createdAt:family.root.createdAt,goal:runtime.store.getScope(family.root.id)?.goal??null},versions:family.versions.map(one=>({id:one.id,title:one.title,state:one.state})),runs:family.versions.flatMap(version=>version.id===data.task.id?data.runs.map(run=>({...run,taskId:version.id})):runtime.store.runsFor(version.refId).map(run=>({...run,taskId:version.id})))}),presentedData.failure=failureOf(presentedData.family?.runs??data.runs,data.assignment??null),presentedData.runChecks=runChecksHere(data.assignment?.receipt?.runId??null,who,taskHref(taskId));const liveRun=data.liveRunId==null?void 0:data.runs.find(one=>one.id===data.liveRunId);liveRun!==void 0&&(presentedData.activity=runActivityOf(runtime.store,liveRun,runtime.clock()));const paneProject=runtime.restricted()?runtime.store.lookupRef(taskId)?.repo??null:who.via==="cookie"?who.session.project:null,chrome=runtime.chromeFor(paneProject,"tasks"),firstView=buildTaskView(presentedData),mergeReady=mergeReadyViewOf(runtime.store,taskId,data.assignment??null,who,presentedData.runChecks??null,taskHref(taskId),landedOf(presentedData),data.base??null),sensitive=presentedData.pullRequest?.view?.canMerge===!0&&!(who.via==="cookie"&&who.authority==="local-owner")||firstView.approve!=null&&!firstView.approve.facts.passwordless||firstView.lead.some(b=>b.key==="plan-revisions"&&b.ledger.pending?.requiresPassword===!0||b.key==="mirror"&&b.reopenAction!==null),builtView=sensitive?buildTaskView({...presentedData,degraded:"sensitive"}):firstView,focus=taskChatFocus(family?.root.id??taskId,runtime.clock(),who,{mintNonce:!1}),docked=focus===null?null:runtime.dockedConversation(who,focus,null,runtime.clock(),taskHref(focus.id));let taskView={...builtView,...docked===null?{}:{tabs:[]},...who.role==="approver"?{}:{chatHref:null},...who.via==="cookie"?{live:{room:`task:${encodeURIComponent(family?.root.id??taskId)}`,at:(()=>{try{return taskFingerprint(runtime.store,family?.root.id??taskId,runtime.clock())}catch{return null}})()}}:{}};const tab=extras.tab??"plan";taskView=onePageView(taskView,family,presentedData.family?.runs??data.runs.map(run=>({...run,taskId:data.task.id})),{...extras,tab});const rootId=family?.root.id??taskId;if(taskView={...taskView,ship:shipViewOf(shipChecksForTask(runtime.store,rootId),runtime.clock()),release:releaseStepsViewOf(releaseProgressFor(runtime.store,rootId),runtime.clock()),mergeReady},machineChecked(runtime.store,taskId)){const words=machineCheckWords(runtime.store,taskId,data.liveRunId??null,taskView.release??null,runtime.clock()),card=taskView.status;words!==null&&card!==null&&card.status.headline==="Building"&&(taskView.status={...card,status:{...card.status,sentence:words}}),taskView.activity=null,taskView.steering=null,taskView.release!=null&&(taskView.journey=null)}if(taskView.steps=stepRowsOf(taskView),extras.result!=null&&!extras.result.current){const build=extras.result.selected.build,historical={label:build===null?"The task has moved on since.":`Build #${build}. The task has moved on since.`,href:taskHref(rootId)},view={kind:"task",id:taskView.id,title:taskView.title,project:taskView.project,scout:taskView.scout,tabs:[],version:taskView.version,status:null,approval:null,lead:[],facts:[],sections:[],manage:[],cancel:null,thread:[],tab:"result",result:taskView.result??null,historical,more:[{group:"share",label:"Copy link",kind:"copy"}]};return runtime.sendScreen(response,status,{title:`task · ${data.task.id}`,chrome,...sensitive?{sensitive:!0}:{refreshSeconds:runtime.liveRefreshSeconds(),functional:{script:"",app:[{kind:"result"}]}},workspace:{view}})}return extras.recordPack!=null&&(taskView.sections=[...taskView.sections.filter(one=>one.id!=="record"),{id:"record",title:"Record",content:{kind:"record",pack:extras.recordPack},open:!0,count:null}]),runtime.sendScreen(response,status,{title:`task · ${data.task.id}`,chrome,...sensitive?{sensitive:!0}:{refreshSeconds:runtime.liveRefreshSeconds()},...(()=>{if(sensitive)return{};const liveRunId=data.liveRunId??null,liveRun2=liveRunId===null?void 0:data.runs.find(one=>one.id===liveRunId),app=[...liveRun2===void 0?[]:[{kind:"region",region:"check-progress",run:liveRun2.id}],...liveRun2!==void 0&&data.peekable===!0?[{kind:"region",region:"run-peek",run:liveRun2.id}]:[],...data.decisions.some(one=>one.state==="open"||one.state==="expired")?[{kind:"answer"}]:[],...taskView.result!==null?[{kind:"result"}]:[]];return app.length>0?{functional:{script:"",app}}:{}})(),workspace:{view:taskView,...docked===null?{}:{conversation:docked}}})}function armTaskResume(response,who,taskId,named,returnTo,now){if(who.via!=="cookie")return refuse(response,who,403,"resuming a task is a browser session's act");if(who.role!=="approver")return taskScreen(response,who,taskId,"your login can watch — resuming an attempt is an approver's act",403);if(runtime.store.isDemo())return taskScreen(response,who,taskId,"the demo authorizes nothing",403);const ref=runtime.store.lookupRef(taskId);if(ref===null)return taskScreen(response,who,taskId,"That task is not available.",404);if(!/^[0-9]{1,15}$/.test(named))return taskScreen(response,who,taskId,"which attempt? the resume names the exact stopped run",400);const runId=Number(named),stop=runtime.store.stopOf(runId),run=runtime.store.getRun(runId);if(stop===null||run===null||stop.taskRef!==ref.id)return taskScreen(response,who,taskId,`build #${runId} is not a stopped attempt of this task`,409);if(run.role==="reviewer")return taskScreen(response,who,taskId,`build #${runId} was an old review. Nothing reruns it; open the saved result instead`,409);if(stop.resumedAt!==null)return taskScreen(response,who,taskId,`build #${runId} was already resumed by ${stop.resumedBy??"?"}`,409);const control=taskControlOf(runtime.store,ref.id,now);if(control.kind!=="paused"||control.run!==runId)return taskScreen(response,who,taskId,control.kind==="stopping"?`build #${runId} is still stopping. Toolroll is making sure it has ended`:`build #${runId} is no longer the one to resume. Reload and decide again`,409);const digest=resumeDigestOf(taskId,runId,stop.settledAt??"",runtime.store.getScope(taskId)),nonceValue=randomBytes(18).toString("base64url");if(!runtime.store.mintCeremonyNonce({hash:nonceHashOf(nonceValue),approver:who.name,subject:"run-resume",subjectId:runId,digest,ttlMs:15*6e4},now).ok)return taskScreen(response,who,taskId,"too many unfinished confirmations are open — finish or let them expire",429);const gate=diagnoseTaskDispatch(runtime.store,taskId,now),scope=runtime.store.getScope(taskId),blocked=scope!==null&&approvalOf(scope).approved?gate!==null&&gate.code!=="stopped"?`${gate.summary}: ${gate.detail}`:null:"The plan isn't approved as it stands, so nothing builds until it is approved again.";return runtime.sendScreen(response,200,{title:"resume",chrome:runtime.chromeFor(who.session.project,"tasks"),sensitive:!0,workspace:{view:{kind:"task-resume",taskId,taskTitle:runtime.store.getTask(taskId)?.title??taskId,run:control.run,committed:control.committed,nonceValue,returnTo,blocked}}})}function planViewOf(taskRef){const artifact=runtime.store.latestPlanArtifact(taskRef);if(artifact===null)return null;try{const verified=readVerifiedArtifact(runtime.evidenceRoot,artifact);return verified.ok?{document:verified.content.toString("utf8"),sha256:artifact.sha256,run:artifact.run}:null}catch{return null}}function planContractViewOf(taskRef,scope){const artifact=runtime.store.latestPlanContractArtifact(taskRef);if(artifact===null)return null;try{const verified=readVerifiedArtifact(runtime.evidenceRoot,artifact);if(!verified.ok)return{run:artifact.run,problem:`the contract record no longer verifies — ${verified.problem}`};const record=decodePlanContractRecord(verified.content);return record===null?{run:artifact.run,problem:"the contract record is not the JSON it was sealed as"}:{run:artifact.run,sourceDigest:record.sourceDigest,filed:record.filed!==null,amendment:record.amendment,changes:record.changes,changeWords:describeContractChanges(record.changes),current:scope!==null&&contractChangesOf(record.proposed,scope).length===0,revision:runtime.store.revisionSourceOf(taskRef)!==null}}catch{return{run:artifact.run,problem:"the contract record could not be read"}}}function revisionDocOf(row){const artifact=runtime.store.getArtifact(row.artifact);if(artifact===null)return null;try{const verified=readVerifiedArtifact(runtime.evidenceRoot,artifact);return verified.ok?{id:row.id,revision:row.revision,status:row.status,reason:row.reason,evidenceLink:row.evidenceLink,author:row.author,kind:row.kind,authorityKind:row.authorityKind,changedFields:row.changedFields,document:verified.content.toString("utf8"),sha256:artifact.sha256,createdAt:row.createdAt,resolvedAt:row.resolvedAt,resolvedBy:row.resolvedBy}:null}catch{return null}}function revisionLedgerOf(taskRef){const history=runtime.store.listPlanRevisions(taskRef).map(revisionDocOf).filter(view=>view!==null),currentRow=runtime.store.currentPlanRevision(taskRef),latestRow=runtime.store.latestPlanRevision(taskRef),pending=latestRow!==null&&latestRow.status==="blocked"?revisionDocOf(latestRow):null;let current=currentRow===null?null:revisionDocOf(currentRow);if(current===null){const legacy=planViewOf(taskRef);current=legacy===null?null:{id:null,revision:1,status:"applied",reason:"the plan the operator approved",evidenceLink:null,author:"planner",kind:"initial",authorityKind:"plan-only",changedFields:[],document:legacy.document,sha256:legacy.sha256,createdAt:"",resolvedAt:null,resolvedBy:null}}return{current,pending,history}}function progressOf(taskRef,currentDocument){if(currentDocument===null)return null;const parsed=parseExecutionPlanDocument(currentDocument);if(!parsed.ok)return null;const milestones=milestonesOf(parsed.document),checkpoint=runtime.store.latestCheckpointForTask(taskRef),byId=new Map((checkpoint?.snapshot.milestones??[]).map(entry=>[entry.id,entry]));return milestones.map(milestone=>{const entry=byId.get(milestone.id);return{id:milestone.id,description:milestone.description,state:entry?.state??"pending",note:entry?.note??null}})}function resultDetailOf(run,who,now){const taskId=runtime.store.externalIdFor(run.taskRef)??"?",scope=runtime.store.getScope(taskId),artifacts=runtime.store.artifactsFor(run.id),terminal=terminalDiffView(artifacts,runtime.evidenceRoot),proof=proofBundleView(runtime.store,run,artifacts,runtime.evidenceRoot),handoff=structuredHandoffView(artifacts,runtime.evidenceRoot),review=runtime.reviewFactsFor(run.id),receipt=completionReceiptView(runtime.store,run,artifacts,runtime.evidenceRoot,review),patch=terminal?.patch??null,patchOk=patch!==null&&!("problem"in patch),parsedPaths=patchOk?parseReviewDiff(patch.text).files.filter(one=>one.hunks.length>0).map(one=>one.path):[],fileAnchors=new Map(parsedPaths.map(path=>[path,diffFileAnchor(path)])),statFiles=terminal?.stat!==null&&terminal?.stat!==void 0&&!("problem"in terminal.stat)?terminal.stat.files:[],cited=new Set;for(const criterion of proof?.matrix??[])for(const answer of criterion.answered)answer.kind==="changed-path"&&cited.add(answer.ref);const touches=scope?.touches??[],files=orderChangedFiles(statFiles.map(file=>({path:file.path,additions:file.additions,deletions:file.deletions,renamedFrom:file.renamedFrom??null,anchor:fileAnchors.get(file.path)??null,outsideTouches:touches.length>0&&!withinSignedTouches(file.path,touches),cited:cited.has(file.path)})),cited.size>0),publication=runtime.store.publicationForRun(run.id);let skillTest=!1,learningData=null;const learningRepo=runtime.store.refForId(run.taskRef)?.repo;if(learningRepo&&runtime.visible(learningRepo)){const data={contextProblem:null,skillsSnapshot:null,knowledgeSnapshot:null,skillTestProblem:null,skillTest:null,learning:null},csrf=who.via==="cookie"?who.session.csrf:"",canManage=who.role==="approver";try{const view=learningView(runtime.store,runtime.evidenceRoot,learningRepo,who.name),lessons=view.lessons.filter(l=>l.source===run.id);if(lessons.length>0){const platforms={darwin:"macOS",win32:"Windows",linux:"Linux"};data.learning={repo:view.repo,identity:view.identity,revision:view.revision,canManage:canManage&&csrf!=="",source:run.id,lessons:lessons.map(l=>({id:l.id,version:l.version,sha:l.sha,observation:l.payload.observation,action:l.payload.action,lastIncluded:lastIncludedWords(view.use.get(`lesson:${l.id}`)),kindLabel:l.payload.kind==="system"?"System suggestion · No change applied":l.status==="adopted"?"Adopted advice":l.status==="disabled"?"Disabled":"Proposed lesson",isProject:l.payload.kind==="project",status:l.status,source:l.source,reviewer:l.reviewer,metaSummary:`${l.payload.paths.join(", ")} · ${l.payload.phases.join(", ")} · ${platforms[l.payload.platform]??l.payload.platform}`,evidence:l.payload.evidence.map(one=>({runId:one.runId??l.source,artifactId:one.artifactId,excerpt:one.excerpt,sha256:one.sha256}))}))}}}catch{}try{const test=skillTestResult(runtime.store,run.id,who.name);test&&(skillTest=!0,data.skillTest={run:test.run,repo:test.repo,sourceRun:test.sourceRun,feedback:test.feedback,revisions:[...test.revisions],canRevise:canManage&&csrf!=="",nonce:canManage&&csrf!==""?randomUUID():null})}catch{data.skillTestProblem="The saved skill test could not be verified."}try{const skills=readSkillsSnapshot(runtime.store,run.id),knowledge=readKnowledgeSnapshot(runtime.store,run.id);skills&&skills.packages.length>0&&(data.skillsSnapshot={packages:skills.packages.map(s=>({name:s.name,shaShort:s.sha.slice(0,10),source:s.source,fileCountLabel:plural(s.files.length,"file","files"),kb:Math.ceil(s.files.reduce((n,f)=>n+Buffer.from(f.base64,"base64").length,0)/1024),skillMd:Buffer.from(s.files.find(f=>f.path==="SKILL.md").base64,"base64").toString("utf8"),files:s.files.map(f=>f.path)}))}),knowledge&&(data.knowledgeSnapshot={revision:knowledge.revision,inheritedFrom:knowledge.inheritedFrom,instructions:knowledge.instructions,references:knowledge.references.map(r=>({title:r.title,path:r.path,sourceRevision:r.sourceRevision,content:r.content})),omitted:knowledge.omitted.map(r=>({title:r.title,reason:r.reason}))})}catch{data.contextProblem="The context saved for this run could not be verified."}(data.contextProblem!==null||data.skillsSnapshot!==null||data.knowledgeSnapshot!==null||data.skillTestProblem!==null||data.skillTest!==null||data.learning!==null)&&(learningData=data)}const family=runtime.familyOf(taskId);return{learningData,skillTest,taskId,rootId:family?.root.id??taskId,...family===null?{}:{historyData:familyHistoryData(family)},run,receipt,...(()=>{const value=assignmentOf(runtime.store,taskId,now,runtime.workAccess(),runtime.evidenceRoot),assignment=value?.receipt?.runId===run.id&&value.activeTaskId===taskId?freshAssignment(value,receipt):null,completeRefusal=assignment?.state!=="ready-to-check"||assignment.receipt===null?null:personCompletionRefusal(runtime.store,assignment.receipt.taskId,run.id,who.via==="cookie"?who.name:null,runtime.evidenceRoot,who.via==="cookie"&&who.authority==="local-owner"?{rootId:assignment.rootId}:null);return{assignment,completeRefusal,landed:assignment!==null&&landedNowOf(runtime.store,assignment)!==null}})(),handoff,proof,terminal,publication,pullRequestTo:pullRequestTargetOf(run.id),buildNowOnSendBack:who.via==="cookie"&&who.role==="approver"&&(who.authority==="local-owner"||sessionYesPossible(runtime.store,who.name,!0)),publishing:pullRequestTargetOf(run.id)!==null?"pull-request":publishingOf(runtime.store,runtime.store.refById(run.taskRef)?.repo??null).on?"other":"off",ciFailing:publication!==null&&publication.prNumber!==null&&runtime.store.hasOpenCiEpisode(publication.githubRepo,publication.prNumber),files,outsideTouches:files.filter(one=>one.outsideTouches).map(one=>one.path),fileAnchors,comments:runtime.store.liveDiffComments(run.id).filter(isRevisionFeedback),unusableImageNotes:runtime.store.liveDiffComments(run.id).filter(one=>isRevisionFeedback(one)&&one.image!=null&&feedbackImageProblem(runtime.store,runtime.evidenceRoot,run.id,one.image)!==null).map(one=>one.id),pastComments:runtime.store.allDiffComments(run.id).filter(one=>one.reviewerRun===null&&(one.consumedBy!==null||one.supersededBy!==null)),reviewerFindings:runtime.store.allDiffComments(run.id).filter(one=>one.reviewerRun!==null),automaticReview:buildReviewOf(runtime.store,run.id),revisions:runtime.store.revisionsFromRun(run.id).flatMap(one=>{const child=runtime.store.getTask(one.id);if(child===null||!runtime.visible(runtime.store.lookupRef(one.id)?.repo??null))return[];const status=workRowOf({...child,repo:runtime.store.lookupRef(one.id)?.repo??null},now).status;return[{id:one.id,title:one.title,state:one.state,approved:approvalOf(runtime.store.getScope(one.id)).approved,standing:status.label,tone:status.tone}]}),sourceDigest:scope?.digest??null,followUps:followUpsFor(runtime.store,runtime.evidenceRoot,run,now),route:runtime.store.runRoute(run.id),editor:runtime.options.editorLinks!==void 0&&runtime.options.localRunner!==void 0&&run.runner===runtime.options.localRunner&&who.via==="cookie"&&who.session.editorLinks===!0&&run.worktree!==null&&existsSync(run.worktree)?{worktree:run.worktree}:null,signedCriteria:scope?.acceptance.length??0,canAnnotate:who.via==="cookie"&&patchOk&&patch.text.trim()!==""}}function familyHistoryData(family){const problem=family.problem,otherActive=family.versions.length<2?0:new Set([...family.otherActive.map(one=>one.id),...earlierLiveVersions(family,runtime.clock())]).size,versions=family.versions.length<2?[]:family.versions.map((version,index)=>{const label=index===0?"Original":`Revision ${index}`,status=workRowOf(version,runtime.clock()).status,runs=runtime.store.runsFor(version.refId).filter(runIsTaskResult),href=`${taskHref(family.root.id)}?version=${encodeURIComponent(version.id)}`;return{id:version.id,label,current:version.id===family.current.id,statusLabel:status.label,href,runs:runs.map(run=>({id:run.id,href:run.outcome==="built"||run.outcome==="no-change"?chatResultHref(family.root.id,run.id):`/r/${run.id}`,outcomeLabel:run.outcome==="built"?null:run.outcome==="no-change"?"No changes":run.outcome==="failed"?"Failed":run.outcome??"Unfinished"}))}});return problem===null&&versions.length<2?null:{rootId:family.root.id,problem,otherActive,versions}}return{guided,projectFamilyPeek,familiesInView,familyTasksInView,revisionDestination,earlierLiveVersions,familyHistoryData,freshAssignment,workRowOf,runIsLive,runIsTaskResult,revisionViewOf,taskViewData,routeViewOf,taskChatFocus,pullRequestTargetOf,taskPullRequestOf,failureOf,explainAttempt,runChecksHere,taskScreen,armTaskResume,planViewOf,planContractViewOf,revisionDocOf,revisionLedgerOf,progressOf,resultDetailOf}}function autoReleaseOf(scope){return scope===null||scope.approvedDigest!==scope.digest||(scope.candidate??null)===null?null:scope.approvalBasis==="auto-green"?{kind:"approved",candidate:scope.candidate}:scope.approvalBasis==="auto-check"?{kind:"checking",candidate:scope.candidate}:null}export function shipViewOf(ship,now){if(ship===null||ship.checks.length===0)return null;const at=iso=>iso===null?null:Date.parse(iso),observed=Date.parse(ship.observedAt),end=Number.isFinite(observed)?observed:now.getTime(),starts=ship.checks.map(one=>at(one.startedAt)).filter(one=>one!==null&&Number.isFinite(one)),origin=starts.length===0?end:Math.min(...starts),st=state2=>state2==="passed"?"ok":state2==="failed"||state2==="cancelled"?"bad":state2==="running"?"run":state2==="queued"?"q":"ok",rows=ship.checks.map(one=>{const start=at(one.startedAt),done=at(one.completedAt),from=start??origin;return{name:one.name,...one.workflow===null||one.workflow===one.name?{}:{sub:one.workflow},...one.state==="skipped"?{sub:"skipped"}:one.state==="neutral"?{sub:"neutral"}:{},st:st(one.state),start:Math.max(0,(from-origin)/1e3),dur:start===null?0:Math.max(0,((done??end)-start)/1e3)}}),passed=ship.checks.filter(one=>one.state==="passed"||one.state==="skipped"||one.state==="neutral").length,failed=ship.checks.filter(one=>one.state==="failed"||one.state==="cancelled").length,state=ship.observed==="failing"?"failed":ship.observed==="passing"?"passed":ship.observed==="running"?"running":"none";return{pr:ship.prNumber,head:ship.headSha.slice(0,7),state,rows,summary:state==="failed"?failed>0?`${failed} of ${ship.checks.length} ${ship.checks.length===1?"check":"checks"} failed`:"Checks are failing on GitHub":state==="running"?`${passed} of ${ship.checks.length} checks passed`:state==="passed"?`All ${ship.checks.length} ${ship.checks.length===1?"check":"checks"} passed`:"No current checks: the pull request is closed or merged, or GitHub reported none",observedAt:ship.observedAt}}const RELEASE_STEP_WORDS={gate:"Release gate",approval:"Approval",check:"Release check",complete:"Complete the task",quiet:"Wait for quiet",deploy:"Deploy to this Mac",link:"Point the CLI at it",ci:"Pull request checks",merge:"Merge into main",tree:"Verify the merged tree",tag:"Tag",publish:"Publish to npm",homebrew:"Homebrew"};export function releaseStepsViewOf(progress,now){if(progress===null)return null;const origin=Date.parse(progress.startedAt),recorded=new Map(progress.steps.map(one=>[one.step,one])),all=RELEASE_STEPS.filter(step=>step!=="done"),building=progress.building,checkAt=all.indexOf("check"),firstAt=building===null?all.findIndex(step=>recorded.has(step)):Math.min(all.findIndex(step=>recorded.has(step)),checkAt),lastAt=all.reduce((at2,step,index)=>recorded.has(step)?index:at2,-1),steps=firstAt<=0?all:all.slice(firstAt),rows=steps.map(step=>{const one=recorded.get(step);if(building!==null&&step==="check"){const start2=Date.parse(building.startedAt);return{name:RELEASE_STEP_WORDS[step]??step,st:"run",start:Number.isFinite(start2)&&Number.isFinite(origin)?Math.max(0,(start2-origin)/1e3):0,dur:Number.isFinite(start2)?Math.max(0,(now.getTime()-start2)/1e3):0}}if(building!==null&&all.indexOf(step)>checkAt)return{name:RELEASE_STEP_WORDS[step]??step,st:"q",start:0,dur:0};if(one===void 0)return all.indexOf(step)<lastAt?{name:RELEASE_STEP_WORDS[step]??step,sub:"not recorded",st:"q",start:0,dur:0}:{name:RELEASE_STEP_WORDS[step]??step,st:"q",start:0,dur:0};const start=Date.parse(one.startedAt),end=one.endedAt===null?now.getTime():Date.parse(one.endedAt),st=one.state==="failed"&&progress.stopped?.step!==step?"history":one.state==="done"?"ok":one.state==="failed"?"bad":one.state==="waiting"?step==="approval"?"wait":"waiting":"run",waitingReason=st!=="waiting"?null:step==="ci"?"Waiting for PR checks":step==="quiet"?"Waiting for active work to finish":`Waiting for ${(RELEASE_STEP_WORDS[step]??step).toLowerCase()}`,detail=one.state==="done"?null:one.detail??waitingReason;return{name:RELEASE_STEP_WORDS[step]??step,...detail===null?{}:{sub:detail.slice(0,160)},st,start:Number.isFinite(start)&&Number.isFinite(origin)?Math.max(0,(start-origin)/1e3):0,dur:Number.isFinite(start)&&Number.isFinite(end)?Math.max(0,(end-start)/1e3):0}}),current=rows.findIndex(row=>row.st==="run"||row.st==="wait"||row.st==="waiting"||row.st==="bad"),done=progress.stopped===null&&recorded.get("homebrew")?.state==="done",at=current===-1?null:rows[current],last=lastAt===-1?null:RELEASE_STEP_WORDS[all[lastAt]]??all[lastAt];return{tag:progress.tag,version:progress.version,pr:progress.pr,rows,state:progress.stopped!==null?"failed":done?"done":at?.st==="wait"&&steps[current]==="approval"?"waiting":"running",at:current===-1?null:{step:steps[current],name:at.name,index:current+1,of:rows.length},headline:done?`Released ${progress.version}`:progress.stopped!==null?`Stopped at ${RELEASE_STEP_WORDS[progress.stopped.step]??progress.stopped.step}`:at!==null?`${at.name} · Step ${current+1} of ${rows.length}`:last===null?"Starting":`${last} done · the next step starts on its own`,stopped:progress.stopped===null?null:{step:RELEASE_STEP_WORDS[progress.stopped.step]??progress.stopped.step,message:progress.stopped.message,at:progress.stopped.at},startedAt:progress.startedAt}}function landedOf(data){return data.landing?.onBranch===!0?data.landing.landed:null}
|
|
1
|
+
import{broughtInOnBranch,keptHandoffOf,landingHistoryOf,landingOf,publishesThroughPullRequests}from"../local-landing.js";import{requestContext}from"./request-context.js";import{heldFindingCount}from"../findings.js";import{familyInWebReach}from"../findings.js";import{existsSync}from"node:fs";import{resultRecordWordsOf}from"../route-results.js";import{selectionEvidenceWords}from"../route-rules.js";import{feedbackImageProblem}from"../result-actions.js";import{parseFeedbackImage}from"../result-review.js";import{releaseViewOf}from"../release-view.js";import{RELEASE_STEPS}from"../release.js";import{agentSaidOf,releaseProgressFor,shipChecksForTask}from"../store.js";import{releaseCiRunningOf}from"../release-ci-hold.js";import{releaseObligationsOf}from"../release-recheck.js";import{approvalProofOf,freshnessFor,withFreshness}from"../scope.js";import{sessionYesPossible}from"./send-back-build.js";import{approvalPasswordField}from"../approval-password.js";import{fastChangeProblem,fastStarted}from"../fast-start.js";import{routeChangeOf}from"../route-change.js";import{liveAttemptOf,steerControlsFor}from"../steer-controls.js";import{originOf}from"../task-source.js";import{recentGitReads,taskBaseOf}from"../task-base.js";import{landedNowOf}from"../merge-checklist.js";import{assignmentPresentationOf,assignmentStatusOf,assignmentWithEvidence,historicalAssessmentReason}from"../assignment-presentation.js";import{assignmentOf,personCompletionRefusal}from"../assignment.js";import{codexOfflineDependencySuggestion,failedAttemptSentence,failingCheckSuggestion,GENERAL_SUGGESTION,isInternalErrorReason,latestFinishedAttempt,missedRequirementLine,missedRequirementSuggestion,NO_REASON_RECORDED,stopSuggestionOf}from"../needs-you.js";import{planAutoPending}from"../plan-auto.js";import{planSourceOf,retryPinsOf}from"../local-owner-acts.js";import{planBackoffFor,planStoppedFor}from"../engine-reads.js";import{readKnowledgeSnapshot}from"../project-knowledge.js";import{learningView}from"../project-learning.js";import{readSkillsSnapshot,skillTestResult}from"../project-skills.js";import{newestPullRequestOf,publishingOf,pullRequestBlocker}from"../pull-request-flow.js";import{structuredHandoffView,terminalDiffView}from"../result-evidence-readers.js";import{resultCheckLevel}from"../result-follow-ups.js";import{projectCheckSet}from"../check-levels.js";import{archiveOf}from"../store.js";import{runActivityOf}from"../task-activity.js";import{taskFingerprint}from"../task-live.js";import{pullRequestFactOf}from"../task-status.js";import{openWorkDecisionOf}from"../work-summary.js";import{stepRowsOf}from"../workspace-projection.js";import{lastIncludedWords}from"../memory-use.js";import{plural}from"../design/kit.js";import{createHash,randomBytes,randomUUID}from"node:crypto";import"node:http";import{agentChoicesFor,routeOfTask}from"../agentconfig.js";import{rulesSummary}from"../approval-policy.js";import{hasForbiddenControls}from"../decision.js";import{diagnoseTaskDispatch}from"../dispatch.js";import{readVerifiedArtifact,readVerifiedReport}from"../evidence.js";import{computeGaps}from"../gaps.js";import{projectRoute}from"../phase-routing.js";import{milestonesOf,parseExecutionPlanDocument}from"../plan.js";import{contractChangesOf,decodePlanContractRecord,describeContractChanges}from"../planner-source.js";import{projectName}from"../project.js";import{isRevisionFeedback}from"../result-review.js";import{buildReviewOf}from"../review-switch.js";import{isAlive as runnerAlive}from"../runner.js";import{approvalOf}from"../scope.js";import{oneLineOf}from"../plain-words.js";import"./screen.js";import{refuse}from"./refuse.js";import{chatResultHref,refusedInPlace,taskChatHref,taskHref}from"./http.js";import{decisionsFor}from"./chat-projection.js";import"../task-projection.js";import{completionReceiptView,diffFileAnchor,evidenceLinksFor,followUpsFor,orderChangedFiles,parseReviewDiff,proofBundleView,receiptStatusOf,withinSignedTouches}from"../result-projection.js";import{approvalSummaryOf,summaryContextOf}from"../approval-summary.js";import{approvalDecisionFor}from"../approval-decision.js";import{approvalFormDigest,consentDoorOf,nonceHashOf,publicationFactsOf,resumeDigestOf}from"../task-projection.js";import{buildTaskView,followThroughData}from"./task-view-data.js";import"./session.js";import{mergeReadyViewOf}from"./merge-ready-view.js";import{machineChecked,machineCheckWords}from"../machine-check.js";import{budgetHoldWords,budgetLabel,monthOf}from"../spend.js";import"../store.js";import{taskControlOf}from"../task-control.js";import{taskLinkFromLegacy,taskLinkOf}from"../task-link.js";import{lastErrorLineOf,missedRequirementOf,workStatusOf}from"../workspace-projection.js";export function createTaskViews(runtime){const baseGit=recentGitReads();function guided(rootId,now){if(runtime.store.isDemo())return!1;if(runtime.store.firstSuccessAt(now)===null)return!0;const first=runtime.store.handle.prepare("SELECT id FROM task ORDER BY created_at, rowid LIMIT 1").get();return first!==void 0&&String(first.id)===rootId}function projectFamilyPeek(repo,now){const row=runtime.projectCounts(now).find(one=>one.repo===repo);return{waiting:row?.totals["needs-you"]??0,running:row?.totals.running??0,queued:row?.queued??0,doneRecently:row?.doneRecently??0}}function familiesInView(project,options={}){return runtime.store.taskFamiliesAdmitted(project===null?runtime.admissionList():runtime.visible(project)?[project]:[],runtime.visible(null),options)}function familyTasksInView(project,state,limit=200){return familiesInView(project,{...state===void 0?{}:{states:[state]},limit}).map(family=>({...family.current,id:family.root.id,title:family.root.title}))}function revisionDestination(child,back){const root=runtime.familyOf(child)?.root.id??child;if(!back.startsWith("/chat?"))return`${taskHref(root)}?version=${encodeURIComponent(child)}`;const conversation=new URL(back,"http://localhost").searchParams.get("conversation");return`${taskChatHref(root)}&revision=${encodeURIComponent(child)}${conversation?"&conversation="+encodeURIComponent(conversation):""}`}function earlierLiveVersions(family,now){const ids=family.versions.filter(one=>one.id!==family.current.id).map(one=>one.id);return ids.length===0?[]:runtime.store.taskActivityCandidates(family.root.repo===null?[]:[family.root.repo],family.root.repo===null,now,ids).filter(task=>workRowOf(task,now).status.views.includes("running")).map(task=>task.id)}function freshAssignment(assignment,receipt){if(assignment===null)return null;const value=assignmentWithEvidence(assignment,receipt===null?null:receiptStatusOf(receipt),receipt?.runId??null);return receipt===null?value:{...value,attention:[...new Set([...value.attention,...receipt.facts.evidenceProblems,...receipt.caveats.filter(reason=>!historicalAssessmentReason(reason))])]}}function workRowOf(task,now,receipt){const ref=runtime.store.lookupRef(task.id),runs=ref===null?[]:runtime.store.runsFor(ref.id),latest=runs.find(runIsTaskResult)??null,verdict=latest===null?null:runtime.store.proofVerdictFor(latest.id),live=runs.find(one=>runIsLive(one))??null,facts={id:task.id,heldFindings:heldFindingCount(runtime.store,task.id),title:task.title,repo:task.repo,state:task.state,updatedAt:task.updatedAt,dispatch:diagnoseTaskDispatch(runtime.store,task.id,now),result:task.state!=="done"||latest===null?null:{runId:latest.id,role:latest.role,outcome:latest.outcome,verdict:verdict?.verdict??null,reasons:verdict?.reasons??[],accepted:runtime.store.proofAcceptance(latest.id)!==null,checkLevel:resultCheckLevel(runtime.store,latest.id,now),...ref?.repo==null?{}:{checkSet:projectCheckSet(runtime.store,ref.repo)},review:runtime.reviewFactsFor(latest.id),...latest.outcome!=="no-change"?{}:{recordComplete:(()=>{const kinds=new Set(runtime.store.artifactsFor(latest.id).map(one=>one.kind));return kinds.has("handoff")&&kinds.has("terminal-diff")})()}},publication:latest===null?null:publicationFactsOf(runtime.store.publicationForRun(latest.id)),liveRunId:live===null?null:live.id,...machineChecked(runtime.store,task.id)?{machine:!0}:{},openDecision:ref===null?null:openWorkDecisionOf(runtime.store,ref.id,now),unfinishedRunId:runs.find(one=>one.outcome===null&&one.role!=="reviewer")?.id??null,control:ref===null?{kind:"none"}:taskControlOf(runtime.store,ref.id,now)},result=receipt===void 0&&task.state==="done"&&latest!==null&&(latest.outcome==="built"||latest.outcome==="no-change")?completionReceiptView(runtime.store,latest,runtime.store.artifactsFor(latest.id),runtime.evidenceRoot,runtime.reviewFactsFor(latest.id)):receipt,status=workStatusOf(facts,result==null?void 0:receiptStatusOf(result)),earlierLive=task.family===void 0?[]:earlierLiveVersions(task.family,now);earlierLive.length>0&&!status.views.includes("running")&&(status.views=[...status.views,"running"]);const otherActive=new Set([...task.family?.otherActive.map(one=>one.id)??[],...earlierLive]).size,recordedAssignment=task.family===void 0?null:assignmentOf(runtime.store,task.id,now,runtime.workAccess(),runtime.evidenceRoot),assignment=freshAssignment(recordedAssignment,result??null),assignmentStatus=assignment===null?status:assignmentStatusOf(assignment,status);return status.views.includes("running")&&!assignmentStatus.views.includes("running")&&(assignmentStatus.views=[...assignmentStatus.views,"running"]),{...facts,executionId:task.id,id:task.family?.root.id??task.id,title:task.family?.root.title??task.title,familyNotice:task.family?.problem??(otherActive?`${otherActive} earlier version${otherActive===1?" is":"s are"} still waiting or running. Open History.`:null),status:assignment===null?status:{...assignmentStatus,diagnostics:assignmentPresentationOf(assignment,{workStatus:status,diagnostics:[...status.diagnostics??[],...status.tone==="problem"&&status.detail!==assignment.detail?[status]:[]]}).diagnostics},assignment,assignmentProblem:status.tone==="problem",resultRunId:latest===null?null:latest.id}}function runIsLive(run){return run.outcome===null&&runtime.store.currentLiveLease(run.taskRef,runtime.clock())===run.leaseId}const runIsTaskResult=run=>run.finishedAt!==null&&(run.role==="builder"||run.role==="scout");function revisionViewOf(ref){if(ref===null||ref.revisionBriefArtifact===null)return null;const artifact=runtime.store.getArtifact(ref.revisionBriefArtifact);if(artifact===null)return{problem:"the revision brief is missing from this build's records"};const read=readVerifiedArtifact(runtime.evidenceRoot,artifact);if(!read.ok)return{problem:`the revision brief no longer verifies — ${read.problem}`};try{const parsed=JSON.parse(read.content.toString("utf8"));return{sourceTask:String(parsed.sourceTask??"?"),sourceRun:Number(parsed.sourceRun??0),kind:parsed.kind==="ci-repair"?"ci-repair":parsed.kind==="criterion-repair"?"criterion-repair":"annotations",lineage:runtime.store.revisionLineageOf(ref.externalId,runtime.clock()),comments:(parsed.comments??[]).slice(0,100).map(one=>({id:typeof one.id=="number"&&Number.isSafeInteger(one.id)?one.id:null,path:one.path===null||one.path===void 0?null:String(one.path),line:one.line===null||one.line===void 0?null:Number(one.line),note:String(one.note??""),author:String(one.author??"?"),image:parseFeedbackImage(one.image)||null}))}}catch{return{problem:"the revision brief did not parse"}}}function taskViewData(taskId,who,problem,render={}){const found=runtime.store.getTask(taskId);if(found===null)return null;const ref=runtime.store.lookupRef(taskId);if(ref!==null&&!runtime.visible(ref.repo))return null;const now=runtime.clock(),scope=runtime.store.getScope(taskId),revision=revisionViewOf(ref),revisionBroken=revision!==null&&"problem"in revision,planView=ref===null?null:planViewOf(ref.id),routeView=routeViewOf(taskId,ref,scope,now,who),approvalSummary=scope===null?null:approvalSummaryOf(scope,summaryContextOf(runtime.store,taskId,scope,now,routeView?.evidence??null)),approvalDigest=scope===null?null:approvalFormDigest(scope.digest,planView?.sha256??null,approvalSummary?.key??null),nonce=who.via==="cookie"&&scope!==null&&approvalDigest!==null&&!approvalOf(scope).approved&&!revisionBroken&&ref?.plan!=="requested"&&consentDoorOf(scope,routeView).open?render.mintNonce===!1?"unminted":runtime.mintApprovalNonce(who.name,taskId,approvalDigest):"",runs=ref===null?[]:runtime.store.runsFor(ref.id),completion=(()=>{const latest=runs.find(runIsTaskResult);if(latest===void 0)return null;const artifacts=runtime.store.artifactsFor(latest.id),verdict=runtime.store.proofVerdictFor(latest.id),review=runtime.reviewFactsFor(latest.id);return{runId:latest.id,outcome:latest.outcome,hasTerminalDiff:artifacts.some(one=>one.kind==="terminal-diff"),hasHandoff:artifacts.some(one=>one.kind==="handoff"),proofVerdict:verdict?.verdict??null,machineVerdict:verdict?.machineVerdict??null,proofReasons:verdict?.reasons??[],proofMatrix:verdict?.matrix??[],proofMatrixLinks:evidenceLinksFor(artifacts),proofAccepted:runtime.store.proofAcceptance(latest.id)!==null,qualityMode:latest.qualityMode??"default",repairChain:runtime.store.repairChainFor(latest.id)??runtime.store.repairChainForDraft(taskId),reviewRetry:runtime.store.reviewRetryStateOf(latest.id),review,receipt:latest.outcome==="built"||latest.outcome==="no-change"?completionReceiptView(runtime.store,latest,artifacts,runtime.evidenceRoot,review):null}})(),planRevisions=ref===null?null:revisionLedgerOf(ref.id),milestoneProgress=ref===null?null:progressOf(ref.id,planRevisions?.current?.document??null),family=runtime.familyOf(taskId),recordedAssignment=family?.current.id!==taskId?null:assignmentOf(runtime.store,taskId,now,runtime.workAccess(),runtime.evidenceRoot),assignment=freshAssignment(recordedAssignment,completion?.receipt??null),progressRun=runs.find(one=>runIsLive(one))?.id??completion?.runId??null;return{guide:guided(family?.root.id??taskId,now),assignment,checkProgress:progressRun===null?null:runtime.store.checkProgress(progressRun),task:found,status:workRowOf({...found,repo:ref?.repo??null},now,completion?.receipt).status,dispatch:diagnoseTaskDispatch(runtime.store,taskId,now),control:ref===null?{kind:"none"}:taskControlOf(runtime.store,ref.id,now),canRetryReview:who.via==="cookie"&&who.role==="approver",strikes:ref?.strikes??0,filer:runtime.store.taskFiler(taskId),budgetHold:(()=>{if(ref===null||found.state!=="queued")return null;const hold=runtime.store.budgetGate(now)({...runtime.store.budgetSubject(ref.id),agents:runtime.store.agentsFor([runtime.store.getScope(taskId)?.approvedProfile?.provider??"claude"])});return hold.over===null?null:hold.why==="unpriced"?`${budgetHoldWords(hold,monthOf(now).name)}; this waits until then`:`${budgetLabel(hold.over)} monthly budget is used up, so this waits until next month or a higher budget`})(),policyHold:(()=>{if(ref===null||found.state!=="queued")return null;const base=runtime.store.getScope(taskId)?.approvedProfile??null;if(base===null)return null;const verdict=runtime.store.runPolicy(base);return verdict.ok?verdict.lowered:`${verdict.message.replace(/ An instance operator can change it in Settings → Policy\.$/,"")} It waits until the policy allows it.`})(),approvalRules:(()=>{const repo=ref?.repo??null;if(repo===null)return null;const rules=runtime.store.approvalRules(repo);if(!rules.notRequester&&!rules.protectProject&&rules.protectedPaths.length===0)return null;const gate=runtime.store.approvalGate(taskId,"\0nobody","person");return{words:rulesSummary(rules),votes:runtime.store.approvalVotes(taskId).map(one=>one.approver),needsTwo:gate.verdict==="vote"||gate.verdict==="seal"&&gate.protectedWork}})(),plan:ref?.plan??null,planAuto:planAutoPending(runtime.store,taskId,now),planSource:planSourceOf(runtime.store,taskId),retryPins:retryPinsOf(runtime.store,taskId),planStopped:planStoppedFor(runtime.store,taskId),planBackoff:planBackoffFor(runtime.store,taskId,now),planDocument:planView?.document??null,planSha:planView?.sha256??null,planContract:ref===null||planView===null?null:planContractViewOf(ref.id,scope),deliverable:ref?.deliverable??"branch",report:ref===null?null:readVerifiedReport(runtime.store,runtime.evidenceRoot,ref.id),revision,planRevisions,milestoneProgress,repairChain:completion!==null?null:runtime.store.repairChainForDraft(taskId),repo:ref?.repo??null,filedVia:runtime.store.filedViaOf(taskId),origin:(()=>{const repos=runtime.workAccess().repos;return originOf(runtime.store,taskId,repo=>repos===null||repos.includes(repo))})(),coordinator:(()=>{const who2=runtime.store.coordinatorProvenanceOf(taskId);if(who2===null)return null;const ago=who2.filedAt===null?null:(()=>{const minutes=Math.max(0,Math.round((now.getTime()-new Date(who2.filedAt).getTime())/6e4));return minutes<60?`${minutes}m ago`:minutes<1440?`${Math.round(minutes/60)}h ago`:`${Math.round(minutes/1440)}d ago`})();return{label:who2.label,filedAgo:ago}})(),holds:ref===null?[]:runtime.store.activeHolds(ref.id,now),claimed:ref===null?!1:runtime.store.hasLiveClaim(ref.id,now),waitsFor:runtime.store.blockers(taskId).map(blockerId=>{const blockerRef=runtime.store.lookupRef(blockerId),admitted=blockerRef!==null&&runtime.visible(blockerRef.repo),blocker=admitted?runtime.store.getTask(blockerId):null;return{id:!admitted&&runtime.restricted()?"restricted task":blockerId,title:blocker===null?null:blocker.title,state:blocker===null?null:blocker.state,admitted}}),waitCandidates:(()=>{if(who.via!=="cookie")return[];const candidateRepo=ref?.repo??who.session.project;return candidateRepo===null?[]:runtime.store.listTasksScoped(candidateRepo,void 0,100,null).filter(one=>one.id!==taskId&&(one.state==="queued"||one.state==="running")&&runtime.visible(one.repo)).map(one=>({id:one.id,title:one.title}))})(),liveRunId:(()=>{if(ref===null)return null;const found2=runtime.store.runsFor(ref.id).find(one=>runIsLive(one));return found2===void 0?null:found2.id})(),livePause:(()=>{const run=ref===null?null:runtime.store.liveInputRun(ref.id,now);if(run===null)return null;const pause=runtime.store.livePauseOf(run),until=pause?.pausedAt==null||pause.limitMs===null?null:new Date(Date.parse(pause.pausedAt)+pause.limitMs).toISOString();return{run,state:pause?.state??null,until,limitMs:pause?.limitMs??null}})(),worker:(()=>{const runners=runtime.store.listRunners().filter(one=>one.retiredAt===null),eligible=ref?.repo===null||ref?.repo===void 0?[]:runners.filter(one=>one.repos.includes(ref.repo));return{answering:eligible.filter(one=>runnerAlive(one,now)).length,registered:eligible.length,totalRegistered:runtime.restricted()?eligible.length:runners.length,lastHeard:eligible.map(one=>one.heartbeatAt).sort().at(-1)??null}})(),gaps:ref?.repo===null||ref?.repo===void 0?[]:computeGaps(runtime.store,ref.repo,now).filter(one=>one.unblocks.includes(taskId)||one.alsoBlocks.includes(taskId)),peekable:runtime.options.localRunner!==void 0,position:runtime.store.queuePosition(taskId),mirror:runtime.store.mirrorByTask(taskId),scope,approvalDigest,approvalSummary,approvalDecision:scope===null||approvalOf(scope).approved?null:approvalDecisionFor(runtime.store,taskId,scope,now,{evidenceRoot:runtime.evidenceRoot,access:runtime.workAccess(),viewer:who.name,canSee:repo=>runtime.visible(repo)}),route:routeView,canEditRoute:who.role==="approver",resultRecord:resultRecordWordsOf(runtime.store,taskId,runtime.evidenceRoot,now),spendDefaults:runtime.store.getSpendDefaults(),permissionDefault:runtime.store.permissionDefault().mode,permissionMode:ref?.permissionMode??null,qualityDefault:runtime.store.qualityDefault().mode,qualityMode:ref?.qualityMode??null,publication:(()=>{if(ref===null)return null;for(const one of runtime.store.runsFor(ref.id)){const found2=runtime.store.publicationForRun(one.id);if(found2!==null)return found2}return null})(),runs,completion,decisions:ref===null?[]:runtime.store.decisionsForTask(ref.id),incidents:ref===null?[]:runtime.store.incidentsForTask(ref.id),coordinatorProposals:(()=>{if(ref===null||ref.repo===null||who.role!=="approver")return null;const rows=runtime.store.listCoordinatorProposals({repos:[ref.repo],taskId});return{rows,decisions:decisionsFor(runtime.store,rows),now}})(),steering:ref===null?[]:runtime.store.listSteerNotes(ref.id),base:taskBaseOf(runtime.store,taskId,baseGit),steeringLive:ref!==null&&runtime.store.steeringLiveBuild(ref.id,now)!==null,steeringRun:ref===null?null:runtime.store.steeringLiveBuild(ref.id,now),release:ref===null?null:releaseViewOf(runtime.store,ref.externalId,now,authority=>releaseObligationsOf(runtime.store,runtime.evidenceRoot,authority)),canStopRelease:who.role==="approver"&&who.via==="cookie",autoRelease:ref===null?null:autoReleaseOf(runtime.store.getScope(ref.externalId)),releaseCiRunning:ref!==null&&releaseCiRunningOf(runtime.store,ref.externalId)!==null,approvalProof:(()=>{const scope2=ref===null?null:runtime.store.getScope(ref.externalId);return scope2===null||scope2.approvedBy===null||scope2.approvedDigest===null?null:approvalProofOf(runtime.store,ref.externalId,scope2.approvedBy,scope2.approvedDigest)})(),...(()=>{const scope2=ref===null?null:runtime.store.getScope(ref.externalId);if(scope2===null||ref===null||who?.via!=="cookie")return{approvalFresh:null,approvalLocal:null};const fresh=withFreshness("approve-standard",()=>freshnessFor(who.name,Date.now(),!0)),field=approvalPasswordField(runtime.store,{name:who.name,taskId:ref.externalId,scope:scope2,passwordless:!1,localOwner:who.authority==="local-owner",freshAt:fresh?.at??null,returnTo:taskHref(ref.externalId)});return{approvalFresh:field.field==="remembered"?field.since:null,approvalLocal:field.field==="none"&&field.why==="local-owner"?{eligible:!0}:field.field==="local-refused"?{eligible:!1,message:field.message,href:field.href,action:field.action}:null}})(),routeChange:ref===null?null:routeChangeOf(runtime.store,ref.externalId),followThroughData:who===void 0||familyInWebReach(runtime.store,who,taskId,runtime.visible)===null?null:followThroughData(runtime.store,runtime.evidenceRoot,taskId,taskHref(taskId),who.role==="approver"&&who.via==="cookie"&&!runtime.store.isDemo(),runtime.clock()),fastGrown:(()=>{if(ref===null||runtime.store.getTask(ref.externalId)?.state!=="done"||!fastStarted(runtime.store,ref.externalId))return null;const last=runtime.store.lastBuilderRun(ref.id);return last===null?null:fastChangeProblem(runtime.store,ref.externalId,last.id)})(),steerRecent:ref===null?[]:runtime.store.runsFor(ref.id).filter(one=>one.outcome!==null).map(one=>one.id).sort((a,b)=>b-a).slice(0,5),steerComposer:(()=>{const run=ref===null?null:liveAttemptOf(runtime.store,ref.id,now);return run===null?null:steerControlsFor(runtime.store,ref.externalId,run,now,who?.role==="approver")})(),grant:ref===null||ref.repo===null?null:runtime.store.publicationGrantFor(ref.repo),csrf:who.via==="cookie"?who.session.csrf:"",nonce,problem,now}}function routeViewOf(taskId,ref,scope,now,who){if(ref===null)return null;const routed=routeOfTask(runtime.store,taskId,ref,now);if(routed===null)return null;const live=runtime.store.hasLiveClaim(ref.id,now),shared={overrides:ref.routeOverrides??[],editable:who.role==="approver"&&!live,editableWhy:who.role!=="approver"?"your login can watch — choosing agents is an approver's act":live?"this task is running — its agents cannot change under a live claim":null,replanOnPlanChange:ref.plan==="drafted"&&scope!==null&&!approvalOf(scope).approved,digest:scope?.digest??null,choices:agentChoicesFor(runtime.store,ref.repo,routed.kind==="route"?routed.route:null),evidence:routed.kind==="route"?selectionEvidenceWords(runtime.store,routed.route,now):null};return routed.kind==="route"?{kind:"route",source:routed.source,projection:projectRoute(routed.route,runtime.store.readinessLookupFor(ref.repo,ref.assignedRunner,now)),legacy:null,problem:null,...shared}:routed.kind==="legacy"?{kind:"legacy",source:null,projection:null,legacy:{provider:routed.profile.provider,model:routed.profile.model,repairModel:routed.profile.repairModel==="inherit"?routed.profile.model:routed.profile.repairModel,approved:routed.approved},problem:null,...shared}:{kind:"unreadable",source:null,projection:null,legacy:null,problem:routed.problem,...shared}}function taskChatFocus(taskId,now,who,options={}){if(taskId===null||taskId.length===0||taskId.length>64||hasForbiddenControls(taskId))return null;const family=runtime.familyOf(taskId);if(family===null)return null;taskId=family.current.id;const task=family.current,ref=runtime.store.lookupRef(taskId),scope=runtime.store.getScope(taskId),view=who===void 0||family.problem!==null?null:taskViewData(taskId,who,null,options),runs=view?.runs??runtime.store.runsFor(ref.id),latest=runs.find(runIsTaskResult)??null,approval=approvalOf(scope),live=runs.find(one=>runIsLive(one))??null,planRevisions=view?.planRevisions??revisionLedgerOf(ref.id);return{id:family.root.id,executionId:task.id,family,guide:guided(family.root.id,now),historyData:familyHistoryData(family),title:family.root.title,state:task.state,status:view?.status??workRowOf({...task,repo:ref.repo},now).status,assignment:view?.assignment??assignmentOf(runtime.store,task.id,now,runtime.workAccess(),runtime.evidenceRoot),project:ref.repo===null?null:projectName(ref.repo),now,dispatch:diagnoseTaskDispatch(runtime.store,taskId,now),scope:scope===null?"none":approval.approved?"approved":"needs approval",plan:ref.plan,planRevisions,milestoneProgress:view?.milestoneProgress??progressOf(ref.id,planRevisions?.current?.document??null),failure:task.state==="failed"?failureOf(family.versions.flatMap(version=>runtime.store.runsFor(version.refId)),view?.assignment??assignmentOf(runtime.store,task.id,now,runtime.workAccess(),runtime.evidenceRoot)):null,claimed:view?.claimed??runtime.store.hasLiveClaim(ref.id,now),liveRun:live===null?null:{id:live.id,runner:live.runner,startedAt:live.startedAt,phase:live.phase},checkProgress:view?.checkProgress??(live===null&&latest===null?null:runtime.store.checkProgress((live??latest).id)),control:view?.control??taskControlOf(runtime.store,ref.id,now),route:view?.route??null,approval:view===null||who?.role!=="approver"||scope===null||approval.approved?null:{scope,nonce:view.nonce,digest:view.approvalDigest??scope.digest,summary:view.approvalSummary??null,planDocument:view.planDocument,planContract:view.planContract??null,deliverable:view.deliverable??"branch",revision:view.revision??null,coordinator:view.coordinator??null,origin:view.origin??null,repairChain:view.repairChain??null,releaseCiRunning:view.releaseCiRunning===!0},decisions:(view?.decisions??runtime.store.decisionsForTask(ref.id)).filter(one=>one.state==="open"||one.state==="expired").map(one=>({...one,taskId:task.id,repo:ref.repo})),publication:view?.publication??null,result:view?.completion?.receipt!==void 0&&view.completion.receipt!==null?view.completion.receipt:latest===null||latest.outcome!=="built"&&latest.outcome!=="no-change"?null:completionReceiptView(runtime.store,latest,runtime.store.artifactsFor(latest.id),runtime.evidenceRoot,runtime.reviewFactsFor(latest.id))}}function pullRequestTargetOf(runId){const run=runtime.store.getRun(runId),publishing=publishingOf(runtime.store,run===null?null:runtime.store.refById(run.taskRef)?.repo??null);return!publishing.on||publishing.legacy||runtime.store.publicationForRun(runId)!==null||pullRequestBlocker(runtime.store,runId)!==null?null:`${publishing.githubRepo} into ${publishing.base}`}function taskPullRequestOf(taskId,who){const family=runtime.familyOf(taskId),rootId=family?.root.id??taskId,repo=runtime.store.lookupRef(taskId)?.repo??null,publishing=publishingOf(runtime.store,repo),target=publishing.on?publishing.base:null,view=newestPullRequestOf(runtime.store,family===null?[taskId]:family.versions.map(one=>one.id));if(view!==null){const publication=runtime.store.publicationForRun(view.runId),fact=publication===null?null:{...pullRequestFactOf({...publication,merged:view.state==="merged"}),note:view.state==="merged"?`${view.detail}${view.mergeCommit===null?"":` Merge commit ${view.mergeCommit.slice(0,12)}.`}`:null};return{taskId:rootId,view:{...view,canMerge:view.canMerge&&who.role==="approver"&&who.via==="cookie"},offer:null,target,fact}}if(!publishing.on||who.via!=="cookie"||who.role!=="approver")return null;const assignment=assignmentOf(runtime.store,taskId,runtime.clock(),runtime.workAccess(),runtime.evidenceRoot),receipt=assignment?.receipt??null;return assignment?.state!=="complete"||receipt===null||runtime.store.publicationForRun(receipt.runId)!==null||pullRequestBlocker(runtime.store,receipt.runId)!==null?null:{taskId:rootId,view:null,offer:{taskId:receipt.taskId,runId:receipt.runId,digest:receipt.digest},target}}function taskLandingOf(taskId,who){const repo=runtime.store.lookupRef(taskId)?.repo??null;if(repo===null||publishesThroughPullRequests(runtime.store,repo))return null;const rootId=runtime.familyOf(taskId)?.root.id??taskId,record=landingOf(runtime.store,rootId),assignment=assignmentOf(runtime.store,taskId,runtime.clock(),runtime.workAccess(),runtime.evidenceRoot),complete=assignment?.state==="complete";if(!complete&&record===null)return null;const person=who.via==="cookie"&&who.role==="approver",history=landingHistoryOf(runtime.store,repo,rootId,complete?assignment?.receipt?.head??null:null,baseGit);if(history!==null&&!history.recorded)return{taskId:rootId,landed:history.words,onBranch:!0,canLand:!1,canUndo:person&&!history.reverted&&broughtInOnBranch(runtime.store,repo,rootId,baseGit)};const standing=history,kept=complete&&(record===null||record.undone)?keptHandoffOf(runtime.store,repo,rootId,assignment?.receipt?.head??null):null;return{taskId:rootId,landed:standing?.words??null,onBranch:standing?.landed===!0,canLand:person&&complete&&(record===null||record.undone),canUndo:person&&record!==null&&!record.undone&&standing?.reverted!==!0,...kept===null?{}:{kept}}}function failureOf(runs,assignment,readLog=!0){const last=latestFinishedAttempt(runs);if(last===null)return{kind:"reason",line:NO_REASON_RECORDED,evidence:null,suggestion:GENERAL_SUGGESTION,link:null};const full=runtime.store.getRun(last.id);return full===null?{kind:"reason",line:failedAttemptSentence(last.reason),evidence:null,suggestion:stopSuggestionOf(last.reason),link:null}:explainAttempt(full,assignment?.receipt?.runId===last.id?assignment.receipt:null,readLog)}function explainAttempt(run,receipt,readLog=!0){const taskId=runtime.store.externalIdFor(run.taskRef)??"",page=taskLinkOf({task:taskId,run:run.id}),see=taskId===""?null:{label:`See build #${run.id}`,href:page},artifacts=runtime.store.artifactsFor(run.id),logArtifact=readLog?receipt?.checks.status==="failed"&&receipt.checks.logArtifactId!==null?artifacts.find(one=>one.id===receipt.checks.logArtifactId)??null:[...artifacts].reverse().find(one=>one.kind==="check-log")??null:null;if(logArtifact!==null){let read=null;try{read=readVerifiedArtifact(runtime.evidenceRoot,logArtifact)}catch{read=null}const text=read!==null&&read.ok?read.content.toString("utf8"):null,exit=text===null?null:/^\(exit (-?[0-9]+)\)$/m.exec(text),failedCheck=receipt?.checks.status==="failed"||exit!=null&&Number(exit[1])!==0,found=text!==null&&failedCheck?lastErrorLineOf(text):null;if(found!==null){const line=oneLineOf(found.text,140);return{kind:"check",line:`The check failed: ${line}`,evidence:null,suggestion:failingCheckSuggestion(line),link:taskId===""?null:{label:`Check output, line ${found.line}`,href:taskLinkOf({task:taskId,run:run.id,section:"checks",anchor:`check-log-L${found.line}`})}}}}const verdict=runtime.store.proofVerdictFor(run.id),missed=verdict===null?null:missedRequirementOf(verdict.matrix);if(missed!==null)return{kind:"requirement",line:missedRequirementLine(missed.statement),evidence:missed.evidence===null?null:oneLineOf(missed.evidence,240),suggestion:missedRequirementSuggestion(missed.statement),link:see};const internal=isInternalErrorReason(run.reason);let codexHint=null;if(run.provider==="codex"){const repo=taskId===""?null:runtime.store.lookupRef(taskId)?.repo??null;codexHint=codexOfflineDependencySuggestion({provider:run.provider,agentSaid:agentSaidOf(runtime.store,run.id),hasSetup:repo!==null&&runtime.store.liveWorktreeSetup(repo)!==null})}return{kind:"reason",line:failedAttemptSentence(run.reason),evidence:null,suggestion:codexHint??stopSuggestionOf(run.reason),link:internal?{label:"The recorded error",href:`/r/${run.id}?record=1#run-reason-detail`}:see}}function runChecksHere(runId,who,returnTo){if(runId===null||who.via!=="cookie"||who.role!=="approver"||runtime.store.isDemo())return null;const run=runtime.store.getRun(runId),followUps=run===null?null:followUpsFor(runtime.store,runtime.evidenceRoot,run,runtime.clock());return followUps===null||!(followUps.quick||followUps.full)||followUps.checks.some(one=>one.state==="waiting"||one.state==="running")?null:{action:`/r/${runId}/checks`,level:followUps.full?"full":"quick",returnTo}}function onePageView(view,family,runs,extras){const root=family?.root.id??view.id,current=family?.current.id??view.id,versions=new Set(family?.versions.map(one=>one.id)??[view.id]),results=new Map(runs.filter(run=>runIsTaskResult(run)&&(extras.admissible===void 0||extras.admissible.has(run.id))).map(run=>[run.id,run.taskId])),tabHref=(taskId,run,section,hash)=>`${taskHref(root)}?${taskId!==current?`version=${encodeURIComponent(taskId)}&`:""}tab=result${run===null?"":`&run=${run}`}${section===null||section==="summary"?"":`§ion=${section}`}${hash}`,toTab=href=>{const canonical=taskLinkFromLegacy(href)??href,result=/^\/t\/([A-Za-z0-9._~%-]{1,200})\?tab=result(?:&run=([0-9]{1,15}))?(?:§ion=(summary|changes|checks))?(#[A-Za-z0-9_.:-]{1,160})?$/.exec(canonical);if(result!==null){const named=decodeURIComponent(result[1]),run=result[2]===void 0?null:Number(result[2]),taskId=run!==null&&named===root&&results.has(run)?results.get(run):named;if(versions.has(taskId))return tabHref(taskId,run,result[3]??null,result[4]??"")}const record=/^\/r\/([0-9]{1,15})$/.exec(href);return record!==null&&results.has(Number(record[1]))?tabHref(results.get(Number(record[1])),Number(record[1]),null,""):href},link=one=>one===null?null:{...one,href:one.href===null?null:toTab(one.href)},status=view.status===null?null:{...view.status,action:view.status.action===null?null:link(view.status.action),status:{...view.status.status,details:view.status.status.details.map(one=>({...one,href:one.href===null?null:toTab(one.href),action:one.action===null?null:link(one.action)}))}},selected=extras.result?.selected??null,builds=runs.filter(run=>run.role==="builder"||run.role==="scout"||run.role==="repair").map(run=>run.id).sort((a,b)=>a-b),attempts=[...results.entries()].sort((a,b)=>b[0]-a[0]).map(([id,taskId])=>{const run=runs.find(one=>one.id===id),outcome=run.outcome==="built"?"result":run.outcome==="no-change"?"no change":run.outcome===null?"never finished":run.outcome,at=builds.indexOf(id);return{label:`${at<0?`Build #${id}`:`Attempt ${at+1}`} · ${outcome}`,href:tabHref(taskId,id,null,""),current:selected?.build===id}});return{...view,status,...view.failure==null?{}:{failure:{...view.failure,link:link(view.failure.link)}},...view.earlier==null?{}:{earlier:{...view.earlier,attempts:view.earlier.attempts.map(one=>({...one,href:toTab(one.href)}))}},...view.thread===void 0?{}:{thread:view.thread.map(one=>({...one,link:link(one.link)}))},sections:selected===null?view.sections:view.sections.filter(one=>one.id!=="result"),tab:extras.tab??"activity",result:selected===null?null:{selected,current:extras.result.current,attempts,revision:createHash("sha256").update(JSON.stringify(selected).replace(/\b[a-f0-9]{32}\b/g,"")).digest("hex").slice(0,16)}}}function taskScreen(response,who,taskId,problem,status,scopeDraft,cancelDraft,editPlan=!1,extras={}){if(problem!==null&&refusedInPlace(response,status,problem))return;const admittedFamily=runtime.familyOf(taskId);if(admittedFamily?.problem!=null)return runtime.sendScreen(response,status,{title:admittedFamily.root.title,chrome:runtime.chromeFor(admittedFamily.root.repo,"tasks"),workspace:{view:{kind:"task-history-problem",title:admittedFamily.root.title,state:admittedFamily.current.state,problem:admittedFamily.problem,result:extras.result==null?null:{selected:extras.result.selected,current:extras.result.current}}}});const data=taskViewData(taskId,who,problem,{mintNonce:requestContext.getStore()?.readPurpose!=="prefetch"});if(data===null)return refuse(response,who,404,"no such task","/");const family=runtime.familyOf(taskId),presentedData={...data,rootId:family?.root.id??taskId,rootTitle:family?.root.title??data.task.title,...family===null||data.assignment!=null?{}:{historyData:familyHistoryData(family)},versionLabel:family!==null&&family.current.id!==taskId?`Viewing ${family.versions.findIndex(one=>one.id===taskId)===0?"Original":`Revision ${family.versions.findIndex(one=>one.id===taskId)}`} · ${family.current.state==="running"?"A newer revision is running":"A newer revision is current"}`:null,archived:archiveOf(runtime.store,taskId),canPutAway:who.via==="cookie"&&who.role==="approver",...scopeDraft===void 0?{}:{scopeDraft},...cancelDraft===void 0?{}:{cancelDraft},...editPlan?{editPlan:!0}:{},pullRequest:taskPullRequestOf(taskId,who),landing:taskLandingOf(taskId,who),demo:runtime.store.isDemo()};family!==null&&family.problem===null&&(presentedData.family={root:{id:family.root.id,title:family.root.title,createdAt:family.root.createdAt,goal:runtime.store.getScope(family.root.id)?.goal??null},versions:family.versions.map(one=>({id:one.id,title:one.title,state:one.state})),runs:family.versions.flatMap(version=>version.id===data.task.id?data.runs.map(run=>({...run,taskId:version.id})):runtime.store.runsFor(version.refId).map(run=>({...run,taskId:version.id})))}),presentedData.failure=failureOf(presentedData.family?.runs??data.runs,data.assignment??null),presentedData.runChecks=runChecksHere(data.assignment?.receipt?.runId??null,who,taskHref(taskId));const liveRun=data.liveRunId==null?void 0:data.runs.find(one=>one.id===data.liveRunId);liveRun!==void 0&&(presentedData.activity=runActivityOf(runtime.store,liveRun,runtime.clock()));const paneProject=runtime.restricted()?runtime.store.lookupRef(taskId)?.repo??null:who.via==="cookie"?who.session.project:null,chrome=runtime.chromeFor(paneProject,"tasks"),firstView=buildTaskView(presentedData),mergeReady=mergeReadyViewOf(runtime.store,taskId,data.assignment??null,who,presentedData.runChecks??null,taskHref(taskId),landedOf(presentedData),data.base??null),sensitive=presentedData.pullRequest?.view?.canMerge===!0&&!(who.via==="cookie"&&who.authority==="local-owner")||firstView.approve!=null&&!firstView.approve.facts.passwordless||firstView.lead.some(b=>b.key==="plan-revisions"&&b.ledger.pending?.requiresPassword===!0||b.key==="mirror"&&b.reopenAction!==null),builtView=sensitive?buildTaskView({...presentedData,degraded:"sensitive"}):firstView,focus=taskChatFocus(family?.root.id??taskId,runtime.clock(),who,{mintNonce:!1}),docked=focus===null?null:runtime.dockedConversation(who,focus,null,runtime.clock(),taskHref(focus.id));let taskView={...builtView,...docked===null?{}:{tabs:[]},...who.role==="approver"?{}:{chatHref:null},...who.via==="cookie"?{live:{room:`task:${encodeURIComponent(family?.root.id??taskId)}`,at:(()=>{try{return taskFingerprint(runtime.store,family?.root.id??taskId,runtime.clock())}catch{return null}})()}}:{}};const tab=extras.tab??"plan";taskView=onePageView(taskView,family,presentedData.family?.runs??data.runs.map(run=>({...run,taskId:data.task.id})),{...extras,tab});const rootId=family?.root.id??taskId;if(taskView={...taskView,ship:shipViewOf(shipChecksForTask(runtime.store,rootId),runtime.clock()),release:releaseStepsViewOf(releaseProgressFor(runtime.store,rootId),runtime.clock()),mergeReady},machineChecked(runtime.store,taskId)){const words=machineCheckWords(runtime.store,taskId,data.liveRunId??null,taskView.release??null,runtime.clock()),card=taskView.status;words!==null&&card!==null&&card.status.headline==="Building"&&(taskView.status={...card,status:{...card.status,sentence:words}}),taskView.activity=null,taskView.steering=null,taskView.release!=null&&(taskView.journey=null)}if(taskView.steps=stepRowsOf(taskView),extras.result!=null&&!extras.result.current){const build=extras.result.selected.build,historical={label:build===null?"The task has moved on since.":`Build #${build}. The task has moved on since.`,href:taskHref(rootId)},view={kind:"task",id:taskView.id,title:taskView.title,project:taskView.project,scout:taskView.scout,tabs:[],version:taskView.version,status:null,approval:null,lead:[],facts:[],sections:[],manage:[],cancel:null,thread:[],tab:"result",result:taskView.result??null,historical,more:[{group:"share",label:"Copy link",kind:"copy"}]};return runtime.sendScreen(response,status,{title:`task · ${data.task.id}`,chrome,...sensitive?{sensitive:!0}:{refreshSeconds:runtime.liveRefreshSeconds(),functional:{script:"",app:[{kind:"result"}]}},workspace:{view}})}return extras.recordPack!=null&&(taskView.sections=[...taskView.sections.filter(one=>one.id!=="record"),{id:"record",title:"Record",content:{kind:"record",pack:extras.recordPack},open:!0,count:null}]),runtime.sendScreen(response,status,{title:`task · ${data.task.id}`,chrome,...sensitive?{sensitive:!0}:{refreshSeconds:runtime.liveRefreshSeconds()},...(()=>{if(sensitive)return{};const liveRunId=data.liveRunId??null,liveRun2=liveRunId===null?void 0:data.runs.find(one=>one.id===liveRunId),app=[...liveRun2===void 0?[]:[{kind:"region",region:"check-progress",run:liveRun2.id}],...liveRun2!==void 0&&data.peekable===!0?[{kind:"region",region:"run-peek",run:liveRun2.id}]:[],...data.decisions.some(one=>one.state==="open"||one.state==="expired")?[{kind:"answer"}]:[],...taskView.result!==null?[{kind:"result"}]:[]];return app.length>0?{functional:{script:"",app}}:{}})(),workspace:{view:taskView,...docked===null?{}:{conversation:docked}}})}function armTaskResume(response,who,taskId,named,returnTo,now){if(who.via!=="cookie")return refuse(response,who,403,"resuming a task is a browser session's act");if(who.role!=="approver")return taskScreen(response,who,taskId,"your login can watch — resuming an attempt is an approver's act",403);if(runtime.store.isDemo())return taskScreen(response,who,taskId,"the demo authorizes nothing",403);const ref=runtime.store.lookupRef(taskId);if(ref===null)return taskScreen(response,who,taskId,"That task is not available.",404);if(!/^[0-9]{1,15}$/.test(named))return taskScreen(response,who,taskId,"which attempt? the resume names the exact stopped run",400);const runId=Number(named),stop=runtime.store.stopOf(runId),run=runtime.store.getRun(runId);if(stop===null||run===null||stop.taskRef!==ref.id)return taskScreen(response,who,taskId,`build #${runId} is not a stopped attempt of this task`,409);if(run.role==="reviewer")return taskScreen(response,who,taskId,`build #${runId} was an old review. Nothing reruns it; open the saved result instead`,409);if(stop.resumedAt!==null)return taskScreen(response,who,taskId,`build #${runId} was already resumed by ${stop.resumedBy??"?"}`,409);const control=taskControlOf(runtime.store,ref.id,now);if(control.kind!=="paused"||control.run!==runId)return taskScreen(response,who,taskId,control.kind==="stopping"?`build #${runId} is still stopping. Toolroll is making sure it has ended`:`build #${runId} is no longer the one to resume. Reload and decide again`,409);const digest=resumeDigestOf(taskId,runId,stop.settledAt??"",runtime.store.getScope(taskId)),nonceValue=randomBytes(18).toString("base64url");if(!runtime.store.mintCeremonyNonce({hash:nonceHashOf(nonceValue),approver:who.name,subject:"run-resume",subjectId:runId,digest,ttlMs:15*6e4},now).ok)return taskScreen(response,who,taskId,"too many unfinished confirmations are open — finish or let them expire",429);const gate=diagnoseTaskDispatch(runtime.store,taskId,now),scope=runtime.store.getScope(taskId),blocked=scope!==null&&approvalOf(scope).approved?gate!==null&&gate.code!=="stopped"?`${gate.summary}: ${gate.detail}`:null:"The plan isn't approved as it stands, so nothing builds until it is approved again.";return runtime.sendScreen(response,200,{title:"resume",chrome:runtime.chromeFor(who.session.project,"tasks"),sensitive:!0,workspace:{view:{kind:"task-resume",taskId,taskTitle:runtime.store.getTask(taskId)?.title??taskId,run:control.run,committed:control.committed,nonceValue,returnTo,blocked}}})}function planViewOf(taskRef){const artifact=runtime.store.latestPlanArtifact(taskRef);if(artifact===null)return null;try{const verified=readVerifiedArtifact(runtime.evidenceRoot,artifact);return verified.ok?{document:verified.content.toString("utf8"),sha256:artifact.sha256,run:artifact.run}:null}catch{return null}}function planContractViewOf(taskRef,scope){const artifact=runtime.store.latestPlanContractArtifact(taskRef);if(artifact===null)return null;try{const verified=readVerifiedArtifact(runtime.evidenceRoot,artifact);if(!verified.ok)return{run:artifact.run,problem:`the contract record no longer verifies — ${verified.problem}`};const record=decodePlanContractRecord(verified.content);return record===null?{run:artifact.run,problem:"the contract record is not the JSON it was sealed as"}:{run:artifact.run,sourceDigest:record.sourceDigest,filed:record.filed!==null,amendment:record.amendment,changes:record.changes,changeWords:describeContractChanges(record.changes),current:scope!==null&&contractChangesOf(record.proposed,scope).length===0,revision:runtime.store.revisionSourceOf(taskRef)!==null}}catch{return{run:artifact.run,problem:"the contract record could not be read"}}}function revisionDocOf(row){const artifact=runtime.store.getArtifact(row.artifact);if(artifact===null)return null;try{const verified=readVerifiedArtifact(runtime.evidenceRoot,artifact);return verified.ok?{id:row.id,revision:row.revision,status:row.status,reason:row.reason,evidenceLink:row.evidenceLink,author:row.author,kind:row.kind,authorityKind:row.authorityKind,changedFields:row.changedFields,document:verified.content.toString("utf8"),sha256:artifact.sha256,createdAt:row.createdAt,resolvedAt:row.resolvedAt,resolvedBy:row.resolvedBy}:null}catch{return null}}function revisionLedgerOf(taskRef){const history=runtime.store.listPlanRevisions(taskRef).map(revisionDocOf).filter(view=>view!==null),currentRow=runtime.store.currentPlanRevision(taskRef),latestRow=runtime.store.latestPlanRevision(taskRef),pending=latestRow!==null&&latestRow.status==="blocked"?revisionDocOf(latestRow):null;let current=currentRow===null?null:revisionDocOf(currentRow);if(current===null){const legacy=planViewOf(taskRef);current=legacy===null?null:{id:null,revision:1,status:"applied",reason:"the plan the operator approved",evidenceLink:null,author:"planner",kind:"initial",authorityKind:"plan-only",changedFields:[],document:legacy.document,sha256:legacy.sha256,createdAt:"",resolvedAt:null,resolvedBy:null}}return{current,pending,history}}function progressOf(taskRef,currentDocument){if(currentDocument===null)return null;const parsed=parseExecutionPlanDocument(currentDocument);if(!parsed.ok)return null;const milestones=milestonesOf(parsed.document),checkpoint=runtime.store.latestCheckpointForTask(taskRef),byId=new Map((checkpoint?.snapshot.milestones??[]).map(entry=>[entry.id,entry]));return milestones.map(milestone=>{const entry=byId.get(milestone.id);return{id:milestone.id,description:milestone.description,state:entry?.state??"pending",note:entry?.note??null}})}function resultDetailOf(run,who,now){const taskId=runtime.store.externalIdFor(run.taskRef)??"?",scope=runtime.store.getScope(taskId),artifacts=runtime.store.artifactsFor(run.id),terminal=terminalDiffView(artifacts,runtime.evidenceRoot),proof=proofBundleView(runtime.store,run,artifacts,runtime.evidenceRoot),handoff=structuredHandoffView(artifacts,runtime.evidenceRoot),review=runtime.reviewFactsFor(run.id),receipt=completionReceiptView(runtime.store,run,artifacts,runtime.evidenceRoot,review),patch=terminal?.patch??null,patchOk=patch!==null&&!("problem"in patch),parsedPaths=patchOk?parseReviewDiff(patch.text).files.filter(one=>one.hunks.length>0).map(one=>one.path):[],fileAnchors=new Map(parsedPaths.map(path=>[path,diffFileAnchor(path)])),statFiles=terminal?.stat!==null&&terminal?.stat!==void 0&&!("problem"in terminal.stat)?terminal.stat.files:[],cited=new Set;for(const criterion of proof?.matrix??[])for(const answer of criterion.answered)answer.kind==="changed-path"&&cited.add(answer.ref);const touches=scope?.touches??[],files=orderChangedFiles(statFiles.map(file=>({path:file.path,additions:file.additions,deletions:file.deletions,renamedFrom:file.renamedFrom??null,anchor:fileAnchors.get(file.path)??null,outsideTouches:touches.length>0&&!withinSignedTouches(file.path,touches),cited:cited.has(file.path)})),cited.size>0),publication=runtime.store.publicationForRun(run.id);let skillTest=!1,learningData=null;const learningRepo=runtime.store.refForId(run.taskRef)?.repo;if(learningRepo&&runtime.visible(learningRepo)){const data={contextProblem:null,skillsSnapshot:null,knowledgeSnapshot:null,skillTestProblem:null,skillTest:null,learning:null},csrf=who.via==="cookie"?who.session.csrf:"",canManage=who.role==="approver";try{const view=learningView(runtime.store,runtime.evidenceRoot,learningRepo,who.name),lessons=view.lessons.filter(l=>l.source===run.id);if(lessons.length>0){const platforms={darwin:"macOS",win32:"Windows",linux:"Linux"};data.learning={repo:view.repo,identity:view.identity,revision:view.revision,canManage:canManage&&csrf!=="",source:run.id,lessons:lessons.map(l=>({id:l.id,version:l.version,sha:l.sha,observation:l.payload.observation,action:l.payload.action,lastIncluded:lastIncludedWords(view.use.get(`lesson:${l.id}`)),kindLabel:l.payload.kind==="system"?"System suggestion · No change applied":l.status==="adopted"?"Adopted advice":l.status==="disabled"?"Disabled":"Proposed lesson",isProject:l.payload.kind==="project",status:l.status,source:l.source,reviewer:l.reviewer,metaSummary:`${l.payload.paths.join(", ")} · ${l.payload.phases.join(", ")} · ${platforms[l.payload.platform]??l.payload.platform}`,evidence:l.payload.evidence.map(one=>({runId:one.runId??l.source,artifactId:one.artifactId,excerpt:one.excerpt,sha256:one.sha256}))}))}}}catch{}try{const test=skillTestResult(runtime.store,run.id,who.name);test&&(skillTest=!0,data.skillTest={run:test.run,repo:test.repo,sourceRun:test.sourceRun,feedback:test.feedback,revisions:[...test.revisions],canRevise:canManage&&csrf!=="",nonce:canManage&&csrf!==""?randomUUID():null})}catch{data.skillTestProblem="The saved skill test could not be verified."}try{const skills=readSkillsSnapshot(runtime.store,run.id),knowledge=readKnowledgeSnapshot(runtime.store,run.id);skills&&skills.packages.length>0&&(data.skillsSnapshot={packages:skills.packages.map(s=>({name:s.name,shaShort:s.sha.slice(0,10),source:s.source,fileCountLabel:plural(s.files.length,"file","files"),kb:Math.ceil(s.files.reduce((n,f)=>n+Buffer.from(f.base64,"base64").length,0)/1024),skillMd:Buffer.from(s.files.find(f=>f.path==="SKILL.md").base64,"base64").toString("utf8"),files:s.files.map(f=>f.path)}))}),knowledge&&(data.knowledgeSnapshot={revision:knowledge.revision,inheritedFrom:knowledge.inheritedFrom,instructions:knowledge.instructions,references:knowledge.references.map(r=>({title:r.title,path:r.path,sourceRevision:r.sourceRevision,content:r.content})),omitted:knowledge.omitted.map(r=>({title:r.title,reason:r.reason}))})}catch{data.contextProblem="The context saved for this run could not be verified."}(data.contextProblem!==null||data.skillsSnapshot!==null||data.knowledgeSnapshot!==null||data.skillTestProblem!==null||data.skillTest!==null||data.learning!==null)&&(learningData=data)}const family=runtime.familyOf(taskId);return{learningData,skillTest,taskId,rootId:family?.root.id??taskId,...family===null?{}:{historyData:familyHistoryData(family)},run,receipt,...(()=>{const value=assignmentOf(runtime.store,taskId,now,runtime.workAccess(),runtime.evidenceRoot),assignment=value?.receipt?.runId===run.id&&value.activeTaskId===taskId?freshAssignment(value,receipt):null,completeRefusal=assignment?.state!=="ready-to-check"||assignment.receipt===null?null:personCompletionRefusal(runtime.store,assignment.receipt.taskId,run.id,who.via==="cookie"?who.name:null,runtime.evidenceRoot,who.via==="cookie"&&who.authority==="local-owner"?{rootId:assignment.rootId}:null);return{assignment,completeRefusal,landed:assignment!==null&&landedNowOf(runtime.store,assignment)!==null}})(),handoff,proof,terminal,publication,pullRequestTo:pullRequestTargetOf(run.id),buildNowOnSendBack:who.via==="cookie"&&who.role==="approver"&&(who.authority==="local-owner"||sessionYesPossible(runtime.store,who.name,!0)),publishing:pullRequestTargetOf(run.id)!==null?"pull-request":publishingOf(runtime.store,runtime.store.refById(run.taskRef)?.repo??null).on?"other":"off",ciFailing:publication!==null&&publication.prNumber!==null&&runtime.store.hasOpenCiEpisode(publication.githubRepo,publication.prNumber),files,outsideTouches:files.filter(one=>one.outsideTouches).map(one=>one.path),fileAnchors,comments:runtime.store.liveDiffComments(run.id).filter(isRevisionFeedback),unusableImageNotes:runtime.store.liveDiffComments(run.id).filter(one=>isRevisionFeedback(one)&&one.image!=null&&feedbackImageProblem(runtime.store,runtime.evidenceRoot,run.id,one.image)!==null).map(one=>one.id),pastComments:runtime.store.allDiffComments(run.id).filter(one=>one.reviewerRun===null&&(one.consumedBy!==null||one.supersededBy!==null)),reviewerFindings:runtime.store.allDiffComments(run.id).filter(one=>one.reviewerRun!==null),automaticReview:buildReviewOf(runtime.store,run.id),revisions:runtime.store.revisionsFromRun(run.id).flatMap(one=>{const child=runtime.store.getTask(one.id);if(child===null||!runtime.visible(runtime.store.lookupRef(one.id)?.repo??null))return[];const status=workRowOf({...child,repo:runtime.store.lookupRef(one.id)?.repo??null},now).status;return[{id:one.id,title:one.title,state:one.state,approved:approvalOf(runtime.store.getScope(one.id)).approved,standing:status.label,tone:status.tone}]}),sourceDigest:scope?.digest??null,followUps:followUpsFor(runtime.store,runtime.evidenceRoot,run,now),route:runtime.store.runRoute(run.id),editor:runtime.options.editorLinks!==void 0&&runtime.options.localRunner!==void 0&&run.runner===runtime.options.localRunner&&who.via==="cookie"&&who.session.editorLinks===!0&&run.worktree!==null&&existsSync(run.worktree)?{worktree:run.worktree}:null,signedCriteria:scope?.acceptance.length??0,canAnnotate:who.via==="cookie"&&patchOk&&patch.text.trim()!==""}}function familyHistoryData(family){const problem=family.problem,otherActive=family.versions.length<2?0:new Set([...family.otherActive.map(one=>one.id),...earlierLiveVersions(family,runtime.clock())]).size,versions=family.versions.length<2?[]:family.versions.map((version,index)=>{const label=index===0?"Original":`Revision ${index}`,status=workRowOf(version,runtime.clock()).status,runs=runtime.store.runsFor(version.refId).filter(runIsTaskResult),href=`${taskHref(family.root.id)}?version=${encodeURIComponent(version.id)}`;return{id:version.id,label,current:version.id===family.current.id,statusLabel:status.label,href,runs:runs.map(run=>({id:run.id,href:run.outcome==="built"||run.outcome==="no-change"?chatResultHref(family.root.id,run.id):`/r/${run.id}`,outcomeLabel:run.outcome==="built"?null:run.outcome==="no-change"?"No changes":run.outcome==="failed"?"Failed":run.outcome??"Unfinished"}))}});return problem===null&&versions.length<2?null:{rootId:family.root.id,problem,otherActive,versions}}return{guided,projectFamilyPeek,familiesInView,familyTasksInView,revisionDestination,earlierLiveVersions,familyHistoryData,freshAssignment,workRowOf,runIsLive,runIsTaskResult,revisionViewOf,taskViewData,routeViewOf,taskChatFocus,pullRequestTargetOf,taskPullRequestOf,failureOf,explainAttempt,runChecksHere,taskScreen,armTaskResume,planViewOf,planContractViewOf,revisionDocOf,revisionLedgerOf,progressOf,resultDetailOf}}function autoReleaseOf(scope){return scope===null||scope.approvedDigest!==scope.digest||(scope.candidate??null)===null?null:scope.approvalBasis==="auto-green"?{kind:"approved",candidate:scope.candidate}:scope.approvalBasis==="auto-check"?{kind:"checking",candidate:scope.candidate}:null}export function shipViewOf(ship,now){if(ship===null||ship.checks.length===0)return null;const at=iso=>iso===null?null:Date.parse(iso),observed=Date.parse(ship.observedAt),end=Number.isFinite(observed)?observed:now.getTime(),starts=ship.checks.map(one=>at(one.startedAt)).filter(one=>one!==null&&Number.isFinite(one)),origin=starts.length===0?end:Math.min(...starts),st=state2=>state2==="passed"?"ok":state2==="failed"||state2==="cancelled"?"bad":state2==="running"?"run":state2==="queued"?"q":"ok",rows=ship.checks.map(one=>{const start=at(one.startedAt),done=at(one.completedAt),from=start??origin;return{name:one.name,...one.workflow===null||one.workflow===one.name?{}:{sub:one.workflow},...one.state==="skipped"?{sub:"skipped"}:one.state==="neutral"?{sub:"neutral"}:{},st:st(one.state),start:Math.max(0,(from-origin)/1e3),dur:start===null?0:Math.max(0,((done??end)-start)/1e3)}}),passed=ship.checks.filter(one=>one.state==="passed"||one.state==="skipped"||one.state==="neutral").length,failed=ship.checks.filter(one=>one.state==="failed"||one.state==="cancelled").length,state=ship.observed==="failing"?"failed":ship.observed==="passing"?"passed":ship.observed==="running"?"running":"none";return{pr:ship.prNumber,head:ship.headSha.slice(0,7),state,rows,summary:state==="failed"?failed>0?`${failed} of ${ship.checks.length} ${ship.checks.length===1?"check":"checks"} failed`:"Checks are failing on GitHub":state==="running"?`${passed} of ${ship.checks.length} checks passed`:state==="passed"?`All ${ship.checks.length} ${ship.checks.length===1?"check":"checks"} passed`:"No current checks: the pull request is closed or merged, or GitHub reported none",observedAt:ship.observedAt}}const RELEASE_STEP_WORDS={gate:"Release gate",approval:"Approval",check:"Release check",complete:"Complete the task",quiet:"Wait for quiet",deploy:"Deploy to this Mac",link:"Point the CLI at it",ci:"Pull request checks",merge:"Merge into main",tree:"Verify the merged tree",tag:"Tag",publish:"Publish to npm",homebrew:"Homebrew"};export function releaseStepsViewOf(progress,now){if(progress===null)return null;const origin=Date.parse(progress.startedAt),recorded=new Map(progress.steps.map(one=>[one.step,one])),all=RELEASE_STEPS.filter(step=>step!=="done"),building=progress.building,checkAt=all.indexOf("check"),firstAt=building===null?all.findIndex(step=>recorded.has(step)):Math.min(all.findIndex(step=>recorded.has(step)),checkAt),lastAt=all.reduce((at2,step,index)=>recorded.has(step)?index:at2,-1),steps=firstAt<=0?all:all.slice(firstAt),rows=steps.map(step=>{const one=recorded.get(step);if(building!==null&&step==="check"){const start2=Date.parse(building.startedAt);return{name:RELEASE_STEP_WORDS[step]??step,st:"run",start:Number.isFinite(start2)&&Number.isFinite(origin)?Math.max(0,(start2-origin)/1e3):0,dur:Number.isFinite(start2)?Math.max(0,(now.getTime()-start2)/1e3):0}}if(building!==null&&all.indexOf(step)>checkAt)return{name:RELEASE_STEP_WORDS[step]??step,st:"q",start:0,dur:0};if(one===void 0)return all.indexOf(step)<lastAt?{name:RELEASE_STEP_WORDS[step]??step,sub:"not recorded",st:"q",start:0,dur:0}:{name:RELEASE_STEP_WORDS[step]??step,st:"q",start:0,dur:0};const start=Date.parse(one.startedAt),end=one.endedAt===null?now.getTime():Date.parse(one.endedAt),st=one.state==="failed"&&progress.stopped?.step!==step?"history":one.state==="done"?"ok":one.state==="failed"?"bad":one.state==="waiting"?step==="approval"?"wait":"waiting":"run",waitingReason=st!=="waiting"?null:step==="ci"?"Waiting for PR checks":step==="quiet"?"Waiting for active work to finish":`Waiting for ${(RELEASE_STEP_WORDS[step]??step).toLowerCase()}`,detail=one.state==="done"?null:one.detail??waitingReason;return{name:RELEASE_STEP_WORDS[step]??step,...detail===null?{}:{sub:detail.slice(0,160)},st,start:Number.isFinite(start)&&Number.isFinite(origin)?Math.max(0,(start-origin)/1e3):0,dur:Number.isFinite(start)&&Number.isFinite(end)?Math.max(0,(end-start)/1e3):0}}),current=rows.findIndex(row=>row.st==="run"||row.st==="wait"||row.st==="waiting"||row.st==="bad"),done=progress.stopped===null&&recorded.get("homebrew")?.state==="done",at=current===-1?null:rows[current],last=lastAt===-1?null:RELEASE_STEP_WORDS[all[lastAt]]??all[lastAt];return{tag:progress.tag,version:progress.version,pr:progress.pr,rows,state:progress.stopped!==null?"failed":done?"done":at?.st==="wait"&&steps[current]==="approval"?"waiting":"running",at:current===-1?null:{step:steps[current],name:at.name,index:current+1,of:rows.length},headline:done?`Released ${progress.version}`:progress.stopped!==null?`Stopped at ${RELEASE_STEP_WORDS[progress.stopped.step]??progress.stopped.step}`:at!==null?`${at.name} · Step ${current+1} of ${rows.length}`:last===null?"Starting":`${last} done · the next step starts on its own`,stopped:progress.stopped===null?null:{step:RELEASE_STEP_WORDS[progress.stopped.step]??progress.stopped.step,message:progress.stopped.message,at:progress.stopped.at},startedAt:progress.startedAt}}function landedOf(data){return data.landing?.onBranch===!0?data.landing.landed:null}
|