@iowarp/clio-coder 0.3.8 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (552) hide show
  1. package/CHANGELOG.md +102 -0
  2. package/NOTICE +33 -0
  3. package/README.md +12 -3
  4. package/dist/{acp-U67UHUK2.js → acp-G5WJBNCT.js} +13 -12
  5. package/dist/{agents-YU6SGALZ.js → agents-FMV2Q5G4.js} +41 -36
  6. package/dist/assets/codewiki.json +1 -1
  7. package/dist/{auth-5ZPJOIVG.js → auth-3IDSJEIK.js} +18 -18
  8. package/dist/{builtins-C6JMZVV6.js → builtins-XCZWXSC7.js} +5 -5
  9. package/dist/{chunk-IFBNV6H6.js → chunk-2ANTL7MR.js} +3 -3
  10. package/dist/{chunk-5FR74PWO.js → chunk-2JDWVJND.js} +2 -2
  11. package/dist/{chunk-XWSF374K.js → chunk-2OQE55CK.js} +3 -3
  12. package/dist/{chunk-5H3GB5BO.js → chunk-32KWKNSF.js} +8 -384
  13. package/dist/{chunk-KTYTFRMB.js → chunk-36EJLSQQ.js} +34 -36
  14. package/dist/{chunk-FHJEP5SW.js → chunk-3BT2XMV4.js} +19 -13
  15. package/dist/chunk-3DPEIQKN.js +113 -0
  16. package/dist/{chunk-GU2UIAFZ.js → chunk-3URVFKWK.js} +7 -7
  17. package/dist/{chunk-WEH5XRJQ.js → chunk-3XML7CDN.js} +3 -3
  18. package/dist/chunk-42FMPA75.js +101 -0
  19. package/dist/{chunk-A2NJGIB3.js → chunk-5LXZXPKX.js} +2 -2
  20. package/dist/{chunk-VCBR6CU7.js → chunk-5PSMVOLM.js} +2 -2
  21. package/dist/{chunk-NMPKI6XL.js → chunk-6DB53AJS.js} +203 -25
  22. package/dist/{chunk-3BINW3FP.js → chunk-76ONBSIA.js} +2 -2
  23. package/dist/{chunk-26LEYJZH.js → chunk-7MCTRUCE.js} +2 -2
  24. package/dist/{chunk-TYPGUK6W.js → chunk-AB44T6BB.js} +111 -5
  25. package/dist/{chunk-K4XHGFR5.js → chunk-B7OBL7PK.js} +317 -721
  26. package/dist/{chunk-B5CSFE7B.js → chunk-BBVJUZHB.js} +2 -2
  27. package/dist/{chunk-EQ63NRB7.js → chunk-BBVYXMFO.js} +2 -2
  28. package/dist/{chunk-ZVJ5BLO2.js → chunk-BKFJHQCA.js} +154 -16
  29. package/dist/chunk-BKFM6EJV.js +462 -0
  30. package/dist/chunk-BMS5RKQY.js +27 -0
  31. package/dist/{chunk-ZNLWCMVZ.js → chunk-BPKCPIL7.js} +2 -2
  32. package/dist/{chunk-TLQJPP24.js → chunk-BUMFYQFY.js} +1394 -1349
  33. package/dist/{chunk-BNAZZHFG.js → chunk-BYP5D4HI.js} +1 -1
  34. package/dist/chunk-C2LTL2W6.js +2447 -0
  35. package/dist/{chunk-ME6CCNFO.js → chunk-CODPRO7Q.js} +8 -8
  36. package/dist/{chunk-E77JEWSD.js → chunk-CTJ4RNAA.js} +7 -37
  37. package/dist/{chunk-ODFEOB4F.js → chunk-CY6FY24N.js} +26 -8
  38. package/dist/{chunk-7RFXX52T.js → chunk-DQITNCXG.js} +642 -172
  39. package/dist/{chunk-TTHACPOM.js → chunk-DYJP44XW.js} +578 -117
  40. package/dist/{chunk-2HFZQUHL.js → chunk-F4CKPOEQ.js} +18 -8
  41. package/dist/{chunk-DGSYXYMX.js → chunk-FEFIFZTL.js} +3 -3
  42. package/dist/{chunk-GWS3VEIW.js → chunk-FWDFM5ZU.js} +24 -3
  43. package/dist/{chunk-MV3K5QF2.js → chunk-GCSMB2KY.js} +2 -2
  44. package/dist/chunk-GKF55TAZ.js +391 -0
  45. package/dist/{chunk-VWZOAB7K.js → chunk-GR5G2PVF.js} +9 -8
  46. package/dist/{chunk-4DGYLA73.js → chunk-GXNLGKAB.js} +80 -9
  47. package/dist/chunk-HHV2GANA.js +88 -0
  48. package/dist/{chunk-IIZWH4XA.js → chunk-HI63TFOG.js} +5 -4
  49. package/dist/{chunk-WLFILSD5.js → chunk-HJJTYUHX.js} +113 -83
  50. package/dist/{chunk-TT36MB5S.js → chunk-HLW2MRKE.js} +3 -1
  51. package/dist/{chunk-PMDBGQSJ.js → chunk-HWHKMHUA.js} +7 -7
  52. package/dist/chunk-HZHHCK24.js +1631 -0
  53. package/dist/{chunk-WSB3FPX7.js → chunk-I5VEOC6I.js} +39 -143
  54. package/dist/chunk-IBEBSCYA.js +564 -0
  55. package/dist/chunk-IQ7KR472.js +362 -0
  56. package/dist/{chunk-A3WNZD3P.js → chunk-J4W7KFM7.js} +949 -972
  57. package/dist/{chunk-TB5666IT.js → chunk-JDG2WCRO.js} +5 -5
  58. package/dist/{chunk-N22QMJKY.js → chunk-K5C3NCBD.js} +4 -4
  59. package/dist/{chunk-CGKSTWHD.js → chunk-K6BSR66V.js} +2 -1
  60. package/dist/{chunk-5C3AQNDW.js → chunk-KFZI4NIL.js} +216 -38
  61. package/dist/chunk-KMVISBZR.js +132 -0
  62. package/dist/{chunk-WXY7KU3G.js → chunk-LDQ2ZF2M.js} +2 -2
  63. package/dist/{chunk-XN3L4EYL.js → chunk-LQ3DZAMX.js} +3 -3
  64. package/dist/{chunk-U6MBIEMB.js → chunk-LY4S7GJC.js} +173 -144
  65. package/dist/{chunk-4SPRNWDE.js → chunk-MLKNTWH2.js} +19 -19
  66. package/dist/{chunk-MVVUPGPW.js → chunk-MXHC5QYU.js} +6 -6
  67. package/dist/chunk-NEKRRTYW.js +56 -0
  68. package/dist/{chunk-SPULKLCF.js → chunk-NHCZP4K7.js} +3 -3
  69. package/dist/chunk-NHLBIGRH.js +1506 -0
  70. package/dist/chunk-NQQH3YT7.js +302 -0
  71. package/dist/chunk-NYS75XW5.js +15 -0
  72. package/dist/{chunk-GN57SG4G.js → chunk-O4XIVISU.js} +10 -8
  73. package/dist/{chunk-EMYUUSFG.js → chunk-O6TL7WWY.js} +6 -6
  74. package/dist/chunk-OQBA45DZ.js +97 -0
  75. package/dist/{chunk-LU7P4LHA.js → chunk-P3FOHJT4.js} +2 -2
  76. package/dist/chunk-PMZCIOCJ.js +25 -0
  77. package/dist/{chunk-I4HZDVNP.js → chunk-PQEFIJ36.js} +2 -2
  78. package/dist/{chunk-J3YUBZWY.js → chunk-QBJA7R7N.js} +62 -6
  79. package/dist/chunk-QDC3K2U3.js +262 -0
  80. package/dist/{chunk-2HEJ2F35.js → chunk-QLFS5GO2.js} +22 -10
  81. package/dist/{chunk-7RGZWPB6.js → chunk-QLL7ILRG.js} +95 -32
  82. package/dist/{chunk-YS5VLNH5.js → chunk-QREDIESB.js} +6 -6
  83. package/dist/chunk-QSNYB6ZV.js +195 -0
  84. package/dist/{chunk-GOXNB3AO.js → chunk-RAPCMZL4.js} +75 -4
  85. package/dist/chunk-RKKLTLYB.js +45 -0
  86. package/dist/{chunk-P43ETTHK.js → chunk-SJ5ZKQ4S.js} +2 -2
  87. package/dist/{chunk-GPIEI3LY.js → chunk-SP2RXXYO.js} +6 -54
  88. package/dist/chunk-SUCTJL45.js +45 -0
  89. package/dist/{chunk-DYIM5TJT.js → chunk-SUW5DORT.js} +263 -7
  90. package/dist/chunk-T56WDKA5.js +183 -0
  91. package/dist/chunk-TVHHYFHE.js +255 -0
  92. package/dist/{chunk-FJ3H4MN5.js → chunk-TZ3SGWZZ.js} +3 -3
  93. package/dist/{chunk-MXKJU4JB.js → chunk-U77AMWDL.js} +91 -10
  94. package/dist/{chunk-5DHKRSMQ.js → chunk-ULC6OTWO.js} +11 -7
  95. package/dist/{chunk-RWSI4YD7.js → chunk-UM7N4G5A.js} +33 -12
  96. package/dist/{chunk-FCSXB6T2.js → chunk-UOSL25KY.js} +14 -2
  97. package/dist/{chunk-IGWKHNIQ.js → chunk-UXMFQ54G.js} +44 -37
  98. package/dist/{chunk-HFSBBKSQ.js → chunk-V5DHCITQ.js} +171 -3
  99. package/dist/{chunk-5WIGXA4T.js → chunk-VAZSBTKF.js} +111 -4
  100. package/dist/{chunk-VHN4MY6O.js → chunk-VEO4AP2K.js} +2 -2
  101. package/dist/{chunk-IJ7RPIYJ.js → chunk-VFA6GDY5.js} +65 -4
  102. package/dist/{chunk-PT7HYKEM.js → chunk-VO2LKSTM.js} +2 -2
  103. package/dist/chunk-VO67MWHC.js +75 -0
  104. package/dist/{chunk-XK56QHLX.js → chunk-VPKWYKEY.js} +19 -5
  105. package/dist/{chunk-TANS5ZJS.js → chunk-VYMXRQI6.js} +36 -22
  106. package/dist/{chunk-WWCZ5F23.js → chunk-W5VSYASO.js} +77 -16
  107. package/dist/{chunk-WNIJTQQK.js → chunk-WZR7K7ZX.js} +72 -116
  108. package/dist/{chunk-5Q2VVUKB.js → chunk-X3YGUTOB.js} +4 -4
  109. package/dist/chunk-X75E3D2N.js +686 -0
  110. package/dist/{chunk-VAWNZU7Z.js → chunk-YDFRH54B.js} +4 -4
  111. package/dist/chunk-YJX4SHTD.js +40 -0
  112. package/dist/{chunk-ZI647VB5.js → chunk-YPI3QQCF.js} +2 -2
  113. package/dist/chunk-Z2RR6MAK.js +127 -0
  114. package/dist/{chunk-FBVTI2TJ.js → chunk-Z4TXYIEG.js} +12 -131
  115. package/dist/cli/index.js +47 -36
  116. package/dist/{clio-QVTYJ57A.js → clio-2JXHBBY5.js} +7 -7
  117. package/dist/{code-nav-FGGFIE7L.js → code-nav-3YYRMYNF.js} +8 -8
  118. package/dist/{compile-cache-CVJMMODC.js → compile-cache-7FPE6PS3.js} +3 -3
  119. package/dist/{components-ZFA3SAER.js → components-RYZV4JGP.js} +5 -5
  120. package/dist/{config-LW5IJFQN.js → config-QZPCMYSO.js} +99 -63
  121. package/dist/{configure-7XIZCOU4.js → configure-TEGEBYCA.js} +23 -22
  122. package/dist/{context-Y6Y7QPR6.js → context-AV7OEZ4D.js} +12 -12
  123. package/dist/{context-L3WL3X7K.js → context-E6H5RNMC.js} +56 -47
  124. package/dist/{context-N52ZA626.js → context-GSXUE4CT.js} +29 -27
  125. package/dist/{context-clear-MBQRLSDQ.js → context-clear-SHIBYK6T.js} +55 -46
  126. package/dist/{context-index-HVMFQHK3.js → context-index-HNG3MOME.js} +2 -2
  127. package/dist/{context-working-set-GS6DSO7F.js → context-working-set-5ZGKPGZQ.js} +13 -13
  128. package/dist/{dispatch-runner-22ZCNOM3.js → dispatch-runner-EFMJT4LD.js} +93 -64
  129. package/dist/{docs-7LQ23DLM.js → docs-23KQS3XK.js} +5 -5
  130. package/dist/doctor-QOA5FNY5.js +313 -0
  131. package/dist/{eval-BEC2WHDA.js → eval-TFBYQH4H.js} +2032 -156
  132. package/dist/eval-inventory-SXH7PDKX.js +316 -0
  133. package/dist/{evidence-REJUMSKM.js → evidence-ERGESKGN.js} +203 -48
  134. package/dist/{evolve-PY5ZBA5K.js → evolve-VDXTSYCJ.js} +52 -43
  135. package/dist/{extensions-HVKU65YU.js → extensions-7BGBHN57.js} +13 -7
  136. package/dist/{fleet-7WZEWRFA.js → fleet-2RRVDF2V.js} +228 -108
  137. package/dist/{fleet-commands-UVHWM76J.js → fleet-commands-VJ726XIA.js} +11 -11
  138. package/dist/fleet-decisions-EPAPM3XJ.js +157 -0
  139. package/dist/{fleet-graph-6ULH7PES.js → fleet-graph-JF5QOATM.js} +18 -15
  140. package/dist/fleet-inspect-VLY4S7QM.js +442 -0
  141. package/dist/{fleet-preflight-J53T6CCE.js → fleet-preflight-AIZUEJOY.js} +5 -5
  142. package/dist/{fleet-validate-72PC4SLA.js → fleet-validate-AJRPDMDV.js} +22 -19
  143. package/dist/fleet-verify-JFEL2L3H.js +175 -0
  144. package/dist/fleet-view-ZCON35AG.js +102 -0
  145. package/dist/{init-OG3TPGQG.js → init-DN2WWLFE.js} +72 -62
  146. package/dist/install-XGLBQY5E.js +13 -0
  147. package/dist/interop-OZBKXAYL.js +114 -0
  148. package/dist/{library-CNTMPLRF.js → library-YWZG7IMW.js} +21 -18
  149. package/dist/{memory-6IS7F275.js → memory-I4C4HMLW.js} +54 -45
  150. package/dist/{models-ENRJDA5W.js → models-CEYXJBO6.js} +33 -30
  151. package/dist/{monitor-XLDVO7TN.js → monitor-NZ6GCI3P.js} +59 -52
  152. package/dist/{orchestrator-6KSPYRHA.js → orchestrator-GCGQ4N5I.js} +7827 -7328
  153. package/dist/panes-HMABYVO4.js +58 -0
  154. package/dist/panes-KY6W3V2E.js +103 -0
  155. package/dist/{paths-DBXMZMDU.js → paths-II4K7DNR.js} +5 -5
  156. package/dist/{reset-RZ4ER727.js → reset-DQ6FGCSH.js} +13 -11
  157. package/dist/resources-BB3MVJMD.js +111 -0
  158. package/dist/{run-Y2CNK5RU.js → run-H2GQDUER.js} +119 -87
  159. package/dist/{share-A55GYP6Z.js → share-GTJN6A5O.js} +20 -17
  160. package/dist/{skills-ALC5J6AT.js → skills-L55TEW6R.js} +33 -24
  161. package/dist/{skills-eval-JPBEBYQU.js → skills-eval-XVXPH2JI.js} +67 -56
  162. package/dist/skills-inventory-S4MXPJFV.js +126 -0
  163. package/dist/slash-commands-ZSGASKJC.js +77 -0
  164. package/dist/{steer-GGWFUJUD.js → steer-RZGSCY4R.js} +4 -4
  165. package/dist/{support-MIETYA5E.js → support-PKEUNNQL.js} +6 -6
  166. package/dist/{targets-VGNXIR3S.js → targets-NCPZ644J.js} +68 -40
  167. package/dist/{terminal-lease-WOBR64YA.js → terminal-lease-44SV3YCN.js} +6 -4
  168. package/dist/tools-DAF3DI3C.js +27 -0
  169. package/dist/{trace-PNCASAXC.js → trace-FYVW2MQA.js} +207 -10
  170. package/dist/tui-primitives-2AKXQNZK.js +13 -0
  171. package/dist/{uninstall-ZJF5H5ZN.js → uninstall-DW2PNOIC.js} +5 -5
  172. package/dist/{upgrade-FUSUAGHR.js → upgrade-3XPP6OQL.js} +27 -24
  173. package/dist/{usage-N4MKVHKD.js → usage-3NLHGTU2.js} +114 -62
  174. package/dist/{verifiers-YAWOJ3H2.js → verifiers-SSQONKRT.js} +172 -13
  175. package/dist/{verify-LTDHYBGY.js → verify-3U6J7FZI.js} +10 -10
  176. package/dist/{web-fetch-2YHJ3KTG.js → web-fetch-S7RR6GZ7.js} +3 -3
  177. package/dist/{wiki-generate-6M7GHTBJ.js → wiki-generate-CEHYGPGQ.js} +75 -65
  178. package/dist/with-panes-MKB46MPQ.js +782 -0
  179. package/dist/worker/entry.js +106 -75
  180. package/docs/README.md +3 -2
  181. package/docs/acp.md +24 -3
  182. package/docs/alcf-provider.md +1 -1
  183. package/docs/architecture.md +2 -2
  184. package/docs/artifact-versions.md +9 -1
  185. package/docs/built-in-agents.md +1 -1
  186. package/docs/capacity-and-scheduling.md +62 -3
  187. package/docs/commands-and-modes.md +31 -2
  188. package/docs/configuration-and-targets.md +69 -12
  189. package/docs/context-engine.md +63 -4
  190. package/docs/development-pipeline.md +19 -0
  191. package/docs/dispatch-typed-intent.md +385 -0
  192. package/docs/documentation-coverage.md +5 -5
  193. package/docs/documentation-guide.md +1 -1
  194. package/docs/environment-variables.md +3 -0
  195. package/docs/eval-runner.md +262 -11
  196. package/docs/evals-internal.md +72 -2
  197. package/docs/evidence-and-memory.md +12 -11
  198. package/docs/evolution.md +1 -1
  199. package/docs/exit-codes-and-output.md +1 -1
  200. package/docs/extensions-and-sharing.md +27 -1
  201. package/docs/fleet-dispatch.md +25 -4
  202. package/docs/installation-and-lifecycle.md +15 -2
  203. package/docs/middleware-and-components.md +1 -1
  204. package/docs/model-catalog.md +10 -1
  205. package/docs/observability.md +55 -4
  206. package/docs/proactive-memory.md +127 -14
  207. package/docs/prompt-envelope-and-tools.md +19 -1
  208. package/docs/provider-adapter-cookbook.md +1 -1
  209. package/docs/release-cut-checklist.md +19 -3
  210. package/docs/safety-model.md +2 -2
  211. package/docs/scientific-validation.md +3 -3
  212. package/docs/session-lifecycle.md +1 -1
  213. package/docs/skills-marketplace.md +1 -1
  214. package/docs/tool-usage.md +18 -8
  215. package/docs/trace-store.md +1 -1
  216. package/docs/troubleshooting.md +88 -1
  217. package/docs/tui-design.md +1 -1
  218. package/docs/worker-dispatch-mechanics.md +1 -1
  219. package/package.json +5 -2
  220. package/src/cli/acp.ts +6 -2
  221. package/src/cli/agents.ts +1 -1
  222. package/src/cli/argv.ts +25 -0
  223. package/src/cli/config-inspect.ts +33 -6
  224. package/src/cli/config.ts +1 -1
  225. package/src/cli/configure.ts +23 -21
  226. package/src/cli/doctor-panes.ts +124 -0
  227. package/src/cli/doctor-state-size.ts +82 -0
  228. package/src/cli/doctor-toolchain.ts +57 -0
  229. package/src/cli/doctor.ts +22 -1
  230. package/src/cli/eval-inventory.ts +436 -0
  231. package/src/cli/eval.ts +93 -16
  232. package/src/cli/evidence-detail.ts +88 -0
  233. package/src/cli/evidence-inventory.ts +183 -0
  234. package/src/cli/evidence.ts +30 -5
  235. package/src/cli/extensions.ts +5 -1
  236. package/src/cli/fleet-decisions.ts +69 -0
  237. package/src/cli/fleet-inspect.ts +334 -0
  238. package/src/cli/fleet-verify.ts +133 -0
  239. package/src/cli/fleet-view.ts +810 -0
  240. package/src/cli/fleet.ts +179 -39
  241. package/src/cli/index.ts +14 -2
  242. package/src/cli/interop-inspect.ts +128 -0
  243. package/src/cli/interop.ts +34 -0
  244. package/src/cli/panes.ts +35 -0
  245. package/src/cli/reset.ts +5 -2
  246. package/src/cli/run.ts +58 -0
  247. package/src/cli/skills-inventory.ts +185 -0
  248. package/src/cli/skills.ts +16 -13
  249. package/src/cli/targets.ts +44 -13
  250. package/src/cli/tools.ts +321 -0
  251. package/src/cli/trace-inspect.ts +252 -0
  252. package/src/cli/trace.ts +85 -5
  253. package/src/cli/usage.ts +63 -14
  254. package/src/cli/verifiers-inspect.ts +347 -0
  255. package/src/cli/verifiers.ts +9 -0
  256. package/src/core/bus-events.ts +33 -1
  257. package/src/core/cache-telemetry.ts +42 -0
  258. package/src/core/config.ts +67 -0
  259. package/src/core/defaults.ts +124 -8
  260. package/src/core/endpoint-key.ts +27 -0
  261. package/src/core/residency-target-key.ts +25 -0
  262. package/src/core/response-schema.ts +80 -6
  263. package/src/core/theme-token-hex.ts +43 -0
  264. package/src/core/tool-names.ts +2 -1
  265. package/src/core/xdg.ts +1 -1
  266. package/src/domains/agents/fleets/build-review.md +0 -3
  267. package/src/domains/agents/fleets/build-test.md +0 -3
  268. package/src/domains/agents/result-contract-filesystem.ts +32 -0
  269. package/src/domains/agents/result-contract.ts +164 -35
  270. package/src/domains/config/classify.ts +6 -0
  271. package/src/domains/context/codewiki/coordinator.ts +12 -4
  272. package/src/domains/dispatch/admission-error.ts +9 -0
  273. package/src/domains/dispatch/admission.ts +52 -14
  274. package/src/domains/dispatch/capacity-lease.ts +118 -9
  275. package/src/domains/dispatch/contract.ts +11 -0
  276. package/src/domains/dispatch/council-topology.ts +398 -0
  277. package/src/domains/dispatch/execution-plan.ts +44 -4
  278. package/src/domains/dispatch/extension.ts +378 -82
  279. package/src/domains/dispatch/fleet-node-prompt.ts +62 -0
  280. package/src/domains/dispatch/fleet-plan.ts +7 -2
  281. package/src/domains/dispatch/fleet-run.ts +87 -4
  282. package/src/domains/dispatch/gate-decisions.ts +11 -1
  283. package/src/domains/dispatch/gate-role-prompts.ts +9 -0
  284. package/src/domains/dispatch/gate-topology.ts +289 -0
  285. package/src/domains/dispatch/heartbeat.ts +32 -8
  286. package/src/domains/dispatch/index.ts +22 -0
  287. package/src/domains/dispatch/intent-compatibility.ts +330 -0
  288. package/src/domains/dispatch/intent.ts +85 -1
  289. package/src/domains/dispatch/orphan-recovery.ts +5 -0
  290. package/src/domains/dispatch/reservation-store.ts +139 -11
  291. package/src/domains/dispatch/run-event-journal-bridge.ts +149 -0
  292. package/src/domains/dispatch/run-event-journal.ts +598 -0
  293. package/src/domains/dispatch/state.ts +49 -1
  294. package/src/domains/dispatch/types.ts +13 -0
  295. package/src/domains/dispatch/validation.ts +33 -8
  296. package/src/domains/dispatch/worker-spawn.ts +25 -11
  297. package/src/domains/dispatch/write-boundary-enforcer.ts +20 -3
  298. package/src/domains/dispatch/write-boundary.ts +62 -1
  299. package/src/domains/eval/artifacts/store.ts +62 -0
  300. package/src/domains/eval/compare/behavioral.ts +224 -0
  301. package/src/domains/eval/compare/compare.ts +342 -2
  302. package/src/domains/eval/compare/envelope.ts +128 -0
  303. package/src/domains/eval/compare/gates.ts +24 -6
  304. package/src/domains/eval/compare/thresholds.ts +30 -3
  305. package/src/domains/eval/execution-provenance.ts +240 -0
  306. package/src/domains/eval/inventory.ts +113 -0
  307. package/src/domains/eval/metrics/aggregate.ts +136 -0
  308. package/src/domains/eval/metrics/call-ledger-stream.ts +112 -0
  309. package/src/domains/eval/metrics/tracked.ts +413 -0
  310. package/src/domains/eval/provenance.ts +117 -0
  311. package/src/domains/eval/reports/comparison.ts +128 -0
  312. package/src/domains/eval/reports/junit.ts +17 -3
  313. package/src/domains/eval/reports/markdown.ts +3 -3
  314. package/src/domains/eval/reports/text.ts +14 -0
  315. package/src/domains/eval/run-compare.ts +20 -0
  316. package/src/domains/eval/runners/clio-run.ts +127 -0
  317. package/src/domains/eval/runners/external-command.ts +28 -3
  318. package/src/domains/eval/schema/adapter.ts +111 -0
  319. package/src/domains/eval/schema/artifact.ts +20 -0
  320. package/src/domains/eval/schema/behavioral-metrics.ts +204 -0
  321. package/src/domains/eval/schema/behavioral.ts +520 -0
  322. package/src/domains/eval/schema/execution-envelope.ts +194 -0
  323. package/src/domains/eval/schema/serving.ts +105 -0
  324. package/src/domains/eval/schema/suite.ts +38 -8
  325. package/src/domains/eval/schema/validate.ts +58 -3
  326. package/src/domains/eval/schema/verdict.ts +237 -0
  327. package/src/domains/eval/suites/resolve.ts +2 -0
  328. package/src/domains/eval/suites/run.ts +264 -33
  329. package/src/domains/eval/verifiers/command.ts +2 -1
  330. package/src/domains/eval/workspaces/temp-copy.ts +145 -13
  331. package/src/domains/evidence/build.ts +2 -13
  332. package/src/domains/evidence/eval.ts +2 -12
  333. package/src/domains/evidence/findings-markdown.ts +33 -0
  334. package/src/domains/evidence/run-trust.ts +7 -113
  335. package/src/domains/evidence/store.ts +6 -0
  336. package/src/domains/evidence/trust-projection.ts +2 -2
  337. package/src/domains/extensions/compatibility.ts +285 -0
  338. package/src/domains/extensions/discovery.ts +38 -3
  339. package/src/domains/extensions/resources.ts +1 -1
  340. package/src/domains/extensions/state.ts +12 -3
  341. package/src/domains/extensions/types.ts +2 -0
  342. package/src/domains/lifecycle/doctor.ts +69 -1
  343. package/src/domains/memory/index.ts +14 -1
  344. package/src/domains/memory/task-bank-promotion.ts +64 -0
  345. package/src/domains/memory/task-memory-policy.ts +82 -17
  346. package/src/domains/memory/task-memory-spend.ts +131 -0
  347. package/src/domains/memory/task-memory-status.ts +7 -0
  348. package/src/domains/memory/task-memory-telemetry.ts +3 -0
  349. package/src/domains/middleware/index.ts +1 -0
  350. package/src/domains/middleware/memory-intervention.ts +97 -21
  351. package/src/domains/middleware/memory-step-endpoint.ts +71 -0
  352. package/src/domains/mux/contract.ts +434 -0
  353. package/src/domains/mux/detect.ts +158 -0
  354. package/src/domains/mux/extension.ts +47 -0
  355. package/src/domains/mux/index.ts +96 -0
  356. package/src/domains/mux/manifest.ts +6 -0
  357. package/src/domains/mux/operations.ts +164 -0
  358. package/src/domains/mux/pane-registry.ts +90 -0
  359. package/src/domains/mux/protocol.ts +49 -0
  360. package/src/domains/mux/socket-client.ts +816 -0
  361. package/src/domains/mux/types.ts +222 -0
  362. package/src/domains/mux/viewer-command.ts +59 -0
  363. package/src/domains/mux/yazi/assets/init.lua +2 -0
  364. package/src/domains/mux/yazi/assets/plugins/git.yazi/LICENSE +21 -0
  365. package/src/domains/mux/yazi/assets/plugins/git.yazi/README.md +78 -0
  366. package/src/domains/mux/yazi/assets/plugins/git.yazi/main.lua +255 -0
  367. package/src/domains/mux/yazi/assets/plugins/git.yazi/types.lua +12 -0
  368. package/src/domains/mux/yazi/assets/yazi.toml +17 -0
  369. package/src/domains/mux/yazi/event-stream.ts +180 -0
  370. package/src/domains/mux/yazi/profile.ts +299 -0
  371. package/src/domains/mux/yazi/session.ts +228 -0
  372. package/src/domains/mux/yazi/theme.ts +30 -0
  373. package/src/domains/observability/background-memory-usage.ts +140 -0
  374. package/src/domains/observability/cost.ts +22 -1
  375. package/src/domains/observability/index.ts +9 -0
  376. package/src/domains/observability/out-of-turn-usage.ts +51 -2
  377. package/src/domains/observability/trace-store.ts +234 -2
  378. package/src/domains/prompts/compiler.ts +100 -13
  379. package/src/domains/providers/endpoint-capacity.ts +228 -0
  380. package/src/domains/providers/endpoint-slots-store.ts +189 -0
  381. package/src/domains/providers/extension.ts +20 -3
  382. package/src/domains/providers/index.ts +32 -0
  383. package/src/domains/providers/model-runtime-capabilities.ts +32 -0
  384. package/src/domains/providers/models/local-models/clio-local-coding-targets.yaml +243 -1
  385. package/src/domains/providers/runtime-resolution.ts +8 -1
  386. package/src/domains/providers/runtimes/boot-manifest.ts +1 -0
  387. package/src/domains/providers/runtimes/builtins.ts +2 -0
  388. package/src/domains/providers/runtimes/common/probe-helpers.ts +31 -9
  389. package/src/domains/providers/runtimes/local-native/llamacpp-anthropic.ts +1 -1
  390. package/src/domains/providers/runtimes/local-native/llamacpp-completion.ts +1 -1
  391. package/src/domains/providers/runtimes/local-native/llamacpp-embed.ts +1 -1
  392. package/src/domains/providers/runtimes/local-native/llamacpp-rerank.ts +1 -1
  393. package/src/domains/providers/runtimes/local-native/llamacpp.ts +4 -1
  394. package/src/domains/providers/runtimes/local-native/lmstudio.ts +4 -1
  395. package/src/domains/providers/runtimes/local-native/ollama-native.ts +6 -1
  396. package/src/domains/providers/runtimes/protocol/litellm.ts +375 -0
  397. package/src/domains/providers/support.ts +1 -0
  398. package/src/domains/providers/target-model-cache.ts +124 -0
  399. package/src/domains/providers/types/capability-flags.ts +2 -0
  400. package/src/domains/providers/types/target-descriptor.ts +2 -0
  401. package/src/domains/resources/index.ts +3 -0
  402. package/src/domains/resources/prompts/loader.ts +95 -33
  403. package/src/domains/resources/skills/loader.ts +33 -0
  404. package/src/domains/safety/action-classifier.ts +6 -0
  405. package/src/domains/safety/call-target.ts +52 -0
  406. package/src/domains/safety/run-effects.ts +35 -4
  407. package/src/domains/session/context-accounting.ts +52 -1
  408. package/src/domains/session/context-ledger.ts +37 -13
  409. package/src/domains/session/index.ts +6 -0
  410. package/src/domains/session/prompt-cache.ts +140 -0
  411. package/src/domains/session/prompt-manifest.ts +42 -0
  412. package/src/domains/toolchain/archive.ts +175 -0
  413. package/src/domains/toolchain/contract.ts +28 -0
  414. package/src/domains/toolchain/extension.ts +47 -0
  415. package/src/domains/toolchain/index.ts +39 -0
  416. package/src/domains/toolchain/install.ts +327 -0
  417. package/src/domains/toolchain/manifest.ts +8 -0
  418. package/src/domains/toolchain/paths.ts +34 -0
  419. package/src/domains/toolchain/registry.ts +265 -0
  420. package/src/domains/toolchain/remove.ts +218 -0
  421. package/src/domains/toolchain/resolve.ts +182 -0
  422. package/src/domains/toolchain/types.ts +113 -0
  423. package/src/domains/toolchain/version.ts +88 -0
  424. package/src/engine/acp/adapter.ts +18 -3
  425. package/src/engine/acp/server.ts +413 -70
  426. package/src/engine/acp/types.ts +19 -1
  427. package/src/engine/ai.ts +35 -0
  428. package/src/engine/apis/llamacpp-residency.ts +55 -3
  429. package/src/engine/apis/lmstudio.ts +25 -5
  430. package/src/engine/apis/ollama-native.ts +2 -1
  431. package/src/engine/apis/openai-completions.ts +80 -17
  432. package/src/engine/apis/residency-lock.ts +3 -1
  433. package/src/engine/apis/residency.ts +34 -1
  434. package/src/engine/claude/sdk-module.ts +98 -0
  435. package/src/engine/claude/sdk-runtime.ts +19 -11
  436. package/src/engine/provider-payload.ts +29 -1
  437. package/src/engine/tui-primitives.ts +21 -0
  438. package/src/engine/tui.ts +1 -0
  439. package/src/engine/worker-runtime.ts +2 -13
  440. package/src/entry/boot-options.ts +2 -0
  441. package/src/entry/orchestrator.ts +279 -35
  442. package/src/entry/panes-activation.ts +31 -0
  443. package/src/entry/with-panes.ts +20 -0
  444. package/src/interactive/chat-loop-messages.ts +26 -7
  445. package/src/interactive/chat-loop.ts +318 -41
  446. package/src/interactive/chat-panel.ts +62 -8
  447. package/src/interactive/clio-editor.ts +45 -8
  448. package/src/interactive/context-activity.ts +5 -1
  449. package/src/interactive/context-meter.ts +1 -1
  450. package/src/interactive/context-overlay.ts +41 -10
  451. package/src/interactive/cost-overlay.ts +66 -6
  452. package/src/interactive/council-grid.ts +1 -3
  453. package/src/interactive/council.ts +11 -0
  454. package/src/interactive/dispatch-board.ts +102 -20
  455. package/src/interactive/fleet-run-preview.ts +41 -15
  456. package/src/interactive/handoff-round.ts +41 -2
  457. package/src/interactive/interactive-application.ts +177 -7
  458. package/src/interactive/interactive-input-runtime.ts +15 -0
  459. package/src/interactive/interactive-presentation.ts +4 -0
  460. package/src/interactive/interactive-shell.ts +20 -17
  461. package/src/interactive/interactive-slash-runtime.ts +63 -10
  462. package/src/interactive/memory-overlay.ts +9 -0
  463. package/src/interactive/modal-marker.ts +170 -0
  464. package/src/interactive/mutation-preview.ts +295 -0
  465. package/src/interactive/mux-bridge.ts +214 -0
  466. package/src/interactive/overlay-frame.ts +58 -2
  467. package/src/interactive/overlay-general-openers.ts +17 -0
  468. package/src/interactive/overlay-key-routing.ts +52 -3
  469. package/src/interactive/overlay-lifecycle.ts +56 -7
  470. package/src/interactive/overlay-model-selectors.ts +40 -3
  471. package/src/interactive/overlay-permission-lifecycle.ts +112 -24
  472. package/src/interactive/overlay-session-lifecycle.ts +73 -9
  473. package/src/interactive/overlay-transitions.ts +18 -4
  474. package/src/interactive/overlays/agents.ts +1 -0
  475. package/src/interactive/overlays/ask-user.ts +227 -49
  476. package/src/interactive/overlays/auth-dialog.ts +1 -0
  477. package/src/interactive/overlays/context-reset.ts +1 -0
  478. package/src/interactive/overlays/cwd-fallback.ts +1 -0
  479. package/src/interactive/overlays/decisions.ts +11 -11
  480. package/src/interactive/overlays/extensions.ts +1 -0
  481. package/src/interactive/overlays/fleet-run-approval.ts +1 -0
  482. package/src/interactive/overlays/handoff-review.ts +1 -0
  483. package/src/interactive/overlays/help-reference.ts +6 -0
  484. package/src/interactive/overlays/interop.ts +1 -0
  485. package/src/interactive/overlays/library-install-confirm.ts +1 -0
  486. package/src/interactive/overlays/library-tabs.ts +28 -0
  487. package/src/interactive/overlays/list-overlay.ts +10 -1
  488. package/src/interactive/overlays/message-picker.ts +1 -0
  489. package/src/interactive/overlays/model-scope.ts +86 -0
  490. package/src/interactive/overlays/model-selector.ts +1 -0
  491. package/src/interactive/overlays/prompts.ts +12 -1
  492. package/src/interactive/overlays/session-selector.ts +1 -0
  493. package/src/interactive/overlays/settings-sections.ts +30 -0
  494. package/src/interactive/overlays/settings.ts +614 -45
  495. package/src/interactive/overlays/side-question.ts +1 -0
  496. package/src/interactive/overlays/skills-hub.ts +3 -11
  497. package/src/interactive/overlays/tree-selector.ts +1 -0
  498. package/src/interactive/pane-policy.ts +46 -0
  499. package/src/interactive/panes-runtime.ts +292 -0
  500. package/src/interactive/permission-hint.ts +34 -2
  501. package/src/interactive/permission-overlay.ts +159 -9
  502. package/src/interactive/prewarm.ts +197 -0
  503. package/src/interactive/render-trace.ts +162 -15
  504. package/src/interactive/renderers/compaction-summary.ts +29 -0
  505. package/src/interactive/renderers/tool-execution.ts +4 -0
  506. package/src/interactive/renderers/worker-entry.ts +122 -14
  507. package/src/interactive/side-question.ts +58 -1
  508. package/src/interactive/slash-commands.ts +251 -15
  509. package/src/interactive/status/controller.ts +11 -0
  510. package/src/interactive/status/state-machine.ts +54 -2
  511. package/src/interactive/status/types.ts +7 -0
  512. package/src/interactive/tasks-overlay.ts +1 -0
  513. package/src/interactive/terminal-lease.ts +2 -0
  514. package/src/interactive/theme/tokens.ts +3 -14
  515. package/src/interactive/turn-context.ts +346 -33
  516. package/src/interactive/turn-persistence.ts +14 -4
  517. package/src/interactive/turn-prewarm.ts +364 -0
  518. package/src/interactive/turn-queues.ts +7 -4
  519. package/src/interactive/turn-runtime.ts +8 -1
  520. package/src/interactive/turn-state.ts +23 -0
  521. package/src/interactive/view/artifacts.ts +109 -1
  522. package/src/interactive/view/view-overlay.ts +29 -3
  523. package/src/interactive/watch-pane.ts +152 -0
  524. package/src/interactive/worker-progress.ts +7 -1
  525. package/src/interactive/worker-receipts.ts +19 -1
  526. package/src/interactive/worker-stream.ts +5 -0
  527. package/src/interactive/yazi-bridge.ts +444 -0
  528. package/src/tools/ask-user.ts +43 -2
  529. package/src/tools/bootstrap.ts +26 -2
  530. package/src/tools/builtin-tool-catalog.ts +15 -0
  531. package/src/tools/compete-worktrees.ts +83 -2
  532. package/src/tools/core-bootstrap.ts +2 -1
  533. package/src/tools/dispatch-admission.ts +14 -3
  534. package/src/tools/dispatch-arguments.ts +20 -20
  535. package/src/tools/dispatch-plan.ts +17 -9
  536. package/src/tools/dispatch-run-events.ts +134 -19
  537. package/src/tools/dispatch-runner.ts +29 -7
  538. package/src/tools/dispatch-scout.ts +1 -1
  539. package/src/tools/dispatch-types.ts +15 -3
  540. package/src/tools/dispatch.ts +1 -1
  541. package/src/tools/executables.ts +17 -14
  542. package/src/tools/observation.ts +54 -4
  543. package/src/tools/panes-surface.ts +38 -0
  544. package/src/tools/panes.ts +112 -0
  545. package/src/tools/policy.ts +10 -1
  546. package/src/tools/presentation.ts +1 -0
  547. package/src/tools/registry.ts +16 -0
  548. package/dist/chunk-AOCYTWAV.js +0 -449
  549. package/dist/chunk-HLE42MG7.js +0 -37
  550. package/dist/chunk-HWUFFB6L.js +0 -83
  551. package/dist/chunk-JOZYP4GM.js +0 -279
  552. package/dist/doctor-M7YEDGAE.js +0 -91
@@ -1,7 +1,16 @@
1
1
  import { createRequire as __clioCreateRequire } from "node:module"; const require = __clioCreateRequire(import.meta.url);
2
2
  import {
3
- AGENT_AUTOMATION_AUTHORITIES
4
- } from "./chunk-AOCYTWAV.js";
3
+ artifactDefaultPath,
4
+ extractCommandCdTargets,
5
+ extractCommandWriteTargets
6
+ } from "./chunk-GCSMB2KY.js";
7
+ import {
8
+ canonicalizeExistingPath
9
+ } from "./chunk-ECH6PKUQ.js";
10
+ import {
11
+ ToolNames,
12
+ isBuiltinToolName
13
+ } from "./chunk-K6BSR66V.js";
5
14
  import {
6
15
  init_esm_shims
7
16
  } from "./chunk-3R73A4XB.js";
@@ -34,10 +43,431 @@ function parseJsonObjectPayload(text) {
34
43
  return { ok: false, reason: parsedSomething ? "not-object" : "not-json" };
35
44
  }
36
45
 
37
- // src/domains/agents/result-contract.ts
46
+ // src/domains/agents/spec.ts
38
47
  init_esm_shims();
39
48
  import { createHash } from "node:crypto";
49
+
50
+ // src/domains/safety/action-classifier.ts
51
+ init_esm_shims();
40
52
  import path from "node:path";
53
+ var GIT_DESTRUCTIVE_PATTERNS = [
54
+ { name: "git-push-force-long", re: /\bgit\s+push\s+--force\b/i },
55
+ { name: "git-push-force-short", re: /\bgit\s+push\s+-f\b/i },
56
+ { name: "git-reset-hard", re: /\bgit\s+reset\s+--hard\b/i },
57
+ { name: "git-clean-fd", re: /\bgit\s+clean\s+-fd?\b/i },
58
+ { name: "git-checkout-dot", re: /\bgit\s+checkout\s+--\s+\./i },
59
+ { name: "git-branch-D", re: /\bgit\s+branch\s+-D\b/i },
60
+ { name: "git-restore-source", re: /\bgit\s+restore\s+--source\b/i }
61
+ ];
62
+ var SYSTEM_MODIFY_PATTERNS = [
63
+ { name: "sudo-or-doas", re: /\b(sudo|doas)\b/i },
64
+ // allow rm -rf /tmp/... and /var/tmp/... but flag everything else rooted at /
65
+ { name: "rm-rf-root", re: /\brm\s+-rf?\s+\/(?!(tmp|var\/tmp)(?:\/|\s|$))/i },
66
+ { name: "apt-install", re: /\bapt(-get)?\s+(install|remove|purge)/i },
67
+ { name: "brew-install", re: /\bbrew\s+(install|uninstall|reinstall)/i },
68
+ { name: "npm-install-global", re: /\bnpm\s+install\s+-g\b/i },
69
+ { name: "pip-install", re: /\bpip\s+install\b/i },
70
+ { name: "systemctl", re: /\bsystemctl\s+/i },
71
+ { name: "chmod-root", re: /\bchmod\s+[0-7]{3,4}\s+\//i },
72
+ { name: "chown", re: /\bchown\s+/i }
73
+ ];
74
+ var SYSTEM_WRITE_ROOT_PREFIXES = ["/etc", "/usr", "/var", "/bin", "/sbin", "/run"];
75
+ var SYSTEM_WRITE_EXEMPT_PREFIXES = ["/var/tmp", "/var/folders"];
76
+ function isUnderPrefix(abs, prefix) {
77
+ return abs === prefix || abs.startsWith(`${prefix}/`);
78
+ }
79
+ function baseClassify(tool) {
80
+ switch (tool) {
81
+ case ToolNames.Read:
82
+ case ToolNames.Grep:
83
+ case ToolNames.Find:
84
+ case ToolNames.Ls:
85
+ case ToolNames.WebFetch:
86
+ case ToolNames.Git:
87
+ case ToolNames.CodeNav:
88
+ case ToolNames.Context:
89
+ case ToolNames.Monitor:
90
+ case ToolNames.AskUser:
91
+ case ToolNames.CredentialPresent:
92
+ // tasks pick mutates only Clio-owned session-ledger and project-local
93
+ // .clio-coder runtime state, never source-workspace files. By intentional
94
+ // policy it stays read class and ungated; the tool itself still requires
95
+ // a durable operator task id before it can mutate either store.
96
+ case ToolNames.Tasks:
97
+ // ledger posts a typed contribution to a coordination board and reads a
98
+ // local mirror. Neither touches the workspace, so it is never gated
99
+ // behind a confirmation.
100
+ case ToolNames.Ledger:
101
+ // panes focuses, opens, and closes terminal panes Clio itself created, in
102
+ // a pane host that lives outside the workspace. Nothing it does writes a
103
+ // file, runs a model-supplied command (its schema exposes presets only),
104
+ // or survives the session, so it is reversible, local, and never gated
105
+ // behind a confirmation.
106
+ case ToolNames.Panes:
107
+ return "read";
108
+ case ToolNames.Write:
109
+ case ToolNames.Edit:
110
+ case ToolNames.Artifact:
111
+ return "write";
112
+ case ToolNames.Bash:
113
+ case ToolNames.Verify:
114
+ return "execute";
115
+ case ToolNames.Dispatch:
116
+ case ToolNames.Steer:
117
+ return "dispatch";
118
+ default:
119
+ return null;
120
+ }
121
+ }
122
+ function scanStringOf(args) {
123
+ if (!args) return "";
124
+ const parts = [];
125
+ for (const value of Object.values(args)) {
126
+ if (value == null) continue;
127
+ if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
128
+ parts.push(String(value));
129
+ } else {
130
+ try {
131
+ parts.push(JSON.stringify(value));
132
+ } catch {
133
+ }
134
+ }
135
+ }
136
+ return parts.join(" ");
137
+ }
138
+ function matchFirst(patterns, haystack) {
139
+ for (const p of patterns) {
140
+ if (p.re.test(haystack)) return p;
141
+ }
142
+ return null;
143
+ }
144
+ function resolveCandidate(p, baseCwd) {
145
+ if (p.startsWith("~")) return p;
146
+ const base = canonicalizeExistingPath(path.resolve(baseCwd ?? process.cwd()));
147
+ const resolved = path.isAbsolute(p) ? path.resolve(p) : path.resolve(base, p);
148
+ return canonicalizeExistingPath(resolved);
149
+ }
150
+ function isInsideCwd(abs) {
151
+ const cwd = canonicalizeExistingPath(path.resolve(process.cwd()));
152
+ const candidate = canonicalizeExistingPath(abs);
153
+ const rel = path.relative(cwd, candidate);
154
+ return rel === "" || !rel.startsWith("..") && !path.isAbsolute(rel);
155
+ }
156
+ function writePathClass(pathArg, baseCwd) {
157
+ if (pathArg.startsWith("~")) {
158
+ return { cls: "system_modify", reason: `write-path-home-escape: ${pathArg}` };
159
+ }
160
+ const abs = resolveCandidate(pathArg, baseCwd);
161
+ const exempt = SYSTEM_WRITE_EXEMPT_PREFIXES.some((prefix) => isUnderPrefix(abs, prefix));
162
+ if (!exempt) {
163
+ for (const prefix of SYSTEM_WRITE_ROOT_PREFIXES) {
164
+ if (isUnderPrefix(abs, prefix)) {
165
+ return { cls: "system_modify", reason: `write-path-system-root: ${prefix}` };
166
+ }
167
+ }
168
+ }
169
+ if (!isInsideCwd(abs)) {
170
+ return { cls: "system_modify", reason: `write-path-outside-cwd: ${abs}` };
171
+ }
172
+ return { cls: "write" };
173
+ }
174
+ function extractWritePath(tool, args) {
175
+ const candidate = args?.path ?? args?.file_path ?? args?.filePath;
176
+ if (typeof candidate === "string" && candidate.length > 0) return candidate;
177
+ return tool === ToolNames.Artifact ? artifactDefaultPath(args?.kind) : null;
178
+ }
179
+ function classify(call) {
180
+ const base = baseClassify(call.tool);
181
+ if (base === null) {
182
+ return { actionClass: "unknown", reasons: [`unknown tool: ${call.tool}`] };
183
+ }
184
+ const reasons = [];
185
+ if (call.tool === ToolNames.Bash) {
186
+ const scan = scanStringOf(call.args);
187
+ const gitHit = matchFirst(GIT_DESTRUCTIVE_PATTERNS, scan);
188
+ if (gitHit) {
189
+ return { actionClass: "git_destructive", reasons: [`pattern:${gitHit.name}`] };
190
+ }
191
+ const sysHit = matchFirst(SYSTEM_MODIFY_PATTERNS, scan);
192
+ if (sysHit) {
193
+ return { actionClass: "system_modify", reasons: [`pattern:${sysHit.name}`] };
194
+ }
195
+ const command = typeof call.args?.command === "string" ? call.args.command : null;
196
+ const argCwd = typeof call.args?.cwd === "string" && call.args.cwd.length > 0 ? call.args.cwd : void 0;
197
+ if (command !== null) {
198
+ const targetReasons = [];
199
+ for (const target of extractCommandWriteTargets(command)) {
200
+ const decision = writePathClass(target, argCwd);
201
+ if (decision.cls === "system_modify") {
202
+ targetReasons.push(decision.reason ?? `bash-write-target: ${target}`);
203
+ }
204
+ }
205
+ for (const target of extractCommandCdTargets(command)) {
206
+ if (target.startsWith("~")) {
207
+ targetReasons.push(`bash-cd-home-escape: ${target}`);
208
+ continue;
209
+ }
210
+ const abs = resolveCandidate(target, argCwd);
211
+ if (!isInsideCwd(abs)) {
212
+ targetReasons.push(`bash-cd-outside-workspace: ${abs}`);
213
+ }
214
+ }
215
+ if (targetReasons.length > 0) {
216
+ return { actionClass: "system_modify", reasons: targetReasons };
217
+ }
218
+ }
219
+ return { actionClass: "execute", reasons };
220
+ }
221
+ if (base === "write") {
222
+ const pathArg = extractWritePath(call.tool, call.args);
223
+ if (pathArg) {
224
+ const decision = writePathClass(pathArg);
225
+ if (decision.cls === "system_modify") {
226
+ return { actionClass: "system_modify", reasons: decision.reason ? [decision.reason] : [] };
227
+ }
228
+ }
229
+ return { actionClass: "write", reasons };
230
+ }
231
+ return { actionClass: base, reasons };
232
+ }
233
+
234
+ // src/domains/agents/spec.ts
235
+ var AGENT_AUTOMATION_AUTHORITIES = ["read-only", "verification", "artifact-write", "workspace-edit"];
236
+ var AGENT_PRODUCTS = ["orientation"];
237
+ var AGENT_CATEGORIES = [
238
+ "explore",
239
+ "plan",
240
+ "research",
241
+ "implement",
242
+ "quality",
243
+ "science",
244
+ "evolution",
245
+ "operations",
246
+ "internal"
247
+ ];
248
+ var AGENT_CAPABILITY_CLASSES = [
249
+ "read-only",
250
+ "artifact-write",
251
+ "workspace-edit",
252
+ "verification",
253
+ "orchestration",
254
+ "internal"
255
+ ];
256
+ var AGENT_LATENCY_CLASSES = ["fast", "balanced", "deep"];
257
+ var AGENT_AUDIENCES = ["base", "shadow", "custom", "internal"];
258
+ var AGENT_PROJECT_CONTEXT_TIERS = ["none", "bounded"];
259
+ function includes(values, value) {
260
+ return typeof value === "string" && values.includes(value);
261
+ }
262
+ function isAgentCategory(value) {
263
+ return includes(AGENT_CATEGORIES, value);
264
+ }
265
+ function isAgentCapabilityClass(value) {
266
+ return includes(AGENT_CAPABILITY_CLASSES, value);
267
+ }
268
+ function isAgentLatencyClass(value) {
269
+ return includes(AGENT_LATENCY_CLASSES, value);
270
+ }
271
+ function isAgentAudience(value) {
272
+ return includes(AGENT_AUDIENCES, value);
273
+ }
274
+ function isAgentProjectContextTier(value) {
275
+ return includes(AGENT_PROJECT_CONTEXT_TIERS, value);
276
+ }
277
+ function isAgentProduct(value) {
278
+ return includes(AGENT_PRODUCTS, value);
279
+ }
280
+ function actionClassesForTools(tools) {
281
+ const actions = /* @__PURE__ */ new Set();
282
+ for (const tool of tools) actions.add(classify({ tool }).actionClass);
283
+ return actions;
284
+ }
285
+ function normalizeTools(recipe) {
286
+ const seen = /* @__PURE__ */ new Set();
287
+ const tools = [];
288
+ for (const tool of recipe.tools) {
289
+ if (typeof tool !== "string" || tool.trim().length === 0) {
290
+ throw new Error(`agent recipe '${recipe.id}' declares an invalid tool name`);
291
+ }
292
+ if (seen.has(tool)) continue;
293
+ seen.add(tool);
294
+ tools.push(isBuiltinToolName(tool) ? tool : tool);
295
+ }
296
+ return tools;
297
+ }
298
+ function asToolName(tool) {
299
+ return isBuiltinToolName(tool) ? tool : tool;
300
+ }
301
+ function normalizeToolRequirements(recipe, tools) {
302
+ if (!recipe.toolRequirements) {
303
+ throw new Error(`agent recipe '${recipe.id}' must declare tools.required and tools.optional`);
304
+ }
305
+ const declared = new Set(tools);
306
+ const required = recipe.toolRequirements.required.map((requirement, index) => {
307
+ if (typeof requirement === "string") return asToolName(requirement);
308
+ if (!Array.isArray(requirement.anyOf) || requirement.anyOf.length === 0) {
309
+ throw new Error(`agent recipe '${recipe.id}' tools.required[${index}].anyOf must be non-empty`);
310
+ }
311
+ return { anyOf: requirement.anyOf.map(asToolName) };
312
+ });
313
+ const optional = recipe.toolRequirements.optional.map(asToolName);
314
+ const mentioned = required.flatMap(
315
+ (requirement) => typeof requirement === "string" ? [requirement] : requirement.anyOf
316
+ );
317
+ for (const tool of [...mentioned, ...optional]) {
318
+ if (!declared.has(tool)) throw new Error(`agent recipe '${recipe.id}' requirement '${tool}' is not declared`);
319
+ }
320
+ if ((/* @__PURE__ */ new Set([...mentioned, ...optional])).size !== mentioned.length + optional.length) {
321
+ throw new Error(`agent recipe '${recipe.id}' contains duplicate tool requirements`);
322
+ }
323
+ if ((/* @__PURE__ */ new Set([...mentioned, ...optional])).size !== tools.length) {
324
+ throw new Error(`agent recipe '${recipe.id}' has declared tools without required/optional semantics`);
325
+ }
326
+ return { required, optional };
327
+ }
328
+ function resolveAgentToolCompatibility(spec, effectiveTools, options) {
329
+ const available = new Set(effectiveTools);
330
+ const missingRequired = [];
331
+ for (const requirement of spec.toolRequirements.required) {
332
+ if (typeof requirement === "string") {
333
+ if (!available.has(requirement)) missingRequired.push(requirement);
334
+ continue;
335
+ }
336
+ if (!requirement.anyOf.some((tool) => available.has(tool))) {
337
+ missingRequired.push(`anyOf(${requirement.anyOf.join("|")})`);
338
+ }
339
+ }
340
+ if (available.has(ToolNames.Dispatch) && !options.mediatesDispatch) {
341
+ missingRequired.push("dispatch(runtime mediation unavailable)");
342
+ }
343
+ return {
344
+ compatible: missingRequired.length === 0,
345
+ missingRequired,
346
+ lostOptional: spec.toolRequirements.optional.filter((tool) => !available.has(tool))
347
+ };
348
+ }
349
+ function normalizeAgentSpec(recipe) {
350
+ const tools = normalizeTools(recipe);
351
+ const toolRequirements = normalizeToolRequirements(recipe, tools);
352
+ return {
353
+ version: recipe.version,
354
+ id: recipe.id,
355
+ name: recipe.name,
356
+ description: recipe.description,
357
+ source: recipe.source,
358
+ filepath: recipe.filepath,
359
+ tools,
360
+ toolRequirements,
361
+ category: recipe.category,
362
+ capabilityClass: recipe.capabilityClass,
363
+ latencyClass: recipe.latencyClass,
364
+ projectContextTier: recipe.projectContextTier,
365
+ audience: recipe.audience,
366
+ tags: recipe.tags,
367
+ skills: recipe.skills,
368
+ resultContract: recipe.resultContract,
369
+ ...recipe.product !== void 0 ? { product: recipe.product } : {},
370
+ budget: recipe.budget,
371
+ body: recipe.body
372
+ };
373
+ }
374
+ function agentSpecFingerprint(spec) {
375
+ const requirement = (entry) => typeof entry === "string" ? entry : `anyOf(${[...entry.anyOf].sort().join("|")})`;
376
+ const payload = JSON.stringify({
377
+ id: spec.id,
378
+ tools: [...spec.tools].sort(),
379
+ required: spec.toolRequirements.required.map(requirement).sort(),
380
+ optional: [...spec.toolRequirements.optional].sort(),
381
+ capabilityClass: spec.capabilityClass,
382
+ latencyClass: spec.latencyClass,
383
+ projectContextTier: spec.projectContextTier,
384
+ audience: spec.audience,
385
+ skills: [...spec.skills].sort(),
386
+ resultContract: spec.resultContract,
387
+ budget: spec.budget,
388
+ body: createHash("sha256").update(spec.body, "utf8").digest("hex")
389
+ });
390
+ return createHash("sha256").update(payload, "utf8").digest("hex");
391
+ }
392
+ function isUserVisibleAgent(spec) {
393
+ return spec.audience === "base" || spec.audience === "custom";
394
+ }
395
+ function isShadowAgent(spec) {
396
+ return spec.audience === "shadow" || spec.audience === "internal";
397
+ }
398
+ function agentSpecPolicyErrors(spec) {
399
+ const errors = [];
400
+ const actions = actionClassesForTools(spec.tools);
401
+ const requiredGroups = spec.toolRequirements.required.map(
402
+ (requirement) => typeof requirement === "string" ? [requirement] : requirement.anyOf
403
+ );
404
+ const requiresTool = (tool) => requiredGroups.some((group) => group.length > 0 && group.every((candidate) => candidate === tool));
405
+ const requiresMutation = requiredGroups.some(
406
+ (group) => group.length > 0 && group.every((tool) => tool === ToolNames.Write || tool === ToolNames.Edit)
407
+ );
408
+ if (spec.capabilityClass === "workspace-edit" && (!requiresTool(ToolNames.Read) || !requiresMutation)) {
409
+ errors.push(`workspace-edit agent '${spec.id}' must require read and write|edit`);
410
+ }
411
+ if (spec.capabilityClass === "verification" && !requiresTool(ToolNames.Verify)) {
412
+ errors.push(`verification agent '${spec.id}' must require verify`);
413
+ }
414
+ if (spec.capabilityClass === "artifact-write" && !requiresTool(ToolNames.Artifact)) {
415
+ errors.push(`artifact-write agent '${spec.id}' must require artifact`);
416
+ }
417
+ if (spec.skills.length > 0 && !requiresTool(ToolNames.Context)) {
418
+ errors.push(`agent '${spec.id}' must require context for bound skills`);
419
+ }
420
+ if (spec.capabilityClass === "orchestration" && spec.tools.includes(ToolNames.Dispatch) && !requiresTool(ToolNames.Dispatch)) {
421
+ errors.push(`orchestration agent '${spec.id}' must require dispatch when it is declared`);
422
+ }
423
+ const toolList = spec.tools.join(", ");
424
+ if (spec.capabilityClass === "read-only") {
425
+ for (const action of actions) {
426
+ if (action !== "read") errors.push(`read-only agent '${spec.id}' requests ${action} tools (${toolList})`);
427
+ }
428
+ }
429
+ if (spec.capabilityClass === "artifact-write") {
430
+ for (const tool of spec.tools) {
431
+ const action = classify({ tool }).actionClass;
432
+ if (action === "execute" || action === "dispatch" || action === "system_modify" || action === "git_destructive") {
433
+ errors.push(`artifact-write agent '${spec.id}' requests ${action} tool '${tool}'`);
434
+ }
435
+ if (action === "write" && tool !== ToolNames.Artifact) {
436
+ errors.push(`artifact-write agent '${spec.id}' can only write terminal artifacts; got '${tool}'`);
437
+ }
438
+ }
439
+ }
440
+ if (spec.capabilityClass === "verification") {
441
+ for (const tool of spec.tools) {
442
+ const action = classify({ tool }).actionClass;
443
+ if (action === "write" || action === "dispatch" || action === "system_modify" || action === "git_destructive") {
444
+ errors.push(`verification agent '${spec.id}' must not request ${action} tool '${tool}'`);
445
+ }
446
+ if (tool === ToolNames.Bash)
447
+ errors.push(`verification agent '${spec.id}' must use typed validation tools, not bash`);
448
+ }
449
+ }
450
+ if (spec.capabilityClass !== "orchestration" && spec.tools.includes(ToolNames.Dispatch)) {
451
+ errors.push(`agent '${spec.id}' exposes dispatch without orchestration capability`);
452
+ }
453
+ if (spec.tools.includes(ToolNames.AskUser)) {
454
+ errors.push(`agent '${spec.id}' exposes ask_user, which is only available to the orchestrator`);
455
+ }
456
+ if (spec.skills.length > 0 && !spec.tools.includes(ToolNames.Context)) {
457
+ errors.push(`agent '${spec.id}' declares skills but does not expose context`);
458
+ }
459
+ return errors;
460
+ }
461
+ function assertAgentSpecPolicy(spec) {
462
+ const errors = agentSpecPolicyErrors(spec);
463
+ if (errors.length > 0) throw new Error(`agent policy violation:
464
+ ${errors.map((error) => `- ${error}`).join("\n")}`);
465
+ }
466
+
467
+ // src/domains/agents/result-contract.ts
468
+ init_esm_shims();
469
+ import { createHash as createHash2 } from "node:crypto";
470
+ import path2 from "node:path";
41
471
  function parseDelegationPlanResult(output) {
42
472
  const parsed = parseJson(output);
43
473
  if (!parsed.ok || !hasOnlyKeys(parsed.value, ["tasks"]) || !Array.isArray(parsed.value.tasks) || parsed.value.tasks.length === 0)
@@ -155,7 +585,7 @@ function canonical(value) {
155
585
  throw new Error(`result contract cannot digest ${typeof value}`);
156
586
  }
157
587
  function digest(value) {
158
- return createHash("sha256").update(canonical(value), "utf8").digest("hex");
588
+ return createHash2("sha256").update(canonical(value), "utf8").digest("hex");
159
589
  }
160
590
  function resultContractDigest(contract) {
161
591
  return digest(contract);
@@ -358,13 +788,24 @@ function parseChecks(value) {
358
788
  }
359
789
  return checks;
360
790
  }
791
+ function citationWithinWorkspace(cwd, citedPath) {
792
+ const relative = path2.relative(cwd, citedPath);
793
+ if (relative === "") return true;
794
+ return !(relative === ".." || relative.startsWith(`..${path2.sep}`) || path2.isAbsolute(relative));
795
+ }
796
+ function directoryCitationDigest(cwd, citedPath) {
797
+ const relative = path2.relative(cwd, citedPath);
798
+ return createHash2("sha256").update(`directory:${relative === "" ? "." : relative}`, "utf8").digest("hex");
799
+ }
361
800
  function validateScoutCitation(input, citation) {
362
- const cwd = path.resolve(input.cwd);
363
- const citedPath = path.resolve(cwd, citation.path);
364
- const relative = path.relative(cwd, citedPath);
365
- if (relative === "" || relative.startsWith(`..${path.sep}`) || relative === ".." || path.isAbsolute(relative)) {
801
+ const cwd = path2.resolve(input.cwd);
802
+ const citedPath = path2.resolve(cwd, citation.path);
803
+ if (!citationWithinWorkspace(cwd, citedPath)) {
366
804
  return { ok: false, reason: `Scout citation path escapes the workspace: ${citation.path}` };
367
805
  }
806
+ if (input.filesystem.isDirectory?.(citedPath) === true) {
807
+ return { ok: true, evidence: { ...citation, contentDigest: directoryCitationDigest(cwd, citedPath) } };
808
+ }
368
809
  const content = input.filesystem.readFile(citedPath);
369
810
  if (content === null) return { ok: false, reason: `Scout citation cannot be read: ${citation.path}` };
370
811
  const lineCount = content.split(/\r\n|\r|\n/u).length;
@@ -383,7 +824,7 @@ function validateScoutCitation(input, citation) {
383
824
  }
384
825
  return {
385
826
  ok: true,
386
- evidence: { ...citation, contentDigest: createHash("sha256").update(content, "utf8").digest("hex") }
827
+ evidence: { ...citation, contentDigest: createHash2("sha256").update(content, "utf8").digest("hex") }
387
828
  };
388
829
  }
389
830
  function validateScoutCitations(input, citations) {
@@ -420,14 +861,57 @@ function groundDegradedScout(contract, input, scout, degradedReason) {
420
861
  }
421
862
  function validateVerifier(contract, output) {
422
863
  const parsed = parseJson(output);
423
- if (!parsed.ok) return failure(contract, "fail", parsed.reason);
864
+ if (!parsed.ok) return failure(contract, "fail", `Verifier result payload failed: ${parsed.reason}`);
424
865
  const value = parsed.value;
425
- if (!hasOnlyKeys(value, ["verdict", "checks"]) || value.verdict !== "pass" && value.verdict !== "fail") {
426
- return failure(contract, "fail", "Verifier result must carry pass or fail verdict and checks");
866
+ const unknown = Object.keys(value).filter((key) => key !== "verdict" && key !== "checks");
867
+ if (unknown.length > 0) {
868
+ return failure(
869
+ contract,
870
+ "fail",
871
+ `Verifier result field${unknown.length === 1 ? "" : "s"} ${unknown.join(", ")} ${unknown.length === 1 ? "is" : "are"} not legal; legal top-level fields are verdict and checks`
872
+ );
427
873
  }
428
- const checks = parseChecks(value.checks);
429
- if (checks === null || value.verdict === "pass" !== checks.every((check) => check.passed)) {
430
- return failure(contract, "fail", "Verifier verdict must agree with every typed check");
874
+ if (value.verdict !== "pass" && value.verdict !== "fail") {
875
+ return failure(contract, "fail", 'Verifier field "verdict" must be one of: pass | fail');
876
+ }
877
+ if (!Array.isArray(value.checks) || value.checks.length === 0) {
878
+ return failure(
879
+ contract,
880
+ "fail",
881
+ 'Verifier field "checks" must be a non-empty array of {name, passed, evidence}; each checks[].passed value must be one of: true | false'
882
+ );
883
+ }
884
+ const checks = [];
885
+ for (const [index, raw] of value.checks.entries()) {
886
+ if (raw === null || typeof raw !== "object" || Array.isArray(raw)) {
887
+ return failure(contract, "fail", `Verifier field "checks[${index}]" must be an object`);
888
+ }
889
+ const check = raw;
890
+ const checkUnknown = Object.keys(check).filter((key) => key !== "name" && key !== "passed" && key !== "evidence");
891
+ if (checkUnknown.length > 0) {
892
+ return failure(
893
+ contract,
894
+ "fail",
895
+ `Verifier field "checks[${index}].${checkUnknown[0]}" is not legal; legal check fields are name, passed, and evidence`
896
+ );
897
+ }
898
+ if (!string(check.name)) {
899
+ return failure(contract, "fail", `Verifier field "checks[${index}].name" must be a non-empty string`);
900
+ }
901
+ if (typeof check.passed !== "boolean") {
902
+ return failure(contract, "fail", `Verifier field "checks[${index}].passed" must be one of: true | false`);
903
+ }
904
+ if (!string(check.evidence)) {
905
+ return failure(contract, "fail", `Verifier field "checks[${index}].evidence" must be a non-empty string`);
906
+ }
907
+ checks.push({ name: check.name, passed: check.passed, evidence: check.evidence });
908
+ }
909
+ if (value.verdict === "pass" !== checks.every((check) => check.passed)) {
910
+ return failure(
911
+ contract,
912
+ "fail",
913
+ 'Verifier field "verdict" must agree with every checks[].passed value; verdict legal values are pass | fail and checks[].passed legal values are true | false'
914
+ );
431
915
  }
432
916
  const verifier = { verdict: value.verdict, checks };
433
917
  return success(contract, value.verdict, verifier, { verifier });
@@ -520,45 +1004,87 @@ function resultContractAuthorship(contract, output) {
520
1004
  }
521
1005
  function validateDebugger(contract, output) {
522
1006
  const parsed = parseJson(output);
523
- if (!parsed.ok) return failure(contract, "unmeasured", parsed.reason);
1007
+ if (!parsed.ok) return failure(contract, "unmeasured", `Debugger result payload failed: ${parsed.reason}`);
524
1008
  const value = parsed.value;
525
- if (!hasOnlyKeys(value, ["diagnosis", "reproduction", "evidence"]) || !string(value.diagnosis) || value.reproduction !== "reproduced" && value.reproduction !== "not-reproduced" && value.reproduction !== "unknown" || !Array.isArray(value.evidence) || value.evidence.some((entry) => !string(entry))) {
1009
+ const unknown = Object.keys(value).filter(
1010
+ (key) => key !== "diagnosis" && key !== "reproduction" && key !== "evidence"
1011
+ );
1012
+ if (unknown.length > 0) {
526
1013
  return failure(
527
1014
  contract,
528
1015
  "unmeasured",
529
- "Debugger result must carry diagnosis, reproduction status, and evidence without a verdict"
1016
+ `Debugger result field${unknown.length === 1 ? "" : "s"} ${unknown.join(", ")} ${unknown.length === 1 ? "is" : "are"} not legal; legal top-level fields are diagnosis, reproduction, and evidence`
530
1017
  );
531
1018
  }
1019
+ if (!string(value.diagnosis)) {
1020
+ return failure(contract, "unmeasured", 'Debugger field "diagnosis" must be a non-empty string');
1021
+ }
1022
+ if (value.reproduction !== "reproduced" && value.reproduction !== "not-reproduced" && value.reproduction !== "unknown") {
1023
+ return failure(
1024
+ contract,
1025
+ "unmeasured",
1026
+ 'Debugger field "reproduction" must be one of: reproduced | not-reproduced | unknown'
1027
+ );
1028
+ }
1029
+ if (!Array.isArray(value.evidence)) {
1030
+ return failure(contract, "unmeasured", 'Debugger field "evidence" must be an array of strings');
1031
+ }
1032
+ const malformedEvidence = value.evidence.findIndex((entry) => !string(entry));
1033
+ if (malformedEvidence >= 0) {
1034
+ return failure(contract, "unmeasured", `Debugger field "evidence[${malformedEvidence}]" must be a non-empty string`);
1035
+ }
532
1036
  return success(contract, "unmeasured", value);
533
1037
  }
534
1038
  function validateResearch(contract, output, networkAllowed) {
535
1039
  const parsed = parseJson(output);
536
- if (!parsed.ok) return failure(contract, "unmeasured", parsed.reason);
1040
+ if (!parsed.ok) return failure(contract, "unmeasured", `Research result payload failed: ${parsed.reason}`);
537
1041
  const value = parsed.value;
538
- if (!hasOnlyKeys(value, ["source", "findings"]) || value.source !== "local" && value.source !== "external" || !Array.isArray(value.findings)) {
1042
+ const unknown = Object.keys(value).filter((key) => key !== "source" && key !== "findings");
1043
+ if (unknown.length > 0) {
539
1044
  return failure(
540
1045
  contract,
541
1046
  "unmeasured",
542
- "Research result must distinguish local or external sources and carry findings"
1047
+ `Research result field${unknown.length === 1 ? "" : "s"} ${unknown.join(", ")} ${unknown.length === 1 ? "is" : "are"} not legal; legal top-level fields are source and findings`
543
1048
  );
544
1049
  }
1050
+ if (value.source !== "local" && value.source !== "external") {
1051
+ return failure(contract, "unmeasured", 'Research field "source" must be one of: local | external');
1052
+ }
1053
+ if (!Array.isArray(value.findings)) {
1054
+ return failure(contract, "unmeasured", 'Research field "findings" must be an array of {claim, evidence} objects');
1055
+ }
545
1056
  if (value.source === "external" && !networkAllowed) {
546
- return failure(contract, "unmeasured", "external research requires an allowed network posture");
1057
+ return failure(
1058
+ contract,
1059
+ "unmeasured",
1060
+ 'Research field "source" is external but the run has no allowed network posture; legal values are local | external, and use local for workspace-only evidence'
1061
+ );
547
1062
  }
548
- for (const finding of value.findings) {
1063
+ for (const [index, finding] of value.findings.entries()) {
549
1064
  if (finding === null || typeof finding !== "object" || Array.isArray(finding)) {
550
- return failure(contract, "unmeasured", "Research findings must be objects");
1065
+ return failure(contract, "unmeasured", `Research field "findings[${index}]" must be an object`);
551
1066
  }
552
1067
  const record = finding;
553
- if (!hasOnlyKeys(record, ["claim", "evidence"]) || !string(record.claim) || !string(record.evidence)) {
554
- return failure(contract, "unmeasured", "Research findings must carry claim and evidence");
1068
+ const findingUnknown = Object.keys(record).filter((key) => key !== "claim" && key !== "evidence");
1069
+ if (findingUnknown.length > 0) {
1070
+ return failure(
1071
+ contract,
1072
+ "unmeasured",
1073
+ `Research field "findings[${index}].${findingUnknown[0]}" is not legal; legal finding fields are claim and evidence`
1074
+ );
1075
+ }
1076
+ if (!string(record.claim)) {
1077
+ return failure(contract, "unmeasured", `Research field "findings[${index}].claim" must be a non-empty string`);
1078
+ }
1079
+ if (!string(record.evidence)) {
1080
+ return failure(contract, "unmeasured", `Research field "findings[${index}].evidence" must be a non-empty string`);
555
1081
  }
556
1082
  }
557
1083
  return success(contract, "unmeasured", value);
558
1084
  }
559
1085
  function describeWriteSet(effects, cwd) {
560
1086
  if (effects.mutatedPaths.size === 0) return "this run wrote nothing";
561
- const written = [...effects.mutatedPaths].map((target) => path.relative(cwd, target) || target).sort().slice(0, MUTATION_WRITE_SET_REASON_LIMIT);
1087
+ const written = [...effects.mutatedPaths].map((target) => path2.relative(cwd, target) || target).sort().slice(0, MUTATION_WRITE_SET_REASON_LIMIT);
562
1088
  const more = effects.mutatedPaths.size - written.length;
563
1089
  return `this run wrote ${written.join(", ")}${more > 0 ? ` (+${more} more)` : ""}`;
564
1090
  }
@@ -589,10 +1115,10 @@ function validateMutation(contract, input) {
589
1115
  const reportedFailure = !validations.every((check) => check.passed);
590
1116
  const effects = input.observedRunEffects;
591
1117
  if (effects === void 0) return success(contract, reportedFailure ? "fail" : "pass", value);
592
- const cwd = path.resolve(input.cwd);
1118
+ const cwd = path2.resolve(input.cwd);
593
1119
  let unverifiedMutation = false;
594
1120
  for (const reported of value.mutatedPaths) {
595
- const target = path.resolve(cwd, reported);
1121
+ const target = path2.resolve(cwd, reported);
596
1122
  if (effects.mutatedPaths.has(target)) continue;
597
1123
  if (effects.failedMutationPaths.has(target)) {
598
1124
  return failure(
@@ -631,14 +1157,14 @@ function validateProvenance(contract, output) {
631
1157
  return success(contract, "unmeasured", value);
632
1158
  }
633
1159
  function validateArchitect(contract, input) {
634
- const artifactPath = path.resolve(input.cwd, contract.path);
1160
+ const artifactPath = path2.resolve(input.cwd, contract.path);
635
1161
  const content = input.filesystem.readFile(artifactPath);
636
1162
  if (content === null || content.trim().length === 0) {
637
1163
  return failure(contract, "unmeasured", `required plan artifact is missing or empty: ${contract.path}`);
638
1164
  }
639
1165
  return success(contract, "unmeasured", {
640
1166
  path: contract.path,
641
- artifactDigest: createHash("sha256").update(content, "utf8").digest("hex")
1167
+ artifactDigest: createHash2("sha256").update(content, "utf8").digest("hex")
642
1168
  });
643
1169
  }
644
1170
  function parseScoutResult(output) {
@@ -742,15 +1268,15 @@ function resultContractShape(contract) {
742
1268
  case "scout-report":
743
1269
  return '{"findings":[{"claim":"what you observed","path":"src/file.ts","line":1}],"needsSplit":false,"proposedSubtasks":[]} or {"findings":[],"needsSplit":true,"proposedSubtasks":[{"id":"inspect","task":"Inspect the boundary","dependencies":[],"expectedResultContract":"scout-report","requestedAuthority":"read-only"}]} or, if you cannot produce a citation you are sure of, at least {"findings":[{"claim":"what you observed"}]}, which is accepted as an ungrounded lead rather than losing the run';
744
1270
  case "verifier-report":
745
- return '{"verdict":"pass","checks":[{"name":"npm run typecheck","passed":true,"evidence":"exit 0"}]}';
1271
+ return 'one of {"verdict":"pass","checks":[{"name":"npm run typecheck","passed":true,"evidence":"exit 0"}]} or {"verdict":"fail","checks":[{"name":"npm run typecheck","passed":false,"evidence":"exit 1"}]}; verdict legal values are pass | fail and checks[].passed legal values are true | false';
746
1272
  case "council-report":
747
1273
  return '{"members":[{"label":"alpha","runId":"run-1","round":1,"answer":"..."}],"synthesis":{"kind":"none"}}';
748
1274
  case "council-ballot":
749
1275
  return COUNCIL_BALLOT_SHAPE;
750
1276
  case "debugger-report":
751
- return '{"diagnosis":"...","reproduction":"reproduced","evidence":["..."]}';
1277
+ return 'one of {"diagnosis":"...","reproduction":"reproduced","evidence":["..."]}, {"diagnosis":"...","reproduction":"not-reproduced","evidence":["..."]}, or {"diagnosis":"...","reproduction":"unknown","evidence":["..."]}; reproduction legal values are reproduced | not-reproduced | unknown';
752
1278
  case "research-report":
753
- return '{"source":"local","findings":[{"claim":"...","evidence":"..."}]}';
1279
+ return 'one of {"source":"local","findings":[{"claim":"...","evidence":"..."}]} or {"source":"external","findings":[{"claim":"...","evidence":"..."}]}; source legal values are local | external';
754
1280
  case "mutation-report":
755
1281
  return '{"mutatedPaths":["src/file.ts"],"validations":[{"name":"npm test","passed":true,"evidence":"exit 0"}],"commitMessage":"optional: the commit message for this change","summary":"optional: one line"}';
756
1282
  case "provenance-report":
@@ -844,7 +1370,7 @@ function parseContract(value, sourcePath, kinds) {
844
1370
  if (!only("kind", "path") || !string(record.path)) {
845
1371
  throw new Error(`agent recipe: ${sourcePath}: architect-plan requires only non-empty path`);
846
1372
  }
847
- if (path.isAbsolute(record.path) || record.path.split(/[\\/]/u).includes("..")) {
1373
+ if (path2.isAbsolute(record.path) || record.path.split(/[\\/]/u).includes("..")) {
848
1374
  throw new Error(`agent recipe: ${sourcePath}: architect-plan path must be workspace-relative`);
849
1375
  }
850
1376
  return { kind: "architect-plan", path: record.path };
@@ -861,80 +1387,22 @@ function parseWorkerResultContract(value, sourcePath) {
861
1387
  return parseContract(value, sourcePath, [...RECIPE_DECLARABLE_KINDS, ...COORDINATOR_AUTHORED_KINDS]);
862
1388
  }
863
1389
 
864
- // src/core/path-boundary.ts
865
- init_esm_shims();
866
- import path2 from "node:path";
867
- var PATH_BOUNDARY_MAX_ENTRIES = 32;
868
- var PathBoundaryError = class extends Error {
869
- code;
870
- constructor(code, message) {
871
- super(message);
872
- this.name = "PathBoundaryError";
873
- this.code = code;
874
- }
875
- };
876
- var GLOB_CHARACTERS = /[*?[\]{}]/u;
877
- function normalizePathBoundaryEntry(entry) {
878
- const raw = entry.trim();
879
- if (raw.length === 0) throw new PathBoundaryError("empty", "write boundary: entry must be a non-empty path");
880
- if (raw.includes("\\")) {
881
- throw new PathBoundaryError("separator", `write boundary: entry '${entry}' must use '/' separators`);
882
- }
883
- if (GLOB_CHARACTERS.test(raw)) {
884
- throw new PathBoundaryError("glob", `write boundary: entry '${entry}' looks like a glob, which v1 does not support`);
885
- }
886
- if (raw.startsWith("/") || /^[A-Za-z]:/u.test(raw)) {
887
- throw new PathBoundaryError("absolute", `write boundary: entry '${entry}' must be repository-relative, not absolute`);
888
- }
889
- const subtree = raw.endsWith("/");
890
- const segments = raw.split("/").filter((segment) => segment.length > 0);
891
- if (segments.length === 0) {
892
- throw new PathBoundaryError("empty", `write boundary: entry '${entry}' must name a path inside the repository`);
893
- }
894
- for (const segment of segments) {
895
- if (segment === "..") {
896
- throw new PathBoundaryError("parent", `write boundary: entry '${entry}' must not contain '..'`);
897
- }
898
- if (segment === ".") {
899
- throw new PathBoundaryError("dot", `write boundary: entry '${entry}' must not contain '.' segments`);
900
- }
901
- }
902
- const joined = segments.join("/");
903
- return subtree ? `${joined}/` : joined;
904
- }
905
- function normalizePathBoundary(entries) {
906
- if (entries.length > PATH_BOUNDARY_MAX_ENTRIES) {
907
- throw new Error(`write boundary: at most ${PATH_BOUNDARY_MAX_ENTRIES} entries may be declared`);
908
- }
909
- return [...new Set(entries.map(normalizePathBoundaryEntry))].sort();
910
- }
911
- function toPosixBoundaryPath(value) {
912
- return value.split("\\").join("/");
913
- }
914
- function isDirectoryPathBoundary(entry) {
915
- return toPosixBoundaryPath(entry).endsWith("/");
916
- }
917
- function asDirectoryPathBoundary(entry) {
918
- const normalized = toPosixBoundaryPath(entry);
919
- return normalized.endsWith("/") ? normalized : `${normalized}/`;
920
- }
921
- function resolvePathBoundary(cwd, entry) {
922
- const directory = isDirectoryPathBoundary(entry);
923
- const withoutMarker = directory ? entry.slice(0, -1) : entry;
924
- const resolved = toPosixBoundaryPath(path2.resolve(cwd, withoutMarker));
925
- return directory ? asDirectoryPathBoundary(resolved) : resolved;
926
- }
927
- function pathBoundaryEntryCovers(outer, inner) {
928
- const normalizedOuter = toPosixBoundaryPath(outer);
929
- const normalizedInner = toPosixBoundaryPath(inner);
930
- return normalizedOuter.endsWith("/") ? normalizedInner.startsWith(normalizedOuter) : !normalizedInner.endsWith("/") && normalizedInner === normalizedOuter;
931
- }
932
- function pathBoundaryCovers(boundary, candidate) {
933
- return boundary.some((entry) => pathBoundaryEntryCovers(entry, candidate));
934
- }
935
-
936
1390
  export {
937
1391
  parseJsonObjectPayload,
1392
+ classify,
1393
+ AGENT_AUTOMATION_AUTHORITIES,
1394
+ isAgentCategory,
1395
+ isAgentCapabilityClass,
1396
+ isAgentLatencyClass,
1397
+ isAgentAudience,
1398
+ isAgentProjectContextTier,
1399
+ isAgentProduct,
1400
+ resolveAgentToolCompatibility,
1401
+ normalizeAgentSpec,
1402
+ agentSpecFingerprint,
1403
+ isUserVisibleAgent,
1404
+ isShadowAgent,
1405
+ assertAgentSpecPolicy,
938
1406
  COUNCIL_BALLOT_VERDICT_MAX_BYTES,
939
1407
  COUNCIL_BALLOT_SHAPE,
940
1408
  parseCouncilReport,
@@ -946,16 +1414,9 @@ export {
946
1414
  validateResultContract,
947
1415
  validateRecipeResult,
948
1416
  RESULT_CONTRACT_REPAIR_LIMIT,
1417
+ resultContractShape,
949
1418
  resultContractRepairMessages,
950
1419
  parseResultContract,
951
- parseWorkerResultContract,
952
- PATH_BOUNDARY_MAX_ENTRIES,
953
- PathBoundaryError,
954
- normalizePathBoundaryEntry,
955
- normalizePathBoundary,
956
- asDirectoryPathBoundary,
957
- resolvePathBoundary,
958
- pathBoundaryEntryCovers,
959
- pathBoundaryCovers
1420
+ parseWorkerResultContract
960
1421
  };
961
- //# sourceMappingURL=chunk-TTHACPOM.js.map
1422
+ //# sourceMappingURL=chunk-DYJP44XW.js.map