@cotal-ai/cli 0.90.1 → 0.92.0

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