@cotal-ai/cli 0.100.2 → 0.101.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 (618) hide show
  1. package/dist/chat/chat-view.d.ts.map +1 -1
  2. package/dist/chat/chat-view.js +5 -1
  3. package/dist/chat/chat-view.js.map +1 -1
  4. package/dist/chat/engine.d.ts +2 -1
  5. package/dist/chat/engine.d.ts.map +1 -1
  6. package/dist/chat/engine.js +2 -1
  7. package/dist/chat/engine.js.map +1 -1
  8. package/dist/chat/frontend.d.ts.map +1 -1
  9. package/dist/chat/frontend.js +13 -7
  10. package/dist/chat/frontend.js.map +1 -1
  11. package/dist/chat/native-session.d.ts +22 -3
  12. package/dist/chat/native-session.d.ts.map +1 -1
  13. package/dist/chat/native-session.js +91 -19
  14. package/dist/chat/native-session.js.map +1 -1
  15. package/dist/chat/open-session.d.ts +1 -0
  16. package/dist/chat/open-session.d.ts.map +1 -1
  17. package/dist/chat/open-session.js +1 -1
  18. package/dist/chat/open-session.js.map +1 -1
  19. package/dist/chat/picker.d.ts +5 -0
  20. package/dist/chat/picker.d.ts.map +1 -1
  21. package/dist/chat/picker.js +23 -10
  22. package/dist/chat/picker.js.map +1 -1
  23. package/dist/chat/plain.d.ts.map +1 -1
  24. package/dist/chat/plain.js +36 -10
  25. package/dist/chat/plain.js.map +1 -1
  26. package/dist/chat/session.d.ts +5 -0
  27. package/dist/chat/session.d.ts.map +1 -1
  28. package/dist/chat/static-session.d.ts +1 -0
  29. package/dist/chat/static-session.d.ts.map +1 -1
  30. package/dist/chat/static-session.js +24 -8
  31. package/dist/chat/static-session.js.map +1 -1
  32. package/dist/chat/stdio-io.d.ts +2 -0
  33. package/dist/chat/stdio-io.d.ts.map +1 -1
  34. package/dist/chat/stdio-io.js +6 -6
  35. package/dist/chat/stdio-io.js.map +1 -1
  36. package/dist/chat/stdio.d.ts +3 -2
  37. package/dist/chat/stdio.d.ts.map +1 -1
  38. package/dist/chat/stdio.js +26 -25
  39. package/dist/chat/stdio.js.map +1 -1
  40. package/dist/chat/user-session.d.ts +1 -0
  41. package/dist/chat/user-session.d.ts.map +1 -1
  42. package/dist/chat/user-session.js +1 -1
  43. package/dist/chat/user-session.js.map +1 -1
  44. package/dist/chat/view.d.ts +5 -4
  45. package/dist/chat/view.d.ts.map +1 -1
  46. package/dist/chat/view.js +10 -8
  47. package/dist/chat/view.js.map +1 -1
  48. package/dist/command.d.ts +5 -0
  49. package/dist/command.d.ts.map +1 -1
  50. package/dist/command.js +295 -82
  51. package/dist/command.js.map +1 -1
  52. package/dist/commands/agents.d.ts +29 -5
  53. package/dist/commands/agents.d.ts.map +1 -1
  54. package/dist/commands/agents.js +100 -35
  55. package/dist/commands/agents.js.map +1 -1
  56. package/dist/commands/backup-maintenance.d.ts.map +1 -1
  57. package/dist/commands/backup-maintenance.js +54 -21
  58. package/dist/commands/backup-maintenance.js.map +1 -1
  59. package/dist/commands/backup-read.d.ts.map +1 -1
  60. package/dist/commands/backup-read.js +12 -15
  61. package/dist/commands/backup-read.js.map +1 -1
  62. package/dist/commands/backup-restore.d.ts.map +1 -1
  63. package/dist/commands/backup-restore.js +20 -4
  64. package/dist/commands/backup-restore.js.map +1 -1
  65. package/dist/commands/backup.d.ts.map +1 -1
  66. package/dist/commands/backup.js +156 -28
  67. package/dist/commands/backup.js.map +1 -1
  68. package/dist/commands/channel-members.d.ts +1 -1
  69. package/dist/commands/channel-members.d.ts.map +1 -1
  70. package/dist/commands/channel-members.js +115 -29
  71. package/dist/commands/channel-members.js.map +1 -1
  72. package/dist/commands/channels.d.ts +11 -1
  73. package/dist/commands/channels.d.ts.map +1 -1
  74. package/dist/commands/channels.js +109 -20
  75. package/dist/commands/channels.js.map +1 -1
  76. package/dist/commands/chat.d.ts +11 -3
  77. package/dist/commands/chat.d.ts.map +1 -1
  78. package/dist/commands/chat.js +50 -22
  79. package/dist/commands/chat.js.map +1 -1
  80. package/dist/commands/clean.d.ts +10 -5
  81. package/dist/commands/clean.d.ts.map +1 -1
  82. package/dist/commands/clean.js +245 -42
  83. package/dist/commands/clean.js.map +1 -1
  84. package/dist/commands/completion.d.ts +15 -2
  85. package/dist/commands/completion.d.ts.map +1 -1
  86. package/dist/commands/completion.js +91 -26
  87. package/dist/commands/completion.js.map +1 -1
  88. package/dist/commands/config.d.ts +24 -1
  89. package/dist/commands/config.d.ts.map +1 -1
  90. package/dist/commands/config.js +65 -13
  91. package/dist/commands/config.js.map +1 -1
  92. package/dist/commands/console.d.ts.map +1 -1
  93. package/dist/commands/console.js +5 -4
  94. package/dist/commands/console.js.map +1 -1
  95. package/dist/commands/describe.d.ts +4 -2
  96. package/dist/commands/describe.d.ts.map +1 -1
  97. package/dist/commands/describe.js +4 -4
  98. package/dist/commands/describe.js.map +1 -1
  99. package/dist/commands/doctor.d.ts +1 -1
  100. package/dist/commands/doctor.d.ts.map +1 -1
  101. package/dist/commands/doctor.js +261 -34
  102. package/dist/commands/doctor.js.map +1 -1
  103. package/dist/commands/down-manifest.d.ts.map +1 -1
  104. package/dist/commands/down-manifest.js +9 -6
  105. package/dist/commands/down-manifest.js.map +1 -1
  106. package/dist/commands/down-services.d.ts +17 -16
  107. package/dist/commands/down-services.d.ts.map +1 -1
  108. package/dist/commands/down-services.js +29 -53
  109. package/dist/commands/down-services.js.map +1 -1
  110. package/dist/commands/down.d.ts +2 -2
  111. package/dist/commands/down.d.ts.map +1 -1
  112. package/dist/commands/down.js +96 -67
  113. package/dist/commands/down.js.map +1 -1
  114. package/dist/commands/endpoint-deregister.d.ts.map +1 -1
  115. package/dist/commands/endpoint-deregister.js +2 -2
  116. package/dist/commands/endpoint-deregister.js.map +1 -1
  117. package/dist/commands/endpoint.d.ts +2 -1
  118. package/dist/commands/endpoint.d.ts.map +1 -1
  119. package/dist/commands/endpoint.js +2 -2
  120. package/dist/commands/endpoint.js.map +1 -1
  121. package/dist/commands/endpoints.d.ts +1 -0
  122. package/dist/commands/endpoints.d.ts.map +1 -1
  123. package/dist/commands/endpoints.js +20 -5
  124. package/dist/commands/endpoints.js.map +1 -1
  125. package/dist/commands/feedback.d.ts.map +1 -1
  126. package/dist/commands/feedback.js +40 -2
  127. package/dist/commands/feedback.js.map +1 -1
  128. package/dist/commands/help.d.ts.map +1 -1
  129. package/dist/commands/help.js +2 -1
  130. package/dist/commands/help.js.map +1 -1
  131. package/dist/commands/history-clear.d.ts.map +1 -1
  132. package/dist/commands/history-clear.js +67 -51
  133. package/dist/commands/history-clear.js.map +1 -1
  134. package/dist/commands/history.d.ts +17 -2
  135. package/dist/commands/history.d.ts.map +1 -1
  136. package/dist/commands/history.js +221 -34
  137. package/dist/commands/history.js.map +1 -1
  138. package/dist/commands/join.d.ts +2 -0
  139. package/dist/commands/join.d.ts.map +1 -1
  140. package/dist/commands/join.js +132 -80
  141. package/dist/commands/join.js.map +1 -1
  142. package/dist/commands/meshes-add.d.ts +19 -4
  143. package/dist/commands/meshes-add.d.ts.map +1 -1
  144. package/dist/commands/meshes-add.js +114 -15
  145. package/dist/commands/meshes-add.js.map +1 -1
  146. package/dist/commands/meshes-wizard.d.ts +1 -0
  147. package/dist/commands/meshes-wizard.d.ts.map +1 -1
  148. package/dist/commands/meshes-wizard.js +45 -13
  149. package/dist/commands/meshes-wizard.js.map +1 -1
  150. package/dist/commands/meshes.d.ts +1 -1
  151. package/dist/commands/meshes.d.ts.map +1 -1
  152. package/dist/commands/meshes.js +76 -47
  153. package/dist/commands/meshes.js.map +1 -1
  154. package/dist/commands/mint.d.ts.map +1 -1
  155. package/dist/commands/mint.js +212 -19
  156. package/dist/commands/mint.js.map +1 -1
  157. package/dist/commands/models.d.ts +5 -1
  158. package/dist/commands/models.d.ts.map +1 -1
  159. package/dist/commands/models.js +21 -13
  160. package/dist/commands/models.js.map +1 -1
  161. package/dist/commands/persona-remote.d.ts.map +1 -1
  162. package/dist/commands/persona-remote.js +24 -13
  163. package/dist/commands/persona-remote.js.map +1 -1
  164. package/dist/commands/persona.d.ts +1 -1
  165. package/dist/commands/persona.d.ts.map +1 -1
  166. package/dist/commands/persona.js +92 -23
  167. package/dist/commands/persona.js.map +1 -1
  168. package/dist/commands/personas.d.ts.map +1 -1
  169. package/dist/commands/personas.js +59 -40
  170. package/dist/commands/personas.js.map +1 -1
  171. package/dist/commands/reset-space-apply.d.ts.map +1 -1
  172. package/dist/commands/reset-space-apply.js +69 -17
  173. package/dist/commands/reset-space-apply.js.map +1 -1
  174. package/dist/commands/reset-store-apply.d.ts +16 -0
  175. package/dist/commands/reset-store-apply.d.ts.map +1 -1
  176. package/dist/commands/reset-store-apply.js +122 -23
  177. package/dist/commands/reset-store-apply.js.map +1 -1
  178. package/dist/commands/reset.d.ts.map +1 -1
  179. package/dist/commands/reset.js +8 -7
  180. package/dist/commands/reset.js.map +1 -1
  181. package/dist/commands/revoke-credential.d.ts +5 -0
  182. package/dist/commands/revoke-credential.d.ts.map +1 -0
  183. package/dist/commands/revoke-credential.js +128 -0
  184. package/dist/commands/revoke-credential.js.map +1 -0
  185. package/dist/commands/send.d.ts +11 -3
  186. package/dist/commands/send.d.ts.map +1 -1
  187. package/dist/commands/send.js +284 -47
  188. package/dist/commands/send.js.map +1 -1
  189. package/dist/commands/service-actions.d.ts +2 -1
  190. package/dist/commands/service-actions.d.ts.map +1 -1
  191. package/dist/commands/service-actions.js +117 -21
  192. package/dist/commands/service-actions.js.map +1 -1
  193. package/dist/commands/service-log-follow.js +1 -1
  194. package/dist/commands/service-log-follow.js.map +1 -1
  195. package/dist/commands/service-registry.d.ts +1 -1
  196. package/dist/commands/service-registry.d.ts.map +1 -1
  197. package/dist/commands/service-registry.js +74 -30
  198. package/dist/commands/service-registry.js.map +1 -1
  199. package/dist/commands/service-set-stop.d.ts.map +1 -1
  200. package/dist/commands/service-set-stop.js +3 -2
  201. package/dist/commands/service-set-stop.js.map +1 -1
  202. package/dist/commands/setup-start.d.ts.map +1 -1
  203. package/dist/commands/setup-start.js +46 -5
  204. package/dist/commands/setup-start.js.map +1 -1
  205. package/dist/commands/setup.d.ts.map +1 -1
  206. package/dist/commands/setup.js +28 -13
  207. package/dist/commands/setup.js.map +1 -1
  208. package/dist/commands/space-delete.d.ts.map +1 -1
  209. package/dist/commands/space-delete.js +130 -41
  210. package/dist/commands/space-delete.js.map +1 -1
  211. package/dist/commands/space-registration.d.ts +13 -6
  212. package/dist/commands/space-registration.d.ts.map +1 -1
  213. package/dist/commands/space-registration.js +167 -46
  214. package/dist/commands/space-registration.js.map +1 -1
  215. package/dist/commands/space.d.ts +15 -1
  216. package/dist/commands/space.d.ts.map +1 -1
  217. package/dist/commands/space.js +66 -24
  218. package/dist/commands/space.js.map +1 -1
  219. package/dist/commands/spawn-preview.d.ts.map +1 -1
  220. package/dist/commands/spawn-preview.js +48 -10
  221. package/dist/commands/spawn-preview.js.map +1 -1
  222. package/dist/commands/spawn.d.ts +36 -13
  223. package/dist/commands/spawn.d.ts.map +1 -1
  224. package/dist/commands/spawn.js +263 -129
  225. package/dist/commands/spawn.js.map +1 -1
  226. package/dist/commands/stack-down.d.ts +9 -3
  227. package/dist/commands/stack-down.d.ts.map +1 -1
  228. package/dist/commands/stack-down.js +344 -64
  229. package/dist/commands/stack-down.js.map +1 -1
  230. package/dist/commands/stack-gone.d.ts +17 -0
  231. package/dist/commands/stack-gone.d.ts.map +1 -0
  232. package/dist/commands/stack-gone.js +218 -0
  233. package/dist/commands/stack-gone.js.map +1 -0
  234. package/dist/commands/stack-up.d.ts +64 -4
  235. package/dist/commands/stack-up.d.ts.map +1 -1
  236. package/dist/commands/stack-up.js +482 -55
  237. package/dist/commands/stack-up.js.map +1 -1
  238. package/dist/commands/status.d.ts +76 -2
  239. package/dist/commands/status.d.ts.map +1 -1
  240. package/dist/commands/status.js +550 -112
  241. package/dist/commands/status.js.map +1 -1
  242. package/dist/commands/team-agent-apply.d.ts.map +1 -1
  243. package/dist/commands/team-agent-apply.js +4 -3
  244. package/dist/commands/team-agent-apply.js.map +1 -1
  245. package/dist/commands/team-agent-remove.d.ts.map +1 -1
  246. package/dist/commands/team-agent-remove.js +4 -4
  247. package/dist/commands/team-agent-remove.js.map +1 -1
  248. package/dist/commands/team-boot-controller.d.ts.map +1 -1
  249. package/dist/commands/team-boot-controller.js +8 -2
  250. package/dist/commands/team-boot-controller.js.map +1 -1
  251. package/dist/commands/team-channel-remove.d.ts.map +1 -1
  252. package/dist/commands/team-channel-remove.js +26 -10
  253. package/dist/commands/team-channel-remove.js.map +1 -1
  254. package/dist/commands/team-deploy-apply.d.ts.map +1 -1
  255. package/dist/commands/team-deploy-apply.js +4 -3
  256. package/dist/commands/team-deploy-apply.js.map +1 -1
  257. package/dist/commands/team-mixed-remove.js +5 -5
  258. package/dist/commands/team-mixed-remove.js.map +1 -1
  259. package/dist/commands/team.d.ts.map +1 -1
  260. package/dist/commands/team.js +94 -32
  261. package/dist/commands/team.js.map +1 -1
  262. package/dist/commands/telemetry.d.ts.map +1 -1
  263. package/dist/commands/telemetry.js +3 -1
  264. package/dist/commands/telemetry.js.map +1 -1
  265. package/dist/commands/topology.d.ts.map +1 -1
  266. package/dist/commands/topology.js +11 -7
  267. package/dist/commands/topology.js.map +1 -1
  268. package/dist/commands/up.d.ts +6 -6
  269. package/dist/commands/up.d.ts.map +1 -1
  270. package/dist/commands/up.js +963 -240
  271. package/dist/commands/up.js.map +1 -1
  272. package/dist/commands/update.d.ts.map +1 -1
  273. package/dist/commands/update.js +9 -3
  274. package/dist/commands/update.js.map +1 -1
  275. package/dist/commands/use.d.ts +5 -1
  276. package/dist/commands/use.d.ts.map +1 -1
  277. package/dist/commands/use.js +55 -12
  278. package/dist/commands/use.js.map +1 -1
  279. package/dist/commands/watch.d.ts +4 -1
  280. package/dist/commands/watch.d.ts.map +1 -1
  281. package/dist/commands/watch.js +15 -3
  282. package/dist/commands/watch.js.map +1 -1
  283. package/dist/commands/who.d.ts +2 -0
  284. package/dist/commands/who.d.ts.map +1 -1
  285. package/dist/commands/who.js +18 -5
  286. package/dist/commands/who.js.map +1 -1
  287. package/dist/commands/whoami.d.ts +44 -5
  288. package/dist/commands/whoami.d.ts.map +1 -1
  289. package/dist/commands/whoami.js +168 -16
  290. package/dist/commands/whoami.js.map +1 -1
  291. package/dist/console/app.d.ts +1 -1
  292. package/dist/console/app.d.ts.map +1 -1
  293. package/dist/console/app.js +15 -9
  294. package/dist/console/app.js.map +1 -1
  295. package/dist/console/launch.d.ts +25 -0
  296. package/dist/console/launch.d.ts.map +1 -0
  297. package/dist/console/launch.js +56 -0
  298. package/dist/console/launch.js.map +1 -0
  299. package/dist/console/ui/CommandPalette.d.ts +5 -4
  300. package/dist/console/ui/CommandPalette.d.ts.map +1 -1
  301. package/dist/console/ui/CommandPalette.js +136 -45
  302. package/dist/console/ui/CommandPalette.js.map +1 -1
  303. package/dist/console/ui/Help.js +1 -1
  304. package/dist/console/ui/Help.js.map +1 -1
  305. package/dist/console/ui/Modal.d.ts +10 -0
  306. package/dist/console/ui/Modal.d.ts.map +1 -0
  307. package/dist/console/ui/Modal.js +8 -0
  308. package/dist/console/ui/Modal.js.map +1 -0
  309. package/dist/console/ui/NewAgent.d.ts +14 -0
  310. package/dist/console/ui/NewAgent.d.ts.map +1 -0
  311. package/dist/console/ui/NewAgent.js +114 -0
  312. package/dist/console/ui/NewAgent.js.map +1 -0
  313. package/dist/console/ui/StatusBar.d.ts +1 -2
  314. package/dist/console/ui/StatusBar.d.ts.map +1 -1
  315. package/dist/console/ui/StatusBar.js +6 -8
  316. package/dist/console/ui/StatusBar.js.map +1 -1
  317. package/dist/console/ui/topo/Map.d.ts.map +1 -1
  318. package/dist/console/ui/topo/Map.js +1 -2
  319. package/dist/console/ui/topo/Map.js.map +1 -1
  320. package/dist/console/ui/topo/Matrix.js +2 -2
  321. package/dist/console/ui/topo/Matrix.js.map +1 -1
  322. package/dist/console/ui/topo/Sequence.d.ts.map +1 -1
  323. package/dist/console/ui/topo/Sequence.js +5 -4
  324. package/dist/console/ui/topo/Sequence.js.map +1 -1
  325. package/dist/console/ui/topo/model.d.ts +2 -1
  326. package/dist/console/ui/topo/model.d.ts.map +1 -1
  327. package/dist/console/ui/topo/model.js +4 -3
  328. package/dist/console/ui/topo/model.js.map +1 -1
  329. package/dist/exec-endpoint/service-adapter.d.ts.map +1 -1
  330. package/dist/exec-endpoint/service-adapter.js +13 -3
  331. package/dist/exec-endpoint/service-adapter.js.map +1 -1
  332. package/dist/ext-loader.d.ts +4 -0
  333. package/dist/ext-loader.d.ts.map +1 -1
  334. package/dist/ext-loader.js +6 -0
  335. package/dist/ext-loader.js.map +1 -1
  336. package/dist/help.d.ts.map +1 -1
  337. package/dist/help.js +44 -23
  338. package/dist/help.js.map +1 -1
  339. package/dist/index.d.ts.map +1 -1
  340. package/dist/index.js +59 -54
  341. package/dist/index.js.map +1 -1
  342. package/dist/lib/agent-skills.d.ts.map +1 -1
  343. package/dist/lib/agent-skills.js +2 -1
  344. package/dist/lib/agent-skills.js.map +1 -1
  345. package/dist/lib/attach-client.js +2 -2
  346. package/dist/lib/attach-client.js.map +1 -1
  347. package/dist/lib/backup-artifact.d.ts +29 -8
  348. package/dist/lib/backup-artifact.d.ts.map +1 -1
  349. package/dist/lib/backup-artifact.js +147 -26
  350. package/dist/lib/backup-artifact.js.map +1 -1
  351. package/dist/lib/broker-service.d.ts +27 -3
  352. package/dist/lib/broker-service.d.ts.map +1 -1
  353. package/dist/lib/broker-service.js +135 -27
  354. package/dist/lib/broker-service.js.map +1 -1
  355. package/dist/lib/broker-store-health.d.ts +89 -0
  356. package/dist/lib/broker-store-health.d.ts.map +1 -0
  357. package/dist/lib/broker-store-health.js +171 -0
  358. package/dist/lib/broker-store-health.js.map +1 -0
  359. package/dist/lib/cancel.d.ts +4 -4
  360. package/dist/lib/cancel.d.ts.map +1 -1
  361. package/dist/lib/cancel.js +5 -5
  362. package/dist/lib/cancel.js.map +1 -1
  363. package/dist/lib/completion-install.d.ts +11 -2
  364. package/dist/lib/completion-install.d.ts.map +1 -1
  365. package/dist/lib/completion-install.js +79 -21
  366. package/dist/lib/completion-install.js.map +1 -1
  367. package/dist/lib/completion-scripts.d.ts.map +1 -1
  368. package/dist/lib/completion-scripts.js +2 -2
  369. package/dist/lib/completion-scripts.js.map +1 -1
  370. package/dist/lib/completion.d.ts +5 -1
  371. package/dist/lib/completion.d.ts.map +1 -1
  372. package/dist/lib/completion.js +10 -0
  373. package/dist/lib/completion.js.map +1 -1
  374. package/dist/lib/concrete-channel.d.ts +6 -0
  375. package/dist/lib/concrete-channel.d.ts.map +1 -0
  376. package/dist/lib/concrete-channel.js +17 -0
  377. package/dist/lib/concrete-channel.js.map +1 -0
  378. package/dist/lib/confirmation-required.d.ts +3 -12
  379. package/dist/lib/confirmation-required.d.ts.map +1 -1
  380. package/dist/lib/confirmation-required.js +9 -8
  381. package/dist/lib/confirmation-required.js.map +1 -1
  382. package/dist/lib/connect.d.ts +9 -0
  383. package/dist/lib/connect.d.ts.map +1 -1
  384. package/dist/lib/connect.js +27 -0
  385. package/dist/lib/connect.js.map +1 -1
  386. package/dist/lib/control.d.ts +42 -12
  387. package/dist/lib/control.d.ts.map +1 -1
  388. package/dist/lib/control.js +130 -31
  389. package/dist/lib/control.js.map +1 -1
  390. package/dist/lib/controller-restore.d.ts.map +1 -1
  391. package/dist/lib/controller-restore.js +12 -7
  392. package/dist/lib/controller-restore.js.map +1 -1
  393. package/dist/lib/credential-authority.d.ts.map +1 -1
  394. package/dist/lib/credential-authority.js +3 -0
  395. package/dist/lib/credential-authority.js.map +1 -1
  396. package/dist/lib/credential-exports.d.ts +17 -0
  397. package/dist/lib/credential-exports.d.ts.map +1 -0
  398. package/dist/lib/credential-exports.js +21 -0
  399. package/dist/lib/credential-exports.js.map +1 -0
  400. package/dist/lib/debug-flag.d.ts +4 -0
  401. package/dist/lib/debug-flag.d.ts.map +1 -0
  402. package/dist/lib/debug-flag.js +7 -0
  403. package/dist/lib/debug-flag.js.map +1 -0
  404. package/dist/lib/default-persona.d.ts +2 -0
  405. package/dist/lib/default-persona.d.ts.map +1 -1
  406. package/dist/lib/default-persona.js +2 -0
  407. package/dist/lib/default-persona.js.map +1 -1
  408. package/dist/lib/delivery-proc.d.ts +1 -1
  409. package/dist/lib/delivery-proc.d.ts.map +1 -1
  410. package/dist/lib/delivery-proc.js +5 -4
  411. package/dist/lib/delivery-proc.js.map +1 -1
  412. package/dist/lib/delivery-responder.d.ts +7 -3
  413. package/dist/lib/delivery-responder.d.ts.map +1 -1
  414. package/dist/lib/delivery-responder.js +8 -4
  415. package/dist/lib/delivery-responder.js.map +1 -1
  416. package/dist/lib/denied-write.d.ts +8 -0
  417. package/dist/lib/denied-write.d.ts.map +1 -0
  418. package/dist/lib/denied-write.js +24 -0
  419. package/dist/lib/denied-write.js.map +1 -0
  420. package/dist/lib/endpoint-capability-gates.js +2 -2
  421. package/dist/lib/endpoint-capability-gates.js.map +1 -1
  422. package/dist/lib/flag-value-refusal.d.ts +8 -0
  423. package/dist/lib/flag-value-refusal.d.ts.map +1 -0
  424. package/dist/lib/flag-value-refusal.js +10 -0
  425. package/dist/lib/flag-value-refusal.js.map +1 -0
  426. package/dist/lib/install-umask.d.ts +5 -0
  427. package/dist/lib/install-umask.d.ts.map +1 -1
  428. package/dist/lib/install-umask.js +25 -0
  429. package/dist/lib/install-umask.js.map +1 -1
  430. package/dist/lib/interrupt-notice.d.ts +23 -1
  431. package/dist/lib/interrupt-notice.d.ts.map +1 -1
  432. package/dist/lib/interrupt-notice.js +27 -6
  433. package/dist/lib/interrupt-notice.js.map +1 -1
  434. package/dist/lib/interrupt-report.d.ts +7 -0
  435. package/dist/lib/interrupt-report.d.ts.map +1 -0
  436. package/dist/lib/interrupt-report.js +24 -0
  437. package/dist/lib/interrupt-report.js.map +1 -0
  438. package/dist/lib/isolated-broker.d.ts +1 -1
  439. package/dist/lib/isolated-broker.d.ts.map +1 -1
  440. package/dist/lib/isolated-broker.js +17 -8
  441. package/dist/lib/isolated-broker.js.map +1 -1
  442. package/dist/lib/legacy-start.d.ts +8 -6
  443. package/dist/lib/legacy-start.d.ts.map +1 -1
  444. package/dist/lib/legacy-start.js +36 -36
  445. package/dist/lib/legacy-start.js.map +1 -1
  446. package/dist/lib/manager-choice.d.ts +45 -4
  447. package/dist/lib/manager-choice.d.ts.map +1 -1
  448. package/dist/lib/manager-choice.js +214 -24
  449. package/dist/lib/manager-choice.js.map +1 -1
  450. package/dist/lib/manager-proc.d.ts.map +1 -1
  451. package/dist/lib/manager-proc.js +7 -6
  452. package/dist/lib/manager-proc.js.map +1 -1
  453. package/dist/lib/manifest/index.d.ts +5 -1
  454. package/dist/lib/manifest/index.d.ts.map +1 -1
  455. package/dist/lib/manifest/index.js +50 -5
  456. package/dist/lib/manifest/index.js.map +1 -1
  457. package/dist/lib/manifest/preflight.d.ts +4 -0
  458. package/dist/lib/manifest/preflight.d.ts.map +1 -1
  459. package/dist/lib/manifest/preflight.js +18 -1
  460. package/dist/lib/manifest/preflight.js.map +1 -1
  461. package/dist/lib/manifest/resolve.d.ts +8 -0
  462. package/dist/lib/manifest/resolve.d.ts.map +1 -1
  463. package/dist/lib/manifest/resolve.js +104 -11
  464. package/dist/lib/manifest/resolve.js.map +1 -1
  465. package/dist/lib/missing-flags.js +1 -1
  466. package/dist/lib/missing-flags.js.map +1 -1
  467. package/dist/lib/nats-bin.d.ts +28 -5
  468. package/dist/lib/nats-bin.d.ts.map +1 -1
  469. package/dist/lib/nats-bin.js +85 -7
  470. package/dist/lib/nats-bin.js.map +1 -1
  471. package/dist/lib/nearest-word.d.ts +14 -0
  472. package/dist/lib/nearest-word.d.ts.map +1 -0
  473. package/dist/lib/nearest-word.js +76 -0
  474. package/dist/lib/nearest-word.js.map +1 -0
  475. package/dist/lib/no-expiry-record.d.ts +8 -0
  476. package/dist/lib/no-expiry-record.d.ts.map +1 -0
  477. package/dist/lib/no-expiry-record.js +27 -0
  478. package/dist/lib/no-expiry-record.js.map +1 -0
  479. package/dist/lib/paths.d.ts +31 -0
  480. package/dist/lib/paths.d.ts.map +1 -1
  481. package/dist/lib/paths.js +92 -2
  482. package/dist/lib/paths.js.map +1 -1
  483. package/dist/lib/persona-files.d.ts +29 -6
  484. package/dist/lib/persona-files.d.ts.map +1 -1
  485. package/dist/lib/persona-files.js +179 -36
  486. package/dist/lib/persona-files.js.map +1 -1
  487. package/dist/lib/personas.d.ts +18 -1
  488. package/dist/lib/personas.d.ts.map +1 -1
  489. package/dist/lib/personas.js +65 -6
  490. package/dist/lib/personas.js.map +1 -1
  491. package/dist/lib/prompts.d.ts +7 -1
  492. package/dist/lib/prompts.d.ts.map +1 -1
  493. package/dist/lib/prompts.js +43 -3
  494. package/dist/lib/prompts.js.map +1 -1
  495. package/dist/lib/registry-errors.d.ts +2 -1
  496. package/dist/lib/registry-errors.d.ts.map +1 -1
  497. package/dist/lib/registry-errors.js +6 -2
  498. package/dist/lib/registry-errors.js.map +1 -1
  499. package/dist/lib/reset-space-plan.d.ts +2 -0
  500. package/dist/lib/reset-space-plan.d.ts.map +1 -1
  501. package/dist/lib/reset-space-plan.js +1 -1
  502. package/dist/lib/reset-space-plan.js.map +1 -1
  503. package/dist/lib/restore.d.ts +45 -3
  504. package/dist/lib/restore.d.ts.map +1 -1
  505. package/dist/lib/restore.js +233 -39
  506. package/dist/lib/restore.js.map +1 -1
  507. package/dist/lib/rolled-back-runs.d.ts +36 -0
  508. package/dist/lib/rolled-back-runs.d.ts.map +1 -0
  509. package/dist/lib/rolled-back-runs.js +96 -0
  510. package/dist/lib/rolled-back-runs.js.map +1 -0
  511. package/dist/lib/service-definitions.d.ts +16 -3
  512. package/dist/lib/service-definitions.d.ts.map +1 -1
  513. package/dist/lib/service-definitions.js +99 -27
  514. package/dist/lib/service-definitions.js.map +1 -1
  515. package/dist/lib/service-instances.d.ts +13 -1
  516. package/dist/lib/service-instances.d.ts.map +1 -1
  517. package/dist/lib/service-instances.js +56 -12
  518. package/dist/lib/service-instances.js.map +1 -1
  519. package/dist/lib/service-presets.d.ts.map +1 -1
  520. package/dist/lib/service-presets.js +16 -0
  521. package/dist/lib/service-presets.js.map +1 -1
  522. package/dist/lib/service-process.d.ts +51 -8
  523. package/dist/lib/service-process.d.ts.map +1 -1
  524. package/dist/lib/service-process.js +385 -48
  525. package/dist/lib/service-process.js.map +1 -1
  526. package/dist/lib/space-streams.d.ts +18 -0
  527. package/dist/lib/space-streams.d.ts.map +1 -0
  528. package/dist/lib/space-streams.js +35 -0
  529. package/dist/lib/space-streams.js.map +1 -0
  530. package/dist/lib/spawn-defaults.d.ts +25 -1
  531. package/dist/lib/spawn-defaults.d.ts.map +1 -1
  532. package/dist/lib/spawn-defaults.js +37 -1
  533. package/dist/lib/spawn-defaults.js.map +1 -1
  534. package/dist/lib/stack-journal.d.ts +157 -14
  535. package/dist/lib/stack-journal.d.ts.map +1 -1
  536. package/dist/lib/stack-journal.js +406 -49
  537. package/dist/lib/stack-journal.js.map +1 -1
  538. package/dist/lib/stack-listeners.d.ts +17 -0
  539. package/dist/lib/stack-listeners.d.ts.map +1 -0
  540. package/dist/lib/stack-listeners.js +54 -0
  541. package/dist/lib/stack-listeners.js.map +1 -0
  542. package/dist/lib/stack-members.d.ts +13 -0
  543. package/dist/lib/stack-members.d.ts.map +1 -0
  544. package/dist/lib/stack-members.js +24 -0
  545. package/dist/lib/stack-members.js.map +1 -0
  546. package/dist/lib/stack-resume.d.ts.map +1 -1
  547. package/dist/lib/stack-resume.js +5 -2
  548. package/dist/lib/stack-resume.js.map +1 -1
  549. package/dist/lib/stack-runs.d.ts +34 -0
  550. package/dist/lib/stack-runs.d.ts.map +1 -0
  551. package/dist/lib/stack-runs.js +75 -0
  552. package/dist/lib/stack-runs.js.map +1 -0
  553. package/dist/lib/status.d.ts +11 -0
  554. package/dist/lib/status.d.ts.map +1 -1
  555. package/dist/lib/status.js +4 -5
  556. package/dist/lib/status.js.map +1 -1
  557. package/dist/lib/stdout-owner.d.ts +12 -3
  558. package/dist/lib/stdout-owner.d.ts.map +1 -1
  559. package/dist/lib/stdout-owner.js +33 -5
  560. package/dist/lib/stdout-owner.js.map +1 -1
  561. package/dist/lib/store-dir.d.ts +68 -4
  562. package/dist/lib/store-dir.d.ts.map +1 -1
  563. package/dist/lib/store-dir.js +253 -17
  564. package/dist/lib/store-dir.js.map +1 -1
  565. package/dist/lib/team-additive-attempt.d.ts +1 -1
  566. package/dist/lib/team-channel-removal.d.ts.map +1 -1
  567. package/dist/lib/team-channel-removal.js +4 -0
  568. package/dist/lib/team-channel-removal.js.map +1 -1
  569. package/dist/lib/team-deploy-inspection.d.ts +13 -0
  570. package/dist/lib/team-deploy-inspection.d.ts.map +1 -1
  571. package/dist/lib/team-deploy-inspection.js +12 -0
  572. package/dist/lib/team-deploy-inspection.js.map +1 -1
  573. package/dist/lib/team-text.d.ts +6 -0
  574. package/dist/lib/team-text.d.ts.map +1 -0
  575. package/dist/lib/team-text.js +36 -0
  576. package/dist/lib/team-text.js.map +1 -0
  577. package/dist/lib/transient.d.ts +14 -8
  578. package/dist/lib/transient.d.ts.map +1 -1
  579. package/dist/lib/transient.js +72 -11
  580. package/dist/lib/transient.js.map +1 -1
  581. package/dist/lib/unusable-file.d.ts +13 -0
  582. package/dist/lib/unusable-file.d.ts.map +1 -0
  583. package/dist/lib/unusable-file.js +12 -0
  584. package/dist/lib/unusable-file.js.map +1 -0
  585. package/dist/lib/up-report.d.ts +6 -0
  586. package/dist/lib/up-report.d.ts.map +1 -1
  587. package/dist/lib/up-report.js +13 -0
  588. package/dist/lib/up-report.js.map +1 -1
  589. package/dist/lib/verdict.d.ts +14 -0
  590. package/dist/lib/verdict.d.ts.map +1 -0
  591. package/dist/lib/verdict.js +15 -0
  592. package/dist/lib/verdict.js.map +1 -0
  593. package/dist/managed-handoff.d.ts +11 -6
  594. package/dist/managed-handoff.d.ts.map +1 -1
  595. package/dist/managed-handoff.js +27 -18
  596. package/dist/managed-handoff.js.map +1 -1
  597. package/dist/render.d.ts +5 -2
  598. package/dist/render.d.ts.map +1 -1
  599. package/dist/render.js +44 -10
  600. package/dist/render.js.map +1 -1
  601. package/dist/telemetry.d.ts +4 -3
  602. package/dist/telemetry.d.ts.map +1 -1
  603. package/dist/telemetry.js +14 -6
  604. package/dist/telemetry.js.map +1 -1
  605. package/dist/ui.d.ts +3 -2
  606. package/dist/ui.d.ts.map +1 -1
  607. package/dist/ui.js +6 -4
  608. package/dist/ui.js.map +1 -1
  609. package/dist/view/mesh-view.d.ts.map +1 -1
  610. package/dist/view/mesh-view.js +4 -1
  611. package/dist/view/mesh-view.js.map +1 -1
  612. package/dist/watch-data.d.ts +9 -1
  613. package/dist/watch-data.d.ts.map +1 -1
  614. package/dist/watch-data.js +17 -3
  615. package/dist/watch-data.js.map +1 -1
  616. package/dist/watch-json.js +4 -3
  617. package/dist/watch-json.js.map +1 -1
  618. package/package.json +5 -5
@@ -2,24 +2,26 @@ import { spawn as spawnProcess } from "node:child_process";
2
2
  import { createHash } from "node:crypto";
3
3
  import { readFileSync, rmSync, statSync } from "node:fs";
4
4
  import { hostname } from "node:os";
5
- import { join, resolve as resolvePath } from "node:path";
6
- import { assertValidRole, agentFilePath, AgentGrantConflictError, connectorServers, spawnEnvAllow, deprovisionAgent, discardLaunchArtifacts, firstFreeName, isReachable, reclaimWithChild, loadCotalConfig, modelPolicyRefusal, mintCreds, newIdentity, DEV_OWNER, parseShareSelection, principalKey, mintLifecycleUid, MANAGED_HANDOFF_FILE_ENV, parseManagedLifecycleHandoff, spawnNameError, provisionAgent, provisionAgentDurables, registry, resolveAuthProvider, resolveReadAcl, runAgentBearer, CotalEndpoint, acquireLock, inspectLock, localConsumerClaimPath, transferBucket, writeTransfer, peerLabel, } from "@cotal-ai/core";
7
- import { CommandFailure, loadLaunchPersonaFile, personaFileReference, PersonaSourceError, inputDisabledByFlag, jsonFlag, plainFlag, presentationOf, renderReport, terminalWidth, writeResult, agentActorTokenKey, agentCredsKey, agentSecretFilePaths, agentSentinelCredsKey, authDir, cachedPreferences, credsFlag, launchFlags, loadMeshes, findMesh, getSpaceAuth, materializeSecretToFile, mergeLaunchOptions, parseLaunchOptions, preflightOrThrow, provenance, resolveAgentType, resolveMeshTarget, resolvePreference, resolveTargetOrThrow, serverFlag, spaceAccountPath, spaceFlag, spaceKey, userAuthStateDir, workspaceSecretStore, refreshRegistrationPolicy, resolveSeatControlTarget, connectUserControlOrExit, userViewAuth, oneLine, recordOperationSpace, } from "@cotal-ai/workspace";
8
- import { c } from "../ui.js";
5
+ import { resolve as resolvePath } from "node:path";
6
+ import { assertValidRole, agentFilePath, AgentGrantConflictError, connectorServers, spawnEnvAllow, deprovisionAgent, discardLaunchArtifacts, firstFreeName, isReachable, reclaimWithChild, loadCotalConfig, modelPolicyRefusal, mintCreds, newIdentity, DEV_OWNER, parseShareSelection, principalKey, assertLifecycleToken, mintLifecycleUid, MANAGED_HANDOFF_FILE_ENV, parseManagedLifecycleHandoff, spawnNameError, provisionAgent, provisionAgentDurables, registry, resolveAuthProvider, resolveReadAcl, runAgentBearer, CotalEndpoint, acquireLock, inspectLock, localConsumerClaimPath, transferBucket, writeTransfer, peerLabel, } from "@cotal-ai/core";
7
+ import { CommandFailure, loadLaunchPersonaFile, personaFileReference, PersonaSourceError, inputDisabledByFlag, jsonFlag, plainFlag, presentationOf, recordOperationWarning, renderReport, terminalWidth, wrapWords, writeResult, agentActorTokenKey, agentCredsKey, agentSecretFilePaths, agentSentinelCredsKey, authDir, cachedPreferences, credsFlag, launchFlags, findMesh, getSpaceAuth, materializeSecretToFile, mergeLaunchOptions, parseLaunchOptions, preflightOrThrow, provenance, resolveAgentType, resolvePreference, resolveTargetOrThrow, serverFlag, spaceAccountPath, spaceFlag, spaceKey, userAuthStateDir, workspaceSecretStore, refreshRegistrationPolicy, resolveSeatControlTarget, connectUserControlOrExit, userViewAuth, oneLine, DEFAULT_CONNECTOR, hintedConnector, manifestExtensionNames, OFFICIAL_CONNECTORS, recordOperationSpace, } from "@cotal-ai/workspace";
8
+ import { c, stderrLine } from "../ui.js";
9
9
  import { liveMeshNames } from "../lib/live-names.js";
10
10
  import { displayCmd } from "../lib/self-exec.js";
11
11
  import { entryScript } from "../seed/paths.js";
12
12
  import { completedFlagValue, completingFlagValue, hasCompletedFlagValue, positionalsForCompletion } from "../lib/completion.js";
13
13
  import { preflightOrExit, resolveTargetOrExit } from "../lib/connect.js";
14
- import { askManager, failIfNotOk, onInstance, onInstanceOrExit, resolveControlTarget, START_TIMEOUT_MS, withControlConnection } from "../lib/control.js";
15
- import { listDeclaredChannels, listDeclaredRoles, listPersonas } from "../lib/personas.js";
16
- import { callerHarness, spawnPersona } from "../lib/spawn-defaults.js";
17
- import { defaultPersonaFix } from "../lib/default-persona.js";
14
+ import { runningStackManagerPid, stackManagerAbsent, stackManagerStarting } from "../lib/stack-journal.js";
15
+ import { askManager, describeUnanswered, failIfNotOk, liveManagerIds, managerRailGone, onInstance, refuseUnregisteredManager, refuseWithoutLiveManager, resolveControlTarget, START_TIMEOUT_MS, withControlConnection } from "../lib/control.js";
16
+ import { managerPin, managersWithPersona, rerunOn } from "../lib/manager-choice.js";
17
+ import { listDeclaredChannels, listDeclaredRoles, listPersonaNames } from "../lib/personas.js";
18
+ import { personaCatalog } from "../lib/persona-files.js";
19
+ import { callerHarness, missingPersona, spawnPersona, spawnUsesManager } from "../lib/spawn-defaults.js";
18
20
  import { spawnLaunchPreview } from "./spawn-preview.js";
19
21
  import { protectedCredentialReference, readLocalRecordSource } from "../lib/protected-records.js";
20
22
  import { attachSeat } from "./agents.js";
21
23
  import { extensionNames, materializeExtension } from "../ext-loader.js";
22
- import { claimManagedHandoff, holdsManagedHandoff } from "../managed-handoff.js";
24
+ import { claimManagedHandoff, holdsManagedHandoff, managedHandoffRefusal } from "../managed-handoff.js";
23
25
  import { checkDialPolicy, checkEnforcement, checkServer, checkUserBundle, persistRemoteUserEntry, probeEnforcement, tlsIntent, userExchangeIssuer, verifyUserExchange, } from "./meshes-add.js";
24
26
  const ENROLLMENT_URL_ENV = "COTAL_ENROLLMENT_URL";
25
27
  const ENROLLMENT_FILE_ENV = "COTAL_ENROLLMENT_FILE";
@@ -64,6 +66,14 @@ export function scrubEnrollmentEnv(env) {
64
66
  delete env[key];
65
67
  }
66
68
  }
69
+ /** Carry the launching manager's validated `COTAL_MANAGER_INSTANCE` onto a managed-handoff
70
+ * child's connector launch spec (`spawnProcess` passes `env: spec.env` only, and `launchEnv`
71
+ * does not forward `COTAL_MANAGER_INSTANCE` from `process.env`). */
72
+ export function applyHandoffManagerInstance(spec, handoffManagerInstanceId) {
73
+ if (handoffManagerInstanceId !== undefined) {
74
+ spec.env = { ...spec.env, COTAL_MANAGER_INSTANCE: handoffManagerInstanceId };
75
+ }
76
+ }
67
77
  export function checkEnrollmentBundle(raw, actor) {
68
78
  const material = checkRemoteAgentMaterial(raw, actor);
69
79
  if (!material.ok)
@@ -170,8 +180,6 @@ async function registerEnrollmentMesh(stock, root, refusals) {
170
180
  * personas, not the cwd's. */
171
181
  export function spawnComplete(argv) {
172
182
  const flag = completingFlagValue(argv, spawnFlags);
173
- if (flag?.name === "space")
174
- return { items: loadMeshes().map((m) => ({ value: m.space })), directive: "nofiles" };
175
183
  if (flag?.name === "agent" || flag?.name === "harness")
176
184
  return { items: registry.all("connector").map((c) => ({ value: c.name })), directive: "nofiles" };
177
185
  if (flag?.name === "role")
@@ -180,12 +188,7 @@ export function spawnComplete(argv) {
180
188
  const current = argv[argv.length - 1] ?? "";
181
189
  if (current.includes("/") || current.includes("\\") || current.endsWith(".md"))
182
190
  return { items: [], directive: "default" };
183
- try {
184
- return { items: personaItems(argv), directive: "nofiles" };
185
- }
186
- catch {
187
- return { items: [], directive: "nofiles" };
188
- }
191
+ return { items: personaItems(argv), directive: "nofiles" };
189
192
  }
190
193
  if (flag && ["subscribe", "allow-subscribe", "allow-publish"].includes(flag.name))
191
194
  return { items: declaredFrom(argv, listDeclaredChannels).map((value) => ({ value, description: "declared channel" })), directive: "nofiles" };
@@ -195,24 +198,28 @@ export function spawnComplete(argv) {
195
198
  return { items: ["pty", ...extensionNames("runtime")].filter((value, i, all) => all.indexOf(value) === i).map((value) => ({ value })), directive: "nofiles" };
196
199
  const positionals = positionalsForCompletion(argv, spawnFlags);
197
200
  // Only the first word after `spawn` is the persona positional; once it's typed, defer to the shell.
198
- if (positionals.length <= 1 && !hasCompletedFlagValue(argv, spawnFlags, "config") && !hasCompletedFlagValue(argv, spawnFlags, "file")) {
199
- try {
200
- return { items: personaItems(argv), directive: "nofiles" };
201
- }
202
- catch {
203
- // No single target (no mesh, or several with no `current`) — fail CLOSED: offer no personas
204
- // rather than throw. `cotal spawn --space <TAB>` still lists the running meshes.
205
- return { items: [], directive: "nofiles" };
206
- }
207
- }
201
+ if (positionals.length <= 1 && !hasCompletedFlagValue(argv, spawnFlags, "config") && !hasCompletedFlagValue(argv, spawnFlags, "file"))
202
+ return { items: personaItems(argv), directive: "nofiles" };
208
203
  return { items: [], directive: "nofiles" };
209
204
  }
205
+ /** The persona catalog root this spawn would read, resolved read-only as `persona show` resolves it,
206
+ * so a prepared space that is not started still lists its personas. */
207
+ const catalogRoot = (argv) => personaCatalog({
208
+ space: completedFlagValue(argv, spawnFlags, "space"),
209
+ server: completedFlagValue(argv, spawnFlags, "server"),
210
+ }).root;
211
+ /** The personas this spawn would launch from. With no single target (no mesh, or several with no
212
+ * `current`) it fails CLOSED and offers none; `cotal spawn --space <TAB>` still lists the running
213
+ * meshes. A catalog folder that cannot be read throws, so the completion fails and names it. */
210
214
  function personaItems(argv) {
211
- const target = resolveMeshTarget(process.cwd(), {
212
- space: completedFlagValue(argv, spawnFlags, "space"),
213
- server: completedFlagValue(argv, spawnFlags, "server"),
214
- });
215
- return listPersonas(target.root).map((p) => ({ value: p.name }));
215
+ let root;
216
+ try {
217
+ root = catalogRoot(argv);
218
+ }
219
+ catch {
220
+ return [];
221
+ }
222
+ return listPersonaNames(root).map((value) => ({ value }));
216
223
  }
217
224
  /** Channels/roles declared by the TARGET mesh's personas — the same root {@link personaItems}
218
225
  * uses, so `--role`/`--subscribe` complete from the personas this spawn would actually launch
@@ -221,10 +228,7 @@ function personaItems(argv) {
221
228
  * offer nothing rather than throw into the operator's shell. */
222
229
  function declaredFrom(argv, list) {
223
230
  try {
224
- return list(resolveMeshTarget(process.cwd(), {
225
- space: completedFlagValue(argv, spawnFlags, "space"),
226
- server: completedFlagValue(argv, spawnFlags, "server"),
227
- }).root);
231
+ return list(catalogRoot(argv));
228
232
  }
229
233
  catch {
230
234
  return [];
@@ -265,40 +269,43 @@ async function provisionFreshForeground(requested, autoName, provision) {
265
269
  }
266
270
  }
267
271
  }
268
- /** `cotal spawn`'s grammar: managed launch/attach by default, explicit native foreground,
269
- * and one positional persona or explicit persona file. Declared `as const` so the values cast
272
+ /** `cotal spawn`'s grammar: the application in this terminal by default, a manager's launch only
273
+ * with `--detach` or `--on`, and one positional persona or explicit persona file. Declared `as const` so the values cast
270
274
  * below is compile-checked against exactly these specs. Foreground and detached parse the SAME
271
275
  * flags — the old `spawn` vs `start` ability drift is structurally gone. */
272
276
  export const spawnFlags = [
273
277
  spaceFlag,
274
278
  serverFlag,
275
- { ...credsFlag, description: "control-caller creds for an off-registry manager (managed launch only, not --foreground)" },
279
+ { ...credsFlag, description: "control-caller creds for an off-registry manager (with --detach or --on)" },
276
280
  ...launchFlags,
277
281
  { name: "harness", short: "H", type: "string", value: "<connector>", description: "application connector; an explicit flag wins over persona and saved defaults" },
278
- { name: "foreground", type: "boolean", description: "run the native application directly; terminal exit may end it" },
279
- { name: "restarts", type: "string", value: "<n>", description: "maximum manager-supervised restarts in the selected restart window" },
282
+ { name: "foreground", type: "boolean", description: "run the application in this terminal, as a spawn without --detach or --on does; terminal exit may end it" },
283
+ { name: "restarts", type: "string", value: "<n>", description: "with --detach or --on: maximum manager-supervised restarts in the selected restart window" },
280
284
  { name: "restart-window", type: "string", value: "<ms>", description: "time window for --restarts; both flags are required together" },
281
285
  jsonFlag, plainFlag,
282
- { name: "detach", type: "boolean", short: "d", description: "launch through the manager, await readiness and return without attaching" },
286
+ { name: "detach", type: "boolean", short: "d", description: "launch through a manager, await readiness and return without attaching" },
283
287
  { name: "live-only", type: "boolean", description: "foreground only: skip the durable backstop (no read-ACL row; messages missed while disconnected are not replayed)" },
284
288
  { name: "file", type: "string", short: "f", value: "<persona-file>", description: "persona file on the execution host; never a manifest deploy or implicit upload" },
285
289
  { name: "dry-run", type: "boolean", description: "preview the launch without allocation, provisioning or starting an application" },
286
- { name: "enrollment-file", type: "string", value: "<private-file>", description: "with --foreground: protected file holding this one seat's enrollment URL; never print or forward it" },
290
+ { name: "enrollment-file", type: "string", value: "<private-file>", description: "foreground only: protected file holding this one seat's enrollment URL; never print or forward it" },
287
291
  { name: "allow-stale", type: "string", value: "<a,b>", description: "refused: a manifest deployment option; use cotal team deploy <file>" },
288
292
  { name: "runtime", type: "string", value: "<name>", description: "refused: a manifest deployment option; use cotal team deploy <file>" },
289
- { name: "on", type: "string", value: "<instance>", description: "managed launch only: launch through one manager instance, by the id `ps` prints, in a space with several managers; by default any one takes it" },
293
+ { name: "on", type: "string", value: "<instance>", description: "launch through this manager instance, by the id `ps` prints, and attach; with --detach, return once it joins" },
290
294
  { name: "expect-owner", type: "string", value: "<u_…>", description: `with ${MANAGED_HANDOFF_FILE_ENV}: the owner the managed handoff must carry` },
291
295
  { name: "expect-lifecycle-uid", type: "string", value: "<uid>", description: `with ${MANAGED_HANDOFF_FILE_ENV}: the lifecycle UID the managed handoff must carry` },
292
296
  ];
293
297
  /** Check the public mode and spelling before catalog preparation or identity allocation. */
294
298
  export function validateSpawnArguments(args) {
295
299
  const values = args.values;
300
+ const handoffRefusal = managedHandoffRefusal();
301
+ if (handoffRefusal)
302
+ throw handoffRefusal;
296
303
  presentationOf(values);
297
304
  // `runCli` has already taken the handoff into custody and deleted its variable.
298
305
  const internal = holdsManagedHandoff() || Boolean(process.env[ENROLLMENT_URL_ENV] || process.env[ENROLLMENT_FILE_ENV]);
299
306
  if (!holdsManagedHandoff() && (values["expect-owner"] !== undefined || values["expect-lifecycle-uid"] !== undefined))
300
307
  throw new CommandFailure("refused", "USAGE_INVALID", `--expect-owner and --expect-lifecycle-uid apply only with ${MANAGED_HANDOFF_FILE_ENV}`);
301
- const direct = values.foreground === true || internal;
308
+ const direct = values.foreground === true || internal || !spawnUsesManager(values);
302
309
  if (values.file !== undefined && (args.positionals.length || values.config !== undefined))
303
310
  throw new CommandFailure("refused", "USAGE_INVALID", "choose one positional persona or --file/-f, not multiple explicit persona sources");
304
311
  if (!internal && values.config !== undefined)
@@ -315,21 +322,21 @@ export function validateSpawnArguments(args) {
315
322
  throw new CommandFailure("refused", "USAGE_INVALID", "manifest deployment options belong to cotal team deploy <file>, not spawn");
316
323
  if (values["enrollment-file"] !== undefined && !values.space)
317
324
  throw new CommandFailure("refused", "USAGE_INVALID", "--enrollment-file requires an explicit --space");
318
- if (values["enrollment-file"] !== undefined && !values.foreground)
319
- throw new CommandFailure("refused", "UNSUPPORTED", "this native enrollment path runs one foreground seat; use --foreground explicitly. It does not substitute for managed enrollment authority");
325
+ if (values["enrollment-file"] !== undefined && !direct)
326
+ throw new CommandFailure("refused", "UNSUPPORTED", "this native enrollment path runs one foreground seat. It does not substitute for managed enrollment authority");
320
327
  if (values["enrollment-file"] !== undefined && (internal || values.detach || values.creds !== undefined || values.on !== undefined))
321
328
  throw new CommandFailure("refused", "USAGE_INVALID", "choose one foreground enrollment source without a manager pin, credential override or internal handoff");
322
329
  if (values.harness !== undefined && values.agent !== undefined)
323
330
  throw new CommandFailure("refused", "USAGE_INVALID", "choose --harness/-H or the legacy --agent spelling, not both");
324
331
  if (values.detach && direct)
325
332
  throw new CommandFailure("refused", "USAGE_INVALID", "--detach and direct foreground execution are different launch modes");
326
- if (values.foreground && ((!values["dry-run"] && (values.json || values.plain)) || values.creds !== undefined || values.on !== undefined))
327
- throw new CommandFailure("refused", "USAGE_INVALID", "direct --foreground execution takes no structured receipt, manager credential or manager pin");
333
+ if (direct && ((!values["dry-run"] && (values.json || values.plain)) || values.creds !== undefined || values.on !== undefined))
334
+ throw new CommandFailure("refused", "USAGE_INVALID", "a spawn in this terminal takes no structured receipt, manager credential or manager pin", { remedy: "add -d to launch it through a manager, which returns a receipt once the agent joins", selfContained: true });
328
335
  if ((values.restarts === undefined) !== (values["restart-window"] === undefined))
329
336
  throw new CommandFailure("refused", "USAGE_INVALID", "--restarts and --restart-window must be supplied together");
330
337
  if (values.restarts !== undefined) {
331
338
  if (direct)
332
- throw new CommandFailure("refused", "USAGE_INVALID", "restart supervision belongs to a managed launch, not direct foreground execution");
339
+ throw new CommandFailure("refused", "USAGE_INVALID", "restart supervision belongs to a managed launch, not a spawn in this terminal", { remedy: "add -d, or --on <instance>, to launch it through a manager" });
333
340
  for (const field of ["restarts", "restart-window"])
334
341
  if (!/^[1-9][0-9]*$/.test(values[field]) || !Number.isSafeInteger(Number(values[field])))
335
342
  throw new CommandFailure("refused", "USAGE_INVALID", `--${field} must be a positive safe integer`);
@@ -337,7 +344,7 @@ export function validateSpawnArguments(args) {
337
344
  if (values["live-only"] && !direct)
338
345
  throw new CommandFailure("refused", "USAGE_INVALID", "--live-only belongs to direct foreground execution");
339
346
  if (!values["dry-run"] && !direct && !values.detach && (values.json || values.plain || inputDisabledByFlag() || !process.stdin.isTTY || !process.stdout.isTTY))
340
- throw new CommandFailure("refused", "USAGE_INVALID", "managed attachment needs usable input and output terminals before an identity is allocated", { remedy: "use cotal spawn -d to wait for readiness without attaching, or --foreground for direct execution" });
347
+ throw new CommandFailure("refused", "USAGE_INVALID", "attaching to a manager's launch needs usable input and output terminals before an identity is allocated", { remedy: "add -d to wait for readiness without attaching, or drop --on to run it in this terminal", selfContained: true });
341
348
  for (const field of ["harness", "agent", "model", "variant", "name"])
342
349
  if (values[field] !== undefined && !values[field].trim())
343
350
  throw new CommandFailure("refused", "USAGE_INVALID", `--${field} cannot be empty`);
@@ -377,6 +384,22 @@ export function validateSpawnArguments(args) {
377
384
  export function spawnRequiredExtensions(_args) {
378
385
  return [];
379
386
  }
387
+ /** Whether the installed manifest lists a connector named `name`. An unreadable manifest answers
388
+ * true, so the import's own refusal reports it. */
389
+ function connectorListed(name) {
390
+ try {
391
+ return manifestExtensionNames("connector").includes(name);
392
+ }
393
+ catch {
394
+ return true;
395
+ }
396
+ }
397
+ /** The refusal for a harness with no installed connector, naming the package when it is official. */
398
+ function missingConnector(name, target) {
399
+ const pkg = OFFICIAL_CONNECTORS[name];
400
+ return new CommandFailure("refused", "DEPENDENCY_UNAVAILABLE", `no connector "${name}" is installed`, { target,
401
+ remedy: pkg ? `add it with \`cotal ext add ${pkg}\`` : "install its integration with `cotal ext add <npm-package>`, or check the name" });
402
+ }
380
403
  /** Comma-list flag → string[] (shared by both spawn modes). Only an absent flag is `undefined` and
381
404
  * defers to the persona; an empty value is the empty list, so `--subscribe ""` clears it. */
382
405
  const splitFlag = (v) => (v === undefined ? undefined : v.split(",").map((s) => s.trim()).filter(Boolean));
@@ -389,16 +412,29 @@ const splitFlag = (v) => (v === undefined ? undefined : v.split(",").map((s) =>
389
412
  function refuseUnmintableNameOrExit(name, userMode) {
390
413
  const refusal = spawnNameError(name, { userMode });
391
414
  if (refusal) {
392
- console.error(c.red(`✗ ${refusal}`));
415
+ stderrLine("✗ ", `${refusal}`, c.red);
393
416
  process.exit(1);
394
417
  }
395
418
  }
396
- function managedLaunchView(r) {
419
+ /** The manager's `acl` launch field: null when the manager sent none, undefined when it cannot be read. */
420
+ export function managedLaunchAcl(value) {
421
+ if (value === undefined)
422
+ return null;
423
+ const lists = (raw) => {
424
+ const { allowSubscribe, allowPublish } = (raw ?? {});
425
+ const channels = (list) => Array.isArray(list) && list.every((channel) => typeof channel === "string");
426
+ return channels(allowSubscribe) && channels(allowPublish) ? { allowSubscribe: [...allowSubscribe], allowPublish: [...allowPublish] } : undefined;
427
+ };
428
+ const requested = lists(value?.requested), effective = lists(value?.effective);
429
+ return requested && effective ? { requested, effective } : undefined;
430
+ }
431
+ const channelList = (channels) => channels.length ? channels.join(", ") : "none";
432
+ export function managedLaunchView(r) {
397
433
  const concrete = [r.name, r.space, r.managerInstanceId].every((value) => /^[A-Za-z0-9_-]+$/.test(value));
398
434
  const target = concrete ? `${r.name} --space ${r.space} --on ${r.managerInstanceId}` : "<name> --space <space> --on <manager-instance>";
399
435
  return { sections: [
400
436
  { title: "Agent joined", blocks: [
401
- { kind: "fields", rows: [["Agent", r.name], ["Identity", r.id], ["Lifecycle", r.lifecycleUid], ["Space", r.space], ["Manager receipt", r.managerInstanceId], ["Original request", r.intent?.requestId ?? r.request?.requestId ?? "not recorded"], ["Accepted goal", r.request?.goalId ?? "not reported"], ["Application", r.harness], ["Runtime", r.runtime], ["Role", r.role ?? "not recorded"], ["Model request", r.requestedModel ?? "persona/manager precedence; not inspected"], ["View", r.detached ? "not attached" : "attaching to the allocated incarnation"]] },
437
+ { kind: "fields", rows: [["Agent", r.name], ["Identity", r.id], ["Lifecycle", r.lifecycleUid], ["Space", r.space], ["Manager receipt", r.managerInstanceId], ["Original request", r.intent?.requestId ?? r.request?.requestId ?? "not recorded"], ["Accepted goal", r.request?.goalId ?? "not reported"], ["Application", r.harness], ["Runtime", r.runtime], ["Role", r.role ?? "not recorded"], ...(r.acl ? [["Granted", `read ${channelList(r.acl.effective.allowSubscribe)} · post ${channelList(r.acl.effective.allowPublish)}; asked for read ${channelList(r.acl.requested.allowSubscribe)} · post ${channelList(r.acl.requested.allowPublish)}`]] : []), ["Model request", r.requestedModel ?? "persona/manager precedence; not inspected"], ["View", r.detached ? "not attached" : "attaching to the allocated incarnation"]] },
402
438
  { kind: "lines", lines: [{ text: "The manager confirmed presence readiness. This is not proof that the kickoff task completed.", tone: "hint" }] },
403
439
  ] },
404
440
  ...(r.detached ? [{ title: "Next", blocks: [{ kind: "commands", items: [
@@ -414,7 +450,7 @@ export async function launchManagedPersona(values, positionals, events, launchOp
414
450
  // `COTAL_DEFAULT_PERSONA` > `default`). Identity is separate:
415
451
  // when `--name` is given it OVERRIDES the file's `name:` (foreground's `requested`), threaded
416
452
  // as the op's `identity` so it is never silently dropped in detached mode.
417
- const on = onInstance(values.on, "cotal spawn <persona>");
453
+ const on = await managerPin(values, "cotal spawn <persona>");
418
454
  // From a managed seat's own shell the launch is the SEAT's, as its `cotal_spawn` tool is: the
419
455
  // manager records the seat as the spawner, so the seat can stop the child it asked for (#718).
420
456
  // `--on` keeps the pin on that path too.
@@ -451,7 +487,11 @@ export async function launchManagedPersona(values, positionals, events, launchOp
451
487
  if (eventsRequired && events === false) {
452
488
  throw new CommandFailure("refused", "PERMISSION_DENIED", `space "${t.space}" requires the event plane by registration policy; no launch was submitted`);
453
489
  }
454
- provenance.read("mesh", `${t.space} (${t.server})`);
490
+ if (on === undefined && !t.auth.bearer)
491
+ await refuseWithoutLiveManager(t.space, t.server, t.auth, { space: t.space, managerInstanceId: null, managerEpoch: null }, "launch an agent");
492
+ // A pin the registry does not list is refused at once; only a registered manager is waited on.
493
+ if (on !== undefined && !t.auth.bearer)
494
+ await refuseUnregisteredManager(t.space, t.server, t.auth, on);
455
495
  const { ref, from: personaFrom } = spawnPersona(values.config, positionals, { space: t.space, preferences: cachedPreferences() });
456
496
  const managerConfigRef = values.config ?? (personaFrom !== undefined ? ref : undefined);
457
497
  const defaultAgent = callerHarness(t.space);
@@ -463,8 +503,11 @@ export async function launchManagedPersona(values, positionals, events, launchOp
463
503
  resumeAgent = values.agent ?? await launchAgentOrExit(t, on, { name: ref, config: managerConfigRef, defaultAgent });
464
504
  resumeClaim = await carryTranscriptOrExit(flags, on, values.resume, resumeAgent);
465
505
  }
466
- console.error(renderReport({ space: t.space, sections: [{ title: "Managed launch", blocks: [{ kind: "fields", rows: [["Space", t.space], ["Manager selector", on ?? t.auth.managerInstanceId ?? "native class selection"], ["Persona", ref], ["File source", managerConfigRef ? `${managerConfigRef} · manager execution host` : "selected manager's persona catalog"], ["File transfer", "none"]] }, { kind: "lines", lines: [{ text: "The accepting manager validates its own visible file before allocation. No local file is uploaded, and a pin never selects a replacement manager.", tone: "hint" }] }] }] }, presentationOf(values) === "plain" ? "plain" : "rich", terminalWidth(process.stderr)));
467
- console.error(c.dim("waiting for it to join the mesh (the manager replies on a real outcome - join, exit, or ~30s) …"));
506
+ // The report that answers names the mesh in its heading, so this block names it once, in a field.
507
+ const toStdout = !observer && presentationOf(values) !== "json";
508
+ (toStdout ? console.log : console.error)(renderReport({ sections: [{ title: "Managed launch", blocks: [{ kind: "fields", rows: [["Space", t.space], ["Manager selector", on ?? t.auth.managerInstanceId ?? "native class selection"], ["Persona", ref], ["File source", managerConfigRef ? `${managerConfigRef} · manager execution host` : "selected manager's persona catalog"], ["File transfer", "none"]] }, { kind: "lines", lines: [{ text: "The accepting manager validates its own visible file before allocation. No local file is uploaded, and a pin never selects a replacement manager.", tone: "hint" }] }] }] }, presentationOf(values) === "plain" ? "plain" : "rich", terminalWidth(toStdout ? process.stdout : process.stderr)));
509
+ for (const line of wrapWords("waiting for the manager: it answers when it refuses the launch, or when the agent joins or exits (at most about 30s) …", terminalWidth(process.stderr)))
510
+ console.error(c.dim(line));
468
511
  const reply = await askManager(t.space, t.server, "start", {
469
512
  name: ref,
470
513
  identity: values.name,
@@ -502,15 +545,42 @@ export async function launchManagedPersona(values, positionals, events, launchOp
502
545
  const refusal = { "permission-denied": "PERMISSION_DENIED", "unauthenticated": "AUTH_REQUIRED", "not-found": "TARGET_NOT_FOUND", "unavailable": "TARGET_UNAVAILABLE", "bad-request": "SCHEMA_INVALID", "failed-precondition": "LIFECYCLE_BLOCKED", "already-exists": "CONFLICT", "unimplemented": "UNSUPPORTED" };
503
546
  const code = reply.code === undefined ? undefined : refusal[reply.code];
504
547
  const native = { code: reply.code, outcome: reply.nativeOutcome, ...(reply.request || reply.intent ? { detail: { request: reply.request ?? null, intent: reply.intent ?? null, observation: reply.observationCause ?? null } } : {}) };
505
- if (reply.nativeOutcome === "not-executed" && code)
506
- throw new CommandFailure("refused", code, reply.error ? oneLine(reply.error) : "the manager refused the launch before execution", { target, native, remedy: "nothing was launched; fix what the manager reported, then run the spawn again" });
548
+ // The broker attested that no manager received an unpinned launch: none takes the class queue.
549
+ if (on === undefined && !t.auth.bearer && reply.unanswered && reply.nativeOutcome === "not-executed")
550
+ throw await unservedClassLaunch(seat ? undefined : flags, t, values.agent ?? defaultAgent, { target, native });
551
+ // A pinned describe that drew no answer means the launch was never sent, as ps and stop --on say.
552
+ if (on !== undefined && describeUnanswered(reply))
553
+ throw new CommandFailure("refused", "TARGET_UNAVAILABLE", `manager instance ${on} did not answer, so the launch was not sent and nothing was launched`, { target, native: { code: reply.code, ...(reply.error ? { detail: oneLine(reply.error) } : {}) }, remedy: "cotal ps shows which managers answer; rerun the spawn on one of them with --on <instance>" });
554
+ // So does an unpinned one: no manager answered, and the launch was never published.
555
+ if (on === undefined && describeUnanswered(reply))
556
+ throw unansweredClassLaunch(t, { target, native: { code: reply.code, ...(reply.error ? { detail: oneLine(reply.error) } : {}) } });
557
+ // A manager without the connector: it is added where that manager runs, not on this machine.
558
+ const absent = reply.nativeOutcome === "not-executed" && reply.error !== undefined ? hintedConnector(reply.error) : undefined;
559
+ if (absent !== undefined) {
560
+ const answered = reply.managerInstanceId ?? on;
561
+ throw new CommandFailure("refused", "DEPENDENCY_UNAVAILABLE", `no connector "${absent}" is installed on ${answered ? await managerNamed(seat ? undefined : flags, t, answered) : "the manager"}; nothing was launched`, { target, native,
562
+ remedy: `add it where that manager runs, such as ${extAddFor(absent)}, then restart that manager; it reads its agent applications when it starts` });
563
+ }
564
+ if (reply.nativeOutcome === "not-executed" && code) {
565
+ // A manager without the persona: it is created on that manager's host, or the spawn goes to
566
+ // another live manager whose catalog has it.
567
+ const missing = managerConfigRef === undefined && reply.error?.startsWith(`no persona "${ref}"`) === true;
568
+ const elsewhere = missing ? await managersWithPersona(flags, reply.managerInstanceId ?? on, ref).catch(() => []) : [];
569
+ throw new CommandFailure("refused", code, reply.error ? oneLine(reply.error) : "the manager refused the launch before execution", { target, native, remedy: elsewhere.length
570
+ ? `nothing was launched; ${elsewhere.length === 1 ? "this manager of yours has" : "these managers of yours have"} ${ref === "default" ? "a default persona" : `persona "${ref}"`}: ${elsewhere.map((selector) => rerunOn(process.argv.slice(2), selector)).join(" or ")}`
571
+ : missing ? "nothing was launched; create that file on the manager's host, then run the spawn again"
572
+ : "nothing was launched; fix what the manager reported, then run the spawn again" });
573
+ }
507
574
  const unknown = reply.nativeOutcome !== "executed" || reply.unanswered;
508
575
  throw new CommandFailure(unknown ? "unknown" : "failed", unknown ? "OPERATION_UNKNOWN" : "OPERATION_FAILED", reply.error ? oneLine(reply.error) : "the manager did not confirm launch readiness", { target, native, remedy: "inspect cotal ps and the selected manager before retrying; this launch was not submitted again" });
509
576
  }
510
577
  const d = reply.data;
511
578
  if (!d || typeof d.name !== "string" || typeof d.id !== "string" || typeof d.lifecycleUid !== "string" || typeof d.agent !== "string" || typeof d.mode !== "string" || !reply.managerInstanceId)
512
579
  throw new CommandFailure("partial", "OPERATION_PARTIAL", "the manager reported a successful launch but did not supply the identity and manager needed for a safe handoff", { target, changed: [{ kind: "managed-launch", readinessReported: true }], remedy: "inspect cotal ps before doing anything else; do not relaunch" });
513
- const result = { kind: "managed-launch", name: d.name, id: d.id, lifecycleUid: d.lifecycleUid, space: t.space, managerInstanceId: reply.managerInstanceId, harness: d.agent, runtime: d.mode, role: d.role ?? null, request: reply.request ?? null, intent: reply.intent ?? null, readiness: "joined", requestedModel: values.model ?? null, detached: values.detach === true };
580
+ const acl = managedLaunchAcl(d.acl);
581
+ if (acl === undefined)
582
+ throw new CommandFailure("partial", "OPERATION_PARTIAL", "the agent joined, but the manager's report of the channels its host granted could not be read; no replacement was launched", { target, changed: [{ kind: "managed-launch", readinessReported: true }], remedy: "inspect cotal ps before doing anything else; do not relaunch" });
583
+ const result = { kind: "managed-launch", name: d.name, id: d.id, lifecycleUid: d.lifecycleUid, space: t.space, managerInstanceId: reply.managerInstanceId, harness: d.agent, runtime: d.mode, role: d.role ?? null, request: reply.request ?? null, intent: reply.intent ?? null, readiness: "joined", requestedModel: values.model ?? null, detached: values.detach === true, acl };
514
584
  const presentation = presentationOf(values);
515
585
  const warnings = d.eventsNotice ? [{ code: "EVENT_PLANE_NOTICE", target, message: d.eventsNotice }] : [];
516
586
  if (observer) {
@@ -538,6 +608,77 @@ export async function launchManagedPersona(values, positionals, events, launchOp
538
608
  throw new CommandFailure("partial", "OPERATION_PARTIAL", "the agent joined, but its exact native terminal was unavailable before setup could open the view; no replacement was launched", { target, changed: [result], remedy: "inspect the original lifecycle and manager before another startup" });
539
609
  console.error(renderReport({ sections: [{ title: verdict.kind === "gone" ? "Attach target unavailable" : verdict.reason === "detached" ? "Detached" : "Attach session ended", blocks: [{ kind: "fields", rows: [["Agent", d.name], ["Identity", d.id], ["Manager", reply.managerInstanceId]] }, { kind: "lines", lines: [{ text: "Leaving the view sent no stop request. The original lifecycle was not replaced.", tone: "hint" }] }] }] }, "rich", terminalWidth(process.stderr)));
540
610
  }
611
+ /** Why no manager received an unpinned launch. A manager whose boot inventory found no agent
612
+ * application leaves the class queue, so when every live one that answered reports that on its own
613
+ * instance rail the refusal names the application to add. A manager the broker affirms gone is
614
+ * skipped and named in a warning, so its registration costs no deadline and hides no reason. A seat
615
+ * (`flags` undefined) does not read the census as the operator. `agent` is the harness this caller
616
+ * would choose, for the install hint. */
617
+ async function unservedClassLaunch(flags, t, agent, at) {
618
+ const census = flags ? await classLaunchCensus(flags, t).catch(() => undefined) : undefined;
619
+ for (const instanceId of census?.gone ?? [])
620
+ recordOperationWarning({ code: "MANAGER_SILENT", target: { space: t.space, managerInstanceId: instanceId }, message: `manager ${instanceId} was skipped: its registration is stale (the broker reports nothing subscribed on its rail; its host is gone and never deregistered)` });
621
+ if (census?.noApplication) {
622
+ return new CommandFailure("refused", "DEPENDENCY_UNAVAILABLE", `no manager of yours takes unpinned launches: none ${census.gone.length ? "that answered " : ""}has an agent application installed${census.managers.length ? ` (${census.managers.join(", ")})` : ""}; nothing was launched`, { ...at,
623
+ remedy: `add one where ${census.managers.length > 1 ? "one of them" : "that manager"} runs, such as ${extAddFor(agent ?? DEFAULT_CONNECTOR)}, then restart that manager; it reads its agent applications when it starts` });
624
+ }
625
+ return new CommandFailure("refused", "TARGET_UNAVAILABLE", "no manager of yours received this unpinned launch; nothing was launched", { ...at, remedy: "run the spawn again, or pin one manager with --on <instance> from cotal ps" });
626
+ }
627
+ /** Why no manager answered an unpinned launch's describe, so the launch was never sent. This root's
628
+ * own stack says why when it records one, in the words `ps` uses for the same silence. */
629
+ function unansweredClassLaunch(t, at) {
630
+ const refused = (message, remedy) => new CommandFailure("refused", "TARGET_UNAVAILABLE", `${message}, so the launch was not sent and nothing was launched`, { ...at, remedy });
631
+ if (t.root !== undefined && stackManagerStarting(t.root, t.space))
632
+ return refused("the stack's manager is starting", "run the spawn again once cotal up reports the manager started");
633
+ if (t.root !== undefined && stackManagerAbsent(t.root, t.space))
634
+ return refused("no manager is running for this space", "start the stack's manager with bare cotal up; a stack started with --no-manager has none");
635
+ const pid = t.root === undefined ? undefined : runningStackManagerPid(t.root, t.space);
636
+ if (pid !== undefined)
637
+ return refused(`this space's stack manager (pid ${pid}) is running but did not answer`, `if it stays unresponsive, end that process with kill -KILL ${pid}; then bare cotal up starts the manager again`);
638
+ return refused("no manager answered", "cotal ps shows which managers answer; run the spawn again once one does");
639
+ }
640
+ /** What the registered managers say about unpinned launches. `noApplication` holds when one answered
641
+ * and each one that answered says it runs agents but takes no unpinned launch; `gone` lists the
642
+ * managers skipped because the broker affirms nothing subscribed on their rail. Status has no
643
+ * scatter route, so each is read pinned to its instance, racing the rail probe: whichever settles
644
+ * first stops the other, so neither a live manager nor a gone one is waited out. */
645
+ async function classLaunchCensus(flags, t) {
646
+ const gone = [];
647
+ const managers = [];
648
+ for (const instanceId of await liveManagerIds(t.space, t.server, t.auth)) {
649
+ const pinned = await resolveControlTarget(flags, "control-caller-privileged", instanceId, { onRefusal: "throw" });
650
+ const settled = new AbortController();
651
+ const status = await Promise.race([
652
+ managerRailGone(pinned.space, pinned.server, pinned.auth, instanceId, settled.signal).then((isGone) => isGone ? undefined : new Promise(() => { })),
653
+ askManager(pinned.space, pinned.server, "managerStatus", undefined, pinned.auth, "owner", 5_000, { instanceId, signal: settled.signal }),
654
+ ]).finally(() => settled.abort());
655
+ if (status === undefined) {
656
+ gone.push(instanceId);
657
+ continue;
658
+ }
659
+ const data = status.data;
660
+ if (!status.ok || data?.classSpawn !== false || data.execution === "none")
661
+ return { noApplication: false, gone, managers };
662
+ managers.push(managerAt(instanceId, data.host));
663
+ }
664
+ return { noApplication: managers.length > 0, gone, managers };
665
+ }
666
+ /** A manager as a refusal names it: its instance id, and the host its own status reports. */
667
+ const managerAt = (instanceId, host) => typeof host === "string" && host ? `manager ${instanceId} on host ${host}` : `manager ${instanceId}`;
668
+ /** {@link managerAt} for one manager, read pinned to it. A seat (`flags` undefined) reads with its
669
+ * own caller, and a status that cannot be read leaves the host out. */
670
+ async function managerNamed(flags, t, instanceId) {
671
+ try {
672
+ const pinned = flags ? await resolveControlTarget(flags, "control-caller-privileged", instanceId, { onRefusal: "throw" }) : t;
673
+ const status = await askManager(pinned.space, pinned.server, "managerStatus", undefined, pinned.auth, "owner", 5_000, { instanceId });
674
+ return managerAt(instanceId, status.ok ? status.data?.host : undefined);
675
+ }
676
+ catch {
677
+ return managerAt(instanceId, undefined);
678
+ }
679
+ }
680
+ /** The `cotal ext add` that installs connector `name`, quoted for a refusal. */
681
+ const extAddFor = (name) => OFFICIAL_CONNECTORS[name] ? `\`cotal ext add ${OFFICIAL_CONNECTORS[name]}\`` : `\`cotal ext add <npm-package>\` for "${name}"`;
541
682
  /** The harness the manager's `spawn` resolves for this persona, read with the same fields `start` sends. */
542
683
  async function launchAgentOrExit(t, on, fields) {
543
684
  const reply = await askManager(t.space, t.server, "resolveAgent", fields, t.auth, "owner", undefined, { instanceId: on });
@@ -558,13 +699,13 @@ async function carryTranscriptOrExit(flags, on, id, agent) {
558
699
  found = registry.resolve("connector", agent).resumeTranscript?.find(id, process.env);
559
700
  }
560
701
  catch (e) {
561
- console.error(c.red(`✗ resume: ${e.message}`));
702
+ stderrLine("✗ ", `resume: ${e.message}`, c.red);
562
703
  process.exit(1);
563
704
  }
564
705
  if (found === undefined)
565
706
  return undefined;
566
707
  if (on === undefined) {
567
- console.error(c.red(`✗ resume: session ${id} is held on this host, and carrying it needs one manager instance; pass --on <instance>`));
708
+ stderrLine("✗ ", `resume: session ${id} is held on this host, and carrying it needs one manager instance; pass --on <instance>`, c.red);
568
709
  process.exit(1);
569
710
  }
570
711
  const bytes = readFileSync(found.path);
@@ -604,20 +745,21 @@ async function transferWriterOrExit(flags, t, instanceId, hex) {
604
745
  return { bearer: view.bearer, sentinelCreds: view.sentinelCreds, tls: conn.tls };
605
746
  }
606
747
  catch (e) {
607
- console.error(c.red(`✗ resume: ${e.message}`));
748
+ stderrLine("✗ ", `resume: ${e.message}`, c.red);
608
749
  process.exit(1);
609
750
  }
610
751
  }
611
752
  if (t.mode !== "auth" || !t.spaceAuth) {
612
- console.error(c.red("✗ resume: carrying a session mints a transfer writer from this mesh's signing seed, and this host holds none for it (an off-registry connection)"));
753
+ stderrLine("✗ ", "resume: carrying a session mints a transfer writer from this mesh's signing seed, and this host holds none for it (an off-registry connection)", c.red);
613
754
  process.exit(1);
614
755
  }
615
756
  return { creds: await mintCreds(t.spaceAuth, newIdentity(), "transfer-writer", { transferWriter: { instanceId, hex } }), tls: t.auth.tls };
616
757
  }
617
758
  /**
618
- * `cotal spawn [<persona>] [--file <persona-file>]` launches through the manager and attaches
619
- * to its allocated incarnation. `--detach` returns after readiness; `--foreground` explicitly
620
- * runs the native application in this terminal. File validation belongs to that execution host.
759
+ * `cotal spawn [<persona>] [--file <persona-file>]` runs the native application in this terminal.
760
+ * `--detach` launches it through a manager and returns after readiness, and `--on <instance>`
761
+ * launches it through that manager and attaches to its allocated incarnation. File validation
762
+ * belongs to the execution host.
621
763
  *
622
764
  * The launch recipe is the connector's `buildLaunch` (the single source of truth,
623
765
  * shared with the manager); only *how the spec runs* differs — foreground exec
@@ -670,25 +812,28 @@ export async function spawn(args) {
670
812
  scrubEnrollmentEnv(process.env);
671
813
  }
672
814
  let redeemedEnrollment;
815
+ let handoffManagerInstanceId;
673
816
  if (handoffText !== undefined) {
674
817
  const refusal = enrollmentUrl ? `${MANAGED_HANDOFF_FILE_ENV} cannot be combined with ${ENROLLMENT_URL_ENV}/${ENROLLMENT_FILE_ENV}`
675
818
  : values.detach || values.file || values.creds ? `${MANAGED_HANDOFF_FILE_ENV} applies only to a foreground persona spawn without --creds`
676
819
  : !values.space || !values.name || !values["expect-owner"] || !values["expect-lifecycle-uid"]
677
820
  ? `${MANAGED_HANDOFF_FILE_ENV} requires --space, --name, --expect-owner and --expect-lifecycle-uid`
678
821
  : !values.config ? `${MANAGED_HANDOFF_FILE_ENV} requires --config <persona-file>`
679
- : undefined;
822
+ : !process.env.COTAL_MANAGER_INSTANCE?.trim() ? `${MANAGED_HANDOFF_FILE_ENV} requires COTAL_MANAGER_INSTANCE`
823
+ : undefined;
680
824
  if (refusal) {
681
- console.error(c.red(`✗ ${refusal}`));
825
+ stderrLine("✗ ", `${refusal}`, c.red);
682
826
  process.exit(1);
683
827
  }
684
828
  try {
685
829
  loadLaunchPersonaFile(resolvePath(values.config));
686
830
  }
687
831
  catch (e) {
688
- console.error(c.red(`✗ cannot load the managed handoff persona: ${e.message}`));
832
+ stderrLine("✗ ", `cannot load the managed handoff persona: ${e.message}`, c.red);
689
833
  process.exit(1);
690
834
  }
691
835
  try {
836
+ handoffManagerInstanceId = assertLifecycleToken(process.env.COTAL_MANAGER_INSTANCE.trim(), "COTAL_MANAGER_INSTANCE");
692
837
  const handoff = parseManagedLifecycleHandoff(handoffText, {
693
838
  space: values.space, owner: values["expect-owner"], actor: values.name, lifecycleUid: values["expect-lifecycle-uid"],
694
839
  });
@@ -711,37 +856,37 @@ export async function spawn(args) {
711
856
  await registerEnrollmentMesh(stock, resolvePath(values.config, ".."), HANDOFF_REFUSALS);
712
857
  }
713
858
  catch (e) {
714
- console.error(c.red(`✗ ${e.message}`));
859
+ stderrLine("✗ ", `${e.message}`, c.red);
715
860
  process.exit(1);
716
861
  }
717
862
  }
718
863
  if (enrollmentUrl && values.detach) {
719
- console.error(c.red(`✗ ${ENROLLMENT_URL_ENV}/${ENROLLMENT_FILE_ENV} apply only to a foreground persona spawn`));
864
+ stderrLine("✗ ", `${ENROLLMENT_URL_ENV}/${ENROLLMENT_FILE_ENV} apply only to a foreground persona spawn`, c.red);
720
865
  process.exit(1);
721
866
  }
722
867
  if (enrollmentUrl && !values.space) {
723
- console.error(c.red(`✗ ${ENROLLMENT_URL_ENV}/${ENROLLMENT_FILE_ENV} require --space <s>`));
868
+ stderrLine("✗ ", `${ENROLLMENT_URL_ENV}/${ENROLLMENT_FILE_ENV} require --space <s>`, c.red);
724
869
  process.exit(1);
725
870
  }
726
- const direct = values.foreground === true || handoffText !== undefined || enrollmentUrl !== undefined;
871
+ const direct = values.foreground === true || handoffText !== undefined || enrollmentUrl !== undefined || !spawnUsesManager(values);
727
872
  const enrollmentBootstrap = Boolean(enrollmentUrl && values.space && !findMesh(values.space));
728
873
  if (enrollmentBootstrap) {
729
874
  if (!values.config || (!values.config.includes("/") && !values.config.includes("\\") && !values.config.endsWith(".md"))) {
730
- console.error(c.red("✗ enrollment bootstrap needs --config <persona-file>; no remote persona catalog exists on this machine yet"));
875
+ stderrLine("✗ ", "enrollment bootstrap needs --config <persona-file>; no remote persona catalog exists on this machine yet", c.red);
731
876
  process.exit(1);
732
877
  }
733
878
  try {
734
879
  loadLaunchPersonaFile(resolvePath(values.config));
735
880
  }
736
881
  catch (e) {
737
- console.error(c.red(`✗ cannot load the enrollment bootstrap persona: ${e.message}`));
882
+ stderrLine("✗ ", `cannot load the enrollment bootstrap persona: ${e.message}`, c.red);
738
883
  process.exit(1);
739
884
  }
740
885
  }
741
886
  // Explicit files retain the execution host's path semantics. A manager pin is meaningful for
742
887
  // either managed persona spelling; direct execution has no manager placement to select.
743
888
  if (values.on !== undefined && direct) {
744
- console.error(c.red("✗ --on pins a managed imperative launch; direct --foreground does not take that manager selector"));
889
+ stderrLine("✗ ", "--on pins a managed imperative launch; a spawn in this terminal does not take that manager selector", c.red);
745
890
  process.exit(1);
746
891
  }
747
892
  // `--resume ""` / `--resume=` means the operator asked to resume but named no session — fail loud
@@ -773,7 +918,7 @@ export async function spawn(args) {
773
918
  // grants publish on the channel the connector names. Both are required, which is what stops a
774
919
  // hand-written grant from turning events on by itself.
775
920
  if (values.events && values["no-events"]) {
776
- console.error(c.red("✗ --events and --no-events are mutually exclusive"));
921
+ stderrLine("✗ ", "--events and --no-events are mutually exclusive", c.red);
777
922
  process.exit(1);
778
923
  }
779
924
  // #373: the detached path sends the bit ONLY when the operator chose it. `--events` gives
@@ -781,15 +926,14 @@ export async function spawn(args) {
781
926
  // an explicit true from a non-admin caller as operator reach and serves an omission unarmed
782
927
  // with a notice, so an unconditional default-true would be refused for an ordinary actor.
783
928
  const events = values.events ? true : values["no-events"] ? false : undefined;
784
- // Managed by default; the persona remains on the manager's execution host. Direct foreground
785
- // execution keeps its separate native custody path below.
929
+ // A manager runs it only with --detach or --on, and the persona then stays on the manager's
930
+ // execution host. Every other spawn keeps the native custody path below, in this terminal.
786
931
  if (!direct)
787
932
  return launchManagedPersona(values, positionals, events, cliLaunchOptions);
788
- console.error(renderReport({ sections: [{ title: "Direct application", blocks: [{ kind: "lines", lines: ["This is native foreground execution, not a detachable Cotal view.", { text: "Native exit, Ctrl-C or terminal loss may end this process. No crash or reboot survival is promised.", tone: "hint" }] }] }] }, "rich", terminalWidth(process.stderr)));
789
933
  // `--creds` names a CONTROL-CALLER credential (reach an off-registry manager) — meaningless for
790
934
  // a foreground launch, which provisions the agent's own creds. Fail loud, never ignore.
791
935
  if (values.creds) {
792
- console.error(c.red("✗ --creds is only valid with --detach (it authenticates the manager control call)"));
936
+ stderrLine("✗ ", "--creds is only valid with --detach (it authenticates the manager control call)", c.red);
793
937
  process.exit(1);
794
938
  }
795
939
  // An enrollment may bootstrap the stock remote user-mesh record before normal target resolution.
@@ -813,7 +957,7 @@ export async function spawn(args) {
813
957
  await registerEnrollmentMesh(redeemedEnrollment.stock, resolvePath(values.config, ".."));
814
958
  }
815
959
  catch (e) {
816
- console.error(c.red(`✗ ${e.message}`));
960
+ stderrLine("✗ ", `${e.message}`, c.red);
817
961
  process.exit(1);
818
962
  }
819
963
  }
@@ -824,11 +968,11 @@ export async function spawn(args) {
824
968
  const target = handoffText === undefined
825
969
  ? await resolveTargetOrExit({ server: values.server, space: values.space })
826
970
  : await resolveTargetOrThrow({ server: values.server, space: values.space }).catch(() => {
827
- console.error(c.red(`✗ ${HANDOFF_REFUSALS.target}`));
971
+ stderrLine("✗ ", `${HANDOFF_REFUSALS.target}`, c.red);
828
972
  process.exit(1);
829
973
  });
830
974
  if (handoffText !== undefined && !(target.mode === "user" && target.userAuth?.remote)) {
831
- console.error(c.red("✗ the managed handoff's space is registered here as a local mesh, so it cannot host a managed handoff"));
975
+ stderrLine("✗ ", "the managed handoff's space is registered here as a local mesh, so it cannot host a managed handoff", c.red);
832
976
  process.exit(1);
833
977
  }
834
978
  let policy;
@@ -836,14 +980,14 @@ export async function spawn(args) {
836
980
  policy = await refreshRegistrationPolicy(target);
837
981
  }
838
982
  catch (e) {
839
- console.error(c.red(`✗ ${handoffText === undefined ? e.message : HANDOFF_REFUSALS.policy}`));
983
+ stderrLine("✗ ", `${handoffText === undefined ? e.message : HANDOFF_REFUSALS.policy}`, c.red);
840
984
  process.exit(1);
841
985
  }
842
986
  const eventsRequired = policy?.events === "required";
843
987
  // A handoff's space is a value from the document, so its policy refusals name the field instead.
844
988
  const policySpace = handoffText === undefined ? `space "${target.space}"` : "the managed handoff's space";
845
989
  if (eventsRequired && values["no-events"]) {
846
- console.error(c.red(`✗ ${policySpace} requires the event plane by registration policy; --no-events is not allowed`));
990
+ stderrLine("✗ ", `${policySpace} requires the event plane by registration policy; --no-events is not allowed`, c.red);
847
991
  process.exit(1);
848
992
  }
849
993
  // Foreground is the operator's own in-process launch (no typed door, no epAdminReach) and is
@@ -865,31 +1009,16 @@ export async function spawn(args) {
865
1009
  if (e instanceof PersonaSourceError)
866
1010
  throw new CommandFailure("refused", "SCHEMA_INVALID", e.message, { target: { space, path }, remedy: "use cotal team deploy <file> for a Mesh manifest; use a native persona file for spawn" });
867
1011
  const code = e.code;
868
- const fromEnv = personaFrom === undefined ? "" : ` from ${personaFrom}`;
869
1012
  // The not-found text names the mesh's space and server, which for a handoff are its values.
870
1013
  if (handoffText !== undefined) {
871
- console.error(c.red(`✗ cannot load the managed handoff persona: ${e.message}`));
872
- }
873
- else if (code === "ENOENT" && path !== join(target.personaRoot, `${ref}.md`)) {
874
- // A path reference opened that one file and never read the catalog, so name the file.
875
- console.error(c.red(`✗ no persona "${ref}"${fromEnv} - ${path} not found`));
1014
+ stderrLine("✗ ", `cannot load the managed handoff persona: ${e.message}`, c.red);
876
1015
  }
877
1016
  else if (code === "ENOENT") {
878
- // A refusal that names no root is why this bug cost an hour. The old text asserted an absence
879
- // ("no default persona yet") and prescribed a remedy (`cotal setup`) without saying WHERE it
880
- // had looked — so when setup seeded a cwd-derived root and spawn read the resolved mesh's,
881
- // the message survived running the exact command it named and pointed at nothing to check.
882
- // Name the absolute directory checked and the mesh that root came from: the two facts that
883
- // make the disagreement visible in one read.
884
- const where = `${target.personaRoot} (mesh "${target.space}" at ${target.server}${target.source === "current" ? ", your current mesh" : target.source === "registry" ? ", the only mesh running" : ""})`;
885
- const fix = defaultPersonaFix(target);
886
- const write = fix.cwd ? `run \`${fix.command}\` in ${fix.cwd} to write one` : `create one with \`${fix.command}\``;
887
- console.error(c.red(ref === "default" && personaFrom === undefined
888
- ? `✗ no default persona in ${where} - ${write}, or name a persona: \`cotal spawn <name>\``
889
- : `✗ no persona "${ref}"${fromEnv} in ${where} - pass a catalog name, or use \`--config <path>\` for a file elsewhere`));
1017
+ const missing = missingPersona(target, ref, personaFrom, path);
1018
+ throw new CommandFailure("refused", "TARGET_NOT_FOUND", missing.message, { target: { space, path }, remedy: missing.remedy });
890
1019
  }
891
1020
  else {
892
- console.error(c.red(`✗ ${e.message}`));
1021
+ stderrLine("✗ ", `${e.message}`, c.red);
893
1022
  }
894
1023
  process.exit(1);
895
1024
  }
@@ -907,7 +1036,7 @@ export async function spawn(args) {
907
1036
  // Opaque connector options: `--opt` flags win per key over the persona's `launchOptions:`.
908
1037
  const launchOptions = mergeLaunchOptions(def.launchOptions, cliLaunchOptions);
909
1038
  if (redeemedEnrollment && redeemedEnrollment.bundle.actor !== requested) {
910
- console.error(c.red(`✗ the enrollment is for actor "${redeemedEnrollment.bundle.actor}" but this spawn names "${requested}"`));
1039
+ stderrLine("✗ ", `the enrollment is for actor "${redeemedEnrollment.bundle.actor}" but this spawn names "${requested}"`, c.red);
911
1040
  process.exit(1);
912
1041
  }
913
1042
  // #867: same door as the detached path — the effective identity (flag or file) must be mintable
@@ -926,12 +1055,12 @@ export async function spawn(args) {
926
1055
  launchOptions,
927
1056
  });
928
1057
  if (refusal) {
929
- console.error(c.red(`✗ ${refusal}`));
1058
+ stderrLine("✗ ", `${refusal}`, c.red);
930
1059
  process.exit(1);
931
1060
  }
932
1061
  }
933
1062
  catch (e) {
934
- console.error(c.red(`✗ ${e.message}`));
1063
+ stderrLine("✗ ", `${e.message}`, c.red);
935
1064
  process.exit(1);
936
1065
  }
937
1066
  // Preflight: fail with one sentence if the mesh is down or won't take our creds, instead of
@@ -940,7 +1069,7 @@ export async function spawn(args) {
940
1069
  await preflightOrExit(target);
941
1070
  else
942
1071
  await preflightOrThrow(target).catch(() => {
943
- console.error(c.red(`✗ ${HANDOFF_REFUSALS.preflight}`));
1072
+ stderrLine("✗ ", `${HANDOFF_REFUSALS.preflight}`, c.red);
944
1073
  process.exit(1);
945
1074
  });
946
1075
  // User mode allocates during guarded provisioning below, without a static operator credential.
@@ -958,7 +1087,9 @@ export async function spawn(args) {
958
1087
  await materializeExtension({ kind: "connector", name: agentType });
959
1088
  }
960
1089
  catch (e) {
961
- console.error(c.red(`✗ ${e.message}`));
1090
+ if (!connectorListed(agentType))
1091
+ throw missingConnector(agentType, { space, path });
1092
+ stderrLine("✗ ", `${e.message}`, c.red);
962
1093
  process.exit(1);
963
1094
  }
964
1095
  let connector;
@@ -966,15 +1097,15 @@ export async function spawn(args) {
966
1097
  connector = registry.resolve("connector", agentType);
967
1098
  }
968
1099
  catch (e) {
969
- console.error(c.red(`✗ ${e.message}`));
1100
+ stderrLine("✗ ", `${e.message}`, c.red);
970
1101
  process.exit(1);
971
1102
  }
972
1103
  if (variant && !connector.supportsModelVariant) {
973
- console.error(c.red(`✗ ${agentType} connector does not support model variants (variant)`));
1104
+ stderrLine("✗ ", `${agentType} connector does not support model variants (variant)`, c.red);
974
1105
  process.exit(1);
975
1106
  }
976
1107
  if (values.prompt !== undefined && !connector.supportsPrompt) {
977
- console.error(c.red(`✗ ${agentType} connector does not support an initial prompt (prompt)`));
1108
+ stderrLine("✗ ", `${agentType} connector does not support an initial prompt (prompt)`, c.red);
978
1109
  process.exit(1);
979
1110
  }
980
1111
  // Which of the operator's personal MCP servers to share with this agent: declared in the cotal
@@ -1017,7 +1148,7 @@ export async function spawn(args) {
1017
1148
  allowSubscribe = resolveReadAcl(subscribe ?? [], splitFlag(values["allow-subscribe"]) ?? def.allowSubscribe);
1018
1149
  }
1019
1150
  catch (e) {
1020
- console.error(c.red(`✗ ${e.message}`));
1151
+ stderrLine("✗ ", `${e.message}`, c.red);
1021
1152
  process.exit(1);
1022
1153
  }
1023
1154
  let allowPublish = splitFlag(values["allow-publish"]) ?? def.allowPublish;
@@ -1040,10 +1171,12 @@ export async function spawn(args) {
1040
1171
  ? target.userAuth.endpoints?.agentProvisioningUrl
1041
1172
  : undefined;
1042
1173
  if (target.mode === "user" && target.userAuth?.remote && !remoteProvisioningUrl && !enrollmentUrl && !redeemedEnrollment) {
1043
- console.error(c.red(`✗ mesh "${target.space}" runs elsewhere and advertises no agent-provisioning endpoint, so agents cannot be provisioned from this machine`));
1044
- console.error(c.dim(` a user-mode agent's credentials are granted where the mesh's signer lives; ask the mesh operator to advertise one (\`cotal up --agent-provisioning-url …\`), or run the agent there`));
1174
+ stderrLine("✗ ", `mesh "${target.space}" runs elsewhere and advertises no agent-provisioning endpoint, so agents cannot be provisioned from this machine`, c.red);
1175
+ console.error(c.dim(` a user-mode agent's credentials are granted where the mesh's signer lives; ask the mesh operator to advertise one (\`cotal up --agent-provisioning-url …\`), run the agent there, or add -d to launch it through one of your managers`));
1045
1176
  process.exit(1);
1046
1177
  }
1178
+ // Said once every check above has passed, so a refusal is never read as a launch that started.
1179
+ console.error(renderReport({ sections: [{ title: "Direct application", blocks: [{ kind: "lines", lines: ["This is native foreground execution, not a detachable Cotal view.", { text: "Native exit, Ctrl-C or terminal loss may end this process. No crash or reboot survival is promised.", tone: "hint" }] }] }] }, "rich", terminalWidth(process.stderr)));
1047
1180
  // Auth mode provisions the identity + writes its creds to disk BEFORE the connector validates the
1048
1181
  // launch (e.g. `buildLaunch` throws on a rejected `--opt`) and before the child execs. The SAME
1049
1182
  // retirement serves a failed provisioning or launch (rollback) and the normal foreground
@@ -1068,7 +1201,7 @@ export async function spawn(args) {
1068
1201
  await attemptCleanup(failed, "broker teardown", () => mintCreds(auth, newIdentity(), "deprovisioner", { deprovisionTarget: { principal: targetId, lifecycleUid } })
1069
1202
  .then((dc) => deprovisionAgent({ servers: server, space, targetId, lifecycleUid, creds: dc })));
1070
1203
  if (failed.length)
1071
- console.error(c.red(`✗ cleaning up after ${name}: ${describeCleanupFailures(failed)}`));
1204
+ stderrLine("✗ ", `cleaning up after ${name}: ${describeCleanupFailures(failed)}`, c.red);
1072
1205
  else
1073
1206
  console.error(` ↩ retired creds for ${name} (${why})`);
1074
1207
  };
@@ -1076,7 +1209,7 @@ export async function spawn(args) {
1076
1209
  if (!redeemedEnrollment) {
1077
1210
  // The record alone decides this refusal, and the redemption below spends the enrollment.
1078
1211
  if (!target.userAuth.endpoints?.url) {
1079
- console.error(c.red(`✗ ${noExchangeEndpoint(space)}`));
1212
+ stderrLine("✗ ", `${noExchangeEndpoint(space)}`, c.red);
1080
1213
  process.exit(1);
1081
1214
  }
1082
1215
  try {
@@ -1087,21 +1220,21 @@ export async function spawn(args) {
1087
1220
  redeemedEnrollment = checkEnrollmentBundle(body, name);
1088
1221
  }
1089
1222
  catch (e) {
1090
- console.error(c.red(`✗ ${e.message}`));
1223
+ stderrLine("✗ ", `${e.message}`, c.red);
1091
1224
  process.exit(1);
1092
1225
  }
1093
1226
  }
1094
1227
  const enrolled = redeemedEnrollment.bundle;
1095
1228
  if (enrolled.space !== space) {
1096
- console.error(c.red(`✗ the enrollment is for space "${enrolled.space}" but this spawn targets "${space}"`));
1229
+ stderrLine("✗ ", `the enrollment is for space "${enrolled.space}" but this spawn targets "${space}"`, c.red);
1097
1230
  process.exit(1);
1098
1231
  }
1099
1232
  if (enrolled.idp.url !== target.userAuth.idp.url || enrolled.idp.issuer !== target.userAuth.idp.issuer || enrolled.idp.audience !== target.userAuth.idp.audience) {
1100
- console.error(c.red("✗ the enrollment's IdP pins do not match the registered mesh"));
1233
+ stderrLine("✗ ", "the enrollment's IdP pins do not match the registered mesh", c.red);
1101
1234
  process.exit(1);
1102
1235
  }
1103
1236
  if (target.userAuth.endpoints?.url !== enrolled.authServiceUrl) {
1104
- console.error(c.red("✗ the enrollment's authServiceUrl does not match the registered mesh exchange"));
1237
+ stderrLine("✗ ", "the enrollment's authServiceUrl does not match the registered mesh exchange", c.red);
1105
1238
  process.exit(1);
1106
1239
  }
1107
1240
  const remote = await provisionRemoteUserForeground(target, name, { body: enrolled, exchangeUrl: enrolled.authServiceUrl }, handoffText === undefined ? undefined : HANDOFF_REFUSALS);
@@ -1266,6 +1399,7 @@ export async function spawn(args) {
1266
1399
  // construction because its write-ahead log had nowhere to live that a later start would look.
1267
1400
  workspaceRoot: target.root,
1268
1401
  });
1402
+ applyHandoffManagerInstance(spec, handoffManagerInstanceId);
1269
1403
  artifacts = spec.artifacts;
1270
1404
  scrubEnrollmentEnv(spec.env);
1271
1405
  // What happens next belongs to the CONNECTOR: naming one harness's first-run gate for all of
@@ -1300,7 +1434,7 @@ export async function spawn(args) {
1300
1434
  // other's mode): revoke the user-mode actor grant AND roll back the static-auth creds + footprint,
1301
1435
  // before rethrowing, so no standing grant survives a spawn that never started.
1302
1436
  if (userCleanup)
1303
- await userCleanup().catch((err) => console.error(c.red(`✗ cleaning up after ${name}: ${err.message}`)));
1437
+ await userCleanup().catch((err) => stderrLine("✗ ", `cleaning up after ${name}: ${err.message}`, c.red));
1304
1438
  await retireProvision("launch build failed");
1305
1439
  // The launch's private files (core launch-artifacts) go too: no child will read them.
1306
1440
  discardLaunchArtifacts(artifacts);
@@ -1310,7 +1444,7 @@ export async function spawn(args) {
1310
1444
  child.on("error", (e) => {
1311
1445
  // The exec never started, so the just-provisioned static-auth identity is orphaned — roll it
1312
1446
  // back. (User-mode revoke runs unconditionally once this promise settles, below.)
1313
- console.error(`✗ failed to launch ${spec.command}: ${e.message}`);
1447
+ stderrLine("✗ ", `failed to launch ${spec.command}: ${e.message}`, (line) => line);
1314
1448
  void retireProvision("exec failed").finally(() => {
1315
1449
  process.exitCode = 1;
1316
1450
  resolve();
@@ -1331,7 +1465,7 @@ export async function spawn(args) {
1331
1465
  // (a SIGKILLed CLI can't run this; its retained grant needs operator recovery), loud
1332
1466
  // on failure, never blocking the exit code already set above.
1333
1467
  if (userCleanup)
1334
- await userCleanup().catch((e) => console.error(c.red(`✗ cleaning up after ${name}: ${e.message}`)));
1468
+ await userCleanup().catch((e) => stderrLine("✗ ", `cleaning up after ${name}: ${e.message}`, c.red));
1335
1469
  // The child has exited or never started, so nothing reads the launch's private files any more
1336
1470
  // (core launch-artifacts). A SIGKILLed CLI cannot run this; the child's watcher removes those.
1337
1471
  discardLaunchArtifacts(spec.artifacts);
@@ -1420,7 +1554,7 @@ async function provisionRemoteUserForeground(target, name, source, refusals) {
1420
1554
  const store = workspaceSecretStore(target.root);
1421
1555
  const composition = { injected: false, root: target.root };
1422
1556
  const fail = (msg) => {
1423
- console.error(c.red(`✗ ${msg}`));
1557
+ stderrLine("✗ ", `${msg}`, c.red);
1424
1558
  process.exit(1);
1425
1559
  };
1426
1560
  // Resolved first, as by every consumer of the space's local state: each resolution migrates a
@@ -1556,7 +1690,7 @@ async function provisionUserForeground(target, name, ref, opts) {
1556
1690
  const store = workspaceSecretStore(target.root);
1557
1691
  const composition = { injected: false, root: target.root };
1558
1692
  const fail = (msg) => {
1559
- console.error(c.red(`✗ ${msg}`));
1693
+ stderrLine("✗ ", `${msg}`, c.red);
1560
1694
  process.exit(1);
1561
1695
  };
1562
1696
  let provider;