chainlesschain 0.166.106 → 0.166.108

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.
Files changed (225) hide show
  1. package/README.md +187 -8
  2. package/package.json +2 -2
  3. package/src/assets/linux-subreaper/linux-arm64/manifest.json +1 -1
  4. package/src/assets/linux-subreaper/linux-x64/manifest.json +1 -1
  5. package/src/assets/web-panel/assets/{AIOps-CKwEku2e.js → AIOps-B5HWUFaS.js} +1 -1
  6. package/src/assets/web-panel/assets/{ActionButton-BSUOuTpW.js → ActionButton-DCIKpxoQ.js} +1 -1
  7. package/src/assets/web-panel/assets/{Analytics-CGxvL_FI.js → Analytics-dsgvjCEQ.js} +3 -3
  8. package/src/assets/web-panel/assets/{AppLayout-bCPwz-5w.js → AppLayout-DWDH5Qbm.js} +5 -5
  9. package/src/assets/web-panel/assets/{Artifacts-2_BOWo6e.js → Artifacts-BD8S8kzU.js} +1 -1
  10. package/src/assets/web-panel/assets/{Audit-CBOruzgW.js → Audit-CDXv4Aoj.js} +1 -1
  11. package/src/assets/web-panel/assets/{BackgroundAgents-lg0IU5HN.js → BackgroundAgents-BLAQ5Uy0.js} +1 -1
  12. package/src/assets/web-panel/assets/{Backup-OspCi452.js → Backup-moPac6tF.js} +1 -1
  13. package/src/assets/web-panel/assets/{BaseInput-BMkliqlz.js → BaseInput-C_6nzsLU.js} +1 -1
  14. package/src/assets/web-panel/assets/{Chat-BfoiUZwp.js → Chat-cYuslkFG.js} +6 -6
  15. package/src/assets/web-panel/assets/{ChatBubbleRenderer-BjnfMwep.js → ChatBubbleRenderer-Ceh3MG6M.js} +1 -1
  16. package/src/assets/web-panel/assets/{Checkbox-jTMlkNQZ.js → Checkbox-Qjb-XOX_.js} +1 -1
  17. package/src/assets/web-panel/assets/{Codegen-CycyJcnU.js → Codegen-IYRWXlMA.js} +1 -1
  18. package/src/assets/web-panel/assets/{Col-BVWlReQj.js → Col-CsQ9jv8M.js} +1 -1
  19. package/src/assets/web-panel/assets/{Community-CKRHl4xK.js → Community-BbNmfTwe.js} +1 -1
  20. package/src/assets/web-panel/assets/{Compact-BtpfMdhT.js → Compact-SShDx-nr.js} +1 -1
  21. package/src/assets/web-panel/assets/{Compliance-DtHB1Ct1.js → Compliance-CLWhKIJp.js} +1 -1
  22. package/src/assets/web-panel/assets/{Cowork-D_8X7-RK.js → Cowork-D4tK9_s3.js} +2 -2
  23. package/src/assets/web-panel/assets/{Cron-DMCOyvEa.js → Cron-D7GnfQ1z.js} +2 -2
  24. package/src/assets/web-panel/assets/{Crosschain-CeHdsu7m.js → Crosschain-TG86SH3X.js} +1 -1
  25. package/src/assets/web-panel/assets/{DID-CL6mR6zX.js → DID-6pue0NCO.js} +2 -2
  26. package/src/assets/web-panel/assets/{Dashboard-oz9n6DC7.js → Dashboard-BwkJ29du.js} +2 -2
  27. package/src/assets/web-panel/assets/{Dropdown-CbWm8mWu.js → Dropdown-DEvpYDof.js} +1 -1
  28. package/src/assets/web-panel/assets/EmailListRenderer-CQj7UlKJ.js +1 -0
  29. package/src/assets/web-panel/assets/{EvolutionSettings-DPwqgRYm.js → EvolutionSettings-tpvPMM9W.js} +1 -1
  30. package/src/assets/web-panel/assets/{FamilyGuardDashboard-DkV4YMFj.js → FamilyGuardDashboard-CWYFW75O.js} +1 -1
  31. package/src/assets/web-panel/assets/{Federation-CpUKHIOH.js → Federation-gRIi96rM.js} +1 -1
  32. package/src/assets/web-panel/assets/{FormItemContext-C6KXRgjR.js → FormItemContext-B7Nr3YkV.js} +1 -1
  33. package/src/assets/web-panel/assets/{GenericCardRenderer-C5Y4L5E3.js → GenericCardRenderer-b1BgGgLT.js} +1 -1
  34. package/src/assets/web-panel/assets/{Git-CBwKdF8s.js → Git-Dis1jjO7.js} +2 -2
  35. package/src/assets/web-panel/assets/{Governance-Dt-OR7Aa.js → Governance-C4Yg99Am.js} +1 -1
  36. package/src/assets/web-panel/assets/{Inference-Czkl-Lhl.js → Inference-D4UQRbGu.js} +1 -1
  37. package/src/assets/web-panel/assets/{KnowledgeGraph-C7NE4949.js → KnowledgeGraph-Co_kLMAq.js} +1 -1
  38. package/src/assets/web-panel/assets/{Logs-CoAuZiMG.js → Logs-D4BRp7bg.js} +2 -2
  39. package/src/assets/web-panel/assets/{MarkdownRenderer-DTkjTwGI.js → MarkdownRenderer-Dgy8arQI.js} +1 -1
  40. package/src/assets/web-panel/assets/{Marketplace-IzrV-7zH.js → Marketplace-ys0j1vr9.js} +1 -1
  41. package/src/assets/web-panel/assets/{McpTools-DYEea7aS.js → McpTools-B3ZvRZe_.js} +2 -2
  42. package/src/assets/web-panel/assets/{Memory-Uqe7ZrV6.js → Memory-BOa0jbr-.js} +2 -2
  43. package/src/assets/web-panel/assets/{MobileBridge-D092EGyM.js → MobileBridge-CWJRmUbj.js} +1 -1
  44. package/src/assets/web-panel/assets/MobileProjects-7ty8vTpj.js +1 -0
  45. package/src/assets/web-panel/assets/{Mtc-gg4jzfB-.js → Mtc-CCcOk5m5.js} +5 -5
  46. package/src/assets/web-panel/assets/{MtcAudit-BibGfs71.js → MtcAudit-vlrrScbQ.js} +4 -4
  47. package/src/assets/web-panel/assets/{Multisig-BmB5yRXP.js → Multisig-C8K59S_8.js} +3 -3
  48. package/src/assets/web-panel/assets/{NLProgramming-BBSlPDyY.js → NLProgramming-oTpFYVme.js} +1 -1
  49. package/src/assets/web-panel/assets/{Notes-Bui3-KiC.js → Notes-BhqAJWiz.js} +3 -3
  50. package/src/assets/web-panel/assets/{NotificationSettings-ovXtbHe5.js → NotificationSettings-DCnV1CJM.js} +1 -1
  51. package/src/assets/web-panel/assets/{OrderTableRenderer-Bq-qD7eG.js → OrderTableRenderer-CZGnsrVW.js} +1 -1
  52. package/src/assets/web-panel/assets/{Organization-DacIY9oJ.js → Organization-DX1LuQlJ.js} +4 -4
  53. package/src/assets/web-panel/assets/{Overflow-CX8osheZ.js → Overflow-CbfKrFdT.js} +1 -1
  54. package/src/assets/web-panel/assets/{P2P-1lnikqVp.js → P2P-BEwYZuHL.js} +2 -2
  55. package/src/assets/web-panel/assets/{PdhVaultBrowser-DCrU-V6A.js → PdhVaultBrowser-YNmWbwd7.js} +3 -3
  56. package/src/assets/web-panel/assets/{Permissions-Dfcb6kM2.js → Permissions-DyZ18LiA.js} +4 -4
  57. package/src/assets/web-panel/assets/{PersonalDataHub-dvgai4hf.js → PersonalDataHub-B2J3aw2g.js} +4 -4
  58. package/src/assets/web-panel/assets/{Pipeline-nymAEtnK.js → Pipeline-CXl2ZlhQ.js} +1 -1
  59. package/src/assets/web-panel/assets/{Privacy-D0Vd91oM.js → Privacy-I5SDmgAp.js} +1 -1
  60. package/src/assets/web-panel/assets/{ProjectInit-BpUBcu7o.js → ProjectInit-Crl9tXw3.js} +2 -2
  61. package/src/assets/web-panel/assets/{ProjectSettings-DIzwTT-M.js → ProjectSettings-DCFtFlSK.js} +2 -2
  62. package/src/assets/web-panel/assets/{Projects-Den4RUw6.js → Projects-Do5BQq1i.js} +1 -1
  63. package/src/assets/web-panel/assets/{Providers-Cq8p-M0d.js → Providers-Cb7OWa3y.js} +1 -1
  64. package/src/assets/web-panel/assets/{QrScannerModal-DSmqOfYk.js → QrScannerModal-CJmhAU-s.js} +1 -1
  65. package/src/assets/web-panel/assets/{QuickAsk-BDHCeSnA.js → QuickAsk-Cu6lEWou.js} +1 -1
  66. package/src/assets/web-panel/assets/{Recommend-B_9M8oF4.js → Recommend-Crip3jLB.js} +1 -1
  67. package/src/assets/web-panel/assets/{RemoteSession-5ot4leHy.js → RemoteSession-KxYY-2CB.js} +3 -3
  68. package/src/assets/web-panel/assets/{Reputation-B3F013PY.js → Reputation-D0vN-htI.js} +1 -1
  69. package/src/assets/web-panel/assets/{Row-BMyBJnZw.js → Row-wqzd_xCD.js} +1 -1
  70. package/src/assets/web-panel/assets/{RssFeed-WmV0l52g.js → RssFeed-8lsPfb0a.js} +3 -3
  71. package/src/assets/web-panel/assets/{Search-Wl80yXnR.js → Search-C-e8qAeU.js} +1 -1
  72. package/src/assets/web-panel/assets/{Security-gbDMKb5m.js → Security-CMM9WgFy.js} +4 -4
  73. package/src/assets/web-panel/assets/{Services-Bx2Bjhah.js → Services-CZdxjN2B.js} +2 -2
  74. package/src/assets/web-panel/assets/{Skeleton-BvJNybjV.js → Skeleton-BI3XNk35.js} +1 -1
  75. package/src/assets/web-panel/assets/Skills-DMlsh9It.js +1 -0
  76. package/src/assets/web-panel/assets/{Sla-BM9gyZwc.js → Sla-HQruznKY.js} +1 -1
  77. package/src/assets/web-panel/assets/{SpeechSettings-Bu9FL9Tz.js → SpeechSettings-Dl-MFq3w.js} +1 -1
  78. package/src/assets/web-panel/assets/{SyncSettings-D8ICJsMt.js → SyncSettings-BU224vDm.js} +2 -2
  79. package/src/assets/web-panel/assets/Tasks-DESg3yCs.js +1 -0
  80. package/src/assets/web-panel/assets/{Templates-BJzpTD0W.js → Templates-Jb3TPz4Q.js} +1 -1
  81. package/src/assets/web-panel/assets/{Tenant-BN8eX4R2.js → Tenant-CQ-GTrfa.js} +1 -1
  82. package/src/assets/web-panel/assets/{Terminal-CjtP9bpq.js → Terminal-BbMl3Rue.js} +2 -2
  83. package/src/assets/web-panel/assets/{TimelineRenderer-CpNRa4XW.js → TimelineRenderer-CS_vstKF.js} +1 -1
  84. package/src/assets/web-panel/assets/{Tokens-2lNNvNAH.js → Tokens-BaopVl1f.js} +1 -1
  85. package/src/assets/web-panel/assets/{Trigger-DxtxXyPg.js → Trigger-DtnD4WUN.js} +1 -1
  86. package/src/assets/web-panel/assets/{Trust-CakzGeF9.js → Trust-CsvG4Tmf.js} +1 -1
  87. package/src/assets/web-panel/assets/{UkeySign-CvJeRXwV.js → UkeySign-C1-A-cOV.js} +1 -1
  88. package/src/assets/web-panel/assets/{VideoEditing-D80pMzcO.js → VideoEditing-CNgJPdSL.js} +1 -1
  89. package/src/assets/web-panel/assets/{Wallet-BF-VOBmZ.js → Wallet-CdF41501.js} +4 -4
  90. package/src/assets/web-panel/assets/{WebAuthn-DXyoAzE_.js → WebAuthn-D-JmxD5g.js} +4 -4
  91. package/src/assets/web-panel/assets/{WorkflowEditor-X6CDxzrF.js → WorkflowEditor-C0XunR13.js} +1 -1
  92. package/src/assets/web-panel/assets/{chat-BcUhqjeA.js → chat-BBAZpD_G.js} +1 -1
  93. package/src/assets/web-panel/assets/{colors-Dw4bKaCm.js → colors-BxSxO5BX.js} +1 -1
  94. package/src/assets/web-panel/assets/{compact-item-BWhu5Eri.js → compact-item-BoxL8pg5.js} +1 -1
  95. package/src/assets/web-panel/assets/{createContext-BLJ9JKoN.js → createContext-W5JAyZmY.js} +1 -1
  96. package/src/assets/web-panel/assets/devWarning-BI5TZ7EX.js +1 -0
  97. package/src/assets/web-panel/assets/{hasIn-DIkCiJbt.js → hasIn-HpiKDPVC.js} +1 -1
  98. package/src/assets/web-panel/assets/index-9-JLDK5n.js +1 -0
  99. package/src/assets/web-panel/assets/{index-BAwcMKaD.js → index-9caMEwQ-.js} +1 -1
  100. package/src/assets/web-panel/assets/{index-0mHbawfQ.js → index-B05_YRHZ.js} +1 -1
  101. package/src/assets/web-panel/assets/index-B7m8ioaQ.js +1 -0
  102. package/src/assets/web-panel/assets/{index-D3wp_jgy.js → index-B9VxE1C-.js} +1 -1
  103. package/src/assets/web-panel/assets/{index-BotMuGS2.js → index-BA3WWQAT.js} +1 -1
  104. package/src/assets/web-panel/assets/{index-LOsZYbic.js → index-BSJ0cAle.js} +1 -1
  105. package/src/assets/web-panel/assets/{index-C5qms36i.js → index-BW4PP5GN.js} +1 -1
  106. package/src/assets/web-panel/assets/{index-CDfB6hWf.js → index-BZAbaY64.js} +1 -1
  107. package/src/assets/web-panel/assets/{index-BipG-tDs.js → index-Ba4usRFM.js} +1 -1
  108. package/src/assets/web-panel/assets/{index-CgsVg5Up.js → index-BgMViZIY.js} +1 -1
  109. package/src/assets/web-panel/assets/{index-CTPoBbIR.js → index-BtFAEG08.js} +1 -1
  110. package/src/assets/web-panel/assets/{index-DKzG3kBM.js → index-Bwn6k_qw.js} +1 -1
  111. package/src/assets/web-panel/assets/{index-PRYboDFm.js → index-C4uI7WCB.js} +1 -1
  112. package/src/assets/web-panel/assets/{index-DQbWGvE4.js → index-C5kqii-G.js} +1 -1
  113. package/src/assets/web-panel/assets/{index-B1fufz1A.js → index-C7GIUWWF.js} +1 -1
  114. package/src/assets/web-panel/assets/{index-DjEP26Te.js → index-CM_gdohF.js} +1 -1
  115. package/src/assets/web-panel/assets/{index-BcTch6Fp.js → index-CRg3aOoj.js} +1 -1
  116. package/src/assets/web-panel/assets/{index-04SKBH8l.js → index-CcyzZloJ.js} +1 -1
  117. package/src/assets/web-panel/assets/{index-DHLW27Je.js → index-CehxfRUR.js} +1 -1
  118. package/src/assets/web-panel/assets/{index-5vzPcr1g.js → index-D6m6B4Wy.js} +1 -1
  119. package/src/assets/web-panel/assets/{index-DV4FSjmI.js → index-DSyfxxQS.js} +3 -3
  120. package/src/assets/web-panel/assets/{index-D5vFJmmX.js → index-DaJk9U9V.js} +1 -1
  121. package/src/assets/web-panel/assets/{index-BxLDNxEQ.js → index-DcmAiq_Y.js} +1 -1
  122. package/src/assets/web-panel/assets/{index-D-Erv8A9.js → index-DdEcQ1rp.js} +1 -1
  123. package/src/assets/web-panel/assets/{index-CqGqoID5.js → index-DinY7IQa.js} +1 -1
  124. package/src/assets/web-panel/assets/{index-BGMzh2oj.js → index-DkSnlgK_.js} +1 -1
  125. package/src/assets/web-panel/assets/{index-BxfimJOH.js → index-DlPvZgv8.js} +1 -1
  126. package/src/assets/web-panel/assets/{index-DOjQi7oU.js → index-DuM9I1If.js} +1 -1
  127. package/src/assets/web-panel/assets/{index-uMtx6e3D.js → index-DwidpDEE.js} +1 -1
  128. package/src/assets/web-panel/assets/{index-CXJ8t1hK.js → index-IO2I7nzu.js} +1 -1
  129. package/src/assets/web-panel/assets/{index-Cmc7qH2C.js → index-JrMBRi62.js} +1 -1
  130. package/src/assets/web-panel/assets/{index-BaStonJm.js → index-QzlEbtRL.js} +1 -1
  131. package/src/assets/web-panel/assets/{index-Cr05twNa.js → index-V6VIJe2N.js} +1 -1
  132. package/src/assets/web-panel/assets/{index-BGFqk1-E.js → index-_38IJqoP.js} +1 -1
  133. package/src/assets/web-panel/assets/{index-u0tqS0iq.js → index-_p4e3KfB.js} +1 -1
  134. package/src/assets/web-panel/assets/{index-D1r2R4a-.js → index-gvfIRZxJ.js} +1 -1
  135. package/src/assets/web-panel/assets/{index-CFGOV-YT.js → index-ooP1pQCt.js} +1 -1
  136. package/src/assets/web-panel/assets/{index-BUC4TZWg.js → index-p6rNtYud.js} +1 -1
  137. package/src/assets/web-panel/assets/{initDefaultProps-Bx6Hj_FG.js → initDefaultProps-Dfn6M05J.js} +1 -1
  138. package/src/assets/web-panel/assets/{motion-BSWivB70.js → motion-BRRwFqGO.js} +1 -1
  139. package/src/assets/web-panel/assets/{move-Dv1Pg9R7.js → move-DpDPN6zR.js} +1 -1
  140. package/src/assets/web-panel/assets/{mtc-parser-Bqtl8fsk.js → mtc-parser-BHlSE87F.js} +1 -1
  141. package/src/assets/web-panel/assets/{omit-DpOBjOSQ.js → omit-CEOri_L5.js} +1 -1
  142. package/src/assets/web-panel/assets/{pickAttrs-D-M-dz48.js → pickAttrs-DqICh-ad.js} +1 -1
  143. package/src/assets/web-panel/assets/{placementArrow-DsTLAifk.js → placementArrow-DQizFFiV.js} +1 -1
  144. package/src/assets/web-panel/assets/{responsiveObserve-BVTetMpc.js → responsiveObserve-DmFHPdvC.js} +1 -1
  145. package/src/assets/web-panel/assets/{slide-abEcz-Cv.js → slide-s2s1XS3T.js} +1 -1
  146. package/src/assets/web-panel/assets/{statusUtils-CBhrdU2G.js → statusUtils-IwEIbBan.js} +1 -1
  147. package/src/assets/web-panel/assets/{styleChecker-CFq8ZCKa.js → styleChecker-CIFLlbXH.js} +1 -1
  148. package/src/assets/web-panel/assets/{useFlexGapSupport-o4eE7fDV.js → useFlexGapSupport-CFkN2Cgh.js} +1 -1
  149. package/src/assets/web-panel/assets/{useFs-Hs9W8ihi.js → useFs-BSY6O48s.js} +1 -1
  150. package/src/assets/web-panel/assets/{usePersonalDataHub-Bnet5Jho.js → usePersonalDataHub-iJl3VnU0.js} +1 -1
  151. package/src/assets/web-panel/assets/{vnode-DJfN4kWs.js → vnode-vu8ReMs7.js} +1 -1
  152. package/src/assets/web-panel/assets/{zoom-BzV-2e7X.js → zoom-CeSrYAHp.js} +1 -1
  153. package/src/assets/web-panel/index.html +1 -1
  154. package/src/command-help-index.json +2 -2
  155. package/src/commands/agent.js +20 -20
  156. package/src/commands/goal.js +299 -1
  157. package/src/commands/plugin.js +129 -68
  158. package/src/constants.js +2 -2
  159. package/src/data/changelog.json +29 -3
  160. package/src/harness/jsonl-session-store.js +128 -5
  161. package/src/harness/prompt-compressor.js +18 -10
  162. package/src/harness/structured-handoff.js +151 -13
  163. package/src/lib/agent-session-export.js +20 -0
  164. package/src/lib/background-agent-supervisor.js +54 -0
  165. package/src/lib/cli-goal-catalog.js +129 -0
  166. package/src/lib/cli-goal-source.js +119 -0
  167. package/src/lib/coding-task-guidance.js +2 -1
  168. package/src/lib/config-schema.js +1 -1
  169. package/src/lib/context-memory-kernel/live-compaction.js +75 -12
  170. package/src/lib/eval/stream-terminal.js +27 -2
  171. package/src/lib/evolution/evolution-artifact-ports.js +22 -11
  172. package/src/lib/evolution/evolution-file-witness.js +86 -63
  173. package/src/lib/evolution/evolution-ledger-file-backend.js +22 -0
  174. package/src/lib/evolution/evolution-ledger-file-manifest-catalog.js +34 -35
  175. package/src/lib/evolution/evolution-ledger-file-manifest-head-store.js +32 -39
  176. package/src/lib/evolution/evolution-ledger.js +367 -169
  177. package/src/lib/evolution/evolution-manifest-state-reader.js +58 -0
  178. package/src/lib/evolution/evolution-physical-state-reader.js +308 -0
  179. package/src/lib/evolution/evolution-witness-segments.js +12 -13
  180. package/src/lib/evolution/governed-wiki-pruning-ledger-adapter.js +82 -56
  181. package/src/lib/evolution/rrsi-observed-text-index.js +17 -1
  182. package/src/lib/evolution/rrsi-tenant-index-anchor-history.js +5 -0
  183. package/src/lib/execution-location-failure-site.js +20 -3
  184. package/src/lib/goal-store.js +8 -1
  185. package/src/lib/image-input.js +43 -14
  186. package/src/lib/llm-providers.js +1 -0
  187. package/src/lib/plugin-runtime/capabilities.js +10 -0
  188. package/src/lib/plugin-runtime/cli-goal-draft-request.js +138 -0
  189. package/src/lib/plugin-runtime/cli-goal-drafts.js +413 -0
  190. package/src/lib/plugin-runtime/cli-goal-extension-host.js +234 -0
  191. package/src/lib/plugin-runtime/examples/goal-description-drafter/plugin.json +17 -0
  192. package/src/lib/plugin-runtime/examples/goal-evidence-viewer/plugin.json +25 -0
  193. package/src/lib/plugin-runtime/examples/goal-progress-viewer/plugin.json +21 -0
  194. package/src/lib/plugin-runtime/examples/project-delivery-assistant/plugin.json +38 -0
  195. package/src/lib/plugin-runtime/goal-extension-contract.js +190 -0
  196. package/src/lib/plugin-runtime/goal-extensions.js +277 -0
  197. package/src/lib/plugin-runtime/install.js +40 -40
  198. package/src/lib/plugin-runtime/manifest.js +12 -0
  199. package/src/lib/plugin-runtime/policy.js +1 -0
  200. package/src/lib/project-goal-connection.js +225 -0
  201. package/src/lib/project-goal-draft-connection.js +217 -0
  202. package/src/lib/read-file-loop-guard.js +124 -8
  203. package/src/lib/session-host-snapshot.js +3 -0
  204. package/src/lib/session-message-provenance.js +24 -5
  205. package/src/lib/session-tool-round.js +39 -0
  206. package/src/lib/session-transcript-history.js +2 -0
  207. package/src/lib/session-transcript-page.js +4 -1
  208. package/src/lib/session-transcript-structure.js +4 -0
  209. package/src/lib/task-model-selector.js +1 -1
  210. package/src/repl/agent-repl.js +14 -7
  211. package/src/repl/config-summary.js +1 -1
  212. package/src/runtime/__tests__/message-roles.test.js +29 -0
  213. package/src/runtime/agent-core.js +116 -44
  214. package/src/runtime/headless-runner.js +191 -34
  215. package/src/runtime/headless-stream.js +144 -48
  216. package/src/runtime/message-roles.js +43 -0
  217. package/src/runtime/policies/agent-policy.js +1 -0
  218. package/src/workers/background-agent-worker.js +146 -47
  219. package/src/assets/web-panel/assets/EmailListRenderer-DXlmbC45.js +0 -1
  220. package/src/assets/web-panel/assets/MobileProjects-CwA1VoVJ.js +0 -1
  221. package/src/assets/web-panel/assets/Skills-Tz4rQcDp.js +0 -1
  222. package/src/assets/web-panel/assets/Tasks-B6MowBDo.js +0 -1
  223. package/src/assets/web-panel/assets/devWarning-D_MJgDGJ.js +0 -1
  224. package/src/assets/web-panel/assets/index-BP8log78.js +0 -1
  225. package/src/assets/web-panel/assets/index-PexF9zYf.js +0 -1
@@ -407,9 +407,9 @@ export class PromptCompressor {
407
407
  if (
408
408
  this.llmQuery &&
409
409
  (currentTokens > this.maxTokens || result.length > this.maxMessages) &&
410
- result.length > 4
410
+ messages.length > 4
411
411
  ) {
412
- const summarized = await this._summarize(result);
412
+ const summarized = await this._summarize(result, messages);
413
413
  result = summarized.messages;
414
414
  summaryStats = summarized.stats;
415
415
  if (summaryStats.summaryMode !== "none") {
@@ -565,7 +565,7 @@ export class PromptCompressor {
565
565
  return result;
566
566
  }
567
567
 
568
- async _summarize(messages) {
568
+ async _summarize(messages, sourceMessages = messages) {
569
569
  // Compaction summaries and collapsed tool groups are derived history, not
570
570
  // immutable host instructions. Fold them into the next summary so a long
571
571
  // session cannot retain one additional durable system message per cycle.
@@ -573,11 +573,11 @@ export class PromptCompressor {
573
573
  (m) => m.role === "system" && !isCompactionArtifact(m),
574
574
  );
575
575
  const last = [...messages].reverse().find((m) => m.role === "user");
576
- const toSummarize = messages.filter(
577
- (m) => (m.role !== "system" || isCompactionArtifact(m)) && m !== last,
578
- );
579
-
580
- if (toSummarize.length < 3) {
576
+ if (
577
+ sourceMessages.filter(
578
+ (m) => m.role !== "system" || isCompactionArtifact(m),
579
+ ).length < 3
580
+ ) {
581
581
  return {
582
582
  messages,
583
583
  stats: {
@@ -590,7 +590,15 @@ export class PromptCompressor {
590
590
  };
591
591
  }
592
592
 
593
- const prompt = summaryPrompt(toSummarize, this.summaryInputMaxChars);
593
+ // The pinned request remains in the output, but the summarizer also needs
594
+ // it to retain the objective/constraints when there is only one user turn.
595
+ // Pair tool observations against the original history: deduplication and
596
+ // collapse may already have removed empty assistant tool-call messages.
597
+ // The same bounded summary input budget applies to this source history.
598
+ const summarySources = sourceMessages.filter(
599
+ (m) => m.role !== "system" || isCompactionArtifact(m),
600
+ );
601
+ const prompt = summaryPrompt(summarySources, this.summaryInputMaxChars);
594
602
  let summary;
595
603
  let summaryMode = "llm-structured";
596
604
  let degraded = false;
@@ -713,7 +721,7 @@ export class PromptCompressor {
713
721
  }
714
722
  }
715
723
  if (degraded) {
716
- summary = buildExtractiveHandoff(toSummarize, {
724
+ summary = buildExtractiveHandoff(summarySources, {
717
725
  maxFallbackSourceChars: Math.min(
718
726
  this.summaryInputMaxChars,
719
727
  SUMMARY_INPUT_DEFAULT_MAX_CHARS,
@@ -3,6 +3,7 @@
3
3
  * parent-to-child agent context. The field order is part of the wire format.
4
4
  */
5
5
 
6
+ import { createHash } from "node:crypto";
6
7
  import { projectCanonicalResumeMessages } from "../lib/session-message-provenance.js";
7
8
 
8
9
  export const STRUCTURED_HANDOFF_FIELDS = Object.freeze([
@@ -154,12 +155,33 @@ function selectBoundedSources(messages, maxChars) {
154
155
  // being quoted into a new handoff. Only the runtime WeakMap capability is
155
156
  // admitted; ordinary user/assistant/tool conversation remains eligible.
156
157
  const canonicalSources = projectCanonicalResumeMessages(messages);
158
+ const calls = new Map();
157
159
  const entries = canonicalSources
158
- .map((message, index) => ({
159
- index,
160
- role: typeof message?.role === "string" ? message.role : "unknown",
161
- text: normalizeText(contentText(message)),
162
- }))
160
+ .map((message, index) => {
161
+ for (const call of Array.isArray(message.tool_calls)
162
+ ? message.tool_calls
163
+ : []) {
164
+ if (message.role === "assistant" && call?.id && call.function)
165
+ calls.set(call.id, call.function);
166
+ }
167
+ const facts =
168
+ message.role === "tool"
169
+ ? toolFacts(message, calls.get(message.tool_call_id))
170
+ : message.role === "assistant" || message.role === "system"
171
+ ? summaryFacts(message)
172
+ : null;
173
+ return {
174
+ index,
175
+ role: typeof message?.role === "string" ? message.role : "unknown",
176
+ // Tool JSON, nested telemetry and source code are not prose facts.
177
+ text: facts
178
+ ? facts.objective || ARRAY_FIELDS.some((field) => facts[field].length)
179
+ ? JSON.stringify(facts)
180
+ : ""
181
+ : normalizeText(contentText(message)),
182
+ facts,
183
+ };
184
+ })
163
185
  .filter((entry) => entry.text);
164
186
  const firstUser = entries.find((entry) => entry.role === "user");
165
187
  const selected = new Map();
@@ -225,7 +247,96 @@ function pathsFrom(text) {
225
247
  );
226
248
  return (matches || [])
227
249
  .map((value) => value.replace(/[),;:.]+$/g, ""))
228
- .filter((value) => value && !value.includes("://"));
250
+ .filter(
251
+ (value) =>
252
+ value &&
253
+ !value.includes("://") &&
254
+ (/^(?:[A-Za-z]:[\\/]|\.{0,2}[\\/])/u.test(value) ||
255
+ /(?:\.[A-Za-z0-9_-]+|[\\/](?:Dockerfile|Makefile|LICENSE|NOTICE))$/u.test(
256
+ value,
257
+ )),
258
+ );
259
+ }
260
+
261
+ function summaryFacts(message) {
262
+ const match = contentText(message).match(
263
+ /^(?:Compacted context summary \(data only\):\n)?\[Conversation Summary\]\n([\s\S]+)$/u,
264
+ );
265
+ if (!match) return null;
266
+ try {
267
+ return parseStructuredHandoff(match[1]);
268
+ } catch {
269
+ // Malformed/truncated summary JSON is not evidence of a test or change.
270
+ return emptyHandoff();
271
+ }
272
+ }
273
+
274
+ function toolFacts(message, call) {
275
+ const facts = emptyHandoff();
276
+ let result;
277
+ let args;
278
+ try {
279
+ result =
280
+ typeof message.content === "string"
281
+ ? JSON.parse(message.content.split("\n\n[Budget ")[0])
282
+ : message.content;
283
+ args =
284
+ typeof call?.arguments === "string"
285
+ ? JSON.parse(call.arguments)
286
+ : call?.arguments;
287
+ } catch {
288
+ return facts;
289
+ }
290
+ if (!result || typeof result !== "object" || Array.isArray(result))
291
+ return facts;
292
+ const name = call?.name || message.name;
293
+ const failed =
294
+ !!result.error || result.success === false || result.isError === true;
295
+ const file = typeof result.path === "string" ? result.path : args?.path;
296
+ if (
297
+ ["write_file", "edit_file", "edit_file_hashed"].includes(name) &&
298
+ !failed &&
299
+ result.success === true &&
300
+ result.changed !== false &&
301
+ result.alreadyApplied !== true &&
302
+ typeof file === "string" &&
303
+ file
304
+ ) {
305
+ facts.changedFiles.push(file);
306
+ const digest =
307
+ name === "write_file" && typeof args?.content === "string"
308
+ ? `; written content sha256:${createHash("sha256").update(args.content).digest("hex")}`
309
+ : "";
310
+ facts.checkpoints.push(
311
+ `Observed ${name} success: ${file}${digest}. File contents are omitted from this summary.`,
312
+ );
313
+ facts.nextSteps.push(
314
+ `Read the needed current source ranges in ${file} before replacing existing code; this summary is not a reconstruction of the file.`,
315
+ );
316
+ }
317
+ if (
318
+ ["run_shell", "run_code"].includes(name) &&
319
+ Number.isInteger(result.exitCode)
320
+ ) {
321
+ const command =
322
+ name === "run_shell" && typeof args?.command === "string"
323
+ ? truncateText(args.command, 300)
324
+ : name;
325
+ facts.checkpoints.push(
326
+ `Observed ${name}: ${command}; exitCode=${result.exitCode}.`,
327
+ );
328
+ if (
329
+ name === "run_shell" &&
330
+ /\b(?:vitest|jest|pytest|playwright|npm\s+(?:run\s+)?test|node\s+--test)\b/u.test(
331
+ command,
332
+ )
333
+ ) {
334
+ facts.tests.push(
335
+ `Observed command ${command}; exitCode=${result.exitCode}.`,
336
+ );
337
+ }
338
+ }
339
+ return facts;
229
340
  }
230
341
 
231
342
  function emptyHandoff(objective = "") {
@@ -313,12 +424,40 @@ export function buildExtractiveHandoff(messages, options = {}) {
313
424
  const sources = selectBoundedSources(messages, maxFallbackSourceChars);
314
425
  const firstUser = sources.find((entry) => entry.role === "user");
315
426
  const candidates = emptyHandoff(
316
- truncateText(firstUser?.text || "", maxItemChars),
427
+ truncateText(
428
+ firstUser?.text ||
429
+ sources.find((entry) => entry.facts?.objective)?.facts.objective ||
430
+ "",
431
+ maxItemChars,
432
+ ),
317
433
  );
318
434
 
319
435
  for (const source of sources) {
320
- for (const fragment of fragments(source.text)) {
321
- candidates.changedFiles.push(...pathsFrom(fragment));
436
+ if (source.facts) {
437
+ // Extract typed observations before budgeting, never regex-match a
438
+ // serialized tool payload (which may contain arbitrary source text).
439
+ for (const field of ARRAY_FIELDS)
440
+ candidates[field].push(...source.facts[field]);
441
+ continue;
442
+ }
443
+ // Quoted implementation examples are source data, not executed outcomes.
444
+ const prose = source.text.replace(
445
+ /```[\s\S]*?(?:```|$)|~~~[\s\S]*?(?:~~~|$)/gu,
446
+ "",
447
+ );
448
+ for (const fragment of fragments(prose)) {
449
+ const statusNarrative =
450
+ source.role !== "user" &&
451
+ !/^(?:must|must not|do not|don't|only|next|todo|remaining|then|we will|will|need to)\b/iu.test(
452
+ fragment,
453
+ );
454
+ if (
455
+ statusNarrative &&
456
+ /^(?:changed|modified|updated|created|deleted|wrote|edited)\b/iu.test(
457
+ fragment,
458
+ )
459
+ )
460
+ candidates.changedFiles.push(...pathsFrom(fragment));
322
461
  if (
323
462
  /^(?:constraint|constraints|requirement|requirements|must|must not|do not|don't|only|约束|必须|不要|只能|仅限)\b/iu.test(
324
463
  fragment,
@@ -326,10 +465,7 @@ export function buildExtractiveHandoff(messages, options = {}) {
326
465
  /\bwithout\s+(?:widening|changing|removing|losing)\b/iu.test(fragment)
327
466
  ) {
328
467
  candidates.constraints.push(
329
- stripLabel(
330
- fragment,
331
- "constraint(?:s)?|requirement(?:s)?|must(?: not)?|do not|don't|only|约束|必须|不要|只能|仅限",
332
- ),
468
+ stripLabel(fragment, "constraint(?:s)?|requirement(?:s)?|约束"),
333
469
  );
334
470
  }
335
471
  if (
@@ -345,6 +481,7 @@ export function buildExtractiveHandoff(messages, options = {}) {
345
481
  );
346
482
  }
347
483
  if (
484
+ statusNarrative &&
348
485
  /\b(?:test|tests|vitest|jest|pytest|playwright|lint|typecheck|build)\b/iu.test(
349
486
  fragment,
350
487
  ) &&
@@ -367,6 +504,7 @@ export function buildExtractiveHandoff(messages, options = {}) {
367
504
  );
368
505
  }
369
506
  if (
507
+ statusNarrative &&
370
508
  /\b(?:checkpoint|commit\s+[0-9a-f]{7,40}|implemented|completed|done|verified|checkpoint|检查点|已完成|已实现)\b/iu.test(
371
509
  fragment,
372
510
  )
@@ -1,3 +1,4 @@
1
+ import { projectToolRoundMessages } from "./session-tool-round.js";
1
2
  /**
2
3
  * Agent-session Markdown export — Claude-Code `/export` parity for the JSONL
3
4
  * headless/agent session store (`~/.../sessions/<id>.jsonl`, the `--resume`
@@ -63,6 +64,25 @@ export function renderAgentSessionMarkdown(sessionId, events, opts = {}) {
63
64
  for (const ev of events) {
64
65
  if (!ev || typeof ev !== "object") continue;
65
66
  switch (ev.type) {
67
+ case "tool_round":
68
+ for (const message of projectToolRoundMessages(ev)) {
69
+ L.push(
70
+ message.role === "assistant"
71
+ ? "## Assistant tool calls"
72
+ : `### Tool result ${message.tool_call_id}`,
73
+ );
74
+ L.push(
75
+ "",
76
+ fence(
77
+ message.role === "assistant"
78
+ ? message.tool_calls
79
+ : message.content,
80
+ "json",
81
+ ),
82
+ "",
83
+ );
84
+ }
85
+ break;
66
86
  case "user_message":
67
87
  users += 1;
68
88
  L.push("## 👤 User");
@@ -1394,6 +1394,60 @@ export function mutateBackgroundAgentState(id, updater, options = {}) {
1394
1394
  );
1395
1395
  }
1396
1396
 
1397
+ export async function mutateBackgroundAgentStateWithLockRetry(
1398
+ id,
1399
+ updater,
1400
+ options = {},
1401
+ ) {
1402
+ const now = options.now || Date.now;
1403
+ const sleep =
1404
+ options.sleep ||
1405
+ ((milliseconds) =>
1406
+ new Promise((resolvePromise) =>
1407
+ setTimeout(resolvePromise, milliseconds),
1408
+ ));
1409
+ const mutate = options.mutate || mutateBackgroundAgentState;
1410
+ const numericOption = (value, fallback, minimum) => {
1411
+ const number = Number(value);
1412
+ return Number.isFinite(number) ? Math.max(minimum, number) : fallback;
1413
+ };
1414
+ const timeoutMs = numericOption(options.timeoutMs ?? 30_000, 30_000, 0);
1415
+ const lockTimeoutMs = numericOption(
1416
+ options.lockTimeoutMs ?? 10_000,
1417
+ 10_000,
1418
+ 0,
1419
+ );
1420
+ const initialRetryMs = numericOption(options.initialRetryMs ?? 100, 100, 1);
1421
+ const maxRetryMs = Math.max(
1422
+ initialRetryMs,
1423
+ numericOption(options.maxRetryMs ?? 1_000, 1_000, 1),
1424
+ );
1425
+ const deadline = now() + timeoutMs;
1426
+ let attempts = 0;
1427
+
1428
+ for (;;) {
1429
+ attempts += 1;
1430
+ try {
1431
+ return mutate(id, updater, {
1432
+ timeoutMs: Math.min(lockTimeoutMs, Math.max(0, deadline - now())),
1433
+ });
1434
+ } catch (error) {
1435
+ if (error?.code !== "STATE_LOCK_UNAVAILABLE") throw error;
1436
+ const remainingMs = deadline - now();
1437
+ if (remainingMs <= 0) {
1438
+ error.attempts = attempts;
1439
+ throw error;
1440
+ }
1441
+ const retryMs = Math.min(
1442
+ maxRetryMs,
1443
+ initialRetryMs * 2 ** Math.min(attempts - 1, 4),
1444
+ remainingMs,
1445
+ );
1446
+ await sleep(retryMs);
1447
+ }
1448
+ }
1449
+ }
1450
+
1397
1451
  export function writeBackgroundAgentState(state, options = {}) {
1398
1452
  return mutateBackgroundAgentState(state.id, () => state, {
1399
1453
  createIfMissing: options.createIfMissing === true,
@@ -0,0 +1,129 @@
1
+ /** Bounded, explicit metadata discovery for native IDE goal pickers. */
2
+ import fs from "node:fs";
3
+ import path from "node:path";
4
+ import { resolveConfigDataRoot } from "./paths.js";
5
+ import { goalFileStoreId } from "./goal-store.js";
6
+ import { createCliGoalSnapshotReader } from "./cli-goal-source.js";
7
+
8
+ export const CLI_GOAL_CATALOG_SCHEMA = "chainlesschain.goal-catalog.v1";
9
+ const MAX_DIRECTORY_ENTRIES = 2048;
10
+ const safeId = (id) =>
11
+ typeof id === "string" &&
12
+ /^[A-Za-z0-9][A-Za-z0-9._-]{0,255}$/u.test(id) &&
13
+ !id.includes("..");
14
+ function fail(code) {
15
+ throw new Error(code);
16
+ }
17
+ function cursor(storeId, afterId) {
18
+ return Buffer.from(JSON.stringify({ v: 1, storeId, afterId })).toString(
19
+ "base64url",
20
+ );
21
+ }
22
+ function decodeCursor(value, storeId) {
23
+ if (value === undefined) return "";
24
+ try {
25
+ if (
26
+ typeof value !== "string" ||
27
+ value.length > 1024 ||
28
+ !/^[A-Za-z0-9_-]+$/u.test(value)
29
+ )
30
+ throw 0;
31
+ const raw = JSON.parse(Buffer.from(value, "base64url").toString("utf8"));
32
+ if (
33
+ Object.keys(raw).sort().join(",") !== "afterId,storeId,v" ||
34
+ raw.v !== 1 ||
35
+ raw.storeId !== storeId ||
36
+ !safeId(raw.afterId) ||
37
+ cursor(storeId, raw.afterId) !== value
38
+ )
39
+ throw 0;
40
+ return raw.afterId;
41
+ } catch {
42
+ fail("CLI_GOAL_CATALOG_INVALID_CURSOR");
43
+ }
44
+ }
45
+
46
+ /** Each page visits at most limit candidates, including invalid sources.
47
+ * Pages are fresh reads; this does not promise a frozen cross-page snapshot. */
48
+ export function readCliGoalCatalog(options = {}) {
49
+ const cwd = path.resolve(options.cwd || process.cwd());
50
+ const env = Object.freeze({ ...(options.env || process.env) });
51
+ const root = path.resolve(
52
+ options.root ||
53
+ path.join(resolveConfigDataRoot({ cwd, env }).path, "goals"),
54
+ );
55
+ const storeId = goalFileStoreId(root);
56
+ const limit = options.limit ?? 20;
57
+ if (!Number.isSafeInteger(limit) || limit < 1 || limit > 20)
58
+ fail("CLI_GOAL_CATALOG_INVALID_LIMIT");
59
+ const afterId = decodeCursor(options.after, storeId);
60
+ const result = {
61
+ schema: CLI_GOAL_CATALOG_SCHEMA,
62
+ storeId,
63
+ snapshot: true,
64
+ observedAt: new Date().toISOString(),
65
+ entries: [],
66
+ scannedCount: 0,
67
+ skippedCount: 0,
68
+ invalidNameCount: 0,
69
+ nextCursor: null,
70
+ };
71
+ try {
72
+ fs.lstatSync(root);
73
+ } catch (error) {
74
+ if (error.code === "ENOENT") return result;
75
+ throw error;
76
+ }
77
+ const source = createCliGoalSnapshotReader(root);
78
+ const directory = fs.opendirSync(root);
79
+ const ids = [];
80
+ try {
81
+ let count = 0;
82
+ for (let entry; (entry = directory.readSync()); ) {
83
+ if (++count > MAX_DIRECTORY_ENTRIES)
84
+ fail("CLI_GOAL_CATALOG_DIRECTORY_LIMIT");
85
+ if (!entry.name.endsWith(".json")) continue;
86
+ const id = entry.name.slice(0, -5);
87
+ if (!safeId(id)) {
88
+ result.invalidNameCount++;
89
+ continue;
90
+ }
91
+ if (safeId(id) && id > afterId) ids.push(id);
92
+ }
93
+ } finally {
94
+ directory.closeSync();
95
+ }
96
+ source.checkRoot();
97
+ ids.sort();
98
+ const snapshots = [];
99
+ const page = ids.slice(0, limit);
100
+ result.scannedCount = page.length;
101
+ for (const id of page) {
102
+ try {
103
+ const snapshot = source.read(id);
104
+ const goal = snapshot.goal;
105
+ const title = (goal.title || goal.objective)
106
+ .replace(
107
+ /[\u0000-\u001f\u007f-\u009f\u200e\u200f\u202a-\u202e\u2066-\u2069]/gu,
108
+ " ",
109
+ )
110
+ .slice(0, 160);
111
+ result.entries.push({
112
+ id: goal.id,
113
+ title,
114
+ status: goal.status,
115
+ revision: goal.revision,
116
+ controlGeneration: goal.controlGeneration,
117
+ });
118
+ snapshots.push(snapshot);
119
+ } catch {
120
+ result.skippedCount++;
121
+ }
122
+ }
123
+ // A changed valid source aborts the page instead of returning stale metadata.
124
+ for (const snapshot of snapshots) source.revalidate(snapshot);
125
+ source.checkRoot();
126
+ if (ids.length > page.length)
127
+ result.nextCursor = cursor(storeId, page.at(-1));
128
+ return result;
129
+ }
@@ -0,0 +1,119 @@
1
+ /** Bounded standalone file reads shared by explicit CLI snapshots. */
2
+ import fs from "node:fs";
3
+ import { createHash } from "node:crypto";
4
+ import { createGoalFileAdapter } from "./goal-store.js";
5
+
6
+ function fail(code) {
7
+ throw new Error(code);
8
+ }
9
+ function sameFile(a, b) {
10
+ return (
11
+ a.dev === b.dev &&
12
+ a.ino === b.ino &&
13
+ a.size === b.size &&
14
+ a.mtimeMs === b.mtimeMs &&
15
+ a.ctimeMs === b.ctimeMs
16
+ );
17
+ }
18
+
19
+ /** Pin the configured store, including directory identity, for this snapshot. */
20
+ function sourceReader(root, onRead) {
21
+ const realRoot = fs.realpathSync(root);
22
+ const initialRoot = fs.statSync(root);
23
+ function checkRoot() {
24
+ const stat = fs.statSync(root);
25
+ if (
26
+ !stat.isDirectory() ||
27
+ fs.realpathSync(root) !== realRoot ||
28
+ stat.dev !== initialRoot.dev ||
29
+ stat.ino !== initialRoot.ino
30
+ )
31
+ fail("CLI_GOAL_STORE_CHANGED");
32
+ }
33
+ const readJson = (file) => {
34
+ checkRoot();
35
+ const entry = fs.lstatSync(file);
36
+ if (!entry.isFile() || entry.isSymbolicLink())
37
+ fail("CLI_GOAL_REGULAR_FILE_REQUIRED");
38
+ let fd;
39
+ try {
40
+ fd = fs.openSync(
41
+ file,
42
+ fs.constants.O_RDONLY |
43
+ (fs.constants.O_NOFOLLOW || 0) |
44
+ (fs.constants.O_NONBLOCK || 0),
45
+ );
46
+ const before = fs.fstatSync(fd);
47
+ if (!before.isFile() || !sameFile(entry, before))
48
+ fail("CLI_GOAL_SOURCE_CHANGED");
49
+ if (before.size > 64 * 1024) fail("CLI_GOAL_SOURCE_TOO_LARGE");
50
+ const buffer = Buffer.alloc(before.size + 1);
51
+ let count = 0;
52
+ while (count < buffer.length) {
53
+ const size = fs.readSync(
54
+ fd,
55
+ buffer,
56
+ count,
57
+ buffer.length - count,
58
+ count,
59
+ );
60
+ if (!size) break;
61
+ count += size;
62
+ }
63
+ checkRoot();
64
+ const after = fs.lstatSync(file);
65
+ if (
66
+ count !== before.size ||
67
+ !sameFile(before, fs.fstatSync(fd)) ||
68
+ !after.isFile() ||
69
+ after.isSymbolicLink() ||
70
+ !sameFile(before, after)
71
+ )
72
+ fail("CLI_GOAL_SOURCE_CHANGED");
73
+ const bytes = buffer.subarray(0, count);
74
+ const value = JSON.parse(
75
+ new TextDecoder("utf-8", { fatal: true }).decode(bytes),
76
+ );
77
+ onRead(createHash("sha256").update(bytes).digest("hex"));
78
+ return value;
79
+ } finally {
80
+ if (fd !== undefined) fs.closeSync(fd);
81
+ }
82
+ };
83
+ return { readJson, checkRoot };
84
+ }
85
+
86
+ export function createCliGoalSnapshotReader(root) {
87
+ let rawDigest;
88
+ const source = sourceReader(root, (value) => {
89
+ rawDigest = value;
90
+ });
91
+ const adapter = createGoalFileAdapter({ root, readJson: source.readJson });
92
+ function read(id) {
93
+ const goal = adapter.get(id);
94
+ if (!goal) fail("CLI_GOAL_NOT_FOUND");
95
+ return { goal, digest: rawDigest };
96
+ }
97
+ function revalidate(snapshot) {
98
+ let current;
99
+ try {
100
+ current = read(snapshot.goal.id);
101
+ } catch {
102
+ fail("CLI_GOAL_SOURCE_CHANGED");
103
+ }
104
+ if (
105
+ current.digest !== snapshot.digest ||
106
+ current.goal.storeId !== snapshot.goal.storeId ||
107
+ current.goal.revision !== snapshot.goal.revision ||
108
+ current.goal.controlGeneration !== snapshot.goal.controlGeneration
109
+ )
110
+ fail("CLI_GOAL_SOURCE_CHANGED");
111
+ return current.goal;
112
+ }
113
+ return {
114
+ storeId: adapter.storeId,
115
+ read,
116
+ revalidate,
117
+ checkRoot: source.checkRoot,
118
+ };
119
+ }
@@ -5,8 +5,9 @@ export const CODING_TASK_QUALITY_GUIDANCE = `Coding task quality:
5
5
  - Resolve each relative import from the destination file's directory. Read back the completed file and fix newDiagnostics from write/edit results before finishing. A successful write confirms persistence, not syntax, test execution or acceptance.
6
6
  - Regression tests need a working positive control and a negative control that exercises the requested behavior through the real production entry point. Assert observable effects; avoid mocks or alternate calls that bypass the behavior under test. Complete the current worker/request when testing cancellation and replacement.
7
7
  - For boundary regressions, derive expected defaults, computed values and rejection rules from the implementation or the explicit requested contract. Inject mismatched, tampered or stale input through the real entry point while keeping other prerequisites valid; verify that the fixture reaches the intended check rather than failing during setup. Compare observable results with independent expected values or authoritative state, not a helper that merely recomputes the same result.
8
+ - Trace rejection before asserting its aftermath: a request can be rejected before registration or persistence. Check whether state stays unchanged, a failed record is saved, or an event is emitted; do not assume every rejection creates a failed task. When testing attribution, verify independently recorded identities and provenance as well as message contents; identical text can still be attributed to the wrong source.
8
9
  - Use available execution tools for a focused check when permitted. When execution tools are unavailable, inspect imports, API contracts and fixtures using the available file tools, and clearly say that tests were not run. Never describe a read-back or static check as a passing test or end-to-end verification.
9
- - Finish requested file changes before the final response. Reserve output and remaining requests for writing, read-back and focused validation. For large files, aim for a few thousand characters of new content per call: write a small complete section, then extend it with edit_file using a unique existing anchor and a replacement containing that anchor plus the next complete section. Keep each tool call complete and wait for its result before extending the file again; do not repeatedly rewrite the growing file. State what was delivered, what was checked and what remains unverified.`;
10
+ - Finish requested file changes before the final response. Reserve output and remaining requests for writing, read-back and focused validation. For large files, aim for a few thousand characters of new content per call: write a small complete section, then extend it with edit_file using a unique existing anchor and a replacement containing that anchor plus the next complete section. A list of available tool names is not a limit on the number of tool calls; use further calls within the actual request budget to finish and inspect the file. Keep each tool call complete and wait for its result before extending the file again; do not repeatedly rewrite the growing file. State what was delivered, what was checked and what remains unverified, without repeating that account in multiple drafts.`;
10
11
 
11
12
  export const HERMETIC_CODING_SYSTEM_PROMPT = `You are a hermetic coding assistant. The exposed file tools are the complete tool surface. Inspect and mutate only the exact paths authorized by the user request. Do not invoke hidden tools, commands, language servers or other execution paths.
12
13
 
@@ -83,7 +83,7 @@ const DESCRIPTORS = [
83
83
  "Requested live service tier; model and endpoint support are checked before dispatch",
84
84
  }),
85
85
  descriptor("llm.visionModel", ["string", "null"], {
86
- description: "Model used for image turns",
86
+ description: "Fallback for image turns when the main model lacks vision",
87
87
  }),
88
88
  descriptor("llm.fallbackModel", ["string", "null"], {
89
89
  deprecated: true,