@iowarp/clio-coder 0.3.9 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (416) hide show
  1. package/CHANGELOG.md +53 -0
  2. package/NOTICE +33 -0
  3. package/README.md +7 -2
  4. package/dist/{acp-7LOELQFP.js → acp-G5WJBNCT.js} +13 -12
  5. package/dist/{agents-FIBG2SHA.js → agents-FMV2Q5G4.js} +39 -36
  6. package/dist/assets/codewiki.json +1 -1
  7. package/dist/{auth-OI4LIH2I.js → auth-3IDSJEIK.js} +16 -15
  8. package/dist/{builtins-AD25UL3C.js → builtins-XCZWXSC7.js} +3 -3
  9. package/dist/{chunk-IFBNV6H6.js → chunk-2ANTL7MR.js} +3 -3
  10. package/dist/{chunk-56KB5IJP.js → chunk-2OQE55CK.js} +3 -3
  11. package/dist/{chunk-N3PBVRTZ.js → chunk-32KWKNSF.js} +9 -7
  12. package/dist/{chunk-VKBMFOYV.js → chunk-36EJLSQQ.js} +23 -27
  13. package/dist/{chunk-465CC7FK.js → chunk-3BT2XMV4.js} +16 -13
  14. package/dist/{chunk-NQ6UCCOD.js → chunk-3URVFKWK.js} +7 -7
  15. package/dist/{chunk-WIE7ZOSW.js → chunk-3XML7CDN.js} +2 -2
  16. package/dist/chunk-42FMPA75.js +101 -0
  17. package/dist/{chunk-A2NJGIB3.js → chunk-5LXZXPKX.js} +2 -2
  18. package/dist/{chunk-HAY4ZE2P.js → chunk-5PSMVOLM.js} +2 -2
  19. package/dist/{chunk-JEQQR47K.js → chunk-6DB53AJS.js} +168 -9
  20. package/dist/{chunk-KV2AOLDF.js → chunk-76ONBSIA.js} +5 -25
  21. package/dist/{chunk-FALJGAWU.js → chunk-7MCTRUCE.js} +2 -2
  22. package/dist/{chunk-5T7RBWN2.js → chunk-AB44T6BB.js} +5 -5
  23. package/dist/chunk-B7OBL7PK.js +1405 -0
  24. package/dist/{chunk-B5CSFE7B.js → chunk-BBVJUZHB.js} +2 -2
  25. package/dist/{chunk-EQ63NRB7.js → chunk-BBVYXMFO.js} +2 -2
  26. package/dist/{chunk-O6I4CIEU.js → chunk-BKFJHQCA.js} +6 -6
  27. package/dist/chunk-BKFM6EJV.js +462 -0
  28. package/dist/chunk-BMS5RKQY.js +27 -0
  29. package/dist/{chunk-MV2VUEJC.js → chunk-BPKCPIL7.js} +2 -2
  30. package/dist/{chunk-TEO2TLVN.js → chunk-BUMFYQFY.js} +964 -1120
  31. package/dist/{chunk-BNAZZHFG.js → chunk-BYP5D4HI.js} +1 -1
  32. package/dist/chunk-C2LTL2W6.js +2447 -0
  33. package/dist/{chunk-EBOC7MT3.js → chunk-CODPRO7Q.js} +8 -8
  34. package/dist/{chunk-HPCTNZM2.js → chunk-CTJ4RNAA.js} +4 -4
  35. package/dist/{chunk-ODFEOB4F.js → chunk-CY6FY24N.js} +26 -8
  36. package/dist/{chunk-MIX5N5AC.js → chunk-DQITNCXG.js} +394 -154
  37. package/dist/{chunk-S4COXYBG.js → chunk-DYJP44XW.js} +129 -106
  38. package/dist/{chunk-N5XKWMDW.js → chunk-F4CKPOEQ.js} +6 -6
  39. package/dist/{chunk-AMKHQW3C.js → chunk-FEFIFZTL.js} +3 -3
  40. package/dist/{chunk-MV3K5QF2.js → chunk-GCSMB2KY.js} +2 -2
  41. package/dist/{chunk-7C6RYZGQ.js → chunk-GKF55TAZ.js} +3 -3
  42. package/dist/{chunk-B5XRQOLB.js → chunk-GR5G2PVF.js} +9 -8
  43. package/dist/{chunk-XDOQXGFO.js → chunk-GXNLGKAB.js} +64 -8
  44. package/dist/chunk-HHV2GANA.js +88 -0
  45. package/dist/{chunk-774ILSRL.js → chunk-HI63TFOG.js} +4 -3
  46. package/dist/{chunk-R7LNVMCS.js → chunk-HJJTYUHX.js} +64 -72
  47. package/dist/{chunk-RKRLDWD3.js → chunk-HLW2MRKE.js} +1 -1
  48. package/dist/{chunk-CA42X6KT.js → chunk-HWHKMHUA.js} +6 -6
  49. package/dist/chunk-HZHHCK24.js +1631 -0
  50. package/dist/{chunk-HJB5IUKP.js → chunk-I5VEOC6I.js} +12 -12
  51. package/dist/chunk-IBEBSCYA.js +564 -0
  52. package/dist/chunk-IQ7KR472.js +362 -0
  53. package/dist/{chunk-4H6ULJ3H.js → chunk-J4W7KFM7.js} +921 -990
  54. package/dist/{chunk-4LJX2PUC.js → chunk-JDG2WCRO.js} +5 -5
  55. package/dist/{chunk-NZU6YDNV.js → chunk-K5C3NCBD.js} +4 -4
  56. package/dist/{chunk-CGKSTWHD.js → chunk-K6BSR66V.js} +2 -1
  57. package/dist/{chunk-NNNWO6F2.js → chunk-KFZI4NIL.js} +93 -3
  58. package/dist/chunk-KMVISBZR.js +132 -0
  59. package/dist/{chunk-BVDVID7E.js → chunk-LDQ2ZF2M.js} +2 -2
  60. package/dist/{chunk-OEDBCISO.js → chunk-LQ3DZAMX.js} +2 -2
  61. package/dist/{chunk-PZ4I4JE2.js → chunk-LY4S7GJC.js} +124 -116
  62. package/dist/{chunk-3DUR4WUA.js → chunk-MLKNTWH2.js} +19 -19
  63. package/dist/chunk-NEKRRTYW.js +56 -0
  64. package/dist/{chunk-5DQRIYDZ.js → chunk-NHCZP4K7.js} +2 -2
  65. package/dist/chunk-NHLBIGRH.js +1506 -0
  66. package/dist/chunk-NQQH3YT7.js +302 -0
  67. package/dist/chunk-NYS75XW5.js +15 -0
  68. package/dist/{chunk-TD7UE2L5.js → chunk-O4XIVISU.js} +7 -7
  69. package/dist/{chunk-WXCJ7VME.js → chunk-O6TL7WWY.js} +6 -6
  70. package/dist/chunk-OQBA45DZ.js +97 -0
  71. package/dist/{chunk-LU7P4LHA.js → chunk-P3FOHJT4.js} +2 -2
  72. package/dist/chunk-PMZCIOCJ.js +25 -0
  73. package/dist/{chunk-I4HZDVNP.js → chunk-PQEFIJ36.js} +2 -2
  74. package/dist/{chunk-HKO36JWF.js → chunk-QBJA7R7N.js} +31 -3
  75. package/dist/chunk-QDC3K2U3.js +262 -0
  76. package/dist/{chunk-5HFBWUMU.js → chunk-QLFS5GO2.js} +4 -4
  77. package/dist/{chunk-GAYUJ7LE.js → chunk-QLL7ILRG.js} +41 -32
  78. package/dist/{chunk-LXPJXFM5.js → chunk-QREDIESB.js} +7 -7
  79. package/dist/chunk-QSNYB6ZV.js +195 -0
  80. package/dist/chunk-R346GLFC.js +31 -0
  81. package/dist/{chunk-VPTUJU4P.js → chunk-SJ5ZKQ4S.js} +2 -2
  82. package/dist/{chunk-QQ7EKM72.js → chunk-SP2RXXYO.js} +6 -54
  83. package/dist/chunk-SUCTJL45.js +45 -0
  84. package/dist/{chunk-5QKCQQ3E.js → chunk-SUW5DORT.js} +2 -2
  85. package/dist/chunk-T56WDKA5.js +183 -0
  86. package/dist/chunk-TVHHYFHE.js +255 -0
  87. package/dist/{chunk-IHKBWSXF.js → chunk-TZ3SGWZZ.js} +2 -2
  88. package/dist/{chunk-ECUO3KDP.js → chunk-U77AMWDL.js} +47 -7
  89. package/dist/{chunk-3UUY7R3Z.js → chunk-ULC6OTWO.js} +7 -7
  90. package/dist/{chunk-AEYBF3TB.js → chunk-UM7N4G5A.js} +2 -2
  91. package/dist/{chunk-3V5AYSEQ.js → chunk-UXMFQ54G.js} +43 -36
  92. package/dist/{chunk-YW7UVM5V.js → chunk-V5DHCITQ.js} +34 -1
  93. package/dist/{chunk-47CMYGET.js → chunk-VAZSBTKF.js} +2 -2
  94. package/dist/{chunk-3MRC2YSQ.js → chunk-VEO4AP2K.js} +2 -2
  95. package/dist/{chunk-PNY46YEY.js → chunk-VFA6GDY5.js} +47 -3
  96. package/dist/chunk-VO67MWHC.js +75 -0
  97. package/dist/{chunk-XK56QHLX.js → chunk-VPKWYKEY.js} +19 -5
  98. package/dist/{chunk-AD7Y7STJ.js → chunk-VYMXRQI6.js} +36 -22
  99. package/dist/{chunk-T3Z6VAAF.js → chunk-W5VSYASO.js} +19 -17
  100. package/dist/{chunk-5PVQ4SRS.js → chunk-WZR7K7ZX.js} +7 -123
  101. package/dist/{chunk-DG4M6ZUE.js → chunk-X3YGUTOB.js} +4 -4
  102. package/dist/chunk-X75E3D2N.js +686 -0
  103. package/dist/{chunk-P3JGPQFL.js → chunk-YDFRH54B.js} +4 -4
  104. package/dist/chunk-YJX4SHTD.js +40 -0
  105. package/dist/{chunk-ZI647VB5.js → chunk-YPI3QQCF.js} +2 -2
  106. package/dist/{chunk-YSEHGPCT.js → chunk-Z2RR6MAK.js} +3 -3
  107. package/dist/{chunk-HCBCAYZU.js → chunk-Z4TXYIEG.js} +5 -5
  108. package/dist/cli/index.js +47 -36
  109. package/dist/{clio-LT5V7SSZ.js → clio-2JXHBBY5.js} +7 -7
  110. package/dist/{code-nav-LMW275PA.js → code-nav-3YYRMYNF.js} +6 -6
  111. package/dist/{compile-cache-CVJMMODC.js → compile-cache-7FPE6PS3.js} +3 -3
  112. package/dist/{components-ZFA3SAER.js → components-RYZV4JGP.js} +5 -5
  113. package/dist/{config-RXS5T3JT.js → config-QZPCMYSO.js} +58 -50
  114. package/dist/{configure-2WYWSCSD.js → configure-TEGEBYCA.js} +21 -19
  115. package/dist/{context-I3BTOTCS.js → context-AV7OEZ4D.js} +11 -11
  116. package/dist/{context-MVOORGMF.js → context-E6H5RNMC.js} +49 -41
  117. package/dist/{context-PALKKQYL.js → context-GSXUE4CT.js} +25 -23
  118. package/dist/{context-clear-N2WOYZ2K.js → context-clear-SHIBYK6T.js} +48 -40
  119. package/dist/{context-working-set-MIEVECVZ.js → context-working-set-5ZGKPGZQ.js} +11 -10
  120. package/dist/{dispatch-runner-VVA4SRRH.js → dispatch-runner-EFMJT4LD.js} +88 -60
  121. package/dist/{docs-7LQ23DLM.js → docs-23KQS3XK.js} +5 -5
  122. package/dist/doctor-QOA5FNY5.js +313 -0
  123. package/dist/{eval-IJ5VEZDJ.js → eval-TFBYQH4H.js} +66 -64
  124. package/dist/eval-inventory-SXH7PDKX.js +316 -0
  125. package/dist/{evidence-L5APPXNV.js → evidence-ERGESKGN.js} +198 -44
  126. package/dist/{evolve-RGNKFJ52.js → evolve-VDXTSYCJ.js} +46 -38
  127. package/dist/{extensions-7WYWUX5A.js → extensions-7BGBHN57.js} +6 -6
  128. package/dist/{fleet-6CNVBZZP.js → fleet-2RRVDF2V.js} +189 -101
  129. package/dist/{fleet-commands-L2SXSYEI.js → fleet-commands-VJ726XIA.js} +10 -10
  130. package/dist/fleet-decisions-EPAPM3XJ.js +157 -0
  131. package/dist/{fleet-graph-2J3OOIPO.js → fleet-graph-JF5QOATM.js} +16 -15
  132. package/dist/fleet-inspect-VLY4S7QM.js +442 -0
  133. package/dist/{fleet-preflight-CZRJ4JP5.js → fleet-preflight-AIZUEJOY.js} +6 -5
  134. package/dist/{fleet-validate-C5RI6DP7.js → fleet-validate-AJRPDMDV.js} +20 -18
  135. package/dist/fleet-verify-JFEL2L3H.js +175 -0
  136. package/dist/fleet-view-ZCON35AG.js +102 -0
  137. package/dist/{init-VBN2ACVA.js → init-DN2WWLFE.js} +64 -56
  138. package/dist/install-XGLBQY5E.js +13 -0
  139. package/dist/interop-OZBKXAYL.js +114 -0
  140. package/dist/{library-JHGUMLY2.js → library-YWZG7IMW.js} +19 -18
  141. package/dist/{memory-K4OQIYWG.js → memory-I4C4HMLW.js} +48 -40
  142. package/dist/{models-2NCZUWDD.js → models-CEYXJBO6.js} +30 -28
  143. package/dist/{monitor-MMVTJABD.js → monitor-NZ6GCI3P.js} +53 -47
  144. package/dist/{orchestrator-ZKBPCHW6.js → orchestrator-GCGQ4N5I.js} +6311 -7145
  145. package/dist/panes-HMABYVO4.js +58 -0
  146. package/dist/panes-KY6W3V2E.js +103 -0
  147. package/dist/{paths-DBXMZMDU.js → paths-II4K7DNR.js} +5 -5
  148. package/dist/{reset-DD5JGOY3.js → reset-DQ6FGCSH.js} +13 -11
  149. package/dist/resources-BB3MVJMD.js +111 -0
  150. package/dist/{run-QEGNX7FL.js → run-H2GQDUER.js} +113 -82
  151. package/dist/{share-JKD3BQMW.js → share-GTJN6A5O.js} +18 -17
  152. package/dist/{skills-LMQIKDOZ.js → skills-L55TEW6R.js} +31 -24
  153. package/dist/{skills-eval-I7X2774U.js → skills-eval-XVXPH2JI.js} +61 -52
  154. package/dist/skills-inventory-S4MXPJFV.js +126 -0
  155. package/dist/slash-commands-ZSGASKJC.js +77 -0
  156. package/dist/{steer-CF5TDANS.js → steer-RZGSCY4R.js} +3 -3
  157. package/dist/{support-I7LOJLIF.js → support-PKEUNNQL.js} +4 -4
  158. package/dist/{targets-RUSR6B5Z.js → targets-NCPZ644J.js} +31 -29
  159. package/dist/{terminal-lease-QYVORFR4.js → terminal-lease-44SV3YCN.js} +4 -4
  160. package/dist/tools-DAF3DI3C.js +27 -0
  161. package/dist/{trace-ODOQIVIW.js → trace-FYVW2MQA.js} +149 -7
  162. package/dist/tui-primitives-2AKXQNZK.js +13 -0
  163. package/dist/{uninstall-ZJF5H5ZN.js → uninstall-DW2PNOIC.js} +5 -5
  164. package/dist/{upgrade-XANW3FXB.js → upgrade-3XPP6OQL.js} +26 -24
  165. package/dist/{usage-4H7ZRXQT.js → usage-3NLHGTU2.js} +57 -49
  166. package/dist/{verifiers-UZXNBZEB.js → verifiers-SSQONKRT.js} +171 -12
  167. package/dist/{verify-BVKWTNDL.js → verify-3U6J7FZI.js} +9 -9
  168. package/dist/{web-fetch-2YHJ3KTG.js → web-fetch-S7RR6GZ7.js} +3 -3
  169. package/dist/{wiki-generate-MY7WV2QI.js → wiki-generate-CEHYGPGQ.js} +67 -59
  170. package/dist/with-panes-MKB46MPQ.js +782 -0
  171. package/dist/worker/entry.js +101 -66
  172. package/docs/README.md +3 -2
  173. package/docs/acp.md +24 -3
  174. package/docs/alcf-provider.md +1 -1
  175. package/docs/architecture.md +2 -2
  176. package/docs/artifact-versions.md +4 -1
  177. package/docs/built-in-agents.md +1 -1
  178. package/docs/capacity-and-scheduling.md +43 -5
  179. package/docs/commands-and-modes.md +31 -2
  180. package/docs/configuration-and-targets.md +40 -10
  181. package/docs/context-engine.md +1 -1
  182. package/docs/development-pipeline.md +19 -0
  183. package/docs/dispatch-typed-intent.md +385 -0
  184. package/docs/documentation-coverage.md +2 -2
  185. package/docs/documentation-guide.md +1 -1
  186. package/docs/environment-variables.md +1 -0
  187. package/docs/eval-runner.md +1 -1
  188. package/docs/evals-internal.md +1 -1
  189. package/docs/evidence-and-memory.md +2 -2
  190. package/docs/evolution.md +1 -1
  191. package/docs/exit-codes-and-output.md +1 -1
  192. package/docs/extensions-and-sharing.md +25 -1
  193. package/docs/fleet-dispatch.md +22 -1
  194. package/docs/installation-and-lifecycle.md +15 -2
  195. package/docs/middleware-and-components.md +1 -1
  196. package/docs/model-catalog.md +10 -1
  197. package/docs/observability.md +3 -3
  198. package/docs/proactive-memory.md +1 -1
  199. package/docs/prompt-envelope-and-tools.md +1 -1
  200. package/docs/provider-adapter-cookbook.md +1 -1
  201. package/docs/safety-model.md +2 -2
  202. package/docs/scientific-validation.md +3 -3
  203. package/docs/session-lifecycle.md +1 -1
  204. package/docs/skills-marketplace.md +1 -1
  205. package/docs/tool-usage.md +18 -8
  206. package/docs/trace-store.md +1 -1
  207. package/docs/troubleshooting.md +1 -1
  208. package/docs/tui-design.md +1 -1
  209. package/docs/worker-dispatch-mechanics.md +1 -1
  210. package/package.json +4 -2
  211. package/src/cli/acp.ts +6 -2
  212. package/src/cli/argv.ts +25 -0
  213. package/src/cli/configure.ts +23 -21
  214. package/src/cli/doctor-panes.ts +124 -0
  215. package/src/cli/doctor-toolchain.ts +57 -0
  216. package/src/cli/doctor.ts +20 -1
  217. package/src/cli/eval-inventory.ts +436 -0
  218. package/src/cli/eval.ts +13 -0
  219. package/src/cli/evidence-detail.ts +88 -0
  220. package/src/cli/evidence-inventory.ts +183 -0
  221. package/src/cli/evidence.ts +30 -5
  222. package/src/cli/fleet-decisions.ts +69 -0
  223. package/src/cli/fleet-inspect.ts +334 -0
  224. package/src/cli/fleet-verify.ts +133 -0
  225. package/src/cli/fleet-view.ts +810 -0
  226. package/src/cli/fleet.ts +148 -37
  227. package/src/cli/index.ts +14 -2
  228. package/src/cli/interop-inspect.ts +128 -0
  229. package/src/cli/interop.ts +34 -0
  230. package/src/cli/panes.ts +35 -0
  231. package/src/cli/reset.ts +5 -2
  232. package/src/cli/run.ts +58 -0
  233. package/src/cli/skills-inventory.ts +185 -0
  234. package/src/cli/skills.ts +16 -13
  235. package/src/cli/tools.ts +321 -0
  236. package/src/cli/trace-inspect.ts +252 -0
  237. package/src/cli/trace.ts +23 -2
  238. package/src/cli/verifiers-inspect.ts +347 -0
  239. package/src/cli/verifiers.ts +9 -0
  240. package/src/core/bus-events.ts +4 -0
  241. package/src/core/config.ts +49 -0
  242. package/src/core/defaults.ts +93 -7
  243. package/src/core/response-schema.ts +44 -4
  244. package/src/core/theme-token-hex.ts +43 -0
  245. package/src/core/tool-names.ts +2 -1
  246. package/src/core/xdg.ts +1 -1
  247. package/src/domains/agents/fleets/build-review.md +0 -3
  248. package/src/domains/agents/fleets/build-test.md +0 -3
  249. package/src/domains/agents/result-contract-filesystem.ts +32 -0
  250. package/src/domains/agents/result-contract.ts +164 -35
  251. package/src/domains/config/classify.ts +3 -0
  252. package/src/domains/dispatch/admission-error.ts +9 -0
  253. package/src/domains/dispatch/admission.ts +22 -21
  254. package/src/domains/dispatch/capacity-lease.ts +21 -1
  255. package/src/domains/dispatch/council-topology.ts +398 -0
  256. package/src/domains/dispatch/extension.ts +222 -50
  257. package/src/domains/dispatch/fleet-node-prompt.ts +62 -0
  258. package/src/domains/dispatch/fleet-plan.ts +7 -2
  259. package/src/domains/dispatch/fleet-run.ts +64 -1
  260. package/src/domains/dispatch/gate-decisions.ts +11 -1
  261. package/src/domains/dispatch/gate-role-prompts.ts +9 -0
  262. package/src/domains/dispatch/gate-topology.ts +289 -0
  263. package/src/domains/dispatch/index.ts +19 -0
  264. package/src/domains/dispatch/intent-compatibility.ts +330 -0
  265. package/src/domains/dispatch/intent.ts +85 -1
  266. package/src/domains/dispatch/reservation-store.ts +24 -4
  267. package/src/domains/dispatch/run-event-journal-bridge.ts +149 -0
  268. package/src/domains/dispatch/run-event-journal.ts +598 -0
  269. package/src/domains/dispatch/state.ts +45 -1
  270. package/src/domains/dispatch/types.ts +13 -0
  271. package/src/domains/dispatch/validation.ts +33 -8
  272. package/src/domains/eval/compare/compare.ts +3 -16
  273. package/src/domains/eval/inventory.ts +113 -0
  274. package/src/domains/eval/schema/serving.ts +31 -0
  275. package/src/domains/evidence/store.ts +6 -0
  276. package/src/domains/memory/index.ts +0 -1
  277. package/src/domains/memory/task-memory-policy.ts +6 -10
  278. package/src/domains/memory/task-memory-telemetry.ts +1 -0
  279. package/src/domains/middleware/memory-intervention.ts +33 -21
  280. package/src/domains/mux/contract.ts +434 -0
  281. package/src/domains/mux/detect.ts +158 -0
  282. package/src/domains/mux/extension.ts +47 -0
  283. package/src/domains/mux/index.ts +96 -0
  284. package/src/domains/mux/manifest.ts +6 -0
  285. package/src/domains/mux/operations.ts +164 -0
  286. package/src/domains/mux/pane-registry.ts +90 -0
  287. package/src/domains/mux/protocol.ts +49 -0
  288. package/src/domains/mux/socket-client.ts +816 -0
  289. package/src/domains/mux/types.ts +222 -0
  290. package/src/domains/mux/viewer-command.ts +59 -0
  291. package/src/domains/mux/yazi/assets/init.lua +2 -0
  292. package/src/domains/mux/yazi/assets/plugins/git.yazi/LICENSE +21 -0
  293. package/src/domains/mux/yazi/assets/plugins/git.yazi/README.md +78 -0
  294. package/src/domains/mux/yazi/assets/plugins/git.yazi/main.lua +255 -0
  295. package/src/domains/mux/yazi/assets/plugins/git.yazi/types.lua +12 -0
  296. package/src/domains/mux/yazi/assets/yazi.toml +17 -0
  297. package/src/domains/mux/yazi/event-stream.ts +180 -0
  298. package/src/domains/mux/yazi/profile.ts +299 -0
  299. package/src/domains/mux/yazi/session.ts +228 -0
  300. package/src/domains/mux/yazi/theme.ts +30 -0
  301. package/src/domains/observability/cost.ts +21 -0
  302. package/src/domains/observability/index.ts +2 -0
  303. package/src/domains/observability/trace-store.ts +42 -0
  304. package/src/domains/providers/endpoint-capacity.ts +154 -22
  305. package/src/domains/providers/endpoint-slots-store.ts +189 -0
  306. package/src/domains/providers/extension.ts +20 -3
  307. package/src/domains/providers/index.ts +22 -0
  308. package/src/domains/providers/model-runtime-capabilities.ts +32 -0
  309. package/src/domains/providers/runtimes/boot-manifest.ts +1 -0
  310. package/src/domains/providers/runtimes/builtins.ts +2 -0
  311. package/src/domains/providers/runtimes/protocol/litellm.ts +375 -0
  312. package/src/domains/providers/support.ts +1 -0
  313. package/src/domains/providers/target-model-cache.ts +124 -0
  314. package/src/domains/resources/index.ts +3 -0
  315. package/src/domains/resources/skills/loader.ts +33 -0
  316. package/src/domains/safety/action-classifier.ts +6 -0
  317. package/src/domains/toolchain/archive.ts +175 -0
  318. package/src/domains/toolchain/contract.ts +28 -0
  319. package/src/domains/toolchain/extension.ts +47 -0
  320. package/src/domains/toolchain/index.ts +39 -0
  321. package/src/domains/toolchain/install.ts +327 -0
  322. package/src/domains/toolchain/manifest.ts +8 -0
  323. package/src/domains/toolchain/paths.ts +34 -0
  324. package/src/domains/toolchain/registry.ts +265 -0
  325. package/src/domains/toolchain/remove.ts +218 -0
  326. package/src/domains/toolchain/resolve.ts +182 -0
  327. package/src/domains/toolchain/types.ts +113 -0
  328. package/src/domains/toolchain/version.ts +88 -0
  329. package/src/engine/acp/server.ts +413 -70
  330. package/src/engine/acp/types.ts +19 -1
  331. package/src/engine/claude/sdk-module.ts +98 -0
  332. package/src/engine/claude/sdk-runtime.ts +19 -11
  333. package/src/engine/tui-primitives.ts +21 -0
  334. package/src/engine/tui.ts +1 -0
  335. package/src/engine/worker-runtime.ts +2 -13
  336. package/src/entry/boot-options.ts +2 -0
  337. package/src/entry/orchestrator.ts +103 -5
  338. package/src/entry/panes-activation.ts +31 -0
  339. package/src/entry/with-panes.ts +20 -0
  340. package/src/interactive/context-overlay.ts +1 -0
  341. package/src/interactive/cost-overlay.ts +2 -0
  342. package/src/interactive/council-grid.ts +1 -3
  343. package/src/interactive/council.ts +11 -0
  344. package/src/interactive/dispatch-board.ts +26 -16
  345. package/src/interactive/interactive-application.ts +153 -6
  346. package/src/interactive/interactive-input-runtime.ts +7 -0
  347. package/src/interactive/interactive-slash-runtime.ts +36 -6
  348. package/src/interactive/memory-overlay.ts +1 -0
  349. package/src/interactive/modal-marker.ts +170 -0
  350. package/src/interactive/mux-bridge.ts +214 -0
  351. package/src/interactive/overlay-frame.ts +58 -2
  352. package/src/interactive/overlay-general-openers.ts +1 -0
  353. package/src/interactive/overlay-key-routing.ts +14 -3
  354. package/src/interactive/overlay-lifecycle.ts +19 -3
  355. package/src/interactive/overlay-model-selectors.ts +40 -3
  356. package/src/interactive/overlay-permission-lifecycle.ts +90 -22
  357. package/src/interactive/overlay-transitions.ts +18 -4
  358. package/src/interactive/overlays/agents.ts +1 -0
  359. package/src/interactive/overlays/ask-user.ts +136 -30
  360. package/src/interactive/overlays/auth-dialog.ts +1 -0
  361. package/src/interactive/overlays/context-reset.ts +1 -0
  362. package/src/interactive/overlays/cwd-fallback.ts +1 -0
  363. package/src/interactive/overlays/decisions.ts +11 -11
  364. package/src/interactive/overlays/extensions.ts +1 -0
  365. package/src/interactive/overlays/fleet-run-approval.ts +1 -0
  366. package/src/interactive/overlays/handoff-review.ts +1 -0
  367. package/src/interactive/overlays/help-reference.ts +2 -0
  368. package/src/interactive/overlays/interop.ts +1 -0
  369. package/src/interactive/overlays/library-install-confirm.ts +1 -0
  370. package/src/interactive/overlays/library-tabs.ts +28 -0
  371. package/src/interactive/overlays/list-overlay.ts +10 -1
  372. package/src/interactive/overlays/message-picker.ts +1 -0
  373. package/src/interactive/overlays/model-scope.ts +86 -0
  374. package/src/interactive/overlays/model-selector.ts +1 -0
  375. package/src/interactive/overlays/prompts.ts +1 -0
  376. package/src/interactive/overlays/session-selector.ts +1 -0
  377. package/src/interactive/overlays/settings-sections.ts +30 -0
  378. package/src/interactive/overlays/settings.ts +579 -44
  379. package/src/interactive/overlays/side-question.ts +1 -0
  380. package/src/interactive/overlays/skills-hub.ts +3 -11
  381. package/src/interactive/overlays/tree-selector.ts +1 -0
  382. package/src/interactive/pane-policy.ts +46 -0
  383. package/src/interactive/panes-runtime.ts +292 -0
  384. package/src/interactive/renderers/compaction-summary.ts +29 -0
  385. package/src/interactive/renderers/worker-entry.ts +122 -14
  386. package/src/interactive/slash-commands.ts +251 -15
  387. package/src/interactive/tasks-overlay.ts +1 -0
  388. package/src/interactive/theme/tokens.ts +3 -14
  389. package/src/interactive/turn-context.ts +47 -2
  390. package/src/interactive/view/artifacts.ts +109 -1
  391. package/src/interactive/view/view-overlay.ts +1 -0
  392. package/src/interactive/watch-pane.ts +152 -0
  393. package/src/interactive/worker-progress.ts +7 -1
  394. package/src/interactive/worker-receipts.ts +19 -1
  395. package/src/interactive/worker-stream.ts +5 -0
  396. package/src/interactive/yazi-bridge.ts +444 -0
  397. package/src/tools/bootstrap.ts +26 -2
  398. package/src/tools/builtin-tool-catalog.ts +15 -0
  399. package/src/tools/compete-worktrees.ts +83 -2
  400. package/src/tools/core-bootstrap.ts +2 -1
  401. package/src/tools/dispatch-admission.ts +14 -3
  402. package/src/tools/dispatch-arguments.ts +20 -20
  403. package/src/tools/dispatch-run-events.ts +134 -19
  404. package/src/tools/dispatch-runner.ts +29 -7
  405. package/src/tools/dispatch-types.ts +15 -3
  406. package/src/tools/dispatch.ts +1 -1
  407. package/src/tools/executables.ts +17 -14
  408. package/src/tools/observation.ts +54 -4
  409. package/src/tools/panes-surface.ts +38 -0
  410. package/src/tools/panes.ts +112 -0
  411. package/src/tools/policy.ts +10 -1
  412. package/src/tools/presentation.ts +1 -0
  413. package/dist/chunk-D73KXYPF.js +0 -37
  414. package/dist/chunk-MLOK6ZOS.js +0 -2888
  415. package/dist/chunk-YKOFT37S.js +0 -279
  416. package/dist/doctor-TWBWFK5V.js +0 -165
@@ -0,0 +1,2447 @@
1
+ import { createRequire as __clioCreateRequire } from "node:module"; const require = __clioCreateRequire(import.meta.url);
2
+ import {
3
+ PANES_PRESETS,
4
+ PANES_PRESET_IDS,
5
+ isPanesPresetId
6
+ } from "./chunk-YJX4SHTD.js";
7
+ import {
8
+ AdmissionCanceledError,
9
+ WORKER_OUTPUT_MAX_BYTES,
10
+ durableAssistantTextFromEvent
11
+ } from "./chunk-T56WDKA5.js";
12
+ import {
13
+ parseSkillCommand
14
+ } from "./chunk-VYMXRQI6.js";
15
+ import {
16
+ TOOL_PROFILE_NAMES,
17
+ isToolProfileName
18
+ } from "./chunk-42FMPA75.js";
19
+ import {
20
+ requestExecutionRole
21
+ } from "./chunk-H7IXIC72.js";
22
+ import {
23
+ truncateUtf8
24
+ } from "./chunk-6XLNIQDB.js";
25
+ import {
26
+ parseCouncilReport,
27
+ parseOracleResult
28
+ } from "./chunk-DYJP44XW.js";
29
+ import {
30
+ resolveModelReference
31
+ } from "./chunk-DQITNCXG.js";
32
+ import {
33
+ BusChannels
34
+ } from "./chunk-HLW2MRKE.js";
35
+ import {
36
+ THINKING_LEVELS
37
+ } from "./chunk-GXNLGKAB.js";
38
+ import {
39
+ init_esm_shims
40
+ } from "./chunk-3R73A4XB.js";
41
+
42
+ // src/interactive/slash-commands.ts
43
+ init_esm_shims();
44
+
45
+ // src/interactive/council.ts
46
+ init_esm_shims();
47
+ var COUNCIL_DEFAULT_ROSTER = "default";
48
+ var COUNCIL_SYNTHESIS_MODES = ["judge", "vote", "none"];
49
+ var COUNCIL_MAX_ROUNDS = 3;
50
+ var COUNCIL_SYNTHESIS_LABEL = "synthesis";
51
+ function isCouncilSynthesisMode(value) {
52
+ return COUNCIL_SYNTHESIS_MODES.some((mode) => mode === value);
53
+ }
54
+ var COUNCIL_NO_ROSTER_NOTICE = `/council needs a roster. Declare one under workers.rosters in settings.yaml, for example workers.rosters.${COUNCIL_DEFAULT_ROSTER} with two to five members, each with a label and a target, then run /council <task> or name another roster with --roster <name>.`;
55
+ function knownRosterNames(rosters) {
56
+ return Object.keys(rosters).sort();
57
+ }
58
+ function resolveCouncilRoster(requested, rosters) {
59
+ const known = knownRosterNames(rosters);
60
+ const wanted = requested?.trim();
61
+ if (wanted !== void 0 && wanted.length > 0) {
62
+ if (Object.hasOwn(rosters, wanted)) return { ok: true, roster: wanted };
63
+ const names = known.length === 0 ? "none are configured" : `configured rosters: ${known.join(", ")}`;
64
+ return { ok: false, reason: `no roster named "${wanted}" in workers.rosters (${names})` };
65
+ }
66
+ if (Object.hasOwn(rosters, COUNCIL_DEFAULT_ROSTER)) return { ok: true, roster: COUNCIL_DEFAULT_ROSTER };
67
+ return { ok: false, reason: COUNCIL_NO_ROSTER_NOTICE };
68
+ }
69
+ function buildCouncilDispatchArgs(task, roster, options = {}) {
70
+ return {
71
+ mode: "council",
72
+ task,
73
+ roster,
74
+ ...options.rounds !== void 0 ? { rounds: options.rounds } : {},
75
+ ...options.synthesis !== void 0 ? { synthesis: options.synthesis } : {}
76
+ };
77
+ }
78
+
79
+ // src/interactive/oracle.ts
80
+ init_esm_shims();
81
+ var ORACLE_AGENT_ID = "oracle";
82
+ var ORACLE_DIGEST_MAX_BYTES = 12 * 1024;
83
+ var ORACLE_DECISIONS_MAX_BYTES = 5120;
84
+ var ORACLE_TASKS_MAX_BYTES = 3072;
85
+ var ORACLE_COMPACTION_MAX_BYTES = 2048;
86
+ var ORACLE_QUESTION_MAX_BYTES = 1536;
87
+ var ORACLE_DECISIONS_MAX_ROWS = 24;
88
+ var ORACLE_TASKS_MAX_ROWS = 24;
89
+ var ORACLE_TRUNCATION_MARKER = "\n[truncated]";
90
+ var ORACLE_NO_DECISIONS = "(no settled decisions on this branch)";
91
+ var ORACLE_NO_TASKS = "(no open tasks on the board)";
92
+ function byteLength(text) {
93
+ return Buffer.byteLength(text, "utf8");
94
+ }
95
+ function clamp(text, maxBytes) {
96
+ if (byteLength(text) <= maxBytes) return { text, truncated: false };
97
+ const room = Math.max(0, maxBytes - byteLength(ORACLE_TRUNCATION_MARKER));
98
+ const buffer = Buffer.from(text, "utf8");
99
+ let cut = Math.min(room, buffer.byteLength);
100
+ while (cut > 0) {
101
+ const next = buffer[cut];
102
+ if (next === void 0 || (next & 192) !== 128) break;
103
+ cut -= 1;
104
+ }
105
+ return { text: `${buffer.subarray(0, cut).toString("utf8")}${ORACLE_TRUNCATION_MARKER}`, truncated: true };
106
+ }
107
+ function decisionLine(decision) {
108
+ const label = decision.label ? ` (${decision.label})` : "";
109
+ if (decision.status === "superseded") {
110
+ const correction = decision.correction ? `; corrected to ${decision.correction}` : "";
111
+ return `- ${decision.key}${label}: ${decision.value} [superseded${correction}]`;
112
+ }
113
+ return `- ${decision.key}${label}: ${decision.value}`;
114
+ }
115
+ function taskLine(task) {
116
+ return `- ${task.id} [${task.status}] ${task.title}`;
117
+ }
118
+ function isOpenTask(task) {
119
+ return task.status === "pending" || task.status === "active";
120
+ }
121
+ function packOracleDigest(sources) {
122
+ let truncated = false;
123
+ const decisionRows = sources.decisions.flatMap((entry) => entry.decisions.map(decisionLine)).slice(0, ORACLE_DECISIONS_MAX_ROWS);
124
+ if (decisionRows.length < sources.decisions.reduce((total, entry) => total + entry.decisions.length, 0)) {
125
+ truncated = true;
126
+ }
127
+ const decisions = clamp(decisionRows.join("\n") || ORACLE_NO_DECISIONS, ORACLE_DECISIONS_MAX_BYTES);
128
+ truncated = truncated || decisions.truncated;
129
+ const openTasks = sources.tasks.filter(isOpenTask);
130
+ const taskRows = openTasks.map(taskLine).slice(0, ORACLE_TASKS_MAX_ROWS);
131
+ if (taskRows.length < openTasks.length) truncated = true;
132
+ const tasks = clamp(taskRows.join("\n") || ORACLE_NO_TASKS, ORACLE_TASKS_MAX_BYTES);
133
+ truncated = truncated || tasks.truncated;
134
+ const summaryText = sources.compactionSummary?.trim() ?? "";
135
+ const summary = clamp(summaryText, ORACLE_COMPACTION_MAX_BYTES);
136
+ truncated = truncated || summary.truncated;
137
+ const question = clamp(sources.question.trim(), ORACLE_QUESTION_MAX_BYTES);
138
+ truncated = truncated || question.truncated;
139
+ const sections = [
140
+ "## Settled decisions",
141
+ decisions.text,
142
+ "",
143
+ "## Open tasks",
144
+ tasks.text,
145
+ "",
146
+ "## Last compaction summary",
147
+ summary.text.length > 0 ? summary.text : "(this session has not compacted)",
148
+ "",
149
+ "## Question",
150
+ question.text
151
+ ];
152
+ const whole = clamp(sections.join("\n"), ORACLE_DIGEST_MAX_BYTES);
153
+ return { text: whole.text, truncated: truncated || whole.truncated };
154
+ }
155
+ var ORACLE_TASK = "Answer the question in the briefing's Question section. Check it against the settled decisions first, then return the strongest challenge you can support and the evidence that would change your mind.";
156
+ function formatOracleAnswer(result) {
157
+ const cited = result.citedDecisions.length === 0 ? "Cited decisions: none bear on this question." : `Cited decisions: ${result.citedDecisions.join(", ")}`;
158
+ return [
159
+ `Verdict: ${result.verdict}`,
160
+ "",
161
+ `Strongest challenge: ${result.challenge}`,
162
+ "",
163
+ `What would change its mind: ${result.changesMyMind}`,
164
+ "",
165
+ cited
166
+ ].join("\n");
167
+ }
168
+
169
+ // src/interactive/overlays/library-tabs.ts
170
+ init_esm_shims();
171
+ var LIBRARY_TABS = [
172
+ { id: "skill", label: "Skills" },
173
+ { id: "agent", label: "Agents" },
174
+ { id: "prompt", label: "Prompts" },
175
+ { id: "fleet", label: "Fleets" }
176
+ ];
177
+ function isLibraryTab(value) {
178
+ return LIBRARY_TABS.some((tab) => tab.id === value);
179
+ }
180
+
181
+ // src/interactive/overlays/settings-sections.ts
182
+ init_esm_shims();
183
+ var SETTINGS_SECTIONS = [
184
+ { id: "safety", label: "Autonomy & Safety", group: "CORE" },
185
+ { id: "orchestrator", label: "Orchestrator", group: "CORE" },
186
+ { id: "fleet", label: "Fleet", group: "ROUTING" },
187
+ { id: "targets", label: "Targets", group: "ROUTING" },
188
+ { id: "models", label: "Models", group: "ROUTING" },
189
+ { id: "budget", label: "Budget", group: "RUNTIME" },
190
+ { id: "compaction", label: "Compaction", group: "RUNTIME" },
191
+ { id: "retry", label: "Retry", group: "RUNTIME" },
192
+ { id: "terminal", label: "Terminal", group: "EXPERIENCE" },
193
+ { id: "watchdog", label: "Watchdog", group: "EXPERIENCE" },
194
+ { id: "advanced", label: "Advanced", group: "EXPERIENCE" }
195
+ ];
196
+
197
+ // src/interactive/slash-spec.ts
198
+ init_esm_shims();
199
+ function getFlagValuePlaceholder(flag) {
200
+ if (flag.valueName) return flag.valueName;
201
+ if (flag.values && flag.values.length > 0) {
202
+ return flag.values.join("|");
203
+ }
204
+ return flag.name.replace(/^--/, "");
205
+ }
206
+ function renderArgsSpec(spec) {
207
+ const parts = [];
208
+ if (spec.flags) {
209
+ for (const flag of spec.flags) {
210
+ if (flag.takesValue) {
211
+ const placeholder = getFlagValuePlaceholder(flag);
212
+ parts.push(`[${flag.name} <${placeholder}>]`);
213
+ } else {
214
+ parts.push(`[${flag.name}]`);
215
+ }
216
+ }
217
+ }
218
+ if (spec.positionals) {
219
+ for (const pos of spec.positionals) {
220
+ if (pos.required) {
221
+ parts.push(`<${pos.name}>`);
222
+ } else {
223
+ parts.push(`[${pos.name}]`);
224
+ }
225
+ }
226
+ }
227
+ return parts.join(" ");
228
+ }
229
+ function usageLine(entry, subcommand) {
230
+ const prefix = `/${entry.name}`;
231
+ const argsSpec = entry.args ?? {};
232
+ if (subcommand && argsSpec.subcommands?.[subcommand]) {
233
+ const subSpec = argsSpec.subcommands[subcommand];
234
+ const subStr = renderArgsSpec(subSpec);
235
+ return `
236
+ usage: ${prefix} ${subcommand}${subStr ? ` ${subStr}` : ""}
237
+ `;
238
+ }
239
+ if (argsSpec.subcommands) {
240
+ const subParts = [];
241
+ const rootSpec = {
242
+ ...argsSpec.flags ? { flags: argsSpec.flags } : {},
243
+ ...argsSpec.positionals ? { positionals: argsSpec.positionals } : {}
244
+ };
245
+ const rootStr = renderArgsSpec(rootSpec);
246
+ if (rootStr.length > 0) subParts.push(`${prefix} ${rootStr}`);
247
+ for (const [subName, subSpec] of Object.entries(argsSpec.subcommands)) {
248
+ const subStr = renderArgsSpec(subSpec);
249
+ subParts.push(`${prefix} ${subName}${subStr ? ` ${subStr}` : ""}`);
250
+ }
251
+ return `
252
+ usage: ${subParts.join(" | ")}
253
+ `;
254
+ }
255
+ const argsStr = renderArgsSpec(argsSpec);
256
+ return `
257
+ usage: ${prefix}${argsStr ? ` ${argsStr}` : ""}
258
+ `;
259
+ }
260
+ function parseArgs(spec, argsLine) {
261
+ const flags = /* @__PURE__ */ new Map();
262
+ const flagValues = /* @__PURE__ */ new Map();
263
+ const positionals = [];
264
+ let subcommand;
265
+ let rest;
266
+ let currentSpec = spec;
267
+ let index = 0;
268
+ const skipWhitespace = () => {
269
+ while (index < argsLine.length) {
270
+ const char = argsLine[index];
271
+ if (char && /\s/.test(char)) {
272
+ index++;
273
+ } else {
274
+ break;
275
+ }
276
+ }
277
+ };
278
+ skipWhitespace();
279
+ if (currentSpec.subcommands && index < argsLine.length) {
280
+ const start = index;
281
+ while (index < argsLine.length) {
282
+ const char = argsLine[index];
283
+ if (char && !/\s/.test(char)) {
284
+ index++;
285
+ } else {
286
+ break;
287
+ }
288
+ }
289
+ const sub = argsLine.slice(start, index);
290
+ if (currentSpec.subcommands[sub]) {
291
+ subcommand = sub;
292
+ currentSpec = currentSpec.subcommands[sub];
293
+ skipWhitespace();
294
+ } else {
295
+ index = start;
296
+ }
297
+ }
298
+ const flagSpecs = currentSpec.flags ?? [];
299
+ const positionalSpecs = currentSpec.positionals ?? [];
300
+ let positionalIndex = 0;
301
+ const readToken = () => {
302
+ const tokenStart = index;
303
+ let token = "";
304
+ let quote = null;
305
+ while (index < argsLine.length) {
306
+ const char = argsLine[index] ?? "";
307
+ if (quote !== null) {
308
+ if (char === quote) quote = null;
309
+ else token += char;
310
+ index++;
311
+ continue;
312
+ }
313
+ if (char === '"' || char === "'") {
314
+ quote = char;
315
+ index++;
316
+ continue;
317
+ }
318
+ if (/\s/.test(char)) break;
319
+ token += char;
320
+ index++;
321
+ }
322
+ if (index === tokenStart) return null;
323
+ return { token };
324
+ };
325
+ const consumeFlag = (matchedFlagSpec, token) => {
326
+ const flagName = matchedFlagSpec.name;
327
+ if (matchedFlagSpec.takesValue) {
328
+ skipWhitespace();
329
+ if (index >= argsLine.length) return `Flag ${token} requires a value`;
330
+ const value = readToken();
331
+ if (value === null) return `Flag ${token} requires a value`;
332
+ const val = value.token;
333
+ if (matchedFlagSpec.values && !matchedFlagSpec.values.includes(val)) {
334
+ return `Invalid value for ${flagName}: ${val}`;
335
+ }
336
+ if (matchedFlagSpec.repeatable) {
337
+ const next = [...flagValues.get(flagName) ?? [], val];
338
+ flagValues.set(flagName, next);
339
+ flags.set(flagName, next.join(" "));
340
+ } else {
341
+ flagValues.set(flagName, [val]);
342
+ flags.set(flagName, val);
343
+ }
344
+ return null;
345
+ }
346
+ flags.set(flagName, true);
347
+ return null;
348
+ };
349
+ const errorResult = (error) => ({
350
+ flags,
351
+ flagValues,
352
+ positionals,
353
+ ...subcommand !== void 0 ? { subcommand } : {},
354
+ error
355
+ });
356
+ while (index < argsLine.length) {
357
+ const currentPositionalSpec = positionalSpecs[positionalIndex];
358
+ if (currentPositionalSpec?.rest) {
359
+ if (currentSpec.parseFlagsBeforeRest) {
360
+ while (index < argsLine.length) {
361
+ const tokenStart = index;
362
+ const read2 = readToken();
363
+ if (read2 === null) break;
364
+ const matchedFlagSpec2 = flagSpecs.find((f) => f.name === read2.token);
365
+ if (!matchedFlagSpec2) {
366
+ index = tokenStart;
367
+ break;
368
+ }
369
+ const error = consumeFlag(matchedFlagSpec2, read2.token);
370
+ if (error) return errorResult(error);
371
+ skipWhitespace();
372
+ }
373
+ }
374
+ const restVal = argsLine.slice(index).trim();
375
+ if (restVal.length > 0) {
376
+ positionals.push(restVal);
377
+ rest = restVal;
378
+ }
379
+ positionalIndex++;
380
+ index = argsLine.length;
381
+ break;
382
+ }
383
+ const read = readToken();
384
+ if (read === null) break;
385
+ const token = read.token;
386
+ let isFlag = false;
387
+ let matchedFlagSpec;
388
+ if (token.startsWith("--")) {
389
+ matchedFlagSpec = flagSpecs.find((f) => f.name === token);
390
+ if (matchedFlagSpec) {
391
+ isFlag = true;
392
+ } else {
393
+ return errorResult(`Unknown flag: ${token}`);
394
+ }
395
+ }
396
+ if (isFlag && matchedFlagSpec) {
397
+ const error = consumeFlag(matchedFlagSpec, token);
398
+ if (error) return errorResult(error);
399
+ } else {
400
+ if (positionalIndex < positionalSpecs.length) {
401
+ positionals.push(token);
402
+ positionalIndex++;
403
+ } else {
404
+ return errorResult(`Unexpected argument: ${token}`);
405
+ }
406
+ }
407
+ skipWhitespace();
408
+ }
409
+ for (let idx = positionalIndex; idx < positionalSpecs.length; idx++) {
410
+ const spec2 = positionalSpecs[idx];
411
+ if (spec2?.required) {
412
+ return {
413
+ flags,
414
+ flagValues,
415
+ positionals,
416
+ ...subcommand !== void 0 ? { subcommand } : {},
417
+ error: `Missing required argument: ${spec2.name}`
418
+ };
419
+ }
420
+ }
421
+ return {
422
+ flags,
423
+ flagValues,
424
+ positionals,
425
+ ...subcommand !== void 0 ? { subcommand } : {},
426
+ ...rest !== void 0 ? { rest } : {}
427
+ };
428
+ }
429
+ function walkCompletedTokens(spec, tokens) {
430
+ const flagSpecs = spec.flags ?? [];
431
+ const positionalSpecs = spec.positionals ?? [];
432
+ const walk = { usedFlags: /* @__PURE__ */ new Set(), awaitingValue: null, positionalIndex: 0, restBegun: false };
433
+ for (const token of tokens) {
434
+ if (walk.awaitingValue) {
435
+ walk.awaitingValue = null;
436
+ continue;
437
+ }
438
+ const atRest = positionalSpecs[walk.positionalIndex]?.rest === true;
439
+ const flagsParseable = !atRest || spec.parseFlagsBeforeRest === true;
440
+ const matched = flagsParseable && token.startsWith("--") ? flagSpecs.find((flag) => flag.name === token) : void 0;
441
+ if (matched) {
442
+ walk.usedFlags.add(matched.name);
443
+ if (matched.takesValue) walk.awaitingValue = matched;
444
+ continue;
445
+ }
446
+ if (atRest) {
447
+ walk.restBegun = true;
448
+ break;
449
+ }
450
+ walk.positionalIndex += 1;
451
+ }
452
+ return walk;
453
+ }
454
+ function flagCompletions(spec, walk, current) {
455
+ const available = (spec.flags ?? []).filter((flag) => flag.repeatable === true || !walk.usedFlags.has(flag.name));
456
+ const rows = available.filter((flag) => flag.name.startsWith(current)).map((flag) => ({ flag, name: flag.name }));
457
+ return rows.map(({ flag, name }) => ({
458
+ token: name,
459
+ ...flag.takesValue ? { hint: `<${getFlagValuePlaceholder(flag)}>` } : {}
460
+ }));
461
+ }
462
+ function completeArgs(spec, argumentText) {
463
+ const trailing = argumentText.match(/\S*$/)?.[0] ?? "";
464
+ const tokenStart = argumentText.length - trailing.length;
465
+ const current = trailing;
466
+ const completed = argumentText.slice(0, tokenStart).split(/\s+/).filter((token) => token.length > 0);
467
+ const completions = [];
468
+ let active = spec;
469
+ let walkTokens = completed;
470
+ if (spec.subcommands) {
471
+ const first = completed[0];
472
+ if (first === void 0) {
473
+ for (const [name, subSpec] of Object.entries(spec.subcommands)) {
474
+ if (!name.startsWith(current)) continue;
475
+ const hint = renderArgsSpec(subSpec);
476
+ completions.push({ token: name, ...hint.length > 0 ? { hint } : {} });
477
+ }
478
+ } else if (spec.subcommands[first]) {
479
+ active = spec.subcommands[first];
480
+ walkTokens = completed.slice(1);
481
+ }
482
+ }
483
+ const walk = walkCompletedTokens(active, walkTokens);
484
+ if (walk.restBegun) {
485
+ return completions.length > 0 ? { completions, tokenStart } : null;
486
+ }
487
+ if (walk.awaitingValue) {
488
+ for (const value of walk.awaitingValue.values ?? []) {
489
+ if (value.startsWith(current)) completions.push({ token: value });
490
+ }
491
+ return completions.length > 0 ? { completions, tokenStart } : null;
492
+ }
493
+ const atRest = (active.positionals ?? [])[walk.positionalIndex]?.rest === true;
494
+ const flagsParseable = !atRest || active.parseFlagsBeforeRest === true;
495
+ if (flagsParseable && (current.length === 0 || current.startsWith("-"))) {
496
+ completions.push(...flagCompletions(active, walk, current));
497
+ }
498
+ return completions.length > 0 ? { completions, tokenStart } : null;
499
+ }
500
+ function matchFromSpec(entry, trimmed) {
501
+ const matchedPrefix = `/${entry.name}`;
502
+ if (trimmed !== matchedPrefix && !trimmed.startsWith(`${matchedPrefix} `)) return null;
503
+ const argsLine = trimmed.slice(matchedPrefix.length);
504
+ const parsed = parseArgs(entry.args ?? {}, argsLine);
505
+ if (entry.fromArgs) {
506
+ return entry.fromArgs(parsed, trimmed);
507
+ }
508
+ return null;
509
+ }
510
+
511
+ // src/interactive/worker-share.ts
512
+ init_esm_shims();
513
+
514
+ // src/interactive/worker-stream.ts
515
+ init_esm_shims();
516
+
517
+ // src/interactive/worker-progress.ts
518
+ init_esm_shims();
519
+ var WORKER_LIVE_TAIL_LINES = 40;
520
+ var WORKER_LIVE_TAIL_MAX_BYTES = 4096;
521
+ var WORKER_TOOL_NAME_LIMIT = 8;
522
+ var WORKER_ACTION_TRAIL_LIMIT = 4;
523
+ var WORKER_PROGRESS_WINDOW_MS = 250;
524
+ var WORKER_PROGRESS_WINDOW_BYTES = 16384;
525
+ var TAIL_TRUNCATION_MARKER = "";
526
+ function isRecord(value) {
527
+ return typeof value === "object" && value !== null && !Array.isArray(value);
528
+ }
529
+ function nonEmptyString(value) {
530
+ return typeof value === "string" && value.trim().length > 0 ? value : void 0;
531
+ }
532
+ function workerTextDelta(event) {
533
+ if (!isRecord(event)) return "";
534
+ if (event.type === "message_update") {
535
+ const assistantEvent = isRecord(event.assistantMessageEvent) ? event.assistantMessageEvent : null;
536
+ if (assistantEvent?.type !== "text_delta") return "";
537
+ return typeof assistantEvent.delta === "string" ? assistantEvent.delta : "";
538
+ }
539
+ if (event.type !== "text_delta") return "";
540
+ if (typeof event.delta === "string") return event.delta;
541
+ return typeof event.text === "string" ? event.text : "";
542
+ }
543
+ function isThinkingEvent(event) {
544
+ if (event.type === "thinking_delta") return true;
545
+ if (event.type !== "message_update") return false;
546
+ const assistantEvent = isRecord(event.assistantMessageEvent) ? event.assistantMessageEvent : null;
547
+ return assistantEvent?.type === "thinking_delta";
548
+ }
549
+ function toolEventAction(event) {
550
+ if (event.type !== "clio_tool_start" && event.type !== "clio_tool_finish") return null;
551
+ const payload = isRecord(event.payload) ? event.payload : null;
552
+ const tool = nonEmptyString(payload?.tool);
553
+ if (tool === void 0) return null;
554
+ const toolCallId = nonEmptyString(payload?.toolCallId);
555
+ const raw = isRecord(payload?.action) ? payload.action : void 0;
556
+ const verb = nonEmptyString(raw?.verb);
557
+ if (verb === void 0) return { tool, ...toolCallId !== void 0 ? { toolCallId } : {} };
558
+ const object = nonEmptyString(raw?.object);
559
+ return {
560
+ tool,
561
+ ...toolCallId !== void 0 ? { toolCallId } : {},
562
+ descriptor: {
563
+ verb,
564
+ ...object !== void 0 ? { object } : {},
565
+ ...raw?.truncated === true ? { truncated: true } : {}
566
+ }
567
+ };
568
+ }
569
+ function lineCount(text) {
570
+ if (text.length === 0) return 0;
571
+ let lines = 1;
572
+ for (let index = 0; index < text.length; index += 1) {
573
+ if (text[index] === "\n") lines += 1;
574
+ }
575
+ return lines;
576
+ }
577
+ function keepTailBytes(text, maxBytes) {
578
+ const buffer = Buffer.from(text, "utf8");
579
+ if (buffer.byteLength <= maxBytes) return text;
580
+ let cut = buffer.byteLength - maxBytes;
581
+ while (cut < buffer.byteLength) {
582
+ const byte = buffer[cut];
583
+ if (byte === void 0 || (byte & 192) !== 128) break;
584
+ cut += 1;
585
+ }
586
+ return buffer.subarray(cut).toString("utf8");
587
+ }
588
+ function boundLiveTail(text) {
589
+ const lines = text.split("\n");
590
+ let droppedLines = 0;
591
+ if (lines.length > WORKER_LIVE_TAIL_LINES) {
592
+ droppedLines = lines.length - WORKER_LIVE_TAIL_LINES;
593
+ lines.splice(0, droppedLines);
594
+ }
595
+ while (lines.length > 1 && Buffer.byteLength(lines.join("\n"), "utf8") > WORKER_LIVE_TAIL_MAX_BYTES) {
596
+ lines.shift();
597
+ droppedLines += 1;
598
+ }
599
+ const joined = lines.join("\n");
600
+ const bytes = Buffer.byteLength(joined, "utf8");
601
+ if (bytes <= WORKER_LIVE_TAIL_MAX_BYTES) return { text: joined, droppedLines, droppedBytes: 0 };
602
+ const kept = keepTailBytes(joined, WORKER_LIVE_TAIL_MAX_BYTES);
603
+ return { text: kept, droppedLines, droppedBytes: bytes - Buffer.byteLength(kept, "utf8") };
604
+ }
605
+ function boundSettledText(text) {
606
+ const bounded = truncateUtf8(text, WORKER_OUTPUT_MAX_BYTES, TAIL_TRUNCATION_MARKER);
607
+ if (bounded === text) return { text, dropped: 0 };
608
+ return { text: bounded, dropped: Math.max(0, lineCount(text) - lineCount(bounded)) };
609
+ }
610
+ var EMPTY_SNAPSHOT = {
611
+ revision: 0,
612
+ phase: "starting",
613
+ tailText: "",
614
+ droppedLines: 0,
615
+ droppedBytes: 0,
616
+ currentAction: null,
617
+ recentActions: [],
618
+ toolNames: [],
619
+ settled: false
620
+ };
621
+ function createWorkerProgressFold() {
622
+ let revision = 0;
623
+ let phase = "starting";
624
+ let tailText = "";
625
+ let droppedLines = 0;
626
+ let droppedBytes = 0;
627
+ let currentAction = null;
628
+ const recentActions = [];
629
+ const toolNames = [];
630
+ let settled = false;
631
+ let durable = "";
632
+ let betweenAssistantMessages = false;
633
+ const pendingActions = [];
634
+ const pendingActionsById = /* @__PURE__ */ new Map();
635
+ let windowStartMs = 0;
636
+ let windowBytes = 0;
637
+ let cached = EMPTY_SNAPSHOT;
638
+ const touch = () => {
639
+ revision += 1;
640
+ cached = null;
641
+ return true;
642
+ };
643
+ const setPhase = (next) => {
644
+ if (phase === next) return false;
645
+ phase = next;
646
+ return touch();
647
+ };
648
+ const admitDelta = (delta, nowMs) => {
649
+ if (nowMs - windowStartMs >= WORKER_PROGRESS_WINDOW_MS) {
650
+ windowStartMs = nowMs;
651
+ windowBytes = 0;
652
+ }
653
+ const bytes = Buffer.byteLength(delta, "utf8");
654
+ if (windowBytes + bytes <= WORKER_PROGRESS_WINDOW_BYTES) {
655
+ windowBytes += bytes;
656
+ return delta;
657
+ }
658
+ windowBytes = WORKER_PROGRESS_WINDOW_BYTES;
659
+ droppedBytes += bytes;
660
+ return "";
661
+ };
662
+ const appendTail = (text) => {
663
+ if (text.length === 0) return false;
664
+ const bounded = boundLiveTail(tailText + text);
665
+ tailText = bounded.text;
666
+ droppedLines += bounded.droppedLines;
667
+ droppedBytes += bounded.droppedBytes;
668
+ return touch();
669
+ };
670
+ const noteToolName = (tool) => {
671
+ if (toolNames.includes(tool) || toolNames.length >= WORKER_TOOL_NAME_LIMIT) return false;
672
+ toolNames.push(tool);
673
+ return touch();
674
+ };
675
+ const removePendingAction = (action) => {
676
+ const index = pendingActions.lastIndexOf(action);
677
+ if (index >= 0) pendingActions.splice(index, 1);
678
+ if (action.toolCallId !== void 0 && pendingActionsById.get(action.toolCallId) === action) {
679
+ pendingActionsById.delete(action.toolCallId);
680
+ }
681
+ };
682
+ const lastPendingActionForTool = (tool) => {
683
+ for (let index = pendingActions.length - 1; index >= 0; index -= 1) {
684
+ const candidate = pendingActions[index];
685
+ if (candidate?.tool === tool) return candidate;
686
+ }
687
+ return void 0;
688
+ };
689
+ return {
690
+ observe(event, nowMs = Date.now()) {
691
+ if (!isRecord(event) || settled) return false;
692
+ let changed = false;
693
+ const delta = workerTextDelta(event);
694
+ if (delta.length > 0) {
695
+ const separator = betweenAssistantMessages && tailText.length > 0 && !tailText.endsWith("\n") ? "\n\n" : "";
696
+ betweenAssistantMessages = false;
697
+ changed = appendTail(admitDelta(`${separator}${delta}`, nowMs)) || changed;
698
+ changed = setPhase("writing") || changed;
699
+ } else if (isThinkingEvent(event)) {
700
+ changed = setPhase("thinking") || changed;
701
+ }
702
+ const durableText = durableAssistantTextFromEvent(event);
703
+ if (durableText.trim().length > 0) {
704
+ durable = durableText;
705
+ if (delta.length === 0 && tailText.trim().length === 0) {
706
+ changed = appendTail(durableText) || changed;
707
+ }
708
+ betweenAssistantMessages = true;
709
+ }
710
+ const action = toolEventAction(event);
711
+ if (action !== null && event.type === "clio_tool_start") {
712
+ if (action.toolCallId !== void 0) {
713
+ const duplicate = pendingActionsById.get(action.toolCallId);
714
+ if (duplicate !== void 0) removePendingAction(duplicate);
715
+ pendingActionsById.set(action.toolCallId, action);
716
+ }
717
+ pendingActions.push(action);
718
+ currentAction = action;
719
+ noteToolName(action.tool);
720
+ touch();
721
+ setPhase("tool");
722
+ changed = true;
723
+ } else if (action !== null && event.type === "clio_tool_finish") {
724
+ const finished = (action.toolCallId !== void 0 ? pendingActionsById.get(action.toolCallId) : void 0) ?? lastPendingActionForTool(action.tool) ?? action;
725
+ removePendingAction(finished);
726
+ currentAction = pendingActions[pendingActions.length - 1] ?? null;
727
+ recentActions.unshift(finished);
728
+ if (recentActions.length > WORKER_ACTION_TRAIL_LIMIT) recentActions.length = WORKER_ACTION_TRAIL_LIMIT;
729
+ noteToolName(finished.tool);
730
+ touch();
731
+ setPhase(currentAction === null ? "waiting" : "tool");
732
+ changed = true;
733
+ }
734
+ if (event.type === "agent_start") changed = setPhase("starting") || changed;
735
+ return changed;
736
+ },
737
+ settle(text) {
738
+ const sealed = nonEmptyString(text) ?? nonEmptyString(durable);
739
+ if (sealed !== void 0) {
740
+ const bounded = boundSettledText(sealed);
741
+ tailText = bounded.text;
742
+ droppedLines = bounded.dropped;
743
+ }
744
+ currentAction = null;
745
+ pendingActions.length = 0;
746
+ pendingActionsById.clear();
747
+ settled = true;
748
+ phase = "settled";
749
+ touch();
750
+ return true;
751
+ },
752
+ restart() {
753
+ currentAction = null;
754
+ pendingActions.length = 0;
755
+ pendingActionsById.clear();
756
+ durable = "";
757
+ betweenAssistantMessages = false;
758
+ settled = false;
759
+ phase = "starting";
760
+ touch();
761
+ },
762
+ snapshot() {
763
+ if (cached !== null) return cached;
764
+ cached = {
765
+ revision,
766
+ phase,
767
+ tailText,
768
+ droppedLines,
769
+ droppedBytes,
770
+ currentAction: currentAction === null ? null : { ...currentAction },
771
+ recentActions: recentActions.map((entry) => ({ ...entry })),
772
+ toolNames: [...toolNames],
773
+ settled
774
+ };
775
+ return cached;
776
+ },
777
+ durableText() {
778
+ return durable;
779
+ }
780
+ };
781
+ }
782
+
783
+ // src/interactive/worker-stream.ts
784
+ function workerAskedByModel(state) {
785
+ return state.parentToolCallId !== void 0 || state.origin === "agent";
786
+ }
787
+ function nonEmptyString2(value) {
788
+ return typeof value === "string" && value.trim().length > 0 ? value : void 0;
789
+ }
790
+ function finiteNumber(value) {
791
+ return typeof value === "number" && Number.isFinite(value) ? value : void 0;
792
+ }
793
+ function workerRuntimeKind(runtimeKind, runtimeId) {
794
+ if (runtimeKind === "acp-delegation") return "acp";
795
+ if (runtimeId === "claude-code") return "claude-code";
796
+ if (runtimeId === "claude-sdk") return "claude-sdk";
797
+ return "clio";
798
+ }
799
+ function runtimeIdentity(payload) {
800
+ const kind = workerRuntimeKind(payload.runtimeKind, payload.runtimeId);
801
+ if (kind === "acp") {
802
+ const peerId = nonEmptyString2(payload.agentId);
803
+ return { kind, ...peerId !== void 0 ? { peerId } : {} };
804
+ }
805
+ const targetId = nonEmptyString2(payload.targetId);
806
+ const wireModelId = nonEmptyString2(payload.wireModelId);
807
+ return {
808
+ kind,
809
+ ...targetId !== void 0 ? { targetId } : {},
810
+ ...wireModelId !== void 0 ? { wireModelId } : {}
811
+ };
812
+ }
813
+ function workerTargetLabel(runtime) {
814
+ if (runtime.kind === "acp") return runtime.peerId ?? "acp";
815
+ if (runtime.targetId !== void 0 && runtime.wireModelId !== void 0) {
816
+ return `${runtime.targetId}/${runtime.wireModelId}`;
817
+ }
818
+ return runtime.targetId ?? runtime.wireModelId ?? "unknown";
819
+ }
820
+ function terminalFacts(payload) {
821
+ const detail = nonEmptyString2(payload.outcomeDetail);
822
+ const tokenCount = finiteNumber(payload.tokenCount);
823
+ const durationMs = finiteNumber(payload.durationMs);
824
+ const exitCode = finiteNumber(payload.exitCode);
825
+ return {
826
+ outcome: payload.outcome,
827
+ ...payload.outcomeCode !== null && payload.outcomeCode !== void 0 ? { outcomeCode: payload.outcomeCode } : {},
828
+ ...detail !== void 0 ? { failureMessage: detail } : {},
829
+ ...exitCode !== void 0 ? { exitCode } : {},
830
+ ...tokenCount !== void 0 ? { tokenCount } : {},
831
+ ...durationMs !== void 0 ? { durationMs } : {},
832
+ ...payload.toolActivity ? { toolCalls: payload.toolActivity.calls } : {}
833
+ };
834
+ }
835
+ function workerReceiptSummary(facts) {
836
+ if (facts === null) return { outcome: "unknown", receiptUnavailable: true };
837
+ const { text: _text, ...summary } = facts;
838
+ return summary;
839
+ }
840
+ function createWorkerStream(options = {}) {
841
+ const byAssignment = /* @__PURE__ */ new Map();
842
+ const attemptByAssignment = /* @__PURE__ */ new Map();
843
+ const assignmentByRun = /* @__PURE__ */ new Map();
844
+ const progressByAssignment = /* @__PURE__ */ new Map();
845
+ const applyProgress = (entry, fold) => {
846
+ const snapshot = fold.snapshot();
847
+ entry.text = snapshot.tailText;
848
+ entry.droppedLines = snapshot.droppedLines;
849
+ entry.tools = [...snapshot.toolNames];
850
+ entry.progress = snapshot;
851
+ };
852
+ const currentEntryForRun = (runId) => {
853
+ const id = nonEmptyString2(runId);
854
+ if (id === void 0) return void 0;
855
+ const assignmentId = assignmentByRun.get(id);
856
+ const entry = assignmentId === void 0 ? void 0 : byAssignment.get(assignmentId);
857
+ return entry?.runId === id ? entry : void 0;
858
+ };
859
+ const settle = (entry, payloadFacts) => {
860
+ const facts = options.readReceipt?.(entry.runId) ?? { ...payloadFacts, receiptUnavailable: true };
861
+ entry.receipt = workerReceiptSummary(facts);
862
+ entry.pending = false;
863
+ const attempt = entry.attempts[entry.attempts.length - 1];
864
+ if (attempt !== void 0) attempt.outcome = facts.outcome;
865
+ const fold = progressByAssignment.get(entry.assignmentId);
866
+ if (fold !== void 0) {
867
+ fold.settle(nonEmptyString2(facts.text));
868
+ applyProgress(entry, fold);
869
+ }
870
+ return { kind: "updated", entry };
871
+ };
872
+ return {
873
+ started(payload) {
874
+ const runId = nonEmptyString2(payload.runId);
875
+ const assignmentId = nonEmptyString2(payload.assignmentId) ?? runId;
876
+ if (runId === void 0 || assignmentId === void 0) return null;
877
+ const runtime = runtimeIdentity(payload);
878
+ const existing = byAssignment.get(assignmentId);
879
+ if (existing !== void 0) {
880
+ if (payload.attempt <= (attemptByAssignment.get(assignmentId) ?? -1)) return null;
881
+ attemptByAssignment.set(assignmentId, payload.attempt);
882
+ existing.runId = runId;
883
+ existing.runtime = runtime;
884
+ existing.pending = true;
885
+ delete existing.receipt;
886
+ existing.attempts.push({ runId, targetLabel: workerTargetLabel(runtime) });
887
+ assignmentByRun.set(runId, assignmentId);
888
+ const progress2 = progressByAssignment.get(assignmentId);
889
+ if (progress2 !== void 0) {
890
+ progress2.restart();
891
+ applyProgress(existing, progress2);
892
+ }
893
+ return { kind: "updated", entry: existing };
894
+ }
895
+ if (payload.requestOrigin !== "user" && payload.requestOrigin !== "agent") return null;
896
+ attemptByAssignment.set(assignmentId, payload.attempt);
897
+ const progress = createWorkerProgressFold();
898
+ const entry = {
899
+ assignmentId,
900
+ runId,
901
+ origin: payload.requestOrigin,
902
+ agentId: payload.agentId,
903
+ runtime,
904
+ text: "",
905
+ droppedLines: 0,
906
+ tools: [],
907
+ progress: progress.snapshot(),
908
+ attempts: [{ runId, targetLabel: workerTargetLabel(runtime) }],
909
+ pending: true,
910
+ ...payload.council !== void 0 ? { council: { ...payload.council } } : {},
911
+ ...payload.parentToolCallId !== void 0 ? { parentToolCallId: payload.parentToolCallId } : {}
912
+ };
913
+ byAssignment.set(assignmentId, entry);
914
+ assignmentByRun.set(runId, assignmentId);
915
+ progressByAssignment.set(assignmentId, progress);
916
+ return { kind: "created", entry };
917
+ },
918
+ progress(payload) {
919
+ const entry = currentEntryForRun(payload.runId);
920
+ if (entry === void 0 || !entry.pending) return null;
921
+ const fold = progressByAssignment.get(entry.assignmentId);
922
+ if (fold === void 0 || !fold.observe(payload.event)) return null;
923
+ applyProgress(entry, fold);
924
+ return { kind: "updated", entry };
925
+ },
926
+ completed(payload) {
927
+ const entry = currentEntryForRun(payload.runId);
928
+ if (entry === void 0) return null;
929
+ return settle(entry, terminalFacts(payload));
930
+ },
931
+ failed(payload) {
932
+ const entry = currentEntryForRun(payload.runId);
933
+ if (entry === void 0) return null;
934
+ return settle(entry, terminalFacts(payload));
935
+ },
936
+ aborted(payload) {
937
+ const entry = currentEntryForRun(payload.runId);
938
+ if (entry === void 0 || !entry.pending) return null;
939
+ const durationMs = finiteNumber(payload.elapsedMs);
940
+ const failureMessage = nonEmptyString2(payload.reason);
941
+ entry.pending = false;
942
+ entry.receipt = {
943
+ outcome: "canceled",
944
+ ...durationMs !== void 0 ? { durationMs } : {},
945
+ ...failureMessage !== void 0 ? { failureMessage } : {},
946
+ provisional: true
947
+ };
948
+ const attempt = entry.attempts[entry.attempts.length - 1];
949
+ if (attempt !== void 0) attempt.outcome = "canceled";
950
+ return { kind: "updated", entry };
951
+ },
952
+ get(assignmentId) {
953
+ return byAssignment.get(assignmentId);
954
+ },
955
+ reset() {
956
+ byAssignment.clear();
957
+ attemptByAssignment.clear();
958
+ assignmentByRun.clear();
959
+ progressByAssignment.clear();
960
+ }
961
+ };
962
+ }
963
+
964
+ // src/interactive/worker-share.ts
965
+ var WORKER_SHARE_MAX_BYTES = WORKER_OUTPUT_MAX_BYTES;
966
+ var SHARE_TRUNCATION_MARKER = "\n[worker output truncated]";
967
+ function outcomeWord(outcome) {
968
+ return outcome === "succeeded" ? "ok" : outcome;
969
+ }
970
+ var WORKER_SHARE_NOTE_PREFIX = "[worker result]";
971
+ var WORKER_SHARE_ORIGIN = "shared by the operator";
972
+ function formatWorkerShareNote(facts) {
973
+ return shareNote(facts, facts.text);
974
+ }
975
+ function shareNote(facts, body) {
976
+ const text = body.trim();
977
+ if (text.length === 0) return null;
978
+ const header = `${WORKER_SHARE_NOTE_PREFIX} ${facts.agentId} \xB7 run ${facts.runId} \xB7 ${outcomeWord(facts.outcome)} \xB7 ${WORKER_SHARE_ORIGIN}`;
979
+ return `${header}
980
+ ${truncateUtf8(text, WORKER_SHARE_MAX_BYTES, SHARE_TRUNCATION_MARKER)}`;
981
+ }
982
+ function councilMemberLine(member) {
983
+ if (member.failed !== void 0) return `[${member.label}] failed: ${member.failed.reason}`;
984
+ const verdict = member.verdict === void 0 ? "" : ` (verdict ${member.verdict})`;
985
+ return `[${member.label}]${verdict} ${member.answer.trim()}`;
986
+ }
987
+ function councilSynthesisLines(synthesis) {
988
+ if (synthesis.kind === "none") return ["[synthesis none] the members answered separately; no synthesis was run."];
989
+ const facts = [
990
+ ...synthesis.verdict !== void 0 ? [`verdict ${synthesis.verdict}`] : [],
991
+ ...synthesis.tally !== void 0 ? [
992
+ `tally ${Object.entries(synthesis.tally).map(([key, count]) => `${key}=${count}`).join(" ")}`
993
+ ] : [],
994
+ ...synthesis.judgeRunId !== void 0 ? [`judge run ${synthesis.judgeRunId}`] : []
995
+ ];
996
+ const head = `[synthesis ${synthesis.kind}]${facts.length > 0 ? ` ${facts.join(" \xB7 ")}` : ""}`;
997
+ const text = synthesis.text?.trim() ?? "";
998
+ return text.length > 0 ? [head, text] : [head];
999
+ }
1000
+ function formatCouncilShareNote(facts, report) {
1001
+ const finalRound = report.members.reduce((highest, member) => Math.max(highest, member.round), 1);
1002
+ const body = [
1003
+ ...report.members.filter((member) => member.round === finalRound).map(councilMemberLine),
1004
+ ...councilSynthesisLines(report.synthesis)
1005
+ ].join("\n\n");
1006
+ return shareNote(facts, body);
1007
+ }
1008
+ function formatCouncilMemberShareNote(facts, label) {
1009
+ const text = facts.text.trim();
1010
+ if (text.length === 0) return null;
1011
+ return shareNote(facts, `[${label}] ${text}`);
1012
+ }
1013
+ function isWorkerShareNote(text) {
1014
+ return text.trimStart().startsWith(`${WORKER_SHARE_NOTE_PREFIX} `);
1015
+ }
1016
+ function workerShareFactsFromEntry(entry) {
1017
+ if (entry.pending || entry.receipt === void 0) return null;
1018
+ return { agentId: entry.agentId, runId: entry.runId, outcome: entry.receipt.outcome, text: entry.text };
1019
+ }
1020
+ function selectWorkerRunToShare(entries, id) {
1021
+ const wanted = id?.trim();
1022
+ for (let index = entries.length - 1; index >= 0; index -= 1) {
1023
+ const entry = entries[index];
1024
+ if (entry === void 0 || entry.pending || entry.receipt === void 0) continue;
1025
+ if (wanted === void 0 || wanted.length === 0) {
1026
+ if (!workerAskedByModel(entry)) return entry;
1027
+ continue;
1028
+ }
1029
+ if (entry.assignmentId === wanted || entry.attempts.some((attempt) => attempt.runId === wanted)) return entry;
1030
+ }
1031
+ return null;
1032
+ }
1033
+
1034
+ // src/interactive/slash-commands.ts
1035
+ function shareReceipt(agentId, receipt, deps) {
1036
+ if (!deps.submitOperatorNote) {
1037
+ deps.notice("error", "--share is not wired in this session; the result stayed local");
1038
+ return;
1039
+ }
1040
+ const note = formatWorkerShareNote({
1041
+ agentId,
1042
+ runId: receipt.runId,
1043
+ outcome: receipt.outcome,
1044
+ text: receipt.output?.text ?? ""
1045
+ });
1046
+ if (note === null) {
1047
+ deps.notice("warn", `--share: run ${receipt.runId} produced no text to share`);
1048
+ return;
1049
+ }
1050
+ deps.submitOperatorNote(note);
1051
+ }
1052
+ async function runAttributed(command, request, deps, share) {
1053
+ const { dispatch, notice, bus } = deps;
1054
+ const progressBus = dispatch.ownsProgressBus?.(bus) === true ? void 0 : bus;
1055
+ try {
1056
+ const handle = await dispatch.dispatch(request);
1057
+ for await (const event of handle.events) {
1058
+ const e = event;
1059
+ if (!e.type || e.type === "heartbeat") continue;
1060
+ progressBus?.emit(BusChannels.DispatchProgress, { runId: handle.runId, agentId: request.agentId, event });
1061
+ }
1062
+ const receipt = await handle.finalPromise;
1063
+ if (receipt.outcome === "canceled") {
1064
+ notice("warn", `${command} aborted: ${receipt.outcomeDetail ?? "operator abort"}`);
1065
+ } else if (receipt.exitCode !== 0 || receipt.failureMessage) {
1066
+ const failure = receipt.failureMessage ? ` ${receipt.failureMessage}` : "";
1067
+ notice("error", `${command} failed: exit=${receipt.exitCode}${failure}`);
1068
+ }
1069
+ if (share) shareReceipt(request.agentId, receipt, deps);
1070
+ } catch (err) {
1071
+ const msg = err instanceof Error ? err.message : String(err);
1072
+ if (err instanceof AdmissionCanceledError) {
1073
+ notice("warn", `${command} aborted: ${msg.replace(/^dispatch:\s*/u, "")}`);
1074
+ } else {
1075
+ notice("error", `${command} failed: ${msg}`);
1076
+ }
1077
+ }
1078
+ }
1079
+ async function handleRun(agentId, task, deps, options = {}) {
1080
+ if (options.target && options.workerProfile) {
1081
+ deps.notice(
1082
+ "warn",
1083
+ `--target ${options.target} takes precedence; --agent-profile ${options.workerProfile} will be ignored`
1084
+ );
1085
+ }
1086
+ if (options.target && options.workerRuntime) {
1087
+ deps.notice(
1088
+ "warn",
1089
+ `--target ${options.target} takes precedence; --runtime ${options.workerRuntime} will be ignored`
1090
+ );
1091
+ }
1092
+ await runAttributed(
1093
+ "run",
1094
+ {
1095
+ agentId,
1096
+ task,
1097
+ executionRole: requestExecutionRole({
1098
+ agentId,
1099
+ ...deps.getAgentRoleFacts ? { resolveFacts: deps.getAgentRoleFacts } : {}
1100
+ }),
1101
+ requestOrigin: "user",
1102
+ ...options.workerProfile ? { workerProfile: options.workerProfile } : {},
1103
+ ...options.workerRuntime ? { workerRuntime: options.workerRuntime } : {},
1104
+ ...options.target ? { target: options.target } : {},
1105
+ ...options.model ? { model: options.model } : {},
1106
+ ...options.thinkingLevel ? { thinkingLevel: options.thinkingLevel } : {},
1107
+ ...options.toolProfile ? { toolProfile: options.toolProfile } : {},
1108
+ ...options.requiredCapabilities && options.requiredCapabilities.length > 0 ? { requiredCapabilities: options.requiredCapabilities } : {}
1109
+ },
1110
+ deps,
1111
+ options.share === true
1112
+ );
1113
+ }
1114
+ async function handleDelegate(agentId, task, deps, options = {}) {
1115
+ await runAttributed(
1116
+ "delegate",
1117
+ { agentId, delegationAgentId: agentId, executionRole: "builder", requestOrigin: "user", task },
1118
+ deps,
1119
+ options.share === true
1120
+ );
1121
+ }
1122
+ async function handleOracle(question, ctx) {
1123
+ if (!ctx.submitOperatorNote) {
1124
+ ctx.notice("error", "/oracle is not wired in this session; there is nowhere to put the answer");
1125
+ return;
1126
+ }
1127
+ if (ctx.isTurnInFlight?.() === true) {
1128
+ ctx.notice("warn", "a turn is in flight; /oracle is refused rather than queued");
1129
+ return;
1130
+ }
1131
+ const sources = ctx.oracleBriefing?.();
1132
+ if (!sources) {
1133
+ ctx.notice("error", "/oracle needs the session record, which is not wired in this session");
1134
+ return;
1135
+ }
1136
+ const digest = packOracleDigest({ ...sources, question });
1137
+ const request = {
1138
+ agentId: ORACLE_AGENT_ID,
1139
+ task: ORACLE_TASK,
1140
+ briefing: digest.text,
1141
+ executionRole: requestExecutionRole({
1142
+ agentId: ORACLE_AGENT_ID,
1143
+ ...ctx.getAgentRoleFacts ? { resolveFacts: ctx.getAgentRoleFacts } : {}
1144
+ }),
1145
+ requestOrigin: "internal",
1146
+ autonomy: "read-only"
1147
+ };
1148
+ const progressBus = ctx.dispatch.ownsProgressBus?.(ctx.bus) === true ? void 0 : ctx.bus;
1149
+ try {
1150
+ const handle = await ctx.dispatch.dispatch(request);
1151
+ for await (const event of handle.events) {
1152
+ const typed = event;
1153
+ if (!typed.type || typed.type === "heartbeat") continue;
1154
+ progressBus?.emit(BusChannels.DispatchProgress, { runId: handle.runId, agentId: ORACLE_AGENT_ID, event });
1155
+ }
1156
+ const receipt = await handle.finalPromise;
1157
+ const parsed = parseOracleResult(receipt.output?.text ?? null);
1158
+ if (parsed === null) {
1159
+ ctx.notice("error", `/oracle run ${receipt.runId} returned no usable answer (${receipt.outcome})`);
1160
+ return;
1161
+ }
1162
+ const note = formatWorkerShareNote({
1163
+ agentId: ORACLE_AGENT_ID,
1164
+ runId: receipt.runId,
1165
+ outcome: receipt.outcome,
1166
+ text: formatOracleAnswer(parsed)
1167
+ });
1168
+ if (note === null) {
1169
+ ctx.notice("error", `/oracle run ${receipt.runId} produced no text to share`);
1170
+ return;
1171
+ }
1172
+ ctx.submitOperatorNote(note);
1173
+ } catch (err) {
1174
+ ctx.notice("error", `/oracle failed: ${err instanceof Error ? err.message : String(err)}`);
1175
+ }
1176
+ }
1177
+ async function handleCouncil(task, options, ctx) {
1178
+ if (ctx.isTurnInFlight?.() === true) {
1179
+ ctx.notice("warn", "a turn is in flight; /council is refused rather than queued");
1180
+ return;
1181
+ }
1182
+ if (!ctx.runCouncilDispatch) {
1183
+ ctx.notice("error", "/council is not wired in this session");
1184
+ return;
1185
+ }
1186
+ const rosters = ctx.getWorkerRosters?.();
1187
+ if (rosters === void 0) {
1188
+ ctx.notice("error", "/council needs workers.rosters, which is not wired in this session");
1189
+ return;
1190
+ }
1191
+ const resolved = resolveCouncilRoster(options.roster, rosters);
1192
+ if (!resolved.ok) {
1193
+ ctx.notice("error", resolved.reason);
1194
+ return;
1195
+ }
1196
+ try {
1197
+ const outcome = await ctx.runCouncilDispatch(buildCouncilDispatchArgs(task, resolved.roster, options));
1198
+ if (outcome.status === "blocked") ctx.notice("warn", `/council was not admitted: ${outcome.reason}`);
1199
+ else if (outcome.status === "error") ctx.notice("error", `/council failed: ${outcome.message}`);
1200
+ } catch (err) {
1201
+ ctx.notice("error", `/council failed: ${err instanceof Error ? err.message : String(err)}`);
1202
+ }
1203
+ }
1204
+ function councilAwareShareNote(facts, entry) {
1205
+ const council = entry.council;
1206
+ if (council === void 0) return formatWorkerShareNote(facts);
1207
+ if (council.label !== COUNCIL_SYNTHESIS_LABEL) return formatCouncilMemberShareNote(facts, council.label);
1208
+ const report = parseCouncilReport(facts.text);
1209
+ return report === null ? formatWorkerShareNote(facts) : formatCouncilShareNote(facts, report);
1210
+ }
1211
+ function shareWorkerRun(runId, ctx) {
1212
+ if (!ctx.submitOperatorNote) {
1213
+ ctx.notice("error", "share is not wired; the worker transcript is unavailable in this session");
1214
+ return;
1215
+ }
1216
+ const entry = selectWorkerRunToShare(ctx.listWorkerRuns?.() ?? [], runId);
1217
+ if (!entry) {
1218
+ ctx.notice(
1219
+ "error",
1220
+ runId === void 0 ? "no finished /run or /delegate result to share yet" : `no finished run ${runId} in this session`
1221
+ );
1222
+ return;
1223
+ }
1224
+ const facts = workerShareFactsFromEntry(entry);
1225
+ const note = facts === null ? null : councilAwareShareNote(facts, entry);
1226
+ if (note === null) {
1227
+ ctx.notice("error", `run ${entry.runId} produced no text to share`);
1228
+ return;
1229
+ }
1230
+ ctx.submitOperatorNote(note);
1231
+ }
1232
+ function formatReceiptVerificationBlock(runId, result) {
1233
+ const status = result.ok ? result.compromised ? "compromised" : "ok" : result.retired ? "retired" : "fail";
1234
+ const lines = [
1235
+ `verify ${status} ${runId}`,
1236
+ `receipt ${result.receiptPath ?? "unavailable"}`,
1237
+ `digest ${result.sealedDigest ?? "unavailable"}`,
1238
+ `evidence ${result.trustSummary ?? (!result.ok ? result.reason : "trust status unavailable")}`
1239
+ ];
1240
+ if (result.checks && result.checks.length > 0) {
1241
+ lines.push("checks");
1242
+ for (const check of result.checks) lines.push(` ${check.ok ? "\u2713" : "\u2717"} ${check.name}: ${check.evidence}`);
1243
+ }
1244
+ return lines.join("\n");
1245
+ }
1246
+ function formatUserTaskHandoff(task) {
1247
+ const note = task.note ? ` ${task.note}.` : "";
1248
+ return `Operator task ${task.id}: ${task.title}.${note} Pick it up with tasks action="pick" id="${task.id}" and work it when appropriate.`;
1249
+ }
1250
+ var SLASH_COMMAND_GROUPS = ["Run", "Inspect", "Configure", "Sessions"];
1251
+ var RUN_THINKING_LEVELS = THINKING_LEVELS;
1252
+ function isRunThinkingLevel(value) {
1253
+ return RUN_THINKING_LEVELS.some((level) => level === value);
1254
+ }
1255
+ function isSettingsSectionId(value) {
1256
+ return SETTINGS_SECTIONS.some((section) => section.id === value);
1257
+ }
1258
+ var COMPACT_POSITIONALS = [
1259
+ { name: "instructions", required: false, rest: true }
1260
+ ];
1261
+ var RECALL_POSITIONALS = [{ name: "ref", required: true }];
1262
+ function fromArgsOrUsage(name, command) {
1263
+ return (parsed) => parsed.error ? { kind: "usage-error", command: name, reason: parsed.error } : command;
1264
+ }
1265
+ function settingsDeepLink(name, section, description, rowId) {
1266
+ return {
1267
+ name,
1268
+ description,
1269
+ group: "Configure",
1270
+ kinds: [],
1271
+ args: {},
1272
+ fromArgs: fromArgsOrUsage(name, { kind: "settings", section, ...rowId ? { rowId } : {} }),
1273
+ handle: () => void 0
1274
+ };
1275
+ }
1276
+ function usageNotice(entry, subcommand) {
1277
+ return usageLine(entry, subcommand).trim();
1278
+ }
1279
+ function formatPanesStatus(status) {
1280
+ const server = status.server ? `pane host ${status.server.version}, protocol ${status.server.protocol}` : "no server";
1281
+ const lines = [
1282
+ `panes: mode=${status.mode} ${status.available ? "available" : "unavailable"} (${server})`,
1283
+ ` ${status.reason}`,
1284
+ ...status.socketPath ? [` socket ${status.socketPath}`] : [],
1285
+ ` settings: enabled=${status.settings.enabled} notifications=${status.settings.notifications} journal=${status.settings.journal}`,
1286
+ ` files: enabled=${status.settings.yazi.enabled} mode=${status.settings.yazi.mode} profile=${status.settings.yazi.profile} followCwd=${status.settings.yazi.followCwd}`,
1287
+ ` file pane: mode=${status.yazi.mode} pane=${status.yazi.paneId ?? "none"} cwd=${status.yazi.paneCwd ?? "unknown"} lastLine=${status.yazi.lastLineAt === null ? "never" : new Date(status.yazi.lastLineAt).toISOString()} dropped=${status.yazi.droppedLines}`
1288
+ ];
1289
+ if (status.panes.length === 0) {
1290
+ lines.push(" no Clio-owned panes");
1291
+ } else {
1292
+ lines.push(` ${status.panes.length} Clio-owned pane(s):`);
1293
+ for (const pane of status.panes) {
1294
+ const adopted = pane.adopted ? " adopted" : "";
1295
+ const pending = pane.pending ? " opening" : "";
1296
+ lines.push(` ${pane.paneId} ${pane.purpose} ${pane.label}${adopted}${pending}`);
1297
+ }
1298
+ }
1299
+ lines.push(` presets: ${PANES_PRESETS.map((preset) => `${preset.id} (${preset.summary})`).join(", ")}`);
1300
+ return lines;
1301
+ }
1302
+ var BUILTIN_SLASH_COMMANDS = [
1303
+ {
1304
+ name: "quit",
1305
+ description: "Exit Clio Coder",
1306
+ group: "Sessions",
1307
+ kinds: ["quit"],
1308
+ args: {},
1309
+ fromArgs: fromArgsOrUsage("quit", { kind: "quit" }),
1310
+ handle(_command, ctx) {
1311
+ ctx.shutdown();
1312
+ }
1313
+ },
1314
+ {
1315
+ name: "help",
1316
+ description: "Open the interactive help center showing commands and keys",
1317
+ group: "Inspect",
1318
+ kinds: ["help"],
1319
+ args: {
1320
+ positionals: [{ name: "query", required: false, rest: true }]
1321
+ },
1322
+ fromArgs(parsed) {
1323
+ return { kind: "help", ...parsed.rest ? { query: parsed.rest } : {} };
1324
+ },
1325
+ handle(command, ctx) {
1326
+ ctx.openHelp(command.kind === "help" ? command.query : void 0);
1327
+ }
1328
+ },
1329
+ {
1330
+ name: "skill",
1331
+ description: "Open the Skills Hub or invoke a skill",
1332
+ group: "Run",
1333
+ kinds: ["skill-selector", "skill-invocation"],
1334
+ args: {
1335
+ positionals: [
1336
+ { name: "name", required: false },
1337
+ { name: "task", required: false, rest: true }
1338
+ ]
1339
+ },
1340
+ match(trimmed) {
1341
+ if (trimmed === "/skill") {
1342
+ return { kind: "skill-selector" };
1343
+ }
1344
+ const command = parseSkillCommand(trimmed);
1345
+ if (command) {
1346
+ return { kind: "skill-invocation", text: trimmed };
1347
+ }
1348
+ return null;
1349
+ },
1350
+ handle(command, ctx) {
1351
+ if (command.kind === "skill-selector") {
1352
+ ctx.openSkillsHub?.();
1353
+ } else if (command.kind === "skill-invocation") {
1354
+ ctx.submitChat(command.text);
1355
+ }
1356
+ }
1357
+ },
1358
+ {
1359
+ name: "library",
1360
+ description: "Open the Skills Hub on a resource library tab",
1361
+ group: "Run",
1362
+ kinds: ["library"],
1363
+ args: { positionals: [{ name: "kind", required: false }] },
1364
+ fromArgs(parsed) {
1365
+ if (parsed.error) return { kind: "usage-error", command: "library", reason: parsed.error };
1366
+ const tab = parsed.positionals[0];
1367
+ if (tab === void 0) return { kind: "library" };
1368
+ if (!isLibraryTab(tab)) {
1369
+ const known = LIBRARY_TABS.map((entry) => entry.id).join(", ");
1370
+ return { kind: "usage-error", command: "library", reason: `Unknown kind: ${tab} (one of ${known})` };
1371
+ }
1372
+ return { kind: "library", tab };
1373
+ },
1374
+ handle(command, ctx) {
1375
+ if (command.kind === "library") ctx.openSkillsHub?.(command.tab);
1376
+ }
1377
+ },
1378
+ {
1379
+ name: "prompts",
1380
+ description: "List prompt templates",
1381
+ group: "Inspect",
1382
+ kinds: ["prompts"],
1383
+ args: {},
1384
+ fromArgs: fromArgsOrUsage("prompts", { kind: "prompts" }),
1385
+ handle(_command, ctx) {
1386
+ ctx.openPrompts();
1387
+ }
1388
+ },
1389
+ {
1390
+ name: "extensions",
1391
+ description: "List installed extensions",
1392
+ group: "Inspect",
1393
+ kinds: ["extensions"],
1394
+ args: {},
1395
+ fromArgs: fromArgsOrUsage("extensions", { kind: "extensions" }),
1396
+ handle(_command, ctx) {
1397
+ ctx.openExtensions?.();
1398
+ }
1399
+ },
1400
+ {
1401
+ name: "interop",
1402
+ description: "Review other coding agents detected on this machine",
1403
+ group: "Inspect",
1404
+ kinds: ["interop"],
1405
+ args: {},
1406
+ fromArgs: fromArgsOrUsage("interop", { kind: "interop" }),
1407
+ handle(_command, ctx) {
1408
+ ctx.openInterop?.();
1409
+ }
1410
+ },
1411
+ {
1412
+ name: "share",
1413
+ description: "Share a worker result with the main agent, or export and import Clio archives",
1414
+ group: "Sessions",
1415
+ kinds: ["share"],
1416
+ args: {
1417
+ positionals: [{ name: "runId", required: false }],
1418
+ subcommands: {
1419
+ export: {
1420
+ positionals: [{ name: "path", required: true }]
1421
+ },
1422
+ import: {
1423
+ flags: [{ name: "--dry-run" }, { name: "--force" }],
1424
+ positionals: [{ name: "path", required: true }]
1425
+ }
1426
+ }
1427
+ },
1428
+ fromArgs(parsed) {
1429
+ const subcommand = parsed.subcommand === "export" || parsed.subcommand === "import" ? parsed.subcommand : void 0;
1430
+ if (parsed.error) {
1431
+ return {
1432
+ kind: "share",
1433
+ action: "usage",
1434
+ ...subcommand !== void 0 ? { subcommand } : {},
1435
+ error: parsed.error
1436
+ };
1437
+ }
1438
+ const path = parsed.positionals[0];
1439
+ if (subcommand === "export" && path !== void 0) return { kind: "share", action: "export", path };
1440
+ if (subcommand === "import" && path !== void 0) {
1441
+ return {
1442
+ kind: "share",
1443
+ action: "import",
1444
+ path,
1445
+ dryRun: parsed.flags.has("--dry-run"),
1446
+ force: parsed.flags.has("--force")
1447
+ };
1448
+ }
1449
+ if (subcommand === void 0) {
1450
+ return { kind: "share", action: "worker-run", ...path !== void 0 ? { runId: path } : {} };
1451
+ }
1452
+ return { kind: "share", action: "usage", ...subcommand !== void 0 ? { subcommand } : {} };
1453
+ },
1454
+ handle(command, ctx) {
1455
+ if (command.kind !== "share") return;
1456
+ if (command.action === "worker-run") {
1457
+ shareWorkerRun(command.runId, ctx);
1458
+ return;
1459
+ }
1460
+ if (command.action === "usage") {
1461
+ const entry = BUILTIN_SLASH_COMMANDS.find((candidate) => candidate.name === "share");
1462
+ if (!entry) return;
1463
+ const usage = usageNotice(entry, command.subcommand);
1464
+ ctx.notice("info", command.error ? `${command.error}
1465
+ ${usage}` : usage);
1466
+ return;
1467
+ }
1468
+ if (command.action === "export") {
1469
+ if (!ctx.exportShareArchive) {
1470
+ ctx.notice("error", "share export is not wired");
1471
+ return;
1472
+ }
1473
+ const result = ctx.exportShareArchive(command.path);
1474
+ ctx.notice("success", `exported ${result.fileCount} item(s) to ${result.path}`);
1475
+ return;
1476
+ }
1477
+ if (command.action === "import") {
1478
+ if (!ctx.importShareArchive) {
1479
+ ctx.notice("error", "share import is not wired");
1480
+ return;
1481
+ }
1482
+ const plan = ctx.importShareArchive(command.path, { dryRun: command.dryRun, force: command.force });
1483
+ for (const diag of plan.diagnostics) {
1484
+ const detail = diag.path ? `${diag.message}: ${diag.path}` : diag.message;
1485
+ ctx.notice("warn", `${diag.type}: ${detail}`);
1486
+ }
1487
+ const write = plan.actions.filter((action) => action.action === "write").length;
1488
+ const overwrite = plan.actions.filter((action) => action.action === "overwrite").length;
1489
+ const skip = plan.actions.filter((action) => action.action === "skip").length;
1490
+ ctx.notice(
1491
+ command.dryRun ? "info" : "success",
1492
+ `${command.dryRun ? "dry-run" : "import"} write=${write} overwrite=${overwrite} skip=${skip} settings=${plan.actions.filter((action) => action.action === "settings").length}`
1493
+ );
1494
+ }
1495
+ }
1496
+ },
1497
+ {
1498
+ name: "run",
1499
+ description: "Run a fleet agent",
1500
+ group: "Run",
1501
+ kinds: ["run", "run-usage"],
1502
+ args: {
1503
+ parseFlagsBeforeRest: true,
1504
+ flags: [
1505
+ { name: "--agent-profile", takesValue: true, valueName: "profile" },
1506
+ { name: "--runtime", takesValue: true, valueName: "runtimeId" },
1507
+ { name: "--target", takesValue: true, valueName: "id" },
1508
+ { name: "--model", takesValue: true, valueName: "id" },
1509
+ { name: "--thinking", takesValue: true, values: RUN_THINKING_LEVELS, valueName: "level" },
1510
+ { name: "--tool-profile", takesValue: true, values: TOOL_PROFILE_NAMES },
1511
+ { name: "--require", takesValue: true, repeatable: true, valueName: "cap" },
1512
+ { name: "--share" }
1513
+ ],
1514
+ positionals: [
1515
+ { name: "agent", required: true },
1516
+ { name: "task", required: true, rest: true }
1517
+ ]
1518
+ },
1519
+ fromArgs(parsed, trimmed) {
1520
+ if (parsed.error) return { kind: "run-usage" };
1521
+ const options = {};
1522
+ const workerProfile = parsed.flags.get("--agent-profile");
1523
+ if (typeof workerProfile === "string") options.workerProfile = workerProfile;
1524
+ const workerRuntime = parsed.flags.get("--runtime");
1525
+ if (typeof workerRuntime === "string") options.workerRuntime = workerRuntime;
1526
+ const target = parsed.flags.get("--target");
1527
+ if (typeof target === "string") options.target = target;
1528
+ const model = parsed.flags.get("--model");
1529
+ if (typeof model === "string") options.model = model;
1530
+ const thinking = parsed.flags.get("--thinking");
1531
+ if (typeof thinking === "string") {
1532
+ if (!isRunThinkingLevel(thinking)) return { kind: "run-usage" };
1533
+ options.thinkingLevel = thinking;
1534
+ }
1535
+ const toolProfile = parsed.flags.get("--tool-profile");
1536
+ if (typeof toolProfile === "string") {
1537
+ if (!isToolProfileName(toolProfile)) return { kind: "run-usage" };
1538
+ options.toolProfile = toolProfile;
1539
+ }
1540
+ const requiredCapabilities = parsed.flagValues.get("--require");
1541
+ if (requiredCapabilities && requiredCapabilities.length > 0) {
1542
+ options.requiredCapabilities = [...requiredCapabilities];
1543
+ }
1544
+ if (parsed.flags.has("--share")) options.share = true;
1545
+ const agentId = parsed.positionals[0] ?? "";
1546
+ const task = parsed.positionals[1] ?? "";
1547
+ return { kind: "run", agentId, task, options, source: trimmed };
1548
+ },
1549
+ handle(command, ctx) {
1550
+ if (command.kind === "run-usage") {
1551
+ const entry = BUILTIN_SLASH_COMMANDS.find((e) => e.name === "run");
1552
+ if (entry) {
1553
+ ctx.notice("info", usageNotice(entry));
1554
+ }
1555
+ return;
1556
+ }
1557
+ if (command.kind !== "run") return;
1558
+ const { agentId, task, options } = command;
1559
+ ctx.echoOperatorCommand?.(command.source);
1560
+ void (async () => {
1561
+ await handleRun(
1562
+ agentId,
1563
+ task,
1564
+ {
1565
+ dispatch: ctx.dispatch,
1566
+ ...ctx.getAgentRoleFacts ? { getAgentRoleFacts: ctx.getAgentRoleFacts } : {},
1567
+ io: ctx.io,
1568
+ notice: ctx.notice,
1569
+ bus: ctx.bus,
1570
+ ...ctx.submitOperatorNote ? { submitOperatorNote: ctx.submitOperatorNote } : {}
1571
+ },
1572
+ options
1573
+ );
1574
+ ctx.render();
1575
+ })();
1576
+ }
1577
+ },
1578
+ {
1579
+ name: "delegate",
1580
+ description: "Run an ACP delegation agent",
1581
+ group: "Run",
1582
+ kinds: ["delegate", "delegate-usage"],
1583
+ args: {
1584
+ parseFlagsBeforeRest: true,
1585
+ flags: [{ name: "--share" }],
1586
+ positionals: [
1587
+ { name: "agent-id", required: true },
1588
+ { name: "task", required: true, rest: true }
1589
+ ]
1590
+ },
1591
+ fromArgs(parsed, trimmed) {
1592
+ if (parsed.error) return { kind: "delegate-usage" };
1593
+ const agentId = parsed.positionals[0] ?? "";
1594
+ const task = parsed.positionals[1] ?? "";
1595
+ return { kind: "delegate", agentId, task, source: trimmed, ...parsed.flags.has("--share") ? { share: true } : {} };
1596
+ },
1597
+ handle(command, ctx) {
1598
+ if (command.kind === "delegate-usage") {
1599
+ const entry = BUILTIN_SLASH_COMMANDS.find((e) => e.name === "delegate");
1600
+ if (entry) {
1601
+ ctx.notice("info", usageNotice(entry));
1602
+ }
1603
+ return;
1604
+ }
1605
+ if (command.kind !== "delegate") return;
1606
+ ctx.echoOperatorCommand?.(command.source);
1607
+ const share = command.share === true;
1608
+ void (async () => {
1609
+ await handleDelegate(
1610
+ command.agentId,
1611
+ command.task,
1612
+ {
1613
+ dispatch: ctx.dispatch,
1614
+ io: ctx.io,
1615
+ notice: ctx.notice,
1616
+ bus: ctx.bus,
1617
+ ...ctx.submitOperatorNote ? { submitOperatorNote: ctx.submitOperatorNote } : {}
1618
+ },
1619
+ { share }
1620
+ );
1621
+ ctx.render();
1622
+ })();
1623
+ }
1624
+ },
1625
+ {
1626
+ name: "btw",
1627
+ description: "Ask a side question that never enters the session transcript",
1628
+ group: "Run",
1629
+ kinds: ["btw", "btw-usage"],
1630
+ args: {
1631
+ positionals: [{ name: "question", required: true, rest: true }]
1632
+ },
1633
+ fromArgs(parsed) {
1634
+ const question = parsed.rest?.trim() ?? "";
1635
+ if (parsed.error || question.length === 0) return { kind: "btw-usage" };
1636
+ return { kind: "btw", question };
1637
+ },
1638
+ handle(command, ctx) {
1639
+ if (command.kind === "btw-usage") {
1640
+ const entry = BUILTIN_SLASH_COMMANDS.find((candidate) => candidate.name === "btw");
1641
+ if (entry) ctx.notice("info", usageNotice(entry));
1642
+ return;
1643
+ }
1644
+ if (command.kind !== "btw") return;
1645
+ ctx.openSideQuestion(command.question);
1646
+ }
1647
+ },
1648
+ {
1649
+ name: "oracle",
1650
+ description: "Ask a read-only advisor to challenge a question against this session's settled decisions",
1651
+ group: "Run",
1652
+ kinds: ["oracle", "oracle-usage"],
1653
+ args: {
1654
+ positionals: [{ name: "question", required: true, rest: true }]
1655
+ },
1656
+ fromArgs(parsed) {
1657
+ const question = parsed.rest?.trim() ?? "";
1658
+ if (parsed.error || question.length === 0) return { kind: "oracle-usage" };
1659
+ return { kind: "oracle", question };
1660
+ },
1661
+ handle(command, ctx) {
1662
+ if (command.kind === "oracle-usage") {
1663
+ const entry = BUILTIN_SLASH_COMMANDS.find((candidate) => candidate.name === "oracle");
1664
+ if (entry) ctx.notice("info", usageNotice(entry));
1665
+ return;
1666
+ }
1667
+ if (command.kind !== "oracle") return;
1668
+ void (async () => {
1669
+ await handleOracle(command.question, ctx);
1670
+ ctx.render();
1671
+ })();
1672
+ }
1673
+ },
1674
+ {
1675
+ name: "council",
1676
+ description: "Ask a roster of read-only members the same task, with an optional vote or judge synthesis",
1677
+ group: "Run",
1678
+ kinds: ["council", "council-usage"],
1679
+ args: {
1680
+ parseFlagsBeforeRest: true,
1681
+ flags: [
1682
+ { name: "--roster", takesValue: true, valueName: "name" },
1683
+ { name: "--rounds", takesValue: true, valueName: "n" },
1684
+ { name: "--synthesis", takesValue: true, values: COUNCIL_SYNTHESIS_MODES }
1685
+ ],
1686
+ positionals: [{ name: "task", required: true, rest: true }]
1687
+ },
1688
+ fromArgs(parsed) {
1689
+ const task = parsed.rest?.trim() ?? "";
1690
+ if (parsed.error) return { kind: "council-usage", reason: parsed.error };
1691
+ if (task.length === 0) return { kind: "council-usage" };
1692
+ const options = {};
1693
+ const roster = parsed.flags.get("--roster");
1694
+ if (typeof roster === "string") options.roster = roster;
1695
+ const rounds = parsed.flags.get("--rounds");
1696
+ if (typeof rounds === "string") {
1697
+ const parsedRounds = Number(rounds);
1698
+ if (!Number.isInteger(parsedRounds) || parsedRounds < 1 || parsedRounds > COUNCIL_MAX_ROUNDS) {
1699
+ return { kind: "council-usage", reason: `--rounds must be an integer 1..${COUNCIL_MAX_ROUNDS}` };
1700
+ }
1701
+ options.rounds = parsedRounds;
1702
+ }
1703
+ const synthesis = parsed.flags.get("--synthesis");
1704
+ if (typeof synthesis === "string") {
1705
+ if (!isCouncilSynthesisMode(synthesis)) return { kind: "council-usage" };
1706
+ options.synthesis = synthesis;
1707
+ }
1708
+ return { kind: "council", task, options };
1709
+ },
1710
+ handle(command, ctx) {
1711
+ if (command.kind === "council-usage") {
1712
+ const entry = BUILTIN_SLASH_COMMANDS.find((candidate) => candidate.name === "council");
1713
+ const usage = entry ? usageNotice(entry) : "usage: /council <task>";
1714
+ ctx.notice("info", command.reason ? `${command.reason}
1715
+ ${usage}` : usage);
1716
+ return;
1717
+ }
1718
+ if (command.kind !== "council") return;
1719
+ void (async () => {
1720
+ await handleCouncil(command.task, command.options, ctx);
1721
+ ctx.render();
1722
+ })();
1723
+ }
1724
+ },
1725
+ {
1726
+ name: "agents",
1727
+ description: "List Clio agents and ACP delegation agents",
1728
+ group: "Inspect",
1729
+ kinds: ["agents"],
1730
+ args: {},
1731
+ fromArgs: fromArgsOrUsage("agents", { kind: "agents" }),
1732
+ handle(_command, ctx) {
1733
+ ctx.openAgents();
1734
+ }
1735
+ },
1736
+ settingsDeepLink("targets", "targets", "Open Settings \u2192 Targets: health, use, connect, probe, remove"),
1737
+ {
1738
+ name: "cost",
1739
+ description: "Show session token and cost totals",
1740
+ group: "Inspect",
1741
+ kinds: ["cost"],
1742
+ args: {},
1743
+ fromArgs: fromArgsOrUsage("cost", { kind: "cost" }),
1744
+ handle(_command, ctx) {
1745
+ ctx.openCost();
1746
+ }
1747
+ },
1748
+ {
1749
+ name: "context",
1750
+ description: "Context hub: window overlay plus compact, recall, init, refresh, and reset",
1751
+ group: "Inspect",
1752
+ kinds: ["context-view", "compact", "context-recall", "init", "context-clear", "context-refresh"],
1753
+ subcommandDescriptions: {
1754
+ compact: "Compact session context",
1755
+ recall: "Recall an evicted result",
1756
+ init: "Initialize project context",
1757
+ refresh: "Refresh project context",
1758
+ reset: "Reset project context"
1759
+ },
1760
+ args: {
1761
+ subcommands: {
1762
+ compact: { positionals: [...COMPACT_POSITIONALS] },
1763
+ recall: { positionals: [...RECALL_POSITIONALS] },
1764
+ init: {},
1765
+ refresh: {},
1766
+ reset: {}
1767
+ }
1768
+ },
1769
+ fromArgs(parsed) {
1770
+ if (parsed.error) return { kind: "usage-error", command: "context", reason: parsed.error };
1771
+ switch (parsed.subcommand) {
1772
+ case "compact":
1773
+ return { kind: "compact", instructions: parsed.rest };
1774
+ case "recall":
1775
+ return { kind: "context-recall", ref: parsed.positionals[0] ?? "" };
1776
+ case "init":
1777
+ return { kind: "init", options: {} };
1778
+ case "refresh":
1779
+ return { kind: "context-refresh" };
1780
+ case "reset":
1781
+ return { kind: "context-clear", options: {} };
1782
+ default:
1783
+ return { kind: "context-view" };
1784
+ }
1785
+ },
1786
+ handle(command, ctx) {
1787
+ switch (command.kind) {
1788
+ case "context-view":
1789
+ ctx.openContextView();
1790
+ return;
1791
+ case "compact":
1792
+ ctx.runCompact(command.instructions);
1793
+ return;
1794
+ case "context-recall":
1795
+ if (ctx.runContextRecall) {
1796
+ ctx.runContextRecall(command.ref);
1797
+ } else {
1798
+ ctx.notice("error", "context recall is not wired; no session is bound to this process");
1799
+ }
1800
+ return;
1801
+ case "init":
1802
+ ctx.runInit(command.options);
1803
+ return;
1804
+ case "context-clear":
1805
+ ctx.runContextClear(command.options);
1806
+ return;
1807
+ case "context-refresh":
1808
+ if (ctx.runContextRefresh) {
1809
+ ctx.runContextRefresh();
1810
+ } else {
1811
+ ctx.notice("error", "context refresh is not wired; pass onContextRefresh to startInteractive");
1812
+ }
1813
+ return;
1814
+ default:
1815
+ return;
1816
+ }
1817
+ }
1818
+ },
1819
+ {
1820
+ name: "fleet",
1821
+ description: "Open Settings \u2192 Fleet, or run a fleet contract with an approval preview",
1822
+ group: "Configure",
1823
+ kinds: ["fleet-run", "fleet-run-usage"],
1824
+ subcommandDescriptions: { run: "Preview and run a repo-owned fleet contract" },
1825
+ args: {
1826
+ subcommands: {
1827
+ run: {
1828
+ flags: [{ name: "--var", takesValue: true, repeatable: true, valueName: "key=value" }],
1829
+ positionals: [{ name: "name", required: true }]
1830
+ }
1831
+ }
1832
+ },
1833
+ /**
1834
+ * `/fleet` alone keeps the settings deep link it has always been, and
1835
+ * only `run` parses as a command of its own, so an operator who types
1836
+ * `/fleet` out of habit still lands in Settings → Fleet. Anything else
1837
+ * on the line stays the usage error every other deep link reports.
1838
+ */
1839
+ fromArgs(parsed) {
1840
+ if (parsed.subcommand !== "run") {
1841
+ return parsed.error ? { kind: "usage-error", command: "fleet", reason: parsed.error } : { kind: "settings", section: "fleet" };
1842
+ }
1843
+ if (parsed.error) return { kind: "fleet-run-usage", reason: parsed.error };
1844
+ const name = parsed.positionals[0] ?? "";
1845
+ if (name.length === 0) return { kind: "fleet-run-usage" };
1846
+ const vars = {};
1847
+ for (const pair of parsed.flagValues.get("--var") ?? []) {
1848
+ const eq = pair.indexOf("=");
1849
+ const key = eq < 0 ? "" : pair.slice(0, eq).trim();
1850
+ if (key.length === 0) return { kind: "fleet-run-usage", reason: "--var requires key=value" };
1851
+ vars[key] = pair.slice(eq + 1);
1852
+ }
1853
+ return { kind: "fleet-run", name, vars };
1854
+ },
1855
+ handle(command, ctx) {
1856
+ if (command.kind === "fleet-run-usage") {
1857
+ const entry = BUILTIN_SLASH_COMMANDS.find((candidate) => candidate.name === "fleet");
1858
+ const usage = entry ? usageNotice(entry, "run") : "usage: /fleet run <name> [--var key=value ...]";
1859
+ ctx.notice("info", command.reason ? `${command.reason}
1860
+ ${usage}` : usage);
1861
+ return;
1862
+ }
1863
+ if (command.kind !== "fleet-run") return;
1864
+ if (!ctx.startFleetRun) {
1865
+ ctx.notice("error", "/fleet run is not wired in this session");
1866
+ return;
1867
+ }
1868
+ ctx.startFleetRun(command.name, command.vars);
1869
+ }
1870
+ },
1871
+ {
1872
+ name: "decisions",
1873
+ description: "Show settled interview decisions and operator revisions",
1874
+ group: "Inspect",
1875
+ kinds: ["decisions"],
1876
+ fromArgs(parsed) {
1877
+ if (parsed.error) return { kind: "usage-error", command: "decisions", reason: parsed.error };
1878
+ return { kind: "decisions" };
1879
+ },
1880
+ handle(_command, ctx) {
1881
+ ctx.openDecisions();
1882
+ }
1883
+ },
1884
+ {
1885
+ name: "tasks",
1886
+ description: "Show the session board or manage project operator tasks",
1887
+ group: "Inspect",
1888
+ kinds: ["tasks", "tasks-add", "tasks-hand", "tasks-done", "tasks-drop"],
1889
+ subcommandDescriptions: {
1890
+ add: "Log a project task without notifying the agent",
1891
+ hand: "Hand an operator task to the agent",
1892
+ done: "Mark an operator task done",
1893
+ drop: "Drop an operator task"
1894
+ },
1895
+ args: {
1896
+ subcommands: {
1897
+ add: { positionals: [{ name: "text", required: true, rest: true }] },
1898
+ hand: { positionals: [{ name: "id", required: true }] },
1899
+ done: { positionals: [{ name: "id", required: true }] },
1900
+ drop: { positionals: [{ name: "id", required: true }] }
1901
+ }
1902
+ },
1903
+ fromArgs(parsed) {
1904
+ if (parsed.error) return { kind: "usage-error", command: "tasks", reason: parsed.error };
1905
+ switch (parsed.subcommand) {
1906
+ case "add":
1907
+ return parsed.rest ? { kind: "tasks-add", text: parsed.rest } : { kind: "usage-error", command: "tasks", reason: "add requires task text" };
1908
+ case "hand":
1909
+ case "done":
1910
+ case "drop": {
1911
+ const id = parsed.positionals[0];
1912
+ if (!id || !/^u[1-9]\d*$/.test(id)) {
1913
+ return { kind: "usage-error", command: "tasks", reason: `${parsed.subcommand} requires a uN id` };
1914
+ }
1915
+ if (parsed.subcommand === "hand") return { kind: "tasks-hand", id };
1916
+ if (parsed.subcommand === "done") return { kind: "tasks-done", id };
1917
+ return { kind: "tasks-drop", id };
1918
+ }
1919
+ default:
1920
+ return { kind: "tasks" };
1921
+ }
1922
+ },
1923
+ handle(command, ctx) {
1924
+ if (command.kind === "tasks") {
1925
+ ctx.openTasks();
1926
+ return;
1927
+ }
1928
+ if (!ctx.userTasks) {
1929
+ ctx.notice("error", "operator task inbox is not wired in this session");
1930
+ return;
1931
+ }
1932
+ try {
1933
+ if (command.kind === "tasks-add") {
1934
+ const task = ctx.userTasks.add(command.text);
1935
+ ctx.notice("success", `logged operator task ${task.id}: ${task.title}`);
1936
+ return;
1937
+ }
1938
+ if (command.kind === "tasks-hand") {
1939
+ const task = ctx.userTasks.hand(command.id);
1940
+ ctx.submitChat(formatUserTaskHandoff(task));
1941
+ return;
1942
+ }
1943
+ if (command.kind === "tasks-done") {
1944
+ const task = ctx.userTasks.done(command.id);
1945
+ ctx.notice("success", `marked operator task ${task.id} done`);
1946
+ return;
1947
+ }
1948
+ if (command.kind === "tasks-drop") {
1949
+ const task = ctx.userTasks.drop(command.id);
1950
+ ctx.notice("success", `dropped operator task ${task.id}`);
1951
+ }
1952
+ } catch (error) {
1953
+ const message = error instanceof Error ? error.message : String(error);
1954
+ ctx.notice("error", message);
1955
+ }
1956
+ }
1957
+ },
1958
+ {
1959
+ name: "memory",
1960
+ description: "Inspect, promote, or seed task memory",
1961
+ group: "Inspect",
1962
+ kinds: ["memory", "memory-seed"],
1963
+ subcommandDescriptions: { seed: "Seed the task bank from the newest handoff" },
1964
+ args: { subcommands: { seed: {} } },
1965
+ fromArgs(parsed) {
1966
+ if (parsed.error) return { kind: "usage-error", command: "memory", reason: parsed.error };
1967
+ return parsed.subcommand === "seed" ? { kind: "memory-seed" } : { kind: "memory" };
1968
+ },
1969
+ handle(command, ctx) {
1970
+ if (command.kind === "memory") {
1971
+ ctx.openMemory();
1972
+ return;
1973
+ }
1974
+ if (command.kind !== "memory-seed") return;
1975
+ const result = ctx.seedTaskMemory?.() ?? { status: "not-found" };
1976
+ switch (result.status) {
1977
+ case "seeded":
1978
+ ctx.notice(
1979
+ "success",
1980
+ `task memory seeded ${result.seeded} entr${result.seeded === 1 ? "y" : "ies"} from ${result.source}${result.skipped > 0 ? `; skipped ${result.skipped} duplicate${result.skipped === 1 ? "" : "s"}` : ""}`
1981
+ );
1982
+ return;
1983
+ case "disabled":
1984
+ ctx.notice("warn", "task memory is disabled; enable memory.intervention before seeding");
1985
+ return;
1986
+ case "not-found":
1987
+ ctx.notice("info", "no structured task-memory snapshot found in the newest handoff");
1988
+ }
1989
+ }
1990
+ },
1991
+ {
1992
+ name: "view",
1993
+ description: "Browse session artifacts and verify receipts",
1994
+ group: "Inspect",
1995
+ kinds: ["view", "view-verify", "view-usage"],
1996
+ args: {
1997
+ positionals: [{ name: "filter", required: false, rest: true }],
1998
+ subcommands: {
1999
+ verify: {
2000
+ positionals: [{ name: "runId", required: true }]
2001
+ }
2002
+ }
2003
+ },
2004
+ fromArgs(parsed) {
2005
+ if (parsed.error) return { kind: "view-usage" };
2006
+ if (parsed.subcommand === "verify") {
2007
+ const runId = parsed.positionals[0] ?? "";
2008
+ return { kind: "view-verify", runId };
2009
+ }
2010
+ return parsed.rest ? { kind: "view", filter: parsed.rest } : { kind: "view" };
2011
+ },
2012
+ handle(command, ctx) {
2013
+ const entry = BUILTIN_SLASH_COMMANDS.find((e) => e.name === "view");
2014
+ if (!entry) return;
2015
+ if (command.kind === "view") {
2016
+ ctx.openView(command.filter);
2017
+ return;
2018
+ }
2019
+ if (command.kind === "view-usage") {
2020
+ ctx.notice("info", usageNotice(entry, "verify"));
2021
+ return;
2022
+ }
2023
+ if (command.kind !== "view-verify") return;
2024
+ const result = ctx.verifyReceipt(command.runId);
2025
+ const block = formatReceiptVerificationBlock(command.runId, result);
2026
+ if (result.ok) {
2027
+ ctx.notice(result.compromised ? "warn" : "success", block);
2028
+ } else if (result.retired !== void 0) {
2029
+ ctx.notice("warn", block);
2030
+ } else {
2031
+ ctx.notice("error", block);
2032
+ }
2033
+ }
2034
+ },
2035
+ {
2036
+ name: "panes",
2037
+ description: "Inspect the pane layer, watch a live run in a pane, or open a utility pane",
2038
+ group: "Inspect",
2039
+ kinds: ["panes", "panes-show", "panes-open", "panes-close", "panes-usage"],
2040
+ args: {
2041
+ subcommands: {
2042
+ show: { positionals: [{ name: "run-or-agent", required: true }] },
2043
+ // A rest positional, so an argv pane keeps its own flags: the parser
2044
+ // would otherwise refuse `--follow` as an unknown flag of `/panes`.
2045
+ open: { positionals: [{ name: "preset-or-argv", required: true, rest: true }] },
2046
+ close: { positionals: [{ name: "target", required: false }] }
2047
+ }
2048
+ },
2049
+ subcommandDescriptions: {
2050
+ show: "watch a live run or agent in the watch pane",
2051
+ open: `open a utility pane (${PANES_PRESET_IDS.join(", ")}, or a command)`,
2052
+ close: "close a Clio-owned pane, or all of them"
2053
+ },
2054
+ fromArgs(parsed) {
2055
+ if (parsed.error) return { kind: "panes-usage", reason: parsed.error };
2056
+ if (parsed.subcommand === "show") {
2057
+ return { kind: "panes-show", target: parsed.positionals[0] ?? "" };
2058
+ }
2059
+ if (parsed.subcommand === "open") {
2060
+ const rest = (parsed.rest ?? "").trim();
2061
+ if (rest.length === 0) return { kind: "panes-usage", reason: "Missing required argument: preset-or-argv" };
2062
+ const argv = rest.split(/\s+/).filter((token) => token.length > 0);
2063
+ const first = argv[0] ?? "";
2064
+ if (argv.length === 1 && isPanesPresetId(first)) return { kind: "panes-open", preset: first };
2065
+ if (argv.length === 2 && first === "yazi" && argv[1] === "--once") {
2066
+ return { kind: "panes-open", preset: "yazi", once: true };
2067
+ }
2068
+ return { kind: "panes-open", argv };
2069
+ }
2070
+ if (parsed.subcommand === "close") {
2071
+ return { kind: "panes-close", target: parsed.positionals[0] ?? "all" };
2072
+ }
2073
+ if (parsed.positionals.length > 0) {
2074
+ return { kind: "panes-usage", reason: `Unexpected argument: ${parsed.positionals[0]}` };
2075
+ }
2076
+ return { kind: "panes" };
2077
+ },
2078
+ handle(command, ctx) {
2079
+ const entry = BUILTIN_SLASH_COMMANDS.find((candidate) => candidate.name === "panes");
2080
+ if (command.kind === "panes-usage") {
2081
+ if (entry) ctx.notice("info", command.reason ? `${command.reason}
2082
+ ${usageNotice(entry)}` : usageNotice(entry));
2083
+ return;
2084
+ }
2085
+ const panes = ctx.panes;
2086
+ if (!panes) {
2087
+ ctx.notice(
2088
+ "info",
2089
+ "panes are inactive: this session started without them. Restart with `clio-coder --with-panes`, or set panes.enabled=auto"
2090
+ );
2091
+ return;
2092
+ }
2093
+ const runLocal = ctx.runLocalOperation ?? ((operation) => void operation());
2094
+ if (command.kind === "panes") {
2095
+ runLocal(async () => {
2096
+ for (const line of formatPanesStatus(panes.status())) ctx.io.stdout(`${line}
2097
+ `);
2098
+ ctx.render();
2099
+ });
2100
+ return;
2101
+ }
2102
+ if (command.kind === "panes-show") {
2103
+ runLocal(async () => {
2104
+ const result = await panes.show(command.target);
2105
+ if (result.status === "watching") {
2106
+ ctx.notice("success", `watching ${result.agentId} (${result.runId})${result.opened ? " in a new pane" : ""}`);
2107
+ } else if (result.status === "not-found") {
2108
+ const known = result.candidates.length > 0 ? `; live runs: ${result.candidates.join(", ")}` : "";
2109
+ ctx.notice("warn", `no live run matches ${result.target}${known}`);
2110
+ } else {
2111
+ ctx.notice("warn", result.reason);
2112
+ }
2113
+ });
2114
+ return;
2115
+ }
2116
+ if (command.kind === "panes-open") {
2117
+ runLocal(async () => {
2118
+ const result = await panes.open({
2119
+ ...command.preset ? { preset: command.preset } : {},
2120
+ ...command.argv ? { argv: command.argv } : {},
2121
+ ...command.once ? { once: true } : {}
2122
+ });
2123
+ if (result.status === "opened") {
2124
+ if (result.paneId !== null) ctx.notice("success", `opened pane ${result.label} (${result.paneId})`);
2125
+ } else if (result.status === "missing-binary") {
2126
+ ctx.io.stdout(`${result.detail}
2127
+ `);
2128
+ ctx.render();
2129
+ } else {
2130
+ ctx.notice("warn", result.reason);
2131
+ }
2132
+ });
2133
+ return;
2134
+ }
2135
+ if (command.kind !== "panes-close") return;
2136
+ runLocal(async () => {
2137
+ const result = await panes.close(command.target);
2138
+ if (result.status === "closed") {
2139
+ const what = result.labels.length > 0 ? `: ${result.labels.join(", ")}` : "";
2140
+ ctx.notice(result.closed > 0 ? "success" : "info", `closed ${result.closed} pane(s)${what}`);
2141
+ } else if (result.status === "not-found") {
2142
+ ctx.notice("warn", `no Clio-owned pane matches ${result.target}`);
2143
+ } else {
2144
+ ctx.notice("warn", result.reason);
2145
+ }
2146
+ });
2147
+ }
2148
+ },
2149
+ {
2150
+ name: "thinking",
2151
+ description: "Set the chat thinking level, or open Settings \u2192 Orchestrator",
2152
+ group: "Configure",
2153
+ kinds: ["thinking-set"],
2154
+ args: { positionals: [{ name: "level", required: false }] },
2155
+ fromArgs(parsed) {
2156
+ if (parsed.error) return { kind: "usage-error", command: "thinking", reason: parsed.error };
2157
+ const level = parsed.positionals[0];
2158
+ return level ? { kind: "thinking-set", level } : { kind: "settings", section: "orchestrator", rowId: "orchestrator.thinkingLevel" };
2159
+ },
2160
+ handle(command, ctx) {
2161
+ if (command.kind !== "thinking-set") return;
2162
+ const result = ctx.setThinkingLevel?.(command.level) ?? { status: "unavailable" };
2163
+ if (result.status === "applied") {
2164
+ ctx.notice("success", `thinking: ${result.display}`);
2165
+ } else if (result.status === "unsupported") {
2166
+ ctx.notice("error", `thinking level "${result.level}" is not available here; try ${result.supported.join(", ")}`);
2167
+ } else {
2168
+ ctx.notice("error", "thinking level cannot be set right now");
2169
+ }
2170
+ ctx.render();
2171
+ }
2172
+ },
2173
+ {
2174
+ name: "output",
2175
+ description: "Set transcript detail (minimal, default, verbose), or open Settings \u2192 Terminal",
2176
+ group: "Configure",
2177
+ kinds: ["output-set"],
2178
+ args: { positionals: [{ name: "verbosity", required: false }] },
2179
+ fromArgs(parsed) {
2180
+ if (parsed.error) return { kind: "usage-error", command: "output", reason: parsed.error };
2181
+ const verbosity = parsed.positionals[0];
2182
+ return verbosity ? { kind: "output-set", verbosity } : { kind: "settings", section: "terminal", rowId: "terminal.outputVerbosity" };
2183
+ },
2184
+ handle(command, ctx) {
2185
+ if (command.kind !== "output-set") return;
2186
+ const result = ctx.setOutputVerbosity?.(command.verbosity) ?? { status: "unavailable" };
2187
+ if (result.status === "applied") {
2188
+ ctx.notice("success", `output detail: ${result.verbosity}`);
2189
+ } else if (result.status === "unsupported") {
2190
+ ctx.notice("error", `output detail "${result.verbosity}" is not one of ${result.supported.join(", ")}`);
2191
+ } else {
2192
+ ctx.notice("error", "output detail cannot be set right now");
2193
+ }
2194
+ ctx.render();
2195
+ }
2196
+ },
2197
+ {
2198
+ name: "model",
2199
+ description: "Open model selector or set a model",
2200
+ group: "Configure",
2201
+ kinds: ["model", "model-set"],
2202
+ args: {
2203
+ positionals: [{ name: "pattern", required: false, rest: true }]
2204
+ },
2205
+ fromArgs(parsed) {
2206
+ const pattern = parsed.positionals[0];
2207
+ if (pattern) {
2208
+ return { kind: "model-set", pattern };
2209
+ }
2210
+ return { kind: "model" };
2211
+ },
2212
+ handle(command, ctx) {
2213
+ if (command.kind === "model") {
2214
+ ctx.openModel();
2215
+ return;
2216
+ }
2217
+ if (command.kind !== "model-set") return;
2218
+ void (async () => {
2219
+ try {
2220
+ await ctx.providers.probeAllLive();
2221
+ } catch (err) {
2222
+ const msg = err instanceof Error ? err.message : String(err);
2223
+ ctx.notice("warn", `model refresh failed; resolving cached catalog: ${msg}`);
2224
+ }
2225
+ const result = resolveModelReference(command.pattern, ctx.providers);
2226
+ if (!result.ref) {
2227
+ ctx.notice("error", result.error ?? `no match for "${command.pattern}"`);
2228
+ ctx.render();
2229
+ return;
2230
+ }
2231
+ if (result.warning) ctx.notice("warn", result.warning);
2232
+ if (ctx.applyModelRef(result.ref) === "applied") {
2233
+ const suffix = result.ref.thinkingLevel ? ` thinking=${result.ref.thinkingLevel}` : "";
2234
+ ctx.notice("success", `active this session: ${result.ref.target}/${result.ref.model}${suffix}`);
2235
+ }
2236
+ ctx.render();
2237
+ })();
2238
+ }
2239
+ },
2240
+ settingsDeepLink(
2241
+ "scoped-models",
2242
+ "models",
2243
+ "Open Settings \u2192 Models: the Alt+J / Alt+K cycle set and favorites",
2244
+ "scope"
2245
+ ),
2246
+ {
2247
+ name: "settings",
2248
+ description: "Open interactive settings",
2249
+ group: "Configure",
2250
+ kinds: ["settings"],
2251
+ args: { positionals: [{ name: "section", required: false }] },
2252
+ fromArgs(parsed) {
2253
+ if (parsed.error) return { kind: "usage-error", command: "settings", reason: parsed.error };
2254
+ const section = parsed.positionals[0];
2255
+ if (section === void 0) return { kind: "settings" };
2256
+ if (!isSettingsSectionId(section)) {
2257
+ const known = SETTINGS_SECTIONS.map((entry) => entry.id).join(", ");
2258
+ return { kind: "usage-error", command: "settings", reason: `Unknown section: ${section} (one of ${known})` };
2259
+ }
2260
+ return { kind: "settings", section };
2261
+ },
2262
+ handle(command, ctx) {
2263
+ if (command.kind === "settings") ctx.openSettings(command.section, command.rowId);
2264
+ }
2265
+ },
2266
+ {
2267
+ name: "resume",
2268
+ description: "Resume a past session",
2269
+ group: "Sessions",
2270
+ kinds: ["resume"],
2271
+ args: {},
2272
+ fromArgs: fromArgsOrUsage("resume", { kind: "resume" }),
2273
+ handle(_command, ctx) {
2274
+ ctx.openResume();
2275
+ }
2276
+ },
2277
+ {
2278
+ name: "new",
2279
+ description: "Start a fresh session",
2280
+ group: "Sessions",
2281
+ kinds: ["new"],
2282
+ args: {},
2283
+ fromArgs: fromArgsOrUsage("new", { kind: "new" }),
2284
+ handle(_command, ctx) {
2285
+ ctx.startNewSession();
2286
+ }
2287
+ },
2288
+ {
2289
+ name: "handoff",
2290
+ description: "Hand this session's working state to a fresh session for a stated goal",
2291
+ group: "Sessions",
2292
+ kinds: ["handoff", "handoff-usage"],
2293
+ args: {
2294
+ positionals: [{ name: "goal", required: true, rest: true }]
2295
+ },
2296
+ fromArgs(parsed) {
2297
+ const goal = parsed.rest?.trim() ?? "";
2298
+ if (parsed.error || goal.length === 0) return { kind: "handoff-usage" };
2299
+ return { kind: "handoff", goal };
2300
+ },
2301
+ handle(command, ctx) {
2302
+ if (command.kind === "handoff-usage") {
2303
+ const entry = BUILTIN_SLASH_COMMANDS.find((candidate) => candidate.name === "handoff");
2304
+ if (entry) ctx.notice("info", usageNotice(entry));
2305
+ return;
2306
+ }
2307
+ if (command.kind !== "handoff") return;
2308
+ ctx.startHandoff(command.goal);
2309
+ }
2310
+ },
2311
+ {
2312
+ name: "tree",
2313
+ description: "Open session tree navigator",
2314
+ group: "Sessions",
2315
+ kinds: ["tree"],
2316
+ args: {},
2317
+ fromArgs: fromArgsOrUsage("tree", { kind: "tree" }),
2318
+ handle(_command, ctx) {
2319
+ ctx.openTree();
2320
+ }
2321
+ },
2322
+ {
2323
+ name: "fork",
2324
+ description: "Fork from an assistant turn",
2325
+ group: "Sessions",
2326
+ kinds: ["fork"],
2327
+ args: {},
2328
+ fromArgs: fromArgsOrUsage("fork", { kind: "fork" }),
2329
+ handle(_command, ctx) {
2330
+ ctx.openMessagePicker();
2331
+ }
2332
+ },
2333
+ {
2334
+ name: "export",
2335
+ description: "Export a self-contained HTML transcript by default; a .md path writes Markdown",
2336
+ group: "Sessions",
2337
+ kinds: ["export"],
2338
+ args: {
2339
+ positionals: [{ name: "path", required: false }]
2340
+ },
2341
+ fromArgs(parsed) {
2342
+ if (parsed.error) return { kind: "usage-error", command: "export", reason: parsed.error };
2343
+ return { kind: "export", path: parsed.positionals[0] };
2344
+ },
2345
+ handle(command, ctx) {
2346
+ if (command.kind !== "export") return;
2347
+ ctx.exportTranscript(command.path);
2348
+ }
2349
+ }
2350
+ ];
2351
+ var HANDLER_BY_KIND = /* @__PURE__ */ new Map();
2352
+ var COMMAND_NAMES = /* @__PURE__ */ new Set();
2353
+ for (const entry of BUILTIN_SLASH_COMMANDS) {
2354
+ if (COMMAND_NAMES.has(entry.name)) {
2355
+ throw new Error(`BUILTIN_SLASH_COMMANDS: command name "${entry.name}" is registered more than once`);
2356
+ }
2357
+ COMMAND_NAMES.add(entry.name);
2358
+ for (const kind of entry.kinds) {
2359
+ if (HANDLER_BY_KIND.has(kind)) {
2360
+ throw new Error(`BUILTIN_SLASH_COMMANDS: kind "${kind}" is owned by multiple entries`);
2361
+ }
2362
+ HANDLER_BY_KIND.set(kind, entry);
2363
+ }
2364
+ }
2365
+ var COMMAND_SHAPED_TOKEN = /^[A-Za-z][A-Za-z0-9:-]*$/u;
2366
+ var COMMAND_ESCAPE = "\\/";
2367
+ function parseSlashCommand(input) {
2368
+ const trimmed = input.trim();
2369
+ if (trimmed.length === 0) return { kind: "empty" };
2370
+ if (trimmed.startsWith(COMMAND_ESCAPE)) return { kind: "unknown", text: trimmed.slice(1) };
2371
+ for (const entry of BUILTIN_SLASH_COMMANDS) {
2372
+ const match = entry.match ? entry.match(trimmed) : matchFromSpec(entry, trimmed);
2373
+ if (match) return match;
2374
+ }
2375
+ if (trimmed.startsWith("/")) {
2376
+ const token = trimmed.slice(1).split(/\s+/u)[0] ?? "";
2377
+ if (COMMAND_SHAPED_TOKEN.test(token)) return { kind: "unknown-command", token, text: trimmed };
2378
+ }
2379
+ return { kind: "unknown", text: trimmed };
2380
+ }
2381
+ function dispatchSlashCommand(command, ctx) {
2382
+ if (command.kind === "empty") return "rejected";
2383
+ if (command.kind === "unknown") {
2384
+ ctx.submitChat(command.text);
2385
+ return "accepted";
2386
+ }
2387
+ if (command.kind === "unknown-command") {
2388
+ const expansion = ctx.expandPromptTemplate?.(command.text);
2389
+ if (expansion?.expanded === true) {
2390
+ ctx.submitChat(command.text);
2391
+ return "accepted";
2392
+ }
2393
+ const refusal = expansion?.expanded === false ? expansion.refusal : void 0;
2394
+ ctx.notice("error", refusal ? refusal.message : `/${command.token} is not a command. Type /help for the list.`);
2395
+ ctx.render();
2396
+ return "rejected";
2397
+ }
2398
+ if (command.kind === "usage-error") {
2399
+ const entry2 = BUILTIN_SLASH_COMMANDS.find((candidate) => candidate.name === command.command);
2400
+ const usage = entry2 ? ` ${usageNotice(entry2)}` : "";
2401
+ ctx.notice("error", `${command.reason}.${usage}`);
2402
+ ctx.render();
2403
+ return "rejected";
2404
+ }
2405
+ const entry = HANDLER_BY_KIND.get(command.kind);
2406
+ if (!entry) return "rejected";
2407
+ entry.handle(command, ctx);
2408
+ return "accepted";
2409
+ }
2410
+ function commandReference() {
2411
+ return BUILTIN_SLASH_COMMANDS.filter((entry) => entry.hidden !== true).map((entry) => {
2412
+ const usage = usageLine(entry).replace(/^\nusage:\s*/, "").replace(/\n$/, "");
2413
+ return {
2414
+ name: entry.name,
2415
+ usage,
2416
+ description: entry.description,
2417
+ group: entry.group,
2418
+ ...entry.args ? { args: entry.args } : {},
2419
+ ...entry.subcommandDescriptions ? { subcommandDescriptions: entry.subcommandDescriptions } : {}
2420
+ };
2421
+ });
2422
+ }
2423
+
2424
+ export {
2425
+ COUNCIL_SYNTHESIS_LABEL,
2426
+ boundSettledText,
2427
+ createWorkerProgressFold,
2428
+ workerAskedByModel,
2429
+ workerTargetLabel,
2430
+ workerReceiptSummary,
2431
+ createWorkerStream,
2432
+ isWorkerShareNote,
2433
+ LIBRARY_TABS,
2434
+ SETTINGS_SECTIONS,
2435
+ renderArgsSpec,
2436
+ completeArgs,
2437
+ handleRun,
2438
+ formatReceiptVerificationBlock,
2439
+ formatUserTaskHandoff,
2440
+ SLASH_COMMAND_GROUPS,
2441
+ formatPanesStatus,
2442
+ BUILTIN_SLASH_COMMANDS,
2443
+ parseSlashCommand,
2444
+ dispatchSlashCommand,
2445
+ commandReference
2446
+ };
2447
+ //# sourceMappingURL=chunk-C2LTL2W6.js.map