@cotal-ai/cli 0.90.1 → 0.91.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 (759) hide show
  1. package/dist/chat/chat-view.d.ts +17 -0
  2. package/dist/chat/chat-view.d.ts.map +1 -0
  3. package/dist/chat/chat-view.js +179 -0
  4. package/dist/chat/chat-view.js.map +1 -0
  5. package/dist/chat/controller.d.ts +19 -0
  6. package/dist/chat/controller.d.ts.map +1 -0
  7. package/dist/chat/controller.js +116 -0
  8. package/dist/chat/controller.js.map +1 -0
  9. package/dist/chat/engine.d.ts +108 -0
  10. package/dist/chat/engine.d.ts.map +1 -0
  11. package/dist/chat/engine.js +226 -0
  12. package/dist/chat/engine.js.map +1 -0
  13. package/dist/chat/frontend.d.ts +35 -0
  14. package/dist/chat/frontend.d.ts.map +1 -0
  15. package/dist/chat/frontend.js +151 -0
  16. package/dist/chat/frontend.js.map +1 -0
  17. package/dist/chat/native-session.d.ts +71 -0
  18. package/dist/chat/native-session.d.ts.map +1 -0
  19. package/dist/chat/native-session.js +348 -0
  20. package/dist/chat/native-session.js.map +1 -0
  21. package/dist/chat/open-session.d.ts +8 -0
  22. package/dist/chat/open-session.d.ts.map +1 -0
  23. package/dist/chat/open-session.js +120 -0
  24. package/dist/chat/open-session.js.map +1 -0
  25. package/dist/chat/picker.d.ts +34 -0
  26. package/dist/chat/picker.d.ts.map +1 -0
  27. package/dist/chat/picker.js +97 -0
  28. package/dist/chat/picker.js.map +1 -0
  29. package/dist/chat/plain.d.ts +15 -0
  30. package/dist/chat/plain.d.ts.map +1 -0
  31. package/dist/chat/plain.js +242 -0
  32. package/dist/chat/plain.js.map +1 -0
  33. package/dist/chat/session.d.ts +217 -0
  34. package/dist/chat/session.d.ts.map +1 -0
  35. package/dist/chat/session.js +2 -0
  36. package/dist/chat/session.js.map +1 -0
  37. package/dist/chat/static-session.d.ts +61 -0
  38. package/dist/chat/static-session.d.ts.map +1 -0
  39. package/dist/chat/static-session.js +212 -0
  40. package/dist/chat/static-session.js.map +1 -0
  41. package/dist/chat/stdio-io.d.ts +34 -0
  42. package/dist/chat/stdio-io.d.ts.map +1 -0
  43. package/dist/chat/stdio-io.js +175 -0
  44. package/dist/chat/stdio-io.js.map +1 -0
  45. package/dist/chat/stdio.d.ts +173 -0
  46. package/dist/chat/stdio.d.ts.map +1 -0
  47. package/dist/chat/stdio.js +400 -0
  48. package/dist/chat/stdio.js.map +1 -0
  49. package/dist/chat/user-session.d.ts +21 -0
  50. package/dist/chat/user-session.d.ts.map +1 -0
  51. package/dist/chat/user-session.js +180 -0
  52. package/dist/chat/user-session.js.map +1 -0
  53. package/dist/chat/view.d.ts +186 -0
  54. package/dist/chat/view.d.ts.map +1 -0
  55. package/dist/chat/view.js +386 -0
  56. package/dist/chat/view.js.map +1 -0
  57. package/dist/command.d.ts +11 -3
  58. package/dist/command.d.ts.map +1 -1
  59. package/dist/command.js +392 -147
  60. package/dist/command.js.map +1 -1
  61. package/dist/commands/agents.d.ts +103 -11
  62. package/dist/commands/agents.d.ts.map +1 -1
  63. package/dist/commands/agents.js +501 -251
  64. package/dist/commands/agents.js.map +1 -1
  65. package/dist/commands/app-identity.d.ts.map +1 -1
  66. package/dist/commands/app-identity.js +10 -1
  67. package/dist/commands/app-identity.js.map +1 -1
  68. package/dist/commands/backup-maintenance.d.ts +4 -0
  69. package/dist/commands/backup-maintenance.d.ts.map +1 -0
  70. package/dist/commands/backup-maintenance.js +92 -0
  71. package/dist/commands/backup-maintenance.js.map +1 -0
  72. package/dist/commands/backup-read.d.ts +4 -0
  73. package/dist/commands/backup-read.d.ts.map +1 -0
  74. package/dist/commands/backup-read.js +27 -0
  75. package/dist/commands/backup-read.js.map +1 -0
  76. package/dist/commands/backup-restore.d.ts +7 -0
  77. package/dist/commands/backup-restore.d.ts.map +1 -0
  78. package/dist/commands/backup-restore.js +81 -0
  79. package/dist/commands/backup-restore.js.map +1 -0
  80. package/dist/commands/backup.d.ts +2 -1
  81. package/dist/commands/backup.d.ts.map +1 -1
  82. package/dist/commands/backup.js +102 -24
  83. package/dist/commands/backup.js.map +1 -1
  84. package/dist/commands/channel-members.d.ts +8 -0
  85. package/dist/commands/channel-members.d.ts.map +1 -0
  86. package/dist/commands/channel-members.js +144 -0
  87. package/dist/commands/channel-members.js.map +1 -0
  88. package/dist/commands/channels.d.ts +75 -22
  89. package/dist/commands/channels.d.ts.map +1 -1
  90. package/dist/commands/channels.js +181 -100
  91. package/dist/commands/channels.js.map +1 -1
  92. package/dist/commands/chat.d.ts +109 -0
  93. package/dist/commands/chat.d.ts.map +1 -0
  94. package/dist/commands/chat.js +227 -0
  95. package/dist/commands/chat.js.map +1 -0
  96. package/dist/commands/clean.d.ts +43 -1
  97. package/dist/commands/clean.d.ts.map +1 -1
  98. package/dist/commands/clean.js +90 -47
  99. package/dist/commands/clean.js.map +1 -1
  100. package/dist/commands/completion.d.ts +39 -1
  101. package/dist/commands/completion.d.ts.map +1 -1
  102. package/dist/commands/completion.js +211 -87
  103. package/dist/commands/completion.js.map +1 -1
  104. package/dist/commands/config.d.ts +33 -0
  105. package/dist/commands/config.d.ts.map +1 -0
  106. package/dist/commands/config.js +159 -0
  107. package/dist/commands/config.js.map +1 -0
  108. package/dist/commands/console.d.ts.map +1 -1
  109. package/dist/commands/console.js +25 -7
  110. package/dist/commands/console.js.map +1 -1
  111. package/dist/commands/describe.d.ts +63 -31
  112. package/dist/commands/describe.d.ts.map +1 -1
  113. package/dist/commands/describe.js +264 -136
  114. package/dist/commands/describe.js.map +1 -1
  115. package/dist/commands/doctor.d.ts +11 -6
  116. package/dist/commands/doctor.d.ts.map +1 -1
  117. package/dist/commands/doctor.js +195 -288
  118. package/dist/commands/doctor.js.map +1 -1
  119. package/dist/commands/down-services.d.ts +29 -0
  120. package/dist/commands/down-services.d.ts.map +1 -0
  121. package/dist/commands/down-services.js +129 -0
  122. package/dist/commands/down-services.js.map +1 -0
  123. package/dist/commands/down.d.ts +37 -11
  124. package/dist/commands/down.d.ts.map +1 -1
  125. package/dist/commands/down.js +276 -115
  126. package/dist/commands/down.js.map +1 -1
  127. package/dist/commands/endpoint-authoring.d.ts +4 -0
  128. package/dist/commands/endpoint-authoring.d.ts.map +1 -0
  129. package/dist/commands/endpoint-authoring.js +125 -0
  130. package/dist/commands/endpoint-authoring.js.map +1 -0
  131. package/dist/commands/endpoint-deregister.d.ts +5 -0
  132. package/dist/commands/endpoint-deregister.d.ts.map +1 -0
  133. package/dist/commands/endpoint-deregister.js +70 -0
  134. package/dist/commands/endpoint-deregister.js.map +1 -0
  135. package/dist/commands/endpoint.d.ts +118 -0
  136. package/dist/commands/endpoint.d.ts.map +1 -0
  137. package/dist/commands/endpoint.js +177 -0
  138. package/dist/commands/endpoint.js.map +1 -0
  139. package/dist/commands/endpoints.d.ts +27 -1
  140. package/dist/commands/endpoints.d.ts.map +1 -1
  141. package/dist/commands/endpoints.js +42 -30
  142. package/dist/commands/endpoints.js.map +1 -1
  143. package/dist/commands/ext.d.ts +38 -1
  144. package/dist/commands/ext.d.ts.map +1 -1
  145. package/dist/commands/ext.js +84 -49
  146. package/dist/commands/ext.js.map +1 -1
  147. package/dist/commands/feedback.d.ts +58 -1
  148. package/dist/commands/feedback.d.ts.map +1 -1
  149. package/dist/commands/feedback.js +119 -47
  150. package/dist/commands/feedback.js.map +1 -1
  151. package/dist/commands/help.d.ts +20 -0
  152. package/dist/commands/help.d.ts.map +1 -0
  153. package/dist/commands/help.js +52 -0
  154. package/dist/commands/help.js.map +1 -0
  155. package/dist/commands/history-clear.d.ts +14 -0
  156. package/dist/commands/history-clear.d.ts.map +1 -0
  157. package/dist/commands/history-clear.js +73 -0
  158. package/dist/commands/history-clear.js.map +1 -0
  159. package/dist/commands/history.d.ts +146 -4
  160. package/dist/commands/history.d.ts.map +1 -1
  161. package/dist/commands/history.js +443 -19
  162. package/dist/commands/history.js.map +1 -1
  163. package/dist/commands/join.d.ts.map +1 -1
  164. package/dist/commands/join.js +7 -3
  165. package/dist/commands/join.js.map +1 -1
  166. package/dist/commands/meshes-add.d.ts +3 -0
  167. package/dist/commands/meshes-add.d.ts.map +1 -1
  168. package/dist/commands/meshes-add.js +41 -34
  169. package/dist/commands/meshes-add.js.map +1 -1
  170. package/dist/commands/meshes-wizard.js +3 -3
  171. package/dist/commands/meshes-wizard.js.map +1 -1
  172. package/dist/commands/mint-endpoint-caller.d.ts +5 -0
  173. package/dist/commands/mint-endpoint-caller.d.ts.map +1 -0
  174. package/dist/commands/mint-endpoint-caller.js +130 -0
  175. package/dist/commands/mint-endpoint-caller.js.map +1 -0
  176. package/dist/commands/mint.d.ts +2 -37
  177. package/dist/commands/mint.d.ts.map +1 -1
  178. package/dist/commands/mint.js +142 -325
  179. package/dist/commands/mint.js.map +1 -1
  180. package/dist/commands/models.d.ts +30 -8
  181. package/dist/commands/models.d.ts.map +1 -1
  182. package/dist/commands/models.js +72 -41
  183. package/dist/commands/models.js.map +1 -1
  184. package/dist/commands/persona-remote.d.ts +5 -0
  185. package/dist/commands/persona-remote.d.ts.map +1 -0
  186. package/dist/commands/persona-remote.js +237 -0
  187. package/dist/commands/persona-remote.js.map +1 -0
  188. package/dist/commands/persona.d.ts +91 -0
  189. package/dist/commands/persona.d.ts.map +1 -0
  190. package/dist/commands/persona.js +200 -0
  191. package/dist/commands/persona.js.map +1 -0
  192. package/dist/commands/personas.d.ts.map +1 -1
  193. package/dist/commands/personas.js +16 -59
  194. package/dist/commands/personas.js.map +1 -1
  195. package/dist/commands/reset-space-apply.d.ts +5 -0
  196. package/dist/commands/reset-space-apply.d.ts.map +1 -0
  197. package/dist/commands/reset-space-apply.js +140 -0
  198. package/dist/commands/reset-space-apply.js.map +1 -0
  199. package/dist/commands/reset-store-apply.d.ts +11 -0
  200. package/dist/commands/reset-store-apply.d.ts.map +1 -0
  201. package/dist/commands/reset-store-apply.js +154 -0
  202. package/dist/commands/reset-store-apply.js.map +1 -0
  203. package/dist/commands/reset.d.ts +26 -0
  204. package/dist/commands/reset.d.ts.map +1 -0
  205. package/dist/commands/reset.js +143 -0
  206. package/dist/commands/reset.js.map +1 -0
  207. package/dist/commands/runtimes.d.ts +26 -1
  208. package/dist/commands/runtimes.d.ts.map +1 -1
  209. package/dist/commands/runtimes.js +68 -32
  210. package/dist/commands/runtimes.js.map +1 -1
  211. package/dist/commands/send.d.ts +91 -6
  212. package/dist/commands/send.d.ts.map +1 -1
  213. package/dist/commands/send.js +180 -106
  214. package/dist/commands/send.js.map +1 -1
  215. package/dist/commands/service-actions.d.ts +6 -0
  216. package/dist/commands/service-actions.d.ts.map +1 -0
  217. package/dist/commands/service-actions.js +405 -0
  218. package/dist/commands/service-actions.js.map +1 -0
  219. package/dist/commands/service-log-follow.d.ts +5 -0
  220. package/dist/commands/service-log-follow.d.ts.map +1 -0
  221. package/dist/commands/service-log-follow.js +106 -0
  222. package/dist/commands/service-log-follow.js.map +1 -0
  223. package/dist/commands/service-registry.d.ts +67 -0
  224. package/dist/commands/service-registry.d.ts.map +1 -0
  225. package/dist/commands/service-registry.js +275 -0
  226. package/dist/commands/service-registry.js.map +1 -0
  227. package/dist/commands/service-set-stop.d.ts +6 -0
  228. package/dist/commands/service-set-stop.d.ts.map +1 -0
  229. package/dist/commands/service-set-stop.js +161 -0
  230. package/dist/commands/service-set-stop.js.map +1 -0
  231. package/dist/commands/service-unit-entry.d.ts +5 -0
  232. package/dist/commands/service-unit-entry.d.ts.map +1 -0
  233. package/dist/commands/service-unit-entry.js +113 -0
  234. package/dist/commands/service-unit-entry.js.map +1 -0
  235. package/dist/commands/setup-start.d.ts +21 -0
  236. package/dist/commands/setup-start.d.ts.map +1 -0
  237. package/dist/commands/setup-start.js +95 -0
  238. package/dist/commands/setup-start.js.map +1 -0
  239. package/dist/commands/setup.d.ts +86 -100
  240. package/dist/commands/setup.d.ts.map +1 -1
  241. package/dist/commands/setup.js +766 -487
  242. package/dist/commands/setup.js.map +1 -1
  243. package/dist/commands/space-delete.d.ts +3 -0
  244. package/dist/commands/space-delete.d.ts.map +1 -0
  245. package/dist/commands/space-delete.js +341 -0
  246. package/dist/commands/space-delete.js.map +1 -0
  247. package/dist/commands/space-registration.d.ts +92 -0
  248. package/dist/commands/space-registration.d.ts.map +1 -0
  249. package/dist/commands/space-registration.js +388 -0
  250. package/dist/commands/space-registration.js.map +1 -0
  251. package/dist/commands/space.d.ts +128 -0
  252. package/dist/commands/space.d.ts.map +1 -0
  253. package/dist/commands/space.js +230 -0
  254. package/dist/commands/space.js.map +1 -0
  255. package/dist/commands/spawn-manifest.d.ts.map +1 -1
  256. package/dist/commands/spawn-manifest.js +2 -2
  257. package/dist/commands/spawn-manifest.js.map +1 -1
  258. package/dist/commands/spawn-preview.d.ts +9 -0
  259. package/dist/commands/spawn-preview.d.ts.map +1 -0
  260. package/dist/commands/spawn-preview.js +68 -0
  261. package/dist/commands/spawn-preview.js.map +1 -0
  262. package/dist/commands/spawn.d.ts +78 -18
  263. package/dist/commands/spawn.d.ts.map +1 -1
  264. package/dist/commands/spawn.js +236 -96
  265. package/dist/commands/spawn.js.map +1 -1
  266. package/dist/commands/stack-down.d.ts +6 -0
  267. package/dist/commands/stack-down.d.ts.map +1 -0
  268. package/dist/commands/stack-down.js +206 -0
  269. package/dist/commands/stack-down.js.map +1 -0
  270. package/dist/commands/stack-up.d.ts +149 -0
  271. package/dist/commands/stack-up.d.ts.map +1 -0
  272. package/dist/commands/stack-up.js +459 -0
  273. package/dist/commands/stack-up.js.map +1 -0
  274. package/dist/commands/stack-user-auth.d.ts +52 -0
  275. package/dist/commands/stack-user-auth.d.ts.map +1 -0
  276. package/dist/commands/stack-user-auth.js +128 -0
  277. package/dist/commands/stack-user-auth.js.map +1 -0
  278. package/dist/commands/status.d.ts +232 -5
  279. package/dist/commands/status.d.ts.map +1 -1
  280. package/dist/commands/status.js +989 -406
  281. package/dist/commands/status.js.map +1 -1
  282. package/dist/commands/sync.d.ts +23 -0
  283. package/dist/commands/sync.d.ts.map +1 -1
  284. package/dist/commands/sync.js +69 -17
  285. package/dist/commands/sync.js.map +1 -1
  286. package/dist/commands/team-agent-apply.d.ts +5 -0
  287. package/dist/commands/team-agent-apply.d.ts.map +1 -0
  288. package/dist/commands/team-agent-apply.js +204 -0
  289. package/dist/commands/team-agent-apply.js.map +1 -0
  290. package/dist/commands/team-agent-remove.d.ts +87 -0
  291. package/dist/commands/team-agent-remove.d.ts.map +1 -0
  292. package/dist/commands/team-agent-remove.js +348 -0
  293. package/dist/commands/team-agent-remove.js.map +1 -0
  294. package/dist/commands/team-boot-controller.d.ts +11 -0
  295. package/dist/commands/team-boot-controller.d.ts.map +1 -0
  296. package/dist/commands/team-boot-controller.js +176 -0
  297. package/dist/commands/team-boot-controller.js.map +1 -0
  298. package/dist/commands/team-channel-remove.d.ts +167 -0
  299. package/dist/commands/team-channel-remove.d.ts.map +1 -0
  300. package/dist/commands/team-channel-remove.js +486 -0
  301. package/dist/commands/team-channel-remove.js.map +1 -0
  302. package/dist/commands/team-deploy-apply.d.ts +11 -0
  303. package/dist/commands/team-deploy-apply.d.ts.map +1 -0
  304. package/dist/commands/team-deploy-apply.js +320 -0
  305. package/dist/commands/team-deploy-apply.js.map +1 -0
  306. package/dist/commands/team-mixed-remove.d.ts +8 -0
  307. package/dist/commands/team-mixed-remove.d.ts.map +1 -0
  308. package/dist/commands/team-mixed-remove.js +207 -0
  309. package/dist/commands/team-mixed-remove.js.map +1 -0
  310. package/dist/commands/team.d.ts +51 -0
  311. package/dist/commands/team.d.ts.map +1 -0
  312. package/dist/commands/team.js +727 -0
  313. package/dist/commands/team.js.map +1 -0
  314. package/dist/commands/topology.d.ts +4 -0
  315. package/dist/commands/topology.d.ts.map +1 -1
  316. package/dist/commands/topology.js +8 -0
  317. package/dist/commands/topology.js.map +1 -1
  318. package/dist/commands/up.d.ts +144 -5
  319. package/dist/commands/up.d.ts.map +1 -1
  320. package/dist/commands/up.js +1015 -124
  321. package/dist/commands/up.js.map +1 -1
  322. package/dist/commands/update.d.ts +11 -0
  323. package/dist/commands/update.d.ts.map +1 -1
  324. package/dist/commands/update.js +72 -15
  325. package/dist/commands/update.js.map +1 -1
  326. package/dist/commands/use.d.ts +16 -3
  327. package/dist/commands/use.d.ts.map +1 -1
  328. package/dist/commands/use.js +45 -19
  329. package/dist/commands/use.js.map +1 -1
  330. package/dist/commands/watch.d.ts +37 -0
  331. package/dist/commands/watch.d.ts.map +1 -0
  332. package/dist/commands/watch.js +106 -0
  333. package/dist/commands/watch.js.map +1 -0
  334. package/dist/commands/who.d.ts +79 -0
  335. package/dist/commands/who.d.ts.map +1 -0
  336. package/dist/commands/who.js +193 -0
  337. package/dist/commands/who.js.map +1 -0
  338. package/dist/commands/whoami.d.ts +56 -0
  339. package/dist/commands/whoami.d.ts.map +1 -0
  340. package/dist/commands/whoami.js +106 -0
  341. package/dist/commands/whoami.js.map +1 -0
  342. package/dist/console/app.d.ts.map +1 -1
  343. package/dist/console/app.js +8 -4
  344. package/dist/console/app.js.map +1 -1
  345. package/dist/console/commands.d.ts.map +1 -1
  346. package/dist/console/commands.js +12 -6
  347. package/dist/console/commands.js.map +1 -1
  348. package/dist/exec-endpoint/definition.d.ts +15 -0
  349. package/dist/exec-endpoint/definition.d.ts.map +1 -0
  350. package/dist/exec-endpoint/definition.js +56 -0
  351. package/dist/exec-endpoint/definition.js.map +1 -0
  352. package/dist/exec-endpoint/handler.d.ts +13 -0
  353. package/dist/exec-endpoint/handler.d.ts.map +1 -0
  354. package/dist/exec-endpoint/handler.js +155 -0
  355. package/dist/exec-endpoint/handler.js.map +1 -0
  356. package/dist/exec-endpoint/registration.d.ts +34 -0
  357. package/dist/exec-endpoint/registration.d.ts.map +1 -0
  358. package/dist/exec-endpoint/registration.js +148 -0
  359. package/dist/exec-endpoint/registration.js.map +1 -0
  360. package/dist/exec-endpoint/serve.d.ts +8 -0
  361. package/dist/exec-endpoint/serve.d.ts.map +1 -0
  362. package/dist/exec-endpoint/serve.js +159 -0
  363. package/dist/exec-endpoint/serve.js.map +1 -0
  364. package/dist/exec-endpoint/service-adapter.d.ts +6 -0
  365. package/dist/exec-endpoint/service-adapter.d.ts.map +1 -0
  366. package/dist/exec-endpoint/service-adapter.js +110 -0
  367. package/dist/exec-endpoint/service-adapter.js.map +1 -0
  368. package/dist/ext-loader.d.ts +10 -0
  369. package/dist/ext-loader.d.ts.map +1 -1
  370. package/dist/ext-loader.js +61 -13
  371. package/dist/ext-loader.js.map +1 -1
  372. package/dist/help.d.ts +18 -0
  373. package/dist/help.d.ts.map +1 -0
  374. package/dist/help.js +256 -0
  375. package/dist/help.js.map +1 -0
  376. package/dist/index.d.ts +2 -0
  377. package/dist/index.d.ts.map +1 -1
  378. package/dist/index.js +444 -118
  379. package/dist/index.js.map +1 -1
  380. package/dist/lib/assist.d.ts.map +1 -1
  381. package/dist/lib/assist.js +3 -2
  382. package/dist/lib/assist.js.map +1 -1
  383. package/dist/lib/attach-client.d.ts +7 -6
  384. package/dist/lib/attach-client.d.ts.map +1 -1
  385. package/dist/lib/attach-client.js +14 -15
  386. package/dist/lib/attach-client.js.map +1 -1
  387. package/dist/lib/auth-proc.d.ts +3 -3
  388. package/dist/lib/auth-proc.d.ts.map +1 -1
  389. package/dist/lib/auth-proc.js +8 -8
  390. package/dist/lib/auth-proc.js.map +1 -1
  391. package/dist/lib/backup-artifact.d.ts +34 -1
  392. package/dist/lib/backup-artifact.d.ts.map +1 -1
  393. package/dist/lib/backup-artifact.js +67 -17
  394. package/dist/lib/backup-artifact.js.map +1 -1
  395. package/dist/lib/broker-service.d.ts +10 -0
  396. package/dist/lib/broker-service.d.ts.map +1 -0
  397. package/dist/lib/broker-service.js +329 -0
  398. package/dist/lib/broker-service.js.map +1 -0
  399. package/dist/lib/cancel.js +1 -1
  400. package/dist/lib/cancel.js.map +1 -1
  401. package/dist/lib/choose-target.d.ts +10 -0
  402. package/dist/lib/choose-target.d.ts.map +1 -0
  403. package/dist/lib/choose-target.js +42 -0
  404. package/dist/lib/choose-target.js.map +1 -0
  405. package/dist/lib/command-path.d.ts +13 -0
  406. package/dist/lib/command-path.d.ts.map +1 -0
  407. package/dist/lib/command-path.js +40 -0
  408. package/dist/lib/command-path.js.map +1 -0
  409. package/dist/lib/completion-install.d.ts +29 -0
  410. package/dist/lib/completion-install.d.ts.map +1 -0
  411. package/dist/lib/completion-install.js +369 -0
  412. package/dist/lib/completion-install.js.map +1 -0
  413. package/dist/lib/completion-scripts.d.ts +4 -0
  414. package/dist/lib/completion-scripts.d.ts.map +1 -0
  415. package/dist/lib/completion-scripts.js +15 -0
  416. package/dist/lib/completion-scripts.js.map +1 -0
  417. package/dist/lib/completion.d.ts.map +1 -1
  418. package/dist/lib/completion.js +4 -1
  419. package/dist/lib/completion.js.map +1 -1
  420. package/dist/lib/control.d.ts +65 -6
  421. package/dist/lib/control.d.ts.map +1 -1
  422. package/dist/lib/control.js +121 -27
  423. package/dist/lib/control.js.map +1 -1
  424. package/dist/lib/controller-preserve.d.ts +12 -0
  425. package/dist/lib/controller-preserve.d.ts.map +1 -0
  426. package/dist/lib/controller-preserve.js +373 -0
  427. package/dist/lib/controller-preserve.js.map +1 -0
  428. package/dist/lib/controller-restore.d.ts +38 -0
  429. package/dist/lib/controller-restore.d.ts.map +1 -0
  430. package/dist/lib/controller-restore.js +205 -0
  431. package/dist/lib/controller-restore.js.map +1 -0
  432. package/dist/lib/controller-resume.d.ts +92 -0
  433. package/dist/lib/controller-resume.d.ts.map +1 -0
  434. package/dist/lib/controller-resume.js +300 -0
  435. package/dist/lib/controller-resume.js.map +1 -0
  436. package/dist/lib/credential-authority.d.ts +17 -0
  437. package/dist/lib/credential-authority.d.ts.map +1 -0
  438. package/dist/lib/credential-authority.js +28 -0
  439. package/dist/lib/credential-authority.js.map +1 -0
  440. package/dist/lib/default-persona.d.ts +38 -0
  441. package/dist/lib/default-persona.d.ts.map +1 -0
  442. package/dist/lib/default-persona.js +85 -0
  443. package/dist/lib/default-persona.js.map +1 -0
  444. package/dist/lib/delivery-proc.d.ts +9 -9
  445. package/dist/lib/delivery-proc.d.ts.map +1 -1
  446. package/dist/lib/delivery-proc.js +9 -19
  447. package/dist/lib/delivery-proc.js.map +1 -1
  448. package/dist/lib/endpoint-capability-gates.d.ts +10 -0
  449. package/dist/lib/endpoint-capability-gates.d.ts.map +1 -0
  450. package/dist/lib/endpoint-capability-gates.js +70 -0
  451. package/dist/lib/endpoint-capability-gates.js.map +1 -0
  452. package/dist/lib/endpoint-client.d.ts +20 -0
  453. package/dist/lib/endpoint-client.d.ts.map +1 -0
  454. package/dist/lib/endpoint-client.js +42 -0
  455. package/dist/lib/endpoint-client.js.map +1 -0
  456. package/dist/lib/endpoint-errors.d.ts +11 -0
  457. package/dist/lib/endpoint-errors.d.ts.map +1 -0
  458. package/dist/lib/endpoint-errors.js +30 -0
  459. package/dist/lib/endpoint-errors.js.map +1 -0
  460. package/dist/lib/endpoint-goal.d.ts +19 -0
  461. package/dist/lib/endpoint-goal.d.ts.map +1 -0
  462. package/dist/lib/endpoint-goal.js +31 -0
  463. package/dist/lib/endpoint-goal.js.map +1 -0
  464. package/dist/lib/endpoint-inventory.d.ts +30 -0
  465. package/dist/lib/endpoint-inventory.d.ts.map +1 -0
  466. package/dist/lib/endpoint-inventory.js +79 -0
  467. package/dist/lib/endpoint-inventory.js.map +1 -0
  468. package/dist/lib/endpoint-references.d.ts +22 -0
  469. package/dist/lib/endpoint-references.d.ts.map +1 -0
  470. package/dist/lib/endpoint-references.js +44 -0
  471. package/dist/lib/endpoint-references.js.map +1 -0
  472. package/dist/lib/endpoint-scatter.d.ts +57 -0
  473. package/dist/lib/endpoint-scatter.d.ts.map +1 -0
  474. package/dist/lib/endpoint-scatter.js +75 -0
  475. package/dist/lib/endpoint-scatter.js.map +1 -0
  476. package/dist/lib/endpoint-selection.d.ts +35 -0
  477. package/dist/lib/endpoint-selection.d.ts.map +1 -0
  478. package/dist/lib/endpoint-selection.js +80 -0
  479. package/dist/lib/endpoint-selection.js.map +1 -0
  480. package/dist/lib/install-umask.d.ts +6 -0
  481. package/dist/lib/install-umask.d.ts.map +1 -0
  482. package/dist/lib/install-umask.js +15 -0
  483. package/dist/lib/install-umask.js.map +1 -0
  484. package/dist/lib/isolated-broker.d.ts.map +1 -1
  485. package/dist/lib/isolated-broker.js +9 -5
  486. package/dist/lib/isolated-broker.js.map +1 -1
  487. package/dist/lib/local-process-stop.d.ts.map +1 -1
  488. package/dist/lib/local-process-stop.js +7 -1
  489. package/dist/lib/local-process-stop.js.map +1 -1
  490. package/dist/lib/manager-proc.d.ts +11 -5
  491. package/dist/lib/manager-proc.d.ts.map +1 -1
  492. package/dist/lib/manager-proc.js +12 -17
  493. package/dist/lib/manager-proc.js.map +1 -1
  494. package/dist/lib/manifest/apply.d.ts +4 -1
  495. package/dist/lib/manifest/apply.d.ts.map +1 -1
  496. package/dist/lib/manifest/apply.js +1 -1
  497. package/dist/lib/manifest/apply.js.map +1 -1
  498. package/dist/lib/manifest/ledger.d.ts +3 -1
  499. package/dist/lib/manifest/ledger.d.ts.map +1 -1
  500. package/dist/lib/manifest/ledger.js +16 -3
  501. package/dist/lib/manifest/ledger.js.map +1 -1
  502. package/dist/lib/manifest/schema.d.ts +1 -117
  503. package/dist/lib/manifest/schema.d.ts.map +1 -1
  504. package/dist/lib/manifest/schema.js +1 -95
  505. package/dist/lib/manifest/schema.js.map +1 -1
  506. package/dist/lib/offline-recipient.d.ts +5 -0
  507. package/dist/lib/offline-recipient.d.ts.map +1 -0
  508. package/dist/lib/offline-recipient.js +7 -0
  509. package/dist/lib/offline-recipient.js.map +1 -0
  510. package/dist/lib/onboard.js +3 -3
  511. package/dist/lib/onboard.js.map +1 -1
  512. package/dist/lib/persona-files.d.ts +29 -0
  513. package/dist/lib/persona-files.d.ts.map +1 -0
  514. package/dist/lib/persona-files.js +154 -0
  515. package/dist/lib/persona-files.js.map +1 -0
  516. package/dist/lib/personas.d.ts +3 -0
  517. package/dist/lib/personas.d.ts.map +1 -1
  518. package/dist/lib/personas.js +14 -2
  519. package/dist/lib/personas.js.map +1 -1
  520. package/dist/lib/prompts.d.ts +16 -0
  521. package/dist/lib/prompts.d.ts.map +1 -0
  522. package/dist/lib/prompts.js +35 -0
  523. package/dist/lib/prompts.js.map +1 -0
  524. package/dist/lib/protected-records.d.ts +2 -0
  525. package/dist/lib/protected-records.d.ts.map +1 -0
  526. package/dist/lib/protected-records.js +3 -0
  527. package/dist/lib/protected-records.js.map +1 -0
  528. package/dist/lib/registry-errors.d.ts +4 -0
  529. package/dist/lib/registry-errors.d.ts.map +1 -0
  530. package/dist/lib/registry-errors.js +6 -0
  531. package/dist/lib/registry-errors.js.map +1 -0
  532. package/dist/lib/reset-space-plan.d.ts +36 -0
  533. package/dist/lib/reset-space-plan.d.ts.map +1 -0
  534. package/dist/lib/reset-space-plan.js +181 -0
  535. package/dist/lib/reset-space-plan.js.map +1 -0
  536. package/dist/lib/restore.d.ts +3 -1
  537. package/dist/lib/restore.d.ts.map +1 -1
  538. package/dist/lib/restore.js +38 -10
  539. package/dist/lib/restore.js.map +1 -1
  540. package/dist/lib/seat-resume.d.ts +4 -1
  541. package/dist/lib/seat-resume.d.ts.map +1 -1
  542. package/dist/lib/seat-resume.js +7 -4
  543. package/dist/lib/seat-resume.js.map +1 -1
  544. package/dist/lib/service-adapters.d.ts +32 -0
  545. package/dist/lib/service-adapters.d.ts.map +1 -0
  546. package/dist/lib/service-adapters.js +55 -0
  547. package/dist/lib/service-adapters.js.map +1 -0
  548. package/dist/lib/service-census.d.ts +73 -0
  549. package/dist/lib/service-census.d.ts.map +1 -0
  550. package/dist/lib/service-census.js +42 -0
  551. package/dist/lib/service-census.js.map +1 -0
  552. package/dist/lib/service-definitions.d.ts +49 -0
  553. package/dist/lib/service-definitions.d.ts.map +1 -0
  554. package/dist/lib/service-definitions.js +61 -0
  555. package/dist/lib/service-definitions.js.map +1 -0
  556. package/dist/lib/service-install-intent.d.ts +48 -0
  557. package/dist/lib/service-install-intent.d.ts.map +1 -0
  558. package/dist/lib/service-install-intent.js +95 -0
  559. package/dist/lib/service-install-intent.js.map +1 -0
  560. package/dist/lib/service-instances.d.ts +143 -0
  561. package/dist/lib/service-instances.d.ts.map +1 -0
  562. package/dist/lib/service-instances.js +193 -0
  563. package/dist/lib/service-instances.js.map +1 -0
  564. package/dist/lib/service-journal.d.ts +38 -0
  565. package/dist/lib/service-journal.d.ts.map +1 -0
  566. package/dist/lib/service-journal.js +210 -0
  567. package/dist/lib/service-journal.js.map +1 -0
  568. package/dist/lib/service-launchd-plan.d.ts +21 -0
  569. package/dist/lib/service-launchd-plan.d.ts.map +1 -0
  570. package/dist/lib/service-launchd-plan.js +69 -0
  571. package/dist/lib/service-launchd-plan.js.map +1 -0
  572. package/dist/lib/service-launchd-unit.d.ts +20 -0
  573. package/dist/lib/service-launchd-unit.d.ts.map +1 -0
  574. package/dist/lib/service-launchd-unit.js +66 -0
  575. package/dist/lib/service-launchd-unit.js.map +1 -0
  576. package/dist/lib/service-presets.d.ts +17 -0
  577. package/dist/lib/service-presets.d.ts.map +1 -0
  578. package/dist/lib/service-presets.js +138 -0
  579. package/dist/lib/service-presets.js.map +1 -0
  580. package/dist/lib/service-private-seed.d.ts +7 -0
  581. package/dist/lib/service-private-seed.d.ts.map +1 -0
  582. package/dist/lib/service-private-seed.js +64 -0
  583. package/dist/lib/service-private-seed.js.map +1 -0
  584. package/dist/lib/service-private-tree.d.ts +6 -0
  585. package/dist/lib/service-private-tree.d.ts.map +1 -0
  586. package/dist/lib/service-private-tree.js +100 -0
  587. package/dist/lib/service-private-tree.js.map +1 -0
  588. package/dist/lib/service-process.d.ts +121 -0
  589. package/dist/lib/service-process.d.ts.map +1 -0
  590. package/dist/lib/service-process.js +742 -0
  591. package/dist/lib/service-process.js.map +1 -0
  592. package/dist/lib/service-stopped-allocation.d.ts +6 -0
  593. package/dist/lib/service-stopped-allocation.d.ts.map +1 -0
  594. package/dist/lib/service-stopped-allocation.js +42 -0
  595. package/dist/lib/service-stopped-allocation.js.map +1 -0
  596. package/dist/lib/service-supervision.d.ts +59 -0
  597. package/dist/lib/service-supervision.d.ts.map +1 -0
  598. package/dist/lib/service-supervision.js +71 -0
  599. package/dist/lib/service-supervision.js.map +1 -0
  600. package/dist/lib/service-systemd-attempt-read.d.ts +40 -0
  601. package/dist/lib/service-systemd-attempt-read.d.ts.map +1 -0
  602. package/dist/lib/service-systemd-attempt-read.js +80 -0
  603. package/dist/lib/service-systemd-attempt-read.js.map +1 -0
  604. package/dist/lib/service-systemd-control.d.ts +38 -0
  605. package/dist/lib/service-systemd-control.d.ts.map +1 -0
  606. package/dist/lib/service-systemd-control.js +141 -0
  607. package/dist/lib/service-systemd-control.js.map +1 -0
  608. package/dist/lib/service-systemd-files.d.ts +8 -0
  609. package/dist/lib/service-systemd-files.d.ts.map +1 -0
  610. package/dist/lib/service-systemd-files.js +63 -0
  611. package/dist/lib/service-systemd-files.js.map +1 -0
  612. package/dist/lib/service-systemd-install.d.ts +17 -0
  613. package/dist/lib/service-systemd-install.d.ts.map +1 -0
  614. package/dist/lib/service-systemd-install.js +146 -0
  615. package/dist/lib/service-systemd-install.js.map +1 -0
  616. package/dist/lib/service-systemd-plan.d.ts +28 -0
  617. package/dist/lib/service-systemd-plan.d.ts.map +1 -0
  618. package/dist/lib/service-systemd-plan.js +56 -0
  619. package/dist/lib/service-systemd-plan.js.map +1 -0
  620. package/dist/lib/service-systemd-reseed.d.ts +16 -0
  621. package/dist/lib/service-systemd-reseed.d.ts.map +1 -0
  622. package/dist/lib/service-systemd-reseed.js +106 -0
  623. package/dist/lib/service-systemd-reseed.js.map +1 -0
  624. package/dist/lib/service-systemd-uninstall-plan.d.ts +29 -0
  625. package/dist/lib/service-systemd-uninstall-plan.d.ts.map +1 -0
  626. package/dist/lib/service-systemd-uninstall-plan.js +56 -0
  627. package/dist/lib/service-systemd-uninstall-plan.js.map +1 -0
  628. package/dist/lib/service-systemd-uninstall.d.ts +17 -0
  629. package/dist/lib/service-systemd-uninstall.d.ts.map +1 -0
  630. package/dist/lib/service-systemd-uninstall.js +106 -0
  631. package/dist/lib/service-systemd-uninstall.js.map +1 -0
  632. package/dist/lib/service-systemd-unit.d.ts +28 -0
  633. package/dist/lib/service-systemd-unit.d.ts.map +1 -0
  634. package/dist/lib/service-systemd-unit.js +73 -0
  635. package/dist/lib/service-systemd-unit.js.map +1 -0
  636. package/dist/lib/service-systemd.d.ts +49 -0
  637. package/dist/lib/service-systemd.d.ts.map +1 -0
  638. package/dist/lib/service-systemd.js +134 -0
  639. package/dist/lib/service-systemd.js.map +1 -0
  640. package/dist/lib/service-uninstall-intent.d.ts +38 -0
  641. package/dist/lib/service-uninstall-intent.d.ts.map +1 -0
  642. package/dist/lib/service-uninstall-intent.js +74 -0
  643. package/dist/lib/service-uninstall-intent.js.map +1 -0
  644. package/dist/lib/service-unit-action.d.ts +24 -0
  645. package/dist/lib/service-unit-action.d.ts.map +1 -0
  646. package/dist/lib/service-unit-action.js +61 -0
  647. package/dist/lib/service-unit-action.js.map +1 -0
  648. package/dist/lib/setup-log.d.ts +5 -4
  649. package/dist/lib/setup-log.d.ts.map +1 -1
  650. package/dist/lib/setup-log.js +18 -9
  651. package/dist/lib/setup-log.js.map +1 -1
  652. package/dist/lib/space-schema-inspection.d.ts +73 -0
  653. package/dist/lib/space-schema-inspection.d.ts.map +1 -0
  654. package/dist/lib/space-schema-inspection.js +118 -0
  655. package/dist/lib/space-schema-inspection.js.map +1 -0
  656. package/dist/lib/space-schema-report.d.ts +82 -0
  657. package/dist/lib/space-schema-report.d.ts.map +1 -0
  658. package/dist/lib/space-schema-report.js +109 -0
  659. package/dist/lib/space-schema-report.js.map +1 -0
  660. package/dist/lib/spawn-defaults.d.ts +14 -0
  661. package/dist/lib/spawn-defaults.d.ts.map +1 -0
  662. package/dist/lib/spawn-defaults.js +20 -0
  663. package/dist/lib/spawn-defaults.js.map +1 -0
  664. package/dist/lib/stack-journal.d.ts +92 -0
  665. package/dist/lib/stack-journal.d.ts.map +1 -0
  666. package/dist/lib/stack-journal.js +199 -0
  667. package/dist/lib/stack-journal.js.map +1 -0
  668. package/dist/lib/stack-resume.d.ts +35 -0
  669. package/dist/lib/stack-resume.d.ts.map +1 -0
  670. package/dist/lib/stack-resume.js +123 -0
  671. package/dist/lib/stack-resume.js.map +1 -0
  672. package/dist/lib/status.d.ts +19 -20
  673. package/dist/lib/status.d.ts.map +1 -1
  674. package/dist/lib/status.js +41 -40
  675. package/dist/lib/status.js.map +1 -1
  676. package/dist/lib/steps.d.ts.map +1 -1
  677. package/dist/lib/steps.js +3 -2
  678. package/dist/lib/steps.js.map +1 -1
  679. package/dist/lib/systemd-supervision.d.ts +11 -4
  680. package/dist/lib/systemd-supervision.d.ts.map +1 -1
  681. package/dist/lib/systemd-supervision.js +19 -8
  682. package/dist/lib/systemd-supervision.js.map +1 -1
  683. package/dist/lib/team-additive-attempt.d.ts +286 -0
  684. package/dist/lib/team-additive-attempt.d.ts.map +1 -0
  685. package/dist/lib/team-additive-attempt.js +387 -0
  686. package/dist/lib/team-additive-attempt.js.map +1 -0
  687. package/dist/lib/team-additive-native.d.ts +17 -0
  688. package/dist/lib/team-additive-native.d.ts.map +1 -0
  689. package/dist/lib/team-additive-native.js +29 -0
  690. package/dist/lib/team-additive-native.js.map +1 -0
  691. package/dist/lib/team-agent-removal.d.ts +104 -0
  692. package/dist/lib/team-agent-removal.d.ts.map +1 -0
  693. package/dist/lib/team-agent-removal.js +121 -0
  694. package/dist/lib/team-agent-removal.js.map +1 -0
  695. package/dist/lib/team-channel-removal.d.ts +220 -0
  696. package/dist/lib/team-channel-removal.d.ts.map +1 -0
  697. package/dist/lib/team-channel-removal.js +258 -0
  698. package/dist/lib/team-channel-removal.js.map +1 -0
  699. package/dist/lib/team-deploy-inspection.d.ts +59 -0
  700. package/dist/lib/team-deploy-inspection.d.ts.map +1 -0
  701. package/dist/lib/team-deploy-inspection.js +177 -0
  702. package/dist/lib/team-deploy-inspection.js.map +1 -0
  703. package/dist/lib/team-fresh.d.ts +73 -0
  704. package/dist/lib/team-fresh.d.ts.map +1 -0
  705. package/dist/lib/team-fresh.js +207 -0
  706. package/dist/lib/team-fresh.js.map +1 -0
  707. package/dist/lib/team-removal-reconcile.d.ts +118 -0
  708. package/dist/lib/team-removal-reconcile.d.ts.map +1 -0
  709. package/dist/lib/team-removal-reconcile.js +90 -0
  710. package/dist/lib/team-removal-reconcile.js.map +1 -0
  711. package/dist/lib/team-removal-record.d.ts +7 -0
  712. package/dist/lib/team-removal-record.d.ts.map +1 -0
  713. package/dist/lib/team-removal-record.js +46 -0
  714. package/dist/lib/team-removal-record.js.map +1 -0
  715. package/dist/lib/team-retained.d.ts +33 -0
  716. package/dist/lib/team-retained.d.ts.map +1 -0
  717. package/dist/lib/team-retained.js +55 -0
  718. package/dist/lib/team-retained.js.map +1 -0
  719. package/dist/lib/theme.d.ts.map +1 -1
  720. package/dist/lib/theme.js +9 -8
  721. package/dist/lib/theme.js.map +1 -1
  722. package/dist/lib/transient.d.ts +14 -9
  723. package/dist/lib/transient.d.ts.map +1 -1
  724. package/dist/lib/transient.js +25 -18
  725. package/dist/lib/transient.js.map +1 -1
  726. package/dist/lib/up-report.d.ts +1 -0
  727. package/dist/lib/up-report.d.ts.map +1 -1
  728. package/dist/lib/up-report.js +2 -1
  729. package/dist/lib/up-report.js.map +1 -1
  730. package/dist/lib/version.d.ts +8 -2
  731. package/dist/lib/version.d.ts.map +1 -1
  732. package/dist/lib/version.js +16 -9
  733. package/dist/lib/version.js.map +1 -1
  734. package/dist/seed/paths.d.ts +1 -1
  735. package/dist/seed/paths.js +1 -1
  736. package/dist/seed/reconcile.d.ts.map +1 -1
  737. package/dist/seed/reconcile.js +19 -3
  738. package/dist/seed/reconcile.js.map +1 -1
  739. package/dist/ui.d.ts +6 -0
  740. package/dist/ui.d.ts.map +1 -1
  741. package/dist/ui.js +12 -1
  742. package/dist/ui.js.map +1 -1
  743. package/dist/watch-data.d.ts +15 -0
  744. package/dist/watch-data.d.ts.map +1 -0
  745. package/dist/watch-data.js +66 -0
  746. package/dist/watch-data.js.map +1 -0
  747. package/dist/watch-json.d.ts +5 -0
  748. package/dist/watch-json.d.ts.map +1 -0
  749. package/dist/watch-json.js +131 -0
  750. package/dist/watch-json.js.map +1 -0
  751. package/dist/watch-view.d.ts +8 -0
  752. package/dist/watch-view.d.ts.map +1 -0
  753. package/dist/watch-view.js +65 -0
  754. package/dist/watch-view.js.map +1 -0
  755. package/package.json +8 -5
  756. package/dist/commands/service.d.ts +0 -17
  757. package/dist/commands/service.d.ts.map +0 -1
  758. package/dist/commands/service.js +0 -589
  759. package/dist/commands/service.js.map +0 -1
package/dist/command.js CHANGED
@@ -1,94 +1,118 @@
1
- import { commandUsage, parseCommandArgs } from "@cotal-ai/core";
2
- import { hasMeshTargetFlags, isWorkspaceTargetError, renderWorkspaceError } from "@cotal-ai/workspace";
3
- import { c, staleStoreHint } from "./ui.js";
1
+ import { writeSync } from "node:fs";
2
+ import { commandDeclarationProblems, findCommand, findSubcommand, parseCommandArgs } from "@cotal-ai/core";
3
+ import { CommandFailure, commandFailureReport, cachedPreferences, disableColor, disableInput, envelopeLine, exitCode, failureEnvelope, globalFlagDeclarationProblems, hasMeshTargetFlags, inOperationSpace, isCommandFailure, isConnectRefusal, isSeededCommand, isWorkspaceTargetError, outputDeclarationProblems, renderReport, renderWorkspaceError, runOperation, workspaceErrorParts, targetErrorCode, terminalWidth, } from "@cotal-ai/workspace";
4
+ import { c, staleStoreHint, stderrLine } from "./ui.js";
4
5
  import { isExtensionStub, materializeExtension, materializeExtensionCommand, overlayExtensions, setCommandSurface, setInstalledExtensionsEnabled, } from "./ext-loader.js";
5
6
  import { reconcileSeededConnectors } from "./seed/reconcile.js";
6
7
  import { isAuthenticSeedChild } from "./seed/lock.js";
7
- import { cliVersion, extensionVersions } from "./lib/version.js";
8
- import { prepareCatalogCommand } from "./commands/sync.js";
8
+ import { printCommandHelp, printHelpPath, printEntry } from "./help.js";
9
+ import { CatalogPreparationError, prepareCatalogCommand } from "./commands/sync.js";
10
+ import { servicePresetCommand } from "./lib/service-presets.js";
11
+ import { metadataPositionals } from "./lib/command-path.js";
12
+ import { chooseMeshTarget } from "./lib/choose-target.js";
9
13
  import { takeManagedHandoffCustody } from "./managed-handoff.js";
10
- /** Display order for the help groups — an explicit ranking, NOT registration order: modules
11
- * self-register on import and the dev runner (tsx) doesn't guarantee entry-import evaluation
12
- * order, so the daemon surface could otherwise print above Setup. Groups not listed here
13
- * (e.g. an extension's custom group) follow, in first-registered order. */
14
- const GROUP_ORDER = ["Setup", "Mesh", "Messaging", "Agents", "Observe", "Extensions", "Manager"];
15
- function help(commands) {
16
- // `__`-prefixed commands are internal (e.g. `__complete`, the completion dispatcher); `hidden`
17
- // ones are runnable dev/test aids (e.g. `demo`) kept off the surface — hide both.
18
- const visible = commands.filter((cmd) => !cmd.name.startsWith("__") && !cmd.hidden);
19
- const groups = new Map();
20
- for (const cmd of visible) {
21
- const g = cmd.group ?? "Commands";
22
- (groups.get(g) ?? groups.set(g, []).get(g)).push(cmd);
23
- }
24
- const rank = (g) => {
25
- const i = GROUP_ORDER.indexOf(g);
26
- return i === -1 ? GROUP_ORDER.length : i;
27
- };
28
- const ordered = [...groups.entries()].sort(([a], [b]) => rank(a) - rank(b));
29
- const pad = Math.max(...visible.map((c) => c.name.length));
30
- let out = `${c.bold("cotal")} - lateral agent coordination over NATS\n`;
31
- for (const [group, cmds] of ordered) {
32
- out += `\n${c.bold(group)}\n`;
33
- for (const cmd of cmds)
34
- out += ` ${cmd.name.padEnd(pad)} ${c.dim(cmd.summary)}\n`;
35
- }
36
- console.log(out);
14
+ /** Whether `args` ask for help: `--help` or `-h` before any `--`, after which every word is text. */
15
+ function asksForHelp(args) {
16
+ const end = args.indexOf("--");
17
+ const options = end === -1 ? args : args.slice(0, end);
18
+ return options.includes("--help") || options.includes("-h");
37
19
  }
38
- /** Full help for one command, generated from its declared specs: summary, usage line, and a
39
- * flag table (short, long, metavar, description). */
40
- function commandHelp(cmd) {
41
- console.log(`${c.bold(`cotal ${cmd.name}`)} - ${cmd.summary}`);
42
- console.log(c.dim(`usage: ${commandUsage(cmd)}`));
43
- const flags = cmd.flags ?? [];
44
- if (!flags.length)
45
- return;
46
- const left = flags.map((f) => {
47
- const metavar = f.type === "string" ? ` ${f.value ?? "<value>"}` : "";
48
- return `${f.short ? `-${f.short}, ` : " "}--${f.name}${metavar}`;
49
- });
50
- const pad = Math.max(...left.map((s) => s.length));
51
- console.log(c.bold("flags:"));
52
- flags.forEach((f, i) => console.log(` ${left[i].padEnd(pad)} ${c.dim(f.description ?? "")}`));
20
+ /** Whether a global flag (`--no-color`, `--no-input`) is `word`, applying it when it is. */
21
+ function takeGlobalFlag(word) {
22
+ if (word === "--no-color")
23
+ disableColor();
24
+ else if (word === "--no-input")
25
+ disableInput();
26
+ else
27
+ return false;
28
+ return true;
29
+ }
30
+ /** `words` without the global flags before any `--`, each applied. */
31
+ function stripGlobalFlags(words) {
32
+ const end = words.indexOf("--");
33
+ const head = (end === -1 ? words : words.slice(0, end)).filter((word) => !takeGlobalFlag(word));
34
+ return end === -1 ? head : [...head, ...words.slice(end)];
35
+ }
36
+ /** Whether `cmd` takes its words raw: it declares so, or it is an internal command, whose words are
37
+ * another command line. Such a command parses no flags of its own. */
38
+ function takesWordsRaw(cmd) {
39
+ return Boolean(cmd && (cmd.rawArgs || cmd.name.startsWith("__")));
40
+ }
41
+ /** The words `cmd` parses: the global flags are the kernel's, except for a command that takes its
42
+ * words raw. */
43
+ function ownWords(cmd, words) {
44
+ return takesWordsRaw(cmd) ? [...words] : stripGlobalFlags(words);
45
+ }
46
+ /** Whether the invoked mode declares a structured output, so it reports every outcome by the 0 to 5
47
+ * table: the subcommand `first` selects, else the command's bare form. */
48
+ function structured(cmd, first) {
49
+ const sub = findSubcommand(cmd, first);
50
+ return ((sub ? sub.outputs : cmd.outputs) ?? []).some((mode) => mode === "json" || mode === "ndjson");
51
+ }
52
+ /** Whether `args` ask `cmd` for JSON before any `--`: `--json`, `-j`, or `-j` in a group of the
53
+ * command's boolean short flags. Read from the words, because a usage error has no parse, so the mode
54
+ * is the first word that is not a flag. */
55
+ function asksForJson(cmd, args) {
56
+ if (!structured(cmd, args.find((word) => !word.startsWith("-"))))
57
+ return false;
58
+ const booleans = new Set((cmd.flags ?? []).flatMap((flag) => (flag.type === "boolean" && flag.short ? [flag.short] : [])));
59
+ const end = args.indexOf("--");
60
+ return (end === -1 ? args : args.slice(0, end)).some((word) => word === "--json" || word === "-j" || (/^-[A-Za-z]{2,}$/.test(word) && word.includes("j") && [...word.slice(1)].every((ch) => booleans.has(ch))));
61
+ }
62
+ /** A classified failure: its line and remedy on stderr, its envelope on stdout when one was asked
63
+ * for, and the exit code its outcome sets. The envelope is written synchronously, because stdout
64
+ * to a pipe is asynchronous on some platforms and `exit` would cut it short. */
65
+ function failureExit(cmd, failure, json, plain = false) {
66
+ // A command's own usage refusal reads as the parser's: the error, its remedy, then the help.
67
+ if (failure.code === "USAGE_INVALID" && !json) {
68
+ stderrLine("✗ ", failure.message, c.red);
69
+ if (failure.remedy)
70
+ stderrLine(" ", failure.remedy, c.dim);
71
+ printCommandHelp(cmd, undefined, (line) => console.error(line), terminalWidth(process.stderr));
72
+ process.exit(1);
73
+ }
74
+ writeSync(2, `${renderReport(commandFailureReport(failure), plain ? "plain" : "rich", terminalWidth(process.stderr))}
75
+ `);
76
+ if (json)
77
+ writeSync(1, envelopeLine(failureEnvelope(cmd.name, failure)));
78
+ process.exit(exitCode(failure.outcome, failure.code));
53
79
  }
54
80
  /**
55
- * The connector-seeding boot gate. Returns `true` iff it fully handled the command (maintenance
56
- * `ext seed`), so the caller returns without the normal dispatch.
57
- *
58
- * - `ext seed [--repair|--reset|--force]` is dispatched HERE, before the manifest overlay, so repair
59
- * survives a corrupt manifest.
60
- * - every other real command reconciles first (so `npm i -g cotal-ai && cotal ext list` shows the
61
- * four, and a first-command `ext add` still seeds), EXCEPT completion/help and an AUTHENTIC seed
62
- * CHILD — an `ext add` whose `COTAL_EXT_SEEDING` nonce + parent PID match the live reconcile lock
63
- * (a forged marker no longer skips, so it can't bypass the recursive-reconcile guard or the lock).
81
+ * `ext seed [--repair|--reset|--force]`, dispatched before the manifest overlay so repair survives a
82
+ * corrupt manifest. Returns `true` iff `argv` was that command (or its help), so the caller returns.
83
+ * The overlay cannot list the command yet, so the built-in `ext` is found through the registry,
84
+ * which resolves its alias too.
64
85
  */
65
- async function seedBoot(registry, argv) {
66
- const [name, sub] = argv;
67
- if (name === "ext" && sub === "seed") {
68
- const extCmd = registry.all("command").find((cmd) => cmd.name === "ext");
69
- if (!extCmd)
70
- throw new Error("internal error: the `ext` command is not registered");
71
- // `ext seed` is dispatched HERE, before the global/per-command help intercepts, so `--repair` can
72
- // fix a corrupt manifest. A help request must still short-circuit to usage and mutate NOTHING
73
- // (the maintenance run below writes the seed stamp/manifest).
74
- if (argv.includes("--help") || argv.includes("-h")) {
75
- commandHelp(extCmd);
76
- return true;
77
- }
78
- await extCmd.run(parseCommandArgs(extCmd, argv.slice(1)));
86
+ async function extSeedGate(registry, argv) {
87
+ const [word, sub] = argv;
88
+ const extCmd = word === undefined || !registry.has("command", word) ? undefined : registry.resolve("command", word);
89
+ if (extCmd?.name !== "ext" || sub !== "seed")
90
+ return false;
91
+ // A help request short-circuits to usage and mutates NOTHING (the maintenance run writes the seed
92
+ // stamp/manifest).
93
+ if (asksForHelp(argv)) {
94
+ printCommandHelp(extCmd);
79
95
  return true;
80
96
  }
81
- if (skipAutoReconcile(argv))
82
- return false;
83
- await reconcileSeededConnectors();
84
- return false;
97
+ await extCmd.run(parseCommandArgs(extCmd, stripGlobalFlags(argv.slice(1))));
98
+ return true;
85
99
  }
86
- function skipAutoReconcile(argv) {
87
- const [name, sub] = argv;
88
- if (name === undefined || name === "help" || name === "-h" || name === "--help" || name === "__complete" || name === "completion")
100
+ /**
101
+ * Whether a validated invocation skips the connector seed. Every command reconciles first (so a
102
+ * first-command `ext add` still seeds, and the first command after an upgrade refreshes what is
103
+ * installed), EXCEPT help, version, completion, a read its command declares and the cases below. A
104
+ * read never repairs as a hidden prelude. `name` is the canonical command, `cmd` the command when it
105
+ * resolved, and `sub` its first positional; an AUTHENTIC seed CHILD is an `ext add` whose
106
+ * `COTAL_EXT_SEEDING` nonce + parent PID match the live reconcile lock (a forged marker no longer
107
+ * skips, so it can't bypass the recursive-reconcile guard or the lock).
108
+ */
109
+ function skipsSeed(name, sub, argv, cmd) {
110
+ if (name === "help" || name === "version" || name === "__complete" || name === "completion")
111
+ return true;
112
+ if (cmd && readsOnly(cmd, sub))
89
113
  return true;
90
- if (argv.includes("--help") || argv.includes("-h"))
91
- return true; // command-specific help must not mutate state
114
+ if (name === "use" && sub === undefined)
115
+ return true; // bare `use` shows the selection: a read
92
116
  // A dry run promises to plan and print while mutating NOTHING, and the boot-gate reconcile is a
93
117
  // mutation of the operator-global seed store, manifest and npm prefix — it ran BEFORE the command
94
118
  // body could reject the invocation, so `down --preserve-state --dry-run` (an unsupported
@@ -97,6 +121,18 @@ function skipAutoReconcile(argv) {
97
121
  // planning surface reads what is installed; it never seeds to make the plan prettier.
98
122
  if (argv.includes("--dry-run"))
99
123
  return true;
124
+ if (name === "persona" || (name === "personas" && !argv.includes("--running")))
125
+ return true; // local files or existing native manager routes; neither installs connectors
126
+ if (["__service-feedback-intake", "__service-delivery", "__service-manager", "__service-auth", "__service-linear", "__service-web", "__service-exec-endpoint"].includes(name))
127
+ return true; // explicit native service child; never repairs the installation
128
+ if (name === "team" && (sub === "deploy" || sub === "remove"))
129
+ return true; // existing native manager/channel operations never install local connectors
130
+ // `backup restore` is excluded: it starts the restored stack and resumes its seats through `up
131
+ // --restore`, so it reconciles connectors under the same rules as that startup. Other modes stay offline.
132
+ if (name === "reset" || name === "down" || name === "doctor" || name === "feedback" || (name === "backup" && sub !== "restore") || name === "mint" || name === "manager" || name === "channel" || name === "stop" || name === "input" || name === "auth" || name === "endpoint" || name === "service")
133
+ return true; // native maintenance and channel policy never install connector packages
134
+ if (name === "run" && (sub === "turns" || sub === "yield"))
135
+ return true; // self-only relay does not repair the operator installation
100
136
  if (name === "update")
101
137
  return true; // update owns one explicit reconcile; never auto-refresh then force-refresh
102
138
  // The seed is skipped for an INTERNAL CHILD re-exec — the `up`/`spawn` that spawns the delivery
@@ -105,8 +141,6 @@ function skipAutoReconcile(argv) {
105
141
  // `cotal supervise --roster`, the agent supervisor + container entrypoint) still seeds on first run.
106
142
  if (process.env.COTAL_SKIP_CONNECTOR_SEED === "1")
107
143
  return true;
108
- if (name === "ext" && sub === "root")
109
- return true; // a side-effect-free path print: no seed noise, so `$(cotal ext root)` stays exactly one line even on first run
110
144
  if (name === "ext" && sub === "seed")
111
145
  return true; // the explicit maintenance command self-reconciles
112
146
  if (name === "ext" && sub === "add" && isAuthenticSeedChild())
@@ -117,6 +151,8 @@ function skipAutoReconcile(argv) {
117
151
  // (disconnecting a live seat at its token's expiry, #1857), and a matching generation seeded every
118
152
  // connector as a side effect of a credential exchange. The seat's env carries no
119
153
  // COTAL_SKIP_CONNECTOR_SEED (only an operator-set one is forwarded), so the skip is by name.
154
+ if (name === "history" && sub === "clear")
155
+ return true; // purge authority does not require installing connectors
120
156
  if (name === "agent-bearer")
121
157
  return true;
122
158
  // `app-identity` is machine-facing too: the Claude connector's local server runs it on every
@@ -125,6 +161,11 @@ function skipAutoReconcile(argv) {
125
161
  return true;
126
162
  return false;
127
163
  }
164
+ /** Whether the invocation is a mode its command declares as a read ({@link Command.reads}). */
165
+ function readsOnly(cmd, first) {
166
+ const sub = findSubcommand(cmd, first);
167
+ return sub ? sub.reads === true : cmd.reads === true;
168
+ }
128
169
  /** node's parseArgs throws these for unknown/malformed flags; treat as a usage error. */
129
170
  function isArgError(e) {
130
171
  const code = e?.code;
@@ -132,8 +173,18 @@ function isArgError(e) {
132
173
  }
133
174
  /** One dispatcher-owned catalog gate for every command that uses the shared mesh target grammar,
134
175
  * including commands self-registered by other packages. Registry-local `meshes add/rm` stay
135
- * offline. `use` takes its target positionally, and status keeps stale bytes diagnostic-only. */
176
+ * offline. `use` takes its target positionally, and status keeps stale bytes diagnostic-only.
177
+ * Those commands then let a terminal choose between running spaces (see {@link chooseMeshTarget});
178
+ * `status` reports an ambiguous target instead. */
136
179
  async function prepareCatalogForCommand(cmd, args) {
180
+ if ((cmd.name === "supervise" || cmd.name === "__daemon-manager") && args.values.execution === "none")
181
+ return;
182
+ if (args.values["dry-run"] === true)
183
+ return; // preview handlers own read-only resolution; no catalog refresh or picker
184
+ if (findSubcommand(cmd, args.positionals[0])?.prepareMeshTarget === false)
185
+ return;
186
+ if (cmd.name === "update" && args.values.check === true)
187
+ return;
137
188
  if (cmd.name === "meshes") {
138
189
  const sub = args.positionals[0];
139
190
  if (sub === undefined || sub === "list")
@@ -142,109 +193,303 @@ async function prepareCatalogForCommand(cmd, args) {
142
193
  }
143
194
  if (cmd.name === "use")
144
195
  return prepareCatalogCommand(args, false, "use");
145
- if (cmd.name === "status")
146
- return prepareCatalogCommand(args, true);
196
+ if (cmd.name === "status") {
197
+ if (!args.positionals.length)
198
+ return prepareCatalogCommand(args, true);
199
+ await prepareCatalogCommand(args);
200
+ return chooseMeshTarget(args);
201
+ }
147
202
  if (cmd.name === "personas" && args.values.running !== true)
148
203
  return;
149
- if (cmd.prepareMeshTarget !== false && hasMeshTargetFlags(cmd.flags))
204
+ if (cmd.prepareMeshTarget !== false && hasMeshTargetFlags(cmd.flags)) {
150
205
  await prepareCatalogCommand(args);
206
+ await chooseMeshTarget(args);
207
+ }
208
+ }
209
+ /** A usage error, rendered as one red line plus the command's help when there is one. Exit 1. */
210
+ function usageExit(message, cmd, json = false) {
211
+ // A JSON caller gets the refusal as an envelope, so stdout stays one document and the help text
212
+ // the remedy names stays out of it.
213
+ if (cmd && json)
214
+ failureExit(cmd, new CommandFailure("refused", "USAGE_INVALID", message, { remedy: `run \`cotal help ${cmd.name}\`` }), true);
215
+ // The help goes to stderr with the reason, so a refused run leaves stdout empty and a script that
216
+ // sources or parses it gets nothing.
217
+ stderrLine("✗ ", message, c.red);
218
+ if (cmd)
219
+ printCommandHelp(cmd, undefined, (line) => console.error(line), terminalWidth(process.stderr));
220
+ process.exit(1);
221
+ }
222
+ /** `rest` parsed against `cmd`'s declared flags, positionals and subcommands, or a usage exit. Node's
223
+ * parse error is trimmed to its first sentence: the verbose "To specify a positional argument
224
+ * starting with a '-' …" tail is dropped. */
225
+ function parseOrExit(cmd, rest) {
226
+ const json = asksForJson(cmd, rest);
227
+ let parsed;
228
+ try {
229
+ parsed = parseCommandArgs(cmd, rest);
230
+ }
231
+ catch (e) {
232
+ if (isArgError(e))
233
+ usageExit(e.message.split(".")[0], cmd, json);
234
+ throw e;
235
+ }
236
+ const first = parsed.positionals[0];
237
+ // History also accepts a root channel positional; only its reserved clear token is a mode.
238
+ if (cmd.subcommands?.length && first !== undefined && cmd.name !== "history" && !findSubcommand(cmd, first))
239
+ usageExit(`cotal ${cmd.name} has no subcommand "${first}" - run \`cotal help ${cmd.name}\``, cmd, json);
240
+ // `--json` implies `--no-input`: a script reading one document cannot answer a prompt.
241
+ if (structured(cmd, first) && parsed.values.json === true)
242
+ disableInput();
243
+ const canonical = canonicalSubcommand(cmd, parsed);
244
+ try {
245
+ cmd.validate?.(canonical);
246
+ }
247
+ catch (error) {
248
+ if (isCommandFailure(error))
249
+ failureExit(cmd, error, json, canonical.values.plain === true);
250
+ if (isArgError(error))
251
+ usageExit(error.message.split(".")[0], cmd, json);
252
+ throw error;
253
+ }
254
+ return canonical;
255
+ }
256
+ /** The parsed args with a subcommand alias in the first positional replaced by its name, so `run`
257
+ * only ever sees canonical subcommands. */
258
+ function canonicalSubcommand(cmd, parsed) {
259
+ const positionals = [...parsed.positionals];
260
+ let surface = cmd;
261
+ let changed = false;
262
+ for (let index = 0; index < positionals.length; index++) {
263
+ const sub = findSubcommand(surface, positionals[index]);
264
+ if (!sub)
265
+ break;
266
+ changed ||= sub.name !== positionals[index];
267
+ positionals[index] = sub.name;
268
+ surface = sub;
269
+ if (!sub.subcommands?.length)
270
+ break;
271
+ }
272
+ return changed ? { ...parsed, positionals } : parsed;
151
273
  }
152
- /** Dispatch `argv` against the commands self-registered in a {@link Registry}.
153
- * The single entry point a composition root calls — no hardcoded command list.
154
- * Parsing happens HERE, from the command's declared specs; `run` gets parsed args. */
274
+ /** `-h`/`--help` anywhere after a command: that command's help, or its subcommand's when the first
275
+ * positional names one. Read from the declared specs, so a stub's help never imports its package. */
276
+ function printHelpFor(cmd, rest) {
277
+ const words = metadataPositionals(cmd, rest).positionals.map((item) => item.value);
278
+ let surface = cmd;
279
+ const path = [];
280
+ for (const word of words) {
281
+ const sub = findSubcommand(surface, word);
282
+ if (!sub || sub.hidden)
283
+ break;
284
+ path.push(sub.name);
285
+ surface = sub;
286
+ if (!sub.subcommands?.length)
287
+ break;
288
+ }
289
+ printHelpPath(cmd, path);
290
+ }
291
+ /**
292
+ * Dispatch `argv` against the commands self-registered in a {@link Registry}. The single entry point
293
+ * a composition root calls — no hardcoded command list.
294
+ *
295
+ * It runs in two phases. The front end reads only local metadata: it resolves the command by exact
296
+ * name or alias (never a prefix), answers help and version, and parses a built-in command's flags
297
+ * against its declared specs. Only an invocation that passed it reaches the effects: the connector
298
+ * seed, provider materialization, target preparation and `run`. So a usage error seeds, writes and
299
+ * launches nothing. An extension command's flags are parsed after the seed, because its live specs
300
+ * come from importing a package the seed keeps current.
301
+ */
155
302
  export async function runCli(registry, argv, opts = {}) {
156
- // Before anything that can exit, so every outcome leaves no handoff file and no child inherits
157
- // the variable naming it.
158
- takeManagedHandoffCustody(process.env);
159
- // `-v` / `--version` short-circuits before any extension seeding or dispatch: a side-effect-free
160
- // print of this binary's version plus each installed extension's, read straight off disk. First,
161
- // so it never triggers the connector reconcile. Plain text (no ANSI) — a `--version` line is
162
- // routinely machine-read.
163
- if (argv[0] === "-v" || argv[0] === "--version") {
164
- const exts = extensionVersions();
165
- const lines = [`cotal-ai ${cliVersion()}`];
166
- if (exts.length) {
167
- const pad = Math.max(...exts.map((e) => e.label.length));
168
- for (const e of exts)
169
- lines.push(` ${e.label.padEnd(pad)} ${e.version}`);
303
+ // Global flags before the command word apply whatever the command is. The output flags are the
304
+ // command's own, so one written before the command word moves after it, and a `--` there ends
305
+ // the leading flags. A command that takes its words raw has no flags to read them as, so it
306
+ // refuses them there. The built-in surface decides that before any extension overlay is read.
307
+ const output = [];
308
+ let lead = 0;
309
+ for (; lead < argv.length; lead++) {
310
+ const word = argv[lead];
311
+ if (word === "--json" || word === "-j" || word === "--plain")
312
+ output.push(word);
313
+ else if (!takeGlobalFlag(word))
314
+ break;
315
+ }
316
+ if (argv[lead] === "--")
317
+ lead++;
318
+ if (output.length && lead >= argv.length)
319
+ usageExit(`${output[0]} needs a command after it - run \`cotal help\` to list commands`);
320
+ if (output.length && takesWordsRaw(findCommand(registry.all("command"), argv[lead])))
321
+ usageExit(`${output[0]} before ${argv[lead]} is not read - ${argv[lead]} takes its words raw, with no output flags`);
322
+ argv = [...argv.slice(lead, lead + 1), ...output, ...argv.slice(lead + 1)];
323
+ // A recorded unit boots from built-in code only. Even reading the extension overlay can
324
+ // prevent recovery from an unrelated broken manifest. Validate before any handoff custody,
325
+ // installation repair, package materialization or target preparation. This is one exact
326
+ // private entry, not an exemption for arbitrary internal or extension command names.
327
+ if (argv[0] === "__service-unit") {
328
+ if (!registry.has("command", "__service-unit"))
329
+ usageExit("the native unit entry is not available in this composition root");
330
+ const unit = registry.resolve("command", "__service-unit");
331
+ const parsed = parseOrExit(unit, argv.slice(1));
332
+ try {
333
+ await unit.run(parsed);
334
+ }
335
+ catch (error) {
336
+ failureExit(unit, isCommandFailure(error) ? error : new CommandFailure("unknown", "OPERATION_UNKNOWN", "the original unit entry did not confirm its outcome; no replacement or repair was attempted"), false, true);
170
337
  }
171
- console.log(lines.join("\n"));
172
338
  return;
173
339
  }
340
+ // Before any ordinary dispatch outcome can exit, take the spawn handoff and ensure no child
341
+ // inherits its variable. The unit entry refuses such a handoff without consuming its file.
342
+ takeManagedHandoffCustody(process.env);
174
343
  setInstalledExtensionsEnabled(Boolean(opts.extensions));
175
- // On the published binary, keep the four built-in connectors seeded (first run + version bump)
176
- // through the SAME `ext add` path a third party uses. This runs BEFORE the manifest overlay so
177
- // `ext seed --repair` can fix a corrupt manifest (the overlay is fatal on corrupt JSON).
344
+ // The global spellings of help and version are the `help` and `version` commands.
345
+ if (argv[0] === "-v")
346
+ usageExit("-v is not the version flag - run `cotal version` or `cotal -V`");
347
+ if (argv[0] === "--version" || argv[0] === "-V")
348
+ argv = ["version", ...argv.slice(1)];
349
+ else if (argv[0] === "--help" || argv[0] === "-h")
350
+ argv = ["help", ...argv.slice(1)];
178
351
  if (opts.extensions) {
179
352
  try {
180
- if (await seedBoot(registry, argv))
353
+ if (await extSeedGate(registry, argv))
181
354
  return;
182
355
  }
183
356
  catch (e) {
184
- console.error(c.red(`✗ ${e.message}`));
357
+ stderrLine("✗ ", e.message, c.red);
185
358
  process.exit(1);
186
359
  }
187
360
  }
188
- let commands;
189
- try {
190
- commands = opts.extensions ? overlayExtensions(registry) : registry.all("command");
191
- }
192
- catch (e) {
193
- // A corrupt extensions manifest must not silently shrink the surface — fatal and loud, but
194
- // rendered as the CLI's one red line, not an unhandled-rejection stack dump.
195
- console.error(c.red(`✗ ${e.message}`));
196
- process.exit(1);
197
- }
198
- setCommandSurface(commands); // the completion dispatcher reads the SAME surface help renders
199
- const [name, ...rest] = argv;
200
- if (name === undefined || name === "help" || name === "-h" || name === "--help") {
201
- help(commands);
202
- return;
203
- }
204
- let cmd = commands.find((c) => c.name === name);
205
- if (!cmd) {
206
- console.error(c.red(`unknown command: ${name}`));
207
- help(commands);
208
- process.exit(1);
361
+ const surface = () => {
362
+ let commands;
363
+ try {
364
+ commands = opts.extensions ? overlayExtensions(registry) : registry.all("command");
365
+ }
366
+ catch (e) {
367
+ // A corrupt extensions manifest must not silently shrink the surface — fatal and loud, but
368
+ // rendered as the CLI's one red line, not an unhandled-rejection stack dump.
369
+ stderrLine("✗ ", e.message, c.red);
370
+ process.exit(1);
371
+ }
372
+ for (const cmd of commands) {
373
+ const problems = [
374
+ ...commandDeclarationProblems(cmd),
375
+ ...outputDeclarationProblems(cmd),
376
+ ...(cmd.subcommands ?? []).flatMap((sub) => outputDeclarationProblems({ name: `${cmd.name} ${sub.name}`, outputs: sub.outputs, flags: cmd.flags })),
377
+ ...globalFlagDeclarationProblems(cmd),
378
+ ];
379
+ if (problems.length)
380
+ usageExit(`internal error: ${problems.join("; ")}`);
381
+ }
382
+ setCommandSurface(commands); // the completion dispatcher reads the SAME surface help renders
383
+ return commands;
384
+ };
385
+ let commands = surface();
386
+ const [word, ...words] = argv;
387
+ if (word === undefined)
388
+ return printEntry(commands);
389
+ let cmd = findCommand(commands, word);
390
+ let rest = ownWords(cmd, words);
391
+ const wantsHelp = asksForHelp(rest);
392
+ if (cmd?.name === "service") {
393
+ try {
394
+ cmd = servicePresetCommand(cmd, rest);
395
+ }
396
+ catch (error) {
397
+ const failure = isCommandFailure(error) ? error : new CommandFailure("refused", "SCHEMA_INVALID", "service preset metadata could not be read; no provider was imported or installed");
398
+ failureExit(cmd, failure, asksForJson(cmd, rest), rest.includes("--plain"));
399
+ }
209
400
  }
401
+ // A seeded package's command (`web`) can be absent only because the first seed has not installed
402
+ // it yet, so running it seeds and resolves again. Asking for its help seeds nothing, and any other
403
+ // unknown word is a usage error.
404
+ const awaitingSeed = !cmd && opts.extensions === true && isSeededCommand(word) && !wantsHelp && !skipsSeed(word, rest[0], rest);
405
+ if (!cmd && !awaitingSeed)
406
+ usageExit(`unknown command: ${word} - run \`cotal help\` to list commands`);
210
407
  // `cotal <cmd> --help` / `-h` → that command's help, never run it. This intercept also covers
211
408
  // rawArgs commands and extension STUBS (cached specs are exactly the display surface) — only
212
409
  // `__`-internal ones are exempt, because __complete's argv is ANOTHER command's half-typed
213
410
  // line, where `--help` is a word being completed, not a request.
214
- if (!cmd.name.startsWith("__") && (rest.includes("--help") || rest.includes("-h"))) {
215
- commandHelp(cmd);
216
- return;
411
+ if (cmd && !cmd.name.startsWith("__") && wantsHelp)
412
+ return printHelpFor(cmd, rest);
413
+ let parsed = cmd && !isExtensionStub(cmd) ? parseOrExit(cmd, rest) : undefined;
414
+ // ---- Effects: only a validated invocation reaches this line. ----
415
+ // The seed can install or upgrade an extension package, so the surface is read again after it and
416
+ // an extension stub resolves against the manifest the seed left.
417
+ const controlOnlyManager = parsed?.values.execution === "none" && (cmd?.name === "supervise" || cmd?.name === "__daemon-manager");
418
+ if (opts.extensions && !controlOnlyManager && !skipsSeed(cmd?.name ?? word, parsed ? parsed.positionals[0] : rest[0], rest, cmd)) {
419
+ try {
420
+ await reconcileSeededConnectors();
421
+ }
422
+ catch (e) {
423
+ stderrLine("✗ ", e.message, c.red);
424
+ process.exit(1);
425
+ }
426
+ commands = surface();
427
+ cmd = findCommand(commands, word);
428
+ if (!cmd)
429
+ usageExit(`unknown command: ${word} - run \`cotal help\` to list commands`);
430
+ rest = ownWords(cmd, words);
217
431
  }
218
432
  // An extension stub materializes before parsing: verify the version pin, import the package
219
433
  // (self-registers), and parse with the LIVE specs — the cache never drives run's input.
220
- if (isExtensionStub(cmd)) {
434
+ if (cmd && isExtensionStub(cmd)) {
221
435
  try {
222
436
  cmd = await materializeExtensionCommand(cmd);
223
437
  }
224
438
  catch (e) {
225
- console.error(c.red(`✗ ${e.message}`));
439
+ stderrLine("✗ ", e.message, c.red);
226
440
  process.exit(1);
227
441
  }
442
+ parsed = parseOrExit(cmd, rest);
443
+ }
444
+ if (!cmd || !parsed)
445
+ throw new Error("internal error: dispatch reached its effects without a parsed command");
446
+ // A preferences file that does not validate stops every command, as a broken config file does, so
447
+ // nothing runs on a default the person did not mean. Help has already returned above.
448
+ if (!cmd.name.startsWith("__")) {
449
+ try {
450
+ cachedPreferences();
451
+ }
452
+ catch (e) {
453
+ if (!isCommandFailure(e))
454
+ throw e;
455
+ failureExit(cmd, e, structured(cmd, parsed.positionals[0]) && parsed.values.json === true, parsed.values.plain === true);
456
+ }
228
457
  }
458
+ // A failure raised after the command recorded the space it resolved is reported in that space.
459
+ const scope = {};
229
460
  try {
230
- const parsed = parseCommandArgs(cmd, rest);
231
461
  if (opts.extensions && cmd.requiredExtensions) {
232
462
  for (const ref of cmd.requiredExtensions(parsed))
233
463
  await materializeExtension(ref);
234
464
  }
235
465
  await prepareCatalogForCommand(cmd, parsed);
236
- if (cmd.prepare)
237
- await cmd.prepare(parsed);
238
- await cmd.run(parsed);
466
+ await runOperation(scope, async () => {
467
+ if (cmd.prepare)
468
+ await cmd.prepare(parsed);
469
+ await cmd.run(parsed);
470
+ });
239
471
  }
240
472
  catch (e) {
241
- // A bad flag/arg prints the command's help, not a stack trace. Trim node's verbose
242
- // "To specify a positional argument starting with a '-' …" tail to the first sentence.
243
- if (isArgError(e)) {
244
- const msg = e.message.split(".")[0];
245
- console.error(c.red(`✗ ${msg}`));
246
- commandHelp(cmd);
247
- process.exit(1);
473
+ const mode = parsed.positionals[0];
474
+ const json = structured(cmd, mode) && parsed.values.json === true;
475
+ // A usage error a command raises from its own checks prints the command's help, not a stack trace.
476
+ if (isArgError(e))
477
+ usageExit(e.message.split(".")[0], cmd, json);
478
+ if (isCommandFailure(e))
479
+ failureExit(cmd, inOperationSpace(e, scope.space), json, parsed.values.plain === true);
480
+ // A command that declares a structured output reports by the outcome table. A target it could
481
+ // not resolve or connect to is refused before any request, under the refusal's own code; a
482
+ // failure it did not classify is unknown: it may have had effects that cannot be attributed.
483
+ if (structured(cmd, mode)) {
484
+ if (isConnectRefusal(e))
485
+ failureExit(cmd, inOperationSpace(e.failure(), scope.space), json, parsed.values.plain === true);
486
+ if (isWorkspaceTargetError(e)) {
487
+ const { message, remedy } = workspaceErrorParts({ kind: "target", error: e });
488
+ failureExit(cmd, new CommandFailure("refused", targetErrorCode(e.code), message, remedy ? { remedy } : {}), json, parsed.values.plain === true);
489
+ }
490
+ if (e instanceof CatalogPreparationError)
491
+ failureExit(cmd, new CommandFailure("refused", e.code, e.message), json, parsed.values.plain === true);
492
+ failureExit(cmd, inOperationSpace(new CommandFailure("unknown", "OPERATION_UNKNOWN", e instanceof Error ? e.message : String(e)), scope.space), json, parsed.values.plain === true);
248
493
  }
249
494
  // A workspace TARGET error carries structured recovery — which entry, whether it was removed,
250
495
  // what to run next — and has its own renderer. Its raw `.message` is deliberately dev-safe
@@ -263,12 +508,12 @@ export async function runCli(registry, argv, opts = {}) {
263
508
  // contract is "denied, not absent", not a crash. The full stack stays available under
264
509
  // COTAL_DEBUG for diagnosis.
265
510
  const msg = e instanceof Error ? e.message : String(e);
266
- console.error(c.red(`✗ ${msg}`));
511
+ stderrLine("✗ ", msg, c.red);
267
512
  // Known failure signatures get a one-line operator hint (e.g. a stale-store durable
268
513
  // collision names the `cotal clean` reset) - the error itself stays verbatim.
269
514
  const hint = staleStoreHint(msg);
270
515
  if (hint)
271
- console.error(c.dim(` ↳ ${hint}`));
516
+ stderrLine(" ↳ ", hint, c.dim);
272
517
  if (process.env.COTAL_DEBUG && e instanceof Error && e.stack)
273
518
  console.error(c.dim(e.stack));
274
519
  process.exit(1);