@iowarp/clio-coder 0.3.9 → 0.4.1

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 (733) hide show
  1. package/CHANGELOG.md +92 -0
  2. package/NOTICE +33 -0
  3. package/README.md +121 -16
  4. package/dist/{acp-7LOELQFP.js → acp-ZILU3AUO.js} +19 -18
  5. package/dist/{agents-FIBG2SHA.js → agents-HYWGBGQR.js} +53 -39
  6. package/dist/assets/codewiki.json +1 -1
  7. package/dist/{auth-OI4LIH2I.js → auth-N3QT7CBO.js} +24 -21
  8. package/dist/{builtins-AD25UL3C.js → builtins-UJLMOVOV.js} +6 -6
  9. package/dist/{chunk-I4HZDVNP.js → chunk-2LEAKD4C.js} +2 -3
  10. package/dist/{chunk-465CC7FK.js → chunk-2NM363SV.js} +60 -64
  11. package/dist/{chunk-4H6ULJ3H.js → chunk-2VG7KLYV.js} +1046 -1370
  12. package/dist/{chunk-SST6Z5JA.js → chunk-336NSSKI.js} +1 -1
  13. package/dist/{chunk-NZU6YDNV.js → chunk-3I5NY75V.js} +5 -5
  14. package/dist/{chunk-47CMYGET.js → chunk-3QSOM6PA.js} +2 -2
  15. package/dist/chunk-42FMPA75.js +101 -0
  16. package/dist/{chunk-HAY4ZE2P.js → chunk-5PSMVOLM.js} +2 -2
  17. package/dist/{chunk-IHKBWSXF.js → chunk-5QIAJV2D.js} +3 -3
  18. package/dist/chunk-5YHDIDBP.js +97 -0
  19. package/dist/chunk-6CCS4G3W.js +1529 -0
  20. package/dist/{chunk-2JDWVJND.js → chunk-6DWBAZ5U.js} +2 -2
  21. package/dist/{chunk-BVDVID7E.js → chunk-6FN3E6KX.js} +6 -6
  22. package/dist/{chunk-DG4M6ZUE.js → chunk-6HMJX2VU.js} +59 -59
  23. package/dist/{chunk-3MRC2YSQ.js → chunk-6I5ILFOF.js} +3 -2
  24. package/dist/chunk-6NJQITNH.js +1412 -0
  25. package/dist/chunk-6VC4OV3Z.js +365 -0
  26. package/dist/{chunk-LU7P4LHA.js → chunk-72GZI5EV.js} +2 -2
  27. package/dist/{chunk-5T7RBWN2.js → chunk-74YWRRU5.js} +9 -8
  28. package/dist/{chunk-VPTUJU4P.js → chunk-7EPLI7VL.js} +2 -2
  29. package/dist/{chunk-CA42X6KT.js → chunk-7OBGU7UB.js} +7 -7
  30. package/dist/{chunk-56KB5IJP.js → chunk-7PWAODYW.js} +3 -3
  31. package/dist/chunk-7RY5VZPH.js +573 -0
  32. package/dist/{chunk-OEDBCISO.js → chunk-ABLSQ6JX.js} +3 -3
  33. package/dist/{chunk-5HFBWUMU.js → chunk-AFKWHWXF.js} +13 -23
  34. package/dist/{chunk-FWDFM5ZU.js → chunk-AK5XEFVZ.js} +3 -3
  35. package/dist/{chunk-WXCJ7VME.js → chunk-AKB4GYDL.js} +7 -7
  36. package/dist/chunk-AP73CFDC.js +308 -0
  37. package/dist/{chunk-4LJX2PUC.js → chunk-BBTJOK6Y.js} +5 -5
  38. package/dist/{chunk-QQ7EKM72.js → chunk-BDPT6GTK.js} +13 -61
  39. package/dist/chunk-BJGUKIG4.js +302 -0
  40. package/dist/chunk-BMS5RKQY.js +27 -0
  41. package/dist/{chunk-TD7UE2L5.js → chunk-BTGG6BG2.js} +81 -40
  42. package/dist/chunk-BTK3SSSK.js +67 -0
  43. package/dist/{chunk-M6L6IDJG.js → chunk-BWH6N36D.js} +1 -1
  44. package/dist/chunk-BWW4HLO4.js +301 -0
  45. package/dist/{chunk-BNAZZHFG.js → chunk-BYP5D4HI.js} +1 -1
  46. package/dist/{chunk-HJB5IUKP.js → chunk-C537JADH.js} +18 -18
  47. package/dist/{chunk-774ILSRL.js → chunk-CDNVLKUX.js} +5 -4
  48. package/dist/{chunk-HPCTNZM2.js → chunk-CTJ4RNAA.js} +4 -4
  49. package/dist/{chunk-AEYBF3TB.js → chunk-CWVRRIEI.js} +2 -2
  50. package/dist/chunk-D4CJV46V.js +462 -0
  51. package/dist/chunk-D7E7WCDF.js +27 -0
  52. package/dist/{chunk-5PVQ4SRS.js → chunk-E67WX76H.js} +10 -126
  53. package/dist/{chunk-FQ4SKYE4.js → chunk-EBY63B7G.js} +2 -5
  54. package/dist/chunk-EIMVLWB3.js +1842 -0
  55. package/dist/{chunk-AMKHQW3C.js → chunk-FEFIFZTL.js} +3 -3
  56. package/dist/{chunk-RAPCMZL4.js → chunk-FSP7CMNU.js} +9 -1
  57. package/dist/{chunk-3DUR4WUA.js → chunk-FYUN5KZ3.js} +25 -25
  58. package/dist/{chunk-MV3K5QF2.js → chunk-GCSMB2KY.js} +2 -2
  59. package/dist/chunk-GIZNH63R.js +40 -0
  60. package/dist/chunk-GPPB3JBE.js +688 -0
  61. package/dist/{chunk-B5XRQOLB.js → chunk-GVQJ5CCZ.js} +17 -11
  62. package/dist/chunk-HHV2GANA.js +88 -0
  63. package/dist/chunk-HJWWJ6IL.js +184 -0
  64. package/dist/{chunk-RKRLDWD3.js → chunk-HLW2MRKE.js} +1 -1
  65. package/dist/chunk-HRQMFLJP.js +75 -0
  66. package/dist/{chunk-AD7Y7STJ.js → chunk-HUAS7ITX.js} +107 -97
  67. package/dist/{chunk-O6I4CIEU.js → chunk-I66EAJFY.js} +6 -6
  68. package/dist/{chunk-S4COXYBG.js → chunk-IG7BCQBA.js} +129 -106
  69. package/dist/{chunk-N3PBVRTZ.js → chunk-IXJT6DCX.js} +9 -7
  70. package/dist/chunk-J4HBWF6Y.js +2635 -0
  71. package/dist/chunk-J5LZHVIT.js +284 -0
  72. package/dist/{chunk-GAYUJ7LE.js → chunk-JA5QWE4Z.js} +544 -227
  73. package/dist/{chunk-B5CSFE7B.js → chunk-JIEGK6UF.js} +6 -174
  74. package/dist/{chunk-VKBMFOYV.js → chunk-JZWT5J3Y.js} +23 -27
  75. package/dist/chunk-K6BF4U2H.js +1785 -0
  76. package/dist/{chunk-CGKSTWHD.js → chunk-K6BSR66V.js} +2 -1
  77. package/dist/{chunk-YSEHGPCT.js → chunk-MA3H6DM5.js} +6 -6
  78. package/dist/{chunk-EBOC7MT3.js → chunk-MOPSG2X7.js} +9 -9
  79. package/dist/{chunk-KV2AOLDF.js → chunk-MQXIVJ35.js} +18 -29
  80. package/dist/{chunk-P3JGPQFL.js → chunk-N5UK64DP.js} +4 -4
  81. package/dist/chunk-NDDGJUXD.js +81 -0
  82. package/dist/chunk-NEKRRTYW.js +56 -0
  83. package/dist/{chunk-4ZG3XFUR.js → chunk-NLFAQR7Z.js} +12 -1
  84. package/dist/{chunk-VO2LKSTM.js → chunk-O42A54GG.js} +2 -2
  85. package/dist/{chunk-T3Z6VAAF.js → chunk-OJTRZGR3.js} +53 -92
  86. package/dist/{chunk-5DQRIYDZ.js → chunk-PBP4B7XR.js} +3 -3
  87. package/dist/{chunk-NQ6UCCOD.js → chunk-PJJ6MY27.js} +8 -8
  88. package/dist/chunk-PMZCIOCJ.js +25 -0
  89. package/dist/{chunk-ZGVHUX3M.js → chunk-PMZVFWSR.js} +2 -2
  90. package/dist/{chunk-7C6RYZGQ.js → chunk-PVAMAVBB.js} +5 -4
  91. package/dist/chunk-QDC3K2U3.js +262 -0
  92. package/dist/{chunk-JEQQR47K.js → chunk-QKIFBZKT.js} +173 -14
  93. package/dist/{chunk-R7LNVMCS.js → chunk-QMXC4JB7.js} +70 -78
  94. package/dist/chunk-QSNYB6ZV.js +195 -0
  95. package/dist/chunk-QTFGO774.js +644 -0
  96. package/dist/{chunk-ODFEOB4F.js → chunk-R23Z6K6I.js} +27 -9
  97. package/dist/{chunk-3UUY7R3Z.js → chunk-R32CLGZ6.js} +14 -14
  98. package/dist/chunk-R346GLFC.js +31 -0
  99. package/dist/chunk-RKSR6VSF.js +132 -0
  100. package/dist/{chunk-N5XKWMDW.js → chunk-SCYB3HA4.js} +73 -27
  101. package/dist/{chunk-PZ4I4JE2.js → chunk-SINK3QR6.js} +135 -125
  102. package/dist/{chunk-5QKCQQ3E.js → chunk-SUW5DORT.js} +2 -2
  103. package/dist/chunk-T56WDKA5.js +183 -0
  104. package/dist/{chunk-ECUO3KDP.js → chunk-TD3PGPQA.js} +87 -26
  105. package/dist/{chunk-HKO36JWF.js → chunk-THYWACCR.js} +31 -3
  106. package/dist/{chunk-LXPJXFM5.js → chunk-TVH4ONAM.js} +18 -12
  107. package/dist/chunk-TVHHYFHE.js +255 -0
  108. package/dist/chunk-U2WB7TZS.js +271 -0
  109. package/dist/{chunk-NNNWO6F2.js → chunk-UAPGZHYC.js} +237 -33
  110. package/dist/{chunk-MIX5N5AC.js → chunk-UEDMSP56.js} +415 -160
  111. package/dist/{chunk-WIE7ZOSW.js → chunk-UXN6JT4W.js} +3 -3
  112. package/dist/{chunk-CMZWFGD2.js → chunk-VAVR4IJY.js} +19 -15
  113. package/dist/{chunk-MV2VUEJC.js → chunk-VEGN6WIQ.js} +2 -2
  114. package/dist/chunk-VKFQTNDV.js +66 -0
  115. package/dist/{chunk-FALJGAWU.js → chunk-VKRH2TCS.js} +2 -2
  116. package/dist/{chunk-A2NJGIB3.js → chunk-VN3SHNBN.js} +2 -2
  117. package/dist/{chunk-XK56QHLX.js → chunk-VPKWYKEY.js} +19 -5
  118. package/dist/{chunk-UOSL25KY.js → chunk-VXMFAE2W.js} +1 -1
  119. package/dist/{chunk-EQ63NRB7.js → chunk-WNP7O5WZ.js} +3 -3
  120. package/dist/chunk-WR6U3OVP.js +45 -0
  121. package/dist/{chunk-TEO2TLVN.js → chunk-XKA2ICR3.js} +1051 -1196
  122. package/dist/{chunk-3V5AYSEQ.js → chunk-Y45G3AXC.js} +72 -65
  123. package/dist/{chunk-J5Q24KAG.js → chunk-Y4CAGMM6.js} +2 -2
  124. package/dist/chunk-YAKGTXEV.js +17 -0
  125. package/dist/{chunk-ZI647VB5.js → chunk-YPI3QQCF.js} +2 -2
  126. package/dist/{chunk-YW7UVM5V.js → chunk-ZAZB4JMW.js} +55 -11
  127. package/dist/{chunk-HCBCAYZU.js → chunk-ZJLUDYFY.js} +11 -11
  128. package/dist/{chunk-HKIYEGME.js → chunk-ZTJUVLTU.js} +2 -2
  129. package/dist/{chunk-IFBNV6H6.js → chunk-ZW55JB7N.js} +3 -3
  130. package/dist/cli/index.js +48 -37
  131. package/dist/clio-IT3G3VQH.js +25 -0
  132. package/dist/{code-nav-LMW275PA.js → code-nav-RK6S7F6E.js} +8 -8
  133. package/dist/codewiki/build-worker.js +1 -1
  134. package/dist/{compile-cache-CVJMMODC.js → compile-cache-OQAVB7Y5.js} +3 -5
  135. package/dist/{components-ZFA3SAER.js → components-UBWCQSRW.js} +6 -6
  136. package/dist/{config-RXS5T3JT.js → config-3QZRWZJF.js} +73 -61
  137. package/dist/configure-FL7Y3KJF.js +54 -0
  138. package/dist/{context-MVOORGMF.js → context-5HE7ODYK.js} +61 -49
  139. package/dist/{context-I3BTOTCS.js → context-KYQFRVDC.js} +11 -11
  140. package/dist/{context-PALKKQYL.js → context-XNHL75JV.js} +43 -28
  141. package/dist/{context-clear-N2WOYZ2K.js → context-clear-N545L53A.js} +60 -48
  142. package/dist/{context-working-set-MIEVECVZ.js → context-working-set-QHKXSV2F.js} +15 -13
  143. package/dist/{dispatch-runner-VVA4SRRH.js → dispatch-runner-RGIE5PCT.js} +109 -72
  144. package/dist/{docs-7LQ23DLM.js → docs-5NAF6AU7.js} +7 -13
  145. package/dist/doctor-ZGPEGHIP.js +772 -0
  146. package/dist/{eval-IJ5VEZDJ.js → eval-GXLL44RD.js} +106 -86
  147. package/dist/eval-inventory-HBWSWQOK.js +315 -0
  148. package/dist/{evidence-L5APPXNV.js → evidence-HWLBRH3Q.js} +209 -51
  149. package/dist/{evolve-RGNKFJ52.js → evolve-FTZBMNVW.js} +57 -45
  150. package/dist/{extensions-7WYWUX5A.js → extensions-VHRBEID7.js} +7 -7
  151. package/dist/{fleet-6CNVBZZP.js → fleet-CKZHJWZJ.js} +215 -114
  152. package/dist/{fleet-commands-L2SXSYEI.js → fleet-commands-EXDXBMV6.js} +13 -12
  153. package/dist/fleet-decisions-OTHB6KRL.js +157 -0
  154. package/dist/{fleet-graph-2J3OOIPO.js → fleet-graph-YTEZUCUT.js} +20 -17
  155. package/dist/fleet-inspect-SS6YMDCK.js +445 -0
  156. package/dist/{fleet-preflight-CZRJ4JP5.js → fleet-preflight-PBY4VYOM.js} +6 -9
  157. package/dist/{fleet-validate-C5RI6DP7.js → fleet-validate-KMEM5L3S.js} +25 -20
  158. package/dist/fleet-verify-QD5M7E7Q.js +178 -0
  159. package/dist/fleet-view-WAMJYNDT.js +94 -0
  160. package/dist/{init-VBN2ACVA.js → init-5XQRBOFV.js} +79 -66
  161. package/dist/install-NKNG7KD4.js +13 -0
  162. package/dist/interop-34TVO25M.js +116 -0
  163. package/dist/{library-JHGUMLY2.js → library-3QY6KF57.js} +25 -21
  164. package/dist/{memory-K4OQIYWG.js → memory-L4UTIIIW.js} +59 -47
  165. package/dist/{models-2NCZUWDD.js → models-ZVX3QOWE.js} +47 -37
  166. package/dist/{monitor-MMVTJABD.js → monitor-CEKVSYTS.js} +67 -57
  167. package/dist/{orchestrator-ZKBPCHW6.js → orchestrator-77BAP6BC.js} +7633 -7699
  168. package/dist/panes-7STHOAUJ.js +103 -0
  169. package/dist/panes-SHAUIRXY.js +60 -0
  170. package/dist/{paths-DBXMZMDU.js → paths-L7LGY6RN.js} +6 -6
  171. package/dist/{reset-DD5JGOY3.js → reset-EOLM7GVE.js} +15 -14
  172. package/dist/resources-74GKTLSF.js +115 -0
  173. package/dist/{run-QEGNX7FL.js → run-HBAUJNNZ.js} +139 -98
  174. package/dist/{share-JKD3BQMW.js → share-G3APVLVP.js} +25 -21
  175. package/dist/{skills-LMQIKDOZ.js → skills-35HHUKCR.js} +37 -27
  176. package/dist/{skills-eval-I7X2774U.js → skills-eval-QN4HSHDC.js} +80 -73
  177. package/dist/skills-inventory-J357J34F.js +129 -0
  178. package/dist/slash-commands-JZZCQA32.js +79 -0
  179. package/dist/{steer-CF5TDANS.js → steer-XAVHJM22.js} +4 -4
  180. package/dist/{support-I7LOJLIF.js → support-U7QOWY26.js} +7 -7
  181. package/dist/{targets-RUSR6B5Z.js → targets-DSM6CY3M.js} +67 -59
  182. package/dist/{terminal-lease-QYVORFR4.js → terminal-lease-JOPFUVEM.js} +15 -10
  183. package/dist/tools-MKNWVPBH.js +29 -0
  184. package/dist/{trace-ODOQIVIW.js → trace-ECQ7TIYZ.js} +194 -7
  185. package/dist/tui-primitives-K5PASC3O.js +17 -0
  186. package/dist/{uninstall-ZJF5H5ZN.js → uninstall-N34PCTGJ.js} +6 -8
  187. package/dist/{upgrade-XANW3FXB.js → upgrade-H7TOM7YL.js} +37 -62
  188. package/dist/{usage-4H7ZRXQT.js → usage-X52N3IDJ.js} +70 -59
  189. package/dist/{verifiers-UZXNBZEB.js → verifiers-EJTVVSMA.js} +174 -14
  190. package/dist/{verify-BVKWTNDL.js → verify-YJL6XET2.js} +12 -11
  191. package/dist/{web-fetch-2YHJ3KTG.js → web-fetch-MPIFL3LL.js} +3 -4
  192. package/dist/{wiki-generate-MY7WV2QI.js → wiki-generate-4NDZTQ4B.js} +86 -75
  193. package/dist/with-panes-OBOBFIIR.js +818 -0
  194. package/dist/worker/entry.js +131 -91
  195. package/docs/README.md +3 -2
  196. package/docs/acp.md +25 -4
  197. package/docs/alcf-provider.md +1 -1
  198. package/docs/architecture.md +2 -2
  199. package/docs/artifact-versions.md +4 -1
  200. package/docs/built-in-agents.md +40 -32
  201. package/docs/capacity-and-scheduling.md +43 -5
  202. package/docs/commands-and-modes.md +39 -4
  203. package/docs/config-knobs-audit.md +3 -0
  204. package/docs/configuration-and-targets.md +138 -167
  205. package/docs/context-engine.md +1 -1
  206. package/docs/development-pipeline.md +19 -0
  207. package/docs/dispatch-typed-intent.md +385 -0
  208. package/docs/documentation-coverage.md +2 -2
  209. package/docs/documentation-guide.md +1 -1
  210. package/docs/environment-variables.md +3 -1
  211. package/docs/eval-runner.md +1 -1
  212. package/docs/evals-internal.md +1 -1
  213. package/docs/evidence-and-memory.md +2 -2
  214. package/docs/evolution.md +1 -1
  215. package/docs/exit-codes-and-output.md +3 -1
  216. package/docs/extensions-and-sharing.md +25 -1
  217. package/docs/fleet-demo-runbook.md +6 -3
  218. package/docs/fleet-dispatch.md +30 -7
  219. package/docs/installation-and-lifecycle.md +16 -3
  220. package/docs/middleware-and-components.md +1 -1
  221. package/docs/model-catalog.md +10 -1
  222. package/docs/observability.md +3 -3
  223. package/docs/proactive-memory.md +1 -1
  224. package/docs/prompt-envelope-and-tools.md +1 -1
  225. package/docs/provider-adapter-cookbook.md +1 -1
  226. package/docs/release-cut-checklist.md +164 -177
  227. package/docs/safety-model.md +2 -2
  228. package/docs/scientific-validation.md +3 -3
  229. package/docs/session-lifecycle.md +1 -1
  230. package/docs/skills-marketplace.md +1 -1
  231. package/docs/tool-usage.md +18 -8
  232. package/docs/trace-store.md +16 -11
  233. package/docs/troubleshooting.md +2 -2
  234. package/docs/tui-design.md +1 -1
  235. package/docs/worker-dispatch-mechanics.md +1 -1
  236. package/evals/README.md +5 -0
  237. package/evals/behavioral-corpus-grader.mjs +103 -0
  238. package/evals/behavioral-machinery-baseline.json +2276 -0
  239. package/evals/behavioral-machinery-driver.ts +250 -0
  240. package/evals/behavioral-machinery-support.ts +253 -0
  241. package/evals/behavioral-machinery.yaml +614 -0
  242. package/evals/behavioral-model-negative-control.yaml +68 -0
  243. package/evals/behavioral-model.yaml +216 -0
  244. package/evals/fixtures/behavioral-facts.txt +3 -0
  245. package/evals/fixtures/behavioral-main.ts +7 -0
  246. package/evals/fixtures/decoy/note.txt +2 -0
  247. package/evals/fixtures/private/credentials.txt +1 -0
  248. package/evals/tracked-metrics-baseline.yaml +229 -0
  249. package/evals/tracked-metrics-grader.mjs +129 -0
  250. package/package.json +8 -16
  251. package/skills/README.md +6 -6
  252. package/skills/coding/ast-grep/SKILL.md +8 -2
  253. package/skills/coding/coding-standards/SKILL.md +8 -2
  254. package/skills/coding/prototype/SKILL.md +8 -2
  255. package/skills/coding/tdd/SKILL.md +8 -2
  256. package/skills/context/context-handoff/SKILL.md +12 -3
  257. package/skills/context/context-handoff/evals.md +3 -3
  258. package/skills/context/context-prime/SKILL.md +8 -2
  259. package/skills/context/context-prime/evals.md +2 -2
  260. package/skills/git/file-ticket/SKILL.md +9 -4
  261. package/skills/git/file-ticket/evals.md +2 -2
  262. package/skills/git/fix-issue/SKILL.md +12 -5
  263. package/skills/git/fix-issue/evals.md +4 -4
  264. package/skills/git/resolve-merge-conflicts/SKILL.md +8 -2
  265. package/skills/git/resolve-merge-conflicts/evals.md +2 -2
  266. package/skills/git/ship/SKILL.md +9 -3
  267. package/skills/git/ship/evals.md +4 -4
  268. package/skills/git/worktree-create/SKILL.md +7 -2
  269. package/skills/git/worktree-create/evals.md +6 -6
  270. package/skills/git/worktree-merge/SKILL.md +7 -2
  271. package/skills/git/worktree-merge/evals.md +6 -6
  272. package/skills/meta/{clio-dev → clio-coder-dev}/SKILL.md +14 -8
  273. package/skills/meta/{clio-dev → clio-coder-dev}/evals.md +3 -3
  274. package/skills/meta/{clio-test → clio-coder-test}/SKILL.md +11 -5
  275. package/skills/meta/{clio-test → clio-coder-test}/evals.md +1 -1
  276. package/skills/meta/credentials/SKILL.md +9 -2
  277. package/skills/meta/find-skills/SKILL.md +8 -2
  278. package/skills/meta/herdr/SKILL.md +8 -2
  279. package/skills/meta/skill-craft/SKILL.md +21 -4
  280. package/skills/planning/architecture/SKILL.md +9 -3
  281. package/skills/planning/backlog/SKILL.md +8 -2
  282. package/skills/planning/prd/SKILL.md +8 -2
  283. package/skills/planning/product-intent/SKILL.md +8 -2
  284. package/skills/planning/tech-spec/SKILL.md +9 -3
  285. package/skills/registry.yaml +66 -66
  286. package/skills/research/arxiv-literature/SKILL.md +8 -2
  287. package/skills/research/experiment-protocol/SKILL.md +9 -2
  288. package/skills/research/scientific-debugging/SKILL.md +9 -2
  289. package/skills/research/scientific-debugging/evals.md +2 -2
  290. package/skills/research/scientific-modernization/SKILL.md +9 -2
  291. package/skills/skill-marketplace.json +257 -38
  292. package/skills/workflow/cut-it/SKILL.md +10 -2
  293. package/skills/workflow/design-council/SKILL.md +11 -2
  294. package/skills/workflow/grill-me/SKILL.md +8 -2
  295. package/skills/workflow/workflow-distiller/SKILL.md +8 -2
  296. package/src/cli/acp.ts +8 -4
  297. package/src/cli/argv.ts +25 -0
  298. package/src/cli/auth.ts +2 -2
  299. package/src/cli/bootstrap-generate.ts +5 -5
  300. package/src/cli/clio.ts +6 -1
  301. package/src/cli/config-inspect.ts +3 -3
  302. package/src/cli/configure-interop.ts +1 -1
  303. package/src/cli/configure.ts +50 -48
  304. package/src/cli/default-target.ts +1 -1
  305. package/src/cli/docs.ts +6 -6
  306. package/src/cli/doctor-naming.ts +323 -0
  307. package/src/cli/doctor-panes.ts +156 -0
  308. package/src/cli/doctor-toolchain.ts +78 -0
  309. package/src/cli/doctor.ts +34 -1
  310. package/src/cli/eval-inventory.ts +436 -0
  311. package/src/cli/eval.ts +13 -0
  312. package/src/cli/evidence-detail.ts +88 -0
  313. package/src/cli/evidence-inventory.ts +183 -0
  314. package/src/cli/evidence.ts +30 -5
  315. package/src/cli/fleet-decisions.ts +69 -0
  316. package/src/cli/fleet-inspect.ts +334 -0
  317. package/src/cli/fleet-preflight.ts +1 -1
  318. package/src/cli/fleet-verify.ts +133 -0
  319. package/src/cli/fleet-view.ts +827 -0
  320. package/src/cli/fleet.ts +154 -40
  321. package/src/cli/index.ts +14 -2
  322. package/src/cli/interop-inspect.ts +128 -0
  323. package/src/cli/interop.ts +34 -0
  324. package/src/cli/models.ts +3 -3
  325. package/src/cli/modes/print.ts +1 -1
  326. package/src/cli/panes.ts +35 -0
  327. package/src/cli/reset.ts +6 -3
  328. package/src/cli/run.ts +67 -13
  329. package/src/cli/share.ts +1 -1
  330. package/src/cli/skills-eval.ts +11 -11
  331. package/src/cli/skills-inventory.ts +185 -0
  332. package/src/cli/skills.ts +16 -13
  333. package/src/cli/targets.ts +23 -24
  334. package/src/cli/tools.ts +321 -0
  335. package/src/cli/trace-inspect.ts +252 -0
  336. package/src/cli/trace.ts +64 -2
  337. package/src/cli/uninstall.ts +2 -2
  338. package/src/cli/upgrade.ts +29 -34
  339. package/src/cli/usage.ts +2 -2
  340. package/src/cli/validate-model.ts +1 -1
  341. package/src/cli/verifiers-inspect.ts +347 -0
  342. package/src/cli/verifiers.ts +9 -0
  343. package/src/cli/wiki-generate.ts +5 -5
  344. package/src/core/bash-exec.ts +1 -1
  345. package/src/core/boot-trace.ts +3 -3
  346. package/src/core/bus-events.ts +4 -0
  347. package/src/core/bus-trace.ts +2 -2
  348. package/src/core/compile-cache.ts +1 -1
  349. package/src/core/config.ts +1070 -845
  350. package/src/core/defaults.ts +342 -463
  351. package/src/core/domain-loader.ts +6 -4
  352. package/src/core/event-bus.ts +1 -1
  353. package/src/core/file-references.ts +78 -88
  354. package/src/core/git-commit-attribution.ts +3 -9
  355. package/src/core/guardrails.ts +24 -4
  356. package/src/core/naming-compat.ts +45 -0
  357. package/src/core/naming-events.ts +62 -0
  358. package/src/core/recent-models.ts +1 -7
  359. package/src/core/residency-protection.ts +4 -8
  360. package/src/core/resolve-config-value.ts +1 -1
  361. package/src/core/response-model-id.ts +0 -14
  362. package/src/core/response-schema.ts +44 -4
  363. package/src/core/session-routing.ts +84 -74
  364. package/src/core/skill-activation.ts +18 -0
  365. package/src/core/termination.ts +4 -4
  366. package/src/core/theme-token-hex.ts +43 -0
  367. package/src/core/timers.ts +2 -12
  368. package/src/core/tool-names.ts +2 -1
  369. package/src/core/xdg.ts +1 -1
  370. package/src/domains/agents/catalog.ts +2 -12
  371. package/src/domains/agents/extension.ts +3 -3
  372. package/src/domains/agents/fleets/build-review.md +0 -3
  373. package/src/domains/agents/fleets/build-test.md +0 -3
  374. package/src/domains/agents/registry.ts +7 -7
  375. package/src/domains/agents/result-contract-filesystem.ts +32 -0
  376. package/src/domains/agents/result-contract.ts +165 -36
  377. package/src/domains/agents/spec.ts +0 -11
  378. package/src/domains/config/classify.ts +37 -46
  379. package/src/domains/config/extension.ts +5 -5
  380. package/src/domains/config/keybindings.ts +48 -47
  381. package/src/domains/config/watcher.ts +1 -1
  382. package/src/domains/context/codewiki/indexer.ts +1 -1
  383. package/src/domains/context/extension.ts +3 -3
  384. package/src/domains/context/prompt-context.ts +1 -1
  385. package/src/domains/context/wiki/assemble.ts +2 -2
  386. package/src/domains/context/working-set/replay/metrics.ts +0 -4
  387. package/src/domains/context/working-set/replay/report.ts +1 -1
  388. package/src/domains/context/working-set/replay/synthetic.ts +2 -2
  389. package/src/domains/dispatch/active-route-planner.ts +2 -2
  390. package/src/domains/dispatch/admission-error.ts +9 -0
  391. package/src/domains/dispatch/admission.ts +22 -21
  392. package/src/domains/dispatch/agent-candidates.ts +1 -1
  393. package/src/domains/dispatch/agent-ledger-store.ts +1 -1
  394. package/src/domains/dispatch/agent-ledger.ts +1 -1
  395. package/src/domains/dispatch/assignment.ts +5 -5
  396. package/src/domains/dispatch/capacity-lease.ts +23 -6
  397. package/src/domains/dispatch/code-step.ts +1 -1
  398. package/src/domains/dispatch/contract.ts +2 -2
  399. package/src/domains/dispatch/council-topology.ts +398 -0
  400. package/src/domains/dispatch/extension.ts +287 -111
  401. package/src/domains/dispatch/fleet-node-prompt.ts +62 -0
  402. package/src/domains/dispatch/fleet-plan.ts +7 -2
  403. package/src/domains/dispatch/fleet-preflight.ts +8 -17
  404. package/src/domains/dispatch/fleet-run.ts +59 -3
  405. package/src/domains/dispatch/gate-decisions.ts +36 -15
  406. package/src/domains/dispatch/gate-role-prompts.ts +9 -0
  407. package/src/domains/dispatch/gate-topology.ts +289 -0
  408. package/src/domains/dispatch/index.ts +19 -0
  409. package/src/domains/dispatch/intent-compatibility.ts +330 -0
  410. package/src/domains/dispatch/intent.ts +85 -1
  411. package/src/domains/dispatch/joint-route-resolver.ts +1 -1
  412. package/src/domains/dispatch/path-scope.ts +0 -61
  413. package/src/domains/dispatch/placement.ts +2 -2
  414. package/src/domains/dispatch/receipt-findings.ts +1 -1
  415. package/src/domains/dispatch/receipt-integrity.ts +20 -8
  416. package/src/domains/dispatch/reservation-store.ts +24 -27
  417. package/src/domains/dispatch/route-decision.ts +1 -1
  418. package/src/domains/dispatch/route-history.ts +1 -1
  419. package/src/domains/dispatch/route-policy.ts +1 -1
  420. package/src/domains/dispatch/route-readiness.ts +0 -28
  421. package/src/domains/dispatch/run-event-journal-bridge.ts +149 -0
  422. package/src/domains/dispatch/run-event-journal.ts +599 -0
  423. package/src/domains/dispatch/state.ts +45 -1
  424. package/src/domains/dispatch/tool-stats.ts +1 -1
  425. package/src/domains/dispatch/transport.ts +2 -19
  426. package/src/domains/dispatch/types.ts +16 -3
  427. package/src/domains/dispatch/validation.ts +33 -8
  428. package/src/domains/dispatch/worker-protocol.ts +2 -2
  429. package/src/domains/eval/artifacts/store.ts +5 -4
  430. package/src/domains/eval/compare/compare.ts +3 -16
  431. package/src/domains/eval/compare/thresholds.ts +0 -8
  432. package/src/domains/eval/execution-provenance.ts +1 -1
  433. package/src/domains/eval/inventory.ts +113 -0
  434. package/src/domains/eval/metrics/token-stream.ts +0 -7
  435. package/src/domains/eval/report.ts +1 -1
  436. package/src/domains/eval/runner.ts +1 -1
  437. package/src/domains/eval/runners/clio-run.ts +7 -6
  438. package/src/domains/eval/runners/external-command.ts +4 -3
  439. package/src/domains/eval/schema/artifact.ts +1 -1
  440. package/src/domains/eval/schema/behavioral-metrics.ts +3 -2
  441. package/src/domains/eval/schema/behavioral.ts +7 -6
  442. package/src/domains/eval/schema/execution-envelope.ts +4 -2
  443. package/src/domains/eval/schema/naming.ts +10 -0
  444. package/src/domains/eval/schema/serving.ts +31 -0
  445. package/src/domains/eval/schema/suite.ts +2 -2
  446. package/src/domains/eval/schema/validate.ts +9 -5
  447. package/src/domains/eval/schema/verdict.ts +4 -2
  448. package/src/domains/eval/store.ts +12 -2
  449. package/src/domains/eval/suites/run.ts +12 -6
  450. package/src/domains/eval/types.ts +1 -1
  451. package/src/domains/eval/workspaces/git.ts +1 -1
  452. package/src/domains/eval/workspaces/temp-copy.ts +1 -1
  453. package/src/domains/evidence/build.ts +13 -5
  454. package/src/domains/evidence/store.ts +6 -0
  455. package/src/domains/interop/consent.ts +7 -7
  456. package/src/domains/interop/extension.ts +1 -1
  457. package/src/domains/lifecycle/doctor.ts +27 -21
  458. package/src/domains/lifecycle/migrations/2026-09-01-clio-coder-naming.ts +155 -0
  459. package/src/domains/lifecycle/migrations/2026-09-01-retire-panes-knobs.ts +59 -0
  460. package/src/domains/lifecycle/migrations/2026-09-01-settings-v2.ts +338 -0
  461. package/src/domains/lifecycle/migrations/index.ts +20 -1
  462. package/src/domains/lifecycle/naming-history.ts +153 -0
  463. package/src/domains/lifecycle/naming-mutable-state.ts +104 -0
  464. package/src/domains/lifecycle/naming-resources.ts +261 -0
  465. package/src/domains/lifecycle/naming-tool-markers.ts +139 -0
  466. package/src/domains/lifecycle/naming-yazi.ts +81 -0
  467. package/src/domains/lifecycle/upgrade-notice.ts +1 -1
  468. package/src/domains/memory/index.ts +0 -1
  469. package/src/domains/memory/task-memory-handoff.ts +6 -3
  470. package/src/domains/memory/task-memory-policy.ts +6 -10
  471. package/src/domains/memory/task-memory-telemetry.ts +1 -0
  472. package/src/domains/middleware/index.ts +7 -0
  473. package/src/domains/middleware/marketplace-offer.ts +339 -0
  474. package/src/domains/middleware/memory-intervention.ts +33 -21
  475. package/src/domains/middleware/runtime.ts +2 -2
  476. package/src/domains/mux/contract.ts +566 -0
  477. package/src/domains/mux/detect.ts +182 -0
  478. package/src/domains/mux/dock-controller.ts +365 -0
  479. package/src/domains/mux/extension.ts +53 -0
  480. package/src/domains/mux/index.ts +116 -0
  481. package/src/domains/mux/manifest.ts +6 -0
  482. package/src/domains/mux/operations.ts +192 -0
  483. package/src/domains/mux/pane-registry.ts +90 -0
  484. package/src/domains/mux/protocol.ts +62 -0
  485. package/src/domains/mux/socket-client.ts +964 -0
  486. package/src/domains/mux/types.ts +265 -0
  487. package/src/domains/mux/viewer-command.ts +59 -0
  488. package/src/domains/mux/yazi/assets/init.lua +2 -0
  489. package/src/domains/mux/yazi/assets/plugins/git.yazi/LICENSE +21 -0
  490. package/src/domains/mux/yazi/assets/plugins/git.yazi/README.md +78 -0
  491. package/src/domains/mux/yazi/assets/plugins/git.yazi/main.lua +255 -0
  492. package/src/domains/mux/yazi/assets/plugins/git.yazi/types.lua +12 -0
  493. package/src/domains/mux/yazi/assets/yazi.toml +17 -0
  494. package/src/domains/mux/yazi/event-stream.ts +182 -0
  495. package/src/domains/mux/yazi/profile.ts +299 -0
  496. package/src/domains/mux/yazi/session.ts +251 -0
  497. package/src/domains/mux/yazi/theme.ts +30 -0
  498. package/src/domains/observability/cost.ts +21 -0
  499. package/src/domains/observability/extension.ts +1 -1
  500. package/src/domains/observability/index.ts +2 -0
  501. package/src/domains/observability/out-of-turn-usage.ts +2 -2
  502. package/src/domains/observability/projection.ts +1 -1
  503. package/src/domains/observability/trace-store.ts +63 -11
  504. package/src/domains/prompts/compiler.ts +2 -2
  505. package/src/domains/prompts/extension.ts +3 -3
  506. package/src/domains/prompts/fragments/identity/clio-worker.md +1 -1
  507. package/src/domains/prompts/fragments/operating/skills.md +25 -18
  508. package/src/domains/providers/endpoint-capacity.ts +154 -22
  509. package/src/domains/providers/endpoint-slots-store.ts +189 -0
  510. package/src/domains/providers/extension.ts +25 -8
  511. package/src/domains/providers/index.ts +22 -0
  512. package/src/domains/providers/knowledge-base-path.ts +1 -1
  513. package/src/domains/providers/model-runtime-capabilities.ts +46 -2
  514. package/src/domains/providers/models/cloud-models/alcf.yaml +1 -1
  515. package/src/domains/providers/models/local-models/{clio-local-coding-targets.yaml → clio-coder-local-coding-targets.yaml} +4 -4
  516. package/src/domains/providers/plugins.ts +1 -1
  517. package/src/domains/providers/resolver.ts +1 -1
  518. package/src/domains/providers/runtimes/boot-manifest.ts +1 -0
  519. package/src/domains/providers/runtimes/builtins.ts +2 -0
  520. package/src/domains/providers/runtimes/cloud/alcf.ts +4 -4
  521. package/src/domains/providers/runtimes/common/lmstudio-http.ts +1 -5
  522. package/src/domains/providers/runtimes/common/local-synth.ts +3 -3
  523. package/src/domains/providers/runtimes/common/probe-helpers.ts +2 -2
  524. package/src/domains/providers/runtimes/local-native/llamacpp-completion.ts +1 -1
  525. package/src/domains/providers/runtimes/local-native/lmstudio.ts +2 -9
  526. package/src/domains/providers/runtimes/protocol/litellm.ts +285 -0
  527. package/src/domains/providers/support.ts +1 -0
  528. package/src/domains/providers/target-model-cache.ts +124 -0
  529. package/src/domains/providers/types/knowledge-base.ts +13 -0
  530. package/src/domains/providers/types/local-model-quirks.ts +2 -2
  531. package/src/domains/providers/types/target-descriptor.ts +3 -3
  532. package/src/domains/resources/extension.ts +1 -1
  533. package/src/domains/resources/index.ts +3 -0
  534. package/src/domains/resources/library.ts +6 -6
  535. package/src/domains/resources/prompts/loader.ts +1 -1
  536. package/src/domains/resources/skills/content-hash.ts +7 -6
  537. package/src/domains/resources/skills/evals.ts +1 -1
  538. package/src/domains/resources/skills/install.ts +36 -12
  539. package/src/domains/resources/skills/loader.ts +72 -13
  540. package/src/domains/resources/skills/marketplace.ts +21 -2
  541. package/src/domains/resources/skills/promotion.ts +214 -0
  542. package/src/domains/safety/action-classifier.ts +6 -0
  543. package/src/domains/safety/audit.ts +2 -2
  544. package/src/domains/safety/finish-contract.ts +2 -1
  545. package/src/domains/safety/run-effects.ts +1 -1
  546. package/src/domains/scheduling/extension.ts +4 -4
  547. package/src/domains/session/archive-readers.ts +9 -1
  548. package/src/domains/session/compaction/branch-summary.ts +4 -0
  549. package/src/domains/session/compaction/compact.ts +1 -1
  550. package/src/domains/session/compaction/tokens.ts +4 -0
  551. package/src/domains/session/context-accounting.ts +1 -1
  552. package/src/domains/session/decision-board.ts +1 -1
  553. package/src/domains/session/extension.ts +1 -1
  554. package/src/domains/session/handoff.ts +2 -2
  555. package/src/domains/session/prompt-manifest.ts +0 -5
  556. package/src/domains/session/protected-artifact-journal.ts +12 -6
  557. package/src/domains/session/retry.ts +1 -1
  558. package/src/domains/share/archive.ts +85 -36
  559. package/src/domains/toolchain/archive.ts +175 -0
  560. package/src/domains/toolchain/contract.ts +28 -0
  561. package/src/domains/toolchain/extension.ts +47 -0
  562. package/src/domains/toolchain/index.ts +39 -0
  563. package/src/domains/toolchain/install.ts +327 -0
  564. package/src/domains/toolchain/manifest.ts +8 -0
  565. package/src/domains/toolchain/paths.ts +34 -0
  566. package/src/domains/toolchain/registry.ts +265 -0
  567. package/src/domains/toolchain/remove.ts +218 -0
  568. package/src/domains/toolchain/resolve.ts +182 -0
  569. package/src/domains/toolchain/types.ts +113 -0
  570. package/src/domains/toolchain/version.ts +88 -0
  571. package/src/engine/acp/adapter.ts +3 -3
  572. package/src/engine/acp/event-mapper.ts +3 -3
  573. package/src/engine/acp/server.ts +440 -96
  574. package/src/engine/acp/tool-mediator.ts +2 -2
  575. package/src/engine/acp/types.ts +20 -2
  576. package/src/engine/alcf-oauth.ts +5 -5
  577. package/src/engine/antigravity/subprocess-runtime.ts +2 -2
  578. package/src/engine/api-registry.ts +1 -1
  579. package/src/engine/apis/llamacpp-residency.ts +1 -19
  580. package/src/engine/apis/lmstudio.ts +1 -6
  581. package/src/engine/apis/ollama-native.ts +3 -3
  582. package/src/engine/apis/openai-completions.ts +2 -2
  583. package/src/engine/apis/residency.ts +3 -9
  584. package/src/engine/claude/sdk-module.ts +87 -0
  585. package/src/engine/claude/sdk-runtime.ts +25 -17
  586. package/src/engine/claude/subprocess-runtime.ts +1 -1
  587. package/src/engine/claude/tool-safety.ts +4 -4
  588. package/src/engine/loop-guard.ts +0 -5
  589. package/src/engine/session.ts +14 -7
  590. package/src/engine/tui-primitives.ts +21 -0
  591. package/src/engine/tui.ts +1 -0
  592. package/src/engine/worker-events.ts +6 -6
  593. package/src/engine/worker-runtime.ts +16 -26
  594. package/src/entry/boot-options.ts +2 -0
  595. package/src/entry/orchestrator.ts +207 -90
  596. package/src/entry/panes-activation.ts +31 -0
  597. package/src/entry/with-panes.ts +20 -0
  598. package/src/interactive/application-controller.ts +21 -21
  599. package/src/interactive/bus-notices.ts +2 -2
  600. package/src/interactive/chat-loop.ts +8 -8
  601. package/src/interactive/chat-panel.ts +1 -1
  602. package/src/interactive/clio-editor.ts +105 -1
  603. package/src/interactive/context-activity.ts +8 -6
  604. package/src/interactive/context-meter.ts +3 -6
  605. package/src/interactive/context-overlay.ts +2 -1
  606. package/src/interactive/cost-overlay.ts +3 -1
  607. package/src/interactive/council-grid.ts +3 -5
  608. package/src/interactive/council.ts +11 -0
  609. package/src/interactive/dispatch-board.ts +56 -49
  610. package/src/interactive/editor-bash.ts +21 -0
  611. package/src/interactive/editor-steer.ts +9 -4
  612. package/src/interactive/editor-submit.ts +24 -18
  613. package/src/interactive/external-editor.ts +1 -1
  614. package/src/interactive/file-reference-completion.ts +360 -0
  615. package/src/interactive/footer/dashboard.ts +15 -17
  616. package/src/interactive/footer/notifications.ts +14 -8
  617. package/src/interactive/footer/widgets.ts +2 -44
  618. package/src/interactive/interactive-application.ts +229 -62
  619. package/src/interactive/interactive-event-projection.ts +1 -1
  620. package/src/interactive/interactive-input-runtime.ts +9 -2
  621. package/src/interactive/interactive-presentation.ts +21 -16
  622. package/src/interactive/interactive-shell.ts +2 -2
  623. package/src/interactive/interactive-slash-runtime.ts +99 -23
  624. package/src/interactive/interactive-subscriptions.ts +1 -1
  625. package/src/interactive/interactive-tickers.ts +1 -1
  626. package/src/interactive/keybinding-manager.ts +4 -4
  627. package/src/interactive/layout.ts +1 -1
  628. package/src/interactive/memory-overlay.ts +3 -2
  629. package/src/interactive/modal-marker.ts +151 -0
  630. package/src/interactive/mutation-preview.ts +1 -1
  631. package/src/interactive/mux-bridge.ts +214 -0
  632. package/src/interactive/overlay-frame.ts +62 -14
  633. package/src/interactive/overlay-general-openers.ts +7 -2
  634. package/src/interactive/overlay-key-routing.ts +21 -10
  635. package/src/interactive/overlay-lifecycle.ts +20 -4
  636. package/src/interactive/overlay-model-selectors.ts +43 -6
  637. package/src/interactive/overlay-permission-lifecycle.ts +90 -22
  638. package/src/interactive/overlay-transitions.ts +18 -4
  639. package/src/interactive/overlays/agents.ts +3 -2
  640. package/src/interactive/overlays/ask-user.ts +161 -41
  641. package/src/interactive/overlays/auth-dialog.ts +1 -0
  642. package/src/interactive/overlays/context-reset.ts +29 -4
  643. package/src/interactive/overlays/cwd-fallback.ts +29 -4
  644. package/src/interactive/overlays/decisions.ts +15 -13
  645. package/src/interactive/overlays/extensions.ts +1 -0
  646. package/src/interactive/overlays/fleet-run-approval.ts +4 -3
  647. package/src/interactive/overlays/handoff-review.ts +3 -2
  648. package/src/interactive/overlays/help-reference.ts +2 -0
  649. package/src/interactive/overlays/interop.ts +2 -1
  650. package/src/interactive/overlays/library-install-confirm.ts +2 -1
  651. package/src/interactive/overlays/library-tabs.ts +28 -0
  652. package/src/interactive/overlays/list-overlay.ts +10 -1
  653. package/src/interactive/overlays/message-picker.ts +2 -1
  654. package/src/interactive/overlays/model-scope.ts +86 -0
  655. package/src/interactive/overlays/model-selector.ts +40 -31
  656. package/src/interactive/overlays/prompts.ts +11 -4
  657. package/src/interactive/overlays/session-selector.ts +3 -2
  658. package/src/interactive/overlays/settings-sections.ts +30 -0
  659. package/src/interactive/overlays/settings.ts +849 -268
  660. package/src/interactive/overlays/side-question.ts +3 -2
  661. package/src/interactive/overlays/skills-hub.ts +11 -19
  662. package/src/interactive/overlays/tree-selector.ts +3 -2
  663. package/src/interactive/pane-policy.ts +46 -0
  664. package/src/interactive/panes-runtime.ts +318 -0
  665. package/src/interactive/permission-overlay.ts +2 -2
  666. package/src/interactive/renderers/compaction-summary.ts +29 -0
  667. package/src/interactive/renderers/retry-status.ts +12 -4
  668. package/src/interactive/renderers/tool-execution.ts +4 -4
  669. package/src/interactive/renderers/worker-entry.ts +122 -14
  670. package/src/interactive/session-transcript.ts +3 -3
  671. package/src/interactive/slash-autocomplete.ts +454 -165
  672. package/src/interactive/slash-commands.ts +521 -189
  673. package/src/interactive/slash-spec.ts +160 -17
  674. package/src/interactive/status/controller.ts +2 -2
  675. package/src/interactive/stream-pacing-policy.ts +1 -1
  676. package/src/interactive/tasks-overlay.ts +21 -13
  677. package/src/interactive/terminal-lease.ts +6 -7
  678. package/src/interactive/theme/tokens.ts +3 -14
  679. package/src/interactive/turn-context.ts +58 -13
  680. package/src/interactive/turn-persistence.ts +2 -2
  681. package/src/interactive/turn-prewarm.ts +2 -2
  682. package/src/interactive/turn-runtime.ts +8 -8
  683. package/src/interactive/turn-state.ts +1 -1
  684. package/src/interactive/view/artifacts.ts +120 -9
  685. package/src/interactive/view/view-overlay.ts +14 -10
  686. package/src/interactive/watch-pane.ts +180 -0
  687. package/src/interactive/welcome-dashboard.ts +15 -15
  688. package/src/interactive/worker-progress.ts +11 -5
  689. package/src/interactive/worker-receipts.ts +20 -2
  690. package/src/interactive/worker-stream.ts +6 -4
  691. package/src/interactive/yazi-bridge.ts +451 -0
  692. package/src/tools/ask-user.ts +3 -3
  693. package/src/tools/bash.ts +1 -1
  694. package/src/tools/bootstrap.ts +26 -2
  695. package/src/tools/builtin-tool-catalog.ts +16 -1
  696. package/src/tools/compete-worktrees.ts +108 -17
  697. package/src/tools/context/index.ts +15 -1
  698. package/src/tools/core-bootstrap.ts +2 -1
  699. package/src/tools/dispatch-admission.ts +18 -5
  700. package/src/tools/dispatch-arguments.ts +21 -21
  701. package/src/tools/dispatch-plan.ts +0 -11
  702. package/src/tools/dispatch-run-events.ts +145 -28
  703. package/src/tools/dispatch-runner.ts +40 -13
  704. package/src/tools/dispatch-types.ts +15 -3
  705. package/src/tools/dispatch.ts +2 -2
  706. package/src/tools/executables.ts +17 -14
  707. package/src/tools/find.ts +1 -6
  708. package/src/tools/monitor.ts +4 -4
  709. package/src/tools/observation.ts +54 -4
  710. package/src/tools/observers.ts +0 -33
  711. package/src/tools/panes-surface.ts +38 -0
  712. package/src/tools/panes.ts +112 -0
  713. package/src/tools/policy.ts +10 -1
  714. package/src/tools/presentation.ts +1 -0
  715. package/src/tools/task-worktree.ts +28 -7
  716. package/src/tools/verify/authoring.ts +3 -6
  717. package/src/tools/verify/frontend.ts +1 -1
  718. package/src/tools/web-fetch.ts +1 -1
  719. package/src/worker/entry.ts +4 -3
  720. package/src/worker/protocol.ts +16 -14
  721. package/src/worker/spec-contract.ts +2 -2
  722. package/src/worker/stdin-demux.ts +2 -2
  723. package/dist/chunk-D73KXYPF.js +0 -37
  724. package/dist/chunk-MLOK6ZOS.js +0 -2888
  725. package/dist/chunk-PNY46YEY.js +0 -1581
  726. package/dist/chunk-XDOQXGFO.js +0 -515
  727. package/dist/chunk-YKOFT37S.js +0 -279
  728. package/dist/clio-LT5V7SSZ.js +0 -26
  729. package/dist/configure-2WYWSCSD.js +0 -49
  730. package/dist/doctor-TWBWFK5V.js +0 -165
  731. package/src/engine/apis/degraded-inference.ts +0 -95
  732. /package/skills/meta/{clio-test → clio-coder-test}/references/harness.md +0 -0
  733. /package/skills/meta/{clio-test → clio-coder-test}/references/test-map.md +0 -0
@@ -0,0 +1,1842 @@
1
+ import { createRequire as __clioCreateRequire } from "node:module"; const require = __clioCreateRequire(import.meta.url);
2
+ import {
3
+ warnLegacyNaming
4
+ } from "./chunk-D7E7WCDF.js";
5
+ import {
6
+ MAX_TIMER_DELAY_MS
7
+ } from "./chunk-EBY63B7G.js";
8
+ import {
9
+ ACTIVE_AGENT_AUTOMATION_ROLES,
10
+ ACTIVE_ROUTING_POSTURES,
11
+ ACTIVE_ROUTING_ROLES,
12
+ COUNCIL_MEMBER_LABEL_PATTERN,
13
+ DEFAULT_SETTINGS,
14
+ THEME_NAMED_COLORS,
15
+ THINKING_LEVELS
16
+ } from "./chunk-BWW4HLO4.js";
17
+ import {
18
+ withStateFileLockSync
19
+ } from "./chunk-IKCO5N3L.js";
20
+ import {
21
+ require_dist
22
+ } from "./chunk-APJ265NV.js";
23
+ import {
24
+ clioConfigDir,
25
+ resolveClioDirs
26
+ } from "./chunk-BYP5D4HI.js";
27
+ import {
28
+ safeResourceWrite
29
+ } from "./chunk-WEPFGWHJ.js";
30
+ import {
31
+ __toESM,
32
+ init_esm_shims
33
+ } from "./chunk-3R73A4XB.js";
34
+
35
+ // src/core/config.ts
36
+ init_esm_shims();
37
+ var import_yaml = __toESM(require_dist(), 1);
38
+ import { existsSync, readFileSync } from "node:fs";
39
+ import { join } from "node:path";
40
+ function settingsPath() {
41
+ return join(clioConfigDir(), "settings.yaml");
42
+ }
43
+ function issuesKind(issues) {
44
+ return issues[0]?.kind ?? "schema";
45
+ }
46
+ function settingsRemedy(kind, path) {
47
+ if (kind === "unreadable") return `Restore read access to ${path}, then run \`clio-coder doctor\` to re-check.`;
48
+ if (kind === "syntax") return `Fix the YAML in ${path}, then run \`clio-coder doctor\` to re-check.`;
49
+ return `Fix the keys above in ${path}, then run \`clio-coder doctor\` to re-check.`;
50
+ }
51
+ function settingsRemedyInline(kind, path) {
52
+ if (kind === "unreadable") return `restore read access to ${path}`;
53
+ if (kind === "syntax") return `fix the YAML in ${path}`;
54
+ return `edit the named keys in ${path}`;
55
+ }
56
+ var SettingsValidationError = class extends Error {
57
+ issues;
58
+ /**
59
+ * The headline and the remedy both follow the failure kind. A file that
60
+ * cannot be read has no key at fault, so telling its reader to "fix the keys
61
+ * above" named a repair that does not exist for the problem they have.
62
+ */
63
+ constructor(issues) {
64
+ const path = join(resolveClioDirs().config, "settings.yaml");
65
+ const kind = issuesKind(issues);
66
+ const lines = kind === "schema" ? issues.map((issue) => ` ${issue.path}: ${issue.message}`) : issues.map((issue) => ` ${issue.message}`);
67
+ const headline = kind === "schema" ? "settings.yaml failed validation:" : "settings.yaml cannot be loaded:";
68
+ super(
69
+ `${headline}
70
+ ${lines.join("\n")}
71
+
72
+ ${settingsRemedy(kind, path)}
73
+ \`clio-coder doctor --fix\` repairs directories and credential permissions; it never rewrites settings.
74
+ To discard these settings and start from defaults instead, run \`clio-coder reset --config --force\`.`
75
+ );
76
+ this.name = "SettingsValidationError";
77
+ this.issues = issues;
78
+ }
79
+ };
80
+ function foldToOneLine(text) {
81
+ return text.replace(/\s*\n\s*/g, " ").trim();
82
+ }
83
+ function yamlErrorSummary(error) {
84
+ const raw = error instanceof Error ? error.message : String(error);
85
+ return (raw.split("\n")[0] ?? raw).trim().replace(/:$/u, "");
86
+ }
87
+ function settingsFailureHeadline(kind) {
88
+ if (kind === "unreadable") return "settings.yaml cannot be read";
89
+ if (kind === "syntax") return "settings.yaml is not valid YAML";
90
+ return "settings.yaml failed validation";
91
+ }
92
+ function formatSettingsIssues(issues) {
93
+ if (issues.length === 0) return "";
94
+ const path = join(resolveClioDirs().config, "settings.yaml");
95
+ const kind = issuesKind(issues);
96
+ const detail = kind === "schema" ? issues.map((issue) => `${issue.path}: ${issue.message}`).join("; ") : issues.map((issue) => issue.message.replace(/^(?:invalid YAML|unreadable): /u, "")).join("; ");
97
+ const discard = "`clio-coder reset --config --force` to start from defaults";
98
+ return foldToOneLine(
99
+ `${settingsFailureHeadline(kind)}: ${settingsRemedyInline(kind, path)}, or ${discard}. ${detail}`
100
+ );
101
+ }
102
+ function formatSettingsFailure(error) {
103
+ if (error instanceof SettingsValidationError && error.issues.length > 0) return formatSettingsIssues(error.issues);
104
+ return foldToOneLine(error instanceof Error ? error.message : String(error));
105
+ }
106
+ function isPlainObject(value) {
107
+ return typeof value === "object" && value !== null && !Array.isArray(value);
108
+ }
109
+ function cloneValue(value) {
110
+ return structuredClone(value);
111
+ }
112
+ var Issues = class {
113
+ list = [];
114
+ add(path, message) {
115
+ this.list.push({ path, message });
116
+ }
117
+ unknownKeys(path, raw, known) {
118
+ const knownSet = new Set(known);
119
+ for (const key of Object.keys(raw)) {
120
+ if (!knownSet.has(key)) this.add(path ? `${path}.${key}` : key, "unknown key");
121
+ }
122
+ }
123
+ /**
124
+ * A key that used to be honored and is not any more. `unknown key` is the
125
+ * true answer for a typo and the wrong one here: the operator wrote a real
126
+ * key that a real release read, and the useful thing to tell them is what
127
+ * replaced it, not that the schema has never heard of it. The keys stay
128
+ * listed as known at their {@link unknownKeys} call so this message is the
129
+ * one that lands.
130
+ */
131
+ retiredKeys(path, raw, retired) {
132
+ for (const [key, because] of Object.entries(retired)) {
133
+ if (key in raw) this.add(path ? `${path}.${key}` : key, `retired: ${because}. Remove this key.`);
134
+ }
135
+ }
136
+ };
137
+ function expectString(issues, path, value) {
138
+ if (typeof value !== "string") {
139
+ issues.add(path, `expected a string, got ${describe(value)}`);
140
+ return void 0;
141
+ }
142
+ const trimmed = value.trim();
143
+ if (trimmed.length === 0) {
144
+ issues.add(path, "expected a non-empty string");
145
+ return void 0;
146
+ }
147
+ return trimmed;
148
+ }
149
+ function expectBoolean(issues, path, value) {
150
+ if (typeof value !== "boolean") {
151
+ issues.add(path, `expected a boolean, got ${describe(value)}`);
152
+ return void 0;
153
+ }
154
+ return value;
155
+ }
156
+ function expectNumber(issues, path, value, opts) {
157
+ if (typeof value !== "number" || !Number.isFinite(value)) {
158
+ issues.add(path, `expected a number, got ${describe(value)}`);
159
+ return void 0;
160
+ }
161
+ if (opts?.min !== void 0 && value < opts.min) {
162
+ issues.add(path, `expected a number >= ${opts.min}, got ${value}`);
163
+ return void 0;
164
+ }
165
+ if (opts?.max !== void 0 && value > opts.max) {
166
+ issues.add(path, `expected a number <= ${opts.max}, got ${value}`);
167
+ return void 0;
168
+ }
169
+ return value;
170
+ }
171
+ function expectInteger(issues, path, value, opts) {
172
+ if (typeof value !== "number" || !Number.isInteger(value)) {
173
+ issues.add(path, `expected an integer, got ${describe(value)}`);
174
+ return void 0;
175
+ }
176
+ if (opts?.min !== void 0 && value < opts.min) {
177
+ issues.add(path, `expected an integer >= ${opts.min}, got ${value}`);
178
+ return void 0;
179
+ }
180
+ if (opts?.max !== void 0 && value > opts.max) {
181
+ issues.add(path, `expected an integer <= ${opts.max}, got ${value}`);
182
+ return void 0;
183
+ }
184
+ return value;
185
+ }
186
+ function expectEnum(issues, path, value, allowed) {
187
+ if (typeof value === "string" && allowed.includes(value)) return value;
188
+ issues.add(path, `expected one of ${allowed.join(" | ")}, got ${describe(value)}`);
189
+ return void 0;
190
+ }
191
+ function expectStringArray(issues, path, value) {
192
+ if (!Array.isArray(value)) {
193
+ issues.add(path, `expected a list of strings, got ${describe(value)}`);
194
+ return void 0;
195
+ }
196
+ const seen = /* @__PURE__ */ new Set();
197
+ const out = [];
198
+ for (let i = 0; i < value.length; i += 1) {
199
+ const entry = expectString(issues, `${path}[${i}]`, value[i]);
200
+ if (entry === void 0) continue;
201
+ if (seen.has(entry)) continue;
202
+ seen.add(entry);
203
+ out.push(entry);
204
+ }
205
+ return out;
206
+ }
207
+ function expectStringRecord(issues, path, value) {
208
+ if (!isPlainObject(value)) {
209
+ issues.add(path, `expected a string map, got ${describe(value)}`);
210
+ return void 0;
211
+ }
212
+ const out = {};
213
+ for (const [key, raw] of Object.entries(value)) {
214
+ const entry = expectString(issues, `${path}.${key}`, raw);
215
+ if (entry !== void 0) out[key] = entry;
216
+ }
217
+ return out;
218
+ }
219
+ function describe(value) {
220
+ if (value === null) return "null";
221
+ if (Array.isArray(value)) return "a list";
222
+ if (typeof value === "object") return "a map";
223
+ if (typeof value === "string") return value.trim().length === 0 ? "an empty string" : JSON.stringify(value);
224
+ return String(value);
225
+ }
226
+ var TOOL_CALL_FORMATS = ["openai", "anthropic", "hermes", "llama3-json", "mistral", "qwen", "xml"];
227
+ var THINKING_FORMATS = [
228
+ "qwen-chat-template",
229
+ "openrouter",
230
+ "zai",
231
+ "anthropic-extended",
232
+ "deepseek-r1",
233
+ "openai-codex",
234
+ "harmony"
235
+ ];
236
+ var STRUCTURED_OUTPUTS = ["json-schema", "gbnf", "xgrammar", "none"];
237
+ var AUTONOMY_LEVELS = ["read-only", "suggest", "auto-edit", "full-auto"];
238
+ var TOOL_GOVERNANCE = ["clio-coder-policy", "agent-managed", "deny-all"];
239
+ function normalizeLegacyNamingValue(value, legacy, canonical) {
240
+ if (value !== legacy) return value;
241
+ warnLegacyNaming(legacy, canonical);
242
+ return canonical;
243
+ }
244
+ function validateCapabilities(issues, path, value) {
245
+ if (!isPlainObject(value)) {
246
+ issues.add(path, `expected a map, got ${describe(value)}`);
247
+ return void 0;
248
+ }
249
+ issues.unknownKeys(path, value, [
250
+ "chat",
251
+ "tools",
252
+ "toolCallFormat",
253
+ "reasoning",
254
+ "thinkingFormat",
255
+ "structuredOutputs",
256
+ "vision",
257
+ "audio",
258
+ "embeddings",
259
+ "rerank",
260
+ "fim",
261
+ "contextWindow",
262
+ "maxTokens"
263
+ ]);
264
+ const out = {};
265
+ for (const key of ["chat", "tools", "reasoning", "vision", "audio", "embeddings", "rerank", "fim"]) {
266
+ if (key in value) {
267
+ const v = expectBoolean(issues, `${path}.${key}`, value[key]);
268
+ if (v !== void 0) out[key] = v;
269
+ }
270
+ }
271
+ if ("toolCallFormat" in value) {
272
+ const v = expectEnum(issues, `${path}.toolCallFormat`, value.toolCallFormat, TOOL_CALL_FORMATS);
273
+ if (v !== void 0) out.toolCallFormat = v;
274
+ }
275
+ if ("thinkingFormat" in value) {
276
+ const v = expectEnum(issues, `${path}.thinkingFormat`, value.thinkingFormat, THINKING_FORMATS);
277
+ if (v !== void 0) out.thinkingFormat = v;
278
+ }
279
+ if ("structuredOutputs" in value) {
280
+ const v = expectEnum(issues, `${path}.structuredOutputs`, value.structuredOutputs, STRUCTURED_OUTPUTS);
281
+ if (v !== void 0) out.structuredOutputs = v;
282
+ }
283
+ if ("contextWindow" in value) {
284
+ const v = expectInteger(issues, `${path}.contextWindow`, value.contextWindow, { min: 0 });
285
+ if (v !== void 0) out.contextWindow = v;
286
+ }
287
+ if ("maxTokens" in value) {
288
+ const v = expectInteger(issues, `${path}.maxTokens`, value.maxTokens, { min: 0 });
289
+ if (v !== void 0) out.maxTokens = v;
290
+ }
291
+ return Object.keys(out).length > 0 ? out : void 0;
292
+ }
293
+ function validateAuth(issues, path, value) {
294
+ if (!isPlainObject(value)) {
295
+ issues.add(path, `expected a map, got ${describe(value)}`);
296
+ return void 0;
297
+ }
298
+ issues.unknownKeys(path, value, ["apiKeyEnvVar", "apiKeyRef", "oauthProfile", "headers"]);
299
+ const out = {};
300
+ for (const key of ["apiKeyEnvVar", "apiKeyRef", "oauthProfile"]) {
301
+ if (key in value) {
302
+ const v = expectString(issues, `${path}.${key}`, value[key]);
303
+ if (v !== void 0) out[key] = v;
304
+ }
305
+ }
306
+ if ("headers" in value) {
307
+ const v = expectStringRecord(issues, `${path}.headers`, value.headers);
308
+ if (v !== void 0 && Object.keys(v).length > 0) out.headers = v;
309
+ }
310
+ return Object.keys(out).length > 0 ? out : void 0;
311
+ }
312
+ function validatePricing(issues, path, value) {
313
+ if (!isPlainObject(value)) {
314
+ issues.add(path, `expected a map, got ${describe(value)}`);
315
+ return void 0;
316
+ }
317
+ issues.unknownKeys(path, value, ["input", "output", "cacheRead", "cacheWrite"]);
318
+ const input = expectNumber(issues, `${path}.input`, value.input, { min: 0 });
319
+ const output = expectNumber(issues, `${path}.output`, value.output, { min: 0 });
320
+ if (input === void 0 || output === void 0) return void 0;
321
+ const out = { input, output };
322
+ if ("cacheRead" in value) {
323
+ const v = expectNumber(issues, `${path}.cacheRead`, value.cacheRead, { min: 0 });
324
+ if (v !== void 0) out.cacheRead = v;
325
+ }
326
+ if ("cacheWrite" in value) {
327
+ const v = expectNumber(issues, `${path}.cacheWrite`, value.cacheWrite, { min: 0 });
328
+ if (v !== void 0) out.cacheWrite = v;
329
+ }
330
+ return out;
331
+ }
332
+ function validateLmStudioSettings(issues, path, value) {
333
+ if (!isPlainObject(value)) {
334
+ issues.add(path, `expected a map, got ${describe(value)}`);
335
+ return void 0;
336
+ }
337
+ issues.unknownKeys(path, value, ["load", "request"]);
338
+ const out = {};
339
+ if ("load" in value) {
340
+ if (!isPlainObject(value.load)) {
341
+ issues.add(`${path}.load`, `expected a map, got ${describe(value.load)}`);
342
+ } else {
343
+ issues.unknownKeys(`${path}.load`, value.load, [
344
+ "contextLength",
345
+ "flashAttention",
346
+ "evalBatchSize",
347
+ "numExperts",
348
+ "offloadKvCacheToGpu"
349
+ ]);
350
+ const load = {};
351
+ for (const key of ["contextLength", "evalBatchSize", "numExperts"]) {
352
+ if (key in value.load) {
353
+ const parsed = expectInteger(issues, `${path}.load.${key}`, value.load[key], { min: 1 });
354
+ if (parsed !== void 0) load[key] = parsed;
355
+ }
356
+ }
357
+ for (const key of ["flashAttention", "offloadKvCacheToGpu"]) {
358
+ if (key in value.load) {
359
+ const parsed = expectBoolean(issues, `${path}.load.${key}`, value.load[key]);
360
+ if (parsed !== void 0) load[key] = parsed;
361
+ }
362
+ }
363
+ if (Object.keys(load).length > 0) out.load = load;
364
+ }
365
+ }
366
+ if ("request" in value) {
367
+ if (!isPlainObject(value.request)) {
368
+ issues.add(`${path}.request`, `expected a map, got ${describe(value.request)}`);
369
+ } else {
370
+ issues.unknownKeys(`${path}.request`, value.request, ["ttlSeconds", "draftModel", "reasoning"]);
371
+ const request = {};
372
+ if ("ttlSeconds" in value.request) {
373
+ const parsed = expectInteger(issues, `${path}.request.ttlSeconds`, value.request.ttlSeconds, { min: 1 });
374
+ if (parsed !== void 0) request.ttlSeconds = parsed;
375
+ }
376
+ if ("draftModel" in value.request) {
377
+ const parsed = expectString(issues, `${path}.request.draftModel`, value.request.draftModel);
378
+ if (parsed !== void 0) request.draftModel = parsed;
379
+ }
380
+ if ("reasoning" in value.request) {
381
+ const parsed = expectEnum(issues, `${path}.request.reasoning`, value.request.reasoning, [
382
+ "auto",
383
+ "off",
384
+ "on",
385
+ "low",
386
+ "medium",
387
+ "high"
388
+ ]);
389
+ if (parsed !== void 0) request.reasoning = parsed;
390
+ }
391
+ if (Object.keys(request).length > 0) out.request = request;
392
+ }
393
+ }
394
+ return Object.keys(out).length > 0 ? out : void 0;
395
+ }
396
+ function validateTarget(issues, path, value) {
397
+ if (!isPlainObject(value)) {
398
+ issues.add(path, `expected a map, got ${describe(value)}`);
399
+ return null;
400
+ }
401
+ issues.unknownKeys(path, value, [
402
+ "id",
403
+ "runtime",
404
+ "url",
405
+ "auth",
406
+ "defaultModel",
407
+ "wireModels",
408
+ "capabilities",
409
+ "lifecycle",
410
+ "gateway",
411
+ "pricing",
412
+ "lmstudio",
413
+ "maxConcurrentRequests"
414
+ ]);
415
+ const id = "id" in value ? expectString(issues, `${path}.id`, value.id) : void 0;
416
+ const runtime = "runtime" in value ? expectString(issues, `${path}.runtime`, value.runtime) : void 0;
417
+ if (!("id" in value)) issues.add(`${path}.id`, "required");
418
+ if (!("runtime" in value)) issues.add(`${path}.runtime`, "required");
419
+ if (id === void 0 || runtime === void 0) return null;
420
+ const target = { id, runtime };
421
+ if ("url" in value) {
422
+ const v = expectString(issues, `${path}.url`, value.url);
423
+ if (v !== void 0) target.url = v;
424
+ }
425
+ if ("auth" in value) {
426
+ const v = validateAuth(issues, `${path}.auth`, value.auth);
427
+ if (v !== void 0) target.auth = v;
428
+ }
429
+ if ("wireModels" in value) {
430
+ const v = expectStringArray(issues, `${path}.wireModels`, value.wireModels);
431
+ if (v !== void 0 && v.length > 0) target.wireModels = v;
432
+ }
433
+ if ("defaultModel" in value) {
434
+ const v = expectString(issues, `${path}.defaultModel`, value.defaultModel);
435
+ if (v !== void 0) target.defaultModel = v;
436
+ } else if (target.wireModels?.[0]) {
437
+ target.defaultModel = target.wireModels[0];
438
+ }
439
+ if ("capabilities" in value) {
440
+ const v = validateCapabilities(issues, `${path}.capabilities`, value.capabilities);
441
+ if (v !== void 0) target.capabilities = v;
442
+ }
443
+ if ("lifecycle" in value) {
444
+ const v = expectEnum(
445
+ issues,
446
+ `${path}.lifecycle`,
447
+ normalizeLegacyNamingValue(value.lifecycle, "clio-managed", "clio-coder-managed"),
448
+ ["user-managed", "clio-coder-managed"]
449
+ );
450
+ if (v !== void 0) target.lifecycle = v;
451
+ }
452
+ if ("gateway" in value) {
453
+ const v = expectBoolean(issues, `${path}.gateway`, value.gateway);
454
+ if (v !== void 0) target.gateway = v;
455
+ }
456
+ if ("pricing" in value) {
457
+ const v = validatePricing(issues, `${path}.pricing`, value.pricing);
458
+ if (v !== void 0) target.pricing = v;
459
+ }
460
+ if ("lmstudio" in value) {
461
+ const v = validateLmStudioSettings(issues, `${path}.lmstudio`, value.lmstudio);
462
+ if (v !== void 0) target.lmstudio = v;
463
+ }
464
+ if ("maxConcurrentRequests" in value) {
465
+ const v = expectInteger(issues, `${path}.maxConcurrentRequests`, value.maxConcurrentRequests, { min: 1 });
466
+ if (v !== void 0) target.maxConcurrentRequests = v;
467
+ }
468
+ return target;
469
+ }
470
+ var SETTINGS_V1_PATH_MOVES = Object.freeze([
471
+ ["autonomy", "safety.autonomy"],
472
+ ["orchestrator.target", "chat.target"],
473
+ ["orchestrator.model", "chat.model"],
474
+ ["orchestrator.thinkingLevel", "chat.thinkingLevel"],
475
+ ["scope[]", "chat.modelPicker.cycleSet[]"],
476
+ ["modelSelector.favorites[]", "chat.modelPicker.favorites[]"],
477
+ ["modelSelector.recentLimit", "chat.modelPicker.recentLimit"],
478
+ ["defaults.maxTokens", "chat.maxOutputTokens"],
479
+ ["prewarm.enabled", "chat.prewarm"],
480
+ ["retry.enabled", "chat.retry.enabled"],
481
+ ["retry.maxRetries", "chat.retry.maxRetries"],
482
+ ["retry.baseDelayMs", "chat.retry.baseDelayMs"],
483
+ ["retry.maxDelayMs", "chat.retry.maxDelayMs"],
484
+ ["retry.streamStallMs", "chat.retry.streamStallMs"],
485
+ ["workers.default.target", "fleet.default.target"],
486
+ ["workers.default.model", "fleet.default.model"],
487
+ ["workers.default.thinkingLevel", "fleet.default.thinkingLevel"],
488
+ ["workers.default.node", "fleet.default.node"],
489
+ ["workers.profiles.*.target", "fleet.profiles.*.target"],
490
+ ["workers.profiles.*.model", "fleet.profiles.*.model"],
491
+ ["workers.profiles.*.thinkingLevel", "fleet.profiles.*.thinkingLevel"],
492
+ ["workers.profiles.*.node", "fleet.profiles.*.node"],
493
+ ["workers.rosters.*.members[].label", "fleet.rosters.*.members[].label"],
494
+ ["workers.rosters.*.members[].target", "fleet.rosters.*.members[].target"],
495
+ ["workers.rosters.*.members[].model", "fleet.rosters.*.members[].model"],
496
+ ["workers.rosters.*.members[].thinking", "fleet.rosters.*.members[].thinkingLevel"],
497
+ ["workers.rosters.*.members[].color", "fleet.rosters.*.members[].color"],
498
+ ["workers.agentBindings.*", "fleet.agentProfiles.*"],
499
+ ["routing.activeRoles[]", "fleet.adaptiveRouting.roles[]"],
500
+ ["routing.activePostures[]", "fleet.adaptiveRouting.postures[]"],
501
+ ["routing.agentAutomation.activeAgentRoles[].agentId", "fleet.adaptiveRouting.agentRoles[].agentId"],
502
+ ["routing.agentAutomation.activeAgentRoles[].executionRole", "fleet.adaptiveRouting.agentRoles[].executionRole"],
503
+ ["budget.concurrency", "fleet.concurrency"],
504
+ ["workers.maxRetries", "fleet.retry.maxRetries"],
505
+ ["workers.resilienceCooldownMs", "fleet.retry.routeCooldownMs"],
506
+ ["workers.onPermission", "fleet.permissions.mode"],
507
+ ["workers.escalation.timeoutMs", "fleet.permissions.escalation.timeoutMs"],
508
+ ["workers.escalation.fallback", "fleet.permissions.escalation.fallback"],
509
+ ["guardrails.workerToolCallCap", "fleet.limits.toolCallsPerRun"],
510
+ ["guardrails.internalDispatchTimeoutMs", "fleet.limits.internalRunTimeoutMs"],
511
+ ["guardrails.maxDispatchRuns", "fleet.history.maxRuns"],
512
+ ["compaction.auto", "context.compaction.auto"],
513
+ ["compaction.threshold", "context.compaction.threshold"],
514
+ ["compaction.model", "context.compaction.model"],
515
+ ["compaction.systemPrompt", "context.compaction.systemPrompt"],
516
+ ["background.target", "context.memory.target"],
517
+ ["background.model", "context.memory.model"],
518
+ ["memory.intervention.enabled", "context.memory.enabled"],
519
+ ["memory.intervention.everyNTools", "context.memory.cadenceToolCalls"],
520
+ ["memory.intervention.windowSteps", "context.memory.trajectorySteps"],
521
+ ["memory.intervention.maxTokens", "context.memory.maxOutputTokens"],
522
+ ["memory.intervention.timeoutMs", "context.memory.timeoutMs"],
523
+ ["budget.sessionCeilingUsd", "safety.limits.sessionCostUsd"],
524
+ ["guardrails.turnToolCallBudget", "safety.limits.chatToolCallsPerTurn"],
525
+ ["guardrails.readMaxBytes", "safety.limits.readBytesPerCall"],
526
+ ["guardrails.observationTurnBudgetBytes", "safety.limits.observationBytesPerTurn"],
527
+ ["watchdog.enabled", "safety.review.enabled"],
528
+ ["watchdog.target", "safety.review.target"],
529
+ ["watchdog.cadenceToolCalls", "safety.review.cadenceToolCalls"],
530
+ ["terminal.outputVerbosity", "interface.outputDetail"],
531
+ ["terminal.smoothStreaming", "interface.smoothStreaming"],
532
+ ["terminal.tuiMode", "interface.mode"],
533
+ ["terminal.fullscreenScrollbar", "interface.fullscreenScrollbar"],
534
+ ["terminal.showTerminalProgress", "interface.terminalProgress"],
535
+ ["terminal.notify", "interface.desktopNotifications"],
536
+ // The panes keys shipped for exactly one release (v0.4.0, the day before
537
+ // this rework) but they did ship, and each has a direct v2 successor with
538
+ // an identical value domain, so they move like everything else. The
539
+ // retired agents/keepFailed pair and the `panes` root itself stay in
540
+ // SETTINGS_V1_RETIRED-adjacent handling via V1_ONLY_ROOTS.
541
+ ["panes.enabled", "interface.panes.enabled"],
542
+ ["panes.notifications", "interface.panes.notifications"],
543
+ ["panes.journal", "fleet.history.journal"],
544
+ ["panes.yazi.enabled", "interface.panes.files.enabled"],
545
+ ["panes.yazi.mode", "interface.panes.files.mode"],
546
+ ["panes.yazi.profile", "interface.panes.files.profile"],
547
+ ["panes.yazi.followCwd", "interface.panes.files.followCwd"],
548
+ ["keybindings.*", "interface.keybindings.*"],
549
+ ["skills.trustProjectCompatRoots", "integrations.projectResources.trustProjectImports"],
550
+ ["delegation.defaults.connectTimeoutMs", "integrations.externalAgents.defaults.connectTimeoutMs"],
551
+ ["delegation.defaults.turnTimeoutMs", "integrations.externalAgents.defaults.turnTimeoutMs"],
552
+ ["delegation.defaults.permissionTimeoutMs", "integrations.externalAgents.defaults.permissionTimeoutMs"],
553
+ ["delegation.defaults.toolGovernance", "integrations.externalAgents.defaults.toolGovernance"],
554
+ ["delegation.agents[].id", "integrations.externalAgents.entries[].id"],
555
+ ["delegation.agents[].command", "integrations.externalAgents.entries[].command"],
556
+ ["delegation.agents[].args[]", "integrations.externalAgents.entries[].args[]"],
557
+ ["delegation.agents[].cwd", "integrations.externalAgents.entries[].cwd"],
558
+ ["delegation.agents[].env.*", "integrations.externalAgents.entries[].env.*"],
559
+ ["delegation.agents[].connectTimeoutMs", "integrations.externalAgents.entries[].connectTimeoutMs"],
560
+ ["delegation.agents[].turnTimeoutMs", "integrations.externalAgents.entries[].turnTimeoutMs"],
561
+ ["delegation.agents[].permissionTimeoutMs", "integrations.externalAgents.entries[].permissionTimeoutMs"],
562
+ ["delegation.agents[].stallTimeoutMs", "integrations.externalAgents.entries[].stallTimeoutMs"],
563
+ ["delegation.agents[].toolGovernance", "integrations.externalAgents.entries[].toolGovernance"],
564
+ ["delegation.agents[].projectContext", "integrations.externalAgents.entries[].projectContext"],
565
+ ["delegation.agents[].labels.*", "integrations.externalAgents.entries[].labels.*"],
566
+ ["runtimePlugins[]", "integrations.runtimePlugins[]"],
567
+ ["library.catalog", "integrations.library.catalog"],
568
+ ["library.remote", "integrations.library.remote"],
569
+ ["library.confirmedRemote", "integrations.library.confirmedRemote"],
570
+ ["library.sync", "integrations.library.sync"],
571
+ ["attribution.gitCommits", "integrations.git.commitAttribution"],
572
+ ["fleet.nodes[].clioEntry", "fleet.nodes[].clioCoderEntry"]
573
+ ]);
574
+ var SETTINGS_V1_RETIRED_PATHS = Object.freeze({
575
+ identity: "it was accepted and ignored; no behavior is lost",
576
+ "background.thinkingLevel": "proactive memory always resolves thinking off",
577
+ theme: "the only registered theme was not read by runtime rendering",
578
+ "compaction.excludeLastTurns": "only the temporary legacy mask used it; context.workingSet.protectLastTurns remains"
579
+ });
580
+ var V1_ONLY_ROOTS = /* @__PURE__ */ new Set([
581
+ "identity",
582
+ "autonomy",
583
+ "runtimePlugins",
584
+ "orchestrator",
585
+ "background",
586
+ "memory",
587
+ "watchdog",
588
+ "workers",
589
+ "routing",
590
+ "scope",
591
+ "modelSelector",
592
+ "budget",
593
+ "defaults",
594
+ "theme",
595
+ "terminal",
596
+ "skills",
597
+ "library",
598
+ "attribution",
599
+ "delegation",
600
+ "keybindings",
601
+ "compaction",
602
+ "prewarm",
603
+ "panes",
604
+ "retry",
605
+ "guardrails"
606
+ ]);
607
+ function pathPatternSegments(pattern) {
608
+ return pattern.split(".");
609
+ }
610
+ function patternMatches(value, pattern) {
611
+ const out = [];
612
+ const visit = (current, segments, path) => {
613
+ const segment = segments[0];
614
+ if (segment === void 0) {
615
+ out.push({ path });
616
+ return;
617
+ }
618
+ const rest = segments.slice(1);
619
+ if (segment === "*") {
620
+ if (!isPlainObject(current)) return;
621
+ for (const [key2, child2] of Object.entries(current)) visit(child2, rest, path ? `${path}.${key2}` : key2);
622
+ return;
623
+ }
624
+ const list = segment.endsWith("[]");
625
+ const key = list ? segment.slice(0, -2) : segment;
626
+ if (!isPlainObject(current) || !(key in current)) return;
627
+ const child = current[key];
628
+ const nextPath = path ? `${path}.${key}` : key;
629
+ if (!list) {
630
+ visit(child, rest, nextPath);
631
+ return;
632
+ }
633
+ if (!Array.isArray(child)) return;
634
+ for (let index = 0; index < child.length; index += 1) visit(child[index], rest, `${nextPath}[${index}]`);
635
+ };
636
+ visit(value, pathPatternSegments(pattern), "");
637
+ return out;
638
+ }
639
+ function reportV1Tombstones(issues, raw) {
640
+ const reportedRoots = /* @__PURE__ */ new Set();
641
+ for (const [from, to] of SETTINGS_V1_PATH_MOVES) {
642
+ for (const match of patternMatches(raw, from)) {
643
+ issues.add(match.path, `retired settings-v1 path; use ${to} in version 2`);
644
+ reportedRoots.add(match.path.split(/[.[]/u)[0] ?? match.path);
645
+ }
646
+ }
647
+ for (const [path, reason] of Object.entries(SETTINGS_V1_RETIRED_PATHS)) {
648
+ for (const match of patternMatches(raw, path)) {
649
+ issues.add(match.path, `retired without replacement: ${reason}. Remove this key`);
650
+ reportedRoots.add(match.path.split(/[.[]/u)[0] ?? match.path);
651
+ }
652
+ }
653
+ for (const root of V1_ONLY_ROOTS) {
654
+ if (root in raw && !reportedRoots.has(root)) {
655
+ const replacements = new Set(
656
+ SETTINGS_V1_PATH_MOVES.filter(([from]) => from.split(/[.[]/u)[0] === root).map(
657
+ ([, to]) => to.split(/[.[]/u)[0] ?? to
658
+ )
659
+ );
660
+ const hint = replacements.size > 0 ? `; use ${[...replacements].join(" or ")} in version 2` : "";
661
+ issues.add(root, `retired settings-v1 namespace${hint}; migrate this document with \`clio-coder upgrade\``);
662
+ }
663
+ }
664
+ }
665
+ function validateRoute(issues, path, value, defaults, targets, options) {
666
+ const out = cloneValue(defaults);
667
+ if (!isPlainObject(value)) {
668
+ issues.add(path, `expected a map, got ${describe(value)}`);
669
+ return out;
670
+ }
671
+ const allowNode = options?.nodeIds !== void 0;
672
+ issues.unknownKeys(
673
+ path,
674
+ value,
675
+ allowNode ? ["target", "model", "thinkingLevel", "node"] : ["target", "model", "thinkingLevel"]
676
+ );
677
+ if ("target" in value) {
678
+ if (value.target === null) out.target = null;
679
+ else {
680
+ const parsed = expectString(issues, `${path}.target`, value.target);
681
+ if (parsed !== void 0) out.target = targets.some((entry) => entry.id === parsed) ? parsed : null;
682
+ }
683
+ }
684
+ if ("model" in value) {
685
+ if (value.model === null) out.model = null;
686
+ else {
687
+ const parsed = expectString(issues, `${path}.model`, value.model);
688
+ if (parsed !== void 0) out.model = parsed;
689
+ }
690
+ }
691
+ if ("thinkingLevel" in value) {
692
+ const parsed = expectEnum(issues, `${path}.thinkingLevel`, value.thinkingLevel, THINKING_LEVELS);
693
+ if (parsed !== void 0) out.thinkingLevel = parsed;
694
+ }
695
+ if (allowNode && "node" in value) {
696
+ if (value.node === null) delete out.node;
697
+ else {
698
+ const parsed = expectString(issues, `${path}.node`, value.node);
699
+ if (parsed !== void 0 && (parsed === "local" || options.nodeIds?.has(parsed) === true)) out.node = parsed;
700
+ }
701
+ }
702
+ if (!out.target) out.model = null;
703
+ else if (out.model === null) out.model = targets.find((entry) => entry.id === out.target)?.defaultModel ?? null;
704
+ return out;
705
+ }
706
+ function normalizeModelRefs(refs, targets) {
707
+ const targetIds = new Set(targets.map((target) => target.id));
708
+ return refs.filter((ref) => {
709
+ const [targetId, ...model] = ref.split("/");
710
+ return Boolean(targetId && targetIds.has(targetId) && model.join("/").trim());
711
+ });
712
+ }
713
+ function normalizeCycleSet(refs) {
714
+ return refs.filter((ref) => Boolean(ref.trim().split("/")[0]));
715
+ }
716
+ function validateExternalAgent(issues, path, value, defaults, seen) {
717
+ if (!isPlainObject(value)) {
718
+ issues.add(path, `expected a map, got ${describe(value)}`);
719
+ return null;
720
+ }
721
+ issues.unknownKeys(path, value, [
722
+ "id",
723
+ "command",
724
+ "args",
725
+ "cwd",
726
+ "env",
727
+ "connectTimeoutMs",
728
+ "turnTimeoutMs",
729
+ "permissionTimeoutMs",
730
+ "stallTimeoutMs",
731
+ "toolGovernance",
732
+ "projectContext",
733
+ "labels"
734
+ ]);
735
+ const id = "id" in value ? expectString(issues, `${path}.id`, value.id) : void 0;
736
+ const command = "command" in value ? expectString(issues, `${path}.command`, value.command) : void 0;
737
+ if (!("id" in value)) issues.add(`${path}.id`, "required");
738
+ if (!("command" in value)) issues.add(`${path}.command`, "required");
739
+ if (id === void 0 || command === void 0) return null;
740
+ if (id === "auto") {
741
+ issues.add(`${path}.id`, "'auto' is reserved for coordinator-owned agent selection");
742
+ return null;
743
+ }
744
+ if (seen.has(id)) {
745
+ issues.add(`${path}.id`, `duplicate external agent id '${id}'`);
746
+ return null;
747
+ }
748
+ seen.add(id);
749
+ const agent = {
750
+ id,
751
+ command,
752
+ args: [],
753
+ connectTimeoutMs: defaults.connectTimeoutMs,
754
+ turnTimeoutMs: defaults.turnTimeoutMs,
755
+ permissionTimeoutMs: defaults.permissionTimeoutMs,
756
+ toolGovernance: defaults.toolGovernance
757
+ };
758
+ if ("args" in value) {
759
+ const parsed = expectStringArray(issues, `${path}.args`, value.args);
760
+ if (parsed !== void 0) agent.args = parsed;
761
+ }
762
+ for (const key of ["connectTimeoutMs", "turnTimeoutMs", "permissionTimeoutMs"]) {
763
+ if (!(key in value)) continue;
764
+ const parsed = expectInteger(issues, `${path}.${key}`, value[key], { min: 1, max: MAX_TIMER_DELAY_MS });
765
+ if (parsed !== void 0) agent[key] = parsed;
766
+ }
767
+ if ("stallTimeoutMs" in value) {
768
+ const parsed = expectInteger(issues, `${path}.stallTimeoutMs`, value.stallTimeoutMs);
769
+ if (parsed !== void 0) agent.stallTimeoutMs = parsed;
770
+ }
771
+ if ("toolGovernance" in value) {
772
+ const parsed = expectEnum(
773
+ issues,
774
+ `${path}.toolGovernance`,
775
+ normalizeLegacyNamingValue(value.toolGovernance, "clio-policy", "clio-coder-policy"),
776
+ TOOL_GOVERNANCE
777
+ );
778
+ if (parsed !== void 0) agent.toolGovernance = parsed;
779
+ }
780
+ if ("projectContext" in value) {
781
+ const parsed = expectEnum(issues, `${path}.projectContext`, value.projectContext, ["none", "bounded"]);
782
+ if (parsed !== void 0) agent.projectContext = parsed;
783
+ }
784
+ for (const key of ["cwd"]) {
785
+ if (!(key in value)) continue;
786
+ const parsed = expectString(issues, `${path}.${key}`, value[key]);
787
+ if (parsed !== void 0) agent[key] = parsed;
788
+ }
789
+ for (const key of ["env", "labels"]) {
790
+ if (!(key in value)) continue;
791
+ const parsed = expectStringRecord(issues, `${path}.${key}`, value[key]);
792
+ if (parsed !== void 0 && Object.keys(parsed).length > 0) agent[key] = parsed;
793
+ }
794
+ return agent;
795
+ }
796
+ function validateFleetNode(issues, path, value, seen) {
797
+ if (!isPlainObject(value)) {
798
+ issues.add(path, `expected a map, got ${describe(value)}`);
799
+ return null;
800
+ }
801
+ issues.unknownKeys(path, value, [
802
+ "id",
803
+ "host",
804
+ "user",
805
+ "port",
806
+ "identityFile",
807
+ "clioCoderEntry",
808
+ "clioEntry",
809
+ "labels",
810
+ "maxWorkers",
811
+ "residency"
812
+ ]);
813
+ const id = "id" in value ? expectString(issues, `${path}.id`, value.id) : void 0;
814
+ const host = "host" in value ? expectString(issues, `${path}.host`, value.host) : void 0;
815
+ if (!("id" in value)) issues.add(`${path}.id`, "required");
816
+ if (!("host" in value)) issues.add(`${path}.host`, "required");
817
+ if (id === void 0 || host === void 0) return null;
818
+ if (id === "local") {
819
+ issues.add(`${path}.id`, "'local' is reserved for the implicit local node");
820
+ return null;
821
+ }
822
+ if (seen.has(id)) {
823
+ issues.add(`${path}.id`, `duplicate fleet node id '${id}'`);
824
+ return null;
825
+ }
826
+ seen.add(id);
827
+ const node = { id, host, maxWorkers: 2 };
828
+ for (const key of ["user", "identityFile", "clioCoderEntry"]) {
829
+ if (!(key in value)) continue;
830
+ const parsed = expectString(issues, `${path}.${key}`, value[key]);
831
+ if (parsed !== void 0) node[key] = parsed;
832
+ }
833
+ if ("port" in value) {
834
+ const parsed = expectInteger(issues, `${path}.port`, value.port, { min: 1 });
835
+ if (parsed !== void 0) node.port = parsed;
836
+ }
837
+ if ("labels" in value) {
838
+ const parsed = expectStringArray(issues, `${path}.labels`, value.labels);
839
+ if (parsed !== void 0) node.labels = parsed;
840
+ }
841
+ if ("maxWorkers" in value) {
842
+ const parsed = expectInteger(issues, `${path}.maxWorkers`, value.maxWorkers, { min: 1 });
843
+ if (parsed !== void 0) node.maxWorkers = parsed;
844
+ }
845
+ if ("residency" in value) {
846
+ const parsed = expectEnum(issues, `${path}.residency`, value.residency, ["observe", "manage"]);
847
+ if (parsed !== void 0) node.residency = parsed;
848
+ }
849
+ return node;
850
+ }
851
+ function validateKeybindings(issues, path, value) {
852
+ if (!isPlainObject(value)) {
853
+ issues.add(path, `expected a map, got ${describe(value)}`);
854
+ return {};
855
+ }
856
+ const next = {};
857
+ for (const [rawKey, rawValue] of Object.entries(value)) {
858
+ const legacyId = rawKey.trim();
859
+ const id = legacyId.startsWith("clio.") ? `clio-coder.${legacyId.slice("clio.".length)}` : legacyId;
860
+ if (!id) {
861
+ issues.add(path, "empty keybinding id");
862
+ continue;
863
+ }
864
+ if (id !== legacyId) {
865
+ warnLegacyNaming(legacyId, id);
866
+ if (Object.hasOwn(value, id)) continue;
867
+ }
868
+ if (typeof rawValue === "string") {
869
+ const parsed = expectString(issues, `${path}.${legacyId}`, rawValue);
870
+ if (parsed !== void 0) next[id] = parsed;
871
+ } else if (Array.isArray(rawValue)) {
872
+ const parsed = expectStringArray(issues, `${path}.${legacyId}`, rawValue);
873
+ if (parsed !== void 0 && parsed.length > 0) next[id] = parsed;
874
+ } else issues.add(`${path}.${legacyId}`, `expected a string or list of strings, got ${describe(rawValue)}`);
875
+ }
876
+ return next;
877
+ }
878
+ var TOP_LEVEL_KEYS = [
879
+ "version",
880
+ "targets",
881
+ "chat",
882
+ "fleet",
883
+ "context",
884
+ "safety",
885
+ "interface",
886
+ "integrations",
887
+ ...V1_ONLY_ROOTS
888
+ ];
889
+ function validateSettings(raw) {
890
+ const issues = new Issues();
891
+ const settings = cloneValue(DEFAULT_SETTINGS);
892
+ if (!isPlainObject(raw)) {
893
+ issues.add("(root)", `expected a map, got ${describe(raw)}`);
894
+ return { settings, issues: issues.list };
895
+ }
896
+ reportV1Tombstones(issues, raw);
897
+ issues.unknownKeys("", raw, TOP_LEVEL_KEYS);
898
+ if ("version" in raw && raw.version !== 2) {
899
+ issues.add("version", `expected 2, got ${describe(raw.version)}; run \`clio-coder upgrade\` for version 1`);
900
+ }
901
+ if ("targets" in raw) {
902
+ if (!Array.isArray(raw.targets)) issues.add("targets", `expected a list, got ${describe(raw.targets)}`);
903
+ else {
904
+ const seen = /* @__PURE__ */ new Set();
905
+ const targets = [];
906
+ for (let index = 0; index < raw.targets.length; index += 1) {
907
+ const target = validateTarget(issues, `targets[${index}]`, raw.targets[index]);
908
+ if (!target) continue;
909
+ if (seen.has(target.id)) {
910
+ issues.add(`targets[${index}].id`, `duplicate target id '${target.id}'`);
911
+ continue;
912
+ }
913
+ seen.add(target.id);
914
+ targets.push(target);
915
+ }
916
+ settings.targets = targets;
917
+ }
918
+ }
919
+ if ("chat" in raw) {
920
+ if (!isPlainObject(raw.chat)) issues.add("chat", `expected a map, got ${describe(raw.chat)}`);
921
+ else {
922
+ const chat = raw.chat;
923
+ issues.unknownKeys("chat", chat, [
924
+ "target",
925
+ "model",
926
+ "thinkingLevel",
927
+ "modelPicker",
928
+ "maxOutputTokens",
929
+ "prewarm",
930
+ "retry"
931
+ ]);
932
+ const routeInput = {};
933
+ for (const key of ["target", "model", "thinkingLevel"]) {
934
+ if (key in chat) routeInput[key] = chat[key];
935
+ }
936
+ const route = validateRoute(
937
+ issues,
938
+ "chat",
939
+ routeInput,
940
+ { target: settings.chat.target, model: settings.chat.model, thinkingLevel: settings.chat.thinkingLevel },
941
+ settings.targets
942
+ );
943
+ settings.chat.target = route.target;
944
+ settings.chat.model = route.model;
945
+ settings.chat.thinkingLevel = route.thinkingLevel;
946
+ if ("modelPicker" in chat) {
947
+ if (!isPlainObject(chat.modelPicker))
948
+ issues.add("chat.modelPicker", `expected a map, got ${describe(chat.modelPicker)}`);
949
+ else {
950
+ issues.unknownKeys("chat.modelPicker", chat.modelPicker, ["cycleSet", "favorites", "recentLimit"]);
951
+ if ("cycleSet" in chat.modelPicker) {
952
+ const parsed = expectStringArray(issues, "chat.modelPicker.cycleSet", chat.modelPicker.cycleSet);
953
+ if (parsed !== void 0) settings.chat.modelPicker.cycleSet = normalizeCycleSet(parsed);
954
+ }
955
+ if ("favorites" in chat.modelPicker) {
956
+ const parsed = expectStringArray(issues, "chat.modelPicker.favorites", chat.modelPicker.favorites);
957
+ if (parsed !== void 0) settings.chat.modelPicker.favorites = normalizeModelRefs(parsed, settings.targets);
958
+ }
959
+ if ("recentLimit" in chat.modelPicker) {
960
+ const parsed = expectInteger(issues, "chat.modelPicker.recentLimit", chat.modelPicker.recentLimit, { min: 1 });
961
+ if (parsed !== void 0) settings.chat.modelPicker.recentLimit = parsed;
962
+ }
963
+ }
964
+ }
965
+ if ("maxOutputTokens" in chat) {
966
+ const parsed = expectInteger(issues, "chat.maxOutputTokens", chat.maxOutputTokens, { min: 0 });
967
+ if (parsed !== void 0) settings.chat.maxOutputTokens = parsed;
968
+ }
969
+ if ("prewarm" in chat) {
970
+ const parsed = expectBoolean(issues, "chat.prewarm", chat.prewarm);
971
+ if (parsed !== void 0) settings.chat.prewarm = parsed;
972
+ }
973
+ if ("retry" in chat) {
974
+ if (!isPlainObject(chat.retry)) issues.add("chat.retry", `expected a map, got ${describe(chat.retry)}`);
975
+ else {
976
+ issues.unknownKeys("chat.retry", chat.retry, [
977
+ "enabled",
978
+ "maxRetries",
979
+ "baseDelayMs",
980
+ "maxDelayMs",
981
+ "streamStallMs"
982
+ ]);
983
+ if ("enabled" in chat.retry) {
984
+ const parsed = expectBoolean(issues, "chat.retry.enabled", chat.retry.enabled);
985
+ if (parsed !== void 0) settings.chat.retry.enabled = parsed;
986
+ }
987
+ for (const key of ["maxRetries", "baseDelayMs", "maxDelayMs", "streamStallMs"]) {
988
+ if (!(key in chat.retry)) continue;
989
+ const parsed = expectInteger(issues, `chat.retry.${key}`, chat.retry[key], { min: 0 });
990
+ if (parsed !== void 0) settings.chat.retry[key] = parsed;
991
+ }
992
+ }
993
+ }
994
+ }
995
+ }
996
+ let rawFleet = null;
997
+ if ("fleet" in raw) {
998
+ if (!isPlainObject(raw.fleet)) issues.add("fleet", `expected a map, got ${describe(raw.fleet)}`);
999
+ else {
1000
+ rawFleet = raw.fleet;
1001
+ issues.unknownKeys("fleet", rawFleet, [
1002
+ "default",
1003
+ "profiles",
1004
+ "rosters",
1005
+ "agentProfiles",
1006
+ "adaptiveRouting",
1007
+ "nodes",
1008
+ "permissions",
1009
+ "concurrency",
1010
+ "retry",
1011
+ "limits",
1012
+ "history"
1013
+ ]);
1014
+ }
1015
+ }
1016
+ if (rawFleet && "nodes" in rawFleet) {
1017
+ if (!Array.isArray(rawFleet.nodes)) issues.add("fleet.nodes", `expected a list, got ${describe(rawFleet.nodes)}`);
1018
+ else {
1019
+ const seen = /* @__PURE__ */ new Set();
1020
+ settings.fleet.nodes = rawFleet.nodes.map((entry, index) => validateFleetNode(issues, `fleet.nodes[${index}]`, entry, seen)).filter((entry) => entry !== null);
1021
+ }
1022
+ }
1023
+ const fleetNodeIds = new Set(settings.fleet.nodes.map((node) => node.id));
1024
+ if (rawFleet) {
1025
+ if ("default" in rawFleet) {
1026
+ settings.fleet.default = validateRoute(
1027
+ issues,
1028
+ "fleet.default",
1029
+ rawFleet.default,
1030
+ settings.fleet.default,
1031
+ settings.targets,
1032
+ {
1033
+ nodeIds: fleetNodeIds
1034
+ }
1035
+ );
1036
+ }
1037
+ if ("profiles" in rawFleet) {
1038
+ if (!isPlainObject(rawFleet.profiles))
1039
+ issues.add("fleet.profiles", `expected a map, got ${describe(rawFleet.profiles)}`);
1040
+ else {
1041
+ const profiles = {};
1042
+ for (const [rawName, rawProfile] of Object.entries(rawFleet.profiles)) {
1043
+ const name = rawName.trim();
1044
+ if (!name) {
1045
+ issues.add("fleet.profiles", "empty profile name");
1046
+ continue;
1047
+ }
1048
+ const profile = validateRoute(
1049
+ issues,
1050
+ `fleet.profiles.${name}`,
1051
+ rawProfile,
1052
+ DEFAULT_SETTINGS.fleet.default,
1053
+ settings.targets,
1054
+ {
1055
+ nodeIds: fleetNodeIds
1056
+ }
1057
+ );
1058
+ if (profile.target) profiles[name] = profile;
1059
+ }
1060
+ settings.fleet.profiles = profiles;
1061
+ }
1062
+ }
1063
+ if ("rosters" in rawFleet) {
1064
+ if (!isPlainObject(rawFleet.rosters))
1065
+ issues.add("fleet.rosters", `expected a map, got ${describe(rawFleet.rosters)}`);
1066
+ else {
1067
+ const rosters = {};
1068
+ for (const [rawName, rawRoster] of Object.entries(rawFleet.rosters)) {
1069
+ const name = rawName.trim();
1070
+ const path = `fleet.rosters.${name}`;
1071
+ if (!name) {
1072
+ issues.add("fleet.rosters", "empty roster name");
1073
+ continue;
1074
+ }
1075
+ if (!isPlainObject(rawRoster)) {
1076
+ issues.add(path, `expected a map, got ${describe(rawRoster)}`);
1077
+ continue;
1078
+ }
1079
+ issues.unknownKeys(path, rawRoster, ["members"]);
1080
+ if (!Array.isArray(rawRoster.members)) {
1081
+ issues.add(`${path}.members`, "expected a list");
1082
+ continue;
1083
+ }
1084
+ if (rawRoster.members.length < 2 || rawRoster.members.length > 5)
1085
+ issues.add(`${path}.members`, "expected 2 to 5 members");
1086
+ const members = [];
1087
+ const labels = /* @__PURE__ */ new Set();
1088
+ for (const [index, rawMember] of rawRoster.members.entries()) {
1089
+ const memberPath = `${path}.members[${index}]`;
1090
+ if (!isPlainObject(rawMember)) {
1091
+ issues.add(memberPath, `expected a map, got ${describe(rawMember)}`);
1092
+ continue;
1093
+ }
1094
+ issues.unknownKeys(memberPath, rawMember, ["label", "target", "model", "thinkingLevel", "color"]);
1095
+ const label = expectString(issues, `${memberPath}.label`, rawMember.label);
1096
+ const target = expectString(issues, `${memberPath}.target`, rawMember.target);
1097
+ if (label !== void 0 && !COUNCIL_MEMBER_LABEL_PATTERN.test(label))
1098
+ issues.add(`${memberPath}.label`, "expected [a-z][a-z0-9_-]{0,31}");
1099
+ if (label !== void 0 && labels.has(label)) issues.add(`${memberPath}.label`, "duplicate label");
1100
+ if (label !== void 0) labels.add(label);
1101
+ if (target !== void 0 && !settings.targets.some((entry) => entry.id === target))
1102
+ issues.add(`${memberPath}.target`, `unknown target '${target}'`);
1103
+ const model = rawMember.model === void 0 ? void 0 : expectString(issues, `${memberPath}.model`, rawMember.model);
1104
+ const thinkingLevel = rawMember.thinkingLevel === void 0 ? void 0 : expectEnum(issues, `${memberPath}.thinkingLevel`, rawMember.thinkingLevel, THINKING_LEVELS);
1105
+ const color = rawMember.color === void 0 ? void 0 : expectString(issues, `${memberPath}.color`, rawMember.color);
1106
+ if (color !== void 0 && !THEME_NAMED_COLORS.includes(color) && !/^#[0-9a-fA-F]{6}$/u.test(color)) {
1107
+ issues.add(`${memberPath}.color`, "expected a theme named color or 6-digit hex color");
1108
+ }
1109
+ if (label === void 0 || target === void 0) continue;
1110
+ members.push({
1111
+ label,
1112
+ target,
1113
+ ...model ? { model } : {},
1114
+ ...thinkingLevel ? { thinkingLevel } : {},
1115
+ ...color ? { color } : {}
1116
+ });
1117
+ }
1118
+ if (rawRoster.members.length >= 2 && rawRoster.members.length <= 5 && members.length === rawRoster.members.length)
1119
+ rosters[name] = { members };
1120
+ }
1121
+ settings.fleet.rosters = rosters;
1122
+ }
1123
+ }
1124
+ if ("agentProfiles" in rawFleet) {
1125
+ if (!isPlainObject(rawFleet.agentProfiles))
1126
+ issues.add("fleet.agentProfiles", `expected a map, got ${describe(rawFleet.agentProfiles)}`);
1127
+ else {
1128
+ const bindings = {};
1129
+ for (const [rawAgentId, rawProfileName] of Object.entries(rawFleet.agentProfiles)) {
1130
+ const agentId = rawAgentId.trim();
1131
+ if (!agentId) {
1132
+ issues.add("fleet.agentProfiles", "empty agent id");
1133
+ continue;
1134
+ }
1135
+ if (agentId === "auto") {
1136
+ issues.add("fleet.agentProfiles", "'auto' is reserved for coordinator-owned agent selection");
1137
+ continue;
1138
+ }
1139
+ const profile = expectString(issues, `fleet.agentProfiles.${agentId}`, rawProfileName);
1140
+ if (profile !== void 0) bindings[agentId] = profile;
1141
+ }
1142
+ settings.fleet.agentProfiles = bindings;
1143
+ }
1144
+ }
1145
+ if ("adaptiveRouting" in rawFleet) {
1146
+ if (!isPlainObject(rawFleet.adaptiveRouting))
1147
+ issues.add("fleet.adaptiveRouting", `expected a map, got ${describe(rawFleet.adaptiveRouting)}`);
1148
+ else {
1149
+ const adaptive = rawFleet.adaptiveRouting;
1150
+ issues.unknownKeys("fleet.adaptiveRouting", adaptive, ["roles", "postures", "agentRoles"]);
1151
+ for (const [key, allowed] of [
1152
+ ["roles", ACTIVE_ROUTING_ROLES],
1153
+ ["postures", ACTIVE_ROUTING_POSTURES]
1154
+ ]) {
1155
+ if (!(key in adaptive)) continue;
1156
+ const parsed = expectStringArray(issues, `fleet.adaptiveRouting.${key}`, adaptive[key]);
1157
+ if (parsed === void 0) continue;
1158
+ const allowedSet = new Set(allowed);
1159
+ for (const value of parsed)
1160
+ if (!allowedSet.has(value))
1161
+ issues.add(`fleet.adaptiveRouting.${key}`, `unsupported ${key === "roles" ? "role" : "posture"} '${value}'`);
1162
+ if (parsed.every((value) => allowedSet.has(value))) settings.fleet.adaptiveRouting[key] = parsed;
1163
+ }
1164
+ if ("agentRoles" in adaptive) {
1165
+ if (!Array.isArray(adaptive.agentRoles)) issues.add("fleet.adaptiveRouting.agentRoles", "expected a list");
1166
+ else {
1167
+ const pairs = [];
1168
+ const seen = /* @__PURE__ */ new Set();
1169
+ for (const [index, value] of adaptive.agentRoles.entries()) {
1170
+ const path = `fleet.adaptiveRouting.agentRoles[${index}]`;
1171
+ if (!isPlainObject(value)) {
1172
+ issues.add(path, "expected a map");
1173
+ continue;
1174
+ }
1175
+ issues.unknownKeys(path, value, ["agentId", "executionRole"]);
1176
+ const agentId = expectString(issues, `${path}.agentId`, value.agentId);
1177
+ const executionRole = expectEnum(
1178
+ issues,
1179
+ `${path}.executionRole`,
1180
+ value.executionRole,
1181
+ ACTIVE_AGENT_AUTOMATION_ROLES
1182
+ );
1183
+ if (agentId === "auto")
1184
+ issues.add(`${path}.agentId`, "'auto' is reserved for coordinator-owned agent selection");
1185
+ if (agentId === void 0 || agentId === "auto" || executionRole === void 0) continue;
1186
+ const pairKey = `${agentId}\0${executionRole}`;
1187
+ if (seen.has(pairKey)) {
1188
+ issues.add(path, "duplicate agent and execution-role pair");
1189
+ continue;
1190
+ }
1191
+ seen.add(pairKey);
1192
+ pairs.push({ agentId, executionRole });
1193
+ }
1194
+ if (pairs.length === adaptive.agentRoles.length) settings.fleet.adaptiveRouting.agentRoles = pairs;
1195
+ }
1196
+ }
1197
+ }
1198
+ }
1199
+ if ("permissions" in rawFleet) {
1200
+ if (!isPlainObject(rawFleet.permissions))
1201
+ issues.add("fleet.permissions", `expected a map, got ${describe(rawFleet.permissions)}`);
1202
+ else {
1203
+ issues.unknownKeys("fleet.permissions", rawFleet.permissions, ["mode", "escalation"]);
1204
+ if ("mode" in rawFleet.permissions) {
1205
+ const parsed = expectEnum(issues, "fleet.permissions.mode", rawFleet.permissions.mode, [
1206
+ "deny",
1207
+ "fail",
1208
+ "escalate"
1209
+ ]);
1210
+ if (parsed !== void 0) settings.fleet.permissions.mode = parsed;
1211
+ }
1212
+ if ("escalation" in rawFleet.permissions) {
1213
+ if (!isPlainObject(rawFleet.permissions.escalation))
1214
+ issues.add("fleet.permissions.escalation", `expected a map, got ${describe(rawFleet.permissions.escalation)}`);
1215
+ else {
1216
+ const escalation = rawFleet.permissions.escalation;
1217
+ issues.unknownKeys("fleet.permissions.escalation", escalation, ["timeoutMs", "fallback"]);
1218
+ if ("timeoutMs" in escalation) {
1219
+ const parsed = expectInteger(issues, "fleet.permissions.escalation.timeoutMs", escalation.timeoutMs, { min: 1 });
1220
+ if (parsed !== void 0) settings.fleet.permissions.escalation.timeoutMs = parsed;
1221
+ }
1222
+ if ("fallback" in escalation) {
1223
+ const parsed = expectEnum(issues, "fleet.permissions.escalation.fallback", escalation.fallback, [
1224
+ "deny",
1225
+ "fail"
1226
+ ]);
1227
+ if (parsed !== void 0) settings.fleet.permissions.escalation.fallback = parsed;
1228
+ }
1229
+ }
1230
+ }
1231
+ }
1232
+ }
1233
+ if ("concurrency" in rawFleet) {
1234
+ if (rawFleet.concurrency === "auto") settings.fleet.concurrency = "auto";
1235
+ else {
1236
+ const parsed = expectInteger(issues, "fleet.concurrency", rawFleet.concurrency, { min: 1 });
1237
+ if (parsed !== void 0) settings.fleet.concurrency = parsed;
1238
+ }
1239
+ }
1240
+ for (const [blockName, fields] of [
1241
+ [
1242
+ "retry",
1243
+ [
1244
+ ["maxRetries", 0],
1245
+ ["routeCooldownMs", 0]
1246
+ ]
1247
+ ],
1248
+ [
1249
+ "limits",
1250
+ [
1251
+ ["toolCallsPerRun", 1],
1252
+ ["internalRunTimeoutMs", 1]
1253
+ ]
1254
+ ],
1255
+ ["history", [["maxRuns", 1]]]
1256
+ ]) {
1257
+ if (!(blockName in rawFleet)) continue;
1258
+ const block = rawFleet[blockName];
1259
+ if (!isPlainObject(block)) {
1260
+ issues.add(`fleet.${blockName}`, `expected a map, got ${describe(block)}`);
1261
+ continue;
1262
+ }
1263
+ const known = fields.map(([key]) => key);
1264
+ if (blockName === "history") known.push("journal");
1265
+ issues.unknownKeys(`fleet.${blockName}`, block, known);
1266
+ for (const [key, min] of fields) {
1267
+ if (!(key in block)) continue;
1268
+ const parsed = expectInteger(issues, `fleet.${blockName}.${key}`, block[key], { min });
1269
+ if (parsed !== void 0) settings.fleet[blockName][key] = parsed;
1270
+ }
1271
+ if (blockName === "history" && "journal" in block) {
1272
+ const parsed = expectBoolean(issues, "fleet.history.journal", block.journal);
1273
+ if (parsed !== void 0) settings.fleet.history.journal = parsed;
1274
+ }
1275
+ }
1276
+ }
1277
+ if ("context" in raw) {
1278
+ if (!isPlainObject(raw.context)) issues.add("context", `expected a map, got ${describe(raw.context)}`);
1279
+ else {
1280
+ const context = raw.context;
1281
+ issues.unknownKeys("context", context, ["workingSet", "compaction", "memory"]);
1282
+ if ("workingSet" in context) {
1283
+ if (!isPlainObject(context.workingSet))
1284
+ issues.add("context.workingSet", `expected a map, got ${describe(context.workingSet)}`);
1285
+ else {
1286
+ const workingSet = context.workingSet;
1287
+ issues.unknownKeys("context.workingSet", workingSet, [
1288
+ "enabled",
1289
+ "policy",
1290
+ "target",
1291
+ "protectLastTurns",
1292
+ "minEvictableTokens"
1293
+ ]);
1294
+ if ("enabled" in workingSet) {
1295
+ const parsed = expectBoolean(issues, "context.workingSet.enabled", workingSet.enabled);
1296
+ if (parsed !== void 0) settings.context.workingSet.enabled = parsed;
1297
+ }
1298
+ if ("policy" in workingSet) {
1299
+ const parsed = expectEnum(issues, "context.workingSet.policy", workingSet.policy, [
1300
+ "age-horizon",
1301
+ "structural-v1"
1302
+ ]);
1303
+ if (parsed !== void 0) settings.context.workingSet.policy = parsed;
1304
+ }
1305
+ if ("target" in workingSet) {
1306
+ const parsed = expectNumber(issues, "context.workingSet.target", workingSet.target);
1307
+ if (parsed !== void 0 && (parsed <= 0 || parsed >= 1))
1308
+ issues.add("context.workingSet.target", `expected a number > 0 and < 1, got ${parsed}`);
1309
+ else if (parsed !== void 0) settings.context.workingSet.target = parsed;
1310
+ }
1311
+ for (const [key, min] of [
1312
+ ["protectLastTurns", 1],
1313
+ ["minEvictableTokens", 0]
1314
+ ]) {
1315
+ if (!(key in workingSet)) continue;
1316
+ const parsed = expectInteger(issues, `context.workingSet.${key}`, workingSet[key], { min });
1317
+ if (parsed !== void 0) settings.context.workingSet[key] = parsed;
1318
+ }
1319
+ }
1320
+ }
1321
+ if ("compaction" in context) {
1322
+ if (!isPlainObject(context.compaction))
1323
+ issues.add("context.compaction", `expected a map, got ${describe(context.compaction)}`);
1324
+ else {
1325
+ const compaction = context.compaction;
1326
+ issues.unknownKeys("context.compaction", compaction, [
1327
+ "auto",
1328
+ "threshold",
1329
+ "model",
1330
+ "systemPrompt",
1331
+ "excludeLastTurns"
1332
+ ]);
1333
+ if ("excludeLastTurns" in compaction)
1334
+ issues.add(
1335
+ "context.compaction.excludeLastTurns",
1336
+ "retired without replacement; use context.workingSet.protectLastTurns"
1337
+ );
1338
+ if ("auto" in compaction) {
1339
+ const parsed = expectBoolean(issues, "context.compaction.auto", compaction.auto);
1340
+ if (parsed !== void 0) settings.context.compaction.auto = parsed;
1341
+ }
1342
+ if ("threshold" in compaction) {
1343
+ const parsed = expectNumber(issues, "context.compaction.threshold", compaction.threshold, { min: 0, max: 1 });
1344
+ if (parsed !== void 0) settings.context.compaction.threshold = parsed;
1345
+ }
1346
+ for (const key of ["model", "systemPrompt"]) {
1347
+ if (!(key in compaction)) continue;
1348
+ const parsed = expectString(issues, `context.compaction.${key}`, compaction[key]);
1349
+ if (parsed !== void 0) settings.context.compaction[key] = parsed;
1350
+ }
1351
+ }
1352
+ }
1353
+ if ("memory" in context) {
1354
+ if (!isPlainObject(context.memory)) issues.add("context.memory", `expected a map, got ${describe(context.memory)}`);
1355
+ else {
1356
+ const memory = context.memory;
1357
+ issues.unknownKeys("context.memory", memory, [
1358
+ "enabled",
1359
+ "target",
1360
+ "model",
1361
+ "cadenceToolCalls",
1362
+ "trajectorySteps",
1363
+ "maxOutputTokens",
1364
+ "timeoutMs"
1365
+ ]);
1366
+ if ("enabled" in memory) {
1367
+ const parsed = expectBoolean(issues, "context.memory.enabled", memory.enabled);
1368
+ if (parsed !== void 0) settings.context.memory.enabled = parsed;
1369
+ }
1370
+ if ("target" in memory) {
1371
+ if (memory.target === null) settings.context.memory.target = null;
1372
+ else {
1373
+ const parsed = expectString(issues, "context.memory.target", memory.target);
1374
+ if (parsed !== void 0)
1375
+ settings.context.memory.target = settings.targets.some((target) => target.id === parsed) ? parsed : null;
1376
+ }
1377
+ }
1378
+ if ("model" in memory) {
1379
+ if (memory.model === null) settings.context.memory.model = null;
1380
+ else {
1381
+ const parsed = expectString(issues, "context.memory.model", memory.model);
1382
+ if (parsed !== void 0) settings.context.memory.model = parsed;
1383
+ }
1384
+ }
1385
+ if (!settings.context.memory.target) settings.context.memory.model = null;
1386
+ else if (settings.context.memory.model === null)
1387
+ settings.context.memory.model = settings.targets.find((target) => target.id === settings.context.memory.target)?.defaultModel ?? null;
1388
+ for (const [key, min] of [
1389
+ ["cadenceToolCalls", 2],
1390
+ ["trajectorySteps", 1],
1391
+ ["maxOutputTokens", 1],
1392
+ ["timeoutMs", 1]
1393
+ ]) {
1394
+ if (!(key in memory)) continue;
1395
+ const parsed = expectInteger(issues, `context.memory.${key}`, memory[key], { min });
1396
+ if (parsed !== void 0) settings.context.memory[key] = parsed;
1397
+ }
1398
+ }
1399
+ }
1400
+ }
1401
+ }
1402
+ if ("safety" in raw) {
1403
+ if (!isPlainObject(raw.safety)) issues.add("safety", `expected a map, got ${describe(raw.safety)}`);
1404
+ else {
1405
+ const safety = raw.safety;
1406
+ issues.unknownKeys("safety", safety, ["autonomy", "limits", "review"]);
1407
+ if ("autonomy" in safety) {
1408
+ const parsed = expectEnum(issues, "safety.autonomy", safety.autonomy, AUTONOMY_LEVELS);
1409
+ if (parsed !== void 0) settings.safety.autonomy = parsed;
1410
+ }
1411
+ if ("limits" in safety) {
1412
+ if (!isPlainObject(safety.limits)) issues.add("safety.limits", `expected a map, got ${describe(safety.limits)}`);
1413
+ else {
1414
+ const limits = safety.limits;
1415
+ issues.unknownKeys("safety.limits", limits, [
1416
+ "sessionCostUsd",
1417
+ "chatToolCallsPerTurn",
1418
+ "readBytesPerCall",
1419
+ "observationBytesPerTurn"
1420
+ ]);
1421
+ if ("sessionCostUsd" in limits) {
1422
+ const parsed = expectNumber(issues, "safety.limits.sessionCostUsd", limits.sessionCostUsd, { min: 0 });
1423
+ if (parsed !== void 0) settings.safety.limits.sessionCostUsd = parsed;
1424
+ }
1425
+ for (const key of ["chatToolCallsPerTurn", "readBytesPerCall", "observationBytesPerTurn"]) {
1426
+ if (!(key in limits)) continue;
1427
+ const parsed = expectInteger(issues, `safety.limits.${key}`, limits[key], { min: 1 });
1428
+ if (parsed !== void 0) settings.safety.limits[key] = parsed;
1429
+ }
1430
+ }
1431
+ }
1432
+ if ("review" in safety) {
1433
+ if (!isPlainObject(safety.review)) issues.add("safety.review", `expected a map, got ${describe(safety.review)}`);
1434
+ else {
1435
+ const review = safety.review;
1436
+ issues.unknownKeys("safety.review", review, ["enabled", "target", "cadenceToolCalls"]);
1437
+ if ("enabled" in review) {
1438
+ const parsed = expectBoolean(issues, "safety.review.enabled", review.enabled);
1439
+ if (parsed !== void 0) settings.safety.review.enabled = parsed;
1440
+ }
1441
+ if ("target" in review && review.target !== null) {
1442
+ const parsed = expectString(issues, "safety.review.target", review.target);
1443
+ if (parsed !== void 0 && settings.targets.some((target) => target.id === parsed))
1444
+ settings.safety.review.target = parsed;
1445
+ else if (parsed !== void 0) issues.add("safety.review.target", `unknown target '${parsed}'`);
1446
+ }
1447
+ if ("cadenceToolCalls" in review && review.cadenceToolCalls !== null) {
1448
+ const parsed = expectInteger(issues, "safety.review.cadenceToolCalls", review.cadenceToolCalls, { min: 1 });
1449
+ if (parsed !== void 0) settings.safety.review.cadenceToolCalls = parsed;
1450
+ }
1451
+ }
1452
+ }
1453
+ }
1454
+ }
1455
+ if ("interface" in raw) {
1456
+ if (!isPlainObject(raw.interface)) issues.add("interface", `expected a map, got ${describe(raw.interface)}`);
1457
+ else {
1458
+ const ui = raw.interface;
1459
+ issues.unknownKeys("interface", ui, [
1460
+ "outputDetail",
1461
+ "smoothStreaming",
1462
+ "mode",
1463
+ "fullscreenScrollbar",
1464
+ "terminalProgress",
1465
+ "desktopNotifications",
1466
+ "panes",
1467
+ "keybindings"
1468
+ ]);
1469
+ for (const key of ["terminalProgress", "desktopNotifications"]) {
1470
+ if (!(key in ui)) continue;
1471
+ const parsed = expectBoolean(issues, `interface.${key}`, ui[key]);
1472
+ if (parsed !== void 0) settings.interface[key] = parsed;
1473
+ }
1474
+ for (const [key, allowed] of [
1475
+ ["outputDetail", ["minimal", "default", "verbose"]],
1476
+ ["smoothStreaming", ["off", "auto", "on"]],
1477
+ ["mode", ["regular", "fullscreen"]],
1478
+ ["fullscreenScrollbar", ["hidden", "auto", "always"]]
1479
+ ]) {
1480
+ if (!(key in ui)) continue;
1481
+ const parsed = expectEnum(issues, `interface.${key}`, ui[key], allowed);
1482
+ if (parsed !== void 0) settings.interface[key] = parsed;
1483
+ }
1484
+ if ("panes" in ui) {
1485
+ if (!isPlainObject(ui.panes)) issues.add("interface.panes", `expected a map, got ${describe(ui.panes)}`);
1486
+ else {
1487
+ const panes = ui.panes;
1488
+ issues.unknownKeys("interface.panes", panes, ["enabled", "notifications", "layout", "workers", "files"]);
1489
+ if ("enabled" in panes) {
1490
+ const parsed = expectEnum(issues, "interface.panes.enabled", panes.enabled, ["auto", "embedded", "off"]);
1491
+ if (parsed !== void 0) settings.interface.panes.enabled = parsed;
1492
+ }
1493
+ if ("notifications" in panes) {
1494
+ const parsed = expectEnum(issues, "interface.panes.notifications", panes.notifications, [
1495
+ "failures",
1496
+ "all",
1497
+ "off"
1498
+ ]);
1499
+ if (parsed !== void 0) settings.interface.panes.notifications = parsed;
1500
+ }
1501
+ if ("layout" in panes) {
1502
+ const parsed = expectEnum(issues, "interface.panes.layout", panes.layout, ["off", "workers", "cockpit"]);
1503
+ if (parsed !== void 0) settings.interface.panes.layout = parsed;
1504
+ }
1505
+ if ("workers" in panes) {
1506
+ if (!isPlainObject(panes.workers))
1507
+ issues.add("interface.panes.workers", `expected a map, got ${describe(panes.workers)}`);
1508
+ else {
1509
+ const workers = panes.workers;
1510
+ issues.unknownKeys("interface.panes.workers", workers, ["ratio"]);
1511
+ if ("ratio" in workers) {
1512
+ const parsed = expectNumber(issues, "interface.panes.workers.ratio", workers.ratio, {
1513
+ min: 0.05,
1514
+ max: 0.5
1515
+ });
1516
+ if (parsed !== void 0) settings.interface.panes.workers.ratio = parsed;
1517
+ }
1518
+ }
1519
+ }
1520
+ if ("files" in panes) {
1521
+ if (!isPlainObject(panes.files))
1522
+ issues.add("interface.panes.files", `expected a map, got ${describe(panes.files)}`);
1523
+ else {
1524
+ const files = panes.files;
1525
+ issues.unknownKeys("interface.panes.files", files, ["enabled", "mode", "profile", "followCwd", "ratio"]);
1526
+ for (const key of ["enabled", "followCwd"]) {
1527
+ if (!(key in files)) continue;
1528
+ const parsed = expectBoolean(issues, `interface.panes.files.${key}`, files[key]);
1529
+ if (parsed !== void 0) settings.interface.panes.files[key] = parsed;
1530
+ }
1531
+ if ("mode" in files) {
1532
+ const parsed = expectEnum(issues, "interface.panes.files.mode", files.mode, ["companion", "chooser"]);
1533
+ if (parsed !== void 0) settings.interface.panes.files.mode = parsed;
1534
+ }
1535
+ if ("profile" in files) {
1536
+ const parsed = expectEnum(issues, "interface.panes.files.profile", files.profile, ["managed", "user"]);
1537
+ if (parsed !== void 0) settings.interface.panes.files.profile = parsed;
1538
+ }
1539
+ if ("ratio" in files) {
1540
+ const parsed = expectNumber(issues, "interface.panes.files.ratio", files.ratio, { min: 0.05, max: 0.5 });
1541
+ if (parsed !== void 0) settings.interface.panes.files.ratio = parsed;
1542
+ }
1543
+ }
1544
+ }
1545
+ }
1546
+ }
1547
+ if ("keybindings" in ui)
1548
+ settings.interface.keybindings = validateKeybindings(issues, "interface.keybindings", ui.keybindings);
1549
+ }
1550
+ }
1551
+ if ("integrations" in raw) {
1552
+ if (!isPlainObject(raw.integrations)) issues.add("integrations", `expected a map, got ${describe(raw.integrations)}`);
1553
+ else {
1554
+ const integrations = raw.integrations;
1555
+ issues.unknownKeys("integrations", integrations, [
1556
+ "projectResources",
1557
+ "externalAgents",
1558
+ "runtimePlugins",
1559
+ "library",
1560
+ "git"
1561
+ ]);
1562
+ if ("projectResources" in integrations) {
1563
+ if (!isPlainObject(integrations.projectResources))
1564
+ issues.add("integrations.projectResources", `expected a map, got ${describe(integrations.projectResources)}`);
1565
+ else {
1566
+ issues.unknownKeys("integrations.projectResources", integrations.projectResources, ["trustProjectImports"]);
1567
+ if ("trustProjectImports" in integrations.projectResources) {
1568
+ const parsed = expectBoolean(
1569
+ issues,
1570
+ "integrations.projectResources.trustProjectImports",
1571
+ integrations.projectResources.trustProjectImports
1572
+ );
1573
+ if (parsed !== void 0) settings.integrations.projectResources.trustProjectImports = parsed;
1574
+ }
1575
+ }
1576
+ }
1577
+ if ("runtimePlugins" in integrations) {
1578
+ const parsed = expectStringArray(issues, "integrations.runtimePlugins", integrations.runtimePlugins);
1579
+ if (parsed !== void 0) settings.integrations.runtimePlugins = parsed;
1580
+ }
1581
+ if ("library" in integrations) {
1582
+ if (!isPlainObject(integrations.library))
1583
+ issues.add("integrations.library", `expected a map, got ${describe(integrations.library)}`);
1584
+ else {
1585
+ const library = integrations.library;
1586
+ issues.unknownKeys("integrations.library", library, ["catalog", "remote", "confirmedRemote", "sync"]);
1587
+ for (const key of ["catalog", "remote", "confirmedRemote"]) {
1588
+ if (!(key in library)) continue;
1589
+ const value = library[key];
1590
+ if (value !== null && typeof value !== "string")
1591
+ issues.add(`integrations.library.${key}`, `expected a string or null, got ${describe(value)}`);
1592
+ else settings.integrations.library[key] = value;
1593
+ }
1594
+ if ("sync" in library) {
1595
+ const parsed = expectBoolean(issues, "integrations.library.sync", library.sync);
1596
+ if (parsed !== void 0) settings.integrations.library.sync = parsed;
1597
+ }
1598
+ }
1599
+ }
1600
+ if ("git" in integrations) {
1601
+ if (!isPlainObject(integrations.git))
1602
+ issues.add("integrations.git", `expected a map, got ${describe(integrations.git)}`);
1603
+ else {
1604
+ issues.unknownKeys("integrations.git", integrations.git, ["commitAttribution"]);
1605
+ if ("commitAttribution" in integrations.git) {
1606
+ const parsed = expectBoolean(issues, "integrations.git.commitAttribution", integrations.git.commitAttribution);
1607
+ if (parsed !== void 0) settings.integrations.git.commitAttribution = parsed;
1608
+ }
1609
+ }
1610
+ }
1611
+ if ("externalAgents" in integrations) {
1612
+ if (!isPlainObject(integrations.externalAgents))
1613
+ issues.add("integrations.externalAgents", `expected a map, got ${describe(integrations.externalAgents)}`);
1614
+ else {
1615
+ const external = integrations.externalAgents;
1616
+ issues.unknownKeys("integrations.externalAgents", external, ["entries", "defaults"]);
1617
+ if ("defaults" in external) {
1618
+ if (!isPlainObject(external.defaults))
1619
+ issues.add("integrations.externalAgents.defaults", `expected a map, got ${describe(external.defaults)}`);
1620
+ else {
1621
+ const defaults = external.defaults;
1622
+ issues.unknownKeys("integrations.externalAgents.defaults", defaults, [
1623
+ "connectTimeoutMs",
1624
+ "turnTimeoutMs",
1625
+ "permissionTimeoutMs",
1626
+ "toolGovernance"
1627
+ ]);
1628
+ for (const key of ["connectTimeoutMs", "turnTimeoutMs", "permissionTimeoutMs"]) {
1629
+ if (!(key in defaults)) continue;
1630
+ const parsed = expectInteger(issues, `integrations.externalAgents.defaults.${key}`, defaults[key], {
1631
+ min: 1,
1632
+ max: MAX_TIMER_DELAY_MS
1633
+ });
1634
+ if (parsed !== void 0) settings.integrations.externalAgents.defaults[key] = parsed;
1635
+ }
1636
+ if ("toolGovernance" in defaults) {
1637
+ const parsed = expectEnum(
1638
+ issues,
1639
+ "integrations.externalAgents.defaults.toolGovernance",
1640
+ normalizeLegacyNamingValue(defaults.toolGovernance, "clio-policy", "clio-coder-policy"),
1641
+ TOOL_GOVERNANCE
1642
+ );
1643
+ if (parsed !== void 0) settings.integrations.externalAgents.defaults.toolGovernance = parsed;
1644
+ }
1645
+ }
1646
+ }
1647
+ if ("entries" in external) {
1648
+ if (!Array.isArray(external.entries))
1649
+ issues.add("integrations.externalAgents.entries", `expected a list, got ${describe(external.entries)}`);
1650
+ else {
1651
+ const seen = /* @__PURE__ */ new Set();
1652
+ settings.integrations.externalAgents.entries = external.entries.map(
1653
+ (entry, index) => validateExternalAgent(
1654
+ issues,
1655
+ `integrations.externalAgents.entries[${index}]`,
1656
+ entry,
1657
+ settings.integrations.externalAgents.defaults,
1658
+ seen
1659
+ )
1660
+ ).filter((entry) => entry !== null);
1661
+ }
1662
+ }
1663
+ }
1664
+ }
1665
+ }
1666
+ }
1667
+ return { settings, issues: issues.list };
1668
+ }
1669
+ function validateSettingsFile() {
1670
+ const path = join(resolveClioDirs().config, "settings.yaml");
1671
+ if (!existsSync(path)) return { settings: cloneValue(DEFAULT_SETTINGS), issues: [] };
1672
+ let text;
1673
+ try {
1674
+ text = readFileSync(path, "utf8");
1675
+ } catch (err) {
1676
+ return {
1677
+ settings: cloneValue(DEFAULT_SETTINGS),
1678
+ issues: [
1679
+ { path: "(root)", message: `unreadable: ${err instanceof Error ? err.message : String(err)}`, kind: "unreadable" }
1680
+ ]
1681
+ };
1682
+ }
1683
+ let parsed;
1684
+ try {
1685
+ parsed = (0, import_yaml.parse)(text);
1686
+ } catch (err) {
1687
+ return {
1688
+ settings: cloneValue(DEFAULT_SETTINGS),
1689
+ issues: [{ path: "(root)", message: `invalid YAML: ${yamlErrorSummary(err)}`, kind: "syntax" }]
1690
+ };
1691
+ }
1692
+ return validateSettings(parsed);
1693
+ }
1694
+ function readSettings() {
1695
+ const result = validateSettingsFile();
1696
+ if (result.issues.length > 0) throw new SettingsValidationError(result.issues);
1697
+ return result.settings;
1698
+ }
1699
+ function persistSettings(document) {
1700
+ safeResourceWrite(settingsPath(), (0, import_yaml.stringify)(document), { encoding: "utf8", mode: 420 });
1701
+ }
1702
+ function readSavedDocument() {
1703
+ const path = settingsPath();
1704
+ if (!existsSync(path)) return {};
1705
+ try {
1706
+ return (0, import_yaml.parse)(readFileSync(path, "utf8")) ?? {};
1707
+ } catch {
1708
+ return {};
1709
+ }
1710
+ }
1711
+ function applySettingsDelta(saved, before, after) {
1712
+ if (!isPlainObject(before) || !isPlainObject(after)) return cloneValue(after);
1713
+ const out = isPlainObject(saved) ? { ...saved } : {};
1714
+ for (const [key, next] of Object.entries(after)) {
1715
+ if (deepEquals(before[key], next)) continue;
1716
+ out[key] = applySettingsDelta(out[key], before[key], next);
1717
+ }
1718
+ for (const key of Object.keys(out)) {
1719
+ if (!(key in after)) delete out[key];
1720
+ }
1721
+ return out;
1722
+ }
1723
+ function deepEquals(a, b) {
1724
+ if (a === b) return true;
1725
+ if (Array.isArray(a) || Array.isArray(b)) {
1726
+ if (!Array.isArray(a) || !Array.isArray(b) || a.length !== b.length) return false;
1727
+ return a.every((entry, index) => deepEquals(entry, b[index]));
1728
+ }
1729
+ if (!isPlainObject(a) || !isPlainObject(b)) return false;
1730
+ const keys = Object.keys(a);
1731
+ if (keys.length !== Object.keys(b).length) return false;
1732
+ return keys.every((key) => key in b && deepEquals(a[key], b[key]));
1733
+ }
1734
+ function updateSavedSettingsDocument(mutate, options = {}) {
1735
+ withSettingsLock(() => {
1736
+ readSettings();
1737
+ const saved = readSavedDocument();
1738
+ persistSettings(mutate(cloneValue(saved)));
1739
+ }, options);
1740
+ }
1741
+ function withSettingsLock(fn, options = {}) {
1742
+ return withStateFileLockSync(settingsPath(), fn, { timeoutMs: options.timeoutMs ?? 1e4 });
1743
+ }
1744
+ function updateSettings(mutate, options = {}) {
1745
+ return withSettingsLock(() => {
1746
+ const saved = readSavedDocument();
1747
+ const current = readSettings();
1748
+ const before = cloneValue(current);
1749
+ const next = mutate(current) ?? current;
1750
+ const revalidated = validateSettings(JSON.parse(JSON.stringify(next)));
1751
+ if (revalidated.issues.length > 0) throw new SettingsValidationError(revalidated.issues);
1752
+ persistSettings(applySettingsDelta(saved, before, revalidated.settings));
1753
+ return revalidated.settings;
1754
+ }, options);
1755
+ }
1756
+ function useTargetInSettings(settings, targetId, options = {}) {
1757
+ const target = settings.targets.find((entry) => entry.id === targetId);
1758
+ if (!target) return null;
1759
+ const workerTarget = options.workerTargetId !== void 0 && options.workerTargetId !== target.id ? settings.targets.find((entry) => entry.id === options.workerTargetId) : target;
1760
+ if (!workerTarget) return null;
1761
+ const sharedModel = options.model ?? target.defaultModel ?? null;
1762
+ settings.chat.target = target.id;
1763
+ settings.chat.model = options.orchestratorModel ?? sharedModel;
1764
+ settings.fleet.default.target = workerTarget.id;
1765
+ settings.fleet.default.model = options.workerModel ?? (workerTarget === target ? sharedModel : workerTarget.defaultModel ?? null);
1766
+ if (options.backgroundModel !== void 0) {
1767
+ settings.context.memory.target = target.id;
1768
+ settings.context.memory.model = options.backgroundModel;
1769
+ }
1770
+ return { workerTargetId: workerTarget.id };
1771
+ }
1772
+ function removeTargetFromSettings(settings, id) {
1773
+ if (!settings.targets.some((entry) => entry.id === id)) return false;
1774
+ settings.targets = settings.targets.filter((entry) => entry.id !== id);
1775
+ if (settings.chat.target === id) {
1776
+ settings.chat.target = null;
1777
+ settings.chat.model = null;
1778
+ }
1779
+ if (settings.context.memory.target === id) {
1780
+ settings.context.memory.target = null;
1781
+ settings.context.memory.model = null;
1782
+ }
1783
+ if (settings.fleet.default.target === id) {
1784
+ settings.fleet.default.target = null;
1785
+ settings.fleet.default.model = null;
1786
+ }
1787
+ for (const [name, profile] of Object.entries(settings.fleet.profiles)) {
1788
+ if (profile.target === id) delete settings.fleet.profiles[name];
1789
+ }
1790
+ settings.chat.modelPicker.cycleSet = settings.chat.modelPicker.cycleSet.filter((entry) => entry.split("/")[0] !== id);
1791
+ settings.chat.modelPicker.favorites = settings.chat.modelPicker.favorites.filter(
1792
+ (entry) => entry.split("/")[0] !== id
1793
+ );
1794
+ return true;
1795
+ }
1796
+ function setFleetProfileInSettings(settings, name, targetId, options = {}) {
1797
+ const target = settings.targets.find((entry) => entry.id === targetId);
1798
+ if (!target) return false;
1799
+ const existing = settings.fleet.profiles[name];
1800
+ settings.fleet.profiles[name] = {
1801
+ target: target.id,
1802
+ model: options.model ?? target.defaultModel ?? null,
1803
+ thinkingLevel: options.thinkingLevel ?? existing?.thinkingLevel ?? "off"
1804
+ };
1805
+ return true;
1806
+ }
1807
+ function removeFleetProfileFromSettings(settings, name) {
1808
+ delete settings.fleet.profiles[name];
1809
+ let removedBindings = 0;
1810
+ for (const [agentId, profileName] of Object.entries(settings.fleet.agentProfiles)) {
1811
+ if (profileName !== name) continue;
1812
+ delete settings.fleet.agentProfiles[agentId];
1813
+ removedBindings += 1;
1814
+ }
1815
+ return removedBindings;
1816
+ }
1817
+ function bindAgentProfileInSettings(settings, agentId, profileName) {
1818
+ if (settings.integrations.externalAgents.entries.some((agent) => agent.id === agentId)) return false;
1819
+ settings.fleet.agentProfiles[agentId] = profileName;
1820
+ return true;
1821
+ }
1822
+
1823
+ export {
1824
+ settingsPath,
1825
+ SettingsValidationError,
1826
+ formatSettingsIssues,
1827
+ formatSettingsFailure,
1828
+ SETTINGS_V1_PATH_MOVES,
1829
+ validateSettings,
1830
+ validateSettingsFile,
1831
+ readSettings,
1832
+ applySettingsDelta,
1833
+ updateSavedSettingsDocument,
1834
+ withSettingsLock,
1835
+ updateSettings,
1836
+ useTargetInSettings,
1837
+ removeTargetFromSettings,
1838
+ setFleetProfileInSettings,
1839
+ removeFleetProfileFromSettings,
1840
+ bindAgentProfileInSettings
1841
+ };
1842
+ //# sourceMappingURL=chunk-EIMVLWB3.js.map