@cotal-ai/cli 0.90.1 → 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,232 +1,200 @@
1
- import { existsSync, readFileSync, readdirSync } from "node:fs";
1
+ import { existsSync, readdirSync } from "node:fs";
2
2
  import { hostname } from "node:os";
3
3
  import { basename, join } from "node:path";
4
4
  import { credentialLifetime, CotalEndpoint, inspectCredHealth, mintCreds, mintLifecycleUid, newIdentity, probeConnect, } from "@cotal-ai/core";
5
- import { agentCredsDir, authDir, CONNECTION_EVICTOR_CREDS_KIND, DELIVERY_CREDS_KIND, findCotalRoot, getSoleSpaceAuth, getSpaceAuth, hasUserAuthState, legacyRenewalRecord, MEMBERSHIP_OBSERVER_CREDS_KIND, MEMBERSHIP_RW_CREDS_KIND, MeshTargetError, migrateLegacyCotalMaterial, preflightTarget, readRenewalRecord, remintDaemonCreds, resolveMeshTarget, spaceAccountPath, staleSystemCreds, workspaceSecretStore, writeRenewalRecord, } from "@cotal-ai/workspace";
5
+ import { CommandFailure, accountInventory, canonicalRoot, isCommandFailure, jsonFlag, plainFlag, presentationOf, readLocalRecordSource, renewalRecordPath, writeResult, agentCredsDir, authDir, CONNECTION_EVICTOR_CREDS_KIND, DELIVERY_CREDS_KIND, findCotalRoot, getSoleSpaceAuth, getSpaceAuth, hasUserAuthState, legacyRenewalRecord, MEMBERSHIP_OBSERVER_CREDS_KIND, MEMBERSHIP_RW_CREDS_KIND, MeshTargetError, migrateLegacyCotalMaterial, preflightTarget, remintDaemonCreds, resolveMeshTarget, spaceAccountPath, staleSystemCreds, workspaceSecretStore, writeRenewalRecord, recordOperationSpace, } from "@cotal-ai/workspace";
6
6
  import { displayCmd } from "../lib/self-exec.js";
7
7
  import { RESPONDER_UNBOUND_CONSEQUENCE } from "../lib/delivery-responder.js";
8
- import { c } from "../ui.js";
9
- export const doctorFlags = [
8
+ export const doctorFlags = [jsonFlag, plainFlag,
10
9
  { name: "fix", type: "boolean", description: "execute the safe repairs (re-sign the manager-remintable daemon creds; needs the local signer)" },
11
10
  { name: "space", type: "string", description: "target space on a multi-space root (default: the sole space)" },
12
11
  ];
13
- /** `cotal doctor auth` — the ONE stale-credential repair surface (D5 slice 6). Read-only diagnosis
14
- * of every managed credential file in this folder against the credential-lifetime matrix, rendered
15
- * as healthy / near-expiry (yellow) / expired / unreadable (red) with the LAST-RENEWAL timestamp
16
- * for manager-reminted creds — ending in either `healthy` or the exact next command (exit 1).
17
- * `--fix` executes the one safe local repair (re-sign the class-2 daemon files for their existing
18
- * nkeys); $SYS and agent creds are never auto-fixed — their repairs are printed, not guessed. */
12
+ export function validateDoctorArguments(args) {
13
+ presentationOf(args.values);
14
+ if (args.positionals.length !== 1 || args.positionals[0] !== "auth")
15
+ throw new CommandFailure("refused", "USAGE_INVALID", "use doctor auth [--fix] [--space <space>] [--json|--plain]");
16
+ }
17
+ /** Local credential observations only; native repair remains an explicit, separately labeled phase. */
19
18
  export async function doctor(args) {
20
- const sub = args.positionals[0];
21
- if (sub !== "auth") {
22
- console.error(`usage: ${displayCmd()} doctor auth [--fix] [--space <s>] - credential-health diagnosis + repair for this folder's mesh`);
23
- process.exitCode = 1;
24
- return;
25
- }
19
+ validateDoctorArguments(args);
26
20
  const values = args.values;
27
21
  const root = findCotalRoot(process.cwd());
28
- const auth = values.space ? await getSpaceAuth(workspaceSecretStore(root), values.space) : await getSoleSpaceAuth(workspaceSecretStore(root), authDir(root));
29
- console.log(c.bold("cotal doctor auth"));
30
- console.log(` root ${root}`);
31
- if (!auth) {
32
- // An explicitly named space that has no record is a selection error, never "healthy" —
33
- // falling through to the open-mesh answer would turn a typo into a green diagnosis.
34
- if (values.space) {
35
- console.error(c.red(`\n✗ no account record for space "${values.space}" under ${authDir(root)} (expected ${spaceAccountPath(authDir(root), values.space)})`));
36
- process.exitCode = 1;
37
- return;
22
+ const repair = { requested: values.fix === true, attempted: false, authority: null, results: [], migrationAttempted: false, migrations: [], coordinationCleanup: "not-opened" };
23
+ if (!values.space) {
24
+ // Several valid accounts are a target the caller picks with --space, not an inventory that failed
25
+ // validation. An unreadable or corrupt inventory still refuses as SCHEMA_INVALID below.
26
+ let spaces = [];
27
+ try {
28
+ const inventory = accountInventory(authDir(root));
29
+ if (!inventory.corrupt.length)
30
+ spaces = inventory.spaces;
38
31
  }
39
- // An open mesh has no minted credentials at all — nothing to diagnose is a healthy answer,
40
- // not a silent one.
41
- console.log(c.green("\nauth: healthy - open mesh (no credential material in this folder)"));
32
+ catch { /* refused by the read below */ }
33
+ if (spaces.length > 1)
34
+ throw new CommandFailure("refused", "TARGET_AMBIGUOUS", `this root holds accounts for ${spaces.length} spaces (${spaces.join(", ")}); doctor auth diagnoses one space`, { target: { root, space: null, candidates: spaces }, remedy: `pass --space with one of ${spaces.join(", ")}` });
35
+ }
36
+ let auth;
37
+ try {
38
+ auth = values.space ? await getSpaceAuth(workspaceSecretStore(root), values.space) : await getSoleSpaceAuth(workspaceSecretStore(root), authDir(root));
39
+ }
40
+ catch {
41
+ throw new CommandFailure("refused", "SCHEMA_INVALID", "the local authority inventory could not be validated; no repair was attempted", { target: { root, space: values.space ?? null } });
42
+ }
43
+ if (!auth) {
44
+ if (values.fix || values.space)
45
+ throw new CommandFailure("refused", "AUTH_REQUIRED", "no validated signing trust for the named local diagnostic scope is present; no open mode or broader authority was inferred", { target: { root, space: values.space ?? null } });
46
+ writeResult(presentationOf(values), { command: "doctor auth", target: { root }, result: { kind: "credential-health", root, space: null, localFindings: null, credentialScope: "not-established", brokerAuthorization: "not-checked", repair }, completeness: "not-checked", partial: { message: "No local static authority was established. This is not proof of an open or healthy mesh." } }, () => ({ sections: [{ title: "Local credential scope not established", blocks: [{ kind: "fields", rows: [["Root", root], ["Space", "not established"], ["Live authorization", "not checked"], ["Repair", "not requested"]] }] }] }));
42
47
  return;
43
48
  }
44
- const userMode = hasUserAuthState(root, auth.space);
45
- // A legacy monolith root genuinely holds the signer in auth.json until a write splits it.
46
- const acctPath = spaceAccountPath(authDir(root), auth.space);
47
- const signerPath = existsSync(acctPath) ? acctPath : join(authDir(root), "auth.json");
48
- console.log(` space ${auth.space}${userMode ? " · user-auth" : ""} · signer ${c.green("present")} (${signerPath})`);
49
- let reports = inventory(root, auth.space, auth.sys.pub);
50
- let problems = reports.filter((r) => r.problem);
51
- // --fix: the one safe local repair — re-sign the remintable daemon files (same nkeys), exactly
52
- // what the manager's renewal pass does, and record the pass so the audit trail stays honest
53
- // (adoption is the DAEMON's explicit reload, which only the running manager requests — a doctor
54
- // fix without a live manager is adopted by the daemon's own 75% renewal timer). Then re-diagnose:
55
- // the doctor reports what IS, never what it hopes the fix did.
56
- if (values.fix && problems.some((r) => isRemintable(r.kind))) {
57
- // Decide reachability with the shipped probe (#1063 fix step 1). `resolveMeshTarget` throws for
58
- // an unregistered/not-running mesh (`unknown-space`/`no-meshes`); a reachable-but-unhealthy target
59
- // fails `preflightTarget`. Either is read as "no broker" — the offline repair below, unchanged
60
- // from before this fix. `getSpaceAuth` above already means this root has a static signer, so a
61
- // user-mode root never reaches here (`preflightTarget` throws by design for `mode: "user"`; the
62
- // doctor's fix path only runs against a static signer, so that throw can never fire here).
63
- let target;
64
- try {
65
- target = resolveMeshTarget(root, { space: auth.space });
66
- const pf = await preflightTarget(target);
67
- if (!pf.ok)
68
- target = undefined;
69
- }
70
- catch (e) {
71
- if (e instanceof MeshTargetError && (e.code === "unknown-space" || e.code === "no-meshes"))
72
- target = undefined;
73
- else
74
- throw e;
49
+ const target = { root, space: auth.space };
50
+ let reports;
51
+ let userMode;
52
+ try {
53
+ userMode = hasUserAuthState(root, auth.space, { readOnly: true });
54
+ if (values.fix && userMode)
55
+ throw new CommandFailure("refused", "UNSUPPORTED", "this static daemon repair cannot replace a user-auth space's supported issuer authority", { target });
56
+ repair.migrationAttempted = values.fix === true;
57
+ reports = inventory(root, auth.space, auth.sys.pub, !values.fix, (receipt) => repair.migrations.push(receipt));
58
+ if (values.fix && reports.some((row) => row.problem && isRemintable(row.kind)))
59
+ await repairDoctorCredentials(root, auth, repair);
60
+ if (repair.attempted)
61
+ reports = inventory(root, auth.space, auth.sys.pub, true);
62
+ }
63
+ catch (error) {
64
+ const changed = [...repair.migrations.map((receipt) => ({ kind: "credential-material-migrated", materialKind: receipt.kind, from: receipt.from, to: receipt.to, space: receipt.space })), ...repair.results.filter((row) => row.ok).map((row) => ({ kind: "daemon-credential-resigned", file: row.file, space: auth.space }))];
65
+ if (isCommandFailure(error) && !repair.attempted && !repair.migrations.length)
66
+ throw error;
67
+ if (changed.length)
68
+ throw new CommandFailure("partial", "OPERATION_PARTIAL", "native local credential material changed, but the final diagnostic/audit or coordination cleanup was not confirmed", { target, changed, remedy: "inspect the original local files and renewal owner; do not respawn agents or rotate the system account as an automatic substitute" });
69
+ throw new CommandFailure(repair.attempted || repair.migrationAttempted ? "unknown" : "failed", repair.attempted || repair.migrationAttempted ? "OPERATION_UNKNOWN" : "OPERATION_FAILED", repair.attempted || repair.migrationAttempted ? "the native daemon repair outcome is unconfirmed; no re-sign was retried" : "local credential observations could not be completed; raw credential and parser diagnostics were not printed", { target });
70
+ }
71
+ const renewal = renewalObservation(root, auth.space);
72
+ const items = reports.map((row) => ({
73
+ label: row.label, kind: row.kind, path: row.path, state: row.superseded ? "superseded-local-file" : row.health?.state ?? "not-provisioned-here",
74
+ issuedAt: Number.isFinite(row.health?.iat) ? row.health.iat : null,
75
+ expiresAt: Number.isFinite(row.health?.exp) ? row.health.exp : null,
76
+ renewAt: Number.isFinite(row.health?.renewAt) ? row.health.renewAt : null,
77
+ problem: row.health?.state === "unreadable" ? "credential parsing failed; raw diagnostic omitted" : row.problem ?? null,
78
+ repair: row.repair ?? null, superseded: row.superseded === true,
79
+ }));
80
+ const findings = items.filter((row) => row.problem !== null).length;
81
+ const refused = renewal.state === "present" && renewal.brokerAcceptance === "recorded-refusal";
82
+ const incomplete = renewal.state === "unreadable";
83
+ const result = { kind: "credential-health", root, space: auth.space, mode: userMode ? "user" : "static", scope: "local credential claims and recorded renewal only", items, findings, renewal, repair, brokerAuthorization: "not-checked", liveAgentHealth: "not-checked", systemAccountRotated: false, agentCredentialsReminted: false };
84
+ // A recorded refusal names the renewal owner to repair, so the finding keeps its next step.
85
+ const failure = incomplete ? new CommandFailure("partial", "OPERATION_PARTIAL", "credential observations were collected but the renewal record is unreadable; a complete healthy verdict was not inferred", { target }) : findings || refused ? new CommandFailure(repair.results.some((row) => row.ok) || repair.migrations.length ? "partial" : "failed", repair.results.some((row) => row.ok) || repair.migrations.length ? "OPERATION_PARTIAL" : "OPERATION_FAILED", refused ? "the recorded renewal was not broker-accepted; local re-signing alone cannot clear that finding" : "local credential findings remain; per-file native repair guidance is retained", { target, ...(refused ? { remedy: "start or repair this space's manager, the renewal owner, so it re-signs the daemon credentials and the broker accepts them; do not respawn agents for this finding" } : {}) }) : undefined;
86
+ writeResult(presentationOf(values), { command: "doctor auth", target, result, completeness: incomplete ? "partial" : "complete", failure, noOp: failure === undefined && values.fix === true && !repair.attempted && !repair.migrations.length }, (data) => ({ sections: [
87
+ { title: data.findings || refused || incomplete ? "Credential findings" : "No local credential findings", blocks: [
88
+ { kind: "fields", rows: [["Root", data.root], ["Space", data.space], ["Mode", data.mode], ["Scope", data.scope], ["Current broker authorization", { text: "not checked", tone: "waiting" }], ["Live agent health", { text: "not checked", tone: "waiting" }], ["Repair requested", data.repair.requested ? "yes" : "no"], ["Acknowledged local migrations", String(data.repair.migrations.length)], ["Repair coordination", data.repair.authority ?? "not used"]] },
89
+ { kind: "lines", lines: [{ text: "Credential expiry/claim inspection is not live broker acceptance, daemon adoption, process health or task progress. Locally ordered superseded files are not proof that their successor is connected. No agent was respawned and no system account was rotated.", tone: "hint" }] },
90
+ ] },
91
+ { title: "Local credential files", blocks: [
92
+ { kind: "table", columns: [{ key: "name", label: "Credential" }, { key: "state", label: "Local state" }, { key: "issued", label: "Issued" }, { key: "expiry", label: "Expiry" }], rows: data.items.slice(0, 200).map((row) => ({ name: row.label, state: row.state, issued: at(row.issuedAt ?? undefined), expiry: at(row.expiresAt ?? undefined) })) },
93
+ ...(data.items.length > 200 ? [{ kind: "lines", lines: [`${data.items.length - 200} credential rows are not shown; JSON retains every public diagnostic row.`] }] : []),
94
+ ] },
95
+ { title: "Recorded renewal", blocks: [{ kind: "fields", rows: [["Record", data.renewal.state], ["Recorded time", data.renewal.recordedAt ?? "not established"], ["Recorded owner", data.renewal.recordedOwner ?? "not established"], ["Broker acceptance at that pass", data.renewal.brokerAcceptance], ["Recorded coordination", data.renewal.authority ?? "not recorded"], ["Delivery responder at that pass", data.renewal.deliveryResponderUnbound ? "reported unbound" : "not established by this view"]] }, ...(data.renewal.deliveryResponderUnbound ? [{ kind: "lines", lines: [RESPONDER_UNBOUND_CONSEQUENCE, "Repair the original delivery responder and inspect status; do not respawn agents merely because a responder was absent at that recorded pass."] }] : []),
96
+ // The leftover root-scoped record is named, never read as this space's verdict.
97
+ ...("legacyRecordPresent" in data.renewal && data.renewal.legacyRecordPresent ? [{ kind: "lines", lines: [`This root also holds .cotal/renewal.json, a pre-per-space renewal record. It names no space, so it is not read as this space's verdict. ${displayCmd()} clean all --force removes it when this root is reset.`] }] : [])] },
98
+ ...(data.items.some((row) => row.problem !== null || row.superseded) ? [{ title: "Inspect before changing identities", blocks: [{ kind: "table", columns: [{ key: "name", label: "Credential" }, { key: "finding", label: "Finding" }, { key: "next", label: "Native guidance" }], rows: data.items.filter((row) => row.problem !== null || row.superseded).slice(0, 200).map((row) => ({ name: row.label, finding: row.problem ?? "superseded in local credential family; not a broken-agent verdict", next: row.repair ?? "inspect the original file and authority" })) }] }] : []),
99
+ ] }));
100
+ }
101
+ async function repairDoctorCredentials(root, auth, observed) {
102
+ let target;
103
+ try {
104
+ target = resolveMeshTarget(root, { space: auth.space, readOnly: true });
105
+ recordOperationSpace(target.space);
106
+ if (target.mode !== "auth" || canonicalRoot(target.root) !== canonicalRoot(root) || target.auth?.account.pub !== auth.account.pub)
107
+ throw new CommandFailure("refused", "CONFLICT", "the resolved repair target differs from this local static authority; no broader root or auth mode was substituted");
108
+ const preflight = await preflightTarget(target);
109
+ if (!preflight.ok) {
110
+ if (preflight.kind.includes("creds") || preflight.kind === "stale-auth")
111
+ throw new CommandFailure("refused", "AUTH_REQUIRED", "the selected broker's authenticated preflight failed; it was not called an offline repair target");
112
+ target = undefined;
75
113
  }
76
- const prior = readRenewalRecord(root, auth.space);
77
- let results;
78
- let authority;
79
- if (target) {
80
- // Take the mesh's one renewal lease before re-signing (#1063 fix step 2): a one-shot endpoint,
81
- // the `supervisor` profile (the only grant that may publish the `renewal` key), same
82
- // one-mint-for-both-mint-and-endpoint shape as `status.ts`'s `componentEp`.
83
- const holderId = `doctor:${hostname()}:${process.pid}`;
84
- const uid = mintLifecycleUid();
85
- const id = newIdentity();
86
- const ep = new CotalEndpoint({
87
- space: target.space,
88
- servers: target.server,
89
- tls: target.tlsRequired,
90
- creds: await mintCreds(auth, id, "supervisor", { lifecycleUid: uid }),
91
- lifecycleUid: uid,
92
- channels: [],
93
- consume: false,
94
- registerPresence: false,
95
- watchPresence: false,
96
- watchChannels: false,
97
- card: { id: id.id, name: "doctor-auth-fix", kind: "endpoint" },
98
- });
99
- ep.on("error", () => { });
114
+ }
115
+ catch (error) {
116
+ if (error instanceof MeshTargetError && ["unknown-space", "no-meshes", "not-started"].includes(error.code))
117
+ target = undefined;
118
+ else
119
+ throw error;
120
+ }
121
+ const prior = renewalObservation(root, auth.space);
122
+ if (prior.state === "unreadable")
123
+ throw new CommandFailure("refused", "SCHEMA_INVALID", "the prior renewal record is unreadable; a possible broker refusal was not overwritten");
124
+ let results;
125
+ const retain = (rows) => { observed.results = rows.map((row) => ({ file: row.file, ok: row.ok === true, skipped: row.skipped !== undefined })); };
126
+ if (target) {
127
+ const uid = mintLifecycleUid(), identity = newIdentity();
128
+ const ep = new CotalEndpoint({ space: target.space, servers: target.server, tls: target.tlsRequired, creds: await mintCreds(auth, identity, "supervisor", { lifecycleUid: uid }), lifecycleUid: uid, channels: [], consume: false, registerPresence: false, watchPresence: false, watchChannels: false, card: { id: identity.id, name: "doctor-auth-fix", kind: "endpoint" } });
129
+ ep.on("error", () => { });
130
+ let held = false;
131
+ try {
100
132
  await ep.start();
101
- try {
102
- const held = await ep.holdDaemonRenewalLease(holderId);
103
- if (!held) {
104
- const row = await ep.readDaemonRenewalLease();
105
- const holder = row?.instanceId;
106
- const holderIsManager = holder !== undefined && !holder.startsWith("doctor:");
107
- const message = holderIsManager
108
- ? `✗ daemon credential renewal for space "${auth.space}" is held by manager "${holder}" - stop that manager (\`cotal down\`) or let it renew; --fix changed nothing`
109
- : `✗ daemon credential renewal for space "${auth.space}" is held by "${holder ?? "unknown"}" - wait for it to finish (the lease expires in about ten seconds if it died)`;
110
- console.error(c.red(message));
111
- process.exitCode = 1;
112
- return;
133
+ held = await ep.holdDaemonRenewalLease(`doctor:${hostname()}:${process.pid}`);
134
+ if (!held)
135
+ throw new CommandFailure("refused", "LIFECYCLE_BLOCKED", "another native renewal owner holds the lease; no daemon credential was re-signed");
136
+ observed.authority = "lease";
137
+ observed.attempted = true;
138
+ results = await remintDaemonCreds(root, auth.space, undefined, { preflight: async (creds) => (await probeConnect(target.server, { creds, tls: target.tlsRequired })).ok === true });
139
+ retain(results);
140
+ }
141
+ finally {
142
+ let cleanupError;
143
+ if (held)
144
+ try {
145
+ await ep.releaseDaemonRenewalLease();
113
146
  }
114
- console.log(c.dim("\n--fix: re-signing the remintable daemon creds under the mesh's renewal lease…"));
115
- results = await remintDaemonCreds(root, auth.space, undefined, {
116
- preflight: async (creds) => (await probeConnect(target.server, { creds, tls: target.tlsRequired })).ok === true,
117
- });
118
- authority = "lease";
147
+ catch (error) {
148
+ cleanupError = error;
149
+ }
150
+ try {
151
+ await ep.stop();
119
152
  }
120
- finally {
121
- await ep.releaseDaemonRenewalLease();
122
- await ep.stop().catch(() => { });
153
+ catch (error) {
154
+ cleanupError ??= error;
123
155
  }
156
+ observed.coordinationCleanup = cleanupError === undefined ? "confirmed" : "unconfirmed";
157
+ if (cleanupError)
158
+ throw cleanupError;
124
159
  }
125
- else {
126
- // Offline stays an explicit offline repair (#1063 fix step 4): continuity proof, no lease, and
127
- // it never claims coordination. A stale lease row cannot block it - with no broker there is no
128
- // row to read.
129
- console.log(c.dim("\n--fix: broker not reachable - re-signing the remintable daemon creds OFFLINE (uncoordinated; the daemon adopts on its own renewal timer)…"));
130
- results = await remintDaemonCreds(root, auth.space);
131
- authority = "offline";
132
- }
133
- // A local re-sign is NOT a broker proof: `--fix` has no live admin rail to adopt through, it
134
- // relies on the daemon's 75% renewal timer. So it must NEVER erase a KNOWN broker refusal to
135
- // green — if the last renewal was refused (e.g. the signer the broker rejects), the re-signed
136
- // generation is still unproven and may be broker-dead. Carry the refusal forward as an explicit
137
- // unproven state until a REAL proof (the manager's/daemon's reloadCreds) supersedes it, so the
138
- // verdict below stays exit 1 with an actionable next step. A prior non-refusal is left absent
139
- // (the "backstop will adopt" state), unchanged from before.
140
- const adoption = prior?.adoption?.ok === false
141
- ? { ok: false, error: "re-signed locally by `doctor auth --fix`, but the previous renewal was refused by the broker and the re-signed generation is not yet broker-proven - start the mesh's manager (the renewal owner) so it proves and adopts it" }
142
- : undefined;
143
- writeRenewalRecord(root, auth.space, { ts: new Date().toISOString(), owner: "doctor --fix", results, adoption, authority });
144
- for (const r of results.filter((x) => !x.ok && !x.skipped))
145
- console.error(c.red(` ✗ ${r.file}: ${r.error}`));
146
- reports = inventory(root, auth.space, auth.sys.pub);
147
- problems = reports.filter((r) => r.problem);
148
160
  }
149
- render("Daemon creds (manager-reminted - class 2)", reports.filter((r) => isRemintable(r.kind)));
150
- renderRenewalRecord(root, auth.space);
151
- render("$SYS creds (rotation-renewed - never remintable from disk)", reports.filter((r) => r.kind === "membership-observer" || r.kind === "connection-evictor"));
152
- render("Agent creds (static, pre-flip)", reports.filter((r) => r.kind === "agent"));
153
- // A broker-REFUSED renewal is a first-class problem for the final verdict + exit status, not just a
154
- // warning line. Cred-file health alone is not enough: a structurally-valid JWT the broker rejected
155
- // must never let `auth: healthy` / exit 0 stand (the whole point of the renewal-honesty slice).
156
- const rec = readRenewalRecord(root, auth.space);
157
- const adoptionRefused = rec?.adoption?.ok === false;
158
- // Superseded leftovers are reported but never block `healthy` (#1576). An operator whose fleet is
159
- // fine must be told so in one word; the leftovers are a tidy-up, and burying that in an `auth: 15
160
- // cred problems` line is what sent one operator toward respawning 18 working agents.
161
- //
162
- // REPORTED ON BOTH PATHS, and that is not symmetry for its own sake. During the reported incident
163
- // there WERE genuine problems alongside the 15 husks, so a note printed only on the healthy path
164
- // would have been absent exactly when the operator needed it — and the one thing they must not
165
- // conclude, while reading real failures, is that the husks are more of the same.
166
- const superseded = reports.filter((r) => r.superseded);
167
- const leftovers = superseded.length
168
- ? ` (${superseded.length} superseded credential file${superseded.length === 1 ? "" : "s"} left on disk from earlier incarnations - safe to delete, the agents using their successors are unaffected)`
169
- : "";
170
- if (!problems.length && !adoptionRefused) {
171
- console.log(c.green("\nauth: healthy") + c.dim(leftovers));
172
- if (superseded.length)
173
- printSuperseded(superseded);
174
- return;
161
+ else {
162
+ observed.authority = "offline";
163
+ observed.attempted = true;
164
+ results = await remintDaemonCreds(root, auth.space);
165
+ retain(results);
175
166
  }
176
- const parts = [];
177
- if (problems.length)
178
- parts.push(`${problems.length} cred problem${problems.length === 1 ? "" : "s"}`);
179
- if (adoptionRefused)
180
- parts.push("last renewal not broker-accepted");
181
- console.log(c.red(`\nauth: ${parts.join(", ")}`) + c.dim(leftovers));
182
- for (const p of problems)
183
- console.log(` ${c.red("✗")} ${p.label}: ${p.problem}\n next: ${p.repair}`);
184
- if (adoptionRefused)
185
- console.log(` ${c.red("✗")} the last renewal pass was refused by the broker: ${rec?.adoption?.error ?? "unknown"}\n next: start or repair the mesh's manager (the renewal owner) so it re-signs and re-proves the daemon creds`);
186
- if (superseded.length)
187
- printSuperseded(superseded);
188
- process.exitCode = 1;
167
+ const adoption = prior.brokerAcceptance === "recorded-refusal" ? { ok: false, error: "re-signed locally by doctor auth --fix; the previous broker refusal remains unproven until the native renewal owner proves and adopts the generation" } : undefined;
168
+ writeRenewalRecord(root, auth.space, { ts: new Date().toISOString(), owner: "doctor --fix", results, adoption, authority: observed.authority });
189
169
  }
190
- /** The superseded leftovers, with their cleanup, rendered BELOW the verdict on both paths (#1576).
191
- *
192
- * Each one repeats "not a broken agent" and its own cleanup rather than sharing one footnote,
193
- * because the failure mode being designed against is an operator scanning a long list during an
194
- * incident and acting per row. A single note at the top of 15 rows is a note that gets skipped, and
195
- * the action it would have prevented destroys live sessions. */
196
- function printSuperseded(reports) {
197
- console.log(c.dim(` ${reports.length} superseded credential file${reports.length === 1 ? "" : "s"} (not a broken agent - the live successor of each is listed above):`));
198
- for (const r of reports)
199
- console.log(c.dim(` ⊖ ${r.label}\n next: ${r.repair}`));
170
+ function renewalObservation(root, space) {
171
+ const absent = { state: "absent", recordedAt: null, recordedOwner: null, authority: null, brokerAcceptance: "not-recorded", deliveryResponderUnbound: false };
172
+ try {
173
+ const bytes = readLocalRecordSource(renewalRecordPath(root, space), 1024 * 1024, true);
174
+ if (!bytes)
175
+ return { ...absent, legacyRecordPresent: legacyRenewalRecord(root) !== undefined };
176
+ const value = JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(bytes));
177
+ if (!value || typeof value !== "object" || typeof value.ts !== "string" || !Number.isFinite(Date.parse(value.ts)) || typeof value.owner !== "string" || !Array.isArray(value.results))
178
+ throw new Error();
179
+ const adoption = value.adoption;
180
+ if (adoption !== undefined && (!adoption || typeof adoption !== "object" || typeof adoption.ok !== "boolean"))
181
+ throw new Error();
182
+ return { state: "present", recordedAt: value.ts, recordedOwner: value.owner, authority: value.authority === "lease" || value.authority === "offline" ? value.authority : null, brokerAcceptance: adoption === undefined ? "not-requested-by-that-pass" : adoption.ok ? "recorded-acceptance" : "recorded-refusal", deliveryResponderUnbound: responderUnboundAtLastRenewal(typeof adoption?.error === "string" ? adoption.error : undefined), legacyRecordPresent: legacyRenewalRecord(root) !== undefined };
183
+ }
184
+ catch {
185
+ return { ...absent, state: "unreadable", brokerAcceptance: "not-established", legacyRecordPresent: false };
186
+ }
200
187
  }
201
188
  function isRemintable(kind) {
202
189
  return kind === "delivery" || kind === "membership-rw";
203
190
  }
204
- /** THE REMEDY SPLIT (#1576 ask 2).
205
- *
206
- * The old text was one sentence for every agent credential: "respawn the agent - its old cred is
207
- * dead by design". It is correct for exactly one of the three cases below and DESTRUCTIVE for the
208
- * other two. A reporter was shown it for 15 credentials during an outage; following it would have
209
- * destroyed 18 live agent sessions, each holding working context, to fix a state the manager's own
210
- * renewal pass repaired by itself thirty minutes later.
211
- *
212
- * WHAT THE MANAGER ACTUALLY DOES, which is what makes the distinction real rather than softer
213
- * wording: its renewal pass walks its managed agents and re-signs any whose credential is expired
214
- * or near expiry for the SAME nkey, and the agent adopts the new file through its own source
215
- * re-read. It explicitly does NOT renew an `unbounded` or `unreadable` credential. So:
216
- * - an EXPIRED current incarnation is re-minted by a running manager: start it, do not respawn;
217
- * - an UNBOUNDED/UNREADABLE one genuinely cannot be renewed: respawn is the honest answer;
218
- * - a SUPERSEDED incarnation belongs to no live agent at all: it is a leftover FILE, and the
219
- * repair is to delete it, never to touch the running agent that replaced it. */
220
- function agentRepair(path, live) {
221
- if (live?.role === "superseded")
222
- return `nothing is wrong with this agent - this file is a SUPERSEDED incarnation left on disk after a re-mint, and its live successor is listed above. Delete it when convenient (\`rm ${path}\`). DO NOT respawn the agent.`;
223
- return `if the mesh's manager is running it RE-MINTS this credential by itself (it is the renewal owner for managed agents; start it with \`${displayCmd()} up\` and the agent adopts the new file without being restarted). Respawn only if the manager cannot: \`${displayCmd()} spawn\``;
191
+ function agentRepair(path, family) {
192
+ if (family?.role === "superseded")
193
+ return `an older local incarnation file exists at ${path}; inspect its exact lifecycle and owner before removing it. File ordering alone proves no live successor. Do not respawn an agent from this finding`;
194
+ return `inspect this original lifecycle under its manager; supported managed renewal can re-sign the same nkey without a replacement. Do not spawn another agent only because a local file expired`;
224
195
  }
225
- /** The repair for a credential no renewal pass can rescue — the one case where respawning is right.
226
- * An `unbounded` credential predates the renewal slice and an `unreadable` one cannot be parsed to
227
- * re-sign; the manager skips both by name, so promising a re-mint here would be a false hope. */
228
196
  function agentUnrenewableRepair() {
229
- return `respawn the agent (\`${displayCmd()} spawn\`) - this credential cannot be re-minted from disk (the manager's renewal pass skips unbounded/unreadable material), so its old cred is dead by design`;
197
+ return "native renewal skips unbounded or unreadable material; inspect the exact lifecycle and authority before choosing an explicit replacement. This diagnosis does not prove the agent is stopped or authorize a blind respawn";
230
198
  }
231
199
  /** Classify every `agent` file by alias family, so a superseded incarnation is never reported as a
232
200
  * broken fleet (#1576 ask 3).
@@ -296,13 +264,13 @@ function aliasOf(label) {
296
264
  /** Inspect every managed credential file for this folder. Missing files are noted (with how they
297
265
  * get provisioned) but only EXISTING-but-bad material is a problem — process presence is `cotal
298
266
  * status`'s job; this surface owns credential health. */
299
- function inventory(root, space, sysPub) {
267
+ function inventory(root, space, sysPub, readOnly = false, onMigrated) {
300
268
  // Through the choke point, not a hand-composed `.cotal/<file>` (P7 §2 rule 1). The four kinds are
301
269
  // per-space now, and a diagnosis that read the canonical location past an unmigrated copy would
302
270
  // report every one of them "missing" on a root `up` has not re-provisioned — the worst possible
303
271
  // answer from the surface an operator reaches for when something is already wrong. The LABEL stays
304
272
  // the kind, which is what the operator reads and what `staleSystemCreds` keys its answer by.
305
- const at = (kind) => migrateLegacyCotalMaterial(root, space, kind);
273
+ const at = (kind) => migrateLegacyCotalMaterial(root, space, kind, { readOnly, onMigrated });
306
274
  const fixed = [
307
275
  { label: DELIVERY_CREDS_KIND, kind: "delivery", path: at(DELIVERY_CREDS_KIND) },
308
276
  { label: MEMBERSHIP_RW_CREDS_KIND, kind: "membership-rw", path: at(MEMBERSHIP_RW_CREDS_KIND) },
@@ -311,14 +279,14 @@ function inventory(root, space, sysPub) {
311
279
  ];
312
280
  // Ask the staleness question ONCE, through the same helper the boot path uses, so `doctor auth`
313
281
  // and `cotal up` can never disagree about which $SYS creds the trust record authorizes.
314
- const stale = new Map(sysPub ? staleSystemCreds(root, sysPub, space).map((x) => [x.file, x]) : []);
282
+ const stale = new Map(sysPub ? staleSystemCreds(root, sysPub, space, { readOnly, onMigrated }).map((x) => [x.file, x]) : []);
315
283
  const reports = fixed.map((f) => report(f.label, f.kind, f.path, sysPub, stale.get(f.label)));
316
284
  // Same posture for the per-agent secrets (P1), and for the same reason: this space's segment
317
285
  // through the choke point, never `join(authDir(root), "creds")`, so an operator running `doctor`
318
286
  // on a root that has not migrated yet sees their agents' creds rather than an empty inventory. It
319
287
  // is also what keeps the report SPACE-scoped now that the dir holds every tenant's segment — a
320
288
  // diagnosis must not name a co-resident tenant's material.
321
- const agentDir = agentCredsDir(root, space);
289
+ const agentDir = agentCredsDir(root, space, { readOnly, onMigrated });
322
290
  if (existsSync(agentDir)) {
323
291
  for (const f of readdirSync(agentDir).filter((f) => f.endsWith(".creds") && !f.endsWith(".sentinel.creds")).sort()) {
324
292
  reports.push(report(basename(f), "agent", join(agentDir, f)));
@@ -332,10 +300,18 @@ function inventory(root, space, sysPub) {
332
300
  return reports.map((r) => r.kind === "agent" && r.health ? report(r.label, r.kind, r.path, undefined, undefined, { role: roles.get(r.label) ?? "sole" }) : r);
333
301
  }
334
302
  function report(label, kind, path, sysPub, stale, live) {
335
- if (!existsSync(path))
336
- return { label, kind, path };
337
- const creds = readFileSync(path, "utf8");
338
- const health = inspectCredHealth(creds);
303
+ let health;
304
+ try {
305
+ const bytes = readLocalRecordSource(path, 1024 * 1024, true);
306
+ if (!bytes)
307
+ return { label, kind, path };
308
+ health = inspectCredHealth(new TextDecoder("utf-8", { fatal: true }).decode(bytes));
309
+ }
310
+ catch (error) {
311
+ if (isCommandFailure(error) && error.code === "UNSUPPORTED")
312
+ throw error;
313
+ health = { state: "unreadable", error: "protected credential could not be read or parsed" };
314
+ }
339
315
  const r = { label, kind, path, health };
340
316
  const policy = credentialLifetime(kind);
341
317
  const standing = policy.class === "standing-renewable" || policy.class === "rotation-renewed";
@@ -355,7 +331,7 @@ function report(label, kind, path, sysPub, stale, live) {
355
331
  // helper the boot path uses, so the two surfaces cannot drift on what "stale" means. Checked
356
332
  // before the health switch, so it wins over a merely-healthy verdict.
357
333
  if (stale && sysPub) {
358
- r.problem = `signed by a RETIRED system account (${stale.iss ? `${stale.iss.slice(0, 12)}…` : "unreadable"}, but this root's is ${sysPub.slice(0, 12)}…) - the broker denies it`;
334
+ r.problem = stale.iss ? `the claimed system-account issuer ${stale.iss} differs from this root's ${sysPub}; current broker acceptance is not checked` : "the system-account issuer could not be established; current broker acceptance is not checked";
359
335
  r.repair = repair;
360
336
  return r;
361
337
  }
@@ -388,88 +364,16 @@ function report(label, kind, path, sysPub, stale, live) {
388
364
  }
389
365
  break;
390
366
  case "unbounded":
391
- if (standing) {
392
- r.problem = "unbounded standing credential (minted before the renewal slice) - a copied cred never dies";
393
- r.repair = repair;
394
- }
367
+ // A credential with no expiry claim stays valid until its signer rotates, whatever its kind,
368
+ // so it is a finding even where no renewal owner bounds it.
369
+ r.problem = standing
370
+ ? "unbounded standing credential (minted before the renewal slice) - a copied cred never dies"
371
+ : "unbounded credential (no expiry claim) - a copied cred never dies";
372
+ r.repair = kind === "agent" && live?.role !== "superseded" ? agentUnrenewableRepair() : repair;
395
373
  break;
396
374
  }
397
375
  return r;
398
376
  }
399
- function render(title, reports) {
400
- console.log(`\n ${c.bold(title)}`);
401
- if (!reports.length) {
402
- console.log(c.dim(" none"));
403
- return;
404
- }
405
- for (const r of reports) {
406
- if (!r.health) {
407
- console.log(` ${c.dim("−")} ${r.label} ${c.dim(`not provisioned here (written by \`${displayCmd()} up\`)`)}`);
408
- continue;
409
- }
410
- const h = r.health;
411
- const lastRenewal = h.iat ? c.dim(` · last renewal ${at(h.iat)}`) : "";
412
- const expiry = h.exp ? c.dim(` · expires ${at(h.exp)}`) : "";
413
- // A superseded incarnation is dim and NAMED, never red (#1576): its expiry is the expected
414
- // consequence of the re-mint that replaced it, and an operator scanning red rows during an
415
- // incident must not be sent to destroy the live agent that succeeded it.
416
- const badge = r.superseded
417
- ? c.dim("⊖ superseded")
418
- : h.state === "healthy" ? c.green("● healthy")
419
- : h.state === "near-expiry" ? c.yellow("◐ near-expiry")
420
- : h.state === "unbounded" ? (r.problem ? c.red("∞ unbounded") : c.dim("∞ static (dies at the flip)"))
421
- : c.red(`✗ ${h.state}`);
422
- const note = r.superseded ? c.dim(` · replaced by a newer incarnation of "${aliasOf(r.label)}" - leftover file, not a broken agent`) : "";
423
- console.log(` ${badge} ${r.label}${lastRenewal}${expiry}${note}`);
424
- }
425
- }
426
- /** Render the renewal owner's audit record (written by the manager's pass / doctor --fix): when the
427
- * last pass ran, who ran it, and whether the daemon EXPLICITLY adopted — the "file re-signed" vs
428
- * "daemon adopted" distinction the D5 panel required. Absence is informational (a mesh started
429
- * before the renewal owner existed, or an open mesh). The record is PER-SPACE (`renewal.<spaceKey>.json`);
430
- * a root-only `renewal.json` left by a pre-per-space build names no space, so it is never read as
431
- * this space's verdict — it is named as a leftover, with the exact next command. */
432
- function renderRenewalRecord(root, space) {
433
- const rec = readRenewalRecord(root, space);
434
- if (!rec) {
435
- console.log(c.dim(" no renewal record yet (written by the manager's renewal pass)"));
436
- const legacy = legacyRenewalRecord(root);
437
- if (legacy)
438
- console.log(c.yellow(` ⚠ ${legacy.path} is a pre-per-space renewal record that names no space - not read as this space's verdict; remove it with \`cotal clean all --force\` when resetting this root`));
439
- return;
440
- }
441
- const resigned = rec.results.filter((r) => r.ok).map((r) => r.file);
442
- const failed = rec.results.filter((r) => !r.ok && !r.skipped);
443
- // Per-component result from the daemon's structured reply detail (persisted on ok AND failed
444
- // passes): "accepted" = the broker accepted this generation (the proof); "rejected" (ok:false);
445
- // "n/a" (absent/skipped). NOT "adopted" — the resident wire swap is best-effort/self-healing, not
446
- // witnessed. Empty for an older record.
447
- const detail = rec.adoption?.detail;
448
- const compStatus = (comp) => comp === undefined ? "n/a" : comp.ok === false ? "rejected" : comp.skipped ? "n/a" : comp.brokerAccepted ? "accepted" : "n/a";
449
- const perComponent = detail && typeof detail === "object" && (detail.delivery !== undefined || detail.membership !== undefined)
450
- ? ` (delivery: ${compStatus(detail.delivery)}, membership: ${compStatus(detail.membership)})`
451
- : "";
452
- const adoption = rec.adoption === undefined
453
- ? resigned.length
454
- ? c.yellow("daemon reload not requested by this pass - daemons pick up the re-sign via the 75% re-read backstop or the next renewal pass")
455
- : c.dim("renewal: n/a (nothing re-signed)")
456
- : rec.adoption.ok
457
- ? c.green(`broker-accepted ✓${perComponent}`)
458
- : c.yellow(`renewal not accepted - ${rec.adoption.error ?? "unknown"}${perComponent}`);
459
- console.log(` ${c.dim(`last renewal pass ${rec.ts} by ${rec.owner}`)} - re-signed [${resigned.join(", ") || "none"}] · ${adoption}${rec.authority === "offline" ? c.dim(" · offline") : ""}`);
460
- for (const f of failed)
461
- console.log(` ${c.red("✗")} last pass failed on ${f.file}: ${f.error}`);
462
- // #1576: NAME THE DELIVERY RESPONDER, OFFLINE. `doctor auth` resolves no mesh and opens no
463
- // connection by design (and on a user-auth mesh it is forbidden to mint at all), so it cannot read
464
- // the delivery lease that `cotal status` reads. It does not have to: when the manager's renewal
465
- // pass finds no responder on the delivery-admin rail it RECORDS that, in this file, which doctor
466
- // already reads. That record was being rendered only as a generic "renewal not accepted", so the
467
- // one surface an operator reaches for when credentials look wrong never said the word "delivery"
468
- // — and in the reported incident credentials were exactly what the operator wrongly suspected.
469
- if (responderUnboundAtLastRenewal(rec.adoption?.error))
470
- console.log(` ${c.red("✗")} the delivery daemon's responder was NOT BOUND at that pass - ${RESPONDER_UNBOUND_CONSEQUENCE}\n` +
471
- ` next: start it (\`${displayCmd()} up\`) and confirm with \`${displayCmd()} status --components\`. Expired agent creds above are re-minted once it binds - do NOT respawn agents for this.`);
472
- }
473
377
  /** Did the last renewal pass fail because the delivery-admin rail had NO RESPONDER (#1576)?
474
378
  *
475
379
  * Matched on the manager's own recorded sentence for that case. A TIMEOUT is deliberately excluded:
@@ -481,6 +385,9 @@ function responderUnboundAtLastRenewal(error) {
481
385
  return /no delivery-admin responder|no responders/i.test(error);
482
386
  }
483
387
  function at(sec) {
484
- return sec ? new Date(sec * 1000).toISOString() : "?";
388
+ if (sec === undefined)
389
+ return "not reported";
390
+ const date = new Date(sec * 1000);
391
+ return Number.isFinite(date.getTime()) ? date.toISOString() : "not representable as a date";
485
392
  }
486
393
  //# sourceMappingURL=doctor.js.map