@iowarp/clio-coder 0.4.0 → 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 (581) hide show
  1. package/CHANGELOG.md +39 -0
  2. package/README.md +116 -16
  3. package/dist/{acp-G5WJBNCT.js → acp-ZILU3AUO.js} +14 -14
  4. package/dist/{agents-FMV2Q5G4.js → agents-HYWGBGQR.js} +40 -29
  5. package/dist/assets/codewiki.json +1 -1
  6. package/dist/{auth-3IDSJEIK.js → auth-N3QT7CBO.js} +21 -19
  7. package/dist/{builtins-XCZWXSC7.js → builtins-UJLMOVOV.js} +6 -6
  8. package/dist/{chunk-PQEFIJ36.js → chunk-2LEAKD4C.js} +1 -2
  9. package/dist/{chunk-3BT2XMV4.js → chunk-2NM363SV.js} +50 -57
  10. package/dist/{chunk-J4W7KFM7.js → chunk-2VG7KLYV.js} +24 -279
  11. package/dist/{chunk-SST6Z5JA.js → chunk-336NSSKI.js} +1 -1
  12. package/dist/{chunk-K5C3NCBD.js → chunk-3I5NY75V.js} +5 -5
  13. package/dist/{chunk-VAZSBTKF.js → chunk-3QSOM6PA.js} +2 -2
  14. package/dist/{chunk-TZ3SGWZZ.js → chunk-5QIAJV2D.js} +2 -2
  15. package/dist/{chunk-OQBA45DZ.js → chunk-5YHDIDBP.js} +2 -2
  16. package/dist/{chunk-NHLBIGRH.js → chunk-6CCS4G3W.js} +40 -17
  17. package/dist/{chunk-2JDWVJND.js → chunk-6DWBAZ5U.js} +2 -2
  18. package/dist/{chunk-LDQ2ZF2M.js → chunk-6FN3E6KX.js} +5 -5
  19. package/dist/{chunk-X3YGUTOB.js → chunk-6HMJX2VU.js} +59 -59
  20. package/dist/{chunk-VEO4AP2K.js → chunk-6I5ILFOF.js} +3 -2
  21. package/dist/{chunk-B7OBL7PK.js → chunk-6NJQITNH.js} +18 -11
  22. package/dist/{chunk-IQ7KR472.js → chunk-6VC4OV3Z.js} +6 -3
  23. package/dist/{chunk-P3FOHJT4.js → chunk-72GZI5EV.js} +2 -2
  24. package/dist/{chunk-AB44T6BB.js → chunk-74YWRRU5.js} +8 -7
  25. package/dist/{chunk-SJ5ZKQ4S.js → chunk-7EPLI7VL.js} +2 -2
  26. package/dist/{chunk-HWHKMHUA.js → chunk-7OBGU7UB.js} +3 -3
  27. package/dist/{chunk-2OQE55CK.js → chunk-7PWAODYW.js} +2 -2
  28. package/dist/{chunk-IBEBSCYA.js → chunk-7RY5VZPH.js} +42 -33
  29. package/dist/{chunk-LQ3DZAMX.js → chunk-ABLSQ6JX.js} +2 -2
  30. package/dist/{chunk-QLFS5GO2.js → chunk-AFKWHWXF.js} +12 -22
  31. package/dist/{chunk-FWDFM5ZU.js → chunk-AK5XEFVZ.js} +3 -3
  32. package/dist/{chunk-O6TL7WWY.js → chunk-AKB4GYDL.js} +4 -4
  33. package/dist/chunk-AP73CFDC.js +308 -0
  34. package/dist/{chunk-JDG2WCRO.js → chunk-BBTJOK6Y.js} +5 -5
  35. package/dist/{chunk-SP2RXXYO.js → chunk-BDPT6GTK.js} +10 -10
  36. package/dist/{chunk-NQQH3YT7.js → chunk-BJGUKIG4.js} +3 -3
  37. package/dist/{chunk-O4XIVISU.js → chunk-BTGG6BG2.js} +79 -38
  38. package/dist/chunk-BTK3SSSK.js +67 -0
  39. package/dist/{chunk-M6L6IDJG.js → chunk-BWH6N36D.js} +1 -1
  40. package/dist/chunk-BWW4HLO4.js +301 -0
  41. package/dist/{chunk-I5VEOC6I.js → chunk-C537JADH.js} +10 -10
  42. package/dist/{chunk-HI63TFOG.js → chunk-CDNVLKUX.js} +3 -3
  43. package/dist/{chunk-UM7N4G5A.js → chunk-CWVRRIEI.js} +2 -2
  44. package/dist/{chunk-BKFM6EJV.js → chunk-D4CJV46V.js} +2 -2
  45. package/dist/chunk-D7E7WCDF.js +27 -0
  46. package/dist/{chunk-WZR7K7ZX.js → chunk-E67WX76H.js} +6 -6
  47. package/dist/{chunk-FQ4SKYE4.js → chunk-EBY63B7G.js} +2 -5
  48. package/dist/chunk-EIMVLWB3.js +1842 -0
  49. package/dist/{chunk-RAPCMZL4.js → chunk-FSP7CMNU.js} +9 -1
  50. package/dist/{chunk-MLKNTWH2.js → chunk-FYUN5KZ3.js} +21 -21
  51. package/dist/{chunk-YJX4SHTD.js → chunk-GIZNH63R.js} +1 -1
  52. package/dist/{chunk-X75E3D2N.js → chunk-GPPB3JBE.js} +18 -16
  53. package/dist/{chunk-GR5G2PVF.js → chunk-GVQJ5CCZ.js} +15 -10
  54. package/dist/chunk-HJWWJ6IL.js +184 -0
  55. package/dist/{chunk-VO67MWHC.js → chunk-HRQMFLJP.js} +3 -3
  56. package/dist/{chunk-VYMXRQI6.js → chunk-HUAS7ITX.js} +89 -93
  57. package/dist/{chunk-BKFJHQCA.js → chunk-I66EAJFY.js} +2 -2
  58. package/dist/{chunk-DYJP44XW.js → chunk-IG7BCQBA.js} +1 -1
  59. package/dist/{chunk-32KWKNSF.js → chunk-IXJT6DCX.js} +3 -3
  60. package/dist/{chunk-C2LTL2W6.js → chunk-J4HBWF6Y.js} +360 -172
  61. package/dist/chunk-J5LZHVIT.js +284 -0
  62. package/dist/{chunk-QLL7ILRG.js → chunk-JA5QWE4Z.js} +510 -202
  63. package/dist/{chunk-BBVJUZHB.js → chunk-JIEGK6UF.js} +5 -173
  64. package/dist/{chunk-36EJLSQQ.js → chunk-JZWT5J3Y.js} +4 -4
  65. package/dist/{chunk-HZHHCK24.js → chunk-K6BF4U2H.js} +476 -322
  66. package/dist/{chunk-Z2RR6MAK.js → chunk-MA3H6DM5.js} +6 -6
  67. package/dist/{chunk-CODPRO7Q.js → chunk-MOPSG2X7.js} +6 -6
  68. package/dist/{chunk-76ONBSIA.js → chunk-MQXIVJ35.js} +14 -5
  69. package/dist/{chunk-YDFRH54B.js → chunk-N5UK64DP.js} +4 -4
  70. package/dist/chunk-NDDGJUXD.js +81 -0
  71. package/dist/{chunk-4ZG3XFUR.js → chunk-NLFAQR7Z.js} +12 -1
  72. package/dist/{chunk-VO2LKSTM.js → chunk-O42A54GG.js} +2 -2
  73. package/dist/{chunk-W5VSYASO.js → chunk-OJTRZGR3.js} +46 -87
  74. package/dist/{chunk-NHCZP4K7.js → chunk-PBP4B7XR.js} +2 -2
  75. package/dist/{chunk-3URVFKWK.js → chunk-PJJ6MY27.js} +5 -5
  76. package/dist/{chunk-ZGVHUX3M.js → chunk-PMZVFWSR.js} +2 -2
  77. package/dist/{chunk-GKF55TAZ.js → chunk-PVAMAVBB.js} +3 -2
  78. package/dist/{chunk-6DB53AJS.js → chunk-QKIFBZKT.js} +7 -7
  79. package/dist/{chunk-HJJTYUHX.js → chunk-QMXC4JB7.js} +20 -20
  80. package/dist/chunk-QTFGO774.js +644 -0
  81. package/dist/{chunk-CY6FY24N.js → chunk-R23Z6K6I.js} +2 -2
  82. package/dist/{chunk-ULC6OTWO.js → chunk-R32CLGZ6.js} +13 -13
  83. package/dist/{chunk-KMVISBZR.js → chunk-RKSR6VSF.js} +1 -1
  84. package/dist/{chunk-F4CKPOEQ.js → chunk-SCYB3HA4.js} +72 -26
  85. package/dist/{chunk-LY4S7GJC.js → chunk-SINK3QR6.js} +18 -16
  86. package/dist/{chunk-U77AMWDL.js → chunk-TD3PGPQA.js} +43 -22
  87. package/dist/{chunk-QBJA7R7N.js → chunk-THYWACCR.js} +2 -2
  88. package/dist/{chunk-QREDIESB.js → chunk-TVH4ONAM.js} +14 -8
  89. package/dist/chunk-U2WB7TZS.js +271 -0
  90. package/dist/{chunk-KFZI4NIL.js → chunk-UAPGZHYC.js} +145 -31
  91. package/dist/{chunk-DQITNCXG.js → chunk-UEDMSP56.js} +29 -14
  92. package/dist/{chunk-3XML7CDN.js → chunk-UXN6JT4W.js} +2 -2
  93. package/dist/{chunk-CMZWFGD2.js → chunk-VAVR4IJY.js} +19 -15
  94. package/dist/{chunk-BPKCPIL7.js → chunk-VEGN6WIQ.js} +2 -2
  95. package/dist/chunk-VKFQTNDV.js +66 -0
  96. package/dist/{chunk-7MCTRUCE.js → chunk-VKRH2TCS.js} +2 -2
  97. package/dist/{chunk-5LXZXPKX.js → chunk-VN3SHNBN.js} +2 -2
  98. package/dist/{chunk-UOSL25KY.js → chunk-VXMFAE2W.js} +1 -1
  99. package/dist/{chunk-BBVYXMFO.js → chunk-WNP7O5WZ.js} +2 -2
  100. package/dist/{chunk-SUCTJL45.js → chunk-WR6U3OVP.js} +3 -3
  101. package/dist/{chunk-BUMFYQFY.js → chunk-XKA2ICR3.js} +124 -113
  102. package/dist/{chunk-UXMFQ54G.js → chunk-Y45G3AXC.js} +39 -39
  103. package/dist/{chunk-J5Q24KAG.js → chunk-Y4CAGMM6.js} +2 -2
  104. package/dist/{chunk-NYS75XW5.js → chunk-YAKGTXEV.js} +5 -3
  105. package/dist/{chunk-V5DHCITQ.js → chunk-ZAZB4JMW.js} +23 -12
  106. package/dist/{chunk-Z4TXYIEG.js → chunk-ZJLUDYFY.js} +9 -9
  107. package/dist/{chunk-HKIYEGME.js → chunk-ZTJUVLTU.js} +2 -2
  108. package/dist/{chunk-2ANTL7MR.js → chunk-ZW55JB7N.js} +2 -2
  109. package/dist/cli/index.js +36 -36
  110. package/dist/{clio-2JXHBBY5.js → clio-IT3G3VQH.js} +12 -13
  111. package/dist/{code-nav-3YYRMYNF.js → code-nav-RK6S7F6E.js} +5 -5
  112. package/dist/codewiki/build-worker.js +1 -1
  113. package/dist/{compile-cache-7FPE6PS3.js → compile-cache-OQAVB7Y5.js} +2 -4
  114. package/dist/{components-RYZV4JGP.js → components-UBWCQSRW.js} +4 -4
  115. package/dist/{config-QZPCMYSO.js → config-3QZRWZJF.js} +53 -49
  116. package/dist/{configure-TEGEBYCA.js → configure-FL7Y3KJF.js} +25 -22
  117. package/dist/{context-E6H5RNMC.js → context-5HE7ODYK.js} +47 -43
  118. package/dist/{context-AV7OEZ4D.js → context-KYQFRVDC.js} +11 -11
  119. package/dist/{context-GSXUE4CT.js → context-XNHL75JV.js} +32 -19
  120. package/dist/{context-clear-SHIBYK6T.js → context-clear-N545L53A.js} +47 -43
  121. package/dist/{context-working-set-5ZGKPGZQ.js → context-working-set-QHKXSV2F.js} +10 -9
  122. package/dist/{dispatch-runner-EFMJT4LD.js → dispatch-runner-RGIE5PCT.js} +56 -47
  123. package/dist/{docs-23KQS3XK.js → docs-5NAF6AU7.js} +5 -11
  124. package/dist/doctor-ZGPEGHIP.js +772 -0
  125. package/dist/{eval-TFBYQH4H.js → eval-GXLL44RD.js} +63 -45
  126. package/dist/{eval-inventory-SXH7PDKX.js → eval-inventory-HBWSWQOK.js} +7 -8
  127. package/dist/{evidence-ERGESKGN.js → evidence-HWLBRH3Q.js} +44 -40
  128. package/dist/{evolve-VDXTSYCJ.js → evolve-FTZBMNVW.js} +43 -39
  129. package/dist/{extensions-7BGBHN57.js → extensions-VHRBEID7.js} +4 -4
  130. package/dist/{fleet-2RRVDF2V.js → fleet-CKZHJWZJ.js} +86 -73
  131. package/dist/{fleet-commands-VJ726XIA.js → fleet-commands-EXDXBMV6.js} +10 -9
  132. package/dist/{fleet-decisions-EPAPM3XJ.js → fleet-decisions-OTHB6KRL.js} +5 -5
  133. package/dist/{fleet-graph-JF5QOATM.js → fleet-graph-YTEZUCUT.js} +13 -11
  134. package/dist/{fleet-inspect-VLY4S7QM.js → fleet-inspect-SS6YMDCK.js} +44 -41
  135. package/dist/{fleet-preflight-AIZUEJOY.js → fleet-preflight-PBY4VYOM.js} +5 -9
  136. package/dist/{fleet-validate-AJRPDMDV.js → fleet-validate-KMEM5L3S.js} +16 -13
  137. package/dist/{fleet-verify-JFEL2L3H.js → fleet-verify-QD5M7E7Q.js} +42 -39
  138. package/dist/{fleet-view-ZCON35AG.js → fleet-view-WAMJYNDT.js} +44 -52
  139. package/dist/{init-DN2WWLFE.js → init-5XQRBOFV.js} +63 -58
  140. package/dist/{install-XGLBQY5E.js → install-NKNG7KD4.js} +2 -2
  141. package/dist/{interop-OZBKXAYL.js → interop-34TVO25M.js} +13 -11
  142. package/dist/{library-YWZG7IMW.js → library-3QY6KF57.js} +17 -14
  143. package/dist/{memory-I4C4HMLW.js → memory-L4UTIIIW.js} +45 -41
  144. package/dist/{models-CEYXJBO6.js → models-ZVX3QOWE.js} +39 -31
  145. package/dist/{monitor-NZ6GCI3P.js → monitor-CEKVSYTS.js} +50 -46
  146. package/dist/{orchestrator-GCGQ4N5I.js → orchestrator-77BAP6BC.js} +1807 -1039
  147. package/dist/{panes-KY6W3V2E.js → panes-7STHOAUJ.js} +4 -4
  148. package/dist/{panes-HMABYVO4.js → panes-SHAUIRXY.js} +10 -8
  149. package/dist/{paths-II4K7DNR.js → paths-L7LGY6RN.js} +4 -4
  150. package/dist/{reset-DQ6FGCSH.js → reset-EOLM7GVE.js} +7 -8
  151. package/dist/{resources-BB3MVJMD.js → resources-74GKTLSF.js} +17 -13
  152. package/dist/{run-H2GQDUER.js → run-HBAUJNNZ.js} +86 -76
  153. package/dist/{share-GTJN6A5O.js → share-G3APVLVP.js} +17 -14
  154. package/dist/{skills-L55TEW6R.js → skills-35HHUKCR.js} +19 -16
  155. package/dist/{skills-eval-XVXPH2JI.js → skills-eval-QN4HSHDC.js} +55 -57
  156. package/dist/{skills-inventory-S4MXPJFV.js → skills-inventory-J357J34F.js} +15 -12
  157. package/dist/{slash-commands-ZSGASKJC.js → slash-commands-JZZCQA32.js} +31 -29
  158. package/dist/{steer-RZGSCY4R.js → steer-XAVHJM22.js} +3 -3
  159. package/dist/{support-PKEUNNQL.js → support-U7QOWY26.js} +6 -6
  160. package/dist/{targets-NCPZ644J.js → targets-DSM6CY3M.js} +59 -53
  161. package/dist/{terminal-lease-44SV3YCN.js → terminal-lease-JOPFUVEM.js} +14 -9
  162. package/dist/{tools-DAF3DI3C.js → tools-MKNWVPBH.js} +10 -8
  163. package/dist/{trace-FYVW2MQA.js → trace-ECQ7TIYZ.js} +48 -3
  164. package/dist/{tui-primitives-2AKXQNZK.js → tui-primitives-K5PASC3O.js} +8 -4
  165. package/dist/{uninstall-DW2PNOIC.js → uninstall-N34PCTGJ.js} +4 -6
  166. package/dist/{upgrade-3XPP6OQL.js → upgrade-H7TOM7YL.js} +35 -62
  167. package/dist/{usage-3NLHGTU2.js → usage-X52N3IDJ.js} +51 -48
  168. package/dist/{verifiers-SSQONKRT.js → verifiers-EJTVVSMA.js} +10 -9
  169. package/dist/{verify-3U6J7FZI.js → verify-YJL6XET2.js} +9 -8
  170. package/dist/{web-fetch-S7RR6GZ7.js → web-fetch-MPIFL3LL.js} +1 -2
  171. package/dist/{wiki-generate-CEHYGPGQ.js → wiki-generate-4NDZTQ4B.js} +66 -63
  172. package/dist/{with-panes-MKB46MPQ.js → with-panes-OBOBFIIR.js} +62 -26
  173. package/dist/worker/entry.js +57 -52
  174. package/docs/acp.md +1 -1
  175. package/docs/built-in-agents.md +40 -32
  176. package/docs/commands-and-modes.md +9 -3
  177. package/docs/config-knobs-audit.md +3 -0
  178. package/docs/configuration-and-targets.md +105 -164
  179. package/docs/environment-variables.md +2 -1
  180. package/docs/exit-codes-and-output.md +2 -0
  181. package/docs/fleet-demo-runbook.md +6 -3
  182. package/docs/fleet-dispatch.md +8 -6
  183. package/docs/installation-and-lifecycle.md +1 -1
  184. package/docs/release-cut-checklist.md +164 -177
  185. package/docs/trace-store.md +15 -10
  186. package/docs/troubleshooting.md +1 -1
  187. package/evals/README.md +5 -0
  188. package/evals/behavioral-corpus-grader.mjs +103 -0
  189. package/evals/behavioral-machinery-baseline.json +2276 -0
  190. package/evals/behavioral-machinery-driver.ts +250 -0
  191. package/evals/behavioral-machinery-support.ts +253 -0
  192. package/evals/behavioral-machinery.yaml +614 -0
  193. package/evals/behavioral-model-negative-control.yaml +68 -0
  194. package/evals/behavioral-model.yaml +216 -0
  195. package/evals/fixtures/behavioral-facts.txt +3 -0
  196. package/evals/fixtures/behavioral-main.ts +7 -0
  197. package/evals/fixtures/decoy/note.txt +2 -0
  198. package/evals/fixtures/private/credentials.txt +1 -0
  199. package/evals/tracked-metrics-baseline.yaml +229 -0
  200. package/evals/tracked-metrics-grader.mjs +129 -0
  201. package/package.json +5 -15
  202. package/skills/README.md +6 -6
  203. package/skills/coding/ast-grep/SKILL.md +8 -2
  204. package/skills/coding/coding-standards/SKILL.md +8 -2
  205. package/skills/coding/prototype/SKILL.md +8 -2
  206. package/skills/coding/tdd/SKILL.md +8 -2
  207. package/skills/context/context-handoff/SKILL.md +12 -3
  208. package/skills/context/context-handoff/evals.md +3 -3
  209. package/skills/context/context-prime/SKILL.md +8 -2
  210. package/skills/context/context-prime/evals.md +2 -2
  211. package/skills/git/file-ticket/SKILL.md +9 -4
  212. package/skills/git/file-ticket/evals.md +2 -2
  213. package/skills/git/fix-issue/SKILL.md +12 -5
  214. package/skills/git/fix-issue/evals.md +4 -4
  215. package/skills/git/resolve-merge-conflicts/SKILL.md +8 -2
  216. package/skills/git/resolve-merge-conflicts/evals.md +2 -2
  217. package/skills/git/ship/SKILL.md +9 -3
  218. package/skills/git/ship/evals.md +4 -4
  219. package/skills/git/worktree-create/SKILL.md +7 -2
  220. package/skills/git/worktree-create/evals.md +6 -6
  221. package/skills/git/worktree-merge/SKILL.md +7 -2
  222. package/skills/git/worktree-merge/evals.md +6 -6
  223. package/skills/meta/{clio-dev → clio-coder-dev}/SKILL.md +14 -8
  224. package/skills/meta/{clio-dev → clio-coder-dev}/evals.md +3 -3
  225. package/skills/meta/{clio-test → clio-coder-test}/SKILL.md +11 -5
  226. package/skills/meta/{clio-test → clio-coder-test}/evals.md +1 -1
  227. package/skills/meta/credentials/SKILL.md +9 -2
  228. package/skills/meta/find-skills/SKILL.md +8 -2
  229. package/skills/meta/herdr/SKILL.md +8 -2
  230. package/skills/meta/skill-craft/SKILL.md +21 -4
  231. package/skills/planning/architecture/SKILL.md +9 -3
  232. package/skills/planning/backlog/SKILL.md +8 -2
  233. package/skills/planning/prd/SKILL.md +8 -2
  234. package/skills/planning/product-intent/SKILL.md +8 -2
  235. package/skills/planning/tech-spec/SKILL.md +9 -3
  236. package/skills/registry.yaml +66 -66
  237. package/skills/research/arxiv-literature/SKILL.md +8 -2
  238. package/skills/research/experiment-protocol/SKILL.md +9 -2
  239. package/skills/research/scientific-debugging/SKILL.md +9 -2
  240. package/skills/research/scientific-debugging/evals.md +2 -2
  241. package/skills/research/scientific-modernization/SKILL.md +9 -2
  242. package/skills/skill-marketplace.json +257 -38
  243. package/skills/workflow/cut-it/SKILL.md +10 -2
  244. package/skills/workflow/design-council/SKILL.md +11 -2
  245. package/skills/workflow/grill-me/SKILL.md +8 -2
  246. package/skills/workflow/workflow-distiller/SKILL.md +8 -2
  247. package/src/cli/acp.ts +2 -2
  248. package/src/cli/auth.ts +2 -2
  249. package/src/cli/bootstrap-generate.ts +5 -5
  250. package/src/cli/clio.ts +6 -1
  251. package/src/cli/config-inspect.ts +3 -3
  252. package/src/cli/configure-interop.ts +1 -1
  253. package/src/cli/configure.ts +27 -27
  254. package/src/cli/default-target.ts +1 -1
  255. package/src/cli/docs.ts +6 -6
  256. package/src/cli/doctor-naming.ts +323 -0
  257. package/src/cli/doctor-panes.ts +46 -14
  258. package/src/cli/doctor-toolchain.ts +29 -8
  259. package/src/cli/doctor.ts +15 -1
  260. package/src/cli/eval-inventory.ts +8 -8
  261. package/src/cli/evidence-detail.ts +1 -1
  262. package/src/cli/evidence-inventory.ts +1 -1
  263. package/src/cli/fleet-decisions.ts +1 -1
  264. package/src/cli/fleet-inspect.ts +1 -1
  265. package/src/cli/fleet-preflight.ts +1 -1
  266. package/src/cli/fleet-verify.ts +1 -1
  267. package/src/cli/fleet-view.ts +40 -23
  268. package/src/cli/fleet.ts +8 -5
  269. package/src/cli/interop-inspect.ts +2 -2
  270. package/src/cli/models.ts +3 -3
  271. package/src/cli/modes/print.ts +1 -1
  272. package/src/cli/reset.ts +1 -1
  273. package/src/cli/run.ts +11 -15
  274. package/src/cli/share.ts +1 -1
  275. package/src/cli/skills-eval.ts +11 -11
  276. package/src/cli/targets.ts +23 -24
  277. package/src/cli/trace-inspect.ts +1 -1
  278. package/src/cli/trace.ts +41 -0
  279. package/src/cli/uninstall.ts +2 -2
  280. package/src/cli/upgrade.ts +29 -34
  281. package/src/cli/usage.ts +2 -2
  282. package/src/cli/validate-model.ts +1 -1
  283. package/src/cli/verifiers-inspect.ts +1 -1
  284. package/src/cli/wiki-generate.ts +5 -5
  285. package/src/core/bash-exec.ts +1 -1
  286. package/src/core/boot-trace.ts +3 -3
  287. package/src/core/bus-trace.ts +2 -2
  288. package/src/core/compile-cache.ts +1 -1
  289. package/src/core/config.ts +1062 -886
  290. package/src/core/defaults.ts +321 -528
  291. package/src/core/domain-loader.ts +6 -4
  292. package/src/core/event-bus.ts +1 -1
  293. package/src/core/file-references.ts +78 -88
  294. package/src/core/git-commit-attribution.ts +3 -9
  295. package/src/core/guardrails.ts +24 -4
  296. package/src/core/naming-compat.ts +45 -0
  297. package/src/core/naming-events.ts +62 -0
  298. package/src/core/recent-models.ts +1 -7
  299. package/src/core/residency-protection.ts +4 -8
  300. package/src/core/resolve-config-value.ts +1 -1
  301. package/src/core/response-model-id.ts +0 -14
  302. package/src/core/session-routing.ts +84 -74
  303. package/src/core/skill-activation.ts +18 -0
  304. package/src/core/termination.ts +4 -4
  305. package/src/core/timers.ts +2 -12
  306. package/src/domains/agents/catalog.ts +2 -12
  307. package/src/domains/agents/extension.ts +3 -3
  308. package/src/domains/agents/registry.ts +7 -7
  309. package/src/domains/agents/result-contract.ts +1 -1
  310. package/src/domains/agents/spec.ts +0 -11
  311. package/src/domains/config/classify.ts +35 -47
  312. package/src/domains/config/extension.ts +5 -5
  313. package/src/domains/config/keybindings.ts +48 -47
  314. package/src/domains/config/watcher.ts +1 -1
  315. package/src/domains/context/codewiki/indexer.ts +1 -1
  316. package/src/domains/context/extension.ts +3 -3
  317. package/src/domains/context/prompt-context.ts +1 -1
  318. package/src/domains/context/wiki/assemble.ts +2 -2
  319. package/src/domains/context/working-set/replay/metrics.ts +0 -4
  320. package/src/domains/context/working-set/replay/report.ts +1 -1
  321. package/src/domains/context/working-set/replay/synthetic.ts +2 -2
  322. package/src/domains/dispatch/active-route-planner.ts +2 -2
  323. package/src/domains/dispatch/agent-candidates.ts +1 -1
  324. package/src/domains/dispatch/agent-ledger-store.ts +1 -1
  325. package/src/domains/dispatch/agent-ledger.ts +1 -1
  326. package/src/domains/dispatch/assignment.ts +5 -5
  327. package/src/domains/dispatch/capacity-lease.ts +2 -5
  328. package/src/domains/dispatch/code-step.ts +1 -1
  329. package/src/domains/dispatch/contract.ts +2 -2
  330. package/src/domains/dispatch/extension.ts +65 -61
  331. package/src/domains/dispatch/fleet-node-prompt.ts +1 -1
  332. package/src/domains/dispatch/fleet-preflight.ts +8 -17
  333. package/src/domains/dispatch/fleet-run.ts +0 -7
  334. package/src/domains/dispatch/gate-decisions.ts +25 -14
  335. package/src/domains/dispatch/joint-route-resolver.ts +1 -1
  336. package/src/domains/dispatch/path-scope.ts +0 -61
  337. package/src/domains/dispatch/placement.ts +2 -2
  338. package/src/domains/dispatch/receipt-findings.ts +1 -1
  339. package/src/domains/dispatch/receipt-integrity.ts +20 -8
  340. package/src/domains/dispatch/reservation-store.ts +0 -23
  341. package/src/domains/dispatch/route-decision.ts +1 -1
  342. package/src/domains/dispatch/route-history.ts +1 -1
  343. package/src/domains/dispatch/route-policy.ts +1 -1
  344. package/src/domains/dispatch/route-readiness.ts +0 -28
  345. package/src/domains/dispatch/run-event-journal.ts +6 -5
  346. package/src/domains/dispatch/tool-stats.ts +1 -1
  347. package/src/domains/dispatch/transport.ts +2 -19
  348. package/src/domains/dispatch/types.ts +3 -3
  349. package/src/domains/dispatch/worker-protocol.ts +2 -2
  350. package/src/domains/eval/artifacts/store.ts +5 -4
  351. package/src/domains/eval/compare/thresholds.ts +0 -8
  352. package/src/domains/eval/execution-provenance.ts +1 -1
  353. package/src/domains/eval/metrics/token-stream.ts +0 -7
  354. package/src/domains/eval/report.ts +1 -1
  355. package/src/domains/eval/runner.ts +1 -1
  356. package/src/domains/eval/runners/clio-run.ts +7 -6
  357. package/src/domains/eval/runners/external-command.ts +4 -3
  358. package/src/domains/eval/schema/artifact.ts +1 -1
  359. package/src/domains/eval/schema/behavioral-metrics.ts +3 -2
  360. package/src/domains/eval/schema/behavioral.ts +7 -6
  361. package/src/domains/eval/schema/execution-envelope.ts +4 -2
  362. package/src/domains/eval/schema/naming.ts +10 -0
  363. package/src/domains/eval/schema/suite.ts +2 -2
  364. package/src/domains/eval/schema/validate.ts +9 -5
  365. package/src/domains/eval/schema/verdict.ts +4 -2
  366. package/src/domains/eval/store.ts +12 -2
  367. package/src/domains/eval/suites/run.ts +12 -6
  368. package/src/domains/eval/types.ts +1 -1
  369. package/src/domains/eval/workspaces/git.ts +1 -1
  370. package/src/domains/eval/workspaces/temp-copy.ts +1 -1
  371. package/src/domains/evidence/build.ts +13 -5
  372. package/src/domains/interop/consent.ts +7 -7
  373. package/src/domains/interop/extension.ts +1 -1
  374. package/src/domains/lifecycle/doctor.ts +27 -21
  375. package/src/domains/lifecycle/migrations/2026-09-01-clio-coder-naming.ts +155 -0
  376. package/src/domains/lifecycle/migrations/2026-09-01-retire-panes-knobs.ts +59 -0
  377. package/src/domains/lifecycle/migrations/2026-09-01-settings-v2.ts +338 -0
  378. package/src/domains/lifecycle/migrations/index.ts +20 -1
  379. package/src/domains/lifecycle/naming-history.ts +153 -0
  380. package/src/domains/lifecycle/naming-mutable-state.ts +104 -0
  381. package/src/domains/lifecycle/naming-resources.ts +261 -0
  382. package/src/domains/lifecycle/naming-tool-markers.ts +139 -0
  383. package/src/domains/lifecycle/naming-yazi.ts +81 -0
  384. package/src/domains/lifecycle/upgrade-notice.ts +1 -1
  385. package/src/domains/memory/task-memory-handoff.ts +6 -3
  386. package/src/domains/middleware/index.ts +7 -0
  387. package/src/domains/middleware/marketplace-offer.ts +339 -0
  388. package/src/domains/middleware/runtime.ts +2 -2
  389. package/src/domains/mux/contract.ts +157 -25
  390. package/src/domains/mux/detect.ts +29 -5
  391. package/src/domains/mux/dock-controller.ts +365 -0
  392. package/src/domains/mux/extension.ts +7 -1
  393. package/src/domains/mux/index.ts +20 -0
  394. package/src/domains/mux/operations.ts +28 -0
  395. package/src/domains/mux/protocol.ts +19 -6
  396. package/src/domains/mux/socket-client.ts +167 -19
  397. package/src/domains/mux/types.ts +49 -6
  398. package/src/domains/mux/yazi/event-stream.ts +6 -4
  399. package/src/domains/mux/yazi/profile.ts +1 -1
  400. package/src/domains/mux/yazi/session.ts +26 -3
  401. package/src/domains/observability/extension.ts +1 -1
  402. package/src/domains/observability/out-of-turn-usage.ts +2 -2
  403. package/src/domains/observability/projection.ts +1 -1
  404. package/src/domains/observability/trace-store.ts +22 -12
  405. package/src/domains/prompts/compiler.ts +2 -2
  406. package/src/domains/prompts/extension.ts +3 -3
  407. package/src/domains/prompts/fragments/identity/clio-worker.md +1 -1
  408. package/src/domains/prompts/fragments/operating/skills.md +25 -18
  409. package/src/domains/providers/extension.ts +5 -5
  410. package/src/domains/providers/knowledge-base-path.ts +1 -1
  411. package/src/domains/providers/model-runtime-capabilities.ts +14 -2
  412. package/src/domains/providers/models/cloud-models/alcf.yaml +1 -1
  413. package/src/domains/providers/models/local-models/{clio-local-coding-targets.yaml → clio-coder-local-coding-targets.yaml} +4 -4
  414. package/src/domains/providers/plugins.ts +1 -1
  415. package/src/domains/providers/resolver.ts +1 -1
  416. package/src/domains/providers/runtimes/cloud/alcf.ts +4 -4
  417. package/src/domains/providers/runtimes/common/lmstudio-http.ts +1 -5
  418. package/src/domains/providers/runtimes/common/local-synth.ts +3 -3
  419. package/src/domains/providers/runtimes/common/probe-helpers.ts +2 -2
  420. package/src/domains/providers/runtimes/local-native/llamacpp-completion.ts +1 -1
  421. package/src/domains/providers/runtimes/local-native/lmstudio.ts +2 -9
  422. package/src/domains/providers/runtimes/protocol/litellm.ts +1 -91
  423. package/src/domains/providers/types/knowledge-base.ts +13 -0
  424. package/src/domains/providers/types/local-model-quirks.ts +2 -2
  425. package/src/domains/providers/types/target-descriptor.ts +3 -3
  426. package/src/domains/resources/extension.ts +1 -1
  427. package/src/domains/resources/library.ts +6 -6
  428. package/src/domains/resources/prompts/loader.ts +1 -1
  429. package/src/domains/resources/skills/content-hash.ts +7 -6
  430. package/src/domains/resources/skills/evals.ts +1 -1
  431. package/src/domains/resources/skills/install.ts +36 -12
  432. package/src/domains/resources/skills/loader.ts +39 -13
  433. package/src/domains/resources/skills/marketplace.ts +21 -2
  434. package/src/domains/resources/skills/promotion.ts +214 -0
  435. package/src/domains/safety/audit.ts +2 -2
  436. package/src/domains/safety/finish-contract.ts +2 -1
  437. package/src/domains/safety/run-effects.ts +1 -1
  438. package/src/domains/scheduling/extension.ts +4 -4
  439. package/src/domains/session/archive-readers.ts +9 -1
  440. package/src/domains/session/compaction/branch-summary.ts +4 -0
  441. package/src/domains/session/compaction/compact.ts +1 -1
  442. package/src/domains/session/compaction/tokens.ts +4 -0
  443. package/src/domains/session/context-accounting.ts +1 -1
  444. package/src/domains/session/decision-board.ts +1 -1
  445. package/src/domains/session/extension.ts +1 -1
  446. package/src/domains/session/handoff.ts +2 -2
  447. package/src/domains/session/prompt-manifest.ts +0 -5
  448. package/src/domains/session/protected-artifact-journal.ts +12 -6
  449. package/src/domains/session/retry.ts +1 -1
  450. package/src/domains/share/archive.ts +85 -36
  451. package/src/domains/toolchain/install.ts +1 -1
  452. package/src/engine/acp/adapter.ts +3 -3
  453. package/src/engine/acp/event-mapper.ts +3 -3
  454. package/src/engine/acp/server.ts +27 -26
  455. package/src/engine/acp/tool-mediator.ts +2 -2
  456. package/src/engine/acp/types.ts +1 -1
  457. package/src/engine/alcf-oauth.ts +5 -5
  458. package/src/engine/antigravity/subprocess-runtime.ts +2 -2
  459. package/src/engine/api-registry.ts +1 -1
  460. package/src/engine/apis/llamacpp-residency.ts +1 -19
  461. package/src/engine/apis/lmstudio.ts +1 -6
  462. package/src/engine/apis/ollama-native.ts +3 -3
  463. package/src/engine/apis/openai-completions.ts +2 -2
  464. package/src/engine/apis/residency.ts +3 -9
  465. package/src/engine/claude/sdk-module.ts +1 -12
  466. package/src/engine/claude/sdk-runtime.ts +6 -6
  467. package/src/engine/claude/subprocess-runtime.ts +1 -1
  468. package/src/engine/claude/tool-safety.ts +4 -4
  469. package/src/engine/loop-guard.ts +0 -5
  470. package/src/engine/session.ts +14 -7
  471. package/src/engine/tui-primitives.ts +1 -1
  472. package/src/engine/worker-events.ts +6 -6
  473. package/src/engine/worker-runtime.ts +14 -13
  474. package/src/entry/orchestrator.ts +107 -88
  475. package/src/interactive/application-controller.ts +21 -21
  476. package/src/interactive/bus-notices.ts +2 -2
  477. package/src/interactive/chat-loop.ts +8 -8
  478. package/src/interactive/chat-panel.ts +1 -1
  479. package/src/interactive/clio-editor.ts +105 -1
  480. package/src/interactive/context-activity.ts +8 -6
  481. package/src/interactive/context-meter.ts +3 -6
  482. package/src/interactive/context-overlay.ts +1 -1
  483. package/src/interactive/cost-overlay.ts +1 -1
  484. package/src/interactive/council-grid.ts +2 -2
  485. package/src/interactive/dispatch-board.ts +30 -33
  486. package/src/interactive/editor-bash.ts +21 -0
  487. package/src/interactive/editor-steer.ts +9 -4
  488. package/src/interactive/editor-submit.ts +24 -18
  489. package/src/interactive/external-editor.ts +1 -1
  490. package/src/interactive/file-reference-completion.ts +360 -0
  491. package/src/interactive/footer/dashboard.ts +15 -17
  492. package/src/interactive/footer/notifications.ts +14 -8
  493. package/src/interactive/footer/widgets.ts +2 -44
  494. package/src/interactive/interactive-application.ts +79 -59
  495. package/src/interactive/interactive-event-projection.ts +1 -1
  496. package/src/interactive/interactive-input-runtime.ts +2 -2
  497. package/src/interactive/interactive-presentation.ts +21 -16
  498. package/src/interactive/interactive-shell.ts +2 -2
  499. package/src/interactive/interactive-slash-runtime.ts +63 -17
  500. package/src/interactive/interactive-subscriptions.ts +1 -1
  501. package/src/interactive/interactive-tickers.ts +1 -1
  502. package/src/interactive/keybinding-manager.ts +4 -4
  503. package/src/interactive/layout.ts +1 -1
  504. package/src/interactive/memory-overlay.ts +2 -2
  505. package/src/interactive/modal-marker.ts +2 -21
  506. package/src/interactive/mutation-preview.ts +1 -1
  507. package/src/interactive/overlay-frame.ts +4 -12
  508. package/src/interactive/overlay-general-openers.ts +6 -2
  509. package/src/interactive/overlay-key-routing.ts +7 -7
  510. package/src/interactive/overlay-lifecycle.ts +1 -1
  511. package/src/interactive/overlay-model-selectors.ts +3 -3
  512. package/src/interactive/overlays/agents.ts +2 -2
  513. package/src/interactive/overlays/ask-user.ts +25 -11
  514. package/src/interactive/overlays/context-reset.ts +28 -4
  515. package/src/interactive/overlays/cwd-fallback.ts +28 -4
  516. package/src/interactive/overlays/decisions.ts +4 -2
  517. package/src/interactive/overlays/fleet-run-approval.ts +3 -3
  518. package/src/interactive/overlays/handoff-review.ts +2 -2
  519. package/src/interactive/overlays/interop.ts +1 -1
  520. package/src/interactive/overlays/library-install-confirm.ts +1 -1
  521. package/src/interactive/overlays/message-picker.ts +1 -1
  522. package/src/interactive/overlays/model-selector.ts +39 -31
  523. package/src/interactive/overlays/prompts.ts +10 -4
  524. package/src/interactive/overlays/session-selector.ts +2 -2
  525. package/src/interactive/overlays/settings.ts +339 -293
  526. package/src/interactive/overlays/side-question.ts +2 -2
  527. package/src/interactive/overlays/skills-hub.ts +8 -8
  528. package/src/interactive/overlays/tree-selector.ts +2 -2
  529. package/src/interactive/panes-runtime.ts +36 -10
  530. package/src/interactive/permission-overlay.ts +2 -2
  531. package/src/interactive/renderers/retry-status.ts +12 -4
  532. package/src/interactive/renderers/tool-execution.ts +4 -4
  533. package/src/interactive/session-transcript.ts +3 -3
  534. package/src/interactive/slash-autocomplete.ts +454 -165
  535. package/src/interactive/slash-commands.ts +279 -183
  536. package/src/interactive/slash-spec.ts +160 -17
  537. package/src/interactive/status/controller.ts +2 -2
  538. package/src/interactive/stream-pacing-policy.ts +1 -1
  539. package/src/interactive/tasks-overlay.ts +20 -13
  540. package/src/interactive/terminal-lease.ts +6 -7
  541. package/src/interactive/turn-context.ts +11 -11
  542. package/src/interactive/turn-persistence.ts +2 -2
  543. package/src/interactive/turn-prewarm.ts +2 -2
  544. package/src/interactive/turn-runtime.ts +8 -8
  545. package/src/interactive/turn-state.ts +1 -1
  546. package/src/interactive/view/artifacts.ts +12 -9
  547. package/src/interactive/view/view-overlay.ts +13 -10
  548. package/src/interactive/watch-pane.ts +38 -10
  549. package/src/interactive/welcome-dashboard.ts +15 -15
  550. package/src/interactive/worker-progress.ts +4 -4
  551. package/src/interactive/worker-receipts.ts +1 -1
  552. package/src/interactive/worker-stream.ts +1 -4
  553. package/src/interactive/yazi-bridge.ts +12 -5
  554. package/src/tools/ask-user.ts +3 -3
  555. package/src/tools/bash.ts +1 -1
  556. package/src/tools/builtin-tool-catalog.ts +1 -1
  557. package/src/tools/compete-worktrees.ts +27 -17
  558. package/src/tools/context/index.ts +15 -1
  559. package/src/tools/dispatch-admission.ts +4 -2
  560. package/src/tools/dispatch-arguments.ts +1 -1
  561. package/src/tools/dispatch-plan.ts +0 -11
  562. package/src/tools/dispatch-run-events.ts +12 -10
  563. package/src/tools/dispatch-runner.ts +11 -6
  564. package/src/tools/dispatch.ts +1 -1
  565. package/src/tools/find.ts +1 -6
  566. package/src/tools/monitor.ts +4 -4
  567. package/src/tools/observers.ts +0 -33
  568. package/src/tools/task-worktree.ts +28 -7
  569. package/src/tools/verify/authoring.ts +3 -6
  570. package/src/tools/verify/frontend.ts +1 -1
  571. package/src/tools/web-fetch.ts +1 -1
  572. package/src/worker/entry.ts +4 -3
  573. package/src/worker/protocol.ts +16 -14
  574. package/src/worker/spec-contract.ts +2 -2
  575. package/src/worker/stdin-demux.ts +2 -2
  576. package/dist/chunk-GXNLGKAB.js +0 -571
  577. package/dist/chunk-VFA6GDY5.js +0 -1625
  578. package/dist/doctor-QOA5FNY5.js +0 -313
  579. package/src/engine/apis/degraded-inference.ts +0 -95
  580. /package/skills/meta/{clio-test → clio-coder-test}/references/harness.md +0 -0
  581. /package/skills/meta/{clio-test → clio-coder-test}/references/test-map.md +0 -0
@@ -1,1625 +0,0 @@
1
- import { createRequire as __clioCreateRequire } from "node:module"; const require = __clioCreateRequire(import.meta.url);
2
- import {
3
- MAX_TIMER_DELAY_MS
4
- } from "./chunk-FQ4SKYE4.js";
5
- import {
6
- ACTIVE_AGENT_AUTOMATION_ROLES,
7
- ACTIVE_ROUTING_POSTURES,
8
- ACTIVE_ROUTING_ROLES,
9
- COUNCIL_MEMBER_LABEL_PATTERN,
10
- DEFAULT_SETTINGS,
11
- THEME_NAMED_COLORS,
12
- THINKING_LEVELS
13
- } from "./chunk-GXNLGKAB.js";
14
- import {
15
- withStateFileLockSync
16
- } from "./chunk-IKCO5N3L.js";
17
- import {
18
- require_dist
19
- } from "./chunk-APJ265NV.js";
20
- import {
21
- clioConfigDir,
22
- resolveClioDirs
23
- } from "./chunk-BYP5D4HI.js";
24
- import {
25
- safeResourceWrite
26
- } from "./chunk-WEPFGWHJ.js";
27
- import {
28
- __toESM,
29
- init_esm_shims
30
- } from "./chunk-3R73A4XB.js";
31
-
32
- // src/core/config.ts
33
- init_esm_shims();
34
- var import_yaml = __toESM(require_dist(), 1);
35
- import { existsSync, readFileSync } from "node:fs";
36
- import { join } from "node:path";
37
- function settingsPath() {
38
- return join(clioConfigDir(), "settings.yaml");
39
- }
40
- function issuesKind(issues) {
41
- return issues[0]?.kind ?? "schema";
42
- }
43
- function settingsRemedy(kind, path) {
44
- if (kind === "unreadable") return `Restore read access to ${path}, then run \`clio-coder doctor\` to re-check.`;
45
- if (kind === "syntax") return `Fix the YAML in ${path}, then run \`clio-coder doctor\` to re-check.`;
46
- return `Fix the keys above in ${path}, then run \`clio-coder doctor\` to re-check.`;
47
- }
48
- function settingsRemedyInline(kind, path) {
49
- if (kind === "unreadable") return `restore read access to ${path}`;
50
- if (kind === "syntax") return `fix the YAML in ${path}`;
51
- return `edit the named keys in ${path}`;
52
- }
53
- var SettingsValidationError = class extends Error {
54
- issues;
55
- /**
56
- * The headline and the remedy both follow the failure kind. A file that
57
- * cannot be read has no key at fault, so telling its reader to "fix the keys
58
- * above" named a repair that does not exist for the problem they have.
59
- */
60
- constructor(issues) {
61
- const path = join(resolveClioDirs().config, "settings.yaml");
62
- const kind = issuesKind(issues);
63
- const lines = kind === "schema" ? issues.map((issue) => ` ${issue.path}: ${issue.message}`) : issues.map((issue) => ` ${issue.message}`);
64
- const headline = kind === "schema" ? "settings.yaml failed validation:" : "settings.yaml cannot be loaded:";
65
- super(
66
- `${headline}
67
- ${lines.join("\n")}
68
-
69
- ${settingsRemedy(kind, path)}
70
- \`clio-coder doctor --fix\` repairs directories and credential permissions; it never rewrites settings.
71
- To discard these settings and start from defaults instead, run \`clio-coder reset --config --force\`.`
72
- );
73
- this.name = "SettingsValidationError";
74
- this.issues = issues;
75
- }
76
- };
77
- function foldToOneLine(text) {
78
- return text.replace(/\s*\n\s*/g, " ").trim();
79
- }
80
- function yamlErrorSummary(error) {
81
- const raw = error instanceof Error ? error.message : String(error);
82
- return (raw.split("\n")[0] ?? raw).trim().replace(/:$/u, "");
83
- }
84
- function settingsFailureHeadline(kind) {
85
- if (kind === "unreadable") return "settings.yaml cannot be read";
86
- if (kind === "syntax") return "settings.yaml is not valid YAML";
87
- return "settings.yaml failed validation";
88
- }
89
- function formatSettingsIssues(issues) {
90
- if (issues.length === 0) return "";
91
- const path = join(resolveClioDirs().config, "settings.yaml");
92
- const kind = issuesKind(issues);
93
- const detail = kind === "schema" ? issues.map((issue) => `${issue.path}: ${issue.message}`).join("; ") : issues.map((issue) => issue.message.replace(/^(?:invalid YAML|unreadable): /u, "")).join("; ");
94
- const discard = "`clio-coder reset --config --force` to start from defaults";
95
- return foldToOneLine(
96
- `${settingsFailureHeadline(kind)}: ${settingsRemedyInline(kind, path)}, or ${discard}. ${detail}`
97
- );
98
- }
99
- function formatSettingsFailure(error) {
100
- if (error instanceof SettingsValidationError && error.issues.length > 0) return formatSettingsIssues(error.issues);
101
- return foldToOneLine(error instanceof Error ? error.message : String(error));
102
- }
103
- function isPlainObject(value) {
104
- return typeof value === "object" && value !== null && !Array.isArray(value);
105
- }
106
- function cloneValue(value) {
107
- return structuredClone(value);
108
- }
109
- var Issues = class {
110
- list = [];
111
- add(path, message) {
112
- this.list.push({ path, message });
113
- }
114
- unknownKeys(path, raw, known) {
115
- const knownSet = new Set(known);
116
- for (const key of Object.keys(raw)) {
117
- if (!knownSet.has(key)) this.add(path ? `${path}.${key}` : key, "unknown key");
118
- }
119
- }
120
- };
121
- function expectString(issues, path, value) {
122
- if (typeof value !== "string") {
123
- issues.add(path, `expected a string, got ${describe(value)}`);
124
- return void 0;
125
- }
126
- const trimmed = value.trim();
127
- if (trimmed.length === 0) {
128
- issues.add(path, "expected a non-empty string");
129
- return void 0;
130
- }
131
- return trimmed;
132
- }
133
- function expectBoolean(issues, path, value) {
134
- if (typeof value !== "boolean") {
135
- issues.add(path, `expected a boolean, got ${describe(value)}`);
136
- return void 0;
137
- }
138
- return value;
139
- }
140
- function expectNumber(issues, path, value, opts) {
141
- if (typeof value !== "number" || !Number.isFinite(value)) {
142
- issues.add(path, `expected a number, got ${describe(value)}`);
143
- return void 0;
144
- }
145
- if (opts?.min !== void 0 && value < opts.min) {
146
- issues.add(path, `expected a number >= ${opts.min}, got ${value}`);
147
- return void 0;
148
- }
149
- if (opts?.max !== void 0 && value > opts.max) {
150
- issues.add(path, `expected a number <= ${opts.max}, got ${value}`);
151
- return void 0;
152
- }
153
- return value;
154
- }
155
- function expectInteger(issues, path, value, opts) {
156
- if (typeof value !== "number" || !Number.isInteger(value)) {
157
- issues.add(path, `expected an integer, got ${describe(value)}`);
158
- return void 0;
159
- }
160
- if (opts?.min !== void 0 && value < opts.min) {
161
- issues.add(path, `expected an integer >= ${opts.min}, got ${value}`);
162
- return void 0;
163
- }
164
- if (opts?.max !== void 0 && value > opts.max) {
165
- issues.add(path, `expected an integer <= ${opts.max}, got ${value}`);
166
- return void 0;
167
- }
168
- return value;
169
- }
170
- function expectEnum(issues, path, value, allowed) {
171
- if (typeof value === "string" && allowed.includes(value)) return value;
172
- issues.add(path, `expected one of ${allowed.join(" | ")}, got ${describe(value)}`);
173
- return void 0;
174
- }
175
- function expectStringArray(issues, path, value) {
176
- if (!Array.isArray(value)) {
177
- issues.add(path, `expected a list of strings, got ${describe(value)}`);
178
- return void 0;
179
- }
180
- const seen = /* @__PURE__ */ new Set();
181
- const out = [];
182
- for (let i = 0; i < value.length; i += 1) {
183
- const entry = expectString(issues, `${path}[${i}]`, value[i]);
184
- if (entry === void 0) continue;
185
- if (seen.has(entry)) continue;
186
- seen.add(entry);
187
- out.push(entry);
188
- }
189
- return out;
190
- }
191
- function expectStringRecord(issues, path, value) {
192
- if (!isPlainObject(value)) {
193
- issues.add(path, `expected a string map, got ${describe(value)}`);
194
- return void 0;
195
- }
196
- const out = {};
197
- for (const [key, raw] of Object.entries(value)) {
198
- const entry = expectString(issues, `${path}.${key}`, raw);
199
- if (entry !== void 0) out[key] = entry;
200
- }
201
- return out;
202
- }
203
- function describe(value) {
204
- if (value === null) return "null";
205
- if (Array.isArray(value)) return "a list";
206
- if (typeof value === "object") return "a map";
207
- if (typeof value === "string") return value.trim().length === 0 ? "an empty string" : JSON.stringify(value);
208
- return String(value);
209
- }
210
- var TOOL_CALL_FORMATS = ["openai", "anthropic", "hermes", "llama3-json", "mistral", "qwen", "xml"];
211
- var THINKING_FORMATS = [
212
- "qwen-chat-template",
213
- "openrouter",
214
- "zai",
215
- "anthropic-extended",
216
- "deepseek-r1",
217
- "openai-codex",
218
- "harmony"
219
- ];
220
- var STRUCTURED_OUTPUTS = ["json-schema", "gbnf", "xgrammar", "none"];
221
- var AUTONOMY_LEVELS = ["read-only", "suggest", "auto-edit", "full-auto"];
222
- var TOOL_GOVERNANCE = ["clio-policy", "agent-managed", "deny-all"];
223
- function validateCapabilities(issues, path, value) {
224
- if (!isPlainObject(value)) {
225
- issues.add(path, `expected a map, got ${describe(value)}`);
226
- return void 0;
227
- }
228
- issues.unknownKeys(path, value, [
229
- "chat",
230
- "tools",
231
- "toolCallFormat",
232
- "reasoning",
233
- "thinkingFormat",
234
- "structuredOutputs",
235
- "vision",
236
- "audio",
237
- "embeddings",
238
- "rerank",
239
- "fim",
240
- "contextWindow",
241
- "maxTokens"
242
- ]);
243
- const out = {};
244
- for (const key of ["chat", "tools", "reasoning", "vision", "audio", "embeddings", "rerank", "fim"]) {
245
- if (key in value) {
246
- const v = expectBoolean(issues, `${path}.${key}`, value[key]);
247
- if (v !== void 0) out[key] = v;
248
- }
249
- }
250
- if ("toolCallFormat" in value) {
251
- const v = expectEnum(issues, `${path}.toolCallFormat`, value.toolCallFormat, TOOL_CALL_FORMATS);
252
- if (v !== void 0) out.toolCallFormat = v;
253
- }
254
- if ("thinkingFormat" in value) {
255
- const v = expectEnum(issues, `${path}.thinkingFormat`, value.thinkingFormat, THINKING_FORMATS);
256
- if (v !== void 0) out.thinkingFormat = v;
257
- }
258
- if ("structuredOutputs" in value) {
259
- const v = expectEnum(issues, `${path}.structuredOutputs`, value.structuredOutputs, STRUCTURED_OUTPUTS);
260
- if (v !== void 0) out.structuredOutputs = v;
261
- }
262
- if ("contextWindow" in value) {
263
- const v = expectInteger(issues, `${path}.contextWindow`, value.contextWindow, { min: 0 });
264
- if (v !== void 0) out.contextWindow = v;
265
- }
266
- if ("maxTokens" in value) {
267
- const v = expectInteger(issues, `${path}.maxTokens`, value.maxTokens, { min: 0 });
268
- if (v !== void 0) out.maxTokens = v;
269
- }
270
- return Object.keys(out).length > 0 ? out : void 0;
271
- }
272
- function validateAuth(issues, path, value) {
273
- if (!isPlainObject(value)) {
274
- issues.add(path, `expected a map, got ${describe(value)}`);
275
- return void 0;
276
- }
277
- issues.unknownKeys(path, value, ["apiKeyEnvVar", "apiKeyRef", "oauthProfile", "headers"]);
278
- const out = {};
279
- for (const key of ["apiKeyEnvVar", "apiKeyRef", "oauthProfile"]) {
280
- if (key in value) {
281
- const v = expectString(issues, `${path}.${key}`, value[key]);
282
- if (v !== void 0) out[key] = v;
283
- }
284
- }
285
- if ("headers" in value) {
286
- const v = expectStringRecord(issues, `${path}.headers`, value.headers);
287
- if (v !== void 0 && Object.keys(v).length > 0) out.headers = v;
288
- }
289
- return Object.keys(out).length > 0 ? out : void 0;
290
- }
291
- function validatePricing(issues, path, value) {
292
- if (!isPlainObject(value)) {
293
- issues.add(path, `expected a map, got ${describe(value)}`);
294
- return void 0;
295
- }
296
- issues.unknownKeys(path, value, ["input", "output", "cacheRead", "cacheWrite"]);
297
- const input = expectNumber(issues, `${path}.input`, value.input, { min: 0 });
298
- const output = expectNumber(issues, `${path}.output`, value.output, { min: 0 });
299
- if (input === void 0 || output === void 0) return void 0;
300
- const out = { input, output };
301
- if ("cacheRead" in value) {
302
- const v = expectNumber(issues, `${path}.cacheRead`, value.cacheRead, { min: 0 });
303
- if (v !== void 0) out.cacheRead = v;
304
- }
305
- if ("cacheWrite" in value) {
306
- const v = expectNumber(issues, `${path}.cacheWrite`, value.cacheWrite, { min: 0 });
307
- if (v !== void 0) out.cacheWrite = v;
308
- }
309
- return out;
310
- }
311
- function validateLmStudioSettings(issues, path, value) {
312
- if (!isPlainObject(value)) {
313
- issues.add(path, `expected a map, got ${describe(value)}`);
314
- return void 0;
315
- }
316
- issues.unknownKeys(path, value, ["load", "request"]);
317
- const out = {};
318
- if ("load" in value) {
319
- if (!isPlainObject(value.load)) {
320
- issues.add(`${path}.load`, `expected a map, got ${describe(value.load)}`);
321
- } else {
322
- issues.unknownKeys(`${path}.load`, value.load, [
323
- "contextLength",
324
- "flashAttention",
325
- "evalBatchSize",
326
- "numExperts",
327
- "offloadKvCacheToGpu"
328
- ]);
329
- const load = {};
330
- for (const key of ["contextLength", "evalBatchSize", "numExperts"]) {
331
- if (key in value.load) {
332
- const parsed = expectInteger(issues, `${path}.load.${key}`, value.load[key], { min: 1 });
333
- if (parsed !== void 0) load[key] = parsed;
334
- }
335
- }
336
- for (const key of ["flashAttention", "offloadKvCacheToGpu"]) {
337
- if (key in value.load) {
338
- const parsed = expectBoolean(issues, `${path}.load.${key}`, value.load[key]);
339
- if (parsed !== void 0) load[key] = parsed;
340
- }
341
- }
342
- if (Object.keys(load).length > 0) out.load = load;
343
- }
344
- }
345
- if ("request" in value) {
346
- if (!isPlainObject(value.request)) {
347
- issues.add(`${path}.request`, `expected a map, got ${describe(value.request)}`);
348
- } else {
349
- issues.unknownKeys(`${path}.request`, value.request, ["ttlSeconds", "draftModel", "reasoning"]);
350
- const request = {};
351
- if ("ttlSeconds" in value.request) {
352
- const parsed = expectInteger(issues, `${path}.request.ttlSeconds`, value.request.ttlSeconds, { min: 1 });
353
- if (parsed !== void 0) request.ttlSeconds = parsed;
354
- }
355
- if ("draftModel" in value.request) {
356
- const parsed = expectString(issues, `${path}.request.draftModel`, value.request.draftModel);
357
- if (parsed !== void 0) request.draftModel = parsed;
358
- }
359
- if ("reasoning" in value.request) {
360
- const parsed = expectEnum(issues, `${path}.request.reasoning`, value.request.reasoning, [
361
- "auto",
362
- "off",
363
- "on",
364
- "low",
365
- "medium",
366
- "high"
367
- ]);
368
- if (parsed !== void 0) request.reasoning = parsed;
369
- }
370
- if (Object.keys(request).length > 0) out.request = request;
371
- }
372
- }
373
- return Object.keys(out).length > 0 ? out : void 0;
374
- }
375
- function validateTarget(issues, path, value) {
376
- if (!isPlainObject(value)) {
377
- issues.add(path, `expected a map, got ${describe(value)}`);
378
- return null;
379
- }
380
- issues.unknownKeys(path, value, [
381
- "id",
382
- "runtime",
383
- "url",
384
- "auth",
385
- "defaultModel",
386
- "wireModels",
387
- "capabilities",
388
- "lifecycle",
389
- "gateway",
390
- "pricing",
391
- "lmstudio",
392
- "maxConcurrentRequests"
393
- ]);
394
- const id = "id" in value ? expectString(issues, `${path}.id`, value.id) : void 0;
395
- const runtime = "runtime" in value ? expectString(issues, `${path}.runtime`, value.runtime) : void 0;
396
- if (!("id" in value)) issues.add(`${path}.id`, "required");
397
- if (!("runtime" in value)) issues.add(`${path}.runtime`, "required");
398
- if (id === void 0 || runtime === void 0) return null;
399
- const target = { id, runtime };
400
- if ("url" in value) {
401
- const v = expectString(issues, `${path}.url`, value.url);
402
- if (v !== void 0) target.url = v;
403
- }
404
- if ("auth" in value) {
405
- const v = validateAuth(issues, `${path}.auth`, value.auth);
406
- if (v !== void 0) target.auth = v;
407
- }
408
- if ("wireModels" in value) {
409
- const v = expectStringArray(issues, `${path}.wireModels`, value.wireModels);
410
- if (v !== void 0 && v.length > 0) target.wireModels = v;
411
- }
412
- if ("defaultModel" in value) {
413
- const v = expectString(issues, `${path}.defaultModel`, value.defaultModel);
414
- if (v !== void 0) target.defaultModel = v;
415
- } else if (target.wireModels?.[0]) {
416
- target.defaultModel = target.wireModels[0];
417
- }
418
- if ("capabilities" in value) {
419
- const v = validateCapabilities(issues, `${path}.capabilities`, value.capabilities);
420
- if (v !== void 0) target.capabilities = v;
421
- }
422
- if ("lifecycle" in value) {
423
- const v = expectEnum(issues, `${path}.lifecycle`, value.lifecycle, ["user-managed", "clio-managed"]);
424
- if (v !== void 0) target.lifecycle = v;
425
- }
426
- if ("gateway" in value) {
427
- const v = expectBoolean(issues, `${path}.gateway`, value.gateway);
428
- if (v !== void 0) target.gateway = v;
429
- }
430
- if ("pricing" in value) {
431
- const v = validatePricing(issues, `${path}.pricing`, value.pricing);
432
- if (v !== void 0) target.pricing = v;
433
- }
434
- if ("lmstudio" in value) {
435
- const v = validateLmStudioSettings(issues, `${path}.lmstudio`, value.lmstudio);
436
- if (v !== void 0) target.lmstudio = v;
437
- }
438
- if ("maxConcurrentRequests" in value) {
439
- const v = expectInteger(issues, `${path}.maxConcurrentRequests`, value.maxConcurrentRequests, { min: 1 });
440
- if (v !== void 0) target.maxConcurrentRequests = v;
441
- }
442
- return target;
443
- }
444
- function validateWorkerTarget(issues, path, value, defaults, targets, options) {
445
- const out = cloneValue(defaults);
446
- if (!isPlainObject(value)) {
447
- issues.add(path, `expected a map, got ${describe(value)}`);
448
- return out;
449
- }
450
- const allowNode = options?.nodeIds !== void 0;
451
- issues.unknownKeys(
452
- path,
453
- value,
454
- allowNode ? ["target", "model", "thinkingLevel", "node"] : ["target", "model", "thinkingLevel"]
455
- );
456
- if ("target" in value && value.target !== null) {
457
- const v = expectString(issues, `${path}.target`, value.target);
458
- if (v !== void 0) out.target = targets.some((entry) => entry.id === v) ? v : null;
459
- }
460
- if ("thinkingLevel" in value) {
461
- const v = expectEnum(issues, `${path}.thinkingLevel`, value.thinkingLevel, THINKING_LEVELS);
462
- if (v !== void 0) out.thinkingLevel = v;
463
- }
464
- if ("model" in value && value.model !== null) {
465
- const v = expectString(issues, `${path}.model`, value.model);
466
- if (v !== void 0) out.model = v;
467
- }
468
- if (allowNode && "node" in value && value.node !== null) {
469
- const v = expectString(issues, `${path}.node`, value.node);
470
- if (v !== void 0) {
471
- const id = v.trim();
472
- if (id.length > 0 && (id === "local" || options?.nodeIds?.has(id) === true)) out.node = id;
473
- }
474
- }
475
- if (!out.target) {
476
- out.model = null;
477
- } else if (out.model === null) {
478
- out.model = targets.find((entry) => entry.id === out.target)?.defaultModel ?? null;
479
- }
480
- return out;
481
- }
482
- function normalizeModelRefs(refs, targets) {
483
- const byId = new Set(targets.map((target) => target.id));
484
- const out = [];
485
- for (const ref of refs) {
486
- const [targetId, ...modelParts] = ref.split("/");
487
- if (!targetId || !byId.has(targetId) || modelParts.length === 0) continue;
488
- const model = modelParts.join("/").trim();
489
- if (!model) continue;
490
- const normalized = `${targetId}/${model}`;
491
- if (!out.includes(normalized)) out.push(normalized);
492
- }
493
- return out;
494
- }
495
- function normalizeScope(refs) {
496
- const out = [];
497
- for (const ref of refs) {
498
- const trimmed = ref.trim();
499
- const [targetId] = trimmed.split("/");
500
- if (!targetId) continue;
501
- if (!out.includes(trimmed)) out.push(trimmed);
502
- }
503
- return out;
504
- }
505
- function validateDelegationAgent(issues, path, value, defaults, seen) {
506
- if (!isPlainObject(value)) {
507
- issues.add(path, `expected a map, got ${describe(value)}`);
508
- return null;
509
- }
510
- issues.unknownKeys(path, value, [
511
- "id",
512
- "command",
513
- "args",
514
- "cwd",
515
- "env",
516
- "connectTimeoutMs",
517
- "turnTimeoutMs",
518
- "permissionTimeoutMs",
519
- "stallTimeoutMs",
520
- "toolGovernance",
521
- "projectContext",
522
- "labels"
523
- ]);
524
- const id = "id" in value ? expectString(issues, `${path}.id`, value.id) : void 0;
525
- const command = "command" in value ? expectString(issues, `${path}.command`, value.command) : void 0;
526
- if (!("id" in value)) issues.add(`${path}.id`, "required");
527
- if (!("command" in value)) issues.add(`${path}.command`, "required");
528
- if (id === void 0 || command === void 0) return null;
529
- if (id === "auto") {
530
- issues.add(`${path}.id`, "'auto' is reserved for coordinator-owned agent selection");
531
- return null;
532
- }
533
- if (seen.has(id)) {
534
- issues.add(`${path}.id`, `duplicate delegation agent id '${id}'`);
535
- return null;
536
- }
537
- seen.add(id);
538
- const agent = {
539
- id,
540
- command,
541
- args: [],
542
- connectTimeoutMs: defaults.connectTimeoutMs,
543
- turnTimeoutMs: defaults.turnTimeoutMs,
544
- permissionTimeoutMs: defaults.permissionTimeoutMs,
545
- toolGovernance: defaults.toolGovernance
546
- };
547
- if ("args" in value) {
548
- const v = expectStringArray(issues, `${path}.args`, value.args);
549
- if (v !== void 0) agent.args = v;
550
- }
551
- for (const key of ["connectTimeoutMs", "turnTimeoutMs", "permissionTimeoutMs"]) {
552
- if (key in value) {
553
- const v = expectInteger(issues, `${path}.${key}`, value[key], { min: 1, max: MAX_TIMER_DELAY_MS });
554
- if (v !== void 0) agent[key] = v;
555
- }
556
- }
557
- if ("stallTimeoutMs" in value) {
558
- const v = expectInteger(issues, `${path}.stallTimeoutMs`, value.stallTimeoutMs);
559
- if (v !== void 0) agent.stallTimeoutMs = v;
560
- }
561
- if ("toolGovernance" in value) {
562
- const v = expectEnum(issues, `${path}.toolGovernance`, value.toolGovernance, TOOL_GOVERNANCE);
563
- if (v !== void 0) agent.toolGovernance = v;
564
- }
565
- if ("projectContext" in value) {
566
- const v = expectEnum(issues, `${path}.projectContext`, value.projectContext, ["none", "bounded"]);
567
- if (v !== void 0) agent.projectContext = v;
568
- }
569
- if ("cwd" in value) {
570
- const v = expectString(issues, `${path}.cwd`, value.cwd);
571
- if (v !== void 0) agent.cwd = v;
572
- }
573
- if ("env" in value) {
574
- const v = expectStringRecord(issues, `${path}.env`, value.env);
575
- if (v !== void 0 && Object.keys(v).length > 0) agent.env = v;
576
- }
577
- if ("labels" in value) {
578
- const v = expectStringRecord(issues, `${path}.labels`, value.labels);
579
- if (v !== void 0 && Object.keys(v).length > 0) agent.labels = v;
580
- }
581
- return agent;
582
- }
583
- function validateDelegation(issues, value) {
584
- const out = cloneValue(DEFAULT_SETTINGS.delegation);
585
- if (!isPlainObject(value)) {
586
- issues.add("delegation", `expected a map, got ${describe(value)}`);
587
- return out;
588
- }
589
- issues.unknownKeys("delegation", value, ["agents", "defaults"]);
590
- if ("defaults" in value) {
591
- if (!isPlainObject(value.defaults)) {
592
- issues.add("delegation.defaults", `expected a map, got ${describe(value.defaults)}`);
593
- } else {
594
- issues.unknownKeys("delegation.defaults", value.defaults, [
595
- "connectTimeoutMs",
596
- "turnTimeoutMs",
597
- "permissionTimeoutMs",
598
- "toolGovernance"
599
- ]);
600
- for (const key of ["connectTimeoutMs", "turnTimeoutMs", "permissionTimeoutMs"]) {
601
- if (key in value.defaults) {
602
- const v = expectInteger(issues, `delegation.defaults.${key}`, value.defaults[key], {
603
- min: 1,
604
- max: MAX_TIMER_DELAY_MS
605
- });
606
- if (v !== void 0) out.defaults[key] = v;
607
- }
608
- }
609
- if ("toolGovernance" in value.defaults) {
610
- const v = expectEnum(issues, "delegation.defaults.toolGovernance", value.defaults.toolGovernance, TOOL_GOVERNANCE);
611
- if (v !== void 0) out.defaults.toolGovernance = v;
612
- }
613
- }
614
- }
615
- if ("agents" in value) {
616
- if (!Array.isArray(value.agents)) {
617
- issues.add("delegation.agents", `expected a list, got ${describe(value.agents)}`);
618
- } else {
619
- const seen = /* @__PURE__ */ new Set();
620
- out.agents = value.agents.map((entry, i) => validateDelegationAgent(issues, `delegation.agents[${i}]`, entry, out.defaults, seen)).filter((entry) => entry !== null);
621
- }
622
- }
623
- return out;
624
- }
625
- function validateFleetNode(issues, path, value, seen) {
626
- if (!isPlainObject(value)) {
627
- issues.add(path, `expected a map, got ${describe(value)}`);
628
- return null;
629
- }
630
- issues.unknownKeys(path, value, [
631
- "id",
632
- "host",
633
- "user",
634
- "port",
635
- "identityFile",
636
- "clioCoderEntry",
637
- // Pre-0.3.1 spelling, still read.
638
- "clioEntry",
639
- "labels",
640
- "maxWorkers",
641
- "residency"
642
- ]);
643
- const id = "id" in value ? expectString(issues, `${path}.id`, value.id) : void 0;
644
- const host = "host" in value ? expectString(issues, `${path}.host`, value.host) : void 0;
645
- if (!("id" in value)) issues.add(`${path}.id`, "required");
646
- if (!("host" in value)) issues.add(`${path}.host`, "required");
647
- if (id === void 0 || host === void 0) return null;
648
- const trimmedId = id.trim();
649
- if (trimmedId.length === 0) {
650
- issues.add(`${path}.id`, "must not be blank");
651
- return null;
652
- }
653
- if (trimmedId === "local") {
654
- issues.add(`${path}.id`, "'local' is reserved for the implicit local node");
655
- return null;
656
- }
657
- if (seen.has(trimmedId)) {
658
- issues.add(`${path}.id`, `duplicate fleet node id '${trimmedId}'`);
659
- return null;
660
- }
661
- seen.add(trimmedId);
662
- const node = { id: trimmedId, host, maxWorkers: 2 };
663
- if ("user" in value) {
664
- const v = expectString(issues, `${path}.user`, value.user);
665
- if (v !== void 0) node.user = v;
666
- }
667
- if ("port" in value) {
668
- const v = expectInteger(issues, `${path}.port`, value.port, { min: 1 });
669
- if (v !== void 0) node.port = v;
670
- }
671
- if ("identityFile" in value) {
672
- const v = expectString(issues, `${path}.identityFile`, value.identityFile);
673
- if (v !== void 0) node.identityFile = v;
674
- }
675
- if ("clioEntry" in value) {
676
- const v = expectString(issues, `${path}.clioEntry`, value.clioEntry);
677
- if (v !== void 0) node.clioCoderEntry = v;
678
- }
679
- if ("clioCoderEntry" in value) {
680
- const v = expectString(issues, `${path}.clioCoderEntry`, value.clioCoderEntry);
681
- if (v !== void 0) node.clioCoderEntry = v;
682
- }
683
- if ("labels" in value) {
684
- const v = expectStringArray(issues, `${path}.labels`, value.labels);
685
- if (v !== void 0) node.labels = v;
686
- }
687
- if ("maxWorkers" in value) {
688
- const v = expectInteger(issues, `${path}.maxWorkers`, value.maxWorkers, { min: 1 });
689
- if (v !== void 0) node.maxWorkers = v;
690
- }
691
- if ("residency" in value) {
692
- const v = expectEnum(issues, `${path}.residency`, value.residency, ["observe", "manage"]);
693
- if (v !== void 0) node.residency = v;
694
- }
695
- return node;
696
- }
697
- function validateFleet(issues, value) {
698
- const out = cloneValue(DEFAULT_SETTINGS.fleet);
699
- if (!isPlainObject(value)) {
700
- issues.add("fleet", `expected a map, got ${describe(value)}`);
701
- return out;
702
- }
703
- issues.unknownKeys("fleet", value, ["nodes"]);
704
- if ("nodes" in value) {
705
- if (!Array.isArray(value.nodes)) {
706
- issues.add("fleet.nodes", `expected a list, got ${describe(value.nodes)}`);
707
- } else {
708
- const seen = /* @__PURE__ */ new Set();
709
- out.nodes = value.nodes.map((entry, i) => validateFleetNode(issues, `fleet.nodes[${i}]`, entry, seen)).filter((entry) => entry !== null);
710
- }
711
- }
712
- return out;
713
- }
714
- function validateMemorySettings(issues, value) {
715
- const out = cloneValue(DEFAULT_SETTINGS.memory);
716
- if (!isPlainObject(value)) {
717
- issues.add("memory", `expected a map, got ${describe(value)}`);
718
- return out;
719
- }
720
- issues.unknownKeys("memory", value, ["intervention"]);
721
- if (!("intervention" in value)) return out;
722
- if (!isPlainObject(value.intervention)) {
723
- issues.add("memory.intervention", `expected a map, got ${describe(value.intervention)}`);
724
- return out;
725
- }
726
- const raw = value.intervention;
727
- issues.unknownKeys("memory.intervention", raw, ["enabled", "everyNTools", "windowSteps", "maxTokens", "timeoutMs"]);
728
- if ("enabled" in raw) {
729
- const enabled = expectBoolean(issues, "memory.intervention.enabled", raw.enabled);
730
- if (enabled !== void 0) out.intervention.enabled = enabled;
731
- }
732
- for (const key of ["everyNTools", "windowSteps", "maxTokens", "timeoutMs"]) {
733
- if (!(key in raw)) continue;
734
- const parsed = expectInteger(issues, `memory.intervention.${key}`, raw[key], {
735
- min: key === "everyNTools" ? 2 : 1
736
- });
737
- if (parsed !== void 0) out.intervention[key] = parsed;
738
- }
739
- return out;
740
- }
741
- function validateWatchdogSettings(issues, value) {
742
- const out = cloneValue(DEFAULT_SETTINGS.watchdog);
743
- if (!isPlainObject(value)) {
744
- issues.add("watchdog", `expected a map, got ${describe(value)}`);
745
- return out;
746
- }
747
- issues.unknownKeys("watchdog", value, ["enabled", "target", "cadenceToolCalls"]);
748
- if ("enabled" in value) {
749
- const enabled = expectBoolean(issues, "watchdog.enabled", value.enabled);
750
- if (enabled !== void 0) out.enabled = enabled;
751
- }
752
- if ("target" in value && value.target !== null) {
753
- const target = expectString(issues, "watchdog.target", value.target);
754
- if (target !== void 0) {
755
- if (target.trim().length === 0) issues.add("watchdog.target", "expected a non-empty target id");
756
- else out.target = target.trim();
757
- }
758
- }
759
- if ("cadenceToolCalls" in value && value.cadenceToolCalls !== null) {
760
- const cadence = expectInteger(issues, "watchdog.cadenceToolCalls", value.cadenceToolCalls, { min: 1 });
761
- if (cadence !== void 0) out.cadenceToolCalls = cadence;
762
- }
763
- return out;
764
- }
765
- function validateKeybindings(issues, value) {
766
- if (!isPlainObject(value)) {
767
- issues.add("keybindings", `expected a map, got ${describe(value)}`);
768
- return {};
769
- }
770
- const next = {};
771
- for (const [rawKey, rawValue] of Object.entries(value)) {
772
- const id = rawKey.trim();
773
- if (!id) {
774
- issues.add("keybindings", "empty keybinding id");
775
- continue;
776
- }
777
- if (typeof rawValue === "string") {
778
- const v = expectString(issues, `keybindings.${id}`, rawValue);
779
- if (v !== void 0) next[id] = v;
780
- continue;
781
- }
782
- if (Array.isArray(rawValue)) {
783
- const v = expectStringArray(issues, `keybindings.${id}`, rawValue);
784
- if (v !== void 0 && v.length > 0) next[id] = v;
785
- continue;
786
- }
787
- issues.add(`keybindings.${id}`, `expected a string or list of strings, got ${describe(rawValue)}`);
788
- }
789
- return next;
790
- }
791
- var TOP_LEVEL_KEYS = [
792
- "version",
793
- // Accepted and ignored. Settings files generated before 0.3.1 carry an
794
- // `identity:` line for a control nothing ever read; listing it here keeps
795
- // those files loading without an unknown-key issue.
796
- "identity",
797
- "autonomy",
798
- "targets",
799
- "runtimePlugins",
800
- "orchestrator",
801
- "background",
802
- "memory",
803
- "watchdog",
804
- "workers",
805
- "fleet",
806
- "routing",
807
- "scope",
808
- "modelSelector",
809
- "budget",
810
- "defaults",
811
- "theme",
812
- "terminal",
813
- "skills",
814
- "library",
815
- "attribution",
816
- "delegation",
817
- "keybindings",
818
- "compaction",
819
- "context",
820
- "prewarm",
821
- "panes",
822
- "retry",
823
- "guardrails"
824
- ];
825
- function validateSettings(raw) {
826
- const issues = new Issues();
827
- const settings = cloneValue(DEFAULT_SETTINGS);
828
- if (!isPlainObject(raw)) {
829
- issues.add("(root)", `expected a map, got ${describe(raw)}`);
830
- return { settings, issues: issues.list };
831
- }
832
- issues.unknownKeys("", raw, TOP_LEVEL_KEYS);
833
- if ("version" in raw && raw.version !== 1) {
834
- issues.add("version", `expected 1, got ${describe(raw.version)}`);
835
- }
836
- if ("autonomy" in raw) {
837
- const v = expectEnum(issues, "autonomy", raw.autonomy, AUTONOMY_LEVELS);
838
- if (v !== void 0) settings.autonomy = v;
839
- }
840
- if ("targets" in raw) {
841
- if (!Array.isArray(raw.targets)) {
842
- issues.add("targets", `expected a list, got ${describe(raw.targets)}`);
843
- } else {
844
- const seen = /* @__PURE__ */ new Set();
845
- const out = [];
846
- for (let i = 0; i < raw.targets.length; i += 1) {
847
- const target = validateTarget(issues, `targets[${i}]`, raw.targets[i]);
848
- if (!target) continue;
849
- if (seen.has(target.id)) {
850
- issues.add(`targets[${i}].id`, `duplicate target id '${target.id}'`);
851
- continue;
852
- }
853
- seen.add(target.id);
854
- out.push(target);
855
- }
856
- settings.targets = out;
857
- }
858
- }
859
- if ("runtimePlugins" in raw) {
860
- const v = expectStringArray(issues, "runtimePlugins", raw.runtimePlugins);
861
- if (v !== void 0) settings.runtimePlugins = v;
862
- }
863
- if ("library" in raw) {
864
- if (!isPlainObject(raw.library)) {
865
- issues.add("library", `expected a map, got ${describe(raw.library)}`);
866
- } else {
867
- issues.unknownKeys("library", raw.library, ["catalog", "remote", "confirmedRemote", "sync"]);
868
- for (const key of ["catalog", "remote", "confirmedRemote"]) {
869
- const value = raw.library[key];
870
- if (value === void 0) continue;
871
- if (value !== null && typeof value !== "string")
872
- issues.add(`library.${key}`, `expected a string or null, got ${describe(value)}`);
873
- else settings.library[key] = value;
874
- }
875
- if (raw.library.sync !== void 0) {
876
- if (typeof raw.library.sync !== "boolean")
877
- issues.add("library.sync", `expected a boolean, got ${describe(raw.library.sync)}`);
878
- else settings.library.sync = raw.library.sync;
879
- }
880
- }
881
- }
882
- if ("orchestrator" in raw) {
883
- settings.orchestrator = validateWorkerTarget(
884
- issues,
885
- "orchestrator",
886
- raw.orchestrator,
887
- settings.orchestrator,
888
- settings.targets
889
- );
890
- }
891
- if ("background" in raw) {
892
- settings.background = validateWorkerTarget(
893
- issues,
894
- "background",
895
- raw.background,
896
- settings.background,
897
- settings.targets
898
- );
899
- }
900
- if ("memory" in raw) settings.memory = validateMemorySettings(issues, raw.memory);
901
- if ("watchdog" in raw) settings.watchdog = validateWatchdogSettings(issues, raw.watchdog);
902
- if ("fleet" in raw) {
903
- settings.fleet = validateFleet(issues, raw.fleet);
904
- }
905
- const fleetNodeIds = new Set(settings.fleet.nodes.map((node) => node.id));
906
- if ("routing" in raw) {
907
- if (!isPlainObject(raw.routing)) {
908
- issues.add("routing", `expected a map, got ${describe(raw.routing)}`);
909
- } else {
910
- issues.unknownKeys("routing", raw.routing, ["activeRoles", "activePostures", "agentAutomation"]);
911
- const activeRoles = expectStringArray(issues, "routing.activeRoles", raw.routing.activeRoles);
912
- if (activeRoles !== void 0) {
913
- const allowed = new Set(ACTIVE_ROUTING_ROLES);
914
- const rawRoles = raw.routing.activeRoles;
915
- const stringRoles = rawRoles.filter((role) => typeof role === "string");
916
- const complete = activeRoles.length === rawRoles.length;
917
- for (const role of activeRoles) {
918
- if (!allowed.has(role)) issues.add("routing.activeRoles", `unsupported active role '${role}'`);
919
- }
920
- if (new Set(stringRoles).size !== stringRoles.length) {
921
- issues.add("routing.activeRoles", "expected unique roles");
922
- }
923
- if (complete && activeRoles.every((role) => allowed.has(role))) {
924
- settings.routing.activeRoles = activeRoles;
925
- }
926
- }
927
- const activePostures = expectStringArray(issues, "routing.activePostures", raw.routing.activePostures);
928
- if (activePostures !== void 0) {
929
- const allowed = new Set(ACTIVE_ROUTING_POSTURES);
930
- const rawPostures = raw.routing.activePostures;
931
- const stringPostures = rawPostures.filter((posture) => typeof posture === "string");
932
- const complete = activePostures.length === rawPostures.length;
933
- for (const posture of activePostures) {
934
- if (!allowed.has(posture)) issues.add("routing.activePostures", `unsupported active posture '${posture}'`);
935
- }
936
- if (new Set(stringPostures).size !== stringPostures.length) {
937
- issues.add("routing.activePostures", "expected unique postures");
938
- }
939
- if (complete && activePostures.every((posture) => allowed.has(posture))) {
940
- settings.routing.activePostures = activePostures;
941
- }
942
- }
943
- if (!isPlainObject(raw.routing.agentAutomation)) {
944
- issues.add("routing.agentAutomation", "expected a map");
945
- } else {
946
- const automation = raw.routing.agentAutomation;
947
- issues.unknownKeys("routing.agentAutomation", automation, ["activeAgentRoles"]);
948
- if (!Array.isArray(automation.activeAgentRoles)) {
949
- issues.add("routing.agentAutomation.activeAgentRoles", "expected a list");
950
- } else {
951
- const pairs = [];
952
- const seen = /* @__PURE__ */ new Set();
953
- for (const [index, value] of automation.activeAgentRoles.entries()) {
954
- const path = `routing.agentAutomation.activeAgentRoles[${index}]`;
955
- if (!isPlainObject(value)) {
956
- issues.add(path, "expected a map");
957
- continue;
958
- }
959
- issues.unknownKeys(path, value, ["agentId", "executionRole"]);
960
- const agentId = expectString(issues, `${path}.agentId`, value.agentId);
961
- const executionRole = expectEnum(
962
- issues,
963
- `${path}.executionRole`,
964
- value.executionRole,
965
- ACTIVE_AGENT_AUTOMATION_ROLES
966
- );
967
- if (agentId === "auto") {
968
- issues.add(`${path}.agentId`, "'auto' is reserved for coordinator-owned agent selection");
969
- }
970
- if (agentId === void 0 || agentId === "auto" || executionRole === void 0) continue;
971
- const key = `${agentId}\0${executionRole}`;
972
- if (seen.has(key)) {
973
- issues.add(path, "duplicate agent and execution-role pair");
974
- continue;
975
- }
976
- seen.add(key);
977
- pairs.push({ agentId, executionRole });
978
- }
979
- if (pairs.length === automation.activeAgentRoles.length) {
980
- settings.routing.agentAutomation.activeAgentRoles = pairs;
981
- }
982
- }
983
- }
984
- }
985
- }
986
- if ("workers" in raw) {
987
- if (!isPlainObject(raw.workers)) {
988
- issues.add("workers", `expected a map, got ${describe(raw.workers)}`);
989
- } else {
990
- issues.unknownKeys("workers", raw.workers, [
991
- "default",
992
- "profiles",
993
- "rosters",
994
- "agentBindings",
995
- "maxRetries",
996
- "onPermission",
997
- "escalation",
998
- "resilienceCooldownMs"
999
- ]);
1000
- if ("default" in raw.workers) {
1001
- settings.workers.default = validateWorkerTarget(
1002
- issues,
1003
- "workers.default",
1004
- raw.workers.default,
1005
- settings.workers.default,
1006
- settings.targets,
1007
- { nodeIds: fleetNodeIds }
1008
- );
1009
- }
1010
- if ("profiles" in raw.workers) {
1011
- if (!isPlainObject(raw.workers.profiles)) {
1012
- issues.add("workers.profiles", `expected a map, got ${describe(raw.workers.profiles)}`);
1013
- } else {
1014
- const profiles = {};
1015
- for (const [rawName, rawProfile] of Object.entries(raw.workers.profiles)) {
1016
- const name = rawName.trim();
1017
- if (!name) {
1018
- issues.add("workers.profiles", "empty profile name");
1019
- continue;
1020
- }
1021
- const profile = validateWorkerTarget(
1022
- issues,
1023
- `workers.profiles.${name}`,
1024
- rawProfile,
1025
- DEFAULT_SETTINGS.workers.default,
1026
- settings.targets,
1027
- { nodeIds: fleetNodeIds }
1028
- );
1029
- if (!profile.target) continue;
1030
- profiles[name] = profile;
1031
- }
1032
- settings.workers.profiles = profiles;
1033
- }
1034
- }
1035
- if ("rosters" in raw.workers) {
1036
- if (!isPlainObject(raw.workers.rosters)) {
1037
- issues.add("workers.rosters", `expected a map, got ${describe(raw.workers.rosters)}`);
1038
- } else {
1039
- const rosters = {};
1040
- for (const [rawName, rawRoster] of Object.entries(raw.workers.rosters)) {
1041
- const name = rawName.trim();
1042
- const path = `workers.rosters.${name}`;
1043
- if (!name) {
1044
- issues.add("workers.rosters", "empty roster name");
1045
- continue;
1046
- }
1047
- if (!isPlainObject(rawRoster)) {
1048
- issues.add(path, `expected a map, got ${describe(rawRoster)}`);
1049
- continue;
1050
- }
1051
- issues.unknownKeys(path, rawRoster, ["members"]);
1052
- if (!Array.isArray(rawRoster.members)) {
1053
- issues.add(`${path}.members`, "expected a list");
1054
- continue;
1055
- }
1056
- if (rawRoster.members.length < 2 || rawRoster.members.length > 5) {
1057
- issues.add(`${path}.members`, "expected 2 to 5 members");
1058
- }
1059
- const members = [];
1060
- const labels = /* @__PURE__ */ new Set();
1061
- for (const [index, rawMember] of rawRoster.members.entries()) {
1062
- const memberPath = `${path}.members[${index}]`;
1063
- if (!isPlainObject(rawMember)) {
1064
- issues.add(memberPath, `expected a map, got ${describe(rawMember)}`);
1065
- continue;
1066
- }
1067
- issues.unknownKeys(memberPath, rawMember, ["label", "target", "model", "thinking", "color"]);
1068
- const label = expectString(issues, `${memberPath}.label`, rawMember.label);
1069
- const target = expectString(issues, `${memberPath}.target`, rawMember.target);
1070
- if (label !== void 0 && !COUNCIL_MEMBER_LABEL_PATTERN.test(label)) {
1071
- issues.add(`${memberPath}.label`, "expected [a-z][a-z0-9_-]{0,31}");
1072
- }
1073
- if (label !== void 0 && labels.has(label)) issues.add(`${memberPath}.label`, "duplicate label");
1074
- if (label !== void 0) labels.add(label);
1075
- if (target !== void 0 && !settings.targets.some((entry) => entry.id === target)) {
1076
- issues.add(`${memberPath}.target`, `unknown target '${target}'`);
1077
- }
1078
- const model = rawMember.model === void 0 ? void 0 : expectString(issues, `${memberPath}.model`, rawMember.model);
1079
- const thinking = rawMember.thinking === void 0 ? void 0 : expectEnum(issues, `${memberPath}.thinking`, rawMember.thinking, THINKING_LEVELS);
1080
- const color = rawMember.color === void 0 ? void 0 : expectString(issues, `${memberPath}.color`, rawMember.color);
1081
- if (color !== void 0 && !THEME_NAMED_COLORS.includes(color) && !/^#[0-9a-fA-F]{6}$/u.test(color)) {
1082
- issues.add(`${memberPath}.color`, "expected a theme named color or 6-digit hex color");
1083
- }
1084
- if (label === void 0 || target === void 0) continue;
1085
- members.push({
1086
- label,
1087
- target,
1088
- ...model ? { model } : {},
1089
- ...thinking ? { thinking } : {},
1090
- ...color ? { color } : {}
1091
- });
1092
- }
1093
- if (rawRoster.members.length >= 2 && rawRoster.members.length <= 5 && members.length === rawRoster.members.length)
1094
- rosters[name] = { members };
1095
- }
1096
- settings.workers.rosters = rosters;
1097
- }
1098
- }
1099
- if ("agentBindings" in raw.workers) {
1100
- if (!isPlainObject(raw.workers.agentBindings)) {
1101
- issues.add("workers.agentBindings", `expected a map, got ${describe(raw.workers.agentBindings)}`);
1102
- } else {
1103
- const agentBindings = {};
1104
- for (const [rawAgentId, rawProfileName] of Object.entries(raw.workers.agentBindings)) {
1105
- const agentId = rawAgentId.trim();
1106
- if (!agentId) {
1107
- issues.add("workers.agentBindings", "empty agent id");
1108
- continue;
1109
- }
1110
- if (agentId === "auto") {
1111
- issues.add("workers.agentBindings", "'auto' is reserved for coordinator-owned agent selection");
1112
- continue;
1113
- }
1114
- const profileName = expectString(issues, `workers.agentBindings.${agentId}`, rawProfileName);
1115
- if (profileName !== void 0) agentBindings[agentId] = profileName;
1116
- }
1117
- settings.workers.agentBindings = agentBindings;
1118
- }
1119
- }
1120
- if ("maxRetries" in raw.workers) {
1121
- const v = expectInteger(issues, "workers.maxRetries", raw.workers.maxRetries, { min: 0 });
1122
- if (v !== void 0) settings.workers.maxRetries = v;
1123
- }
1124
- if ("onPermission" in raw.workers) {
1125
- const v = expectEnum(issues, "workers.onPermission", raw.workers.onPermission, [
1126
- "deny",
1127
- "fail",
1128
- "escalate"
1129
- ]);
1130
- if (v !== void 0) settings.workers.onPermission = v;
1131
- }
1132
- if ("escalation" in raw.workers) {
1133
- if (!isPlainObject(raw.workers.escalation)) {
1134
- issues.add("workers.escalation", `expected a map, got ${describe(raw.workers.escalation)}`);
1135
- } else {
1136
- const base = settings.workers.escalation ?? DEFAULT_SETTINGS.workers.escalation;
1137
- const escalation = { timeoutMs: base?.timeoutMs ?? 12e4, fallback: base?.fallback ?? "deny" };
1138
- issues.unknownKeys("workers.escalation", raw.workers.escalation, ["timeoutMs", "fallback"]);
1139
- if ("timeoutMs" in raw.workers.escalation) {
1140
- const v = expectInteger(issues, "workers.escalation.timeoutMs", raw.workers.escalation.timeoutMs, {
1141
- min: 1
1142
- });
1143
- if (v !== void 0) escalation.timeoutMs = v;
1144
- }
1145
- if ("fallback" in raw.workers.escalation) {
1146
- const v = expectEnum(issues, "workers.escalation.fallback", raw.workers.escalation.fallback, [
1147
- "deny",
1148
- "fail"
1149
- ]);
1150
- if (v !== void 0) escalation.fallback = v;
1151
- }
1152
- settings.workers.escalation = escalation;
1153
- }
1154
- }
1155
- if ("resilienceCooldownMs" in raw.workers) {
1156
- const v = expectInteger(issues, "workers.resilienceCooldownMs", raw.workers.resilienceCooldownMs, { min: 0 });
1157
- if (v !== void 0) settings.workers.resilienceCooldownMs = v;
1158
- }
1159
- }
1160
- }
1161
- if ("scope" in raw) {
1162
- const v = expectStringArray(issues, "scope", raw.scope);
1163
- if (v !== void 0) settings.scope = normalizeScope(v);
1164
- }
1165
- if ("modelSelector" in raw) {
1166
- if (!isPlainObject(raw.modelSelector)) {
1167
- issues.add("modelSelector", `expected a map, got ${describe(raw.modelSelector)}`);
1168
- } else {
1169
- issues.unknownKeys("modelSelector", raw.modelSelector, ["favorites", "recentLimit"]);
1170
- if ("favorites" in raw.modelSelector) {
1171
- const v = expectStringArray(issues, "modelSelector.favorites", raw.modelSelector.favorites);
1172
- if (v !== void 0) settings.modelSelector.favorites = normalizeModelRefs(v, settings.targets);
1173
- }
1174
- if ("recentLimit" in raw.modelSelector) {
1175
- const v = expectInteger(issues, "modelSelector.recentLimit", raw.modelSelector.recentLimit, { min: 1 });
1176
- if (v !== void 0) settings.modelSelector.recentLimit = v;
1177
- }
1178
- }
1179
- }
1180
- if ("budget" in raw) {
1181
- if (!isPlainObject(raw.budget)) {
1182
- issues.add("budget", `expected a map, got ${describe(raw.budget)}`);
1183
- } else {
1184
- issues.unknownKeys("budget", raw.budget, ["sessionCeilingUsd", "concurrency"]);
1185
- if ("sessionCeilingUsd" in raw.budget) {
1186
- const v = expectNumber(issues, "budget.sessionCeilingUsd", raw.budget.sessionCeilingUsd, { min: 0 });
1187
- if (v !== void 0) settings.budget.sessionCeilingUsd = v;
1188
- }
1189
- if ("concurrency" in raw.budget) {
1190
- if (raw.budget.concurrency === "auto") {
1191
- settings.budget.concurrency = "auto";
1192
- } else {
1193
- const v = expectInteger(issues, "budget.concurrency", raw.budget.concurrency, { min: 1 });
1194
- if (v !== void 0) settings.budget.concurrency = v;
1195
- }
1196
- }
1197
- }
1198
- }
1199
- if ("defaults" in raw) {
1200
- if (!isPlainObject(raw.defaults)) {
1201
- issues.add("defaults", `expected a map, got ${describe(raw.defaults)}`);
1202
- } else {
1203
- issues.unknownKeys("defaults", raw.defaults, ["maxTokens"]);
1204
- if ("maxTokens" in raw.defaults) {
1205
- const v = expectInteger(issues, "defaults.maxTokens", raw.defaults.maxTokens, { min: 0 });
1206
- if (v !== void 0) settings.defaults.maxTokens = v;
1207
- }
1208
- }
1209
- }
1210
- if ("theme" in raw) {
1211
- const v = expectString(issues, "theme", raw.theme);
1212
- if (v !== void 0) settings.theme = v;
1213
- }
1214
- if ("terminal" in raw) {
1215
- if (!isPlainObject(raw.terminal)) {
1216
- issues.add("terminal", `expected a map, got ${describe(raw.terminal)}`);
1217
- } else {
1218
- issues.unknownKeys("terminal", raw.terminal, [
1219
- "showTerminalProgress",
1220
- "outputVerbosity",
1221
- "tuiMode",
1222
- "fullscreenScrollbar",
1223
- "smoothStreaming",
1224
- "notify"
1225
- ]);
1226
- if ("showTerminalProgress" in raw.terminal) {
1227
- const v = expectBoolean(issues, "terminal.showTerminalProgress", raw.terminal.showTerminalProgress);
1228
- if (v !== void 0) settings.terminal.showTerminalProgress = v;
1229
- }
1230
- if ("outputVerbosity" in raw.terminal) {
1231
- const v = expectString(issues, "terminal.outputVerbosity", raw.terminal.outputVerbosity);
1232
- if (v === "minimal" || v === "default" || v === "verbose") settings.terminal.outputVerbosity = v;
1233
- else if (v !== void 0) issues.add("terminal.outputVerbosity", "expected minimal, default, or verbose");
1234
- }
1235
- if ("tuiMode" in raw.terminal) {
1236
- const v = expectString(issues, "terminal.tuiMode", raw.terminal.tuiMode);
1237
- if (v === "regular" || v === "fullscreen") settings.terminal.tuiMode = v;
1238
- else if (v !== void 0) issues.add("terminal.tuiMode", "expected regular or fullscreen");
1239
- }
1240
- if ("fullscreenScrollbar" in raw.terminal) {
1241
- const v = expectString(issues, "terminal.fullscreenScrollbar", raw.terminal.fullscreenScrollbar);
1242
- if (v === "hidden" || v === "auto" || v === "always") settings.terminal.fullscreenScrollbar = v;
1243
- else if (v !== void 0) issues.add("terminal.fullscreenScrollbar", "expected hidden, auto, or always");
1244
- }
1245
- if ("smoothStreaming" in raw.terminal) {
1246
- const v = expectString(issues, "terminal.smoothStreaming", raw.terminal.smoothStreaming);
1247
- if (v === "off" || v === "auto" || v === "on") settings.terminal.smoothStreaming = v;
1248
- else if (v !== void 0) issues.add("terminal.smoothStreaming", "expected off, auto, or on");
1249
- }
1250
- if ("notify" in raw.terminal) {
1251
- const v = expectBoolean(issues, "terminal.notify", raw.terminal.notify);
1252
- if (v !== void 0) settings.terminal.notify = v;
1253
- }
1254
- }
1255
- }
1256
- if ("skills" in raw) {
1257
- if (!isPlainObject(raw.skills)) {
1258
- issues.add("skills", `expected a map, got ${describe(raw.skills)}`);
1259
- } else {
1260
- issues.unknownKeys("skills", raw.skills, ["trustProjectCompatRoots"]);
1261
- if ("trustProjectCompatRoots" in raw.skills) {
1262
- const v = expectBoolean(issues, "skills.trustProjectCompatRoots", raw.skills.trustProjectCompatRoots);
1263
- if (v !== void 0) settings.skills.trustProjectCompatRoots = v;
1264
- }
1265
- }
1266
- }
1267
- if ("attribution" in raw) {
1268
- if (!isPlainObject(raw.attribution)) {
1269
- issues.add("attribution", `expected a map, got ${describe(raw.attribution)}`);
1270
- } else {
1271
- issues.unknownKeys("attribution", raw.attribution, ["gitCommits"]);
1272
- if ("gitCommits" in raw.attribution) {
1273
- const v = expectBoolean(issues, "attribution.gitCommits", raw.attribution.gitCommits);
1274
- if (v !== void 0) settings.attribution.gitCommits = v;
1275
- }
1276
- }
1277
- }
1278
- if ("delegation" in raw) {
1279
- settings.delegation = validateDelegation(issues, raw.delegation);
1280
- }
1281
- if ("keybindings" in raw) {
1282
- settings.keybindings = validateKeybindings(issues, raw.keybindings);
1283
- }
1284
- if ("compaction" in raw) {
1285
- if (!isPlainObject(raw.compaction)) {
1286
- issues.add("compaction", `expected a map, got ${describe(raw.compaction)}`);
1287
- } else {
1288
- issues.unknownKeys("compaction", raw.compaction, ["auto", "threshold", "excludeLastTurns", "model", "systemPrompt"]);
1289
- if ("auto" in raw.compaction) {
1290
- const v = expectBoolean(issues, "compaction.auto", raw.compaction.auto);
1291
- if (v !== void 0) settings.compaction.auto = v;
1292
- }
1293
- if ("threshold" in raw.compaction) {
1294
- const v = expectNumber(issues, "compaction.threshold", raw.compaction.threshold, { min: 0, max: 1 });
1295
- if (v !== void 0) settings.compaction.threshold = v;
1296
- }
1297
- if ("excludeLastTurns" in raw.compaction) {
1298
- const v = expectInteger(issues, "compaction.excludeLastTurns", raw.compaction.excludeLastTurns, { min: 1 });
1299
- if (v !== void 0) settings.compaction.excludeLastTurns = v;
1300
- }
1301
- if ("model" in raw.compaction) {
1302
- const v = expectString(issues, "compaction.model", raw.compaction.model);
1303
- if (v !== void 0) settings.compaction.model = v;
1304
- }
1305
- if ("systemPrompt" in raw.compaction) {
1306
- const v = expectString(issues, "compaction.systemPrompt", raw.compaction.systemPrompt);
1307
- if (v !== void 0) settings.compaction.systemPrompt = v;
1308
- }
1309
- }
1310
- }
1311
- if ("context" in raw) {
1312
- if (!isPlainObject(raw.context)) {
1313
- issues.add("context", `expected a map, got ${describe(raw.context)}`);
1314
- } else {
1315
- issues.unknownKeys("context", raw.context, ["workingSet"]);
1316
- if ("workingSet" in raw.context) {
1317
- if (!isPlainObject(raw.context.workingSet)) {
1318
- issues.add("context.workingSet", `expected a map, got ${describe(raw.context.workingSet)}`);
1319
- } else {
1320
- const workingSet = raw.context.workingSet;
1321
- issues.unknownKeys("context.workingSet", workingSet, [
1322
- "enabled",
1323
- "policy",
1324
- "target",
1325
- "protectLastTurns",
1326
- "minEvictableTokens"
1327
- ]);
1328
- if ("enabled" in workingSet) {
1329
- const v = expectBoolean(issues, "context.workingSet.enabled", workingSet.enabled);
1330
- if (v !== void 0) settings.context.workingSet.enabled = v;
1331
- }
1332
- if ("policy" in workingSet) {
1333
- const v = expectEnum(issues, "context.workingSet.policy", workingSet.policy, [
1334
- "age-horizon",
1335
- "structural-v1"
1336
- ]);
1337
- if (v !== void 0) settings.context.workingSet.policy = v;
1338
- }
1339
- if ("target" in workingSet) {
1340
- const v = expectNumber(issues, "context.workingSet.target", workingSet.target);
1341
- if (v !== void 0 && (v <= 0 || v >= 1)) {
1342
- issues.add("context.workingSet.target", `expected a number > 0 and < 1, got ${v}`);
1343
- } else if (v !== void 0) {
1344
- settings.context.workingSet.target = v;
1345
- }
1346
- }
1347
- if ("protectLastTurns" in workingSet) {
1348
- const v = expectInteger(issues, "context.workingSet.protectLastTurns", workingSet.protectLastTurns, {
1349
- min: 1
1350
- });
1351
- if (v !== void 0) settings.context.workingSet.protectLastTurns = v;
1352
- }
1353
- if ("minEvictableTokens" in workingSet) {
1354
- const v = expectInteger(issues, "context.workingSet.minEvictableTokens", workingSet.minEvictableTokens, {
1355
- min: 0
1356
- });
1357
- if (v !== void 0) settings.context.workingSet.minEvictableTokens = v;
1358
- }
1359
- }
1360
- }
1361
- }
1362
- }
1363
- if ("prewarm" in raw) {
1364
- if (!isPlainObject(raw.prewarm)) {
1365
- issues.add("prewarm", `expected a map, got ${describe(raw.prewarm)}`);
1366
- } else {
1367
- issues.unknownKeys("prewarm", raw.prewarm, ["enabled"]);
1368
- if ("enabled" in raw.prewarm) {
1369
- const v = expectBoolean(issues, "prewarm.enabled", raw.prewarm.enabled);
1370
- if (v !== void 0) settings.prewarm.enabled = v;
1371
- }
1372
- }
1373
- }
1374
- if ("panes" in raw) {
1375
- if (!isPlainObject(raw.panes)) {
1376
- issues.add("panes", `expected a map, got ${describe(raw.panes)}`);
1377
- } else {
1378
- issues.unknownKeys("panes", raw.panes, ["enabled", "agents", "keepFailed", "notifications", "journal", "yazi"]);
1379
- if ("enabled" in raw.panes) {
1380
- const v = expectEnum(issues, "panes.enabled", raw.panes.enabled, ["auto", "embedded", "off"]);
1381
- if (v !== void 0) settings.panes.enabled = v;
1382
- }
1383
- if ("notifications" in raw.panes) {
1384
- const v = expectEnum(issues, "panes.notifications", raw.panes.notifications, ["failures", "all", "off"]);
1385
- if (v !== void 0) settings.panes.notifications = v;
1386
- }
1387
- if ("journal" in raw.panes) {
1388
- const v = expectBoolean(issues, "panes.journal", raw.panes.journal);
1389
- if (v !== void 0) settings.panes.journal = v;
1390
- }
1391
- if ("yazi" in raw.panes) {
1392
- if (!isPlainObject(raw.panes.yazi)) {
1393
- issues.add("panes.yazi", `expected a map, got ${describe(raw.panes.yazi)}`);
1394
- } else {
1395
- const yazi = raw.panes.yazi;
1396
- issues.unknownKeys("panes.yazi", yazi, ["enabled", "mode", "profile", "followCwd"]);
1397
- if ("enabled" in yazi) {
1398
- const v = expectBoolean(issues, "panes.yazi.enabled", yazi.enabled);
1399
- if (v !== void 0) settings.panes.yazi.enabled = v;
1400
- }
1401
- if ("mode" in yazi) {
1402
- const v = expectEnum(issues, "panes.yazi.mode", yazi.mode, ["companion", "chooser"]);
1403
- if (v !== void 0) settings.panes.yazi.mode = v;
1404
- }
1405
- if ("profile" in yazi) {
1406
- const v = expectEnum(issues, "panes.yazi.profile", yazi.profile, ["managed", "user"]);
1407
- if (v !== void 0) settings.panes.yazi.profile = v;
1408
- }
1409
- if ("followCwd" in yazi) {
1410
- const v = expectBoolean(issues, "panes.yazi.followCwd", yazi.followCwd);
1411
- if (v !== void 0) settings.panes.yazi.followCwd = v;
1412
- }
1413
- }
1414
- }
1415
- }
1416
- }
1417
- if ("retry" in raw) {
1418
- if (!isPlainObject(raw.retry)) {
1419
- issues.add("retry", `expected a map, got ${describe(raw.retry)}`);
1420
- } else {
1421
- issues.unknownKeys("retry", raw.retry, ["enabled", "maxRetries", "baseDelayMs", "maxDelayMs", "streamStallMs"]);
1422
- if ("enabled" in raw.retry) {
1423
- const v = expectBoolean(issues, "retry.enabled", raw.retry.enabled);
1424
- if (v !== void 0) settings.retry.enabled = v;
1425
- }
1426
- for (const key of ["maxRetries", "baseDelayMs", "maxDelayMs", "streamStallMs"]) {
1427
- if (key in raw.retry) {
1428
- const v = expectInteger(issues, `retry.${key}`, raw.retry[key], { min: 0 });
1429
- if (v !== void 0) settings.retry[key] = v;
1430
- }
1431
- }
1432
- }
1433
- }
1434
- if ("guardrails" in raw) {
1435
- if (!isPlainObject(raw.guardrails)) {
1436
- issues.add("guardrails", `expected a map, got ${describe(raw.guardrails)}`);
1437
- } else {
1438
- const keys = [
1439
- "turnToolCallBudget",
1440
- "workerToolCallCap",
1441
- "maxDispatchRuns",
1442
- "readMaxBytes",
1443
- "observationTurnBudgetBytes",
1444
- "internalDispatchTimeoutMs"
1445
- ];
1446
- issues.unknownKeys("guardrails", raw.guardrails, keys);
1447
- for (const key of keys) {
1448
- if (key in raw.guardrails) {
1449
- const v = expectInteger(issues, `guardrails.${key}`, raw.guardrails[key], { min: 1 });
1450
- if (v !== void 0) settings.guardrails[key] = v;
1451
- }
1452
- }
1453
- }
1454
- }
1455
- return { settings, issues: issues.list };
1456
- }
1457
- function validateSettingsFile() {
1458
- const path = join(resolveClioDirs().config, "settings.yaml");
1459
- if (!existsSync(path)) return { settings: cloneValue(DEFAULT_SETTINGS), issues: [] };
1460
- let text;
1461
- try {
1462
- text = readFileSync(path, "utf8");
1463
- } catch (err) {
1464
- return {
1465
- settings: cloneValue(DEFAULT_SETTINGS),
1466
- issues: [
1467
- { path: "(root)", message: `unreadable: ${err instanceof Error ? err.message : String(err)}`, kind: "unreadable" }
1468
- ]
1469
- };
1470
- }
1471
- let parsed;
1472
- try {
1473
- parsed = (0, import_yaml.parse)(text);
1474
- } catch (err) {
1475
- return {
1476
- settings: cloneValue(DEFAULT_SETTINGS),
1477
- issues: [{ path: "(root)", message: `invalid YAML: ${yamlErrorSummary(err)}`, kind: "syntax" }]
1478
- };
1479
- }
1480
- return validateSettings(parsed);
1481
- }
1482
- function readSettings() {
1483
- const result = validateSettingsFile();
1484
- if (result.issues.length > 0) throw new SettingsValidationError(result.issues);
1485
- return result.settings;
1486
- }
1487
- function persistSettings(document) {
1488
- safeResourceWrite(settingsPath(), (0, import_yaml.stringify)(document), { encoding: "utf8", mode: 420 });
1489
- }
1490
- function readSavedDocument() {
1491
- const path = settingsPath();
1492
- if (!existsSync(path)) return {};
1493
- try {
1494
- return (0, import_yaml.parse)(readFileSync(path, "utf8")) ?? {};
1495
- } catch {
1496
- return {};
1497
- }
1498
- }
1499
- function applySettingsDelta(saved, before, after) {
1500
- if (!isPlainObject(before) || !isPlainObject(after)) return cloneValue(after);
1501
- const out = isPlainObject(saved) ? { ...saved } : {};
1502
- for (const [key, next] of Object.entries(after)) {
1503
- if (deepEquals(before[key], next)) continue;
1504
- out[key] = applySettingsDelta(out[key], before[key], next);
1505
- }
1506
- for (const key of Object.keys(out)) {
1507
- if (!(key in after)) delete out[key];
1508
- }
1509
- return out;
1510
- }
1511
- function deepEquals(a, b) {
1512
- if (a === b) return true;
1513
- if (Array.isArray(a) || Array.isArray(b)) {
1514
- if (!Array.isArray(a) || !Array.isArray(b) || a.length !== b.length) return false;
1515
- return a.every((entry, index) => deepEquals(entry, b[index]));
1516
- }
1517
- if (!isPlainObject(a) || !isPlainObject(b)) return false;
1518
- const keys = Object.keys(a);
1519
- if (keys.length !== Object.keys(b).length) return false;
1520
- return keys.every((key) => key in b && deepEquals(a[key], b[key]));
1521
- }
1522
- function updateSavedSettingsDocument(mutate, options = {}) {
1523
- withSettingsLock(() => {
1524
- readSettings();
1525
- const saved = readSavedDocument();
1526
- persistSettings(mutate(cloneValue(saved)));
1527
- }, options);
1528
- }
1529
- function withSettingsLock(fn, options = {}) {
1530
- return withStateFileLockSync(settingsPath(), fn, { timeoutMs: options.timeoutMs ?? 1e4 });
1531
- }
1532
- function updateSettings(mutate, options = {}) {
1533
- return withSettingsLock(() => {
1534
- const saved = readSavedDocument();
1535
- const current = readSettings();
1536
- const before = cloneValue(current);
1537
- const next = mutate(current) ?? current;
1538
- const revalidated = validateSettings(JSON.parse(JSON.stringify(next)));
1539
- if (revalidated.issues.length > 0) throw new SettingsValidationError(revalidated.issues);
1540
- persistSettings(applySettingsDelta(saved, before, revalidated.settings));
1541
- return revalidated.settings;
1542
- }, options);
1543
- }
1544
- function useTargetInSettings(settings, targetId, options = {}) {
1545
- const target = settings.targets.find((entry) => entry.id === targetId);
1546
- if (!target) return null;
1547
- const workerTarget = options.workerTargetId !== void 0 && options.workerTargetId !== target.id ? settings.targets.find((entry) => entry.id === options.workerTargetId) : target;
1548
- if (!workerTarget) return null;
1549
- const sharedModel = options.model ?? target.defaultModel ?? null;
1550
- settings.orchestrator.target = target.id;
1551
- settings.orchestrator.model = options.orchestratorModel ?? sharedModel;
1552
- settings.workers.default.target = workerTarget.id;
1553
- settings.workers.default.model = options.workerModel ?? (workerTarget === target ? sharedModel : workerTarget.defaultModel ?? null);
1554
- if (options.backgroundModel !== void 0) {
1555
- settings.background.target = target.id;
1556
- settings.background.model = options.backgroundModel;
1557
- }
1558
- return { workerTargetId: workerTarget.id };
1559
- }
1560
- function removeTargetFromSettings(settings, id) {
1561
- if (!settings.targets.some((entry) => entry.id === id)) return false;
1562
- settings.targets = settings.targets.filter((entry) => entry.id !== id);
1563
- if (settings.orchestrator.target === id) {
1564
- settings.orchestrator.target = null;
1565
- settings.orchestrator.model = null;
1566
- }
1567
- if (settings.background.target === id) {
1568
- settings.background.target = null;
1569
- settings.background.model = null;
1570
- }
1571
- if (settings.workers.default.target === id) {
1572
- settings.workers.default.target = null;
1573
- settings.workers.default.model = null;
1574
- }
1575
- for (const [name, profile] of Object.entries(settings.workers.profiles)) {
1576
- if (profile.target === id) delete settings.workers.profiles[name];
1577
- }
1578
- settings.scope = settings.scope.filter((entry) => entry.split("/")[0] !== id);
1579
- return true;
1580
- }
1581
- function setFleetProfileInSettings(settings, name, targetId, options = {}) {
1582
- const target = settings.targets.find((entry) => entry.id === targetId);
1583
- if (!target) return false;
1584
- const existing = settings.workers.profiles[name];
1585
- settings.workers.profiles[name] = {
1586
- target: target.id,
1587
- model: options.model ?? target.defaultModel ?? null,
1588
- thinkingLevel: options.thinkingLevel ?? existing?.thinkingLevel ?? "off"
1589
- };
1590
- return true;
1591
- }
1592
- function removeFleetProfileFromSettings(settings, name) {
1593
- delete settings.workers.profiles[name];
1594
- let removedBindings = 0;
1595
- for (const [agentId, profileName] of Object.entries(settings.workers.agentBindings)) {
1596
- if (profileName !== name) continue;
1597
- delete settings.workers.agentBindings[agentId];
1598
- removedBindings += 1;
1599
- }
1600
- return removedBindings;
1601
- }
1602
- function bindAgentProfileInSettings(settings, agentId, profileName) {
1603
- if (settings.delegation.agents.some((agent) => agent.id === agentId)) return false;
1604
- settings.workers.agentBindings[agentId] = profileName;
1605
- return true;
1606
- }
1607
-
1608
- export {
1609
- settingsPath,
1610
- SettingsValidationError,
1611
- formatSettingsIssues,
1612
- formatSettingsFailure,
1613
- validateSettings,
1614
- validateSettingsFile,
1615
- readSettings,
1616
- applySettingsDelta,
1617
- updateSavedSettingsDocument,
1618
- updateSettings,
1619
- useTargetInSettings,
1620
- removeTargetFromSettings,
1621
- setFleetProfileInSettings,
1622
- removeFleetProfileFromSettings,
1623
- bindAgentProfileInSettings
1624
- };
1625
- //# sourceMappingURL=chunk-VFA6GDY5.js.map