@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,153 +1,280 @@
1
1
  import { existsSync, readFileSync } from "node:fs";
2
+ import { homedir } from "node:os";
2
3
  import { join } from "node:path";
3
- import { CotalEndpoint, dialerFor, EpEnvelopeError, isReachable, mintCreds, mintLifecycleUid, resolveService, invokeRepairingSplit, standaloneConnectOpts, newIdentity, idFromCreds, principalKey, DEV_OWNER, unansweredRequest, resolveAuthProvider, peerLabel, personaDir, presenceText, } from "@cotal-ai/core";
4
- import { accountInventory, authDir, canonicalRoot, CLI_USER_ACTOR, deliveryCredsKey, DELIVERY_PIDFILE, extensionsDir, findCotalRoot, getCurrent, hasUserAuthState, isWorkspaceTargetError, loadMeshes, loadSoleSpaceAuth, localProcessPath, localProcessVisible, MANAGER_PIDFILE, oneLine, parsePid, preflightTarget, probeLiveness, probeWebReadiness, readRenewalRecord, renderWorkspaceError, resolveMeshTarget, serverFlag, spaceFlag, userAuthStateDir, WEB_PIDFILE, WEB_SESSION_FILE, workspaceSecretStore } from "@cotal-ai/workspace";
4
+ import { CotalEndpoint, dialerFor, EpEnvelopeError, formatAge, isReachable, mintCreds, mintLifecycleUid, resolveService, realDirNoSymlink, invokeRepairingSplit, standaloneConnectOpts, newIdentity, idFromCreds, principalKey, DEV_OWNER, unansweredRequest, resolveAuthProvider, personaDir, presenceText, } from "@cotal-ai/core";
5
+ import { accountInventory, authDir, isCommandFailure, brokerAddressForDisplay, canonicalRoot, CLI_USER_ACTOR, CommandFailure, deliveryCredsKey, DELIVERY_PIDFILE, extensionsDir, findCotalRoot, findPreparedSpace, hasUserAuthState, homeCotalDir, cachedPreferences, resolvePreference, isMeshRegistryError, isWorkspaceTargetError, jsonFlag, loadSoleSpaceAuth, localProcessPath, localProcessVisible, MANAGER_PIDFILE, oneLine, parsePid, plainFlag, preflightTarget, presentationOf, probeLiveness, probeWebReadiness, readCurrent, readMeshRegistry, readRenewalRecord, renderWorkspaceError, resolveMeshTarget, serverFlag, spaceFlag, userAuthStateDir, WEB_PIDFILE, WEB_READINESS_HEADER, workspaceSecretStore, writeResult } from "@cotal-ai/workspace";
5
6
  import { localProcessSurface } from "../ext-loader.js";
6
- import { cliVersion, cliProvenance, extensionVersions } from "../lib/version.js";
7
+ import { cliVersion, cliProvenance, readExtensionVersions } from "../lib/version.js";
7
8
  import { agentSkillsSkew } from "../lib/agent-skills.js";
8
9
  import { managerHasDeliveryMarker } from "../lib/manager-proc.js";
9
- import { connectorHarnesses, connectorStatusRows, machineStatus, recordedWebUrl, resolveRuntimeSpace, webBoundAddress, webInstalled } from "../lib/status.js";
10
+ import { connectorHarnesses, connectorStatusRows, machineStatus, recordedWebUrl, resolveRuntimeSpace, webBoundAddress, webInstalled, webSessionSource } from "../lib/status.js";
10
11
  import { deliveryResponderFromLease, deliveryResponderState, deliveryRowSuffix, RESPONDER_UNBOUND_CONSEQUENCE } from "../lib/delivery-responder.js";
11
12
  import { pidfileState } from "./down.js";
12
13
  import { displayCmd } from "../lib/self-exec.js";
13
- import { listPersonas } from "../lib/personas.js";
14
- import { activityAge, c, presenceDetail, statusBadge } from "../ui.js";
14
+ import { readPersonas } from "../lib/personas.js";
15
+ import { defaultPersonaFix } from "../lib/default-persona.js";
16
+ import { c } from "../ui.js";
15
17
  import { preparedCatalogDiagnostics } from "./sync.js";
18
+ import { agentStatus } from "./agents.js";
19
+ import { onInstance } from "../lib/control.js";
20
+ import { serviceDefinitionProjection, serviceDefinitionStore } from "../lib/service-definitions.js";
21
+ import { instanceProjection, serviceInstances } from "../lib/service-instances.js";
22
+ import { freshTeamAttemptSettled, listFreshTeamAttempts, listFreshTeamSummaries } from "../lib/team-fresh.js";
23
+ import { additiveTeamRecordedState, listAdditiveTeamAttempts } from "../lib/team-additive-attempt.js";
16
24
  /** `--components` is the fail-loud health pass with a machine-readable EXIT DISPOSITION. Bare
17
- * `status` remains a broad, recovery-oriented diagnostic and keeps exit 0; this explicit mode is for
18
- * an operator or monitor that needs a component state per component and an exit code to branch on.
25
+ * `status` is a broad, recovery-oriented report: it exits 0, or 4 when it could not read part of what
26
+ * it reports; this explicit mode is for an operator or monitor that needs a component state per
27
+ * component and an exit code to branch on.
19
28
  *
20
29
  * THAT DIVISION IS ABOUT EXIT CODES AND COMPLETENESS, NOT ABOUT TRUTHFULNESS, and #1576 is where the
21
30
  * difference bit. Bare status printed `delivery running (pid N)` over a daemon whose responder had
22
31
  * never bound — not a broad answer but a specific and wrong one, identical to the line it prints
23
32
  * when delivery is fully healthy, for 22 hours, while spawn/retirement/join all failed. A broad
24
- * diagnostic may omit an axis; it may not claim one it never checked. So bare status stays broad and
25
- * zero-exit, and the delivery row now names the responder state it actually read (or says plainly
26
- * that it did not read it, and points here). */
33
+ * diagnostic may omit an axis; it may not claim one it never checked. So bare status stays broad,
34
+ * and the delivery row names the responder state it actually read (or says plainly that it did not
35
+ * read it, and points here). */
27
36
  export const statusFlags = [
28
37
  spaceFlag,
29
38
  serverFlag,
39
+ { name: "on", type: "string", value: "<manager-instance>", description: "named agent: inspect one manager instance" },
40
+ { name: "creds", type: "string", value: "<file>", description: "named agent: use an explicit connection credential" },
41
+ { name: "all", type: "boolean", description: "check every recorded mesh, not only the selected one" },
42
+ { name: "verbose", short: "v", type: "boolean", description: "include installation paths, local records and detailed diagnostics" },
30
43
  { name: "components", type: "boolean", description: "probe manager, delivery, web, and registered broker component health (exit: 0 serving; 1 absent; 2 present but not serving; 3 probe refused)" },
44
+ jsonFlag,
45
+ plainFlag,
31
46
  ];
47
+ /** A project root with no registration or prepared space here, such as one whose space was
48
+ * forgotten. The resolver gives it the default broker address, which any broker may hold, so
49
+ * status selects no space for it and dials nothing. */
50
+ class UnregisteredRoot {
51
+ root;
52
+ constructor(root) {
53
+ this.root = root;
54
+ }
55
+ }
32
56
  function resolveSelected(cwd, values) {
33
57
  try {
34
- return { ok: true, target: resolveMeshTarget(cwd, { server: values.server, space: values.space }) };
58
+ const target = resolveMeshTarget(cwd, { server: values.server, space: values.space });
59
+ return target.source === "local-space" ? { ok: false, error: new UnregisteredRoot(target.root) } : { ok: true, target };
35
60
  }
36
61
  catch (e) {
37
62
  return { ok: false, error: e };
38
63
  }
39
64
  }
65
+ /** Collects what each reader could not read, so the report names it on its row and the run is
66
+ * reported partial rather than complete. */
67
+ class Gaps {
68
+ warnings = [];
69
+ /** Two readers that hit the same part, such as one catalog read as the folder's and the selected
70
+ * mesh's, name it once. */
71
+ add(code, message, target = null) {
72
+ if (this.warnings.some((w) => w.code === code && w.message === message))
73
+ return;
74
+ this.warnings.push({ code, target, message });
75
+ }
76
+ }
77
+ /** Keep unsafe stored addresses explicit without exposing their original text. */
78
+ function displayStatusBroker(server, space, gaps) {
79
+ const display = brokerAddressForDisplay(server);
80
+ if (display !== undefined)
81
+ return display;
82
+ gaps.add("BROKER_ADDRESS_INVALID", `broker address for '${space}' cannot be displayed`, { space });
83
+ return null;
84
+ }
85
+ /** Named-agent and infrastructure inputs choose different reads. */
86
+ export function validateStatusArguments(args) {
87
+ if (args.positionals.length > 1 || args.positionals.length && !args.positionals[0]?.trim())
88
+ throw new CommandFailure("refused", "USAGE_INVALID", "status takes at most one agent name");
89
+ if (args.positionals.length && (args.values.all || args.values.components))
90
+ throw new CommandFailure("refused", "USAGE_INVALID", "a named agent status takes no --all or --components");
91
+ if (typeof args.values.on === "string")
92
+ onInstance(args.values.on, "cotal status");
93
+ if (!args.positionals.length && (args.values.on !== undefined || args.values.creds !== undefined))
94
+ throw new CommandFailure("refused", "USAGE_INVALID", "--on and --creds select a named agent read, not infrastructure status");
95
+ }
40
96
  /** `cotal status` — detailed, read-only diagnostics for the local machine + selected mesh. */
41
97
  export async function status(args) {
98
+ validateStatusArguments(args);
99
+ if (args.positionals.length)
100
+ return agentStatus(args);
42
101
  const values = args.values;
102
+ const presentation = presentationOf(values);
103
+ if (values.components && (presentation !== "rich" || values.all))
104
+ throw new CommandFailure("refused", "USAGE_INVALID", "--components checks the selected mesh and writes its own records - it takes no --json, --plain or --all", {
105
+ remedy: `run \`${displayCmd()} status --components\` on its own`,
106
+ });
43
107
  const cwd = process.cwd();
44
108
  const root = findCotalRoot(cwd);
45
- const cmd = displayCmd();
46
- console.log(c.bold("cotal status"));
47
109
  const selected = resolveSelected(cwd, values);
48
- await printMachine(selected);
49
- printExtensions();
110
+ const gaps = new Gaps();
111
+ const hints = [];
112
+ const machine = await readMachine(selected, gaps);
113
+ const extensions = readExtensions(gaps);
50
114
  // THE RESPONDER AXIS (#1576), read ONCE and threaded into the rows that would otherwise claim
51
115
  // health they never checked. It is read before the folder section because that section renders
52
116
  // the delivery process row, and a live pid means nothing without it.
53
117
  const responder = await readResponderAxis(selected);
54
- await printProject(root, cmd, selected, values, responder);
55
- await printRegistry();
56
- await printTarget(selected, cmd, responder);
118
+ const folder = await readFolder(root, selected, values, responder, gaps, hints);
119
+ const meshes = await readMeshes(selected, Boolean(values.all), gaps);
120
+ const target = await readSelected(selected, responder, gaps, hints);
121
+ const services = readOwnedServices(selected, gaps);
122
+ const bootAttempts = readBootAttempts(root, gaps);
123
+ const result = { kind: "infrastructure", machine, extensions, folder, meshes, selected: target, services, bootAttempts, hints };
124
+ const parts = gaps.warnings.length;
125
+ writeResult(presentation, {
126
+ command: "status",
127
+ target: { space: selected.ok ? selected.target.space : null, scope: values.all ? "all" : "selected" },
128
+ result,
129
+ completeness: parts ? "partial" : "complete",
130
+ warnings: gaps.warnings,
131
+ ...(parts ? { partial: { message: `status could not read ${parts === 1 ? "one part" : `${parts} parts`} of what it reports; the warnings name ${parts === 1 ? "it" : "each"}` } } : {}),
132
+ }, (result) => statusView(result, Boolean(values.verbose)));
57
133
  if (values.components)
58
134
  await printComponentHealth(cwd, values);
59
135
  }
60
- /** The installed extensions (seeded built-in connectors + operator `ext add`s) with their pinned
61
- * versions. Always rendered — the `root` line plus an explicit empty state answers "where do these
62
- * live / is anything installed", which is precisely ambiguous on a fresh binary before its first
63
- * seed. Versions are the manifest pin (add-time), not a live on-disk/host-compat check. */
64
- function printExtensions() {
65
- const exts = extensionVersions();
66
- section("Extensions");
67
- row("root", extensionsDir());
68
- if (!exts.length) {
69
- row("installed", c.dim("none"));
70
- return;
136
+ /** Local boot and additive intents are recovery coordinates, not evidence of native state. */
137
+ function readBootAttempts(root, gaps) {
138
+ const result = { root, state: "not-checked", observedAt: new Date().toISOString(), unsettled: [], additive: [], unreadable: [] };
139
+ try {
140
+ if (!realDirNoSymlink(root, ".cotal"))
141
+ return result;
142
+ const attempts = listFreshTeamAttempts(root), summaries = listFreshTeamSummaries(root);
143
+ const byId = new Map(summaries.valid.map((summary) => [summary.deploymentId, summary]));
144
+ result.unsettled = attempts.valid.filter((attempt) => !freshTeamAttemptSettled(attempt, byId.get(attempt.deploymentId)))
145
+ .map(({ deploymentId, space, server, createdAt }) => ({ deploymentId, space, server: brokerAddressForDisplay(server) ?? "not displayable", createdAt }));
146
+ const unreadable = [...attempts.refused, ...summaries.refused].map(({ path }) => path);
147
+ result.unreadable.push(...unreadable);
148
+ if (unreadable.length)
149
+ gaps.add("FRESH_BOOT_RECORD_UNREADABLE", "one or more fresh boot attempts or returned summaries are unreadable; their outcomes were not treated as absent", { root, paths: unreadable });
150
+ }
151
+ catch {
152
+ result.state = "partial";
153
+ gaps.add("FRESH_BOOT_RECORD_UNAVAILABLE", "this folder's fresh boot attempt inventory could not be read; no empty inventory was inferred", { root });
71
154
  }
72
- for (const e of exts)
73
- row(e.label, c.green(`v${e.version}`) + (e.pkg === e.label ? "" : c.dim(` · ${e.pkg}`)));
74
- }
75
- /** Cotal's authored skills reach non-Claude harnesses through the cross-vendor `~/.agents/skills`
76
- * directory (Codex, Cursor, OpenCode, Gemini CLI, Windsurf). Those harnesses have no remote update, so
77
- * surface a stale/missing/retired drop here and point at the skills-only write (`cotal setup --skills`).
78
- * A corrupt skills bundle throws (fail-loud); we render that as a red integrity error rather than "none shipped". */
79
- function skillsSkewRow() {
80
- let skew;
81
155
  try {
82
- skew = agentSkillsSkew();
156
+ const additive = listAdditiveTeamAttempts(root);
157
+ result.additive = additive.valid.map((attempt) => ({ deploymentId: attempt.deploymentId, space: attempt.space, server: brokerAddressForDisplay(attempt.server) ?? "not displayable", createdAt: attempt.createdAt, recordedState: additiveTeamRecordedState(attempt, additive) }));
158
+ const unreadable = additive.refused.map(({ path }) => path);
159
+ result.unreadable.push(...unreadable);
160
+ if (unreadable.length)
161
+ gaps.add("ADDITIVE_ATTEMPT_UNREADABLE", "one or more additive attempts are unreadable; their effects were not treated as absent", { root, paths: unreadable });
83
162
  }
84
- catch (e) {
85
- return c.red(`bundle error: ${e.message}`);
163
+ catch {
164
+ result.state = "partial";
165
+ gaps.add("ADDITIVE_ATTEMPT_UNAVAILABLE", "this folder's additive attempt inventory could not be read; no empty inventory was inferred", { root });
86
166
  }
87
- const behind = skew.filter((s) => s.state !== "current");
88
- if (!behind.length)
89
- return c.green(`current (${skew.length})`);
90
- if (behind.every((s) => s.state === "missing"))
91
- return c.dim(`not installed · ${displayCmd()} setup --skills`);
92
- const retired = behind.filter((s) => s.state === "retired").length;
93
- const label = retired ? `${behind.length} to reconcile (${retired} retired)` : `${behind.length}/${skew.length} out of date`;
94
- return c.yellow(`${label} · ${displayCmd()} setup --skills`);
167
+ if (result.state !== "partial")
168
+ result.state = result.unreadable.length ? "partial" : "read";
169
+ result.observedAt = new Date().toISOString();
170
+ return result;
95
171
  }
96
- function cliProvenanceLabel() {
97
- const provenance = cliProvenance();
98
- const kind = provenance.kind === "source" ? "source checkout" : provenance.kind;
99
- return `(${kind}: ${provenance.root})`;
172
+ /** Separate the new owned-controller records from legacy pidfiles and remote registrations.
173
+ * An unreadable family is null and makes the report partial, never a complete empty list. */
174
+ function readOwnedServices(selected, gaps) {
175
+ const result = { space: selected.ok ? selected.target.space : null, state: "not-checked", observedAt: new Date().toISOString(), atomicSnapshot: false, definitions: null, instances: null, scope: "selected-space local owned records; no remote registration or fresh endpoint probe" };
176
+ if (!selected.ok)
177
+ return result;
178
+ const space = selected.target.space;
179
+ try {
180
+ result.definitions = serviceDefinitionStore(space).list().map(serviceDefinitionProjection);
181
+ }
182
+ catch (error) {
183
+ const causeCode = isCommandFailure(error) ? error.code : "TARGET_UNAVAILABLE";
184
+ gaps.add("SERVICE_DEFINITIONS_UNAVAILABLE", `the selected space's owned service definitions could not be read (${causeCode}); no empty inventory or repair was inferred`, { space, causeCode });
185
+ }
186
+ try {
187
+ result.instances = serviceInstances(space).map(instanceProjection);
188
+ }
189
+ catch (error) {
190
+ const causeCode = isCommandFailure(error) ? error.code : "TARGET_UNAVAILABLE";
191
+ gaps.add("SERVICE_INSTANCES_UNAVAILABLE", `the selected space's owned service instance observations could not be established (${causeCode}); no stopped, empty or serving state was inferred`, { space, causeCode });
192
+ }
193
+ result.state = result.definitions === null || result.instances === null ? "partial" : "read";
194
+ result.observedAt = new Date().toISOString();
195
+ return result;
100
196
  }
101
- async function printMachine(selected) {
197
+ async function readMachine(selected, gaps) {
102
198
  const m = await machineStatus();
103
- section("Machine");
104
- row("cotal-ai", `${c.green(`v${cliVersion()}`)} ${c.dim(cliProvenanceLabel())}`);
105
- row("NATS", m.nats === "missing" ? c.red("missing") : c.green(m.nats));
106
- await printHarnesses();
107
- row("Skills (.agents)", skillsSkewRow());
108
- let webExt;
199
+ let defaults = null;
200
+ try {
201
+ const context = { preferences: cachedPreferences(), space: selected.ok ? selected.target.space : undefined };
202
+ defaults = { harness: resolvePreference("harness", context).value, persona: resolvePreference("persona", context).value };
203
+ }
204
+ catch {
205
+ gaps.add("PREFERENCES_UNREADABLE", "the saved agent defaults could not be read");
206
+ }
207
+ let connectors = null;
208
+ const integrations = [];
109
209
  try {
110
- webExt = webInstalled();
111
- row("Web extension", webExt ? c.green("installed") : c.dim("not installed"));
210
+ connectors = connectorHarnesses();
112
211
  }
113
212
  catch (e) {
114
- row("Web extension", c.red(e.message));
213
+ gaps.add("CONNECTORS_UNREADABLE", `the installed connectors could not be listed: ${e.message}`);
115
214
  }
116
- row("Web process", webProcessRow(selected, webExt));
117
- }
118
- /** The selected mesh's dashboard where its own records place it. An unreadable `web.pid` or
119
- * `web.session` is named on the row, like the folder's process rows, so the rest of status still
120
- * prints. An install state that could not be read is `undefined` and reads `down`, since only a known
121
- * absence is `not installed`. */
122
- function webProcessRow(selected, installed) {
123
- let url;
215
+ if (connectors)
216
+ for (const r of await connectorStatusRows(connectors))
217
+ integrations.push({ name: r.label, state: r.state, text: r.text });
218
+ let installed = null;
219
+ let installedError = null;
124
220
  try {
125
- url = selected.ok ? recordedWebUrl({ root: selected.target.root, space: selected.target.space }) : undefined;
221
+ installed = webInstalled();
126
222
  }
127
223
  catch (e) {
128
- return c.red(e.message);
224
+ installedError = e.message;
225
+ gaps.add("WEB_UNREADABLE", `the web extension's record could not be read: ${installedError}`);
129
226
  }
130
- return url ? c.green(url) : c.dim(installed === false ? "not installed" : "down");
227
+ let url = null;
228
+ let urlError = null;
229
+ try {
230
+ url = (selected.ok ? recordedWebUrl({ root: selected.target.root, space: selected.target.space }) : undefined) ?? null;
231
+ }
232
+ catch (e) {
233
+ // An unreadable `web.pid` or session record is named on the row, like the folder's process rows,
234
+ // so the rest of status still prints.
235
+ urlError = e.message;
236
+ gaps.add("WEB_UNREADABLE", `the dashboard's records could not be read: ${urlError}`);
237
+ }
238
+ return {
239
+ version: cliVersion(),
240
+ node: process.version,
241
+ platform: `${process.platform === "darwin" ? "macOS" : process.platform === "win32" ? "Windows" : process.platform === "linux" ? "Linux" : process.platform} ${process.arch}`,
242
+ install: cliProvenance(),
243
+ nats: m.nats,
244
+ integrations,
245
+ defaults,
246
+ connectors: connectors?.map((h) => ({ name: h.name, requires: [...h.requires], missing: h.missing })) ?? null,
247
+ skills: readSkills(gaps),
248
+ web: { installed, installedError, url, urlError },
249
+ };
131
250
  }
132
- /** The rows each connector's setup provider reports, then one row per installed connector, named by
133
- * the connector and judged by the executables it declares. A manifest that cannot list them renders
134
- * as one red row, so the rest of status still prints. */
135
- async function printHarnesses() {
136
- let harnesses;
251
+ /** Cotal's authored skills reach non-Claude harnesses through the cross-vendor `~/.agents/skills`
252
+ * directory (Codex, Cursor, OpenCode, Gemini CLI, Windsurf). Those harnesses have no remote update, so
253
+ * surface a stale/missing/retired drop here and point at the skills-only write (`cotal setup --skills`).
254
+ * A corrupt skills bundle throws (fail-loud); we report that as an integrity error rather than "none shipped". */
255
+ function readSkills(gaps) {
256
+ let skew;
137
257
  try {
138
- harnesses = connectorHarnesses();
258
+ skew = agentSkillsSkew();
139
259
  }
140
260
  catch (e) {
141
- row("Connectors", c.red(e.message));
142
- return;
261
+ gaps.add("SKILLS_UNREADABLE", `the skills bundle could not be read: ${e.message}`);
262
+ return { state: "unreadable", total: 0, behind: 0, retired: 0, error: e.message };
143
263
  }
144
- const paint = { ok: c.green, warn: c.yellow, error: c.red, off: c.dim };
145
- for (const r of await connectorStatusRows(harnesses))
146
- row(r.label, paint[r.state](r.text));
147
- if (!harnesses.length)
148
- row("Connectors", c.dim(`none installed · ${displayCmd()} ext seed`));
149
- for (const h of harnesses)
150
- row(h.name, h.missing.length ? c.dim(`${h.missing.join(", ")} not on PATH`) : c.green(h.requires.length ? `${h.requires.join(", ")} on PATH` : "in-process"));
264
+ const behind = skew.filter((s) => s.state !== "current");
265
+ const retired = behind.filter((s) => s.state === "retired").length;
266
+ const state = !behind.length ? "current" : behind.every((s) => s.state === "missing") ? "not-installed" : "behind";
267
+ return { state, total: skew.length, behind: behind.length, retired, error: null };
268
+ }
269
+ /** The installed extensions (seeded built-in connectors + operator `ext add`s) with their pinned
270
+ * versions. The root plus an explicit empty state answers "where do these live / is anything
271
+ * installed", which is ambiguous on a fresh binary before its first seed. Versions are the manifest
272
+ * pin (add-time), not a live on-disk/host-compat check. */
273
+ function readExtensions(gaps) {
274
+ const { versions, unreadable } = readExtensionVersions();
275
+ if (unreadable !== undefined)
276
+ gaps.add("EXTENSIONS_UNREADABLE", `the extensions manifest could not be read: ${unreadable}`);
277
+ return { root: extensionsDir(), items: unreadable === undefined ? versions.map((e) => ({ package: e.pkg, label: e.label, version: e.version })) : null };
151
278
  }
152
279
  /** The lease `holder` the delivery daemon THIS WORKSPACE launched would write, or `undefined` when it
153
280
  * cannot be known (#1576, and the reason is #837).
@@ -249,46 +376,47 @@ async function readResponderAxis(selected) {
249
376
  return "unknown";
250
377
  }
251
378
  }
252
- async function printProject(root, cmd, selected, values, responder = "unknown") {
253
- section("This Folder");
254
- row("root", root);
379
+ async function readFolder(root, selected, values, responder, gaps, hints) {
380
+ const cmd = displayCmd();
381
+ const folder = (auth, processes = null, storedState = false, processSpace = null) => ({
382
+ root,
383
+ auth,
384
+ ...folderPersonas(root, selected, values, gaps, hints),
385
+ processes,
386
+ processSpace,
387
+ storedState,
388
+ });
389
+ const unreadable = (error, hint) => {
390
+ gaps.add("AUTH_UNREADABLE", `this folder's trust material could not be read: ${error}`, { root });
391
+ hints.push(hint);
392
+ return folder({ state: "unreadable", spaces: [], userAuth: false, error });
393
+ };
255
394
  // The inventory READ itself can throw (an EACCES/ELOOP on `.cotal/auth`, not just a bad record):
256
395
  // `accountInventory` lets that propagate so the broker-wide guards fail CLOSED, but status is the
257
- // recovery command and must exit 0 for any trust material it cannot read. Frame the unreadable
258
- // auth dir and stop.
396
+ // recovery command and must report any trust material it cannot read. Frame the unreadable auth
397
+ // dir and stop.
259
398
  let spaces;
260
399
  let corrupt;
261
400
  try {
262
401
  ({ spaces, corrupt } = accountInventory(authDir(root)));
263
402
  }
264
403
  catch (e) {
265
- row("auth", c.red(`auth dir unreadable · ${e.message}`));
266
- row("hint", `check permissions on ${authDir(root)} - broker-wide commands refuse while the tenant list cannot be read`);
267
- printPersonas(root, cmd, selected, values);
268
- return;
404
+ return unreadable(`auth dir unreadable · ${e.message}`, `check permissions on ${authDir(root)} - broker-wide commands refuse while the tenant list cannot be read`);
269
405
  }
270
406
  // Status is the command the broker-wide refusals send the operator to, so it must DESCRIBE every
271
407
  // state those refusals can name - crashing on one is a dead end in the exact recovery flow. An
272
408
  // unreadable record means the tenant list is uncertain: report it (the space-blind sole-load
273
409
  // below would throw on it).
274
- if (corrupt.length > 0) {
275
- row("auth", c.red(`${corrupt.length} unreadable account record(s) · ${corrupt.join(", ")}`));
276
- row("hint", `repair or remove ${corrupt.map((f) => join(authDir(root), f)).join(", ")} - broker-wide commands refuse while the tenant list is uncertain`);
277
- printPersonas(root, cmd, selected, values);
278
- return;
279
- }
410
+ if (corrupt.length > 0)
411
+ return unreadable(`${corrupt.length} unreadable account record(s) · ${corrupt.join(", ")}`, `repair or remove ${corrupt.map((f) => join(authDir(root), f)).join(", ")} - broker-wide commands refuse while the tenant list is uncertain`);
280
412
  // A root holding several accounts has no single "this folder's space", and the process rows below
281
413
  // are keyed by one. Report the tenant list instead of letting the space-blind read throw.
282
- if (spaces.length > 1) {
283
- row("auth", c.green(`${spaces.length} spaces · ${spaces.join(", ")}`));
284
- printPersonas(root, cmd, selected, values);
285
- console.log(c.dim(" per-space process state is not reported on a multi-space root yet"));
286
- return;
287
- }
414
+ if (spaces.length > 1)
415
+ return folder({ state: "spaces", spaces, userAuth: false, error: null });
288
416
  // The inventory shape-check is necessary but not sufficient: a record can carry non-empty
289
417
  // account fields yet fail COMPOSITION (a malformed account JWT, or one signed by a foreign
290
418
  // operator - `composeSpaceAuth` throws on both). Status is the recovery command the broker-wide
291
- // refusals point at, so it must exit 0 with guidance for ANY record it cannot load, not crash on
419
+ // refusals point at, so it must report any record it cannot load with guidance, not crash on
292
420
  // the ones the cheap shape gate lets through. Frame the load failure the same as an unreadable
293
421
  // record and stop.
294
422
  let auth;
@@ -296,12 +424,9 @@ async function printProject(root, cmd, selected, values, responder = "unknown")
296
424
  auth = loadSoleSpaceAuth(authDir(root));
297
425
  }
298
426
  catch (e) {
299
- row("auth", c.red(`unreadable trust material · ${e.message.split(" - ")[0]}`));
300
- row("hint", `${e.message}`);
301
- printPersonas(root, cmd, selected, values);
302
- return;
427
+ return unreadable(`unreadable trust material · ${e.message.split(" - ")[0]}`, e.message);
303
428
  }
304
- const userDisk = auth && hasUserAuthState(root, auth.space);
429
+ const userDisk = Boolean(auth && hasUserAuthState(root, auth.space));
305
430
  // An open mesh has no account record to name its space, so the folder's space is read off its
306
431
  // runtime records - and a root whose records show two spaces RUNNING has no single answer, the
307
432
  // same shape as the multi-account case above. The process rows below are keyed by one space, so
@@ -311,114 +436,263 @@ async function printProject(root, cmd, selected, values, responder = "unknown")
311
436
  space = auth?.space ?? resolveRuntimeSpace(root);
312
437
  }
313
438
  catch (e) {
314
- row("auth", c.dim("none (open/local only)"));
315
- row("hint", e.message);
316
- row("personas", personaSummary(root));
317
- return;
439
+ hints.push(e.message);
440
+ return folder({ state: "none", spaces: [], userAuth: false, error: null });
318
441
  }
319
- const context = { root, space, userAuth: Boolean(userDisk) };
320
- row("auth", auth ? c.green(`space ${auth.space}${userDisk ? " · user-auth" : ""}`) : c.dim("none (open/local only)"));
321
- printPersonas(root, cmd, selected, values);
442
+ const context = { root, space, userAuth: userDisk };
443
+ const processes = [];
322
444
  let nats;
323
445
  for (const component of localProcessSurface().filter((component) => localProcessVisible(component, context)).sort((a, b) => (a.order ?? 50) - (b.order ?? 50))) {
324
446
  let state;
325
447
  try {
326
- state = proc(localProcessPath(component.pidFile, context));
448
+ state = pidfileState(localProcessPath(component.pidFile, context));
327
449
  }
328
450
  catch (e) {
329
451
  // `localProcessPath` throws on an ambiguous record and `pidfileState` on one it cannot read, so
330
452
  // `clean` and `down` refuse to act on either. Status is the recovery command: name the failed
331
453
  // read on this row and report the rest.
332
- row(component.name, c.red(`pidfile unreadable · ${e.message}`));
454
+ gaps.add("PIDFILE_UNREADABLE", `the ${component.name} pidfile could not be read: ${e.message}`, { root, space, process: component.name });
455
+ processes.push({ name: component.name, state: "unreadable", pid: null, detail: `pidfile unreadable · ${e.message}` });
333
456
  continue;
334
457
  }
335
458
  if (component.name === "nats")
336
459
  nats = state;
337
- if (component.name === "manager") {
338
- // #2073: a live manager pid used to print green `running` on the pidfile alone, which is how
339
- // a manager whose service rail had died read as healthy for hours. One probe of the service
340
- // endpoint now decides the row; see `managerRowState`.
341
- row(component.name, await managerRowState(selected.ok ? selected.target : undefined, state, context.space));
342
- continue;
343
- }
460
+ // #2073: a live manager pid used to print green `running` on the pidfile alone, which is how
461
+ // a manager whose service rail had died read as healthy for hours. One probe of the service
462
+ // endpoint now decides the row; see `managerProcess`.
463
+ if (component.name === "manager")
464
+ processes.push(await managerProcess(selected.ok ? selected.target : undefined, state, context.space, gaps));
344
465
  // THE #1576 ROW. A live delivery PID is not the fact an operator needs; the responder is.
345
- // `formatProc` greens any live pid, which is how `delivery running (pid N)` came to be printed
346
- // identically over a bound responder and one that never bound. The suffix names which it is,
347
- // and when unbound it names the CONSEQUENCE rather than a reconcile that has not happened yet.
348
- const detail = component.name === "delivery" ? deliveryRowNote(state.liveness === "alive", responder) : "";
349
- row(component.name, `${formatProc(state)}${detail}`);
466
+ // A live pid alone read as `delivery running (pid N)` identically over a bound responder and one
467
+ // that never bound. The detail names which it is, and when unbound it names the CONSEQUENCE
468
+ // rather than a reconcile that has not happened yet.
469
+ else
470
+ processes.push(processRow(component.name, state, component.name === "delivery" ? deliveryDetail(state.liveness === "alive", responder) : null));
350
471
  }
351
472
  // A stopped mesh with a persisted store: name the reset verb. Stale state (e.g. durables from
352
473
  // an older Cotal generation) is otherwise invisible until a spawn fails on it. The restart is
353
474
  // deliberately "your usual flags", never a bare `up` (mode/name/store-dir aren't recorded).
354
- if (nats?.liveness !== "alive" && existsSync(join(root, ".cotal", "nats")))
355
- row("stored state", c.dim(`JetStream store persists across down/up - if stale: ${cmd} clean store --force, then \`up\` with your usual flags (\`clean all\` also resets identity)`));
475
+ const storedState = nats?.liveness !== "alive" && existsSync(join(root, ".cotal", "nats"));
476
+ if (storedState)
477
+ hints.push(`if the stored JetStream state is stale: ${cmd} clean store --force, then \`up\` with your usual flags (\`clean all\` also resets identity)`);
478
+ return folder({ state: auth ? "space" : "none", spaces: auth ? [auth.space] : [], userAuth: userDisk, error: null }, processes, storedState, space);
356
479
  }
357
- async function printRegistry() {
358
- const meshes = loadMeshes();
359
- const current = getCurrent();
360
- section("Recorded Meshes");
361
- if (!meshes.length) {
362
- console.log(c.dim(" none - start one with `cotal up --detach`, or register one running elsewhere with `cotal meshes add`"));
363
- return;
480
+ /** The folder's persona catalog, which must never let a catalog imply a `spawn` the operator does
481
+ * not have.
482
+ *
483
+ * The row used to read `personas default` in green under "This Folder" while `cotal spawn` in the
484
+ * same second refused with "no default persona yet". Both were right about their OWN root and
485
+ * neither NAMED it: the folder's catalog is `<cwd-root>/.cotal/agents`, and spawn loads the
486
+ * RESOLVED mesh's `target.personaRoot`, which is a different directory whenever `cotal use`, a
487
+ * `--space`, or the registry's sole entry points elsewhere. The listed names and the launchable
488
+ * names were disjoint sets.
489
+ *
490
+ * So: always name the root each summary describes, and say whether the folder's catalog is the one
491
+ * a bare spawn launches from (`launches`): true when the two roots are one directory, false when the
492
+ * selected mesh's root differs, null when no mesh resolves and nothing is launchable here. */
493
+ function folderPersonas(root, selected, values, gaps, hints) {
494
+ const personas = personaCatalog(root, gaps);
495
+ if (!selected.ok)
496
+ return { personas, launches: null };
497
+ if (sameDir(personaDir(root), selected.target.personaRoot))
498
+ return { personas, launches: true };
499
+ hints.push(`a bare \`${displayCmd()} spawn\` uses the selected mesh, NOT this folder - personas in ${personaDir(root)} will not launch until you run it from that mesh's root or select it (\`${displayCmd()} use <space>\`${values.space ? "" : ", or pass `--space`"})`);
500
+ return { personas, launches: false };
501
+ }
502
+ /** Summarize the catalog through the shipped loader. A file is launchable only when
503
+ * {@link readPersonas} parsed it with the same {@code loadAgentFile} path spawn uses. Only an absent
504
+ * directory is an empty catalog: one that cannot be read is a gap, not `missing`. */
505
+ function personaCatalog(root, gaps) {
506
+ let personas;
507
+ try {
508
+ personas = readPersonas(root);
509
+ }
510
+ catch (e) {
511
+ const error = e.message;
512
+ gaps.add("PERSONAS_UNREADABLE", `the persona catalog ${personaDir(root)} could not be read: ${error}`, { root: personaDir(root) });
513
+ return { root: personaDir(root), default: "unreadable", demo: null, error };
514
+ }
515
+ const byName = new Map(personas.map((persona) => [persona.name, persona]));
516
+ const def = byName.get("default");
517
+ return {
518
+ root: personaDir(root),
519
+ default: def?.def ? "valid" : def?.error ? "invalid" : "missing",
520
+ demo: ["david", "sven", "me"].filter((name) => byName.get(name)?.def !== undefined).length,
521
+ error: null,
522
+ };
523
+ }
524
+ /** Do two catalog paths denote the SAME directory? `canonicalRoot` (realpath, `resolve` fallback
525
+ * for a path not on disk) is the repo's one spelling for this: a raw `===` reads a symlinked or
526
+ * 8.3-short-name spelling of one directory as two, which here would fabricate a divergence and
527
+ * send the operator chasing a split that does not exist. */
528
+ function sameDir(a, b) {
529
+ return canonicalRoot(a) === canonicalRoot(b);
530
+ }
531
+ function processRow(name, p, detail) {
532
+ if (p.liveness === "alive")
533
+ return { name, state: "running", pid: p.pid ?? null, detail };
534
+ return { name, state: p.liveness === "unknown" ? "unknown" : "stopped", pid: p.pid ?? null, detail: p.note ?? null };
535
+ }
536
+ /** Bare status's manager row, #2073: a live pid alone is not proof the manager serves — that was
537
+ * exactly the incident (a lease holder whose service rail had died stayed `running` for hours).
538
+ * So a live manager pid gets ONE probe of its own service endpoint before the row is reported. This
539
+ * adds one request to every bare `status` call for a live manager pid.
540
+ *
541
+ * Three outcomes:
542
+ * - answered: `running` with the delivery-aware detail.
543
+ * - a DEFINITIVE no-answer — the same predicate `managerHealth`'s not-serving branch uses
544
+ * (`unansweredRequest`, or the service-registry-missing text): `not-serving` with
545
+ * `service endpoint not answering`, plus the marker error when the marker could not be read.
546
+ * - any other failure (a refused probe, an `unavailable` user-mode credential): `running` with
547
+ * `service unchecked`, so a failed probe never reads as a dead rail.
548
+ *
549
+ * A dead/stopped pid never reaches the probe at all (the early return below), so a stopped manager
550
+ * still reads as stopped, not `not-serving` — a dead pid is not a live pid that will not answer. */
551
+ async function managerProcess(target, state, space, gaps) {
552
+ if (state.liveness !== "alive")
553
+ return processRow("manager", state, null);
554
+ const details = [];
555
+ let deliveryAware = false;
556
+ try {
557
+ deliveryAware = managerHasDeliveryMarker(state.pid, space);
558
+ details.push(deliveryAware ? "delivery-aware" : "old/unknown build");
364
559
  }
365
- const pad = Math.max(...meshes.map((m) => m.space.length));
366
- await Promise.all(meshes.map(async (m) => {
367
- const mark = m.space === current ? c.green("*") : " ";
368
- // Honour the recorded transport. A bare TCP/INFO probe green-lights a plaintext broker that
369
- // has substituted for a TLS-required mesh — the FAIL1 attack — so a monitoring list that only
370
- // asks "is anything listening" cannot report on the one property the record claims.
371
- const live = m.origin === "catalog" ? undefined : await isReachable(m.server, m.tlsRequired ? { tls: true } : {});
372
- // A `down` record means two different things, and the repair differs: a mesh this machine
373
- // started can be re-`up`ed here, one registered by hand runs somewhere this machine doesn't
374
- // control (and, unlike the others, its record is never swept away for it).
375
- const origin = m.origin === "manual" ? c.dim(" registered") : m.origin === "catalog" ? c.dim(" discovered") : "";
376
- const catalog = m.origin === "catalog"
377
- ? c.dim(` ${m.catalogName && m.catalogName !== m.space ? `${m.catalogName} ` : ""}catalog ${m.catalogError ? `stale since ${m.catalogFetchedAt ?? "unknown"}: ${m.catalogError}` : `snapshot ${m.catalogFetchedAt ?? "unknown"}`}`)
378
- : "";
379
- const transport = m.tlsRequired ? " tls-required" : "";
380
- const policy = m.policy?.events === "required" ? " events: required" : "";
381
- console.log(` ${mark} ${m.space.padEnd(pad)} ${live === undefined ? c.dim("not probed") : live ? c.green("reachable") : c.red("down")} ${c.dim(`${m.mode}${transport}${policy} ${m.server} ${m.root}`)}${origin}${catalog}`);
382
- }));
383
- if (current && !meshes.some((m) => m.space === current))
384
- console.log(c.dim(` note: current mesh "${current}" is not recorded`));
385
- const catalogs = preparedCatalogDiagnostics();
386
- if (catalogs.length) {
387
- section("Space Catalog Accounts");
388
- for (const result of catalogs) {
389
- const detail = result.state === "failed" ? `: ${result.error ?? "refresh failed"}` : "";
390
- console.log(` ${result.account.idpUrl} ${result.state}${detail}`);
560
+ catch (e) {
561
+ // The marker reader throws so `up` and the delivery preflight refuse to act on a marker they
562
+ // cannot read. Status is the recovery command: name the failed read on this row and report the rest.
563
+ details.push(`delivery-aware marker unreadable: ${e.message}`);
564
+ gaps.add("MARKER_UNREADABLE", `the manager's delivery-aware marker could not be read: ${e.message}`, { space, process: "manager" });
565
+ }
566
+ const running = (extra) => ({ name: "manager", state: "running", pid: state.pid ?? null, detail: [...details, ...(extra ? [extra] : [])].join(" · ") });
567
+ if (!target)
568
+ return running();
569
+ try {
570
+ let auth;
571
+ if (target.mode === "user") {
572
+ const credential = await componentCredential(target);
573
+ if (credential.kind !== "user")
574
+ return running("service unchecked");
575
+ auth = { bearer: credential.bearer, sentinelCreds: credential.sentinelCreds, caller: credential.caller };
576
+ }
577
+ else {
578
+ auth = await staticServiceAuth(target.auth);
391
579
  }
580
+ await managerServiceHealth(target, auth);
581
+ return running();
582
+ }
583
+ catch (e) {
584
+ const noService = e instanceof EpEnvelopeError && (unansweredRequest(e) || /service registry.*stream not found/i.test(e.message));
585
+ if (noService)
586
+ return { name: "manager", state: "not-serving", pid: state.pid ?? null, detail: ["service endpoint not answering", ...details.filter((d) => d.startsWith("delivery-aware marker unreadable"))].join(" · ") };
587
+ return running("service unchecked");
588
+ }
589
+ }
590
+ /** The delivery row's responder detail (#1576). An unbound responder is not a footnote about a
591
+ * component: while it holds, the mesh cannot spawn, retire or accept a join, and the whole reported
592
+ * incident is that this read as ordinary. `unknown` names `--components`, because an unchecked axis
593
+ * must not look like a diagnosis in either direction. */
594
+ function deliveryDetail(live, responder) {
595
+ return deliveryRowSuffix(live, responder, `${displayCmd()} status --components`).replace(/^ · /, "") || null;
596
+ }
597
+ /** The recorded meshes. Only the selected one is checked unless `--all` asks for every one; each
598
+ * check dials that record's own address with its own recorded TLS requirement. A bare TCP/INFO
599
+ * probe would green-light a plaintext broker that has substituted for a TLS-required mesh — the
600
+ * FAIL1 attack — so a list that only asks "is anything listening" cannot report on the one property
601
+ * the record claims. */
602
+ async function readMeshes(selected, all, gaps) {
603
+ // A registry file that cannot be read is named, and the readable records are still listed and
604
+ // checked. Only an absent directory or pointer is an empty registry or no current mesh.
605
+ const unreadable = [];
606
+ const unread = (file, error) => {
607
+ unreadable.push({ file, error });
608
+ gaps.add("MESH_REGISTRY_UNREADABLE", error, { file });
609
+ };
610
+ let entries = [];
611
+ try {
612
+ const registry = readMeshRegistry();
613
+ entries = registry.entries;
614
+ for (const e of registry.unusable)
615
+ unread(e.file, e.message);
616
+ }
617
+ catch (e) {
618
+ if (!isMeshRegistryError(e))
619
+ throw e;
620
+ unread(e.file, e.message);
621
+ }
622
+ let current = null;
623
+ try {
624
+ current = readCurrent() ?? null;
625
+ }
626
+ catch (e) {
627
+ if (!isMeshRegistryError(e))
628
+ throw e;
629
+ unread(e.file, e.message);
392
630
  }
631
+ const chosen = selected.ok ? selected.target.space : undefined;
632
+ const items = await Promise.all(entries.map(async (m) => ({
633
+ space: m.space,
634
+ server: displayStatusBroker(m.server, m.space, gaps),
635
+ mode: m.mode,
636
+ root: m.root,
637
+ origin: m.origin ?? null,
638
+ tlsRequired: Boolean(m.tlsRequired),
639
+ eventsRequired: m.policy?.events === "required",
640
+ current: m.space === current,
641
+ check: all || m.space === chosen ? ((await isReachable(m.server, m.tlsRequired ? { tls: true } : {})) ? "reachable" : "unreachable") : "not-checked",
642
+ catalog: m.origin === "catalog" ? { name: m.catalogName && m.catalogName !== m.space ? m.catalogName : null, fetchedAt: m.catalogFetchedAt ?? null, error: m.catalogError ?? null } : null,
643
+ })));
644
+ return {
645
+ current,
646
+ currentRecorded: current === null || entries.some((m) => m.space === current),
647
+ currentPrepared: current !== null && !entries.some((m) => m.space === current) && findPreparedSpace(current) !== undefined,
648
+ unreadable,
649
+ items,
650
+ catalogs: preparedCatalogDiagnostics().map((r) => ({ idp: r.account.idpUrl, state: r.state, error: r.state === "failed" ? (r.error ?? "refresh failed") : null })),
651
+ };
393
652
  }
394
- async function printTarget(selected, cmd, responder = "unknown") {
395
- section("Selected Mesh");
653
+ async function readSelected(selected, responder, gaps, hints) {
654
+ const cmd = displayCmd();
396
655
  if (!selected.ok) {
397
656
  const e = selected.error;
398
- if (isWorkspaceTargetError(e)) {
399
- row("target", c.red(e.code));
400
- // The canonical renderer names the ACTUAL repair per code (`cotal meshes rm`, `--space
401
- // <name>`, `cotal up --user-auth`, …). The fixed `up --detach` hint that used to sit here was
402
- // right for at most one of the seven codes and pointed the other six at a command that does
403
- // not fix them — worse than no hint, because it reads as a diagnosis.
404
- row("hint", renderWorkspaceError({ kind: "target", error: e }).replace(/^✗ /, ""));
405
- return;
657
+ // Resolution reads the whole registry and refuses a directory or record it cannot use. The meshes
658
+ // reader has already named it, so this is the same gap, and the selection is unresolved.
659
+ if (isMeshRegistryError(e)) {
660
+ gaps.add("MESH_REGISTRY_UNREADABLE", e.message, { file: e.file });
661
+ hints.push(e.message);
662
+ return { resolved: false, code: "registry-unreadable", message: e.message };
406
663
  }
407
- throw e;
664
+ if (e instanceof UnregisteredRoot) {
665
+ const message = `no space is registered or prepared here for ${e.root}`;
666
+ hints.push(`${message} - run \`${cmd} up\` there to start one, or select a space with \`${cmd} use <name>\``);
667
+ return { resolved: false, code: "unregistered-root", message };
668
+ }
669
+ if (!isWorkspaceTargetError(e))
670
+ throw e;
671
+ // The canonical renderer names the ACTUAL repair per code (`cotal meshes rm`, `--space
672
+ // <name>`, `cotal up --user-auth`, …). A fixed `up --detach` hint would be right for at most one
673
+ // of the codes and point the others at a command that does not fix them.
674
+ const message = renderWorkspaceError({ kind: "target", error: e }).replace(/^✗ /, "");
675
+ hints.push(message);
676
+ return { resolved: false, code: e.code, message };
408
677
  }
409
678
  const target = selected.target;
410
- row("space", target.space);
411
- row("server", target.server);
412
- row("mode", target.mode);
413
- if (target.policy?.events === "required")
414
- row("events", "required");
415
- if (target.tlsRequired)
416
- row("transport", "tls-required");
417
- if (target.userAuth)
418
- row("idp", target.userAuth.idp.url);
419
- row("source", target.source);
420
- row("root", target.root);
421
- row("personas", `${personaSummary(target.root)} ${c.dim(`· ${target.personaRoot}`)}`);
679
+ const base = {
680
+ resolved: true,
681
+ space: target.space,
682
+ server: displayStatusBroker(target.server, target.space, gaps),
683
+ mode: target.mode,
684
+ source: target.source,
685
+ root: target.root,
686
+ tlsRequired: Boolean(target.tlsRequired),
687
+ eventsRequired: target.policy?.events === "required",
688
+ idp: target.userAuth?.idp.url ?? null,
689
+ personas: personaCatalog(target.root, gaps),
690
+ staleRecord: false,
691
+ login: null,
692
+ deliveryResponder: null,
693
+ channels: null,
694
+ membershipFeed: null,
695
+ };
422
696
  if (target.mode === "user") {
423
697
  // Status never static-mints on a user-auth mesh (the flip). Everything here is offline
424
698
  // introspection — the login cache + the locally-readable ledger — plus, only when this
@@ -426,93 +700,74 @@ async function printTarget(selected, cmd, responder = "unknown") {
426
700
  // Same transport discipline as the open/auth path below: a recorded TLS requirement must
427
701
  // not collapse to a bare reachability probe (that green-lights a plaintext substitute).
428
702
  const live = await isReachable(target.server, target.tlsRequired ? { tls: true } : {});
429
- row("connection", live ? c.green("reachable") : c.red("unreachable"));
430
703
  const stateDir = userAuthStateDir(target.root, target.space);
431
704
  let st;
432
705
  try {
433
706
  st = await resolveAuthProvider().userStatus({ store: workspaceSecretStore(target.root), dir: stateDir, space: target.space, actor: CLI_USER_ACTOR });
434
707
  }
435
708
  catch (e) {
436
- row("login", c.dim(e.message));
437
- }
438
- if (st && !st.login)
439
- row("login", c.yellow(`not signed in - ${cmd} login --idp ${st.idpUrl}`));
440
- if (st?.login) {
441
- row("login", c.green(st.login.sub) + c.dim(` · session until ${new Date(st.login.expiresAt * 1000).toISOString()}`));
442
- if (st.grant === "not-granted")
443
- row("actor", c.yellow(`"${CLI_USER_ACTOR}" not granted - ${cmd} actor grant ${CLI_USER_ACTOR} --sub ${st.login.sub} --full`));
444
- else if (st.grant)
445
- row("actor", c.green(`"${CLI_USER_ACTOR}" granted${st.grant.label ? ` (${st.grant.label})` : ""}`) +
446
- c.dim(` - read [${st.grant.allowSubscribe.join(", ")}], post [${st.grant.allowPublish.join(", ")}]${st.grant.scope.length ? `, scope [${st.grant.scope.join(", ")}]` : ""}`));
447
- else
448
- row("actor", c.dim("grant not checkable on this machine (no local ledger)"));
709
+ gaps.add("LOGIN_UNREADABLE", `the login for ${target.space} could not be read: ${e.message}`, { space: target.space });
449
710
  }
711
+ const login = st
712
+ ? {
713
+ idp: st.idpUrl,
714
+ subject: st.login?.sub ?? null,
715
+ expiresAt: st.login ? new Date(st.login.expiresAt * 1000).toISOString() : null,
716
+ actor: !st.login ? null : st.grant === "not-granted" ? "not-granted" : st.grant ? "granted" : "not-checkable",
717
+ grant: st.login && st.grant && st.grant !== "not-granted" ? { label: st.grant.label ?? null, read: [...st.grant.allowSubscribe], post: [...st.grant.allowPublish], scope: [...st.grant.scope] } : null,
718
+ }
719
+ : null;
450
720
  const granted = Boolean(st?.login && st.grant && st.grant !== "not-granted");
451
- if (live && granted) {
452
- await userLiveSnapshot(target, stateDir).catch((e) => row("live snapshot", c.dim(`unavailable (${e.message})`)));
453
- }
454
- else {
455
- row("live snapshot", c.dim(live ? "needs a signed-in, granted login (see above)" : "broker unreachable"));
456
- }
457
- return;
721
+ const result = { ...base, connection: live ? "reachable" : "unreachable", login };
722
+ if (!live)
723
+ return { ...result, snapshot: { state: "skipped", reason: "broker unreachable" } };
724
+ if (!granted)
725
+ return { ...result, snapshot: { state: "skipped", reason: "needs a signed-in, granted login" } };
726
+ return { ...result, ...(await readSnapshot(() => userSnapshotEndpoint(target, stateDir), target.space, gaps)) };
458
727
  }
459
728
  const preflight = await preflightTarget(target);
460
- if (!preflight.ok) {
461
- row("connection", c.red(`${preflight.kind}${preflight.prune ? " (stale registry entry)" : ""}`));
462
- return;
463
- }
464
- row("connection", c.green("ok"));
729
+ if (!preflight.ok)
730
+ return { ...base, connection: preflight.kind, staleRecord: preflight.prune, snapshot: { state: "skipped", reason: "broker not connected" } };
465
731
  // The mesh-level statement of the same axis (#1576). The folder section says what this machine's
466
732
  // delivery PROCESS is doing; this says whether the SPACE currently has a bound responder, which is
467
733
  // the question "can I spawn into this mesh right now" actually reduces to. An operator reading a
468
734
  // reachable broker and a running daemon had, before this, no row that said otherwise.
469
- if (responder === "unbound")
470
- row("delivery responder", c.red(`NOT BOUND - ${RESPONDER_UNBOUND_CONSEQUENCE}`) + c.dim(` · start it with \`${cmd} up\` (or \`${cmd} deliver --space <space>\`)`));
471
- else if (responder === "stale")
472
- // A stale record is NOT BOUND with a different next move: the slot is occupied by a corpse, so
473
- // starting a daemon now loses the single-flight CAS. Say that, rather than sending the operator
474
- // into a refusal they will read as a second failure.
475
- row("delivery responder", c.red(`NOT BOUND - a DEAD daemon's ready record still holds the lease - ${RESPONDER_UNBOUND_CONSEQUENCE}`) + c.dim(" · it expires on its own; a replacement can then take the shard"));
476
- else if (responder === "bound")
477
- row("delivery responder", c.green("bound"));
478
- await liveSnapshot(target).catch((e) => row("live snapshot", c.dim(`unavailable (${e.message})`)));
735
+ return { ...base, connection: "ok", deliveryResponder: responder, ...(await readSnapshot(() => snapshotEndpoint(target), target.space, gaps)) };
479
736
  }
480
- async function liveSnapshot(target) {
737
+ async function snapshotEndpoint(target) {
481
738
  const id = newIdentity();
482
739
  const creds = target.auth ? await mintCreds(target.auth, id, "observer") : undefined;
483
- const watchBrokerState = Boolean(target.auth);
484
- const ep = new CotalEndpoint({
740
+ return new CotalEndpoint({
485
741
  space: target.space,
486
742
  servers: target.server,
487
- // The recorded requirement, for the same reason as the preflight probe above it: a monitoring
488
- // command that connects to whatever answers on the address cannot report on the one property
489
- // this feature provides, and reporting "ok" against a substituted plaintext broker is worse
490
- // than reporting nothing.
743
+ // The recorded requirement, for the same reason as the preflight probe: a monitoring command
744
+ // that connects to whatever answers on the address cannot report on the one property this
745
+ // feature provides, and reporting "ok" against a substituted plaintext broker is worse than
746
+ // reporting nothing.
491
747
  tls: target.tlsRequired,
492
748
  creds,
493
749
  channels: [],
494
750
  consume: false,
495
751
  registerPresence: false,
496
752
  // In open mode the endpoint lazily creates KV buckets for watches. Keep status read-only.
497
- watchPresence: watchBrokerState,
498
- watchChannels: watchBrokerState,
753
+ watchPresence: false,
754
+ watchChannels: Boolean(target.auth),
499
755
  card: { id: id.id, name: "status", kind: "endpoint" },
500
756
  });
501
- await renderSnapshot(ep, watchBrokerState);
502
757
  }
503
- /** The user-auth live snapshot: the same read-only roster/channels view, connected as THIS
504
- * machine's signed-in, ledger-granted login (bearer + sentinel — the flip forbids a status mint). */
505
- async function userLiveSnapshot(target, stateDir) {
758
+ /** The user-auth snapshot endpoint, connected as THIS machine's signed-in, ledger-granted login
759
+ * (bearer + sentinel — the flip forbids a status mint). */
760
+ async function userSnapshotEndpoint(target, stateDir) {
506
761
  const { bearer, sentinelCreds } = await resolveAuthProvider().userCredentials({
507
762
  store: workspaceSecretStore(target.root),
508
763
  dir: stateDir,
509
764
  space: target.space,
510
765
  actor: CLI_USER_ACTOR,
511
766
  });
512
- const ep = new CotalEndpoint({
767
+ return new CotalEndpoint({
513
768
  space: target.space,
514
769
  servers: target.server,
515
- // Same reason as liveSnapshot: the recorded requirement is the primary fence against a
770
+ // Same reason as the static path: the recorded requirement is the primary fence against a
516
771
  // forged INFO, and a monitoring snapshot that auto-upgrades cannot report on it.
517
772
  tls: target.tlsRequired,
518
773
  bearer,
@@ -520,190 +775,466 @@ async function userLiveSnapshot(target, stateDir) {
520
775
  channels: [],
521
776
  consume: false,
522
777
  registerPresence: false,
523
- watchPresence: true,
778
+ watchPresence: false,
524
779
  watchChannels: true,
525
780
  card: { name: "status", kind: "endpoint" }, // card.id derives from the bearer principal
526
781
  });
527
- await renderSnapshot(ep, true);
528
782
  }
529
- async function renderSnapshot(ep, watchBrokerState) {
530
- ep.on("error", () => { });
531
- // This endpoint is a one-shot read. Awaited reads and their per-row unavailable results own the
532
- // verdict, so a recoverable side channel is deliberately quiet rather than duplicated.
533
- const ignoreSnapshotWarning = () => { };
534
- ep.on("warning", ignoreSnapshotWarning);
535
- await ep.start();
783
+ /** The selected space's channels and membership feed, read over one short-lived connection. The
784
+ * roster is not part of status: who is present is a separate read. */
785
+ async function readSnapshot(endpoint, space, gaps) {
786
+ let ep;
787
+ try {
788
+ ep = await endpoint();
789
+ ep.on("error", () => { });
790
+ // This endpoint is a one-shot read. Awaited reads and their per-row unavailable results own the
791
+ // verdict, so a recoverable side channel is deliberately quiet rather than duplicated.
792
+ const ignoreSnapshotWarning = () => { };
793
+ ep.on("warning", ignoreSnapshotWarning);
794
+ await ep.start();
795
+ }
796
+ catch (e) {
797
+ gaps.add("SNAPSHOT_UNAVAILABLE", `the channels of ${space} could not be read: ${e.message}`, { space });
798
+ return { snapshot: { state: "unavailable", reason: e.message }, channels: null, membershipFeed: null };
799
+ }
536
800
  try {
537
- const roster = watchBrokerState ? ep.getRoster() : [];
538
801
  const channels = await ep.listChannels();
539
- const membership = await ep.readMembership().catch(() => undefined);
540
- row("roster", watchBrokerState
541
- ? (roster.length ? `${roster.length} endpoint${roster.length === 1 ? "" : "s"}` : "empty")
542
- : c.dim("skipped in open mode (read-only)"));
543
- for (const p of roster.slice(0, 8)) {
544
- const label = peerLabel(p.card);
545
- const condition = presenceDetail(p);
546
- console.log(` ${statusBadge(p.status)}${condition} ${label}${p.activity ? c.dim(` - ${presenceText(p.activity)}${activityAge(p)}`) : ""}`);
547
- }
548
- if (roster.length > 8)
549
- console.log(c.dim(` +${roster.length - 8} more`));
550
- row("channels", channels.length ? channels.map((ch) => `${ch.channel}(${ch.messages})`).join(", ") : "none");
551
- if (membership)
552
- row("membership feed", membership.asOf ? c.green(`${membership.members.length} entries · ${new Date(membership.asOf).toISOString()}`) : c.dim("no heartbeat"));
802
+ const feed = await ep.readMembership().catch(() => undefined);
803
+ return {
804
+ snapshot: { state: "read", reason: null },
805
+ channels: channels.map((ch) => ({ channel: ch.channel, messages: ch.messages })),
806
+ membershipFeed: feed ? { entries: feed.members.length, asOf: feed.asOf ? new Date(feed.asOf).toISOString() : null } : null,
807
+ };
808
+ }
809
+ catch (e) {
810
+ gaps.add("SNAPSHOT_UNAVAILABLE", `the channels of ${space} could not be read: ${e.message}`, { space });
811
+ return { snapshot: { state: "unavailable", reason: e.message }, channels: null, membershipFeed: null };
553
812
  }
554
813
  finally {
555
- await ep.stop();
814
+ await ep.stop().catch(() => { });
556
815
  }
557
816
  }
558
- /** Summarize the catalog through the shipped loader. A file is launchable only when
559
- * {@link listPersonas} parsed it with the same {@code loadAgentFile} path spawn uses. */
560
- function personaSummary(root) {
561
- const personas = listPersonas(root);
562
- const byName = new Map(personas.map((persona) => [persona.name, persona]));
563
- const def = byName.get("default");
564
- const demo = ["david", "sven", "me"].filter((name) => byName.get(name)?.def !== undefined).length;
565
- const parts = [def?.def ? c.green("default") : def?.error ? c.red("invalid default") : c.dim("no default")];
566
- if (demo)
567
- parts.push(c.dim(`demo team ${demo}/3`));
817
+ // ---- the report ------------------------------------------------------------------------------
818
+ const cell = (text, tone) => (tone ? { text, tone } : text);
819
+ function personaText(p) {
820
+ if (p.default === "unreadable")
821
+ return `unreadable: ${p.error}`;
822
+ const parts = [p.default === "valid" ? "default" : p.default === "invalid" ? "invalid default" : "no default"];
823
+ if (p.demo)
824
+ parts.push(`demo team ${p.demo}/3`);
568
825
  return parts.join(" · ");
569
826
  }
570
- /** The persona rows, which must never let a catalog imply a `spawn` the operator does not have.
571
- *
572
- * The row used to read `personas default` in green under "This Folder" while `cotal spawn` in the
573
- * same second refused with "no default persona yet". Both were right about their OWN root and
574
- * neither NAMED it: the folder's catalog is `<cwd-root>/.cotal/agents`, and spawn loads the
575
- * RESOLVED mesh's `target.personaRoot`, which is a different directory whenever `cotal use`, a
576
- * `--space`, or the registry's sole entry points elsewhere. The listed names and the launchable
577
- * names were disjoint sets.
578
- *
579
- * So: always name the root each summary describes, and when the folder is NOT the root a bare
580
- * spawn would use, say so in the same breath and give the folder's catalog its real, reduced
581
- * status — a catalog that does not launch. The divergence is the whole diagnosis, so it gets its
582
- * own row rather than a parenthetical.
583
- *
584
- * Never throws. Status is where broker-wide refusals send the operator, and the resolver fails on
585
- * ordinary states (no mesh, several meshes, unreadable trust); an unresolvable target is reported
586
- * as an unknown spawn root, matching the unreadable-auth / multi-space / corrupt-record paths
587
- * above, which all describe the failure and continue. */
588
- function printPersonas(root, cmd, selected, values) {
589
- const folder = personaDir(root);
590
- if (!selected.ok) {
591
- // No single mesh resolves, so there is no root a bare spawn would use, and this catalog cannot
592
- // be claimed to be it. Report the folder as the folder, and refuse to imply launchability.
593
- row("personas", `${personaSummary(root)} ${c.dim(`· ${folder}`)}`);
594
- row("spawn root", c.yellow("unresolved - see Selected Mesh below; until it resolves, no persona here is launchable"));
595
- return;
827
+ function personaTone(p) {
828
+ return p.default === "valid" ? "ok" : p.default === "invalid" || p.default === "unreadable" ? "failed" : "hint";
829
+ }
830
+ /** A catalog's summary and root. Green only for a `default` that loads, and never for a catalog
831
+ * `dim` marks as not the one spawn launches from. */
832
+ function personaCell(p, dim = false) {
833
+ const tone = dim ? "hint" : personaTone(p);
834
+ return cell(`${personaText(p)} · ${p.root}`, tone);
835
+ }
836
+ function processCell(p) {
837
+ const detail = p.detail ? ` · ${p.detail}` : "";
838
+ if (p.state === "unreadable")
839
+ return cell(p.detail ?? "pidfile unreadable", "failed");
840
+ if (p.state === "not-serving")
841
+ return cell(`not serving (pid ${p.pid})${detail}`, "failed");
842
+ if (p.state === "running")
843
+ return cell(`running (pid ${p.pid})${detail}`, /NOT BOUND|unreadable/.test(detail) ? "failed" : "ok");
844
+ return cell(p.pid ? `${p.detail ?? "stopped"} (${p.pid})` : (p.detail ?? "down"), "hint");
845
+ }
846
+ function skillsCell(s) {
847
+ const remedy = `${displayCmd()} setup --skills`;
848
+ if (s.state === "unreadable")
849
+ return cell(`bundle error: ${s.error}`, "failed");
850
+ if (s.state === "current")
851
+ return cell(`current (${s.total})`, "ok");
852
+ if (s.state === "not-installed")
853
+ return cell(`not installed · ${remedy}`, "hint");
854
+ return cell(`${s.retired ? `${s.behind} to reconcile (${s.retired} retired)` : `${s.behind}/${s.total} out of date`} · ${remedy}`, "waiting");
855
+ }
856
+ function machineSection(m) {
857
+ const tone = { ok: "ok", warn: "waiting", error: "failed", off: "hint" };
858
+ const rows = [
859
+ ["cotal-ai", cell(`v${m.version} (${m.install.kind === "source" ? "source checkout" : m.install.kind}: ${m.install.root})`, "ok")],
860
+ ["NATS", m.nats === "missing" ? cell("missing", "failed") : cell(m.nats === "path" ? "nats-server on PATH" : "bundled nats-server", "ok")],
861
+ ...m.integrations.map((r) => [r.name, cell(r.text, tone[r.state])]),
862
+ ];
863
+ if (m.connectors === null)
864
+ rows.push(["Connectors", cell("unreadable - see the warning below", "failed")]);
865
+ else if (!m.connectors.length)
866
+ rows.push(["Connectors", cell(`none installed · ${displayCmd()} setup`, "hint")]);
867
+ for (const h of m.connectors ?? [])
868
+ rows.push([h.name, h.missing.length ? cell(`${h.missing.join(", ")} not on PATH`, "hint") : cell(h.requires.length ? `${h.requires.join(", ")} on PATH` : "in-process", "ok")]);
869
+ rows.push(["Skills (.agents)", skillsCell(m.skills)]);
870
+ rows.push(["Web extension", m.web.installed === null ? cell(m.web.installedError ?? "unreadable", "failed") : m.web.installed ? cell("installed", "ok") : cell("not installed", "hint")]);
871
+ // An install state that could not be read reads `down`, since only a known absence is `not installed`.
872
+ rows.push(["Web process", m.web.url ? cell(m.web.url, "ok") : m.web.urlError ? cell(m.web.urlError, "failed") : cell(m.web.installed === false ? "not installed" : "down", "hint")]);
873
+ return { title: "Machine", blocks: [{ kind: "fields", rows }] };
874
+ }
875
+ function extensionsSection(e) {
876
+ const rows = [["root", e.root]];
877
+ if (e.items === null)
878
+ rows.push(["installed", cell("manifest unreadable - see the warning below", "failed")]);
879
+ else if (!e.items.length)
880
+ rows.push(["installed", cell("none", "hint")]);
881
+ for (const x of e.items ?? [])
882
+ rows.push([x.label, cell(`v${x.version}${x.package === x.label ? "" : ` · ${x.package}`}`, "ok")]);
883
+ return { title: "Extensions", blocks: [{ kind: "fields", rows }] };
884
+ }
885
+ function folderSection(f, selected) {
886
+ const rows = [["root", f.root]];
887
+ const cwd = canonicalRoot(process.cwd());
888
+ if (cwd !== canonicalRoot(f.root) && (canonicalRoot(f.root) === canonicalRoot(homedir()) || canonicalRoot(join(f.root, ".cotal")) === canonicalRoot(homeCotalDir())))
889
+ rows.push(["root selection", cell("inherited the machine's home .cotal; unqualified up refuses before starting there. Prepare this folder with space create <space> --root . before starting it", "waiting")]);
890
+ const auth = f.auth;
891
+ if (auth.state === "unreadable")
892
+ rows.push(["auth", cell(auth.error ?? "unreadable", "failed")]);
893
+ else if (auth.state === "spaces")
894
+ rows.push(["auth", cell(`${auth.spaces.length} spaces · ${auth.spaces.join(", ")}`, "ok")]);
895
+ else if (auth.state === "space")
896
+ rows.push(["auth", cell(`space ${auth.spaces[0]}${auth.userAuth ? " · user-auth" : ""}`, "ok")]);
897
+ else
898
+ rows.push(["auth", cell("none (open/local only)", "hint")]);
899
+ if (f.launches === null) {
900
+ rows.push(["personas", personaCell(f.personas)]);
901
+ rows.push(["spawn root", cell("unresolved - see Selected Mesh below; until it resolves, no persona here is launchable", "waiting")]);
596
902
  }
597
- const spawnRoot = selected.target.personaRoot;
598
- if (sameDir(folder, spawnRoot)) {
599
- // The simple case: one root, one catalog. Naming it is still worth the width — it is the
600
- // difference between "personas exist" and "personas exist HERE, and here is what launches".
601
- row("personas", `${personaSummary(root)} ${c.dim(`· ${folder}`)}`);
602
- return;
903
+ else if (f.launches)
904
+ rows.push(["personas", personaCell(f.personas)]);
905
+ else {
906
+ // The divergence. The folder's catalog is real and worth reporting, but it is NOT the spawn
907
+ // catalog, so its `default` must not be green: green here is the false capability claim.
908
+ rows.push(["personas", personaCell(f.personas, true)]);
909
+ if (selected.resolved) {
910
+ rows.push(["spawn root", cell(`differs · ${selected.personas.root}`, "waiting")]);
911
+ rows.push(["→ launches", cell(`${personaText(selected.personas)} · space ${selected.space} · via ${selected.source}`, personaTone(selected.personas))]);
912
+ }
603
913
  }
604
- // The divergence. The folder's catalog is real and worth reporting — an operator standing in a
605
- // directory full of personas deserves to be told why they are not the ones that will launch —
606
- // but it is NOT the spawn catalog, so its `default` must not be green: green here is precisely
607
- // the false capability claim. Dim the folder's summary and give the spawn root the live one.
608
- row("personas", `${c.dim(stripColor(personaSummary(root)))} ${c.dim(`· ${folder}`)}`);
609
- row("spawn root", `${c.yellow("differs")} ${c.dim(`· ${spawnRoot}`)}`);
610
- row("→ launches", `${personaSummary(selected.target.root)} ${c.dim(`· space ${selected.target.space} · via ${selected.target.source}`)}`);
611
- row("hint", `a bare \`${cmd} spawn\` uses the mesh above, NOT this folder - personas in ${folder} will not launch until you run it from that mesh's root or select it (\`${cmd} use <space>\`${values.space ? "" : ", or pass `--space`"})`);
914
+ if (auth.state === "spaces")
915
+ rows.push(["processes", cell("not reported per space on a multi-space root", "hint")]);
916
+ for (const p of f.processes ?? [])
917
+ rows.push([p.name, processCell(p)]);
918
+ if (f.storedState)
919
+ rows.push(["stored state", cell("JetStream store persists across down/up", "hint")]);
920
+ return { title: "This Folder", blocks: [{ kind: "fields", rows }] };
612
921
  }
613
- /** Do two catalog paths denote the SAME directory? `canonicalRoot` (realpath, `resolve` fallback
614
- * for a path not on disk) is the repo's one spelling for this: a raw `===` reads a symlinked or
615
- * 8.3-short-name spelling of one directory as two, which here would fabricate a divergence and
616
- * send the operator chasing a split that does not exist. */
617
- function sameDir(a, b) {
618
- return canonicalRoot(a) === canonicalRoot(b);
922
+ function meshesSections(m) {
923
+ const check = { reachable: cell("reachable", "ok"), unreachable: cell("down", "failed"), "not-checked": cell("not checked", "hint") };
924
+ const blocks = [];
925
+ if (!m.items.length && !m.unreadable.length)
926
+ blocks.push({ kind: "lines", lines: [cell("none", "hint")] });
927
+ else
928
+ blocks.push({
929
+ kind: "table",
930
+ columns: [
931
+ { key: "space", label: "SPACE" },
932
+ { key: "check", label: "CHECK" },
933
+ { key: "mode", label: "MODE" },
934
+ { key: "server", label: "SERVER" },
935
+ { key: "root", label: "ROOT" },
936
+ { key: "note", label: "NOTE" },
937
+ ],
938
+ rows: m.items.map((x) => ({
939
+ space: x.current ? cell(`* ${x.space}`, "selected") : ` ${x.space}`,
940
+ check: check[x.check],
941
+ mode: x.mode,
942
+ server: x.server ?? cell("unavailable", "failed"),
943
+ root: x.root,
944
+ // A `down` record means two different things, and the repair differs: a mesh this machine
945
+ // started can be re-`up`ed here, one registered by hand runs somewhere this machine doesn't
946
+ // control (and, unlike the others, its record is never swept away for it).
947
+ note: [
948
+ x.origin === "manual" ? "registered" : x.origin === "catalog" ? "discovered" : "",
949
+ x.tlsRequired ? "tls-required" : "",
950
+ x.eventsRequired ? "events: required" : "",
951
+ x.catalog ? `${x.catalog.name ? `${x.catalog.name} ` : ""}catalog ${x.catalog.error ? `stale since ${x.catalog.fetchedAt ?? "unknown"}: ${x.catalog.error}` : `snapshot ${x.catalog.fetchedAt ?? "unknown"}`}` : "",
952
+ ].filter(Boolean).join(" "),
953
+ })),
954
+ });
955
+ if (!m.currentRecorded)
956
+ blocks.push({ kind: "lines", lines: [cell(`note: current mesh "${m.current}" is ${m.currentPrepared ? "prepared, not started" : "not recorded"}`, "hint")] });
957
+ if (m.unreadable.length)
958
+ blocks.push({ kind: "lines", lines: m.unreadable.map((u) => cell(`unreadable: ${u.error}`, "failed")) });
959
+ const sections = [{ title: "Recorded Meshes", blocks }];
960
+ if (m.catalogs.length)
961
+ sections.push({ title: "Space Catalog Accounts", blocks: [{ kind: "lines", lines: m.catalogs.map((r) => `${r.idp} ${r.state}${r.error ? `: ${r.error}` : ""}`) }] });
962
+ return sections;
963
+ }
964
+ function selectedSection(s) {
965
+ if (!s.resolved)
966
+ return { title: "Selected Mesh", blocks: [{ kind: "fields", rows: [["target", cell(s.code, "failed")]] }] };
967
+ const rows = [
968
+ ["space", s.space],
969
+ ["server", s.server ?? cell("unavailable", "failed")],
970
+ ["mode", s.mode],
971
+ ];
972
+ if (s.eventsRequired)
973
+ rows.push(["events", "required"]);
974
+ if (s.tlsRequired)
975
+ rows.push(["transport", "tls-required"]);
976
+ if (s.idp)
977
+ rows.push(["idp", s.idp]);
978
+ rows.push(["source", s.source], ["root", s.root], ["personas", personaCell(s.personas)]);
979
+ if (s.mode === "user") {
980
+ rows.push(["connection", s.connection === "reachable" ? cell("reachable", "ok") : cell("unreachable", "failed")]);
981
+ const l = s.login;
982
+ if (!l)
983
+ rows.push(["login", cell("unreadable - see the warning below", "failed")]);
984
+ if (l && !l.subject)
985
+ rows.push(["login", cell(`not signed in - ${displayCmd()} login --idp ${l.idp}`, "waiting")]);
986
+ if (l?.subject) {
987
+ rows.push(["login", cell(`${l.subject} · session until ${l.expiresAt}`, "ok")]);
988
+ if (l.actor === "not-granted")
989
+ rows.push(["actor", cell(`"${CLI_USER_ACTOR}" not granted - ${displayCmd()} actor grant ${CLI_USER_ACTOR} --sub ${l.subject} --full`, "waiting")]);
990
+ else if (l.actor === "granted" && l.grant)
991
+ rows.push([
992
+ "actor",
993
+ cell(`"${CLI_USER_ACTOR}" granted${l.grant.label ? ` (${l.grant.label})` : ""} - read [${l.grant.read.join(", ")}], post [${l.grant.post.join(", ")}]${l.grant.scope.length ? `, scope [${l.grant.scope.join(", ")}]` : ""}`, "ok"),
994
+ ]);
995
+ else
996
+ rows.push(["actor", cell("grant not checkable on this machine (no local ledger)", "hint")]);
997
+ }
998
+ }
999
+ else {
1000
+ rows.push(["connection", s.connection === "ok" ? cell("ok", "ok") : cell(`${s.connection}${s.staleRecord ? " (stale registry entry)" : ""}`, "failed")]);
1001
+ if (s.deliveryResponder === "unbound")
1002
+ rows.push(["delivery responder", cell(`NOT BOUND - ${RESPONDER_UNBOUND_CONSEQUENCE} · start it with \`${displayCmd()} up\` (or \`${displayCmd()} deliver --space <space>\`)`, "failed")]);
1003
+ // A stale record is NOT BOUND with a different next move: the slot is occupied by a corpse, so
1004
+ // starting a daemon now loses the single-flight CAS. Say that, rather than sending the operator
1005
+ // into a refusal they will read as a second failure.
1006
+ else if (s.deliveryResponder === "stale")
1007
+ rows.push(["delivery responder", cell(`NOT BOUND - a DEAD daemon's ready record still holds the lease - ${RESPONDER_UNBOUND_CONSEQUENCE} · it expires on its own; a replacement can then take the shard`, "failed")]);
1008
+ else if (s.deliveryResponder === "bound")
1009
+ rows.push(["delivery responder", cell("bound", "ok")]);
1010
+ }
1011
+ if (s.snapshot.state === "unavailable" || (s.mode === "user" && s.snapshot.state === "skipped"))
1012
+ rows.push(["live snapshot", cell(`${s.snapshot.state === "unavailable" ? "unavailable" : "not read"} (${s.snapshot.reason})`, s.snapshot.state === "unavailable" ? "failed" : "hint")]);
1013
+ if (s.channels)
1014
+ rows.push(["channels", s.channels.length ? s.channels.map((ch) => `${ch.channel}(${ch.messages})`).join(", ") : "none"]);
1015
+ if (s.membershipFeed)
1016
+ rows.push(["membership feed", s.membershipFeed.asOf ? cell(`${s.membershipFeed.entries} entries · updated ${formatAge(Math.max(0, Date.now() - Date.parse(s.membershipFeed.asOf)))} ago`, "ok") : cell("no heartbeat", "hint")]);
1017
+ return { title: "Selected Mesh", blocks: [{ kind: "fields", rows }] };
619
1018
  }
620
- /** Drop ANSI SGR sequences so an already-coloured summary can be re-coloured. `personaSummary`
621
- * greens its `default`, and on the divergent path that green is the untrue claim; wrapping without
622
- * stripping leaves the inner green intact (the reset ends it early) and the row still reads
623
- * "launchable". */
624
- function stripColor(s) {
625
- return s.replace(/\x1b\[[0-9;]*m/g, "");
1019
+ function stateCell(text, tone) {
1020
+ return { text, tone, mark: tone === "hint" ? "○" : "●" };
626
1021
  }
627
- function proc(path) {
628
- return pidfileState(path);
1022
+ function machineOverview(r) {
1023
+ const m = r.machine;
1024
+ const tones = { ok: "ok", warn: "waiting", error: "failed", off: "hint" };
1025
+ const rows = m.integrations.map((item) => [item.name, stateCell(item.text, tones[item.state])]);
1026
+ if (m.connectors === null)
1027
+ rows.push(["Agent applications", stateCell("could not be read", "failed")]);
1028
+ else if (!m.connectors.length)
1029
+ rows.push(["Agent applications", stateCell("not set up", "hint")]);
1030
+ for (const connector of m.connectors ?? []) {
1031
+ if (m.integrations.some((item) => item.name.toLowerCase().includes(connector.name.toLowerCase())))
1032
+ continue;
1033
+ rows.push([connector.name, stateCell(connector.missing.length ? `${connector.missing.join(", ")} not on PATH` : connector.requires.length ? "available on PATH" : "in-process", connector.missing.length ? "waiting" : "ok")]);
1034
+ }
1035
+ rows.push(["Broker executable", stateCell(m.nats === "missing" ? "not installed" : m.nats === "path" ? "available on PATH" : "bundled", m.nats === "missing" ? "waiting" : "ok")]);
1036
+ rows.push(["Agent skills", skillsCell(m.skills)]);
1037
+ rows.push(["Dashboard", stateCell(m.web.installed === null ? "installation could not be read" : m.web.installed ? "installed" : "not installed · optional", m.web.installed === null ? "failed" : m.web.installed ? "ok" : "hint")]);
1038
+ if (r.extensions.items === null)
1039
+ rows.push(["Extensions", stateCell("manifest could not be read", "failed")]);
1040
+ else if (r.extensions.items.length)
1041
+ rows.push(["Extensions", r.extensions.items.map((item) => `${item.label} v${item.version}`).join(" · ")]);
1042
+ return {
1043
+ title: "This machine",
1044
+ blocks: [
1045
+ { kind: "lines", lines: [`cotal ${m.version} · Node ${m.node} · ${m.platform}`] },
1046
+ { kind: "fields", rows },
1047
+ ],
1048
+ };
629
1049
  }
630
- function formatProc(p) {
631
- if (p.liveness === "alive")
632
- return c.green(`running (pid ${p.pid})`);
633
- return c.dim(p.pid ? `${p.note} (${p.pid})` : (p.note ?? "down"));
1050
+ function connectionCell(s) {
1051
+ if (s.connection === "ok" || s.connection === "reachable")
1052
+ return stateCell("reachable", "ok");
1053
+ const states = {
1054
+ unreachable: "unreachable",
1055
+ "slow-link": "connection timed out",
1056
+ "tls-trust": "TLS could not be verified",
1057
+ "stale-auth": "credentials need renewal",
1058
+ "auth-required": "authentication required",
1059
+ "open-wants-auth": "authentication required",
1060
+ "registry-open-now-auth": "authentication required",
1061
+ "creds-rejected": "credentials rejected",
1062
+ "registry-creds-rejected": "credentials rejected",
1063
+ };
1064
+ return stateCell(`${states[s.connection] ?? s.connection.replaceAll("-", " ")}${s.staleRecord ? " · saved registration needs attention" : ""}`, "failed");
634
1065
  }
635
- /** Bare status's manager row, #2073: a live pid alone is not proof the manager serves — that was
636
- * exactly the incident (a lease holder whose service rail had died stayed `running` for hours).
637
- * So a live manager pid gets ONE probe of its own service endpoint before the row prints. This
638
- * adds one request to every bare `status` call for a live manager pid.
639
- *
640
- * Three outcomes:
641
- * - answered: the row prints exactly as before (green `running (pid N)` plus the delivery-aware
642
- * suffix).
643
- * - a DEFINITIVE no-answer — the same predicate `managerHealth`'s not-serving branch uses
644
- * (`unansweredRequest`, or the service-registry-missing text): red `not serving (pid N)` with
645
- * ` · service endpoint not answering`, plus the marker error when the marker could not be read.
646
- * - any other failure (a refused probe, an `unavailable` user-mode credential): `running (pid N)`
647
- * as today with a dim ` · service unchecked`, so a failed probe never reads as a dead rail.
648
- *
649
- * Bare status keeps exit 0 in every case; this only changes what the row says. A dead/stopped pid
650
- * never reaches the probe at all (the early return below), so a stopped manager still reads as the
651
- * dim stopped row, not `not serving` — a dead pid is not a live pid that will not answer. */
652
- async function managerRowState(target, state, space) {
653
- if (state.liveness !== "alive")
654
- return formatProc(state);
655
- let deliveryAware = false;
656
- let markerUnreadable = "";
657
- try {
658
- deliveryAware = managerHasDeliveryMarker(state.pid, space);
1066
+ function brokerOverview(r) {
1067
+ const blocks = [];
1068
+ const groups = new Map();
1069
+ for (const entry of r.meshes.items) {
1070
+ const key = entry.server ?? `unavailable:${entry.space}`;
1071
+ const group = groups.get(key);
1072
+ if (group)
1073
+ group.push(entry);
1074
+ else
1075
+ groups.set(key, [entry]);
659
1076
  }
660
- catch (e) {
661
- // The marker reader throws so `up` and the delivery preflight refuse to act on a marker they
662
- // cannot read. Status is the recovery command: name the failed read on this row and report the rest.
663
- markerUnreadable = c.red(` · delivery-aware marker unreadable: ${e.message}`);
1077
+ if (!groups.size && !r.meshes.unreadable.length)
1078
+ blocks.push({ kind: "lines", lines: [cell("No spaces registered", "hint")] });
1079
+ for (const entries of groups.values()) {
1080
+ blocks.push({ kind: "lines", lines: [cell(entries[0].server ?? "Broker address unavailable", "title")] });
1081
+ blocks.push({
1082
+ kind: "table",
1083
+ header: false,
1084
+ columns: [{ key: "space", label: "Space" }, { key: "state", label: "Connection" }, { key: "detail", label: "Details" }],
1085
+ rows: entries.map((entry) => {
1086
+ const selected = r.selected.resolved && entry.space === r.selected.space;
1087
+ const detail = [entry.mode === "user" ? "user sign-in" : entry.mode === "auth" ? "static auth" : "open", entry.origin === "catalog" ? "saved catalog entry" : entry.origin === "manual" ? "registered endpoint" : "local registration", entry.tlsRequired ? "TLS required" : "", entry.catalog?.error ? "catalog refresh failed" : ""].filter(Boolean).join(" · ");
1088
+ return {
1089
+ space: selected ? cell(`→ ${entry.space}`, "selected") : entry.space,
1090
+ state: selected && r.selected.resolved ? connectionCell(r.selected) : entry.check === "not-checked" ? stateCell("not checked", "hint") : stateCell(entry.check === "reachable" ? "reachable" : "unreachable", entry.check === "reachable" ? "ok" : "failed"),
1091
+ detail: cell(detail, "hint"),
1092
+ };
1093
+ }),
1094
+ });
664
1095
  }
665
- const unprobed = `${formatProc(state)}${markerUnreadable || c.dim(deliveryAware ? " · delivery-aware" : " · old/unknown build")}`;
666
- if (!target)
667
- return unprobed;
668
- try {
669
- let auth;
670
- if (target.mode === "user") {
671
- const credential = await componentCredential(target);
672
- if (credential.kind !== "user")
673
- return `${unprobed}${c.dim(" · service unchecked")}`;
674
- auth = { bearer: credential.bearer, sentinelCreds: credential.sentinelCreds, caller: credential.caller };
675
- }
1096
+ for (const unreadable of r.meshes.unreadable)
1097
+ blocks.push({ kind: "lines", lines: [stateCell(`Registration could not be read: ${unreadable.error}`, "failed")] });
1098
+ for (const account of r.meshes.catalogs)
1099
+ if (account.error)
1100
+ blocks.push({ kind: "lines", lines: [stateCell(`Space catalog for ${account.idp}: ${account.error}`, "failed")] });
1101
+ if (!r.meshes.currentRecorded)
1102
+ blocks.push({ kind: "lines", lines: [cell(`Selected space '${r.meshes.current}' is ${r.meshes.currentPrepared ? "prepared, not started" : "not recorded"}`, "waiting")] });
1103
+ return { title: "Brokers", blocks };
1104
+ }
1105
+ function selectedOverview(r) {
1106
+ const s = r.selected;
1107
+ if (!s.resolved)
1108
+ return { title: "Selected space", blocks: [{ kind: "lines", lines: [stateCell(s.message, "failed")] }] };
1109
+ if (!r.meshes.items.length && !r.meshes.currentPrepared && r.folder.auth.state === "none" && !r.folder.processes?.some((item) => item.pid !== null))
1110
+ return undefined;
1111
+ const rows = [
1112
+ ["Broker", s.server ?? stateCell("address unavailable", "failed")],
1113
+ ["Connection", connectionCell(s)],
1114
+ ["Access", s.mode === "user" ? "user sign-in" : s.mode === "auth" ? "static auth" : "open"],
1115
+ ["Project", s.root],
1116
+ ["Default agent", r.machine.defaults ? `${r.machine.defaults.harness ?? "application not set"} · persona ${r.machine.defaults.persona ?? "not set"}` : stateCell("saved defaults could not be read", "failed")],
1117
+ ["Persona catalog", s.personas.default === "valid" ? "default available" : stateCell(s.personas.default === "invalid" ? "default is invalid" : s.personas.default === "unreadable" ? "could not be read" : "no default persona", s.personas.default === "invalid" || s.personas.default === "unreadable" ? "failed" : "hint")],
1118
+ ];
1119
+ if (s.tlsRequired)
1120
+ rows.push(["Transport", "TLS required"]);
1121
+ if (s.eventsRequired)
1122
+ rows.push(["Events", "required"]);
1123
+ if (s.mode === "user") {
1124
+ if (!s.login)
1125
+ rows.push(["Account", stateCell("could not be read", "failed")]);
1126
+ else if (!s.login.subject)
1127
+ rows.push(["Account", stateCell("not signed in", "waiting")]);
676
1128
  else {
677
- auth = await staticServiceAuth(target.auth);
1129
+ rows.push(["Account", `${s.login.subject} · session until ${s.login.expiresAt}`]);
1130
+ rows.push(["Grant", stateCell(s.login.actor === "granted" ? "granted" : s.login.actor === "not-granted" ? "not granted" : "not checkable on this machine", s.login.actor === "granted" ? "ok" : s.login.actor === "not-granted" ? "waiting" : "hint")]);
678
1131
  }
679
- await managerServiceHealth(target, auth);
680
- return unprobed;
681
1132
  }
682
- catch (e) {
683
- const noService = e instanceof EpEnvelopeError && (unansweredRequest(e) || /service registry.*stream not found/i.test(e.message));
684
- if (noService)
685
- return `${c.red(`not serving (pid ${state.pid})`)}${c.dim(" · service endpoint not answering")}${markerUnreadable}`;
686
- return `${unprobed}${c.dim(" · service unchecked")}`;
1133
+ if (s.snapshot.state === "unavailable")
1134
+ rows.push(["Live details", stateCell(`unavailable · ${s.snapshot.reason}`, "waiting")]);
1135
+ const blocks = [{ kind: "fields", rows }];
1136
+ if (r.folder.root === s.root && r.folder.processSpace === s.space && r.folder.processes) {
1137
+ blocks.push({ kind: "lines", lines: [cell("Legacy local process records", "label")] });
1138
+ blocks.push({
1139
+ kind: "table", header: false,
1140
+ columns: [{ key: "name", label: "Service" }, { key: "state", label: "State" }],
1141
+ rows: r.folder.processes.map((item) => ({
1142
+ name: item.name === "nats" ? "Broker" : item.name === "manager" ? "Manager" : item.name === "delivery" ? "Delivery" : item.name === "web" ? "Web" : item.name,
1143
+ state: item.state === "running" || item.state === "not-serving" || item.state === "unreadable" ? processCell(item) : stateCell(item.pid === null ? "not started" : item.detail ?? "stopped", "hint"),
1144
+ })),
1145
+ });
687
1146
  }
1147
+ else
1148
+ blocks.push({ kind: "lines", lines: [cell("Legacy process records not checked here · the selected space has a different or unresolved local process scope", "hint")] });
1149
+ if (r.folder.launches === false)
1150
+ blocks.push({ kind: "lines", lines: [cell(`This folder's personas are not used by the selected space. Spawn uses ${s.personas.root}.`, "waiting")] });
1151
+ return { title: `Selected space → ${s.space}`, blocks };
688
1152
  }
689
- /** The delivery row's responder suffix, coloured for the bare-status renderer (#1576).
690
- *
691
- * RED, NOT DIM, FOR AN UNBOUND RESPONDER. The state is not a footnote about a component: while it
692
- * holds, the mesh cannot spawn, retire or accept a join, and the whole reported incident is that
693
- * this read as ordinary. `unknown` stays dim and names `--components`, because an unchecked axis
694
- * must not look like a diagnosis in either direction. */
695
- function deliveryRowNote(live, responder) {
696
- const suffix = deliveryRowSuffix(live, responder, `${displayCmd()} status --components`);
697
- if (!suffix)
698
- return "";
699
- return responder === "unbound" || responder === "stale" ? c.red(suffix) : c.dim(suffix);
1153
+ function nextActions(r) {
1154
+ const cmd = displayCmd();
1155
+ const items = [];
1156
+ if (!r.machine.connectors?.length)
1157
+ items.push({ command: `${cmd} setup`, description: "Set up an agent application and a space" });
1158
+ else {
1159
+ if (r.selected.resolved) {
1160
+ const s = r.selected;
1161
+ // Name what fixes the default persona alone; setup does far more than that.
1162
+ if (s.personas.default === "missing") {
1163
+ const fix = defaultPersonaFix({ space: s.space, root: s.root, origin: r.meshes.items.find((m) => m.space === s.space)?.origin }, cmd);
1164
+ items.push({ command: fix.command, description: fix.cwd ? `Write the default persona; run it in ${fix.cwd}` : "Create the default persona" });
1165
+ }
1166
+ else if (s.personas.default !== "valid")
1167
+ items.push({ command: `${cmd} persona show default --space ${s.space}`, description: "See what is wrong with the default persona" });
1168
+ else
1169
+ items.push({ command: `${cmd} spawn`, description: "Open your default agent" });
1170
+ items.push({ command: `${cmd} ps`, description: "See the agent roster" });
1171
+ }
1172
+ items.push({ command: `${cmd} use`, description: "Choose another space" });
1173
+ if (r.meshes.items.length > 1)
1174
+ items.push({ command: `${cmd} status --all`, description: "Check every registered space" });
1175
+ }
1176
+ if (r.selected.resolved && r.selected.mode === "user" && r.selected.login && !r.selected.login.subject)
1177
+ items.unshift({ command: `${cmd} login --idp ${r.selected.login.idp}`, description: "Sign in to the selected space" });
1178
+ return { title: "Next", blocks: [{ kind: "commands", items }, ...r.hints.map((hint) => ({ kind: "lines", lines: [cell(hint, "hint")] }))] };
1179
+ }
1180
+ function ownedServicesOverview(services) {
1181
+ if (!services || services.state === "not-checked")
1182
+ return undefined;
1183
+ const blocks = [];
1184
+ if (services.definitions === null)
1185
+ blocks.push({ kind: "lines", lines: [stateCell("Saved service definitions unavailable", "waiting")] });
1186
+ if (services.instances === null)
1187
+ blocks.push({ kind: "lines", lines: [stateCell("Owned service instances unavailable; no stopped state inferred", "waiting")] });
1188
+ if (services.instances?.length)
1189
+ blocks.push({ kind: "table", columns: [{ key: "service", label: "Service" }, { key: "instance", label: "Full instance" }, { key: "host", label: "Execution host" }, { key: "process", label: "Process observation" }, { key: "readiness", label: "Recorded readiness" }, { key: "supervisor", label: "Supervisor record" }], rows: services.instances.slice(0, 100).map((row) => ({
1190
+ service: row.definition, instance: row.instanceId, host: row.executionHost,
1191
+ process: stateCell(row.observedProcess.replaceAll("-", " "), row.observedProcess === "running" ? "ok" : row.observedProcess === "unreadable" || row.observedProcess === "unresolved-launch" || row.observedProcess === "foreign-host" ? "waiting" : "hint"),
1192
+ readiness: cell(`${row.readinessObservation.replaceAll("-", " ")} · ${row.readinessAsOf}`, "hint"),
1193
+ supervisor: row.supervisorRecord.mechanism === "none-recorded" ? "not assigned here" : `${row.supervisorRecord.mechanism} · ${row.supervisorRecord.fileObservation}; OS state not checked`,
1194
+ })) });
1195
+ if (services.instances && services.instances.length > 100)
1196
+ blocks.push({ kind: "lines", lines: [cell(`${services.instances.length - 100} instance rows omitted; --json retains the complete readable inventory.`, "hint")] });
1197
+ const instantiated = new Set(services.instances?.map((row) => row.definition));
1198
+ const saved = services.instances === null ? [] : services.definitions?.filter((row) => !instantiated.has(row.name)) ?? [];
1199
+ if (saved.length)
1200
+ blocks.push({ kind: "table", columns: [{ key: "service", label: "Saved service" }, { key: "type", label: "Launch type" }, { key: "observation", label: "Instance records" }], rows: saved.slice(0, 100).map((row) => ({ service: row.name, type: row.launch.type === "adapter" ? row.launch.adapter : "process", observation: "no owned instance recorded" })) });
1201
+ if (saved.length > 100)
1202
+ blocks.push({ kind: "lines", lines: [cell(`${saved.length - 100} saved definitions omitted; --json retains the complete readable inventory.`, "hint")] });
1203
+ if (services.definitions?.length === 0 && services.instances?.length === 0)
1204
+ blocks.push({ kind: "lines", lines: [cell("No saved definitions or owned instance records in this selected space.", "hint")] });
1205
+ blocks.push({ kind: "lines", lines: [cell(`Local records and process observations as of ${services.observedAt}; non-atomic. Recorded readiness is historical, not a fresh endpoint response. No OS unit query, service control, adoption or remote process ownership is implied.`, "hint")] });
1206
+ // The space is known here, and a sole instance names its service and full ID as well.
1207
+ const sole = services.instances?.length === 1 ? services.instances[0] : undefined;
1208
+ const inspect = sole ? `${displayCmd()} svc status ${sole.definition} --instance ${sole.instanceId} --space ${services.space}` : `${displayCmd()} svc status <service> --instance <full-id> --space ${services.space}`;
1209
+ if (services.instances?.length || services.definitions?.length)
1210
+ blocks.push({ kind: "commands", items: [{ command: inspect, description: "Inspect one exact owned instance and its recorded supervisor" }, { command: `${displayCmd()} svc`, description: "Read the full saved-service inventory" }] });
1211
+ return { title: `Owned services → ${services.space}`, blocks };
1212
+ }
1213
+ function bootAttemptOverview(snapshot) {
1214
+ if (!snapshot || !snapshot.unsettled.length && !snapshot.additive.length && !snapshot.unreadable.length)
1215
+ return undefined;
1216
+ return { title: "Deployment attempts", blocks: [
1217
+ { kind: "fields", rows: [["Folder root", snapshot.root], ["Local read", snapshot.state], ["Unsettled fresh", String(snapshot.unsettled.length)], ["Additive attempts", String(snapshot.additive.length)], ["Unreadable records", String(snapshot.unreadable.length)]] },
1218
+ snapshot.unsettled.length ? { kind: "table", columns: [{ key: "id", label: "Fresh boot" }, { key: "space", label: "Space" }, { key: "broker", label: "Recorded broker" }], rows: snapshot.unsettled.slice(0, 100).map((row) => ({ id: row.deploymentId, space: row.space, broker: row.server })) } : { kind: "lines", lines: ["No readable unsettled fresh attempt in this folder."] },
1219
+ snapshot.additive.length ? { kind: "table", columns: [{ key: "id", label: "Additive intent" }, { key: "space", label: "Space" }, { key: "state", label: "Recorded state" }], rows: snapshot.additive.slice(0, 100).map((row) => ({ id: row.deploymentId, space: row.space, state: row.recordedState })) } : { kind: "lines", lines: ["No readable additive attempt in this folder."] },
1220
+ { kind: "lines", lines: [...snapshot.unreadable.slice(0, 100).map((path) => `Unreadable record: ${path}`), ...(snapshot.unsettled.length > 100 || snapshot.additive.length > 100 || snapshot.unreadable.length > 100 ? ["Additional records are in JSON."] : []), "A fresh intent may have started a broker; an additive intent may have changed its resources. No retry or stop authority follows from this read."] },
1221
+ { kind: "commands", items: [{ command: `${displayCmd()} team show <deployment-id>`, description: "Inspect the original attempt from its recorded root" }] },
1222
+ ] };
1223
+ }
1224
+ /** The approved screen hierarchy; record-level diagnostics are opt-in. */
1225
+ export function statusView(r, verbose = false) {
1226
+ const selected = selectedOverview(r);
1227
+ const owned = ownedServicesOverview(r.services);
1228
+ const attempts = bootAttemptOverview(r.bootAttempts);
1229
+ const sections = [machineOverview(r), brokerOverview(r), ...(selected ? [selected] : []), ...(attempts ? [attempts] : []), ...(owned ? [owned] : [])];
1230
+ if (verbose)
1231
+ sections.push(machineSection(r.machine), extensionsSection(r.extensions), folderSection(r.folder, r.selected), ...meshesSections(r.meshes), selectedSection(r.selected));
1232
+ sections.push(nextActions(r));
1233
+ return { sections };
700
1234
  }
701
1235
  function section(name) {
702
1236
  console.log(`\n${c.bold(name)}`);
703
1237
  }
704
- function row(name, value) {
705
- console.log(` ${name.padEnd(16)} ${value}`);
706
- }
707
1238
  const COMPONENT_EXIT = {
708
1239
  serving: 0,
709
1240
  absent: 1,
@@ -839,6 +1370,39 @@ async function staticServiceAuth(auth) {
839
1370
  caller: { owner: "local", actor: serviceIdentity.id, uid: serviceUid },
840
1371
  };
841
1372
  }
1373
+ /** Display only. A status observation never authorizes process control or proves cleanup. */
1374
+ function managerStopImpactFacts(input) {
1375
+ if (!input || typeof input !== "object" || Array.isArray(input))
1376
+ return ["stop impact not reported by this manager build"];
1377
+ const impact = input;
1378
+ if (!["manager", "owner-filtered"].includes(String(impact.agentScope)) || typeof impact.observedAt !== "string" || impact.observedAt.length > 100 || !Number.isFinite(Date.parse(impact.observedAt)) || !Array.isArray(impact.agents))
1379
+ return ["stop impact could not be interpreted; no safe stop inferred"];
1380
+ const facts = [`stop impact ${impact.agentScope === "manager" ? "manager-owned rows" : "owner-filtered; full scope unknown"} as of ${new Date(impact.observedAt).toISOString()}`];
1381
+ const actions = { stop: 0, release: 0, retained: 0, unknown: 0 };
1382
+ for (const row of impact.agents) {
1383
+ const action = row && typeof row === "object" && !Array.isArray(row) ? row.defaultAction : undefined;
1384
+ if (action === "stop")
1385
+ actions.stop++;
1386
+ else if (action === "release-custody")
1387
+ actions.release++;
1388
+ else if (action === "stop-retaining-state")
1389
+ actions.retained++;
1390
+ else
1391
+ actions.unknown++;
1392
+ }
1393
+ facts.push(`default stop policy: stop ${actions.stop}, release custody ${actions.release}, stop retaining state ${actions.retained}, unknown ${actions.unknown} visible seats`);
1394
+ for (const [key, label] of [["lifecycleInFlight", "lifecycle work"], ["reservedLaunches", "reserved launches"], ["retirementsPending", "pending retirements"], ["deprovisioningInFlight", "cleanup in flight"], ["staticReconciliationInFlight", "reconciliation in flight"]]) {
1395
+ const count = impact[key];
1396
+ if (!Number.isSafeInteger(count) || Number(count) < 0)
1397
+ facts.push(`${label} unknown`);
1398
+ else if (Number(count) > 0)
1399
+ facts.push(`${label} ${count}`);
1400
+ }
1401
+ if (impact.stopping === true)
1402
+ facts.push("native manager stop already in progress");
1403
+ facts.push("stop not reserved; seat exit and cleanup not checked");
1404
+ return facts;
1405
+ }
842
1406
  /** A service registration is the health target itself. Calling its `status` command through a
843
1407
  * generic endpoint does not work on this base because a passive status endpoint has no v0.4 caller
844
1408
  * rail; a one-shot standalone caller does. */
@@ -919,6 +1483,7 @@ async function managerHealth(target, context, credential) {
919
1483
  const served = await managerServiceHealth(target, serviceAuth);
920
1484
  facts.push(`service instance ${served.instanceId ?? "unreported"}`);
921
1485
  facts.push(`runtime ${served.runtime ?? "unreported"}`);
1486
+ facts.push(...managerStopImpactFacts(served.stopImpact));
922
1487
  const reconcile = served.staticReconciliation;
923
1488
  if (!reconcile) {
924
1489
  facts.push("static reconciliation not reported by this manager build");
@@ -1061,12 +1626,21 @@ async function webHealth(context) {
1061
1626
  if (record.kind !== "live")
1062
1627
  throw new Error("web component record lost its live pid after classification");
1063
1628
  const pid = record.pid;
1629
+ let source;
1630
+ try {
1631
+ source = webSessionSource(context, pid);
1632
+ }
1633
+ catch (e) {
1634
+ return { name: "web", verdict: "refused", facts: [...facts, `service instance records unreadable: ${e.message}`] };
1635
+ }
1636
+ if (source.instance !== undefined)
1637
+ facts.push(`service instance ${source.instance}`);
1064
1638
  let bound;
1065
1639
  try {
1066
- bound = webBoundAddress(localProcessPath(WEB_SESSION_FILE, context));
1640
+ bound = webBoundAddress(source.path);
1067
1641
  }
1068
1642
  catch (e) {
1069
- return { name: "web", verdict: "refused", facts: [...facts, `${WEB_SESSION_FILE} unreadable: ${e.message}`] };
1643
+ return { name: "web", verdict: "refused", facts: [...facts, `${source.label} unreadable: ${e.message}`] };
1070
1644
  }
1071
1645
  if (!bound)
1072
1646
  return { name: "web", verdict: "refused", facts: [...facts, "probe refused (no bound address recorded)"] };
@@ -1085,14 +1659,17 @@ async function webHealth(context) {
1085
1659
  return { name: "web", verdict: "not-serving", facts: [...facts, `host ${bound.host}`, `port ${bound.port}`, "http not answered"] };
1086
1660
  }
1087
1661
  async function brokerHealth(target) {
1662
+ const address = brokerAddressForDisplay(target.server);
1663
+ if (address === undefined)
1664
+ return { name: "broker", verdict: "refused", facts: ["registered address unavailable", "invalid broker address"] };
1088
1665
  try {
1089
1666
  const reachable = await isReachable(target.server, target.tlsRequired ? { tls: true } : {});
1090
1667
  return reachable
1091
- ? { name: "broker", verdict: "serving", facts: [`registered ${target.server}`, "reachable"] }
1092
- : { name: "broker", verdict: "not-serving", facts: [`registered ${target.server}`, "unreachable"] };
1668
+ ? { name: "broker", verdict: "serving", facts: [`registered ${address}`, "reachable"] }
1669
+ : { name: "broker", verdict: "not-serving", facts: [`registered ${address}`, "unreachable"] };
1093
1670
  }
1094
1671
  catch (e) {
1095
- return { name: "broker", verdict: "refused", facts: [`registered ${target.server}`, `probe refused: ${e.message}`] };
1672
+ return { name: "broker", verdict: "refused", facts: [`registered ${address}`, `probe refused: ${e.message}`] };
1096
1673
  }
1097
1674
  }
1098
1675
  async function printComponentHealth(cwd, values) {
@@ -1109,6 +1686,12 @@ async function printComponentHealth(cwd, values) {
1109
1686
  }
1110
1687
  throw e;
1111
1688
  }
1689
+ // The report's own rule: an unregistered project root is given no broker to probe.
1690
+ if (target.source === "local-space") {
1691
+ printComponent({ name: "target", verdict: "refused", facts: ["unregistered-root", `no space is registered or prepared here for ${target.root}`] });
1692
+ process.exitCode = COMPONENT_EXIT.refused;
1693
+ return;
1694
+ }
1112
1695
  const context = { root: target.root, space: target.space, userAuth: target.mode === "user" };
1113
1696
  // ONE credential read for the whole pass (user mode resolves the signed-in login once; the
1114
1697
  // static shape is just the target's own auth material), shared by the manager and delivery