@cotal-ai/cli 0.90.0 → 0.91.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (759) hide show
  1. package/dist/chat/chat-view.d.ts +17 -0
  2. package/dist/chat/chat-view.d.ts.map +1 -0
  3. package/dist/chat/chat-view.js +179 -0
  4. package/dist/chat/chat-view.js.map +1 -0
  5. package/dist/chat/controller.d.ts +19 -0
  6. package/dist/chat/controller.d.ts.map +1 -0
  7. package/dist/chat/controller.js +116 -0
  8. package/dist/chat/controller.js.map +1 -0
  9. package/dist/chat/engine.d.ts +108 -0
  10. package/dist/chat/engine.d.ts.map +1 -0
  11. package/dist/chat/engine.js +226 -0
  12. package/dist/chat/engine.js.map +1 -0
  13. package/dist/chat/frontend.d.ts +35 -0
  14. package/dist/chat/frontend.d.ts.map +1 -0
  15. package/dist/chat/frontend.js +151 -0
  16. package/dist/chat/frontend.js.map +1 -0
  17. package/dist/chat/native-session.d.ts +71 -0
  18. package/dist/chat/native-session.d.ts.map +1 -0
  19. package/dist/chat/native-session.js +348 -0
  20. package/dist/chat/native-session.js.map +1 -0
  21. package/dist/chat/open-session.d.ts +8 -0
  22. package/dist/chat/open-session.d.ts.map +1 -0
  23. package/dist/chat/open-session.js +120 -0
  24. package/dist/chat/open-session.js.map +1 -0
  25. package/dist/chat/picker.d.ts +34 -0
  26. package/dist/chat/picker.d.ts.map +1 -0
  27. package/dist/chat/picker.js +97 -0
  28. package/dist/chat/picker.js.map +1 -0
  29. package/dist/chat/plain.d.ts +15 -0
  30. package/dist/chat/plain.d.ts.map +1 -0
  31. package/dist/chat/plain.js +242 -0
  32. package/dist/chat/plain.js.map +1 -0
  33. package/dist/chat/session.d.ts +217 -0
  34. package/dist/chat/session.d.ts.map +1 -0
  35. package/dist/chat/session.js +2 -0
  36. package/dist/chat/session.js.map +1 -0
  37. package/dist/chat/static-session.d.ts +61 -0
  38. package/dist/chat/static-session.d.ts.map +1 -0
  39. package/dist/chat/static-session.js +212 -0
  40. package/dist/chat/static-session.js.map +1 -0
  41. package/dist/chat/stdio-io.d.ts +34 -0
  42. package/dist/chat/stdio-io.d.ts.map +1 -0
  43. package/dist/chat/stdio-io.js +175 -0
  44. package/dist/chat/stdio-io.js.map +1 -0
  45. package/dist/chat/stdio.d.ts +173 -0
  46. package/dist/chat/stdio.d.ts.map +1 -0
  47. package/dist/chat/stdio.js +400 -0
  48. package/dist/chat/stdio.js.map +1 -0
  49. package/dist/chat/user-session.d.ts +21 -0
  50. package/dist/chat/user-session.d.ts.map +1 -0
  51. package/dist/chat/user-session.js +180 -0
  52. package/dist/chat/user-session.js.map +1 -0
  53. package/dist/chat/view.d.ts +186 -0
  54. package/dist/chat/view.d.ts.map +1 -0
  55. package/dist/chat/view.js +386 -0
  56. package/dist/chat/view.js.map +1 -0
  57. package/dist/command.d.ts +11 -3
  58. package/dist/command.d.ts.map +1 -1
  59. package/dist/command.js +392 -147
  60. package/dist/command.js.map +1 -1
  61. package/dist/commands/agents.d.ts +103 -11
  62. package/dist/commands/agents.d.ts.map +1 -1
  63. package/dist/commands/agents.js +501 -251
  64. package/dist/commands/agents.js.map +1 -1
  65. package/dist/commands/app-identity.d.ts.map +1 -1
  66. package/dist/commands/app-identity.js +10 -1
  67. package/dist/commands/app-identity.js.map +1 -1
  68. package/dist/commands/backup-maintenance.d.ts +4 -0
  69. package/dist/commands/backup-maintenance.d.ts.map +1 -0
  70. package/dist/commands/backup-maintenance.js +92 -0
  71. package/dist/commands/backup-maintenance.js.map +1 -0
  72. package/dist/commands/backup-read.d.ts +4 -0
  73. package/dist/commands/backup-read.d.ts.map +1 -0
  74. package/dist/commands/backup-read.js +27 -0
  75. package/dist/commands/backup-read.js.map +1 -0
  76. package/dist/commands/backup-restore.d.ts +7 -0
  77. package/dist/commands/backup-restore.d.ts.map +1 -0
  78. package/dist/commands/backup-restore.js +81 -0
  79. package/dist/commands/backup-restore.js.map +1 -0
  80. package/dist/commands/backup.d.ts +2 -1
  81. package/dist/commands/backup.d.ts.map +1 -1
  82. package/dist/commands/backup.js +102 -24
  83. package/dist/commands/backup.js.map +1 -1
  84. package/dist/commands/channel-members.d.ts +8 -0
  85. package/dist/commands/channel-members.d.ts.map +1 -0
  86. package/dist/commands/channel-members.js +144 -0
  87. package/dist/commands/channel-members.js.map +1 -0
  88. package/dist/commands/channels.d.ts +75 -22
  89. package/dist/commands/channels.d.ts.map +1 -1
  90. package/dist/commands/channels.js +181 -100
  91. package/dist/commands/channels.js.map +1 -1
  92. package/dist/commands/chat.d.ts +109 -0
  93. package/dist/commands/chat.d.ts.map +1 -0
  94. package/dist/commands/chat.js +227 -0
  95. package/dist/commands/chat.js.map +1 -0
  96. package/dist/commands/clean.d.ts +43 -1
  97. package/dist/commands/clean.d.ts.map +1 -1
  98. package/dist/commands/clean.js +90 -47
  99. package/dist/commands/clean.js.map +1 -1
  100. package/dist/commands/completion.d.ts +39 -1
  101. package/dist/commands/completion.d.ts.map +1 -1
  102. package/dist/commands/completion.js +211 -87
  103. package/dist/commands/completion.js.map +1 -1
  104. package/dist/commands/config.d.ts +33 -0
  105. package/dist/commands/config.d.ts.map +1 -0
  106. package/dist/commands/config.js +159 -0
  107. package/dist/commands/config.js.map +1 -0
  108. package/dist/commands/console.d.ts.map +1 -1
  109. package/dist/commands/console.js +25 -7
  110. package/dist/commands/console.js.map +1 -1
  111. package/dist/commands/describe.d.ts +63 -31
  112. package/dist/commands/describe.d.ts.map +1 -1
  113. package/dist/commands/describe.js +264 -136
  114. package/dist/commands/describe.js.map +1 -1
  115. package/dist/commands/doctor.d.ts +11 -6
  116. package/dist/commands/doctor.d.ts.map +1 -1
  117. package/dist/commands/doctor.js +195 -288
  118. package/dist/commands/doctor.js.map +1 -1
  119. package/dist/commands/down-services.d.ts +29 -0
  120. package/dist/commands/down-services.d.ts.map +1 -0
  121. package/dist/commands/down-services.js +129 -0
  122. package/dist/commands/down-services.js.map +1 -0
  123. package/dist/commands/down.d.ts +37 -11
  124. package/dist/commands/down.d.ts.map +1 -1
  125. package/dist/commands/down.js +276 -115
  126. package/dist/commands/down.js.map +1 -1
  127. package/dist/commands/endpoint-authoring.d.ts +4 -0
  128. package/dist/commands/endpoint-authoring.d.ts.map +1 -0
  129. package/dist/commands/endpoint-authoring.js +125 -0
  130. package/dist/commands/endpoint-authoring.js.map +1 -0
  131. package/dist/commands/endpoint-deregister.d.ts +5 -0
  132. package/dist/commands/endpoint-deregister.d.ts.map +1 -0
  133. package/dist/commands/endpoint-deregister.js +70 -0
  134. package/dist/commands/endpoint-deregister.js.map +1 -0
  135. package/dist/commands/endpoint.d.ts +118 -0
  136. package/dist/commands/endpoint.d.ts.map +1 -0
  137. package/dist/commands/endpoint.js +177 -0
  138. package/dist/commands/endpoint.js.map +1 -0
  139. package/dist/commands/endpoints.d.ts +27 -1
  140. package/dist/commands/endpoints.d.ts.map +1 -1
  141. package/dist/commands/endpoints.js +42 -30
  142. package/dist/commands/endpoints.js.map +1 -1
  143. package/dist/commands/ext.d.ts +38 -1
  144. package/dist/commands/ext.d.ts.map +1 -1
  145. package/dist/commands/ext.js +84 -49
  146. package/dist/commands/ext.js.map +1 -1
  147. package/dist/commands/feedback.d.ts +58 -1
  148. package/dist/commands/feedback.d.ts.map +1 -1
  149. package/dist/commands/feedback.js +119 -47
  150. package/dist/commands/feedback.js.map +1 -1
  151. package/dist/commands/help.d.ts +20 -0
  152. package/dist/commands/help.d.ts.map +1 -0
  153. package/dist/commands/help.js +52 -0
  154. package/dist/commands/help.js.map +1 -0
  155. package/dist/commands/history-clear.d.ts +14 -0
  156. package/dist/commands/history-clear.d.ts.map +1 -0
  157. package/dist/commands/history-clear.js +73 -0
  158. package/dist/commands/history-clear.js.map +1 -0
  159. package/dist/commands/history.d.ts +146 -4
  160. package/dist/commands/history.d.ts.map +1 -1
  161. package/dist/commands/history.js +443 -19
  162. package/dist/commands/history.js.map +1 -1
  163. package/dist/commands/join.d.ts.map +1 -1
  164. package/dist/commands/join.js +7 -3
  165. package/dist/commands/join.js.map +1 -1
  166. package/dist/commands/meshes-add.d.ts +3 -0
  167. package/dist/commands/meshes-add.d.ts.map +1 -1
  168. package/dist/commands/meshes-add.js +41 -34
  169. package/dist/commands/meshes-add.js.map +1 -1
  170. package/dist/commands/meshes-wizard.js +3 -3
  171. package/dist/commands/meshes-wizard.js.map +1 -1
  172. package/dist/commands/mint-endpoint-caller.d.ts +5 -0
  173. package/dist/commands/mint-endpoint-caller.d.ts.map +1 -0
  174. package/dist/commands/mint-endpoint-caller.js +130 -0
  175. package/dist/commands/mint-endpoint-caller.js.map +1 -0
  176. package/dist/commands/mint.d.ts +2 -37
  177. package/dist/commands/mint.d.ts.map +1 -1
  178. package/dist/commands/mint.js +142 -325
  179. package/dist/commands/mint.js.map +1 -1
  180. package/dist/commands/models.d.ts +30 -8
  181. package/dist/commands/models.d.ts.map +1 -1
  182. package/dist/commands/models.js +72 -41
  183. package/dist/commands/models.js.map +1 -1
  184. package/dist/commands/persona-remote.d.ts +5 -0
  185. package/dist/commands/persona-remote.d.ts.map +1 -0
  186. package/dist/commands/persona-remote.js +237 -0
  187. package/dist/commands/persona-remote.js.map +1 -0
  188. package/dist/commands/persona.d.ts +91 -0
  189. package/dist/commands/persona.d.ts.map +1 -0
  190. package/dist/commands/persona.js +200 -0
  191. package/dist/commands/persona.js.map +1 -0
  192. package/dist/commands/personas.d.ts.map +1 -1
  193. package/dist/commands/personas.js +16 -59
  194. package/dist/commands/personas.js.map +1 -1
  195. package/dist/commands/reset-space-apply.d.ts +5 -0
  196. package/dist/commands/reset-space-apply.d.ts.map +1 -0
  197. package/dist/commands/reset-space-apply.js +140 -0
  198. package/dist/commands/reset-space-apply.js.map +1 -0
  199. package/dist/commands/reset-store-apply.d.ts +11 -0
  200. package/dist/commands/reset-store-apply.d.ts.map +1 -0
  201. package/dist/commands/reset-store-apply.js +154 -0
  202. package/dist/commands/reset-store-apply.js.map +1 -0
  203. package/dist/commands/reset.d.ts +26 -0
  204. package/dist/commands/reset.d.ts.map +1 -0
  205. package/dist/commands/reset.js +143 -0
  206. package/dist/commands/reset.js.map +1 -0
  207. package/dist/commands/runtimes.d.ts +26 -1
  208. package/dist/commands/runtimes.d.ts.map +1 -1
  209. package/dist/commands/runtimes.js +68 -32
  210. package/dist/commands/runtimes.js.map +1 -1
  211. package/dist/commands/send.d.ts +91 -6
  212. package/dist/commands/send.d.ts.map +1 -1
  213. package/dist/commands/send.js +180 -106
  214. package/dist/commands/send.js.map +1 -1
  215. package/dist/commands/service-actions.d.ts +6 -0
  216. package/dist/commands/service-actions.d.ts.map +1 -0
  217. package/dist/commands/service-actions.js +405 -0
  218. package/dist/commands/service-actions.js.map +1 -0
  219. package/dist/commands/service-log-follow.d.ts +5 -0
  220. package/dist/commands/service-log-follow.d.ts.map +1 -0
  221. package/dist/commands/service-log-follow.js +106 -0
  222. package/dist/commands/service-log-follow.js.map +1 -0
  223. package/dist/commands/service-registry.d.ts +67 -0
  224. package/dist/commands/service-registry.d.ts.map +1 -0
  225. package/dist/commands/service-registry.js +275 -0
  226. package/dist/commands/service-registry.js.map +1 -0
  227. package/dist/commands/service-set-stop.d.ts +6 -0
  228. package/dist/commands/service-set-stop.d.ts.map +1 -0
  229. package/dist/commands/service-set-stop.js +161 -0
  230. package/dist/commands/service-set-stop.js.map +1 -0
  231. package/dist/commands/service-unit-entry.d.ts +5 -0
  232. package/dist/commands/service-unit-entry.d.ts.map +1 -0
  233. package/dist/commands/service-unit-entry.js +113 -0
  234. package/dist/commands/service-unit-entry.js.map +1 -0
  235. package/dist/commands/setup-start.d.ts +21 -0
  236. package/dist/commands/setup-start.d.ts.map +1 -0
  237. package/dist/commands/setup-start.js +95 -0
  238. package/dist/commands/setup-start.js.map +1 -0
  239. package/dist/commands/setup.d.ts +86 -100
  240. package/dist/commands/setup.d.ts.map +1 -1
  241. package/dist/commands/setup.js +766 -487
  242. package/dist/commands/setup.js.map +1 -1
  243. package/dist/commands/space-delete.d.ts +3 -0
  244. package/dist/commands/space-delete.d.ts.map +1 -0
  245. package/dist/commands/space-delete.js +341 -0
  246. package/dist/commands/space-delete.js.map +1 -0
  247. package/dist/commands/space-registration.d.ts +92 -0
  248. package/dist/commands/space-registration.d.ts.map +1 -0
  249. package/dist/commands/space-registration.js +388 -0
  250. package/dist/commands/space-registration.js.map +1 -0
  251. package/dist/commands/space.d.ts +128 -0
  252. package/dist/commands/space.d.ts.map +1 -0
  253. package/dist/commands/space.js +230 -0
  254. package/dist/commands/space.js.map +1 -0
  255. package/dist/commands/spawn-manifest.d.ts.map +1 -1
  256. package/dist/commands/spawn-manifest.js +2 -2
  257. package/dist/commands/spawn-manifest.js.map +1 -1
  258. package/dist/commands/spawn-preview.d.ts +9 -0
  259. package/dist/commands/spawn-preview.d.ts.map +1 -0
  260. package/dist/commands/spawn-preview.js +68 -0
  261. package/dist/commands/spawn-preview.js.map +1 -0
  262. package/dist/commands/spawn.d.ts +78 -18
  263. package/dist/commands/spawn.d.ts.map +1 -1
  264. package/dist/commands/spawn.js +236 -96
  265. package/dist/commands/spawn.js.map +1 -1
  266. package/dist/commands/stack-down.d.ts +6 -0
  267. package/dist/commands/stack-down.d.ts.map +1 -0
  268. package/dist/commands/stack-down.js +206 -0
  269. package/dist/commands/stack-down.js.map +1 -0
  270. package/dist/commands/stack-up.d.ts +149 -0
  271. package/dist/commands/stack-up.d.ts.map +1 -0
  272. package/dist/commands/stack-up.js +459 -0
  273. package/dist/commands/stack-up.js.map +1 -0
  274. package/dist/commands/stack-user-auth.d.ts +52 -0
  275. package/dist/commands/stack-user-auth.d.ts.map +1 -0
  276. package/dist/commands/stack-user-auth.js +128 -0
  277. package/dist/commands/stack-user-auth.js.map +1 -0
  278. package/dist/commands/status.d.ts +232 -5
  279. package/dist/commands/status.d.ts.map +1 -1
  280. package/dist/commands/status.js +989 -406
  281. package/dist/commands/status.js.map +1 -1
  282. package/dist/commands/sync.d.ts +23 -0
  283. package/dist/commands/sync.d.ts.map +1 -1
  284. package/dist/commands/sync.js +69 -17
  285. package/dist/commands/sync.js.map +1 -1
  286. package/dist/commands/team-agent-apply.d.ts +5 -0
  287. package/dist/commands/team-agent-apply.d.ts.map +1 -0
  288. package/dist/commands/team-agent-apply.js +204 -0
  289. package/dist/commands/team-agent-apply.js.map +1 -0
  290. package/dist/commands/team-agent-remove.d.ts +87 -0
  291. package/dist/commands/team-agent-remove.d.ts.map +1 -0
  292. package/dist/commands/team-agent-remove.js +348 -0
  293. package/dist/commands/team-agent-remove.js.map +1 -0
  294. package/dist/commands/team-boot-controller.d.ts +11 -0
  295. package/dist/commands/team-boot-controller.d.ts.map +1 -0
  296. package/dist/commands/team-boot-controller.js +176 -0
  297. package/dist/commands/team-boot-controller.js.map +1 -0
  298. package/dist/commands/team-channel-remove.d.ts +167 -0
  299. package/dist/commands/team-channel-remove.d.ts.map +1 -0
  300. package/dist/commands/team-channel-remove.js +486 -0
  301. package/dist/commands/team-channel-remove.js.map +1 -0
  302. package/dist/commands/team-deploy-apply.d.ts +11 -0
  303. package/dist/commands/team-deploy-apply.d.ts.map +1 -0
  304. package/dist/commands/team-deploy-apply.js +320 -0
  305. package/dist/commands/team-deploy-apply.js.map +1 -0
  306. package/dist/commands/team-mixed-remove.d.ts +8 -0
  307. package/dist/commands/team-mixed-remove.d.ts.map +1 -0
  308. package/dist/commands/team-mixed-remove.js +207 -0
  309. package/dist/commands/team-mixed-remove.js.map +1 -0
  310. package/dist/commands/team.d.ts +51 -0
  311. package/dist/commands/team.d.ts.map +1 -0
  312. package/dist/commands/team.js +727 -0
  313. package/dist/commands/team.js.map +1 -0
  314. package/dist/commands/topology.d.ts +4 -0
  315. package/dist/commands/topology.d.ts.map +1 -1
  316. package/dist/commands/topology.js +8 -0
  317. package/dist/commands/topology.js.map +1 -1
  318. package/dist/commands/up.d.ts +144 -5
  319. package/dist/commands/up.d.ts.map +1 -1
  320. package/dist/commands/up.js +1015 -124
  321. package/dist/commands/up.js.map +1 -1
  322. package/dist/commands/update.d.ts +11 -0
  323. package/dist/commands/update.d.ts.map +1 -1
  324. package/dist/commands/update.js +72 -15
  325. package/dist/commands/update.js.map +1 -1
  326. package/dist/commands/use.d.ts +16 -3
  327. package/dist/commands/use.d.ts.map +1 -1
  328. package/dist/commands/use.js +45 -19
  329. package/dist/commands/use.js.map +1 -1
  330. package/dist/commands/watch.d.ts +37 -0
  331. package/dist/commands/watch.d.ts.map +1 -0
  332. package/dist/commands/watch.js +106 -0
  333. package/dist/commands/watch.js.map +1 -0
  334. package/dist/commands/who.d.ts +79 -0
  335. package/dist/commands/who.d.ts.map +1 -0
  336. package/dist/commands/who.js +193 -0
  337. package/dist/commands/who.js.map +1 -0
  338. package/dist/commands/whoami.d.ts +56 -0
  339. package/dist/commands/whoami.d.ts.map +1 -0
  340. package/dist/commands/whoami.js +106 -0
  341. package/dist/commands/whoami.js.map +1 -0
  342. package/dist/console/app.d.ts.map +1 -1
  343. package/dist/console/app.js +8 -4
  344. package/dist/console/app.js.map +1 -1
  345. package/dist/console/commands.d.ts.map +1 -1
  346. package/dist/console/commands.js +12 -6
  347. package/dist/console/commands.js.map +1 -1
  348. package/dist/exec-endpoint/definition.d.ts +15 -0
  349. package/dist/exec-endpoint/definition.d.ts.map +1 -0
  350. package/dist/exec-endpoint/definition.js +56 -0
  351. package/dist/exec-endpoint/definition.js.map +1 -0
  352. package/dist/exec-endpoint/handler.d.ts +13 -0
  353. package/dist/exec-endpoint/handler.d.ts.map +1 -0
  354. package/dist/exec-endpoint/handler.js +155 -0
  355. package/dist/exec-endpoint/handler.js.map +1 -0
  356. package/dist/exec-endpoint/registration.d.ts +34 -0
  357. package/dist/exec-endpoint/registration.d.ts.map +1 -0
  358. package/dist/exec-endpoint/registration.js +148 -0
  359. package/dist/exec-endpoint/registration.js.map +1 -0
  360. package/dist/exec-endpoint/serve.d.ts +8 -0
  361. package/dist/exec-endpoint/serve.d.ts.map +1 -0
  362. package/dist/exec-endpoint/serve.js +159 -0
  363. package/dist/exec-endpoint/serve.js.map +1 -0
  364. package/dist/exec-endpoint/service-adapter.d.ts +6 -0
  365. package/dist/exec-endpoint/service-adapter.d.ts.map +1 -0
  366. package/dist/exec-endpoint/service-adapter.js +110 -0
  367. package/dist/exec-endpoint/service-adapter.js.map +1 -0
  368. package/dist/ext-loader.d.ts +10 -0
  369. package/dist/ext-loader.d.ts.map +1 -1
  370. package/dist/ext-loader.js +61 -13
  371. package/dist/ext-loader.js.map +1 -1
  372. package/dist/help.d.ts +18 -0
  373. package/dist/help.d.ts.map +1 -0
  374. package/dist/help.js +256 -0
  375. package/dist/help.js.map +1 -0
  376. package/dist/index.d.ts +2 -0
  377. package/dist/index.d.ts.map +1 -1
  378. package/dist/index.js +444 -118
  379. package/dist/index.js.map +1 -1
  380. package/dist/lib/assist.d.ts.map +1 -1
  381. package/dist/lib/assist.js +3 -2
  382. package/dist/lib/assist.js.map +1 -1
  383. package/dist/lib/attach-client.d.ts +7 -6
  384. package/dist/lib/attach-client.d.ts.map +1 -1
  385. package/dist/lib/attach-client.js +14 -15
  386. package/dist/lib/attach-client.js.map +1 -1
  387. package/dist/lib/auth-proc.d.ts +3 -3
  388. package/dist/lib/auth-proc.d.ts.map +1 -1
  389. package/dist/lib/auth-proc.js +8 -8
  390. package/dist/lib/auth-proc.js.map +1 -1
  391. package/dist/lib/backup-artifact.d.ts +34 -1
  392. package/dist/lib/backup-artifact.d.ts.map +1 -1
  393. package/dist/lib/backup-artifact.js +67 -17
  394. package/dist/lib/backup-artifact.js.map +1 -1
  395. package/dist/lib/broker-service.d.ts +10 -0
  396. package/dist/lib/broker-service.d.ts.map +1 -0
  397. package/dist/lib/broker-service.js +329 -0
  398. package/dist/lib/broker-service.js.map +1 -0
  399. package/dist/lib/cancel.js +1 -1
  400. package/dist/lib/cancel.js.map +1 -1
  401. package/dist/lib/choose-target.d.ts +10 -0
  402. package/dist/lib/choose-target.d.ts.map +1 -0
  403. package/dist/lib/choose-target.js +42 -0
  404. package/dist/lib/choose-target.js.map +1 -0
  405. package/dist/lib/command-path.d.ts +13 -0
  406. package/dist/lib/command-path.d.ts.map +1 -0
  407. package/dist/lib/command-path.js +40 -0
  408. package/dist/lib/command-path.js.map +1 -0
  409. package/dist/lib/completion-install.d.ts +29 -0
  410. package/dist/lib/completion-install.d.ts.map +1 -0
  411. package/dist/lib/completion-install.js +369 -0
  412. package/dist/lib/completion-install.js.map +1 -0
  413. package/dist/lib/completion-scripts.d.ts +4 -0
  414. package/dist/lib/completion-scripts.d.ts.map +1 -0
  415. package/dist/lib/completion-scripts.js +15 -0
  416. package/dist/lib/completion-scripts.js.map +1 -0
  417. package/dist/lib/completion.d.ts.map +1 -1
  418. package/dist/lib/completion.js +4 -1
  419. package/dist/lib/completion.js.map +1 -1
  420. package/dist/lib/control.d.ts +65 -6
  421. package/dist/lib/control.d.ts.map +1 -1
  422. package/dist/lib/control.js +121 -27
  423. package/dist/lib/control.js.map +1 -1
  424. package/dist/lib/controller-preserve.d.ts +12 -0
  425. package/dist/lib/controller-preserve.d.ts.map +1 -0
  426. package/dist/lib/controller-preserve.js +373 -0
  427. package/dist/lib/controller-preserve.js.map +1 -0
  428. package/dist/lib/controller-restore.d.ts +38 -0
  429. package/dist/lib/controller-restore.d.ts.map +1 -0
  430. package/dist/lib/controller-restore.js +205 -0
  431. package/dist/lib/controller-restore.js.map +1 -0
  432. package/dist/lib/controller-resume.d.ts +92 -0
  433. package/dist/lib/controller-resume.d.ts.map +1 -0
  434. package/dist/lib/controller-resume.js +300 -0
  435. package/dist/lib/controller-resume.js.map +1 -0
  436. package/dist/lib/credential-authority.d.ts +17 -0
  437. package/dist/lib/credential-authority.d.ts.map +1 -0
  438. package/dist/lib/credential-authority.js +28 -0
  439. package/dist/lib/credential-authority.js.map +1 -0
  440. package/dist/lib/default-persona.d.ts +38 -0
  441. package/dist/lib/default-persona.d.ts.map +1 -0
  442. package/dist/lib/default-persona.js +85 -0
  443. package/dist/lib/default-persona.js.map +1 -0
  444. package/dist/lib/delivery-proc.d.ts +9 -9
  445. package/dist/lib/delivery-proc.d.ts.map +1 -1
  446. package/dist/lib/delivery-proc.js +9 -19
  447. package/dist/lib/delivery-proc.js.map +1 -1
  448. package/dist/lib/endpoint-capability-gates.d.ts +10 -0
  449. package/dist/lib/endpoint-capability-gates.d.ts.map +1 -0
  450. package/dist/lib/endpoint-capability-gates.js +70 -0
  451. package/dist/lib/endpoint-capability-gates.js.map +1 -0
  452. package/dist/lib/endpoint-client.d.ts +20 -0
  453. package/dist/lib/endpoint-client.d.ts.map +1 -0
  454. package/dist/lib/endpoint-client.js +42 -0
  455. package/dist/lib/endpoint-client.js.map +1 -0
  456. package/dist/lib/endpoint-errors.d.ts +11 -0
  457. package/dist/lib/endpoint-errors.d.ts.map +1 -0
  458. package/dist/lib/endpoint-errors.js +30 -0
  459. package/dist/lib/endpoint-errors.js.map +1 -0
  460. package/dist/lib/endpoint-goal.d.ts +19 -0
  461. package/dist/lib/endpoint-goal.d.ts.map +1 -0
  462. package/dist/lib/endpoint-goal.js +31 -0
  463. package/dist/lib/endpoint-goal.js.map +1 -0
  464. package/dist/lib/endpoint-inventory.d.ts +30 -0
  465. package/dist/lib/endpoint-inventory.d.ts.map +1 -0
  466. package/dist/lib/endpoint-inventory.js +79 -0
  467. package/dist/lib/endpoint-inventory.js.map +1 -0
  468. package/dist/lib/endpoint-references.d.ts +22 -0
  469. package/dist/lib/endpoint-references.d.ts.map +1 -0
  470. package/dist/lib/endpoint-references.js +44 -0
  471. package/dist/lib/endpoint-references.js.map +1 -0
  472. package/dist/lib/endpoint-scatter.d.ts +57 -0
  473. package/dist/lib/endpoint-scatter.d.ts.map +1 -0
  474. package/dist/lib/endpoint-scatter.js +75 -0
  475. package/dist/lib/endpoint-scatter.js.map +1 -0
  476. package/dist/lib/endpoint-selection.d.ts +35 -0
  477. package/dist/lib/endpoint-selection.d.ts.map +1 -0
  478. package/dist/lib/endpoint-selection.js +80 -0
  479. package/dist/lib/endpoint-selection.js.map +1 -0
  480. package/dist/lib/install-umask.d.ts +6 -0
  481. package/dist/lib/install-umask.d.ts.map +1 -0
  482. package/dist/lib/install-umask.js +15 -0
  483. package/dist/lib/install-umask.js.map +1 -0
  484. package/dist/lib/isolated-broker.d.ts.map +1 -1
  485. package/dist/lib/isolated-broker.js +9 -5
  486. package/dist/lib/isolated-broker.js.map +1 -1
  487. package/dist/lib/local-process-stop.d.ts.map +1 -1
  488. package/dist/lib/local-process-stop.js +7 -1
  489. package/dist/lib/local-process-stop.js.map +1 -1
  490. package/dist/lib/manager-proc.d.ts +11 -5
  491. package/dist/lib/manager-proc.d.ts.map +1 -1
  492. package/dist/lib/manager-proc.js +12 -17
  493. package/dist/lib/manager-proc.js.map +1 -1
  494. package/dist/lib/manifest/apply.d.ts +4 -1
  495. package/dist/lib/manifest/apply.d.ts.map +1 -1
  496. package/dist/lib/manifest/apply.js +1 -1
  497. package/dist/lib/manifest/apply.js.map +1 -1
  498. package/dist/lib/manifest/ledger.d.ts +3 -1
  499. package/dist/lib/manifest/ledger.d.ts.map +1 -1
  500. package/dist/lib/manifest/ledger.js +16 -3
  501. package/dist/lib/manifest/ledger.js.map +1 -1
  502. package/dist/lib/manifest/schema.d.ts +1 -117
  503. package/dist/lib/manifest/schema.d.ts.map +1 -1
  504. package/dist/lib/manifest/schema.js +1 -95
  505. package/dist/lib/manifest/schema.js.map +1 -1
  506. package/dist/lib/offline-recipient.d.ts +5 -0
  507. package/dist/lib/offline-recipient.d.ts.map +1 -0
  508. package/dist/lib/offline-recipient.js +7 -0
  509. package/dist/lib/offline-recipient.js.map +1 -0
  510. package/dist/lib/onboard.js +3 -3
  511. package/dist/lib/onboard.js.map +1 -1
  512. package/dist/lib/persona-files.d.ts +29 -0
  513. package/dist/lib/persona-files.d.ts.map +1 -0
  514. package/dist/lib/persona-files.js +154 -0
  515. package/dist/lib/persona-files.js.map +1 -0
  516. package/dist/lib/personas.d.ts +3 -0
  517. package/dist/lib/personas.d.ts.map +1 -1
  518. package/dist/lib/personas.js +14 -2
  519. package/dist/lib/personas.js.map +1 -1
  520. package/dist/lib/prompts.d.ts +16 -0
  521. package/dist/lib/prompts.d.ts.map +1 -0
  522. package/dist/lib/prompts.js +35 -0
  523. package/dist/lib/prompts.js.map +1 -0
  524. package/dist/lib/protected-records.d.ts +2 -0
  525. package/dist/lib/protected-records.d.ts.map +1 -0
  526. package/dist/lib/protected-records.js +3 -0
  527. package/dist/lib/protected-records.js.map +1 -0
  528. package/dist/lib/registry-errors.d.ts +4 -0
  529. package/dist/lib/registry-errors.d.ts.map +1 -0
  530. package/dist/lib/registry-errors.js +6 -0
  531. package/dist/lib/registry-errors.js.map +1 -0
  532. package/dist/lib/reset-space-plan.d.ts +36 -0
  533. package/dist/lib/reset-space-plan.d.ts.map +1 -0
  534. package/dist/lib/reset-space-plan.js +181 -0
  535. package/dist/lib/reset-space-plan.js.map +1 -0
  536. package/dist/lib/restore.d.ts +3 -1
  537. package/dist/lib/restore.d.ts.map +1 -1
  538. package/dist/lib/restore.js +38 -10
  539. package/dist/lib/restore.js.map +1 -1
  540. package/dist/lib/seat-resume.d.ts +4 -1
  541. package/dist/lib/seat-resume.d.ts.map +1 -1
  542. package/dist/lib/seat-resume.js +7 -4
  543. package/dist/lib/seat-resume.js.map +1 -1
  544. package/dist/lib/service-adapters.d.ts +32 -0
  545. package/dist/lib/service-adapters.d.ts.map +1 -0
  546. package/dist/lib/service-adapters.js +55 -0
  547. package/dist/lib/service-adapters.js.map +1 -0
  548. package/dist/lib/service-census.d.ts +73 -0
  549. package/dist/lib/service-census.d.ts.map +1 -0
  550. package/dist/lib/service-census.js +42 -0
  551. package/dist/lib/service-census.js.map +1 -0
  552. package/dist/lib/service-definitions.d.ts +49 -0
  553. package/dist/lib/service-definitions.d.ts.map +1 -0
  554. package/dist/lib/service-definitions.js +61 -0
  555. package/dist/lib/service-definitions.js.map +1 -0
  556. package/dist/lib/service-install-intent.d.ts +48 -0
  557. package/dist/lib/service-install-intent.d.ts.map +1 -0
  558. package/dist/lib/service-install-intent.js +95 -0
  559. package/dist/lib/service-install-intent.js.map +1 -0
  560. package/dist/lib/service-instances.d.ts +143 -0
  561. package/dist/lib/service-instances.d.ts.map +1 -0
  562. package/dist/lib/service-instances.js +193 -0
  563. package/dist/lib/service-instances.js.map +1 -0
  564. package/dist/lib/service-journal.d.ts +38 -0
  565. package/dist/lib/service-journal.d.ts.map +1 -0
  566. package/dist/lib/service-journal.js +210 -0
  567. package/dist/lib/service-journal.js.map +1 -0
  568. package/dist/lib/service-launchd-plan.d.ts +21 -0
  569. package/dist/lib/service-launchd-plan.d.ts.map +1 -0
  570. package/dist/lib/service-launchd-plan.js +69 -0
  571. package/dist/lib/service-launchd-plan.js.map +1 -0
  572. package/dist/lib/service-launchd-unit.d.ts +20 -0
  573. package/dist/lib/service-launchd-unit.d.ts.map +1 -0
  574. package/dist/lib/service-launchd-unit.js +66 -0
  575. package/dist/lib/service-launchd-unit.js.map +1 -0
  576. package/dist/lib/service-presets.d.ts +17 -0
  577. package/dist/lib/service-presets.d.ts.map +1 -0
  578. package/dist/lib/service-presets.js +138 -0
  579. package/dist/lib/service-presets.js.map +1 -0
  580. package/dist/lib/service-private-seed.d.ts +7 -0
  581. package/dist/lib/service-private-seed.d.ts.map +1 -0
  582. package/dist/lib/service-private-seed.js +64 -0
  583. package/dist/lib/service-private-seed.js.map +1 -0
  584. package/dist/lib/service-private-tree.d.ts +6 -0
  585. package/dist/lib/service-private-tree.d.ts.map +1 -0
  586. package/dist/lib/service-private-tree.js +100 -0
  587. package/dist/lib/service-private-tree.js.map +1 -0
  588. package/dist/lib/service-process.d.ts +121 -0
  589. package/dist/lib/service-process.d.ts.map +1 -0
  590. package/dist/lib/service-process.js +742 -0
  591. package/dist/lib/service-process.js.map +1 -0
  592. package/dist/lib/service-stopped-allocation.d.ts +6 -0
  593. package/dist/lib/service-stopped-allocation.d.ts.map +1 -0
  594. package/dist/lib/service-stopped-allocation.js +42 -0
  595. package/dist/lib/service-stopped-allocation.js.map +1 -0
  596. package/dist/lib/service-supervision.d.ts +59 -0
  597. package/dist/lib/service-supervision.d.ts.map +1 -0
  598. package/dist/lib/service-supervision.js +71 -0
  599. package/dist/lib/service-supervision.js.map +1 -0
  600. package/dist/lib/service-systemd-attempt-read.d.ts +40 -0
  601. package/dist/lib/service-systemd-attempt-read.d.ts.map +1 -0
  602. package/dist/lib/service-systemd-attempt-read.js +80 -0
  603. package/dist/lib/service-systemd-attempt-read.js.map +1 -0
  604. package/dist/lib/service-systemd-control.d.ts +38 -0
  605. package/dist/lib/service-systemd-control.d.ts.map +1 -0
  606. package/dist/lib/service-systemd-control.js +141 -0
  607. package/dist/lib/service-systemd-control.js.map +1 -0
  608. package/dist/lib/service-systemd-files.d.ts +8 -0
  609. package/dist/lib/service-systemd-files.d.ts.map +1 -0
  610. package/dist/lib/service-systemd-files.js +63 -0
  611. package/dist/lib/service-systemd-files.js.map +1 -0
  612. package/dist/lib/service-systemd-install.d.ts +17 -0
  613. package/dist/lib/service-systemd-install.d.ts.map +1 -0
  614. package/dist/lib/service-systemd-install.js +146 -0
  615. package/dist/lib/service-systemd-install.js.map +1 -0
  616. package/dist/lib/service-systemd-plan.d.ts +28 -0
  617. package/dist/lib/service-systemd-plan.d.ts.map +1 -0
  618. package/dist/lib/service-systemd-plan.js +56 -0
  619. package/dist/lib/service-systemd-plan.js.map +1 -0
  620. package/dist/lib/service-systemd-reseed.d.ts +16 -0
  621. package/dist/lib/service-systemd-reseed.d.ts.map +1 -0
  622. package/dist/lib/service-systemd-reseed.js +106 -0
  623. package/dist/lib/service-systemd-reseed.js.map +1 -0
  624. package/dist/lib/service-systemd-uninstall-plan.d.ts +29 -0
  625. package/dist/lib/service-systemd-uninstall-plan.d.ts.map +1 -0
  626. package/dist/lib/service-systemd-uninstall-plan.js +56 -0
  627. package/dist/lib/service-systemd-uninstall-plan.js.map +1 -0
  628. package/dist/lib/service-systemd-uninstall.d.ts +17 -0
  629. package/dist/lib/service-systemd-uninstall.d.ts.map +1 -0
  630. package/dist/lib/service-systemd-uninstall.js +106 -0
  631. package/dist/lib/service-systemd-uninstall.js.map +1 -0
  632. package/dist/lib/service-systemd-unit.d.ts +28 -0
  633. package/dist/lib/service-systemd-unit.d.ts.map +1 -0
  634. package/dist/lib/service-systemd-unit.js +73 -0
  635. package/dist/lib/service-systemd-unit.js.map +1 -0
  636. package/dist/lib/service-systemd.d.ts +49 -0
  637. package/dist/lib/service-systemd.d.ts.map +1 -0
  638. package/dist/lib/service-systemd.js +134 -0
  639. package/dist/lib/service-systemd.js.map +1 -0
  640. package/dist/lib/service-uninstall-intent.d.ts +38 -0
  641. package/dist/lib/service-uninstall-intent.d.ts.map +1 -0
  642. package/dist/lib/service-uninstall-intent.js +74 -0
  643. package/dist/lib/service-uninstall-intent.js.map +1 -0
  644. package/dist/lib/service-unit-action.d.ts +24 -0
  645. package/dist/lib/service-unit-action.d.ts.map +1 -0
  646. package/dist/lib/service-unit-action.js +61 -0
  647. package/dist/lib/service-unit-action.js.map +1 -0
  648. package/dist/lib/setup-log.d.ts +5 -4
  649. package/dist/lib/setup-log.d.ts.map +1 -1
  650. package/dist/lib/setup-log.js +18 -9
  651. package/dist/lib/setup-log.js.map +1 -1
  652. package/dist/lib/space-schema-inspection.d.ts +73 -0
  653. package/dist/lib/space-schema-inspection.d.ts.map +1 -0
  654. package/dist/lib/space-schema-inspection.js +118 -0
  655. package/dist/lib/space-schema-inspection.js.map +1 -0
  656. package/dist/lib/space-schema-report.d.ts +82 -0
  657. package/dist/lib/space-schema-report.d.ts.map +1 -0
  658. package/dist/lib/space-schema-report.js +109 -0
  659. package/dist/lib/space-schema-report.js.map +1 -0
  660. package/dist/lib/spawn-defaults.d.ts +14 -0
  661. package/dist/lib/spawn-defaults.d.ts.map +1 -0
  662. package/dist/lib/spawn-defaults.js +20 -0
  663. package/dist/lib/spawn-defaults.js.map +1 -0
  664. package/dist/lib/stack-journal.d.ts +92 -0
  665. package/dist/lib/stack-journal.d.ts.map +1 -0
  666. package/dist/lib/stack-journal.js +199 -0
  667. package/dist/lib/stack-journal.js.map +1 -0
  668. package/dist/lib/stack-resume.d.ts +35 -0
  669. package/dist/lib/stack-resume.d.ts.map +1 -0
  670. package/dist/lib/stack-resume.js +123 -0
  671. package/dist/lib/stack-resume.js.map +1 -0
  672. package/dist/lib/status.d.ts +19 -20
  673. package/dist/lib/status.d.ts.map +1 -1
  674. package/dist/lib/status.js +41 -40
  675. package/dist/lib/status.js.map +1 -1
  676. package/dist/lib/steps.d.ts.map +1 -1
  677. package/dist/lib/steps.js +3 -2
  678. package/dist/lib/steps.js.map +1 -1
  679. package/dist/lib/systemd-supervision.d.ts +11 -4
  680. package/dist/lib/systemd-supervision.d.ts.map +1 -1
  681. package/dist/lib/systemd-supervision.js +19 -8
  682. package/dist/lib/systemd-supervision.js.map +1 -1
  683. package/dist/lib/team-additive-attempt.d.ts +286 -0
  684. package/dist/lib/team-additive-attempt.d.ts.map +1 -0
  685. package/dist/lib/team-additive-attempt.js +387 -0
  686. package/dist/lib/team-additive-attempt.js.map +1 -0
  687. package/dist/lib/team-additive-native.d.ts +17 -0
  688. package/dist/lib/team-additive-native.d.ts.map +1 -0
  689. package/dist/lib/team-additive-native.js +29 -0
  690. package/dist/lib/team-additive-native.js.map +1 -0
  691. package/dist/lib/team-agent-removal.d.ts +104 -0
  692. package/dist/lib/team-agent-removal.d.ts.map +1 -0
  693. package/dist/lib/team-agent-removal.js +121 -0
  694. package/dist/lib/team-agent-removal.js.map +1 -0
  695. package/dist/lib/team-channel-removal.d.ts +220 -0
  696. package/dist/lib/team-channel-removal.d.ts.map +1 -0
  697. package/dist/lib/team-channel-removal.js +258 -0
  698. package/dist/lib/team-channel-removal.js.map +1 -0
  699. package/dist/lib/team-deploy-inspection.d.ts +59 -0
  700. package/dist/lib/team-deploy-inspection.d.ts.map +1 -0
  701. package/dist/lib/team-deploy-inspection.js +177 -0
  702. package/dist/lib/team-deploy-inspection.js.map +1 -0
  703. package/dist/lib/team-fresh.d.ts +73 -0
  704. package/dist/lib/team-fresh.d.ts.map +1 -0
  705. package/dist/lib/team-fresh.js +207 -0
  706. package/dist/lib/team-fresh.js.map +1 -0
  707. package/dist/lib/team-removal-reconcile.d.ts +118 -0
  708. package/dist/lib/team-removal-reconcile.d.ts.map +1 -0
  709. package/dist/lib/team-removal-reconcile.js +90 -0
  710. package/dist/lib/team-removal-reconcile.js.map +1 -0
  711. package/dist/lib/team-removal-record.d.ts +7 -0
  712. package/dist/lib/team-removal-record.d.ts.map +1 -0
  713. package/dist/lib/team-removal-record.js +46 -0
  714. package/dist/lib/team-removal-record.js.map +1 -0
  715. package/dist/lib/team-retained.d.ts +33 -0
  716. package/dist/lib/team-retained.d.ts.map +1 -0
  717. package/dist/lib/team-retained.js +55 -0
  718. package/dist/lib/team-retained.js.map +1 -0
  719. package/dist/lib/theme.d.ts.map +1 -1
  720. package/dist/lib/theme.js +9 -8
  721. package/dist/lib/theme.js.map +1 -1
  722. package/dist/lib/transient.d.ts +14 -9
  723. package/dist/lib/transient.d.ts.map +1 -1
  724. package/dist/lib/transient.js +25 -18
  725. package/dist/lib/transient.js.map +1 -1
  726. package/dist/lib/up-report.d.ts +1 -0
  727. package/dist/lib/up-report.d.ts.map +1 -1
  728. package/dist/lib/up-report.js +2 -1
  729. package/dist/lib/up-report.js.map +1 -1
  730. package/dist/lib/version.d.ts +8 -2
  731. package/dist/lib/version.d.ts.map +1 -1
  732. package/dist/lib/version.js +16 -9
  733. package/dist/lib/version.js.map +1 -1
  734. package/dist/seed/paths.d.ts +1 -1
  735. package/dist/seed/paths.js +1 -1
  736. package/dist/seed/reconcile.d.ts.map +1 -1
  737. package/dist/seed/reconcile.js +19 -3
  738. package/dist/seed/reconcile.js.map +1 -1
  739. package/dist/ui.d.ts +6 -0
  740. package/dist/ui.d.ts.map +1 -1
  741. package/dist/ui.js +12 -1
  742. package/dist/ui.js.map +1 -1
  743. package/dist/watch-data.d.ts +15 -0
  744. package/dist/watch-data.d.ts.map +1 -0
  745. package/dist/watch-data.js +66 -0
  746. package/dist/watch-data.js.map +1 -0
  747. package/dist/watch-json.d.ts +5 -0
  748. package/dist/watch-json.d.ts.map +1 -0
  749. package/dist/watch-json.js +131 -0
  750. package/dist/watch-json.js.map +1 -0
  751. package/dist/watch-view.d.ts +8 -0
  752. package/dist/watch-view.d.ts.map +1 -0
  753. package/dist/watch-view.js +65 -0
  754. package/dist/watch-view.js.map +1 -0
  755. package/package.json +8 -5
  756. package/dist/commands/service.d.ts +0 -17
  757. package/dist/commands/service.d.ts.map +0 -1
  758. package/dist/commands/service.js +0 -589
  759. package/dist/commands/service.js.map +0 -1
@@ -1,8 +1,10 @@
1
- import { dialerFor, mintCreds, newIdentity, openSessionRail, peerLabel, standaloneConnectOpts } from "@cotal-ai/core";
2
- import { ConnectRefusal, divergentCwdAnchor, isWorkspaceTargetError, loadMeshes, renderWorkspaceError, targetFlags, userSessionAuth } from "@cotal-ai/workspace";
1
+ import { DEV_OWNER, assertLifecycleToken, dialerFor, mintCreds, newIdentity, openSessionRail, peerLabel, standaloneConnectOpts } from "@cotal-ai/core";
2
+ import { CommandFailure, ConnectRefusal, divergentCwdAnchor, isWorkspaceTargetError, jsonFlag, loadMeshes, oneLine, renderReport, terminalWidth, plainFlag, presentationOf, resolveSeatControlTarget, renderWorkspaceError, targetFlags, userSessionAuth, writeResult, recordOperationSpace, } from "@cotal-ai/workspace";
3
+ import * as prompts from "../lib/prompts.js";
4
+ import { canPrompt } from "./meshes-wizard.js";
3
5
  import {} from "@nats-io/transport-node";
4
- import { c, presenceDetail } from "../ui.js";
5
- import { askManager, scatterManager, failIfNotOk, resolveControlTarget, onInstanceOrExit, onFlag } from "../lib/control.js";
6
+ import { c, presenceFacts } from "../ui.js";
7
+ import { askManager, scatterManager, failIfNotOk, managerFailure, readFailure, resolveControlTarget, onInstance, onInstanceOrExit, onFlag } from "../lib/control.js";
6
8
  import { attachClient, detachKey, holdTerminal, isDetachPress, isTransportEnd, meshSessionTransport } from "../lib/attach-client.js";
7
9
  import { completingFlagValue } from "../lib/completion.js";
8
10
  /**
@@ -16,15 +18,17 @@ const nameFlag = (what) => ({ name: "name", type: "string", value: "<n>", descri
16
18
  // seat); `--json` is the machine form (one JSON object per line, exactly the row the manager
17
19
  // sent). Mutually exclusive because they are two answers to "how should I read this".
18
20
  const wideFlag = { name: "wide", type: "boolean", description: "also print the per-seat facts the manager already records: cwd, pid, spawner, lifecycle uid, host/instance" };
19
- const jsonFlag = { name: "json", type: "boolean", description: "machine-readable: one JSON object per seat per line (instance headers go to stderr)" };
20
- const slotsFlag = { name: "slots", type: "boolean", description: "list durable static slot rows instead of live seats (#1274); mutually exclusive with --wide" };
21
- export const stopFlags = [...targetFlags, nameFlag("managed agent to stop (required)"), onFlag];
22
- export const psFlags = [...targetFlags, onFlag, wideFlag, jsonFlag, slotsFlag];
21
+ const slotsFlag = { name: "slots", type: "boolean", description: "list the durable static slots instead of live seats; not with --wide" };
22
+ export const stopFlags = [...targetFlags, nameFlag("agent name; you can name it positionally"),
23
+ { name: "self", type: "boolean", description: "stop only the verified managed seat running this command" },
24
+ { name: "force", type: "boolean", description: "request native hard despawn (graceful:false); does not bypass authority" },
25
+ onFlag, jsonFlag, plainFlag];
26
+ export const psFlags = [...targetFlags, onFlag, wideFlag, jsonFlag, plainFlag, slotsFlag];
23
27
  /** `--no-reconnect`: one session, exit when it ends, whatever ended it. The default reconnects,
24
28
  * which is right for a person at a terminal and wrong for a script that wants a single run with a
25
29
  * single exit code. */
26
30
  const noReconnectFlag = { name: "no-reconnect", type: "boolean", description: "exit when the session ends instead of re-establishing it" };
27
- export const attachFlags = [...targetFlags, nameFlag("managed agent to attach to (required)"), onFlag, noReconnectFlag];
31
+ export const attachFlags = [...targetFlags, nameFlag("agent name; you can name it positionally"), onFlag, noReconnectFlag];
28
32
  /** `cotal input`: type into a seat without holding a terminal open. `--text` is a VALUE flag, so
29
33
  * its argument is taken verbatim and may begin with `/` or `-` (`--text "/compact"`) - which is
30
34
  * the point: a harness command is exactly the payload that would be eaten by a positional
@@ -36,7 +40,7 @@ export const inputFlags = [
36
40
  nameFlag("managed agent to type into (required)"),
37
41
  { name: "text", type: "string", value: "<text>", description: "the text to type, verbatim (required); quote it when it starts with / or -" },
38
42
  { name: "no-enter", type: "boolean", description: "type the text without pressing Enter after it" },
39
- onFlag,
43
+ onFlag, jsonFlag, plainFlag,
40
44
  ];
41
45
  export function managedAgentComplete(argv) {
42
46
  const flag = completingFlagValue(argv, attachFlags);
@@ -50,30 +54,114 @@ export function managedAgentComplete(argv) {
50
54
  return { items: attachFlags.map((f) => ({ value: `--${f.name}`, description: f.description })), directive: "nofiles" };
51
55
  return { items: [], directive: "nofiles" };
52
56
  }
57
+ /** The named target grammar, checked before any command preparation. */
58
+ export function managedTarget(args, operation, allowPicker = false) {
59
+ const named = typeof args.values.name === "string" ? args.values.name : undefined;
60
+ if (args.positionals.length > 1 || (args.positionals.length && named !== undefined))
61
+ throw new CommandFailure("refused", "USAGE_INVALID", `choose one agent: cotal ${operation} <name>`);
62
+ const name = args.positionals[0] ?? named;
63
+ if (typeof args.values.on === "string")
64
+ onInstance(args.values.on, `cotal ${operation}`);
65
+ if (name === undefined && operation === "attach" && allowPicker) {
66
+ if (!canPrompt())
67
+ throw new CommandFailure("refused", "USAGE_INVALID", "name the agent to attach without an interactive terminal", { remedy: "run cotal ps, then cotal attach <name>" });
68
+ return undefined;
69
+ }
70
+ if (name !== undefined && /[\u0000-\u001f\u007f]/u.test(name))
71
+ throw new CommandFailure("refused", "USAGE_INVALID", "the agent name contains terminal control characters");
72
+ if (!name?.trim())
73
+ throw new CommandFailure("refused", "USAGE_INVALID", `name the agent to ${operation}`, { remedy: "run cotal ps, then cotal " + operation + " <name>" });
74
+ return name;
75
+ }
76
+ export function validateStopArguments(args) {
77
+ presentationOf(args.values);
78
+ if (args.values.self) {
79
+ if (args.positionals.length || args.values.name !== undefined || args.values.creds !== undefined)
80
+ throw new CommandFailure("refused", "USAGE_INVALID", "stop --self takes no other agent or caller credential");
81
+ if (args.values.on !== undefined) {
82
+ const pin = onInstance(String(args.values.on), "cotal stop --self");
83
+ if (pin !== process.env.COTAL_MANAGER_INSTANCE)
84
+ throw new CommandFailure("refused", "CONFLICT", "stop --self cannot select a different manager than the seat's launcher");
85
+ }
86
+ return;
87
+ }
88
+ managedTarget(args, "stop");
89
+ }
53
90
  export async function stop(args) {
91
+ validateStopArguments(args);
54
92
  const v = args.values;
55
- if (!v.name) {
56
- console.error(c.red("--name is required"));
57
- process.exit(1);
93
+ let on;
94
+ let t;
95
+ let name;
96
+ if (v.self) {
97
+ const space = v.space ?? process.env.COTAL_SPACE;
98
+ const manager = process.env.COTAL_MANAGER_INSTANCE;
99
+ if (!space || !manager)
100
+ throw new CommandFailure("refused", "UNSUPPORTED", "stop --self requires a managed seat's own shell, space and launcher attribution");
101
+ on = onInstance(manager, "cotal stop --self");
102
+ let seat;
103
+ try {
104
+ seat = await resolveSeatControlTarget({ space, server: v.server }, on);
105
+ }
106
+ catch {
107
+ throw new CommandFailure("refused", "AUTH_REQUIRED", "the seat's own caller could not be verified; no operator identity was substituted");
108
+ }
109
+ if (!seat)
110
+ throw new CommandFailure("refused", "UNSUPPORTED", "this caller cannot stop itself through the CLI; missing or mismatched seat context and user-auth self impersonation never fall back to the operator");
111
+ t = seat;
58
112
  }
59
- // STATIC mesh: operator stop is a cross-agent op — the `control-caller-admin` instrument holds
60
- // the any-mode despawn row, so `reach: "any"` names any target (the broker grant IS the
61
- // authority).
62
- // USER mesh: ONE deterministic path — the op rides the operator's own bearer with `reach:
63
- // "owner"` (its own-domain despawn row), and the MANAGER authorizes: agents under your own
64
- // owner pass with scope "spawn", another owner's agent needs "admin" on your ledger row (the
65
- // handler's fresh any-mode authorization). No client-side try-admin-then-owner fallback.
66
- // Seat-locality: the manager that can stop a seat is the one HOSTING it, so resolve WHERE before
67
- // choosing WHO. Must precede the mint — a credential cannot gain an instance rail after issuance.
68
- const on = await pinForTarget(v, "cotal stop");
69
- const t = await resolveControlTarget(v, "control-caller-admin", on);
70
- const reach = t.auth.bearer ? "owner" : "any";
71
- const reply = await askManager(t.space, t.server, "stop", { name: v.name }, t.auth, reach, undefined, { instanceId: on });
72
- failIfNotOk(reply);
73
- // User mesh: a stop IS a grant revoke (rows are runtime grants — a non-running agent holds no
74
- // standing mint secret); a respawn re-grants automatically. Say so, so the operator's
75
- // restart-vs-revoke model is visible at the command, not inferred from docs.
76
- console.log(c.dim(`✓ stopped ${v.name}${t.auth.bearer ? " - its actor grant is revoked; a respawn re-grants automatically" : ""}`));
113
+ else {
114
+ name = managedTarget(args, "stop");
115
+ on = await pinForTarget({ ...v, name }, "cotal stop");
116
+ t = await resolveControlTarget(v, "control-caller-admin", on);
117
+ }
118
+ recordOperationSpace(t.space);
119
+ const reply = await askManager(t.space, t.server, v.self ? "stopSelf" : "stop", { ...(name ? { name } : {}), graceful: v.force !== true }, t.auth, t.auth.bearer ? "owner" : "any", undefined, { instanceId: on });
120
+ const target = { space: t.space, managerInstanceId: reply.managerInstanceId ?? on ?? null, selection: v.self ? "verified-self" : "named", ...(name ? { agent: name } : {}) };
121
+ if (!reply.ok)
122
+ throw managerFailure(reply, "agent stop", target);
123
+ const data = reply.data;
124
+ if (!data || typeof data.name !== "string" || typeof data.stopped !== "boolean" || typeof data.graceful !== "boolean")
125
+ throw new CommandFailure("unknown", "OPERATION_UNKNOWN", "the manager answered, but the stop receipt could not be read; the request was not repeated", { target, ...(reply.request ? { native: { detail: { request: reply.request } } } : {}) });
126
+ if (!data.stopped)
127
+ throw new CommandFailure("failed", "OPERATION_FAILED", "the manager reported that it did not stop the selected agent", { target });
128
+ const result = { kind: "agent-stop", name: data.name, stopped: data.stopped, graceful: data.graceful, request: reply.request ?? null, grantRevocation: t.auth.bearer ? "native user-mode stop policy" : "not asserted" };
129
+ writeResult(presentationOf(v), { command: "stop", target, result }, (row) => ({ sections: [
130
+ { title: "Agent stop acknowledged", blocks: [{ kind: "fields", rows: [["Agent", row.name], ["Space", t.space], ["Manager", reply.managerInstanceId ?? "not attributed"], ["Native mode", row.graceful ? "graceful" : "hard despawn"], ["Selection", v.self ? "this verified seat only" : "named agent's resolved incarnation"]] }, { kind: "lines", lines: [{ text: "This is the manager's stop result, not an independent process-exit measurement. No other agent was selected and no replacement was launched.", tone: "hint" }] }] },
131
+ ] }));
132
+ }
133
+ /** The named status contract separates process, presence and work observations. A missing
134
+ * manager field is null, never inferred from a process handle or an old heartbeat. */
135
+ function agentStatusProjection(row, managerInstanceId) {
136
+ const principal = row.id.split(".");
137
+ const owner = principal.length === 1 ? DEV_OWNER : principal.length === 2 && principal[0] ? principal[0] : null;
138
+ const actor = principal.length === 1 ? principal[0] || null : principal.length === 2 && principal[1] ? principal[1] : null;
139
+ const viewCurrent = row.meshView === undefined || row.meshView === "current";
140
+ const exactPresence = viewCurrent && row.presenceIdentityVerified === true;
141
+ const reportedAt = typeof row.activeAt === "number" && Number.isFinite(row.activeAt) && Math.abs(row.activeAt) <= 8.64e15
142
+ ? new Date(row.activeAt).toISOString() : null;
143
+ const observedAt = exactPresence && typeof row.presenceObservedAt === "number" && Number.isSafeInteger(row.presenceObservedAt) && row.presenceObservedAt >= 0 && row.presenceObservedAt <= 8.64e15
144
+ ? new Date(row.presenceObservedAt).toISOString() : null;
145
+ const since = row.condition?.since;
146
+ const conditionSince = typeof since === "number" && Number.isSafeInteger(since) && since >= 0 && since <= 8.64e15
147
+ ? new Date(since).toISOString() : null;
148
+ return {
149
+ identity: { name: row.name, owner, actor, lifecycleUid: row.lifecycleUid || null, source: "manager-ps" },
150
+ execution: { managerInstanceId, host: row.host ?? null, harness: row.agent, model: row.model ?? null,
151
+ runtime: row.mode, pid: typeof row.pid === "number" && Number.isSafeInteger(row.pid) && row.pid > 0 ? row.pid : null, processState: row.status, source: "manager-ps" },
152
+ mesh: { presenceState: exactPresence ? row.mesh : null, observedAt, nameMatchedState: !exactPresence && viewCurrent && row.mesh !== "absent" ? row.mesh : null,
153
+ source: exactPresence ? "manager-ps-exact-principal-lifecycle-current-view" : "manager-ps-name-match-not-incarnation-verified" },
154
+ activity: { state: exactPresence && ["idle", "working", "waiting"].includes(row.mesh) ? row.mesh : null,
155
+ text: null, reportedAt: exactPresence ? reportedAt : null, nameMatchedWorkEventAt: exactPresence ? null : reportedAt,
156
+ condition: exactPresence ? row.condition ?? null : null, conditionSince: exactPresence ? conditionSince : null,
157
+ nameMatchedCondition: exactPresence ? null : row.condition ?? null,
158
+ source: exactPresence ? "manager-ps-exact-principal-lifecycle-current-view" : "manager-ps-name-match-not-incarnation-verified" },
159
+ details: { role: row.role ?? null, variant: row.variant ?? null, provider: row.provider ?? null,
160
+ providerSource: row.provider ? exactPresence ? "exact-principal-lifecycle" : "name-match-unverified" : null, cwd: row.cwd ?? null,
161
+ uptimeMs: row.uptimeMs, spawner: row.spawner ?? null, presenceView: row.meshView ?? null, presenceIdentityVerified: row.presenceIdentityVerified ?? null,
162
+ presenceObservedAt: row.presenceObservedAt ?? null, offlineSince: row.offlineSince ?? null,
163
+ authHealth: row.authHealth ?? null, authReason: row.authReason ?? null, resume: row.resume ?? null },
164
+ };
77
165
  }
78
166
  /** A seat's compact runtime identity. Model is provenance, not a debugging detail, so it belongs
79
167
  * beside the connector in the default row. `variant` is the requested override the manager
@@ -211,17 +299,18 @@ export function seatMissRefusal(name, verb, loc) {
211
299
  * - `not-probed` / `probe-refused`: this command could not ask. That is a fact about the command,
212
300
  * not the instance, and saying so is what keeps a local gap from reading as a remote fault.
213
301
  */
214
- function silentManagerRow(liveness, instanceId) {
302
+ function silentManager(liveness, instanceId) {
215
303
  if (liveness === "gone")
216
- return (c.red("registration is stale") +
217
- c.dim(` (the broker reports nothing subscribed on its rail; its host is gone and never deregistered)`) +
218
- c.dim(`\n ↳ remove the record: cotal deregister-instance --instance ${instanceId}`));
304
+ return {
305
+ state: { text: "registration is stale (the broker reports nothing subscribed on its rail; its host is gone and never deregistered)", tone: "failed" },
306
+ remedy: `remove the record: cotal deregister-instance --instance ${instanceId}`,
307
+ };
219
308
  const why = liveness === "probe-refused"
220
309
  ? " (its liveness could not be probed: the broker refused this command's probe, named above)"
221
310
  : liveness === "not-probed"
222
311
  ? " (its liveness was not probed: this command holds no probe grant for it)"
223
312
  : " (either the host is alive and slow, or it died and its registration was never removed)";
224
- return c.red("registered, no answer within the deadline") + c.dim(why);
313
+ return { state: { text: `registered, no answer within the deadline${why}`, tone: "failed" } };
225
314
  }
226
315
  /** The mesh column of one `ps` row. A verdict needs a fresh observer: when the manager reports its
227
316
  * own presence view as `stale` (its watch went silent past TTL) or `unpopulated` (its watch has not
@@ -230,233 +319,346 @@ function silentManagerRow(liveness, instanceId) {
230
319
  * on. A row from a manager that predates `meshView` carries no field and renders as before.
231
320
  * An offline verdict says how long it has stood when the row carries `offlineSince` (#1208), so a
232
321
  * seat that dropped a minute ago reads differently from one that dropped two days ago. */
233
- export function meshColumn(r, now = Date.now()) {
322
+ export function meshCell(r, now = Date.now()) {
234
323
  if (r.meshView === "stale")
235
- return c.yellow("mesh unknown") + c.dim(" (manager's presence view is stale)");
324
+ return { text: "mesh unknown (manager's presence view is stale)", tone: "waiting" };
236
325
  if (r.meshView === "unpopulated")
237
- return c.yellow("mesh unknown") + c.dim(" (manager's presence view not yet populated)");
326
+ return { text: "mesh unknown (manager's presence view not yet populated)", tone: "waiting" };
238
327
  // The harness-reported condition and the last work progress ride beside the status, as the roster
239
328
  // renders them (#618): a turn that died upstream 40m ago reads `waiting (rate_limit for 40m) ·
240
329
  // active 40m ago`, not a bare `waiting`, and a turn that stopped advancing shows the age of its
241
330
  // last event.
242
- const condition = presenceDetail(r, now);
243
- const mesh = r.mesh === "absent"
244
- ? c.yellow("not in roster")
245
- : r.mesh === "offline"
246
- ? c.dim(r.offlineSince === undefined ? "mesh offline" : `mesh offline for ${fmtUptime(now - r.offlineSince)}`)
247
- : r.mesh === "working"
248
- ? c.green("working · progress unknown")
249
- : r.mesh === "waiting"
250
- ? c.yellow("waiting")
251
- : c.cyan(r.mesh);
252
- return mesh + condition;
331
+ const { condition, ages } = presenceFacts(r, now);
332
+ const detail = condition + ages;
333
+ if (r.mesh === "absent")
334
+ return { text: `not in roster${detail}`, tone: "waiting" };
335
+ if (r.mesh === "offline")
336
+ return { text: `${r.offlineSince === undefined ? "mesh offline" : `mesh offline for ${fmtUptime(now - r.offlineSince)}`}${detail}`, tone: "hint" };
337
+ if (r.mesh === "working")
338
+ return { text: `working · progress unknown${detail}`, tone: "ok" };
339
+ if (r.mesh === "waiting")
340
+ return { text: `waiting${detail}`, tone: "waiting" };
341
+ return { text: `${r.mesh}${detail}` };
253
342
  }
254
- /** Render one managed-agent row (process fact, mesh fact, optional auth-health line), indented for
255
- * the per-manager grouping a class scatter prints.
343
+ /** The process column of one `ps` row, beside the mesh column and never folded into it.
256
344
  *
257
- * Two facts, printed as two facts. The manager reports the PROCESS (`status` from the runtime
258
- * handle, `uptimeMs` from its start) and the MESH presence separately, and they disagree in the
259
- * common failure: a seat that is `running` for two days but `offline` on the mesh. Folding them
260
- * into one word rendered ten live processes as "offline" and a 57h-old process with no roster
261
- * entry as "starting…", both false. `mesh: absent` means exactly "not in the presence roster",
262
- * so it prints as that; the process age next to it tells the reader whether it is a fresh start
263
- * or a seat that never joined. */
264
- function printAgentRow(r, indent = "") {
265
- const proc = r.status === "running"
266
- ? c.green("running") + c.dim(" " + fmtUptime(r.uptimeMs))
267
- : r.status === "exited"
268
- ? c.red("exited") + c.dim(" after " + fmtUptime(r.uptimeMs))
269
- : c.yellow(r.status) + c.dim(" " + fmtUptime(r.uptimeMs));
270
- const mesh = meshColumn(r);
271
- // Confirmed failure is red; ambiguity/warning states (unknown/stale) are yellow — the operator
272
- // triages "definitely broken" before "might be".
273
- const authColor = r.authHealth === "auth-renewal-failed" ? c.red : c.yellow;
274
- console.log(`${indent}${c.bold(peerLabel(r))} ${c.dim(agentIdentity(r))} ${proc} ${mesh}${r.authHealth ? " " + authColor(r.authHealth) : ""}`);
275
- // The detached agent's ONLY operator window into a failing bearer refresh: the provider command's
276
- // operator-exact sentence, verbatim (it already names the repair).
277
- if (r.authHealth && r.authReason)
278
- console.log(authColor(`${indent} ${r.authReason}`));
345
+ * Two facts, shown as two facts. The manager reports the PROCESS (`status` from the runtime handle,
346
+ * `uptimeMs` from its start) and the MESH presence separately, and they disagree in the common
347
+ * failure: a seat that is `running` for two days but `offline` on the mesh. Folding them into one
348
+ * word rendered ten live processes as "offline" and a 57h-old process with no roster entry as
349
+ * "starting…", both false. `mesh: absent` means exactly "not in the presence roster", so it prints
350
+ * as that; the process age next to it tells the reader whether it is a fresh start or a seat that
351
+ * never joined. */
352
+ function processCell(r) {
353
+ if (r.status === "running")
354
+ return { text: `running ${fmtUptime(r.uptimeMs)}`, tone: "ok" };
355
+ if (r.status === "exited")
356
+ return { text: `exited after ${fmtUptime(r.uptimeMs)}`, tone: "failed" };
357
+ return { text: `${r.status} ${fmtUptime(r.uptimeMs)}`, tone: "waiting" };
279
358
  }
280
- /** Extra operational facts for `--wide`. Model and requested variant are already in the compact
281
- * identity row, so repeating them here would make wide output noisier without adding provenance.
282
- * Only fields the manager actually recorded print; lifecycle uid is required on every row. */
283
- export function agentWideFacts(r) {
284
- const facts = [];
359
+ /** Confirmed failure is red; ambiguity/warning states (unknown/stale) are amber, so the operator
360
+ * triages "definitely broken" before "might be". */
361
+ const authTone = (r) => (r.authHealth === "auth-renewal-failed" ? "failed" : "waiting");
362
+ /** Extra operational facts for `--wide`, as label and value. Model and requested variant are already
363
+ * in the compact identity, so repeating them here would make wide output noisier without adding
364
+ * provenance. Only fields the manager actually recorded appear; lifecycle uid is required on every
365
+ * row. */
366
+ function wideFields(r) {
367
+ const fields = [];
285
368
  if (r.provider)
286
- facts.push(`provider ${r.provider}`);
369
+ fields.push(["provider", r.provider]);
287
370
  if (r.cwd)
288
- facts.push(`cwd ${r.cwd}`);
371
+ fields.push(["cwd", r.cwd]);
289
372
  if (r.pid !== undefined)
290
- facts.push(`pid ${r.pid}`);
373
+ fields.push(["pid", String(r.pid)]);
291
374
  if (r.spawner)
292
- facts.push(`spawner ${r.spawner}`);
293
- facts.push(`uid ${r.lifecycleUid}`);
375
+ fields.push(["spawner", r.spawner]);
376
+ fields.push(["uid", r.lifecycleUid]);
294
377
  if (r.instanceId)
295
- facts.push(`instance ${r.instanceId}`);
378
+ fields.push(["instance", r.instanceId]);
296
379
  if (r.host)
297
- facts.push(`host ${r.host}`);
380
+ fields.push(["host", r.host]);
298
381
  if (r.resume) {
299
382
  const { source, title, transcriptSha256, host, transferredAt } = r.resume;
300
- facts.push(`forked from ${host ? `${host}:` : ""}${source}${title ? ` ${JSON.stringify(title)}` : ""}${transcriptSha256 ? ` sha256:${transcriptSha256}` : ""}${transferredAt ? ` carried ${transferredAt}` : ""}`);
383
+ fields.push(["forked from", `${host ? `${host}:` : ""}${source}${title ? ` ${JSON.stringify(title)}` : ""}${transcriptSha256 ? ` sha256:${transcriptSha256}` : ""}${transferredAt ? ` carried ${transferredAt}` : ""}`]);
301
384
  }
302
- return facts;
385
+ return fields;
303
386
  }
304
- function printWideFacts(r, indent = "") {
305
- console.log(c.dim(`${indent} ${agentWideFacts(r).join(" · ")}`));
387
+ /** {@link wideFields} as one line of facts. */
388
+ export function agentWideFacts(r) {
389
+ return wideFields(r).map(([label, value]) => `${label} ${value}`);
306
390
  }
307
- /** How one seat renders in the chosen presentation. `--json` prints the manager's row EXACTLY as
308
- * received; `--wide` adds the facts line under the compact row. */
309
- function printSeat(r, opts, indent = "") {
310
- if (opts.json) {
311
- console.log(JSON.stringify(r));
312
- return;
313
- }
314
- printAgentRow(r, indent);
315
- if (opts.wide)
316
- printWideFacts(r, indent);
391
+ /** The seats one manager answered with: a table, or with `--wide` one labeled record per seat. A
392
+ * failing bearer refresh is a detached seat's only window to the operator, so the provider's own
393
+ * sentence follows, verbatim (it already names the repair). A record's labels read as its facts'
394
+ * do, and a field the seat leaves empty is left out. */
395
+ function seatBlocks(rows, wide) {
396
+ const auth = rows.some((r) => r.authHealth);
397
+ const cells = (r) => [
398
+ ["NAME", peerLabel(r)],
399
+ ["AGENT", { text: agentIdentity(r), tone: "hint" }],
400
+ ["PROCESS", processCell(r)],
401
+ ["MESH", meshCell(r)],
402
+ ...(auth ? [["AUTH", r.authHealth ? { text: r.authHealth, tone: authTone(r) } : ""]] : []),
403
+ ];
404
+ const blocks = wide
405
+ ? rows.flatMap((r, i) => [...(i ? [{ kind: "lines", lines: [""] }] : []), { kind: "fields", rows: [...cells(r).filter(([, value]) => value !== "").map(([label, value]) => [label.toLowerCase(), value]), ...wideFields(r)] }])
406
+ : [{
407
+ kind: "table",
408
+ columns: cells(rows[0]).map(([label]) => ({ key: label, label })),
409
+ rows: rows.map((r) => Object.fromEntries(cells(r))),
410
+ }];
411
+ const reasons = rows.filter((r) => r.authHealth && r.authReason).map((r) => ({ text: `${peerLabel(r)}: ${r.authReason}`, tone: authTone(r) }));
412
+ if (reasons.length)
413
+ blocks.push({ kind: "lines", lines: reasons });
414
+ return blocks;
317
415
  }
318
- /** `--slots` rendering, beside `printSeat`. `--json` prints the row unchanged; the human form is
319
- * one compact line naming phase, slot uid, cleanup, head and liveness. */
320
- function printSlot(r, opts, indent = "") {
321
- if (opts.json) {
322
- console.log(JSON.stringify(r));
323
- return;
324
- }
325
- const cleanup = r.cleanupComplete === undefined ? "unknown" : String(r.cleanupComplete);
326
- const head = r.headState === undefined ? "absent" : `${r.headState}${r.headOp ? ` op ${r.headOp.kind}:${r.headOp.opId}` : ""}`;
327
- console.log(`${indent}${r.name} ${r.slotPhase} slot ${r.slotLifecycleUid} cleanupComplete=${cleanup} head=${head} live=${r.live} readOrder=slot,head consistency=${r.consistency}`);
416
+ /** `--slots`: one row per slot naming phase, slot uid, cleanup, head and liveness. The read order
417
+ * and its consistency are the same on every row, so they are stated once. */
418
+ function slotBlocks(rows) {
419
+ return [
420
+ {
421
+ kind: "table",
422
+ columns: [
423
+ { key: "name", label: "NAME" },
424
+ { key: "phase", label: "PHASE" },
425
+ { key: "slot", label: "SLOT" },
426
+ { key: "cleanup", label: "CLEANUP COMPLETE" },
427
+ { key: "head", label: "HEAD" },
428
+ { key: "live", label: "LIVE" },
429
+ ],
430
+ rows: rows.map((r) => ({
431
+ name: r.name,
432
+ phase: r.slotPhase,
433
+ slot: r.slotLifecycleUid,
434
+ cleanup: r.cleanupComplete === undefined ? "unknown" : String(r.cleanupComplete),
435
+ head: r.headState === undefined ? "absent" : `${r.headState}${r.headOp ? ` op ${r.headOp.kind}:${r.headOp.opId}` : ""}`,
436
+ live: String(r.live),
437
+ })),
438
+ },
439
+ { kind: "lines", lines: [{ text: `read order slot,head; consistency ${rows[0].consistency}`, tone: "hint" }] },
440
+ ];
441
+ }
442
+ /** `rowsOf` is each answered instance's rows as the census received them, so a row that names no
443
+ * instance of its own is still listed under the manager that returned it. */
444
+ function psView(result, wide, rowsOf = new Map()) {
445
+ const empty = result.kind === "slots" ? "No active static slots." : "No managed agents.";
446
+ const blocksFor = (rows) => !rows.length ? [{ kind: "lines", lines: [{ text: empty, tone: "hint" }] }]
447
+ : result.kind === "slots" ? slotBlocks(rows)
448
+ : seatBlocks(rows, wide);
449
+ // A single manager that answered is the common case: a flat list, no per-manager grouping noise.
450
+ if (result.managers.length <= 1 && result.managers.every((m) => m.state === "answered"))
451
+ return { sections: [
452
+ { title: result.kind === "slots" ? "Static slots" : "Agents", blocks: blocksFor(result.items) },
453
+ { title: "Next", blocks: [{ kind: "commands", items: result.items.length ? [
454
+ { command: "cotal attach <name>", description: "Return to an agent's terminal" },
455
+ { command: "cotal stop <name>", description: "Stop one agent" },
456
+ ] : [{ command: "cotal spawn", description: "Launch your default agent" }] }] },
457
+ ] };
458
+ // Several managers: one section each, named by the FULL instance id, since `--on` takes nothing
459
+ // shorter and this is precisely where it becomes the one way to address a manager. Silent and
460
+ // refused instances are shown, never dropped.
461
+ return {
462
+ sections: result.managers.map((m) => {
463
+ const title = `manager ${m.instanceId}`;
464
+ if (m.state === "silent") {
465
+ const silent = silentManager(m.liveness, m.instanceId);
466
+ return { title, blocks: [{ kind: "lines", lines: [silent.state, ...(silent.remedy ? [{ text: `↳ ${silent.remedy}`, tone: "hint" }] : [])] }] };
467
+ }
468
+ if (m.state === "contract-mismatch")
469
+ return { title, blocks: [{ kind: "lines", lines: [{ text: "contract mismatch; seats not listed", tone: "failed" }] }] };
470
+ if (m.state === "refused")
471
+ return { title, blocks: [{ kind: "lines", lines: [{ text: `list refused: ${m.error}`, tone: "failed" }] }] };
472
+ const rows = rowsOf.get(m.instanceId) ?? [];
473
+ const count = rows.length ? `${rows.length} ${result.kind === "slots" ? "slot" : "agent"}${rows.length === 1 ? "" : "s"}` : `no ${result.kind === "slots" ? "slots" : "agents"}`;
474
+ return { title, blocks: [{ kind: "lines", lines: [{ text: count, tone: "hint" }] }, ...(rows.length ? blocksFor(rows) : [])] };
475
+ }),
476
+ };
328
477
  }
329
478
  export async function ps(args) {
330
479
  const v = args.values;
331
- // #651 presentations: the two forms are mutually exclusive because they answer "how do I read
332
- // this" two different ways;
333
- // inventing a precedence would be a silent fallback, so refuse instead.
334
- const opts = { wide: v.wide === true, json: v.json === true, slots: v.slots === true };
335
- if (opts.wide && opts.json) {
336
- console.error(c.red("✗ --wide and --json are mutually exclusive: --wide is the human table, --json the machine form"));
337
- process.exit(1);
338
- }
339
- if (opts.slots && opts.wide) {
340
- console.error(c.red("✗ --slots and --wide are mutually exclusive: --slots lists durable static slot rows, --wide the live seat facts"));
341
- process.exit(1);
480
+ // #651 presentations: --wide is a human layout and --json the document that already carries every
481
+ // field, so the pair asks one question two ways; inventing a precedence would be a silent
482
+ // fallback, so refuse instead.
483
+ const presentation = presentationOf(v);
484
+ const wide = v.wide === true;
485
+ const slots = v.slots === true;
486
+ if (wide && presentation === "json")
487
+ throw new CommandFailure("refused", "USAGE_INVALID", "--wide and --json are mutually exclusive: --wide is the human layout, --json the document with every field", { remedy: "drop --wide; --json already carries every field the manager recorded" });
488
+ if (slots && wide)
489
+ throw new CommandFailure("refused", "USAGE_INVALID", "--slots and --wide are mutually exclusive: --slots lists durable static slot rows, --wide the live seat facts", { remedy: "pass one of them" });
490
+ const command = slots ? "slots" : "ps";
491
+ const kind = slots ? "slots" : "seats";
492
+ const census = await readSeats(v, command, onInstance(v.on, "cotal ps"));
493
+ const view = (result) => psView(result, wide, census.rowsOf);
494
+ writeResult(presentation, {
495
+ command: "ps",
496
+ target: census.target,
497
+ result: { kind, items: census.items, managers: census.managers },
498
+ completeness: census.partial ? "partial" : "complete",
499
+ warnings: census.warnings,
500
+ ...(census.partial ? { partial: census.partial } : {}),
501
+ }, view);
502
+ }
503
+ /** A named-agent detail uses the same authorized census as ps, never an invented process view. */
504
+ export async function agentStatus(args) {
505
+ const name = args.positionals[0];
506
+ const values = args.values;
507
+ const census = await readSeats(values, "ps", onInstance(values.on, "cotal status"));
508
+ const rows = census.items.map((value) => {
509
+ if (!value || typeof value !== "object")
510
+ throw new CommandFailure("failed", "OPERATION_FAILED", "a manager returned an invalid agent record", { target: census.target });
511
+ const row = value;
512
+ if (typeof row.name !== "string" || typeof row.id !== "string" || typeof row.agent !== "string" || typeof row.mode !== "string" || typeof row.status !== "string" || typeof row.mesh !== "string" || typeof row.uptimeMs !== "number" || !Number.isFinite(row.uptimeMs))
513
+ throw new CommandFailure("failed", "OPERATION_FAILED", "a manager returned an incomplete agent record", { target: census.target });
514
+ return value;
515
+ });
516
+ const matches = rows.filter((row) => row.name === name || row.id === name);
517
+ if (matches.length > 1)
518
+ throw new CommandFailure("refused", "TARGET_AMBIGUOUS", "more than one manager reports this agent; select a manager with --on", { target: { ...census.target, name, candidates: matches.map((row) => ({ name: row.name, id: row.id, instanceId: row.instanceId ?? null })) } });
519
+ if (!matches.length && !census.partial)
520
+ throw new CommandFailure("refused", "TARGET_NOT_FOUND", "the answering managers report no agent with that name or identity", { target: { ...census.target, name } });
521
+ const item = matches[0] ?? null;
522
+ const managerInstanceId = item ? [...census.rowsOf].find(([, rows]) => rows.includes(item))?.[0] ?? census.target.managerInstanceId ?? item.instanceId ?? null : null;
523
+ let managerHint = "";
524
+ if (managerInstanceId) {
525
+ try {
526
+ managerHint = ` --on ${assertLifecycleToken(managerInstanceId, "instanceId")}`;
527
+ }
528
+ catch {
529
+ managerHint = " --on <manager-instance>";
530
+ }
342
531
  }
343
- const command = opts.slots ? "slots" : "ps";
344
- const emptyLine = opts.slots ? "(no nonretired static slots)" : "(no managed agents)";
345
- const print = opts.slots
346
- ? (r, indent = "") => printSlot(r, { json: opts.json }, indent)
347
- : (r, indent = "") => printSeat(r, opts, indent);
348
- const on = onInstanceOrExit(v.on, "cotal ps");
532
+ const projected = item ? agentStatusProjection(item, managerInstanceId) : { identity: null, execution: null, mesh: null, activity: null, details: null };
533
+ writeResult(presentationOf(values), {
534
+ command: "status",
535
+ target: { ...census.target, name },
536
+ result: { kind: "agent", ...projected, managers: census.managers },
537
+ completeness: census.partial ? "partial" : "complete",
538
+ warnings: census.warnings,
539
+ ...(census.partial ? { partial: census.partial } : {}),
540
+ }, (result) => {
541
+ const row = item;
542
+ if (!row || !result.identity || !result.execution || !result.mesh || !result.activity || !result.details)
543
+ return { sections: [
544
+ { title: "Agent could not be located", blocks: [{ kind: "lines", lines: [{ text: "Some managers did not answer. This does not establish that the agent is gone.", tone: "waiting" }] }] },
545
+ { title: "Next", blocks: [{ kind: "commands", items: [{ command: "cotal ps", description: "See the responding and unavailable managers" }, { command: "cotal status <agent> --on <manager-instance>", description: "Address a known manager directly" }] }] },
546
+ ] };
547
+ const identity = result.identity, execution = result.execution, mesh = result.mesh, activity = result.activity;
548
+ const credential = row.authHealth ? [["Credential", { text: row.authHealth, tone: authTone(row) }]] : [];
549
+ return { sections: [
550
+ { title: "Identity", blocks: [
551
+ ...(census.partial ? [{ kind: "lines", lines: [{ text: "Other managers did not answer. This is one known match, not a complete uniqueness check.", tone: "waiting" }] }] : []),
552
+ { kind: "fields", rows: [["Agent", identity.name], ["Space", census.target.space], ["Principal", row.id], ["Owner", identity.owner ?? "not established"], ["Actor", identity.actor ?? "not established"], ["Lifecycle", identity.lifecycleUid ?? "not reported"], ["Role", result.details.role ?? "not reported"]] },
553
+ ] },
554
+ { title: "Execution", blocks: [
555
+ { kind: "fields", rows: [["Process", processCell(row)], ["Application", execution.harness], ["Model", execution.model ? `${execution.model} · requested, not provider-confirmed` : "not reported"], ["Variant", result.details.variant ?? "not reported"], ["Reported provider", result.details.providerSource === "exact-principal-lifecycle" ? result.details.provider ?? "not reported" : "not established"], ["Name-matched provider", result.details.providerSource === "name-match-unverified" ? result.details.provider ?? "not reported" : "none"], ["Runtime", execution.runtime], ["PID", execution.pid === null ? "not reported" : String(execution.pid)], ["Host", execution.host ?? "not reported"], ["Folder", result.details.cwd ?? "not reported"], ["Manager", execution.managerInstanceId ?? "not reported"], ...credential] },
556
+ ...(row.authReason ? [{ kind: "lines", lines: [{ text: row.authReason, tone: authTone(row) }] }] : []),
557
+ ] },
558
+ { title: "Mesh", blocks: [
559
+ { kind: "fields", rows: [["Exact presence", mesh.presenceState ?? "not established"], ["Connection", mesh.presenceState === null ? "not attributable to this lifecycle" : meshCell(row)], ["Name-matched roster", mesh.nameMatchedState === null ? "none separate" : meshCell(row)], ["Observed at", mesh.observedAt ?? "not reported"], ["Presence view", result.details.presenceView ?? "not reported"]] },
560
+ ...(mesh.presenceState === null ? [{ kind: "lines", lines: [{ text: "This manager has not established a current roster record for the agent's exact principal and lifecycle UID. A matching name alone is not proof.", tone: "waiting" }] }] : []),
561
+ ] },
562
+ { title: "Last reported activity", blocks: [
563
+ { kind: "fields", rows: [["State", activity.state ?? "not established"], ["Text", "not reported"], ["Condition", activity.condition?.code ?? "not established"], ["Condition since", activity.conditionSince ?? "not reported"], ["Work event", activity.reportedAt ?? "not reported"], ["Unverified name-match condition", activity.nameMatchedCondition?.code ?? "none"], ["Unverified name-match event", activity.nameMatchedWorkEventAt ?? "none"]] },
564
+ { kind: "lines", lines: [{ text: "A work event is not task completion or a measured blocked duration. A name-match without the manager's exact-identity proof is not this agent's activity.", tone: "hint" }] },
565
+ ] },
566
+ { title: "Next", blocks: [{ kind: "commands", items: [{ command: `cotal attach <agent>${managerHint}`, description: managerHint ? "Return to its terminal through this manager" : "Return to its terminal" }, { command: `cotal stop <agent>${managerHint}`, description: managerHint ? "Stop the named agent through this manager" : "Stop the named agent" }] }] },
567
+ ] };
568
+ });
569
+ }
570
+ /** Read the managed seats the way `ps` lists them: from one manager when `on` pins it or the caller
571
+ * holds a user bearer, otherwise from every registered instance. Throws the classified failure when
572
+ * the target cannot be resolved or no manager can be asked. */
573
+ export async function readSeats(v, command, on) {
349
574
  // `--on` must reach the MINT, not just the invoke: the one-shot instrument is issued during
350
575
  // this resolve, and a credential cannot gain an instance rail after it is minted.
351
- const t = await resolveControlTarget(v, "control-caller-privileged", on);
352
- // `--on <instance>`: pin ps to ONE manager instance's `inst` route (P2 item 3 multi-manager) — a
353
- // single-manager view. Same path for both modes (no freeze; no scatter).
354
- if (on !== undefined) {
355
- const reply = await askManager(t.space, t.server, command, undefined, t.auth, "owner", undefined, { instanceId: on });
356
- failIfNotOk(reply);
357
- const rows = reply.data ?? [];
358
- if (!rows.length) {
359
- // A JSON stream with zero rows is zero lines on stdout, not a prose line that would
360
- // corrupt a consumer reading JSONL.
361
- if (!opts.json)
362
- console.log(c.dim(emptyLine));
363
- return;
364
- }
365
- for (const r of rows)
366
- print(r);
367
- return;
368
- }
576
+ const t = await resolveControlTarget(v, "control-caller-privileged", on, { onRefusal: "throw" });
577
+ recordOperationSpace(t.space);
578
+ // One manager instance: `--on <instance>` pins ps to its `inst` route on a multi-manager mesh,
579
+ // and in USER MODE (bearer present) the borrowed manager view pins one authorized instance and
580
+ // keeps the actor's existing command scopes. That view has no registry freeze rows and never
581
+ // scatters; the manager answers from its in-memory roster with an owner filter, which is not a
582
+ // complete multi-manager inventory (see docs/cli.md), and the target says so.
583
+ //
369
584
  // Mode chosen UP FRONT from the connection shape. Never try-scatter-catch-degrade: a silent
370
585
  // downgrade is the bug this branch fixes, and reintroducing it in the fix would be the whole
371
586
  // night in miniature.
372
- //
373
- // USER MODE (bearer present): the borrowed manager view pins one authorized instance and keeps
374
- // the actor's existing command scopes. It has no registry freeze rows and never scatters.
375
- // The manager answers from its in-memory roster with an owner filter; this is not a complete
376
- // multi-manager inventory (see docs/cli.md).
377
- //
378
- // STATIC/OPEN (no bearer): class scatter. The operator instrument (or bare open connect) holds
379
- // the freeze rows; every registered instance is attributed, and a non-answering one is labeled
380
- // unreachable (pin 3).
381
- if (t.auth.bearer) {
382
- // No explicit --on on this branch; askManager uses the issuer's concrete selection.
383
- const reply = await askManager(t.space, t.server, command, undefined, t.auth, "owner", undefined, {});
384
- failIfNotOk(reply);
385
- const rows = reply.data ?? [];
386
- if (!rows.length) {
387
- if (!opts.json)
388
- console.log(c.dim(emptyLine));
389
- return;
587
+ if (on !== undefined || t.auth.bearer) {
588
+ const instanceId = on ?? t.auth.managerInstanceId;
589
+ const target = { space: t.space, scope: "manager", managerInstanceId: instanceId ?? null };
590
+ const reply = await askManager(t.space, t.server, command, undefined, t.auth, "owner", undefined, on !== undefined ? { instanceId: on } : {});
591
+ if (!reply.ok) {
592
+ const failure = readFailure(reply, target);
593
+ // A user-mode manager view that the broker refused before any responder saw the call. The
594
+ // broker does not say which row was missing, so this names the documented requirement for
595
+ // these reads instead of asserting a cause, and keeps the native refusal as it was. A refusal
596
+ // the manager answered, such as a retiring caller's, already states its own reason.
597
+ if (t.auth.bearer && failure.code === "PERMISSION_DENIED" && reply.nativeOutcome === "not-executed" && !reply.answered)
598
+ throw new CommandFailure(failure.outcome, failure.code, failure.message, {
599
+ target,
600
+ remedy: `on a user-auth mesh, the manager's \`${command}\` read is documented to need the \`admin\` scope on your actor grant; \`spawn\` alone does not carry it. Check what your row holds with \`cotal auth grants\``,
601
+ ...(failure.native ? { native: failure.native } : {}),
602
+ });
603
+ throw failure;
390
604
  }
391
- for (const r of rows)
392
- print(r);
393
- return;
605
+ const items = reply.data ?? [];
606
+ return { target, items, managers: instanceId ? [{ instanceId, state: "answered" }] : [], warnings: [], rowsOf: new Map() };
394
607
  }
608
+ // STATIC/OPEN (no bearer): class scatter. The operator instrument (or bare open connect) holds the
609
+ // freeze rows; every registered instance is attributed, and a non-answering one is labeled with
610
+ // what this command established about it (pin 3).
611
+ const target = { space: t.space, scope: "all-managers" };
395
612
  const scatter = await scatterManager(t.space, t.server, command, t.auth, t.spaceAuth);
396
- if (!scatter.ok) {
397
- console.error(c.red(`✗ ${scatter.error}`));
398
- process.exit(1);
399
- }
613
+ if (!scatter.ok)
614
+ throw readFailure(scatter, target);
400
615
  // Stable ordering: reachable instances first, then by instance id.
401
616
  const instances = [...scatter.instances].sort((a, b) => Number(b.reachable) - Number(a.reachable) || a.instanceId.localeCompare(b.instanceId));
402
- // A single-manager space is the common case — print a flat list, no per-manager grouping noise.
403
- if (instances.length === 1 && instances[0].reachable && !instances[0].error) {
404
- const rows = instances[0].data ?? [];
405
- if (!rows.length) {
406
- if (!opts.json)
407
- console.log(c.dim(emptyLine));
408
- return;
409
- }
410
- for (const r of rows)
411
- print(r);
412
- return;
413
- }
414
- // Multi-manager: group under a per-instance header; unreachable instances are shown, never dropped.
415
- //
416
- // The header prints the FULL instance id, not a prefix. This block runs only in a multi-manager
417
- // space (precisely when the split makes `--on <instance>` the one way to address a manager) and
418
- // `--on` takes nothing but the whole 26-32 char lifecycle token (`assertLifecycleToken`). An
419
- // abbreviated header therefore showed the operator an id that the very next command refuses
420
- // (`"4ik6rb0e" is not a valid lifecycle token`), with the full value printed nowhere: the remedy
421
- // was named and then withheld. Width costs one line here; the prefix cost the flag entirely.
422
- let incomplete = false;
617
+ const items = [];
618
+ const managers = [];
619
+ const warnings = [];
423
620
  const mismatches = [];
621
+ const rowsOf = new Map();
424
622
  for (const inst of instances) {
425
- const label = `manager ${inst.instanceId}`;
426
- // Under --json the instance headers are STRUCTURE, not data: they go to stderr so stdout is
427
- // pure rows (each row carries its own instanceId/host, so nothing is lost).
428
- const header = (line) => { (opts.json ? console.error : console.log)(line); };
623
+ const at = { space: t.space, managerInstanceId: inst.instanceId };
429
624
  if (!inst.reachable) {
430
- incomplete = true;
431
625
  // Not "unreachable": the client holds no network verdict. What it knows is which question it
432
626
  // asked about this instance and what came back, which is narrower and more useful. The four
433
- // cases and their wording are `silentManagerRow`.
434
- header(`${c.bold(label)} ${silentManagerRow(inst.liveness, inst.instanceId)}`);
627
+ // cases and their wording are `silentManager`.
628
+ managers.push({ instanceId: inst.instanceId, state: "silent", ...(inst.liveness ? { liveness: inst.liveness } : {}) });
629
+ warnings.push({ code: "MANAGER_SILENT", target: at, message: `manager ${inst.instanceId}: ${silentManager(inst.liveness, inst.instanceId).state.text}` });
435
630
  continue;
436
631
  }
437
632
  if (inst.error) {
438
- incomplete = true;
439
633
  const mismatch = /^pinned digests (sha256:[a-f0-9]{64})\/(sha256:[a-f0-9]{64}) do not match the served contract (sha256:[a-f0-9]{64})\/(sha256:[a-f0-9]{64});/.exec(inst.error);
634
+ const code = inst.code === undefined ? {} : { code: inst.code };
440
635
  if (mismatch) {
441
- header(`${c.bold(label)} ${c.red("contract mismatch; seats not listed")}`);
636
+ managers.push({ instanceId: inst.instanceId, state: "contract-mismatch", error: inst.error, ...code });
442
637
  mismatches.push(`manager ${inst.instanceId}: requested input/output ${mismatch[1]} / ${mismatch[2]}; served input/output ${mismatch[3]} / ${mismatch[4]}`);
638
+ warnings.push({ code: "MANAGER_CONTRACT_MISMATCH", target: at, message: `manager ${inst.instanceId} serves a different ps contract; its seats were not listed` });
443
639
  }
444
640
  else {
445
- header(`${c.bold(label)} ${c.red(`list refused: ${inst.error}`)}`);
641
+ managers.push({ instanceId: inst.instanceId, state: "refused", error: inst.error, ...code });
642
+ warnings.push({ code: "MANAGER_REFUSED", target: at, message: `manager ${inst.instanceId} refused the list: ${inst.error}` });
446
643
  }
447
644
  continue;
448
645
  }
449
646
  const rows = inst.data ?? [];
450
- header(`${c.bold(label)} ${c.dim(rows.length ? `${rows.length} agent${rows.length === 1 ? "" : "s"}` : "no agents")}`);
451
- for (const r of rows)
452
- print(r, " ");
453
- }
454
- if (mismatches.length)
455
- console.error(c.red(`✗ Managers in this space serve different ps contracts. ${mismatches.join("; ")}. Align the manager versions and retry.`));
456
- if (incomplete) {
457
- console.error(c.red("✗ Incomplete manager census: some instances did not return seats. Rows above are partial, not a complete list."));
458
- process.exitCode = 1;
647
+ managers.push({ instanceId: inst.instanceId, state: "answered" });
648
+ rowsOf.set(inst.instanceId, rows);
649
+ items.push(...rows);
459
650
  }
651
+ const unread = managers.filter((m) => m.state !== "answered").length;
652
+ const kind = command === "slots" ? "slots" : "seats";
653
+ const partial = unread
654
+ ? {
655
+ message: `Incomplete manager census: ${unread} of ${managers.length} instances did not return ${kind}. Rows above are partial, not a complete list.`,
656
+ remedy: mismatches.length
657
+ ? `Managers in this space serve different ps contracts. ${mismatches.join("; ")}. Align the manager versions and retry.`
658
+ : "retry, or read one manager with `cotal ps --on <instance>`",
659
+ }
660
+ : undefined;
661
+ return { target, items, managers, warnings, rowsOf, ...(partial ? { partial } : {}) };
460
662
  }
461
663
  /** Re-establishment backoff, in order; the last value is the cap and repeats forever. A seat that
462
664
  * exists is worth waiting for — the operator asked to be attached to it, and the alternative is
@@ -531,7 +733,12 @@ export function attachRefusal(code, details) {
531
733
  * helper can wrap it, and it only rethrows the codes that are not "no mesh found", so that is fatal
532
734
  * too. Anything else, including a broker that is not reachable yet, is transient.
533
735
  */
736
+ class SeatAttachCallerUnavailable extends Error {
737
+ constructor() { super("the launching seat could not re-establish its own caller; no operator identity was substituted"); }
738
+ }
534
739
  function thrownEstablishment(e) {
740
+ if (e instanceof SeatAttachCallerUnavailable)
741
+ return { ok: false, kind: "fatal", message: e.message };
535
742
  if (e instanceof ConnectRefusal && e.kind === "permanent")
536
743
  return { ok: false, kind: "fatal", message: [e.rendered.replace(/^✗ /, ""), e.hint].filter(Boolean).join("\n") };
537
744
  if (isWorkspaceTargetError(e))
@@ -604,11 +811,20 @@ async function establishAttachSession(v, on, reconnect, firstAttempt) {
604
811
  // mid-session, and the refusal becomes a status-line notice instead. So "first" here means the
605
812
  // first attempt of a command that wants the exit.
606
813
  const first = firstAttempt && (v.onRefusal ?? "exit") === "exit";
607
- const t = await resolveControlTarget(v, "control-caller-admin", on, first ? {} : { onRefusal: "throw" });
814
+ const seat = v.asSeat ? await resolveSeatControlTarget(v, on) : undefined;
815
+ if (v.asSeat && !seat)
816
+ throw new SeatAttachCallerUnavailable();
817
+ const t = seat ?? await resolveControlTarget(v, "control-caller-admin", on, first ? {} : { onRefusal: "throw" });
818
+ recordOperationSpace(t.space);
608
819
  const reach = t.auth.bearer ? "owner" : "any";
609
- const reply = await askManager(t.space, t.server, "attach", { name: v.name }, t.auth, reach, undefined, { instanceId: on });
610
- if (!reply.ok)
820
+ if (first)
821
+ console.error(renderReport({ space: t.space, sections: [{ title: "Attach", blocks: [{ kind: "fields", rows: [["Agent", v.name], ["Manager", on ?? t.auth.managerInstanceId ?? "native selection"]] }] }] }, "rich", terminalWidth(process.stderr)));
822
+ const reply = await askManager(t.space, t.server, "attach", { name: v.name }, t.auth, reach, undefined, { instanceId: on, expectedTarget: v.expectedTarget });
823
+ if (!reply.ok) {
824
+ if (first && (reply.preSubmitRefusal || reply.nativeOutcome === "not-executed"))
825
+ throw managerFailure(reply, "terminal attach", { space: t.space, agent: v.name, managerInstanceId: reply.managerInstanceId ?? on ?? null });
611
826
  return { ok: false, kind: attachRefusal(reply.code, reply.details), message: reply.error ?? "error", fromManager: true };
827
+ }
612
828
  // P2 item 6: the reply is the holder-bound §13.6 session GRANT (no ws:// URL). Redeem it over the
613
829
  // mesh. A static-auth mesh mints a per-session, rails-only caller cred from the resolved root's
614
830
  // seed. A registered open mesh has no seed: the same bare connection `askManagerEp` already used
@@ -962,7 +1178,7 @@ async function runAttachLoop(vv, pin, reconnect, key, hold) {
962
1178
  const detached = watch ? await Promise.race([waited, watch.pressed.then(() => true)]) : await waited;
963
1179
  clearTimeout(timer);
964
1180
  if (detached)
965
- return await done({ kind: "ended" });
1181
+ return await done({ kind: "ended", reason: "detached" });
966
1182
  attempt++;
967
1183
  }
968
1184
  // Give the manager its slots back BEFORE claiming another one. The order is load-bearing at the
@@ -999,7 +1215,7 @@ async function runAttachLoop(vv, pin, reconnect, key, hold) {
999
1215
  // abandoned backoff timer, one layer down.
1000
1216
  await closeLink(late.nc);
1001
1217
  }
1002
- return await done({ kind: "ended" });
1218
+ return await done({ kind: "ended", reason: "detached" });
1003
1219
  }
1004
1220
  }
1005
1221
  try {
@@ -1085,7 +1301,7 @@ async function runAttachLoop(vv, pin, reconnect, key, hold) {
1085
1301
  // One-shot: a faulted session still throws, so `--no-reconnect` exits the way it does today.
1086
1302
  if (outcome.error)
1087
1303
  throw outcome.error;
1088
- return await done({ kind: "ended" });
1304
+ return await done({ kind: "ended", reason: outcome.reason });
1089
1305
  }
1090
1306
  if (!isTransportEnd(outcome.reason)) {
1091
1307
  // A faulted end this classification does not recognise is NOT a detach. Printing
@@ -1094,7 +1310,7 @@ async function runAttachLoop(vv, pin, reconnect, key, hold) {
1094
1310
  // this is a guard against a future one that forgets, not a live path.
1095
1311
  if (outcome.error)
1096
1312
  return await done({ kind: "failed", message: outcome.error.message });
1097
- return await done({ kind: "ended" });
1313
+ return await done({ kind: "ended", reason: outcome.reason });
1098
1314
  }
1099
1315
  console.error(c.dim("[cotal: connection lost, reconnecting]"));
1100
1316
  // Raw from here on, whether or not the session that just ended reached ready. A first session
@@ -1143,28 +1359,49 @@ export async function attachSeat(v, opts) {
1143
1359
  hold.restore();
1144
1360
  }
1145
1361
  }
1362
+ async function pickAttach(values) {
1363
+ const census = await readSeats(values, "ps", onInstance(values.on, "cotal attach"));
1364
+ const choices = census.items.map((value) => {
1365
+ const row = value;
1366
+ if (!row || typeof row.name !== "string" || typeof row.id !== "string" || typeof row.lifecycleUid !== "string")
1367
+ throw new CommandFailure("refused", "UNSUPPORTED", "a manager did not report the identity needed for a safe attach selection", { remedy: "align the manager versions before using the picker", target: census.target });
1368
+ const on = [...census.rowsOf].find(([, rows]) => rows.includes(value))?.[0] ?? census.target.managerInstanceId;
1369
+ if (!on)
1370
+ throw new CommandFailure("refused", "TARGET_UNAVAILABLE", "the agent's manager instance was not established", { target: census.target });
1371
+ return { name: row.name, on, expectedTarget: { id: row.id, lifecycleUid: row.lifecycleUid }, status: typeof row.status === "string" ? row.status : "not reported" };
1372
+ });
1373
+ if (census.partial)
1374
+ console.error(renderReport({ space: census.target.space, sections: [{ title: "Agent list is partial", blocks: [{ kind: "lines", lines: [{ text: census.partial.message, tone: "waiting" }] }] }] }, "rich", terminalWidth(process.stderr)));
1375
+ if (!choices.length)
1376
+ throw new CommandFailure("refused", census.partial ? "TARGET_UNAVAILABLE" : "TARGET_NOT_FOUND", census.partial ? "no attachable agent was returned; some managers did not answer" : "the answering managers report no agents to attach", { target: census.target, remedy: "run cotal ps, or launch an agent with cotal spawn" });
1377
+ const choice = await prompts.select({
1378
+ message: `Return to an agent in ${oneLine(census.target.space)}`,
1379
+ options: choices.map((item, index) => ({ value: index, label: oneLine(`${item.name} · ${item.status}`), hint: oneLine(`${item.expectedTarget.id} · manager ${item.on}`) })),
1380
+ });
1381
+ if (prompts.isCancel(choice))
1382
+ return undefined;
1383
+ const selected = choices[choice];
1384
+ console.error(renderReport({ space: census.target.space, sections: [{ title: "Attaching", blocks: [{ kind: "fields", rows: [["Agent", selected.name], ["Identity", selected.expectedTarget.id], ["Manager", selected.on], ["Detach", `${detachKey().label} leaves the agent running`]] }] }] }, "rich", terminalWidth(process.stderr)));
1385
+ return selected;
1386
+ }
1146
1387
  export async function attach(args) {
1147
- const v = args.values;
1148
- if (!v.name) {
1149
- console.error(c.red("--name is required"));
1150
- process.exit(1);
1388
+ const name = managedTarget(args, "attach", true);
1389
+ const selection = name === undefined ? await pickAttach(args.values) : undefined;
1390
+ if (name === undefined && selection === undefined) {
1391
+ console.error("Attach cancelled. No agent was stopped.");
1392
+ return;
1151
1393
  }
1394
+ const v = { ...args.values, name: name ?? selection.name, ...(selection ? { on: selection.on } : {}) };
1152
1395
  const reconnecting = v["no-reconnect"] !== true;
1153
- // Seat-locality first, exactly as `stop` does it: attaching to a seat means reaching the process,
1154
- // which only its host manager has. Resolved ONCE — the seat does not move between reconnects, and
1155
- // a manager that stops answering is a transient the loop already retries through. An explicit
1156
- // `--on` skips the lookup (the empty-value refusal lives in `pinForTarget`).
1157
1396
  const on = v.on !== undefined ? await pinForTarget(v, "cotal attach") : undefined;
1158
- const verdict = await attachSeat({ space: v.space, server: v.server, creds: v.creds, name: v.name }, { reconnect: reconnecting, onRefusal: "exit", on });
1159
- if (verdict.kind === "failed") {
1160
- console.error(c.red(`✗ ${verdict.message}`));
1161
- process.exit(1);
1162
- }
1163
- if (verdict.kind === "gone") {
1164
- console.error(c.dim(`\nseat ${v.name} is gone`));
1165
- return;
1166
- }
1167
- console.error(c.dim(`\ndetached from ${v.name}`));
1397
+ const verdict = await attachSeat({ space: v.space, server: v.server, creds: v.creds, name: v.name, ...(selection ? { expectedTarget: selection.expectedTarget } : {}) }, { reconnect: reconnecting, onRefusal: "exit", on });
1398
+ if (verdict.kind === "failed")
1399
+ throw new CommandFailure("failed", "OPERATION_FAILED", verdict.message);
1400
+ const detached = verdict.kind === "ended" && verdict.reason === "detached";
1401
+ console.error(renderReport({ sections: [{ title: verdict.kind === "gone" ? "Attach target no longer available" : detached ? "Detached" : "Attach session ended", blocks: [
1402
+ { kind: "fields", rows: [["Agent", v.name]] },
1403
+ { kind: "lines", lines: [{ text: verdict.kind === "gone" ? "The selected agent or incarnation was not available to this attach request." : detached ? "Detaching did not send a stop request." : "The terminal session ended. This view sent no agent stop request; run cotal ps to check the agent's current state.", tone: "hint" }] },
1404
+ ] }] }, "rich", terminalWidth(process.stderr)));
1168
1405
  }
1169
1406
  /**
1170
1407
  * `cotal input --name <seat> --text <text> [--no-enter]`: deliver one line of text into a running
@@ -1177,26 +1414,39 @@ export async function attach(args) {
1177
1414
  * reads the resulting turns from the event plane or the transcript, so this prints only what was
1178
1415
  * delivered.
1179
1416
  */
1417
+ export function inputArguments(args) {
1418
+ presentationOf(args.values);
1419
+ const [positionalName, positionalText, ...extra] = args.positionals;
1420
+ const values = args.values;
1421
+ if (extra.length || (positionalName !== undefined && values.name !== undefined) || (positionalText !== undefined && values.text !== undefined))
1422
+ throw new CommandFailure("refused", "USAGE_INVALID", "choose one agent and one text source: cotal input <agent> <text>, or --name and --text");
1423
+ const name = positionalName ?? values.name;
1424
+ const text = positionalText ?? values.text;
1425
+ if (!name?.trim() || /[\u0000-\u001f\u007f]/u.test(name))
1426
+ throw new CommandFailure("refused", "USAGE_INVALID", "input needs one concrete agent name without terminal control characters");
1427
+ if (!text)
1428
+ throw new CommandFailure("refused", "USAGE_INVALID", "input needs nonempty text; use --text for a value beginning with a dash");
1429
+ if (values.on !== undefined)
1430
+ onInstance(values.on, "cotal input");
1431
+ return { name, text };
1432
+ }
1180
1433
  export async function input(args) {
1181
- const v = args.values;
1182
- if (!v.name) {
1183
- console.error(c.red("--name is required"));
1184
- process.exit(1);
1185
- }
1186
- // An EMPTY --text is refused here rather than sent: the op's contract requires a non-empty
1187
- // string, so sending it would spend a round trip to be told the same thing in a contract error
1188
- // that names a schema instead of the flag the operator got wrong. `v.text === undefined` (flag
1189
- // omitted) and `""` (flag given, empty) are the same mistake to the caller, so one message.
1190
- if (!v.text) {
1191
- console.error(c.red("--text is required and must not be empty"));
1192
- process.exit(1);
1193
- }
1434
+ const parsed = inputArguments(args);
1435
+ const v = { ...args.values, ...parsed };
1194
1436
  const on = await pinForTarget(v, "cotal input");
1195
1437
  const t = await resolveControlTarget(v, "control-caller-admin", on);
1438
+ recordOperationSpace(t.space);
1196
1439
  const reach = t.auth.bearer ? "owner" : "any";
1197
1440
  const reply = await askManager(t.space, t.server, "input", { name: v.name, text: v.text, enter: v["no-enter"] !== true }, t.auth, reach, undefined, { instanceId: on });
1198
- failIfNotOk(reply);
1199
- const { name, bytes } = reply.data;
1200
- console.log(c.dim(`✓ sent ${bytes} bytes to ${name}`));
1441
+ const target = { space: t.space, managerInstanceId: reply.managerInstanceId ?? on ?? null, agent: v.name };
1442
+ if (!reply.ok)
1443
+ throw managerFailure(reply, "terminal input", target);
1444
+ const data = reply.data;
1445
+ if (!data || typeof data.name !== "string" || typeof data.bytes !== "number" || !Number.isSafeInteger(data.bytes) || data.bytes < 0)
1446
+ throw new CommandFailure("unknown", "OPERATION_UNKNOWN", "the manager answered, but the terminal-input receipt was unreadable; the text was not sent again", { target, ...(reply.request ? { native: { detail: { request: reply.request } } } : {}) });
1447
+ const result = { kind: "terminal-input", name: data.name, bytes: Number(data.bytes), enterRequested: v["no-enter"] !== true, request: reply.request ?? null };
1448
+ writeResult(presentationOf(v), { command: "input", target, result }, (row) => ({ sections: [
1449
+ { title: "Terminal input written", blocks: [{ kind: "fields", rows: [["Agent", row.name], ["Space", t.space], ["Manager", reply.managerInstanceId ?? "not attributed"], ["Bytes reported", String(row.bytes)], ["Enter requested", row.enterRequested ? "yes" : "no"]] }, { kind: "lines", lines: [{ text: "The native manager acknowledged writing to the terminal. This does not prove the application read it or completed a task. The input text is not echoed.", tone: "hint" }] }] },
1450
+ ] }));
1201
1451
  }
1202
1452
  //# sourceMappingURL=agents.js.map