@cotal-ai/cli 0.90.0 → 0.91.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (759) hide show
  1. package/dist/chat/chat-view.d.ts +17 -0
  2. package/dist/chat/chat-view.d.ts.map +1 -0
  3. package/dist/chat/chat-view.js +179 -0
  4. package/dist/chat/chat-view.js.map +1 -0
  5. package/dist/chat/controller.d.ts +19 -0
  6. package/dist/chat/controller.d.ts.map +1 -0
  7. package/dist/chat/controller.js +116 -0
  8. package/dist/chat/controller.js.map +1 -0
  9. package/dist/chat/engine.d.ts +108 -0
  10. package/dist/chat/engine.d.ts.map +1 -0
  11. package/dist/chat/engine.js +226 -0
  12. package/dist/chat/engine.js.map +1 -0
  13. package/dist/chat/frontend.d.ts +35 -0
  14. package/dist/chat/frontend.d.ts.map +1 -0
  15. package/dist/chat/frontend.js +151 -0
  16. package/dist/chat/frontend.js.map +1 -0
  17. package/dist/chat/native-session.d.ts +71 -0
  18. package/dist/chat/native-session.d.ts.map +1 -0
  19. package/dist/chat/native-session.js +348 -0
  20. package/dist/chat/native-session.js.map +1 -0
  21. package/dist/chat/open-session.d.ts +8 -0
  22. package/dist/chat/open-session.d.ts.map +1 -0
  23. package/dist/chat/open-session.js +120 -0
  24. package/dist/chat/open-session.js.map +1 -0
  25. package/dist/chat/picker.d.ts +34 -0
  26. package/dist/chat/picker.d.ts.map +1 -0
  27. package/dist/chat/picker.js +97 -0
  28. package/dist/chat/picker.js.map +1 -0
  29. package/dist/chat/plain.d.ts +15 -0
  30. package/dist/chat/plain.d.ts.map +1 -0
  31. package/dist/chat/plain.js +242 -0
  32. package/dist/chat/plain.js.map +1 -0
  33. package/dist/chat/session.d.ts +217 -0
  34. package/dist/chat/session.d.ts.map +1 -0
  35. package/dist/chat/session.js +2 -0
  36. package/dist/chat/session.js.map +1 -0
  37. package/dist/chat/static-session.d.ts +61 -0
  38. package/dist/chat/static-session.d.ts.map +1 -0
  39. package/dist/chat/static-session.js +212 -0
  40. package/dist/chat/static-session.js.map +1 -0
  41. package/dist/chat/stdio-io.d.ts +34 -0
  42. package/dist/chat/stdio-io.d.ts.map +1 -0
  43. package/dist/chat/stdio-io.js +175 -0
  44. package/dist/chat/stdio-io.js.map +1 -0
  45. package/dist/chat/stdio.d.ts +173 -0
  46. package/dist/chat/stdio.d.ts.map +1 -0
  47. package/dist/chat/stdio.js +400 -0
  48. package/dist/chat/stdio.js.map +1 -0
  49. package/dist/chat/user-session.d.ts +21 -0
  50. package/dist/chat/user-session.d.ts.map +1 -0
  51. package/dist/chat/user-session.js +180 -0
  52. package/dist/chat/user-session.js.map +1 -0
  53. package/dist/chat/view.d.ts +186 -0
  54. package/dist/chat/view.d.ts.map +1 -0
  55. package/dist/chat/view.js +386 -0
  56. package/dist/chat/view.js.map +1 -0
  57. package/dist/command.d.ts +11 -3
  58. package/dist/command.d.ts.map +1 -1
  59. package/dist/command.js +392 -147
  60. package/dist/command.js.map +1 -1
  61. package/dist/commands/agents.d.ts +103 -11
  62. package/dist/commands/agents.d.ts.map +1 -1
  63. package/dist/commands/agents.js +501 -251
  64. package/dist/commands/agents.js.map +1 -1
  65. package/dist/commands/app-identity.d.ts.map +1 -1
  66. package/dist/commands/app-identity.js +10 -1
  67. package/dist/commands/app-identity.js.map +1 -1
  68. package/dist/commands/backup-maintenance.d.ts +4 -0
  69. package/dist/commands/backup-maintenance.d.ts.map +1 -0
  70. package/dist/commands/backup-maintenance.js +92 -0
  71. package/dist/commands/backup-maintenance.js.map +1 -0
  72. package/dist/commands/backup-read.d.ts +4 -0
  73. package/dist/commands/backup-read.d.ts.map +1 -0
  74. package/dist/commands/backup-read.js +27 -0
  75. package/dist/commands/backup-read.js.map +1 -0
  76. package/dist/commands/backup-restore.d.ts +7 -0
  77. package/dist/commands/backup-restore.d.ts.map +1 -0
  78. package/dist/commands/backup-restore.js +81 -0
  79. package/dist/commands/backup-restore.js.map +1 -0
  80. package/dist/commands/backup.d.ts +2 -1
  81. package/dist/commands/backup.d.ts.map +1 -1
  82. package/dist/commands/backup.js +102 -24
  83. package/dist/commands/backup.js.map +1 -1
  84. package/dist/commands/channel-members.d.ts +8 -0
  85. package/dist/commands/channel-members.d.ts.map +1 -0
  86. package/dist/commands/channel-members.js +144 -0
  87. package/dist/commands/channel-members.js.map +1 -0
  88. package/dist/commands/channels.d.ts +75 -22
  89. package/dist/commands/channels.d.ts.map +1 -1
  90. package/dist/commands/channels.js +181 -100
  91. package/dist/commands/channels.js.map +1 -1
  92. package/dist/commands/chat.d.ts +109 -0
  93. package/dist/commands/chat.d.ts.map +1 -0
  94. package/dist/commands/chat.js +227 -0
  95. package/dist/commands/chat.js.map +1 -0
  96. package/dist/commands/clean.d.ts +43 -1
  97. package/dist/commands/clean.d.ts.map +1 -1
  98. package/dist/commands/clean.js +90 -47
  99. package/dist/commands/clean.js.map +1 -1
  100. package/dist/commands/completion.d.ts +39 -1
  101. package/dist/commands/completion.d.ts.map +1 -1
  102. package/dist/commands/completion.js +211 -87
  103. package/dist/commands/completion.js.map +1 -1
  104. package/dist/commands/config.d.ts +33 -0
  105. package/dist/commands/config.d.ts.map +1 -0
  106. package/dist/commands/config.js +159 -0
  107. package/dist/commands/config.js.map +1 -0
  108. package/dist/commands/console.d.ts.map +1 -1
  109. package/dist/commands/console.js +25 -7
  110. package/dist/commands/console.js.map +1 -1
  111. package/dist/commands/describe.d.ts +63 -31
  112. package/dist/commands/describe.d.ts.map +1 -1
  113. package/dist/commands/describe.js +264 -136
  114. package/dist/commands/describe.js.map +1 -1
  115. package/dist/commands/doctor.d.ts +11 -6
  116. package/dist/commands/doctor.d.ts.map +1 -1
  117. package/dist/commands/doctor.js +195 -288
  118. package/dist/commands/doctor.js.map +1 -1
  119. package/dist/commands/down-services.d.ts +29 -0
  120. package/dist/commands/down-services.d.ts.map +1 -0
  121. package/dist/commands/down-services.js +129 -0
  122. package/dist/commands/down-services.js.map +1 -0
  123. package/dist/commands/down.d.ts +37 -11
  124. package/dist/commands/down.d.ts.map +1 -1
  125. package/dist/commands/down.js +276 -115
  126. package/dist/commands/down.js.map +1 -1
  127. package/dist/commands/endpoint-authoring.d.ts +4 -0
  128. package/dist/commands/endpoint-authoring.d.ts.map +1 -0
  129. package/dist/commands/endpoint-authoring.js +125 -0
  130. package/dist/commands/endpoint-authoring.js.map +1 -0
  131. package/dist/commands/endpoint-deregister.d.ts +5 -0
  132. package/dist/commands/endpoint-deregister.d.ts.map +1 -0
  133. package/dist/commands/endpoint-deregister.js +70 -0
  134. package/dist/commands/endpoint-deregister.js.map +1 -0
  135. package/dist/commands/endpoint.d.ts +118 -0
  136. package/dist/commands/endpoint.d.ts.map +1 -0
  137. package/dist/commands/endpoint.js +177 -0
  138. package/dist/commands/endpoint.js.map +1 -0
  139. package/dist/commands/endpoints.d.ts +27 -1
  140. package/dist/commands/endpoints.d.ts.map +1 -1
  141. package/dist/commands/endpoints.js +42 -30
  142. package/dist/commands/endpoints.js.map +1 -1
  143. package/dist/commands/ext.d.ts +38 -1
  144. package/dist/commands/ext.d.ts.map +1 -1
  145. package/dist/commands/ext.js +84 -49
  146. package/dist/commands/ext.js.map +1 -1
  147. package/dist/commands/feedback.d.ts +58 -1
  148. package/dist/commands/feedback.d.ts.map +1 -1
  149. package/dist/commands/feedback.js +119 -47
  150. package/dist/commands/feedback.js.map +1 -1
  151. package/dist/commands/help.d.ts +20 -0
  152. package/dist/commands/help.d.ts.map +1 -0
  153. package/dist/commands/help.js +52 -0
  154. package/dist/commands/help.js.map +1 -0
  155. package/dist/commands/history-clear.d.ts +14 -0
  156. package/dist/commands/history-clear.d.ts.map +1 -0
  157. package/dist/commands/history-clear.js +73 -0
  158. package/dist/commands/history-clear.js.map +1 -0
  159. package/dist/commands/history.d.ts +146 -4
  160. package/dist/commands/history.d.ts.map +1 -1
  161. package/dist/commands/history.js +443 -19
  162. package/dist/commands/history.js.map +1 -1
  163. package/dist/commands/join.d.ts.map +1 -1
  164. package/dist/commands/join.js +7 -3
  165. package/dist/commands/join.js.map +1 -1
  166. package/dist/commands/meshes-add.d.ts +3 -0
  167. package/dist/commands/meshes-add.d.ts.map +1 -1
  168. package/dist/commands/meshes-add.js +41 -34
  169. package/dist/commands/meshes-add.js.map +1 -1
  170. package/dist/commands/meshes-wizard.js +3 -3
  171. package/dist/commands/meshes-wizard.js.map +1 -1
  172. package/dist/commands/mint-endpoint-caller.d.ts +5 -0
  173. package/dist/commands/mint-endpoint-caller.d.ts.map +1 -0
  174. package/dist/commands/mint-endpoint-caller.js +130 -0
  175. package/dist/commands/mint-endpoint-caller.js.map +1 -0
  176. package/dist/commands/mint.d.ts +2 -37
  177. package/dist/commands/mint.d.ts.map +1 -1
  178. package/dist/commands/mint.js +142 -325
  179. package/dist/commands/mint.js.map +1 -1
  180. package/dist/commands/models.d.ts +30 -8
  181. package/dist/commands/models.d.ts.map +1 -1
  182. package/dist/commands/models.js +72 -41
  183. package/dist/commands/models.js.map +1 -1
  184. package/dist/commands/persona-remote.d.ts +5 -0
  185. package/dist/commands/persona-remote.d.ts.map +1 -0
  186. package/dist/commands/persona-remote.js +237 -0
  187. package/dist/commands/persona-remote.js.map +1 -0
  188. package/dist/commands/persona.d.ts +91 -0
  189. package/dist/commands/persona.d.ts.map +1 -0
  190. package/dist/commands/persona.js +200 -0
  191. package/dist/commands/persona.js.map +1 -0
  192. package/dist/commands/personas.d.ts.map +1 -1
  193. package/dist/commands/personas.js +16 -59
  194. package/dist/commands/personas.js.map +1 -1
  195. package/dist/commands/reset-space-apply.d.ts +5 -0
  196. package/dist/commands/reset-space-apply.d.ts.map +1 -0
  197. package/dist/commands/reset-space-apply.js +140 -0
  198. package/dist/commands/reset-space-apply.js.map +1 -0
  199. package/dist/commands/reset-store-apply.d.ts +11 -0
  200. package/dist/commands/reset-store-apply.d.ts.map +1 -0
  201. package/dist/commands/reset-store-apply.js +154 -0
  202. package/dist/commands/reset-store-apply.js.map +1 -0
  203. package/dist/commands/reset.d.ts +26 -0
  204. package/dist/commands/reset.d.ts.map +1 -0
  205. package/dist/commands/reset.js +143 -0
  206. package/dist/commands/reset.js.map +1 -0
  207. package/dist/commands/runtimes.d.ts +26 -1
  208. package/dist/commands/runtimes.d.ts.map +1 -1
  209. package/dist/commands/runtimes.js +68 -32
  210. package/dist/commands/runtimes.js.map +1 -1
  211. package/dist/commands/send.d.ts +91 -6
  212. package/dist/commands/send.d.ts.map +1 -1
  213. package/dist/commands/send.js +180 -106
  214. package/dist/commands/send.js.map +1 -1
  215. package/dist/commands/service-actions.d.ts +6 -0
  216. package/dist/commands/service-actions.d.ts.map +1 -0
  217. package/dist/commands/service-actions.js +405 -0
  218. package/dist/commands/service-actions.js.map +1 -0
  219. package/dist/commands/service-log-follow.d.ts +5 -0
  220. package/dist/commands/service-log-follow.d.ts.map +1 -0
  221. package/dist/commands/service-log-follow.js +106 -0
  222. package/dist/commands/service-log-follow.js.map +1 -0
  223. package/dist/commands/service-registry.d.ts +67 -0
  224. package/dist/commands/service-registry.d.ts.map +1 -0
  225. package/dist/commands/service-registry.js +275 -0
  226. package/dist/commands/service-registry.js.map +1 -0
  227. package/dist/commands/service-set-stop.d.ts +6 -0
  228. package/dist/commands/service-set-stop.d.ts.map +1 -0
  229. package/dist/commands/service-set-stop.js +161 -0
  230. package/dist/commands/service-set-stop.js.map +1 -0
  231. package/dist/commands/service-unit-entry.d.ts +5 -0
  232. package/dist/commands/service-unit-entry.d.ts.map +1 -0
  233. package/dist/commands/service-unit-entry.js +113 -0
  234. package/dist/commands/service-unit-entry.js.map +1 -0
  235. package/dist/commands/setup-start.d.ts +21 -0
  236. package/dist/commands/setup-start.d.ts.map +1 -0
  237. package/dist/commands/setup-start.js +95 -0
  238. package/dist/commands/setup-start.js.map +1 -0
  239. package/dist/commands/setup.d.ts +86 -100
  240. package/dist/commands/setup.d.ts.map +1 -1
  241. package/dist/commands/setup.js +766 -487
  242. package/dist/commands/setup.js.map +1 -1
  243. package/dist/commands/space-delete.d.ts +3 -0
  244. package/dist/commands/space-delete.d.ts.map +1 -0
  245. package/dist/commands/space-delete.js +341 -0
  246. package/dist/commands/space-delete.js.map +1 -0
  247. package/dist/commands/space-registration.d.ts +92 -0
  248. package/dist/commands/space-registration.d.ts.map +1 -0
  249. package/dist/commands/space-registration.js +388 -0
  250. package/dist/commands/space-registration.js.map +1 -0
  251. package/dist/commands/space.d.ts +128 -0
  252. package/dist/commands/space.d.ts.map +1 -0
  253. package/dist/commands/space.js +230 -0
  254. package/dist/commands/space.js.map +1 -0
  255. package/dist/commands/spawn-manifest.d.ts.map +1 -1
  256. package/dist/commands/spawn-manifest.js +2 -2
  257. package/dist/commands/spawn-manifest.js.map +1 -1
  258. package/dist/commands/spawn-preview.d.ts +9 -0
  259. package/dist/commands/spawn-preview.d.ts.map +1 -0
  260. package/dist/commands/spawn-preview.js +68 -0
  261. package/dist/commands/spawn-preview.js.map +1 -0
  262. package/dist/commands/spawn.d.ts +78 -18
  263. package/dist/commands/spawn.d.ts.map +1 -1
  264. package/dist/commands/spawn.js +236 -96
  265. package/dist/commands/spawn.js.map +1 -1
  266. package/dist/commands/stack-down.d.ts +6 -0
  267. package/dist/commands/stack-down.d.ts.map +1 -0
  268. package/dist/commands/stack-down.js +206 -0
  269. package/dist/commands/stack-down.js.map +1 -0
  270. package/dist/commands/stack-up.d.ts +149 -0
  271. package/dist/commands/stack-up.d.ts.map +1 -0
  272. package/dist/commands/stack-up.js +459 -0
  273. package/dist/commands/stack-up.js.map +1 -0
  274. package/dist/commands/stack-user-auth.d.ts +52 -0
  275. package/dist/commands/stack-user-auth.d.ts.map +1 -0
  276. package/dist/commands/stack-user-auth.js +128 -0
  277. package/dist/commands/stack-user-auth.js.map +1 -0
  278. package/dist/commands/status.d.ts +232 -5
  279. package/dist/commands/status.d.ts.map +1 -1
  280. package/dist/commands/status.js +989 -406
  281. package/dist/commands/status.js.map +1 -1
  282. package/dist/commands/sync.d.ts +23 -0
  283. package/dist/commands/sync.d.ts.map +1 -1
  284. package/dist/commands/sync.js +69 -17
  285. package/dist/commands/sync.js.map +1 -1
  286. package/dist/commands/team-agent-apply.d.ts +5 -0
  287. package/dist/commands/team-agent-apply.d.ts.map +1 -0
  288. package/dist/commands/team-agent-apply.js +204 -0
  289. package/dist/commands/team-agent-apply.js.map +1 -0
  290. package/dist/commands/team-agent-remove.d.ts +87 -0
  291. package/dist/commands/team-agent-remove.d.ts.map +1 -0
  292. package/dist/commands/team-agent-remove.js +348 -0
  293. package/dist/commands/team-agent-remove.js.map +1 -0
  294. package/dist/commands/team-boot-controller.d.ts +11 -0
  295. package/dist/commands/team-boot-controller.d.ts.map +1 -0
  296. package/dist/commands/team-boot-controller.js +176 -0
  297. package/dist/commands/team-boot-controller.js.map +1 -0
  298. package/dist/commands/team-channel-remove.d.ts +167 -0
  299. package/dist/commands/team-channel-remove.d.ts.map +1 -0
  300. package/dist/commands/team-channel-remove.js +486 -0
  301. package/dist/commands/team-channel-remove.js.map +1 -0
  302. package/dist/commands/team-deploy-apply.d.ts +11 -0
  303. package/dist/commands/team-deploy-apply.d.ts.map +1 -0
  304. package/dist/commands/team-deploy-apply.js +320 -0
  305. package/dist/commands/team-deploy-apply.js.map +1 -0
  306. package/dist/commands/team-mixed-remove.d.ts +8 -0
  307. package/dist/commands/team-mixed-remove.d.ts.map +1 -0
  308. package/dist/commands/team-mixed-remove.js +207 -0
  309. package/dist/commands/team-mixed-remove.js.map +1 -0
  310. package/dist/commands/team.d.ts +51 -0
  311. package/dist/commands/team.d.ts.map +1 -0
  312. package/dist/commands/team.js +727 -0
  313. package/dist/commands/team.js.map +1 -0
  314. package/dist/commands/topology.d.ts +4 -0
  315. package/dist/commands/topology.d.ts.map +1 -1
  316. package/dist/commands/topology.js +8 -0
  317. package/dist/commands/topology.js.map +1 -1
  318. package/dist/commands/up.d.ts +144 -5
  319. package/dist/commands/up.d.ts.map +1 -1
  320. package/dist/commands/up.js +1015 -124
  321. package/dist/commands/up.js.map +1 -1
  322. package/dist/commands/update.d.ts +11 -0
  323. package/dist/commands/update.d.ts.map +1 -1
  324. package/dist/commands/update.js +72 -15
  325. package/dist/commands/update.js.map +1 -1
  326. package/dist/commands/use.d.ts +16 -3
  327. package/dist/commands/use.d.ts.map +1 -1
  328. package/dist/commands/use.js +45 -19
  329. package/dist/commands/use.js.map +1 -1
  330. package/dist/commands/watch.d.ts +37 -0
  331. package/dist/commands/watch.d.ts.map +1 -0
  332. package/dist/commands/watch.js +106 -0
  333. package/dist/commands/watch.js.map +1 -0
  334. package/dist/commands/who.d.ts +79 -0
  335. package/dist/commands/who.d.ts.map +1 -0
  336. package/dist/commands/who.js +193 -0
  337. package/dist/commands/who.js.map +1 -0
  338. package/dist/commands/whoami.d.ts +56 -0
  339. package/dist/commands/whoami.d.ts.map +1 -0
  340. package/dist/commands/whoami.js +106 -0
  341. package/dist/commands/whoami.js.map +1 -0
  342. package/dist/console/app.d.ts.map +1 -1
  343. package/dist/console/app.js +8 -4
  344. package/dist/console/app.js.map +1 -1
  345. package/dist/console/commands.d.ts.map +1 -1
  346. package/dist/console/commands.js +12 -6
  347. package/dist/console/commands.js.map +1 -1
  348. package/dist/exec-endpoint/definition.d.ts +15 -0
  349. package/dist/exec-endpoint/definition.d.ts.map +1 -0
  350. package/dist/exec-endpoint/definition.js +56 -0
  351. package/dist/exec-endpoint/definition.js.map +1 -0
  352. package/dist/exec-endpoint/handler.d.ts +13 -0
  353. package/dist/exec-endpoint/handler.d.ts.map +1 -0
  354. package/dist/exec-endpoint/handler.js +155 -0
  355. package/dist/exec-endpoint/handler.js.map +1 -0
  356. package/dist/exec-endpoint/registration.d.ts +34 -0
  357. package/dist/exec-endpoint/registration.d.ts.map +1 -0
  358. package/dist/exec-endpoint/registration.js +148 -0
  359. package/dist/exec-endpoint/registration.js.map +1 -0
  360. package/dist/exec-endpoint/serve.d.ts +8 -0
  361. package/dist/exec-endpoint/serve.d.ts.map +1 -0
  362. package/dist/exec-endpoint/serve.js +159 -0
  363. package/dist/exec-endpoint/serve.js.map +1 -0
  364. package/dist/exec-endpoint/service-adapter.d.ts +6 -0
  365. package/dist/exec-endpoint/service-adapter.d.ts.map +1 -0
  366. package/dist/exec-endpoint/service-adapter.js +110 -0
  367. package/dist/exec-endpoint/service-adapter.js.map +1 -0
  368. package/dist/ext-loader.d.ts +10 -0
  369. package/dist/ext-loader.d.ts.map +1 -1
  370. package/dist/ext-loader.js +61 -13
  371. package/dist/ext-loader.js.map +1 -1
  372. package/dist/help.d.ts +18 -0
  373. package/dist/help.d.ts.map +1 -0
  374. package/dist/help.js +256 -0
  375. package/dist/help.js.map +1 -0
  376. package/dist/index.d.ts +2 -0
  377. package/dist/index.d.ts.map +1 -1
  378. package/dist/index.js +444 -118
  379. package/dist/index.js.map +1 -1
  380. package/dist/lib/assist.d.ts.map +1 -1
  381. package/dist/lib/assist.js +3 -2
  382. package/dist/lib/assist.js.map +1 -1
  383. package/dist/lib/attach-client.d.ts +7 -6
  384. package/dist/lib/attach-client.d.ts.map +1 -1
  385. package/dist/lib/attach-client.js +14 -15
  386. package/dist/lib/attach-client.js.map +1 -1
  387. package/dist/lib/auth-proc.d.ts +3 -3
  388. package/dist/lib/auth-proc.d.ts.map +1 -1
  389. package/dist/lib/auth-proc.js +8 -8
  390. package/dist/lib/auth-proc.js.map +1 -1
  391. package/dist/lib/backup-artifact.d.ts +34 -1
  392. package/dist/lib/backup-artifact.d.ts.map +1 -1
  393. package/dist/lib/backup-artifact.js +67 -17
  394. package/dist/lib/backup-artifact.js.map +1 -1
  395. package/dist/lib/broker-service.d.ts +10 -0
  396. package/dist/lib/broker-service.d.ts.map +1 -0
  397. package/dist/lib/broker-service.js +329 -0
  398. package/dist/lib/broker-service.js.map +1 -0
  399. package/dist/lib/cancel.js +1 -1
  400. package/dist/lib/cancel.js.map +1 -1
  401. package/dist/lib/choose-target.d.ts +10 -0
  402. package/dist/lib/choose-target.d.ts.map +1 -0
  403. package/dist/lib/choose-target.js +42 -0
  404. package/dist/lib/choose-target.js.map +1 -0
  405. package/dist/lib/command-path.d.ts +13 -0
  406. package/dist/lib/command-path.d.ts.map +1 -0
  407. package/dist/lib/command-path.js +40 -0
  408. package/dist/lib/command-path.js.map +1 -0
  409. package/dist/lib/completion-install.d.ts +29 -0
  410. package/dist/lib/completion-install.d.ts.map +1 -0
  411. package/dist/lib/completion-install.js +369 -0
  412. package/dist/lib/completion-install.js.map +1 -0
  413. package/dist/lib/completion-scripts.d.ts +4 -0
  414. package/dist/lib/completion-scripts.d.ts.map +1 -0
  415. package/dist/lib/completion-scripts.js +15 -0
  416. package/dist/lib/completion-scripts.js.map +1 -0
  417. package/dist/lib/completion.d.ts.map +1 -1
  418. package/dist/lib/completion.js +4 -1
  419. package/dist/lib/completion.js.map +1 -1
  420. package/dist/lib/control.d.ts +65 -6
  421. package/dist/lib/control.d.ts.map +1 -1
  422. package/dist/lib/control.js +121 -27
  423. package/dist/lib/control.js.map +1 -1
  424. package/dist/lib/controller-preserve.d.ts +12 -0
  425. package/dist/lib/controller-preserve.d.ts.map +1 -0
  426. package/dist/lib/controller-preserve.js +373 -0
  427. package/dist/lib/controller-preserve.js.map +1 -0
  428. package/dist/lib/controller-restore.d.ts +38 -0
  429. package/dist/lib/controller-restore.d.ts.map +1 -0
  430. package/dist/lib/controller-restore.js +205 -0
  431. package/dist/lib/controller-restore.js.map +1 -0
  432. package/dist/lib/controller-resume.d.ts +92 -0
  433. package/dist/lib/controller-resume.d.ts.map +1 -0
  434. package/dist/lib/controller-resume.js +300 -0
  435. package/dist/lib/controller-resume.js.map +1 -0
  436. package/dist/lib/credential-authority.d.ts +17 -0
  437. package/dist/lib/credential-authority.d.ts.map +1 -0
  438. package/dist/lib/credential-authority.js +28 -0
  439. package/dist/lib/credential-authority.js.map +1 -0
  440. package/dist/lib/default-persona.d.ts +38 -0
  441. package/dist/lib/default-persona.d.ts.map +1 -0
  442. package/dist/lib/default-persona.js +85 -0
  443. package/dist/lib/default-persona.js.map +1 -0
  444. package/dist/lib/delivery-proc.d.ts +9 -9
  445. package/dist/lib/delivery-proc.d.ts.map +1 -1
  446. package/dist/lib/delivery-proc.js +9 -19
  447. package/dist/lib/delivery-proc.js.map +1 -1
  448. package/dist/lib/endpoint-capability-gates.d.ts +10 -0
  449. package/dist/lib/endpoint-capability-gates.d.ts.map +1 -0
  450. package/dist/lib/endpoint-capability-gates.js +70 -0
  451. package/dist/lib/endpoint-capability-gates.js.map +1 -0
  452. package/dist/lib/endpoint-client.d.ts +20 -0
  453. package/dist/lib/endpoint-client.d.ts.map +1 -0
  454. package/dist/lib/endpoint-client.js +42 -0
  455. package/dist/lib/endpoint-client.js.map +1 -0
  456. package/dist/lib/endpoint-errors.d.ts +11 -0
  457. package/dist/lib/endpoint-errors.d.ts.map +1 -0
  458. package/dist/lib/endpoint-errors.js +30 -0
  459. package/dist/lib/endpoint-errors.js.map +1 -0
  460. package/dist/lib/endpoint-goal.d.ts +19 -0
  461. package/dist/lib/endpoint-goal.d.ts.map +1 -0
  462. package/dist/lib/endpoint-goal.js +31 -0
  463. package/dist/lib/endpoint-goal.js.map +1 -0
  464. package/dist/lib/endpoint-inventory.d.ts +30 -0
  465. package/dist/lib/endpoint-inventory.d.ts.map +1 -0
  466. package/dist/lib/endpoint-inventory.js +79 -0
  467. package/dist/lib/endpoint-inventory.js.map +1 -0
  468. package/dist/lib/endpoint-references.d.ts +22 -0
  469. package/dist/lib/endpoint-references.d.ts.map +1 -0
  470. package/dist/lib/endpoint-references.js +44 -0
  471. package/dist/lib/endpoint-references.js.map +1 -0
  472. package/dist/lib/endpoint-scatter.d.ts +57 -0
  473. package/dist/lib/endpoint-scatter.d.ts.map +1 -0
  474. package/dist/lib/endpoint-scatter.js +75 -0
  475. package/dist/lib/endpoint-scatter.js.map +1 -0
  476. package/dist/lib/endpoint-selection.d.ts +35 -0
  477. package/dist/lib/endpoint-selection.d.ts.map +1 -0
  478. package/dist/lib/endpoint-selection.js +80 -0
  479. package/dist/lib/endpoint-selection.js.map +1 -0
  480. package/dist/lib/install-umask.d.ts +6 -0
  481. package/dist/lib/install-umask.d.ts.map +1 -0
  482. package/dist/lib/install-umask.js +15 -0
  483. package/dist/lib/install-umask.js.map +1 -0
  484. package/dist/lib/isolated-broker.d.ts.map +1 -1
  485. package/dist/lib/isolated-broker.js +9 -5
  486. package/dist/lib/isolated-broker.js.map +1 -1
  487. package/dist/lib/local-process-stop.d.ts.map +1 -1
  488. package/dist/lib/local-process-stop.js +7 -1
  489. package/dist/lib/local-process-stop.js.map +1 -1
  490. package/dist/lib/manager-proc.d.ts +11 -5
  491. package/dist/lib/manager-proc.d.ts.map +1 -1
  492. package/dist/lib/manager-proc.js +12 -17
  493. package/dist/lib/manager-proc.js.map +1 -1
  494. package/dist/lib/manifest/apply.d.ts +4 -1
  495. package/dist/lib/manifest/apply.d.ts.map +1 -1
  496. package/dist/lib/manifest/apply.js +1 -1
  497. package/dist/lib/manifest/apply.js.map +1 -1
  498. package/dist/lib/manifest/ledger.d.ts +3 -1
  499. package/dist/lib/manifest/ledger.d.ts.map +1 -1
  500. package/dist/lib/manifest/ledger.js +16 -3
  501. package/dist/lib/manifest/ledger.js.map +1 -1
  502. package/dist/lib/manifest/schema.d.ts +1 -117
  503. package/dist/lib/manifest/schema.d.ts.map +1 -1
  504. package/dist/lib/manifest/schema.js +1 -95
  505. package/dist/lib/manifest/schema.js.map +1 -1
  506. package/dist/lib/offline-recipient.d.ts +5 -0
  507. package/dist/lib/offline-recipient.d.ts.map +1 -0
  508. package/dist/lib/offline-recipient.js +7 -0
  509. package/dist/lib/offline-recipient.js.map +1 -0
  510. package/dist/lib/onboard.js +3 -3
  511. package/dist/lib/onboard.js.map +1 -1
  512. package/dist/lib/persona-files.d.ts +29 -0
  513. package/dist/lib/persona-files.d.ts.map +1 -0
  514. package/dist/lib/persona-files.js +154 -0
  515. package/dist/lib/persona-files.js.map +1 -0
  516. package/dist/lib/personas.d.ts +3 -0
  517. package/dist/lib/personas.d.ts.map +1 -1
  518. package/dist/lib/personas.js +14 -2
  519. package/dist/lib/personas.js.map +1 -1
  520. package/dist/lib/prompts.d.ts +16 -0
  521. package/dist/lib/prompts.d.ts.map +1 -0
  522. package/dist/lib/prompts.js +35 -0
  523. package/dist/lib/prompts.js.map +1 -0
  524. package/dist/lib/protected-records.d.ts +2 -0
  525. package/dist/lib/protected-records.d.ts.map +1 -0
  526. package/dist/lib/protected-records.js +3 -0
  527. package/dist/lib/protected-records.js.map +1 -0
  528. package/dist/lib/registry-errors.d.ts +4 -0
  529. package/dist/lib/registry-errors.d.ts.map +1 -0
  530. package/dist/lib/registry-errors.js +6 -0
  531. package/dist/lib/registry-errors.js.map +1 -0
  532. package/dist/lib/reset-space-plan.d.ts +36 -0
  533. package/dist/lib/reset-space-plan.d.ts.map +1 -0
  534. package/dist/lib/reset-space-plan.js +181 -0
  535. package/dist/lib/reset-space-plan.js.map +1 -0
  536. package/dist/lib/restore.d.ts +3 -1
  537. package/dist/lib/restore.d.ts.map +1 -1
  538. package/dist/lib/restore.js +38 -10
  539. package/dist/lib/restore.js.map +1 -1
  540. package/dist/lib/seat-resume.d.ts +4 -1
  541. package/dist/lib/seat-resume.d.ts.map +1 -1
  542. package/dist/lib/seat-resume.js +7 -4
  543. package/dist/lib/seat-resume.js.map +1 -1
  544. package/dist/lib/service-adapters.d.ts +32 -0
  545. package/dist/lib/service-adapters.d.ts.map +1 -0
  546. package/dist/lib/service-adapters.js +55 -0
  547. package/dist/lib/service-adapters.js.map +1 -0
  548. package/dist/lib/service-census.d.ts +73 -0
  549. package/dist/lib/service-census.d.ts.map +1 -0
  550. package/dist/lib/service-census.js +42 -0
  551. package/dist/lib/service-census.js.map +1 -0
  552. package/dist/lib/service-definitions.d.ts +49 -0
  553. package/dist/lib/service-definitions.d.ts.map +1 -0
  554. package/dist/lib/service-definitions.js +61 -0
  555. package/dist/lib/service-definitions.js.map +1 -0
  556. package/dist/lib/service-install-intent.d.ts +48 -0
  557. package/dist/lib/service-install-intent.d.ts.map +1 -0
  558. package/dist/lib/service-install-intent.js +95 -0
  559. package/dist/lib/service-install-intent.js.map +1 -0
  560. package/dist/lib/service-instances.d.ts +143 -0
  561. package/dist/lib/service-instances.d.ts.map +1 -0
  562. package/dist/lib/service-instances.js +193 -0
  563. package/dist/lib/service-instances.js.map +1 -0
  564. package/dist/lib/service-journal.d.ts +38 -0
  565. package/dist/lib/service-journal.d.ts.map +1 -0
  566. package/dist/lib/service-journal.js +210 -0
  567. package/dist/lib/service-journal.js.map +1 -0
  568. package/dist/lib/service-launchd-plan.d.ts +21 -0
  569. package/dist/lib/service-launchd-plan.d.ts.map +1 -0
  570. package/dist/lib/service-launchd-plan.js +69 -0
  571. package/dist/lib/service-launchd-plan.js.map +1 -0
  572. package/dist/lib/service-launchd-unit.d.ts +20 -0
  573. package/dist/lib/service-launchd-unit.d.ts.map +1 -0
  574. package/dist/lib/service-launchd-unit.js +66 -0
  575. package/dist/lib/service-launchd-unit.js.map +1 -0
  576. package/dist/lib/service-presets.d.ts +17 -0
  577. package/dist/lib/service-presets.d.ts.map +1 -0
  578. package/dist/lib/service-presets.js +138 -0
  579. package/dist/lib/service-presets.js.map +1 -0
  580. package/dist/lib/service-private-seed.d.ts +7 -0
  581. package/dist/lib/service-private-seed.d.ts.map +1 -0
  582. package/dist/lib/service-private-seed.js +64 -0
  583. package/dist/lib/service-private-seed.js.map +1 -0
  584. package/dist/lib/service-private-tree.d.ts +6 -0
  585. package/dist/lib/service-private-tree.d.ts.map +1 -0
  586. package/dist/lib/service-private-tree.js +100 -0
  587. package/dist/lib/service-private-tree.js.map +1 -0
  588. package/dist/lib/service-process.d.ts +121 -0
  589. package/dist/lib/service-process.d.ts.map +1 -0
  590. package/dist/lib/service-process.js +742 -0
  591. package/dist/lib/service-process.js.map +1 -0
  592. package/dist/lib/service-stopped-allocation.d.ts +6 -0
  593. package/dist/lib/service-stopped-allocation.d.ts.map +1 -0
  594. package/dist/lib/service-stopped-allocation.js +42 -0
  595. package/dist/lib/service-stopped-allocation.js.map +1 -0
  596. package/dist/lib/service-supervision.d.ts +59 -0
  597. package/dist/lib/service-supervision.d.ts.map +1 -0
  598. package/dist/lib/service-supervision.js +71 -0
  599. package/dist/lib/service-supervision.js.map +1 -0
  600. package/dist/lib/service-systemd-attempt-read.d.ts +40 -0
  601. package/dist/lib/service-systemd-attempt-read.d.ts.map +1 -0
  602. package/dist/lib/service-systemd-attempt-read.js +80 -0
  603. package/dist/lib/service-systemd-attempt-read.js.map +1 -0
  604. package/dist/lib/service-systemd-control.d.ts +38 -0
  605. package/dist/lib/service-systemd-control.d.ts.map +1 -0
  606. package/dist/lib/service-systemd-control.js +141 -0
  607. package/dist/lib/service-systemd-control.js.map +1 -0
  608. package/dist/lib/service-systemd-files.d.ts +8 -0
  609. package/dist/lib/service-systemd-files.d.ts.map +1 -0
  610. package/dist/lib/service-systemd-files.js +63 -0
  611. package/dist/lib/service-systemd-files.js.map +1 -0
  612. package/dist/lib/service-systemd-install.d.ts +17 -0
  613. package/dist/lib/service-systemd-install.d.ts.map +1 -0
  614. package/dist/lib/service-systemd-install.js +146 -0
  615. package/dist/lib/service-systemd-install.js.map +1 -0
  616. package/dist/lib/service-systemd-plan.d.ts +28 -0
  617. package/dist/lib/service-systemd-plan.d.ts.map +1 -0
  618. package/dist/lib/service-systemd-plan.js +56 -0
  619. package/dist/lib/service-systemd-plan.js.map +1 -0
  620. package/dist/lib/service-systemd-reseed.d.ts +16 -0
  621. package/dist/lib/service-systemd-reseed.d.ts.map +1 -0
  622. package/dist/lib/service-systemd-reseed.js +106 -0
  623. package/dist/lib/service-systemd-reseed.js.map +1 -0
  624. package/dist/lib/service-systemd-uninstall-plan.d.ts +29 -0
  625. package/dist/lib/service-systemd-uninstall-plan.d.ts.map +1 -0
  626. package/dist/lib/service-systemd-uninstall-plan.js +56 -0
  627. package/dist/lib/service-systemd-uninstall-plan.js.map +1 -0
  628. package/dist/lib/service-systemd-uninstall.d.ts +17 -0
  629. package/dist/lib/service-systemd-uninstall.d.ts.map +1 -0
  630. package/dist/lib/service-systemd-uninstall.js +106 -0
  631. package/dist/lib/service-systemd-uninstall.js.map +1 -0
  632. package/dist/lib/service-systemd-unit.d.ts +28 -0
  633. package/dist/lib/service-systemd-unit.d.ts.map +1 -0
  634. package/dist/lib/service-systemd-unit.js +73 -0
  635. package/dist/lib/service-systemd-unit.js.map +1 -0
  636. package/dist/lib/service-systemd.d.ts +49 -0
  637. package/dist/lib/service-systemd.d.ts.map +1 -0
  638. package/dist/lib/service-systemd.js +134 -0
  639. package/dist/lib/service-systemd.js.map +1 -0
  640. package/dist/lib/service-uninstall-intent.d.ts +38 -0
  641. package/dist/lib/service-uninstall-intent.d.ts.map +1 -0
  642. package/dist/lib/service-uninstall-intent.js +74 -0
  643. package/dist/lib/service-uninstall-intent.js.map +1 -0
  644. package/dist/lib/service-unit-action.d.ts +24 -0
  645. package/dist/lib/service-unit-action.d.ts.map +1 -0
  646. package/dist/lib/service-unit-action.js +61 -0
  647. package/dist/lib/service-unit-action.js.map +1 -0
  648. package/dist/lib/setup-log.d.ts +5 -4
  649. package/dist/lib/setup-log.d.ts.map +1 -1
  650. package/dist/lib/setup-log.js +18 -9
  651. package/dist/lib/setup-log.js.map +1 -1
  652. package/dist/lib/space-schema-inspection.d.ts +73 -0
  653. package/dist/lib/space-schema-inspection.d.ts.map +1 -0
  654. package/dist/lib/space-schema-inspection.js +118 -0
  655. package/dist/lib/space-schema-inspection.js.map +1 -0
  656. package/dist/lib/space-schema-report.d.ts +82 -0
  657. package/dist/lib/space-schema-report.d.ts.map +1 -0
  658. package/dist/lib/space-schema-report.js +109 -0
  659. package/dist/lib/space-schema-report.js.map +1 -0
  660. package/dist/lib/spawn-defaults.d.ts +14 -0
  661. package/dist/lib/spawn-defaults.d.ts.map +1 -0
  662. package/dist/lib/spawn-defaults.js +20 -0
  663. package/dist/lib/spawn-defaults.js.map +1 -0
  664. package/dist/lib/stack-journal.d.ts +92 -0
  665. package/dist/lib/stack-journal.d.ts.map +1 -0
  666. package/dist/lib/stack-journal.js +199 -0
  667. package/dist/lib/stack-journal.js.map +1 -0
  668. package/dist/lib/stack-resume.d.ts +35 -0
  669. package/dist/lib/stack-resume.d.ts.map +1 -0
  670. package/dist/lib/stack-resume.js +123 -0
  671. package/dist/lib/stack-resume.js.map +1 -0
  672. package/dist/lib/status.d.ts +19 -20
  673. package/dist/lib/status.d.ts.map +1 -1
  674. package/dist/lib/status.js +41 -40
  675. package/dist/lib/status.js.map +1 -1
  676. package/dist/lib/steps.d.ts.map +1 -1
  677. package/dist/lib/steps.js +3 -2
  678. package/dist/lib/steps.js.map +1 -1
  679. package/dist/lib/systemd-supervision.d.ts +11 -4
  680. package/dist/lib/systemd-supervision.d.ts.map +1 -1
  681. package/dist/lib/systemd-supervision.js +19 -8
  682. package/dist/lib/systemd-supervision.js.map +1 -1
  683. package/dist/lib/team-additive-attempt.d.ts +286 -0
  684. package/dist/lib/team-additive-attempt.d.ts.map +1 -0
  685. package/dist/lib/team-additive-attempt.js +387 -0
  686. package/dist/lib/team-additive-attempt.js.map +1 -0
  687. package/dist/lib/team-additive-native.d.ts +17 -0
  688. package/dist/lib/team-additive-native.d.ts.map +1 -0
  689. package/dist/lib/team-additive-native.js +29 -0
  690. package/dist/lib/team-additive-native.js.map +1 -0
  691. package/dist/lib/team-agent-removal.d.ts +104 -0
  692. package/dist/lib/team-agent-removal.d.ts.map +1 -0
  693. package/dist/lib/team-agent-removal.js +121 -0
  694. package/dist/lib/team-agent-removal.js.map +1 -0
  695. package/dist/lib/team-channel-removal.d.ts +220 -0
  696. package/dist/lib/team-channel-removal.d.ts.map +1 -0
  697. package/dist/lib/team-channel-removal.js +258 -0
  698. package/dist/lib/team-channel-removal.js.map +1 -0
  699. package/dist/lib/team-deploy-inspection.d.ts +59 -0
  700. package/dist/lib/team-deploy-inspection.d.ts.map +1 -0
  701. package/dist/lib/team-deploy-inspection.js +177 -0
  702. package/dist/lib/team-deploy-inspection.js.map +1 -0
  703. package/dist/lib/team-fresh.d.ts +73 -0
  704. package/dist/lib/team-fresh.d.ts.map +1 -0
  705. package/dist/lib/team-fresh.js +207 -0
  706. package/dist/lib/team-fresh.js.map +1 -0
  707. package/dist/lib/team-removal-reconcile.d.ts +118 -0
  708. package/dist/lib/team-removal-reconcile.d.ts.map +1 -0
  709. package/dist/lib/team-removal-reconcile.js +90 -0
  710. package/dist/lib/team-removal-reconcile.js.map +1 -0
  711. package/dist/lib/team-removal-record.d.ts +7 -0
  712. package/dist/lib/team-removal-record.d.ts.map +1 -0
  713. package/dist/lib/team-removal-record.js +46 -0
  714. package/dist/lib/team-removal-record.js.map +1 -0
  715. package/dist/lib/team-retained.d.ts +33 -0
  716. package/dist/lib/team-retained.d.ts.map +1 -0
  717. package/dist/lib/team-retained.js +55 -0
  718. package/dist/lib/team-retained.js.map +1 -0
  719. package/dist/lib/theme.d.ts.map +1 -1
  720. package/dist/lib/theme.js +9 -8
  721. package/dist/lib/theme.js.map +1 -1
  722. package/dist/lib/transient.d.ts +14 -9
  723. package/dist/lib/transient.d.ts.map +1 -1
  724. package/dist/lib/transient.js +25 -18
  725. package/dist/lib/transient.js.map +1 -1
  726. package/dist/lib/up-report.d.ts +1 -0
  727. package/dist/lib/up-report.d.ts.map +1 -1
  728. package/dist/lib/up-report.js +2 -1
  729. package/dist/lib/up-report.js.map +1 -1
  730. package/dist/lib/version.d.ts +8 -2
  731. package/dist/lib/version.d.ts.map +1 -1
  732. package/dist/lib/version.js +16 -9
  733. package/dist/lib/version.js.map +1 -1
  734. package/dist/seed/paths.d.ts +1 -1
  735. package/dist/seed/paths.js +1 -1
  736. package/dist/seed/reconcile.d.ts.map +1 -1
  737. package/dist/seed/reconcile.js +19 -3
  738. package/dist/seed/reconcile.js.map +1 -1
  739. package/dist/ui.d.ts +6 -0
  740. package/dist/ui.d.ts.map +1 -1
  741. package/dist/ui.js +12 -1
  742. package/dist/ui.js.map +1 -1
  743. package/dist/watch-data.d.ts +15 -0
  744. package/dist/watch-data.d.ts.map +1 -0
  745. package/dist/watch-data.js +66 -0
  746. package/dist/watch-data.js.map +1 -0
  747. package/dist/watch-json.d.ts +5 -0
  748. package/dist/watch-json.d.ts.map +1 -0
  749. package/dist/watch-json.js +131 -0
  750. package/dist/watch-json.js.map +1 -0
  751. package/dist/watch-view.d.ts +8 -0
  752. package/dist/watch-view.d.ts.map +1 -0
  753. package/dist/watch-view.js +65 -0
  754. package/dist/watch-view.js.map +1 -0
  755. package/package.json +8 -5
  756. package/dist/commands/service.d.ts +0 -17
  757. package/dist/commands/service.d.ts.map +0 -1
  758. package/dist/commands/service.js +0 -589
  759. package/dist/commands/service.js.map +0 -1
@@ -1,58 +1,118 @@
1
1
  import { spawnSync } from "node:child_process";
2
- import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
3
- import { dirname, join, resolve } from "node:path";
4
- import * as p from "@clack/prompts";
5
- import { registry } from "@cotal-ai/core";
6
- import { findCotalRoot, homeCotalDir, isWorkspaceTargetError, manifestExtensionNames, personaDir, provenance, resolveMeshTarget, resolveOnPath, seedConnectorServers, } from "@cotal-ai/workspace";
7
- import { materializeExtension } from "../ext-loader.js";
8
- import { agentSkillsHome, canonicalSkillNames, canonicalSkillsDir, installAgentSkills } from "../lib/agent-skills.js";
2
+ import { existsSync, mkdirSync, readFileSync, statSync } from "node:fs";
3
+ import { basename, dirname, join, resolve } from "node:path";
4
+ import * as p from "../lib/prompts.js";
5
+ import { registry, writePrivateRecord } from "@cotal-ai/core";
6
+ import { CommandFailure, OFFICIAL_CONNECTORS, isCommandFailure, renderReport, canonicalRoot, checkUserBundle, extensionPackageDir, findMesh, homeCotalDir, inputDisabledByFlag, jsonFlag, loadMeshes, manifestExtensionNames, meshFile, personaDir, plainFlag, preferenceSpaceProblem, preferencesPath, preparedSpaceAt, presentationOf, provenance, readPreferences, resolveOnPath, seedConnectorServers, writePreference, writeResult, } from "@cotal-ai/workspace";
7
+ import { OFFICIAL_RUNTIMES, OFFICIAL_RUNTIME_TOOLS, materializeExtension } from "../ext-loader.js";
8
+ import { agentSkillsHome, agentSkillsSkew, canonicalSkillsDir, installAgentSkills } from "../lib/agent-skills.js";
9
9
  import { cliVersion } from "../lib/version.js";
10
- import { brand, brandBold, dim, ok, note, splash } from "../lib/theme.js";
10
+ import { seedWriterKind } from "../seed/paths.js";
11
+ import { brand, brandBold, dim, note, splash } from "../lib/theme.js";
11
12
  import { runSteps } from "../lib/steps.js";
12
13
  import { abortIfCancel } from "../lib/cancel.js";
14
+ import { withInstallUmask } from "../lib/install-umask.js";
13
15
  import { openSetupLog } from "../lib/setup-log.js";
14
16
  import { resolveNatsServer } from "../lib/nats-bin.js";
15
17
  import { isOnboarded, markOnboarded } from "../lib/onboard.js";
16
- import { connectorHarnesses, connectorStatusRows, machineStatus, meshStatus, recordedWebUrl, webInstalled } from "../lib/status.js";
17
- import { managerUp } from "../lib/manager-proc.js";
18
+ import { seedDefaultPersona } from "../lib/default-persona.js";
18
19
  import { cotalOnPath, displayCmd, isNpx, selfArgv } from "../lib/self-exec.js";
20
+ import { addExtension } from "./ext.js";
21
+ import { canPrompt } from "./meshes-wizard.js";
22
+ import { runtimeProviders } from "./runtimes.js";
23
+ import { onInstance } from "../lib/control.js";
24
+ import { addFromBundle, checkLocalSpace, checkSelfHostedSpace, recordLocalSpace } from "./space-registration.js";
19
25
  const ONBOARD_VERSION = "2";
20
- const README_URL = "https://github.com/Cotal-AI/Cotal/blob/main/README.md";
21
- const NATS_RELEASES_URL = "https://github.com/nats-io/nats-server/releases";
22
- /** `cotal setup`'s grammar — configure-only knobs. The old `--auth`/`--open` flags configured the
23
- * MESH MODE at setup-launch time; setup no longer launches anything, so both are gone here —
24
- * mesh mode is `cotal up [--open]`'s concern (where `--open` already lived; `--auth` simply died
25
- * with the launch behavior). An unknown-option error rejects them, nothing silently. */
26
+ /** Setup saves its preparation before a separate start decision. Scripts name every input;
27
+ * an explicit start must detach so no script inherits a terminal view. */
26
28
  export const setupFlags = [
27
- { name: "full", type: "boolean", description: "redo the full guided flow (implies --demo)" },
29
+ { name: "destination", type: "string", value: "<local|self-hosted>", description: "where the space runs: local (this machine starts it) or self-hosted (a space registered here); Cloud is in development" },
30
+ { name: "harness", short: "H", type: "string", value: "<connector>", description: "the application your agents run in: its own setup runs, and `cotal spawn` in the space launches it" },
31
+ { name: "project", type: "string", value: "<dir>", description: "the project folder: the space's root, whose .cotal/agents holds its personas" },
32
+ { name: "space", short: "s", type: "string", value: "<name>", description: "the space to prepare (local) or the registered space to use (self-hosted)" },
33
+ { name: "runtime", type: "string", multiple: true, value: "<name>", description: "a runtime to set up besides the built-in pty: tmux, cmux, orca, herdr or an installed one (repeatable); none without it" },
34
+ { name: "connection-file", type: "string", value: "<bundle.json>", description: "self-hosted: register the space from a connection bundle exported where it runs" },
35
+ { name: "configure-only", type: "boolean", description: "write the preparation and start nothing (the default)" },
36
+ { name: "start", type: "boolean", description: "after preparation, start the local stack when needed and launch the default persona; scripts require --detach" },
37
+ { name: "on", type: "string", value: "<instance>", description: "self-hosted startup: launch through this manager instance, not class selection" },
38
+ { name: "detach", short: "d", type: "boolean", description: "with --start, leave the managed agent running without opening its terminal" },
39
+ { name: "full", type: "boolean", description: "the guided flow with the guided expert team (implies --demo)" },
28
40
  { name: "demo", type: "boolean", description: "also seed the guided expert team (david, sven, me)" },
29
- { name: "yes", type: "boolean", short: "y", description: "non-interactive accept-all (agents/CI)" },
41
+ { name: "yes", short: "y", type: "boolean", description: "ask nothing: every input comes from the flags" },
30
42
  { name: "skills", type: "boolean", description: "reconcile Cotal skills through installed connector providers and ~/.agents/skills; no personas or onboard writes" },
43
+ jsonFlag,
44
+ plainFlag,
31
45
  ];
46
+ /** The inputs a script names as flags. */
47
+ const REQUIRED = ["destination", "harness", "project", "space"];
48
+ const INPUTS = [...REQUIRED, "runtime", "connection-file", "configure-only", "start", "on", "detach", "json", "plain"];
49
+ const usage = (message, remedy) => new CommandFailure("refused", "USAGE_INVALID", message, remedy ? { remedy } : {});
50
+ const SCRIPTED_FORM = "cotal setup --destination local --harness <connector> --project <dir> --space <name> [--runtime <name>]";
51
+ /** Input-only validation before connector seeding or preparation writes. */
52
+ export function validateSetupArguments(args) {
53
+ const values = args.values;
54
+ if (args.positionals.length)
55
+ throw usage("setup takes flags, not positional inputs");
56
+ if (values.skills) {
57
+ if (values.full || values.demo)
58
+ throw usage("--skills cannot be combined with --full or --demo");
59
+ const other = INPUTS.find((flag) => values[flag] !== undefined);
60
+ if (other)
61
+ throw usage(`--skills reconciles skills only, so it takes no --${other}`);
62
+ return;
63
+ }
64
+ if (values.destination !== undefined)
65
+ destinationOf(values.destination);
66
+ if (values.start && values["configure-only"])
67
+ throw usage("choose --start or --configure-only, not both");
68
+ if (values.detach && !values.start)
69
+ throw usage("--detach requires an explicit --start");
70
+ const interactive = presentationOf(values) === "rich" && !values.yes && canPrompt();
71
+ if (values.on !== undefined) {
72
+ onInstance(values.on, "cotal setup");
73
+ if (values.destination === "local")
74
+ throw usage("--on selects a self-hosted manager; local startup pins the manager this root starts");
75
+ if (values["configure-only"] || (!values.start && !interactive))
76
+ throw usage("--on requires a possible startup; pass --start for a scripted setup");
77
+ }
78
+ if (values.start && !values.detach && !interactive)
79
+ throw usage("setup --start requires --detach when it cannot open an interactive terminal");
80
+ if (!interactive)
81
+ scriptedInputs(values, runtimeChoices());
82
+ }
32
83
  /**
33
- * `cotal setup`: guided setup — CONFIGURE-ONLY, state-independent. It checks prerequisites,
34
- * installs the Claude Code plugin, and seeds persona files; it NEVER launches anything (no mesh,
35
- * no web, no manager, no delivery daemon, no cmux/tmux session — launching is `cotal up` /
36
- * `cotal web` / `cotal supervise`). Every file it writes is announced (`→ wrote …`). First run
37
- * (no onboarded stamp) gets the full narrated flow; later runs get a status card. `--full`
38
- * forces the full flow. By default it seeds ONE agent (the `default` persona a bare `cotal spawn`
39
- * launches); the guided expert team (david/sven/me) is opt-in via `--demo` (and `--full`). Each
40
- * failed step offers the debug handoff of each present connector that declares one
41
- * (COTAL_SKIP_ASSIST=1 disables).
84
+ * Setup prepares a space before a separate, explicit startup decision. Its inputs are the
85
+ * destination (a local space this machine starts, or a self-hosted one registered here), the
86
+ * application (the connector your agents run in), the runtimes to set up besides the built-in
87
+ * `pty`, the project folder (the space's root) and the space name. On a terminal it asks for each
88
+ * one no flag gave and shows the answers before it writes; in a script every one is a flag, and a
89
+ * missing one is refused before anything is written. It then prepares or registers the space,
90
+ * seeds the default persona into the project's `.cotal/agents`, records the application as the
91
+ * space's `harness` preference and, when you have none, as your own, runs the application's own
92
+ * setup actions, reconciles Cotal's skills and sets up the chosen runtimes. A rerun with the same
93
+ * answers changes nothing.
94
+ * `--start` launches only after preparation is complete; scripts must detach.
95
+ * `--skills` only reconciles skills.
42
96
  */
43
97
  export async function setup(args) {
98
+ validateSetupArguments(args);
44
99
  const values = args.values;
45
100
  if (values.skills) {
46
- if (values.full || values.demo)
47
- throw new Error("--skills cannot be combined with --full or --demo");
48
101
  await runSkillsOnly();
49
102
  return;
50
103
  }
51
- const demo = Boolean(values.demo) || Boolean(values.full); // --full is the whole guided flow ⇒ team
52
- if (!isOnboarded() || values.full || values.yes)
53
- await runFirstRun(Boolean(values.yes), demo);
54
- else
55
- await runEnsure(demo);
104
+ const presentation = presentationOf(values);
105
+ if (values.destination !== undefined)
106
+ destinationOf(values.destination);
107
+ const interactive = presentation === "rich" && !values.yes && canPrompt();
108
+ const runtimes = runtimeChoices();
109
+ const inputs = interactive ? await askInputs(values, runtimes) : scriptedInputs(values, runtimes);
110
+ if (inputs === undefined)
111
+ return cancelled(presentation, values.space);
112
+ if (values.on !== undefined && inputs.destination !== "self-hosted")
113
+ throw usage("--on selects a self-hosted manager; local startup pins the manager this root starts");
114
+ const plan = await planSetup(inputs, runtimes);
115
+ await prepare(plan, { demo: Boolean(values.demo) || Boolean(values.full), interactive, presentation, start: values.start === true, detach: values.detach === true, configureOnly: values["configure-only"] === true, managerInstanceId: values.on });
56
116
  }
57
117
  /** Skills-only write for the status card: let installed connectors reconcile their own harness,
58
118
  * then reconcile `~/.agents/skills`. Does not seed personas, offer a global install, or write the
@@ -61,137 +121,639 @@ async function runSkillsOnly() {
61
121
  await reconcileConnectorSkills();
62
122
  seedAgentSkills();
63
123
  }
64
- /** The full, narrated first-run experience. `yes` = non-interactive accept-all; `demo` also seeds
65
- * the guided expert team. Configure-only: prerequisites are CHECKED (never started); the finale
66
- * tells the user what to run. */
67
- async function runFirstRun(yes, demo) {
68
- splash();
69
- p.intro(brandBold("Welcome to Cotal"));
70
- note("Cotal is the open web for agents: they join a shared space, see who's around, and coordinate as peers instead of in silos. Build whole agent societies, even across different machines, on one open web. Let's set yours up.", "Give your agents a place to work together");
71
- const log = openSetupLog();
72
- // Prerequisites — CHECKS only, no side effects, no prompts.
73
- const core = [
74
- {
75
- name: "node-version",
76
- title: "Check Node.js",
77
- explain: "Cotal needs Node 22 or newer.",
78
- context: [README_URL],
79
- async run() {
80
- const major = Number(process.versions.node.split(".")[0]);
81
- if (major < 22)
82
- throw new Error(`Node ${process.versions.node} is too old; Cotal needs Node >= 22`);
83
- return `Node ${process.versions.node}`;
84
- },
85
- },
86
- {
87
- name: "nats-binary",
88
- title: "Locate the NATS server",
89
- explain: "Cotal runs on NATS + JetStream, the wire your agents speak over. (Located only - `cotal up` starts it.)",
90
- context: [NATS_RELEASES_URL, README_URL],
91
- async run() {
92
- const r = await resolveNatsServer();
93
- return r.source === "path" ? "nats-server from PATH" : "bundled binary";
94
- },
95
- },
124
+ /** A destination this cut can prepare. Cloud is in development, so it is refused before anything is
125
+ * written or any endpoint is contacted. */
126
+ function destinationOf(value) {
127
+ if (value === "local" || value === "self-hosted")
128
+ return value;
129
+ if (value === "cloud")
130
+ throw new CommandFailure("refused", "UNSUPPORTED", "Cotal Cloud is in development, so setup cannot prepare a Cloud space yet", { remedy: "pass --destination local or --destination self-hosted" });
131
+ throw usage(`--destination ${value} is not a destination: pass local or self-hosted`);
132
+ }
133
+ /** The inputs of a run that asks nothing: every one is a flag, and the project folder exists. No
134
+ * `--runtime` sets up no runtime beyond `pty`. */
135
+ function scriptedInputs(v, choices) {
136
+ const missing = REQUIRED.filter((flag) => v[flag] === undefined);
137
+ if (missing.length > 0)
138
+ throw usage(`setup asks nothing here, so every input is a flag: pass ${missing.map((flag) => `--${flag}`).join(", ")}`, SCRIPTED_FORM);
139
+ const project = resolve(v.project);
140
+ if (!isDir(project))
141
+ throw usage(`--project ${project} is not a directory`, "create the folder first, or pass an existing one");
142
+ return { destination: destinationOf(v.destination), harness: v.harness, runtimes: runtimeFlags(v.runtime ?? [], choices), project, createProject: false, space: v.space, ...(v["connection-file"] === undefined ? {} : { connectionFile: v["connection-file"] }) };
143
+ }
144
+ /**
145
+ * Asks for each input no flag gave: destination, application, runtimes, then the project and
146
+ * space. The answers are shown before anything is written. Change asks every question again with
147
+ * the answers so far, and Cancel saves nothing.
148
+ */
149
+ async function askInputs(v, choices) {
150
+ const runtimes = v.runtime === undefined ? undefined : runtimeFlags(v.runtime, choices);
151
+ if (!isOnboarded())
152
+ splash();
153
+ p.intro(brandBold("Set up Cotal"));
154
+ const candidates = await harnessCandidates(v.harness);
155
+ let given = {
156
+ ...(v.destination === undefined ? {} : { destination: destinationOf(v.destination) }),
157
+ ...(v.harness === undefined ? {} : { harness: v.harness }),
158
+ ...(runtimes === undefined ? {} : { runtimes }),
159
+ ...(v.project === undefined ? {} : { project: resolve(v.project) }),
160
+ ...(v.space === undefined ? {} : { space: v.space }),
161
+ ...(v["connection-file"] === undefined ? {} : { connectionFile: v["connection-file"] }),
162
+ };
163
+ let again = false;
164
+ for (;;) {
165
+ const ask = (key) => again || given[key] === undefined;
166
+ const destination = ask("destination") ? await askDestination(given.destination) : given.destination;
167
+ const harness = ask("harness") ? await askHarness(candidates, given.harness) : given.harness;
168
+ const runtimes = ask("runtimes") ? await askRuntimes(choices, given.runtimes) : given.runtimes;
169
+ const place = destination === "local" ? await askLocal(given, ask) : await askSelfHosted(given, ask);
170
+ const inputs = { destination, harness, runtimes, ...place };
171
+ note([
172
+ `destination ${destination === "local" ? "Local" : "Self-hosted"}`,
173
+ `application ${harness}`,
174
+ `runtimes ${["pty", ...runtimes].join(", ")}`,
175
+ `project ${inputs.project}${inputs.createProject ? " (created on save)" : ""}`,
176
+ `space ${inputs.space}`,
177
+ ...(inputs.connectionFile === undefined ? [] : [`registered from ${inputs.connectionFile}`]),
178
+ ].join("\n"), "Your setup");
179
+ const choice = abortIfCancel(await p.select({
180
+ message: "Save it?",
181
+ options: [
182
+ { value: "save", label: "Save" },
183
+ { value: "change", label: "Change an answer" },
184
+ { value: "cancel", label: "Cancel", hint: "nothing is saved" },
185
+ ],
186
+ initialValue: "save",
187
+ }));
188
+ if (choice === "save")
189
+ return inputs;
190
+ if (choice === "cancel")
191
+ return undefined;
192
+ given = inputs;
193
+ again = true;
194
+ }
195
+ }
196
+ async function askDestination(initial) {
197
+ return abortIfCancel(await p.select({
198
+ message: "Where does your space run?",
199
+ options: [
200
+ { value: "local", label: "Local", hint: "this machine starts it" },
201
+ { value: "self-hosted", label: "Self-hosted", hint: "it runs on a server and is registered here" },
202
+ { value: "cloud", label: "Cloud", hint: "in development", disabled: true },
203
+ ],
204
+ initialValue: initial ?? "local",
205
+ }));
206
+ }
207
+ async function askHarness(candidates, initial) {
208
+ return abortIfCancel(await p.select({
209
+ message: "Which application do your agents run in?",
210
+ options: candidates.map((c) => ({ value: c.value, label: c.label, hint: c.hint })),
211
+ initialValue: initial ?? candidates.find((c) => c.missing.length === 0)?.value ?? candidates[0].value,
212
+ }));
213
+ }
214
+ /** The runtimes to set up besides `pty`. Installed ones and those whose host tool is found start
215
+ * selected. A note lists every runtime's state first, because clack shows a hint only on the
216
+ * focused and selected rows, and a label is what the answer repeats. */
217
+ async function askRuntimes(choices, initial) {
218
+ const offered = choices.filter((r) => r.name !== "pty");
219
+ const width = Math.max(...choices.map((r) => r.name.length));
220
+ note(choices.map((r) => `${r.name.padEnd(width)} ${r.name === "pty" ? "built in, always set up" : runtimeState(r)}`).join("\n"), "Runtimes");
221
+ return abortIfCancel(await p.multiselect({
222
+ message: "Which runtimes do your agents run in?",
223
+ options: offered.map((r) => ({ value: r.name, label: r.name, hint: runtimeState(r) })),
224
+ initialValues: [...(initial ?? offered.filter((r) => r.installed || r.found !== null).map((r) => r.name))],
225
+ required: false,
226
+ }));
227
+ }
228
+ /** Whether a runtime is set up, and its host tool or, for a third-party one, its package. */
229
+ function runtimeState(r) {
230
+ const tool = r.tools.length === 0 ? r.package : r.found !== null ? `${r.found} found` : `${r.tools.join(" or ")} not on PATH`;
231
+ return `${r.installed ? "set up" : "not set up"}${tool ? ` · ${tool}` : ""}`;
232
+ }
233
+ /** A local space: the project folder, which a terminal may create, and the space's name. */
234
+ async function askLocal(given, ask) {
235
+ let project = given.project;
236
+ let createProject = given.createProject ?? false;
237
+ if (ask("project") || project === undefined) {
238
+ for (;;) {
239
+ project = resolve(abortIfCancel(await p.text({ message: "Project folder (the space's root)", initialValue: project ?? process.cwd(), validate: (s) => (s?.trim() ? undefined : "name a folder") })).trim());
240
+ if (isDir(project)) {
241
+ createProject = false;
242
+ break;
243
+ }
244
+ if (existsSync(project)) {
245
+ p.log.warn(`${project} is not a folder`);
246
+ continue;
247
+ }
248
+ if (abortIfCancel(await p.confirm({ message: `${project} does not exist. Create it?`, initialValue: true }))) {
249
+ createProject = true;
250
+ break;
251
+ }
252
+ }
253
+ }
254
+ const root = project;
255
+ const space = ask("space") || given.space === undefined
256
+ ? abortIfCancel(await p.text({ message: "Space name", initialValue: given.space ?? localSpaceAt(root), validate: (s) => preferenceSpaceProblem(s ?? "") })).trim()
257
+ : given.space;
258
+ return { project: root, createProject, space };
259
+ }
260
+ /** The space a project folder already holds, else one named after the folder. */
261
+ function localSpaceAt(root) {
262
+ const here = preparedSpaceAt(root)?.space ?? loadMeshes().find((m) => m.origin === "up" && canonicalRoot(m.root) === canonicalRoot(root))?.space;
263
+ if (here)
264
+ return here;
265
+ const named = basename(root).replace(/[^A-Za-z0-9_-]+/g, "-").replace(/^-+|-+$/g, "");
266
+ return named || "main";
267
+ }
268
+ const FROM_FILE = "\0file";
269
+ /** A self-hosted space: one registered here, whose root is the project, or one to register from a
270
+ * connection file into a project folder that exists. */
271
+ async function askSelfHosted(given, ask) {
272
+ const registered = loadMeshes().filter((m) => m.origin === "manual" || m.origin === "catalog");
273
+ let space = given.space;
274
+ if (ask("space") || space === undefined) {
275
+ const picked = registered.length === 0
276
+ ? FROM_FILE
277
+ : abortIfCancel(await p.select({
278
+ message: "Which space?",
279
+ options: [...registered.map((m) => ({ value: m.space, label: m.space, hint: `${m.server} · ${m.root}` })), { value: FROM_FILE, label: "Register one from a connection file" }],
280
+ initialValue: space !== undefined && registered.some((m) => m.space === space) ? space : registered[0].space,
281
+ }));
282
+ space = picked === FROM_FILE ? undefined : picked;
283
+ }
284
+ const entry = space === undefined ? undefined : findMesh(space);
285
+ if (entry)
286
+ return { project: given.project ?? entry.root, createProject: false, space: entry.space };
287
+ const connectionFile = ask("connectionFile") || given.connectionFile === undefined
288
+ ? resolve(abortIfCancel(await p.text({ message: "Connection file (exported where the space runs)", initialValue: given.connectionFile ?? "", validate: bundleProblem })).trim())
289
+ : given.connectionFile;
290
+ const project = ask("project") || given.project === undefined
291
+ ? resolve(abortIfCancel(await p.text({ message: "Project folder (the space's root)", initialValue: given.project ?? process.cwd(), validate: (s) => (isDir(resolve(s?.trim() ?? "")) ? undefined : "name a folder that exists") })).trim())
292
+ : given.project;
293
+ return { project, createProject: false, space: space ?? bundleSpace(connectionFile), connectionFile };
294
+ }
295
+ function bundleProblem(file) {
296
+ try {
297
+ const check = checkUserBundle(readFileSync(resolve(file?.trim() ?? ""), "utf8"));
298
+ return check.ok ? undefined : check.message.replace(/^✗ /, "");
299
+ }
300
+ catch (e) {
301
+ return `cannot read it (${e.code ?? e.message})`;
302
+ }
303
+ }
304
+ function bundleSpace(file) {
305
+ const check = checkUserBundle(readFileSync(file, "utf8"));
306
+ if (!check.ok)
307
+ throw usage(check.message.replace(/^✗ /, ""));
308
+ return check.value.space;
309
+ }
310
+ /** The applications setup can set up: every installed connector. With none installed, a `harness`
311
+ * no official connector provides is refused as a usage error, and the remedy names `cotal ext seed`
312
+ * only where it runs: it refuses a source checkout unless a sandboxed release test opts in. */
313
+ async function harnessCandidates(harness) {
314
+ const candidates = await setupConnectorCandidates(await setupConnectorSurface());
315
+ if (candidates.length > 0)
316
+ return candidates;
317
+ if (harness !== undefined && !Object.hasOwn(OFFICIAL_CONNECTORS, harness))
318
+ throw usage(`no harness "${harness}"; the official connectors are ${Object.keys(OFFICIAL_CONNECTORS).join(", ")}`);
319
+ const seeds = seedWriterKind() === "released" || process.env.COTAL_ALLOW_CHECKOUT_SEED === "1";
320
+ throw new CommandFailure("refused", "DEPENDENCY_UNAVAILABLE", "no connector is installed, so there is no application to set up", {
321
+ remedy: seeds ? "run `cotal ext seed`" : "this cotal is not a released install, so it does not seed connectors; run setup from an installed cotal-ai, or for a sandboxed release test set COTAL_ALLOW_CHECKOUT_SEED=1 and run `cotal ext seed`",
322
+ });
323
+ }
324
+ /** The runtimes setup offers: `pty`, the official ones in a stable order, then each third-party one
325
+ * an installed extension provides. */
326
+ function runtimeChoices() {
327
+ const providers = runtimeProviders();
328
+ const official = Object.keys(OFFICIAL_RUNTIMES).map((name) => {
329
+ const tool = OFFICIAL_RUNTIME_TOOLS[name] ?? { names: [] };
330
+ const override = tool.override === undefined ? undefined : process.env[tool.override]?.trim();
331
+ return { name, package: OFFICIAL_RUNTIMES[name], tools: tool.names, found: override || (tool.names.find((bin) => resolveOnPath(bin)) ?? null), installed: providers.has(name) };
332
+ });
333
+ const others = [...providers].filter(([name]) => name !== "pty" && !(name in OFFICIAL_RUNTIMES)).map(([name, pkg]) => ({ name, package: pkg ?? null, tools: [], found: null, installed: true }));
334
+ return [{ name: "pty", package: null, tools: [], found: null, installed: true }, ...official, ...others];
335
+ }
336
+ /** The `--runtime` names, checked before anything is written: each must be a runtime setup offers,
337
+ * and an official one needs its host tool found. `pty` is always set up, so naming it adds nothing. */
338
+ function runtimeFlags(names, choices) {
339
+ for (const name of names) {
340
+ const choice = choices.find((r) => r.name === name);
341
+ if (!choice)
342
+ throw usage(`--runtime ${name} is not a runtime: pass ${choices.map((r) => r.name).join(", ")}`, "install a third-party runtime with `cotal ext add <package>` first");
343
+ if (choice.tools.length > 0 && choice.found === null)
344
+ throw new CommandFailure("refused", "DEPENDENCY_UNAVAILABLE", `the ${name} runtime drives ${choice.tools.join(" or ")}, which is not on PATH`, { remedy: `install ${choice.tools[0]}, then run the same setup again` });
345
+ }
346
+ return [...new Set(names)].filter((name) => name !== "pty");
347
+ }
348
+ /** Every check setup makes before it writes: the space name, the application, the space at the
349
+ * destination, and for a local space the NATS server `cotal up` will run. */
350
+ async function planSetup(inputs, runtimes) {
351
+ const target = { space: inputs.space };
352
+ const problem = preferenceSpaceProblem(inputs.space);
353
+ if (problem)
354
+ throw usage(problem);
355
+ const candidates = await harnessCandidates(inputs.harness);
356
+ const candidate = candidates.find((c) => c.value === inputs.harness);
357
+ if (!candidate)
358
+ throw usage(`no harness "${inputs.harness}"; known harnesses: ${candidates.map((c) => c.value).join(", ")}`);
359
+ if (inputs.destination === "self-hosted")
360
+ return { inputs, runtimes, candidate, space: checkSelfHostedSpace(inputs.space, inputs.project, inputs.connectionFile) };
361
+ if (inputs.connectionFile !== undefined)
362
+ throw usage("--connection-file registers a self-hosted space", "pass --destination self-hosted, or drop --connection-file");
363
+ const state = checkLocalSpace(inputs.space, inputs.project, "--project", true);
364
+ try {
365
+ await resolveNatsServer();
366
+ }
367
+ catch (e) {
368
+ throw new CommandFailure("refused", "DEPENDENCY_UNAVAILABLE", e.message.split("\n")[0], { target, remedy: "install nats-server and put it on PATH, or reinstall cotal-ai under Node 22 or newer" });
369
+ }
370
+ return { inputs, runtimes, candidate, space: { kind: "local", state } };
371
+ }
372
+ /**
373
+ * Writes what the plan checked: the space, the personas, the `harness` preference, the
374
+ * application's own setup actions, Cotal's skills and the chosen runtimes. A harness or runtime
375
+ * whose host tool is missing, an action that does not finish, or a runtime that does not install or
376
+ * answer leaves the rest saved and the result partial.
377
+ */
378
+ async function prepare(plan, opts) {
379
+ const { inputs, candidate } = plan;
380
+ const target = { space: inputs.space };
381
+ const written = [];
382
+ const wrote = (what, path) => {
383
+ written.push({ what, path });
384
+ provenance.wrote(what, path);
385
+ };
386
+ const warnings = [];
387
+ let spaceState;
388
+ if (plan.space.kind === "add") {
389
+ const added = await addFromBundle(inputs.space, { file: plan.space.file, root: inputs.project, yes: !opts.interactive }, opts.interactive);
390
+ if (added === undefined)
391
+ return cancelled(opts.presentation, inputs.space);
392
+ warnings.push(...added.warnings);
393
+ written.push({ what: "space registration", path: meshFile(inputs.space) });
394
+ spaceState = "added";
395
+ }
396
+ else if (plan.space.kind === "registered") {
397
+ spaceState = "registered";
398
+ }
399
+ else {
400
+ if (inputs.createProject) {
401
+ mkdirSync(inputs.project, { recursive: true });
402
+ wrote("project folder", inputs.project);
403
+ }
404
+ if (plan.space.state === "created")
405
+ wrote("prepared space", recordLocalSpace(inputs.space, inputs.project).file);
406
+ spaceState = plan.space.state;
407
+ }
408
+ const persona = seedDefaultPersona(inputs.project);
409
+ if (persona)
410
+ wrote(persona.what, persona.path);
411
+ if (opts.demo) {
412
+ const agents = personaDir(inputs.project);
413
+ for (const [name, body] of Object.entries(DEMO_AGENTS))
414
+ writeDemoAgent(join(agents, `${name}.md`), body, wrote);
415
+ }
416
+ if (writePreference({ space: inputs.space }, "harness", inputs.harness, readPreferences().revision).changed)
417
+ wrote(`harness preference of ${inputs.space}`, preferencesPath());
418
+ // A space prepared later without setup takes the application from your own value. One you
419
+ // already chose stays as it is.
420
+ const prefs = readPreferences();
421
+ if (prefs.defaults.harness === undefined && writePreference({}, "harness", inputs.harness, prefs.revision).changed)
422
+ wrote("your harness preference", preferencesPath());
423
+ const narrate = opts.presentation === "rich";
424
+ const log = openSetupLog(join(inputs.project, ".cotal", "setup.log"));
425
+ const actions = actionRunner(narrate, opts.interactive, log);
426
+ if (candidate.missing.length === 0) {
427
+ const provider = await connectorSetupProvider(candidate.connector);
428
+ if (provider?.connector)
429
+ await actions.run(candidate.value, actionStep(provider.connector, { cotal: selfArgv() }, provider));
430
+ // Recheck inside each selected action so lost readiness is a recorded failure, never a skipped step.
431
+ const share = await connectorSetupProvider(candidate.connector);
432
+ if (share?.mcpServers)
433
+ await actions.run(candidate.value, actionStep(share.mcpServers, connectorShareInput(candidate.connector), share));
434
+ const skills = await connectorSetupProvider(candidate.connector);
435
+ if (skills?.skills)
436
+ await actions.run(candidate.value, actionStep(skills.skills, connectorSkillsInput(), skills));
437
+ }
438
+ // A connector's skills action runs for every connector whose harness is present, so someone using
439
+ // that harness gets Cotal's skills even without joining the mesh through it.
440
+ for (const other of await setupConnectorCandidates(await setupConnectorSurface())) {
441
+ if (other.value === candidate.value || other.missing.length > 0)
442
+ continue;
443
+ const provider = await connectorSetupProvider(other.connector);
444
+ if (provider?.skills)
445
+ await actions.run(other.value, actionStep(provider.skills, connectorSkillsInput(), provider));
446
+ }
447
+ if (agentSkillsSkew().some((s) => s.state !== "current")) {
448
+ const skills = seedAgentSkills(log);
449
+ written.push({ what: "cross-vendor skills", path: agentSkillsHome() });
450
+ if (narrate)
451
+ p.log.success(`Installed ${skills.installed.length} cross-vendor skill${skills.installed.length !== 1 ? "s" : ""} to ~/.agents/skills; read by Codex, Cursor, OpenCode, Gemini CLI, and Windsurf`);
452
+ for (const b of skills.backedUp)
453
+ warnings.push({ code: "SKILL_BACKED_UP", target, message: `your edited ${b.name} skill was backed up to ${b.path} before it was refreshed` });
454
+ }
455
+ const runtimes = await setUpRuntimes(plan.runtimes, inputs.runtimes, narrate, wrote);
456
+ if (!isOnboarded()) {
457
+ markOnboarded(ONBOARD_VERSION);
458
+ wrote("onboarded stamp", join(homeCotalDir(), "onboarded.json"));
459
+ }
460
+ if (narrate)
461
+ await offerGlobalInstall(!opts.interactive);
462
+ const failed = actions.failed ?? null;
463
+ const local = inputs.destination === "local" && spaceState !== "started";
464
+ const startup = { requested: opts.start, requestedManagerInstanceId: opts.managerInstanceId ?? null, state: "not-requested", stackAttempted: false, stack: null, agent: null, joinedAt: null, failure: null };
465
+ const result = {
466
+ kind: "setup",
467
+ destination: inputs.destination,
468
+ space: inputs.space,
469
+ project: inputs.project,
470
+ spaceState,
471
+ harness: { name: candidate.value, missing: candidate.missing, failed },
472
+ actions: actions.ran,
473
+ runtimes: runtimes.rows,
474
+ written,
475
+ startup,
476
+ next: local ? { command: `${displayCmd()} up`, cwd: inputs.project } : { command: `${displayCmd()} spawn --space ${inputs.space}${opts.managerInstanceId ? ` --on ${opts.managerInstanceId}` : ""}`, cwd: null },
477
+ };
478
+ const problems = [
479
+ ...(candidate.missing.length > 0
480
+ ? [{ message: candidate.unavailable ? `${candidate.value} is unavailable, so its own setup did not run` : `${candidate.value} needs ${candidate.missing.join(", ")} on PATH, so its own setup did not run`, remedy: `install or repair ${candidate.missing.join(", ")}, then run the same setup again` }]
481
+ : failed
482
+ ? [{ message: `${failed.title} did not finish (${failed.message})`, remedy: "fix it, then run the same setup again" }]
483
+ : []),
484
+ ...runtimes.problems,
96
485
  ];
97
- if (!(await runSteps(core, log, { yes, assists: connectorAssists })))
98
- return abort();
99
- // Connectors: which agents should be able to join. MEMBERSHIP is the live registry plus the
100
- // installed extension manifest — every connector that declares itself is a choice — and each
101
- // candidate's hints come from that connector's own declarations (`requires`, `setup`,
102
- // `pluginRoot`). No connector name is privileged here: the install itself is whatever the
103
- // connector's own setup provider declares.
104
- const candidates = setupConnectorCandidates(await setupConnectorSurface());
105
- const selected = await pickConnectors(candidates, yes);
106
- for (const candidate of candidates) {
107
- if (!selected.has(candidate.value))
486
+ const partial = problems.length === 0
487
+ ? undefined
488
+ : { message: `${problems.map((x) => x.message).join("; ")}; the rest is saved`, remedy: [...new Set(problems.map((x) => x.remedy))].join("; ") };
489
+ if (partial && opts.start)
490
+ startup.state = "preparation-incomplete";
491
+ let start = opts.start && partial === undefined;
492
+ if (!partial && !opts.start && !opts.configureOnly && opts.interactive) {
493
+ const answer = await p.confirm({ message: inputs.destination === "local" ? "Start this local space and open the default agent?" : "Launch the default agent on the registered space's manager?", initialValue: false });
494
+ start = answer === true;
495
+ startup.requested = start;
496
+ if (!start)
497
+ startup.state = "declined";
498
+ }
499
+ if (opts.interactive)
500
+ p.outro(brand(partial ? "Saved, with a step left to finish." : start ? "Saved. Starting…" : "Saved."));
501
+ if (start) {
502
+ try {
503
+ if (inputs.destination === "local") {
504
+ startup.stackAttempted = true;
505
+ const { startSetupLocalStack } = await import("./setup-start.js");
506
+ startup.stack = await startSetupLocalStack(inputs.project, inputs.space);
507
+ }
508
+ const { launchManagedPersona } = await import("./spawn.js");
509
+ await launchManagedPersona({ space: inputs.space, agent: inputs.harness, detach: opts.detach, ...(startup.stack ? { on: startup.stack.managerInstanceId, cwd: inputs.project } : opts.managerInstanceId ? { on: opts.managerInstanceId } : {}), ...(opts.presentation === "json" ? { json: true } : opts.presentation === "plain" ? { plain: true } : {}) }, ["default"], undefined, undefined, {
510
+ ready(agent, notices) {
511
+ startup.agent = agent;
512
+ startup.joinedAt = new Date().toISOString();
513
+ startup.state = "joined";
514
+ warnings.push(...notices);
515
+ if (opts.interactive && !opts.detach)
516
+ console.error(renderReport({ space: inputs.space, sections: [{ title: "Agent joined", blocks: [{ kind: "fields", rows: [["Agent", agent.name], ["Identity", agent.id], ["Manager", agent.managerInstanceId]] }, { kind: "lines", lines: [{ text: "Opening the allocated incarnation's terminal. Leaving the view sends no stop request.", tone: "hint" }] }] }] }, "rich"));
517
+ },
518
+ });
519
+ if (!startup.agent)
520
+ throw new CommandFailure("unknown", "OPERATION_UNKNOWN", "setup received no native joined receipt; no readiness was inferred");
521
+ }
522
+ catch (error) {
523
+ const known = isCommandFailure(error) ? error : undefined;
524
+ const unknown = known === undefined || known.outcome === "unknown";
525
+ startup.state = unknown ? "unknown" : known.outcome === "refused" ? "refused" : known.outcome === "failed" ? "failed" : "partial";
526
+ const failureTarget = setupFailureCoordinates(known?.target, inputs.space);
527
+ startup.failure = { code: known?.code ?? "OPERATION_UNKNOWN", outcome: known?.outcome ?? "unknown", target: failureTarget };
528
+ const failure = new CommandFailure(unknown ? "unknown" : "partial", unknown ? "OPERATION_UNKNOWN" : "OPERATION_PARTIAL", startup.agent ? "preparation is saved and the agent joined, but its terminal handoff did not finish" : "preparation is saved, but the requested startup did not finish", { target, native: { code: known?.code, outcome: known?.outcome, detail: { target: failureTarget } }, changed: [...written, ...(startup.agent ? [startup.agent] : [])], remedy: "inspect the recorded startup, selected space and original manager/agent before another attempt; saved preparation was not rolled back and startup was not retried" });
529
+ writeResult(opts.presentation, { command: "setup", target, result, warnings, failure }, setupView);
530
+ return;
531
+ }
532
+ }
533
+ writeResult(opts.presentation, { command: "setup", target, result, warnings, ...(partial ? { partial } : { noOp: !startup.requested && written.length === 0 && actions.ran.length === 0 }) }, setupView);
534
+ }
535
+ /**
536
+ * Sets up each selected runtime. An official one that is not installed is added the way `ext add`
537
+ * adds it, at this cotal's version, when its host tool is on PATH; then each selected provider is
538
+ * asked whether it answers. A runtime left unselected is never removed: `ext remove` does that.
539
+ */
540
+ async function setUpRuntimes(choices, selected, narrate, wrote) {
541
+ const rows = [];
542
+ const problems = [];
543
+ for (const r of choices) {
544
+ const tool = r.tools.length === 0 ? null : { names: r.tools, found: r.found };
545
+ const row = { name: r.name, package: r.package, tool };
546
+ if (r.name === "pty") {
547
+ rows.push({ ...row, selected: true, state: "built-in", reachable: null, error: null });
108
548
  continue;
109
- if (candidate.missing.length) {
110
- p.log.warn(`${candidate.value} needs ${candidate.missing.join(", ")} on PATH. Install it, then re-run ${displayCmd()} setup.`);
549
+ }
550
+ if (!selected.includes(r.name)) {
551
+ rows.push({ ...row, selected: false, state: r.installed ? "set-up" : "left-out", reachable: null, error: null });
111
552
  continue;
112
553
  }
113
- const provider = await availableSetupProvider(candidate.connector);
114
- if (provider?.connector) {
115
- if (!(await runSteps([actionStep(provider.connector, { cotal: selfArgv() })], log, { yes, assists: connectorAssists })))
116
- return abort();
554
+ let state = "set-up";
555
+ if (!r.installed && r.package !== null) {
556
+ if (r.found === null) {
557
+ rows.push({ ...row, selected: true, state: "left-out", reachable: null, error: `${r.tools.join(" or ")} not on PATH` });
558
+ problems.push({ message: `the ${r.name} runtime needs ${r.tools.join(" or ")} on PATH, so it is not set up`, remedy: `install ${r.tools[0]}, then run the same setup again` });
559
+ continue;
560
+ }
561
+ try {
562
+ // With --json or --plain, stdout carries the result alone.
563
+ await addExtension(`${r.package}@${cliVersion()}`, r.package, false, narrate ? console.log : (line) => console.error(line));
564
+ }
565
+ catch (e) {
566
+ const error = e.message;
567
+ rows.push({ ...row, selected: true, state: "left-out", reachable: null, error });
568
+ problems.push({ message: `the ${r.name} runtime did not install (${error.split("\n")[0]})`, remedy: "fix it, then run the same setup again" });
569
+ continue;
570
+ }
571
+ wrote(`${r.name} runtime`, extensionPackageDir(r.package));
572
+ state = "added";
117
573
  }
118
- else {
119
- p.log.success(`${candidate.value} ready (auto-wired when you spawn it)`);
120
- log.line(`connector ${candidate.value}: ready (no install)`);
574
+ try {
575
+ const reachable = (await materializeExtension({ kind: "runtime", name: r.name })).available();
576
+ rows.push({ ...row, selected: true, state, reachable, error: null });
577
+ if (!reachable)
578
+ problems.push({ message: `the ${r.name} runtime is set up but does not answer here`, remedy: `${r.tools.length > 0 ? `make sure ${r.tools.join(" or ")} works here, then ` : ""}see \`cotal runtimes\`` });
121
579
  }
122
- // Resolved again because the connector action can change what is on PATH, and a provider whose
123
- // executables are gone must not write.
124
- const share = (await availableSetupProvider(candidate.connector))?.mcpServers;
125
- if (share && !(await runSteps([actionStep(share, connectorShareInput(candidate.connector))], log, { yes, assists: connectorAssists })))
126
- return abort();
127
- }
128
- // A connector's skills action is independent of the mesh connector selection: it runs for every
129
- // connector whose harness is present, so someone using that harness gets Cotal's authored skills
130
- // even without joining the mesh through it (Claude Code, for one, does not read `.agents/skills`).
131
- for (const candidate of candidates) {
132
- if (candidate.missing.length)
133
- continue;
134
- const provider = await availableSetupProvider(candidate.connector);
135
- if (provider?.skills && !(await runSteps([actionStep(provider.skills, connectorSkillsInput())], log, { yes, assists: connectorAssists })))
136
- return abort();
137
- }
138
- // Your agent: the generic `default` persona a bare `cotal spawn` launches — one agent, yours to
139
- // shape. This is the whole first-run default; the guided expert team is opt-in right below.
140
- //
141
- // The destination is resolved ONCE, the way `spawn` resolves it, and announced BEFORE the write:
142
- // the persona has to land in the catalog spawn reads, and when that is not this folder the user
143
- // has to be told so by the output rather than discover it from a refusal an hour later.
144
- const dest = seedDefaultForSetup(process.cwd());
145
- p.log.success(`Seeded your agent (${join(dest.dir, "default.md")}) - spawn it with \`${displayCmd()} spawn\` once your mesh is up`);
146
- log.line(`default-agent: wrote ${join(dest.dir, "default.md")} (${dest.source === "mesh" ? `mesh ${dest.target.space}` : "cwd fallback"})`);
147
- // The guided expert team (david the engineer + sven the guide + me, your session) is opt-in:
148
- // `cotal setup --demo` (or `--full`). Keeps the default first run to one agent, not a crowd.
149
- if (demo)
150
- seedDemoTeam(dest, log);
151
- // Cotal's own skills, for the non-Claude harnesses, via the cross-vendor `.agents/skills` convention.
152
- const skills = seedAgentSkills(log);
153
- p.log.success(`Installed ${skills.installed.length} cross-vendor skill${skills.installed.length !== 1 ? "s" : ""} (${skills.installed.join(", ")}) to ~/.agents/skills; read by Codex, Cursor, OpenCode, Gemini CLI, and Windsurf`);
154
- if (skills.backedUp.length)
155
- p.log.warn(`Backed up your edited copy before refreshing: ${skills.backedUp.map((b) => `${b.name} -> ${b.path}`).join(", ")} (Cotal manages only its own skills under ~/.agents/skills).`);
156
- await offerGlobalInstall(yes);
157
- markOnboarded(ONBOARD_VERSION);
158
- provenance.wrote("onboarded stamp", join(homeCotalDir(), "onboarded.json"));
159
- const cmd = displayCmd();
160
- // The finale is the whole loop, minimal by default: start the mesh, talk to your one agent, watch
161
- // it in the browser, stop. The browser dashboard is the first experience; the terminal console is
162
- // the tail alternative. With --demo it names the team; without, it points at --demo.
163
- const driveLines = demo
164
- ? [
165
- `${ok("✓")} start the mesh ${dim(`${cmd} up --detach`)}`,
166
- `${ok("✓")} drive a session ${dim(`${cmd} spawn me`)}`,
167
- `${ok("✓")} ask the experts ${dim(`${cmd} spawn david · ${cmd} spawn sven`)}`,
168
- `${ok("✓")} watch the mesh ${dim(`${cmd} web`)}`,
169
- `${ok("✓")} stop everything ${dim(`${cmd} down`)}`,
170
- ]
171
- : [
172
- `${ok("✓")} start the mesh ${dim(`${cmd} up --detach`)}`,
173
- `${ok("✓")} talk to your agent ${dim(`${cmd} spawn`)}`,
174
- `${ok("✓")} watch the mesh ${dim(`${cmd} web`)}`,
175
- `${ok("✓")} stop everything ${dim(`${cmd} down`)}`,
176
- ];
177
- const tail = demo
178
- ? [dim(`Terminal instead of a browser? ${cmd} console`)]
179
- : [
180
- dim(`Terminal instead of a browser? ${cmd} console`),
181
- dim(`Want a guided team (david the engineer, sven the guide)? ${cmd} setup --demo`),
182
- ];
183
- note([
184
- "Everything is configured - nothing has been started. Bring your mesh up when you're ready:",
185
- "",
186
- ...driveLines,
187
- "",
188
- ...tail,
189
- dim(`Cotal not working? Tell your agent to send feedback (built-in cotal_feedback), or run ${cmd} feedback "<msg>".`),
190
- ].join("\n"), "You're set");
191
- p.outro(brand(yes ? "Cotal is configured." : "Happy meshing."));
192
- function abort() {
193
- p.outro(brand(`Setup paused. Fix the step above and run \`${displayCmd()} setup\` again.`));
194
- process.exitCode = 1;
580
+ catch (e) {
581
+ const error = e.message;
582
+ rows.push({ ...row, selected: true, state, reachable: null, error });
583
+ problems.push({ message: `the ${r.name} runtime did not load (${error.split("\n")[0]})`, remedy: r.package === null ? "see `cotal runtimes`" : `reinstall it with \`cotal ext add ${r.package}\`` });
584
+ }
585
+ }
586
+ return { rows, problems };
587
+ }
588
+ /** Runs connector-owned setup actions in order and stops at the first that does not finish. The rich
589
+ * presentation narrates each one, with the recovery menu on a terminal; the others run quietly. */
590
+ function actionRunner(narrate, interactive, log) {
591
+ const ran = [];
592
+ let failed;
593
+ return {
594
+ ran,
595
+ get failed() {
596
+ return failed;
597
+ },
598
+ async run(connector, step) {
599
+ if (failed)
600
+ return;
601
+ let error;
602
+ let detail = null;
603
+ const tracked = {
604
+ ...step,
605
+ async run() {
606
+ try {
607
+ const d = await step.run();
608
+ detail = d ?? null;
609
+ error = undefined;
610
+ return d;
611
+ }
612
+ catch (e) {
613
+ error = e.message;
614
+ throw e;
615
+ }
616
+ },
617
+ };
618
+ let finished;
619
+ if (narrate)
620
+ finished = await runSteps([tracked], log, { yes: !interactive, assists: connectorAssists });
621
+ else {
622
+ try {
623
+ await tracked.run();
624
+ log.line(`${step.name}: ok${detail ? ` · ${detail}` : ""}`);
625
+ finished = true;
626
+ }
627
+ catch {
628
+ log.line(`${step.name}: FAILED · ${error}`);
629
+ finished = false;
630
+ }
631
+ }
632
+ if (finished)
633
+ ran.push({ connector, action: step.name, title: step.title, detail });
634
+ else
635
+ failed = { connector, action: step.name, title: step.title, message: error ?? "stopped before it finished" };
636
+ },
637
+ };
638
+ }
639
+ function cancelled(presentation, space) {
640
+ const target = space === undefined ? null : { space };
641
+ const result = { kind: "setup-cancelled" };
642
+ writeResult(presentation, { command: "setup", target, result, noOp: true, warnings: [{ code: "USER_CANCELLED", target, message: "nothing was saved" }] }, () => ({
643
+ sections: [{ blocks: [{ kind: "lines", lines: [{ text: "nothing was saved", tone: "hint" }] }] }],
644
+ }));
645
+ }
646
+ const SPACE_STATE = {
647
+ created: "prepared by this setup",
648
+ prepared: "already prepared",
649
+ started: "already started here",
650
+ added: "registered by this setup",
651
+ registered: "already registered",
652
+ };
653
+ function setupView(r) {
654
+ const unready = r.runtimes.filter((x) => x.selected && (x.state === "left-out" || x.error !== null || x.reachable === false)).map((x) => x.name);
655
+ const head = r.startup.failure
656
+ ? { text: `saved ${r.space}; requested startup ${r.startup.state}`, tone: "waiting", mark: "!" }
657
+ : r.harness.missing.length > 0 || r.harness.failed
658
+ ? { text: `saved ${r.space}; ${r.harness.name} is not set up yet`, tone: "waiting", mark: "!" }
659
+ : unready.length > 0
660
+ ? { text: `set up ${r.space} for ${r.harness.name}; the ${unready.join(", ")} runtime${unready.length === 1 ? " is" : "s are"} not ready`, tone: "waiting", mark: "!" }
661
+ : r.written.length > 0 || r.actions.length > 0
662
+ ? { text: `set up ${r.space} for ${r.harness.name}`, tone: "ok", mark: "✓" }
663
+ : { text: `${r.space} is already set up for ${r.harness.name}`, tone: "ok", mark: "✓" };
664
+ const leftOut = r.runtimes.filter((x) => !x.selected && x.state === "left-out").map((x) => x.name);
665
+ const application = r.harness.missing.length > 0
666
+ ? { text: `${r.harness.name} · ${r.harness.missing.join(", ")} not on PATH`, tone: "failed" }
667
+ : r.harness.failed
668
+ ? { text: `${r.harness.name} · ${r.harness.failed.title} did not finish`, tone: "failed" }
669
+ : r.harness.name;
670
+ const fields = [
671
+ ["destination", r.destination],
672
+ ["project", r.project],
673
+ ["space", `${r.space} · ${SPACE_STATE[r.spaceState]}`],
674
+ ["application", application],
675
+ ...r.runtimes.filter((x) => x.selected || x.state !== "left-out").map((x) => ["runtime", runtimeCell(x)]),
676
+ ...(leftOut.length === 0 ? [] : [["not set up", leftOut.join(", ")]]),
677
+ ...r.actions.map((a) => ["ran", `${a.title}${a.detail ? ` · ${a.detail}` : ""}`]),
678
+ ...r.written.map((w) => ["wrote", `${w.what}: ${w.path}`]),
679
+ ];
680
+ const context = fields.filter(([name]) => name === "destination" || name === "project" || name === "space" || name === "application");
681
+ const prepared = [
682
+ ...r.runtimes.filter((item) => item.selected || item.state !== "left-out").map(runtimeCell),
683
+ ...r.actions.map((action) => ({ text: `${action.title}${action.detail ? ` · ${action.detail}` : ""}`, tone: "ok", mark: "✓" })),
684
+ ...r.written.map((item) => ({ text: item.what, tone: "ok", mark: "✓" })),
685
+ ];
686
+ const agent = r.startup.agent;
687
+ const concrete = agent && [agent.name, agent.managerInstanceId, r.space].every((value) => /^[A-Za-z0-9_-]+$/.test(value));
688
+ const nextCommand = r.startup.failure ? `${displayCmd()} status --space ${r.space}`
689
+ : agent ? concrete ? `${displayCmd()} attach ${agent.name} --space ${r.space} --on ${agent.managerInstanceId}` : `${displayCmd()} attach <name> --space <space> --on <manager-instance>`
690
+ : r.next.command;
691
+ return {
692
+ sections: [
693
+ { title: "Setup", blocks: [{ kind: "lines", lines: [head] }, { kind: "fields", rows: context }] },
694
+ ...(prepared.length ? [{ title: "Prepared", blocks: [{ kind: "lines", lines: prepared }] }] : []),
695
+ ...(leftOut.length ? [{ blocks: [{ kind: "lines", lines: [{ text: `Left out: ${leftOut.join(", ")}. Existing runtime installations were kept.`, tone: "hint" }] }] }] : []),
696
+ startupSection(r.startup),
697
+ { title: "Next", blocks: [{ kind: "commands", items: [{ command: nextCommand, description: r.startup.failure ? "Inspect the selected space and original startup before requesting another launch" : agent ? concrete ? "Return to the joined agent's exact manager" : "Use the full identities recorded above" : r.next.cwd === null ? "Continue from this setup" : `Run from ${r.next.cwd}` }] }] },
698
+ ],
699
+ };
700
+ }
701
+ /** Only declared routing/request coordinates reach a composite receipt. Native detail bodies,
702
+ * connection inputs and exception text are not part of setup's public result. */
703
+ function setupFailureCoordinates(value, space) {
704
+ const result = { space };
705
+ if (value === null || typeof value !== "object" || Array.isArray(value))
706
+ return result;
707
+ const native = value;
708
+ for (const key of ["managerInstanceId", "managerEpoch", "requestId", "requestedGoalId", "acceptedGoalId"]) {
709
+ const coordinate = native[key];
710
+ if (typeof coordinate === "string" && coordinate.length <= 512 && !/[\u0000-\u001f\u007f]/u.test(coordinate))
711
+ result[key] = coordinate;
712
+ if (key === "managerEpoch" && typeof coordinate === "number" && Number.isSafeInteger(coordinate) && coordinate >= 0)
713
+ result[key] = coordinate;
714
+ }
715
+ const coordinator = native.coordinator;
716
+ if (coordinator !== null && typeof coordinator === "object" && !Array.isArray(coordinator)) {
717
+ const { pid, token } = coordinator;
718
+ if (typeof pid === "number" && Number.isSafeInteger(pid) && pid > 0)
719
+ result.coordinator = { pid, token: typeof token === "string" && token.length <= 512 && !/[\u0000-\u001f\u007f]/u.test(token) ? token : null };
720
+ }
721
+ return result;
722
+ }
723
+ function startupSection(s) {
724
+ const label = s.state === "joined" ? { text: "Agent joined", tone: "ok", mark: "✓" }
725
+ : s.state === "unknown" ? { text: "Startup outcome unknown; inspect before retrying", tone: "waiting", mark: "!" }
726
+ : s.state === "refused" || s.state === "failed" ? { text: `Startup ${s.state}; preparation remains saved`, tone: "failed", mark: "✗" }
727
+ : s.state === "partial" || s.state === "preparation-incomplete" ? { text: "Startup incomplete; preparation remains saved", tone: "waiting", mark: "!" }
728
+ : s.state === "declined" ? { text: "Start declined; preparation saved", tone: "hint" }
729
+ : { text: "Configure only; no startup requested", tone: "hint" };
730
+ const rows = [
731
+ ["Startup", label],
732
+ ...(s.requestedManagerInstanceId ? [["Requested manager", s.requestedManagerInstanceId]] : []),
733
+ ...(s.stack ? [["Local startup", "Native up returned; exit status is not a stack-readiness receipt"], ["Selected manager", s.stack.managerInstanceId]] : s.stackAttempted ? [["Local startup", { text: "Command outcome unconfirmed", tone: "waiting" }]] : []),
734
+ ...(s.agent ? [["Agent", s.agent.name], ["Identity", s.agent.id], ["Lifecycle", s.agent.lifecycleUid], ["Manager receipt", s.agent.managerInstanceId], ["Joined receipt time", s.joinedAt ?? "not recorded"], ["Application", s.agent.harness], ["Runtime", s.agent.runtime]].map(([key, value]) => [key, value]) : []),
735
+ ...(s.failure ? [["Cause", s.failure.code]] : []),
736
+ ];
737
+ return { title: "Start", blocks: [{ kind: "fields", rows }, ...(s.agent ? [{ kind: "lines", lines: [{ text: "The manager confirmed the recorded presence join, not task completion or current whole-stack health.", tone: "hint" }] }] : [])] };
738
+ }
739
+ function runtimeCell(r) {
740
+ if (r.state === "built-in")
741
+ return `${r.name} · built in`;
742
+ if (r.state === "left-out")
743
+ return { text: `${r.name} · not set up: ${r.error}`, tone: "failed" };
744
+ const state = r.state === "added" ? "added" : "already set up";
745
+ if (r.error !== null)
746
+ return { text: `${r.name} · ${state} · did not load`, tone: "failed" };
747
+ if (r.reachable === false)
748
+ return { text: `${r.name} · ${state} · does not answer`, tone: "waiting" };
749
+ return `${r.name} · ${state}${r.reachable ? " · answers" : ""}`;
750
+ }
751
+ function isDir(path) {
752
+ try {
753
+ return statSync(path).isDirectory();
754
+ }
755
+ catch {
756
+ return false;
195
757
  }
196
758
  }
197
759
  /** When run via `npx` without a global `cotal`, offer to install it so the user can just type
@@ -201,7 +763,7 @@ async function runFirstRun(yes, demo) {
201
763
  export async function offerGlobalInstall(yes) {
202
764
  if (!isNpx() || cotalOnPath())
203
765
  return; // already have `cotal`, or not an npx run
204
- if (!yes && process.stdin.isTTY) {
766
+ if (!yes && process.stdin.isTTY && !inputDisabledByFlag()) {
205
767
  const go = abortIfCancel(await p.confirm({ message: "Install `cotal` globally so you can just type `cotal`?", initialValue: true }));
206
768
  if (!go) {
207
769
  p.log.info(`No problem - keep using ${dim("npx cotal-ai")}. Install later with ${dim("npm i -g cotal-ai")}.`);
@@ -211,7 +773,7 @@ export async function offerGlobalInstall(yes) {
211
773
  const pkg = `cotal-ai@${runningVersion() ?? "latest"}`;
212
774
  const s = p.spinner();
213
775
  s.start("Installing cotal globally");
214
- const r = spawnSync("npm", ["install", "-g", pkg], { encoding: "utf8" });
776
+ const r = withInstallUmask(() => spawnSync("npm", ["install", "-g", pkg], { encoding: "utf8" }));
215
777
  if (r.status === 0) {
216
778
  s.stop("Installed - you can now run `cotal`");
217
779
  }
@@ -232,28 +794,34 @@ function runningVersion() {
232
794
  return null;
233
795
  }
234
796
  }
235
- /** Every connector on the setup surface becomes a choice. Its OWN declarations drive the hints —
236
- * `requires` for readiness, `setup` for whether it runs connector-owned setup at all, `pluginRoot`
237
- * for how that reads — and connector names never gate membership. Exported for the genericity smoke. */
238
- export function setupConnectorCandidates(connectors, pathProbe = (bin) => !!resolveOnPath(bin)) {
239
- return [...connectors]
797
+ /** Every connector becomes a choice. Its provider owns setup readiness; the connector's launch
798
+ * requirements apply when no provider overrides them. Names never gate membership. */
799
+ export async function setupConnectorCandidates(connectors, pathProbe = (bin) => !!resolveOnPath(bin), providerFor = connectorSetupProvider) {
800
+ return Promise.all([...connectors]
240
801
  .sort((a, b) => a.name.localeCompare(b.name))
241
- .map((connector) => {
242
- const missing = (connector.requires ?? []).filter((bin) => !pathProbe(bin));
802
+ .map(async (connector) => {
803
+ const provider = await providerFor(connector);
804
+ const available = provider?.available?.();
805
+ const missing = available === undefined
806
+ ? (provider?.requires ?? connector.requires ?? []).filter((bin) => !pathProbe(bin))
807
+ : available ? [] : [provider.name];
243
808
  return {
244
809
  connector,
245
810
  value: connector.name,
246
811
  label: connector.name,
247
812
  missing,
248
- hint: missing.length
249
- ? `${missing.join(", ")} not on PATH`
250
- : connector.setup
251
- ? connector.pluginRoot
252
- ? "installs a plugin"
253
- : "runs its own setup"
254
- : "ready at spawn",
813
+ unavailable: available === false,
814
+ hint: available === false
815
+ ? `${provider.name} unavailable`
816
+ : missing.length
817
+ ? `${missing.join(", ")} not on PATH`
818
+ : connector.setup
819
+ ? connector.pluginRoot
820
+ ? "installs a plugin"
821
+ : "runs its own setup"
822
+ : "ready at spawn",
255
823
  };
256
- });
824
+ }));
257
825
  }
258
826
  /** Materialize every connector advertised by the registry or installed manifest. Exported so the
259
827
  * fail-loud smoke reaches the same discovery boundary as guided setup. */
@@ -263,49 +831,6 @@ export async function setupConnectorSurface() {
263
831
  names.add(name);
264
832
  return Promise.all([...names].sort().map((name) => materializeExtension({ kind: "connector", name })));
265
833
  }
266
- async function pickConnectors(candidates, yes) {
267
- const all = candidates.filter((candidate) => candidate.missing.length === 0).map((candidate) => candidate.value);
268
- if (yes || !process.stdin.isTTY)
269
- return new Set(all);
270
- // Common case: show what was detected and offer a visible Continue button (clack's multiselect
271
- // has no native one). Only "Customize" (or nothing detected) drops into the toggle list.
272
- if (all.length) {
273
- note(all.join(", "), "Agents found");
274
- const go = abortIfCancel(await p.confirm({ message: "Set these up?", active: "Continue", inactive: "Customize", initialValue: true }));
275
- if (go)
276
- return new Set(all);
277
- }
278
- const picked = abortIfCancel(await p.multiselect({
279
- message: "Pick the agents to set up (space toggles, enter continues)",
280
- options: [...candidates],
281
- initialValues: all,
282
- required: false,
283
- }));
284
- return new Set(picked);
285
- }
286
- /** The compact repeat-run: a one-glance status card, plus re-seeding the default persona if it's
287
- * missing (announced). Nothing is launched — the card tells you what's down and how to start it.
288
- * `--demo` here adds the guided team to an already-configured machine (no need to re-narrate). */
289
- async function runEnsure(demo) {
290
- // Same destination question as the first run, same disclosure: a repeat `cotal setup` is exactly
291
- // what the old refusal told the user to run, so it above all must seed where `spawn` reads.
292
- const dest = seedDefaultForSetup(process.cwd()); // ensure `cotal spawn` (no name) always has a default to launch
293
- p.log.success(`Your agent: ${join(dest.dir, "default.md")}`);
294
- if (demo)
295
- seedDemoTeam(dest); // `cotal setup --demo` on a configured machine: add the team, then card
296
- await reconcileConnectorSkills();
297
- for (const line of await refreshConnectorInstalls())
298
- p.log.success(line);
299
- seedAgentSkills(); // reconcile the cross-vendor `.agents/skills` drop so an upgrade + re-run isn't stale
300
- // A repeat `npx cotal-ai setup` on an onboarded machine that still lacks a durable `cotal` must
301
- // ALSO get the global-install offer — the first-run stamp is written once, so without this any
302
- // second setup (declined/failed install the first time, or a machine onboarded before the offer
303
- // existed) never installs `cotal`. The offer no-ops for a dev clone (`!isNpx()`) or an already
304
- // installed `cotal` (`cotalOnPath()`), so only the npx-without-cotal case is affected. Before the
305
- // card so its hints render `cotal` rather than `npx cotal-ai`.
306
- await offerGlobalInstall(false);
307
- await readyCard(process.cwd());
308
- }
309
834
  /** Resolve a connector's declared setup provider from the CONNECTOR the surface produced, never
310
835
  * from a name this file knows. A connector that declares none simply owns no setup; a DECLARED
311
836
  * provider that is missing or broken fails loud, because the base CLI never substitutes a built-in
@@ -326,13 +851,17 @@ async function availableSetupProvider(connector) {
326
851
  * compiler checks each call site's pairing of an action with the input it hands it. `NoInfer` infers
327
852
  * `I` from the action alone: inferring it from the input too widens it to accept a dropped
328
853
  * (`undefined`) input. */
329
- function actionStep(setup, input) {
854
+ function actionStep(setup, input, provider) {
330
855
  return {
331
856
  name: setup.name,
332
857
  title: setup.title,
333
858
  explain: setup.explain,
334
859
  context: [...(setup.context ?? [])],
335
- async run() { return setup.run(input); },
860
+ async run() {
861
+ if (!setupProviderAvailable(provider))
862
+ throw new Error(`${provider.name} is unavailable; ${setup.title} did not run`);
863
+ return setup.run(input);
864
+ },
336
865
  };
337
866
  }
338
867
  /** The generic Cotal inputs every connector-owned skills installer receives. Nothing in it names a
@@ -356,9 +885,11 @@ async function reconcileConnectorSkills() {
356
885
  export async function refreshConnectorInstalls() {
357
886
  const lines = [];
358
887
  for (const connector of await setupConnectorSurface()) {
359
- const refresh = (await availableSetupProvider(connector))?.refresh;
888
+ // Refresh owns installed state even when a harness executable disappeared. Its provider must
889
+ // distinguish an absent integration from one it cannot update; availability must not hide it.
890
+ const refresh = (await connectorSetupProvider(connector))?.refresh;
360
891
  if (refresh)
361
- lines.push(`${refresh.title}: ${await refresh.run({ cotal: selfArgv() })}`);
892
+ lines.push(`${refresh.title}: ${await refresh.run({ cotal: selfArgv(), skills: connectorSkillsInput() })}`);
362
893
  }
363
894
  return lines;
364
895
  }
@@ -373,90 +904,10 @@ async function connectorAssists() {
373
904
  }
374
905
  return assists;
375
906
  }
376
- /** Pure availability rule for connector-owned setup actions. No executable means no harness write;
377
- * the caller still continues to the cross-vendor Agent Skills reconcile. */
907
+ /** Provider-owned readiness or the declared executable check. An unavailable harness is skipped;
908
+ * an installed integration's refresh obligation is checked separately, without this filter. */
378
909
  export function setupProviderAvailable(provider) {
379
- return !(provider.requires?.some((command) => !resolveOnPath(command)) ?? false);
380
- }
381
- // The web dashboard is a first-party seeded extension now (@cotal-ai/web, in SEEDED_EXTENSIONS): the
382
- // boot reconcile installs and version-refreshes it from the umbrella's bundled payload, exactly like
383
- // the connectors. So setup no longer fetches it — by the time these steps run, the reconcile has
384
- // already seeded web at the binary's version.
385
- /** The `cotal · status` one-glance card: machine + mesh + web + manager status (read-only
386
- * probes — displaying state is not depending on it), plus the key commands. */
387
- export async function readyCard(cwd) {
388
- const mesh = await meshStatus(cwd);
389
- const m = await machineStatus();
390
- const connectorRows = await cardConnectorRows();
391
- const mgr = managerUp();
392
- const cmd = displayCmd();
393
- const web = cardWebRow(mesh, cmd);
394
- // Read the demo marker out of the catalog the card's own `spawn` hints will resolve — the same
395
- // seed destination, not a second cwd-derived guess. Hinting `cotal spawn me` off a `david.md` in
396
- // a directory spawn never opens is the identical defect, one line further down the output.
397
- const personas = seedDestination();
398
- const hasDemo = existsSync(join(personas.dir, "david.md")); // the guided team is present ⇒ richer hint
399
- const line = (on, text) => `${on ? ok("✓") : dim("○")} ${text}`;
400
- const remote = mesh.origin === "catalog" || mesh.origin === "manual";
401
- const meshLine = mesh.reachable === undefined
402
- ? `${mesh.server} · space ${mesh.space} · selected (not probed)`
403
- : mesh.reachable
404
- ? `${mesh.server} · space ${mesh.space}`
405
- : remote
406
- ? `${mesh.server} · space ${mesh.space} · unreachable`
407
- : `down · start: ${cmd} up --detach`;
408
- note([
409
- line(m.nats !== "missing", `NATS ${dim(m.nats === "missing" ? "missing" : m.nats)}`),
410
- ...connectorRows.map((r) => line(r.state === "ok", `${r.label.padEnd(8)} ${dim(r.text)}`)),
411
- line(mesh.reachable !== false, `mesh ${dim(meshLine)}`),
412
- line(web.up, `web ${dim(web.text)}`),
413
- line(mgr, `manager ${dim(mgr ? "running" : `not running · start: ${cmd} up, or: ${cmd} supervise`)}`),
414
- "",
415
- ...(remote ? [] : [`start the mesh: ${dim(`${cmd} up --detach`)}`]),
416
- // Match the hint to what's actually on disk: the guided team (with --demo) vs the one default agent.
417
- hasDemo
418
- ? `drive it: ${dim(`${cmd} spawn me`)} ${dim("(or david / sven)")}`
419
- : `drive it: ${dim(`${cmd} spawn`)} ${dim("(talk to your agent · guided team: " + cmd + " setup --demo)")}`,
420
- `watch it: ${dim(`${cmd} web`)} ${dim("(browser dashboard)")}`,
421
- `more: ${dim(`${cmd} console · ${cmd} down · ${cmd} feedback "<msg>" · ${cmd} --help`)}`,
422
- ].join("\n"), brandBold("cotal · status"));
423
- }
424
- /** The card's web row from the mesh's dashboard records. An unreadable `web.pid`, `web.session` or
425
- * extension record is named on the row, like the status Machine section, so the rest of the card
426
- * still prints. The dashboard records and the extension record are both read before either decides
427
- * the row, since status names each on its own row and a listening dashboard does not make its
428
- * package record readable. */
429
- function cardWebRow(mesh, cmd) {
430
- let url;
431
- let installed;
432
- const unreadable = [];
433
- try {
434
- url = recordedWebUrl({ root: mesh.root, space: mesh.space });
435
- }
436
- catch (e) {
437
- unreadable.push(e.message);
438
- }
439
- try {
440
- installed = webInstalled();
441
- }
442
- catch (e) {
443
- unreadable.push(e.message);
444
- }
445
- if (unreadable.length > 0)
446
- return { up: false, text: (url ? [url, ...unreadable] : unreadable).join(" · ") };
447
- if (url)
448
- return { up: true, text: url };
449
- return { up: false, text: installed ? `down · start: ${cmd} web` : `not installed · retry: ${cmd} setup` };
450
- }
451
- /** The card's connector-reported rows. A manifest that cannot list connectors becomes one row naming
452
- * why, like the status Machine section. */
453
- async function cardConnectorRows() {
454
- try {
455
- return await connectorStatusRows(connectorHarnesses());
456
- }
457
- catch (e) {
458
- return [{ label: "connectors", state: "error", text: e.message }];
459
- }
910
+ return provider.available?.() ?? !(provider.requires?.some((command) => !resolveOnPath(command)) ?? false);
460
911
  }
461
912
  /** Reconcile Cotal's authored skills into the cross-vendor `~/.agents/skills` directory that Codex,
462
913
  * Cursor, OpenCode, Gemini CLI, and Windsurf/Devin all read. Unlike the Claude Code plugin, these
@@ -476,196 +927,24 @@ function seedAgentSkills(log) {
476
927
  const MANAGED_MARKER = "# managed by cotal-setup";
477
928
  /** Write a setup-managed demo persona, refreshing it when its DEMO_AGENTS body changes — but never
478
929
  * silently clobber a file the user has taken ownership of (one without the marker): back it up to
479
- * `<name>.md.bak` first. Missing or marker-carrying files are written in place; every write is
480
- * announced. */
481
- function writeDemoAgent(path, body) {
930
+ * `<name>.md.bak` first. Missing or marker-carrying files are written in place, 0o600 and never
931
+ * through a symlink; every write goes through `wrote`. */
932
+ function writeDemoAgent(path, body, wrote) {
482
933
  if (existsSync(path)) {
483
934
  const cur = readFileSync(path, "utf8");
484
935
  if (cur === body)
485
936
  return; // already current
486
937
  if (!cur.includes(MANAGED_MARKER)) {
487
- writeFileSync(`${path}.bak`, cur); // preserve a user/pre-marker edit
488
- provenance.wrote("backup of your edited persona", `${path}.bak`);
938
+ writePrivateRecord(`${path}.bak`, cur); // preserve a user/pre-marker edit
939
+ wrote("backup of your edited persona", `${path}.bak`);
489
940
  }
490
941
  }
491
- writeFileSync(path, body);
492
- provenance.wrote("persona", path);
493
- }
494
- /** The default persona `cotal spawn` (no name) launches: a generic mesh agent, seeded once and
495
- * then the user's to shape. Unlike the demo team it is not generally refreshed; only the
496
- * byte-exact legacy template below is migrated, so any edit stands. Deleting it means the next
497
- * `cotal setup` writes a fresh copy.
498
- *
499
- * Channel scope is split intentionally: the ACTIVE set (`subscribe`) is EMPTY, so a fresh agent
500
- * isn't firehosed every channel on the mesh at boot, while the read and post ACLs permit it to
501
- * join, create, read, and post channels on demand. (`subscribe: [">"]` would auto-subscribe to
502
- * every channel, the old behavior.) */
503
- export const DEFAULT_AGENT = `---
504
- name: default_agent
505
- role: default
506
- description: An agent on the mesh
507
- tags: []
508
- subscribe: []
509
- allowSubscribe: [">"]
510
- allowPublish: [">"]
511
- capabilities: [spawn, run]
512
- ---
513
-
514
- You are an agent on the Cotal mesh - a shared space where agents join, see who's around, and
515
- coordinate as peers rather than working in silos. Use the Cotal tools available to you to find
516
- your peers and work with them. Edit this file to give yourself a name, role, and purpose.
517
- `;
518
- /** The byte-exact default template shipped before wildcard post permission. Keep this frozen: a
519
- * future edit to the current template must not make an older untouched file ineligible for repair. */
520
- export const LEGACY_DEFAULT_AGENT = [
521
- "---",
522
- "name: default_agent",
523
- "role: default",
524
- "description: An agent on the mesh",
525
- "tags: []",
526
- "subscribe: []",
527
- 'allowSubscribe: [">"]',
528
- "allowPublish: []",
529
- "capabilities: [spawn]",
530
- "---",
531
- "",
532
- "You are an agent on the Cotal mesh - a shared space where agents join, see who's around, and",
533
- "coordinate as peers rather than working in silos. Use the Cotal tools available to you to find",
534
- "your peers and work with them. Edit this file to give yourself a name, role, and purpose.",
535
- "",
536
- ].join("\n");
537
- /** Return the shipped replacement only for the byte-exact legacy default. Any user edit, including
538
- * whitespace or frontmatter changes, keeps the persona under user ownership. Exported so the
539
- * static template smoke can grade the upgrade decision without touching real setup state. */
540
- export function migrateLegacyDefaultAgent(current) {
541
- return current === LEGACY_DEFAULT_AGENT ? DEFAULT_AGENT : undefined;
542
- }
543
- export function reconcileDefaultAgent(path) {
544
- if (existsSync(path)) {
545
- const replacement = migrateLegacyDefaultAgent(readFileSync(path, "utf8"));
546
- if (replacement === undefined)
547
- return "unchanged";
548
- writeFileSync(path, replacement);
549
- return "migrated";
550
- }
551
942
  mkdirSync(dirname(path), { recursive: true });
552
- writeFileSync(path, DEFAULT_AGENT);
553
- return "seeded";
554
- }
555
- /**
556
- * Resolve the persona catalog to seed into, offline. `cwd` is a parameter so the smoke can drive
557
- * this without chdir'ing a shared process; production always passes `process.cwd()`.
558
- *
559
- * Deliberately NOT `resolveTargetOrExit`: that prunes the registry and exits the process on an
560
- * unresolved mesh. Setup is the command you run BEFORE a mesh exists, and on a fresh machine it
561
- * must still seed a persona rather than refuse.
562
- *
563
- * The fallback is narrow ON PURPOSE — `no-meshes` and nothing else. "No mesh is running" has one
564
- * honest answer (this folder), so seeding there and saying so is right. But `ambiguous-target`
565
- * (several meshes up, none selected) is a case where the OPERATOR has a real choice, and quietly
566
- * seeding the cwd would be this very defect wearing a different hat: a root chosen for them,
567
- * without being asked, that the spawn they run next may not read. Every other resolution failure
568
- * — unreadable trust, a stale auth root, an unrecorded user-auth space — is a fault to repair, not
569
- * a licence to guess a directory. Those RETHROW, and `command.ts` renders them with their own
570
- * recovery copy.
571
- */
572
- export function seedDestinationFor(cwd) {
573
- try {
574
- const target = resolveMeshTarget(cwd, {});
575
- // `personaRoot` is the target's own `<root>/.cotal/agents` — the exact string spawn resolves
576
- // its persona file under. Taken from the target rather than recomputed, so the two cannot drift.
577
- return { dir: target.personaRoot, source: "mesh", target };
578
- }
579
- catch (e) {
580
- // ONLY "there is no mesh at all" falls back. Anything else is a decision that is not setup's
581
- // to make, or a fault that wants fixing; either way the cwd is not the answer.
582
- if (isWorkspaceTargetError(e) && e.code === "no-meshes")
583
- return { dir: personaDir(findCotalRoot(cwd)), source: "cwd", reason: e.message };
584
- throw e;
585
- }
586
- }
587
- function seedDestination() {
588
- return seedDestinationFor(process.cwd());
589
- }
590
- /**
591
- * Say where the personas are going, ABSOLUTE, before anything is written.
592
- *
593
- * The rule is NOT "never use the cwd" — it is "never use a root SILENTLY". The whole defect was a
594
- * cwd-derived root substituted for the mesh's without the output disclosing it, so the user read
595
- * `Seeded your agent (.cotal/agents/default.md)` and reasonably assumed the folder they were
596
- * standing in. Every path through this function therefore names the destination in full:
597
- *
598
- * - mesh root == cwd root : the ordinary single-project case. Still printed, just without the
599
- * comparison, because there is no divergence to explain.
600
- * - mesh root != cwd root : the case that bit. Prints BOTH roots, so the difference is visible
601
- * in the output rather than discoverable only from a later refusal.
602
- * - no mesh at all : the fresh-machine fallback, where the cwd IS the honest answer. Says
603
- * it fell back, why, and where it is writing.
604
- */
605
- function announceSeedDestination(dest) {
606
- if (dest.source === "cwd") {
607
- p.log.info(`No mesh resolved yet (${dest.reason}) - seeding into this folder's catalog:\n` +
608
- ` ${dest.dir}\n` +
609
- `Once a mesh is running, \`${displayCmd()} setup\` seeds into THAT mesh's root instead.`);
610
- return;
611
- }
612
- const t = dest.target;
613
- // The cwd's own answer, for comparison only — never to choose with.
614
- const cwdRoot = findCotalRoot();
615
- if (resolve(cwdRoot) === resolve(t.root)) {
616
- p.log.info(`Seeding personas for mesh "${t.space}" into:\n ${dest.dir}`);
617
- return;
618
- }
619
- p.log.info(`Seeding into mesh "${t.space}"'s personas, not this folder's:\n` +
620
- ` writing to ${dest.dir}\n` +
621
- ` mesh "${t.space}" (${t.server}) root ${t.root}\n` +
622
- ` this folder would have used ${cwdRoot}\n` +
623
- `\`${displayCmd()} spawn\` reads the mesh's catalog, so that is where the persona has to live.`);
624
- }
625
- /** Seed the default persona if it's missing, or migrate the byte-exact legacy template, in the
626
- * catalog `cotal spawn` actually reads. Called from both first-run and repeat-run paths so new
627
- * installs and untouched upgrades get the current grant while edited personas are never
628
- * overwritten. Returns the destination so the caller can report the ABSOLUTE path it wrote. */
629
- function seedDefaultAgent(dest = seedDestination()) {
630
- seedDefaultAgentInto(dest.dir);
631
- return dest;
632
- }
633
- /** Resolve, disclose and write through setup's shipped destination wiring. The smoke disables only
634
- * the presentation step while keeping the production resolver-to-writer path intact. */
635
- export function seedDefaultForSetup(cwd, announce = true) {
636
- const dest = seedDestinationFor(cwd);
637
- if (announce)
638
- announceSeedDestination(dest);
639
- return seedDefaultAgent(dest);
640
- }
641
- /** The write itself, seam-exported for the smoke: reconcile into an explicit catalog directory. */
642
- export function seedDefaultAgentInto(dir) {
643
- const path = join(dir, "default.md");
644
- const result = reconcileDefaultAgent(path);
645
- if (result === "migrated") {
646
- provenance.wrote("updated default persona permissions", path);
647
- return;
648
- }
649
- if (result === "seeded")
650
- provenance.wrote("default persona", path);
651
- }
652
- /** Seed the guided expert team — david (the engineer), sven (the guide), me (your session) — the
653
- * opt-in richer first experience (`cotal setup --demo` / `--full`). These are setup-managed, unlike
654
- * the seed-once default: refreshed when a DEMO_AGENTS body changes so persona edits actually land,
655
- * but a file you've taken ownership of is backed up first, never silently lost (see writeDemoAgent).
656
- * Every write is announced; `log` (present only in the narrated first run) also records it.
657
- *
658
- * Takes the SAME destination the default persona used, so the team can never land in a different
659
- * catalog than the default — one `cotal spawn david` reading a root that `cotal spawn` does not is
660
- * the same defect wearing a different name. */
661
- function seedDemoTeam(dest, log) {
662
- mkdirSync(dest.dir, { recursive: true });
663
- for (const [name, body] of Object.entries(DEMO_AGENTS)) {
664
- writeDemoAgent(join(dest.dir, `${name}.md`), body);
665
- }
666
- p.log.success(`Added the guided team - david (the engineer), sven (the guide), and your session (me) in ${dest.dir}; spawn them when your mesh is up`);
667
- log?.line(`demo-agents: wrote david + sven + me into ${dest.dir}`);
943
+ writePrivateRecord(path, body);
944
+ wrote("persona", path);
668
945
  }
946
+ /** The guided expert team `--demo` seeds: david (the engineer), sven (the guide) and me (your
947
+ * session). Setup-managed, unlike the seed-once default: see {@link writeDemoAgent}. */
669
948
  const DEMO_AGENTS = {
670
949
  david: `---
671
950
  ${MANAGED_MARKER} - edit DEMO_AGENTS in the cotal CLI; delete this line to keep local changes