@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
@@ -1,15 +1,23 @@
1
- import { readFileSync, rmSync, statSync } from "node:fs";
1
+ import { lstatSync, readFileSync, rmSync, statSync } from "node:fs";
2
+ import { homedir } from "node:os";
2
3
  import { join, resolve as resolvePath } from "node:path";
3
4
  import {} from "@cotal-ai/core";
4
- import { abortMaintenanceCut, acquireMaintenanceLock, assertSingleSpaceBroker, authDir, beginMaintenanceCut, clearPreservationCommitIntent, clearPreservationPrepareIntent, completeMaintenanceCut, loadMeshes, meshesForRoot, localProcessPath, localProcessPathCandidates, readMaintenanceJournal, readMaintenanceResumeDocument, readPreservationCommitIntent, readPreservationPrepareIntent, readStoreIdentity, recordPreservationManagerCommit, releaseMaintenanceLock, removeMeshesByRoot, resolveMeshTarget, sameStoreIdentity, writePreservationCommitIntent, writePreservationPrepareIntent, DELIVERY_PIDFILE, MANAGER_DELIVERY_AWARE_MARKER, MANAGER_PIDFILE, WEB_PIDFILE, MAINTENANCE_RESUME_DOCUMENT_VERSION, writeMaintenanceResumeDocument, loadSeatWriterGeneration, materializeFromManifest, seatCheckpointDir, } from "@cotal-ai/workspace";
5
+ import { CommandFailure, localRecordName, presentationOf, abortMaintenanceCut, acquireMaintenanceLock, assertSingleSpaceBroker, authDir, beginMaintenanceCut, clearPreservationCommitIntent, clearPreservationPrepareIntent, completeMaintenanceCut, loadMeshes, meshesForRoot, localProcessPath, localProcessPathCandidates, canonicalRoot, brokerAddressForDisplay, findMesh, localMeshesForRoot, writeResult, readMaintenanceJournal, readMaintenanceResumeDocument, readPreservationCommitIntent, readPreservationPrepareIntent, readStoreIdentity, recordPreservationManagerCommit, releaseMaintenanceLock, removeMeshesByRoot, sameStoreIdentity, writePreservationCommitIntent, writePreservationPrepareIntent, DELIVERY_PIDFILE, MANAGER_DELIVERY_AWARE_MARKER, MANAGER_PIDFILE, WEB_PIDFILE, MAINTENANCE_RESUME_DOCUMENT_VERSION, writeMaintenanceResumeDocument, loadSeatWriterGeneration, materializeFromManifest, seatCheckpointDir, } from "@cotal-ai/workspace";
5
6
  import { jetstreamManager } from "@nats-io/jetstream";
6
- import { DEV_OWNER, dialerFor, isReachable, LEASE_TTL_MS, MANAGER_LEASE_KEY, MANAGER_LEASE_TTL_MS, deliveryBucket, managerBucket, presenceBucket, parsePrincipalKey, principalKey, standaloneConnectOpts, } from "@cotal-ai/core";
7
- import { extensionNames, localProcessSurface } from "../ext-loader.js";
7
+ import { DEV_OWNER, dialerFor, isReachable, realDirNoSymlink, LEASE_TTL_MS, MANAGER_LEASE_KEY, MANAGER_LEASE_TTL_MS, deliveryBucket, managerBucket, presenceBucket, parsePrincipalKey, principalKey, standaloneConnectOpts, } from "@cotal-ai/core";
8
+ import { localProcessSurface } from "../ext-loader.js";
8
9
  import { c } from "../ui.js";
9
10
  import { cotalRoot } from "../lib/paths.js";
10
11
  import { parsePid, probeLiveness, readPidfile } from "@cotal-ai/workspace";
11
12
  import { resolveRuntimeSpace } from "../lib/status.js";
12
13
  import { downManifest } from "./down-manifest.js";
14
+ import { listLedgerFiles } from "../lib/manifest/ledger.js";
15
+ import { freshTeamAttemptSettled, listFreshTeamAttempts, listFreshTeamSummaries } from "../lib/team-fresh.js";
16
+ import { additiveTeamRecordedState, listAdditiveTeamAttempts, retainedAdditiveTeamAttempts } from "../lib/team-additive-attempt.js";
17
+ import { service, serviceComplete, validateServiceArguments } from "./service-registry.js";
18
+ import { stopNamedServiceSet } from "./service-set-stop.js";
19
+ import { readLocalServiceCensus } from "../lib/service-census.js";
20
+ import { assertBareDownServicesVerified, bareDownServicesView, planBareDownServices, stopBareDownServices } from "./down-services.js";
13
21
  import { askManager, resolveControlTarget } from "../lib/control.js";
14
22
  import { connectOrExit, userViewAuthOrExit } from "../lib/connect.js";
15
23
  import { waitForEndpointUnreachable } from "../lib/endpoint-cut.js";
@@ -17,124 +25,277 @@ import { captureSeatCheckpoint } from "../lib/seat-capture.js";
17
25
  import { processRecorded, stopLocalProcess } from "../lib/local-process-stop.js";
18
26
  import { stopManager } from "../lib/manager-proc.js";
19
27
  import { removeDeliveryCredentials, stopDelivery } from "../lib/delivery-proc.js";
28
+ import { controllerStackRecorded, stackDown, validateStackDownArguments } from "./stack-down.js";
20
29
  /** Complete selective component names without importing installed packages. */
21
30
  export function downComplete(argv) {
22
31
  if (argv.some((word) => word === "-f" || word === "--file" || word === "--run"))
23
32
  return { items: [], directive: "nofiles" };
24
33
  if ((argv[argv.length - 1] ?? "").startsWith("-"))
25
34
  return { items: [], directive: "nofiles" };
26
- const used = new Set(argv.slice(0, -1).filter((word) => !word.startsWith("-")));
27
- return {
28
- items: extensionNames("local-process").filter((name) => !used.has(name)).map((value) => ({ value })),
29
- directive: "nofiles",
30
- };
35
+ return serviceComplete(["stop", ...(argv.length ? argv : [""])]);
31
36
  }
32
- /** Stop the whole local stack by default, or only named self-registered process components. The
33
- * manifest forms remain ownership-scoped deploy teardown and cannot be mixed with components. */
37
+ function namedStopArguments(args) {
38
+ return { ...args, positionals: ["stop", args.positionals[0]] };
39
+ }
40
+ /** Named stops use only the owned-service controller. Multiple definitions require complete
41
+ * set selection, reservation and impact preflight. Legacy bare-stack integration stays separate. */
42
+ export function validateDownArguments(args) {
43
+ presentationOf(args.values);
44
+ if (args.positionals.length) {
45
+ for (const name of args.positionals)
46
+ localRecordName(name);
47
+ if (args.values["with-agents"] !== undefined)
48
+ throw new CommandFailure("refused", "USAGE_INVALID", "named down does not accept --with-agents; no flag was dropped", { remedy: "use cotal service stop <manager-name> --instance <full-id> --with-agents for the exact owned manager and its native impact review" });
49
+ if (args.values.instance !== undefined && args.positionals.length !== 1)
50
+ throw new CommandFailure("refused", "USAGE_INVALID", "--instance qualifies one service name, never a multi-service set");
51
+ const allowed = new Set(["space", "instance", "yes", "dry-run", "json", "plain"]);
52
+ if (Object.keys(args.values).some((name) => !allowed.has(name)))
53
+ throw new CommandFailure("refused", "USAGE_INVALID", "named down accepts only space, instance, confirmation, preview and presentation flags; no whole-stack or manifest option was ignored");
54
+ if (new Set(args.positionals).size !== args.positionals.length)
55
+ throw new CommandFailure("refused", "USAGE_INVALID", "name each service once; duplicate targets were not silently collapsed");
56
+ for (const name of args.positionals)
57
+ validateServiceArguments({ ...args, positionals: ["stop", name] });
58
+ return;
59
+ }
60
+ if (args.values.instance !== undefined)
61
+ throw new CommandFailure("refused", "USAGE_INVALID", "--instance needs one explicit service definition name");
62
+ if (controllerStackRecorded(cotalRoot()))
63
+ return validateStackDownArguments(cotalRoot(), args.values);
64
+ if (args.values["dry-run"] === true && args.values.yes === true)
65
+ throw new CommandFailure("refused", "USAGE_INVALID", "--yes acknowledges a guarded apply, not a read-only stack preview");
66
+ if ((args.values.json !== undefined || args.values.plain !== undefined) && args.values["dry-run"] === true && args.values.file === undefined && args.values.run === undefined && args.values["preserve-state"] === undefined && args.values["store-dir"] === undefined && args.values["session-store"] === undefined)
67
+ return;
68
+ if (args.values.yes !== undefined)
69
+ throw new CommandFailure("refused", "UNSUPPORTED", "--yes applies only to a controller stack, and this root has none; a bare stop here needs no --yes, and nothing was stopped", { remedy: "run `cotal down` from this root without --yes" });
70
+ if (args.values.json !== undefined || args.values.plain !== undefined)
71
+ throw new CommandFailure("refused", "UNSUPPORTED", "--json and --plain apply only to a controller stack or a --dry-run preview; a bare stop here prints its own lines, and nothing was stopped", { remedy: "run `cotal down` from this root without --json or --plain; `cotal down --dry-run --json` reads this root's stack" });
72
+ }
73
+ /** A bare stack preview is a local record census, never an effect plan or stop authority. */
74
+ function previewWholeStack(args) {
75
+ const root = canonicalRoot(cotalRoot());
76
+ const selectedSpace = args.values.space;
77
+ const target = { root, ...(selectedSpace ? { space: selectedSpace } : {}) };
78
+ if (root === canonicalRoot(homedir()))
79
+ throw new CommandFailure("refused", "CONFLICT", "the machine home is not an isolated project root for a whole-stack preview", { target });
80
+ let mesh;
81
+ let maintenance;
82
+ let components;
83
+ let services, serviceStops;
84
+ let additiveRecords, additiveAttempts;
85
+ let bootAttempts, bootSummaries;
86
+ let otherBrokerRegistrations;
87
+ // A root with no control directory, or with no stack registered at it, holds no stack. That is a
88
+ // plain miss, not records that could not be read.
89
+ const noStack = () => new CommandFailure("refused", "TARGET_NOT_FOUND", "there is no stack at this folder's root, so there is nothing to preview", { target, remedy: "run `cotal down --dry-run` from the folder where `cotal up` started the stack" });
90
+ try {
91
+ try {
92
+ lstatSync(join(root, ".cotal"));
93
+ }
94
+ catch (error) {
95
+ if (error.code === "ENOENT")
96
+ throw noStack();
97
+ throw error;
98
+ }
99
+ if (!realDirNoSymlink(root, ".cotal"))
100
+ throw new Error("missing project control directory");
101
+ const local = localMeshesForRoot(root), sole = local[0];
102
+ if (!local.length)
103
+ throw noStack();
104
+ if (local.length !== 1 || sole?.origin !== "up")
105
+ throw new Error("no unique locally started stack at this root");
106
+ const candidate = selectedSpace ? findMesh(selectedSpace) : sole;
107
+ if (!candidate || candidate.origin !== "up" || candidate.space !== sole.space || canonicalRoot(candidate.root) !== root)
108
+ throw new Error("space does not belong to the selected root");
109
+ mesh = candidate;
110
+ assertSingleSpaceBroker(authDir(root), "down preview");
111
+ otherBrokerRegistrations = loadMeshes().filter((row) => row.space !== mesh.space && row.server === mesh.server)
112
+ .map((row) => ({ space: row.space, root: row.root, origin: row.origin ?? "not recorded" }));
113
+ maintenance = readMaintenanceJournal(root);
114
+ const context = { root, space: mesh.space };
115
+ components = localProcessSurface().map((component) => {
116
+ const pidfile = localProcessPath(component.pidFile, context);
117
+ const state = pidfileState(pidfile);
118
+ return { name: component.name, label: component.label, pidfile, recorded: processRecorded(component, context), liveness: state.liveness, pid: state.pid ?? null, note: state.note ?? null };
119
+ });
120
+ services = readLocalServiceCensus(mesh.space);
121
+ serviceStops = planBareDownServices(mesh.space);
122
+ additiveRecords = listLedgerFiles(root, { requireReadable: true });
123
+ additiveAttempts = listAdditiveTeamAttempts(root);
124
+ bootAttempts = listFreshTeamAttempts(root);
125
+ bootSummaries = listFreshTeamSummaries(root);
126
+ }
127
+ catch (error) {
128
+ if (error instanceof CommandFailure)
129
+ throw error;
130
+ throw new CommandFailure("refused", "CONFLICT", "the local stack, process or service records, or maintenance state could not be inspected consistently; no stop target was inferred", { target });
131
+ }
132
+ const byBootId = new Map(bootSummaries.valid.map((summary) => [summary.deploymentId, summary]));
133
+ const unsettledBootAttempts = bootAttempts.valid.filter((attempt) => !freshTeamAttemptSettled(attempt, byBootId.get(attempt.deploymentId)));
134
+ const result = { kind: "whole-stack-local-preview", space: mesh.space, root, recordedBroker: brokerAddressForDisplay(mesh.server) ?? null,
135
+ maintenance: maintenance?.state ?? "none-recorded", withAgentsRequested: args.values["with-agents"] === true,
136
+ components, ...services, serviceStops, otherBrokerRegistrations,
137
+ additiveLedgers: additiveRecords.valid.map(({ ledger }) => ({ deploymentId: ledger.runId, space: ledger.space, agents: ledger.created.agents.length, channels: ledger.created.channels.length })),
138
+ unreadableAdditiveLedgers: additiveRecords.refused.map(({ path }) => path),
139
+ retainedAdditiveAttempts: additiveAttempts.valid.map((attempt) => ({ deploymentId: attempt.deploymentId, space: attempt.space, server: brokerAddressForDisplay(attempt.server) ?? "not displayable", createdAt: attempt.createdAt, recordedState: additiveTeamRecordedState(attempt, additiveAttempts) })),
140
+ unreadableAdditiveAttempts: additiveAttempts.refused.map(({ path }) => path),
141
+ unsettledBootAttempts: unsettledBootAttempts.map((attempt) => ({ deploymentId: attempt.deploymentId, space: attempt.space, server: brokerAddressForDisplay(attempt.server) ?? "not displayable", createdAt: attempt.createdAt })),
142
+ unreadableBootRecords: [...bootAttempts.refused, ...bootSummaries.refused].map(({ path }) => path),
143
+ brokerSharing: "exact recorded address matches only; aliases and live tenants not checked", agentImpact: "not-established", serviceInstanceScope: "selected-space workstation records only; root ownership and live state not established",
144
+ dryRun: true, effectAttempted: false, reserved: false };
145
+ writeResult(presentationOf(args.values), { command: "down", target: { root, space: mesh.space }, result,
146
+ completeness: "partial", partial: { message: "Pidfiles, additive ledgers, service records, supervisor receipts and retained attempts are not a complete owned stack or native agent-impact plan. No process identity, service root ownership, broker sharing or stop authority was established." } }, (data) => ({ sections: [
147
+ { title: "Whole-stack local inspection", blocks: [{ kind: "fields", rows: [["Space", data.space], ["Root", data.root], ["Maintenance", data.maintenance], ["Saved service definitions", String(data.serviceDefinitions.length)], ["Saved service instances", String(data.serviceRecords.length)], ["Supervisor receipts", String(data.supervisors.length)], ["Retained native attempts", String(data.nativeAttempts.length)], ["Other exact-address registrations", String(data.otherBrokerRegistrations.length)], ["Additive ledgers", String(data.additiveLedgers.length)], ["Unreadable additive ledgers", String(data.unreadableAdditiveLedgers.length)], ["Retained additive deployments", String(data.retainedAdditiveAttempts.length)], ["Unreadable additive attempts", String(data.unreadableAdditiveAttempts.length)], ["Unsettled fresh attempts", String(data.unsettledBootAttempts.length)], ["Unreadable fresh records", String(data.unreadableBootRecords.length)], ["Deprovision agents", data.withAgentsRequested ? "requested; impact unknown" : "not requested; process impact unknown"], ["Stop authority", "not established"]] }, { kind: "lines", lines: [{ text: "This is a read of local records, not a stop plan. Liveness does not prove identity, and service, broker-sharing and agent consequences are not checked. No process was signalled.", tone: "waiting" }] }] },
148
+ { title: "Recorded broker address matches", blocks: [data.otherBrokerRegistrations.length ? { kind: "table", columns: [{ key: "space", label: "Other space" }, { key: "root", label: "Recorded root" }, { key: "origin", label: "Registration" }], rows: data.otherBrokerRegistrations.slice(0, 100) } : { kind: "lines", lines: ["No other registration uses this exact broker address in the local workstation registry."] }, { kind: "lines", lines: [...(data.otherBrokerRegistrations.length > 100 ? ["Additional exact-address matches are in JSON."] : []), "An exact-address match is a sharing warning. No match is not proof of an exclusive broker: aliases, remote tenants and live attachments were not checked."] }] },
149
+ { title: "Recorded additive deployments", blocks: [data.additiveLedgers.length ? { kind: "table", columns: [{ key: "id", label: "Deployment" }, { key: "space", label: "Recorded space" }, { key: "agents", label: "Agent rows" }, { key: "channels", label: "Channel rows" }], rows: data.additiveLedgers.slice(0, 100).map((row) => ({ id: row.deploymentId, space: row.space, agents: String(row.agents), channels: String(row.channels) })) } : { kind: "lines", lines: ["No readable additive ledgers under this project root."] }, { kind: "lines", lines: [...(data.additiveLedgers.length > 100 ? ["Additional additive ledgers are in JSON."] : []), ...data.unreadableAdditiveLedgers.slice(0, 100).map((path) => `Unreadable ledger: ${path}`), ...(data.unreadableAdditiveLedgers.length > 100 ? ["Additional unreadable paths are in JSON."] : []), "An additive ledger is not whole-stack ownership. A recorded or unreadable one blocks the retained bare apply; this preview changes nothing."] }] },
150
+ { title: "Retained additive deployments", blocks: [data.retainedAdditiveAttempts.length ? { kind: "table", columns: [{ key: "id", label: "Deployment" }, { key: "space", label: "Space" }, { key: "state", label: "Recorded state" }, { key: "time", label: "Intent recorded" }], rows: data.retainedAdditiveAttempts.slice(0, 100).map((attempt) => ({ id: attempt.deploymentId, space: attempt.space, state: attempt.recordedState, time: attempt.createdAt })) } : { kind: "lines", lines: ["No readable additive attempts under this root."] }, { kind: "lines", lines: [...data.unreadableAdditiveAttempts.slice(0, 100).map((path) => `Unreadable additive attempt: ${path}`), ...(data.retainedAdditiveAttempts.length > 100 || data.unreadableAdditiveAttempts.length > 100 ? ["Additional attempts or paths are in JSON."] : []), "Unsettled or unremoved additive deployments block the legacy bare stop. A full matched static agent-retirement receipt releases only its original deployment's blocker; all other ownership and process guards remain."] }] },
151
+ { title: "Fresh boot attempts", blocks: [data.unsettledBootAttempts.length ? { kind: "table", columns: [{ key: "deploymentId", label: "Deployment" }, { key: "space", label: "Space" }, { key: "server", label: "Recorded broker" }, { key: "createdAt", label: "Intent recorded" }], rows: data.unsettledBootAttempts.slice(0, 100) } : { kind: "lines", lines: ["No unsettled readable fresh boot attempts under this root."] }, { kind: "lines", lines: [...data.unreadableBootRecords.slice(0, 100).map((path) => `Unreadable fresh record: ${path}`), ...(data.unsettledBootAttempts.length > 100 || data.unreadableBootRecords.length > 100 ? ["Additional attempts or unreadable paths are in JSON."] : []), "An unsettled fresh attempt or unreadable record blocks the retained bare apply; a missing summary does not prove the broker never started."] }] },
152
+ { title: "Local process records", blocks: [data.components.length ? { kind: "table", columns: [{ key: "name", label: "Component" }, { key: "state", label: "Pidfile probe" }, { key: "record", label: "Recorded" }, { key: "pid", label: "PID" }], rows: data.components.map((row) => ({ name: row.label, state: row.liveness, record: row.recorded ? "yes" : "no", pid: row.pid === null ? "not pinned" : String(row.pid) })) } : { kind: "lines", lines: ["No local process descriptors were found."] }] },
153
+ { title: "Selected-space service definitions", blocks: [data.serviceDefinitions.length ? { kind: "table", columns: [{ key: "name", label: "Definition" }, { key: "launch", label: "Launch type" }, { key: "instances", label: "Instance records" }], rows: data.serviceDefinitions.slice(0, 100).map((row) => ({ name: row.name, launch: row.launch, instances: String(row.instanceRecords) })) } : { kind: "lines", lines: ["No saved service definitions in this space's workstation store."] }, ...(data.serviceDefinitions.length > 100 ? [{ kind: "lines", lines: ["Additional definitions are in JSON."] }] : [])] },
154
+ { title: "Selected-space service instances", blocks: [data.serviceRecords.length ? { kind: "table", columns: [{ key: "definition", label: "Definition" }, { key: "instance", label: "Full instance" }, { key: "state", label: "Recorded state" }, { key: "host", label: "Recorded host" }], rows: data.serviceRecords.slice(0, 100).map((row) => ({ definition: row.definition, instance: row.instanceId, state: row.recordedState, host: row.host })) } : { kind: "lines", lines: ["No saved service instances in this space's workstation store."] }, { kind: "lines", lines: [...(data.serviceRecords.length > 100 ? ["Additional service records are in JSON."] : []), "These records are scoped by space, not proven owned by this project root. Their recorded state is not live process or supervisor status; the next section observes each process on this host."] }] },
155
+ ...(data.serviceStops.length ? bareDownServicesView(data.space, data.serviceStops).sections : [{ title: "Services bare down stops first", blocks: [{ kind: "lines", lines: ["No saved service instance in this space, so bare down stops no service first."] }] }]),
156
+ { title: "Recorded native supervisors", blocks: [data.supervisors.length ? { kind: "table", columns: [{ key: "definition", label: "Definition" }, { key: "instance", label: "Full instance" }, { key: "mechanism", label: "Mechanism" }, { key: "unit", label: "Recorded unit" }], rows: data.supervisors.slice(0, 100).map((row) => ({ definition: row.definition, instance: row.instanceId, mechanism: row.mechanism, unit: row.unit })) } : { kind: "lines", lines: ["No supervisor receipts in this space's workstation store."] }, { kind: "lines", lines: [...(data.supervisors.length > 100 ? ["Additional supervisor receipts are in JSON."] : []), "A receipt is not a live unit observation or authority to stop it. No native service status request was made."] }] },
157
+ { title: "Retained native attempts", blocks: [data.nativeAttempts.length ? { kind: "table", columns: [{ key: "kind", label: "Action" }, { key: "definition", label: "Definition" }, { key: "instance", label: "Full instance" }, { key: "step", label: "Step" }, { key: "position", label: "Position" }], rows: data.nativeAttempts.slice(0, 100).map((row) => ({ kind: row.kind, definition: row.definition, instance: row.instanceId, step: row.step, position: row.position })) } : { kind: "lines", lines: ["No retained install, uninstall or unit-action attempts in this space's workstation store."] }, { kind: "lines", lines: [...(data.nativeAttempts.length > 100 ? ["Additional attempts and their full IDs are in JSON."] : []), "A submitted or unknown step may already have changed native state. This preview neither reconciles nor retries it."] }] },
158
+ ] }));
159
+ }
160
+ /** Keep the retained pidfile sweep from crossing an exact recorded broker-sharing boundary, and
161
+ * return the space's service instances it stops first, each one verified. This is not a complete
162
+ * live ownership or agent-impact proof. */
163
+ function guardLegacyBareDown() {
164
+ const root = canonicalRoot(cotalRoot());
165
+ const target = { root };
166
+ if (root === canonicalRoot(homedir()))
167
+ throw new CommandFailure("refused", "CONFLICT", "the machine home is not an isolated whole-stack stop root; no process was signalled", { target });
168
+ let mesh;
169
+ try {
170
+ if (!realDirNoSymlink(root, ".cotal"))
171
+ throw new Error("missing project control directory");
172
+ // A root that hosts several spaces refuses before the registration lookup, naming them.
173
+ try {
174
+ assertSingleSpaceBroker(authDir(root), "bare down");
175
+ }
176
+ catch (error) {
177
+ throw new CommandFailure("refused", "CONFLICT", error.message, { target });
178
+ }
179
+ const local = localMeshesForRoot(root), sole = local[0];
180
+ if (local.length !== 1 || sole?.origin !== "up")
181
+ throw new Error("no unique locally started stack at this root");
182
+ mesh = sole;
183
+ }
184
+ catch (error) {
185
+ if (error instanceof CommandFailure)
186
+ throw error;
187
+ throw new CommandFailure("refused", "CONFLICT", "the local root has no unique owned stack registration and real control directory; no whole-stack stop target was inferred", { target });
188
+ }
189
+ const scoped = { root, space: mesh.space };
190
+ const maintenance = readMaintenanceJournal(root);
191
+ // A validated active restore is complete, so its retained journal does not fence ordinary stop.
192
+ // Pending transitions and a journal naming another space still cannot authorize this sweep.
193
+ if (maintenance && (maintenance.state !== "active" || maintenance.space !== mesh.space))
194
+ throw new CommandFailure("refused", "LIFECYCLE_BLOCKED", "this stack retains a maintenance transition; ordinary bare down did not bypass it", { target: { ...scoped, state: maintenance.state } });
195
+ let ledgers;
196
+ try {
197
+ ledgers = listLedgerFiles(root, { requireReadable: true });
198
+ }
199
+ catch {
200
+ throw new CommandFailure("refused", "TARGET_UNAVAILABLE", "the root's additive ledger directory could not be inspected; bare down did not infer that it owns every resource", { target: scoped });
201
+ }
202
+ if (ledgers.valid.length || ledgers.refused.length)
203
+ throw new CommandFailure("refused", "LIFECYCLE_BLOCKED", "additive ownership ledgers or unreadable ledger records remain under this root; bare down did not adopt or stop their resources", { target: { ...scoped, deploymentIds: ledgers.valid.map(({ ledger }) => ledger.runId), unreadable: ledgers.refused.map(({ path }) => path) }, remedy: "finish each additive deployment's own lifecycle before a guarded whole-stack stop" });
204
+ let additiveAttempts;
205
+ try {
206
+ additiveAttempts = listAdditiveTeamAttempts(root);
207
+ }
208
+ catch {
209
+ throw new CommandFailure("refused", "TARGET_UNAVAILABLE", "the additive attempt inventory could not be read; bare down did not infer an empty resource set", { target: scoped });
210
+ }
211
+ if (retainedAdditiveTeamAttempts(additiveAttempts).length || additiveAttempts.refused.length)
212
+ throw new CommandFailure("refused", "LIFECYCLE_BLOCKED", "an additive attempt or returned additive deployment remains under this root; legacy bare down did not adopt its resources", { target: { ...scoped, deploymentIds: retainedAdditiveTeamAttempts(additiveAttempts).map((attempt) => attempt.deploymentId), unreadable: additiveAttempts.refused.map(({ path }) => path) } });
213
+ let attempts, summaries;
214
+ try {
215
+ attempts = listFreshTeamAttempts(root);
216
+ summaries = listFreshTeamSummaries(root);
217
+ }
218
+ catch {
219
+ throw new CommandFailure("refused", "TARGET_UNAVAILABLE", "fresh boot attempt or summary records could not be read; bare down did not infer stop authority", { target: scoped });
220
+ }
221
+ const returned = new Map(summaries.valid.map((summary) => [summary.deploymentId, summary]));
222
+ const unsettled = attempts.valid.filter((attempt) => !freshTeamAttemptSettled(attempt, returned.get(attempt.deploymentId)));
223
+ if (unsettled.length || attempts.refused.length || summaries.refused.length)
224
+ throw new CommandFailure("refused", "LIFECYCLE_BLOCKED", "a fresh boot attempt is unsettled or a boot record unreadable; legacy bare down did not stop a process whose original launch outcome is unknown", { target: { ...scoped, unsettledIds: unsettled.map((row) => row.deploymentId), unreadable: [...attempts.refused, ...summaries.refused].map(({ path }) => path) }, remedy: "inspect the original boot and process custody before any stop; the pidfile sweep is not recovery" });
225
+ const other = loadMeshes().filter((row) => row.space !== mesh.space && row.server === mesh.server);
226
+ if (other.length)
227
+ throw new CommandFailure("refused", "LIFECYCLE_BLOCKED", "another registered space names this exact broker address; bare down did not stop its shared listener", { target: { ...scoped, otherSpaces: other.map((row) => row.space) }, remedy: "inspect both registrations and their native ownership; an exact-address match is a blocker, while no match does not prove exclusivity" });
228
+ const services = planBareDownServices(mesh.space);
229
+ assertBareDownServicesVerified(mesh.space, services);
230
+ return { space: mesh.space, services };
231
+ }
232
+ /** One named service is a thin native-controller alias. The retained bare-stack and manifest
233
+ * paths below have not yet been replaced by the approved whole-stack controller. */
34
234
  export async function down(args) {
235
+ validateDownArguments(args);
236
+ if (args.positionals.length > 1)
237
+ return stopNamedServiceSet(args);
238
+ if (args.positionals.length)
239
+ return service(namedStopArguments(args), "down");
240
+ // A root whose stack the service controller owns stops only through its recorded members.
241
+ if (controllerStackRecorded(cotalRoot()))
242
+ return stackDown(cotalRoot(), args.values);
35
243
  const values = args.values;
36
- const requested = [...new Set(args.positionals)];
244
+ if (values["dry-run"] && !values.file && !values.run && !values["preserve-state"] && !values["store-dir"] && !values["session-store"]?.length)
245
+ return previewWholeStack(args);
37
246
  if (values["preserve-state"] && values["with-agents"])
38
- throw new Error("--preserve-state cannot be combined with --with-agents");
39
- if (values["with-agents"] && (requested.length || values.file || values.run || values.space))
40
- throw new Error("--with-agents is bare-whole-stack only and cannot be combined with components, --space, --file, or --run");
247
+ throw new CommandFailure("refused", "USAGE_INVALID", "--preserve-state cannot be combined with --with-agents");
248
+ if (values["with-agents"] && (values.file || values.run || values.space))
249
+ throw new CommandFailure("refused", "USAGE_INVALID", "--with-agents is bare-whole-stack only and cannot be combined with components, --space, --file, or --run");
41
250
  if (values["preserve-state"]) {
42
- if (requested.length || values.file || values.run || values["dry-run"] || values.space)
43
- throw new Error("--preserve-state is bare-whole-stack only and cannot be combined with components, --space, --file, --run, or --dry-run");
251
+ if (values.file || values.run || values["dry-run"] || values.space)
252
+ throw new CommandFailure("refused", "USAGE_INVALID", "--preserve-state is bare-whole-stack only and cannot be combined with components, --space, --file, --run, or --dry-run");
44
253
  assertSingleSpaceBroker(authDir(cotalRoot()), "cotal down");
45
254
  await preserveStateDown(values["store-dir"], assertSessionStores(values["session-store"] ?? []));
46
255
  return;
47
256
  }
48
257
  if (values["store-dir"])
49
- throw new Error("--store-dir is only valid with down --preserve-state");
258
+ throw new CommandFailure("refused", "USAGE_INVALID", "--store-dir is only valid with down --preserve-state");
50
259
  if (values["session-store"]?.length)
51
- throw new Error("--session-store is only valid with down --preserve-state");
52
- if ((values.file || values.run) && (requested.length || values.space)) {
53
- throw new Error("component names and --space cannot be combined with --file or --run");
260
+ throw new CommandFailure("refused", "USAGE_INVALID", "--session-store is only valid with down --preserve-state");
261
+ if ((values.file || values.run) && values.space) {
262
+ throw new CommandFailure("refused", "USAGE_INVALID", "component names and --space cannot be combined with --file or --run");
54
263
  }
55
264
  if (values.file || values.run) {
56
265
  await downManifest(values.file ?? "<run>", { run: values.run, dryRun: Boolean(values["dry-run"]) });
57
266
  return;
58
267
  }
59
- if (values.space && !requested.length)
60
- throw new Error("--space only selects the mesh for target-addressed components - name them (e.g. `cotal down web --space <name>`); bare `cotal down` always stops this folder's stack");
61
- const all = localProcessSurface();
62
- const known = all.map((component) => component.name).sort();
63
- const unknown = requested.filter((name) => !known.includes(name));
64
- if (unknown.length)
65
- throw new Error(`unknown component${unknown.length > 1 ? "s" : ""} ${unknown.map((name) => JSON.stringify(name)).join(", ")} - known: ${known.join(", ")}`);
66
- const selected = (requested.length ? requested.map((name) => all.find((part) => part.name === name)) : all)
268
+ if (values.space)
269
+ throw new CommandFailure("refused", "USAGE_INVALID", "a bare stop takes no --space: `cotal down` stops the stack recorded at this folder's root", {
270
+ target: { root: cotalRoot(), space: values.space },
271
+ remedy: "run `cotal down` without --space from the stack's root; to stop one saved service, run `cotal service stop <service-name> --space <space>`",
272
+ });
273
+ const guarded = guardLegacyBareDown();
274
+ // Every dry run returned or was refused above, so from here on this is the whole-stack stop of
275
+ // this folder's root. Its services stop first, through the service controller.
276
+ await stopBareDownServices(guarded.space, guarded.services, { style: "rich", withAgents: values["with-agents"] === true });
277
+ const selected = localProcessSurface()
67
278
  .sort((a, b) => Number(Boolean(a.stopLast)) - Number(Boolean(b.stopLast)) || (a.order ?? 50) - (b.order ?? 50));
68
- // A component whose START is target-resolved (`rootedAt: "target"` — the web dashboard) records
69
- // its pidfile under the TARGET mesh's root, so a selective stop resolves the SAME mesh the start
70
- // side did (registry current mesh first, `--space` to name one) instead of assuming this folder.
71
- // Bare `cotal down` stays a sweep of this folder's stack: its pidfiles live here, and reaching
72
- // into another mesh's root mid-sweep would stop a process the folder's broker does not own.
73
- const targetAddressed = (component) => requested.length > 0 && component.rootedAt === "target";
74
- if (values.space) {
75
- const folderRooted = selected.filter((component) => !targetAddressed(component));
76
- if (folderRooted.length)
77
- throw new Error(`--space only applies to target-addressed components - ${folderRooted.map((component) => component.name).join(", ")} always stop${folderRooted.length === 1 ? "s" : ""} under this folder's root`);
78
- }
79
279
  // A `down` that touches this folder's stack stops the shared broker and its per-space daemons;
80
280
  // none of them can address one space, so a multi-space root is refused up front rather than at
81
- // the space-blind pidfile lookup below. A purely target-addressed stop never reads this folder's
82
- // pidfiles, so it is exempt (its space comes from the resolved mesh target).
83
- if (selected.some((component) => !targetAddressed(component)))
84
- assertSingleSpaceBroker(authDir(cotalRoot()), "cotal down");
85
- // Both contexts resolve lazily: a purely target-addressed stop must not require a mesh root at
86
- // the cwd, and a folder sweep must not require a resolvable mesh target.
281
+ // the space-blind pidfile lookup below.
282
+ assertSingleSpaceBroker(authDir(cotalRoot()), "cotal down");
87
283
  let folderContext;
88
284
  const folderCtx = () => (folderContext ??= { root: cotalRoot(), space: resolveRuntimeSpace(process.cwd()) });
89
- let targetContext;
90
- const contextFor = (component) => {
91
- if (!targetAddressed(component))
92
- return folderCtx();
93
- if (!targetContext) {
94
- const target = resolveMeshTarget(process.cwd(), values.space ? { space: values.space } : {});
95
- targetContext = { root: target.root, space: target.space };
96
- }
97
- return targetContext;
98
- };
99
- if (selected.some((component) => component.stopLast)) {
100
- const selectedNames = new Set(selected.map((component) => component.name));
101
- // Fail CLOSED: an unselected dependant that MIGHT be running (including one behind an
102
- // unattributable/unknown pidfile) blocks a stop-last shutdown - stopping the broker out from
103
- // under a live dependant we could not confirm gone is exactly the signer-orphan the contract
104
- // forbids. `mayBeRunning`, not `processAlive` (which reads uncertainty as "not running").
105
- // Folder context: the question is what depends on THIS folder's broker, so a dependant is
106
- // judged by the record under this root regardless of how it would be addressed selectively.
107
- const dependants = all.filter((component) => !selectedNames.has(component.name) && mayBeRunning(component, folderCtx()));
108
- if (dependants.length) {
109
- throw new Error(`cannot stop ${selected.filter((component) => component.stopLast).map((component) => component.name).join(", ")} while ${dependants.map((component) => component.name).join(", ")} ${dependants.length === 1 ? "is" : "are"} still running (or its liveness cannot be confirmed) - name them too, or run bare \`cotal down\``);
110
- }
111
- }
112
- if (values["dry-run"]) {
113
- const recorded = selected.filter((component) => processRecorded(component, contextFor(component)));
114
- for (const component of recorded)
115
- console.log(c.dim(`would stop ${component.label}`));
116
- if (!recorded.length) {
117
- const target = requested.length ? requested.join(", ") : "the local stack";
118
- console.error(c.red(`Nothing running for ${target} (no recorded pidfiles).`));
119
- process.exit(1);
120
- }
121
- console.log(c.dim("Dry run - nothing was changed. Re-run without --dry-run to stop these components."));
122
- return;
123
- }
124
285
  let any = false;
125
286
  let allStopped = true;
126
287
  for (const component of selected) {
127
- any = processRecorded(component, contextFor(component)) || any;
288
+ any = processRecorded(component, folderCtx()) || any;
128
289
  if (component.stopLast && !allStopped) {
129
290
  console.error(c.red(`✗ not stopping ${component.label} because an earlier component did not stop`));
130
291
  continue;
131
292
  }
132
293
  try {
133
- const context = contextFor(component);
294
+ const context = folderCtx();
134
295
  if (component.name === "manager")
135
296
  await stopManager(context.space, { withAgents: values["with-agents"] });
136
297
  else if (component.name === "delivery")
137
- await stopDelivery(context.space, { preserveCredentials: !requested.length });
298
+ await stopDelivery(context.space, { preserveCredentials: true });
138
299
  else
139
300
  await stopLocalProcess(component, context);
140
301
  }
@@ -148,11 +309,11 @@ export async function down(args) {
148
309
  process.exitCode = 1;
149
310
  return;
150
311
  }
151
- if (!requested.length && selected.some((component) => component.name === "delivery"))
312
+ if (selected.some((component) => component.name === "delivery"))
152
313
  await removeDeliveryCredentials(folderCtx().space);
153
314
  for (const component of selected) {
154
315
  for (const artifact of component.artifacts ?? [])
155
- rmSync(localProcessPath(artifact, contextFor(component)), { force: true });
316
+ rmSync(localProcessPath(artifact, folderCtx()), { force: true });
156
317
  }
157
318
  // Pidfiles are the only thing this stack owns. A registered broker that answers with no pidfile
158
319
  // is a different situation: something is running that `down` did not start and must not stop.
@@ -161,27 +322,24 @@ export async function down(args) {
161
322
  // Owned components (a detached web, a manager) do not change the question: stopping them is not
162
323
  // the same as this stack owning the broker. The probe runs on every bare down that holds no
163
324
  // nats pidfile, AFTER their owned artifacts cleared, so those components stop exactly as they
164
- // do with no broker present. Targeted stops and --dry-run stay pidfile-only.
165
- if (!requested.length && !values["dry-run"]) {
166
- const unowned = await liveUnownedBrokers(folderCtx());
167
- if (unowned.length) {
168
- for (const broker of unowned) {
169
- console.error(c.red(`Broker for "${broker.space}" is running at ${broker.server}, but no pidfile records it. ` +
170
- `cotal down will not stop a process it did not start. ` +
171
- `Stop that broker with the supervisor that started it, or remove the registration with \`cotal meshes rm ${broker.space}\`.`));
172
- }
173
- process.exit(1);
325
+ // do with no broker present.
326
+ const unowned = await liveUnownedBrokers(folderCtx());
327
+ if (unowned.length) {
328
+ for (const broker of unowned) {
329
+ console.error(c.red(`Broker for "${broker.space}" is running at ${broker.server}, but no pidfile records it. ` +
330
+ `cotal down will not stop a process it did not start. ` +
331
+ `Stop that broker with the supervisor that started it, or remove the registration with \`cotal meshes rm ${broker.space}\`.`));
174
332
  }
333
+ process.exit(1);
175
334
  }
176
- // The broker owns the mesh registry entry and transient whole-mesh launch material. Selective
177
- // control-plane shutdown leaves both intact so `cotal up` can heal only what was stopped.
335
+ // The broker owns the mesh registry entry and transient whole-mesh launch material, so they go
336
+ // with it.
178
337
  if (selected.some((component) => component.clearsMesh)) {
179
338
  rmSync(join(folderCtx().root, ".cotal", "run"), { recursive: true, force: true });
180
339
  removeMeshesByRoot(folderCtx().root);
181
340
  }
182
341
  if (!any) {
183
- const target = requested.length ? requested.join(", ") : "the local stack";
184
- console.error(c.red(`Nothing running for ${target} (no recorded pidfiles).`));
342
+ console.error(c.red("Nothing running for the local stack (no recorded pidfiles)."));
185
343
  process.exit(1);
186
344
  }
187
345
  }
@@ -212,14 +370,14 @@ export function processAlive(component, context) {
212
370
  const pid = parsePid(raw);
213
371
  return pid !== undefined && isAlive(pid);
214
372
  }
215
- /** Whether a component MIGHT still be running - the question the pre-stop `stopLast` guard must ask,
216
- * and it fails CLOSED on uncertainty. A component with NO pidfile, an EMPTY husk, or a valid pid
217
- * PROVEN dead (ESRCH) is not running. ANY other state - an unparsable/unattributable record, or a
218
- * valid pid that is alive or whose liveness cannot be confirmed (`unknown`) - MIGHT be running, so
219
- * it must BLOCK a stop-last (broker) shutdown. `processAlive` collapses unparsable and `unknown` to
220
- * "not alive", which is fine for "is it worth stopping" but WRONG for "is it safe to stop the broker
221
- * out from under this": that read would let `cotal down nats` orphan a live auth signer behind a
222
- * torn pidfile. Only an ESRCH-confirmed death (or no record) clears a dependant. */
373
+ /** Whether a component MIGHT still be running. It fails CLOSED on uncertainty. A component with NO
374
+ * pidfile, an EMPTY husk, or a valid pid PROVEN dead (ESRCH) is not running. ANY other state - an
375
+ * unparsable/unattributable record, or a valid pid that is alive or whose liveness cannot be
376
+ * confirmed (`unknown`) - MIGHT be running. `down --preserve-state` asks it to fence an uncertain
377
+ * delivery daemon, to treat an uncertain manager as alive, and to refuse to call a cut complete.
378
+ * `processAlive` collapses unparsable and `unknown` to "not alive", which is fine for "is it worth
379
+ * stopping" but WRONG for those questions: it would count a live auth signer behind a torn pidfile
380
+ * as stopped. Only an ESRCH-confirmed death (or no record) clears a component. */
223
381
  export function mayBeRunning(component, context) {
224
382
  const raw = readPidfile(localProcessPath(component.pidFile, context));
225
383
  if (!raw)
@@ -231,7 +389,7 @@ export function mayBeRunning(component, context) {
231
389
  }
232
390
  /** The principal keys of every retained agent in a preservation inventory — the dot-form ids that
233
391
  * appear in the presence roster, so a caller can tell which retained agents are still live. */
234
- function retainedPrincipalKeys(inventory) {
392
+ export function retainedPrincipalKeys(inventory) {
235
393
  const agents = (inventory.agents ?? []);
236
394
  return new Set(agents.map((agent) => {
237
395
  if (agent.identity?.mode === "user" && agent.identity.owner && agent.identity.actor)
@@ -258,10 +416,10 @@ function assertSessionStores(paths) {
258
416
  stat = statSync(resolved);
259
417
  }
260
418
  catch (error) {
261
- throw new Error(`--session-store ${resolved} cannot be read (${error.code ?? error.message}); name the harness transcript store directory for this host`);
419
+ throw new CommandFailure("refused", "USAGE_INVALID", `--session-store ${resolved} cannot be read (${error.code ?? error.message}); name the harness transcript store directory for this host`);
262
420
  }
263
421
  if (!stat.isDirectory())
264
- throw new Error(`--session-store ${resolved} is not a directory; name the harness transcript store directory for this host`);
422
+ throw new CommandFailure("refused", "USAGE_INVALID", `--session-store ${resolved} is not a directory; name the harness transcript store directory for this host`);
265
423
  return resolved;
266
424
  });
267
425
  }
@@ -269,13 +427,16 @@ async function preserveStateDown(storeOverride, sessionStores = []) {
269
427
  const root = cotalRoot();
270
428
  const matching = loadMeshes().filter((mesh) => mesh.root === root);
271
429
  if (matching.length !== 1)
272
- throw new Error(`down --preserve-state requires exactly one recorded mesh for this root; found ${matching.length}`);
430
+ throw new CommandFailure("refused", matching.length ? "TARGET_AMBIGUOUS" : "TARGET_NOT_FOUND", `down --preserve-state requires exactly one recorded mesh for this root; found ${matching.length}, and nothing was stopped`, { target: { root, spaces: matching.map((mesh) => mesh.space) } });
273
431
  const mesh = matching[0];
274
432
  const storeDir = storeOverride ? resolveStore(storeOverride) : join(root, ".cotal", "nats");
275
433
  // The store cap the broker was started with travels with the store, so the resume re-renders it.
276
434
  const cap = mesh.maxFileStore !== undefined ? { maxFileStore: mesh.maxFileStore } : {};
277
435
  const lock = acquireMaintenanceLock(root);
278
436
  try {
437
+ const additiveAttempts = listAdditiveTeamAttempts(root);
438
+ if (retainedAdditiveTeamAttempts(additiveAttempts).length || additiveAttempts.refused.length)
439
+ throw new CommandFailure("refused", "LIFECYCLE_BLOCKED", "an additive attempt or returned additive deployment remains; preserve-state down did not fold its resources into the retained stack", { target: { root, space: mesh.space, deploymentIds: retainedAdditiveTeamAttempts(additiveAttempts).map((attempt) => attempt.deploymentId), unreadable: additiveAttempts.refused.map(({ path }) => path) } });
279
440
  const all = localProcessSurface();
280
441
  const context = { root, space: mesh.space };
281
442
  const existing = readMaintenanceJournal(root);
@@ -550,7 +711,7 @@ async function preserveStateDown(storeOverride, sessionStores = []) {
550
711
  * source`, and a checkpoint inherits that refusal rather than writing something that will not
551
712
  * reproduce the seat.
552
713
  */
553
- function assertSeatsCheckpointable(inventory) {
714
+ export function assertSeatsCheckpointable(inventory) {
554
715
  for (const entry of (inventory.agents ?? [])) {
555
716
  const keys = entry.launch?.unresolvedLaunchOptionKeys ?? [];
556
717
  if (keys.length)
@@ -560,7 +721,7 @@ function assertSeatsCheckpointable(inventory) {
560
721
  }
561
722
  }
562
723
  /** Capture one checkpoint per retained seat, after the cut has proven the whole stack down. */
563
- async function captureSeatCheckpoints(root, space, resume, destination, sessionStores) {
724
+ export async function captureSeatCheckpoints(root, space, resume, destination, sessionStores) {
564
725
  const document = readMaintenanceResumeDocument(root, resume);
565
726
  const inventory = document.inventory;
566
727
  const agents = inventory?.agents ?? [];
@@ -631,7 +792,7 @@ async function directKvValue(nc, stream, subject, allowEmpty = false) {
631
792
  * continuously, so the cut publishes `ready` only once BOTH lease buckets hold no live value —
632
793
  * a dead daemon's lease expires by TTL, a pidless live one keeps renewing and is refused here.
633
794
  * Pidfiles are hints; leases are proof. */
634
- async function assertControlPlaneQuiesced(space, server) {
795
+ export async function assertControlPlaneQuiesced(space, server) {
635
796
  const resolved = await connectOrExit({ space, server }, "deployer");
636
797
  const user = resolved.bearer ? await userViewAuthOrExit(resolved, "deployer") : undefined;
637
798
  const nc = await dialerFor(server)({