@cotal-ai/cli 0.90.1 → 0.92.0

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