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